@heybox/hb-sdk 0.3.3 → 0.4.0

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 (35) hide show
  1. package/README.md +63 -28
  2. package/dist/cli-chunks/browser-RAy8e8cV.cjs +635 -0
  3. package/dist/cli-chunks/create-D1j9UnM7.cjs +1376 -0
  4. package/dist/cli-chunks/deploy-CknDDoS_.cjs +3730 -0
  5. package/dist/cli-chunks/dev-BS9h09yG.cjs +955 -0
  6. package/dist/cli-chunks/doctor-WTl1HCW0.cjs +186 -0
  7. package/dist/cli-chunks/index-io4h3kr-.cjs +13348 -0
  8. package/dist/cli-chunks/index-yjJgBEBF.cjs +64023 -0
  9. package/dist/cli-chunks/login-B-A53Sta.cjs +193 -0
  10. package/dist/cli-chunks/session-CMBN3o9z.cjs +3040 -0
  11. package/dist/cli.cjs +19 -77707
  12. package/dist/devtools/mock-host/index.html +62 -2
  13. package/dist/devtools/mock-host/main.js +3246 -20
  14. package/dist/index.cjs.js +20 -0
  15. package/dist/index.esm.js +20 -0
  16. package/dist/miniapp-publish.cjs.js +2810 -4
  17. package/dist/miniapp-publish.esm.js +2809 -4
  18. package/dist/protocol.cjs.js +15 -0
  19. package/dist/protocol.esm.js +15 -1
  20. package/dist/templates/vue3-vite-ts/README.md.ejs +2 -2
  21. package/dist/vite.cjs.js +2814 -14
  22. package/dist/vite.esm.js +2814 -14
  23. package/package.json +6 -1
  24. package/skill/SKILL.md +19 -13
  25. package/skill/references/api-protocol.md +7 -2
  26. package/skill/references/api-root.md +24 -13
  27. package/skill/references/cli.md +335 -104
  28. package/skill/scripts/sync-references.mjs +17 -1
  29. package/skill/skill.json +4 -4
  30. package/types/index.d.ts +1 -1
  31. package/types/miniapp-manifest/schema.d.ts +2 -1
  32. package/types/miniapp-publish/index.d.ts +2 -1
  33. package/types/modules/viewport/index.d.ts +33 -0
  34. package/types/protocol/capabilities.d.ts +17 -2
  35. package/types/protocol.d.ts +2 -2
@@ -1,11 +1,2816 @@
1
- const PUBLISH_VERSION_RE = /^\d+\.\d+\.\d+$/;
1
+ var re = {exports: {}};
2
+
3
+ var constants;
4
+ var hasRequiredConstants;
5
+
6
+ function requireConstants () {
7
+ if (hasRequiredConstants) return constants;
8
+ hasRequiredConstants = 1;
9
+
10
+ // Note: this is the semver.org version of the spec that it implements
11
+ // Not necessarily the package version of this code.
12
+ const SEMVER_SPEC_VERSION = '2.0.0';
13
+
14
+ const MAX_LENGTH = 256;
15
+ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
16
+ /* istanbul ignore next */ 9007199254740991;
17
+
18
+ // Max safe segment length for coercion.
19
+ const MAX_SAFE_COMPONENT_LENGTH = 16;
20
+
21
+ // Max safe length for a build identifier. The max length minus 6 characters for
22
+ // the shortest version with a build 0.0.0+BUILD.
23
+ const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
24
+
25
+ const RELEASE_TYPES = [
26
+ 'major',
27
+ 'premajor',
28
+ 'minor',
29
+ 'preminor',
30
+ 'patch',
31
+ 'prepatch',
32
+ 'prerelease',
33
+ ];
34
+
35
+ constants = {
36
+ MAX_LENGTH,
37
+ MAX_SAFE_COMPONENT_LENGTH,
38
+ MAX_SAFE_BUILD_LENGTH,
39
+ MAX_SAFE_INTEGER,
40
+ RELEASE_TYPES,
41
+ SEMVER_SPEC_VERSION,
42
+ FLAG_INCLUDE_PRERELEASE: 0b001,
43
+ FLAG_LOOSE: 0b010,
44
+ };
45
+ return constants;
46
+ }
47
+
48
+ var debug_1;
49
+ var hasRequiredDebug;
50
+
51
+ function requireDebug () {
52
+ if (hasRequiredDebug) return debug_1;
53
+ hasRequiredDebug = 1;
54
+
55
+ const debug = (
56
+ typeof process === 'object' &&
57
+ process.env &&
58
+ process.env.NODE_DEBUG &&
59
+ /\bsemver\b/i.test(process.env.NODE_DEBUG)
60
+ ) ? (...args) => console.error('SEMVER', ...args)
61
+ : () => {};
62
+
63
+ debug_1 = debug;
64
+ return debug_1;
65
+ }
66
+
67
+ var hasRequiredRe;
68
+
69
+ function requireRe () {
70
+ if (hasRequiredRe) return re.exports;
71
+ hasRequiredRe = 1;
72
+ (function (module, exports) {
73
+
74
+ const {
75
+ MAX_SAFE_COMPONENT_LENGTH,
76
+ MAX_SAFE_BUILD_LENGTH,
77
+ MAX_LENGTH,
78
+ } = requireConstants();
79
+ const debug = requireDebug();
80
+ exports = module.exports = {};
81
+
82
+ // The actual regexps go on exports.re
83
+ const re = exports.re = [];
84
+ const safeRe = exports.safeRe = [];
85
+ const src = exports.src = [];
86
+ const safeSrc = exports.safeSrc = [];
87
+ const t = exports.t = {};
88
+ let R = 0;
89
+
90
+ const LETTERDASHNUMBER = '[a-zA-Z0-9-]';
91
+
92
+ // Replace some greedy regex tokens to prevent regex dos issues. These regex are
93
+ // used internally via the safeRe object since all inputs in this library get
94
+ // normalized first to trim and collapse all extra whitespace. The original
95
+ // regexes are exported for userland consumption and lower level usage. A
96
+ // future breaking change could export the safer regex only with a note that
97
+ // all input should have extra whitespace removed.
98
+ const safeRegexReplacements = [
99
+ ['\\s', 1],
100
+ ['\\d', MAX_LENGTH],
101
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
102
+ ];
103
+
104
+ const makeSafeRegex = (value) => {
105
+ for (const [token, max] of safeRegexReplacements) {
106
+ value = value
107
+ .split(`${token}*`).join(`${token}{0,${max}}`)
108
+ .split(`${token}+`).join(`${token}{1,${max}}`);
109
+ }
110
+ return value
111
+ };
112
+
113
+ const createToken = (name, value, isGlobal) => {
114
+ const safe = makeSafeRegex(value);
115
+ const index = R++;
116
+ debug(name, index, value);
117
+ t[name] = index;
118
+ src[index] = value;
119
+ safeSrc[index] = safe;
120
+ re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
121
+ safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined);
122
+ };
123
+
124
+ // The following Regular Expressions can be used for tokenizing,
125
+ // validating, and parsing SemVer version strings.
126
+
127
+ // ## Numeric Identifier
128
+ // A single `0`, or a non-zero digit followed by zero or more digits.
129
+
130
+ createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
131
+ createToken('NUMERICIDENTIFIERLOOSE', '\\d+');
132
+
133
+ // ## Non-numeric Identifier
134
+ // Zero or more digits, followed by a letter or hyphen, and then zero or
135
+ // more letters, digits, or hyphens.
136
+
137
+ createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
138
+
139
+ // ## Main Version
140
+ // Three dot-separated numeric identifiers.
141
+
142
+ createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
143
+ `(${src[t.NUMERICIDENTIFIER]})\\.` +
144
+ `(${src[t.NUMERICIDENTIFIER]})`);
145
+
146
+ createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
147
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
148
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
149
+
150
+ // ## Pre-release Version Identifier
151
+ // A numeric identifier, or a non-numeric identifier.
152
+ // Non-numeric identifiers include numeric identifiers but can be longer.
153
+ // Therefore non-numeric identifiers must go first.
154
+
155
+ createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NONNUMERICIDENTIFIER]
156
+ }|${src[t.NUMERICIDENTIFIER]})`);
157
+
158
+ createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NONNUMERICIDENTIFIER]
159
+ }|${src[t.NUMERICIDENTIFIERLOOSE]})`);
160
+
161
+ // ## Pre-release Version
162
+ // Hyphen, followed by one or more dot-separated pre-release version
163
+ // identifiers.
164
+
165
+ createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
166
+ }(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
167
+
168
+ createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
169
+ }(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
170
+
171
+ // ## Build Metadata Identifier
172
+ // Any combination of digits, letters, or hyphens.
173
+
174
+ createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`);
175
+
176
+ // ## Build Metadata
177
+ // Plus sign, followed by one or more period-separated build metadata
178
+ // identifiers.
179
+
180
+ createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
181
+ }(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
182
+
183
+ // ## Full Version String
184
+ // A main version, followed optionally by a pre-release version and
185
+ // build metadata.
186
+
187
+ // Note that the only major, minor, patch, and pre-release sections of
188
+ // the version string are capturing groups. The build metadata is not a
189
+ // capturing group, because it should not ever be used in version
190
+ // comparison.
191
+
192
+ createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
193
+ }${src[t.PRERELEASE]}?${
194
+ src[t.BUILD]}?`);
195
+
196
+ createToken('FULL', `^${src[t.FULLPLAIN]}$`);
197
+
198
+ // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
199
+ // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
200
+ // common in the npm registry.
201
+ createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
202
+ }${src[t.PRERELEASELOOSE]}?${
203
+ src[t.BUILD]}?`);
204
+
205
+ createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
206
+
207
+ createToken('GTLT', '((?:<|>)?=?)');
208
+
209
+ // Something like "2.*" or "1.2.x".
210
+ // Note that "x.x" is a valid xRange identifier, meaning "any version"
211
+ // Only the first item is strictly required.
212
+ createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
213
+ createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
214
+
215
+ createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
216
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
217
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
218
+ `(?:${src[t.PRERELEASE]})?${
219
+ src[t.BUILD]}?` +
220
+ `)?)?`);
221
+
222
+ createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
223
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
224
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
225
+ `(?:${src[t.PRERELEASELOOSE]})?${
226
+ src[t.BUILD]}?` +
227
+ `)?)?`);
228
+
229
+ createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
230
+ createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
231
+
232
+ // Coercion.
233
+ // Extract anything that could conceivably be a part of a valid semver
234
+ createToken('COERCEPLAIN', `${'(^|[^\\d])' +
235
+ '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
236
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
237
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
238
+ createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
239
+ createToken('COERCEFULL', src[t.COERCEPLAIN] +
240
+ `(?:${src[t.PRERELEASE]})?` +
241
+ `(?:${src[t.BUILD]})?` +
242
+ `(?:$|[^\\d])`);
243
+ createToken('COERCERTL', src[t.COERCE], true);
244
+ createToken('COERCERTLFULL', src[t.COERCEFULL], true);
245
+
246
+ // Tilde ranges.
247
+ // Meaning is "reasonably at or greater than"
248
+ createToken('LONETILDE', '(?:~>?)');
249
+
250
+ createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
251
+ exports.tildeTrimReplace = '$1~';
252
+
253
+ createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
254
+ createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
255
+
256
+ // Caret ranges.
257
+ // Meaning is "at least and backwards compatible with"
258
+ createToken('LONECARET', '(?:\\^)');
259
+
260
+ createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
261
+ exports.caretTrimReplace = '$1^';
262
+
263
+ createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
264
+ createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
265
+
266
+ // A simple gt/lt/eq thing, or just "" to indicate "any version"
267
+ createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
268
+ createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
269
+
270
+ // An expression to strip any whitespace between the gtlt and the thing
271
+ // it modifies, so that `> 1.2.3` ==> `>1.2.3`
272
+ createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
273
+ }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
274
+ exports.comparatorTrimReplace = '$1$2$3';
275
+
276
+ // Something like `1.2.3 - 1.2.4`
277
+ // Note that these all use the loose form, because they'll be
278
+ // checked against either the strict or loose comparator form
279
+ // later.
280
+ createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
281
+ `\\s+-\\s+` +
282
+ `(${src[t.XRANGEPLAIN]})` +
283
+ `\\s*$`);
284
+
285
+ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
286
+ `\\s+-\\s+` +
287
+ `(${src[t.XRANGEPLAINLOOSE]})` +
288
+ `\\s*$`);
289
+
290
+ // Star ranges basically just allow anything at all.
291
+ createToken('STAR', '(<|>)?=?\\s*\\*');
292
+ // >=0.0.0 is like a star
293
+ createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
294
+ createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
295
+ } (re, re.exports));
296
+ return re.exports;
297
+ }
298
+
299
+ var parseOptions_1;
300
+ var hasRequiredParseOptions;
301
+
302
+ function requireParseOptions () {
303
+ if (hasRequiredParseOptions) return parseOptions_1;
304
+ hasRequiredParseOptions = 1;
305
+
306
+ // parse out just the options we care about
307
+ const looseOption = Object.freeze({ loose: true });
308
+ const emptyOpts = Object.freeze({ });
309
+ const parseOptions = options => {
310
+ if (!options) {
311
+ return emptyOpts
312
+ }
313
+
314
+ if (typeof options !== 'object') {
315
+ return looseOption
316
+ }
317
+
318
+ return options
319
+ };
320
+ parseOptions_1 = parseOptions;
321
+ return parseOptions_1;
322
+ }
323
+
324
+ var identifiers;
325
+ var hasRequiredIdentifiers;
326
+
327
+ function requireIdentifiers () {
328
+ if (hasRequiredIdentifiers) return identifiers;
329
+ hasRequiredIdentifiers = 1;
330
+
331
+ const numeric = /^[0-9]+$/;
332
+ const compareIdentifiers = (a, b) => {
333
+ if (typeof a === 'number' && typeof b === 'number') {
334
+ return a === b ? 0 : a < b ? -1 : 1
335
+ }
336
+
337
+ const anum = numeric.test(a);
338
+ const bnum = numeric.test(b);
339
+
340
+ if (anum && bnum) {
341
+ a = +a;
342
+ b = +b;
343
+ }
344
+
345
+ return a === b ? 0
346
+ : (anum && !bnum) ? -1
347
+ : (bnum && !anum) ? 1
348
+ : a < b ? -1
349
+ : 1
350
+ };
351
+
352
+ const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
353
+
354
+ identifiers = {
355
+ compareIdentifiers,
356
+ rcompareIdentifiers,
357
+ };
358
+ return identifiers;
359
+ }
360
+
361
+ var semver$1;
362
+ var hasRequiredSemver$1;
363
+
364
+ function requireSemver$1 () {
365
+ if (hasRequiredSemver$1) return semver$1;
366
+ hasRequiredSemver$1 = 1;
367
+
368
+ const debug = requireDebug();
369
+ const { MAX_LENGTH, MAX_SAFE_INTEGER } = requireConstants();
370
+ const { safeRe: re, t } = requireRe();
371
+
372
+ const parseOptions = requireParseOptions();
373
+ const { compareIdentifiers } = requireIdentifiers();
374
+ class SemVer {
375
+ constructor (version, options) {
376
+ options = parseOptions(options);
377
+
378
+ if (version instanceof SemVer) {
379
+ if (version.loose === !!options.loose &&
380
+ version.includePrerelease === !!options.includePrerelease) {
381
+ return version
382
+ } else {
383
+ version = version.version;
384
+ }
385
+ } else if (typeof version !== 'string') {
386
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`)
387
+ }
388
+
389
+ if (version.length > MAX_LENGTH) {
390
+ throw new TypeError(
391
+ `version is longer than ${MAX_LENGTH} characters`
392
+ )
393
+ }
394
+
395
+ debug('SemVer', version, options);
396
+ this.options = options;
397
+ this.loose = !!options.loose;
398
+ // this isn't actually relevant for versions, but keep it so that we
399
+ // don't run into trouble passing this.options around.
400
+ this.includePrerelease = !!options.includePrerelease;
401
+
402
+ const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
403
+
404
+ if (!m) {
405
+ throw new TypeError(`Invalid Version: ${version}`)
406
+ }
407
+
408
+ this.raw = version;
409
+
410
+ // these are actually numbers
411
+ this.major = +m[1];
412
+ this.minor = +m[2];
413
+ this.patch = +m[3];
414
+
415
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
416
+ throw new TypeError('Invalid major version')
417
+ }
418
+
419
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
420
+ throw new TypeError('Invalid minor version')
421
+ }
422
+
423
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
424
+ throw new TypeError('Invalid patch version')
425
+ }
426
+
427
+ // numberify any prerelease numeric ids
428
+ if (!m[4]) {
429
+ this.prerelease = [];
430
+ } else {
431
+ this.prerelease = m[4].split('.').map((id) => {
432
+ if (/^[0-9]+$/.test(id)) {
433
+ const num = +id;
434
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
435
+ return num
436
+ }
437
+ }
438
+ return id
439
+ });
440
+ }
441
+
442
+ this.build = m[5] ? m[5].split('.') : [];
443
+ this.format();
444
+ }
445
+
446
+ format () {
447
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
448
+ if (this.prerelease.length) {
449
+ this.version += `-${this.prerelease.join('.')}`;
450
+ }
451
+ return this.version
452
+ }
453
+
454
+ toString () {
455
+ return this.version
456
+ }
457
+
458
+ compare (other) {
459
+ debug('SemVer.compare', this.version, this.options, other);
460
+ if (!(other instanceof SemVer)) {
461
+ if (typeof other === 'string' && other === this.version) {
462
+ return 0
463
+ }
464
+ other = new SemVer(other, this.options);
465
+ }
466
+
467
+ if (other.version === this.version) {
468
+ return 0
469
+ }
470
+
471
+ return this.compareMain(other) || this.comparePre(other)
472
+ }
473
+
474
+ compareMain (other) {
475
+ if (!(other instanceof SemVer)) {
476
+ other = new SemVer(other, this.options);
477
+ }
478
+
479
+ if (this.major < other.major) {
480
+ return -1
481
+ }
482
+ if (this.major > other.major) {
483
+ return 1
484
+ }
485
+ if (this.minor < other.minor) {
486
+ return -1
487
+ }
488
+ if (this.minor > other.minor) {
489
+ return 1
490
+ }
491
+ if (this.patch < other.patch) {
492
+ return -1
493
+ }
494
+ if (this.patch > other.patch) {
495
+ return 1
496
+ }
497
+ return 0
498
+ }
499
+
500
+ comparePre (other) {
501
+ if (!(other instanceof SemVer)) {
502
+ other = new SemVer(other, this.options);
503
+ }
504
+
505
+ // NOT having a prerelease is > having one
506
+ if (this.prerelease.length && !other.prerelease.length) {
507
+ return -1
508
+ } else if (!this.prerelease.length && other.prerelease.length) {
509
+ return 1
510
+ } else if (!this.prerelease.length && !other.prerelease.length) {
511
+ return 0
512
+ }
513
+
514
+ let i = 0;
515
+ do {
516
+ const a = this.prerelease[i];
517
+ const b = other.prerelease[i];
518
+ debug('prerelease compare', i, a, b);
519
+ if (a === undefined && b === undefined) {
520
+ return 0
521
+ } else if (b === undefined) {
522
+ return 1
523
+ } else if (a === undefined) {
524
+ return -1
525
+ } else if (a === b) {
526
+ continue
527
+ } else {
528
+ return compareIdentifiers(a, b)
529
+ }
530
+ } while (++i)
531
+ }
532
+
533
+ compareBuild (other) {
534
+ if (!(other instanceof SemVer)) {
535
+ other = new SemVer(other, this.options);
536
+ }
537
+
538
+ let i = 0;
539
+ do {
540
+ const a = this.build[i];
541
+ const b = other.build[i];
542
+ debug('build compare', i, a, b);
543
+ if (a === undefined && b === undefined) {
544
+ return 0
545
+ } else if (b === undefined) {
546
+ return 1
547
+ } else if (a === undefined) {
548
+ return -1
549
+ } else if (a === b) {
550
+ continue
551
+ } else {
552
+ return compareIdentifiers(a, b)
553
+ }
554
+ } while (++i)
555
+ }
556
+
557
+ // preminor will bump the version up to the next minor release, and immediately
558
+ // down to pre-release. premajor and prepatch work the same way.
559
+ inc (release, identifier, identifierBase) {
560
+ if (release.startsWith('pre')) {
561
+ if (!identifier && identifierBase === false) {
562
+ throw new Error('invalid increment argument: identifier is empty')
563
+ }
564
+ // Avoid an invalid semver results
565
+ if (identifier) {
566
+ const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
567
+ if (!match || match[1] !== identifier) {
568
+ throw new Error(`invalid identifier: ${identifier}`)
569
+ }
570
+ }
571
+ }
572
+
573
+ switch (release) {
574
+ case 'premajor':
575
+ this.prerelease.length = 0;
576
+ this.patch = 0;
577
+ this.minor = 0;
578
+ this.major++;
579
+ this.inc('pre', identifier, identifierBase);
580
+ break
581
+ case 'preminor':
582
+ this.prerelease.length = 0;
583
+ this.patch = 0;
584
+ this.minor++;
585
+ this.inc('pre', identifier, identifierBase);
586
+ break
587
+ case 'prepatch':
588
+ // If this is already a prerelease, it will bump to the next version
589
+ // drop any prereleases that might already exist, since they are not
590
+ // relevant at this point.
591
+ this.prerelease.length = 0;
592
+ this.inc('patch', identifier, identifierBase);
593
+ this.inc('pre', identifier, identifierBase);
594
+ break
595
+ // If the input is a non-prerelease version, this acts the same as
596
+ // prepatch.
597
+ case 'prerelease':
598
+ if (this.prerelease.length === 0) {
599
+ this.inc('patch', identifier, identifierBase);
600
+ }
601
+ this.inc('pre', identifier, identifierBase);
602
+ break
603
+ case 'release':
604
+ if (this.prerelease.length === 0) {
605
+ throw new Error(`version ${this.raw} is not a prerelease`)
606
+ }
607
+ this.prerelease.length = 0;
608
+ break
609
+
610
+ case 'major':
611
+ // If this is a pre-major version, bump up to the same major version.
612
+ // Otherwise increment major.
613
+ // 1.0.0-5 bumps to 1.0.0
614
+ // 1.1.0 bumps to 2.0.0
615
+ if (
616
+ this.minor !== 0 ||
617
+ this.patch !== 0 ||
618
+ this.prerelease.length === 0
619
+ ) {
620
+ this.major++;
621
+ }
622
+ this.minor = 0;
623
+ this.patch = 0;
624
+ this.prerelease = [];
625
+ break
626
+ case 'minor':
627
+ // If this is a pre-minor version, bump up to the same minor version.
628
+ // Otherwise increment minor.
629
+ // 1.2.0-5 bumps to 1.2.0
630
+ // 1.2.1 bumps to 1.3.0
631
+ if (this.patch !== 0 || this.prerelease.length === 0) {
632
+ this.minor++;
633
+ }
634
+ this.patch = 0;
635
+ this.prerelease = [];
636
+ break
637
+ case 'patch':
638
+ // If this is not a pre-release version, it will increment the patch.
639
+ // If it is a pre-release it will bump up to the same patch version.
640
+ // 1.2.0-5 patches to 1.2.0
641
+ // 1.2.0 patches to 1.2.1
642
+ if (this.prerelease.length === 0) {
643
+ this.patch++;
644
+ }
645
+ this.prerelease = [];
646
+ break
647
+ // This probably shouldn't be used publicly.
648
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
649
+ case 'pre': {
650
+ const base = Number(identifierBase) ? 1 : 0;
651
+
652
+ if (this.prerelease.length === 0) {
653
+ this.prerelease = [base];
654
+ } else {
655
+ let i = this.prerelease.length;
656
+ while (--i >= 0) {
657
+ if (typeof this.prerelease[i] === 'number') {
658
+ this.prerelease[i]++;
659
+ i = -2;
660
+ }
661
+ }
662
+ if (i === -1) {
663
+ // didn't increment anything
664
+ if (identifier === this.prerelease.join('.') && identifierBase === false) {
665
+ throw new Error('invalid increment argument: identifier already exists')
666
+ }
667
+ this.prerelease.push(base);
668
+ }
669
+ }
670
+ if (identifier) {
671
+ // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
672
+ // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
673
+ let prerelease = [identifier, base];
674
+ if (identifierBase === false) {
675
+ prerelease = [identifier];
676
+ }
677
+ if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
678
+ if (isNaN(this.prerelease[1])) {
679
+ this.prerelease = prerelease;
680
+ }
681
+ } else {
682
+ this.prerelease = prerelease;
683
+ }
684
+ }
685
+ break
686
+ }
687
+ default:
688
+ throw new Error(`invalid increment argument: ${release}`)
689
+ }
690
+ this.raw = this.format();
691
+ if (this.build.length) {
692
+ this.raw += `+${this.build.join('.')}`;
693
+ }
694
+ return this
695
+ }
696
+ }
697
+
698
+ semver$1 = SemVer;
699
+ return semver$1;
700
+ }
701
+
702
+ var parse_1;
703
+ var hasRequiredParse;
704
+
705
+ function requireParse () {
706
+ if (hasRequiredParse) return parse_1;
707
+ hasRequiredParse = 1;
708
+
709
+ const SemVer = requireSemver$1();
710
+ const parse = (version, options, throwErrors = false) => {
711
+ if (version instanceof SemVer) {
712
+ return version
713
+ }
714
+ try {
715
+ return new SemVer(version, options)
716
+ } catch (er) {
717
+ if (!throwErrors) {
718
+ return null
719
+ }
720
+ throw er
721
+ }
722
+ };
723
+
724
+ parse_1 = parse;
725
+ return parse_1;
726
+ }
727
+
728
+ var valid_1;
729
+ var hasRequiredValid$1;
730
+
731
+ function requireValid$1 () {
732
+ if (hasRequiredValid$1) return valid_1;
733
+ hasRequiredValid$1 = 1;
734
+
735
+ const parse = requireParse();
736
+ const valid = (version, options) => {
737
+ const v = parse(version, options);
738
+ return v ? v.version : null
739
+ };
740
+ valid_1 = valid;
741
+ return valid_1;
742
+ }
743
+
744
+ var clean_1;
745
+ var hasRequiredClean;
746
+
747
+ function requireClean () {
748
+ if (hasRequiredClean) return clean_1;
749
+ hasRequiredClean = 1;
750
+
751
+ const parse = requireParse();
752
+ const clean = (version, options) => {
753
+ const s = parse(version.trim().replace(/^[=v]+/, ''), options);
754
+ return s ? s.version : null
755
+ };
756
+ clean_1 = clean;
757
+ return clean_1;
758
+ }
759
+
760
+ var inc_1;
761
+ var hasRequiredInc;
762
+
763
+ function requireInc () {
764
+ if (hasRequiredInc) return inc_1;
765
+ hasRequiredInc = 1;
766
+
767
+ const SemVer = requireSemver$1();
768
+
769
+ const inc = (version, release, options, identifier, identifierBase) => {
770
+ if (typeof (options) === 'string') {
771
+ identifierBase = identifier;
772
+ identifier = options;
773
+ options = undefined;
774
+ }
775
+
776
+ try {
777
+ return new SemVer(
778
+ version instanceof SemVer ? version.version : version,
779
+ options
780
+ ).inc(release, identifier, identifierBase).version
781
+ } catch (er) {
782
+ return null
783
+ }
784
+ };
785
+ inc_1 = inc;
786
+ return inc_1;
787
+ }
788
+
789
+ var diff_1;
790
+ var hasRequiredDiff;
791
+
792
+ function requireDiff () {
793
+ if (hasRequiredDiff) return diff_1;
794
+ hasRequiredDiff = 1;
795
+
796
+ const parse = requireParse();
797
+
798
+ const diff = (version1, version2) => {
799
+ const v1 = parse(version1, null, true);
800
+ const v2 = parse(version2, null, true);
801
+ const comparison = v1.compare(v2);
802
+
803
+ if (comparison === 0) {
804
+ return null
805
+ }
806
+
807
+ const v1Higher = comparison > 0;
808
+ const highVersion = v1Higher ? v1 : v2;
809
+ const lowVersion = v1Higher ? v2 : v1;
810
+ const highHasPre = !!highVersion.prerelease.length;
811
+ const lowHasPre = !!lowVersion.prerelease.length;
812
+
813
+ if (lowHasPre && !highHasPre) {
814
+ // Going from prerelease -> no prerelease requires some special casing
815
+
816
+ // If the low version has only a major, then it will always be a major
817
+ // Some examples:
818
+ // 1.0.0-1 -> 1.0.0
819
+ // 1.0.0-1 -> 1.1.1
820
+ // 1.0.0-1 -> 2.0.0
821
+ if (!lowVersion.patch && !lowVersion.minor) {
822
+ return 'major'
823
+ }
824
+
825
+ // If the main part has no difference
826
+ if (lowVersion.compareMain(highVersion) === 0) {
827
+ if (lowVersion.minor && !lowVersion.patch) {
828
+ return 'minor'
829
+ }
830
+ return 'patch'
831
+ }
832
+ }
833
+
834
+ // add the `pre` prefix if we are going to a prerelease version
835
+ const prefix = highHasPre ? 'pre' : '';
836
+
837
+ if (v1.major !== v2.major) {
838
+ return prefix + 'major'
839
+ }
840
+
841
+ if (v1.minor !== v2.minor) {
842
+ return prefix + 'minor'
843
+ }
844
+
845
+ if (v1.patch !== v2.patch) {
846
+ return prefix + 'patch'
847
+ }
848
+
849
+ // high and low are prereleases
850
+ return 'prerelease'
851
+ };
852
+
853
+ diff_1 = diff;
854
+ return diff_1;
855
+ }
856
+
857
+ var major_1;
858
+ var hasRequiredMajor;
859
+
860
+ function requireMajor () {
861
+ if (hasRequiredMajor) return major_1;
862
+ hasRequiredMajor = 1;
863
+
864
+ const SemVer = requireSemver$1();
865
+ const major = (a, loose) => new SemVer(a, loose).major;
866
+ major_1 = major;
867
+ return major_1;
868
+ }
869
+
870
+ var minor_1;
871
+ var hasRequiredMinor;
872
+
873
+ function requireMinor () {
874
+ if (hasRequiredMinor) return minor_1;
875
+ hasRequiredMinor = 1;
876
+
877
+ const SemVer = requireSemver$1();
878
+ const minor = (a, loose) => new SemVer(a, loose).minor;
879
+ minor_1 = minor;
880
+ return minor_1;
881
+ }
882
+
883
+ var patch_1;
884
+ var hasRequiredPatch;
885
+
886
+ function requirePatch () {
887
+ if (hasRequiredPatch) return patch_1;
888
+ hasRequiredPatch = 1;
889
+
890
+ const SemVer = requireSemver$1();
891
+ const patch = (a, loose) => new SemVer(a, loose).patch;
892
+ patch_1 = patch;
893
+ return patch_1;
894
+ }
895
+
896
+ var prerelease_1;
897
+ var hasRequiredPrerelease;
898
+
899
+ function requirePrerelease () {
900
+ if (hasRequiredPrerelease) return prerelease_1;
901
+ hasRequiredPrerelease = 1;
902
+
903
+ const parse = requireParse();
904
+ const prerelease = (version, options) => {
905
+ const parsed = parse(version, options);
906
+ return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
907
+ };
908
+ prerelease_1 = prerelease;
909
+ return prerelease_1;
910
+ }
911
+
912
+ var compare_1;
913
+ var hasRequiredCompare;
914
+
915
+ function requireCompare () {
916
+ if (hasRequiredCompare) return compare_1;
917
+ hasRequiredCompare = 1;
918
+
919
+ const SemVer = requireSemver$1();
920
+ const compare = (a, b, loose) =>
921
+ new SemVer(a, loose).compare(new SemVer(b, loose));
922
+
923
+ compare_1 = compare;
924
+ return compare_1;
925
+ }
926
+
927
+ var rcompare_1;
928
+ var hasRequiredRcompare;
929
+
930
+ function requireRcompare () {
931
+ if (hasRequiredRcompare) return rcompare_1;
932
+ hasRequiredRcompare = 1;
933
+
934
+ const compare = requireCompare();
935
+ const rcompare = (a, b, loose) => compare(b, a, loose);
936
+ rcompare_1 = rcompare;
937
+ return rcompare_1;
938
+ }
939
+
940
+ var compareLoose_1;
941
+ var hasRequiredCompareLoose;
942
+
943
+ function requireCompareLoose () {
944
+ if (hasRequiredCompareLoose) return compareLoose_1;
945
+ hasRequiredCompareLoose = 1;
946
+
947
+ const compare = requireCompare();
948
+ const compareLoose = (a, b) => compare(a, b, true);
949
+ compareLoose_1 = compareLoose;
950
+ return compareLoose_1;
951
+ }
952
+
953
+ var compareBuild_1;
954
+ var hasRequiredCompareBuild;
955
+
956
+ function requireCompareBuild () {
957
+ if (hasRequiredCompareBuild) return compareBuild_1;
958
+ hasRequiredCompareBuild = 1;
959
+
960
+ const SemVer = requireSemver$1();
961
+ const compareBuild = (a, b, loose) => {
962
+ const versionA = new SemVer(a, loose);
963
+ const versionB = new SemVer(b, loose);
964
+ return versionA.compare(versionB) || versionA.compareBuild(versionB)
965
+ };
966
+ compareBuild_1 = compareBuild;
967
+ return compareBuild_1;
968
+ }
969
+
970
+ var sort_1;
971
+ var hasRequiredSort;
972
+
973
+ function requireSort () {
974
+ if (hasRequiredSort) return sort_1;
975
+ hasRequiredSort = 1;
976
+
977
+ const compareBuild = requireCompareBuild();
978
+ const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
979
+ sort_1 = sort;
980
+ return sort_1;
981
+ }
982
+
983
+ var rsort_1;
984
+ var hasRequiredRsort;
985
+
986
+ function requireRsort () {
987
+ if (hasRequiredRsort) return rsort_1;
988
+ hasRequiredRsort = 1;
989
+
990
+ const compareBuild = requireCompareBuild();
991
+ const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
992
+ rsort_1 = rsort;
993
+ return rsort_1;
994
+ }
995
+
996
+ var gt_1;
997
+ var hasRequiredGt;
998
+
999
+ function requireGt () {
1000
+ if (hasRequiredGt) return gt_1;
1001
+ hasRequiredGt = 1;
1002
+
1003
+ const compare = requireCompare();
1004
+ const gt = (a, b, loose) => compare(a, b, loose) > 0;
1005
+ gt_1 = gt;
1006
+ return gt_1;
1007
+ }
1008
+
1009
+ var lt_1;
1010
+ var hasRequiredLt;
1011
+
1012
+ function requireLt () {
1013
+ if (hasRequiredLt) return lt_1;
1014
+ hasRequiredLt = 1;
1015
+
1016
+ const compare = requireCompare();
1017
+ const lt = (a, b, loose) => compare(a, b, loose) < 0;
1018
+ lt_1 = lt;
1019
+ return lt_1;
1020
+ }
1021
+
1022
+ var eq_1;
1023
+ var hasRequiredEq;
1024
+
1025
+ function requireEq () {
1026
+ if (hasRequiredEq) return eq_1;
1027
+ hasRequiredEq = 1;
1028
+
1029
+ const compare = requireCompare();
1030
+ const eq = (a, b, loose) => compare(a, b, loose) === 0;
1031
+ eq_1 = eq;
1032
+ return eq_1;
1033
+ }
1034
+
1035
+ var neq_1;
1036
+ var hasRequiredNeq;
1037
+
1038
+ function requireNeq () {
1039
+ if (hasRequiredNeq) return neq_1;
1040
+ hasRequiredNeq = 1;
1041
+
1042
+ const compare = requireCompare();
1043
+ const neq = (a, b, loose) => compare(a, b, loose) !== 0;
1044
+ neq_1 = neq;
1045
+ return neq_1;
1046
+ }
1047
+
1048
+ var gte_1;
1049
+ var hasRequiredGte;
1050
+
1051
+ function requireGte () {
1052
+ if (hasRequiredGte) return gte_1;
1053
+ hasRequiredGte = 1;
1054
+
1055
+ const compare = requireCompare();
1056
+ const gte = (a, b, loose) => compare(a, b, loose) >= 0;
1057
+ gte_1 = gte;
1058
+ return gte_1;
1059
+ }
1060
+
1061
+ var lte_1;
1062
+ var hasRequiredLte;
1063
+
1064
+ function requireLte () {
1065
+ if (hasRequiredLte) return lte_1;
1066
+ hasRequiredLte = 1;
1067
+
1068
+ const compare = requireCompare();
1069
+ const lte = (a, b, loose) => compare(a, b, loose) <= 0;
1070
+ lte_1 = lte;
1071
+ return lte_1;
1072
+ }
1073
+
1074
+ var cmp_1;
1075
+ var hasRequiredCmp;
1076
+
1077
+ function requireCmp () {
1078
+ if (hasRequiredCmp) return cmp_1;
1079
+ hasRequiredCmp = 1;
1080
+
1081
+ const eq = requireEq();
1082
+ const neq = requireNeq();
1083
+ const gt = requireGt();
1084
+ const gte = requireGte();
1085
+ const lt = requireLt();
1086
+ const lte = requireLte();
1087
+
1088
+ const cmp = (a, op, b, loose) => {
1089
+ switch (op) {
1090
+ case '===':
1091
+ if (typeof a === 'object') {
1092
+ a = a.version;
1093
+ }
1094
+ if (typeof b === 'object') {
1095
+ b = b.version;
1096
+ }
1097
+ return a === b
1098
+
1099
+ case '!==':
1100
+ if (typeof a === 'object') {
1101
+ a = a.version;
1102
+ }
1103
+ if (typeof b === 'object') {
1104
+ b = b.version;
1105
+ }
1106
+ return a !== b
1107
+
1108
+ case '':
1109
+ case '=':
1110
+ case '==':
1111
+ return eq(a, b, loose)
1112
+
1113
+ case '!=':
1114
+ return neq(a, b, loose)
1115
+
1116
+ case '>':
1117
+ return gt(a, b, loose)
1118
+
1119
+ case '>=':
1120
+ return gte(a, b, loose)
1121
+
1122
+ case '<':
1123
+ return lt(a, b, loose)
1124
+
1125
+ case '<=':
1126
+ return lte(a, b, loose)
1127
+
1128
+ default:
1129
+ throw new TypeError(`Invalid operator: ${op}`)
1130
+ }
1131
+ };
1132
+ cmp_1 = cmp;
1133
+ return cmp_1;
1134
+ }
1135
+
1136
+ var coerce_1;
1137
+ var hasRequiredCoerce;
1138
+
1139
+ function requireCoerce () {
1140
+ if (hasRequiredCoerce) return coerce_1;
1141
+ hasRequiredCoerce = 1;
1142
+
1143
+ const SemVer = requireSemver$1();
1144
+ const parse = requireParse();
1145
+ const { safeRe: re, t } = requireRe();
1146
+
1147
+ const coerce = (version, options) => {
1148
+ if (version instanceof SemVer) {
1149
+ return version
1150
+ }
1151
+
1152
+ if (typeof version === 'number') {
1153
+ version = String(version);
1154
+ }
1155
+
1156
+ if (typeof version !== 'string') {
1157
+ return null
1158
+ }
1159
+
1160
+ options = options || {};
1161
+
1162
+ let match = null;
1163
+ if (!options.rtl) {
1164
+ match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
1165
+ } else {
1166
+ // Find the right-most coercible string that does not share
1167
+ // a terminus with a more left-ward coercible string.
1168
+ // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
1169
+ // With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4'
1170
+ //
1171
+ // Walk through the string checking with a /g regexp
1172
+ // Manually set the index so as to pick up overlapping matches.
1173
+ // Stop when we get a match that ends at the string end, since no
1174
+ // coercible string can be more right-ward without the same terminus.
1175
+ const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
1176
+ let next;
1177
+ while ((next = coerceRtlRegex.exec(version)) &&
1178
+ (!match || match.index + match[0].length !== version.length)
1179
+ ) {
1180
+ if (!match ||
1181
+ next.index + next[0].length !== match.index + match[0].length) {
1182
+ match = next;
1183
+ }
1184
+ coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
1185
+ }
1186
+ // leave it in a clean state
1187
+ coerceRtlRegex.lastIndex = -1;
1188
+ }
1189
+
1190
+ if (match === null) {
1191
+ return null
1192
+ }
1193
+
1194
+ const major = match[2];
1195
+ const minor = match[3] || '0';
1196
+ const patch = match[4] || '0';
1197
+ const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : '';
1198
+ const build = options.includePrerelease && match[6] ? `+${match[6]}` : '';
1199
+
1200
+ return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options)
1201
+ };
1202
+ coerce_1 = coerce;
1203
+ return coerce_1;
1204
+ }
1205
+
1206
+ var truncate_1;
1207
+ var hasRequiredTruncate;
1208
+
1209
+ function requireTruncate () {
1210
+ if (hasRequiredTruncate) return truncate_1;
1211
+ hasRequiredTruncate = 1;
1212
+
1213
+ const parse = requireParse();
1214
+ const constants = requireConstants();
1215
+ const SemVer = requireSemver$1();
1216
+
1217
+ const truncate = (version, truncation, options) => {
1218
+ if (!constants.RELEASE_TYPES.includes(truncation)) {
1219
+ return null
1220
+ }
1221
+
1222
+ const clonedVersion = cloneInputVersion(version, options);
1223
+ return clonedVersion && doTruncation(clonedVersion, truncation)
1224
+ };
1225
+
1226
+ const cloneInputVersion = (version, options) => {
1227
+ const versionStringToParse = (
1228
+ version instanceof SemVer ? version.version : version
1229
+ );
1230
+
1231
+ return parse(versionStringToParse, options)
1232
+ };
1233
+
1234
+ const doTruncation = (version, truncation) => {
1235
+ if (isPrerelease(truncation)) {
1236
+ return version.version
1237
+ }
1238
+
1239
+ version.prerelease = [];
1240
+
1241
+ switch (truncation) {
1242
+ case 'major':
1243
+ version.minor = 0;
1244
+ version.patch = 0;
1245
+ break
1246
+ case 'minor':
1247
+ version.patch = 0;
1248
+ break
1249
+ }
1250
+
1251
+ return version.format()
1252
+ };
1253
+
1254
+ const isPrerelease = (type) => {
1255
+ return type.startsWith('pre')
1256
+ };
1257
+
1258
+ truncate_1 = truncate;
1259
+ return truncate_1;
1260
+ }
1261
+
1262
+ var lrucache;
1263
+ var hasRequiredLrucache;
1264
+
1265
+ function requireLrucache () {
1266
+ if (hasRequiredLrucache) return lrucache;
1267
+ hasRequiredLrucache = 1;
1268
+
1269
+ class LRUCache {
1270
+ constructor () {
1271
+ this.max = 1000;
1272
+ this.map = new Map();
1273
+ }
1274
+
1275
+ get (key) {
1276
+ const value = this.map.get(key);
1277
+ if (value === undefined) {
1278
+ return undefined
1279
+ } else {
1280
+ // Remove the key from the map and add it to the end
1281
+ this.map.delete(key);
1282
+ this.map.set(key, value);
1283
+ return value
1284
+ }
1285
+ }
1286
+
1287
+ delete (key) {
1288
+ return this.map.delete(key)
1289
+ }
1290
+
1291
+ set (key, value) {
1292
+ const deleted = this.delete(key);
1293
+
1294
+ if (!deleted && value !== undefined) {
1295
+ // If cache is full, delete the least recently used item
1296
+ if (this.map.size >= this.max) {
1297
+ const firstKey = this.map.keys().next().value;
1298
+ this.delete(firstKey);
1299
+ }
1300
+
1301
+ this.map.set(key, value);
1302
+ }
1303
+
1304
+ return this
1305
+ }
1306
+ }
1307
+
1308
+ lrucache = LRUCache;
1309
+ return lrucache;
1310
+ }
1311
+
1312
+ var range;
1313
+ var hasRequiredRange;
1314
+
1315
+ function requireRange () {
1316
+ if (hasRequiredRange) return range;
1317
+ hasRequiredRange = 1;
1318
+
1319
+ const SPACE_CHARACTERS = /\s+/g;
1320
+
1321
+ // hoisted class for cyclic dependency
1322
+ class Range {
1323
+ constructor (range, options) {
1324
+ options = parseOptions(options);
1325
+
1326
+ if (range instanceof Range) {
1327
+ if (
1328
+ range.loose === !!options.loose &&
1329
+ range.includePrerelease === !!options.includePrerelease
1330
+ ) {
1331
+ return range
1332
+ } else {
1333
+ return new Range(range.raw, options)
1334
+ }
1335
+ }
1336
+
1337
+ if (range instanceof Comparator) {
1338
+ // just put it in the set and return
1339
+ this.raw = range.value;
1340
+ this.set = [[range]];
1341
+ this.formatted = undefined;
1342
+ return this
1343
+ }
1344
+
1345
+ this.options = options;
1346
+ this.loose = !!options.loose;
1347
+ this.includePrerelease = !!options.includePrerelease;
1348
+
1349
+ // First reduce all whitespace as much as possible so we do not have to rely
1350
+ // on potentially slow regexes like \s*. This is then stored and used for
1351
+ // future error messages as well.
1352
+ this.raw = range.trim().replace(SPACE_CHARACTERS, ' ');
1353
+
1354
+ // First, split on ||
1355
+ this.set = this.raw
1356
+ .split('||')
1357
+ // map the range to a 2d array of comparators
1358
+ .map(r => this.parseRange(r.trim()))
1359
+ // throw out any comparator lists that are empty
1360
+ // this generally means that it was not a valid range, which is allowed
1361
+ // in loose mode, but will still throw if the WHOLE range is invalid.
1362
+ .filter(c => c.length);
1363
+
1364
+ if (!this.set.length) {
1365
+ throw new TypeError(`Invalid SemVer Range: ${this.raw}`)
1366
+ }
1367
+
1368
+ // if we have any that are not the null set, throw out null sets.
1369
+ if (this.set.length > 1) {
1370
+ // keep the first one, in case they're all null sets
1371
+ const first = this.set[0];
1372
+ this.set = this.set.filter(c => !isNullSet(c[0]));
1373
+ if (this.set.length === 0) {
1374
+ this.set = [first];
1375
+ } else if (this.set.length > 1) {
1376
+ // if we have any that are *, then the range is just *
1377
+ for (const c of this.set) {
1378
+ if (c.length === 1 && isAny(c[0])) {
1379
+ this.set = [c];
1380
+ break
1381
+ }
1382
+ }
1383
+ }
1384
+ }
1385
+
1386
+ this.formatted = undefined;
1387
+ }
1388
+
1389
+ get range () {
1390
+ if (this.formatted === undefined) {
1391
+ this.formatted = '';
1392
+ for (let i = 0; i < this.set.length; i++) {
1393
+ if (i > 0) {
1394
+ this.formatted += '||';
1395
+ }
1396
+ const comps = this.set[i];
1397
+ for (let k = 0; k < comps.length; k++) {
1398
+ if (k > 0) {
1399
+ this.formatted += ' ';
1400
+ }
1401
+ this.formatted += comps[k].toString().trim();
1402
+ }
1403
+ }
1404
+ }
1405
+ return this.formatted
1406
+ }
1407
+
1408
+ format () {
1409
+ return this.range
1410
+ }
1411
+
1412
+ toString () {
1413
+ return this.range
1414
+ }
1415
+
1416
+ parseRange (range) {
1417
+ // strip build metadata so it can't bleed into the version
1418
+ range = range.replace(BUILDSTRIPRE, '');
1419
+
1420
+ // memoize range parsing for performance.
1421
+ // this is a very hot path, and fully deterministic.
1422
+ const memoOpts =
1423
+ (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) |
1424
+ (this.options.loose && FLAG_LOOSE);
1425
+ const memoKey = memoOpts + ':' + range;
1426
+ const cached = cache.get(memoKey);
1427
+ if (cached) {
1428
+ return cached
1429
+ }
1430
+
1431
+ const loose = this.options.loose;
1432
+ // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
1433
+ const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
1434
+ range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
1435
+ debug('hyphen replace', range);
1436
+
1437
+ // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
1438
+ range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
1439
+ debug('comparator trim', range);
1440
+
1441
+ // `~ 1.2.3` => `~1.2.3`
1442
+ range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
1443
+ debug('tilde trim', range);
1444
+
1445
+ // `^ 1.2.3` => `^1.2.3`
1446
+ range = range.replace(re[t.CARETTRIM], caretTrimReplace);
1447
+ debug('caret trim', range);
1448
+
1449
+ // At this point, the range is completely trimmed and
1450
+ // ready to be split into comparators.
1451
+
1452
+ let rangeList = range
1453
+ .split(' ')
1454
+ .map(comp => parseComparator(comp, this.options))
1455
+ .join(' ')
1456
+ .split(/\s+/)
1457
+ // >=0.0.0 is equivalent to *
1458
+ .map(comp => replaceGTE0(comp, this.options));
1459
+
1460
+ if (loose) {
1461
+ // in loose mode, throw out any that are not valid comparators
1462
+ rangeList = rangeList.filter(comp => {
1463
+ debug('loose invalid filter', comp, this.options);
1464
+ return !!comp.match(re[t.COMPARATORLOOSE])
1465
+ });
1466
+ }
1467
+ debug('range list', rangeList);
1468
+
1469
+ // if any comparators are the null set, then replace with JUST null set
1470
+ // if more than one comparator, remove any * comparators
1471
+ // also, don't include the same comparator more than once
1472
+ const rangeMap = new Map();
1473
+ const comparators = rangeList.map(comp => new Comparator(comp, this.options));
1474
+ for (const comp of comparators) {
1475
+ if (isNullSet(comp)) {
1476
+ return [comp]
1477
+ }
1478
+ rangeMap.set(comp.value, comp);
1479
+ }
1480
+ if (rangeMap.size > 1 && rangeMap.has('')) {
1481
+ rangeMap.delete('');
1482
+ }
1483
+
1484
+ const result = [...rangeMap.values()];
1485
+ cache.set(memoKey, result);
1486
+ return result
1487
+ }
1488
+
1489
+ intersects (range, options) {
1490
+ if (!(range instanceof Range)) {
1491
+ throw new TypeError('a Range is required')
1492
+ }
1493
+
1494
+ return this.set.some((thisComparators) => {
1495
+ return (
1496
+ isSatisfiable(thisComparators, options) &&
1497
+ range.set.some((rangeComparators) => {
1498
+ return (
1499
+ isSatisfiable(rangeComparators, options) &&
1500
+ thisComparators.every((thisComparator) => {
1501
+ return rangeComparators.every((rangeComparator) => {
1502
+ return thisComparator.intersects(rangeComparator, options)
1503
+ })
1504
+ })
1505
+ )
1506
+ })
1507
+ )
1508
+ })
1509
+ }
1510
+
1511
+ // if ANY of the sets match ALL of its comparators, then pass
1512
+ test (version) {
1513
+ if (!version) {
1514
+ return false
1515
+ }
1516
+
1517
+ if (typeof version === 'string') {
1518
+ try {
1519
+ version = new SemVer(version, this.options);
1520
+ } catch (er) {
1521
+ return false
1522
+ }
1523
+ }
1524
+
1525
+ for (let i = 0; i < this.set.length; i++) {
1526
+ if (testSet(this.set[i], version, this.options)) {
1527
+ return true
1528
+ }
1529
+ }
1530
+ return false
1531
+ }
1532
+ }
1533
+
1534
+ range = Range;
1535
+
1536
+ const LRU = requireLrucache();
1537
+ const cache = new LRU();
1538
+
1539
+ const parseOptions = requireParseOptions();
1540
+ const Comparator = requireComparator();
1541
+ const debug = requireDebug();
1542
+ const SemVer = requireSemver$1();
1543
+ const {
1544
+ safeRe: re,
1545
+ src,
1546
+ t,
1547
+ comparatorTrimReplace,
1548
+ tildeTrimReplace,
1549
+ caretTrimReplace,
1550
+ } = requireRe();
1551
+ const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = requireConstants();
1552
+
1553
+ // unbounded global build-metadata stripper used by parseRange
1554
+ const BUILDSTRIPRE = new RegExp(src[t.BUILD], 'g');
1555
+
1556
+ const isNullSet = c => c.value === '<0.0.0-0';
1557
+ const isAny = c => c.value === '';
1558
+
1559
+ // take a set of comparators and determine whether there
1560
+ // exists a version which can satisfy it
1561
+ const isSatisfiable = (comparators, options) => {
1562
+ let result = true;
1563
+ const remainingComparators = comparators.slice();
1564
+ let testComparator = remainingComparators.pop();
1565
+
1566
+ while (result && remainingComparators.length) {
1567
+ result = remainingComparators.every((otherComparator) => {
1568
+ return testComparator.intersects(otherComparator, options)
1569
+ });
1570
+
1571
+ testComparator = remainingComparators.pop();
1572
+ }
1573
+
1574
+ return result
1575
+ };
1576
+
1577
+ // comprised of xranges, tildes, stars, and gtlt's at this point.
1578
+ // already replaced the hyphen ranges
1579
+ // turn into a set of JUST comparators.
1580
+ const parseComparator = (comp, options) => {
1581
+ comp = comp.replace(re[t.BUILD], '');
1582
+ debug('comp', comp, options);
1583
+ comp = replaceCarets(comp, options);
1584
+ debug('caret', comp);
1585
+ comp = replaceTildes(comp, options);
1586
+ debug('tildes', comp);
1587
+ comp = replaceXRanges(comp, options);
1588
+ debug('xrange', comp);
1589
+ comp = replaceStars(comp, options);
1590
+ debug('stars', comp);
1591
+ return comp
1592
+ };
1593
+
1594
+ const isX = id => !id || id.toLowerCase() === 'x' || id === '*';
1595
+
1596
+ // ~, ~> --> * (any, kinda silly)
1597
+ // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
1598
+ // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
1599
+ // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
1600
+ // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
1601
+ // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
1602
+ // ~0.0.1 --> >=0.0.1 <0.1.0-0
1603
+ const replaceTildes = (comp, options) => {
1604
+ return comp
1605
+ .trim()
1606
+ .split(/\s+/)
1607
+ .map((c) => replaceTilde(c, options))
1608
+ .join(' ')
1609
+ };
1610
+
1611
+ const replaceTilde = (comp, options) => {
1612
+ const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
1613
+ return comp.replace(r, (_, M, m, p, pr) => {
1614
+ debug('tilde', comp, _, M, m, p, pr);
1615
+ let ret;
1616
+
1617
+ if (isX(M)) {
1618
+ ret = '';
1619
+ } else if (isX(m)) {
1620
+ ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
1621
+ } else if (isX(p)) {
1622
+ // ~1.2 == >=1.2.0 <1.3.0-0
1623
+ ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
1624
+ } else if (pr) {
1625
+ debug('replaceTilde pr', pr);
1626
+ ret = `>=${M}.${m}.${p}-${pr
1627
+ } <${M}.${+m + 1}.0-0`;
1628
+ } else {
1629
+ // ~1.2.3 == >=1.2.3 <1.3.0-0
1630
+ ret = `>=${M}.${m}.${p
1631
+ } <${M}.${+m + 1}.0-0`;
1632
+ }
1633
+
1634
+ debug('tilde return', ret);
1635
+ return ret
1636
+ })
1637
+ };
1638
+
1639
+ // ^ --> * (any, kinda silly)
1640
+ // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
1641
+ // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
1642
+ // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
1643
+ // ^1.2.3 --> >=1.2.3 <2.0.0-0
1644
+ // ^1.2.0 --> >=1.2.0 <2.0.0-0
1645
+ // ^0.0.1 --> >=0.0.1 <0.0.2-0
1646
+ // ^0.1.0 --> >=0.1.0 <0.2.0-0
1647
+ const replaceCarets = (comp, options) => {
1648
+ return comp
1649
+ .trim()
1650
+ .split(/\s+/)
1651
+ .map((c) => replaceCaret(c, options))
1652
+ .join(' ')
1653
+ };
1654
+
1655
+ const replaceCaret = (comp, options) => {
1656
+ debug('caret', comp, options);
1657
+ const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
1658
+ const z = options.includePrerelease ? '-0' : '';
1659
+ return comp.replace(r, (_, M, m, p, pr) => {
1660
+ debug('caret', comp, _, M, m, p, pr);
1661
+ let ret;
1662
+
1663
+ if (isX(M)) {
1664
+ ret = '';
1665
+ } else if (isX(m)) {
1666
+ ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
1667
+ } else if (isX(p)) {
1668
+ if (M === '0') {
1669
+ ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
1670
+ } else {
1671
+ ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
1672
+ }
1673
+ } else if (pr) {
1674
+ debug('replaceCaret pr', pr);
1675
+ if (M === '0') {
1676
+ if (m === '0') {
1677
+ ret = `>=${M}.${m}.${p}-${pr
1678
+ } <${M}.${m}.${+p + 1}-0`;
1679
+ } else {
1680
+ ret = `>=${M}.${m}.${p}-${pr
1681
+ } <${M}.${+m + 1}.0-0`;
1682
+ }
1683
+ } else {
1684
+ ret = `>=${M}.${m}.${p}-${pr
1685
+ } <${+M + 1}.0.0-0`;
1686
+ }
1687
+ } else {
1688
+ debug('no pr');
1689
+ if (M === '0') {
1690
+ if (m === '0') {
1691
+ ret = `>=${M}.${m}.${p
1692
+ }${z} <${M}.${m}.${+p + 1}-0`;
1693
+ } else {
1694
+ ret = `>=${M}.${m}.${p
1695
+ }${z} <${M}.${+m + 1}.0-0`;
1696
+ }
1697
+ } else {
1698
+ ret = `>=${M}.${m}.${p
1699
+ } <${+M + 1}.0.0-0`;
1700
+ }
1701
+ }
1702
+
1703
+ debug('caret return', ret);
1704
+ return ret
1705
+ })
1706
+ };
1707
+
1708
+ const replaceXRanges = (comp, options) => {
1709
+ debug('replaceXRanges', comp, options);
1710
+ return comp
1711
+ .split(/\s+/)
1712
+ .map((c) => replaceXRange(c, options))
1713
+ .join(' ')
1714
+ };
1715
+
1716
+ const replaceXRange = (comp, options) => {
1717
+ comp = comp.trim();
1718
+ const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
1719
+ return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
1720
+ debug('xRange', comp, ret, gtlt, M, m, p, pr);
1721
+ const xM = isX(M);
1722
+ const xm = xM || isX(m);
1723
+ const xp = xm || isX(p);
1724
+ const anyX = xp;
1725
+
1726
+ if (gtlt === '=' && anyX) {
1727
+ gtlt = '';
1728
+ }
1729
+
1730
+ // if we're including prereleases in the match, then we need
1731
+ // to fix this to -0, the lowest possible prerelease value
1732
+ pr = options.includePrerelease ? '-0' : '';
1733
+
1734
+ if (xM) {
1735
+ if (gtlt === '>' || gtlt === '<') {
1736
+ // nothing is allowed
1737
+ ret = '<0.0.0-0';
1738
+ } else {
1739
+ // nothing is forbidden
1740
+ ret = '*';
1741
+ }
1742
+ } else if (gtlt && anyX) {
1743
+ // we know patch is an x, because we have any x at all.
1744
+ // replace X with 0
1745
+ if (xm) {
1746
+ m = 0;
1747
+ }
1748
+ p = 0;
1749
+
1750
+ if (gtlt === '>') {
1751
+ // >1 => >=2.0.0
1752
+ // >1.2 => >=1.3.0
1753
+ gtlt = '>=';
1754
+ if (xm) {
1755
+ M = +M + 1;
1756
+ m = 0;
1757
+ p = 0;
1758
+ } else {
1759
+ m = +m + 1;
1760
+ p = 0;
1761
+ }
1762
+ } else if (gtlt === '<=') {
1763
+ // <=0.7.x is actually <0.8.0, since any 0.7.x should
1764
+ // pass. Similarly, <=7.x is actually <8.0.0, etc.
1765
+ gtlt = '<';
1766
+ if (xm) {
1767
+ M = +M + 1;
1768
+ } else {
1769
+ m = +m + 1;
1770
+ }
1771
+ }
1772
+
1773
+ if (gtlt === '<') {
1774
+ pr = '-0';
1775
+ }
1776
+
1777
+ ret = `${gtlt + M}.${m}.${p}${pr}`;
1778
+ } else if (xm) {
1779
+ ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
1780
+ } else if (xp) {
1781
+ ret = `>=${M}.${m}.0${pr
1782
+ } <${M}.${+m + 1}.0-0`;
1783
+ }
1784
+
1785
+ debug('xRange return', ret);
1786
+
1787
+ return ret
1788
+ })
1789
+ };
1790
+
1791
+ // Because * is AND-ed with everything else in the comparator,
1792
+ // and '' means "any version", just remove the *s entirely.
1793
+ const replaceStars = (comp, options) => {
1794
+ debug('replaceStars', comp, options);
1795
+ // Looseness is ignored here. star is always as loose as it gets!
1796
+ return comp
1797
+ .trim()
1798
+ .replace(re[t.STAR], '')
1799
+ };
1800
+
1801
+ const replaceGTE0 = (comp, options) => {
1802
+ debug('replaceGTE0', comp, options);
1803
+ return comp
1804
+ .trim()
1805
+ .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')
1806
+ };
1807
+
1808
+ // This function is passed to string.replace(re[t.HYPHENRANGE])
1809
+ // M, m, patch, prerelease, build
1810
+ // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
1811
+ // 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
1812
+ // 1.2 - 3.4 => >=1.2.0 <3.5.0-0
1813
+ // TODO build?
1814
+ const hyphenReplace = incPr => ($0,
1815
+ from, fM, fm, fp, fpr, fb,
1816
+ to, tM, tm, tp, tpr) => {
1817
+ if (isX(fM)) {
1818
+ from = '';
1819
+ } else if (isX(fm)) {
1820
+ from = `>=${fM}.0.0${incPr ? '-0' : ''}`;
1821
+ } else if (isX(fp)) {
1822
+ from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`;
1823
+ } else if (fpr) {
1824
+ from = `>=${from}`;
1825
+ } else {
1826
+ from = `>=${from}${incPr ? '-0' : ''}`;
1827
+ }
1828
+
1829
+ if (isX(tM)) {
1830
+ to = '';
1831
+ } else if (isX(tm)) {
1832
+ to = `<${+tM + 1}.0.0-0`;
1833
+ } else if (isX(tp)) {
1834
+ to = `<${tM}.${+tm + 1}.0-0`;
1835
+ } else if (tpr) {
1836
+ to = `<=${tM}.${tm}.${tp}-${tpr}`;
1837
+ } else if (incPr) {
1838
+ to = `<${tM}.${tm}.${+tp + 1}-0`;
1839
+ } else {
1840
+ to = `<=${to}`;
1841
+ }
1842
+
1843
+ return `${from} ${to}`.trim()
1844
+ };
1845
+
1846
+ const testSet = (set, version, options) => {
1847
+ for (let i = 0; i < set.length; i++) {
1848
+ if (!set[i].test(version)) {
1849
+ return false
1850
+ }
1851
+ }
1852
+
1853
+ if (version.prerelease.length && !options.includePrerelease) {
1854
+ // Find the set of versions that are allowed to have prereleases
1855
+ // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
1856
+ // That should allow `1.2.3-pr.2` to pass.
1857
+ // However, `1.2.4-alpha.notready` should NOT be allowed,
1858
+ // even though it's within the range set by the comparators.
1859
+ for (let i = 0; i < set.length; i++) {
1860
+ debug(set[i].semver);
1861
+ if (set[i].semver === Comparator.ANY) {
1862
+ continue
1863
+ }
1864
+
1865
+ if (set[i].semver.prerelease.length > 0) {
1866
+ const allowed = set[i].semver;
1867
+ if (allowed.major === version.major &&
1868
+ allowed.minor === version.minor &&
1869
+ allowed.patch === version.patch) {
1870
+ return true
1871
+ }
1872
+ }
1873
+ }
1874
+
1875
+ // Version has a -pre, but it's not one of the ones we like.
1876
+ return false
1877
+ }
1878
+
1879
+ return true
1880
+ };
1881
+ return range;
1882
+ }
1883
+
1884
+ var comparator;
1885
+ var hasRequiredComparator;
1886
+
1887
+ function requireComparator () {
1888
+ if (hasRequiredComparator) return comparator;
1889
+ hasRequiredComparator = 1;
1890
+
1891
+ const ANY = Symbol('SemVer ANY');
1892
+ // hoisted class for cyclic dependency
1893
+ class Comparator {
1894
+ static get ANY () {
1895
+ return ANY
1896
+ }
1897
+
1898
+ constructor (comp, options) {
1899
+ options = parseOptions(options);
1900
+
1901
+ if (comp instanceof Comparator) {
1902
+ if (comp.loose === !!options.loose) {
1903
+ return comp
1904
+ } else {
1905
+ comp = comp.value;
1906
+ }
1907
+ }
1908
+
1909
+ comp = comp.trim().split(/\s+/).join(' ');
1910
+ debug('comparator', comp, options);
1911
+ this.options = options;
1912
+ this.loose = !!options.loose;
1913
+ this.parse(comp);
1914
+
1915
+ if (this.semver === ANY) {
1916
+ this.value = '';
1917
+ } else {
1918
+ this.value = this.operator + this.semver.version;
1919
+ }
1920
+
1921
+ debug('comp', this);
1922
+ }
1923
+
1924
+ parse (comp) {
1925
+ const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
1926
+ const m = comp.match(r);
1927
+
1928
+ if (!m) {
1929
+ throw new TypeError(`Invalid comparator: ${comp}`)
1930
+ }
1931
+
1932
+ this.operator = m[1] !== undefined ? m[1] : '';
1933
+ if (this.operator === '=') {
1934
+ this.operator = '';
1935
+ }
1936
+
1937
+ // if it literally is just '>' or '' then allow anything.
1938
+ if (!m[2]) {
1939
+ this.semver = ANY;
1940
+ } else {
1941
+ this.semver = new SemVer(m[2], this.options.loose);
1942
+ }
1943
+ }
1944
+
1945
+ toString () {
1946
+ return this.value
1947
+ }
1948
+
1949
+ test (version) {
1950
+ debug('Comparator.test', version, this.options.loose);
1951
+
1952
+ if (this.semver === ANY || version === ANY) {
1953
+ return true
1954
+ }
1955
+
1956
+ if (typeof version === 'string') {
1957
+ try {
1958
+ version = new SemVer(version, this.options);
1959
+ } catch (er) {
1960
+ return false
1961
+ }
1962
+ }
1963
+
1964
+ return cmp(version, this.operator, this.semver, this.options)
1965
+ }
1966
+
1967
+ intersects (comp, options) {
1968
+ if (!(comp instanceof Comparator)) {
1969
+ throw new TypeError('a Comparator is required')
1970
+ }
1971
+
1972
+ if (this.operator === '') {
1973
+ if (this.value === '') {
1974
+ return true
1975
+ }
1976
+ return new Range(comp.value, options).test(this.value)
1977
+ } else if (comp.operator === '') {
1978
+ if (comp.value === '') {
1979
+ return true
1980
+ }
1981
+ return new Range(this.value, options).test(comp.semver)
1982
+ }
1983
+
1984
+ options = parseOptions(options);
1985
+
1986
+ // Special cases where nothing can possibly be lower
1987
+ if (options.includePrerelease &&
1988
+ (this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {
1989
+ return false
1990
+ }
1991
+ if (!options.includePrerelease &&
1992
+ (this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {
1993
+ return false
1994
+ }
1995
+
1996
+ // Same direction increasing (> or >=)
1997
+ if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {
1998
+ return true
1999
+ }
2000
+ // Same direction decreasing (< or <=)
2001
+ if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {
2002
+ return true
2003
+ }
2004
+ // same SemVer and both sides are inclusive (<= or >=)
2005
+ if (
2006
+ (this.semver.version === comp.semver.version) &&
2007
+ this.operator.includes('=') && comp.operator.includes('=')) {
2008
+ return true
2009
+ }
2010
+ // opposite directions less than
2011
+ if (cmp(this.semver, '<', comp.semver, options) &&
2012
+ this.operator.startsWith('>') && comp.operator.startsWith('<')) {
2013
+ return true
2014
+ }
2015
+ // opposite directions greater than
2016
+ if (cmp(this.semver, '>', comp.semver, options) &&
2017
+ this.operator.startsWith('<') && comp.operator.startsWith('>')) {
2018
+ return true
2019
+ }
2020
+ return false
2021
+ }
2022
+ }
2023
+
2024
+ comparator = Comparator;
2025
+
2026
+ const parseOptions = requireParseOptions();
2027
+ const { safeRe: re, t } = requireRe();
2028
+ const cmp = requireCmp();
2029
+ const debug = requireDebug();
2030
+ const SemVer = requireSemver$1();
2031
+ const Range = requireRange();
2032
+ return comparator;
2033
+ }
2034
+
2035
+ var satisfies_1;
2036
+ var hasRequiredSatisfies;
2037
+
2038
+ function requireSatisfies () {
2039
+ if (hasRequiredSatisfies) return satisfies_1;
2040
+ hasRequiredSatisfies = 1;
2041
+
2042
+ const Range = requireRange();
2043
+ const satisfies = (version, range, options) => {
2044
+ try {
2045
+ range = new Range(range, options);
2046
+ } catch (er) {
2047
+ return false
2048
+ }
2049
+ return range.test(version)
2050
+ };
2051
+ satisfies_1 = satisfies;
2052
+ return satisfies_1;
2053
+ }
2054
+
2055
+ var toComparators_1;
2056
+ var hasRequiredToComparators;
2057
+
2058
+ function requireToComparators () {
2059
+ if (hasRequiredToComparators) return toComparators_1;
2060
+ hasRequiredToComparators = 1;
2061
+
2062
+ const Range = requireRange();
2063
+
2064
+ // Mostly just for testing and legacy API reasons
2065
+ const toComparators = (range, options) =>
2066
+ new Range(range, options).set
2067
+ .map(comp => comp.map(c => c.value).join(' ').trim().split(' '));
2068
+
2069
+ toComparators_1 = toComparators;
2070
+ return toComparators_1;
2071
+ }
2072
+
2073
+ var maxSatisfying_1;
2074
+ var hasRequiredMaxSatisfying;
2075
+
2076
+ function requireMaxSatisfying () {
2077
+ if (hasRequiredMaxSatisfying) return maxSatisfying_1;
2078
+ hasRequiredMaxSatisfying = 1;
2079
+
2080
+ const SemVer = requireSemver$1();
2081
+ const Range = requireRange();
2082
+
2083
+ const maxSatisfying = (versions, range, options) => {
2084
+ let max = null;
2085
+ let maxSV = null;
2086
+ let rangeObj = null;
2087
+ try {
2088
+ rangeObj = new Range(range, options);
2089
+ } catch (er) {
2090
+ return null
2091
+ }
2092
+ versions.forEach((v) => {
2093
+ if (rangeObj.test(v)) {
2094
+ // satisfies(v, range, options)
2095
+ if (!max || maxSV.compare(v) === -1) {
2096
+ // compare(max, v, true)
2097
+ max = v;
2098
+ maxSV = new SemVer(max, options);
2099
+ }
2100
+ }
2101
+ });
2102
+ return max
2103
+ };
2104
+ maxSatisfying_1 = maxSatisfying;
2105
+ return maxSatisfying_1;
2106
+ }
2107
+
2108
+ var minSatisfying_1;
2109
+ var hasRequiredMinSatisfying;
2110
+
2111
+ function requireMinSatisfying () {
2112
+ if (hasRequiredMinSatisfying) return minSatisfying_1;
2113
+ hasRequiredMinSatisfying = 1;
2114
+
2115
+ const SemVer = requireSemver$1();
2116
+ const Range = requireRange();
2117
+ const minSatisfying = (versions, range, options) => {
2118
+ let min = null;
2119
+ let minSV = null;
2120
+ let rangeObj = null;
2121
+ try {
2122
+ rangeObj = new Range(range, options);
2123
+ } catch (er) {
2124
+ return null
2125
+ }
2126
+ versions.forEach((v) => {
2127
+ if (rangeObj.test(v)) {
2128
+ // satisfies(v, range, options)
2129
+ if (!min || minSV.compare(v) === 1) {
2130
+ // compare(min, v, true)
2131
+ min = v;
2132
+ minSV = new SemVer(min, options);
2133
+ }
2134
+ }
2135
+ });
2136
+ return min
2137
+ };
2138
+ minSatisfying_1 = minSatisfying;
2139
+ return minSatisfying_1;
2140
+ }
2141
+
2142
+ var minVersion_1;
2143
+ var hasRequiredMinVersion;
2144
+
2145
+ function requireMinVersion () {
2146
+ if (hasRequiredMinVersion) return minVersion_1;
2147
+ hasRequiredMinVersion = 1;
2148
+
2149
+ const SemVer = requireSemver$1();
2150
+ const Range = requireRange();
2151
+ const gt = requireGt();
2152
+
2153
+ const minVersion = (range, loose) => {
2154
+ range = new Range(range, loose);
2155
+
2156
+ let minver = new SemVer('0.0.0');
2157
+ if (range.test(minver)) {
2158
+ return minver
2159
+ }
2160
+
2161
+ minver = new SemVer('0.0.0-0');
2162
+ if (range.test(minver)) {
2163
+ return minver
2164
+ }
2165
+
2166
+ minver = null;
2167
+ for (let i = 0; i < range.set.length; ++i) {
2168
+ const comparators = range.set[i];
2169
+
2170
+ let setMin = null;
2171
+ comparators.forEach((comparator) => {
2172
+ // Clone to avoid manipulating the comparator's semver object.
2173
+ const compver = new SemVer(comparator.semver.version);
2174
+ switch (comparator.operator) {
2175
+ case '>':
2176
+ if (compver.prerelease.length === 0) {
2177
+ compver.patch++;
2178
+ } else {
2179
+ compver.prerelease.push(0);
2180
+ }
2181
+ compver.raw = compver.format();
2182
+ /* fallthrough */
2183
+ case '':
2184
+ case '>=':
2185
+ if (!setMin || gt(compver, setMin)) {
2186
+ setMin = compver;
2187
+ }
2188
+ break
2189
+ case '<':
2190
+ case '<=':
2191
+ /* Ignore maximum versions */
2192
+ break
2193
+ /* istanbul ignore next */
2194
+ default:
2195
+ throw new Error(`Unexpected operation: ${comparator.operator}`)
2196
+ }
2197
+ });
2198
+ if (setMin && (!minver || gt(minver, setMin))) {
2199
+ minver = setMin;
2200
+ }
2201
+ }
2202
+
2203
+ if (minver && range.test(minver)) {
2204
+ return minver
2205
+ }
2206
+
2207
+ return null
2208
+ };
2209
+ minVersion_1 = minVersion;
2210
+ return minVersion_1;
2211
+ }
2212
+
2213
+ var valid;
2214
+ var hasRequiredValid;
2215
+
2216
+ function requireValid () {
2217
+ if (hasRequiredValid) return valid;
2218
+ hasRequiredValid = 1;
2219
+
2220
+ const Range = requireRange();
2221
+ const validRange = (range, options) => {
2222
+ try {
2223
+ // Return '*' instead of '' so that truthiness works.
2224
+ // This will throw if it's invalid anyway
2225
+ return new Range(range, options).range || '*'
2226
+ } catch (er) {
2227
+ return null
2228
+ }
2229
+ };
2230
+ valid = validRange;
2231
+ return valid;
2232
+ }
2233
+
2234
+ var outside_1;
2235
+ var hasRequiredOutside;
2236
+
2237
+ function requireOutside () {
2238
+ if (hasRequiredOutside) return outside_1;
2239
+ hasRequiredOutside = 1;
2240
+
2241
+ const SemVer = requireSemver$1();
2242
+ const Comparator = requireComparator();
2243
+ const { ANY } = Comparator;
2244
+ const Range = requireRange();
2245
+ const satisfies = requireSatisfies();
2246
+ const gt = requireGt();
2247
+ const lt = requireLt();
2248
+ const lte = requireLte();
2249
+ const gte = requireGte();
2250
+
2251
+ const outside = (version, range, hilo, options) => {
2252
+ version = new SemVer(version, options);
2253
+ range = new Range(range, options);
2254
+
2255
+ let gtfn, ltefn, ltfn, comp, ecomp;
2256
+ switch (hilo) {
2257
+ case '>':
2258
+ gtfn = gt;
2259
+ ltefn = lte;
2260
+ ltfn = lt;
2261
+ comp = '>';
2262
+ ecomp = '>=';
2263
+ break
2264
+ case '<':
2265
+ gtfn = lt;
2266
+ ltefn = gte;
2267
+ ltfn = gt;
2268
+ comp = '<';
2269
+ ecomp = '<=';
2270
+ break
2271
+ default:
2272
+ throw new TypeError('Must provide a hilo val of "<" or ">"')
2273
+ }
2274
+
2275
+ // If it satisfies the range it is not outside
2276
+ if (satisfies(version, range, options)) {
2277
+ return false
2278
+ }
2279
+
2280
+ // From now on, variable terms are as if we're in "gtr" mode.
2281
+ // but note that everything is flipped for the "ltr" function.
2282
+
2283
+ for (let i = 0; i < range.set.length; ++i) {
2284
+ const comparators = range.set[i];
2285
+
2286
+ let high = null;
2287
+ let low = null;
2288
+
2289
+ comparators.forEach((comparator) => {
2290
+ if (comparator.semver === ANY) {
2291
+ comparator = new Comparator('>=0.0.0');
2292
+ }
2293
+ high = high || comparator;
2294
+ low = low || comparator;
2295
+ if (gtfn(comparator.semver, high.semver, options)) {
2296
+ high = comparator;
2297
+ } else if (ltfn(comparator.semver, low.semver, options)) {
2298
+ low = comparator;
2299
+ }
2300
+ });
2301
+
2302
+ // If the edge version comparator has a operator then our version
2303
+ // isn't outside it
2304
+ if (high.operator === comp || high.operator === ecomp) {
2305
+ return false
2306
+ }
2307
+
2308
+ // If the lowest version comparator has an operator and our version
2309
+ // is less than it then it isn't higher than the range
2310
+ if ((!low.operator || low.operator === comp) &&
2311
+ ltefn(version, low.semver)) {
2312
+ return false
2313
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
2314
+ return false
2315
+ }
2316
+ }
2317
+ return true
2318
+ };
2319
+
2320
+ outside_1 = outside;
2321
+ return outside_1;
2322
+ }
2323
+
2324
+ var gtr_1;
2325
+ var hasRequiredGtr;
2326
+
2327
+ function requireGtr () {
2328
+ if (hasRequiredGtr) return gtr_1;
2329
+ hasRequiredGtr = 1;
2330
+
2331
+ // Determine if version is greater than all the versions possible in the range.
2332
+ const outside = requireOutside();
2333
+ const gtr = (version, range, options) => outside(version, range, '>', options);
2334
+ gtr_1 = gtr;
2335
+ return gtr_1;
2336
+ }
2337
+
2338
+ var ltr_1;
2339
+ var hasRequiredLtr;
2340
+
2341
+ function requireLtr () {
2342
+ if (hasRequiredLtr) return ltr_1;
2343
+ hasRequiredLtr = 1;
2344
+
2345
+ const outside = requireOutside();
2346
+ // Determine if version is less than all the versions possible in the range
2347
+ const ltr = (version, range, options) => outside(version, range, '<', options);
2348
+ ltr_1 = ltr;
2349
+ return ltr_1;
2350
+ }
2351
+
2352
+ var intersects_1;
2353
+ var hasRequiredIntersects;
2354
+
2355
+ function requireIntersects () {
2356
+ if (hasRequiredIntersects) return intersects_1;
2357
+ hasRequiredIntersects = 1;
2358
+
2359
+ const Range = requireRange();
2360
+ const intersects = (r1, r2, options) => {
2361
+ r1 = new Range(r1, options);
2362
+ r2 = new Range(r2, options);
2363
+ return r1.intersects(r2, options)
2364
+ };
2365
+ intersects_1 = intersects;
2366
+ return intersects_1;
2367
+ }
2368
+
2369
+ var simplify;
2370
+ var hasRequiredSimplify;
2371
+
2372
+ function requireSimplify () {
2373
+ if (hasRequiredSimplify) return simplify;
2374
+ hasRequiredSimplify = 1;
2375
+
2376
+ // given a set of versions and a range, create a "simplified" range
2377
+ // that includes the same versions that the original range does
2378
+ // If the original range is shorter than the simplified one, return that.
2379
+ const satisfies = requireSatisfies();
2380
+ const compare = requireCompare();
2381
+ simplify = (versions, range, options) => {
2382
+ const set = [];
2383
+ let first = null;
2384
+ let prev = null;
2385
+ const v = versions.sort((a, b) => compare(a, b, options));
2386
+ for (const version of v) {
2387
+ const included = satisfies(version, range, options);
2388
+ if (included) {
2389
+ prev = version;
2390
+ if (!first) {
2391
+ first = version;
2392
+ }
2393
+ } else {
2394
+ if (prev) {
2395
+ set.push([first, prev]);
2396
+ }
2397
+ prev = null;
2398
+ first = null;
2399
+ }
2400
+ }
2401
+ if (first) {
2402
+ set.push([first, null]);
2403
+ }
2404
+
2405
+ const ranges = [];
2406
+ for (const [min, max] of set) {
2407
+ if (min === max) {
2408
+ ranges.push(min);
2409
+ } else if (!max && min === v[0]) {
2410
+ ranges.push('*');
2411
+ } else if (!max) {
2412
+ ranges.push(`>=${min}`);
2413
+ } else if (min === v[0]) {
2414
+ ranges.push(`<=${max}`);
2415
+ } else {
2416
+ ranges.push(`${min} - ${max}`);
2417
+ }
2418
+ }
2419
+ const simplified = ranges.join(' || ');
2420
+ const original = typeof range.raw === 'string' ? range.raw : String(range);
2421
+ return simplified.length < original.length ? simplified : range
2422
+ };
2423
+ return simplify;
2424
+ }
2425
+
2426
+ var subset_1;
2427
+ var hasRequiredSubset;
2428
+
2429
+ function requireSubset () {
2430
+ if (hasRequiredSubset) return subset_1;
2431
+ hasRequiredSubset = 1;
2432
+
2433
+ const Range = requireRange();
2434
+ const Comparator = requireComparator();
2435
+ const { ANY } = Comparator;
2436
+ const satisfies = requireSatisfies();
2437
+ const compare = requireCompare();
2438
+
2439
+ // Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff:
2440
+ // - Every simple range `r1, r2, ...` is a null set, OR
2441
+ // - Every simple range `r1, r2, ...` which is not a null set is a subset of
2442
+ // some `R1, R2, ...`
2443
+ //
2444
+ // Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff:
2445
+ // - If c is only the ANY comparator
2446
+ // - If C is only the ANY comparator, return true
2447
+ // - Else if in prerelease mode, return false
2448
+ // - else replace c with `[>=0.0.0]`
2449
+ // - If C is only the ANY comparator
2450
+ // - if in prerelease mode, return true
2451
+ // - else replace C with `[>=0.0.0]`
2452
+ // - Let EQ be the set of = comparators in c
2453
+ // - If EQ is more than one, return true (null set)
2454
+ // - Let GT be the highest > or >= comparator in c
2455
+ // - Let LT be the lowest < or <= comparator in c
2456
+ // - If GT and LT, and GT.semver > LT.semver, return true (null set)
2457
+ // - If any C is a = range, and GT or LT are set, return false
2458
+ // - If EQ
2459
+ // - If GT, and EQ does not satisfy GT, return true (null set)
2460
+ // - If LT, and EQ does not satisfy LT, return true (null set)
2461
+ // - If EQ satisfies every C, return true
2462
+ // - Else return false
2463
+ // - If GT
2464
+ // - If GT.semver is lower than any > or >= comp in C, return false
2465
+ // - If GT is >=, and GT.semver does not satisfy every C, return false
2466
+ // - If GT.semver has a prerelease, and not in prerelease mode
2467
+ // - If no C has a prerelease and the GT.semver tuple, return false
2468
+ // - If LT
2469
+ // - If LT.semver is greater than any < or <= comp in C, return false
2470
+ // - If LT is <=, and LT.semver does not satisfy every C, return false
2471
+ // - If LT.semver has a prerelease, and not in prerelease mode
2472
+ // - If no C has a prerelease and the LT.semver tuple, return false
2473
+ // - Else return true
2474
+
2475
+ const subset = (sub, dom, options = {}) => {
2476
+ if (sub === dom) {
2477
+ return true
2478
+ }
2479
+
2480
+ sub = new Range(sub, options);
2481
+ dom = new Range(dom, options);
2482
+ let sawNonNull = false;
2483
+
2484
+ OUTER: for (const simpleSub of sub.set) {
2485
+ for (const simpleDom of dom.set) {
2486
+ const isSub = simpleSubset(simpleSub, simpleDom, options);
2487
+ sawNonNull = sawNonNull || isSub !== null;
2488
+ if (isSub) {
2489
+ continue OUTER
2490
+ }
2491
+ }
2492
+ // the null set is a subset of everything, but null simple ranges in
2493
+ // a complex range should be ignored. so if we saw a non-null range,
2494
+ // then we know this isn't a subset, but if EVERY simple range was null,
2495
+ // then it is a subset.
2496
+ if (sawNonNull) {
2497
+ return false
2498
+ }
2499
+ }
2500
+ return true
2501
+ };
2502
+
2503
+ const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')];
2504
+ const minimumVersion = [new Comparator('>=0.0.0')];
2505
+
2506
+ const simpleSubset = (sub, dom, options) => {
2507
+ if (sub === dom) {
2508
+ return true
2509
+ }
2510
+
2511
+ if (sub.length === 1 && sub[0].semver === ANY) {
2512
+ if (dom.length === 1 && dom[0].semver === ANY) {
2513
+ return true
2514
+ } else if (options.includePrerelease) {
2515
+ sub = minimumVersionWithPreRelease;
2516
+ } else {
2517
+ sub = minimumVersion;
2518
+ }
2519
+ }
2520
+
2521
+ if (dom.length === 1 && dom[0].semver === ANY) {
2522
+ if (options.includePrerelease) {
2523
+ return true
2524
+ } else {
2525
+ dom = minimumVersion;
2526
+ }
2527
+ }
2528
+
2529
+ const eqSet = new Set();
2530
+ let gt, lt;
2531
+ for (const c of sub) {
2532
+ if (c.operator === '>' || c.operator === '>=') {
2533
+ gt = higherGT(gt, c, options);
2534
+ } else if (c.operator === '<' || c.operator === '<=') {
2535
+ lt = lowerLT(lt, c, options);
2536
+ } else {
2537
+ eqSet.add(c.semver);
2538
+ }
2539
+ }
2540
+
2541
+ if (eqSet.size > 1) {
2542
+ return null
2543
+ }
2544
+
2545
+ let gtltComp;
2546
+ if (gt && lt) {
2547
+ gtltComp = compare(gt.semver, lt.semver, options);
2548
+ if (gtltComp > 0) {
2549
+ return null
2550
+ } else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) {
2551
+ return null
2552
+ }
2553
+ }
2554
+
2555
+ // will iterate one or zero times
2556
+ for (const eq of eqSet) {
2557
+ if (gt && !satisfies(eq, String(gt), options)) {
2558
+ return null
2559
+ }
2560
+
2561
+ if (lt && !satisfies(eq, String(lt), options)) {
2562
+ return null
2563
+ }
2564
+
2565
+ for (const c of dom) {
2566
+ if (!satisfies(eq, String(c), options)) {
2567
+ return false
2568
+ }
2569
+ }
2570
+
2571
+ return true
2572
+ }
2573
+
2574
+ let higher, lower;
2575
+ let hasDomLT, hasDomGT;
2576
+ // if the subset has a prerelease, we need a comparator in the superset
2577
+ // with the same tuple and a prerelease, or it's not a subset
2578
+ let needDomLTPre = lt &&
2579
+ !options.includePrerelease &&
2580
+ lt.semver.prerelease.length ? lt.semver : false;
2581
+ let needDomGTPre = gt &&
2582
+ !options.includePrerelease &&
2583
+ gt.semver.prerelease.length ? gt.semver : false;
2584
+ // exception: <1.2.3-0 is the same as <1.2.3
2585
+ if (needDomLTPre && needDomLTPre.prerelease.length === 1 &&
2586
+ lt.operator === '<' && needDomLTPre.prerelease[0] === 0) {
2587
+ needDomLTPre = false;
2588
+ }
2589
+
2590
+ for (const c of dom) {
2591
+ hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>=';
2592
+ hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<=';
2593
+ if (gt) {
2594
+ if (needDomGTPre) {
2595
+ if (c.semver.prerelease && c.semver.prerelease.length &&
2596
+ c.semver.major === needDomGTPre.major &&
2597
+ c.semver.minor === needDomGTPre.minor &&
2598
+ c.semver.patch === needDomGTPre.patch) {
2599
+ needDomGTPre = false;
2600
+ }
2601
+ }
2602
+ if (c.operator === '>' || c.operator === '>=') {
2603
+ higher = higherGT(gt, c, options);
2604
+ if (higher === c && higher !== gt) {
2605
+ return false
2606
+ }
2607
+ } else if (gt.operator === '>=' && !c.test(gt.semver)) {
2608
+ return false
2609
+ }
2610
+ }
2611
+ if (lt) {
2612
+ if (needDomLTPre) {
2613
+ if (c.semver.prerelease && c.semver.prerelease.length &&
2614
+ c.semver.major === needDomLTPre.major &&
2615
+ c.semver.minor === needDomLTPre.minor &&
2616
+ c.semver.patch === needDomLTPre.patch) {
2617
+ needDomLTPre = false;
2618
+ }
2619
+ }
2620
+ if (c.operator === '<' || c.operator === '<=') {
2621
+ lower = lowerLT(lt, c, options);
2622
+ if (lower === c && lower !== lt) {
2623
+ return false
2624
+ }
2625
+ } else if (lt.operator === '<=' && !c.test(lt.semver)) {
2626
+ return false
2627
+ }
2628
+ }
2629
+ if (!c.operator && (lt || gt) && gtltComp !== 0) {
2630
+ return false
2631
+ }
2632
+ }
2633
+
2634
+ // if there was a < or >, and nothing in the dom, then must be false
2635
+ // UNLESS it was limited by another range in the other direction.
2636
+ // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0
2637
+ if (gt && hasDomLT && !lt && gtltComp !== 0) {
2638
+ return false
2639
+ }
2640
+
2641
+ if (lt && hasDomGT && !gt && gtltComp !== 0) {
2642
+ return false
2643
+ }
2644
+
2645
+ // we needed a prerelease range in a specific tuple, but didn't get one
2646
+ // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0,
2647
+ // because it includes prereleases in the 1.2.3 tuple
2648
+ if (needDomGTPre || needDomLTPre) {
2649
+ return false
2650
+ }
2651
+
2652
+ return true
2653
+ };
2654
+
2655
+ // >=1.2.3 is lower than >1.2.3
2656
+ const higherGT = (a, b, options) => {
2657
+ if (!a) {
2658
+ return b
2659
+ }
2660
+ const comp = compare(a.semver, b.semver, options);
2661
+ return comp > 0 ? a
2662
+ : comp < 0 ? b
2663
+ : b.operator === '>' && a.operator === '>=' ? b
2664
+ : a
2665
+ };
2666
+
2667
+ // <=1.2.3 is higher than <1.2.3
2668
+ const lowerLT = (a, b, options) => {
2669
+ if (!a) {
2670
+ return b
2671
+ }
2672
+ const comp = compare(a.semver, b.semver, options);
2673
+ return comp < 0 ? a
2674
+ : comp > 0 ? b
2675
+ : b.operator === '<' && a.operator === '<=' ? b
2676
+ : a
2677
+ };
2678
+
2679
+ subset_1 = subset;
2680
+ return subset_1;
2681
+ }
2682
+
2683
+ var semver;
2684
+ var hasRequiredSemver;
2685
+
2686
+ function requireSemver () {
2687
+ if (hasRequiredSemver) return semver;
2688
+ hasRequiredSemver = 1;
2689
+
2690
+ // just pre-load all the stuff that index.js lazily exports
2691
+ const internalRe = requireRe();
2692
+ const constants = requireConstants();
2693
+ const SemVer = requireSemver$1();
2694
+ const identifiers = requireIdentifiers();
2695
+ const parse = requireParse();
2696
+ const valid = requireValid$1();
2697
+ const clean = requireClean();
2698
+ const inc = requireInc();
2699
+ const diff = requireDiff();
2700
+ const major = requireMajor();
2701
+ const minor = requireMinor();
2702
+ const patch = requirePatch();
2703
+ const prerelease = requirePrerelease();
2704
+ const compare = requireCompare();
2705
+ const rcompare = requireRcompare();
2706
+ const compareLoose = requireCompareLoose();
2707
+ const compareBuild = requireCompareBuild();
2708
+ const sort = requireSort();
2709
+ const rsort = requireRsort();
2710
+ const gt = requireGt();
2711
+ const lt = requireLt();
2712
+ const eq = requireEq();
2713
+ const neq = requireNeq();
2714
+ const gte = requireGte();
2715
+ const lte = requireLte();
2716
+ const cmp = requireCmp();
2717
+ const coerce = requireCoerce();
2718
+ const truncate = requireTruncate();
2719
+ const Comparator = requireComparator();
2720
+ const Range = requireRange();
2721
+ const satisfies = requireSatisfies();
2722
+ const toComparators = requireToComparators();
2723
+ const maxSatisfying = requireMaxSatisfying();
2724
+ const minSatisfying = requireMinSatisfying();
2725
+ const minVersion = requireMinVersion();
2726
+ const validRange = requireValid();
2727
+ const outside = requireOutside();
2728
+ const gtr = requireGtr();
2729
+ const ltr = requireLtr();
2730
+ const intersects = requireIntersects();
2731
+ const simplifyRange = requireSimplify();
2732
+ const subset = requireSubset();
2733
+ semver = {
2734
+ parse,
2735
+ valid,
2736
+ clean,
2737
+ inc,
2738
+ diff,
2739
+ major,
2740
+ minor,
2741
+ patch,
2742
+ prerelease,
2743
+ compare,
2744
+ rcompare,
2745
+ compareLoose,
2746
+ compareBuild,
2747
+ sort,
2748
+ rsort,
2749
+ gt,
2750
+ lt,
2751
+ eq,
2752
+ neq,
2753
+ gte,
2754
+ lte,
2755
+ cmp,
2756
+ coerce,
2757
+ truncate,
2758
+ Comparator,
2759
+ Range,
2760
+ satisfies,
2761
+ toComparators,
2762
+ maxSatisfying,
2763
+ minSatisfying,
2764
+ minVersion,
2765
+ validRange,
2766
+ outside,
2767
+ gtr,
2768
+ ltr,
2769
+ intersects,
2770
+ simplifyRange,
2771
+ subset,
2772
+ SemVer,
2773
+ re: internalRe.re,
2774
+ src: internalRe.src,
2775
+ tokens: internalRe.t,
2776
+ SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
2777
+ RELEASE_TYPES: constants.RELEASE_TYPES,
2778
+ compareIdentifiers: identifiers.compareIdentifiers,
2779
+ rcompareIdentifiers: identifiers.rcompareIdentifiers,
2780
+ };
2781
+ return semver;
2782
+ }
2783
+
2784
+ var semverExports = requireSemver();
2785
+
2
2786
  function isValidMiniappManifestVersion(version) {
3
- return PUBLISH_VERSION_RE.test(String(version || '').trim());
2787
+ return getMiniappManifestVersionError(version) === undefined;
2788
+ }
2789
+ function getMiniappManifestVersionError(version) {
2790
+ if (typeof version !== 'string' || version.trim() === '') {
2791
+ return `必须是合法 SemVer:${String(version)}`;
2792
+ }
2793
+ const normalized = version.trim();
2794
+ const parsed = semverExports.parse(normalized);
2795
+ if (!parsed) {
2796
+ return `必须是合法 SemVer:${normalized}`;
2797
+ }
2798
+ if (parsed.build.length > 0) {
2799
+ return `不能包含 build metadata:${normalized}`;
2800
+ }
2801
+ if (parsed.version !== normalized) {
2802
+ return `必须是合法 SemVer:${normalized}`;
2803
+ }
2804
+ if (parsed.major === 0 && parsed.minor === 0 && parsed.patch === 0) {
2805
+ return '不能是模板默认版本 0.0.0';
2806
+ }
2807
+ return undefined;
4
2808
  }
5
2809
 
6
2810
  const MINIAPP_UPLOAD_SCOPE = 'activity';
7
2811
  const ACTIVITY_UPLOAD_KEY_MAX_LENGTH = 64;
8
- const PUBLISH_USER_MINIPROGRAM_API_PATH = '/mall/developer/user_miniprogram/publish';
2812
+ const PRECHECK_USER_MINIPROGRAM_VERSION_API_PATH = '/mall/developer/user_miniprogram/version/precheck';
2813
+ const SUBMIT_USER_MINIPROGRAM_AUDIT_API_PATH = '/mall/developer/user_miniprogram/version/submit_audit';
9
2814
  const FNV_OFFSET = 0x811c9dc5;
10
2815
  const FNV_PRIME = 0x01000193;
11
2816
  function normalizeRelativePath(relativePath) {
@@ -64,4 +2869,4 @@ function shouldUploadDistFile(relativePath) {
64
2869
  return true;
65
2870
  }
66
2871
 
67
- export { ACTIVITY_UPLOAD_KEY_MAX_LENGTH, MINIAPP_UPLOAD_SCOPE, PUBLISH_USER_MINIPROGRAM_API_PATH, getMiniProgramUploadAlias, getMiniappUploadKey, isValidMiniappManifestVersion as isValidVersion, normalizeRelativePath, relativePathContainsNodeModulesSegment, shouldUploadDistFile, validateUploadPaths };
2872
+ export { ACTIVITY_UPLOAD_KEY_MAX_LENGTH, MINIAPP_UPLOAD_SCOPE, PRECHECK_USER_MINIPROGRAM_VERSION_API_PATH, SUBMIT_USER_MINIPROGRAM_AUDIT_API_PATH, getMiniProgramUploadAlias, getMiniappUploadKey, isValidMiniappManifestVersion as isValidVersion, normalizeRelativePath, relativePathContainsNodeModulesSegment, shouldUploadDistFile, validateUploadPaths };