@umijs/bundler-vite 4.7.7 → 4.7.8
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/compiled/@vitejs/plugin-legacy/313.index.js +65 -0
- package/compiled/@vitejs/plugin-legacy/319.index.js +112 -0
- package/compiled/@vitejs/plugin-legacy/675.index.js +1034 -0
- package/compiled/@vitejs/plugin-legacy/967.index.js +4726 -0
- package/compiled/@vitejs/plugin-legacy/LICENSE +1 -1
- package/compiled/@vitejs/plugin-legacy/index.js +1 -1
- package/compiled/@vitejs/plugin-legacy/package.json +1 -1
- package/dist/server/plugins/middlewares.d.ts +2 -0
- package/dist/server/plugins/middlewares.js +73 -0
- package/dist/server/server.d.ts +1 -1
- package/dist/server/server.js +11 -23
- package/package.json +13 -9
|
@@ -0,0 +1,4726 @@
|
|
|
1
|
+
exports.id = 967;
|
|
2
|
+
exports.ids = [967];
|
|
3
|
+
exports.modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 3571:
|
|
6
|
+
/***/ (function(module) {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* lodash (Custom Build) <https://lodash.com/>
|
|
10
|
+
* Build: `lodash modularize exports="npm" -o ./`
|
|
11
|
+
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
|
12
|
+
* Released under MIT license <https://lodash.com/license>
|
|
13
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
14
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** Used as the `TypeError` message for "Functions" methods. */
|
|
18
|
+
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
19
|
+
|
|
20
|
+
/** Used as references for various `Number` constants. */
|
|
21
|
+
var NAN = 0 / 0;
|
|
22
|
+
|
|
23
|
+
/** `Object#toString` result references. */
|
|
24
|
+
var symbolTag = '[object Symbol]';
|
|
25
|
+
|
|
26
|
+
/** Used to match leading and trailing whitespace. */
|
|
27
|
+
var reTrim = /^\s+|\s+$/g;
|
|
28
|
+
|
|
29
|
+
/** Used to detect bad signed hexadecimal string values. */
|
|
30
|
+
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
31
|
+
|
|
32
|
+
/** Used to detect binary string values. */
|
|
33
|
+
var reIsBinary = /^0b[01]+$/i;
|
|
34
|
+
|
|
35
|
+
/** Used to detect octal string values. */
|
|
36
|
+
var reIsOctal = /^0o[0-7]+$/i;
|
|
37
|
+
|
|
38
|
+
/** Built-in method references without a dependency on `root`. */
|
|
39
|
+
var freeParseInt = parseInt;
|
|
40
|
+
|
|
41
|
+
/** Detect free variable `global` from Node.js. */
|
|
42
|
+
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
|
43
|
+
|
|
44
|
+
/** Detect free variable `self`. */
|
|
45
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
46
|
+
|
|
47
|
+
/** Used as a reference to the global object. */
|
|
48
|
+
var root = freeGlobal || freeSelf || Function('return this')();
|
|
49
|
+
|
|
50
|
+
/** Used for built-in method references. */
|
|
51
|
+
var objectProto = Object.prototype;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Used to resolve the
|
|
55
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
56
|
+
* of values.
|
|
57
|
+
*/
|
|
58
|
+
var objectToString = objectProto.toString;
|
|
59
|
+
|
|
60
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
61
|
+
var nativeMax = Math.max,
|
|
62
|
+
nativeMin = Math.min;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Gets the timestamp of the number of milliseconds that have elapsed since
|
|
66
|
+
* the Unix epoch (1 January 1970 00:00:00 UTC).
|
|
67
|
+
*
|
|
68
|
+
* @static
|
|
69
|
+
* @memberOf _
|
|
70
|
+
* @since 2.4.0
|
|
71
|
+
* @category Date
|
|
72
|
+
* @returns {number} Returns the timestamp.
|
|
73
|
+
* @example
|
|
74
|
+
*
|
|
75
|
+
* _.defer(function(stamp) {
|
|
76
|
+
* console.log(_.now() - stamp);
|
|
77
|
+
* }, _.now());
|
|
78
|
+
* // => Logs the number of milliseconds it took for the deferred invocation.
|
|
79
|
+
*/
|
|
80
|
+
var now = function() {
|
|
81
|
+
return root.Date.now();
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Creates a debounced function that delays invoking `func` until after `wait`
|
|
86
|
+
* milliseconds have elapsed since the last time the debounced function was
|
|
87
|
+
* invoked. The debounced function comes with a `cancel` method to cancel
|
|
88
|
+
* delayed `func` invocations and a `flush` method to immediately invoke them.
|
|
89
|
+
* Provide `options` to indicate whether `func` should be invoked on the
|
|
90
|
+
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
|
|
91
|
+
* with the last arguments provided to the debounced function. Subsequent
|
|
92
|
+
* calls to the debounced function return the result of the last `func`
|
|
93
|
+
* invocation.
|
|
94
|
+
*
|
|
95
|
+
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
96
|
+
* invoked on the trailing edge of the timeout only if the debounced function
|
|
97
|
+
* is invoked more than once during the `wait` timeout.
|
|
98
|
+
*
|
|
99
|
+
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
100
|
+
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
101
|
+
*
|
|
102
|
+
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
103
|
+
* for details over the differences between `_.debounce` and `_.throttle`.
|
|
104
|
+
*
|
|
105
|
+
* @static
|
|
106
|
+
* @memberOf _
|
|
107
|
+
* @since 0.1.0
|
|
108
|
+
* @category Function
|
|
109
|
+
* @param {Function} func The function to debounce.
|
|
110
|
+
* @param {number} [wait=0] The number of milliseconds to delay.
|
|
111
|
+
* @param {Object} [options={}] The options object.
|
|
112
|
+
* @param {boolean} [options.leading=false]
|
|
113
|
+
* Specify invoking on the leading edge of the timeout.
|
|
114
|
+
* @param {number} [options.maxWait]
|
|
115
|
+
* The maximum time `func` is allowed to be delayed before it's invoked.
|
|
116
|
+
* @param {boolean} [options.trailing=true]
|
|
117
|
+
* Specify invoking on the trailing edge of the timeout.
|
|
118
|
+
* @returns {Function} Returns the new debounced function.
|
|
119
|
+
* @example
|
|
120
|
+
*
|
|
121
|
+
* // Avoid costly calculations while the window size is in flux.
|
|
122
|
+
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
|
|
123
|
+
*
|
|
124
|
+
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
|
|
125
|
+
* jQuery(element).on('click', _.debounce(sendMail, 300, {
|
|
126
|
+
* 'leading': true,
|
|
127
|
+
* 'trailing': false
|
|
128
|
+
* }));
|
|
129
|
+
*
|
|
130
|
+
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
|
|
131
|
+
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
|
|
132
|
+
* var source = new EventSource('/stream');
|
|
133
|
+
* jQuery(source).on('message', debounced);
|
|
134
|
+
*
|
|
135
|
+
* // Cancel the trailing debounced invocation.
|
|
136
|
+
* jQuery(window).on('popstate', debounced.cancel);
|
|
137
|
+
*/
|
|
138
|
+
function debounce(func, wait, options) {
|
|
139
|
+
var lastArgs,
|
|
140
|
+
lastThis,
|
|
141
|
+
maxWait,
|
|
142
|
+
result,
|
|
143
|
+
timerId,
|
|
144
|
+
lastCallTime,
|
|
145
|
+
lastInvokeTime = 0,
|
|
146
|
+
leading = false,
|
|
147
|
+
maxing = false,
|
|
148
|
+
trailing = true;
|
|
149
|
+
|
|
150
|
+
if (typeof func != 'function') {
|
|
151
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
152
|
+
}
|
|
153
|
+
wait = toNumber(wait) || 0;
|
|
154
|
+
if (isObject(options)) {
|
|
155
|
+
leading = !!options.leading;
|
|
156
|
+
maxing = 'maxWait' in options;
|
|
157
|
+
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
158
|
+
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function invokeFunc(time) {
|
|
162
|
+
var args = lastArgs,
|
|
163
|
+
thisArg = lastThis;
|
|
164
|
+
|
|
165
|
+
lastArgs = lastThis = undefined;
|
|
166
|
+
lastInvokeTime = time;
|
|
167
|
+
result = func.apply(thisArg, args);
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function leadingEdge(time) {
|
|
172
|
+
// Reset any `maxWait` timer.
|
|
173
|
+
lastInvokeTime = time;
|
|
174
|
+
// Start the timer for the trailing edge.
|
|
175
|
+
timerId = setTimeout(timerExpired, wait);
|
|
176
|
+
// Invoke the leading edge.
|
|
177
|
+
return leading ? invokeFunc(time) : result;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function remainingWait(time) {
|
|
181
|
+
var timeSinceLastCall = time - lastCallTime,
|
|
182
|
+
timeSinceLastInvoke = time - lastInvokeTime,
|
|
183
|
+
result = wait - timeSinceLastCall;
|
|
184
|
+
|
|
185
|
+
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function shouldInvoke(time) {
|
|
189
|
+
var timeSinceLastCall = time - lastCallTime,
|
|
190
|
+
timeSinceLastInvoke = time - lastInvokeTime;
|
|
191
|
+
|
|
192
|
+
// Either this is the first call, activity has stopped and we're at the
|
|
193
|
+
// trailing edge, the system time has gone backwards and we're treating
|
|
194
|
+
// it as the trailing edge, or we've hit the `maxWait` limit.
|
|
195
|
+
return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
|
|
196
|
+
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function timerExpired() {
|
|
200
|
+
var time = now();
|
|
201
|
+
if (shouldInvoke(time)) {
|
|
202
|
+
return trailingEdge(time);
|
|
203
|
+
}
|
|
204
|
+
// Restart the timer.
|
|
205
|
+
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function trailingEdge(time) {
|
|
209
|
+
timerId = undefined;
|
|
210
|
+
|
|
211
|
+
// Only invoke if we have `lastArgs` which means `func` has been
|
|
212
|
+
// debounced at least once.
|
|
213
|
+
if (trailing && lastArgs) {
|
|
214
|
+
return invokeFunc(time);
|
|
215
|
+
}
|
|
216
|
+
lastArgs = lastThis = undefined;
|
|
217
|
+
return result;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function cancel() {
|
|
221
|
+
if (timerId !== undefined) {
|
|
222
|
+
clearTimeout(timerId);
|
|
223
|
+
}
|
|
224
|
+
lastInvokeTime = 0;
|
|
225
|
+
lastArgs = lastCallTime = lastThis = timerId = undefined;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function flush() {
|
|
229
|
+
return timerId === undefined ? result : trailingEdge(now());
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function debounced() {
|
|
233
|
+
var time = now(),
|
|
234
|
+
isInvoking = shouldInvoke(time);
|
|
235
|
+
|
|
236
|
+
lastArgs = arguments;
|
|
237
|
+
lastThis = this;
|
|
238
|
+
lastCallTime = time;
|
|
239
|
+
|
|
240
|
+
if (isInvoking) {
|
|
241
|
+
if (timerId === undefined) {
|
|
242
|
+
return leadingEdge(lastCallTime);
|
|
243
|
+
}
|
|
244
|
+
if (maxing) {
|
|
245
|
+
// Handle invocations in a tight loop.
|
|
246
|
+
timerId = setTimeout(timerExpired, wait);
|
|
247
|
+
return invokeFunc(lastCallTime);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (timerId === undefined) {
|
|
251
|
+
timerId = setTimeout(timerExpired, wait);
|
|
252
|
+
}
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
255
|
+
debounced.cancel = cancel;
|
|
256
|
+
debounced.flush = flush;
|
|
257
|
+
return debounced;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Checks if `value` is the
|
|
262
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
263
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
264
|
+
*
|
|
265
|
+
* @static
|
|
266
|
+
* @memberOf _
|
|
267
|
+
* @since 0.1.0
|
|
268
|
+
* @category Lang
|
|
269
|
+
* @param {*} value The value to check.
|
|
270
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
271
|
+
* @example
|
|
272
|
+
*
|
|
273
|
+
* _.isObject({});
|
|
274
|
+
* // => true
|
|
275
|
+
*
|
|
276
|
+
* _.isObject([1, 2, 3]);
|
|
277
|
+
* // => true
|
|
278
|
+
*
|
|
279
|
+
* _.isObject(_.noop);
|
|
280
|
+
* // => true
|
|
281
|
+
*
|
|
282
|
+
* _.isObject(null);
|
|
283
|
+
* // => false
|
|
284
|
+
*/
|
|
285
|
+
function isObject(value) {
|
|
286
|
+
var type = typeof value;
|
|
287
|
+
return !!value && (type == 'object' || type == 'function');
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
292
|
+
* and has a `typeof` result of "object".
|
|
293
|
+
*
|
|
294
|
+
* @static
|
|
295
|
+
* @memberOf _
|
|
296
|
+
* @since 4.0.0
|
|
297
|
+
* @category Lang
|
|
298
|
+
* @param {*} value The value to check.
|
|
299
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
300
|
+
* @example
|
|
301
|
+
*
|
|
302
|
+
* _.isObjectLike({});
|
|
303
|
+
* // => true
|
|
304
|
+
*
|
|
305
|
+
* _.isObjectLike([1, 2, 3]);
|
|
306
|
+
* // => true
|
|
307
|
+
*
|
|
308
|
+
* _.isObjectLike(_.noop);
|
|
309
|
+
* // => false
|
|
310
|
+
*
|
|
311
|
+
* _.isObjectLike(null);
|
|
312
|
+
* // => false
|
|
313
|
+
*/
|
|
314
|
+
function isObjectLike(value) {
|
|
315
|
+
return !!value && typeof value == 'object';
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
320
|
+
*
|
|
321
|
+
* @static
|
|
322
|
+
* @memberOf _
|
|
323
|
+
* @since 4.0.0
|
|
324
|
+
* @category Lang
|
|
325
|
+
* @param {*} value The value to check.
|
|
326
|
+
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
327
|
+
* @example
|
|
328
|
+
*
|
|
329
|
+
* _.isSymbol(Symbol.iterator);
|
|
330
|
+
* // => true
|
|
331
|
+
*
|
|
332
|
+
* _.isSymbol('abc');
|
|
333
|
+
* // => false
|
|
334
|
+
*/
|
|
335
|
+
function isSymbol(value) {
|
|
336
|
+
return typeof value == 'symbol' ||
|
|
337
|
+
(isObjectLike(value) && objectToString.call(value) == symbolTag);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Converts `value` to a number.
|
|
342
|
+
*
|
|
343
|
+
* @static
|
|
344
|
+
* @memberOf _
|
|
345
|
+
* @since 4.0.0
|
|
346
|
+
* @category Lang
|
|
347
|
+
* @param {*} value The value to process.
|
|
348
|
+
* @returns {number} Returns the number.
|
|
349
|
+
* @example
|
|
350
|
+
*
|
|
351
|
+
* _.toNumber(3.2);
|
|
352
|
+
* // => 3.2
|
|
353
|
+
*
|
|
354
|
+
* _.toNumber(Number.MIN_VALUE);
|
|
355
|
+
* // => 5e-324
|
|
356
|
+
*
|
|
357
|
+
* _.toNumber(Infinity);
|
|
358
|
+
* // => Infinity
|
|
359
|
+
*
|
|
360
|
+
* _.toNumber('3.2');
|
|
361
|
+
* // => 3.2
|
|
362
|
+
*/
|
|
363
|
+
function toNumber(value) {
|
|
364
|
+
if (typeof value == 'number') {
|
|
365
|
+
return value;
|
|
366
|
+
}
|
|
367
|
+
if (isSymbol(value)) {
|
|
368
|
+
return NAN;
|
|
369
|
+
}
|
|
370
|
+
if (isObject(value)) {
|
|
371
|
+
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
|
|
372
|
+
value = isObject(other) ? (other + '') : other;
|
|
373
|
+
}
|
|
374
|
+
if (typeof value != 'string') {
|
|
375
|
+
return value === 0 ? value : +value;
|
|
376
|
+
}
|
|
377
|
+
value = value.replace(reTrim, '');
|
|
378
|
+
var isBinary = reIsBinary.test(value);
|
|
379
|
+
return (isBinary || reIsOctal.test(value))
|
|
380
|
+
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
|
|
381
|
+
: (reIsBadHex.test(value) ? NAN : +value);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
module.exports = debounce;
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
/***/ }),
|
|
388
|
+
|
|
389
|
+
/***/ 6750:
|
|
390
|
+
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
391
|
+
|
|
392
|
+
"use strict";
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
// A linked list to keep track of recently-used-ness
|
|
396
|
+
const Yallist = __webpack_require__(7350)
|
|
397
|
+
|
|
398
|
+
const MAX = Symbol('max')
|
|
399
|
+
const LENGTH = Symbol('length')
|
|
400
|
+
const LENGTH_CALCULATOR = Symbol('lengthCalculator')
|
|
401
|
+
const ALLOW_STALE = Symbol('allowStale')
|
|
402
|
+
const MAX_AGE = Symbol('maxAge')
|
|
403
|
+
const DISPOSE = Symbol('dispose')
|
|
404
|
+
const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet')
|
|
405
|
+
const LRU_LIST = Symbol('lruList')
|
|
406
|
+
const CACHE = Symbol('cache')
|
|
407
|
+
const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet')
|
|
408
|
+
|
|
409
|
+
const naiveLength = () => 1
|
|
410
|
+
|
|
411
|
+
// lruList is a yallist where the head is the youngest
|
|
412
|
+
// item, and the tail is the oldest. the list contains the Hit
|
|
413
|
+
// objects as the entries.
|
|
414
|
+
// Each Hit object has a reference to its Yallist.Node. This
|
|
415
|
+
// never changes.
|
|
416
|
+
//
|
|
417
|
+
// cache is a Map (or PseudoMap) that matches the keys to
|
|
418
|
+
// the Yallist.Node object.
|
|
419
|
+
class LRUCache {
|
|
420
|
+
constructor (options) {
|
|
421
|
+
if (typeof options === 'number')
|
|
422
|
+
options = { max: options }
|
|
423
|
+
|
|
424
|
+
if (!options)
|
|
425
|
+
options = {}
|
|
426
|
+
|
|
427
|
+
if (options.max && (typeof options.max !== 'number' || options.max < 0))
|
|
428
|
+
throw new TypeError('max must be a non-negative number')
|
|
429
|
+
// Kind of weird to have a default max of Infinity, but oh well.
|
|
430
|
+
const max = this[MAX] = options.max || Infinity
|
|
431
|
+
|
|
432
|
+
const lc = options.length || naiveLength
|
|
433
|
+
this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc
|
|
434
|
+
this[ALLOW_STALE] = options.stale || false
|
|
435
|
+
if (options.maxAge && typeof options.maxAge !== 'number')
|
|
436
|
+
throw new TypeError('maxAge must be a number')
|
|
437
|
+
this[MAX_AGE] = options.maxAge || 0
|
|
438
|
+
this[DISPOSE] = options.dispose
|
|
439
|
+
this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false
|
|
440
|
+
this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false
|
|
441
|
+
this.reset()
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// resize the cache when the max changes.
|
|
445
|
+
set max (mL) {
|
|
446
|
+
if (typeof mL !== 'number' || mL < 0)
|
|
447
|
+
throw new TypeError('max must be a non-negative number')
|
|
448
|
+
|
|
449
|
+
this[MAX] = mL || Infinity
|
|
450
|
+
trim(this)
|
|
451
|
+
}
|
|
452
|
+
get max () {
|
|
453
|
+
return this[MAX]
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
set allowStale (allowStale) {
|
|
457
|
+
this[ALLOW_STALE] = !!allowStale
|
|
458
|
+
}
|
|
459
|
+
get allowStale () {
|
|
460
|
+
return this[ALLOW_STALE]
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
set maxAge (mA) {
|
|
464
|
+
if (typeof mA !== 'number')
|
|
465
|
+
throw new TypeError('maxAge must be a non-negative number')
|
|
466
|
+
|
|
467
|
+
this[MAX_AGE] = mA
|
|
468
|
+
trim(this)
|
|
469
|
+
}
|
|
470
|
+
get maxAge () {
|
|
471
|
+
return this[MAX_AGE]
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// resize the cache when the lengthCalculator changes.
|
|
475
|
+
set lengthCalculator (lC) {
|
|
476
|
+
if (typeof lC !== 'function')
|
|
477
|
+
lC = naiveLength
|
|
478
|
+
|
|
479
|
+
if (lC !== this[LENGTH_CALCULATOR]) {
|
|
480
|
+
this[LENGTH_CALCULATOR] = lC
|
|
481
|
+
this[LENGTH] = 0
|
|
482
|
+
this[LRU_LIST].forEach(hit => {
|
|
483
|
+
hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key)
|
|
484
|
+
this[LENGTH] += hit.length
|
|
485
|
+
})
|
|
486
|
+
}
|
|
487
|
+
trim(this)
|
|
488
|
+
}
|
|
489
|
+
get lengthCalculator () { return this[LENGTH_CALCULATOR] }
|
|
490
|
+
|
|
491
|
+
get length () { return this[LENGTH] }
|
|
492
|
+
get itemCount () { return this[LRU_LIST].length }
|
|
493
|
+
|
|
494
|
+
rforEach (fn, thisp) {
|
|
495
|
+
thisp = thisp || this
|
|
496
|
+
for (let walker = this[LRU_LIST].tail; walker !== null;) {
|
|
497
|
+
const prev = walker.prev
|
|
498
|
+
forEachStep(this, fn, walker, thisp)
|
|
499
|
+
walker = prev
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
forEach (fn, thisp) {
|
|
504
|
+
thisp = thisp || this
|
|
505
|
+
for (let walker = this[LRU_LIST].head; walker !== null;) {
|
|
506
|
+
const next = walker.next
|
|
507
|
+
forEachStep(this, fn, walker, thisp)
|
|
508
|
+
walker = next
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
keys () {
|
|
513
|
+
return this[LRU_LIST].toArray().map(k => k.key)
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
values () {
|
|
517
|
+
return this[LRU_LIST].toArray().map(k => k.value)
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
reset () {
|
|
521
|
+
if (this[DISPOSE] &&
|
|
522
|
+
this[LRU_LIST] &&
|
|
523
|
+
this[LRU_LIST].length) {
|
|
524
|
+
this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value))
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
this[CACHE] = new Map() // hash of items by key
|
|
528
|
+
this[LRU_LIST] = new Yallist() // list of items in order of use recency
|
|
529
|
+
this[LENGTH] = 0 // length of items in the list
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
dump () {
|
|
533
|
+
return this[LRU_LIST].map(hit =>
|
|
534
|
+
isStale(this, hit) ? false : {
|
|
535
|
+
k: hit.key,
|
|
536
|
+
v: hit.value,
|
|
537
|
+
e: hit.now + (hit.maxAge || 0)
|
|
538
|
+
}).toArray().filter(h => h)
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
dumpLru () {
|
|
542
|
+
return this[LRU_LIST]
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
set (key, value, maxAge) {
|
|
546
|
+
maxAge = maxAge || this[MAX_AGE]
|
|
547
|
+
|
|
548
|
+
if (maxAge && typeof maxAge !== 'number')
|
|
549
|
+
throw new TypeError('maxAge must be a number')
|
|
550
|
+
|
|
551
|
+
const now = maxAge ? Date.now() : 0
|
|
552
|
+
const len = this[LENGTH_CALCULATOR](value, key)
|
|
553
|
+
|
|
554
|
+
if (this[CACHE].has(key)) {
|
|
555
|
+
if (len > this[MAX]) {
|
|
556
|
+
del(this, this[CACHE].get(key))
|
|
557
|
+
return false
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
const node = this[CACHE].get(key)
|
|
561
|
+
const item = node.value
|
|
562
|
+
|
|
563
|
+
// dispose of the old one before overwriting
|
|
564
|
+
// split out into 2 ifs for better coverage tracking
|
|
565
|
+
if (this[DISPOSE]) {
|
|
566
|
+
if (!this[NO_DISPOSE_ON_SET])
|
|
567
|
+
this[DISPOSE](key, item.value)
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
item.now = now
|
|
571
|
+
item.maxAge = maxAge
|
|
572
|
+
item.value = value
|
|
573
|
+
this[LENGTH] += len - item.length
|
|
574
|
+
item.length = len
|
|
575
|
+
this.get(key)
|
|
576
|
+
trim(this)
|
|
577
|
+
return true
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
const hit = new Entry(key, value, len, now, maxAge)
|
|
581
|
+
|
|
582
|
+
// oversized objects fall out of cache automatically.
|
|
583
|
+
if (hit.length > this[MAX]) {
|
|
584
|
+
if (this[DISPOSE])
|
|
585
|
+
this[DISPOSE](key, value)
|
|
586
|
+
|
|
587
|
+
return false
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
this[LENGTH] += hit.length
|
|
591
|
+
this[LRU_LIST].unshift(hit)
|
|
592
|
+
this[CACHE].set(key, this[LRU_LIST].head)
|
|
593
|
+
trim(this)
|
|
594
|
+
return true
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
has (key) {
|
|
598
|
+
if (!this[CACHE].has(key)) return false
|
|
599
|
+
const hit = this[CACHE].get(key).value
|
|
600
|
+
return !isStale(this, hit)
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
get (key) {
|
|
604
|
+
return get(this, key, true)
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
peek (key) {
|
|
608
|
+
return get(this, key, false)
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
pop () {
|
|
612
|
+
const node = this[LRU_LIST].tail
|
|
613
|
+
if (!node)
|
|
614
|
+
return null
|
|
615
|
+
|
|
616
|
+
del(this, node)
|
|
617
|
+
return node.value
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
del (key) {
|
|
621
|
+
del(this, this[CACHE].get(key))
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
load (arr) {
|
|
625
|
+
// reset the cache
|
|
626
|
+
this.reset()
|
|
627
|
+
|
|
628
|
+
const now = Date.now()
|
|
629
|
+
// A previous serialized cache has the most recent items first
|
|
630
|
+
for (let l = arr.length - 1; l >= 0; l--) {
|
|
631
|
+
const hit = arr[l]
|
|
632
|
+
const expiresAt = hit.e || 0
|
|
633
|
+
if (expiresAt === 0)
|
|
634
|
+
// the item was created without expiration in a non aged cache
|
|
635
|
+
this.set(hit.k, hit.v)
|
|
636
|
+
else {
|
|
637
|
+
const maxAge = expiresAt - now
|
|
638
|
+
// dont add already expired items
|
|
639
|
+
if (maxAge > 0) {
|
|
640
|
+
this.set(hit.k, hit.v, maxAge)
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
prune () {
|
|
647
|
+
this[CACHE].forEach((value, key) => get(this, key, false))
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
const get = (self, key, doUse) => {
|
|
652
|
+
const node = self[CACHE].get(key)
|
|
653
|
+
if (node) {
|
|
654
|
+
const hit = node.value
|
|
655
|
+
if (isStale(self, hit)) {
|
|
656
|
+
del(self, node)
|
|
657
|
+
if (!self[ALLOW_STALE])
|
|
658
|
+
return undefined
|
|
659
|
+
} else {
|
|
660
|
+
if (doUse) {
|
|
661
|
+
if (self[UPDATE_AGE_ON_GET])
|
|
662
|
+
node.value.now = Date.now()
|
|
663
|
+
self[LRU_LIST].unshiftNode(node)
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
return hit.value
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
const isStale = (self, hit) => {
|
|
671
|
+
if (!hit || (!hit.maxAge && !self[MAX_AGE]))
|
|
672
|
+
return false
|
|
673
|
+
|
|
674
|
+
const diff = Date.now() - hit.now
|
|
675
|
+
return hit.maxAge ? diff > hit.maxAge
|
|
676
|
+
: self[MAX_AGE] && (diff > self[MAX_AGE])
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
const trim = self => {
|
|
680
|
+
if (self[LENGTH] > self[MAX]) {
|
|
681
|
+
for (let walker = self[LRU_LIST].tail;
|
|
682
|
+
self[LENGTH] > self[MAX] && walker !== null;) {
|
|
683
|
+
// We know that we're about to delete this one, and also
|
|
684
|
+
// what the next least recently used key will be, so just
|
|
685
|
+
// go ahead and set it now.
|
|
686
|
+
const prev = walker.prev
|
|
687
|
+
del(self, walker)
|
|
688
|
+
walker = prev
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
const del = (self, node) => {
|
|
694
|
+
if (node) {
|
|
695
|
+
const hit = node.value
|
|
696
|
+
if (self[DISPOSE])
|
|
697
|
+
self[DISPOSE](hit.key, hit.value)
|
|
698
|
+
|
|
699
|
+
self[LENGTH] -= hit.length
|
|
700
|
+
self[CACHE].delete(hit.key)
|
|
701
|
+
self[LRU_LIST].removeNode(node)
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
class Entry {
|
|
706
|
+
constructor (key, value, length, now, maxAge) {
|
|
707
|
+
this.key = key
|
|
708
|
+
this.value = value
|
|
709
|
+
this.length = length
|
|
710
|
+
this.now = now
|
|
711
|
+
this.maxAge = maxAge || 0
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
const forEachStep = (self, fn, node, thisp) => {
|
|
716
|
+
let hit = node.value
|
|
717
|
+
if (isStale(self, hit)) {
|
|
718
|
+
del(self, node)
|
|
719
|
+
if (!self[ALLOW_STALE])
|
|
720
|
+
hit = undefined
|
|
721
|
+
}
|
|
722
|
+
if (hit)
|
|
723
|
+
fn.call(thisp, hit.value, hit.key, self)
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
module.exports = LRUCache
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
/***/ }),
|
|
730
|
+
|
|
731
|
+
/***/ 3167:
|
|
732
|
+
/***/ (function(module, exports) {
|
|
733
|
+
|
|
734
|
+
exports = module.exports = SemVer
|
|
735
|
+
|
|
736
|
+
var debug
|
|
737
|
+
/* istanbul ignore next */
|
|
738
|
+
if (typeof process === 'object' &&
|
|
739
|
+
process.env &&
|
|
740
|
+
process.env.NODE_DEBUG &&
|
|
741
|
+
/\bsemver\b/i.test(process.env.NODE_DEBUG)) {
|
|
742
|
+
debug = function () {
|
|
743
|
+
var args = Array.prototype.slice.call(arguments, 0)
|
|
744
|
+
args.unshift('SEMVER')
|
|
745
|
+
console.log.apply(console, args)
|
|
746
|
+
}
|
|
747
|
+
} else {
|
|
748
|
+
debug = function () {}
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// Note: this is the semver.org version of the spec that it implements
|
|
752
|
+
// Not necessarily the package version of this code.
|
|
753
|
+
exports.SEMVER_SPEC_VERSION = '2.0.0'
|
|
754
|
+
|
|
755
|
+
var MAX_LENGTH = 256
|
|
756
|
+
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
|
757
|
+
/* istanbul ignore next */ 9007199254740991
|
|
758
|
+
|
|
759
|
+
// Max safe segment length for coercion.
|
|
760
|
+
var MAX_SAFE_COMPONENT_LENGTH = 16
|
|
761
|
+
|
|
762
|
+
var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6
|
|
763
|
+
|
|
764
|
+
// The actual regexps go on exports.re
|
|
765
|
+
var re = exports.re = []
|
|
766
|
+
var safeRe = exports.safeRe = []
|
|
767
|
+
var src = exports.src = []
|
|
768
|
+
var t = exports.tokens = {}
|
|
769
|
+
var R = 0
|
|
770
|
+
|
|
771
|
+
function tok (n) {
|
|
772
|
+
t[n] = R++
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
var LETTERDASHNUMBER = '[a-zA-Z0-9-]'
|
|
776
|
+
|
|
777
|
+
// Replace some greedy regex tokens to prevent regex dos issues. These regex are
|
|
778
|
+
// used internally via the safeRe object since all inputs in this library get
|
|
779
|
+
// normalized first to trim and collapse all extra whitespace. The original
|
|
780
|
+
// regexes are exported for userland consumption and lower level usage. A
|
|
781
|
+
// future breaking change could export the safer regex only with a note that
|
|
782
|
+
// all input should have extra whitespace removed.
|
|
783
|
+
var safeRegexReplacements = [
|
|
784
|
+
['\\s', 1],
|
|
785
|
+
['\\d', MAX_LENGTH],
|
|
786
|
+
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
|
|
787
|
+
]
|
|
788
|
+
|
|
789
|
+
function makeSafeRe (value) {
|
|
790
|
+
for (var i = 0; i < safeRegexReplacements.length; i++) {
|
|
791
|
+
var token = safeRegexReplacements[i][0]
|
|
792
|
+
var max = safeRegexReplacements[i][1]
|
|
793
|
+
value = value
|
|
794
|
+
.split(token + '*').join(token + '{0,' + max + '}')
|
|
795
|
+
.split(token + '+').join(token + '{1,' + max + '}')
|
|
796
|
+
}
|
|
797
|
+
return value
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
// The following Regular Expressions can be used for tokenizing,
|
|
801
|
+
// validating, and parsing SemVer version strings.
|
|
802
|
+
|
|
803
|
+
// ## Numeric Identifier
|
|
804
|
+
// A single `0`, or a non-zero digit followed by zero or more digits.
|
|
805
|
+
|
|
806
|
+
tok('NUMERICIDENTIFIER')
|
|
807
|
+
src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*'
|
|
808
|
+
tok('NUMERICIDENTIFIERLOOSE')
|
|
809
|
+
src[t.NUMERICIDENTIFIERLOOSE] = '\\d+'
|
|
810
|
+
|
|
811
|
+
// ## Non-numeric Identifier
|
|
812
|
+
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
|
813
|
+
// more letters, digits, or hyphens.
|
|
814
|
+
|
|
815
|
+
tok('NONNUMERICIDENTIFIER')
|
|
816
|
+
src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-]' + LETTERDASHNUMBER + '*'
|
|
817
|
+
|
|
818
|
+
// ## Main Version
|
|
819
|
+
// Three dot-separated numeric identifiers.
|
|
820
|
+
|
|
821
|
+
tok('MAINVERSION')
|
|
822
|
+
src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
|
|
823
|
+
'(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
|
|
824
|
+
'(' + src[t.NUMERICIDENTIFIER] + ')'
|
|
825
|
+
|
|
826
|
+
tok('MAINVERSIONLOOSE')
|
|
827
|
+
src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
|
828
|
+
'(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
|
829
|
+
'(' + src[t.NUMERICIDENTIFIERLOOSE] + ')'
|
|
830
|
+
|
|
831
|
+
// ## Pre-release Version Identifier
|
|
832
|
+
// A numeric identifier, or a non-numeric identifier.
|
|
833
|
+
|
|
834
|
+
tok('PRERELEASEIDENTIFIER')
|
|
835
|
+
src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] +
|
|
836
|
+
'|' + src[t.NONNUMERICIDENTIFIER] + ')'
|
|
837
|
+
|
|
838
|
+
tok('PRERELEASEIDENTIFIERLOOSE')
|
|
839
|
+
src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] +
|
|
840
|
+
'|' + src[t.NONNUMERICIDENTIFIER] + ')'
|
|
841
|
+
|
|
842
|
+
// ## Pre-release Version
|
|
843
|
+
// Hyphen, followed by one or more dot-separated pre-release version
|
|
844
|
+
// identifiers.
|
|
845
|
+
|
|
846
|
+
tok('PRERELEASE')
|
|
847
|
+
src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] +
|
|
848
|
+
'(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))'
|
|
849
|
+
|
|
850
|
+
tok('PRERELEASELOOSE')
|
|
851
|
+
src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
|
|
852
|
+
'(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))'
|
|
853
|
+
|
|
854
|
+
// ## Build Metadata Identifier
|
|
855
|
+
// Any combination of digits, letters, or hyphens.
|
|
856
|
+
|
|
857
|
+
tok('BUILDIDENTIFIER')
|
|
858
|
+
src[t.BUILDIDENTIFIER] = LETTERDASHNUMBER + '+'
|
|
859
|
+
|
|
860
|
+
// ## Build Metadata
|
|
861
|
+
// Plus sign, followed by one or more period-separated build metadata
|
|
862
|
+
// identifiers.
|
|
863
|
+
|
|
864
|
+
tok('BUILD')
|
|
865
|
+
src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] +
|
|
866
|
+
'(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))'
|
|
867
|
+
|
|
868
|
+
// ## Full Version String
|
|
869
|
+
// A main version, followed optionally by a pre-release version and
|
|
870
|
+
// build metadata.
|
|
871
|
+
|
|
872
|
+
// Note that the only major, minor, patch, and pre-release sections of
|
|
873
|
+
// the version string are capturing groups. The build metadata is not a
|
|
874
|
+
// capturing group, because it should not ever be used in version
|
|
875
|
+
// comparison.
|
|
876
|
+
|
|
877
|
+
tok('FULL')
|
|
878
|
+
tok('FULLPLAIN')
|
|
879
|
+
src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] +
|
|
880
|
+
src[t.PRERELEASE] + '?' +
|
|
881
|
+
src[t.BUILD] + '?'
|
|
882
|
+
|
|
883
|
+
src[t.FULL] = '^' + src[t.FULLPLAIN] + '$'
|
|
884
|
+
|
|
885
|
+
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
|
886
|
+
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
|
887
|
+
// common in the npm registry.
|
|
888
|
+
tok('LOOSEPLAIN')
|
|
889
|
+
src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] +
|
|
890
|
+
src[t.PRERELEASELOOSE] + '?' +
|
|
891
|
+
src[t.BUILD] + '?'
|
|
892
|
+
|
|
893
|
+
tok('LOOSE')
|
|
894
|
+
src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$'
|
|
895
|
+
|
|
896
|
+
tok('GTLT')
|
|
897
|
+
src[t.GTLT] = '((?:<|>)?=?)'
|
|
898
|
+
|
|
899
|
+
// Something like "2.*" or "1.2.x".
|
|
900
|
+
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
|
901
|
+
// Only the first item is strictly required.
|
|
902
|
+
tok('XRANGEIDENTIFIERLOOSE')
|
|
903
|
+
src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*'
|
|
904
|
+
tok('XRANGEIDENTIFIER')
|
|
905
|
+
src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*'
|
|
906
|
+
|
|
907
|
+
tok('XRANGEPLAIN')
|
|
908
|
+
src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' +
|
|
909
|
+
'(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
|
|
910
|
+
'(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
|
|
911
|
+
'(?:' + src[t.PRERELEASE] + ')?' +
|
|
912
|
+
src[t.BUILD] + '?' +
|
|
913
|
+
')?)?'
|
|
914
|
+
|
|
915
|
+
tok('XRANGEPLAINLOOSE')
|
|
916
|
+
src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
|
|
917
|
+
'(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
|
|
918
|
+
'(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
|
|
919
|
+
'(?:' + src[t.PRERELEASELOOSE] + ')?' +
|
|
920
|
+
src[t.BUILD] + '?' +
|
|
921
|
+
')?)?'
|
|
922
|
+
|
|
923
|
+
tok('XRANGE')
|
|
924
|
+
src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$'
|
|
925
|
+
tok('XRANGELOOSE')
|
|
926
|
+
src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$'
|
|
927
|
+
|
|
928
|
+
// Coercion.
|
|
929
|
+
// Extract anything that could conceivably be a part of a valid semver
|
|
930
|
+
tok('COERCE')
|
|
931
|
+
src[t.COERCE] = '(^|[^\\d])' +
|
|
932
|
+
'(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
|
|
933
|
+
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
|
|
934
|
+
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
|
|
935
|
+
'(?:$|[^\\d])'
|
|
936
|
+
tok('COERCERTL')
|
|
937
|
+
re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g')
|
|
938
|
+
safeRe[t.COERCERTL] = new RegExp(makeSafeRe(src[t.COERCE]), 'g')
|
|
939
|
+
|
|
940
|
+
// Tilde ranges.
|
|
941
|
+
// Meaning is "reasonably at or greater than"
|
|
942
|
+
tok('LONETILDE')
|
|
943
|
+
src[t.LONETILDE] = '(?:~>?)'
|
|
944
|
+
|
|
945
|
+
tok('TILDETRIM')
|
|
946
|
+
src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+'
|
|
947
|
+
re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g')
|
|
948
|
+
safeRe[t.TILDETRIM] = new RegExp(makeSafeRe(src[t.TILDETRIM]), 'g')
|
|
949
|
+
var tildeTrimReplace = '$1~'
|
|
950
|
+
|
|
951
|
+
tok('TILDE')
|
|
952
|
+
src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$'
|
|
953
|
+
tok('TILDELOOSE')
|
|
954
|
+
src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$'
|
|
955
|
+
|
|
956
|
+
// Caret ranges.
|
|
957
|
+
// Meaning is "at least and backwards compatible with"
|
|
958
|
+
tok('LONECARET')
|
|
959
|
+
src[t.LONECARET] = '(?:\\^)'
|
|
960
|
+
|
|
961
|
+
tok('CARETTRIM')
|
|
962
|
+
src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+'
|
|
963
|
+
re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g')
|
|
964
|
+
safeRe[t.CARETTRIM] = new RegExp(makeSafeRe(src[t.CARETTRIM]), 'g')
|
|
965
|
+
var caretTrimReplace = '$1^'
|
|
966
|
+
|
|
967
|
+
tok('CARET')
|
|
968
|
+
src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$'
|
|
969
|
+
tok('CARETLOOSE')
|
|
970
|
+
src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$'
|
|
971
|
+
|
|
972
|
+
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
|
973
|
+
tok('COMPARATORLOOSE')
|
|
974
|
+
src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$'
|
|
975
|
+
tok('COMPARATOR')
|
|
976
|
+
src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$'
|
|
977
|
+
|
|
978
|
+
// An expression to strip any whitespace between the gtlt and the thing
|
|
979
|
+
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
|
980
|
+
tok('COMPARATORTRIM')
|
|
981
|
+
src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
|
|
982
|
+
'\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')'
|
|
983
|
+
|
|
984
|
+
// this one has to use the /g flag
|
|
985
|
+
re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g')
|
|
986
|
+
safeRe[t.COMPARATORTRIM] = new RegExp(makeSafeRe(src[t.COMPARATORTRIM]), 'g')
|
|
987
|
+
var comparatorTrimReplace = '$1$2$3'
|
|
988
|
+
|
|
989
|
+
// Something like `1.2.3 - 1.2.4`
|
|
990
|
+
// Note that these all use the loose form, because they'll be
|
|
991
|
+
// checked against either the strict or loose comparator form
|
|
992
|
+
// later.
|
|
993
|
+
tok('HYPHENRANGE')
|
|
994
|
+
src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' +
|
|
995
|
+
'\\s+-\\s+' +
|
|
996
|
+
'(' + src[t.XRANGEPLAIN] + ')' +
|
|
997
|
+
'\\s*$'
|
|
998
|
+
|
|
999
|
+
tok('HYPHENRANGELOOSE')
|
|
1000
|
+
src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' +
|
|
1001
|
+
'\\s+-\\s+' +
|
|
1002
|
+
'(' + src[t.XRANGEPLAINLOOSE] + ')' +
|
|
1003
|
+
'\\s*$'
|
|
1004
|
+
|
|
1005
|
+
// Star ranges basically just allow anything at all.
|
|
1006
|
+
tok('STAR')
|
|
1007
|
+
src[t.STAR] = '(<|>)?=?\\s*\\*'
|
|
1008
|
+
|
|
1009
|
+
// Compile to actual regexp objects.
|
|
1010
|
+
// All are flag-free, unless they were created above with a flag.
|
|
1011
|
+
for (var i = 0; i < R; i++) {
|
|
1012
|
+
debug(i, src[i])
|
|
1013
|
+
if (!re[i]) {
|
|
1014
|
+
re[i] = new RegExp(src[i])
|
|
1015
|
+
|
|
1016
|
+
// Replace all greedy whitespace to prevent regex dos issues. These regex are
|
|
1017
|
+
// used internally via the safeRe object since all inputs in this library get
|
|
1018
|
+
// normalized first to trim and collapse all extra whitespace. The original
|
|
1019
|
+
// regexes are exported for userland consumption and lower level usage. A
|
|
1020
|
+
// future breaking change could export the safer regex only with a note that
|
|
1021
|
+
// all input should have extra whitespace removed.
|
|
1022
|
+
safeRe[i] = new RegExp(makeSafeRe(src[i]))
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
exports.parse = parse
|
|
1027
|
+
function parse (version, options) {
|
|
1028
|
+
if (!options || typeof options !== 'object') {
|
|
1029
|
+
options = {
|
|
1030
|
+
loose: !!options,
|
|
1031
|
+
includePrerelease: false
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
if (version instanceof SemVer) {
|
|
1036
|
+
return version
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
if (typeof version !== 'string') {
|
|
1040
|
+
return null
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
if (version.length > MAX_LENGTH) {
|
|
1044
|
+
return null
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
var r = options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL]
|
|
1048
|
+
if (!r.test(version)) {
|
|
1049
|
+
return null
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
try {
|
|
1053
|
+
return new SemVer(version, options)
|
|
1054
|
+
} catch (er) {
|
|
1055
|
+
return null
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
exports.valid = valid
|
|
1060
|
+
function valid (version, options) {
|
|
1061
|
+
var v = parse(version, options)
|
|
1062
|
+
return v ? v.version : null
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
exports.clean = clean
|
|
1066
|
+
function clean (version, options) {
|
|
1067
|
+
var s = parse(version.trim().replace(/^[=v]+/, ''), options)
|
|
1068
|
+
return s ? s.version : null
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
exports.SemVer = SemVer
|
|
1072
|
+
|
|
1073
|
+
function SemVer (version, options) {
|
|
1074
|
+
if (!options || typeof options !== 'object') {
|
|
1075
|
+
options = {
|
|
1076
|
+
loose: !!options,
|
|
1077
|
+
includePrerelease: false
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
if (version instanceof SemVer) {
|
|
1081
|
+
if (version.loose === options.loose) {
|
|
1082
|
+
return version
|
|
1083
|
+
} else {
|
|
1084
|
+
version = version.version
|
|
1085
|
+
}
|
|
1086
|
+
} else if (typeof version !== 'string') {
|
|
1087
|
+
throw new TypeError('Invalid Version: ' + version)
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
if (version.length > MAX_LENGTH) {
|
|
1091
|
+
throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
if (!(this instanceof SemVer)) {
|
|
1095
|
+
return new SemVer(version, options)
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
debug('SemVer', version, options)
|
|
1099
|
+
this.options = options
|
|
1100
|
+
this.loose = !!options.loose
|
|
1101
|
+
|
|
1102
|
+
var m = version.trim().match(options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL])
|
|
1103
|
+
|
|
1104
|
+
if (!m) {
|
|
1105
|
+
throw new TypeError('Invalid Version: ' + version)
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
this.raw = version
|
|
1109
|
+
|
|
1110
|
+
// these are actually numbers
|
|
1111
|
+
this.major = +m[1]
|
|
1112
|
+
this.minor = +m[2]
|
|
1113
|
+
this.patch = +m[3]
|
|
1114
|
+
|
|
1115
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
1116
|
+
throw new TypeError('Invalid major version')
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
1120
|
+
throw new TypeError('Invalid minor version')
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
1124
|
+
throw new TypeError('Invalid patch version')
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
// numberify any prerelease numeric ids
|
|
1128
|
+
if (!m[4]) {
|
|
1129
|
+
this.prerelease = []
|
|
1130
|
+
} else {
|
|
1131
|
+
this.prerelease = m[4].split('.').map(function (id) {
|
|
1132
|
+
if (/^[0-9]+$/.test(id)) {
|
|
1133
|
+
var num = +id
|
|
1134
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
1135
|
+
return num
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
return id
|
|
1139
|
+
})
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
this.build = m[5] ? m[5].split('.') : []
|
|
1143
|
+
this.format()
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
SemVer.prototype.format = function () {
|
|
1147
|
+
this.version = this.major + '.' + this.minor + '.' + this.patch
|
|
1148
|
+
if (this.prerelease.length) {
|
|
1149
|
+
this.version += '-' + this.prerelease.join('.')
|
|
1150
|
+
}
|
|
1151
|
+
return this.version
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
SemVer.prototype.toString = function () {
|
|
1155
|
+
return this.version
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
SemVer.prototype.compare = function (other) {
|
|
1159
|
+
debug('SemVer.compare', this.version, this.options, other)
|
|
1160
|
+
if (!(other instanceof SemVer)) {
|
|
1161
|
+
other = new SemVer(other, this.options)
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
return this.compareMain(other) || this.comparePre(other)
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
SemVer.prototype.compareMain = function (other) {
|
|
1168
|
+
if (!(other instanceof SemVer)) {
|
|
1169
|
+
other = new SemVer(other, this.options)
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
return compareIdentifiers(this.major, other.major) ||
|
|
1173
|
+
compareIdentifiers(this.minor, other.minor) ||
|
|
1174
|
+
compareIdentifiers(this.patch, other.patch)
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
SemVer.prototype.comparePre = function (other) {
|
|
1178
|
+
if (!(other instanceof SemVer)) {
|
|
1179
|
+
other = new SemVer(other, this.options)
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
// NOT having a prerelease is > having one
|
|
1183
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
|
1184
|
+
return -1
|
|
1185
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
1186
|
+
return 1
|
|
1187
|
+
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
1188
|
+
return 0
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
var i = 0
|
|
1192
|
+
do {
|
|
1193
|
+
var a = this.prerelease[i]
|
|
1194
|
+
var b = other.prerelease[i]
|
|
1195
|
+
debug('prerelease compare', i, a, b)
|
|
1196
|
+
if (a === undefined && b === undefined) {
|
|
1197
|
+
return 0
|
|
1198
|
+
} else if (b === undefined) {
|
|
1199
|
+
return 1
|
|
1200
|
+
} else if (a === undefined) {
|
|
1201
|
+
return -1
|
|
1202
|
+
} else if (a === b) {
|
|
1203
|
+
continue
|
|
1204
|
+
} else {
|
|
1205
|
+
return compareIdentifiers(a, b)
|
|
1206
|
+
}
|
|
1207
|
+
} while (++i)
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
SemVer.prototype.compareBuild = function (other) {
|
|
1211
|
+
if (!(other instanceof SemVer)) {
|
|
1212
|
+
other = new SemVer(other, this.options)
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
var i = 0
|
|
1216
|
+
do {
|
|
1217
|
+
var a = this.build[i]
|
|
1218
|
+
var b = other.build[i]
|
|
1219
|
+
debug('prerelease compare', i, a, b)
|
|
1220
|
+
if (a === undefined && b === undefined) {
|
|
1221
|
+
return 0
|
|
1222
|
+
} else if (b === undefined) {
|
|
1223
|
+
return 1
|
|
1224
|
+
} else if (a === undefined) {
|
|
1225
|
+
return -1
|
|
1226
|
+
} else if (a === b) {
|
|
1227
|
+
continue
|
|
1228
|
+
} else {
|
|
1229
|
+
return compareIdentifiers(a, b)
|
|
1230
|
+
}
|
|
1231
|
+
} while (++i)
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
// preminor will bump the version up to the next minor release, and immediately
|
|
1235
|
+
// down to pre-release. premajor and prepatch work the same way.
|
|
1236
|
+
SemVer.prototype.inc = function (release, identifier) {
|
|
1237
|
+
switch (release) {
|
|
1238
|
+
case 'premajor':
|
|
1239
|
+
this.prerelease.length = 0
|
|
1240
|
+
this.patch = 0
|
|
1241
|
+
this.minor = 0
|
|
1242
|
+
this.major++
|
|
1243
|
+
this.inc('pre', identifier)
|
|
1244
|
+
break
|
|
1245
|
+
case 'preminor':
|
|
1246
|
+
this.prerelease.length = 0
|
|
1247
|
+
this.patch = 0
|
|
1248
|
+
this.minor++
|
|
1249
|
+
this.inc('pre', identifier)
|
|
1250
|
+
break
|
|
1251
|
+
case 'prepatch':
|
|
1252
|
+
// If this is already a prerelease, it will bump to the next version
|
|
1253
|
+
// drop any prereleases that might already exist, since they are not
|
|
1254
|
+
// relevant at this point.
|
|
1255
|
+
this.prerelease.length = 0
|
|
1256
|
+
this.inc('patch', identifier)
|
|
1257
|
+
this.inc('pre', identifier)
|
|
1258
|
+
break
|
|
1259
|
+
// If the input is a non-prerelease version, this acts the same as
|
|
1260
|
+
// prepatch.
|
|
1261
|
+
case 'prerelease':
|
|
1262
|
+
if (this.prerelease.length === 0) {
|
|
1263
|
+
this.inc('patch', identifier)
|
|
1264
|
+
}
|
|
1265
|
+
this.inc('pre', identifier)
|
|
1266
|
+
break
|
|
1267
|
+
|
|
1268
|
+
case 'major':
|
|
1269
|
+
// If this is a pre-major version, bump up to the same major version.
|
|
1270
|
+
// Otherwise increment major.
|
|
1271
|
+
// 1.0.0-5 bumps to 1.0.0
|
|
1272
|
+
// 1.1.0 bumps to 2.0.0
|
|
1273
|
+
if (this.minor !== 0 ||
|
|
1274
|
+
this.patch !== 0 ||
|
|
1275
|
+
this.prerelease.length === 0) {
|
|
1276
|
+
this.major++
|
|
1277
|
+
}
|
|
1278
|
+
this.minor = 0
|
|
1279
|
+
this.patch = 0
|
|
1280
|
+
this.prerelease = []
|
|
1281
|
+
break
|
|
1282
|
+
case 'minor':
|
|
1283
|
+
// If this is a pre-minor version, bump up to the same minor version.
|
|
1284
|
+
// Otherwise increment minor.
|
|
1285
|
+
// 1.2.0-5 bumps to 1.2.0
|
|
1286
|
+
// 1.2.1 bumps to 1.3.0
|
|
1287
|
+
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
1288
|
+
this.minor++
|
|
1289
|
+
}
|
|
1290
|
+
this.patch = 0
|
|
1291
|
+
this.prerelease = []
|
|
1292
|
+
break
|
|
1293
|
+
case 'patch':
|
|
1294
|
+
// If this is not a pre-release version, it will increment the patch.
|
|
1295
|
+
// If it is a pre-release it will bump up to the same patch version.
|
|
1296
|
+
// 1.2.0-5 patches to 1.2.0
|
|
1297
|
+
// 1.2.0 patches to 1.2.1
|
|
1298
|
+
if (this.prerelease.length === 0) {
|
|
1299
|
+
this.patch++
|
|
1300
|
+
}
|
|
1301
|
+
this.prerelease = []
|
|
1302
|
+
break
|
|
1303
|
+
// This probably shouldn't be used publicly.
|
|
1304
|
+
// 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
|
|
1305
|
+
case 'pre':
|
|
1306
|
+
if (this.prerelease.length === 0) {
|
|
1307
|
+
this.prerelease = [0]
|
|
1308
|
+
} else {
|
|
1309
|
+
var i = this.prerelease.length
|
|
1310
|
+
while (--i >= 0) {
|
|
1311
|
+
if (typeof this.prerelease[i] === 'number') {
|
|
1312
|
+
this.prerelease[i]++
|
|
1313
|
+
i = -2
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
if (i === -1) {
|
|
1317
|
+
// didn't increment anything
|
|
1318
|
+
this.prerelease.push(0)
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
if (identifier) {
|
|
1322
|
+
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
|
1323
|
+
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
|
1324
|
+
if (this.prerelease[0] === identifier) {
|
|
1325
|
+
if (isNaN(this.prerelease[1])) {
|
|
1326
|
+
this.prerelease = [identifier, 0]
|
|
1327
|
+
}
|
|
1328
|
+
} else {
|
|
1329
|
+
this.prerelease = [identifier, 0]
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
break
|
|
1333
|
+
|
|
1334
|
+
default:
|
|
1335
|
+
throw new Error('invalid increment argument: ' + release)
|
|
1336
|
+
}
|
|
1337
|
+
this.format()
|
|
1338
|
+
this.raw = this.version
|
|
1339
|
+
return this
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
exports.inc = inc
|
|
1343
|
+
function inc (version, release, loose, identifier) {
|
|
1344
|
+
if (typeof (loose) === 'string') {
|
|
1345
|
+
identifier = loose
|
|
1346
|
+
loose = undefined
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
try {
|
|
1350
|
+
return new SemVer(version, loose).inc(release, identifier).version
|
|
1351
|
+
} catch (er) {
|
|
1352
|
+
return null
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
exports.diff = diff
|
|
1357
|
+
function diff (version1, version2) {
|
|
1358
|
+
if (eq(version1, version2)) {
|
|
1359
|
+
return null
|
|
1360
|
+
} else {
|
|
1361
|
+
var v1 = parse(version1)
|
|
1362
|
+
var v2 = parse(version2)
|
|
1363
|
+
var prefix = ''
|
|
1364
|
+
if (v1.prerelease.length || v2.prerelease.length) {
|
|
1365
|
+
prefix = 'pre'
|
|
1366
|
+
var defaultResult = 'prerelease'
|
|
1367
|
+
}
|
|
1368
|
+
for (var key in v1) {
|
|
1369
|
+
if (key === 'major' || key === 'minor' || key === 'patch') {
|
|
1370
|
+
if (v1[key] !== v2[key]) {
|
|
1371
|
+
return prefix + key
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
return defaultResult // may be undefined
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
exports.compareIdentifiers = compareIdentifiers
|
|
1380
|
+
|
|
1381
|
+
var numeric = /^[0-9]+$/
|
|
1382
|
+
function compareIdentifiers (a, b) {
|
|
1383
|
+
var anum = numeric.test(a)
|
|
1384
|
+
var bnum = numeric.test(b)
|
|
1385
|
+
|
|
1386
|
+
if (anum && bnum) {
|
|
1387
|
+
a = +a
|
|
1388
|
+
b = +b
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
return a === b ? 0
|
|
1392
|
+
: (anum && !bnum) ? -1
|
|
1393
|
+
: (bnum && !anum) ? 1
|
|
1394
|
+
: a < b ? -1
|
|
1395
|
+
: 1
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
exports.rcompareIdentifiers = rcompareIdentifiers
|
|
1399
|
+
function rcompareIdentifiers (a, b) {
|
|
1400
|
+
return compareIdentifiers(b, a)
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
exports.major = major
|
|
1404
|
+
function major (a, loose) {
|
|
1405
|
+
return new SemVer(a, loose).major
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
exports.minor = minor
|
|
1409
|
+
function minor (a, loose) {
|
|
1410
|
+
return new SemVer(a, loose).minor
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
exports.patch = patch
|
|
1414
|
+
function patch (a, loose) {
|
|
1415
|
+
return new SemVer(a, loose).patch
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
exports.compare = compare
|
|
1419
|
+
function compare (a, b, loose) {
|
|
1420
|
+
return new SemVer(a, loose).compare(new SemVer(b, loose))
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
exports.compareLoose = compareLoose
|
|
1424
|
+
function compareLoose (a, b) {
|
|
1425
|
+
return compare(a, b, true)
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
exports.compareBuild = compareBuild
|
|
1429
|
+
function compareBuild (a, b, loose) {
|
|
1430
|
+
var versionA = new SemVer(a, loose)
|
|
1431
|
+
var versionB = new SemVer(b, loose)
|
|
1432
|
+
return versionA.compare(versionB) || versionA.compareBuild(versionB)
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
exports.rcompare = rcompare
|
|
1436
|
+
function rcompare (a, b, loose) {
|
|
1437
|
+
return compare(b, a, loose)
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
exports.sort = sort
|
|
1441
|
+
function sort (list, loose) {
|
|
1442
|
+
return list.sort(function (a, b) {
|
|
1443
|
+
return exports.compareBuild(a, b, loose)
|
|
1444
|
+
})
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
exports.rsort = rsort
|
|
1448
|
+
function rsort (list, loose) {
|
|
1449
|
+
return list.sort(function (a, b) {
|
|
1450
|
+
return exports.compareBuild(b, a, loose)
|
|
1451
|
+
})
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
exports.gt = gt
|
|
1455
|
+
function gt (a, b, loose) {
|
|
1456
|
+
return compare(a, b, loose) > 0
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
exports.lt = lt
|
|
1460
|
+
function lt (a, b, loose) {
|
|
1461
|
+
return compare(a, b, loose) < 0
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
exports.eq = eq
|
|
1465
|
+
function eq (a, b, loose) {
|
|
1466
|
+
return compare(a, b, loose) === 0
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
exports.neq = neq
|
|
1470
|
+
function neq (a, b, loose) {
|
|
1471
|
+
return compare(a, b, loose) !== 0
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
exports.gte = gte
|
|
1475
|
+
function gte (a, b, loose) {
|
|
1476
|
+
return compare(a, b, loose) >= 0
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
exports.lte = lte
|
|
1480
|
+
function lte (a, b, loose) {
|
|
1481
|
+
return compare(a, b, loose) <= 0
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
exports.cmp = cmp
|
|
1485
|
+
function cmp (a, op, b, loose) {
|
|
1486
|
+
switch (op) {
|
|
1487
|
+
case '===':
|
|
1488
|
+
if (typeof a === 'object')
|
|
1489
|
+
a = a.version
|
|
1490
|
+
if (typeof b === 'object')
|
|
1491
|
+
b = b.version
|
|
1492
|
+
return a === b
|
|
1493
|
+
|
|
1494
|
+
case '!==':
|
|
1495
|
+
if (typeof a === 'object')
|
|
1496
|
+
a = a.version
|
|
1497
|
+
if (typeof b === 'object')
|
|
1498
|
+
b = b.version
|
|
1499
|
+
return a !== b
|
|
1500
|
+
|
|
1501
|
+
case '':
|
|
1502
|
+
case '=':
|
|
1503
|
+
case '==':
|
|
1504
|
+
return eq(a, b, loose)
|
|
1505
|
+
|
|
1506
|
+
case '!=':
|
|
1507
|
+
return neq(a, b, loose)
|
|
1508
|
+
|
|
1509
|
+
case '>':
|
|
1510
|
+
return gt(a, b, loose)
|
|
1511
|
+
|
|
1512
|
+
case '>=':
|
|
1513
|
+
return gte(a, b, loose)
|
|
1514
|
+
|
|
1515
|
+
case '<':
|
|
1516
|
+
return lt(a, b, loose)
|
|
1517
|
+
|
|
1518
|
+
case '<=':
|
|
1519
|
+
return lte(a, b, loose)
|
|
1520
|
+
|
|
1521
|
+
default:
|
|
1522
|
+
throw new TypeError('Invalid operator: ' + op)
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
exports.Comparator = Comparator
|
|
1527
|
+
function Comparator (comp, options) {
|
|
1528
|
+
if (!options || typeof options !== 'object') {
|
|
1529
|
+
options = {
|
|
1530
|
+
loose: !!options,
|
|
1531
|
+
includePrerelease: false
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
if (comp instanceof Comparator) {
|
|
1536
|
+
if (comp.loose === !!options.loose) {
|
|
1537
|
+
return comp
|
|
1538
|
+
} else {
|
|
1539
|
+
comp = comp.value
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
if (!(this instanceof Comparator)) {
|
|
1544
|
+
return new Comparator(comp, options)
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
comp = comp.trim().split(/\s+/).join(' ')
|
|
1548
|
+
debug('comparator', comp, options)
|
|
1549
|
+
this.options = options
|
|
1550
|
+
this.loose = !!options.loose
|
|
1551
|
+
this.parse(comp)
|
|
1552
|
+
|
|
1553
|
+
if (this.semver === ANY) {
|
|
1554
|
+
this.value = ''
|
|
1555
|
+
} else {
|
|
1556
|
+
this.value = this.operator + this.semver.version
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
debug('comp', this)
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
var ANY = {}
|
|
1563
|
+
Comparator.prototype.parse = function (comp) {
|
|
1564
|
+
var r = this.options.loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR]
|
|
1565
|
+
var m = comp.match(r)
|
|
1566
|
+
|
|
1567
|
+
if (!m) {
|
|
1568
|
+
throw new TypeError('Invalid comparator: ' + comp)
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
this.operator = m[1] !== undefined ? m[1] : ''
|
|
1572
|
+
if (this.operator === '=') {
|
|
1573
|
+
this.operator = ''
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
// if it literally is just '>' or '' then allow anything.
|
|
1577
|
+
if (!m[2]) {
|
|
1578
|
+
this.semver = ANY
|
|
1579
|
+
} else {
|
|
1580
|
+
this.semver = new SemVer(m[2], this.options.loose)
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
Comparator.prototype.toString = function () {
|
|
1585
|
+
return this.value
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
Comparator.prototype.test = function (version) {
|
|
1589
|
+
debug('Comparator.test', version, this.options.loose)
|
|
1590
|
+
|
|
1591
|
+
if (this.semver === ANY || version === ANY) {
|
|
1592
|
+
return true
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
if (typeof version === 'string') {
|
|
1596
|
+
try {
|
|
1597
|
+
version = new SemVer(version, this.options)
|
|
1598
|
+
} catch (er) {
|
|
1599
|
+
return false
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
return cmp(version, this.operator, this.semver, this.options)
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
Comparator.prototype.intersects = function (comp, options) {
|
|
1607
|
+
if (!(comp instanceof Comparator)) {
|
|
1608
|
+
throw new TypeError('a Comparator is required')
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
if (!options || typeof options !== 'object') {
|
|
1612
|
+
options = {
|
|
1613
|
+
loose: !!options,
|
|
1614
|
+
includePrerelease: false
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
var rangeTmp
|
|
1619
|
+
|
|
1620
|
+
if (this.operator === '') {
|
|
1621
|
+
if (this.value === '') {
|
|
1622
|
+
return true
|
|
1623
|
+
}
|
|
1624
|
+
rangeTmp = new Range(comp.value, options)
|
|
1625
|
+
return satisfies(this.value, rangeTmp, options)
|
|
1626
|
+
} else if (comp.operator === '') {
|
|
1627
|
+
if (comp.value === '') {
|
|
1628
|
+
return true
|
|
1629
|
+
}
|
|
1630
|
+
rangeTmp = new Range(this.value, options)
|
|
1631
|
+
return satisfies(comp.semver, rangeTmp, options)
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
var sameDirectionIncreasing =
|
|
1635
|
+
(this.operator === '>=' || this.operator === '>') &&
|
|
1636
|
+
(comp.operator === '>=' || comp.operator === '>')
|
|
1637
|
+
var sameDirectionDecreasing =
|
|
1638
|
+
(this.operator === '<=' || this.operator === '<') &&
|
|
1639
|
+
(comp.operator === '<=' || comp.operator === '<')
|
|
1640
|
+
var sameSemVer = this.semver.version === comp.semver.version
|
|
1641
|
+
var differentDirectionsInclusive =
|
|
1642
|
+
(this.operator === '>=' || this.operator === '<=') &&
|
|
1643
|
+
(comp.operator === '>=' || comp.operator === '<=')
|
|
1644
|
+
var oppositeDirectionsLessThan =
|
|
1645
|
+
cmp(this.semver, '<', comp.semver, options) &&
|
|
1646
|
+
((this.operator === '>=' || this.operator === '>') &&
|
|
1647
|
+
(comp.operator === '<=' || comp.operator === '<'))
|
|
1648
|
+
var oppositeDirectionsGreaterThan =
|
|
1649
|
+
cmp(this.semver, '>', comp.semver, options) &&
|
|
1650
|
+
((this.operator === '<=' || this.operator === '<') &&
|
|
1651
|
+
(comp.operator === '>=' || comp.operator === '>'))
|
|
1652
|
+
|
|
1653
|
+
return sameDirectionIncreasing || sameDirectionDecreasing ||
|
|
1654
|
+
(sameSemVer && differentDirectionsInclusive) ||
|
|
1655
|
+
oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
exports.Range = Range
|
|
1659
|
+
function Range (range, options) {
|
|
1660
|
+
if (!options || typeof options !== 'object') {
|
|
1661
|
+
options = {
|
|
1662
|
+
loose: !!options,
|
|
1663
|
+
includePrerelease: false
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
if (range instanceof Range) {
|
|
1668
|
+
if (range.loose === !!options.loose &&
|
|
1669
|
+
range.includePrerelease === !!options.includePrerelease) {
|
|
1670
|
+
return range
|
|
1671
|
+
} else {
|
|
1672
|
+
return new Range(range.raw, options)
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
if (range instanceof Comparator) {
|
|
1677
|
+
return new Range(range.value, options)
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
if (!(this instanceof Range)) {
|
|
1681
|
+
return new Range(range, options)
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
this.options = options
|
|
1685
|
+
this.loose = !!options.loose
|
|
1686
|
+
this.includePrerelease = !!options.includePrerelease
|
|
1687
|
+
|
|
1688
|
+
// First reduce all whitespace as much as possible so we do not have to rely
|
|
1689
|
+
// on potentially slow regexes like \s*. This is then stored and used for
|
|
1690
|
+
// future error messages as well.
|
|
1691
|
+
this.raw = range
|
|
1692
|
+
.trim()
|
|
1693
|
+
.split(/\s+/)
|
|
1694
|
+
.join(' ')
|
|
1695
|
+
|
|
1696
|
+
// First, split based on boolean or ||
|
|
1697
|
+
this.set = this.raw.split('||').map(function (range) {
|
|
1698
|
+
return this.parseRange(range.trim())
|
|
1699
|
+
}, this).filter(function (c) {
|
|
1700
|
+
// throw out any that are not relevant for whatever reason
|
|
1701
|
+
return c.length
|
|
1702
|
+
})
|
|
1703
|
+
|
|
1704
|
+
if (!this.set.length) {
|
|
1705
|
+
throw new TypeError('Invalid SemVer Range: ' + this.raw)
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
this.format()
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
Range.prototype.format = function () {
|
|
1712
|
+
this.range = this.set.map(function (comps) {
|
|
1713
|
+
return comps.join(' ').trim()
|
|
1714
|
+
}).join('||').trim()
|
|
1715
|
+
return this.range
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
Range.prototype.toString = function () {
|
|
1719
|
+
return this.range
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
Range.prototype.parseRange = function (range) {
|
|
1723
|
+
var loose = this.options.loose
|
|
1724
|
+
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
|
1725
|
+
var hr = loose ? safeRe[t.HYPHENRANGELOOSE] : safeRe[t.HYPHENRANGE]
|
|
1726
|
+
range = range.replace(hr, hyphenReplace)
|
|
1727
|
+
debug('hyphen replace', range)
|
|
1728
|
+
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
|
1729
|
+
range = range.replace(safeRe[t.COMPARATORTRIM], comparatorTrimReplace)
|
|
1730
|
+
debug('comparator trim', range, safeRe[t.COMPARATORTRIM])
|
|
1731
|
+
|
|
1732
|
+
// `~ 1.2.3` => `~1.2.3`
|
|
1733
|
+
range = range.replace(safeRe[t.TILDETRIM], tildeTrimReplace)
|
|
1734
|
+
|
|
1735
|
+
// `^ 1.2.3` => `^1.2.3`
|
|
1736
|
+
range = range.replace(safeRe[t.CARETTRIM], caretTrimReplace)
|
|
1737
|
+
|
|
1738
|
+
// normalize spaces
|
|
1739
|
+
range = range.split(/\s+/).join(' ')
|
|
1740
|
+
|
|
1741
|
+
// At this point, the range is completely trimmed and
|
|
1742
|
+
// ready to be split into comparators.
|
|
1743
|
+
|
|
1744
|
+
var compRe = loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR]
|
|
1745
|
+
var set = range.split(' ').map(function (comp) {
|
|
1746
|
+
return parseComparator(comp, this.options)
|
|
1747
|
+
}, this).join(' ').split(/\s+/)
|
|
1748
|
+
if (this.options.loose) {
|
|
1749
|
+
// in loose mode, throw out any that are not valid comparators
|
|
1750
|
+
set = set.filter(function (comp) {
|
|
1751
|
+
return !!comp.match(compRe)
|
|
1752
|
+
})
|
|
1753
|
+
}
|
|
1754
|
+
set = set.map(function (comp) {
|
|
1755
|
+
return new Comparator(comp, this.options)
|
|
1756
|
+
}, this)
|
|
1757
|
+
|
|
1758
|
+
return set
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
Range.prototype.intersects = function (range, options) {
|
|
1762
|
+
if (!(range instanceof Range)) {
|
|
1763
|
+
throw new TypeError('a Range is required')
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
return this.set.some(function (thisComparators) {
|
|
1767
|
+
return (
|
|
1768
|
+
isSatisfiable(thisComparators, options) &&
|
|
1769
|
+
range.set.some(function (rangeComparators) {
|
|
1770
|
+
return (
|
|
1771
|
+
isSatisfiable(rangeComparators, options) &&
|
|
1772
|
+
thisComparators.every(function (thisComparator) {
|
|
1773
|
+
return rangeComparators.every(function (rangeComparator) {
|
|
1774
|
+
return thisComparator.intersects(rangeComparator, options)
|
|
1775
|
+
})
|
|
1776
|
+
})
|
|
1777
|
+
)
|
|
1778
|
+
})
|
|
1779
|
+
)
|
|
1780
|
+
})
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
// take a set of comparators and determine whether there
|
|
1784
|
+
// exists a version which can satisfy it
|
|
1785
|
+
function isSatisfiable (comparators, options) {
|
|
1786
|
+
var result = true
|
|
1787
|
+
var remainingComparators = comparators.slice()
|
|
1788
|
+
var testComparator = remainingComparators.pop()
|
|
1789
|
+
|
|
1790
|
+
while (result && remainingComparators.length) {
|
|
1791
|
+
result = remainingComparators.every(function (otherComparator) {
|
|
1792
|
+
return testComparator.intersects(otherComparator, options)
|
|
1793
|
+
})
|
|
1794
|
+
|
|
1795
|
+
testComparator = remainingComparators.pop()
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
return result
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
// Mostly just for testing and legacy API reasons
|
|
1802
|
+
exports.toComparators = toComparators
|
|
1803
|
+
function toComparators (range, options) {
|
|
1804
|
+
return new Range(range, options).set.map(function (comp) {
|
|
1805
|
+
return comp.map(function (c) {
|
|
1806
|
+
return c.value
|
|
1807
|
+
}).join(' ').trim().split(' ')
|
|
1808
|
+
})
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
// comprised of xranges, tildes, stars, and gtlt's at this point.
|
|
1812
|
+
// already replaced the hyphen ranges
|
|
1813
|
+
// turn into a set of JUST comparators.
|
|
1814
|
+
function parseComparator (comp, options) {
|
|
1815
|
+
debug('comp', comp, options)
|
|
1816
|
+
comp = replaceCarets(comp, options)
|
|
1817
|
+
debug('caret', comp)
|
|
1818
|
+
comp = replaceTildes(comp, options)
|
|
1819
|
+
debug('tildes', comp)
|
|
1820
|
+
comp = replaceXRanges(comp, options)
|
|
1821
|
+
debug('xrange', comp)
|
|
1822
|
+
comp = replaceStars(comp, options)
|
|
1823
|
+
debug('stars', comp)
|
|
1824
|
+
return comp
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
function isX (id) {
|
|
1828
|
+
return !id || id.toLowerCase() === 'x' || id === '*'
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
// ~, ~> --> * (any, kinda silly)
|
|
1832
|
+
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
|
|
1833
|
+
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
|
|
1834
|
+
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
|
|
1835
|
+
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
|
|
1836
|
+
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
|
|
1837
|
+
function replaceTildes (comp, options) {
|
|
1838
|
+
return comp.trim().split(/\s+/).map(function (comp) {
|
|
1839
|
+
return replaceTilde(comp, options)
|
|
1840
|
+
}).join(' ')
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
function replaceTilde (comp, options) {
|
|
1844
|
+
var r = options.loose ? safeRe[t.TILDELOOSE] : safeRe[t.TILDE]
|
|
1845
|
+
return comp.replace(r, function (_, M, m, p, pr) {
|
|
1846
|
+
debug('tilde', comp, _, M, m, p, pr)
|
|
1847
|
+
var ret
|
|
1848
|
+
|
|
1849
|
+
if (isX(M)) {
|
|
1850
|
+
ret = ''
|
|
1851
|
+
} else if (isX(m)) {
|
|
1852
|
+
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
|
1853
|
+
} else if (isX(p)) {
|
|
1854
|
+
// ~1.2 == >=1.2.0 <1.3.0
|
|
1855
|
+
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
|
1856
|
+
} else if (pr) {
|
|
1857
|
+
debug('replaceTilde pr', pr)
|
|
1858
|
+
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
1859
|
+
' <' + M + '.' + (+m + 1) + '.0'
|
|
1860
|
+
} else {
|
|
1861
|
+
// ~1.2.3 == >=1.2.3 <1.3.0
|
|
1862
|
+
ret = '>=' + M + '.' + m + '.' + p +
|
|
1863
|
+
' <' + M + '.' + (+m + 1) + '.0'
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
debug('tilde return', ret)
|
|
1867
|
+
return ret
|
|
1868
|
+
})
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
// ^ --> * (any, kinda silly)
|
|
1872
|
+
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
|
|
1873
|
+
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
|
|
1874
|
+
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
|
|
1875
|
+
// ^1.2.3 --> >=1.2.3 <2.0.0
|
|
1876
|
+
// ^1.2.0 --> >=1.2.0 <2.0.0
|
|
1877
|
+
function replaceCarets (comp, options) {
|
|
1878
|
+
return comp.trim().split(/\s+/).map(function (comp) {
|
|
1879
|
+
return replaceCaret(comp, options)
|
|
1880
|
+
}).join(' ')
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
function replaceCaret (comp, options) {
|
|
1884
|
+
debug('caret', comp, options)
|
|
1885
|
+
var r = options.loose ? safeRe[t.CARETLOOSE] : safeRe[t.CARET]
|
|
1886
|
+
return comp.replace(r, function (_, M, m, p, pr) {
|
|
1887
|
+
debug('caret', comp, _, M, m, p, pr)
|
|
1888
|
+
var ret
|
|
1889
|
+
|
|
1890
|
+
if (isX(M)) {
|
|
1891
|
+
ret = ''
|
|
1892
|
+
} else if (isX(m)) {
|
|
1893
|
+
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
|
1894
|
+
} else if (isX(p)) {
|
|
1895
|
+
if (M === '0') {
|
|
1896
|
+
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
|
1897
|
+
} else {
|
|
1898
|
+
ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0'
|
|
1899
|
+
}
|
|
1900
|
+
} else if (pr) {
|
|
1901
|
+
debug('replaceCaret pr', pr)
|
|
1902
|
+
if (M === '0') {
|
|
1903
|
+
if (m === '0') {
|
|
1904
|
+
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
1905
|
+
' <' + M + '.' + m + '.' + (+p + 1)
|
|
1906
|
+
} else {
|
|
1907
|
+
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
1908
|
+
' <' + M + '.' + (+m + 1) + '.0'
|
|
1909
|
+
}
|
|
1910
|
+
} else {
|
|
1911
|
+
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
1912
|
+
' <' + (+M + 1) + '.0.0'
|
|
1913
|
+
}
|
|
1914
|
+
} else {
|
|
1915
|
+
debug('no pr')
|
|
1916
|
+
if (M === '0') {
|
|
1917
|
+
if (m === '0') {
|
|
1918
|
+
ret = '>=' + M + '.' + m + '.' + p +
|
|
1919
|
+
' <' + M + '.' + m + '.' + (+p + 1)
|
|
1920
|
+
} else {
|
|
1921
|
+
ret = '>=' + M + '.' + m + '.' + p +
|
|
1922
|
+
' <' + M + '.' + (+m + 1) + '.0'
|
|
1923
|
+
}
|
|
1924
|
+
} else {
|
|
1925
|
+
ret = '>=' + M + '.' + m + '.' + p +
|
|
1926
|
+
' <' + (+M + 1) + '.0.0'
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
debug('caret return', ret)
|
|
1931
|
+
return ret
|
|
1932
|
+
})
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1935
|
+
function replaceXRanges (comp, options) {
|
|
1936
|
+
debug('replaceXRanges', comp, options)
|
|
1937
|
+
return comp.split(/\s+/).map(function (comp) {
|
|
1938
|
+
return replaceXRange(comp, options)
|
|
1939
|
+
}).join(' ')
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
function replaceXRange (comp, options) {
|
|
1943
|
+
comp = comp.trim()
|
|
1944
|
+
var r = options.loose ? safeRe[t.XRANGELOOSE] : safeRe[t.XRANGE]
|
|
1945
|
+
return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
|
|
1946
|
+
debug('xRange', comp, ret, gtlt, M, m, p, pr)
|
|
1947
|
+
var xM = isX(M)
|
|
1948
|
+
var xm = xM || isX(m)
|
|
1949
|
+
var xp = xm || isX(p)
|
|
1950
|
+
var anyX = xp
|
|
1951
|
+
|
|
1952
|
+
if (gtlt === '=' && anyX) {
|
|
1953
|
+
gtlt = ''
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
// if we're including prereleases in the match, then we need
|
|
1957
|
+
// to fix this to -0, the lowest possible prerelease value
|
|
1958
|
+
pr = options.includePrerelease ? '-0' : ''
|
|
1959
|
+
|
|
1960
|
+
if (xM) {
|
|
1961
|
+
if (gtlt === '>' || gtlt === '<') {
|
|
1962
|
+
// nothing is allowed
|
|
1963
|
+
ret = '<0.0.0-0'
|
|
1964
|
+
} else {
|
|
1965
|
+
// nothing is forbidden
|
|
1966
|
+
ret = '*'
|
|
1967
|
+
}
|
|
1968
|
+
} else if (gtlt && anyX) {
|
|
1969
|
+
// we know patch is an x, because we have any x at all.
|
|
1970
|
+
// replace X with 0
|
|
1971
|
+
if (xm) {
|
|
1972
|
+
m = 0
|
|
1973
|
+
}
|
|
1974
|
+
p = 0
|
|
1975
|
+
|
|
1976
|
+
if (gtlt === '>') {
|
|
1977
|
+
// >1 => >=2.0.0
|
|
1978
|
+
// >1.2 => >=1.3.0
|
|
1979
|
+
// >1.2.3 => >= 1.2.4
|
|
1980
|
+
gtlt = '>='
|
|
1981
|
+
if (xm) {
|
|
1982
|
+
M = +M + 1
|
|
1983
|
+
m = 0
|
|
1984
|
+
p = 0
|
|
1985
|
+
} else {
|
|
1986
|
+
m = +m + 1
|
|
1987
|
+
p = 0
|
|
1988
|
+
}
|
|
1989
|
+
} else if (gtlt === '<=') {
|
|
1990
|
+
// <=0.7.x is actually <0.8.0, since any 0.7.x should
|
|
1991
|
+
// pass. Similarly, <=7.x is actually <8.0.0, etc.
|
|
1992
|
+
gtlt = '<'
|
|
1993
|
+
if (xm) {
|
|
1994
|
+
M = +M + 1
|
|
1995
|
+
} else {
|
|
1996
|
+
m = +m + 1
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
ret = gtlt + M + '.' + m + '.' + p + pr
|
|
2001
|
+
} else if (xm) {
|
|
2002
|
+
ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr
|
|
2003
|
+
} else if (xp) {
|
|
2004
|
+
ret = '>=' + M + '.' + m + '.0' + pr +
|
|
2005
|
+
' <' + M + '.' + (+m + 1) + '.0' + pr
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
debug('xRange return', ret)
|
|
2009
|
+
|
|
2010
|
+
return ret
|
|
2011
|
+
})
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
// Because * is AND-ed with everything else in the comparator,
|
|
2015
|
+
// and '' means "any version", just remove the *s entirely.
|
|
2016
|
+
function replaceStars (comp, options) {
|
|
2017
|
+
debug('replaceStars', comp, options)
|
|
2018
|
+
// Looseness is ignored here. star is always as loose as it gets!
|
|
2019
|
+
return comp.trim().replace(safeRe[t.STAR], '')
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
// This function is passed to string.replace(re[t.HYPHENRANGE])
|
|
2023
|
+
// M, m, patch, prerelease, build
|
|
2024
|
+
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
|
2025
|
+
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
|
|
2026
|
+
// 1.2 - 3.4 => >=1.2.0 <3.5.0
|
|
2027
|
+
function hyphenReplace ($0,
|
|
2028
|
+
from, fM, fm, fp, fpr, fb,
|
|
2029
|
+
to, tM, tm, tp, tpr, tb) {
|
|
2030
|
+
if (isX(fM)) {
|
|
2031
|
+
from = ''
|
|
2032
|
+
} else if (isX(fm)) {
|
|
2033
|
+
from = '>=' + fM + '.0.0'
|
|
2034
|
+
} else if (isX(fp)) {
|
|
2035
|
+
from = '>=' + fM + '.' + fm + '.0'
|
|
2036
|
+
} else {
|
|
2037
|
+
from = '>=' + from
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
if (isX(tM)) {
|
|
2041
|
+
to = ''
|
|
2042
|
+
} else if (isX(tm)) {
|
|
2043
|
+
to = '<' + (+tM + 1) + '.0.0'
|
|
2044
|
+
} else if (isX(tp)) {
|
|
2045
|
+
to = '<' + tM + '.' + (+tm + 1) + '.0'
|
|
2046
|
+
} else if (tpr) {
|
|
2047
|
+
to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr
|
|
2048
|
+
} else {
|
|
2049
|
+
to = '<=' + to
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
return (from + ' ' + to).trim()
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
// if ANY of the sets match ALL of its comparators, then pass
|
|
2056
|
+
Range.prototype.test = function (version) {
|
|
2057
|
+
if (!version) {
|
|
2058
|
+
return false
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
if (typeof version === 'string') {
|
|
2062
|
+
try {
|
|
2063
|
+
version = new SemVer(version, this.options)
|
|
2064
|
+
} catch (er) {
|
|
2065
|
+
return false
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
|
|
2069
|
+
for (var i = 0; i < this.set.length; i++) {
|
|
2070
|
+
if (testSet(this.set[i], version, this.options)) {
|
|
2071
|
+
return true
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
return false
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
function testSet (set, version, options) {
|
|
2078
|
+
for (var i = 0; i < set.length; i++) {
|
|
2079
|
+
if (!set[i].test(version)) {
|
|
2080
|
+
return false
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2084
|
+
if (version.prerelease.length && !options.includePrerelease) {
|
|
2085
|
+
// Find the set of versions that are allowed to have prereleases
|
|
2086
|
+
// For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
|
|
2087
|
+
// That should allow `1.2.3-pr.2` to pass.
|
|
2088
|
+
// However, `1.2.4-alpha.notready` should NOT be allowed,
|
|
2089
|
+
// even though it's within the range set by the comparators.
|
|
2090
|
+
for (i = 0; i < set.length; i++) {
|
|
2091
|
+
debug(set[i].semver)
|
|
2092
|
+
if (set[i].semver === ANY) {
|
|
2093
|
+
continue
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2096
|
+
if (set[i].semver.prerelease.length > 0) {
|
|
2097
|
+
var allowed = set[i].semver
|
|
2098
|
+
if (allowed.major === version.major &&
|
|
2099
|
+
allowed.minor === version.minor &&
|
|
2100
|
+
allowed.patch === version.patch) {
|
|
2101
|
+
return true
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
// Version has a -pre, but it's not one of the ones we like.
|
|
2107
|
+
return false
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
return true
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
exports.satisfies = satisfies
|
|
2114
|
+
function satisfies (version, range, options) {
|
|
2115
|
+
try {
|
|
2116
|
+
range = new Range(range, options)
|
|
2117
|
+
} catch (er) {
|
|
2118
|
+
return false
|
|
2119
|
+
}
|
|
2120
|
+
return range.test(version)
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2123
|
+
exports.maxSatisfying = maxSatisfying
|
|
2124
|
+
function maxSatisfying (versions, range, options) {
|
|
2125
|
+
var max = null
|
|
2126
|
+
var maxSV = null
|
|
2127
|
+
try {
|
|
2128
|
+
var rangeObj = new Range(range, options)
|
|
2129
|
+
} catch (er) {
|
|
2130
|
+
return null
|
|
2131
|
+
}
|
|
2132
|
+
versions.forEach(function (v) {
|
|
2133
|
+
if (rangeObj.test(v)) {
|
|
2134
|
+
// satisfies(v, range, options)
|
|
2135
|
+
if (!max || maxSV.compare(v) === -1) {
|
|
2136
|
+
// compare(max, v, true)
|
|
2137
|
+
max = v
|
|
2138
|
+
maxSV = new SemVer(max, options)
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
})
|
|
2142
|
+
return max
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
exports.minSatisfying = minSatisfying
|
|
2146
|
+
function minSatisfying (versions, range, options) {
|
|
2147
|
+
var min = null
|
|
2148
|
+
var minSV = null
|
|
2149
|
+
try {
|
|
2150
|
+
var rangeObj = new Range(range, options)
|
|
2151
|
+
} catch (er) {
|
|
2152
|
+
return null
|
|
2153
|
+
}
|
|
2154
|
+
versions.forEach(function (v) {
|
|
2155
|
+
if (rangeObj.test(v)) {
|
|
2156
|
+
// satisfies(v, range, options)
|
|
2157
|
+
if (!min || minSV.compare(v) === 1) {
|
|
2158
|
+
// compare(min, v, true)
|
|
2159
|
+
min = v
|
|
2160
|
+
minSV = new SemVer(min, options)
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
})
|
|
2164
|
+
return min
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
exports.minVersion = minVersion
|
|
2168
|
+
function minVersion (range, loose) {
|
|
2169
|
+
range = new Range(range, loose)
|
|
2170
|
+
|
|
2171
|
+
var minver = new SemVer('0.0.0')
|
|
2172
|
+
if (range.test(minver)) {
|
|
2173
|
+
return minver
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
minver = new SemVer('0.0.0-0')
|
|
2177
|
+
if (range.test(minver)) {
|
|
2178
|
+
return minver
|
|
2179
|
+
}
|
|
2180
|
+
|
|
2181
|
+
minver = null
|
|
2182
|
+
for (var i = 0; i < range.set.length; ++i) {
|
|
2183
|
+
var comparators = range.set[i]
|
|
2184
|
+
|
|
2185
|
+
comparators.forEach(function (comparator) {
|
|
2186
|
+
// Clone to avoid manipulating the comparator's semver object.
|
|
2187
|
+
var compver = new SemVer(comparator.semver.version)
|
|
2188
|
+
switch (comparator.operator) {
|
|
2189
|
+
case '>':
|
|
2190
|
+
if (compver.prerelease.length === 0) {
|
|
2191
|
+
compver.patch++
|
|
2192
|
+
} else {
|
|
2193
|
+
compver.prerelease.push(0)
|
|
2194
|
+
}
|
|
2195
|
+
compver.raw = compver.format()
|
|
2196
|
+
/* fallthrough */
|
|
2197
|
+
case '':
|
|
2198
|
+
case '>=':
|
|
2199
|
+
if (!minver || gt(minver, compver)) {
|
|
2200
|
+
minver = compver
|
|
2201
|
+
}
|
|
2202
|
+
break
|
|
2203
|
+
case '<':
|
|
2204
|
+
case '<=':
|
|
2205
|
+
/* Ignore maximum versions */
|
|
2206
|
+
break
|
|
2207
|
+
/* istanbul ignore next */
|
|
2208
|
+
default:
|
|
2209
|
+
throw new Error('Unexpected operation: ' + comparator.operator)
|
|
2210
|
+
}
|
|
2211
|
+
})
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
if (minver && range.test(minver)) {
|
|
2215
|
+
return minver
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2218
|
+
return null
|
|
2219
|
+
}
|
|
2220
|
+
|
|
2221
|
+
exports.validRange = validRange
|
|
2222
|
+
function validRange (range, options) {
|
|
2223
|
+
try {
|
|
2224
|
+
// Return '*' instead of '' so that truthiness works.
|
|
2225
|
+
// This will throw if it's invalid anyway
|
|
2226
|
+
return new Range(range, options).range || '*'
|
|
2227
|
+
} catch (er) {
|
|
2228
|
+
return null
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
// Determine if version is less than all the versions possible in the range
|
|
2233
|
+
exports.ltr = ltr
|
|
2234
|
+
function ltr (version, range, options) {
|
|
2235
|
+
return outside(version, range, '<', options)
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
// Determine if version is greater than all the versions possible in the range.
|
|
2239
|
+
exports.gtr = gtr
|
|
2240
|
+
function gtr (version, range, options) {
|
|
2241
|
+
return outside(version, range, '>', options)
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
exports.outside = outside
|
|
2245
|
+
function outside (version, range, hilo, options) {
|
|
2246
|
+
version = new SemVer(version, options)
|
|
2247
|
+
range = new Range(range, options)
|
|
2248
|
+
|
|
2249
|
+
var gtfn, ltefn, ltfn, comp, ecomp
|
|
2250
|
+
switch (hilo) {
|
|
2251
|
+
case '>':
|
|
2252
|
+
gtfn = gt
|
|
2253
|
+
ltefn = lte
|
|
2254
|
+
ltfn = lt
|
|
2255
|
+
comp = '>'
|
|
2256
|
+
ecomp = '>='
|
|
2257
|
+
break
|
|
2258
|
+
case '<':
|
|
2259
|
+
gtfn = lt
|
|
2260
|
+
ltefn = gte
|
|
2261
|
+
ltfn = gt
|
|
2262
|
+
comp = '<'
|
|
2263
|
+
ecomp = '<='
|
|
2264
|
+
break
|
|
2265
|
+
default:
|
|
2266
|
+
throw new TypeError('Must provide a hilo val of "<" or ">"')
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
// If it satisifes the range it is not outside
|
|
2270
|
+
if (satisfies(version, range, options)) {
|
|
2271
|
+
return false
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
// From now on, variable terms are as if we're in "gtr" mode.
|
|
2275
|
+
// but note that everything is flipped for the "ltr" function.
|
|
2276
|
+
|
|
2277
|
+
for (var i = 0; i < range.set.length; ++i) {
|
|
2278
|
+
var comparators = range.set[i]
|
|
2279
|
+
|
|
2280
|
+
var high = null
|
|
2281
|
+
var low = null
|
|
2282
|
+
|
|
2283
|
+
comparators.forEach(function (comparator) {
|
|
2284
|
+
if (comparator.semver === ANY) {
|
|
2285
|
+
comparator = new Comparator('>=0.0.0')
|
|
2286
|
+
}
|
|
2287
|
+
high = high || comparator
|
|
2288
|
+
low = low || comparator
|
|
2289
|
+
if (gtfn(comparator.semver, high.semver, options)) {
|
|
2290
|
+
high = comparator
|
|
2291
|
+
} else if (ltfn(comparator.semver, low.semver, options)) {
|
|
2292
|
+
low = comparator
|
|
2293
|
+
}
|
|
2294
|
+
})
|
|
2295
|
+
|
|
2296
|
+
// If the edge version comparator has a operator then our version
|
|
2297
|
+
// isn't outside it
|
|
2298
|
+
if (high.operator === comp || high.operator === ecomp) {
|
|
2299
|
+
return false
|
|
2300
|
+
}
|
|
2301
|
+
|
|
2302
|
+
// If the lowest version comparator has an operator and our version
|
|
2303
|
+
// is less than it then it isn't higher than the range
|
|
2304
|
+
if ((!low.operator || low.operator === comp) &&
|
|
2305
|
+
ltefn(version, low.semver)) {
|
|
2306
|
+
return false
|
|
2307
|
+
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
|
|
2308
|
+
return false
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
return true
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2314
|
+
exports.prerelease = prerelease
|
|
2315
|
+
function prerelease (version, options) {
|
|
2316
|
+
var parsed = parse(version, options)
|
|
2317
|
+
return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
exports.intersects = intersects
|
|
2321
|
+
function intersects (r1, r2, options) {
|
|
2322
|
+
r1 = new Range(r1, options)
|
|
2323
|
+
r2 = new Range(r2, options)
|
|
2324
|
+
return r1.intersects(r2)
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
exports.coerce = coerce
|
|
2328
|
+
function coerce (version, options) {
|
|
2329
|
+
if (version instanceof SemVer) {
|
|
2330
|
+
return version
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2333
|
+
if (typeof version === 'number') {
|
|
2334
|
+
version = String(version)
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2337
|
+
if (typeof version !== 'string') {
|
|
2338
|
+
return null
|
|
2339
|
+
}
|
|
2340
|
+
|
|
2341
|
+
options = options || {}
|
|
2342
|
+
|
|
2343
|
+
var match = null
|
|
2344
|
+
if (!options.rtl) {
|
|
2345
|
+
match = version.match(safeRe[t.COERCE])
|
|
2346
|
+
} else {
|
|
2347
|
+
// Find the right-most coercible string that does not share
|
|
2348
|
+
// a terminus with a more left-ward coercible string.
|
|
2349
|
+
// Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
|
|
2350
|
+
//
|
|
2351
|
+
// Walk through the string checking with a /g regexp
|
|
2352
|
+
// Manually set the index so as to pick up overlapping matches.
|
|
2353
|
+
// Stop when we get a match that ends at the string end, since no
|
|
2354
|
+
// coercible string can be more right-ward without the same terminus.
|
|
2355
|
+
var next
|
|
2356
|
+
while ((next = safeRe[t.COERCERTL].exec(version)) &&
|
|
2357
|
+
(!match || match.index + match[0].length !== version.length)
|
|
2358
|
+
) {
|
|
2359
|
+
if (!match ||
|
|
2360
|
+
next.index + next[0].length !== match.index + match[0].length) {
|
|
2361
|
+
match = next
|
|
2362
|
+
}
|
|
2363
|
+
safeRe[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length
|
|
2364
|
+
}
|
|
2365
|
+
// leave it in a clean state
|
|
2366
|
+
safeRe[t.COERCERTL].lastIndex = -1
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
if (match === null) {
|
|
2370
|
+
return null
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2373
|
+
return parse(match[2] +
|
|
2374
|
+
'.' + (match[3] || '0') +
|
|
2375
|
+
'.' + (match[4] || '0'), options)
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
|
|
2379
|
+
/***/ }),
|
|
2380
|
+
|
|
2381
|
+
/***/ 5228:
|
|
2382
|
+
/***/ (function(module) {
|
|
2383
|
+
|
|
2384
|
+
"use strict";
|
|
2385
|
+
|
|
2386
|
+
module.exports = function (Yallist) {
|
|
2387
|
+
Yallist.prototype[Symbol.iterator] = function* () {
|
|
2388
|
+
for (let walker = this.head; walker; walker = walker.next) {
|
|
2389
|
+
yield walker.value
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
|
|
2395
|
+
/***/ }),
|
|
2396
|
+
|
|
2397
|
+
/***/ 7350:
|
|
2398
|
+
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
2399
|
+
|
|
2400
|
+
"use strict";
|
|
2401
|
+
|
|
2402
|
+
module.exports = Yallist
|
|
2403
|
+
|
|
2404
|
+
Yallist.Node = Node
|
|
2405
|
+
Yallist.create = Yallist
|
|
2406
|
+
|
|
2407
|
+
function Yallist (list) {
|
|
2408
|
+
var self = this
|
|
2409
|
+
if (!(self instanceof Yallist)) {
|
|
2410
|
+
self = new Yallist()
|
|
2411
|
+
}
|
|
2412
|
+
|
|
2413
|
+
self.tail = null
|
|
2414
|
+
self.head = null
|
|
2415
|
+
self.length = 0
|
|
2416
|
+
|
|
2417
|
+
if (list && typeof list.forEach === 'function') {
|
|
2418
|
+
list.forEach(function (item) {
|
|
2419
|
+
self.push(item)
|
|
2420
|
+
})
|
|
2421
|
+
} else if (arguments.length > 0) {
|
|
2422
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
2423
|
+
self.push(arguments[i])
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
return self
|
|
2428
|
+
}
|
|
2429
|
+
|
|
2430
|
+
Yallist.prototype.removeNode = function (node) {
|
|
2431
|
+
if (node.list !== this) {
|
|
2432
|
+
throw new Error('removing node which does not belong to this list')
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
var next = node.next
|
|
2436
|
+
var prev = node.prev
|
|
2437
|
+
|
|
2438
|
+
if (next) {
|
|
2439
|
+
next.prev = prev
|
|
2440
|
+
}
|
|
2441
|
+
|
|
2442
|
+
if (prev) {
|
|
2443
|
+
prev.next = next
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2446
|
+
if (node === this.head) {
|
|
2447
|
+
this.head = next
|
|
2448
|
+
}
|
|
2449
|
+
if (node === this.tail) {
|
|
2450
|
+
this.tail = prev
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
node.list.length--
|
|
2454
|
+
node.next = null
|
|
2455
|
+
node.prev = null
|
|
2456
|
+
node.list = null
|
|
2457
|
+
|
|
2458
|
+
return next
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
Yallist.prototype.unshiftNode = function (node) {
|
|
2462
|
+
if (node === this.head) {
|
|
2463
|
+
return
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
if (node.list) {
|
|
2467
|
+
node.list.removeNode(node)
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2470
|
+
var head = this.head
|
|
2471
|
+
node.list = this
|
|
2472
|
+
node.next = head
|
|
2473
|
+
if (head) {
|
|
2474
|
+
head.prev = node
|
|
2475
|
+
}
|
|
2476
|
+
|
|
2477
|
+
this.head = node
|
|
2478
|
+
if (!this.tail) {
|
|
2479
|
+
this.tail = node
|
|
2480
|
+
}
|
|
2481
|
+
this.length++
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
Yallist.prototype.pushNode = function (node) {
|
|
2485
|
+
if (node === this.tail) {
|
|
2486
|
+
return
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2489
|
+
if (node.list) {
|
|
2490
|
+
node.list.removeNode(node)
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2493
|
+
var tail = this.tail
|
|
2494
|
+
node.list = this
|
|
2495
|
+
node.prev = tail
|
|
2496
|
+
if (tail) {
|
|
2497
|
+
tail.next = node
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
this.tail = node
|
|
2501
|
+
if (!this.head) {
|
|
2502
|
+
this.head = node
|
|
2503
|
+
}
|
|
2504
|
+
this.length++
|
|
2505
|
+
}
|
|
2506
|
+
|
|
2507
|
+
Yallist.prototype.push = function () {
|
|
2508
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
2509
|
+
push(this, arguments[i])
|
|
2510
|
+
}
|
|
2511
|
+
return this.length
|
|
2512
|
+
}
|
|
2513
|
+
|
|
2514
|
+
Yallist.prototype.unshift = function () {
|
|
2515
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
2516
|
+
unshift(this, arguments[i])
|
|
2517
|
+
}
|
|
2518
|
+
return this.length
|
|
2519
|
+
}
|
|
2520
|
+
|
|
2521
|
+
Yallist.prototype.pop = function () {
|
|
2522
|
+
if (!this.tail) {
|
|
2523
|
+
return undefined
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
var res = this.tail.value
|
|
2527
|
+
this.tail = this.tail.prev
|
|
2528
|
+
if (this.tail) {
|
|
2529
|
+
this.tail.next = null
|
|
2530
|
+
} else {
|
|
2531
|
+
this.head = null
|
|
2532
|
+
}
|
|
2533
|
+
this.length--
|
|
2534
|
+
return res
|
|
2535
|
+
}
|
|
2536
|
+
|
|
2537
|
+
Yallist.prototype.shift = function () {
|
|
2538
|
+
if (!this.head) {
|
|
2539
|
+
return undefined
|
|
2540
|
+
}
|
|
2541
|
+
|
|
2542
|
+
var res = this.head.value
|
|
2543
|
+
this.head = this.head.next
|
|
2544
|
+
if (this.head) {
|
|
2545
|
+
this.head.prev = null
|
|
2546
|
+
} else {
|
|
2547
|
+
this.tail = null
|
|
2548
|
+
}
|
|
2549
|
+
this.length--
|
|
2550
|
+
return res
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
Yallist.prototype.forEach = function (fn, thisp) {
|
|
2554
|
+
thisp = thisp || this
|
|
2555
|
+
for (var walker = this.head, i = 0; walker !== null; i++) {
|
|
2556
|
+
fn.call(thisp, walker.value, i, this)
|
|
2557
|
+
walker = walker.next
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
|
|
2561
|
+
Yallist.prototype.forEachReverse = function (fn, thisp) {
|
|
2562
|
+
thisp = thisp || this
|
|
2563
|
+
for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
|
|
2564
|
+
fn.call(thisp, walker.value, i, this)
|
|
2565
|
+
walker = walker.prev
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2569
|
+
Yallist.prototype.get = function (n) {
|
|
2570
|
+
for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
|
|
2571
|
+
// abort out of the list early if we hit a cycle
|
|
2572
|
+
walker = walker.next
|
|
2573
|
+
}
|
|
2574
|
+
if (i === n && walker !== null) {
|
|
2575
|
+
return walker.value
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
Yallist.prototype.getReverse = function (n) {
|
|
2580
|
+
for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
|
|
2581
|
+
// abort out of the list early if we hit a cycle
|
|
2582
|
+
walker = walker.prev
|
|
2583
|
+
}
|
|
2584
|
+
if (i === n && walker !== null) {
|
|
2585
|
+
return walker.value
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
|
|
2589
|
+
Yallist.prototype.map = function (fn, thisp) {
|
|
2590
|
+
thisp = thisp || this
|
|
2591
|
+
var res = new Yallist()
|
|
2592
|
+
for (var walker = this.head; walker !== null;) {
|
|
2593
|
+
res.push(fn.call(thisp, walker.value, this))
|
|
2594
|
+
walker = walker.next
|
|
2595
|
+
}
|
|
2596
|
+
return res
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
Yallist.prototype.mapReverse = function (fn, thisp) {
|
|
2600
|
+
thisp = thisp || this
|
|
2601
|
+
var res = new Yallist()
|
|
2602
|
+
for (var walker = this.tail; walker !== null;) {
|
|
2603
|
+
res.push(fn.call(thisp, walker.value, this))
|
|
2604
|
+
walker = walker.prev
|
|
2605
|
+
}
|
|
2606
|
+
return res
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
Yallist.prototype.reduce = function (fn, initial) {
|
|
2610
|
+
var acc
|
|
2611
|
+
var walker = this.head
|
|
2612
|
+
if (arguments.length > 1) {
|
|
2613
|
+
acc = initial
|
|
2614
|
+
} else if (this.head) {
|
|
2615
|
+
walker = this.head.next
|
|
2616
|
+
acc = this.head.value
|
|
2617
|
+
} else {
|
|
2618
|
+
throw new TypeError('Reduce of empty list with no initial value')
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
for (var i = 0; walker !== null; i++) {
|
|
2622
|
+
acc = fn(acc, walker.value, i)
|
|
2623
|
+
walker = walker.next
|
|
2624
|
+
}
|
|
2625
|
+
|
|
2626
|
+
return acc
|
|
2627
|
+
}
|
|
2628
|
+
|
|
2629
|
+
Yallist.prototype.reduceReverse = function (fn, initial) {
|
|
2630
|
+
var acc
|
|
2631
|
+
var walker = this.tail
|
|
2632
|
+
if (arguments.length > 1) {
|
|
2633
|
+
acc = initial
|
|
2634
|
+
} else if (this.tail) {
|
|
2635
|
+
walker = this.tail.prev
|
|
2636
|
+
acc = this.tail.value
|
|
2637
|
+
} else {
|
|
2638
|
+
throw new TypeError('Reduce of empty list with no initial value')
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
for (var i = this.length - 1; walker !== null; i--) {
|
|
2642
|
+
acc = fn(acc, walker.value, i)
|
|
2643
|
+
walker = walker.prev
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2646
|
+
return acc
|
|
2647
|
+
}
|
|
2648
|
+
|
|
2649
|
+
Yallist.prototype.toArray = function () {
|
|
2650
|
+
var arr = new Array(this.length)
|
|
2651
|
+
for (var i = 0, walker = this.head; walker !== null; i++) {
|
|
2652
|
+
arr[i] = walker.value
|
|
2653
|
+
walker = walker.next
|
|
2654
|
+
}
|
|
2655
|
+
return arr
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2658
|
+
Yallist.prototype.toArrayReverse = function () {
|
|
2659
|
+
var arr = new Array(this.length)
|
|
2660
|
+
for (var i = 0, walker = this.tail; walker !== null; i++) {
|
|
2661
|
+
arr[i] = walker.value
|
|
2662
|
+
walker = walker.prev
|
|
2663
|
+
}
|
|
2664
|
+
return arr
|
|
2665
|
+
}
|
|
2666
|
+
|
|
2667
|
+
Yallist.prototype.slice = function (from, to) {
|
|
2668
|
+
to = to || this.length
|
|
2669
|
+
if (to < 0) {
|
|
2670
|
+
to += this.length
|
|
2671
|
+
}
|
|
2672
|
+
from = from || 0
|
|
2673
|
+
if (from < 0) {
|
|
2674
|
+
from += this.length
|
|
2675
|
+
}
|
|
2676
|
+
var ret = new Yallist()
|
|
2677
|
+
if (to < from || to < 0) {
|
|
2678
|
+
return ret
|
|
2679
|
+
}
|
|
2680
|
+
if (from < 0) {
|
|
2681
|
+
from = 0
|
|
2682
|
+
}
|
|
2683
|
+
if (to > this.length) {
|
|
2684
|
+
to = this.length
|
|
2685
|
+
}
|
|
2686
|
+
for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
|
|
2687
|
+
walker = walker.next
|
|
2688
|
+
}
|
|
2689
|
+
for (; walker !== null && i < to; i++, walker = walker.next) {
|
|
2690
|
+
ret.push(walker.value)
|
|
2691
|
+
}
|
|
2692
|
+
return ret
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
Yallist.prototype.sliceReverse = function (from, to) {
|
|
2696
|
+
to = to || this.length
|
|
2697
|
+
if (to < 0) {
|
|
2698
|
+
to += this.length
|
|
2699
|
+
}
|
|
2700
|
+
from = from || 0
|
|
2701
|
+
if (from < 0) {
|
|
2702
|
+
from += this.length
|
|
2703
|
+
}
|
|
2704
|
+
var ret = new Yallist()
|
|
2705
|
+
if (to < from || to < 0) {
|
|
2706
|
+
return ret
|
|
2707
|
+
}
|
|
2708
|
+
if (from < 0) {
|
|
2709
|
+
from = 0
|
|
2710
|
+
}
|
|
2711
|
+
if (to > this.length) {
|
|
2712
|
+
to = this.length
|
|
2713
|
+
}
|
|
2714
|
+
for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
|
|
2715
|
+
walker = walker.prev
|
|
2716
|
+
}
|
|
2717
|
+
for (; walker !== null && i > from; i--, walker = walker.prev) {
|
|
2718
|
+
ret.push(walker.value)
|
|
2719
|
+
}
|
|
2720
|
+
return ret
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
Yallist.prototype.splice = function (start, deleteCount /*, ...nodes */) {
|
|
2724
|
+
if (start > this.length) {
|
|
2725
|
+
start = this.length - 1
|
|
2726
|
+
}
|
|
2727
|
+
if (start < 0) {
|
|
2728
|
+
start = this.length + start;
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
|
|
2732
|
+
walker = walker.next
|
|
2733
|
+
}
|
|
2734
|
+
|
|
2735
|
+
var ret = []
|
|
2736
|
+
for (var i = 0; walker && i < deleteCount; i++) {
|
|
2737
|
+
ret.push(walker.value)
|
|
2738
|
+
walker = this.removeNode(walker)
|
|
2739
|
+
}
|
|
2740
|
+
if (walker === null) {
|
|
2741
|
+
walker = this.tail
|
|
2742
|
+
}
|
|
2743
|
+
|
|
2744
|
+
if (walker !== this.head && walker !== this.tail) {
|
|
2745
|
+
walker = walker.prev
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2748
|
+
for (var i = 2; i < arguments.length; i++) {
|
|
2749
|
+
walker = insert(this, walker, arguments[i])
|
|
2750
|
+
}
|
|
2751
|
+
return ret;
|
|
2752
|
+
}
|
|
2753
|
+
|
|
2754
|
+
Yallist.prototype.reverse = function () {
|
|
2755
|
+
var head = this.head
|
|
2756
|
+
var tail = this.tail
|
|
2757
|
+
for (var walker = head; walker !== null; walker = walker.prev) {
|
|
2758
|
+
var p = walker.prev
|
|
2759
|
+
walker.prev = walker.next
|
|
2760
|
+
walker.next = p
|
|
2761
|
+
}
|
|
2762
|
+
this.head = tail
|
|
2763
|
+
this.tail = head
|
|
2764
|
+
return this
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
function insert (self, node, value) {
|
|
2768
|
+
var inserted = node === self.head ?
|
|
2769
|
+
new Node(value, null, node, self) :
|
|
2770
|
+
new Node(value, node, node.next, self)
|
|
2771
|
+
|
|
2772
|
+
if (inserted.next === null) {
|
|
2773
|
+
self.tail = inserted
|
|
2774
|
+
}
|
|
2775
|
+
if (inserted.prev === null) {
|
|
2776
|
+
self.head = inserted
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2779
|
+
self.length++
|
|
2780
|
+
|
|
2781
|
+
return inserted
|
|
2782
|
+
}
|
|
2783
|
+
|
|
2784
|
+
function push (self, item) {
|
|
2785
|
+
self.tail = new Node(item, self.tail, null, self)
|
|
2786
|
+
if (!self.head) {
|
|
2787
|
+
self.head = self.tail
|
|
2788
|
+
}
|
|
2789
|
+
self.length++
|
|
2790
|
+
}
|
|
2791
|
+
|
|
2792
|
+
function unshift (self, item) {
|
|
2793
|
+
self.head = new Node(item, null, self.head, self)
|
|
2794
|
+
if (!self.tail) {
|
|
2795
|
+
self.tail = self.head
|
|
2796
|
+
}
|
|
2797
|
+
self.length++
|
|
2798
|
+
}
|
|
2799
|
+
|
|
2800
|
+
function Node (value, prev, next, list) {
|
|
2801
|
+
if (!(this instanceof Node)) {
|
|
2802
|
+
return new Node(value, prev, next, list)
|
|
2803
|
+
}
|
|
2804
|
+
|
|
2805
|
+
this.list = list
|
|
2806
|
+
this.value = value
|
|
2807
|
+
|
|
2808
|
+
if (prev) {
|
|
2809
|
+
prev.next = this
|
|
2810
|
+
this.prev = prev
|
|
2811
|
+
} else {
|
|
2812
|
+
this.prev = null
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2815
|
+
if (next) {
|
|
2816
|
+
next.prev = this
|
|
2817
|
+
this.next = next
|
|
2818
|
+
} else {
|
|
2819
|
+
this.next = null
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
try {
|
|
2824
|
+
// add if support for Symbol.iterator is present
|
|
2825
|
+
__webpack_require__(5228)(Yallist)
|
|
2826
|
+
} catch (er) {}
|
|
2827
|
+
|
|
2828
|
+
|
|
2829
|
+
/***/ }),
|
|
2830
|
+
|
|
2831
|
+
/***/ 5174:
|
|
2832
|
+
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
2833
|
+
|
|
2834
|
+
// Todo (Babel 8): remove this file, in Babel 8 users import the .json directly
|
|
2835
|
+
module.exports = __webpack_require__(9468);
|
|
2836
|
+
|
|
2837
|
+
|
|
2838
|
+
/***/ }),
|
|
2839
|
+
|
|
2840
|
+
/***/ 4697:
|
|
2841
|
+
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
2842
|
+
|
|
2843
|
+
// Todo (Babel 8): remove this file, in Babel 8 users import the .json directly
|
|
2844
|
+
module.exports = __webpack_require__(4657);
|
|
2845
|
+
|
|
2846
|
+
|
|
2847
|
+
/***/ }),
|
|
2848
|
+
|
|
2849
|
+
/***/ 1880:
|
|
2850
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2851
|
+
|
|
2852
|
+
"use strict";
|
|
2853
|
+
|
|
2854
|
+
|
|
2855
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
2856
|
+
value: true
|
|
2857
|
+
}));
|
|
2858
|
+
exports.getInclusionReasons = getInclusionReasons;
|
|
2859
|
+
var _semver = __webpack_require__(3167);
|
|
2860
|
+
var _pretty = __webpack_require__(6947);
|
|
2861
|
+
var _utils = __webpack_require__(274);
|
|
2862
|
+
function getInclusionReasons(item, targetVersions, list) {
|
|
2863
|
+
const minVersions = list[item] || {};
|
|
2864
|
+
return Object.keys(targetVersions).reduce((result, env) => {
|
|
2865
|
+
const minVersion = (0, _utils.getLowestImplementedVersion)(minVersions, env);
|
|
2866
|
+
const targetVersion = targetVersions[env];
|
|
2867
|
+
if (!minVersion) {
|
|
2868
|
+
result[env] = (0, _pretty.prettifyVersion)(targetVersion);
|
|
2869
|
+
} else {
|
|
2870
|
+
const minIsUnreleased = (0, _utils.isUnreleasedVersion)(minVersion, env);
|
|
2871
|
+
const targetIsUnreleased = (0, _utils.isUnreleasedVersion)(targetVersion, env);
|
|
2872
|
+
if (!targetIsUnreleased && (minIsUnreleased || _semver.lt(targetVersion.toString(), (0, _utils.semverify)(minVersion)))) {
|
|
2873
|
+
result[env] = (0, _pretty.prettifyVersion)(targetVersion);
|
|
2874
|
+
}
|
|
2875
|
+
}
|
|
2876
|
+
return result;
|
|
2877
|
+
}, {});
|
|
2878
|
+
}
|
|
2879
|
+
|
|
2880
|
+
//# sourceMappingURL=debug.js.map
|
|
2881
|
+
|
|
2882
|
+
|
|
2883
|
+
/***/ }),
|
|
2884
|
+
|
|
2885
|
+
/***/ 9112:
|
|
2886
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2887
|
+
|
|
2888
|
+
"use strict";
|
|
2889
|
+
|
|
2890
|
+
|
|
2891
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
2892
|
+
value: true
|
|
2893
|
+
}));
|
|
2894
|
+
exports["default"] = filterItems;
|
|
2895
|
+
exports.isRequired = isRequired;
|
|
2896
|
+
exports.targetsSupported = targetsSupported;
|
|
2897
|
+
var _semver = __webpack_require__(3167);
|
|
2898
|
+
var _utils = __webpack_require__(274);
|
|
2899
|
+
const pluginsCompatData = __webpack_require__(4697);
|
|
2900
|
+
function targetsSupported(target, support) {
|
|
2901
|
+
const targetEnvironments = Object.keys(target);
|
|
2902
|
+
if (targetEnvironments.length === 0) {
|
|
2903
|
+
return false;
|
|
2904
|
+
}
|
|
2905
|
+
const unsupportedEnvironments = targetEnvironments.filter(environment => {
|
|
2906
|
+
const lowestImplementedVersion = (0, _utils.getLowestImplementedVersion)(support, environment);
|
|
2907
|
+
if (!lowestImplementedVersion) {
|
|
2908
|
+
return true;
|
|
2909
|
+
}
|
|
2910
|
+
const lowestTargetedVersion = target[environment];
|
|
2911
|
+
if ((0, _utils.isUnreleasedVersion)(lowestTargetedVersion, environment)) {
|
|
2912
|
+
return false;
|
|
2913
|
+
}
|
|
2914
|
+
if ((0, _utils.isUnreleasedVersion)(lowestImplementedVersion, environment)) {
|
|
2915
|
+
return true;
|
|
2916
|
+
}
|
|
2917
|
+
if (!_semver.valid(lowestTargetedVersion.toString())) {
|
|
2918
|
+
throw new Error(`Invalid version passed for target "${environment}": "${lowestTargetedVersion}". ` + "Versions must be in semver format (major.minor.patch)");
|
|
2919
|
+
}
|
|
2920
|
+
return _semver.gt((0, _utils.semverify)(lowestImplementedVersion), lowestTargetedVersion.toString());
|
|
2921
|
+
});
|
|
2922
|
+
return unsupportedEnvironments.length === 0;
|
|
2923
|
+
}
|
|
2924
|
+
function isRequired(name, targets, {
|
|
2925
|
+
compatData = pluginsCompatData,
|
|
2926
|
+
includes,
|
|
2927
|
+
excludes
|
|
2928
|
+
} = {}) {
|
|
2929
|
+
if (excludes != null && excludes.has(name)) return false;
|
|
2930
|
+
if (includes != null && includes.has(name)) return true;
|
|
2931
|
+
return !targetsSupported(targets, compatData[name]);
|
|
2932
|
+
}
|
|
2933
|
+
function filterItems(list, includes, excludes, targets, defaultIncludes, defaultExcludes, pluginSyntaxMap) {
|
|
2934
|
+
const result = new Set();
|
|
2935
|
+
const options = {
|
|
2936
|
+
compatData: list,
|
|
2937
|
+
includes,
|
|
2938
|
+
excludes
|
|
2939
|
+
};
|
|
2940
|
+
for (const item in list) {
|
|
2941
|
+
if (isRequired(item, targets, options)) {
|
|
2942
|
+
result.add(item);
|
|
2943
|
+
} else if (pluginSyntaxMap) {
|
|
2944
|
+
const shippedProposalsSyntax = pluginSyntaxMap.get(item);
|
|
2945
|
+
if (shippedProposalsSyntax) {
|
|
2946
|
+
result.add(shippedProposalsSyntax);
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
}
|
|
2950
|
+
defaultIncludes == null || defaultIncludes.forEach(item => !excludes.has(item) && result.add(item));
|
|
2951
|
+
defaultExcludes == null || defaultExcludes.forEach(item => !includes.has(item) && result.delete(item));
|
|
2952
|
+
return result;
|
|
2953
|
+
}
|
|
2954
|
+
|
|
2955
|
+
//# sourceMappingURL=filter-items.js.map
|
|
2956
|
+
|
|
2957
|
+
|
|
2958
|
+
/***/ }),
|
|
2959
|
+
|
|
2960
|
+
/***/ 9287:
|
|
2961
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2962
|
+
|
|
2963
|
+
"use strict";
|
|
2964
|
+
|
|
2965
|
+
|
|
2966
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
2967
|
+
value: true
|
|
2968
|
+
}));
|
|
2969
|
+
Object.defineProperty(exports, "TargetNames", ({
|
|
2970
|
+
enumerable: true,
|
|
2971
|
+
get: function () {
|
|
2972
|
+
return _options.TargetNames;
|
|
2973
|
+
}
|
|
2974
|
+
}));
|
|
2975
|
+
exports["default"] = getTargets;
|
|
2976
|
+
Object.defineProperty(exports, "filterItems", ({
|
|
2977
|
+
enumerable: true,
|
|
2978
|
+
get: function () {
|
|
2979
|
+
return _filterItems.default;
|
|
2980
|
+
}
|
|
2981
|
+
}));
|
|
2982
|
+
Object.defineProperty(exports, "getInclusionReasons", ({
|
|
2983
|
+
enumerable: true,
|
|
2984
|
+
get: function () {
|
|
2985
|
+
return _debug.getInclusionReasons;
|
|
2986
|
+
}
|
|
2987
|
+
}));
|
|
2988
|
+
exports.isBrowsersQueryValid = isBrowsersQueryValid;
|
|
2989
|
+
Object.defineProperty(exports, "isRequired", ({
|
|
2990
|
+
enumerable: true,
|
|
2991
|
+
get: function () {
|
|
2992
|
+
return _filterItems.isRequired;
|
|
2993
|
+
}
|
|
2994
|
+
}));
|
|
2995
|
+
Object.defineProperty(exports, "prettifyTargets", ({
|
|
2996
|
+
enumerable: true,
|
|
2997
|
+
get: function () {
|
|
2998
|
+
return _pretty.prettifyTargets;
|
|
2999
|
+
}
|
|
3000
|
+
}));
|
|
3001
|
+
Object.defineProperty(exports, "unreleasedLabels", ({
|
|
3002
|
+
enumerable: true,
|
|
3003
|
+
get: function () {
|
|
3004
|
+
return _targets.unreleasedLabels;
|
|
3005
|
+
}
|
|
3006
|
+
}));
|
|
3007
|
+
var _browserslist = __webpack_require__(2639);
|
|
3008
|
+
var _helperValidatorOption = __webpack_require__(8809);
|
|
3009
|
+
var _lruCache = __webpack_require__(6750);
|
|
3010
|
+
var _utils = __webpack_require__(274);
|
|
3011
|
+
var _targets = __webpack_require__(6605);
|
|
3012
|
+
var _options = __webpack_require__(6717);
|
|
3013
|
+
var _pretty = __webpack_require__(6947);
|
|
3014
|
+
var _debug = __webpack_require__(1880);
|
|
3015
|
+
var _filterItems = __webpack_require__(9112);
|
|
3016
|
+
const browserModulesData = __webpack_require__(5174);
|
|
3017
|
+
const ESM_SUPPORT = browserModulesData["es6.module"];
|
|
3018
|
+
const v = new _helperValidatorOption.OptionValidator("@babel/helper-compilation-targets");
|
|
3019
|
+
function validateTargetNames(targets) {
|
|
3020
|
+
const validTargets = Object.keys(_options.TargetNames);
|
|
3021
|
+
for (const target of Object.keys(targets)) {
|
|
3022
|
+
if (!(target in _options.TargetNames)) {
|
|
3023
|
+
throw new Error(v.formatMessage(`'${target}' is not a valid target
|
|
3024
|
+
- Did you mean '${(0, _helperValidatorOption.findSuggestion)(target, validTargets)}'?`));
|
|
3025
|
+
}
|
|
3026
|
+
}
|
|
3027
|
+
return targets;
|
|
3028
|
+
}
|
|
3029
|
+
function isBrowsersQueryValid(browsers) {
|
|
3030
|
+
return typeof browsers === "string" || Array.isArray(browsers) && browsers.every(b => typeof b === "string");
|
|
3031
|
+
}
|
|
3032
|
+
function validateBrowsers(browsers) {
|
|
3033
|
+
v.invariant(browsers === undefined || isBrowsersQueryValid(browsers), `'${String(browsers)}' is not a valid browserslist query`);
|
|
3034
|
+
return browsers;
|
|
3035
|
+
}
|
|
3036
|
+
function getLowestVersions(browsers) {
|
|
3037
|
+
return browsers.reduce((all, browser) => {
|
|
3038
|
+
const [browserName, browserVersion] = browser.split(" ");
|
|
3039
|
+
const target = _targets.browserNameMap[browserName];
|
|
3040
|
+
if (!target) {
|
|
3041
|
+
return all;
|
|
3042
|
+
}
|
|
3043
|
+
try {
|
|
3044
|
+
const splitVersion = browserVersion.split("-")[0].toLowerCase();
|
|
3045
|
+
const isSplitUnreleased = (0, _utils.isUnreleasedVersion)(splitVersion, target);
|
|
3046
|
+
if (!all[target]) {
|
|
3047
|
+
all[target] = isSplitUnreleased ? splitVersion : (0, _utils.semverify)(splitVersion);
|
|
3048
|
+
return all;
|
|
3049
|
+
}
|
|
3050
|
+
const version = all[target];
|
|
3051
|
+
const isUnreleased = (0, _utils.isUnreleasedVersion)(version, target);
|
|
3052
|
+
if (isUnreleased && isSplitUnreleased) {
|
|
3053
|
+
all[target] = (0, _utils.getLowestUnreleased)(version, splitVersion, target);
|
|
3054
|
+
} else if (isUnreleased) {
|
|
3055
|
+
all[target] = (0, _utils.semverify)(splitVersion);
|
|
3056
|
+
} else if (!isUnreleased && !isSplitUnreleased) {
|
|
3057
|
+
const parsedBrowserVersion = (0, _utils.semverify)(splitVersion);
|
|
3058
|
+
all[target] = (0, _utils.semverMin)(version, parsedBrowserVersion);
|
|
3059
|
+
}
|
|
3060
|
+
} catch (_) {}
|
|
3061
|
+
return all;
|
|
3062
|
+
}, {});
|
|
3063
|
+
}
|
|
3064
|
+
function outputDecimalWarning(decimalTargets) {
|
|
3065
|
+
if (!decimalTargets.length) {
|
|
3066
|
+
return;
|
|
3067
|
+
}
|
|
3068
|
+
console.warn("Warning, the following targets are using a decimal version:\n");
|
|
3069
|
+
decimalTargets.forEach(({
|
|
3070
|
+
target,
|
|
3071
|
+
value
|
|
3072
|
+
}) => console.warn(` ${target}: ${value}`));
|
|
3073
|
+
console.warn(`
|
|
3074
|
+
We recommend using a string for minor/patch versions to avoid numbers like 6.10
|
|
3075
|
+
getting parsed as 6.1, which can lead to unexpected behavior.
|
|
3076
|
+
`);
|
|
3077
|
+
}
|
|
3078
|
+
function semverifyTarget(target, value) {
|
|
3079
|
+
try {
|
|
3080
|
+
return (0, _utils.semverify)(value);
|
|
3081
|
+
} catch (_) {
|
|
3082
|
+
throw new Error(v.formatMessage(`'${value}' is not a valid value for 'targets.${target}'.`));
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
function nodeTargetParser(value) {
|
|
3086
|
+
const parsed = value === true || value === "current" ? process.versions.node.split("-")[0] : semverifyTarget("node", value);
|
|
3087
|
+
return ["node", parsed];
|
|
3088
|
+
}
|
|
3089
|
+
function defaultTargetParser(target, value) {
|
|
3090
|
+
const version = (0, _utils.isUnreleasedVersion)(value, target) ? value.toLowerCase() : semverifyTarget(target, value);
|
|
3091
|
+
return [target, version];
|
|
3092
|
+
}
|
|
3093
|
+
function generateTargets(inputTargets) {
|
|
3094
|
+
const input = Object.assign({}, inputTargets);
|
|
3095
|
+
delete input.esmodules;
|
|
3096
|
+
delete input.browsers;
|
|
3097
|
+
return input;
|
|
3098
|
+
}
|
|
3099
|
+
function resolveTargets(queries, env) {
|
|
3100
|
+
const resolved = _browserslist(queries, {
|
|
3101
|
+
mobileToDesktop: true,
|
|
3102
|
+
env
|
|
3103
|
+
});
|
|
3104
|
+
return getLowestVersions(resolved);
|
|
3105
|
+
}
|
|
3106
|
+
const targetsCache = new _lruCache({
|
|
3107
|
+
max: 64
|
|
3108
|
+
});
|
|
3109
|
+
function resolveTargetsCached(queries, env) {
|
|
3110
|
+
const cacheKey = typeof queries === "string" ? queries : queries.join() + env;
|
|
3111
|
+
let cached = targetsCache.get(cacheKey);
|
|
3112
|
+
if (!cached) {
|
|
3113
|
+
cached = resolveTargets(queries, env);
|
|
3114
|
+
targetsCache.set(cacheKey, cached);
|
|
3115
|
+
}
|
|
3116
|
+
return Object.assign({}, cached);
|
|
3117
|
+
}
|
|
3118
|
+
function getTargets(inputTargets = {}, options = {}) {
|
|
3119
|
+
var _browsers, _browsers2;
|
|
3120
|
+
let {
|
|
3121
|
+
browsers,
|
|
3122
|
+
esmodules
|
|
3123
|
+
} = inputTargets;
|
|
3124
|
+
const {
|
|
3125
|
+
configPath = ".",
|
|
3126
|
+
onBrowserslistConfigFound
|
|
3127
|
+
} = options;
|
|
3128
|
+
validateBrowsers(browsers);
|
|
3129
|
+
const input = generateTargets(inputTargets);
|
|
3130
|
+
let targets = validateTargetNames(input);
|
|
3131
|
+
const shouldParseBrowsers = !!browsers;
|
|
3132
|
+
const hasTargets = shouldParseBrowsers || Object.keys(targets).length > 0;
|
|
3133
|
+
const shouldSearchForConfig = !options.ignoreBrowserslistConfig && !hasTargets;
|
|
3134
|
+
if (!browsers && shouldSearchForConfig) {
|
|
3135
|
+
browsers = process.env.BROWSERSLIST;
|
|
3136
|
+
if (!browsers) {
|
|
3137
|
+
const configFile = options.configFile || process.env.BROWSERSLIST_CONFIG || _browserslist.findConfigFile(configPath);
|
|
3138
|
+
if (configFile != null) {
|
|
3139
|
+
onBrowserslistConfigFound == null || onBrowserslistConfigFound(configFile);
|
|
3140
|
+
browsers = _browserslist.loadConfig({
|
|
3141
|
+
config: configFile,
|
|
3142
|
+
env: options.browserslistEnv
|
|
3143
|
+
});
|
|
3144
|
+
}
|
|
3145
|
+
}
|
|
3146
|
+
if (browsers == null) {
|
|
3147
|
+
browsers = [];
|
|
3148
|
+
}
|
|
3149
|
+
}
|
|
3150
|
+
if (esmodules && (esmodules !== "intersect" || !((_browsers = browsers) != null && _browsers.length))) {
|
|
3151
|
+
browsers = Object.keys(ESM_SUPPORT).map(browser => `${browser} >= ${ESM_SUPPORT[browser]}`).join(", ");
|
|
3152
|
+
esmodules = false;
|
|
3153
|
+
}
|
|
3154
|
+
if ((_browsers2 = browsers) != null && _browsers2.length) {
|
|
3155
|
+
const queryBrowsers = resolveTargetsCached(browsers, options.browserslistEnv);
|
|
3156
|
+
if (esmodules === "intersect") {
|
|
3157
|
+
for (const browser of Object.keys(queryBrowsers)) {
|
|
3158
|
+
if (browser !== "deno" && browser !== "ie") {
|
|
3159
|
+
const esmSupportVersion = ESM_SUPPORT[browser === "opera_mobile" ? "op_mob" : browser];
|
|
3160
|
+
if (esmSupportVersion) {
|
|
3161
|
+
const version = queryBrowsers[browser];
|
|
3162
|
+
queryBrowsers[browser] = (0, _utils.getHighestUnreleased)(version, (0, _utils.semverify)(esmSupportVersion), browser);
|
|
3163
|
+
} else {
|
|
3164
|
+
delete queryBrowsers[browser];
|
|
3165
|
+
}
|
|
3166
|
+
} else {
|
|
3167
|
+
delete queryBrowsers[browser];
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
targets = Object.assign(queryBrowsers, targets);
|
|
3172
|
+
}
|
|
3173
|
+
const result = {};
|
|
3174
|
+
const decimalWarnings = [];
|
|
3175
|
+
for (const target of Object.keys(targets).sort()) {
|
|
3176
|
+
const value = targets[target];
|
|
3177
|
+
if (typeof value === "number" && value % 1 !== 0) {
|
|
3178
|
+
decimalWarnings.push({
|
|
3179
|
+
target,
|
|
3180
|
+
value
|
|
3181
|
+
});
|
|
3182
|
+
}
|
|
3183
|
+
const [parsedTarget, parsedValue] = target === "node" ? nodeTargetParser(value) : defaultTargetParser(target, value);
|
|
3184
|
+
if (parsedValue) {
|
|
3185
|
+
result[parsedTarget] = parsedValue;
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
outputDecimalWarning(decimalWarnings);
|
|
3189
|
+
return result;
|
|
3190
|
+
}
|
|
3191
|
+
|
|
3192
|
+
//# sourceMappingURL=index.js.map
|
|
3193
|
+
|
|
3194
|
+
|
|
3195
|
+
/***/ }),
|
|
3196
|
+
|
|
3197
|
+
/***/ 6717:
|
|
3198
|
+
/***/ (function(__unused_webpack_module, exports) {
|
|
3199
|
+
|
|
3200
|
+
"use strict";
|
|
3201
|
+
|
|
3202
|
+
|
|
3203
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
3204
|
+
value: true
|
|
3205
|
+
}));
|
|
3206
|
+
exports.TargetNames = void 0;
|
|
3207
|
+
const TargetNames = exports.TargetNames = {
|
|
3208
|
+
node: "node",
|
|
3209
|
+
deno: "deno",
|
|
3210
|
+
chrome: "chrome",
|
|
3211
|
+
opera: "opera",
|
|
3212
|
+
edge: "edge",
|
|
3213
|
+
firefox: "firefox",
|
|
3214
|
+
safari: "safari",
|
|
3215
|
+
ie: "ie",
|
|
3216
|
+
ios: "ios",
|
|
3217
|
+
android: "android",
|
|
3218
|
+
electron: "electron",
|
|
3219
|
+
samsung: "samsung",
|
|
3220
|
+
rhino: "rhino",
|
|
3221
|
+
opera_mobile: "opera_mobile"
|
|
3222
|
+
};
|
|
3223
|
+
|
|
3224
|
+
//# sourceMappingURL=options.js.map
|
|
3225
|
+
|
|
3226
|
+
|
|
3227
|
+
/***/ }),
|
|
3228
|
+
|
|
3229
|
+
/***/ 6947:
|
|
3230
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3231
|
+
|
|
3232
|
+
"use strict";
|
|
3233
|
+
|
|
3234
|
+
|
|
3235
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
3236
|
+
value: true
|
|
3237
|
+
}));
|
|
3238
|
+
exports.prettifyTargets = prettifyTargets;
|
|
3239
|
+
exports.prettifyVersion = prettifyVersion;
|
|
3240
|
+
var _semver = __webpack_require__(3167);
|
|
3241
|
+
var _targets = __webpack_require__(6605);
|
|
3242
|
+
function prettifyVersion(version) {
|
|
3243
|
+
if (typeof version !== "string") {
|
|
3244
|
+
return version;
|
|
3245
|
+
}
|
|
3246
|
+
const {
|
|
3247
|
+
major,
|
|
3248
|
+
minor,
|
|
3249
|
+
patch
|
|
3250
|
+
} = _semver.parse(version);
|
|
3251
|
+
const parts = [major];
|
|
3252
|
+
if (minor || patch) {
|
|
3253
|
+
parts.push(minor);
|
|
3254
|
+
}
|
|
3255
|
+
if (patch) {
|
|
3256
|
+
parts.push(patch);
|
|
3257
|
+
}
|
|
3258
|
+
return parts.join(".");
|
|
3259
|
+
}
|
|
3260
|
+
function prettifyTargets(targets) {
|
|
3261
|
+
return Object.keys(targets).reduce((results, target) => {
|
|
3262
|
+
let value = targets[target];
|
|
3263
|
+
const unreleasedLabel = _targets.unreleasedLabels[target];
|
|
3264
|
+
if (typeof value === "string" && unreleasedLabel !== value) {
|
|
3265
|
+
value = prettifyVersion(value);
|
|
3266
|
+
}
|
|
3267
|
+
results[target] = value;
|
|
3268
|
+
return results;
|
|
3269
|
+
}, {});
|
|
3270
|
+
}
|
|
3271
|
+
|
|
3272
|
+
//# sourceMappingURL=pretty.js.map
|
|
3273
|
+
|
|
3274
|
+
|
|
3275
|
+
/***/ }),
|
|
3276
|
+
|
|
3277
|
+
/***/ 6605:
|
|
3278
|
+
/***/ (function(__unused_webpack_module, exports) {
|
|
3279
|
+
|
|
3280
|
+
"use strict";
|
|
3281
|
+
|
|
3282
|
+
|
|
3283
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
3284
|
+
value: true
|
|
3285
|
+
}));
|
|
3286
|
+
exports.unreleasedLabels = exports.browserNameMap = void 0;
|
|
3287
|
+
const unreleasedLabels = exports.unreleasedLabels = {
|
|
3288
|
+
safari: "tp"
|
|
3289
|
+
};
|
|
3290
|
+
const browserNameMap = exports.browserNameMap = {
|
|
3291
|
+
and_chr: "chrome",
|
|
3292
|
+
and_ff: "firefox",
|
|
3293
|
+
android: "android",
|
|
3294
|
+
chrome: "chrome",
|
|
3295
|
+
edge: "edge",
|
|
3296
|
+
firefox: "firefox",
|
|
3297
|
+
ie: "ie",
|
|
3298
|
+
ie_mob: "ie",
|
|
3299
|
+
ios_saf: "ios",
|
|
3300
|
+
node: "node",
|
|
3301
|
+
deno: "deno",
|
|
3302
|
+
op_mob: "opera_mobile",
|
|
3303
|
+
opera: "opera",
|
|
3304
|
+
safari: "safari",
|
|
3305
|
+
samsung: "samsung"
|
|
3306
|
+
};
|
|
3307
|
+
|
|
3308
|
+
//# sourceMappingURL=targets.js.map
|
|
3309
|
+
|
|
3310
|
+
|
|
3311
|
+
/***/ }),
|
|
3312
|
+
|
|
3313
|
+
/***/ 274:
|
|
3314
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3315
|
+
|
|
3316
|
+
"use strict";
|
|
3317
|
+
|
|
3318
|
+
|
|
3319
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
3320
|
+
value: true
|
|
3321
|
+
}));
|
|
3322
|
+
exports.getHighestUnreleased = getHighestUnreleased;
|
|
3323
|
+
exports.getLowestImplementedVersion = getLowestImplementedVersion;
|
|
3324
|
+
exports.getLowestUnreleased = getLowestUnreleased;
|
|
3325
|
+
exports.isUnreleasedVersion = isUnreleasedVersion;
|
|
3326
|
+
exports.semverMin = semverMin;
|
|
3327
|
+
exports.semverify = semverify;
|
|
3328
|
+
var _semver = __webpack_require__(3167);
|
|
3329
|
+
var _helperValidatorOption = __webpack_require__(8809);
|
|
3330
|
+
var _targets = __webpack_require__(6605);
|
|
3331
|
+
const versionRegExp = /^(?:\d+|\d(?:\d?[^\d\n\r\u2028\u2029]\d+|\d{2,}(?:[^\d\n\r\u2028\u2029]\d+)?))$/;
|
|
3332
|
+
const v = new _helperValidatorOption.OptionValidator("@babel/helper-compilation-targets");
|
|
3333
|
+
function semverMin(first, second) {
|
|
3334
|
+
return first && _semver.lt(first, second) ? first : second;
|
|
3335
|
+
}
|
|
3336
|
+
function semverify(version) {
|
|
3337
|
+
if (typeof version === "string" && _semver.valid(version)) {
|
|
3338
|
+
return version;
|
|
3339
|
+
}
|
|
3340
|
+
v.invariant(typeof version === "number" || typeof version === "string" && versionRegExp.test(version), `'${version}' is not a valid version`);
|
|
3341
|
+
version = version.toString();
|
|
3342
|
+
let pos = 0;
|
|
3343
|
+
let num = 0;
|
|
3344
|
+
while ((pos = version.indexOf(".", pos + 1)) > 0) {
|
|
3345
|
+
num++;
|
|
3346
|
+
}
|
|
3347
|
+
return version + ".0".repeat(2 - num);
|
|
3348
|
+
}
|
|
3349
|
+
function isUnreleasedVersion(version, env) {
|
|
3350
|
+
const unreleasedLabel = _targets.unreleasedLabels[env];
|
|
3351
|
+
return !!unreleasedLabel && unreleasedLabel === version.toString().toLowerCase();
|
|
3352
|
+
}
|
|
3353
|
+
function getLowestUnreleased(a, b, env) {
|
|
3354
|
+
const unreleasedLabel = _targets.unreleasedLabels[env];
|
|
3355
|
+
if (a === unreleasedLabel) {
|
|
3356
|
+
return b;
|
|
3357
|
+
}
|
|
3358
|
+
if (b === unreleasedLabel) {
|
|
3359
|
+
return a;
|
|
3360
|
+
}
|
|
3361
|
+
return semverMin(a, b);
|
|
3362
|
+
}
|
|
3363
|
+
function getHighestUnreleased(a, b, env) {
|
|
3364
|
+
return getLowestUnreleased(a, b, env) === a ? b : a;
|
|
3365
|
+
}
|
|
3366
|
+
function getLowestImplementedVersion(plugin, environment) {
|
|
3367
|
+
const result = plugin[environment];
|
|
3368
|
+
if (!result && environment === "android") {
|
|
3369
|
+
return plugin.chrome;
|
|
3370
|
+
}
|
|
3371
|
+
return result;
|
|
3372
|
+
}
|
|
3373
|
+
|
|
3374
|
+
//# sourceMappingURL=utils.js.map
|
|
3375
|
+
|
|
3376
|
+
|
|
3377
|
+
/***/ }),
|
|
3378
|
+
|
|
3379
|
+
/***/ 1663:
|
|
3380
|
+
/***/ (function(__unused_webpack_module, exports) {
|
|
3381
|
+
|
|
3382
|
+
"use strict";
|
|
3383
|
+
var __webpack_unused_export__;
|
|
3384
|
+
|
|
3385
|
+
|
|
3386
|
+
__webpack_unused_export__ = ({
|
|
3387
|
+
value: true
|
|
3388
|
+
});
|
|
3389
|
+
exports.xe = declare;
|
|
3390
|
+
__webpack_unused_export__ = void 0;
|
|
3391
|
+
const apiPolyfills = {
|
|
3392
|
+
assertVersion: api => range => {
|
|
3393
|
+
throwVersionError(range, api.version);
|
|
3394
|
+
}
|
|
3395
|
+
};
|
|
3396
|
+
Object.assign(apiPolyfills, {
|
|
3397
|
+
targets: () => () => {
|
|
3398
|
+
return {};
|
|
3399
|
+
},
|
|
3400
|
+
assumption: () => () => {
|
|
3401
|
+
return undefined;
|
|
3402
|
+
},
|
|
3403
|
+
addExternalDependency: () => () => {}
|
|
3404
|
+
});
|
|
3405
|
+
function declare(builder) {
|
|
3406
|
+
return (api, options, dirname) => {
|
|
3407
|
+
let clonedApi;
|
|
3408
|
+
for (const name of Object.keys(apiPolyfills)) {
|
|
3409
|
+
if (api[name]) continue;
|
|
3410
|
+
clonedApi != null ? clonedApi : clonedApi = copyApiObject(api);
|
|
3411
|
+
clonedApi[name] = apiPolyfills[name](clonedApi);
|
|
3412
|
+
}
|
|
3413
|
+
return builder(clonedApi != null ? clonedApi : api, options || {}, dirname);
|
|
3414
|
+
};
|
|
3415
|
+
}
|
|
3416
|
+
const declarePreset = __webpack_unused_export__ = declare;
|
|
3417
|
+
function copyApiObject(api) {
|
|
3418
|
+
let proto = null;
|
|
3419
|
+
if (typeof api.version === "string" && api.version.startsWith("7.")) {
|
|
3420
|
+
proto = Object.getPrototypeOf(api);
|
|
3421
|
+
if (proto && (!hasOwnProperty.call(proto, "version") || !hasOwnProperty.call(proto, "transform") || !hasOwnProperty.call(proto, "template") || !hasOwnProperty.call(proto, "types"))) {
|
|
3422
|
+
proto = null;
|
|
3423
|
+
}
|
|
3424
|
+
}
|
|
3425
|
+
return Object.assign({}, proto, api);
|
|
3426
|
+
}
|
|
3427
|
+
function throwVersionError(range, version) {
|
|
3428
|
+
if (typeof range === "number") {
|
|
3429
|
+
if (!Number.isInteger(range)) {
|
|
3430
|
+
throw new Error("Expected string or integer value.");
|
|
3431
|
+
}
|
|
3432
|
+
range = `^${range}.0.0-0`;
|
|
3433
|
+
}
|
|
3434
|
+
if (typeof range !== "string") {
|
|
3435
|
+
throw new Error("Expected string or integer value.");
|
|
3436
|
+
}
|
|
3437
|
+
const limit = Error.stackTraceLimit;
|
|
3438
|
+
if (typeof limit === "number" && limit < 25) {
|
|
3439
|
+
Error.stackTraceLimit = 25;
|
|
3440
|
+
}
|
|
3441
|
+
let err;
|
|
3442
|
+
if (version.startsWith("7.")) {
|
|
3443
|
+
err = new Error(`Requires Babel "^7.0.0-beta.41", but was loaded with "${version}". ` + `You'll need to update your @babel/core version.`);
|
|
3444
|
+
} else {
|
|
3445
|
+
err = new Error(`Requires Babel "${range}", but was loaded with "${version}". ` + `If you are sure you have a compatible version of @babel/core, ` + `it is likely that something in your build process is loading the ` + `wrong version. Inspect the stack trace of this error to look for ` + `the first entry that doesn't mention "@babel/core" or "babel-core" ` + `to see what is calling Babel.`);
|
|
3446
|
+
}
|
|
3447
|
+
if (typeof limit === "number") {
|
|
3448
|
+
Error.stackTraceLimit = limit;
|
|
3449
|
+
}
|
|
3450
|
+
throw Object.assign(err, {
|
|
3451
|
+
code: "BABEL_VERSION_UNSUPPORTED",
|
|
3452
|
+
version,
|
|
3453
|
+
range
|
|
3454
|
+
});
|
|
3455
|
+
}
|
|
3456
|
+
|
|
3457
|
+
//# sourceMappingURL=index.js.map
|
|
3458
|
+
|
|
3459
|
+
|
|
3460
|
+
/***/ }),
|
|
3461
|
+
|
|
3462
|
+
/***/ 9147:
|
|
3463
|
+
/***/ (function(__unused_webpack_module, exports) {
|
|
3464
|
+
|
|
3465
|
+
"use strict";
|
|
3466
|
+
|
|
3467
|
+
|
|
3468
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
3469
|
+
value: true
|
|
3470
|
+
}));
|
|
3471
|
+
exports.findSuggestion = findSuggestion;
|
|
3472
|
+
const {
|
|
3473
|
+
min
|
|
3474
|
+
} = Math;
|
|
3475
|
+
function levenshtein(a, b) {
|
|
3476
|
+
let t = [],
|
|
3477
|
+
u = [],
|
|
3478
|
+
i,
|
|
3479
|
+
j;
|
|
3480
|
+
const m = a.length,
|
|
3481
|
+
n = b.length;
|
|
3482
|
+
if (!m) {
|
|
3483
|
+
return n;
|
|
3484
|
+
}
|
|
3485
|
+
if (!n) {
|
|
3486
|
+
return m;
|
|
3487
|
+
}
|
|
3488
|
+
for (j = 0; j <= n; j++) {
|
|
3489
|
+
t[j] = j;
|
|
3490
|
+
}
|
|
3491
|
+
for (i = 1; i <= m; i++) {
|
|
3492
|
+
for (u = [i], j = 1; j <= n; j++) {
|
|
3493
|
+
u[j] = a[i - 1] === b[j - 1] ? t[j - 1] : min(t[j - 1], t[j], u[j - 1]) + 1;
|
|
3494
|
+
}
|
|
3495
|
+
t = u;
|
|
3496
|
+
}
|
|
3497
|
+
return u[n];
|
|
3498
|
+
}
|
|
3499
|
+
function findSuggestion(str, arr) {
|
|
3500
|
+
const distances = arr.map(el => levenshtein(el, str));
|
|
3501
|
+
return arr[distances.indexOf(min(...distances))];
|
|
3502
|
+
}
|
|
3503
|
+
|
|
3504
|
+
//# sourceMappingURL=find-suggestion.js.map
|
|
3505
|
+
|
|
3506
|
+
|
|
3507
|
+
/***/ }),
|
|
3508
|
+
|
|
3509
|
+
/***/ 8809:
|
|
3510
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3511
|
+
|
|
3512
|
+
"use strict";
|
|
3513
|
+
|
|
3514
|
+
|
|
3515
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
3516
|
+
value: true
|
|
3517
|
+
}));
|
|
3518
|
+
Object.defineProperty(exports, "OptionValidator", ({
|
|
3519
|
+
enumerable: true,
|
|
3520
|
+
get: function () {
|
|
3521
|
+
return _validator.OptionValidator;
|
|
3522
|
+
}
|
|
3523
|
+
}));
|
|
3524
|
+
Object.defineProperty(exports, "findSuggestion", ({
|
|
3525
|
+
enumerable: true,
|
|
3526
|
+
get: function () {
|
|
3527
|
+
return _findSuggestion.findSuggestion;
|
|
3528
|
+
}
|
|
3529
|
+
}));
|
|
3530
|
+
var _validator = __webpack_require__(271);
|
|
3531
|
+
var _findSuggestion = __webpack_require__(9147);
|
|
3532
|
+
|
|
3533
|
+
//# sourceMappingURL=index.js.map
|
|
3534
|
+
|
|
3535
|
+
|
|
3536
|
+
/***/ }),
|
|
3537
|
+
|
|
3538
|
+
/***/ 271:
|
|
3539
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3540
|
+
|
|
3541
|
+
"use strict";
|
|
3542
|
+
|
|
3543
|
+
|
|
3544
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
3545
|
+
value: true
|
|
3546
|
+
}));
|
|
3547
|
+
exports.OptionValidator = void 0;
|
|
3548
|
+
var _findSuggestion = __webpack_require__(9147);
|
|
3549
|
+
class OptionValidator {
|
|
3550
|
+
constructor(descriptor) {
|
|
3551
|
+
this.descriptor = descriptor;
|
|
3552
|
+
}
|
|
3553
|
+
validateTopLevelOptions(options, TopLevelOptionShape) {
|
|
3554
|
+
const validOptionNames = Object.keys(TopLevelOptionShape);
|
|
3555
|
+
for (const option of Object.keys(options)) {
|
|
3556
|
+
if (!validOptionNames.includes(option)) {
|
|
3557
|
+
throw new Error(this.formatMessage(`'${option}' is not a valid top-level option.
|
|
3558
|
+
- Did you mean '${(0, _findSuggestion.findSuggestion)(option, validOptionNames)}'?`));
|
|
3559
|
+
}
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
validateBooleanOption(name, value, defaultValue) {
|
|
3563
|
+
if (value === undefined) {
|
|
3564
|
+
return defaultValue;
|
|
3565
|
+
} else {
|
|
3566
|
+
this.invariant(typeof value === "boolean", `'${name}' option must be a boolean.`);
|
|
3567
|
+
}
|
|
3568
|
+
return value;
|
|
3569
|
+
}
|
|
3570
|
+
validateStringOption(name, value, defaultValue) {
|
|
3571
|
+
if (value === undefined) {
|
|
3572
|
+
return defaultValue;
|
|
3573
|
+
} else {
|
|
3574
|
+
this.invariant(typeof value === "string", `'${name}' option must be a string.`);
|
|
3575
|
+
}
|
|
3576
|
+
return value;
|
|
3577
|
+
}
|
|
3578
|
+
invariant(condition, message) {
|
|
3579
|
+
if (!condition) {
|
|
3580
|
+
throw new Error(this.formatMessage(message));
|
|
3581
|
+
}
|
|
3582
|
+
}
|
|
3583
|
+
formatMessage(message) {
|
|
3584
|
+
return `${this.descriptor}: ${message}`;
|
|
3585
|
+
}
|
|
3586
|
+
}
|
|
3587
|
+
exports.OptionValidator = OptionValidator;
|
|
3588
|
+
|
|
3589
|
+
//# sourceMappingURL=validator.js.map
|
|
3590
|
+
|
|
3591
|
+
|
|
3592
|
+
/***/ }),
|
|
3593
|
+
|
|
3594
|
+
/***/ 8967:
|
|
3595
|
+
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
3596
|
+
|
|
3597
|
+
"use strict";
|
|
3598
|
+
var _babel_core__WEBPACK_IMPORTED_MODULE_2___namespace_cache;
|
|
3599
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3600
|
+
/* harmony export */ A: function() { return /* binding */ definePolyfillProvider; }
|
|
3601
|
+
/* harmony export */ });
|
|
3602
|
+
/* harmony import */ var _babel_helper_plugin_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1663);
|
|
3603
|
+
/* harmony import */ var _babel_helper_compilation_targets__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9287);
|
|
3604
|
+
/* harmony import */ var _babel_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4805);
|
|
3605
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6928);
|
|
3606
|
+
/* harmony import */ var lodash_debounce__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3571);
|
|
3607
|
+
/* harmony import */ var resolve__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(2388);
|
|
3608
|
+
/* harmony import */ var module__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(3339);
|
|
3609
|
+
|
|
3610
|
+
|
|
3611
|
+
|
|
3612
|
+
|
|
3613
|
+
|
|
3614
|
+
|
|
3615
|
+
|
|
3616
|
+
|
|
3617
|
+
const {
|
|
3618
|
+
types: t$1,
|
|
3619
|
+
template: template
|
|
3620
|
+
} = _babel_core__WEBPACK_IMPORTED_MODULE_2__ || /*#__PURE__*/ (_babel_core__WEBPACK_IMPORTED_MODULE_2___namespace_cache || (_babel_core__WEBPACK_IMPORTED_MODULE_2___namespace_cache = __webpack_require__.t(_babel_core__WEBPACK_IMPORTED_MODULE_2__, 2)));
|
|
3621
|
+
const PossibleGlobalObjects = new Set(["global", "globalThis", "self", "window"]);
|
|
3622
|
+
function intersection(a, b) {
|
|
3623
|
+
const result = new Set();
|
|
3624
|
+
a.forEach(v => b.has(v) && result.add(v));
|
|
3625
|
+
return result;
|
|
3626
|
+
}
|
|
3627
|
+
function has$1(object, key) {
|
|
3628
|
+
return Object.prototype.hasOwnProperty.call(object, key);
|
|
3629
|
+
}
|
|
3630
|
+
function resolve$1(path, seen = new Set()) {
|
|
3631
|
+
if (seen.has(path)) return;
|
|
3632
|
+
seen.add(path);
|
|
3633
|
+
if (path.isVariableDeclarator()) {
|
|
3634
|
+
if (path.get("id").isIdentifier()) {
|
|
3635
|
+
return resolve$1(path.get("init"), seen);
|
|
3636
|
+
}
|
|
3637
|
+
} else if (path.isReferencedIdentifier()) {
|
|
3638
|
+
const binding = path.scope.getBinding(path.node.name);
|
|
3639
|
+
if (!binding) return path;
|
|
3640
|
+
if (!binding.constant) return;
|
|
3641
|
+
return resolve$1(binding.path, seen);
|
|
3642
|
+
}
|
|
3643
|
+
return path;
|
|
3644
|
+
}
|
|
3645
|
+
function resolveId(path) {
|
|
3646
|
+
if (path.isIdentifier() && !path.scope.hasBinding(path.node.name, /* noGlobals */true)) {
|
|
3647
|
+
return path.node.name;
|
|
3648
|
+
}
|
|
3649
|
+
|
|
3650
|
+
// globalThis.Object / window.Array / self.Map / global.Set -> resolve to
|
|
3651
|
+
// the property name, because accessing a built-in through a global object
|
|
3652
|
+
// reference is equivalent to accessing it directly.
|
|
3653
|
+
if (path.isMemberExpression() && !path.node.computed) {
|
|
3654
|
+
const object = path.get("object");
|
|
3655
|
+
const property = path.get("property");
|
|
3656
|
+
if (object.isIdentifier() && !object.scope.hasBinding(object.node.name, /* noGlobals */true) && PossibleGlobalObjects.has(object.node.name) && property.isIdentifier()) {
|
|
3657
|
+
return property.node.name;
|
|
3658
|
+
}
|
|
3659
|
+
}
|
|
3660
|
+
const resolved = resolve$1(path);
|
|
3661
|
+
if (resolved != null && resolved.isIdentifier()) {
|
|
3662
|
+
return resolved.node.name;
|
|
3663
|
+
}
|
|
3664
|
+
}
|
|
3665
|
+
function resolveKey(path, computed = false) {
|
|
3666
|
+
const {
|
|
3667
|
+
scope
|
|
3668
|
+
} = path;
|
|
3669
|
+
if (path.isStringLiteral()) return path.node.value;
|
|
3670
|
+
const isIdentifier = path.isIdentifier();
|
|
3671
|
+
if (isIdentifier && !(computed || path.parent.computed)) {
|
|
3672
|
+
return path.node.name;
|
|
3673
|
+
}
|
|
3674
|
+
if (computed && path.isMemberExpression() && path.get("object").isIdentifier({
|
|
3675
|
+
name: "Symbol"
|
|
3676
|
+
}) && !scope.hasBinding("Symbol", /* noGlobals */true)) {
|
|
3677
|
+
const sym = resolveKey(path.get("property"), path.node.computed);
|
|
3678
|
+
if (sym) return "Symbol." + sym;
|
|
3679
|
+
}
|
|
3680
|
+
if (isIdentifier ? scope.hasBinding(path.node.name, /* noGlobals */true) : path.isPure()) {
|
|
3681
|
+
const {
|
|
3682
|
+
value
|
|
3683
|
+
} = path.evaluate();
|
|
3684
|
+
if (typeof value === "string") return value;
|
|
3685
|
+
}
|
|
3686
|
+
}
|
|
3687
|
+
function resolveInstance(obj, seen) {
|
|
3688
|
+
const source = resolveSource(obj, seen);
|
|
3689
|
+
return source.placement === "prototype" ? source.id : null;
|
|
3690
|
+
}
|
|
3691
|
+
function resolveSource(obj, seen) {
|
|
3692
|
+
if (seen.has(obj)) {
|
|
3693
|
+
return {
|
|
3694
|
+
id: null,
|
|
3695
|
+
placement: null
|
|
3696
|
+
};
|
|
3697
|
+
}
|
|
3698
|
+
seen.add(obj);
|
|
3699
|
+
if (obj.isMemberExpression() && obj.get("property").isIdentifier({
|
|
3700
|
+
name: "prototype"
|
|
3701
|
+
})) {
|
|
3702
|
+
const id = resolveId(obj.get("object"));
|
|
3703
|
+
if (id) {
|
|
3704
|
+
return {
|
|
3705
|
+
id,
|
|
3706
|
+
placement: "prototype"
|
|
3707
|
+
};
|
|
3708
|
+
}
|
|
3709
|
+
return {
|
|
3710
|
+
id: null,
|
|
3711
|
+
placement: null
|
|
3712
|
+
};
|
|
3713
|
+
}
|
|
3714
|
+
const id = resolveId(obj);
|
|
3715
|
+
if (id) {
|
|
3716
|
+
return {
|
|
3717
|
+
id,
|
|
3718
|
+
placement: "static"
|
|
3719
|
+
};
|
|
3720
|
+
}
|
|
3721
|
+
const path = resolve$1(obj);
|
|
3722
|
+
switch (path == null ? void 0 : path.type) {
|
|
3723
|
+
case "NullLiteral":
|
|
3724
|
+
return {
|
|
3725
|
+
id: null,
|
|
3726
|
+
placement: null
|
|
3727
|
+
};
|
|
3728
|
+
case "RegExpLiteral":
|
|
3729
|
+
return {
|
|
3730
|
+
id: "RegExp",
|
|
3731
|
+
placement: "prototype"
|
|
3732
|
+
};
|
|
3733
|
+
case "StringLiteral":
|
|
3734
|
+
case "TemplateLiteral":
|
|
3735
|
+
return {
|
|
3736
|
+
id: "String",
|
|
3737
|
+
placement: "prototype"
|
|
3738
|
+
};
|
|
3739
|
+
case "NumericLiteral":
|
|
3740
|
+
return {
|
|
3741
|
+
id: "Number",
|
|
3742
|
+
placement: "prototype"
|
|
3743
|
+
};
|
|
3744
|
+
case "BooleanLiteral":
|
|
3745
|
+
return {
|
|
3746
|
+
id: "Boolean",
|
|
3747
|
+
placement: "prototype"
|
|
3748
|
+
};
|
|
3749
|
+
case "BigIntLiteral":
|
|
3750
|
+
return {
|
|
3751
|
+
id: "BigInt",
|
|
3752
|
+
placement: "prototype"
|
|
3753
|
+
};
|
|
3754
|
+
case "ObjectExpression":
|
|
3755
|
+
return {
|
|
3756
|
+
id: "Object",
|
|
3757
|
+
placement: "prototype"
|
|
3758
|
+
};
|
|
3759
|
+
case "ArrayExpression":
|
|
3760
|
+
return {
|
|
3761
|
+
id: "Array",
|
|
3762
|
+
placement: "prototype"
|
|
3763
|
+
};
|
|
3764
|
+
case "FunctionExpression":
|
|
3765
|
+
case "ArrowFunctionExpression":
|
|
3766
|
+
case "ClassExpression":
|
|
3767
|
+
return {
|
|
3768
|
+
id: "Function",
|
|
3769
|
+
placement: "prototype"
|
|
3770
|
+
};
|
|
3771
|
+
// new Constructor() -> resolve the constructor name
|
|
3772
|
+
case "NewExpression":
|
|
3773
|
+
{
|
|
3774
|
+
const calleeId = resolveId(path.get("callee"));
|
|
3775
|
+
if (calleeId) return {
|
|
3776
|
+
id: calleeId,
|
|
3777
|
+
placement: "prototype"
|
|
3778
|
+
};
|
|
3779
|
+
return {
|
|
3780
|
+
id: null,
|
|
3781
|
+
placement: null
|
|
3782
|
+
};
|
|
3783
|
+
}
|
|
3784
|
+
// Unary expressions -> result type depends on operator
|
|
3785
|
+
case "UnaryExpression":
|
|
3786
|
+
{
|
|
3787
|
+
const {
|
|
3788
|
+
operator
|
|
3789
|
+
} = path.node;
|
|
3790
|
+
if (operator === "typeof") return {
|
|
3791
|
+
id: "String",
|
|
3792
|
+
placement: "prototype"
|
|
3793
|
+
};
|
|
3794
|
+
if (operator === "!" || operator === "delete") return {
|
|
3795
|
+
id: "Boolean",
|
|
3796
|
+
placement: "prototype"
|
|
3797
|
+
};
|
|
3798
|
+
// Unary + always produces Number (throws on BigInt)
|
|
3799
|
+
if (operator === "+") return {
|
|
3800
|
+
id: "Number",
|
|
3801
|
+
placement: "prototype"
|
|
3802
|
+
};
|
|
3803
|
+
// Unary - and ~ can produce Number or BigInt depending on operand
|
|
3804
|
+
if (operator === "-" || operator === "~") {
|
|
3805
|
+
const arg = resolveInstance(path.get("argument"), seen);
|
|
3806
|
+
if (arg === "BigInt") return {
|
|
3807
|
+
id: "BigInt",
|
|
3808
|
+
placement: "prototype"
|
|
3809
|
+
};
|
|
3810
|
+
if (arg !== null) return {
|
|
3811
|
+
id: "Number",
|
|
3812
|
+
placement: "prototype"
|
|
3813
|
+
};
|
|
3814
|
+
return {
|
|
3815
|
+
id: null,
|
|
3816
|
+
placement: null
|
|
3817
|
+
};
|
|
3818
|
+
}
|
|
3819
|
+
return {
|
|
3820
|
+
id: null,
|
|
3821
|
+
placement: null
|
|
3822
|
+
};
|
|
3823
|
+
}
|
|
3824
|
+
// ++i, i++ produce Number or BigInt depending on the argument
|
|
3825
|
+
case "UpdateExpression":
|
|
3826
|
+
{
|
|
3827
|
+
const arg = resolveInstance(path.get("argument"), seen);
|
|
3828
|
+
if (arg === "BigInt") return {
|
|
3829
|
+
id: "BigInt",
|
|
3830
|
+
placement: "prototype"
|
|
3831
|
+
};
|
|
3832
|
+
if (arg !== null) return {
|
|
3833
|
+
id: "Number",
|
|
3834
|
+
placement: "prototype"
|
|
3835
|
+
};
|
|
3836
|
+
return {
|
|
3837
|
+
id: null,
|
|
3838
|
+
placement: null
|
|
3839
|
+
};
|
|
3840
|
+
}
|
|
3841
|
+
// Binary expressions -> result type depends on operator
|
|
3842
|
+
case "BinaryExpression":
|
|
3843
|
+
{
|
|
3844
|
+
const {
|
|
3845
|
+
operator
|
|
3846
|
+
} = path.node;
|
|
3847
|
+
if (operator === "==" || operator === "!=" || operator === "===" || operator === "!==" || operator === "<" || operator === ">" || operator === "<=" || operator === ">=" || operator === "instanceof" || operator === "in") {
|
|
3848
|
+
return {
|
|
3849
|
+
id: "Boolean",
|
|
3850
|
+
placement: "prototype"
|
|
3851
|
+
};
|
|
3852
|
+
}
|
|
3853
|
+
// >>> always produces Number
|
|
3854
|
+
if (operator === ">>>") {
|
|
3855
|
+
return {
|
|
3856
|
+
id: "Number",
|
|
3857
|
+
placement: "prototype"
|
|
3858
|
+
};
|
|
3859
|
+
}
|
|
3860
|
+
// Arithmetic and bitwise operators can produce Number or BigInt
|
|
3861
|
+
if (operator === "-" || operator === "*" || operator === "/" || operator === "%" || operator === "**" || operator === "&" || operator === "|" || operator === "^" || operator === "<<" || operator === ">>") {
|
|
3862
|
+
const left = resolveInstance(path.get("left"), seen);
|
|
3863
|
+
const right = resolveInstance(path.get("right"), seen);
|
|
3864
|
+
if (left === "BigInt" && right === "BigInt") {
|
|
3865
|
+
return {
|
|
3866
|
+
id: "BigInt",
|
|
3867
|
+
placement: "prototype"
|
|
3868
|
+
};
|
|
3869
|
+
}
|
|
3870
|
+
if (left !== null && right !== null) {
|
|
3871
|
+
return {
|
|
3872
|
+
id: "Number",
|
|
3873
|
+
placement: "prototype"
|
|
3874
|
+
};
|
|
3875
|
+
}
|
|
3876
|
+
return {
|
|
3877
|
+
id: null,
|
|
3878
|
+
placement: null
|
|
3879
|
+
};
|
|
3880
|
+
}
|
|
3881
|
+
// + depends on operand types: string wins, otherwise number or bigint
|
|
3882
|
+
if (operator === "+") {
|
|
3883
|
+
const left = resolveInstance(path.get("left"), seen);
|
|
3884
|
+
const right = resolveInstance(path.get("right"), seen);
|
|
3885
|
+
if (left === "String" || right === "String") {
|
|
3886
|
+
return {
|
|
3887
|
+
id: "String",
|
|
3888
|
+
placement: "prototype"
|
|
3889
|
+
};
|
|
3890
|
+
}
|
|
3891
|
+
if (left === "Number" && right === "Number") {
|
|
3892
|
+
return {
|
|
3893
|
+
id: "Number",
|
|
3894
|
+
placement: "prototype"
|
|
3895
|
+
};
|
|
3896
|
+
}
|
|
3897
|
+
if (left === "BigInt" && right === "BigInt") {
|
|
3898
|
+
return {
|
|
3899
|
+
id: "BigInt",
|
|
3900
|
+
placement: "prototype"
|
|
3901
|
+
};
|
|
3902
|
+
}
|
|
3903
|
+
}
|
|
3904
|
+
return {
|
|
3905
|
+
id: null,
|
|
3906
|
+
placement: null
|
|
3907
|
+
};
|
|
3908
|
+
}
|
|
3909
|
+
// (a, b, c) -> the result is the last expression
|
|
3910
|
+
case "SequenceExpression":
|
|
3911
|
+
{
|
|
3912
|
+
const expressions = path.get("expressions");
|
|
3913
|
+
return resolveSource(expressions[expressions.length - 1], seen);
|
|
3914
|
+
}
|
|
3915
|
+
// a = b -> the result is the right side
|
|
3916
|
+
case "AssignmentExpression":
|
|
3917
|
+
{
|
|
3918
|
+
if (path.node.operator === "=") {
|
|
3919
|
+
return resolveSource(path.get("right"), seen);
|
|
3920
|
+
}
|
|
3921
|
+
return {
|
|
3922
|
+
id: null,
|
|
3923
|
+
placement: null
|
|
3924
|
+
};
|
|
3925
|
+
}
|
|
3926
|
+
// a ? b : c -> if both branches resolve to the same type, use it
|
|
3927
|
+
case "ConditionalExpression":
|
|
3928
|
+
{
|
|
3929
|
+
const consequent = resolveSource(path.get("consequent"), seen);
|
|
3930
|
+
const alternate = resolveSource(path.get("alternate"), seen);
|
|
3931
|
+
if (consequent.id && consequent.id === alternate.id) {
|
|
3932
|
+
return consequent;
|
|
3933
|
+
}
|
|
3934
|
+
return {
|
|
3935
|
+
id: null,
|
|
3936
|
+
placement: null
|
|
3937
|
+
};
|
|
3938
|
+
}
|
|
3939
|
+
// (expr) -> unwrap parenthesized expressions
|
|
3940
|
+
case "ParenthesizedExpression":
|
|
3941
|
+
return resolveSource(path.get("expression"), seen);
|
|
3942
|
+
// TypeScript / Flow type wrappers -> unwrap to the inner expression
|
|
3943
|
+
case "TSAsExpression":
|
|
3944
|
+
case "TSSatisfiesExpression":
|
|
3945
|
+
case "TSNonNullExpression":
|
|
3946
|
+
case "TSInstantiationExpression":
|
|
3947
|
+
case "TSTypeAssertion":
|
|
3948
|
+
case "TypeCastExpression":
|
|
3949
|
+
return resolveSource(path.get("expression"), seen);
|
|
3950
|
+
}
|
|
3951
|
+
return {
|
|
3952
|
+
id: null,
|
|
3953
|
+
placement: null
|
|
3954
|
+
};
|
|
3955
|
+
}
|
|
3956
|
+
function getImportSource({
|
|
3957
|
+
node
|
|
3958
|
+
}) {
|
|
3959
|
+
if (node.specifiers.length === 0) return node.source.value;
|
|
3960
|
+
}
|
|
3961
|
+
function getRequireSource({
|
|
3962
|
+
node
|
|
3963
|
+
}) {
|
|
3964
|
+
if (!t$1.isExpressionStatement(node)) return;
|
|
3965
|
+
const {
|
|
3966
|
+
expression
|
|
3967
|
+
} = node;
|
|
3968
|
+
if (t$1.isCallExpression(expression) && t$1.isIdentifier(expression.callee) && expression.callee.name === "require" && expression.arguments.length === 1 && t$1.isStringLiteral(expression.arguments[0])) {
|
|
3969
|
+
return expression.arguments[0].value;
|
|
3970
|
+
}
|
|
3971
|
+
}
|
|
3972
|
+
function hoist(node) {
|
|
3973
|
+
// @ts-expect-error
|
|
3974
|
+
node._blockHoist = 3;
|
|
3975
|
+
return node;
|
|
3976
|
+
}
|
|
3977
|
+
function createUtilsGetter(cache) {
|
|
3978
|
+
return path => {
|
|
3979
|
+
const prog = path.findParent(p => p.isProgram());
|
|
3980
|
+
return {
|
|
3981
|
+
injectGlobalImport(url, moduleName) {
|
|
3982
|
+
cache.storeAnonymous(prog, url, moduleName, (isScript, source) => {
|
|
3983
|
+
return isScript ? template.statement.ast`require(${source})` : t$1.importDeclaration([], source);
|
|
3984
|
+
});
|
|
3985
|
+
},
|
|
3986
|
+
injectNamedImport(url, name, hint = name, moduleName) {
|
|
3987
|
+
return cache.storeNamed(prog, url, name, moduleName, (isScript, source, name) => {
|
|
3988
|
+
const id = prog.scope.generateUidIdentifier(hint);
|
|
3989
|
+
return {
|
|
3990
|
+
node: isScript ? hoist(template.statement.ast`
|
|
3991
|
+
var ${id} = require(${source}).${name}
|
|
3992
|
+
`) : t$1.importDeclaration([t$1.importSpecifier(id, name)], source),
|
|
3993
|
+
name: id.name
|
|
3994
|
+
};
|
|
3995
|
+
});
|
|
3996
|
+
},
|
|
3997
|
+
injectDefaultImport(url, hint = url, moduleName) {
|
|
3998
|
+
return cache.storeNamed(prog, url, "default", moduleName, (isScript, source) => {
|
|
3999
|
+
const id = prog.scope.generateUidIdentifier(hint);
|
|
4000
|
+
return {
|
|
4001
|
+
node: isScript ? hoist(template.statement.ast`var ${id} = require(${source})`) : t$1.importDeclaration([t$1.importDefaultSpecifier(id)], source),
|
|
4002
|
+
name: id.name
|
|
4003
|
+
};
|
|
4004
|
+
});
|
|
4005
|
+
}
|
|
4006
|
+
};
|
|
4007
|
+
};
|
|
4008
|
+
}
|
|
4009
|
+
|
|
4010
|
+
const {
|
|
4011
|
+
types: t
|
|
4012
|
+
} = _babel_core__WEBPACK_IMPORTED_MODULE_2__ || /*#__PURE__*/ (_babel_core__WEBPACK_IMPORTED_MODULE_2___namespace_cache || (_babel_core__WEBPACK_IMPORTED_MODULE_2___namespace_cache = __webpack_require__.t(_babel_core__WEBPACK_IMPORTED_MODULE_2__, 2)));
|
|
4013
|
+
class ImportsCachedInjector {
|
|
4014
|
+
constructor(resolver, getPreferredIndex) {
|
|
4015
|
+
this._imports = new WeakMap();
|
|
4016
|
+
this._anonymousImports = new WeakMap();
|
|
4017
|
+
this._lastImports = new WeakMap();
|
|
4018
|
+
this._resolver = resolver;
|
|
4019
|
+
this._getPreferredIndex = getPreferredIndex;
|
|
4020
|
+
}
|
|
4021
|
+
storeAnonymous(programPath, url, moduleName, getVal) {
|
|
4022
|
+
const key = this._normalizeKey(programPath, url);
|
|
4023
|
+
const imports = this._ensure(this._anonymousImports, programPath, Set);
|
|
4024
|
+
if (imports.has(key)) return;
|
|
4025
|
+
const node = getVal(programPath.node.sourceType === "script", t.stringLiteral(this._resolver(url)));
|
|
4026
|
+
imports.add(key);
|
|
4027
|
+
this._injectImport(programPath, node, moduleName);
|
|
4028
|
+
}
|
|
4029
|
+
storeNamed(programPath, url, name, moduleName, getVal) {
|
|
4030
|
+
const key = this._normalizeKey(programPath, url, name);
|
|
4031
|
+
const imports = this._ensure(this._imports, programPath, Map);
|
|
4032
|
+
if (!imports.has(key)) {
|
|
4033
|
+
const {
|
|
4034
|
+
node,
|
|
4035
|
+
name: id
|
|
4036
|
+
} = getVal(programPath.node.sourceType === "script", t.stringLiteral(this._resolver(url)), t.identifier(name));
|
|
4037
|
+
imports.set(key, id);
|
|
4038
|
+
this._injectImport(programPath, node, moduleName);
|
|
4039
|
+
}
|
|
4040
|
+
return t.identifier(imports.get(key));
|
|
4041
|
+
}
|
|
4042
|
+
_injectImport(programPath, node, moduleName) {
|
|
4043
|
+
var _this$_lastImports$ge;
|
|
4044
|
+
const newIndex = this._getPreferredIndex(moduleName);
|
|
4045
|
+
const lastImports = (_this$_lastImports$ge = this._lastImports.get(programPath)) != null ? _this$_lastImports$ge : [];
|
|
4046
|
+
const isPathStillValid = path => path.node &&
|
|
4047
|
+
// Sometimes the AST is modified and the "last import"
|
|
4048
|
+
// we have has been replaced
|
|
4049
|
+
path.parent === programPath.node && path.container === programPath.node.body;
|
|
4050
|
+
let last;
|
|
4051
|
+
if (newIndex === Infinity) {
|
|
4052
|
+
// Fast path: we can always just insert at the end if newIndex is `Infinity`
|
|
4053
|
+
if (lastImports.length > 0) {
|
|
4054
|
+
last = lastImports[lastImports.length - 1].path;
|
|
4055
|
+
if (!isPathStillValid(last)) last = undefined;
|
|
4056
|
+
}
|
|
4057
|
+
} else {
|
|
4058
|
+
for (const [i, data] of lastImports.entries()) {
|
|
4059
|
+
const {
|
|
4060
|
+
path,
|
|
4061
|
+
index
|
|
4062
|
+
} = data;
|
|
4063
|
+
if (isPathStillValid(path)) {
|
|
4064
|
+
if (newIndex < index) {
|
|
4065
|
+
const [newPath] = path.insertBefore(node);
|
|
4066
|
+
lastImports.splice(i, 0, {
|
|
4067
|
+
path: newPath,
|
|
4068
|
+
index: newIndex
|
|
4069
|
+
});
|
|
4070
|
+
return;
|
|
4071
|
+
}
|
|
4072
|
+
last = path;
|
|
4073
|
+
}
|
|
4074
|
+
}
|
|
4075
|
+
}
|
|
4076
|
+
if (last) {
|
|
4077
|
+
const [newPath] = last.insertAfter(node);
|
|
4078
|
+
lastImports.push({
|
|
4079
|
+
path: newPath,
|
|
4080
|
+
index: newIndex
|
|
4081
|
+
});
|
|
4082
|
+
} else {
|
|
4083
|
+
const [newPath] = programPath.unshiftContainer("body", [node]);
|
|
4084
|
+
this._lastImports.set(programPath, [{
|
|
4085
|
+
path: newPath,
|
|
4086
|
+
index: newIndex
|
|
4087
|
+
}]);
|
|
4088
|
+
}
|
|
4089
|
+
}
|
|
4090
|
+
_ensure(map, programPath, Collection) {
|
|
4091
|
+
let collection = map.get(programPath);
|
|
4092
|
+
if (!collection) {
|
|
4093
|
+
collection = new Collection();
|
|
4094
|
+
map.set(programPath, collection);
|
|
4095
|
+
}
|
|
4096
|
+
return collection;
|
|
4097
|
+
}
|
|
4098
|
+
_normalizeKey(programPath, url, name = "") {
|
|
4099
|
+
const {
|
|
4100
|
+
sourceType
|
|
4101
|
+
} = programPath.node;
|
|
4102
|
+
|
|
4103
|
+
// If we rely on the imported binding (the "name" parameter), we also need to cache
|
|
4104
|
+
// based on the sourceType. This is because the module transforms change the names
|
|
4105
|
+
// of the import variables.
|
|
4106
|
+
return `${name && sourceType}::${url}::${name}`;
|
|
4107
|
+
}
|
|
4108
|
+
}
|
|
4109
|
+
|
|
4110
|
+
const presetEnvSilentDebugHeader = "#__secret_key__@babel/preset-env__don't_log_debug_header_and_resolved_targets";
|
|
4111
|
+
function stringifyTargetsMultiline(targets) {
|
|
4112
|
+
return JSON.stringify((0,_babel_helper_compilation_targets__WEBPACK_IMPORTED_MODULE_1__.prettifyTargets)(targets), null, 2);
|
|
4113
|
+
}
|
|
4114
|
+
|
|
4115
|
+
function patternToRegExp(pattern) {
|
|
4116
|
+
if (pattern instanceof RegExp) return pattern;
|
|
4117
|
+
try {
|
|
4118
|
+
return new RegExp(`^${pattern}$`);
|
|
4119
|
+
} catch {
|
|
4120
|
+
return null;
|
|
4121
|
+
}
|
|
4122
|
+
}
|
|
4123
|
+
function buildUnusedError(label, unused) {
|
|
4124
|
+
if (!unused.length) return "";
|
|
4125
|
+
return ` - The following "${label}" patterns didn't match any polyfill:\n` + unused.map(original => ` ${String(original)}\n`).join("");
|
|
4126
|
+
}
|
|
4127
|
+
function buldDuplicatesError(duplicates) {
|
|
4128
|
+
if (!duplicates.size) return "";
|
|
4129
|
+
return ` - The following polyfills were matched both by "include" and "exclude" patterns:\n` + Array.from(duplicates, name => ` ${name}\n`).join("");
|
|
4130
|
+
}
|
|
4131
|
+
function validateIncludeExclude(provider, polyfills, includePatterns, excludePatterns) {
|
|
4132
|
+
let current;
|
|
4133
|
+
const filter = pattern => {
|
|
4134
|
+
const regexp = patternToRegExp(pattern);
|
|
4135
|
+
if (!regexp) return false;
|
|
4136
|
+
let matched = false;
|
|
4137
|
+
for (const polyfill of polyfills.keys()) {
|
|
4138
|
+
if (regexp.test(polyfill)) {
|
|
4139
|
+
matched = true;
|
|
4140
|
+
current.add(polyfill);
|
|
4141
|
+
}
|
|
4142
|
+
}
|
|
4143
|
+
return !matched;
|
|
4144
|
+
};
|
|
4145
|
+
|
|
4146
|
+
// prettier-ignore
|
|
4147
|
+
const include = current = new Set();
|
|
4148
|
+
const unusedInclude = Array.from(includePatterns).filter(filter);
|
|
4149
|
+
|
|
4150
|
+
// prettier-ignore
|
|
4151
|
+
const exclude = current = new Set();
|
|
4152
|
+
const unusedExclude = Array.from(excludePatterns).filter(filter);
|
|
4153
|
+
const duplicates = intersection(include, exclude);
|
|
4154
|
+
if (duplicates.size > 0 || unusedInclude.length > 0 || unusedExclude.length > 0) {
|
|
4155
|
+
throw new Error(`Error while validating the "${provider}" provider options:\n` + buildUnusedError("include", unusedInclude) + buildUnusedError("exclude", unusedExclude) + buldDuplicatesError(duplicates));
|
|
4156
|
+
}
|
|
4157
|
+
return {
|
|
4158
|
+
include,
|
|
4159
|
+
exclude
|
|
4160
|
+
};
|
|
4161
|
+
}
|
|
4162
|
+
function applyMissingDependenciesDefaults(options, babelApi) {
|
|
4163
|
+
const {
|
|
4164
|
+
missingDependencies = {}
|
|
4165
|
+
} = options;
|
|
4166
|
+
if (missingDependencies === false) return false;
|
|
4167
|
+
const caller = babelApi.caller(caller => caller == null ? void 0 : caller.name);
|
|
4168
|
+
const {
|
|
4169
|
+
log = "deferred",
|
|
4170
|
+
inject = caller === "rollup-plugin-babel" ? "throw" : "import",
|
|
4171
|
+
all = false
|
|
4172
|
+
} = missingDependencies;
|
|
4173
|
+
return {
|
|
4174
|
+
log,
|
|
4175
|
+
inject,
|
|
4176
|
+
all
|
|
4177
|
+
};
|
|
4178
|
+
}
|
|
4179
|
+
|
|
4180
|
+
function isRemoved(path) {
|
|
4181
|
+
if (path.removed) return true;
|
|
4182
|
+
if (!path.parentPath) return false;
|
|
4183
|
+
if (path.listKey) {
|
|
4184
|
+
var _path$parentPath$node;
|
|
4185
|
+
if (!((_path$parentPath$node = path.parentPath.node) != null && (_path$parentPath$node = _path$parentPath$node[path.listKey]) != null && _path$parentPath$node.includes(path.node))) return true;
|
|
4186
|
+
} else {
|
|
4187
|
+
var _path$parentPath$node2;
|
|
4188
|
+
if (((_path$parentPath$node2 = path.parentPath.node) == null ? void 0 : _path$parentPath$node2[path.key]) !== path.node) return true;
|
|
4189
|
+
}
|
|
4190
|
+
return isRemoved(path.parentPath);
|
|
4191
|
+
}
|
|
4192
|
+
var usage = callProvider => {
|
|
4193
|
+
function property(object, key, placement, path) {
|
|
4194
|
+
return callProvider({
|
|
4195
|
+
kind: "property",
|
|
4196
|
+
object,
|
|
4197
|
+
key,
|
|
4198
|
+
placement
|
|
4199
|
+
}, path);
|
|
4200
|
+
}
|
|
4201
|
+
function handleReferencedIdentifier(path) {
|
|
4202
|
+
const {
|
|
4203
|
+
node: {
|
|
4204
|
+
name
|
|
4205
|
+
},
|
|
4206
|
+
scope
|
|
4207
|
+
} = path;
|
|
4208
|
+
if (scope.getBindingIdentifier(name)) return;
|
|
4209
|
+
callProvider({
|
|
4210
|
+
kind: "global",
|
|
4211
|
+
name
|
|
4212
|
+
}, path);
|
|
4213
|
+
}
|
|
4214
|
+
function analyzeMemberExpression(path) {
|
|
4215
|
+
const key = resolveKey(path.get("property"), path.node.computed);
|
|
4216
|
+
return {
|
|
4217
|
+
key,
|
|
4218
|
+
handleAsMemberExpression: !!key && key !== "prototype"
|
|
4219
|
+
};
|
|
4220
|
+
}
|
|
4221
|
+
return {
|
|
4222
|
+
// Symbol(), new Promise
|
|
4223
|
+
ReferencedIdentifier(path) {
|
|
4224
|
+
const {
|
|
4225
|
+
parentPath
|
|
4226
|
+
} = path;
|
|
4227
|
+
if (parentPath.isMemberExpression({
|
|
4228
|
+
object: path.node
|
|
4229
|
+
}) && analyzeMemberExpression(parentPath).handleAsMemberExpression) {
|
|
4230
|
+
return;
|
|
4231
|
+
}
|
|
4232
|
+
handleReferencedIdentifier(path);
|
|
4233
|
+
},
|
|
4234
|
+
"MemberExpression|OptionalMemberExpression"(path) {
|
|
4235
|
+
const {
|
|
4236
|
+
key,
|
|
4237
|
+
handleAsMemberExpression
|
|
4238
|
+
} = analyzeMemberExpression(path);
|
|
4239
|
+
if (!handleAsMemberExpression) return;
|
|
4240
|
+
const object = path.get("object");
|
|
4241
|
+
let objectIsGlobalIdentifier = object.isIdentifier();
|
|
4242
|
+
if (objectIsGlobalIdentifier) {
|
|
4243
|
+
const binding = object.scope.getBinding(object.node.name);
|
|
4244
|
+
if (binding) {
|
|
4245
|
+
if (binding.path.isImportNamespaceSpecifier()) return;
|
|
4246
|
+
objectIsGlobalIdentifier = false;
|
|
4247
|
+
}
|
|
4248
|
+
}
|
|
4249
|
+
const source = resolveSource(object, new Set());
|
|
4250
|
+
const skipObject = property(source.id, key, source.placement, path);
|
|
4251
|
+
const canHandleObject = objectIsGlobalIdentifier && !path.shouldSkip && !object.shouldSkip && !isRemoved(object);
|
|
4252
|
+
if (canHandleObject && (!skipObject || PossibleGlobalObjects.has(source.id))) {
|
|
4253
|
+
handleReferencedIdentifier(object);
|
|
4254
|
+
}
|
|
4255
|
+
},
|
|
4256
|
+
ObjectPattern(path) {
|
|
4257
|
+
const {
|
|
4258
|
+
parentPath,
|
|
4259
|
+
parent
|
|
4260
|
+
} = path;
|
|
4261
|
+
let obj;
|
|
4262
|
+
|
|
4263
|
+
// const { keys, values } = Object
|
|
4264
|
+
if (parentPath.isVariableDeclarator()) {
|
|
4265
|
+
obj = parentPath.get("init");
|
|
4266
|
+
// ({ keys, values } = Object)
|
|
4267
|
+
} else if (parentPath.isAssignmentExpression()) {
|
|
4268
|
+
obj = parentPath.get("right");
|
|
4269
|
+
// !function ({ keys, values }) {...} (Object)
|
|
4270
|
+
// resolution does not work after properties transform :-(
|
|
4271
|
+
} else if (parentPath.isFunction()) {
|
|
4272
|
+
const grand = parentPath.parentPath;
|
|
4273
|
+
if (grand.isCallExpression() || grand.isNewExpression()) {
|
|
4274
|
+
if (grand.node.callee === parent) {
|
|
4275
|
+
obj = grand.get("arguments")[path.key];
|
|
4276
|
+
}
|
|
4277
|
+
}
|
|
4278
|
+
}
|
|
4279
|
+
let id = null;
|
|
4280
|
+
let placement = null;
|
|
4281
|
+
if (obj) ({
|
|
4282
|
+
id,
|
|
4283
|
+
placement
|
|
4284
|
+
} = resolveSource(obj, new Set()));
|
|
4285
|
+
for (const prop of path.get("properties")) {
|
|
4286
|
+
if (prop.isObjectProperty()) {
|
|
4287
|
+
const key = resolveKey(prop.get("key"));
|
|
4288
|
+
if (key) property(id, key, placement, prop);
|
|
4289
|
+
}
|
|
4290
|
+
}
|
|
4291
|
+
},
|
|
4292
|
+
BinaryExpression(path) {
|
|
4293
|
+
if (path.node.operator !== "in") return;
|
|
4294
|
+
const source = resolveSource(path.get("right"), new Set());
|
|
4295
|
+
const key = resolveKey(path.get("left"), true);
|
|
4296
|
+
if (!key) return;
|
|
4297
|
+
callProvider({
|
|
4298
|
+
kind: "in",
|
|
4299
|
+
object: source.id,
|
|
4300
|
+
key,
|
|
4301
|
+
placement: source.placement
|
|
4302
|
+
}, path);
|
|
4303
|
+
}
|
|
4304
|
+
};
|
|
4305
|
+
};
|
|
4306
|
+
|
|
4307
|
+
var entry = callProvider => ({
|
|
4308
|
+
ImportDeclaration(path) {
|
|
4309
|
+
const source = getImportSource(path);
|
|
4310
|
+
if (!source) return;
|
|
4311
|
+
callProvider({
|
|
4312
|
+
kind: "import",
|
|
4313
|
+
source
|
|
4314
|
+
}, path);
|
|
4315
|
+
},
|
|
4316
|
+
Program(path) {
|
|
4317
|
+
path.get("body").forEach(bodyPath => {
|
|
4318
|
+
const source = getRequireSource(bodyPath);
|
|
4319
|
+
if (!source) return;
|
|
4320
|
+
callProvider({
|
|
4321
|
+
kind: "import",
|
|
4322
|
+
source
|
|
4323
|
+
}, bodyPath);
|
|
4324
|
+
});
|
|
4325
|
+
}
|
|
4326
|
+
});
|
|
4327
|
+
|
|
4328
|
+
const nativeRequireResolve = parseFloat(process.versions.node) >= 8.9;
|
|
4329
|
+
const require = (0,module__WEBPACK_IMPORTED_MODULE_6__.createRequire)(require("url").pathToFileURL(__filename).href); // eslint-disable-line
|
|
4330
|
+
|
|
4331
|
+
function myResolve(name, basedir) {
|
|
4332
|
+
if (nativeRequireResolve) {
|
|
4333
|
+
return require.resolve(name, {
|
|
4334
|
+
paths: [basedir]
|
|
4335
|
+
}).replace(/\\/g, "/");
|
|
4336
|
+
} else {
|
|
4337
|
+
return resolve__WEBPACK_IMPORTED_MODULE_5__.sync(name, {
|
|
4338
|
+
basedir
|
|
4339
|
+
}).replace(/\\/g, "/");
|
|
4340
|
+
}
|
|
4341
|
+
}
|
|
4342
|
+
function resolve(dirname, moduleName, absoluteImports) {
|
|
4343
|
+
if (absoluteImports === false) return moduleName;
|
|
4344
|
+
let basedir = dirname;
|
|
4345
|
+
if (typeof absoluteImports === "string") {
|
|
4346
|
+
basedir = path__WEBPACK_IMPORTED_MODULE_3__.resolve(basedir, absoluteImports);
|
|
4347
|
+
}
|
|
4348
|
+
try {
|
|
4349
|
+
return myResolve(moduleName, basedir);
|
|
4350
|
+
} catch (err) {
|
|
4351
|
+
if (err.code !== "MODULE_NOT_FOUND") throw err;
|
|
4352
|
+
throw Object.assign(new Error(`Failed to resolve "${moduleName}" relative to "${dirname}"`), {
|
|
4353
|
+
code: "BABEL_POLYFILL_NOT_FOUND",
|
|
4354
|
+
polyfill: moduleName,
|
|
4355
|
+
dirname
|
|
4356
|
+
});
|
|
4357
|
+
}
|
|
4358
|
+
}
|
|
4359
|
+
function has(basedir, name) {
|
|
4360
|
+
try {
|
|
4361
|
+
myResolve(name, basedir);
|
|
4362
|
+
return true;
|
|
4363
|
+
} catch {
|
|
4364
|
+
return false;
|
|
4365
|
+
}
|
|
4366
|
+
}
|
|
4367
|
+
function logMissing(missingDeps) {
|
|
4368
|
+
if (missingDeps.size === 0) return;
|
|
4369
|
+
const deps = Array.from(missingDeps).sort().join(" ");
|
|
4370
|
+
console.warn("\nSome polyfills have been added but are not present in your dependencies.\n" + "Please run one of the following commands:\n" + `\tnpm install --save ${deps}\n` + `\tyarn add ${deps}\n`);
|
|
4371
|
+
process.exitCode = 1;
|
|
4372
|
+
}
|
|
4373
|
+
let allMissingDeps = new Set();
|
|
4374
|
+
const laterLogMissingDependencies = lodash_debounce__WEBPACK_IMPORTED_MODULE_4__(() => {
|
|
4375
|
+
logMissing(allMissingDeps);
|
|
4376
|
+
allMissingDeps = new Set();
|
|
4377
|
+
}, 100);
|
|
4378
|
+
function laterLogMissing(missingDeps) {
|
|
4379
|
+
if (missingDeps.size === 0) return;
|
|
4380
|
+
missingDeps.forEach(name => allMissingDeps.add(name));
|
|
4381
|
+
laterLogMissingDependencies();
|
|
4382
|
+
}
|
|
4383
|
+
|
|
4384
|
+
function createMetaResolver(polyfills) {
|
|
4385
|
+
const {
|
|
4386
|
+
static: staticP,
|
|
4387
|
+
instance: instanceP,
|
|
4388
|
+
global: globalP
|
|
4389
|
+
} = polyfills;
|
|
4390
|
+
return meta => {
|
|
4391
|
+
if (meta.kind === "global" && globalP && has$1(globalP, meta.name)) {
|
|
4392
|
+
return {
|
|
4393
|
+
kind: "global",
|
|
4394
|
+
desc: globalP[meta.name],
|
|
4395
|
+
name: meta.name
|
|
4396
|
+
};
|
|
4397
|
+
}
|
|
4398
|
+
if (meta.kind === "property" || meta.kind === "in") {
|
|
4399
|
+
const {
|
|
4400
|
+
placement,
|
|
4401
|
+
object,
|
|
4402
|
+
key
|
|
4403
|
+
} = meta;
|
|
4404
|
+
if (object && placement === "static") {
|
|
4405
|
+
if (globalP && PossibleGlobalObjects.has(object) && has$1(globalP, key)) {
|
|
4406
|
+
return {
|
|
4407
|
+
kind: "global",
|
|
4408
|
+
desc: globalP[key],
|
|
4409
|
+
name: key
|
|
4410
|
+
};
|
|
4411
|
+
}
|
|
4412
|
+
if (staticP && has$1(staticP, object) && has$1(staticP[object], key)) {
|
|
4413
|
+
return {
|
|
4414
|
+
kind: "static",
|
|
4415
|
+
desc: staticP[object][key],
|
|
4416
|
+
name: `${object}$${key}`
|
|
4417
|
+
};
|
|
4418
|
+
}
|
|
4419
|
+
}
|
|
4420
|
+
if (instanceP && has$1(instanceP, key)) {
|
|
4421
|
+
return {
|
|
4422
|
+
kind: "instance",
|
|
4423
|
+
desc: instanceP[key],
|
|
4424
|
+
name: `${key}`
|
|
4425
|
+
};
|
|
4426
|
+
}
|
|
4427
|
+
}
|
|
4428
|
+
};
|
|
4429
|
+
}
|
|
4430
|
+
|
|
4431
|
+
const getTargets = _babel_helper_compilation_targets__WEBPACK_IMPORTED_MODULE_1__["default"] || _babel_helper_compilation_targets__WEBPACK_IMPORTED_MODULE_1__;
|
|
4432
|
+
function resolveOptions(options, babelApi) {
|
|
4433
|
+
const {
|
|
4434
|
+
method,
|
|
4435
|
+
targets: targetsOption,
|
|
4436
|
+
ignoreBrowserslistConfig,
|
|
4437
|
+
configPath,
|
|
4438
|
+
debug,
|
|
4439
|
+
shouldInjectPolyfill,
|
|
4440
|
+
absoluteImports,
|
|
4441
|
+
...providerOptions
|
|
4442
|
+
} = options;
|
|
4443
|
+
if (isEmpty(options)) {
|
|
4444
|
+
throw new Error(`\
|
|
4445
|
+
This plugin requires options, for example:
|
|
4446
|
+
{
|
|
4447
|
+
"plugins": [
|
|
4448
|
+
["<plugin name>", { method: "usage-pure" }]
|
|
4449
|
+
]
|
|
4450
|
+
}
|
|
4451
|
+
|
|
4452
|
+
See more options at https://github.com/babel/babel-polyfills/blob/main/docs/usage.md`);
|
|
4453
|
+
}
|
|
4454
|
+
let methodName;
|
|
4455
|
+
if (method === "usage-global") methodName = "usageGlobal";else if (method === "entry-global") methodName = "entryGlobal";else if (method === "usage-pure") methodName = "usagePure";else if (typeof method !== "string") {
|
|
4456
|
+
throw new Error(".method must be a string");
|
|
4457
|
+
} else {
|
|
4458
|
+
throw new Error(`.method must be one of "entry-global", "usage-global"` + ` or "usage-pure" (received ${JSON.stringify(method)})`);
|
|
4459
|
+
}
|
|
4460
|
+
if (typeof shouldInjectPolyfill === "function") {
|
|
4461
|
+
if (options.include || options.exclude) {
|
|
4462
|
+
throw new Error(`.include and .exclude are not supported when using the` + ` .shouldInjectPolyfill function.`);
|
|
4463
|
+
}
|
|
4464
|
+
} else if (shouldInjectPolyfill != null) {
|
|
4465
|
+
throw new Error(`.shouldInjectPolyfill must be a function, or undefined` + ` (received ${JSON.stringify(shouldInjectPolyfill)})`);
|
|
4466
|
+
}
|
|
4467
|
+
if (absoluteImports != null && typeof absoluteImports !== "boolean" && typeof absoluteImports !== "string") {
|
|
4468
|
+
throw new Error(`.absoluteImports must be a boolean, a string, or undefined` + ` (received ${JSON.stringify(absoluteImports)})`);
|
|
4469
|
+
}
|
|
4470
|
+
let targets;
|
|
4471
|
+
if (
|
|
4472
|
+
// If any browserslist-related option is specified, fallback to the old
|
|
4473
|
+
// behavior of not using the targets specified in the top-level options.
|
|
4474
|
+
targetsOption || configPath || ignoreBrowserslistConfig) {
|
|
4475
|
+
const targetsObj = typeof targetsOption === "string" || Array.isArray(targetsOption) ? {
|
|
4476
|
+
browsers: targetsOption
|
|
4477
|
+
} : targetsOption;
|
|
4478
|
+
targets = getTargets(targetsObj, {
|
|
4479
|
+
ignoreBrowserslistConfig,
|
|
4480
|
+
configPath
|
|
4481
|
+
});
|
|
4482
|
+
} else {
|
|
4483
|
+
targets = babelApi.targets();
|
|
4484
|
+
}
|
|
4485
|
+
return {
|
|
4486
|
+
method,
|
|
4487
|
+
methodName,
|
|
4488
|
+
targets,
|
|
4489
|
+
absoluteImports: absoluteImports != null ? absoluteImports : false,
|
|
4490
|
+
shouldInjectPolyfill,
|
|
4491
|
+
debug: !!debug,
|
|
4492
|
+
providerOptions: providerOptions
|
|
4493
|
+
};
|
|
4494
|
+
}
|
|
4495
|
+
function instantiateProvider(factory, options, missingDependencies, dirname, debugLog, babelApi) {
|
|
4496
|
+
const {
|
|
4497
|
+
method,
|
|
4498
|
+
methodName,
|
|
4499
|
+
targets,
|
|
4500
|
+
debug,
|
|
4501
|
+
shouldInjectPolyfill,
|
|
4502
|
+
providerOptions,
|
|
4503
|
+
absoluteImports
|
|
4504
|
+
} = resolveOptions(options, babelApi);
|
|
4505
|
+
|
|
4506
|
+
// eslint-disable-next-line prefer-const
|
|
4507
|
+
let include, exclude;
|
|
4508
|
+
let polyfillsSupport;
|
|
4509
|
+
let polyfillsNames;
|
|
4510
|
+
let filterPolyfills;
|
|
4511
|
+
const getUtils = createUtilsGetter(new ImportsCachedInjector(moduleName => resolve(dirname, moduleName, absoluteImports), name => {
|
|
4512
|
+
var _polyfillsNames$get, _polyfillsNames;
|
|
4513
|
+
return (_polyfillsNames$get = (_polyfillsNames = polyfillsNames) == null ? void 0 : _polyfillsNames.get(name)) != null ? _polyfillsNames$get : Infinity;
|
|
4514
|
+
}));
|
|
4515
|
+
const depsCache = new Map();
|
|
4516
|
+
const api = {
|
|
4517
|
+
babel: babelApi,
|
|
4518
|
+
getUtils,
|
|
4519
|
+
method: options.method,
|
|
4520
|
+
targets,
|
|
4521
|
+
createMetaResolver,
|
|
4522
|
+
shouldInjectPolyfill(name) {
|
|
4523
|
+
if (polyfillsNames === undefined) {
|
|
4524
|
+
throw new Error(`Internal error in the ${factory.name} provider: ` + `shouldInjectPolyfill() can't be called during initialization.`);
|
|
4525
|
+
}
|
|
4526
|
+
if (!polyfillsNames.has(name)) {
|
|
4527
|
+
console.warn(`Internal error in the ${providerName} provider: ` + `unknown polyfill "${name}".`);
|
|
4528
|
+
}
|
|
4529
|
+
if (filterPolyfills && !filterPolyfills(name)) return false;
|
|
4530
|
+
let shouldInject = (0,_babel_helper_compilation_targets__WEBPACK_IMPORTED_MODULE_1__.isRequired)(name, targets, {
|
|
4531
|
+
compatData: polyfillsSupport,
|
|
4532
|
+
includes: include,
|
|
4533
|
+
excludes: exclude
|
|
4534
|
+
});
|
|
4535
|
+
if (shouldInjectPolyfill) {
|
|
4536
|
+
shouldInject = shouldInjectPolyfill(name, shouldInject);
|
|
4537
|
+
if (typeof shouldInject !== "boolean") {
|
|
4538
|
+
throw new Error(`.shouldInjectPolyfill must return a boolean.`);
|
|
4539
|
+
}
|
|
4540
|
+
}
|
|
4541
|
+
return shouldInject;
|
|
4542
|
+
},
|
|
4543
|
+
debug(name) {
|
|
4544
|
+
var _debugLog, _debugLog$polyfillsSu;
|
|
4545
|
+
debugLog().found = true;
|
|
4546
|
+
if (!debug || !name) return;
|
|
4547
|
+
if (debugLog().polyfills.has(providerName)) return;
|
|
4548
|
+
debugLog().polyfills.add(name);
|
|
4549
|
+
(_debugLog$polyfillsSu = (_debugLog = debugLog()).polyfillsSupport) != null ? _debugLog$polyfillsSu : _debugLog.polyfillsSupport = polyfillsSupport;
|
|
4550
|
+
},
|
|
4551
|
+
assertDependency(name, version = "*") {
|
|
4552
|
+
if (missingDependencies === false) return;
|
|
4553
|
+
if (absoluteImports) {
|
|
4554
|
+
// If absoluteImports is not false, we will try resolving
|
|
4555
|
+
// the dependency and throw if it's not possible. We can
|
|
4556
|
+
// skip the check here.
|
|
4557
|
+
return;
|
|
4558
|
+
}
|
|
4559
|
+
const dep = version === "*" ? name : `${name}@^${version}`;
|
|
4560
|
+
const found = missingDependencies.all ? false : mapGetOr(depsCache, `${name} :: ${dirname}`, () => has(dirname, name));
|
|
4561
|
+
if (!found) {
|
|
4562
|
+
debugLog().missingDeps.add(dep);
|
|
4563
|
+
}
|
|
4564
|
+
}
|
|
4565
|
+
};
|
|
4566
|
+
const provider = factory(api, providerOptions, dirname);
|
|
4567
|
+
const providerName = provider.name || factory.name;
|
|
4568
|
+
if (typeof provider[methodName] !== "function") {
|
|
4569
|
+
throw new Error(`The "${providerName}" provider doesn't support the "${method}" polyfilling method.`);
|
|
4570
|
+
}
|
|
4571
|
+
if (Array.isArray(provider.polyfills)) {
|
|
4572
|
+
polyfillsNames = new Map(provider.polyfills.map((name, index) => [name, index]));
|
|
4573
|
+
filterPolyfills = provider.filterPolyfills;
|
|
4574
|
+
} else if (provider.polyfills) {
|
|
4575
|
+
polyfillsNames = new Map(Object.keys(provider.polyfills).map((name, index) => [name, index]));
|
|
4576
|
+
polyfillsSupport = provider.polyfills;
|
|
4577
|
+
filterPolyfills = provider.filterPolyfills;
|
|
4578
|
+
} else {
|
|
4579
|
+
polyfillsNames = new Map();
|
|
4580
|
+
}
|
|
4581
|
+
({
|
|
4582
|
+
include,
|
|
4583
|
+
exclude
|
|
4584
|
+
} = validateIncludeExclude(providerName, polyfillsNames, providerOptions.include || [], providerOptions.exclude || []));
|
|
4585
|
+
let callProvider;
|
|
4586
|
+
if (methodName === "usageGlobal") {
|
|
4587
|
+
callProvider = (payload, path) => {
|
|
4588
|
+
var _ref;
|
|
4589
|
+
const utils = getUtils(path);
|
|
4590
|
+
return (_ref = provider[methodName](payload, utils, path)) != null ? _ref : false;
|
|
4591
|
+
};
|
|
4592
|
+
} else {
|
|
4593
|
+
callProvider = (payload, path) => {
|
|
4594
|
+
const utils = getUtils(path);
|
|
4595
|
+
provider[methodName](payload, utils, path);
|
|
4596
|
+
return false;
|
|
4597
|
+
};
|
|
4598
|
+
}
|
|
4599
|
+
return {
|
|
4600
|
+
debug,
|
|
4601
|
+
method,
|
|
4602
|
+
targets,
|
|
4603
|
+
provider,
|
|
4604
|
+
providerName,
|
|
4605
|
+
callProvider
|
|
4606
|
+
};
|
|
4607
|
+
}
|
|
4608
|
+
function definePolyfillProvider(factory) {
|
|
4609
|
+
return (0,_babel_helper_plugin_utils__WEBPACK_IMPORTED_MODULE_0__/* .declare */ .xe)((babelApi, options, dirname) => {
|
|
4610
|
+
babelApi.assertVersion("^7.0.0 || ^8.0.0-alpha.0");
|
|
4611
|
+
const {
|
|
4612
|
+
traverse
|
|
4613
|
+
} = babelApi;
|
|
4614
|
+
let debugLog;
|
|
4615
|
+
const missingDependencies = applyMissingDependenciesDefaults(options, babelApi);
|
|
4616
|
+
const {
|
|
4617
|
+
debug,
|
|
4618
|
+
method,
|
|
4619
|
+
targets,
|
|
4620
|
+
provider,
|
|
4621
|
+
providerName,
|
|
4622
|
+
callProvider
|
|
4623
|
+
} = instantiateProvider(factory, options, missingDependencies, dirname, () => debugLog, babelApi);
|
|
4624
|
+
const createVisitor = method === "entry-global" ? entry : usage;
|
|
4625
|
+
const visitor = provider.visitor ? traverse.visitors.merge([createVisitor(callProvider), provider.visitor]) : createVisitor(callProvider);
|
|
4626
|
+
if (debug && debug !== presetEnvSilentDebugHeader) {
|
|
4627
|
+
console.log(`${providerName}: \`DEBUG\` option`);
|
|
4628
|
+
console.log(`\nUsing targets: ${stringifyTargetsMultiline(targets)}`);
|
|
4629
|
+
console.log(`\nUsing polyfills with \`${method}\` method:`);
|
|
4630
|
+
}
|
|
4631
|
+
const {
|
|
4632
|
+
runtimeName
|
|
4633
|
+
} = provider;
|
|
4634
|
+
return {
|
|
4635
|
+
name: "inject-polyfills",
|
|
4636
|
+
visitor,
|
|
4637
|
+
pre(file) {
|
|
4638
|
+
var _provider$pre;
|
|
4639
|
+
if (runtimeName) {
|
|
4640
|
+
if (file.get("runtimeHelpersModuleName") && file.get("runtimeHelpersModuleName") !== runtimeName) {
|
|
4641
|
+
console.warn(`Two different polyfill providers` + ` (${file.get("runtimeHelpersModuleProvider")}` + ` and ${providerName}) are trying to define two` + ` conflicting @babel/runtime alternatives:` + ` ${file.get("runtimeHelpersModuleName")} and ${runtimeName}.` + ` The second one will be ignored.`);
|
|
4642
|
+
} else {
|
|
4643
|
+
file.set("runtimeHelpersModuleName", runtimeName);
|
|
4644
|
+
file.set("runtimeHelpersModuleProvider", providerName);
|
|
4645
|
+
}
|
|
4646
|
+
}
|
|
4647
|
+
debugLog = {
|
|
4648
|
+
polyfills: new Set(),
|
|
4649
|
+
polyfillsSupport: undefined,
|
|
4650
|
+
found: false,
|
|
4651
|
+
providers: new Set(),
|
|
4652
|
+
missingDeps: new Set()
|
|
4653
|
+
};
|
|
4654
|
+
(_provider$pre = provider.pre) == null || _provider$pre.apply(this, arguments);
|
|
4655
|
+
},
|
|
4656
|
+
post() {
|
|
4657
|
+
var _provider$post;
|
|
4658
|
+
(_provider$post = provider.post) == null || _provider$post.apply(this, arguments);
|
|
4659
|
+
if (missingDependencies !== false) {
|
|
4660
|
+
if (missingDependencies.log === "per-file") {
|
|
4661
|
+
logMissing(debugLog.missingDeps);
|
|
4662
|
+
} else {
|
|
4663
|
+
laterLogMissing(debugLog.missingDeps);
|
|
4664
|
+
}
|
|
4665
|
+
}
|
|
4666
|
+
if (!debug) return;
|
|
4667
|
+
if (this.filename) console.log(`\n[${this.filename}]`);
|
|
4668
|
+
if (debugLog.polyfills.size === 0) {
|
|
4669
|
+
console.log(method === "entry-global" ? debugLog.found ? `Based on your targets, the ${providerName} polyfill did not add any polyfill.` : `The entry point for the ${providerName} polyfill has not been found.` : `Based on your code and targets, the ${providerName} polyfill did not add any polyfill.`);
|
|
4670
|
+
return;
|
|
4671
|
+
}
|
|
4672
|
+
if (method === "entry-global") {
|
|
4673
|
+
console.log(`The ${providerName} polyfill entry has been replaced with ` + `the following polyfills:`);
|
|
4674
|
+
} else {
|
|
4675
|
+
console.log(`The ${providerName} polyfill added the following polyfills:`);
|
|
4676
|
+
}
|
|
4677
|
+
for (const name of debugLog.polyfills) {
|
|
4678
|
+
var _debugLog$polyfillsSu2;
|
|
4679
|
+
if ((_debugLog$polyfillsSu2 = debugLog.polyfillsSupport) != null && _debugLog$polyfillsSu2[name]) {
|
|
4680
|
+
const filteredTargets = (0,_babel_helper_compilation_targets__WEBPACK_IMPORTED_MODULE_1__.getInclusionReasons)(name, targets, debugLog.polyfillsSupport);
|
|
4681
|
+
const formattedTargets = JSON.stringify(filteredTargets).replace(/,/g, ", ").replace(/^\{"/, '{ "').replace(/"\}$/, '" }');
|
|
4682
|
+
console.log(` ${name} ${formattedTargets}`);
|
|
4683
|
+
} else {
|
|
4684
|
+
console.log(` ${name}`);
|
|
4685
|
+
}
|
|
4686
|
+
}
|
|
4687
|
+
}
|
|
4688
|
+
};
|
|
4689
|
+
});
|
|
4690
|
+
}
|
|
4691
|
+
function mapGetOr(map, key, getDefault) {
|
|
4692
|
+
let val = map.get(key);
|
|
4693
|
+
if (val === undefined) {
|
|
4694
|
+
val = getDefault();
|
|
4695
|
+
map.set(key, val);
|
|
4696
|
+
}
|
|
4697
|
+
return val;
|
|
4698
|
+
}
|
|
4699
|
+
function isEmpty(obj) {
|
|
4700
|
+
return Object.keys(obj).length === 0;
|
|
4701
|
+
}
|
|
4702
|
+
|
|
4703
|
+
|
|
4704
|
+
//# sourceMappingURL=index.node.mjs.map
|
|
4705
|
+
|
|
4706
|
+
|
|
4707
|
+
/***/ }),
|
|
4708
|
+
|
|
4709
|
+
/***/ 9468:
|
|
4710
|
+
/***/ (function(module) {
|
|
4711
|
+
|
|
4712
|
+
"use strict";
|
|
4713
|
+
module.exports = /*#__PURE__*/JSON.parse('{"es6.module":{"chrome":"61","and_chr":"61","edge":"16","firefox":"60","and_ff":"60","node":"13.2.0","opera":"48","op_mob":"45","safari":"10.1","ios":"10.3","samsung":"8.2","android":"61","electron":"2.0","ios_saf":"10.3"}}');
|
|
4714
|
+
|
|
4715
|
+
/***/ }),
|
|
4716
|
+
|
|
4717
|
+
/***/ 4657:
|
|
4718
|
+
/***/ (function(module) {
|
|
4719
|
+
|
|
4720
|
+
"use strict";
|
|
4721
|
+
module.exports = /*#__PURE__*/JSON.parse('{"transform-explicit-resource-management":{"chrome":"141","edge":"141","firefox":"141","node":"25","electron":"39.0"},"transform-duplicate-named-capturing-groups-regex":{"chrome":"126","opera":"112","edge":"126","firefox":"129","safari":"17.4","node":"23","ios":"17.4","rhino":"1.9","electron":"31.0"},"transform-regexp-modifiers":{"chrome":"125","opera":"111","edge":"125","firefox":"132","node":"23","samsung":"27","electron":"31.0"},"transform-unicode-sets-regex":{"chrome":"112","opera":"98","edge":"112","firefox":"116","safari":"17","node":"20","deno":"1.32","ios":"17","samsung":"23","opera_mobile":"75","electron":"24.0"},"bugfix/transform-v8-static-class-fields-redefine-readonly":{"chrome":"98","opera":"84","edge":"98","firefox":"75","safari":"15","node":"12","deno":"1.18","ios":"15","samsung":"11","opera_mobile":"52","electron":"17.0"},"bugfix/transform-firefox-class-in-computed-class-key":{"chrome":"74","opera":"62","edge":"79","firefox":"126","safari":"16","node":"12","deno":"1","ios":"16","samsung":"11","opera_mobile":"53","electron":"6.0"},"bugfix/transform-safari-class-field-initializer-scope":{"chrome":"74","opera":"62","edge":"79","firefox":"69","safari":"16","node":"12","deno":"1","ios":"16","samsung":"11","opera_mobile":"53","electron":"6.0"},"transform-class-static-block":{"chrome":"94","opera":"80","edge":"94","firefox":"93","safari":"16.4","node":"16.11","deno":"1.14","ios":"16.4","samsung":"17","opera_mobile":"66","electron":"15.0"},"proposal-class-static-block":{"chrome":"94","opera":"80","edge":"94","firefox":"93","safari":"16.4","node":"16.11","deno":"1.14","ios":"16.4","samsung":"17","opera_mobile":"66","electron":"15.0"},"transform-private-property-in-object":{"chrome":"91","opera":"77","edge":"91","firefox":"90","safari":"15","node":"16.9","deno":"1.9","ios":"15","samsung":"16","opera_mobile":"64","electron":"13.0"},"proposal-private-property-in-object":{"chrome":"91","opera":"77","edge":"91","firefox":"90","safari":"15","node":"16.9","deno":"1.9","ios":"15","samsung":"16","opera_mobile":"64","electron":"13.0"},"transform-class-properties":{"chrome":"74","opera":"62","edge":"79","firefox":"90","safari":"14.1","node":"12","deno":"1","ios":"14.5","samsung":"11","opera_mobile":"53","electron":"6.0"},"proposal-class-properties":{"chrome":"74","opera":"62","edge":"79","firefox":"90","safari":"14.1","node":"12","deno":"1","ios":"14.5","samsung":"11","opera_mobile":"53","electron":"6.0"},"transform-private-methods":{"chrome":"84","opera":"70","edge":"84","firefox":"90","safari":"15","node":"14.6","deno":"1","ios":"15","samsung":"14","opera_mobile":"60","electron":"10.0"},"proposal-private-methods":{"chrome":"84","opera":"70","edge":"84","firefox":"90","safari":"15","node":"14.6","deno":"1","ios":"15","samsung":"14","opera_mobile":"60","electron":"10.0"},"transform-numeric-separator":{"chrome":"75","opera":"62","edge":"79","firefox":"70","safari":"13","node":"12.5","deno":"1","ios":"13","samsung":"11","rhino":"1.7.14","opera_mobile":"54","electron":"6.0"},"proposal-numeric-separator":{"chrome":"75","opera":"62","edge":"79","firefox":"70","safari":"13","node":"12.5","deno":"1","ios":"13","samsung":"11","rhino":"1.7.14","opera_mobile":"54","electron":"6.0"},"transform-logical-assignment-operators":{"chrome":"85","opera":"71","edge":"85","firefox":"79","safari":"14","node":"15","deno":"1.2","ios":"14","samsung":"14","opera_mobile":"60","electron":"10.0"},"proposal-logical-assignment-operators":{"chrome":"85","opera":"71","edge":"85","firefox":"79","safari":"14","node":"15","deno":"1.2","ios":"14","samsung":"14","opera_mobile":"60","electron":"10.0"},"transform-nullish-coalescing-operator":{"chrome":"80","opera":"67","edge":"80","firefox":"72","safari":"13.1","node":"14","deno":"1","ios":"13.4","samsung":"13","rhino":"1.8","opera_mobile":"57","electron":"8.0"},"proposal-nullish-coalescing-operator":{"chrome":"80","opera":"67","edge":"80","firefox":"72","safari":"13.1","node":"14","deno":"1","ios":"13.4","samsung":"13","rhino":"1.8","opera_mobile":"57","electron":"8.0"},"transform-optional-chaining":{"chrome":"91","opera":"77","edge":"91","firefox":"74","safari":"13.1","node":"16.9","deno":"1.9","ios":"13.4","samsung":"16","opera_mobile":"64","electron":"13.0"},"proposal-optional-chaining":{"chrome":"91","opera":"77","edge":"91","firefox":"74","safari":"13.1","node":"16.9","deno":"1.9","ios":"13.4","samsung":"16","opera_mobile":"64","electron":"13.0"},"transform-json-strings":{"chrome":"66","opera":"53","edge":"79","firefox":"62","safari":"12","node":"10","deno":"1","ios":"12","samsung":"9","rhino":"1.7.14","opera_mobile":"47","electron":"3.0"},"proposal-json-strings":{"chrome":"66","opera":"53","edge":"79","firefox":"62","safari":"12","node":"10","deno":"1","ios":"12","samsung":"9","rhino":"1.7.14","opera_mobile":"47","electron":"3.0"},"transform-optional-catch-binding":{"chrome":"66","opera":"53","edge":"79","firefox":"58","safari":"11.1","node":"10","deno":"1","ios":"11.3","samsung":"9","opera_mobile":"47","electron":"3.0"},"proposal-optional-catch-binding":{"chrome":"66","opera":"53","edge":"79","firefox":"58","safari":"11.1","node":"10","deno":"1","ios":"11.3","samsung":"9","opera_mobile":"47","electron":"3.0"},"transform-parameters":{"chrome":"49","opera":"36","edge":"18","firefox":"52","safari":"16.3","node":"6","deno":"1","ios":"16.3","samsung":"5","opera_mobile":"36","electron":"0.37"},"transform-async-generator-functions":{"chrome":"63","opera":"50","edge":"79","firefox":"57","safari":"12","node":"10","deno":"1","ios":"12","samsung":"8","opera_mobile":"46","electron":"3.0"},"proposal-async-generator-functions":{"chrome":"63","opera":"50","edge":"79","firefox":"57","safari":"12","node":"10","deno":"1","ios":"12","samsung":"8","opera_mobile":"46","electron":"3.0"},"transform-object-rest-spread":{"chrome":"60","opera":"47","edge":"79","firefox":"55","safari":"11.1","node":"8.3","deno":"1","ios":"11.3","samsung":"8","opera_mobile":"44","electron":"2.0"},"proposal-object-rest-spread":{"chrome":"60","opera":"47","edge":"79","firefox":"55","safari":"11.1","node":"8.3","deno":"1","ios":"11.3","samsung":"8","opera_mobile":"44","electron":"2.0"},"transform-dotall-regex":{"chrome":"62","opera":"49","edge":"79","firefox":"78","safari":"11.1","node":"8.10","deno":"1","ios":"11.3","samsung":"8","rhino":"1.7.15","opera_mobile":"46","electron":"3.0"},"transform-unicode-property-regex":{"chrome":"64","opera":"51","edge":"79","firefox":"78","safari":"11.1","node":"10","deno":"1","ios":"11.3","samsung":"9","rhino":"1.9","opera_mobile":"47","electron":"3.0"},"proposal-unicode-property-regex":{"chrome":"64","opera":"51","edge":"79","firefox":"78","safari":"11.1","node":"10","deno":"1","ios":"11.3","samsung":"9","rhino":"1.9","opera_mobile":"47","electron":"3.0"},"transform-named-capturing-groups-regex":{"chrome":"64","opera":"51","edge":"79","firefox":"78","safari":"11.1","node":"10","deno":"1","ios":"11.3","samsung":"9","rhino":"1.9","opera_mobile":"47","electron":"3.0"},"transform-async-to-generator":{"chrome":"55","opera":"42","edge":"15","firefox":"52","safari":"11","node":"7.6","deno":"1","ios":"11","samsung":"6","opera_mobile":"42","electron":"1.6"},"transform-exponentiation-operator":{"chrome":"52","opera":"39","edge":"14","firefox":"52","safari":"10.1","node":"7","deno":"1","ios":"10.3","samsung":"6","rhino":"1.7.14","opera_mobile":"41","electron":"1.3"},"transform-template-literals":{"chrome":"41","opera":"28","edge":"13","firefox":"34","safari":"13","node":"4","deno":"1","ios":"13","samsung":"3.4","rhino":"1.9","opera_mobile":"28","electron":"0.21"},"transform-literals":{"chrome":"44","opera":"31","edge":"12","firefox":"53","safari":"9","node":"4","deno":"1","ios":"9","samsung":"4","rhino":"1.7.15","opera_mobile":"32","electron":"0.30"},"transform-function-name":{"chrome":"51","opera":"38","edge":"79","firefox":"53","safari":"10","node":"6.5","deno":"1","ios":"10","samsung":"5","opera_mobile":"41","electron":"1.2"},"transform-arrow-functions":{"chrome":"47","opera":"34","edge":"13","firefox":"43","safari":"10","node":"6","deno":"1","ios":"10","samsung":"5","rhino":"1.7.13","opera_mobile":"34","electron":"0.36"},"transform-block-scoped-functions":{"chrome":"41","opera":"28","edge":"12","firefox":"46","safari":"10","node":"4","deno":"1","ie":"11","ios":"10","samsung":"3.4","opera_mobile":"28","electron":"0.21"},"transform-classes":{"chrome":"46","opera":"33","edge":"13","firefox":"45","safari":"10","node":"5","deno":"1","ios":"10","samsung":"5","opera_mobile":"33","electron":"0.36"},"transform-object-super":{"chrome":"46","opera":"33","edge":"13","firefox":"45","safari":"10","node":"5","deno":"1","ios":"10","samsung":"5","opera_mobile":"33","electron":"0.36"},"transform-shorthand-properties":{"chrome":"43","opera":"30","edge":"12","firefox":"33","safari":"9","node":"4","deno":"1","ios":"9","samsung":"4","rhino":"1.7.14","opera_mobile":"30","electron":"0.27"},"transform-duplicate-keys":{"chrome":"42","opera":"29","edge":"12","firefox":"34","safari":"9","node":"4","deno":"1","ios":"9","samsung":"3.4","opera_mobile":"29","electron":"0.25"},"transform-computed-properties":{"chrome":"44","opera":"31","edge":"12","firefox":"34","safari":"7.1","node":"4","deno":"1","ios":"8","samsung":"4","rhino":"1.8","opera_mobile":"32","electron":"0.30"},"transform-for-of":{"chrome":"51","opera":"38","edge":"15","firefox":"53","safari":"10","node":"6.5","deno":"1","ios":"10","samsung":"5","opera_mobile":"41","electron":"1.2"},"transform-sticky-regex":{"chrome":"49","opera":"36","edge":"13","firefox":"3","safari":"10","node":"6","deno":"1","ios":"10","samsung":"5","rhino":"1.7.15","opera_mobile":"36","electron":"0.37"},"transform-unicode-escapes":{"chrome":"44","opera":"31","edge":"12","firefox":"53","safari":"9","node":"4","deno":"1","ios":"9","samsung":"4","rhino":"1.7.15","opera_mobile":"32","electron":"0.30"},"transform-unicode-regex":{"chrome":"50","opera":"37","edge":"13","firefox":"46","safari":"12","node":"6","deno":"1","ios":"12","samsung":"5","opera_mobile":"37","electron":"1.1"},"transform-spread":{"chrome":"46","opera":"33","edge":"13","firefox":"45","safari":"10","node":"5","deno":"1","ios":"10","samsung":"5","opera_mobile":"33","electron":"0.36"},"transform-destructuring":{"chrome":"51","opera":"38","edge":"15","firefox":"53","safari":"14.1","node":"6.5","deno":"1","ios":"14.5","samsung":"5","opera_mobile":"41","electron":"1.2"},"transform-block-scoping":{"chrome":"50","opera":"37","edge":"14","firefox":"53","safari":"11","node":"6","deno":"1","ios":"11","samsung":"5","opera_mobile":"37","electron":"1.1"},"transform-typeof-symbol":{"chrome":"48","opera":"35","edge":"12","firefox":"36","safari":"9","node":"6","deno":"1","ios":"9","samsung":"5","rhino":"1.8","opera_mobile":"35","electron":"0.37"},"transform-new-target":{"chrome":"46","opera":"33","edge":"14","firefox":"41","safari":"10","node":"5","deno":"1","ios":"10","samsung":"5","opera_mobile":"33","electron":"0.36"},"transform-regenerator":{"chrome":"50","opera":"37","edge":"13","firefox":"53","safari":"10","node":"6","deno":"1","ios":"10","samsung":"5","opera_mobile":"37","electron":"1.1"},"transform-member-expression-literals":{"chrome":"7","opera":"12","edge":"12","firefox":"2","safari":"5.1","node":"0.4","deno":"1","ie":"9","android":"4","ios":"6","phantom":"1.9","samsung":"1","rhino":"1.7.13","opera_mobile":"12","electron":"0.20"},"transform-property-literals":{"chrome":"7","opera":"12","edge":"12","firefox":"2","safari":"5.1","node":"0.4","deno":"1","ie":"9","android":"4","ios":"6","phantom":"1.9","samsung":"1","rhino":"1.7.13","opera_mobile":"12","electron":"0.20"},"transform-reserved-words":{"chrome":"13","opera":"10.50","edge":"12","firefox":"2","safari":"3.1","node":"0.6","deno":"1","ie":"9","android":"4.4","ios":"6","phantom":"1.9","samsung":"1","rhino":"1.7.13","opera_mobile":"10.1","electron":"0.20"},"transform-export-namespace-from":{"chrome":"72","deno":"1.0","edge":"79","firefox":"80","node":"13.2.0","opera":"60","opera_mobile":"51","safari":"14.1","ios":"14.5","samsung":"11.0","android":"72","electron":"5.0"},"proposal-export-namespace-from":{"chrome":"72","deno":"1.0","edge":"79","firefox":"80","node":"13.2.0","opera":"60","opera_mobile":"51","safari":"14.1","ios":"14.5","samsung":"11.0","android":"72","electron":"5.0"}}');
|
|
4722
|
+
|
|
4723
|
+
/***/ })
|
|
4724
|
+
|
|
4725
|
+
};
|
|
4726
|
+
;
|