@iwsdk/cli 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -18,6 +18,2372 @@ import process$2 from 'node:process';
18
18
  import { createRequire } from 'module';
19
19
  import os from 'os';
20
20
 
21
+ function getDefaultExportFromCjs (x) {
22
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
23
+ }
24
+
25
+ var re$2 = {exports: {}};
26
+
27
+ // Note: this is the semver.org version of the spec that it implements
28
+ // Not necessarily the package version of this code.
29
+ const SEMVER_SPEC_VERSION = '2.0.0';
30
+
31
+ const MAX_LENGTH$1 = 256;
32
+ const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
33
+ /* istanbul ignore next */ 9007199254740991;
34
+
35
+ // Max safe segment length for coercion.
36
+ const MAX_SAFE_COMPONENT_LENGTH = 16;
37
+
38
+ // Max safe length for a build identifier. The max length minus 6 characters for
39
+ // the shortest version with a build 0.0.0+BUILD.
40
+ const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH$1 - 6;
41
+
42
+ const RELEASE_TYPES = [
43
+ 'major',
44
+ 'premajor',
45
+ 'minor',
46
+ 'preminor',
47
+ 'patch',
48
+ 'prepatch',
49
+ 'prerelease',
50
+ ];
51
+
52
+ var constants$2 = {
53
+ MAX_LENGTH: MAX_LENGTH$1,
54
+ MAX_SAFE_COMPONENT_LENGTH,
55
+ MAX_SAFE_BUILD_LENGTH,
56
+ MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
57
+ RELEASE_TYPES,
58
+ SEMVER_SPEC_VERSION,
59
+ FLAG_INCLUDE_PRERELEASE: 0b001,
60
+ FLAG_LOOSE: 0b010,
61
+ };
62
+
63
+ const debug$1 = (
64
+ typeof process === 'object' &&
65
+ process.env &&
66
+ process.env.NODE_DEBUG &&
67
+ /\bsemver\b/i.test(process.env.NODE_DEBUG)
68
+ ) ? (...args) => console.error('SEMVER', ...args)
69
+ : () => {};
70
+
71
+ var debug_1 = debug$1;
72
+
73
+ (function (module, exports) {
74
+
75
+ const {
76
+ MAX_SAFE_COMPONENT_LENGTH,
77
+ MAX_SAFE_BUILD_LENGTH,
78
+ MAX_LENGTH,
79
+ } = constants$2;
80
+ const debug = debug_1;
81
+ exports = module.exports = {};
82
+
83
+ // The actual regexps go on exports.re
84
+ const re = exports.re = [];
85
+ const safeRe = exports.safeRe = [];
86
+ const src = exports.src = [];
87
+ const safeSrc = exports.safeSrc = [];
88
+ const t = exports.t = {};
89
+ let R = 0;
90
+
91
+ const LETTERDASHNUMBER = '[a-zA-Z0-9-]';
92
+
93
+ // Replace some greedy regex tokens to prevent regex dos issues. These regex are
94
+ // used internally via the safeRe object since all inputs in this library get
95
+ // normalized first to trim and collapse all extra whitespace. The original
96
+ // regexes are exported for userland consumption and lower level usage. A
97
+ // future breaking change could export the safer regex only with a note that
98
+ // all input should have extra whitespace removed.
99
+ const safeRegexReplacements = [
100
+ ['\\s', 1],
101
+ ['\\d', MAX_LENGTH],
102
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
103
+ ];
104
+
105
+ const makeSafeRegex = (value) => {
106
+ for (const [token, max] of safeRegexReplacements) {
107
+ value = value
108
+ .split(`${token}*`).join(`${token}{0,${max}}`)
109
+ .split(`${token}+`).join(`${token}{1,${max}}`);
110
+ }
111
+ return value
112
+ };
113
+
114
+ const createToken = (name, value, isGlobal) => {
115
+ const safe = makeSafeRegex(value);
116
+ const index = R++;
117
+ debug(name, index, value);
118
+ t[name] = index;
119
+ src[index] = value;
120
+ safeSrc[index] = safe;
121
+ re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
122
+ safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined);
123
+ };
124
+
125
+ // The following Regular Expressions can be used for tokenizing,
126
+ // validating, and parsing SemVer version strings.
127
+
128
+ // ## Numeric Identifier
129
+ // A single `0`, or a non-zero digit followed by zero or more digits.
130
+
131
+ createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
132
+ createToken('NUMERICIDENTIFIERLOOSE', '\\d+');
133
+
134
+ // ## Non-numeric Identifier
135
+ // Zero or more digits, followed by a letter or hyphen, and then zero or
136
+ // more letters, digits, or hyphens.
137
+
138
+ createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
139
+
140
+ // ## Main Version
141
+ // Three dot-separated numeric identifiers.
142
+
143
+ createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
144
+ `(${src[t.NUMERICIDENTIFIER]})\\.` +
145
+ `(${src[t.NUMERICIDENTIFIER]})`);
146
+
147
+ createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
148
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
149
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
150
+
151
+ // ## Pre-release Version Identifier
152
+ // A numeric identifier, or a non-numeric identifier.
153
+ // Non-numberic identifiers include numberic identifiers but can be longer.
154
+ // Therefore non-numberic identifiers must go first.
155
+
156
+ createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NONNUMERICIDENTIFIER]
157
+ }|${src[t.NUMERICIDENTIFIER]})`);
158
+
159
+ createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NONNUMERICIDENTIFIER]
160
+ }|${src[t.NUMERICIDENTIFIERLOOSE]})`);
161
+
162
+ // ## Pre-release Version
163
+ // Hyphen, followed by one or more dot-separated pre-release version
164
+ // identifiers.
165
+
166
+ createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
167
+ }(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
168
+
169
+ createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
170
+ }(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
171
+
172
+ // ## Build Metadata Identifier
173
+ // Any combination of digits, letters, or hyphens.
174
+
175
+ createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`);
176
+
177
+ // ## Build Metadata
178
+ // Plus sign, followed by one or more period-separated build metadata
179
+ // identifiers.
180
+
181
+ createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
182
+ }(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
183
+
184
+ // ## Full Version String
185
+ // A main version, followed optionally by a pre-release version and
186
+ // build metadata.
187
+
188
+ // Note that the only major, minor, patch, and pre-release sections of
189
+ // the version string are capturing groups. The build metadata is not a
190
+ // capturing group, because it should not ever be used in version
191
+ // comparison.
192
+
193
+ createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
194
+ }${src[t.PRERELEASE]}?${
195
+ src[t.BUILD]}?`);
196
+
197
+ createToken('FULL', `^${src[t.FULLPLAIN]}$`);
198
+
199
+ // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
200
+ // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
201
+ // common in the npm registry.
202
+ createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
203
+ }${src[t.PRERELEASELOOSE]}?${
204
+ src[t.BUILD]}?`);
205
+
206
+ createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
207
+
208
+ createToken('GTLT', '((?:<|>)?=?)');
209
+
210
+ // Something like "2.*" or "1.2.x".
211
+ // Note that "x.x" is a valid xRange identifer, meaning "any version"
212
+ // Only the first item is strictly required.
213
+ createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
214
+ createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
215
+
216
+ createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
217
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
218
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
219
+ `(?:${src[t.PRERELEASE]})?${
220
+ src[t.BUILD]}?` +
221
+ `)?)?`);
222
+
223
+ createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
224
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
225
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
226
+ `(?:${src[t.PRERELEASELOOSE]})?${
227
+ src[t.BUILD]}?` +
228
+ `)?)?`);
229
+
230
+ createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
231
+ createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
232
+
233
+ // Coercion.
234
+ // Extract anything that could conceivably be a part of a valid semver
235
+ createToken('COERCEPLAIN', `${'(^|[^\\d])' +
236
+ '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
237
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
238
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
239
+ createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
240
+ createToken('COERCEFULL', src[t.COERCEPLAIN] +
241
+ `(?:${src[t.PRERELEASE]})?` +
242
+ `(?:${src[t.BUILD]})?` +
243
+ `(?:$|[^\\d])`);
244
+ createToken('COERCERTL', src[t.COERCE], true);
245
+ createToken('COERCERTLFULL', src[t.COERCEFULL], true);
246
+
247
+ // Tilde ranges.
248
+ // Meaning is "reasonably at or greater than"
249
+ createToken('LONETILDE', '(?:~>?)');
250
+
251
+ createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
252
+ exports.tildeTrimReplace = '$1~';
253
+
254
+ createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
255
+ createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
256
+
257
+ // Caret ranges.
258
+ // Meaning is "at least and backwards compatible with"
259
+ createToken('LONECARET', '(?:\\^)');
260
+
261
+ createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
262
+ exports.caretTrimReplace = '$1^';
263
+
264
+ createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
265
+ createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
266
+
267
+ // A simple gt/lt/eq thing, or just "" to indicate "any version"
268
+ createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
269
+ createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
270
+
271
+ // An expression to strip any whitespace between the gtlt and the thing
272
+ // it modifies, so that `> 1.2.3` ==> `>1.2.3`
273
+ createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
274
+ }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
275
+ exports.comparatorTrimReplace = '$1$2$3';
276
+
277
+ // Something like `1.2.3 - 1.2.4`
278
+ // Note that these all use the loose form, because they'll be
279
+ // checked against either the strict or loose comparator form
280
+ // later.
281
+ createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
282
+ `\\s+-\\s+` +
283
+ `(${src[t.XRANGEPLAIN]})` +
284
+ `\\s*$`);
285
+
286
+ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
287
+ `\\s+-\\s+` +
288
+ `(${src[t.XRANGEPLAINLOOSE]})` +
289
+ `\\s*$`);
290
+
291
+ // Star ranges basically just allow anything at all.
292
+ createToken('STAR', '(<|>)?=?\\s*\\*');
293
+ // >=0.0.0 is like a star
294
+ createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
295
+ createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
296
+ } (re$2, re$2.exports));
297
+
298
+ var reExports = re$2.exports;
299
+
300
+ // parse out just the options we care about
301
+ const looseOption = Object.freeze({ loose: true });
302
+ const emptyOpts = Object.freeze({ });
303
+ const parseOptions$1 = options => {
304
+ if (!options) {
305
+ return emptyOpts
306
+ }
307
+
308
+ if (typeof options !== 'object') {
309
+ return looseOption
310
+ }
311
+
312
+ return options
313
+ };
314
+ var parseOptions_1 = parseOptions$1;
315
+
316
+ const numeric = /^[0-9]+$/;
317
+ const compareIdentifiers$1 = (a, b) => {
318
+ if (typeof a === 'number' && typeof b === 'number') {
319
+ return a === b ? 0 : a < b ? -1 : 1
320
+ }
321
+
322
+ const anum = numeric.test(a);
323
+ const bnum = numeric.test(b);
324
+
325
+ if (anum && bnum) {
326
+ a = +a;
327
+ b = +b;
328
+ }
329
+
330
+ return a === b ? 0
331
+ : (anum && !bnum) ? -1
332
+ : (bnum && !anum) ? 1
333
+ : a < b ? -1
334
+ : 1
335
+ };
336
+
337
+ const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
338
+
339
+ var identifiers$1 = {
340
+ compareIdentifiers: compareIdentifiers$1,
341
+ rcompareIdentifiers,
342
+ };
343
+
344
+ const debug = debug_1;
345
+ const { MAX_LENGTH, MAX_SAFE_INTEGER } = constants$2;
346
+ const { safeRe: re$1, t: t$1 } = reExports;
347
+
348
+ const parseOptions = parseOptions_1;
349
+ const { compareIdentifiers } = identifiers$1;
350
+ let SemVer$d = class SemVer {
351
+ constructor (version, options) {
352
+ options = parseOptions(options);
353
+
354
+ if (version instanceof SemVer) {
355
+ if (version.loose === !!options.loose &&
356
+ version.includePrerelease === !!options.includePrerelease) {
357
+ return version
358
+ } else {
359
+ version = version.version;
360
+ }
361
+ } else if (typeof version !== 'string') {
362
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`)
363
+ }
364
+
365
+ if (version.length > MAX_LENGTH) {
366
+ throw new TypeError(
367
+ `version is longer than ${MAX_LENGTH} characters`
368
+ )
369
+ }
370
+
371
+ debug('SemVer', version, options);
372
+ this.options = options;
373
+ this.loose = !!options.loose;
374
+ // this isn't actually relevant for versions, but keep it so that we
375
+ // don't run into trouble passing this.options around.
376
+ this.includePrerelease = !!options.includePrerelease;
377
+
378
+ const m = version.trim().match(options.loose ? re$1[t$1.LOOSE] : re$1[t$1.FULL]);
379
+
380
+ if (!m) {
381
+ throw new TypeError(`Invalid Version: ${version}`)
382
+ }
383
+
384
+ this.raw = version;
385
+
386
+ // these are actually numbers
387
+ this.major = +m[1];
388
+ this.minor = +m[2];
389
+ this.patch = +m[3];
390
+
391
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
392
+ throw new TypeError('Invalid major version')
393
+ }
394
+
395
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
396
+ throw new TypeError('Invalid minor version')
397
+ }
398
+
399
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
400
+ throw new TypeError('Invalid patch version')
401
+ }
402
+
403
+ // numberify any prerelease numeric ids
404
+ if (!m[4]) {
405
+ this.prerelease = [];
406
+ } else {
407
+ this.prerelease = m[4].split('.').map((id) => {
408
+ if (/^[0-9]+$/.test(id)) {
409
+ const num = +id;
410
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
411
+ return num
412
+ }
413
+ }
414
+ return id
415
+ });
416
+ }
417
+
418
+ this.build = m[5] ? m[5].split('.') : [];
419
+ this.format();
420
+ }
421
+
422
+ format () {
423
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
424
+ if (this.prerelease.length) {
425
+ this.version += `-${this.prerelease.join('.')}`;
426
+ }
427
+ return this.version
428
+ }
429
+
430
+ toString () {
431
+ return this.version
432
+ }
433
+
434
+ compare (other) {
435
+ debug('SemVer.compare', this.version, this.options, other);
436
+ if (!(other instanceof SemVer)) {
437
+ if (typeof other === 'string' && other === this.version) {
438
+ return 0
439
+ }
440
+ other = new SemVer(other, this.options);
441
+ }
442
+
443
+ if (other.version === this.version) {
444
+ return 0
445
+ }
446
+
447
+ return this.compareMain(other) || this.comparePre(other)
448
+ }
449
+
450
+ compareMain (other) {
451
+ if (!(other instanceof SemVer)) {
452
+ other = new SemVer(other, this.options);
453
+ }
454
+
455
+ if (this.major < other.major) {
456
+ return -1
457
+ }
458
+ if (this.major > other.major) {
459
+ return 1
460
+ }
461
+ if (this.minor < other.minor) {
462
+ return -1
463
+ }
464
+ if (this.minor > other.minor) {
465
+ return 1
466
+ }
467
+ if (this.patch < other.patch) {
468
+ return -1
469
+ }
470
+ if (this.patch > other.patch) {
471
+ return 1
472
+ }
473
+ return 0
474
+ }
475
+
476
+ comparePre (other) {
477
+ if (!(other instanceof SemVer)) {
478
+ other = new SemVer(other, this.options);
479
+ }
480
+
481
+ // NOT having a prerelease is > having one
482
+ if (this.prerelease.length && !other.prerelease.length) {
483
+ return -1
484
+ } else if (!this.prerelease.length && other.prerelease.length) {
485
+ return 1
486
+ } else if (!this.prerelease.length && !other.prerelease.length) {
487
+ return 0
488
+ }
489
+
490
+ let i = 0;
491
+ do {
492
+ const a = this.prerelease[i];
493
+ const b = other.prerelease[i];
494
+ debug('prerelease compare', i, a, b);
495
+ if (a === undefined && b === undefined) {
496
+ return 0
497
+ } else if (b === undefined) {
498
+ return 1
499
+ } else if (a === undefined) {
500
+ return -1
501
+ } else if (a === b) {
502
+ continue
503
+ } else {
504
+ return compareIdentifiers(a, b)
505
+ }
506
+ } while (++i)
507
+ }
508
+
509
+ compareBuild (other) {
510
+ if (!(other instanceof SemVer)) {
511
+ other = new SemVer(other, this.options);
512
+ }
513
+
514
+ let i = 0;
515
+ do {
516
+ const a = this.build[i];
517
+ const b = other.build[i];
518
+ debug('build 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
+ // preminor will bump the version up to the next minor release, and immediately
534
+ // down to pre-release. premajor and prepatch work the same way.
535
+ inc (release, identifier, identifierBase) {
536
+ if (release.startsWith('pre')) {
537
+ if (!identifier && identifierBase === false) {
538
+ throw new Error('invalid increment argument: identifier is empty')
539
+ }
540
+ // Avoid an invalid semver results
541
+ if (identifier) {
542
+ const match = `-${identifier}`.match(this.options.loose ? re$1[t$1.PRERELEASELOOSE] : re$1[t$1.PRERELEASE]);
543
+ if (!match || match[1] !== identifier) {
544
+ throw new Error(`invalid identifier: ${identifier}`)
545
+ }
546
+ }
547
+ }
548
+
549
+ switch (release) {
550
+ case 'premajor':
551
+ this.prerelease.length = 0;
552
+ this.patch = 0;
553
+ this.minor = 0;
554
+ this.major++;
555
+ this.inc('pre', identifier, identifierBase);
556
+ break
557
+ case 'preminor':
558
+ this.prerelease.length = 0;
559
+ this.patch = 0;
560
+ this.minor++;
561
+ this.inc('pre', identifier, identifierBase);
562
+ break
563
+ case 'prepatch':
564
+ // If this is already a prerelease, it will bump to the next version
565
+ // drop any prereleases that might already exist, since they are not
566
+ // relevant at this point.
567
+ this.prerelease.length = 0;
568
+ this.inc('patch', identifier, identifierBase);
569
+ this.inc('pre', identifier, identifierBase);
570
+ break
571
+ // If the input is a non-prerelease version, this acts the same as
572
+ // prepatch.
573
+ case 'prerelease':
574
+ if (this.prerelease.length === 0) {
575
+ this.inc('patch', identifier, identifierBase);
576
+ }
577
+ this.inc('pre', identifier, identifierBase);
578
+ break
579
+ case 'release':
580
+ if (this.prerelease.length === 0) {
581
+ throw new Error(`version ${this.raw} is not a prerelease`)
582
+ }
583
+ this.prerelease.length = 0;
584
+ break
585
+
586
+ case 'major':
587
+ // If this is a pre-major version, bump up to the same major version.
588
+ // Otherwise increment major.
589
+ // 1.0.0-5 bumps to 1.0.0
590
+ // 1.1.0 bumps to 2.0.0
591
+ if (
592
+ this.minor !== 0 ||
593
+ this.patch !== 0 ||
594
+ this.prerelease.length === 0
595
+ ) {
596
+ this.major++;
597
+ }
598
+ this.minor = 0;
599
+ this.patch = 0;
600
+ this.prerelease = [];
601
+ break
602
+ case 'minor':
603
+ // If this is a pre-minor version, bump up to the same minor version.
604
+ // Otherwise increment minor.
605
+ // 1.2.0-5 bumps to 1.2.0
606
+ // 1.2.1 bumps to 1.3.0
607
+ if (this.patch !== 0 || this.prerelease.length === 0) {
608
+ this.minor++;
609
+ }
610
+ this.patch = 0;
611
+ this.prerelease = [];
612
+ break
613
+ case 'patch':
614
+ // If this is not a pre-release version, it will increment the patch.
615
+ // If it is a pre-release it will bump up to the same patch version.
616
+ // 1.2.0-5 patches to 1.2.0
617
+ // 1.2.0 patches to 1.2.1
618
+ if (this.prerelease.length === 0) {
619
+ this.patch++;
620
+ }
621
+ this.prerelease = [];
622
+ break
623
+ // This probably shouldn't be used publicly.
624
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
625
+ case 'pre': {
626
+ const base = Number(identifierBase) ? 1 : 0;
627
+
628
+ if (this.prerelease.length === 0) {
629
+ this.prerelease = [base];
630
+ } else {
631
+ let i = this.prerelease.length;
632
+ while (--i >= 0) {
633
+ if (typeof this.prerelease[i] === 'number') {
634
+ this.prerelease[i]++;
635
+ i = -2;
636
+ }
637
+ }
638
+ if (i === -1) {
639
+ // didn't increment anything
640
+ if (identifier === this.prerelease.join('.') && identifierBase === false) {
641
+ throw new Error('invalid increment argument: identifier already exists')
642
+ }
643
+ this.prerelease.push(base);
644
+ }
645
+ }
646
+ if (identifier) {
647
+ // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
648
+ // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
649
+ let prerelease = [identifier, base];
650
+ if (identifierBase === false) {
651
+ prerelease = [identifier];
652
+ }
653
+ if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
654
+ if (isNaN(this.prerelease[1])) {
655
+ this.prerelease = prerelease;
656
+ }
657
+ } else {
658
+ this.prerelease = prerelease;
659
+ }
660
+ }
661
+ break
662
+ }
663
+ default:
664
+ throw new Error(`invalid increment argument: ${release}`)
665
+ }
666
+ this.raw = this.format();
667
+ if (this.build.length) {
668
+ this.raw += `+${this.build.join('.')}`;
669
+ }
670
+ return this
671
+ }
672
+ };
673
+
674
+ var semver$2 = SemVer$d;
675
+
676
+ const SemVer$c = semver$2;
677
+ const parse$a = (version, options, throwErrors = false) => {
678
+ if (version instanceof SemVer$c) {
679
+ return version
680
+ }
681
+ try {
682
+ return new SemVer$c(version, options)
683
+ } catch (er) {
684
+ if (!throwErrors) {
685
+ return null
686
+ }
687
+ throw er
688
+ }
689
+ };
690
+
691
+ var parse_1 = parse$a;
692
+
693
+ const parse$9 = parse_1;
694
+ const valid$2 = (version, options) => {
695
+ const v = parse$9(version, options);
696
+ return v ? v.version : null
697
+ };
698
+ var valid_1 = valid$2;
699
+
700
+ const parse$8 = parse_1;
701
+ const clean$1 = (version, options) => {
702
+ const s = parse$8(version.trim().replace(/^[=v]+/, ''), options);
703
+ return s ? s.version : null
704
+ };
705
+ var clean_1 = clean$1;
706
+
707
+ const SemVer$b = semver$2;
708
+
709
+ const inc$1 = (version, release, options, identifier, identifierBase) => {
710
+ if (typeof (options) === 'string') {
711
+ identifierBase = identifier;
712
+ identifier = options;
713
+ options = undefined;
714
+ }
715
+
716
+ try {
717
+ return new SemVer$b(
718
+ version instanceof SemVer$b ? version.version : version,
719
+ options
720
+ ).inc(release, identifier, identifierBase).version
721
+ } catch (er) {
722
+ return null
723
+ }
724
+ };
725
+ var inc_1 = inc$1;
726
+
727
+ const parse$7 = parse_1;
728
+
729
+ const diff$1 = (version1, version2) => {
730
+ const v1 = parse$7(version1, null, true);
731
+ const v2 = parse$7(version2, null, true);
732
+ const comparison = v1.compare(v2);
733
+
734
+ if (comparison === 0) {
735
+ return null
736
+ }
737
+
738
+ const v1Higher = comparison > 0;
739
+ const highVersion = v1Higher ? v1 : v2;
740
+ const lowVersion = v1Higher ? v2 : v1;
741
+ const highHasPre = !!highVersion.prerelease.length;
742
+ const lowHasPre = !!lowVersion.prerelease.length;
743
+
744
+ if (lowHasPre && !highHasPre) {
745
+ // Going from prerelease -> no prerelease requires some special casing
746
+
747
+ // If the low version has only a major, then it will always be a major
748
+ // Some examples:
749
+ // 1.0.0-1 -> 1.0.0
750
+ // 1.0.0-1 -> 1.1.1
751
+ // 1.0.0-1 -> 2.0.0
752
+ if (!lowVersion.patch && !lowVersion.minor) {
753
+ return 'major'
754
+ }
755
+
756
+ // If the main part has no difference
757
+ if (lowVersion.compareMain(highVersion) === 0) {
758
+ if (lowVersion.minor && !lowVersion.patch) {
759
+ return 'minor'
760
+ }
761
+ return 'patch'
762
+ }
763
+ }
764
+
765
+ // add the `pre` prefix if we are going to a prerelease version
766
+ const prefix = highHasPre ? 'pre' : '';
767
+
768
+ if (v1.major !== v2.major) {
769
+ return prefix + 'major'
770
+ }
771
+
772
+ if (v1.minor !== v2.minor) {
773
+ return prefix + 'minor'
774
+ }
775
+
776
+ if (v1.patch !== v2.patch) {
777
+ return prefix + 'patch'
778
+ }
779
+
780
+ // high and low are preleases
781
+ return 'prerelease'
782
+ };
783
+
784
+ var diff_1 = diff$1;
785
+
786
+ const SemVer$a = semver$2;
787
+ const major$1 = (a, loose) => new SemVer$a(a, loose).major;
788
+ var major_1 = major$1;
789
+
790
+ const SemVer$9 = semver$2;
791
+ const minor$1 = (a, loose) => new SemVer$9(a, loose).minor;
792
+ var minor_1 = minor$1;
793
+
794
+ const SemVer$8 = semver$2;
795
+ const patch$1 = (a, loose) => new SemVer$8(a, loose).patch;
796
+ var patch_1 = patch$1;
797
+
798
+ const parse$6 = parse_1;
799
+ const prerelease$1 = (version, options) => {
800
+ const parsed = parse$6(version, options);
801
+ return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
802
+ };
803
+ var prerelease_1 = prerelease$1;
804
+
805
+ const SemVer$7 = semver$2;
806
+ const compare$b = (a, b, loose) =>
807
+ new SemVer$7(a, loose).compare(new SemVer$7(b, loose));
808
+
809
+ var compare_1 = compare$b;
810
+
811
+ const compare$a = compare_1;
812
+ const rcompare$1 = (a, b, loose) => compare$a(b, a, loose);
813
+ var rcompare_1 = rcompare$1;
814
+
815
+ const compare$9 = compare_1;
816
+ const compareLoose$1 = (a, b) => compare$9(a, b, true);
817
+ var compareLoose_1 = compareLoose$1;
818
+
819
+ const SemVer$6 = semver$2;
820
+ const compareBuild$3 = (a, b, loose) => {
821
+ const versionA = new SemVer$6(a, loose);
822
+ const versionB = new SemVer$6(b, loose);
823
+ return versionA.compare(versionB) || versionA.compareBuild(versionB)
824
+ };
825
+ var compareBuild_1 = compareBuild$3;
826
+
827
+ const compareBuild$2 = compareBuild_1;
828
+ const sort$1 = (list, loose) => list.sort((a, b) => compareBuild$2(a, b, loose));
829
+ var sort_1 = sort$1;
830
+
831
+ const compareBuild$1 = compareBuild_1;
832
+ const rsort$1 = (list, loose) => list.sort((a, b) => compareBuild$1(b, a, loose));
833
+ var rsort_1 = rsort$1;
834
+
835
+ const compare$8 = compare_1;
836
+ const gt$4 = (a, b, loose) => compare$8(a, b, loose) > 0;
837
+ var gt_1 = gt$4;
838
+
839
+ const compare$7 = compare_1;
840
+ const lt$3 = (a, b, loose) => compare$7(a, b, loose) < 0;
841
+ var lt_1 = lt$3;
842
+
843
+ const compare$6 = compare_1;
844
+ const eq$2 = (a, b, loose) => compare$6(a, b, loose) === 0;
845
+ var eq_1 = eq$2;
846
+
847
+ const compare$5 = compare_1;
848
+ const neq$2 = (a, b, loose) => compare$5(a, b, loose) !== 0;
849
+ var neq_1 = neq$2;
850
+
851
+ const compare$4 = compare_1;
852
+ const gte$3 = (a, b, loose) => compare$4(a, b, loose) >= 0;
853
+ var gte_1 = gte$3;
854
+
855
+ const compare$3 = compare_1;
856
+ const lte$3 = (a, b, loose) => compare$3(a, b, loose) <= 0;
857
+ var lte_1 = lte$3;
858
+
859
+ const eq$1 = eq_1;
860
+ const neq$1 = neq_1;
861
+ const gt$3 = gt_1;
862
+ const gte$2 = gte_1;
863
+ const lt$2 = lt_1;
864
+ const lte$2 = lte_1;
865
+
866
+ const cmp$1 = (a, op, b, loose) => {
867
+ switch (op) {
868
+ case '===':
869
+ if (typeof a === 'object') {
870
+ a = a.version;
871
+ }
872
+ if (typeof b === 'object') {
873
+ b = b.version;
874
+ }
875
+ return a === b
876
+
877
+ case '!==':
878
+ if (typeof a === 'object') {
879
+ a = a.version;
880
+ }
881
+ if (typeof b === 'object') {
882
+ b = b.version;
883
+ }
884
+ return a !== b
885
+
886
+ case '':
887
+ case '=':
888
+ case '==':
889
+ return eq$1(a, b, loose)
890
+
891
+ case '!=':
892
+ return neq$1(a, b, loose)
893
+
894
+ case '>':
895
+ return gt$3(a, b, loose)
896
+
897
+ case '>=':
898
+ return gte$2(a, b, loose)
899
+
900
+ case '<':
901
+ return lt$2(a, b, loose)
902
+
903
+ case '<=':
904
+ return lte$2(a, b, loose)
905
+
906
+ default:
907
+ throw new TypeError(`Invalid operator: ${op}`)
908
+ }
909
+ };
910
+ var cmp_1 = cmp$1;
911
+
912
+ const SemVer$5 = semver$2;
913
+ const parse$5 = parse_1;
914
+ const { safeRe: re, t } = reExports;
915
+
916
+ const coerce$1 = (version, options) => {
917
+ if (version instanceof SemVer$5) {
918
+ return version
919
+ }
920
+
921
+ if (typeof version === 'number') {
922
+ version = String(version);
923
+ }
924
+
925
+ if (typeof version !== 'string') {
926
+ return null
927
+ }
928
+
929
+ options = options || {};
930
+
931
+ let match = null;
932
+ if (!options.rtl) {
933
+ match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
934
+ } else {
935
+ // Find the right-most coercible string that does not share
936
+ // a terminus with a more left-ward coercible string.
937
+ // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
938
+ // With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4'
939
+ //
940
+ // Walk through the string checking with a /g regexp
941
+ // Manually set the index so as to pick up overlapping matches.
942
+ // Stop when we get a match that ends at the string end, since no
943
+ // coercible string can be more right-ward without the same terminus.
944
+ const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
945
+ let next;
946
+ while ((next = coerceRtlRegex.exec(version)) &&
947
+ (!match || match.index + match[0].length !== version.length)
948
+ ) {
949
+ if (!match ||
950
+ next.index + next[0].length !== match.index + match[0].length) {
951
+ match = next;
952
+ }
953
+ coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
954
+ }
955
+ // leave it in a clean state
956
+ coerceRtlRegex.lastIndex = -1;
957
+ }
958
+
959
+ if (match === null) {
960
+ return null
961
+ }
962
+
963
+ const major = match[2];
964
+ const minor = match[3] || '0';
965
+ const patch = match[4] || '0';
966
+ const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : '';
967
+ const build = options.includePrerelease && match[6] ? `+${match[6]}` : '';
968
+
969
+ return parse$5(`${major}.${minor}.${patch}${prerelease}${build}`, options)
970
+ };
971
+ var coerce_1 = coerce$1;
972
+
973
+ var lrucache;
974
+ var hasRequiredLrucache;
975
+
976
+ function requireLrucache () {
977
+ if (hasRequiredLrucache) return lrucache;
978
+ hasRequiredLrucache = 1;
979
+
980
+ class LRUCache {
981
+ constructor () {
982
+ this.max = 1000;
983
+ this.map = new Map();
984
+ }
985
+
986
+ get (key) {
987
+ const value = this.map.get(key);
988
+ if (value === undefined) {
989
+ return undefined
990
+ } else {
991
+ // Remove the key from the map and add it to the end
992
+ this.map.delete(key);
993
+ this.map.set(key, value);
994
+ return value
995
+ }
996
+ }
997
+
998
+ delete (key) {
999
+ return this.map.delete(key)
1000
+ }
1001
+
1002
+ set (key, value) {
1003
+ const deleted = this.delete(key);
1004
+
1005
+ if (!deleted && value !== undefined) {
1006
+ // If cache is full, delete the least recently used item
1007
+ if (this.map.size >= this.max) {
1008
+ const firstKey = this.map.keys().next().value;
1009
+ this.delete(firstKey);
1010
+ }
1011
+
1012
+ this.map.set(key, value);
1013
+ }
1014
+
1015
+ return this
1016
+ }
1017
+ }
1018
+
1019
+ lrucache = LRUCache;
1020
+ return lrucache;
1021
+ }
1022
+
1023
+ var range;
1024
+ var hasRequiredRange;
1025
+
1026
+ function requireRange () {
1027
+ if (hasRequiredRange) return range;
1028
+ hasRequiredRange = 1;
1029
+
1030
+ const SPACE_CHARACTERS = /\s+/g;
1031
+
1032
+ // hoisted class for cyclic dependency
1033
+ class Range {
1034
+ constructor (range, options) {
1035
+ options = parseOptions(options);
1036
+
1037
+ if (range instanceof Range) {
1038
+ if (
1039
+ range.loose === !!options.loose &&
1040
+ range.includePrerelease === !!options.includePrerelease
1041
+ ) {
1042
+ return range
1043
+ } else {
1044
+ return new Range(range.raw, options)
1045
+ }
1046
+ }
1047
+
1048
+ if (range instanceof Comparator) {
1049
+ // just put it in the set and return
1050
+ this.raw = range.value;
1051
+ this.set = [[range]];
1052
+ this.formatted = undefined;
1053
+ return this
1054
+ }
1055
+
1056
+ this.options = options;
1057
+ this.loose = !!options.loose;
1058
+ this.includePrerelease = !!options.includePrerelease;
1059
+
1060
+ // First reduce all whitespace as much as possible so we do not have to rely
1061
+ // on potentially slow regexes like \s*. This is then stored and used for
1062
+ // future error messages as well.
1063
+ this.raw = range.trim().replace(SPACE_CHARACTERS, ' ');
1064
+
1065
+ // First, split on ||
1066
+ this.set = this.raw
1067
+ .split('||')
1068
+ // map the range to a 2d array of comparators
1069
+ .map(r => this.parseRange(r.trim()))
1070
+ // throw out any comparator lists that are empty
1071
+ // this generally means that it was not a valid range, which is allowed
1072
+ // in loose mode, but will still throw if the WHOLE range is invalid.
1073
+ .filter(c => c.length);
1074
+
1075
+ if (!this.set.length) {
1076
+ throw new TypeError(`Invalid SemVer Range: ${this.raw}`)
1077
+ }
1078
+
1079
+ // if we have any that are not the null set, throw out null sets.
1080
+ if (this.set.length > 1) {
1081
+ // keep the first one, in case they're all null sets
1082
+ const first = this.set[0];
1083
+ this.set = this.set.filter(c => !isNullSet(c[0]));
1084
+ if (this.set.length === 0) {
1085
+ this.set = [first];
1086
+ } else if (this.set.length > 1) {
1087
+ // if we have any that are *, then the range is just *
1088
+ for (const c of this.set) {
1089
+ if (c.length === 1 && isAny(c[0])) {
1090
+ this.set = [c];
1091
+ break
1092
+ }
1093
+ }
1094
+ }
1095
+ }
1096
+
1097
+ this.formatted = undefined;
1098
+ }
1099
+
1100
+ get range () {
1101
+ if (this.formatted === undefined) {
1102
+ this.formatted = '';
1103
+ for (let i = 0; i < this.set.length; i++) {
1104
+ if (i > 0) {
1105
+ this.formatted += '||';
1106
+ }
1107
+ const comps = this.set[i];
1108
+ for (let k = 0; k < comps.length; k++) {
1109
+ if (k > 0) {
1110
+ this.formatted += ' ';
1111
+ }
1112
+ this.formatted += comps[k].toString().trim();
1113
+ }
1114
+ }
1115
+ }
1116
+ return this.formatted
1117
+ }
1118
+
1119
+ format () {
1120
+ return this.range
1121
+ }
1122
+
1123
+ toString () {
1124
+ return this.range
1125
+ }
1126
+
1127
+ parseRange (range) {
1128
+ // memoize range parsing for performance.
1129
+ // this is a very hot path, and fully deterministic.
1130
+ const memoOpts =
1131
+ (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) |
1132
+ (this.options.loose && FLAG_LOOSE);
1133
+ const memoKey = memoOpts + ':' + range;
1134
+ const cached = cache.get(memoKey);
1135
+ if (cached) {
1136
+ return cached
1137
+ }
1138
+
1139
+ const loose = this.options.loose;
1140
+ // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
1141
+ const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
1142
+ range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
1143
+ debug('hyphen replace', range);
1144
+
1145
+ // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
1146
+ range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
1147
+ debug('comparator trim', range);
1148
+
1149
+ // `~ 1.2.3` => `~1.2.3`
1150
+ range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
1151
+ debug('tilde trim', range);
1152
+
1153
+ // `^ 1.2.3` => `^1.2.3`
1154
+ range = range.replace(re[t.CARETTRIM], caretTrimReplace);
1155
+ debug('caret trim', range);
1156
+
1157
+ // At this point, the range is completely trimmed and
1158
+ // ready to be split into comparators.
1159
+
1160
+ let rangeList = range
1161
+ .split(' ')
1162
+ .map(comp => parseComparator(comp, this.options))
1163
+ .join(' ')
1164
+ .split(/\s+/)
1165
+ // >=0.0.0 is equivalent to *
1166
+ .map(comp => replaceGTE0(comp, this.options));
1167
+
1168
+ if (loose) {
1169
+ // in loose mode, throw out any that are not valid comparators
1170
+ rangeList = rangeList.filter(comp => {
1171
+ debug('loose invalid filter', comp, this.options);
1172
+ return !!comp.match(re[t.COMPARATORLOOSE])
1173
+ });
1174
+ }
1175
+ debug('range list', rangeList);
1176
+
1177
+ // if any comparators are the null set, then replace with JUST null set
1178
+ // if more than one comparator, remove any * comparators
1179
+ // also, don't include the same comparator more than once
1180
+ const rangeMap = new Map();
1181
+ const comparators = rangeList.map(comp => new Comparator(comp, this.options));
1182
+ for (const comp of comparators) {
1183
+ if (isNullSet(comp)) {
1184
+ return [comp]
1185
+ }
1186
+ rangeMap.set(comp.value, comp);
1187
+ }
1188
+ if (rangeMap.size > 1 && rangeMap.has('')) {
1189
+ rangeMap.delete('');
1190
+ }
1191
+
1192
+ const result = [...rangeMap.values()];
1193
+ cache.set(memoKey, result);
1194
+ return result
1195
+ }
1196
+
1197
+ intersects (range, options) {
1198
+ if (!(range instanceof Range)) {
1199
+ throw new TypeError('a Range is required')
1200
+ }
1201
+
1202
+ return this.set.some((thisComparators) => {
1203
+ return (
1204
+ isSatisfiable(thisComparators, options) &&
1205
+ range.set.some((rangeComparators) => {
1206
+ return (
1207
+ isSatisfiable(rangeComparators, options) &&
1208
+ thisComparators.every((thisComparator) => {
1209
+ return rangeComparators.every((rangeComparator) => {
1210
+ return thisComparator.intersects(rangeComparator, options)
1211
+ })
1212
+ })
1213
+ )
1214
+ })
1215
+ )
1216
+ })
1217
+ }
1218
+
1219
+ // if ANY of the sets match ALL of its comparators, then pass
1220
+ test (version) {
1221
+ if (!version) {
1222
+ return false
1223
+ }
1224
+
1225
+ if (typeof version === 'string') {
1226
+ try {
1227
+ version = new SemVer(version, this.options);
1228
+ } catch (er) {
1229
+ return false
1230
+ }
1231
+ }
1232
+
1233
+ for (let i = 0; i < this.set.length; i++) {
1234
+ if (testSet(this.set[i], version, this.options)) {
1235
+ return true
1236
+ }
1237
+ }
1238
+ return false
1239
+ }
1240
+ }
1241
+
1242
+ range = Range;
1243
+
1244
+ const LRU = requireLrucache();
1245
+ const cache = new LRU();
1246
+
1247
+ const parseOptions = parseOptions_1;
1248
+ const Comparator = requireComparator();
1249
+ const debug = debug_1;
1250
+ const SemVer = semver$2;
1251
+ const {
1252
+ safeRe: re,
1253
+ t,
1254
+ comparatorTrimReplace,
1255
+ tildeTrimReplace,
1256
+ caretTrimReplace,
1257
+ } = reExports;
1258
+ const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = constants$2;
1259
+
1260
+ const isNullSet = c => c.value === '<0.0.0-0';
1261
+ const isAny = c => c.value === '';
1262
+
1263
+ // take a set of comparators and determine whether there
1264
+ // exists a version which can satisfy it
1265
+ const isSatisfiable = (comparators, options) => {
1266
+ let result = true;
1267
+ const remainingComparators = comparators.slice();
1268
+ let testComparator = remainingComparators.pop();
1269
+
1270
+ while (result && remainingComparators.length) {
1271
+ result = remainingComparators.every((otherComparator) => {
1272
+ return testComparator.intersects(otherComparator, options)
1273
+ });
1274
+
1275
+ testComparator = remainingComparators.pop();
1276
+ }
1277
+
1278
+ return result
1279
+ };
1280
+
1281
+ // comprised of xranges, tildes, stars, and gtlt's at this point.
1282
+ // already replaced the hyphen ranges
1283
+ // turn into a set of JUST comparators.
1284
+ const parseComparator = (comp, options) => {
1285
+ comp = comp.replace(re[t.BUILD], '');
1286
+ debug('comp', comp, options);
1287
+ comp = replaceCarets(comp, options);
1288
+ debug('caret', comp);
1289
+ comp = replaceTildes(comp, options);
1290
+ debug('tildes', comp);
1291
+ comp = replaceXRanges(comp, options);
1292
+ debug('xrange', comp);
1293
+ comp = replaceStars(comp, options);
1294
+ debug('stars', comp);
1295
+ return comp
1296
+ };
1297
+
1298
+ const isX = id => !id || id.toLowerCase() === 'x' || id === '*';
1299
+
1300
+ // ~, ~> --> * (any, kinda silly)
1301
+ // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
1302
+ // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
1303
+ // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
1304
+ // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
1305
+ // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
1306
+ // ~0.0.1 --> >=0.0.1 <0.1.0-0
1307
+ const replaceTildes = (comp, options) => {
1308
+ return comp
1309
+ .trim()
1310
+ .split(/\s+/)
1311
+ .map((c) => replaceTilde(c, options))
1312
+ .join(' ')
1313
+ };
1314
+
1315
+ const replaceTilde = (comp, options) => {
1316
+ const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
1317
+ return comp.replace(r, (_, M, m, p, pr) => {
1318
+ debug('tilde', comp, _, M, m, p, pr);
1319
+ let ret;
1320
+
1321
+ if (isX(M)) {
1322
+ ret = '';
1323
+ } else if (isX(m)) {
1324
+ ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
1325
+ } else if (isX(p)) {
1326
+ // ~1.2 == >=1.2.0 <1.3.0-0
1327
+ ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
1328
+ } else if (pr) {
1329
+ debug('replaceTilde pr', pr);
1330
+ ret = `>=${M}.${m}.${p}-${pr
1331
+ } <${M}.${+m + 1}.0-0`;
1332
+ } else {
1333
+ // ~1.2.3 == >=1.2.3 <1.3.0-0
1334
+ ret = `>=${M}.${m}.${p
1335
+ } <${M}.${+m + 1}.0-0`;
1336
+ }
1337
+
1338
+ debug('tilde return', ret);
1339
+ return ret
1340
+ })
1341
+ };
1342
+
1343
+ // ^ --> * (any, kinda silly)
1344
+ // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
1345
+ // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
1346
+ // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
1347
+ // ^1.2.3 --> >=1.2.3 <2.0.0-0
1348
+ // ^1.2.0 --> >=1.2.0 <2.0.0-0
1349
+ // ^0.0.1 --> >=0.0.1 <0.0.2-0
1350
+ // ^0.1.0 --> >=0.1.0 <0.2.0-0
1351
+ const replaceCarets = (comp, options) => {
1352
+ return comp
1353
+ .trim()
1354
+ .split(/\s+/)
1355
+ .map((c) => replaceCaret(c, options))
1356
+ .join(' ')
1357
+ };
1358
+
1359
+ const replaceCaret = (comp, options) => {
1360
+ debug('caret', comp, options);
1361
+ const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
1362
+ const z = options.includePrerelease ? '-0' : '';
1363
+ return comp.replace(r, (_, M, m, p, pr) => {
1364
+ debug('caret', comp, _, M, m, p, pr);
1365
+ let ret;
1366
+
1367
+ if (isX(M)) {
1368
+ ret = '';
1369
+ } else if (isX(m)) {
1370
+ ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
1371
+ } else if (isX(p)) {
1372
+ if (M === '0') {
1373
+ ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
1374
+ } else {
1375
+ ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
1376
+ }
1377
+ } else if (pr) {
1378
+ debug('replaceCaret pr', pr);
1379
+ if (M === '0') {
1380
+ if (m === '0') {
1381
+ ret = `>=${M}.${m}.${p}-${pr
1382
+ } <${M}.${m}.${+p + 1}-0`;
1383
+ } else {
1384
+ ret = `>=${M}.${m}.${p}-${pr
1385
+ } <${M}.${+m + 1}.0-0`;
1386
+ }
1387
+ } else {
1388
+ ret = `>=${M}.${m}.${p}-${pr
1389
+ } <${+M + 1}.0.0-0`;
1390
+ }
1391
+ } else {
1392
+ debug('no pr');
1393
+ if (M === '0') {
1394
+ if (m === '0') {
1395
+ ret = `>=${M}.${m}.${p
1396
+ }${z} <${M}.${m}.${+p + 1}-0`;
1397
+ } else {
1398
+ ret = `>=${M}.${m}.${p
1399
+ }${z} <${M}.${+m + 1}.0-0`;
1400
+ }
1401
+ } else {
1402
+ ret = `>=${M}.${m}.${p
1403
+ } <${+M + 1}.0.0-0`;
1404
+ }
1405
+ }
1406
+
1407
+ debug('caret return', ret);
1408
+ return ret
1409
+ })
1410
+ };
1411
+
1412
+ const replaceXRanges = (comp, options) => {
1413
+ debug('replaceXRanges', comp, options);
1414
+ return comp
1415
+ .split(/\s+/)
1416
+ .map((c) => replaceXRange(c, options))
1417
+ .join(' ')
1418
+ };
1419
+
1420
+ const replaceXRange = (comp, options) => {
1421
+ comp = comp.trim();
1422
+ const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
1423
+ return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
1424
+ debug('xRange', comp, ret, gtlt, M, m, p, pr);
1425
+ const xM = isX(M);
1426
+ const xm = xM || isX(m);
1427
+ const xp = xm || isX(p);
1428
+ const anyX = xp;
1429
+
1430
+ if (gtlt === '=' && anyX) {
1431
+ gtlt = '';
1432
+ }
1433
+
1434
+ // if we're including prereleases in the match, then we need
1435
+ // to fix this to -0, the lowest possible prerelease value
1436
+ pr = options.includePrerelease ? '-0' : '';
1437
+
1438
+ if (xM) {
1439
+ if (gtlt === '>' || gtlt === '<') {
1440
+ // nothing is allowed
1441
+ ret = '<0.0.0-0';
1442
+ } else {
1443
+ // nothing is forbidden
1444
+ ret = '*';
1445
+ }
1446
+ } else if (gtlt && anyX) {
1447
+ // we know patch is an x, because we have any x at all.
1448
+ // replace X with 0
1449
+ if (xm) {
1450
+ m = 0;
1451
+ }
1452
+ p = 0;
1453
+
1454
+ if (gtlt === '>') {
1455
+ // >1 => >=2.0.0
1456
+ // >1.2 => >=1.3.0
1457
+ gtlt = '>=';
1458
+ if (xm) {
1459
+ M = +M + 1;
1460
+ m = 0;
1461
+ p = 0;
1462
+ } else {
1463
+ m = +m + 1;
1464
+ p = 0;
1465
+ }
1466
+ } else if (gtlt === '<=') {
1467
+ // <=0.7.x is actually <0.8.0, since any 0.7.x should
1468
+ // pass. Similarly, <=7.x is actually <8.0.0, etc.
1469
+ gtlt = '<';
1470
+ if (xm) {
1471
+ M = +M + 1;
1472
+ } else {
1473
+ m = +m + 1;
1474
+ }
1475
+ }
1476
+
1477
+ if (gtlt === '<') {
1478
+ pr = '-0';
1479
+ }
1480
+
1481
+ ret = `${gtlt + M}.${m}.${p}${pr}`;
1482
+ } else if (xm) {
1483
+ ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
1484
+ } else if (xp) {
1485
+ ret = `>=${M}.${m}.0${pr
1486
+ } <${M}.${+m + 1}.0-0`;
1487
+ }
1488
+
1489
+ debug('xRange return', ret);
1490
+
1491
+ return ret
1492
+ })
1493
+ };
1494
+
1495
+ // Because * is AND-ed with everything else in the comparator,
1496
+ // and '' means "any version", just remove the *s entirely.
1497
+ const replaceStars = (comp, options) => {
1498
+ debug('replaceStars', comp, options);
1499
+ // Looseness is ignored here. star is always as loose as it gets!
1500
+ return comp
1501
+ .trim()
1502
+ .replace(re[t.STAR], '')
1503
+ };
1504
+
1505
+ const replaceGTE0 = (comp, options) => {
1506
+ debug('replaceGTE0', comp, options);
1507
+ return comp
1508
+ .trim()
1509
+ .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')
1510
+ };
1511
+
1512
+ // This function is passed to string.replace(re[t.HYPHENRANGE])
1513
+ // M, m, patch, prerelease, build
1514
+ // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
1515
+ // 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
1516
+ // 1.2 - 3.4 => >=1.2.0 <3.5.0-0
1517
+ // TODO build?
1518
+ const hyphenReplace = incPr => ($0,
1519
+ from, fM, fm, fp, fpr, fb,
1520
+ to, tM, tm, tp, tpr) => {
1521
+ if (isX(fM)) {
1522
+ from = '';
1523
+ } else if (isX(fm)) {
1524
+ from = `>=${fM}.0.0${incPr ? '-0' : ''}`;
1525
+ } else if (isX(fp)) {
1526
+ from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`;
1527
+ } else if (fpr) {
1528
+ from = `>=${from}`;
1529
+ } else {
1530
+ from = `>=${from}${incPr ? '-0' : ''}`;
1531
+ }
1532
+
1533
+ if (isX(tM)) {
1534
+ to = '';
1535
+ } else if (isX(tm)) {
1536
+ to = `<${+tM + 1}.0.0-0`;
1537
+ } else if (isX(tp)) {
1538
+ to = `<${tM}.${+tm + 1}.0-0`;
1539
+ } else if (tpr) {
1540
+ to = `<=${tM}.${tm}.${tp}-${tpr}`;
1541
+ } else if (incPr) {
1542
+ to = `<${tM}.${tm}.${+tp + 1}-0`;
1543
+ } else {
1544
+ to = `<=${to}`;
1545
+ }
1546
+
1547
+ return `${from} ${to}`.trim()
1548
+ };
1549
+
1550
+ const testSet = (set, version, options) => {
1551
+ for (let i = 0; i < set.length; i++) {
1552
+ if (!set[i].test(version)) {
1553
+ return false
1554
+ }
1555
+ }
1556
+
1557
+ if (version.prerelease.length && !options.includePrerelease) {
1558
+ // Find the set of versions that are allowed to have prereleases
1559
+ // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
1560
+ // That should allow `1.2.3-pr.2` to pass.
1561
+ // However, `1.2.4-alpha.notready` should NOT be allowed,
1562
+ // even though it's within the range set by the comparators.
1563
+ for (let i = 0; i < set.length; i++) {
1564
+ debug(set[i].semver);
1565
+ if (set[i].semver === Comparator.ANY) {
1566
+ continue
1567
+ }
1568
+
1569
+ if (set[i].semver.prerelease.length > 0) {
1570
+ const allowed = set[i].semver;
1571
+ if (allowed.major === version.major &&
1572
+ allowed.minor === version.minor &&
1573
+ allowed.patch === version.patch) {
1574
+ return true
1575
+ }
1576
+ }
1577
+ }
1578
+
1579
+ // Version has a -pre, but it's not one of the ones we like.
1580
+ return false
1581
+ }
1582
+
1583
+ return true
1584
+ };
1585
+ return range;
1586
+ }
1587
+
1588
+ var comparator;
1589
+ var hasRequiredComparator;
1590
+
1591
+ function requireComparator () {
1592
+ if (hasRequiredComparator) return comparator;
1593
+ hasRequiredComparator = 1;
1594
+
1595
+ const ANY = Symbol('SemVer ANY');
1596
+ // hoisted class for cyclic dependency
1597
+ class Comparator {
1598
+ static get ANY () {
1599
+ return ANY
1600
+ }
1601
+
1602
+ constructor (comp, options) {
1603
+ options = parseOptions(options);
1604
+
1605
+ if (comp instanceof Comparator) {
1606
+ if (comp.loose === !!options.loose) {
1607
+ return comp
1608
+ } else {
1609
+ comp = comp.value;
1610
+ }
1611
+ }
1612
+
1613
+ comp = comp.trim().split(/\s+/).join(' ');
1614
+ debug('comparator', comp, options);
1615
+ this.options = options;
1616
+ this.loose = !!options.loose;
1617
+ this.parse(comp);
1618
+
1619
+ if (this.semver === ANY) {
1620
+ this.value = '';
1621
+ } else {
1622
+ this.value = this.operator + this.semver.version;
1623
+ }
1624
+
1625
+ debug('comp', this);
1626
+ }
1627
+
1628
+ parse (comp) {
1629
+ const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
1630
+ const m = comp.match(r);
1631
+
1632
+ if (!m) {
1633
+ throw new TypeError(`Invalid comparator: ${comp}`)
1634
+ }
1635
+
1636
+ this.operator = m[1] !== undefined ? m[1] : '';
1637
+ if (this.operator === '=') {
1638
+ this.operator = '';
1639
+ }
1640
+
1641
+ // if it literally is just '>' or '' then allow anything.
1642
+ if (!m[2]) {
1643
+ this.semver = ANY;
1644
+ } else {
1645
+ this.semver = new SemVer(m[2], this.options.loose);
1646
+ }
1647
+ }
1648
+
1649
+ toString () {
1650
+ return this.value
1651
+ }
1652
+
1653
+ test (version) {
1654
+ debug('Comparator.test', version, this.options.loose);
1655
+
1656
+ if (this.semver === ANY || version === ANY) {
1657
+ return true
1658
+ }
1659
+
1660
+ if (typeof version === 'string') {
1661
+ try {
1662
+ version = new SemVer(version, this.options);
1663
+ } catch (er) {
1664
+ return false
1665
+ }
1666
+ }
1667
+
1668
+ return cmp(version, this.operator, this.semver, this.options)
1669
+ }
1670
+
1671
+ intersects (comp, options) {
1672
+ if (!(comp instanceof Comparator)) {
1673
+ throw new TypeError('a Comparator is required')
1674
+ }
1675
+
1676
+ if (this.operator === '') {
1677
+ if (this.value === '') {
1678
+ return true
1679
+ }
1680
+ return new Range(comp.value, options).test(this.value)
1681
+ } else if (comp.operator === '') {
1682
+ if (comp.value === '') {
1683
+ return true
1684
+ }
1685
+ return new Range(this.value, options).test(comp.semver)
1686
+ }
1687
+
1688
+ options = parseOptions(options);
1689
+
1690
+ // Special cases where nothing can possibly be lower
1691
+ if (options.includePrerelease &&
1692
+ (this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {
1693
+ return false
1694
+ }
1695
+ if (!options.includePrerelease &&
1696
+ (this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {
1697
+ return false
1698
+ }
1699
+
1700
+ // Same direction increasing (> or >=)
1701
+ if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {
1702
+ return true
1703
+ }
1704
+ // Same direction decreasing (< or <=)
1705
+ if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {
1706
+ return true
1707
+ }
1708
+ // same SemVer and both sides are inclusive (<= or >=)
1709
+ if (
1710
+ (this.semver.version === comp.semver.version) &&
1711
+ this.operator.includes('=') && comp.operator.includes('=')) {
1712
+ return true
1713
+ }
1714
+ // opposite directions less than
1715
+ if (cmp(this.semver, '<', comp.semver, options) &&
1716
+ this.operator.startsWith('>') && comp.operator.startsWith('<')) {
1717
+ return true
1718
+ }
1719
+ // opposite directions greater than
1720
+ if (cmp(this.semver, '>', comp.semver, options) &&
1721
+ this.operator.startsWith('<') && comp.operator.startsWith('>')) {
1722
+ return true
1723
+ }
1724
+ return false
1725
+ }
1726
+ }
1727
+
1728
+ comparator = Comparator;
1729
+
1730
+ const parseOptions = parseOptions_1;
1731
+ const { safeRe: re, t } = reExports;
1732
+ const cmp = cmp_1;
1733
+ const debug = debug_1;
1734
+ const SemVer = semver$2;
1735
+ const Range = requireRange();
1736
+ return comparator;
1737
+ }
1738
+
1739
+ const Range$9 = requireRange();
1740
+ const satisfies$4 = (version, range, options) => {
1741
+ try {
1742
+ range = new Range$9(range, options);
1743
+ } catch (er) {
1744
+ return false
1745
+ }
1746
+ return range.test(version)
1747
+ };
1748
+ var satisfies_1 = satisfies$4;
1749
+
1750
+ const Range$8 = requireRange();
1751
+
1752
+ // Mostly just for testing and legacy API reasons
1753
+ const toComparators$1 = (range, options) =>
1754
+ new Range$8(range, options).set
1755
+ .map(comp => comp.map(c => c.value).join(' ').trim().split(' '));
1756
+
1757
+ var toComparators_1 = toComparators$1;
1758
+
1759
+ const SemVer$4 = semver$2;
1760
+ const Range$7 = requireRange();
1761
+
1762
+ const maxSatisfying$1 = (versions, range, options) => {
1763
+ let max = null;
1764
+ let maxSV = null;
1765
+ let rangeObj = null;
1766
+ try {
1767
+ rangeObj = new Range$7(range, options);
1768
+ } catch (er) {
1769
+ return null
1770
+ }
1771
+ versions.forEach((v) => {
1772
+ if (rangeObj.test(v)) {
1773
+ // satisfies(v, range, options)
1774
+ if (!max || maxSV.compare(v) === -1) {
1775
+ // compare(max, v, true)
1776
+ max = v;
1777
+ maxSV = new SemVer$4(max, options);
1778
+ }
1779
+ }
1780
+ });
1781
+ return max
1782
+ };
1783
+ var maxSatisfying_1 = maxSatisfying$1;
1784
+
1785
+ const SemVer$3 = semver$2;
1786
+ const Range$6 = requireRange();
1787
+ const minSatisfying$1 = (versions, range, options) => {
1788
+ let min = null;
1789
+ let minSV = null;
1790
+ let rangeObj = null;
1791
+ try {
1792
+ rangeObj = new Range$6(range, options);
1793
+ } catch (er) {
1794
+ return null
1795
+ }
1796
+ versions.forEach((v) => {
1797
+ if (rangeObj.test(v)) {
1798
+ // satisfies(v, range, options)
1799
+ if (!min || minSV.compare(v) === 1) {
1800
+ // compare(min, v, true)
1801
+ min = v;
1802
+ minSV = new SemVer$3(min, options);
1803
+ }
1804
+ }
1805
+ });
1806
+ return min
1807
+ };
1808
+ var minSatisfying_1 = minSatisfying$1;
1809
+
1810
+ const SemVer$2 = semver$2;
1811
+ const Range$5 = requireRange();
1812
+ const gt$2 = gt_1;
1813
+
1814
+ const minVersion$1 = (range, loose) => {
1815
+ range = new Range$5(range, loose);
1816
+
1817
+ let minver = new SemVer$2('0.0.0');
1818
+ if (range.test(minver)) {
1819
+ return minver
1820
+ }
1821
+
1822
+ minver = new SemVer$2('0.0.0-0');
1823
+ if (range.test(minver)) {
1824
+ return minver
1825
+ }
1826
+
1827
+ minver = null;
1828
+ for (let i = 0; i < range.set.length; ++i) {
1829
+ const comparators = range.set[i];
1830
+
1831
+ let setMin = null;
1832
+ comparators.forEach((comparator) => {
1833
+ // Clone to avoid manipulating the comparator's semver object.
1834
+ const compver = new SemVer$2(comparator.semver.version);
1835
+ switch (comparator.operator) {
1836
+ case '>':
1837
+ if (compver.prerelease.length === 0) {
1838
+ compver.patch++;
1839
+ } else {
1840
+ compver.prerelease.push(0);
1841
+ }
1842
+ compver.raw = compver.format();
1843
+ /* fallthrough */
1844
+ case '':
1845
+ case '>=':
1846
+ if (!setMin || gt$2(compver, setMin)) {
1847
+ setMin = compver;
1848
+ }
1849
+ break
1850
+ case '<':
1851
+ case '<=':
1852
+ /* Ignore maximum versions */
1853
+ break
1854
+ /* istanbul ignore next */
1855
+ default:
1856
+ throw new Error(`Unexpected operation: ${comparator.operator}`)
1857
+ }
1858
+ });
1859
+ if (setMin && (!minver || gt$2(minver, setMin))) {
1860
+ minver = setMin;
1861
+ }
1862
+ }
1863
+
1864
+ if (minver && range.test(minver)) {
1865
+ return minver
1866
+ }
1867
+
1868
+ return null
1869
+ };
1870
+ var minVersion_1 = minVersion$1;
1871
+
1872
+ const Range$4 = requireRange();
1873
+ const validRange$1 = (range, options) => {
1874
+ try {
1875
+ // Return '*' instead of '' so that truthiness works.
1876
+ // This will throw if it's invalid anyway
1877
+ return new Range$4(range, options).range || '*'
1878
+ } catch (er) {
1879
+ return null
1880
+ }
1881
+ };
1882
+ var valid$1 = validRange$1;
1883
+
1884
+ const SemVer$1 = semver$2;
1885
+ const Comparator$2 = requireComparator();
1886
+ const { ANY: ANY$1 } = Comparator$2;
1887
+ const Range$3 = requireRange();
1888
+ const satisfies$3 = satisfies_1;
1889
+ const gt$1 = gt_1;
1890
+ const lt$1 = lt_1;
1891
+ const lte$1 = lte_1;
1892
+ const gte$1 = gte_1;
1893
+
1894
+ const outside$3 = (version, range, hilo, options) => {
1895
+ version = new SemVer$1(version, options);
1896
+ range = new Range$3(range, options);
1897
+
1898
+ let gtfn, ltefn, ltfn, comp, ecomp;
1899
+ switch (hilo) {
1900
+ case '>':
1901
+ gtfn = gt$1;
1902
+ ltefn = lte$1;
1903
+ ltfn = lt$1;
1904
+ comp = '>';
1905
+ ecomp = '>=';
1906
+ break
1907
+ case '<':
1908
+ gtfn = lt$1;
1909
+ ltefn = gte$1;
1910
+ ltfn = gt$1;
1911
+ comp = '<';
1912
+ ecomp = '<=';
1913
+ break
1914
+ default:
1915
+ throw new TypeError('Must provide a hilo val of "<" or ">"')
1916
+ }
1917
+
1918
+ // If it satisfies the range it is not outside
1919
+ if (satisfies$3(version, range, options)) {
1920
+ return false
1921
+ }
1922
+
1923
+ // From now on, variable terms are as if we're in "gtr" mode.
1924
+ // but note that everything is flipped for the "ltr" function.
1925
+
1926
+ for (let i = 0; i < range.set.length; ++i) {
1927
+ const comparators = range.set[i];
1928
+
1929
+ let high = null;
1930
+ let low = null;
1931
+
1932
+ comparators.forEach((comparator) => {
1933
+ if (comparator.semver === ANY$1) {
1934
+ comparator = new Comparator$2('>=0.0.0');
1935
+ }
1936
+ high = high || comparator;
1937
+ low = low || comparator;
1938
+ if (gtfn(comparator.semver, high.semver, options)) {
1939
+ high = comparator;
1940
+ } else if (ltfn(comparator.semver, low.semver, options)) {
1941
+ low = comparator;
1942
+ }
1943
+ });
1944
+
1945
+ // If the edge version comparator has a operator then our version
1946
+ // isn't outside it
1947
+ if (high.operator === comp || high.operator === ecomp) {
1948
+ return false
1949
+ }
1950
+
1951
+ // If the lowest version comparator has an operator and our version
1952
+ // is less than it then it isn't higher than the range
1953
+ if ((!low.operator || low.operator === comp) &&
1954
+ ltefn(version, low.semver)) {
1955
+ return false
1956
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
1957
+ return false
1958
+ }
1959
+ }
1960
+ return true
1961
+ };
1962
+
1963
+ var outside_1 = outside$3;
1964
+
1965
+ // Determine if version is greater than all the versions possible in the range.
1966
+ const outside$2 = outside_1;
1967
+ const gtr$1 = (version, range, options) => outside$2(version, range, '>', options);
1968
+ var gtr_1 = gtr$1;
1969
+
1970
+ const outside$1 = outside_1;
1971
+ // Determine if version is less than all the versions possible in the range
1972
+ const ltr$1 = (version, range, options) => outside$1(version, range, '<', options);
1973
+ var ltr_1 = ltr$1;
1974
+
1975
+ const Range$2 = requireRange();
1976
+ const intersects$1 = (r1, r2, options) => {
1977
+ r1 = new Range$2(r1, options);
1978
+ r2 = new Range$2(r2, options);
1979
+ return r1.intersects(r2, options)
1980
+ };
1981
+ var intersects_1 = intersects$1;
1982
+
1983
+ // given a set of versions and a range, create a "simplified" range
1984
+ // that includes the same versions that the original range does
1985
+ // If the original range is shorter than the simplified one, return that.
1986
+ const satisfies$2 = satisfies_1;
1987
+ const compare$2 = compare_1;
1988
+ var simplify = (versions, range, options) => {
1989
+ const set = [];
1990
+ let first = null;
1991
+ let prev = null;
1992
+ const v = versions.sort((a, b) => compare$2(a, b, options));
1993
+ for (const version of v) {
1994
+ const included = satisfies$2(version, range, options);
1995
+ if (included) {
1996
+ prev = version;
1997
+ if (!first) {
1998
+ first = version;
1999
+ }
2000
+ } else {
2001
+ if (prev) {
2002
+ set.push([first, prev]);
2003
+ }
2004
+ prev = null;
2005
+ first = null;
2006
+ }
2007
+ }
2008
+ if (first) {
2009
+ set.push([first, null]);
2010
+ }
2011
+
2012
+ const ranges = [];
2013
+ for (const [min, max] of set) {
2014
+ if (min === max) {
2015
+ ranges.push(min);
2016
+ } else if (!max && min === v[0]) {
2017
+ ranges.push('*');
2018
+ } else if (!max) {
2019
+ ranges.push(`>=${min}`);
2020
+ } else if (min === v[0]) {
2021
+ ranges.push(`<=${max}`);
2022
+ } else {
2023
+ ranges.push(`${min} - ${max}`);
2024
+ }
2025
+ }
2026
+ const simplified = ranges.join(' || ');
2027
+ const original = typeof range.raw === 'string' ? range.raw : String(range);
2028
+ return simplified.length < original.length ? simplified : range
2029
+ };
2030
+
2031
+ const Range$1 = requireRange();
2032
+ const Comparator$1 = requireComparator();
2033
+ const { ANY } = Comparator$1;
2034
+ const satisfies$1 = satisfies_1;
2035
+ const compare$1 = compare_1;
2036
+
2037
+ // Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff:
2038
+ // - Every simple range `r1, r2, ...` is a null set, OR
2039
+ // - Every simple range `r1, r2, ...` which is not a null set is a subset of
2040
+ // some `R1, R2, ...`
2041
+ //
2042
+ // Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff:
2043
+ // - If c is only the ANY comparator
2044
+ // - If C is only the ANY comparator, return true
2045
+ // - Else if in prerelease mode, return false
2046
+ // - else replace c with `[>=0.0.0]`
2047
+ // - If C is only the ANY comparator
2048
+ // - if in prerelease mode, return true
2049
+ // - else replace C with `[>=0.0.0]`
2050
+ // - Let EQ be the set of = comparators in c
2051
+ // - If EQ is more than one, return true (null set)
2052
+ // - Let GT be the highest > or >= comparator in c
2053
+ // - Let LT be the lowest < or <= comparator in c
2054
+ // - If GT and LT, and GT.semver > LT.semver, return true (null set)
2055
+ // - If any C is a = range, and GT or LT are set, return false
2056
+ // - If EQ
2057
+ // - If GT, and EQ does not satisfy GT, return true (null set)
2058
+ // - If LT, and EQ does not satisfy LT, return true (null set)
2059
+ // - If EQ satisfies every C, return true
2060
+ // - Else return false
2061
+ // - If GT
2062
+ // - If GT.semver is lower than any > or >= comp in C, return false
2063
+ // - If GT is >=, and GT.semver does not satisfy every C, return false
2064
+ // - If GT.semver has a prerelease, and not in prerelease mode
2065
+ // - If no C has a prerelease and the GT.semver tuple, return false
2066
+ // - If LT
2067
+ // - If LT.semver is greater than any < or <= comp in C, return false
2068
+ // - If LT is <=, and LT.semver does not satisfy every C, return false
2069
+ // - If GT.semver has a prerelease, and not in prerelease mode
2070
+ // - If no C has a prerelease and the LT.semver tuple, return false
2071
+ // - Else return true
2072
+
2073
+ const subset$1 = (sub, dom, options = {}) => {
2074
+ if (sub === dom) {
2075
+ return true
2076
+ }
2077
+
2078
+ sub = new Range$1(sub, options);
2079
+ dom = new Range$1(dom, options);
2080
+ let sawNonNull = false;
2081
+
2082
+ OUTER: for (const simpleSub of sub.set) {
2083
+ for (const simpleDom of dom.set) {
2084
+ const isSub = simpleSubset(simpleSub, simpleDom, options);
2085
+ sawNonNull = sawNonNull || isSub !== null;
2086
+ if (isSub) {
2087
+ continue OUTER
2088
+ }
2089
+ }
2090
+ // the null set is a subset of everything, but null simple ranges in
2091
+ // a complex range should be ignored. so if we saw a non-null range,
2092
+ // then we know this isn't a subset, but if EVERY simple range was null,
2093
+ // then it is a subset.
2094
+ if (sawNonNull) {
2095
+ return false
2096
+ }
2097
+ }
2098
+ return true
2099
+ };
2100
+
2101
+ const minimumVersionWithPreRelease = [new Comparator$1('>=0.0.0-0')];
2102
+ const minimumVersion = [new Comparator$1('>=0.0.0')];
2103
+
2104
+ const simpleSubset = (sub, dom, options) => {
2105
+ if (sub === dom) {
2106
+ return true
2107
+ }
2108
+
2109
+ if (sub.length === 1 && sub[0].semver === ANY) {
2110
+ if (dom.length === 1 && dom[0].semver === ANY) {
2111
+ return true
2112
+ } else if (options.includePrerelease) {
2113
+ sub = minimumVersionWithPreRelease;
2114
+ } else {
2115
+ sub = minimumVersion;
2116
+ }
2117
+ }
2118
+
2119
+ if (dom.length === 1 && dom[0].semver === ANY) {
2120
+ if (options.includePrerelease) {
2121
+ return true
2122
+ } else {
2123
+ dom = minimumVersion;
2124
+ }
2125
+ }
2126
+
2127
+ const eqSet = new Set();
2128
+ let gt, lt;
2129
+ for (const c of sub) {
2130
+ if (c.operator === '>' || c.operator === '>=') {
2131
+ gt = higherGT(gt, c, options);
2132
+ } else if (c.operator === '<' || c.operator === '<=') {
2133
+ lt = lowerLT(lt, c, options);
2134
+ } else {
2135
+ eqSet.add(c.semver);
2136
+ }
2137
+ }
2138
+
2139
+ if (eqSet.size > 1) {
2140
+ return null
2141
+ }
2142
+
2143
+ let gtltComp;
2144
+ if (gt && lt) {
2145
+ gtltComp = compare$1(gt.semver, lt.semver, options);
2146
+ if (gtltComp > 0) {
2147
+ return null
2148
+ } else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) {
2149
+ return null
2150
+ }
2151
+ }
2152
+
2153
+ // will iterate one or zero times
2154
+ for (const eq of eqSet) {
2155
+ if (gt && !satisfies$1(eq, String(gt), options)) {
2156
+ return null
2157
+ }
2158
+
2159
+ if (lt && !satisfies$1(eq, String(lt), options)) {
2160
+ return null
2161
+ }
2162
+
2163
+ for (const c of dom) {
2164
+ if (!satisfies$1(eq, String(c), options)) {
2165
+ return false
2166
+ }
2167
+ }
2168
+
2169
+ return true
2170
+ }
2171
+
2172
+ let higher, lower;
2173
+ let hasDomLT, hasDomGT;
2174
+ // if the subset has a prerelease, we need a comparator in the superset
2175
+ // with the same tuple and a prerelease, or it's not a subset
2176
+ let needDomLTPre = lt &&
2177
+ !options.includePrerelease &&
2178
+ lt.semver.prerelease.length ? lt.semver : false;
2179
+ let needDomGTPre = gt &&
2180
+ !options.includePrerelease &&
2181
+ gt.semver.prerelease.length ? gt.semver : false;
2182
+ // exception: <1.2.3-0 is the same as <1.2.3
2183
+ if (needDomLTPre && needDomLTPre.prerelease.length === 1 &&
2184
+ lt.operator === '<' && needDomLTPre.prerelease[0] === 0) {
2185
+ needDomLTPre = false;
2186
+ }
2187
+
2188
+ for (const c of dom) {
2189
+ hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>=';
2190
+ hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<=';
2191
+ if (gt) {
2192
+ if (needDomGTPre) {
2193
+ if (c.semver.prerelease && c.semver.prerelease.length &&
2194
+ c.semver.major === needDomGTPre.major &&
2195
+ c.semver.minor === needDomGTPre.minor &&
2196
+ c.semver.patch === needDomGTPre.patch) {
2197
+ needDomGTPre = false;
2198
+ }
2199
+ }
2200
+ if (c.operator === '>' || c.operator === '>=') {
2201
+ higher = higherGT(gt, c, options);
2202
+ if (higher === c && higher !== gt) {
2203
+ return false
2204
+ }
2205
+ } else if (gt.operator === '>=' && !satisfies$1(gt.semver, String(c), options)) {
2206
+ return false
2207
+ }
2208
+ }
2209
+ if (lt) {
2210
+ if (needDomLTPre) {
2211
+ if (c.semver.prerelease && c.semver.prerelease.length &&
2212
+ c.semver.major === needDomLTPre.major &&
2213
+ c.semver.minor === needDomLTPre.minor &&
2214
+ c.semver.patch === needDomLTPre.patch) {
2215
+ needDomLTPre = false;
2216
+ }
2217
+ }
2218
+ if (c.operator === '<' || c.operator === '<=') {
2219
+ lower = lowerLT(lt, c, options);
2220
+ if (lower === c && lower !== lt) {
2221
+ return false
2222
+ }
2223
+ } else if (lt.operator === '<=' && !satisfies$1(lt.semver, String(c), options)) {
2224
+ return false
2225
+ }
2226
+ }
2227
+ if (!c.operator && (lt || gt) && gtltComp !== 0) {
2228
+ return false
2229
+ }
2230
+ }
2231
+
2232
+ // if there was a < or >, and nothing in the dom, then must be false
2233
+ // UNLESS it was limited by another range in the other direction.
2234
+ // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0
2235
+ if (gt && hasDomLT && !lt && gtltComp !== 0) {
2236
+ return false
2237
+ }
2238
+
2239
+ if (lt && hasDomGT && !gt && gtltComp !== 0) {
2240
+ return false
2241
+ }
2242
+
2243
+ // we needed a prerelease range in a specific tuple, but didn't get one
2244
+ // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0,
2245
+ // because it includes prereleases in the 1.2.3 tuple
2246
+ if (needDomGTPre || needDomLTPre) {
2247
+ return false
2248
+ }
2249
+
2250
+ return true
2251
+ };
2252
+
2253
+ // >=1.2.3 is lower than >1.2.3
2254
+ const higherGT = (a, b, options) => {
2255
+ if (!a) {
2256
+ return b
2257
+ }
2258
+ const comp = compare$1(a.semver, b.semver, options);
2259
+ return comp > 0 ? a
2260
+ : comp < 0 ? b
2261
+ : b.operator === '>' && a.operator === '>=' ? b
2262
+ : a
2263
+ };
2264
+
2265
+ // <=1.2.3 is higher than <1.2.3
2266
+ const lowerLT = (a, b, options) => {
2267
+ if (!a) {
2268
+ return b
2269
+ }
2270
+ const comp = compare$1(a.semver, b.semver, options);
2271
+ return comp < 0 ? a
2272
+ : comp > 0 ? b
2273
+ : b.operator === '<' && a.operator === '<=' ? b
2274
+ : a
2275
+ };
2276
+
2277
+ var subset_1 = subset$1;
2278
+
2279
+ // just pre-load all the stuff that index.js lazily exports
2280
+ const internalRe = reExports;
2281
+ const constants$1 = constants$2;
2282
+ const SemVer = semver$2;
2283
+ const identifiers = identifiers$1;
2284
+ const parse$4 = parse_1;
2285
+ const valid = valid_1;
2286
+ const clean = clean_1;
2287
+ const inc = inc_1;
2288
+ const diff = diff_1;
2289
+ const major = major_1;
2290
+ const minor = minor_1;
2291
+ const patch = patch_1;
2292
+ const prerelease = prerelease_1;
2293
+ const compare = compare_1;
2294
+ const rcompare = rcompare_1;
2295
+ const compareLoose = compareLoose_1;
2296
+ const compareBuild = compareBuild_1;
2297
+ const sort = sort_1;
2298
+ const rsort = rsort_1;
2299
+ const gt = gt_1;
2300
+ const lt = lt_1;
2301
+ const eq = eq_1;
2302
+ const neq = neq_1;
2303
+ const gte = gte_1;
2304
+ const lte = lte_1;
2305
+ const cmp = cmp_1;
2306
+ const coerce = coerce_1;
2307
+ const Comparator = requireComparator();
2308
+ const Range = requireRange();
2309
+ const satisfies = satisfies_1;
2310
+ const toComparators = toComparators_1;
2311
+ const maxSatisfying = maxSatisfying_1;
2312
+ const minSatisfying = minSatisfying_1;
2313
+ const minVersion = minVersion_1;
2314
+ const validRange = valid$1;
2315
+ const outside = outside_1;
2316
+ const gtr = gtr_1;
2317
+ const ltr = ltr_1;
2318
+ const intersects = intersects_1;
2319
+ const simplifyRange = simplify;
2320
+ const subset = subset_1;
2321
+ var semver = {
2322
+ parse: parse$4,
2323
+ valid,
2324
+ clean,
2325
+ inc,
2326
+ diff,
2327
+ major,
2328
+ minor,
2329
+ patch,
2330
+ prerelease,
2331
+ compare,
2332
+ rcompare,
2333
+ compareLoose,
2334
+ compareBuild,
2335
+ sort,
2336
+ rsort,
2337
+ gt,
2338
+ lt,
2339
+ eq,
2340
+ neq,
2341
+ gte,
2342
+ lte,
2343
+ cmp,
2344
+ coerce,
2345
+ Comparator,
2346
+ Range,
2347
+ satisfies,
2348
+ toComparators,
2349
+ maxSatisfying,
2350
+ minSatisfying,
2351
+ minVersion,
2352
+ validRange,
2353
+ outside,
2354
+ gtr,
2355
+ ltr,
2356
+ intersects,
2357
+ simplifyRange,
2358
+ subset,
2359
+ SemVer,
2360
+ re: internalRe.re,
2361
+ src: internalRe.src,
2362
+ tokens: internalRe.t,
2363
+ SEMVER_SPEC_VERSION: constants$1.SEMVER_SPEC_VERSION,
2364
+ RELEASE_TYPES: constants$1.RELEASE_TYPES,
2365
+ compareIdentifiers: identifiers.compareIdentifiers,
2366
+ rcompareIdentifiers: identifiers.rcompareIdentifiers,
2367
+ };
2368
+
2369
+ var semver$1 = /*@__PURE__*/getDefaultExportFromCjs(semver);
2370
+
2371
+ /**
2372
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
2373
+ *
2374
+ * This source code is licensed under the MIT license found in the
2375
+ * LICENSE file in the root directory of this source tree.
2376
+ */
2377
+ function getUnsupportedNodeMessage(version, requiredRange) {
2378
+ if (semver$1.satisfies(version, requiredRange, { includePrerelease: true })) {
2379
+ return undefined;
2380
+ }
2381
+ return (`Unsupported Node.js version: ${version}. IWSDK requires Node ${requiredRange}. ` +
2382
+ 'Upgrade Node (for example with nvm or Volta) and retry.');
2383
+ }
2384
+
2385
+ const NODE_ENGINE = ">=20.19.0 <21.0.0-0 || >=22.12.0 <23.0.0-0 || >=24.0.0";
2386
+
21
2387
  /**
22
2388
  * Copyright (c) Meta Platforms, Inc. and affiliates.
23
2389
  *
@@ -149,6 +2515,131 @@ var mcpSurfaceMarkers = {
149
2515
  * This source code is licensed under the MIT license found in the
150
2516
  * LICENSE file in the root directory of this source tree.
151
2517
  */
2518
+ const DEFAULT_RUNTIME_COMMAND_TIMEOUT_MS = 30_000;
2519
+ const UI_RENDER_PREVIEW_TIMEOUT_MS = 60_000;
2520
+ function getDefaultRuntimeCommandTimeoutMs(method) {
2521
+ return method === 'ui_render_preview'
2522
+ ? UI_RENDER_PREVIEW_TIMEOUT_MS
2523
+ : DEFAULT_RUNTIME_COMMAND_TIMEOUT_MS;
2524
+ }
2525
+ function describeValue(value) {
2526
+ if (value === null) {
2527
+ return 'null';
2528
+ }
2529
+ if (Array.isArray(value)) {
2530
+ return 'array';
2531
+ }
2532
+ return typeof value;
2533
+ }
2534
+ function assertSchemaValue(value, schema, path) {
2535
+ if (schema.oneOf?.length) {
2536
+ const matches = schema.oneOf.filter((candidate) => {
2537
+ try {
2538
+ assertSchemaValue(value, candidate, path);
2539
+ return true;
2540
+ }
2541
+ catch {
2542
+ return false;
2543
+ }
2544
+ });
2545
+ if (matches.length !== 1) {
2546
+ throw new Error(`${path} must match exactly one supported shape`);
2547
+ }
2548
+ }
2549
+ if (schema.anyOf?.length) {
2550
+ const matches = schema.anyOf.some((candidate) => {
2551
+ try {
2552
+ assertSchemaValue(value, candidate, path);
2553
+ return true;
2554
+ }
2555
+ catch {
2556
+ return false;
2557
+ }
2558
+ });
2559
+ if (!matches) {
2560
+ throw new Error(`${path} must match a supported shape`);
2561
+ }
2562
+ }
2563
+ if (schema.not) {
2564
+ let matchesDisallowedSchema = true;
2565
+ try {
2566
+ assertSchemaValue(value, schema.not, path);
2567
+ }
2568
+ catch {
2569
+ matchesDisallowedSchema = false;
2570
+ }
2571
+ if (matchesDisallowedSchema) {
2572
+ throw new Error(`${path} uses a disallowed value`);
2573
+ }
2574
+ }
2575
+ const typeMatches = schema.type == null ||
2576
+ (schema.type === 'null' && value === null) ||
2577
+ (schema.type === 'array' && Array.isArray(value)) ||
2578
+ (schema.type === 'object' && isRecord$6(value)) ||
2579
+ (schema.type === 'integer' && Number.isInteger(value)) ||
2580
+ (schema.type === 'number' &&
2581
+ typeof value === 'number' &&
2582
+ Number.isFinite(value)) ||
2583
+ (schema.type === 'string' && typeof value === 'string') ||
2584
+ (schema.type === 'boolean' && typeof value === 'boolean');
2585
+ if (!typeMatches) {
2586
+ throw new Error(`${path} must be ${schema.type}; received ${describeValue(value)}`);
2587
+ }
2588
+ if (schema.enum && !schema.enum.includes(value)) {
2589
+ throw new Error(`${path} must be one of: ${schema.enum.join(', ')}`);
2590
+ }
2591
+ if (typeof value === 'number') {
2592
+ if (schema.minimum != null && value < schema.minimum) {
2593
+ throw new Error(`${path} must be at least ${schema.minimum}`);
2594
+ }
2595
+ if (schema.exclusiveMinimum != null && value <= schema.exclusiveMinimum) {
2596
+ throw new Error(`${path} must be greater than ${schema.exclusiveMinimum}`);
2597
+ }
2598
+ if (schema.maximum != null && value > schema.maximum) {
2599
+ throw new Error(`${path} must be at most ${schema.maximum}`);
2600
+ }
2601
+ }
2602
+ if (typeof value === 'string' &&
2603
+ schema.pattern &&
2604
+ !new RegExp(schema.pattern).test(value)) {
2605
+ throw new Error(`${path} must match ${schema.pattern}`);
2606
+ }
2607
+ if (Array.isArray(value)) {
2608
+ if (schema.minItems != null && value.length < schema.minItems) {
2609
+ throw new Error(`${path} requires at least ${schema.minItems} items`);
2610
+ }
2611
+ if (schema.maxItems != null && value.length > schema.maxItems) {
2612
+ throw new Error(`${path} allows at most ${schema.maxItems} items`);
2613
+ }
2614
+ if (schema.items) {
2615
+ value.forEach((entry, index) => assertSchemaValue(entry, schema.items, `${path}[${index}]`));
2616
+ }
2617
+ }
2618
+ if (isRecord$6(value)) {
2619
+ const properties = schema.properties;
2620
+ for (const required of schema.required ?? []) {
2621
+ if (!Object.prototype.hasOwnProperty.call(value, required)) {
2622
+ throw new Error(`${path}.${required} is required`);
2623
+ }
2624
+ }
2625
+ for (const [name, entry] of Object.entries(value)) {
2626
+ const propertySchema = properties?.[name];
2627
+ if (propertySchema) {
2628
+ assertSchemaValue(entry, propertySchema, `${path}.${name}`);
2629
+ }
2630
+ else if (!properties || schema.additionalProperties === true) {
2631
+ continue;
2632
+ }
2633
+ else if (typeof schema.additionalProperties === 'object') {
2634
+ assertSchemaValue(entry, schema.additionalProperties, `${path}.${name}`);
2635
+ }
2636
+ else {
2637
+ const allowed = Object.keys(properties);
2638
+ throw new Error(`${path} has unknown parameter "${name}"${allowed.length ? `; allowed: ${allowed.join(', ')}` : ''}`);
2639
+ }
2640
+ }
2641
+ }
2642
+ }
152
2643
  const IWSDK_RUNTIME_LOGS_DIR = '.iwsdk/runtime/logs';
153
2644
  const IWSDK_RUNTIME_SESSION_PATH = '.iwsdk/runtime/session.json';
154
2645
  const IWSDK_RUNTIME_LAUNCH_PATH = '.iwsdk/runtime/launch.json';
@@ -2620,6 +5111,7 @@ function resolveRuntimeOperationRequest(operation, params) {
2620
5111
  Object.keys(paramsRecord).some((key) => key !== 'expectedTab')) {
2621
5112
  throw new Error('browser_screenshot does not accept parameters; it always captures the application runtime');
2622
5113
  }
5114
+ assertSchemaValue(params, operation.inputSchema, operation.mcpName);
2623
5115
  const commandParams = paramsRecord == null
2624
5116
  ? params
2625
5117
  : Object.fromEntries(Object.entries(paramsRecord).filter(([key]) => key !== 'expectedTab'));
@@ -3830,10 +6322,6 @@ async function handleAdapterPrompt(options, io) {
3830
6322
  return null;
3831
6323
  }
3832
6324
 
3833
- function getDefaultExportFromCjs (x) {
3834
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
3835
- }
3836
-
3837
6325
  var bufferUtil$1 = {exports: {}};
3838
6326
 
3839
6327
  const BINARY_TYPES$2 = ['nodebuffer', 'arraybuffer', 'fragments'];
@@ -8450,7 +10938,7 @@ async function confirmOpenedSceneReady(options, response, deadline, previousScen
8450
10938
  : 'browser_not_ready',
8451
10939
  });
8452
10940
  }
8453
- async function sendRuntimeCommand({ port, method, params, target, timeoutMs = 30000, runtimeSession, }) {
10941
+ async function sendRuntimeCommand({ port, method, params, target, timeoutMs = getDefaultRuntimeCommandTimeoutMs(method), runtimeSession, }) {
8454
10942
  if (runtimeSession?.browser?.status === 'not_launched') {
8455
10943
  throw new RuntimeCommandExecutionError(runtimeSession.browser.lastError?.message ??
8456
10944
  'No managed browser was launched. Run "iwsdk dev restart --open" to enable browser, scene, and runtime tools.', {
@@ -26274,13 +28762,78 @@ async function handleReferenceWarmup(options, context) {
26274
28762
  * This source code is licensed under the MIT license found in the
26275
28763
  * LICENSE file in the root directory of this source tree.
26276
28764
  */
26277
- const DEFAULT_TIMEOUT_MS = 30000;
28765
+ const COMMON_RUNTIME_OPTIONS = new Set([
28766
+ 'help',
28767
+ 'inputJson',
28768
+ 'raw',
28769
+ 'timeout',
28770
+ 'workspace',
28771
+ ]);
28772
+ const DIRECT_OPTION_ALIASES = {
28773
+ browser_get_console_logs: {
28774
+ count: { parameter: 'count', type: 'number' },
28775
+ level: { parameter: 'level', type: 'levels' },
28776
+ pattern: { parameter: 'pattern', type: 'string' },
28777
+ since: { parameter: 'since', type: 'number' },
28778
+ },
28779
+ ecs_step: {
28780
+ count: { parameter: 'count', type: 'number' },
28781
+ frames: { parameter: 'count', type: 'number' },
28782
+ delta: { parameter: 'delta', type: 'number' },
28783
+ },
28784
+ };
28785
+ function parseDirectValue(value, option, type) {
28786
+ if (typeof value !== 'string') {
28787
+ throw new Error(`--${option} requires a value`);
28788
+ }
28789
+ if (type === 'number') {
28790
+ const parsed = Number(value);
28791
+ if (!Number.isFinite(parsed)) {
28792
+ throw new Error(`--${option} must be a number`);
28793
+ }
28794
+ return parsed;
28795
+ }
28796
+ if (type === 'levels') {
28797
+ const levels = value.split(',').map((entry) => entry.trim());
28798
+ return levels.length === 1 ? levels[0] : levels;
28799
+ }
28800
+ return value;
28801
+ }
28802
+ function resolveRuntimeParams(operationName, options) {
28803
+ const aliases = DIRECT_OPTION_ALIASES[operationName] ?? {};
28804
+ const allowed = new Set([...COMMON_RUNTIME_OPTIONS, ...Object.keys(aliases)]);
28805
+ if (operationName === 'browser_screenshot' ||
28806
+ operationName === 'scene_screenshot' ||
28807
+ operationName === 'scene_render_file' ||
28808
+ operationName === 'ui_render_preview') {
28809
+ allowed.add('outputFile');
28810
+ }
28811
+ const unknown = Object.keys(options).filter((name) => !allowed.has(name));
28812
+ if (unknown.length > 0) {
28813
+ const flag = unknown[0].replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
28814
+ throw new Error(`Unknown option --${flag}. Runtime parameters must be passed through --input-json; run this command with --help for its schema.`);
28815
+ }
28816
+ const directEntries = Object.entries(aliases).filter(([name]) => options[name] !== undefined);
28817
+ if (typeof options.inputJson === 'string' && directEntries.length > 0) {
28818
+ throw new Error(`Do not combine --input-json with direct parameter aliases: ${directEntries.map(([name]) => `--${name}`).join(', ')}`);
28819
+ }
28820
+ if (typeof options.inputJson === 'string') {
28821
+ return safeJsonParse(options.inputJson, '--input-json');
28822
+ }
28823
+ return Object.fromEntries(directEntries.map(([name, alias]) => [
28824
+ alias.parameter,
28825
+ parseDirectValue(options[name], name, alias.type),
28826
+ ]));
28827
+ }
26278
28828
  function isRecord(value) {
26279
28829
  return typeof value === 'object' && value !== null && !Array.isArray(value);
26280
28830
  }
26281
28831
  function isScreenshotResult(value) {
26282
28832
  return isRecord(value) && typeof value.imageData === 'string';
26283
28833
  }
28834
+ function isBrowserRelaunchedResult(value) {
28835
+ return isRecord(value) && value.status === 'browser_relaunched';
28836
+ }
26284
28837
  function withBrowserStatus(result, session) {
26285
28838
  const browser = session.browser ?? null;
26286
28839
  const browserConnected = Boolean(session.browser?.connected);
@@ -26304,6 +28857,7 @@ async function saveScreenshot(result, requestedPath) {
26304
28857
  const outputPath = typeof requestedPath === 'string'
26305
28858
  ? requestedPath
26306
28859
  : path.join(os.tmpdir(), `iwsdk-screenshot-${Date.now()}.png`);
28860
+ await mkdir(path.dirname(outputPath), { recursive: true });
26307
28861
  await writeFile(outputPath, Buffer.from(result.imageData, 'base64'));
26308
28862
  return outputPath;
26309
28863
  }
@@ -26315,6 +28869,8 @@ async function handleRuntimeOperation(domain, action, options, io) {
26315
28869
  const available = RUNTIME_OPERATIONS.filter((entry) => entry.domain === domain).map((entry) => entry.action);
26316
28870
  throw new Error(`Unknown ${domain} command "${action}". Available: ${available.join(', ')}`);
26317
28871
  }
28872
+ const parsedParams = resolveRuntimeParams(operation.mcpName, options);
28873
+ const command = resolveRuntimeOperationRequest(operation, parsedParams);
26318
28874
  const workspaceRoot = await resolveWorkspaceRoot({
26319
28875
  cwd: io.cwd,
26320
28876
  workspace: typeof options.workspace === 'string' ? options.workspace : undefined,
@@ -26324,18 +28880,29 @@ async function handleRuntimeOperation(domain, action, options, io) {
26324
28880
  if (!session) {
26325
28881
  throw new Error(formatMissingRuntimeMessage(workspaceRoot));
26326
28882
  }
26327
- const parsedParams = typeof options.inputJson === 'string'
26328
- ? safeJsonParse(options.inputJson, '--input-json')
26329
- : {};
26330
- const command = resolveRuntimeOperationRequest(operation, parsedParams);
26331
- const rawResult = await sendRuntimeCommand({
28883
+ const sendOptions = {
26332
28884
  port: session.port,
26333
28885
  method: operation.wsMethod,
26334
28886
  params: command.params,
26335
28887
  target: command.target,
26336
- timeoutMs: parseIntegerOption(options.timeout, '--timeout', DEFAULT_TIMEOUT_MS),
28888
+ timeoutMs: parseIntegerOption(options.timeout, '--timeout', getDefaultRuntimeCommandTimeoutMs(operation.wsMethod)),
26337
28889
  runtimeSession: session,
26338
- });
28890
+ };
28891
+ let rawResult;
28892
+ try {
28893
+ rawResult = await sendRuntimeCommand(sendOptions);
28894
+ if (operation.mcpName === 'browser_screenshot' &&
28895
+ isBrowserRelaunchedResult(rawResult.result ?? rawResult)) {
28896
+ rawResult = await sendRuntimeCommand(sendOptions);
28897
+ }
28898
+ }
28899
+ catch (error) {
28900
+ if (operation.mcpName === 'xr_accept_session' &&
28901
+ error instanceof RuntimeCommandExecutionError) {
28902
+ error.message = `${error.message} Configure world.xr.offer as "once" or "always" before running iwsdk xr enter.`;
28903
+ }
28904
+ throw error;
28905
+ }
26339
28906
  const result = operation.mcpName === 'xr_get_session_status'
26340
28907
  ? withBrowserStatus(rawResult.result ?? rawResult, session)
26341
28908
  : (rawResult.result ?? rawResult);
@@ -26416,6 +28983,33 @@ function formatSchemaPropertyLines(propertyPath, schema, required, indent = 2) {
26416
28983
  }
26417
28984
  return lines;
26418
28985
  }
28986
+ function schemaExample(schema) {
28987
+ if (schema.enum?.length) {
28988
+ return schema.enum[0];
28989
+ }
28990
+ if (schema.oneOf?.length) {
28991
+ return schemaExample(schema.oneOf[0]);
28992
+ }
28993
+ if (schema.type === 'array') {
28994
+ return [schemaExample(schema.items ?? { type: 'string' })];
28995
+ }
28996
+ if (schema.type === 'object' || schema.properties) {
28997
+ return Object.fromEntries((schema.required ?? []).map((name) => [
28998
+ name,
28999
+ schemaExample(schema.properties?.[name] ?? { type: 'string' }),
29000
+ ]));
29001
+ }
29002
+ if (schema.type === 'number' || schema.type === 'integer') {
29003
+ return schema.minimum ?? 1;
29004
+ }
29005
+ if (schema.type === 'boolean') {
29006
+ return true;
29007
+ }
29008
+ if (schema.type === 'null') {
29009
+ return null;
29010
+ }
29011
+ return '<string>';
29012
+ }
26419
29013
  function buildRuntimeCommandHelp(domain, action) {
26420
29014
  const operation = getRuntimeOperationByCliPath(domain, action);
26421
29015
  if (!operation) {
@@ -26445,10 +29039,16 @@ function buildRuntimeCommandHelp(domain, action) {
26445
29039
  lines.push(...formatSchemaPropertyLines(name, schema, required.has(name)));
26446
29040
  }
26447
29041
  }
26448
- lines.push('', 'Options:', ' --input-json <json>', ' --timeout <ms>', ' --raw');
29042
+ lines.push('', 'Example:', ` iwsdk ${domain} ${action} --input-json '${JSON.stringify(schemaExample(operation.inputSchema))}'`, '', 'Options:', ' --input-json <json>', ' --timeout <ms>', ' --raw');
26449
29043
  if (writesScreenshot) {
26450
29044
  lines.push(' --output-file <path> Write the PNG to this path and return screenshotPath; takes precedence over --raw');
26451
29045
  }
29046
+ if (operation.mcpName === 'ecs_step') {
29047
+ lines.push(' --frames <count> Alias for input count', ' --count <count> Alias for input count', ' --delta <seconds> Alias for input delta');
29048
+ }
29049
+ if (operation.mcpName === 'browser_get_console_logs') {
29050
+ lines.push(' --level <levels> Comma-separated log-level alias', ' --count <count> Maximum log-count alias', ' --pattern <regex> Message-pattern alias', ' --since <timestamp> Timestamp alias');
29051
+ }
26452
29052
  return lines;
26453
29053
  }
26454
29054
  function buildRuntimeDomainHelp(domain) {
@@ -26612,11 +29212,11 @@ async function runCli(argv, io = {}) {
26612
29212
  stdout.write(`${buildReferenceCommandHelp(subcommand).join('\n')}\n`);
26613
29213
  return 0;
26614
29214
  }
26615
- if ((command === 'xr' ||
29215
+ if (command === 'xr' ||
26616
29216
  command === 'browser' ||
26617
29217
  command === 'scene' ||
26618
29218
  command === 'ui' ||
26619
- command === 'ecs')) {
29219
+ command === 'ecs') {
26620
29220
  stdout.write(`${(subcommand
26621
29221
  ? buildRuntimeCommandHelp(command, subcommand)
26622
29222
  : buildRuntimeDomainHelp(command)).join('\n')}\n`);
@@ -26700,6 +29300,9 @@ async function runCli(argv, io = {}) {
26700
29300
  case 'scene':
26701
29301
  case 'ui':
26702
29302
  case 'ecs':
29303
+ if (!subcommand) {
29304
+ throw new Error(buildRuntimeDomainHelp(command).join('\n'));
29305
+ }
26703
29306
  result = await handleRuntimeOperation(command, subcommand, parsed.options, context);
26704
29307
  break;
26705
29308
  default:
@@ -26737,8 +29340,15 @@ async function runCli(argv, io = {}) {
26737
29340
  * This source code is licensed under the MIT license found in the
26738
29341
  * LICENSE file in the root directory of this source tree.
26739
29342
  */
26740
- const exitCode = await runCli(process.argv.slice(2));
26741
- if (typeof exitCode === 'number') {
26742
- process.exitCode = exitCode;
29343
+ const nodeError = getUnsupportedNodeMessage(process.versions.node, NODE_ENGINE);
29344
+ if (nodeError) {
29345
+ console.error(nodeError);
29346
+ process.exitCode = 1;
29347
+ }
29348
+ else {
29349
+ const exitCode = await runCli(process.argv.slice(2));
29350
+ if (typeof exitCode === 'number') {
29351
+ process.exitCode = exitCode;
29352
+ }
26743
29353
  }
26744
29354
  //# sourceMappingURL=cli.js.map