@dbmx/confy 0.0.80 → 0.0.84

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.
Files changed (147) hide show
  1. package/esm/components/Confy/index.js +1 -1
  2. package/esm/components/Confy/index.js.map +1 -1
  3. package/esm/components/SelectMemberMenu/index.js +1 -1
  4. package/esm/ducks/utils.js +1 -1
  5. package/esm/forms/utils.js +2 -2
  6. package/esm/hooks/roles.js +1 -1
  7. package/esm/node_modules/@dbmx/auth/dist/index.js +638 -0
  8. package/esm/node_modules/@dbmx/auth/dist/index.js.map +1 -0
  9. package/esm/node_modules/@dbmx/auth/dist/oidc-client.js +107 -0
  10. package/esm/node_modules/@dbmx/auth/dist/oidc-client.js.map +1 -0
  11. package/esm/node_modules/@dbmx/semver/dist/index.esm.js +960 -0
  12. package/esm/node_modules/@dbmx/semver/dist/index.esm.js.map +1 -0
  13. package/esm/node_modules/@dbmx/semver/node_modules/lru-cache/index.js +340 -0
  14. package/esm/node_modules/@dbmx/semver/node_modules/lru-cache/index.js.map +1 -0
  15. package/esm/node_modules/@dbmx/semver/node_modules/yallist/iterator.js +18 -0
  16. package/esm/node_modules/@dbmx/semver/node_modules/yallist/iterator.js.map +1 -0
  17. package/esm/node_modules/@dbmx/semver/node_modules/yallist/yallist.js +430 -0
  18. package/esm/node_modules/@dbmx/semver/node_modules/yallist/yallist.js.map +1 -0
  19. package/esm/node_modules/@dbmx/users/esm/index.js +251 -0
  20. package/esm/node_modules/@dbmx/users/esm/index.js.map +1 -0
  21. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/ap.js +44 -0
  22. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/ap.js.map +1 -0
  23. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/bind.js +36 -0
  24. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/bind.js.map +1 -0
  25. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/curry.js +53 -0
  26. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/curry.js.map +1 -0
  27. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/curryN.js +60 -0
  28. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/curryN.js.map +1 -0
  29. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/difference.js +50 -0
  30. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/difference.js.map +1 -0
  31. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/either.js +46 -0
  32. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/either.js.map +1 -0
  33. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/equals.js +37 -0
  34. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/equals.js.map +1 -0
  35. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/flip.js +37 -0
  36. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/flip.js.map +1 -0
  37. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/identity.js +29 -0
  38. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/identity.js.map +1 -0
  39. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/includes.js +32 -0
  40. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/includes.js.map +1 -0
  41. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_Set.js +201 -0
  42. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_Set.js.map +1 -0
  43. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_arity.js +65 -0
  44. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_arity.js.map +1 -0
  45. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_arrayFromIterator.js +13 -0
  46. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_arrayFromIterator.js.map +1 -0
  47. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_concat.js +37 -0
  48. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_concat.js.map +1 -0
  49. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_curry1.js +23 -0
  50. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_curry1.js.map +1 -0
  51. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_curry2.js +35 -0
  52. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_curry2.js.map +1 -0
  53. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_curry3.js +53 -0
  54. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_curry3.js.map +1 -0
  55. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_curryN.js +46 -0
  56. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_curryN.js.map +1 -0
  57. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_dispatchable.js +50 -0
  58. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_dispatchable.js.map +1 -0
  59. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_equals.js +170 -0
  60. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_equals.js.map +1 -0
  61. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_filter.js +18 -0
  62. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_filter.js.map +1 -0
  63. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_functionName.js +8 -0
  64. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_functionName.js.map +1 -0
  65. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_has.js +6 -0
  66. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_has.js.map +1 -0
  67. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_identity.js +6 -0
  68. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_identity.js.map +1 -0
  69. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_includes.js +8 -0
  70. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_includes.js.map +1 -0
  71. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_includesWith.js +17 -0
  72. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_includesWith.js.map +1 -0
  73. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_indexOf.js +71 -0
  74. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_indexOf.js.map +1 -0
  75. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_isArguments.js +16 -0
  76. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_isArguments.js.map +1 -0
  77. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_isArray.js +18 -0
  78. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_isArray.js.map +1 -0
  79. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_isArrayLike.js +58 -0
  80. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_isArrayLike.js.map +1 -0
  81. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_isFunction.js +7 -0
  82. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_isFunction.js.map +1 -0
  83. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_isInteger.js +14 -0
  84. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_isInteger.js.map +1 -0
  85. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_isPlaceholder.js +6 -0
  86. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_isPlaceholder.js.map +1 -0
  87. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_isString.js +6 -0
  88. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_isString.js.map +1 -0
  89. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_isTransformer.js +6 -0
  90. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_isTransformer.js.map +1 -0
  91. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_map.js +15 -0
  92. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_map.js.map +1 -0
  93. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_objectIs.js +17 -0
  94. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_objectIs.js.map +1 -0
  95. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_reduce.js +74 -0
  96. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_reduce.js.map +1 -0
  97. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_xfBase.js +11 -0
  98. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_xfBase.js.map +1 -0
  99. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_xmap.js +29 -0
  100. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_xmap.js.map +1 -0
  101. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_xwrap.js +28 -0
  102. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/internal/_xwrap.js.map +1 -0
  103. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/intersection.js +42 -0
  104. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/intersection.js.map +1 -0
  105. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/is.js +34 -0
  106. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/is.js.map +1 -0
  107. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/keys.js +92 -0
  108. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/keys.js.map +1 -0
  109. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/lift.js +34 -0
  110. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/lift.js.map +1 -0
  111. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/liftN.js +35 -0
  112. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/liftN.js.map +1 -0
  113. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/map.js +68 -0
  114. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/map.js.map +1 -0
  115. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/nth.js +39 -0
  116. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/nth.js.map +1 -0
  117. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/or.js +31 -0
  118. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/or.js.map +1 -0
  119. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/path.js +32 -0
  120. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/path.js.map +1 -0
  121. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/paths.js +47 -0
  122. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/paths.js.map +1 -0
  123. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/prop.js +33 -0
  124. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/prop.js.map +1 -0
  125. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/propEq.js +37 -0
  126. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/propEq.js.map +1 -0
  127. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/type.js +36 -0
  128. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/type.js.map +1 -0
  129. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/uniq.js +27 -0
  130. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/uniq.js.map +1 -0
  131. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/uniqBy.js +46 -0
  132. package/esm/node_modules/@dbmx/users/esm/node_modules/ramda/es/uniqBy.js.map +1 -0
  133. package/esm/node_modules/@dbmx/users/esm/roles.js +132 -0
  134. package/esm/node_modules/@dbmx/users/esm/roles.js.map +1 -0
  135. package/esm/node_modules/jsrsasign/lib/jsrsasign.js +248 -0
  136. package/esm/node_modules/jsrsasign/lib/jsrsasign.js.map +1 -0
  137. package/esm/node_modules/jwt-decode/build/esm/index.js +60 -0
  138. package/esm/node_modules/jwt-decode/build/esm/index.js.map +1 -0
  139. package/esm/node_modules/oidc-client-ts/dist/esm/oidc-client-ts.js +3591 -0
  140. package/esm/node_modules/oidc-client-ts/dist/esm/oidc-client-ts.js.map +1 -0
  141. package/esm/node_modules/ramda/es/internal/_objectAssign.js +32 -0
  142. package/esm/node_modules/ramda/es/internal/_objectAssign.js.map +1 -0
  143. package/esm/node_modules/ramda/es/merge.js +36 -0
  144. package/esm/node_modules/ramda/es/merge.js.map +1 -0
  145. package/esm/utils/authorizations.js +1 -1
  146. package/esm/utils/confy.js +1 -1
  147. package/package.json +3 -3
@@ -0,0 +1,960 @@
1
+ import LRU from '../node_modules/lru-cache/index.js';
2
+
3
+ const MAX_LENGTH = 256;
4
+ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
5
+
6
+ const numeric = /^[0-9]+$/;
7
+
8
+ const compareIdentifiers = (a, b) => {
9
+ const anum = numeric.test(a);
10
+ const bnum = numeric.test(b);
11
+
12
+ if (anum && bnum) {
13
+ a = +a;
14
+ b = +b;
15
+ }
16
+
17
+ return a === b ? 0
18
+ : (anum && !bnum) ? -1
19
+ : (bnum && !anum) ? 1
20
+ : a < b ? -1
21
+ : 1
22
+ };
23
+
24
+ class SemVerError extends Error {
25
+ constructor(message) {
26
+ super(message);
27
+ this.name = this.constructor.name;
28
+ }
29
+ }
30
+
31
+ const re = [];
32
+ const src = [];
33
+ const t = {};
34
+ let R = 0;
35
+
36
+ const createToken = (name, value, isGlobal) => {
37
+ const index = R++;
38
+ t[name] = index;
39
+ src[index] = value;
40
+ re[index] = new RegExp(value, undefined);
41
+ };
42
+
43
+ // The following Regular Expressions can be used for tokenizing,
44
+ // validating, and parsing SemVer version strings.
45
+
46
+ // ## Numeric Identifier
47
+ // A single `0`, or a non-zero digit followed by zero or more digits.
48
+
49
+ createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
50
+
51
+ // ## Non-numeric Identifier
52
+ // Zero or more digits, followed by a letter or hyphen, and then zero or
53
+ // more letters, digits, or hyphens.
54
+
55
+ createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*');
56
+
57
+ // ## Main Version
58
+ // Three dot-separated numeric identifiers.
59
+
60
+ createToken(
61
+ 'MAINVERSION',
62
+ `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})(?:\\.` + `(${src[t.NUMERICIDENTIFIER]}))?`,
63
+ );
64
+
65
+ // ## Pre-release Version Identifier
66
+ // A numeric identifier, or a non-numeric identifier.
67
+
68
+ createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]}|${src[t.NONNUMERICIDENTIFIER]})`);
69
+
70
+ // ## Pre-release Version
71
+ // Hyphen, followed by one or more dot-separated pre-release version
72
+ // identifiers.
73
+
74
+ createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
75
+
76
+ // ## Build Metadata Identifier
77
+ // Any combination of digits, letters, or hyphens.
78
+
79
+ createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+');
80
+
81
+ // ## Build Metadata
82
+ // Plus sign, followed by one or more period-separated build metadata
83
+ // identifiers.
84
+
85
+ createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
86
+
87
+ // ## Full Version String
88
+ // A main version, followed optionally by a pre-release version and
89
+ // build metadata.
90
+
91
+ // Note that the only major, minor, patch, and pre-release sections of
92
+ // the version string are capturing groups. The build metadata is not a
93
+ // capturing group, because it should not ever be used in version
94
+ // comparison.
95
+
96
+ createToken('FULLPLAIN', `${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
97
+
98
+ createToken('FULL', `^${src[t.FULLPLAIN]}$`);
99
+
100
+ createToken('GTLT', '((?:<|>)?=?)');
101
+
102
+ // A simple gt/lt/eq thing, or just "" to indicate "any version"
103
+ createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
104
+
105
+ /**
106
+ * Represents a Semantic Version (SemVer) object
107
+ *
108
+ * @function SemVer
109
+ * @tag semver
110
+ * @param {string} - Version to parse
111
+ * @throws {SemVerError} - Throws an error if the provided version is invalid
112
+ * @example
113
+ *
114
+ * expect(SemVer('1.0').parts()).toEqual(2)
115
+ * expect(SemVer('1.0.1').parts()).toEqual(3)
116
+ * expect(SemVer('1.0.1-draft').parts()).toEqual(4)
117
+ * expect(SemVer('1.0').isNonVersioned()).toBeTruthy()
118
+ * expect(SemVer('1.0.1').isNonVersioned()).toBeFalsy()
119
+ *
120
+ * expect(SemVer('1.0').is2Parts()).toBeTruthy()
121
+ * expect(SemVer('1.0').patch).toEqual(null)
122
+ * expect(SemVer('1.0.0').patch).toEqual(0)
123
+ * expect(SemVer('1.0.0').is2Parts()).toBeFalsy()
124
+ * expect(SemVer('1.0.0-draft.1').extension).toEqual('draft.1')
125
+ * expect(() => SemVer('1.0-draft.1')).toThrow(/Invalid version/)
126
+ *
127
+ * expect(SemVer('1.0').isStable()).toBeFalsy()
128
+ * expect(SemVer('0.1.2').isStable()).toBeFalsy()
129
+ * expect(SemVer('3.1.2-draft').isStable()).toBeFalsy()
130
+ * expect(SemVer('3.1.2').isStable()).toBeTruthy()
131
+ *
132
+ * expect(SemVer('1.0').compare('1.0')).toEqual(0)
133
+ * expect(SemVer('1.1').compare('1.0')).toEqual(1)
134
+ * expect(SemVer('1.0').compare('1.0.0')).toEqual(-1)
135
+ * expect(SemVer('1.0.0-draft').compare('1.0')).toEqual(1)
136
+ * expect(SemVer('1.2.1').compare('1.2.1')).toEqual(0)
137
+ * expect(SemVer('1.2.2').compare('1.2.1')).toEqual(1)
138
+ * expect(SemVer('1.2.2').compare('1.2.2-draft')).toEqual(1)
139
+ * expect(SemVer('1.2.2-draft').compare('1.2.2-draft.1')).toEqual(-1)
140
+ *
141
+ */
142
+
143
+ class SemVer {
144
+ constructor(version) {
145
+ if (version.version) {
146
+ version = version.version;
147
+ }
148
+
149
+ if (typeof version !== 'string') {
150
+ throw new SemVerError(`Invalid Version: ${JSON.stringify(version, null, 4)}`)
151
+ }
152
+
153
+ if (version.length > MAX_LENGTH) {
154
+ throw new SemVerError(`version is longer than ${MAX_LENGTH} characters`)
155
+ }
156
+
157
+ const m = version.trim().match(re[t.FULL]);
158
+
159
+ if (!m) {
160
+ throw new SemVerError(`Invalid Version: ${version}`)
161
+ }
162
+
163
+ // these are actually numbers
164
+ this.major = +m[1];
165
+ this.minor = +m[2];
166
+ this.patch = m[3] ? +m[3] : null;
167
+
168
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
169
+ throw new SemVerError('Invalid major version')
170
+ }
171
+
172
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
173
+ throw new SemVerError('Invalid minor version')
174
+ }
175
+
176
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
177
+ throw new SemVerError('Invalid patch version')
178
+ }
179
+
180
+ this.extension = m[4] || null;
181
+
182
+ if (this.patch === null && this.extension) {
183
+ throw new SemVerError('Invalid version')
184
+ }
185
+
186
+ this.format();
187
+ }
188
+
189
+ is2Parts() {
190
+ return this.patch === null
191
+ }
192
+
193
+ parts() {
194
+ return this.extension === null ? (this.patch === null ? 2 : 3) : 4
195
+ }
196
+
197
+ isNonVersioned() {
198
+ return this.parts() === 2
199
+ }
200
+
201
+ isStable() {
202
+ return !this.extension && this.major > 0 && !this.is2Parts()
203
+ }
204
+
205
+ format() {
206
+ this.version = this.is2Parts() ? `${this.major}.${this.minor}` : `${this.major}.${this.minor}.${this.patch}`;
207
+ if (this.extension) this.version += `-${this.extension}`;
208
+ return this.version
209
+ }
210
+
211
+ toString() {
212
+ return this.version
213
+ }
214
+
215
+ compare(other) {
216
+ if (!(other instanceof SemVer)) {
217
+ if (typeof other === 'string' && other === this.version) {
218
+ return 0
219
+ }
220
+ other = new SemVer(other);
221
+ }
222
+
223
+ if (other.version === this.version) {
224
+ return 0
225
+ }
226
+
227
+ return this.compareMain(other) || this.comparePre(other)
228
+ }
229
+
230
+ compareMain(other) {
231
+ if (!(other instanceof SemVer)) {
232
+ other = new SemVer(other);
233
+ }
234
+
235
+ return (
236
+ compareIdentifiers(this.major, other.major) ||
237
+ compareIdentifiers(this.minor, other.minor) ||
238
+ this.comparePatch(other)
239
+ )
240
+ }
241
+
242
+ comparePatch(other) {
243
+ if (this.patch === other.patch) return 0
244
+ // if (this.is2Parts() && other.patch === 0) return 0
245
+ if (this.is2Parts()) return -1
246
+ if (other.is2Parts()) return 1
247
+ return compareIdentifiers(this.patch, other.patch)
248
+ }
249
+
250
+ comparePre(other) {
251
+ if (!(other instanceof SemVer)) {
252
+ other = new SemVer(other);
253
+ }
254
+
255
+ // NOT having a extension is > having one
256
+ if (this.extension && !other.extension) {
257
+ return -1
258
+ } else if (!this.extension && other.extension) {
259
+ return 1
260
+ } else if (!this.extension && !other.extension) {
261
+ return 0
262
+ }
263
+
264
+ let i = 0;
265
+ do {
266
+ const a = this.extension[i];
267
+ const b = other.extension[i];
268
+ if (a === undefined && b === undefined) {
269
+ return 0
270
+ } else if (b === undefined) {
271
+ return 1
272
+ } else if (a === undefined) {
273
+ return -1
274
+ } else if (a === b) {
275
+ continue
276
+ } else {
277
+ return compareIdentifiers(a, b)
278
+ }
279
+ } while (++i)
280
+ }
281
+ }
282
+
283
+ var SemVer$1 = version => new SemVer(version);
284
+
285
+ /**
286
+ * Compares two version strings or SemVer instances
287
+ *
288
+ * @function compare
289
+ * @tag core
290
+ * @param {string|SemVer} - First version string or SemVer instance (a)
291
+ * @param {string|SemVer} - Second version string or SemVer instance (b)
292
+ * @return {number} - Returns 0 if versions are equal, 1 if `a` is greater than `b`, and -1 if `a` is less than `b`
293
+ * @example
294
+ *
295
+ * compare('1.0.0', '1.2.0'); // -1
296
+ * compare('1.2.0', '1.2.0'); // 0
297
+ * compare('2.0.0', '1.2.0'); // 1
298
+ */
299
+
300
+ const compare = (a, b) => SemVer$1(a).compare(SemVer$1(b));
301
+
302
+ /**
303
+ * Checks if two version strings or SemVer instances are equal
304
+ *
305
+ * @function eq
306
+ * @tag core
307
+ * @param {string|SemVer} - First version string or SemVer instance
308
+ * @param {string|SemVer} - Second version string or SemVer instance
309
+ * @return {boolean} - Returns true if the versions are equal, otherwise false
310
+ * @example
311
+ *
312
+ * eq('1.0.0', '1.0.0'); // true
313
+ * eq('1.0.0', '1.2.0'); // false
314
+ */
315
+
316
+ const eq = (a, b) => compare(a, b) === 0;
317
+
318
+ /**
319
+ * Checks if two version strings or SemVer instances are not equal
320
+ *
321
+ * @function neq
322
+ * @tag core
323
+ * @param {string|SemVer} - First version string or SemVer instance
324
+ * @param {string|SemVer} - Second version string or SemVer instance
325
+ * @return {boolean} - Returns true if the versions are not equal, otherwise false
326
+ * @example
327
+ *
328
+ * neq('1.0.0', '1.0.0'); // false
329
+ * neq('1.0.0', '1.2.0'); // true
330
+ */
331
+
332
+ const neq = (a, b) => compare(a, b) !== 0;
333
+
334
+ /**
335
+ * Checks if the first version string or SemVer instance is greater than the second
336
+ *
337
+ * @function gt
338
+ * @tag core
339
+ * @param {string|SemVer} - First version string or SemVer instance (a)
340
+ * @param {string|SemVer} - Second version string or SemVer instance (b)
341
+ * @return {boolean} - Returns true if `a` is greater than `b`, otherwise false
342
+ * @example
343
+ *
344
+ * gt('1.2.0', '1.0.0'); // true
345
+ * gt('1.0.0', '1.2.0'); // false
346
+ */
347
+
348
+ const gt = (a, b) => compare(a, b) > 0;
349
+
350
+ /**
351
+ * Checks if the first version string or SemVer instance is greater than or equal to the second
352
+ *
353
+ * @function gte
354
+ * @tag core
355
+ * @param {string|SemVer} - First version string or SemVer instance (a)
356
+ * @param {string|SemVer} - Second version string or SemVer instance (b)
357
+ * @return {boolean} - Returns true if `a` is greater than or equal `b`, otherwise false
358
+ * @example
359
+ *
360
+ * gte('1.2.0', '1.0.0'); // true
361
+ * gte('1.0.0', '1.2.0'); // false
362
+ * gte('1.2.0', '1.2.0'); // true
363
+ */
364
+
365
+ const gte = (a, b) => compare(a, b) >= 0;
366
+
367
+ /**
368
+ * Checks if the first version string or SemVer instance is less than the second
369
+ *
370
+ * @function lt
371
+ * @tag core
372
+ * @param {string|SemVer} - First version string or SemVer instance (a)
373
+ * @param {string|SemVer} - Second version string or SemVer instance (b)
374
+ * @return {boolean} - Returns true if `a` is less than `b`, otherwise false
375
+ * @example
376
+ *
377
+ * lt('1.0.0', '1.2.0'); // true
378
+ * lt('1.2.0', '1.0.0'); // false
379
+ */
380
+
381
+ const lt = (a, b) => compare(a, b) < 0;
382
+
383
+ /**
384
+ * Checks if the first version string or SemVer instance is less than or equal to the second
385
+ *
386
+ * @function lte
387
+ * @tag core
388
+ * @param {string|SemVer} - First version string or SemVer instance (a)
389
+ * @param {string|SemVer} - Second version string or SemVer instance (b)
390
+ * @return {boolean} - Returns true if `a` is less than or equal than `b`, otherwise false
391
+ * @example
392
+ *
393
+ * lte('1.0.0', '1.2.0'); // true
394
+ * lte('1.2.0', '1.0.0'); // false
395
+ * lte('1.2.0', '1.2.0'); // true
396
+ */
397
+
398
+ const lte = (a, b) => compare(a, b) <= 0;
399
+
400
+ /**
401
+ * Performs comparison operations between version strings or SemVer instances
402
+ *
403
+ * @function cmp
404
+ * @tag core
405
+ * @param {string|SemVer} - First version string or SemVer instance
406
+ * @param {string} - Comparison operator ('===', '!==', '=', '==', '!=', '>', '>=', '<', '<=')
407
+ * @param {string|SemVer} - Second version string or SemVer instance
408
+ * @return {boolean} - Returns true if the comparison operation is true, otherwise false.
409
+ * @throws {SemVerError} - Throws an error if the comparison operator is invalid.
410
+ * @example
411
+ *
412
+ * cmp('1.0.0', '===', '1.0.0'); // true
413
+ * cmp('1.0.0', '!=', '1.0.1'); // true
414
+ * cmp('1.2.0', '>', '1.0.0'); // true
415
+ */
416
+
417
+ var cmp = (a, op, b) => {
418
+ switch (op) {
419
+ case '===':
420
+ if (typeof a === 'object') a = a.version;
421
+ if (typeof b === 'object') b = b.version;
422
+ return a === b
423
+
424
+ case '!==':
425
+ if (typeof a === 'object') a = a.version;
426
+ if (typeof b === 'object') b = b.version;
427
+ return a !== b
428
+
429
+ case '':
430
+ case '=':
431
+ case '==':
432
+ return eq(a, b)
433
+
434
+ case '!=':
435
+ return neq(a, b)
436
+
437
+ case '>':
438
+ return gt(a, b)
439
+
440
+ case '>=':
441
+ return gte(a, b)
442
+
443
+ case '<':
444
+ return lt(a, b)
445
+
446
+ case '<=':
447
+ return lte(a, b)
448
+
449
+ default:
450
+ throw new SemVerError(`Invalid operator: ${op}`)
451
+ }
452
+ };
453
+
454
+ const ANY = Symbol('SemVer ANY');
455
+
456
+ /**
457
+ * Represents a comparator object used for version comparison
458
+ *
459
+ * @function Comparator
460
+ * @param {string|Comparator} - Comparator string or another Comparator object
461
+ * @throw {SemVerError} - Throws an error if the provided comparator is invalid
462
+ * @example
463
+ *
464
+ * Comparator('> 1.2.3')
465
+ * Comparator('<= 1.2')
466
+ * Comparator('= 1.21.3-draft')
467
+ * Comparator('1.21.3-draft')
468
+ *
469
+ */
470
+
471
+ class Comparator {
472
+ static get ANY() {
473
+ return ANY
474
+ }
475
+
476
+ constructor(comp) {
477
+ if (comp instanceof Comparator) {
478
+ comp = comp.value;
479
+ }
480
+
481
+ this.parse(comp);
482
+
483
+ if (this.semver === ANY) {
484
+ this.value = '';
485
+ } else {
486
+ this.value = this.operator + this.semver.version;
487
+ }
488
+ }
489
+
490
+ parse(comp) {
491
+ const r = re[t.COMPARATOR];
492
+ const m = comp.match(r);
493
+
494
+ if (!m) {
495
+ throw new SemVerError(`Invalid comparator: ${comp}`)
496
+ }
497
+
498
+ this.operator = m[1] !== undefined ? m[1] : '';
499
+ if (this.operator === '=') {
500
+ this.operator = '';
501
+ }
502
+
503
+ this.semver = SemVer$1(m[2]);
504
+ }
505
+
506
+ toString() {
507
+ return this.value
508
+ }
509
+
510
+ test(version) {
511
+ // if (this.semver === ANY || version === ANY) {
512
+ // return true
513
+ // }
514
+
515
+ if (typeof version === 'string') {
516
+ try {
517
+ version = SemVer$1(version);
518
+ } catch (err) {
519
+ return false
520
+ }
521
+ }
522
+
523
+ return cmp(version, this.operator, this.semver)
524
+ }
525
+
526
+ intersects(comp) {
527
+ if (!(comp instanceof Comparator)) {
528
+ throw new SemVerError('a Comparator is required')
529
+ }
530
+
531
+ if (this.operator === '') {
532
+ if (this.value === '') {
533
+ return true
534
+ }
535
+ return Range$1(comp.value).test(this.value)
536
+ } else if (comp.operator === '') {
537
+ if (comp.value === '') {
538
+ return true
539
+ }
540
+ return Range$1(this.value).test(comp.semver)
541
+ }
542
+
543
+ const sameDirectionIncreasing =
544
+ (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
545
+ const sameDirectionDecreasing =
546
+ (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
547
+ const sameSemVer = this.semver.version === comp.semver.version;
548
+ const differentDirectionsInclusive =
549
+ (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
550
+ const oppositeDirectionsLessThan =
551
+ cmp(this.semver, '<', comp.semver) &&
552
+ (this.operator === '>=' || this.operator === '>') &&
553
+ (comp.operator === '<=' || comp.operator === '<');
554
+ const oppositeDirectionsGreaterThan =
555
+ cmp(this.semver, '>', comp.semver) &&
556
+ (this.operator === '<=' || this.operator === '<') &&
557
+ (comp.operator === '>=' || comp.operator === '>');
558
+
559
+ return (
560
+ sameDirectionIncreasing ||
561
+ sameDirectionDecreasing ||
562
+ (sameSemVer && differentDirectionsInclusive) ||
563
+ oppositeDirectionsLessThan ||
564
+ oppositeDirectionsGreaterThan
565
+ )
566
+ }
567
+ }
568
+
569
+ var Comparator$1 = comp => new Comparator(comp);
570
+
571
+ const cache = new LRU({ max: 1000 });
572
+
573
+ const NUM = '0|[1-9]\\d*';
574
+
575
+ const RANGE_TYPE = {
576
+ ONE: 'one',
577
+ MANY: 'many',
578
+ LATEST: 'latest',
579
+ };
580
+
581
+ const matchSemVer = (string, map) => regexp => {
582
+ const res = string.match(regexp);
583
+ if (!res) return () => false
584
+ const result = () => true;
585
+ for (const [key, pos, def = 0] of map) {
586
+ result[key] = res[pos] || def;
587
+ }
588
+ return result
589
+ };
590
+
591
+ // take a set of comparators and determine whether there
592
+ // exists a version which can satisfy it
593
+ const isSatisfiable = comparators => {
594
+ let result = true;
595
+ const remainingComparators = comparators.slice();
596
+ let testComparator = remainingComparators.pop();
597
+
598
+ while (result && remainingComparators.length) {
599
+ result = remainingComparators.every(otherComparator => {
600
+ return testComparator.intersects(otherComparator)
601
+ });
602
+
603
+ testComparator = remainingComparators.pop();
604
+ }
605
+
606
+ return result
607
+ };
608
+
609
+ /**
610
+ * Represents a range of versions for semantic versioning
611
+ *
612
+ * @function Range
613
+ * @tag range
614
+ * @param {string} - Version range
615
+ * @throws {SemVerError} - Throws an error if the provided range is invalid
616
+ * @example
617
+ *
618
+ * expect(() => Range('wrong range')).toThrow()
619
+ * expect(Range('1.0').test('1.0')).toBeTruthy()
620
+ * expect(Range('1.0').test('1.0.0')).toBeFalsy()
621
+ *
622
+ * expect(Range('~').toString()).toEqual('>=0.0.0-0')
623
+ * expect(Range('~').test('1.2.3-draft')).toBeTruthy()
624
+ * expect(Range('1.~').test('1.2.3-draft')).toBeFalsy()
625
+ *
626
+ * expect(Range('+').toString()).toEqual('>=1.0.0')
627
+ * expect(Range('+').test('1.2.3-draft')).toBeFalsy()
628
+ * expect(Range('1.0.+').test('1.0.3')).toBeTruthy()
629
+ *
630
+ * expect(Range('*').test('1.0')).toBeTruthy()
631
+ * expect(Range('*').test('1.0.0-draft')).toBeTruthy()
632
+ * expect(Range('1.*').test('1.1.3')).toBeFalsy()
633
+ *
634
+ * expect(Range('1~.2.0').test('4.3.2')).toBeTruthy()
635
+ * expect(Range('1~.2.0').test('4.3.2-draft')).toBeTruthy()
636
+ * expect(Range('1.2~.0').toString()).toEqual('>=1.2.0-0 <2.0.0-0')
637
+ *
638
+ */
639
+ class Range {
640
+ constructor(range) {
641
+ if (range instanceof Range) return new Range(range.raw)
642
+
643
+ if (range instanceof Comparator) {
644
+ this.raw = range.value;
645
+ this.set = [[range]];
646
+ this.format();
647
+ return this
648
+ }
649
+
650
+ this.raw = range;
651
+ const [type, set, subType] = this.makeRangeSet(range);
652
+ this.set = set;
653
+ this.type = type;
654
+ this.subType = subType;
655
+
656
+ if (!this.set.length) {
657
+ throw new SemVerError(`Invalid SemVer Range: ${range}`)
658
+ }
659
+
660
+ this.format();
661
+ }
662
+
663
+ get comparators() {
664
+ const res = [];
665
+ for (const a of this.set) {
666
+ for (const b of a) {
667
+ res.push(b);
668
+ }
669
+ }
670
+ return res
671
+ }
672
+
673
+ isMonoVersion() {
674
+ return this.type === RANGE_TYPE.ONE
675
+ }
676
+
677
+ isResolved() {
678
+ return this.isMonoVersion()
679
+ }
680
+
681
+ format() {
682
+ this.range = this.set
683
+ .map(comps => {
684
+ return comps.join(' ').trim()
685
+ })
686
+ .join('||')
687
+ .trim();
688
+ return this.range
689
+ }
690
+
691
+ toString() {
692
+ return this.range
693
+ }
694
+
695
+ makeRangeSet(range) {
696
+ range = range.trim();
697
+ const memoKey = `parseRange:${range}`;
698
+ const cached = cache.get(memoKey);
699
+ if (cached) return cached
700
+
701
+ range = range.replace(/\s+/, '');
702
+
703
+ const [type, comparators, subType] = makeComparators(range);
704
+ if (!comparators) return [null, []]
705
+
706
+ const set = comparators.map(comp => comp.split(/\s+/).map(comp => Comparator$1(comp)));
707
+
708
+ cache.set(memoKey, [type, set, subType]);
709
+ return [type, set, subType]
710
+ }
711
+
712
+ intersects(range) {
713
+ if (!(range instanceof Range)) {
714
+ throw new SemVerError('a Range is required')
715
+ }
716
+
717
+ return this.set.some(thisComparators => {
718
+ return (
719
+ isSatisfiable(thisComparators) &&
720
+ range.set.some(rangeComparators => {
721
+ return (
722
+ isSatisfiable(rangeComparators) &&
723
+ thisComparators.every(thisComparator => {
724
+ return rangeComparators.every(rangeComparator => {
725
+ return thisComparator.intersects(rangeComparator)
726
+ })
727
+ })
728
+ )
729
+ })
730
+ )
731
+ })
732
+ }
733
+
734
+ // if ANY of the sets match ALL of its comparators, then pass
735
+ test(version) {
736
+ if (!version) {
737
+ return false
738
+ }
739
+
740
+ if (typeof version === 'string') {
741
+ try {
742
+ version = SemVer$1(version);
743
+ } catch (er) {
744
+ return false
745
+ }
746
+ }
747
+
748
+ for (let i = 0; i < this.set.length; i++) {
749
+ if (testSet(this.set[i], version)) return true
750
+ }
751
+ return false
752
+ }
753
+ }
754
+
755
+ const RANGE_SUB_TYPE = {
756
+ RESOLVED: 'resolved',
757
+ STABLE: 'stable',
758
+ LATEST_STABLE: 'latest_stable',
759
+ LATEST_UNSTABLE: 'latest_unstable',
760
+ UNSTABLE: 'unstable',
761
+ ALL: 'all',
762
+ ABOVE: 'above',
763
+ };
764
+
765
+ const makeComparators = comp => {
766
+ let newComp;
767
+
768
+ newComp = checkSpecific(comp);
769
+ if (newComp) return [RANGE_TYPE.ONE, [newComp], RANGE_SUB_TYPE.RESOLVED]
770
+
771
+ newComp = checkOnlyStable(comp);
772
+ if (newComp) return [RANGE_TYPE.LATEST, [newComp], RANGE_SUB_TYPE.STABLE]
773
+
774
+ newComp = checkLatestStable(comp);
775
+ if (newComp) return [RANGE_TYPE.LATEST, [newComp], RANGE_SUB_TYPE.LATEST_STABLE]
776
+
777
+ newComp = checkLatestUnStable(comp);
778
+ if (newComp) return [RANGE_TYPE.LATEST, [newComp], RANGE_SUB_TYPE.LATEST_UNSTABLE]
779
+
780
+ newComp = checkPossibleUnstable(comp);
781
+ if (newComp) return [RANGE_TYPE.LATEST, [newComp], RANGE_SUB_TYPE.UNSTABLE]
782
+
783
+ newComp = checkAllVersions(comp);
784
+ if (newComp) return [RANGE_TYPE.MANY, newComp, RANGE_SUB_TYPE.ALL]
785
+
786
+ newComp = checkAllAboveVersions(comp);
787
+ if (newComp) return [RANGE_TYPE.MANY, newComp, RANGE_SUB_TYPE.ABOVE]
788
+
789
+ return []
790
+ };
791
+
792
+ const checkSpecific = comp => {
793
+ const res = comp.match(re[t.FULL]);
794
+ if (res) return comp
795
+ };
796
+
797
+ const checkAllVersions = comp => {
798
+ if (comp === '*') return ['>=0.0.0-0', '>=0.0']
799
+ const match = matchSemVer(comp, [
800
+ ['M', 1],
801
+ ['m', 2],
802
+ ['p', 3],
803
+ ]);
804
+ let r;
805
+
806
+ r = match(`^(${NUM})[.]([*])$`);
807
+ if (r()) return [`>=${r.M}.0 <${+r.M + 1}.0`]
808
+
809
+ r = match(`^(${NUM})[.]([*])[.](${NUM})$`);
810
+ if (r()) return [`>=${r.M}.0.0-0 <${+r.M + 1}.0.0-0`]
811
+
812
+ r = match(`^(${NUM})[.](${NUM})[.]([*])$`);
813
+ if (r()) return [`>=${r.M}.${r.m}.0-0 <${r.M}.${+r.m + 1}.0-0`]
814
+ };
815
+
816
+ const checkAllAboveVersions = comp => {
817
+ const match = matchSemVer(comp, [
818
+ ['M', 1],
819
+ ['m', 2],
820
+ ['p', 3],
821
+ ]);
822
+ let r;
823
+
824
+ r = match(`^(${NUM})[.](${NUM})[*]$`);
825
+ if (r()) return [`>=${r.M}.${r.m} <${+r.M + 1}.0`]
826
+
827
+ r = match(`^(${NUM})[.](${NUM})[*][.](${NUM})$`);
828
+ if (r()) return [`>=${r.M}.${r.m}.0-0 <${+r.M + 1}.0.0-0`]
829
+
830
+ r = match(`^(${NUM})[.](${NUM})[.](${NUM})[*]$`);
831
+ if (r()) return [`>=${r.M}.${r.m}.${r.p}-0 <${r.M}.${+r.m + 1}.0-0`]
832
+ };
833
+
834
+ const checkPossibleUnstable = comp => {
835
+ if (comp === '~') return `>=0.0.0-0`
836
+ const match = matchSemVer(comp, [
837
+ ['M', 1],
838
+ ['m', 2],
839
+ ['p', 3],
840
+ ]);
841
+ let r;
842
+
843
+ r = match(`^(${NUM})[.]([~])$`);
844
+ if (r()) return `>=${r.M}.0 <${+r.M + 1}.0`
845
+
846
+ r = match(`^(${NUM})[.]([~])[.](${NUM})$`);
847
+ if (r()) return `>=${r.M}.0.0-0 <${+r.M + 1}.0.0-0`
848
+
849
+ r = match(`^(${NUM})[.](${NUM})[.]([~])$`);
850
+ if (r()) return `>=${r.M}.${r.m}.0-0 <${r.M}.${+r.m + 1}.0-0`
851
+ };
852
+
853
+ const checkOnlyStable = comp => {
854
+ if (comp === '+') return `>=1.0.0`
855
+ const match = matchSemVer(comp, [
856
+ ['M', 1],
857
+ ['m', 2],
858
+ ['p', 3],
859
+ ]);
860
+
861
+ let r;
862
+
863
+ r = match(`^(${NUM})[.]([+])(?:[.](${NUM}))?$`);
864
+ if (r()) return `>=${r.M}.0.0 <${+r.M + 1}.0.0`
865
+
866
+ r = match(`^(${NUM})[.](${NUM})[.]([+])$`);
867
+ if (r()) return `>=${r.M}.${r.m}.0 <${r.M}.${+r.m + 1}.0`
868
+ };
869
+
870
+ const checkLatestStable = comp => {
871
+ const match = matchSemVer(comp, [
872
+ ['M', 1],
873
+ ['m', 2],
874
+ ['p', 3],
875
+ ]);
876
+
877
+ let r;
878
+ r = match(`^(${NUM})[+][.](${NUM})[.](${NUM})$`);
879
+ if (r()) return `>=${r.M}.${r.m}.${r.p}`
880
+
881
+ r = match(`^(${NUM})[.](${NUM})[+][.](${NUM})$`);
882
+ if (r()) return `>=${r.M}.${r.m}.${r.p} <${+r.M + 1}.0.0`
883
+
884
+ r = match(`^(${NUM})[.](${NUM})[.](${NUM})[+]$`);
885
+ if (r()) return `>=${r.M}.${r.m}.${r.p} <${r.M}.${+r.m + 1}.0`
886
+ };
887
+
888
+ const checkLatestUnStable = comp => {
889
+ const match = matchSemVer(comp, [
890
+ ['M', 1],
891
+ ['m', 2],
892
+ ['p', 3],
893
+ ]);
894
+
895
+ let r;
896
+ r = match(`^(${NUM})[~][.](${NUM})[.](${NUM})$`);
897
+ if (r()) return `>=${r.M}.${r.m}.${r.p}-0`
898
+
899
+ r = match(`^(${NUM})[.](${NUM})[~][.](${NUM})$`);
900
+ if (r()) return `>=${r.M}.${r.m}.${r.p}-0 <${+r.M + 1}.0.0-0`
901
+
902
+ r = match(`^(${NUM})[.](${NUM})[.](${NUM})[~]$`);
903
+ if (r()) return `>=${r.M}.${r.m}.${r.p}-0 <${r.M}.${+r.m + 1}.0-0`
904
+ };
905
+
906
+ const testSet = (set, version) => {
907
+ for (let i = 0; i < set.length; i++) {
908
+ if (set[i].semver.is2Parts() && !version.is2Parts()) return false
909
+ if (version.is2Parts() && !set[i].semver.is2Parts()) return false
910
+ if (set[i].semver.isStable() && !version.isStable()) return false
911
+ if (!set[i].test(version)) return false
912
+ }
913
+
914
+ return true
915
+ };
916
+
917
+ var Range$1 = range => new Range(range);
918
+
919
+ /**
920
+ * Represents a matcher object used for version matching
921
+ *
922
+ * @function Matcher
923
+ * @tag matcher
924
+ * @param {string} - Version string or range to create a matcher for
925
+ * @throws {SemVerError} - Throws an error if the provided version or range is invalid
926
+ * @example
927
+ *
928
+ * expect(() => Matcher('wrong range')).toThrow()
929
+ * expect(Matcher('1.0').isMonoType()).toBeTruthy()
930
+ * expect(Matcher('1.0.1').isMonoType()).toBeTruthy()
931
+ * expect(Matcher('1.0.1').isResolved()).toBeTruthy()
932
+ * expect(Matcher('1~.2.0').isLatestType()).toBeTruthy()
933
+ * expect(() => Matcher('1.*')).toThrow()
934
+ *
935
+ */
936
+ class Matcher {
937
+ constructor(value) {
938
+ this.raw = value;
939
+ this.range = Range$1(value);
940
+ if (this.range.type !== RANGE_TYPE.ONE && this.range.type !== RANGE_TYPE.LATEST)
941
+ throw new SemVerError(`Wrong version for matcher ${value}`)
942
+ }
943
+
944
+ isMonoType() {
945
+ return this.range.type === RANGE_TYPE.ONE
946
+ }
947
+
948
+ isResolved() {
949
+ return this.isMonoType()
950
+ }
951
+
952
+ isLatestType() {
953
+ return this.range.type === RANGE_TYPE.LATEST
954
+ }
955
+ }
956
+
957
+ var matcher = value => new Matcher(value);
958
+
959
+ export { Comparator$1 as Comparator, matcher as Matcher, RANGE_TYPE, Range$1 as Range, SemVer$1 as SemVer, SemVerError };
960
+ //# sourceMappingURL=index.esm.js.map