ember-repl 6.0.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/README.md +2 -404
- package/config/.try.mjs +87 -0
- package/config/addon-main.cjs +7 -0
- package/config/attw.json +7 -0
- package/config/babel.publish.config.cjs +29 -0
- package/config/ember-cli-update.json +21 -0
- package/config/rollup.config.mjs +44 -0
- package/config/testem.cjs +35 -0
- package/config/tsconfig.publish.json +18 -0
- package/config/vite.config.mjs +36 -0
- package/declarations/compile/Compiled.d.ts +7 -0
- package/declarations/compile/Compiled.d.ts.map +1 -0
- package/declarations/compile/compile.d.ts +17 -0
- package/declarations/compile/compile.d.ts.map +1 -0
- package/declarations/compile/state.d.ts +43 -0
- package/declarations/compile/state.d.ts.map +1 -0
- package/declarations/compile/types.d.ts +5 -12
- package/declarations/compile/types.d.ts.map +1 -1
- package/declarations/index.d.ts +6 -2
- package/declarations/index.d.ts.map +1 -1
- package/declarations/services/compiler.d.ts +94 -0
- package/declarations/services/compiler.d.ts.map +1 -0
- package/declarations/services/known-modules.d.ts +7 -0
- package/declarations/services/known-modules.d.ts.map +1 -0
- package/declarations/setup.d.ts +7 -0
- package/declarations/setup.d.ts.map +1 -0
- package/declarations/test-support.d.ts +20 -0
- package/declarations/test-support.d.ts.map +1 -0
- package/dist/_commonjsHelpers-BAGoDD49.js +37 -0
- package/dist/_commonjsHelpers-BAGoDD49.js.map +1 -0
- package/dist/babel-8wMrbxkT.js +110427 -0
- package/dist/babel-8wMrbxkT.js.map +1 -0
- package/dist/blank-line-Bzg2Qt4K.js +482 -0
- package/dist/blank-line-Bzg2Qt4K.js.map +1 -0
- package/dist/compile/Compiled.js +26 -0
- package/dist/compile/Compiled.js.map +1 -0
- package/dist/compile/compile.js +62 -0
- package/dist/compile/compile.js.map +1 -0
- package/dist/compile/state.js +75 -0
- package/dist/compile/state.js.map +1 -0
- package/dist/compile/utils.js +213 -2
- package/dist/compile/utils.js.map +1 -1
- package/dist/default-CoqAuVeH.js +4 -0
- package/dist/default-CoqAuVeH.js.map +1 -0
- package/dist/index-BTx1k6gT.js +323 -0
- package/dist/index-BTx1k6gT.js.map +1 -0
- package/dist/index-Bxzjtr16.js +87 -0
- package/dist/index-Bxzjtr16.js.map +1 -0
- package/dist/index-C371bO_b.js +1553 -0
- package/dist/index-C371bO_b.js.map +1 -0
- package/dist/index-C4AyeeIa.js +5721 -0
- package/dist/index-C4AyeeIa.js.map +1 -0
- package/dist/index-C8S2G0FH.js +1953 -0
- package/dist/index-C8S2G0FH.js.map +1 -0
- package/dist/index-CCcIVEUK.js +409 -0
- package/dist/index-CCcIVEUK.js.map +1 -0
- package/dist/index-CDSIcg03.js +9070 -0
- package/dist/index-CDSIcg03.js.map +1 -0
- package/dist/index-D8szzCn3.js +2 -0
- package/dist/index-D8szzCn3.js.map +1 -0
- package/dist/index-DBBNT106.js +2644 -0
- package/dist/index-DBBNT106.js.map +1 -0
- package/dist/index-DP_Su7Zc.js +362 -0
- package/dist/index-DP_Su7Zc.js.map +1 -0
- package/dist/index-DejgrVqh.js +11299 -0
- package/dist/index-DejgrVqh.js.map +1 -0
- package/dist/index-Dr5iYoKt.js +1551 -0
- package/dist/index-Dr5iYoKt.js.map +1 -0
- package/dist/index-DxolpiGq.js +3336 -0
- package/dist/index-DxolpiGq.js.map +1 -0
- package/dist/index-ZyJlPFQY.js +249 -0
- package/dist/index-ZyJlPFQY.js.map +1 -0
- package/dist/index-k6CfLgeq.js +26 -0
- package/dist/index-k6CfLgeq.js.map +1 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/services/compiler.js +329 -0
- package/dist/services/compiler.js.map +1 -0
- package/dist/services/known-modules.js +123 -0
- package/dist/services/known-modules.js.map +1 -0
- package/dist/setup.js +15 -0
- package/dist/setup.js.map +1 -0
- package/dist/test-support.js +33 -0
- package/dist/test-support.js.map +1 -0
- package/package.json +117 -138
- package/src/compile/Compiled.ts +45 -0
- package/src/compile/compile.ts +89 -0
- package/src/compile/state.ts +88 -0
- package/src/compile/types.ts +14 -13
- package/src/index.ts +6 -2
- package/src/services/compiler.ts +401 -0
- package/src/services/known-modules.ts +130 -0
- package/src/setup.ts +26 -0
- package/src/test-support.ts +64 -0
- package/addon-main.cjs +0 -5
- package/declarations/__PRIVATE__.d.ts +0 -2
- package/declarations/__PRIVATE__.d.ts.map +0 -1
- package/declarations/compile/formats/gjs/babel.d.ts +0 -7
- package/declarations/compile/formats/gjs/babel.d.ts.map +0 -1
- package/declarations/compile/formats/gjs/eval.d.ts +0 -8
- package/declarations/compile/formats/gjs/eval.d.ts.map +0 -1
- package/declarations/compile/formats/gjs/index.d.ts +0 -24
- package/declarations/compile/formats/gjs/index.d.ts.map +0 -1
- package/declarations/compile/formats/gjs/known-modules.d.ts +0 -48
- package/declarations/compile/formats/gjs/known-modules.d.ts.map +0 -1
- package/declarations/compile/formats/hbs.d.ts +0 -17
- package/declarations/compile/formats/hbs.d.ts.map +0 -1
- package/declarations/compile/formats/markdown.d.ts +0 -22
- package/declarations/compile/formats/markdown.d.ts.map +0 -1
- package/declarations/compile/formats.d.ts +0 -17
- package/declarations/compile/formats.d.ts.map +0 -1
- package/declarations/compile/index.d.ts +0 -80
- package/declarations/compile/index.d.ts.map +0 -1
- package/declarations/test-support/index.d.ts +0 -2
- package/declarations/test-support/index.d.ts.map +0 -1
- package/dist/__PRIVATE__.js +0 -2
- package/dist/__PRIVATE__.js.map +0 -1
- package/dist/compile/formats/gjs/babel.js +0 -2
- package/dist/compile/formats/gjs/babel.js.map +0 -1
- package/dist/compile/formats/gjs/eval.js +0 -19
- package/dist/compile/formats/gjs/eval.js.map +0 -1
- package/dist/compile/formats/gjs/index.js +0 -122
- package/dist/compile/formats/gjs/index.js.map +0 -1
- package/dist/compile/formats/gjs/known-modules.js +0 -52
- package/dist/compile/formats/gjs/known-modules.js.map +0 -1
- package/dist/compile/formats/hbs.js +0 -93
- package/dist/compile/formats/hbs.js.map +0 -1
- package/dist/compile/formats/markdown.js +0 -266
- package/dist/compile/formats/markdown.js.map +0 -1
- package/dist/compile/formats.js +0 -173
- package/dist/compile/formats.js.map +0 -1
- package/dist/compile/index.js +0 -113
- package/dist/compile/index.js.map +0 -1
- package/dist/test-support/index.js +0 -8
- package/dist/test-support/index.js.map +0 -1
- package/src/__PRIVATE__.ts +0 -1
- package/src/compile/formats/gjs/babel.ts +0 -7
- package/src/compile/formats/gjs/eval.ts +0 -29
- package/src/compile/formats/gjs/index.ts +0 -153
- package/src/compile/formats/gjs/known-modules.ts +0 -49
- package/src/compile/formats/hbs.ts +0 -100
- package/src/compile/formats/markdown.ts +0 -345
- package/src/compile/formats.ts +0 -178
- package/src/compile/index.ts +0 -219
- package/src/test-support/index.ts +0 -5
|
@@ -0,0 +1,3336 @@
|
|
|
1
|
+
import { a as getAugmentedNamespace, g as getDefaultExportFromCjs } from './_commonjsHelpers-BAGoDD49.js';
|
|
2
|
+
|
|
3
|
+
function _mergeNamespaces(n, m) {
|
|
4
|
+
m.forEach(function (e) {
|
|
5
|
+
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
6
|
+
if (k !== 'default' && !(k in n)) {
|
|
7
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
8
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return e[k]; }
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
return Object.freeze(n);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
var src$1 = {};
|
|
19
|
+
|
|
20
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
21
|
+
//
|
|
22
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
23
|
+
// copy of this software and associated documentation files (the
|
|
24
|
+
// "Software"), to deal in the Software without restriction, including
|
|
25
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
26
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
27
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
28
|
+
// following conditions:
|
|
29
|
+
//
|
|
30
|
+
// The above copyright notice and this permission notice shall be included
|
|
31
|
+
// in all copies or substantial portions of the Software.
|
|
32
|
+
//
|
|
33
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
34
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
35
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
36
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
37
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
38
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
39
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
40
|
+
|
|
41
|
+
// resolves . and .. elements in a path array with directory names there
|
|
42
|
+
// must be no slashes, empty elements, or device names (c:\) in the array
|
|
43
|
+
// (so also no leading and trailing slashes - it does not distinguish
|
|
44
|
+
// relative and absolute paths)
|
|
45
|
+
function normalizeArray(parts, allowAboveRoot) {
|
|
46
|
+
// if the path tries to go above the root, `up` ends up > 0
|
|
47
|
+
var up = 0;
|
|
48
|
+
for (var i = parts.length - 1; i >= 0; i--) {
|
|
49
|
+
var last = parts[i];
|
|
50
|
+
if (last === '.') {
|
|
51
|
+
parts.splice(i, 1);
|
|
52
|
+
} else if (last === '..') {
|
|
53
|
+
parts.splice(i, 1);
|
|
54
|
+
up++;
|
|
55
|
+
} else if (up) {
|
|
56
|
+
parts.splice(i, 1);
|
|
57
|
+
up--;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// if the path is allowed to go above the root, restore leading ..s
|
|
62
|
+
if (allowAboveRoot) {
|
|
63
|
+
for (; up--; up) {
|
|
64
|
+
parts.unshift('..');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return parts;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Split a filename into [root, dir, basename, ext], unix version
|
|
71
|
+
// 'root' is just a slash, or nothing.
|
|
72
|
+
var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
|
|
73
|
+
var splitPath = function (filename) {
|
|
74
|
+
return splitPathRe.exec(filename).slice(1);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// path.resolve([from ...], to)
|
|
78
|
+
// posix version
|
|
79
|
+
function resolve() {
|
|
80
|
+
var resolvedPath = '',
|
|
81
|
+
resolvedAbsolute = false;
|
|
82
|
+
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
83
|
+
var path = i >= 0 ? arguments[i] : '/';
|
|
84
|
+
|
|
85
|
+
// Skip empty and invalid entries
|
|
86
|
+
if (typeof path !== 'string') {
|
|
87
|
+
throw new TypeError('Arguments to path.resolve must be strings');
|
|
88
|
+
} else if (!path) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
resolvedPath = path + '/' + resolvedPath;
|
|
92
|
+
resolvedAbsolute = path.charAt(0) === '/';
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// At this point the path should be resolved to a full absolute path, but
|
|
96
|
+
// handle relative paths to be safe (might happen when process.cwd() fails)
|
|
97
|
+
|
|
98
|
+
// Normalize the path
|
|
99
|
+
resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function (p) {
|
|
100
|
+
return !!p;
|
|
101
|
+
}), !resolvedAbsolute).join('/');
|
|
102
|
+
return (resolvedAbsolute ? '/' : '') + resolvedPath || '.';
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// path.normalize(path)
|
|
106
|
+
// posix version
|
|
107
|
+
function normalize(path) {
|
|
108
|
+
var isPathAbsolute = isAbsolute(path),
|
|
109
|
+
trailingSlash = substr(path, -1) === '/';
|
|
110
|
+
|
|
111
|
+
// Normalize the path
|
|
112
|
+
path = normalizeArray(filter(path.split('/'), function (p) {
|
|
113
|
+
return !!p;
|
|
114
|
+
}), !isPathAbsolute).join('/');
|
|
115
|
+
if (!path && !isPathAbsolute) {
|
|
116
|
+
path = '.';
|
|
117
|
+
}
|
|
118
|
+
if (path && trailingSlash) {
|
|
119
|
+
path += '/';
|
|
120
|
+
}
|
|
121
|
+
return (isPathAbsolute ? '/' : '') + path;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// posix version
|
|
125
|
+
function isAbsolute(path) {
|
|
126
|
+
return path.charAt(0) === '/';
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// posix version
|
|
130
|
+
function join() {
|
|
131
|
+
var paths = Array.prototype.slice.call(arguments, 0);
|
|
132
|
+
return normalize(filter(paths, function (p, index) {
|
|
133
|
+
if (typeof p !== 'string') {
|
|
134
|
+
throw new TypeError('Arguments to path.join must be strings');
|
|
135
|
+
}
|
|
136
|
+
return p;
|
|
137
|
+
}).join('/'));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// path.relative(from, to)
|
|
141
|
+
// posix version
|
|
142
|
+
function relative(from, to) {
|
|
143
|
+
from = resolve(from).substr(1);
|
|
144
|
+
to = resolve(to).substr(1);
|
|
145
|
+
function trim(arr) {
|
|
146
|
+
var start = 0;
|
|
147
|
+
for (; start < arr.length; start++) {
|
|
148
|
+
if (arr[start] !== '') break;
|
|
149
|
+
}
|
|
150
|
+
var end = arr.length - 1;
|
|
151
|
+
for (; end >= 0; end--) {
|
|
152
|
+
if (arr[end] !== '') break;
|
|
153
|
+
}
|
|
154
|
+
if (start > end) return [];
|
|
155
|
+
return arr.slice(start, end - start + 1);
|
|
156
|
+
}
|
|
157
|
+
var fromParts = trim(from.split('/'));
|
|
158
|
+
var toParts = trim(to.split('/'));
|
|
159
|
+
var length = Math.min(fromParts.length, toParts.length);
|
|
160
|
+
var samePartsLength = length;
|
|
161
|
+
for (var i = 0; i < length; i++) {
|
|
162
|
+
if (fromParts[i] !== toParts[i]) {
|
|
163
|
+
samePartsLength = i;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
var outputParts = [];
|
|
168
|
+
for (var i = samePartsLength; i < fromParts.length; i++) {
|
|
169
|
+
outputParts.push('..');
|
|
170
|
+
}
|
|
171
|
+
outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
|
172
|
+
return outputParts.join('/');
|
|
173
|
+
}
|
|
174
|
+
var sep = '/';
|
|
175
|
+
var delimiter = ':';
|
|
176
|
+
function dirname(path) {
|
|
177
|
+
var result = splitPath(path),
|
|
178
|
+
root = result[0],
|
|
179
|
+
dir = result[1];
|
|
180
|
+
if (!root && !dir) {
|
|
181
|
+
// No dirname whatsoever
|
|
182
|
+
return '.';
|
|
183
|
+
}
|
|
184
|
+
if (dir) {
|
|
185
|
+
// It has a dirname, strip trailing slash
|
|
186
|
+
dir = dir.substr(0, dir.length - 1);
|
|
187
|
+
}
|
|
188
|
+
return root + dir;
|
|
189
|
+
}
|
|
190
|
+
function basename(path, ext) {
|
|
191
|
+
var f = splitPath(path)[2];
|
|
192
|
+
// TODO: make this comparison case-insensitive on windows?
|
|
193
|
+
if (ext && f.substr(-1 * ext.length) === ext) {
|
|
194
|
+
f = f.substr(0, f.length - ext.length);
|
|
195
|
+
}
|
|
196
|
+
return f;
|
|
197
|
+
}
|
|
198
|
+
function extname(path) {
|
|
199
|
+
return splitPath(path)[3];
|
|
200
|
+
}
|
|
201
|
+
var path = {
|
|
202
|
+
extname: extname,
|
|
203
|
+
basename: basename,
|
|
204
|
+
dirname: dirname,
|
|
205
|
+
sep: sep,
|
|
206
|
+
delimiter: delimiter,
|
|
207
|
+
relative: relative,
|
|
208
|
+
join: join,
|
|
209
|
+
isAbsolute: isAbsolute,
|
|
210
|
+
normalize: normalize,
|
|
211
|
+
resolve: resolve
|
|
212
|
+
};
|
|
213
|
+
function filter(xs, f) {
|
|
214
|
+
if (xs.filter) return xs.filter(f);
|
|
215
|
+
var res = [];
|
|
216
|
+
for (var i = 0; i < xs.length; i++) {
|
|
217
|
+
if (f(xs[i], i, xs)) res.push(xs[i]);
|
|
218
|
+
}
|
|
219
|
+
return res;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// String.prototype.substr - negative index don't work in IE8
|
|
223
|
+
var substr = 'ab'.substr(-1) === 'b' ? function (str, start, len) {
|
|
224
|
+
return str.substr(start, len);
|
|
225
|
+
} : function (str, start, len) {
|
|
226
|
+
if (start < 0) start = str.length + start;
|
|
227
|
+
return str.substr(start, len);
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
var path$1 = /*#__PURE__*/Object.freeze({
|
|
231
|
+
__proto__: null,
|
|
232
|
+
basename: basename,
|
|
233
|
+
default: path,
|
|
234
|
+
delimiter: delimiter,
|
|
235
|
+
dirname: dirname,
|
|
236
|
+
extname: extname,
|
|
237
|
+
isAbsolute: isAbsolute,
|
|
238
|
+
join: join,
|
|
239
|
+
normalize: normalize,
|
|
240
|
+
relative: relative,
|
|
241
|
+
resolve: resolve,
|
|
242
|
+
sep: sep
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
var require$$0 = /*@__PURE__*/getAugmentedNamespace(path$1);
|
|
246
|
+
|
|
247
|
+
var macros = {};
|
|
248
|
+
|
|
249
|
+
var builder = {};
|
|
250
|
+
|
|
251
|
+
var hasRequiredBuilder;
|
|
252
|
+
|
|
253
|
+
function requireBuilder () {
|
|
254
|
+
if (hasRequiredBuilder) return builder;
|
|
255
|
+
hasRequiredBuilder = 1;
|
|
256
|
+
|
|
257
|
+
Object.defineProperty(builder, "__esModule", {
|
|
258
|
+
value: true
|
|
259
|
+
});
|
|
260
|
+
class Builder {
|
|
261
|
+
constructor(t, util, options) {
|
|
262
|
+
this.t = t;
|
|
263
|
+
this.expressions = [];
|
|
264
|
+
this.module = options.module;
|
|
265
|
+
this.global = options.global;
|
|
266
|
+
this.assertPredicateIndex = options.assertPredicateIndex;
|
|
267
|
+
this.isDebug = options.isDebug;
|
|
268
|
+
this.util = util;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Expands:
|
|
272
|
+
*
|
|
273
|
+
* assert($PREDICATE, $MESSAGE)
|
|
274
|
+
*
|
|
275
|
+
* into
|
|
276
|
+
*
|
|
277
|
+
* ($DEBUG && console.assert($PREDICATE, $MESSAGE));
|
|
278
|
+
*
|
|
279
|
+
* or
|
|
280
|
+
*
|
|
281
|
+
* ($DEBUG && assert($PREDICATE, $MESSAGE));
|
|
282
|
+
*
|
|
283
|
+
* or
|
|
284
|
+
*
|
|
285
|
+
* ($DEBUG && $GLOBAL_NS.assert($PREDICATE, $MESSAGE));
|
|
286
|
+
*/
|
|
287
|
+
assert(path) {
|
|
288
|
+
let predicate;
|
|
289
|
+
const index = this.assertPredicateIndex;
|
|
290
|
+
if (index !== undefined) {
|
|
291
|
+
predicate = (expression, args) => {
|
|
292
|
+
return args[index];
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
this._createMacroExpression(path, {
|
|
296
|
+
predicate
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Expands:
|
|
301
|
+
*
|
|
302
|
+
* warn($MESSAGE)
|
|
303
|
+
*
|
|
304
|
+
* into
|
|
305
|
+
*
|
|
306
|
+
* ($DEBUG && console.warn($MESSAGE));
|
|
307
|
+
*
|
|
308
|
+
* or
|
|
309
|
+
*
|
|
310
|
+
* ($DEBUG && warn($MESSAGE));
|
|
311
|
+
*
|
|
312
|
+
* or
|
|
313
|
+
*
|
|
314
|
+
* ($DEBUG && $GLOBAL_NS.warn($MESSAGE));
|
|
315
|
+
*/
|
|
316
|
+
warn(path) {
|
|
317
|
+
this._createMacroExpression(path);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Expands:
|
|
321
|
+
*
|
|
322
|
+
* log($MESSAGE)
|
|
323
|
+
*
|
|
324
|
+
* into
|
|
325
|
+
*
|
|
326
|
+
* ($DEBUG && console.log($MESSAGE));
|
|
327
|
+
*
|
|
328
|
+
* or
|
|
329
|
+
*
|
|
330
|
+
* ($DEBUG && log($MESSAGE));
|
|
331
|
+
*
|
|
332
|
+
* or
|
|
333
|
+
*
|
|
334
|
+
* ($DEBUG && $GLOBAL_NS.log($MESSAGE));
|
|
335
|
+
*/
|
|
336
|
+
log(path) {
|
|
337
|
+
this._createMacroExpression(path);
|
|
338
|
+
}
|
|
339
|
+
_createMacroExpression(path, options = {}) {
|
|
340
|
+
let t = this.t;
|
|
341
|
+
let expression = path.node.expression;
|
|
342
|
+
let callee = expression.callee;
|
|
343
|
+
let args = expression.arguments;
|
|
344
|
+
if (options.validate) {
|
|
345
|
+
options.validate(expression, args);
|
|
346
|
+
}
|
|
347
|
+
let callExpression;
|
|
348
|
+
if (this.module) {
|
|
349
|
+
callExpression = expression;
|
|
350
|
+
} else if (this.global) {
|
|
351
|
+
callExpression = this._createGlobalExternalHelper(callee, args, this.global);
|
|
352
|
+
} else if (options.buildConsoleAPI) {
|
|
353
|
+
callExpression = options.buildConsoleAPI(expression, args);
|
|
354
|
+
} else {
|
|
355
|
+
callExpression = this._createConsoleAPI(options.consoleAPI || callee, args);
|
|
356
|
+
}
|
|
357
|
+
let prefixedIdentifiers = [];
|
|
358
|
+
if (options.predicate) {
|
|
359
|
+
let predicate = options.predicate(expression, args) || t.identifier('false');
|
|
360
|
+
if (!this.t.isExpression(predicate)) {
|
|
361
|
+
throw new Error(`bug: this doesn't support ${predicate.type}`);
|
|
362
|
+
}
|
|
363
|
+
let negatedPredicate = t.unaryExpression('!', t.parenthesizedExpression(predicate));
|
|
364
|
+
prefixedIdentifiers.push(negatedPredicate);
|
|
365
|
+
}
|
|
366
|
+
this.expressions.push([path, this._buildLogicalExpressions(prefixedIdentifiers, callExpression)]);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Expands:
|
|
370
|
+
*
|
|
371
|
+
* deprecate($MESSAGE, $PREDICATE)
|
|
372
|
+
*
|
|
373
|
+
* or
|
|
374
|
+
*
|
|
375
|
+
* deprecate($MESSAGE, $PREDICATE, {
|
|
376
|
+
* $ID,
|
|
377
|
+
* $URL,
|
|
378
|
+
* $UNIL
|
|
379
|
+
* });
|
|
380
|
+
*
|
|
381
|
+
* into
|
|
382
|
+
*
|
|
383
|
+
* ($DEBUG && $PREDICATE && console.warn($MESSAGE));
|
|
384
|
+
*
|
|
385
|
+
* or
|
|
386
|
+
*
|
|
387
|
+
* ($DEBUG && $PREDICATE && deprecate($MESSAGE, $PREDICATE, { $ID, $URL, $UNTIL }));
|
|
388
|
+
*
|
|
389
|
+
* or
|
|
390
|
+
*
|
|
391
|
+
* ($DEBUG && $PREDICATE && $GLOBAL_NS.deprecate($MESSAGE, $PREDICATE, { $ID, $URL, $UNTIL }));
|
|
392
|
+
*/
|
|
393
|
+
deprecate(path) {
|
|
394
|
+
this._createMacroExpression(path, {
|
|
395
|
+
predicate: (expression, args) => args[1],
|
|
396
|
+
buildConsoleAPI: (expression, args) => {
|
|
397
|
+
let message = args[0];
|
|
398
|
+
return this._createConsoleAPI(this.t.identifier('warn'), [message]);
|
|
399
|
+
},
|
|
400
|
+
validate: (expression, args) => {
|
|
401
|
+
let meta = args[2];
|
|
402
|
+
if (meta && this.t.isObjectExpression(meta) && meta.properties && !meta.properties.some(prop => this.t.isObjectProperty(prop) && (this.t.isIdentifier(prop.key) && prop.key.name === 'id' || this.t.isStringLiteral(prop.key) && prop.key.value === 'id'))) {
|
|
403
|
+
throw new ReferenceError(`deprecate's meta information requires an "id" field.`);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Performs the actually expansion of macros
|
|
410
|
+
*/
|
|
411
|
+
expandMacros() {
|
|
412
|
+
let t = this.t;
|
|
413
|
+
for (let i = 0; i < this.expressions.length; i++) {
|
|
414
|
+
let expression = this.expressions[i];
|
|
415
|
+
let exp = expression[0];
|
|
416
|
+
let flag = this._debugExpression(exp);
|
|
417
|
+
let logicalExp = expression[1];
|
|
418
|
+
exp.replaceWith(t.parenthesizedExpression(logicalExp(flag)));
|
|
419
|
+
exp.scope.crawl();
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
_debugExpression(target) {
|
|
423
|
+
if (typeof this.isDebug === 'boolean') {
|
|
424
|
+
return this.t.booleanLiteral(this.isDebug);
|
|
425
|
+
} else {
|
|
426
|
+
return this.t.callExpression(this.util.import(target, '@embroider/macros', 'isDevelopingApp'), []);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
_createGlobalExternalHelper(identifier, args, ns) {
|
|
430
|
+
let t = this.t;
|
|
431
|
+
return t.callExpression(t.memberExpression(t.identifier(ns), identifier), args);
|
|
432
|
+
}
|
|
433
|
+
_createConsoleAPI(identifier, args) {
|
|
434
|
+
let t = this.t;
|
|
435
|
+
return t.callExpression(t.memberExpression(t.identifier('console'), identifier), args);
|
|
436
|
+
}
|
|
437
|
+
_buildLogicalExpressions(identifiers, callExpression) {
|
|
438
|
+
let t = this.t;
|
|
439
|
+
return debugIdentifier => {
|
|
440
|
+
identifiers.unshift(debugIdentifier);
|
|
441
|
+
identifiers.push(callExpression);
|
|
442
|
+
let logicalExpressions;
|
|
443
|
+
for (let i = 0; i < identifiers.length; i++) {
|
|
444
|
+
let left = identifiers[i];
|
|
445
|
+
let right = identifiers[i + 1];
|
|
446
|
+
if (!logicalExpressions) {
|
|
447
|
+
logicalExpressions = t.logicalExpression('&&', left, right);
|
|
448
|
+
} else if (right) {
|
|
449
|
+
logicalExpressions = t.logicalExpression('&&', logicalExpressions, right);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return logicalExpressions;
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
builder.default = Builder;
|
|
457
|
+
return builder;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
var babelTypeHelpers = {};
|
|
461
|
+
|
|
462
|
+
var hasRequiredBabelTypeHelpers;
|
|
463
|
+
|
|
464
|
+
function requireBabelTypeHelpers () {
|
|
465
|
+
if (hasRequiredBabelTypeHelpers) return babelTypeHelpers;
|
|
466
|
+
hasRequiredBabelTypeHelpers = 1;
|
|
467
|
+
|
|
468
|
+
Object.defineProperty(babelTypeHelpers, "__esModule", {
|
|
469
|
+
value: true
|
|
470
|
+
});
|
|
471
|
+
babelTypeHelpers.isCallStatementPath = babelTypeHelpers.isCallIdentifierExpression = babelTypeHelpers.name = void 0;
|
|
472
|
+
function name(value) {
|
|
473
|
+
if (value.type === 'Identifier') {
|
|
474
|
+
return value.name;
|
|
475
|
+
} else {
|
|
476
|
+
return value.value;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
babelTypeHelpers.name = name;
|
|
480
|
+
function isCallIdentifierExpression(exp) {
|
|
481
|
+
return exp.callee.type === 'Identifier';
|
|
482
|
+
}
|
|
483
|
+
babelTypeHelpers.isCallIdentifierExpression = isCallIdentifierExpression;
|
|
484
|
+
function isCallStatementPath(path) {
|
|
485
|
+
return path.node.expression.type === 'CallExpression' && isCallIdentifierExpression(path.node.expression);
|
|
486
|
+
}
|
|
487
|
+
babelTypeHelpers.isCallStatementPath = isCallStatementPath;
|
|
488
|
+
return babelTypeHelpers;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
var hasRequiredMacros;
|
|
492
|
+
|
|
493
|
+
function requireMacros () {
|
|
494
|
+
if (hasRequiredMacros) return macros;
|
|
495
|
+
hasRequiredMacros = 1;
|
|
496
|
+
|
|
497
|
+
var __importDefault = macros && macros.__importDefault || function (mod) {
|
|
498
|
+
return mod && mod.__esModule ? mod : {
|
|
499
|
+
"default": mod
|
|
500
|
+
};
|
|
501
|
+
};
|
|
502
|
+
Object.defineProperty(macros, "__esModule", {
|
|
503
|
+
value: true
|
|
504
|
+
});
|
|
505
|
+
const builder_1 = __importDefault(requireBuilder());
|
|
506
|
+
const babel_type_helpers_1 = requireBabelTypeHelpers();
|
|
507
|
+
const SUPPORTED_MACROS = ['assert', 'deprecate', 'warn', 'log'];
|
|
508
|
+
class Macros {
|
|
509
|
+
constructor(babel, options, util) {
|
|
510
|
+
this.localDebugBindings = [];
|
|
511
|
+
this.debugHelpers = options.externalizeHelpers;
|
|
512
|
+
this.builder = new builder_1.default(babel.types, util, {
|
|
513
|
+
module: this.debugHelpers?.module,
|
|
514
|
+
global: this.debugHelpers?.global,
|
|
515
|
+
assertPredicateIndex: options.debugTools && options.debugTools.assertPredicateIndex,
|
|
516
|
+
isDebug: options.debugTools.isDebug
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Injects the either the env-flags module with the debug binding or
|
|
521
|
+
* adds the debug binding if missing from the env-flags module.
|
|
522
|
+
*/
|
|
523
|
+
expand() {
|
|
524
|
+
this.builder.expandMacros();
|
|
525
|
+
this._cleanImports();
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Collects the import bindings for the debug tools.
|
|
529
|
+
*/
|
|
530
|
+
collectDebugToolsSpecifiers(specifiers) {
|
|
531
|
+
specifiers.forEach(specifier => {
|
|
532
|
+
if (specifier.node.type === 'ImportSpecifier' && SUPPORTED_MACROS.indexOf((0, babel_type_helpers_1.name)(specifier.node.imported)) > -1) {
|
|
533
|
+
this.localDebugBindings.push(specifier.get('local'));
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Builds the expressions that the CallExpression will expand into.
|
|
539
|
+
*/
|
|
540
|
+
build(path) {
|
|
541
|
+
if (!(0, babel_type_helpers_1.isCallStatementPath)(path)) {
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
if (this.localDebugBindings.some(b => b.node.name === path.node.expression.callee.name)) {
|
|
545
|
+
let imported = (0, babel_type_helpers_1.name)(path.scope.getBinding(path.node.expression.callee.name).path.node.imported);
|
|
546
|
+
this.builder[`${imported}`](path);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
_cleanImports() {
|
|
550
|
+
if (!this.debugHelpers?.module) {
|
|
551
|
+
if (this.localDebugBindings.length > 0) {
|
|
552
|
+
let importPath = this.localDebugBindings[0].findParent(p => p.isImportDeclaration());
|
|
553
|
+
if (importPath === null) {
|
|
554
|
+
// import declaration in question seems to have already been removed
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
let specifiers = importPath.get('specifiers');
|
|
558
|
+
if (specifiers.length === this.localDebugBindings.length) {
|
|
559
|
+
this.localDebugBindings[0].parentPath.parentPath.remove();
|
|
560
|
+
} else {
|
|
561
|
+
this.localDebugBindings.forEach(binding => binding.parentPath.remove());
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
macros.default = Macros;
|
|
568
|
+
return macros;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
var normalizeOptions = {};
|
|
572
|
+
|
|
573
|
+
var re = {exports: {}};
|
|
574
|
+
|
|
575
|
+
var constants;
|
|
576
|
+
var hasRequiredConstants;
|
|
577
|
+
|
|
578
|
+
function requireConstants () {
|
|
579
|
+
if (hasRequiredConstants) return constants;
|
|
580
|
+
hasRequiredConstants = 1;
|
|
581
|
+
|
|
582
|
+
// Note: this is the semver.org version of the spec that it implements
|
|
583
|
+
// Not necessarily the package version of this code.
|
|
584
|
+
const SEMVER_SPEC_VERSION = '2.0.0';
|
|
585
|
+
const MAX_LENGTH = 256;
|
|
586
|
+
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */9007199254740991;
|
|
587
|
+
|
|
588
|
+
// Max safe segment length for coercion.
|
|
589
|
+
const MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
590
|
+
|
|
591
|
+
// Max safe length for a build identifier. The max length minus 6 characters for
|
|
592
|
+
// the shortest version with a build 0.0.0+BUILD.
|
|
593
|
+
const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
|
|
594
|
+
const RELEASE_TYPES = ['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease'];
|
|
595
|
+
constants = {
|
|
596
|
+
MAX_LENGTH,
|
|
597
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
598
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
599
|
+
MAX_SAFE_INTEGER,
|
|
600
|
+
RELEASE_TYPES,
|
|
601
|
+
SEMVER_SPEC_VERSION,
|
|
602
|
+
FLAG_INCLUDE_PRERELEASE: 0b001,
|
|
603
|
+
FLAG_LOOSE: 0b010
|
|
604
|
+
};
|
|
605
|
+
return constants;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
var debug_1;
|
|
609
|
+
var hasRequiredDebug;
|
|
610
|
+
|
|
611
|
+
function requireDebug () {
|
|
612
|
+
if (hasRequiredDebug) return debug_1;
|
|
613
|
+
hasRequiredDebug = 1;
|
|
614
|
+
|
|
615
|
+
const debug = typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error('SEMVER', ...args) : () => {};
|
|
616
|
+
debug_1 = debug;
|
|
617
|
+
return debug_1;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
var hasRequiredRe;
|
|
621
|
+
|
|
622
|
+
function requireRe () {
|
|
623
|
+
if (hasRequiredRe) return re.exports;
|
|
624
|
+
hasRequiredRe = 1;
|
|
625
|
+
(function (module, exports) {
|
|
626
|
+
|
|
627
|
+
const {
|
|
628
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
629
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
630
|
+
MAX_LENGTH
|
|
631
|
+
} = requireConstants();
|
|
632
|
+
const debug = requireDebug();
|
|
633
|
+
exports = module.exports = {};
|
|
634
|
+
|
|
635
|
+
// The actual regexps go on exports.re
|
|
636
|
+
const re = exports.re = [];
|
|
637
|
+
const safeRe = exports.safeRe = [];
|
|
638
|
+
const src = exports.src = [];
|
|
639
|
+
const safeSrc = exports.safeSrc = [];
|
|
640
|
+
const t = exports.t = {};
|
|
641
|
+
let R = 0;
|
|
642
|
+
const LETTERDASHNUMBER = '[a-zA-Z0-9-]';
|
|
643
|
+
|
|
644
|
+
// Replace some greedy regex tokens to prevent regex dos issues. These regex are
|
|
645
|
+
// used internally via the safeRe object since all inputs in this library get
|
|
646
|
+
// normalized first to trim and collapse all extra whitespace. The original
|
|
647
|
+
// regexes are exported for userland consumption and lower level usage. A
|
|
648
|
+
// future breaking change could export the safer regex only with a note that
|
|
649
|
+
// all input should have extra whitespace removed.
|
|
650
|
+
const safeRegexReplacements = [['\\s', 1], ['\\d', MAX_LENGTH], [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]];
|
|
651
|
+
const makeSafeRegex = value => {
|
|
652
|
+
for (const [token, max] of safeRegexReplacements) {
|
|
653
|
+
value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
|
|
654
|
+
}
|
|
655
|
+
return value;
|
|
656
|
+
};
|
|
657
|
+
const createToken = (name, value, isGlobal) => {
|
|
658
|
+
const safe = makeSafeRegex(value);
|
|
659
|
+
const index = R++;
|
|
660
|
+
debug(name, index, value);
|
|
661
|
+
t[name] = index;
|
|
662
|
+
src[index] = value;
|
|
663
|
+
safeSrc[index] = safe;
|
|
664
|
+
re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
|
|
665
|
+
safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined);
|
|
666
|
+
};
|
|
667
|
+
|
|
668
|
+
// The following Regular Expressions can be used for tokenizing,
|
|
669
|
+
// validating, and parsing SemVer version strings.
|
|
670
|
+
|
|
671
|
+
// ## Numeric Identifier
|
|
672
|
+
// A single `0`, or a non-zero digit followed by zero or more digits.
|
|
673
|
+
|
|
674
|
+
createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
|
|
675
|
+
createToken('NUMERICIDENTIFIERLOOSE', '\\d+');
|
|
676
|
+
|
|
677
|
+
// ## Non-numeric Identifier
|
|
678
|
+
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
|
679
|
+
// more letters, digits, or hyphens.
|
|
680
|
+
|
|
681
|
+
createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
682
|
+
|
|
683
|
+
// ## Main Version
|
|
684
|
+
// Three dot-separated numeric identifiers.
|
|
685
|
+
|
|
686
|
+
createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})`);
|
|
687
|
+
createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
688
|
+
|
|
689
|
+
// ## Pre-release Version Identifier
|
|
690
|
+
// A numeric identifier, or a non-numeric identifier.
|
|
691
|
+
// Non-numberic identifiers include numberic identifiers but can be longer.
|
|
692
|
+
// Therefore non-numberic identifiers must go first.
|
|
693
|
+
|
|
694
|
+
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
695
|
+
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
696
|
+
|
|
697
|
+
// ## Pre-release Version
|
|
698
|
+
// Hyphen, followed by one or more dot-separated pre-release version
|
|
699
|
+
// identifiers.
|
|
700
|
+
|
|
701
|
+
createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
702
|
+
createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
703
|
+
|
|
704
|
+
// ## Build Metadata Identifier
|
|
705
|
+
// Any combination of digits, letters, or hyphens.
|
|
706
|
+
|
|
707
|
+
createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`);
|
|
708
|
+
|
|
709
|
+
// ## Build Metadata
|
|
710
|
+
// Plus sign, followed by one or more period-separated build metadata
|
|
711
|
+
// identifiers.
|
|
712
|
+
|
|
713
|
+
createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
714
|
+
|
|
715
|
+
// ## Full Version String
|
|
716
|
+
// A main version, followed optionally by a pre-release version and
|
|
717
|
+
// build metadata.
|
|
718
|
+
|
|
719
|
+
// Note that the only major, minor, patch, and pre-release sections of
|
|
720
|
+
// the version string are capturing groups. The build metadata is not a
|
|
721
|
+
// capturing group, because it should not ever be used in version
|
|
722
|
+
// comparison.
|
|
723
|
+
|
|
724
|
+
createToken('FULLPLAIN', `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
|
725
|
+
createToken('FULL', `^${src[t.FULLPLAIN]}$`);
|
|
726
|
+
|
|
727
|
+
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
|
728
|
+
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
|
729
|
+
// common in the npm registry.
|
|
730
|
+
createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
|
731
|
+
createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
|
|
732
|
+
createToken('GTLT', '((?:<|>)?=?)');
|
|
733
|
+
|
|
734
|
+
// Something like "2.*" or "1.2.x".
|
|
735
|
+
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
|
736
|
+
// Only the first item is strictly required.
|
|
737
|
+
createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
738
|
+
createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
739
|
+
createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?` + `)?)?`);
|
|
740
|
+
createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?` + `)?)?`);
|
|
741
|
+
createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
742
|
+
createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
743
|
+
|
|
744
|
+
// Coercion.
|
|
745
|
+
// Extract anything that could conceivably be a part of a valid semver
|
|
746
|
+
createToken('COERCEPLAIN', `${'(^|[^\\d])' + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
747
|
+
createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
748
|
+
createToken('COERCEFULL', src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?` + `(?:${src[t.BUILD]})?` + `(?:$|[^\\d])`);
|
|
749
|
+
createToken('COERCERTL', src[t.COERCE], true);
|
|
750
|
+
createToken('COERCERTLFULL', src[t.COERCEFULL], true);
|
|
751
|
+
|
|
752
|
+
// Tilde ranges.
|
|
753
|
+
// Meaning is "reasonably at or greater than"
|
|
754
|
+
createToken('LONETILDE', '(?:~>?)');
|
|
755
|
+
createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
756
|
+
exports.tildeTrimReplace = '$1~';
|
|
757
|
+
createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
758
|
+
createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
759
|
+
|
|
760
|
+
// Caret ranges.
|
|
761
|
+
// Meaning is "at least and backwards compatible with"
|
|
762
|
+
createToken('LONECARET', '(?:\\^)');
|
|
763
|
+
createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
764
|
+
exports.caretTrimReplace = '$1^';
|
|
765
|
+
createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
766
|
+
createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
767
|
+
|
|
768
|
+
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
|
769
|
+
createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
770
|
+
createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
771
|
+
|
|
772
|
+
// An expression to strip any whitespace between the gtlt and the thing
|
|
773
|
+
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
|
774
|
+
createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
775
|
+
exports.comparatorTrimReplace = '$1$2$3';
|
|
776
|
+
|
|
777
|
+
// Something like `1.2.3 - 1.2.4`
|
|
778
|
+
// Note that these all use the loose form, because they'll be
|
|
779
|
+
// checked against either the strict or loose comparator form
|
|
780
|
+
// later.
|
|
781
|
+
createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAIN]})` + `\\s*$`);
|
|
782
|
+
createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAINLOOSE]})` + `\\s*$`);
|
|
783
|
+
|
|
784
|
+
// Star ranges basically just allow anything at all.
|
|
785
|
+
createToken('STAR', '(<|>)?=?\\s*\\*');
|
|
786
|
+
// >=0.0.0 is like a star
|
|
787
|
+
createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
|
|
788
|
+
createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
|
|
789
|
+
} (re, re.exports));
|
|
790
|
+
return re.exports;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
var parseOptions_1;
|
|
794
|
+
var hasRequiredParseOptions;
|
|
795
|
+
|
|
796
|
+
function requireParseOptions () {
|
|
797
|
+
if (hasRequiredParseOptions) return parseOptions_1;
|
|
798
|
+
hasRequiredParseOptions = 1;
|
|
799
|
+
|
|
800
|
+
// parse out just the options we care about
|
|
801
|
+
const looseOption = Object.freeze({
|
|
802
|
+
loose: true
|
|
803
|
+
});
|
|
804
|
+
const emptyOpts = Object.freeze({});
|
|
805
|
+
const parseOptions = options => {
|
|
806
|
+
if (!options) {
|
|
807
|
+
return emptyOpts;
|
|
808
|
+
}
|
|
809
|
+
if (typeof options !== 'object') {
|
|
810
|
+
return looseOption;
|
|
811
|
+
}
|
|
812
|
+
return options;
|
|
813
|
+
};
|
|
814
|
+
parseOptions_1 = parseOptions;
|
|
815
|
+
return parseOptions_1;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
var identifiers;
|
|
819
|
+
var hasRequiredIdentifiers;
|
|
820
|
+
|
|
821
|
+
function requireIdentifiers () {
|
|
822
|
+
if (hasRequiredIdentifiers) return identifiers;
|
|
823
|
+
hasRequiredIdentifiers = 1;
|
|
824
|
+
|
|
825
|
+
const numeric = /^[0-9]+$/;
|
|
826
|
+
const compareIdentifiers = (a, b) => {
|
|
827
|
+
const anum = numeric.test(a);
|
|
828
|
+
const bnum = numeric.test(b);
|
|
829
|
+
if (anum && bnum) {
|
|
830
|
+
a = +a;
|
|
831
|
+
b = +b;
|
|
832
|
+
}
|
|
833
|
+
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
834
|
+
};
|
|
835
|
+
const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
|
836
|
+
identifiers = {
|
|
837
|
+
compareIdentifiers,
|
|
838
|
+
rcompareIdentifiers
|
|
839
|
+
};
|
|
840
|
+
return identifiers;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
var semver$1;
|
|
844
|
+
var hasRequiredSemver$1;
|
|
845
|
+
|
|
846
|
+
function requireSemver$1 () {
|
|
847
|
+
if (hasRequiredSemver$1) return semver$1;
|
|
848
|
+
hasRequiredSemver$1 = 1;
|
|
849
|
+
|
|
850
|
+
const debug = requireDebug();
|
|
851
|
+
const {
|
|
852
|
+
MAX_LENGTH,
|
|
853
|
+
MAX_SAFE_INTEGER
|
|
854
|
+
} = requireConstants();
|
|
855
|
+
const {
|
|
856
|
+
safeRe: re,
|
|
857
|
+
t
|
|
858
|
+
} = requireRe();
|
|
859
|
+
const parseOptions = requireParseOptions();
|
|
860
|
+
const {
|
|
861
|
+
compareIdentifiers
|
|
862
|
+
} = requireIdentifiers();
|
|
863
|
+
class SemVer {
|
|
864
|
+
constructor(version, options) {
|
|
865
|
+
options = parseOptions(options);
|
|
866
|
+
if (version instanceof SemVer) {
|
|
867
|
+
if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
|
|
868
|
+
return version;
|
|
869
|
+
} else {
|
|
870
|
+
version = version.version;
|
|
871
|
+
}
|
|
872
|
+
} else if (typeof version !== 'string') {
|
|
873
|
+
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
|
|
874
|
+
}
|
|
875
|
+
if (version.length > MAX_LENGTH) {
|
|
876
|
+
throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
|
|
877
|
+
}
|
|
878
|
+
debug('SemVer', version, options);
|
|
879
|
+
this.options = options;
|
|
880
|
+
this.loose = !!options.loose;
|
|
881
|
+
// this isn't actually relevant for versions, but keep it so that we
|
|
882
|
+
// don't run into trouble passing this.options around.
|
|
883
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
884
|
+
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
885
|
+
if (!m) {
|
|
886
|
+
throw new TypeError(`Invalid Version: ${version}`);
|
|
887
|
+
}
|
|
888
|
+
this.raw = version;
|
|
889
|
+
|
|
890
|
+
// these are actually numbers
|
|
891
|
+
this.major = +m[1];
|
|
892
|
+
this.minor = +m[2];
|
|
893
|
+
this.patch = +m[3];
|
|
894
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
895
|
+
throw new TypeError('Invalid major version');
|
|
896
|
+
}
|
|
897
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
898
|
+
throw new TypeError('Invalid minor version');
|
|
899
|
+
}
|
|
900
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
901
|
+
throw new TypeError('Invalid patch version');
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
// numberify any prerelease numeric ids
|
|
905
|
+
if (!m[4]) {
|
|
906
|
+
this.prerelease = [];
|
|
907
|
+
} else {
|
|
908
|
+
this.prerelease = m[4].split('.').map(id => {
|
|
909
|
+
if (/^[0-9]+$/.test(id)) {
|
|
910
|
+
const num = +id;
|
|
911
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
912
|
+
return num;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
return id;
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
this.build = m[5] ? m[5].split('.') : [];
|
|
919
|
+
this.format();
|
|
920
|
+
}
|
|
921
|
+
format() {
|
|
922
|
+
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
923
|
+
if (this.prerelease.length) {
|
|
924
|
+
this.version += `-${this.prerelease.join('.')}`;
|
|
925
|
+
}
|
|
926
|
+
return this.version;
|
|
927
|
+
}
|
|
928
|
+
toString() {
|
|
929
|
+
return this.version;
|
|
930
|
+
}
|
|
931
|
+
compare(other) {
|
|
932
|
+
debug('SemVer.compare', this.version, this.options, other);
|
|
933
|
+
if (!(other instanceof SemVer)) {
|
|
934
|
+
if (typeof other === 'string' && other === this.version) {
|
|
935
|
+
return 0;
|
|
936
|
+
}
|
|
937
|
+
other = new SemVer(other, this.options);
|
|
938
|
+
}
|
|
939
|
+
if (other.version === this.version) {
|
|
940
|
+
return 0;
|
|
941
|
+
}
|
|
942
|
+
return this.compareMain(other) || this.comparePre(other);
|
|
943
|
+
}
|
|
944
|
+
compareMain(other) {
|
|
945
|
+
if (!(other instanceof SemVer)) {
|
|
946
|
+
other = new SemVer(other, this.options);
|
|
947
|
+
}
|
|
948
|
+
return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
|
|
949
|
+
}
|
|
950
|
+
comparePre(other) {
|
|
951
|
+
if (!(other instanceof SemVer)) {
|
|
952
|
+
other = new SemVer(other, this.options);
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
// NOT having a prerelease is > having one
|
|
956
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
|
957
|
+
return -1;
|
|
958
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
959
|
+
return 1;
|
|
960
|
+
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
961
|
+
return 0;
|
|
962
|
+
}
|
|
963
|
+
let i = 0;
|
|
964
|
+
do {
|
|
965
|
+
const a = this.prerelease[i];
|
|
966
|
+
const b = other.prerelease[i];
|
|
967
|
+
debug('prerelease compare', i, a, b);
|
|
968
|
+
if (a === undefined && b === undefined) {
|
|
969
|
+
return 0;
|
|
970
|
+
} else if (b === undefined) {
|
|
971
|
+
return 1;
|
|
972
|
+
} else if (a === undefined) {
|
|
973
|
+
return -1;
|
|
974
|
+
} else if (a === b) {
|
|
975
|
+
continue;
|
|
976
|
+
} else {
|
|
977
|
+
return compareIdentifiers(a, b);
|
|
978
|
+
}
|
|
979
|
+
} while (++i);
|
|
980
|
+
}
|
|
981
|
+
compareBuild(other) {
|
|
982
|
+
if (!(other instanceof SemVer)) {
|
|
983
|
+
other = new SemVer(other, this.options);
|
|
984
|
+
}
|
|
985
|
+
let i = 0;
|
|
986
|
+
do {
|
|
987
|
+
const a = this.build[i];
|
|
988
|
+
const b = other.build[i];
|
|
989
|
+
debug('build compare', i, a, b);
|
|
990
|
+
if (a === undefined && b === undefined) {
|
|
991
|
+
return 0;
|
|
992
|
+
} else if (b === undefined) {
|
|
993
|
+
return 1;
|
|
994
|
+
} else if (a === undefined) {
|
|
995
|
+
return -1;
|
|
996
|
+
} else if (a === b) {
|
|
997
|
+
continue;
|
|
998
|
+
} else {
|
|
999
|
+
return compareIdentifiers(a, b);
|
|
1000
|
+
}
|
|
1001
|
+
} while (++i);
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
// preminor will bump the version up to the next minor release, and immediately
|
|
1005
|
+
// down to pre-release. premajor and prepatch work the same way.
|
|
1006
|
+
inc(release, identifier, identifierBase) {
|
|
1007
|
+
if (release.startsWith('pre')) {
|
|
1008
|
+
if (!identifier && identifierBase === false) {
|
|
1009
|
+
throw new Error('invalid increment argument: identifier is empty');
|
|
1010
|
+
}
|
|
1011
|
+
// Avoid an invalid semver results
|
|
1012
|
+
if (identifier) {
|
|
1013
|
+
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
|
|
1014
|
+
if (!match || match[1] !== identifier) {
|
|
1015
|
+
throw new Error(`invalid identifier: ${identifier}`);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
switch (release) {
|
|
1020
|
+
case 'premajor':
|
|
1021
|
+
this.prerelease.length = 0;
|
|
1022
|
+
this.patch = 0;
|
|
1023
|
+
this.minor = 0;
|
|
1024
|
+
this.major++;
|
|
1025
|
+
this.inc('pre', identifier, identifierBase);
|
|
1026
|
+
break;
|
|
1027
|
+
case 'preminor':
|
|
1028
|
+
this.prerelease.length = 0;
|
|
1029
|
+
this.patch = 0;
|
|
1030
|
+
this.minor++;
|
|
1031
|
+
this.inc('pre', identifier, identifierBase);
|
|
1032
|
+
break;
|
|
1033
|
+
case 'prepatch':
|
|
1034
|
+
// If this is already a prerelease, it will bump to the next version
|
|
1035
|
+
// drop any prereleases that might already exist, since they are not
|
|
1036
|
+
// relevant at this point.
|
|
1037
|
+
this.prerelease.length = 0;
|
|
1038
|
+
this.inc('patch', identifier, identifierBase);
|
|
1039
|
+
this.inc('pre', identifier, identifierBase);
|
|
1040
|
+
break;
|
|
1041
|
+
// If the input is a non-prerelease version, this acts the same as
|
|
1042
|
+
// prepatch.
|
|
1043
|
+
case 'prerelease':
|
|
1044
|
+
if (this.prerelease.length === 0) {
|
|
1045
|
+
this.inc('patch', identifier, identifierBase);
|
|
1046
|
+
}
|
|
1047
|
+
this.inc('pre', identifier, identifierBase);
|
|
1048
|
+
break;
|
|
1049
|
+
case 'release':
|
|
1050
|
+
if (this.prerelease.length === 0) {
|
|
1051
|
+
throw new Error(`version ${this.raw} is not a prerelease`);
|
|
1052
|
+
}
|
|
1053
|
+
this.prerelease.length = 0;
|
|
1054
|
+
break;
|
|
1055
|
+
case 'major':
|
|
1056
|
+
// If this is a pre-major version, bump up to the same major version.
|
|
1057
|
+
// Otherwise increment major.
|
|
1058
|
+
// 1.0.0-5 bumps to 1.0.0
|
|
1059
|
+
// 1.1.0 bumps to 2.0.0
|
|
1060
|
+
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
|
|
1061
|
+
this.major++;
|
|
1062
|
+
}
|
|
1063
|
+
this.minor = 0;
|
|
1064
|
+
this.patch = 0;
|
|
1065
|
+
this.prerelease = [];
|
|
1066
|
+
break;
|
|
1067
|
+
case 'minor':
|
|
1068
|
+
// If this is a pre-minor version, bump up to the same minor version.
|
|
1069
|
+
// Otherwise increment minor.
|
|
1070
|
+
// 1.2.0-5 bumps to 1.2.0
|
|
1071
|
+
// 1.2.1 bumps to 1.3.0
|
|
1072
|
+
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
1073
|
+
this.minor++;
|
|
1074
|
+
}
|
|
1075
|
+
this.patch = 0;
|
|
1076
|
+
this.prerelease = [];
|
|
1077
|
+
break;
|
|
1078
|
+
case 'patch':
|
|
1079
|
+
// If this is not a pre-release version, it will increment the patch.
|
|
1080
|
+
// If it is a pre-release it will bump up to the same patch version.
|
|
1081
|
+
// 1.2.0-5 patches to 1.2.0
|
|
1082
|
+
// 1.2.0 patches to 1.2.1
|
|
1083
|
+
if (this.prerelease.length === 0) {
|
|
1084
|
+
this.patch++;
|
|
1085
|
+
}
|
|
1086
|
+
this.prerelease = [];
|
|
1087
|
+
break;
|
|
1088
|
+
// This probably shouldn't be used publicly.
|
|
1089
|
+
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
|
1090
|
+
case 'pre':
|
|
1091
|
+
{
|
|
1092
|
+
const base = Number(identifierBase) ? 1 : 0;
|
|
1093
|
+
if (this.prerelease.length === 0) {
|
|
1094
|
+
this.prerelease = [base];
|
|
1095
|
+
} else {
|
|
1096
|
+
let i = this.prerelease.length;
|
|
1097
|
+
while (--i >= 0) {
|
|
1098
|
+
if (typeof this.prerelease[i] === 'number') {
|
|
1099
|
+
this.prerelease[i]++;
|
|
1100
|
+
i = -2;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
if (i === -1) {
|
|
1104
|
+
// didn't increment anything
|
|
1105
|
+
if (identifier === this.prerelease.join('.') && identifierBase === false) {
|
|
1106
|
+
throw new Error('invalid increment argument: identifier already exists');
|
|
1107
|
+
}
|
|
1108
|
+
this.prerelease.push(base);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
if (identifier) {
|
|
1112
|
+
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
|
1113
|
+
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
|
1114
|
+
let prerelease = [identifier, base];
|
|
1115
|
+
if (identifierBase === false) {
|
|
1116
|
+
prerelease = [identifier];
|
|
1117
|
+
}
|
|
1118
|
+
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
|
|
1119
|
+
if (isNaN(this.prerelease[1])) {
|
|
1120
|
+
this.prerelease = prerelease;
|
|
1121
|
+
}
|
|
1122
|
+
} else {
|
|
1123
|
+
this.prerelease = prerelease;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
break;
|
|
1127
|
+
}
|
|
1128
|
+
default:
|
|
1129
|
+
throw new Error(`invalid increment argument: ${release}`);
|
|
1130
|
+
}
|
|
1131
|
+
this.raw = this.format();
|
|
1132
|
+
if (this.build.length) {
|
|
1133
|
+
this.raw += `+${this.build.join('.')}`;
|
|
1134
|
+
}
|
|
1135
|
+
return this;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
semver$1 = SemVer;
|
|
1139
|
+
return semver$1;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
var parse_1;
|
|
1143
|
+
var hasRequiredParse;
|
|
1144
|
+
|
|
1145
|
+
function requireParse () {
|
|
1146
|
+
if (hasRequiredParse) return parse_1;
|
|
1147
|
+
hasRequiredParse = 1;
|
|
1148
|
+
|
|
1149
|
+
const SemVer = requireSemver$1();
|
|
1150
|
+
const parse = (version, options, throwErrors = false) => {
|
|
1151
|
+
if (version instanceof SemVer) {
|
|
1152
|
+
return version;
|
|
1153
|
+
}
|
|
1154
|
+
try {
|
|
1155
|
+
return new SemVer(version, options);
|
|
1156
|
+
} catch (er) {
|
|
1157
|
+
if (!throwErrors) {
|
|
1158
|
+
return null;
|
|
1159
|
+
}
|
|
1160
|
+
throw er;
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
parse_1 = parse;
|
|
1164
|
+
return parse_1;
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
var valid_1;
|
|
1168
|
+
var hasRequiredValid$1;
|
|
1169
|
+
|
|
1170
|
+
function requireValid$1 () {
|
|
1171
|
+
if (hasRequiredValid$1) return valid_1;
|
|
1172
|
+
hasRequiredValid$1 = 1;
|
|
1173
|
+
|
|
1174
|
+
const parse = requireParse();
|
|
1175
|
+
const valid = (version, options) => {
|
|
1176
|
+
const v = parse(version, options);
|
|
1177
|
+
return v ? v.version : null;
|
|
1178
|
+
};
|
|
1179
|
+
valid_1 = valid;
|
|
1180
|
+
return valid_1;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
var clean_1;
|
|
1184
|
+
var hasRequiredClean;
|
|
1185
|
+
|
|
1186
|
+
function requireClean () {
|
|
1187
|
+
if (hasRequiredClean) return clean_1;
|
|
1188
|
+
hasRequiredClean = 1;
|
|
1189
|
+
|
|
1190
|
+
const parse = requireParse();
|
|
1191
|
+
const clean = (version, options) => {
|
|
1192
|
+
const s = parse(version.trim().replace(/^[=v]+/, ''), options);
|
|
1193
|
+
return s ? s.version : null;
|
|
1194
|
+
};
|
|
1195
|
+
clean_1 = clean;
|
|
1196
|
+
return clean_1;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
var inc_1;
|
|
1200
|
+
var hasRequiredInc;
|
|
1201
|
+
|
|
1202
|
+
function requireInc () {
|
|
1203
|
+
if (hasRequiredInc) return inc_1;
|
|
1204
|
+
hasRequiredInc = 1;
|
|
1205
|
+
|
|
1206
|
+
const SemVer = requireSemver$1();
|
|
1207
|
+
const inc = (version, release, options, identifier, identifierBase) => {
|
|
1208
|
+
if (typeof options === 'string') {
|
|
1209
|
+
identifierBase = identifier;
|
|
1210
|
+
identifier = options;
|
|
1211
|
+
options = undefined;
|
|
1212
|
+
}
|
|
1213
|
+
try {
|
|
1214
|
+
return new SemVer(version instanceof SemVer ? version.version : version, options).inc(release, identifier, identifierBase).version;
|
|
1215
|
+
} catch (er) {
|
|
1216
|
+
return null;
|
|
1217
|
+
}
|
|
1218
|
+
};
|
|
1219
|
+
inc_1 = inc;
|
|
1220
|
+
return inc_1;
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
var diff_1;
|
|
1224
|
+
var hasRequiredDiff;
|
|
1225
|
+
|
|
1226
|
+
function requireDiff () {
|
|
1227
|
+
if (hasRequiredDiff) return diff_1;
|
|
1228
|
+
hasRequiredDiff = 1;
|
|
1229
|
+
|
|
1230
|
+
const parse = requireParse();
|
|
1231
|
+
const diff = (version1, version2) => {
|
|
1232
|
+
const v1 = parse(version1, null, true);
|
|
1233
|
+
const v2 = parse(version2, null, true);
|
|
1234
|
+
const comparison = v1.compare(v2);
|
|
1235
|
+
if (comparison === 0) {
|
|
1236
|
+
return null;
|
|
1237
|
+
}
|
|
1238
|
+
const v1Higher = comparison > 0;
|
|
1239
|
+
const highVersion = v1Higher ? v1 : v2;
|
|
1240
|
+
const lowVersion = v1Higher ? v2 : v1;
|
|
1241
|
+
const highHasPre = !!highVersion.prerelease.length;
|
|
1242
|
+
const lowHasPre = !!lowVersion.prerelease.length;
|
|
1243
|
+
if (lowHasPre && !highHasPre) {
|
|
1244
|
+
// Going from prerelease -> no prerelease requires some special casing
|
|
1245
|
+
|
|
1246
|
+
// If the low version has only a major, then it will always be a major
|
|
1247
|
+
// Some examples:
|
|
1248
|
+
// 1.0.0-1 -> 1.0.0
|
|
1249
|
+
// 1.0.0-1 -> 1.1.1
|
|
1250
|
+
// 1.0.0-1 -> 2.0.0
|
|
1251
|
+
if (!lowVersion.patch && !lowVersion.minor) {
|
|
1252
|
+
return 'major';
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
// If the main part has no difference
|
|
1256
|
+
if (lowVersion.compareMain(highVersion) === 0) {
|
|
1257
|
+
if (lowVersion.minor && !lowVersion.patch) {
|
|
1258
|
+
return 'minor';
|
|
1259
|
+
}
|
|
1260
|
+
return 'patch';
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
// add the `pre` prefix if we are going to a prerelease version
|
|
1265
|
+
const prefix = highHasPre ? 'pre' : '';
|
|
1266
|
+
if (v1.major !== v2.major) {
|
|
1267
|
+
return prefix + 'major';
|
|
1268
|
+
}
|
|
1269
|
+
if (v1.minor !== v2.minor) {
|
|
1270
|
+
return prefix + 'minor';
|
|
1271
|
+
}
|
|
1272
|
+
if (v1.patch !== v2.patch) {
|
|
1273
|
+
return prefix + 'patch';
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
// high and low are preleases
|
|
1277
|
+
return 'prerelease';
|
|
1278
|
+
};
|
|
1279
|
+
diff_1 = diff;
|
|
1280
|
+
return diff_1;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
var major_1;
|
|
1284
|
+
var hasRequiredMajor;
|
|
1285
|
+
|
|
1286
|
+
function requireMajor () {
|
|
1287
|
+
if (hasRequiredMajor) return major_1;
|
|
1288
|
+
hasRequiredMajor = 1;
|
|
1289
|
+
|
|
1290
|
+
const SemVer = requireSemver$1();
|
|
1291
|
+
const major = (a, loose) => new SemVer(a, loose).major;
|
|
1292
|
+
major_1 = major;
|
|
1293
|
+
return major_1;
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
var minor_1;
|
|
1297
|
+
var hasRequiredMinor;
|
|
1298
|
+
|
|
1299
|
+
function requireMinor () {
|
|
1300
|
+
if (hasRequiredMinor) return minor_1;
|
|
1301
|
+
hasRequiredMinor = 1;
|
|
1302
|
+
|
|
1303
|
+
const SemVer = requireSemver$1();
|
|
1304
|
+
const minor = (a, loose) => new SemVer(a, loose).minor;
|
|
1305
|
+
minor_1 = minor;
|
|
1306
|
+
return minor_1;
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
var patch_1;
|
|
1310
|
+
var hasRequiredPatch;
|
|
1311
|
+
|
|
1312
|
+
function requirePatch () {
|
|
1313
|
+
if (hasRequiredPatch) return patch_1;
|
|
1314
|
+
hasRequiredPatch = 1;
|
|
1315
|
+
|
|
1316
|
+
const SemVer = requireSemver$1();
|
|
1317
|
+
const patch = (a, loose) => new SemVer(a, loose).patch;
|
|
1318
|
+
patch_1 = patch;
|
|
1319
|
+
return patch_1;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
var prerelease_1;
|
|
1323
|
+
var hasRequiredPrerelease;
|
|
1324
|
+
|
|
1325
|
+
function requirePrerelease () {
|
|
1326
|
+
if (hasRequiredPrerelease) return prerelease_1;
|
|
1327
|
+
hasRequiredPrerelease = 1;
|
|
1328
|
+
|
|
1329
|
+
const parse = requireParse();
|
|
1330
|
+
const prerelease = (version, options) => {
|
|
1331
|
+
const parsed = parse(version, options);
|
|
1332
|
+
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
1333
|
+
};
|
|
1334
|
+
prerelease_1 = prerelease;
|
|
1335
|
+
return prerelease_1;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
var compare_1;
|
|
1339
|
+
var hasRequiredCompare;
|
|
1340
|
+
|
|
1341
|
+
function requireCompare () {
|
|
1342
|
+
if (hasRequiredCompare) return compare_1;
|
|
1343
|
+
hasRequiredCompare = 1;
|
|
1344
|
+
|
|
1345
|
+
const SemVer = requireSemver$1();
|
|
1346
|
+
const compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
1347
|
+
compare_1 = compare;
|
|
1348
|
+
return compare_1;
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
var rcompare_1;
|
|
1352
|
+
var hasRequiredRcompare;
|
|
1353
|
+
|
|
1354
|
+
function requireRcompare () {
|
|
1355
|
+
if (hasRequiredRcompare) return rcompare_1;
|
|
1356
|
+
hasRequiredRcompare = 1;
|
|
1357
|
+
|
|
1358
|
+
const compare = requireCompare();
|
|
1359
|
+
const rcompare = (a, b, loose) => compare(b, a, loose);
|
|
1360
|
+
rcompare_1 = rcompare;
|
|
1361
|
+
return rcompare_1;
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
var compareLoose_1;
|
|
1365
|
+
var hasRequiredCompareLoose;
|
|
1366
|
+
|
|
1367
|
+
function requireCompareLoose () {
|
|
1368
|
+
if (hasRequiredCompareLoose) return compareLoose_1;
|
|
1369
|
+
hasRequiredCompareLoose = 1;
|
|
1370
|
+
|
|
1371
|
+
const compare = requireCompare();
|
|
1372
|
+
const compareLoose = (a, b) => compare(a, b, true);
|
|
1373
|
+
compareLoose_1 = compareLoose;
|
|
1374
|
+
return compareLoose_1;
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
var compareBuild_1;
|
|
1378
|
+
var hasRequiredCompareBuild;
|
|
1379
|
+
|
|
1380
|
+
function requireCompareBuild () {
|
|
1381
|
+
if (hasRequiredCompareBuild) return compareBuild_1;
|
|
1382
|
+
hasRequiredCompareBuild = 1;
|
|
1383
|
+
|
|
1384
|
+
const SemVer = requireSemver$1();
|
|
1385
|
+
const compareBuild = (a, b, loose) => {
|
|
1386
|
+
const versionA = new SemVer(a, loose);
|
|
1387
|
+
const versionB = new SemVer(b, loose);
|
|
1388
|
+
return versionA.compare(versionB) || versionA.compareBuild(versionB);
|
|
1389
|
+
};
|
|
1390
|
+
compareBuild_1 = compareBuild;
|
|
1391
|
+
return compareBuild_1;
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
var sort_1;
|
|
1395
|
+
var hasRequiredSort;
|
|
1396
|
+
|
|
1397
|
+
function requireSort () {
|
|
1398
|
+
if (hasRequiredSort) return sort_1;
|
|
1399
|
+
hasRequiredSort = 1;
|
|
1400
|
+
|
|
1401
|
+
const compareBuild = requireCompareBuild();
|
|
1402
|
+
const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
|
|
1403
|
+
sort_1 = sort;
|
|
1404
|
+
return sort_1;
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
var rsort_1;
|
|
1408
|
+
var hasRequiredRsort;
|
|
1409
|
+
|
|
1410
|
+
function requireRsort () {
|
|
1411
|
+
if (hasRequiredRsort) return rsort_1;
|
|
1412
|
+
hasRequiredRsort = 1;
|
|
1413
|
+
|
|
1414
|
+
const compareBuild = requireCompareBuild();
|
|
1415
|
+
const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
|
|
1416
|
+
rsort_1 = rsort;
|
|
1417
|
+
return rsort_1;
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
var gt_1;
|
|
1421
|
+
var hasRequiredGt;
|
|
1422
|
+
|
|
1423
|
+
function requireGt () {
|
|
1424
|
+
if (hasRequiredGt) return gt_1;
|
|
1425
|
+
hasRequiredGt = 1;
|
|
1426
|
+
|
|
1427
|
+
const compare = requireCompare();
|
|
1428
|
+
const gt = (a, b, loose) => compare(a, b, loose) > 0;
|
|
1429
|
+
gt_1 = gt;
|
|
1430
|
+
return gt_1;
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
var lt_1;
|
|
1434
|
+
var hasRequiredLt;
|
|
1435
|
+
|
|
1436
|
+
function requireLt () {
|
|
1437
|
+
if (hasRequiredLt) return lt_1;
|
|
1438
|
+
hasRequiredLt = 1;
|
|
1439
|
+
|
|
1440
|
+
const compare = requireCompare();
|
|
1441
|
+
const lt = (a, b, loose) => compare(a, b, loose) < 0;
|
|
1442
|
+
lt_1 = lt;
|
|
1443
|
+
return lt_1;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
var eq_1;
|
|
1447
|
+
var hasRequiredEq;
|
|
1448
|
+
|
|
1449
|
+
function requireEq () {
|
|
1450
|
+
if (hasRequiredEq) return eq_1;
|
|
1451
|
+
hasRequiredEq = 1;
|
|
1452
|
+
|
|
1453
|
+
const compare = requireCompare();
|
|
1454
|
+
const eq = (a, b, loose) => compare(a, b, loose) === 0;
|
|
1455
|
+
eq_1 = eq;
|
|
1456
|
+
return eq_1;
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
var neq_1;
|
|
1460
|
+
var hasRequiredNeq;
|
|
1461
|
+
|
|
1462
|
+
function requireNeq () {
|
|
1463
|
+
if (hasRequiredNeq) return neq_1;
|
|
1464
|
+
hasRequiredNeq = 1;
|
|
1465
|
+
|
|
1466
|
+
const compare = requireCompare();
|
|
1467
|
+
const neq = (a, b, loose) => compare(a, b, loose) !== 0;
|
|
1468
|
+
neq_1 = neq;
|
|
1469
|
+
return neq_1;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
var gte_1;
|
|
1473
|
+
var hasRequiredGte;
|
|
1474
|
+
|
|
1475
|
+
function requireGte () {
|
|
1476
|
+
if (hasRequiredGte) return gte_1;
|
|
1477
|
+
hasRequiredGte = 1;
|
|
1478
|
+
|
|
1479
|
+
const compare = requireCompare();
|
|
1480
|
+
const gte = (a, b, loose) => compare(a, b, loose) >= 0;
|
|
1481
|
+
gte_1 = gte;
|
|
1482
|
+
return gte_1;
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
var lte_1;
|
|
1486
|
+
var hasRequiredLte;
|
|
1487
|
+
|
|
1488
|
+
function requireLte () {
|
|
1489
|
+
if (hasRequiredLte) return lte_1;
|
|
1490
|
+
hasRequiredLte = 1;
|
|
1491
|
+
|
|
1492
|
+
const compare = requireCompare();
|
|
1493
|
+
const lte = (a, b, loose) => compare(a, b, loose) <= 0;
|
|
1494
|
+
lte_1 = lte;
|
|
1495
|
+
return lte_1;
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
var cmp_1;
|
|
1499
|
+
var hasRequiredCmp;
|
|
1500
|
+
|
|
1501
|
+
function requireCmp () {
|
|
1502
|
+
if (hasRequiredCmp) return cmp_1;
|
|
1503
|
+
hasRequiredCmp = 1;
|
|
1504
|
+
|
|
1505
|
+
const eq = requireEq();
|
|
1506
|
+
const neq = requireNeq();
|
|
1507
|
+
const gt = requireGt();
|
|
1508
|
+
const gte = requireGte();
|
|
1509
|
+
const lt = requireLt();
|
|
1510
|
+
const lte = requireLte();
|
|
1511
|
+
const cmp = (a, op, b, loose) => {
|
|
1512
|
+
switch (op) {
|
|
1513
|
+
case '===':
|
|
1514
|
+
if (typeof a === 'object') {
|
|
1515
|
+
a = a.version;
|
|
1516
|
+
}
|
|
1517
|
+
if (typeof b === 'object') {
|
|
1518
|
+
b = b.version;
|
|
1519
|
+
}
|
|
1520
|
+
return a === b;
|
|
1521
|
+
case '!==':
|
|
1522
|
+
if (typeof a === 'object') {
|
|
1523
|
+
a = a.version;
|
|
1524
|
+
}
|
|
1525
|
+
if (typeof b === 'object') {
|
|
1526
|
+
b = b.version;
|
|
1527
|
+
}
|
|
1528
|
+
return a !== b;
|
|
1529
|
+
case '':
|
|
1530
|
+
case '=':
|
|
1531
|
+
case '==':
|
|
1532
|
+
return eq(a, b, loose);
|
|
1533
|
+
case '!=':
|
|
1534
|
+
return neq(a, b, loose);
|
|
1535
|
+
case '>':
|
|
1536
|
+
return gt(a, b, loose);
|
|
1537
|
+
case '>=':
|
|
1538
|
+
return gte(a, b, loose);
|
|
1539
|
+
case '<':
|
|
1540
|
+
return lt(a, b, loose);
|
|
1541
|
+
case '<=':
|
|
1542
|
+
return lte(a, b, loose);
|
|
1543
|
+
default:
|
|
1544
|
+
throw new TypeError(`Invalid operator: ${op}`);
|
|
1545
|
+
}
|
|
1546
|
+
};
|
|
1547
|
+
cmp_1 = cmp;
|
|
1548
|
+
return cmp_1;
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
var coerce_1;
|
|
1552
|
+
var hasRequiredCoerce;
|
|
1553
|
+
|
|
1554
|
+
function requireCoerce () {
|
|
1555
|
+
if (hasRequiredCoerce) return coerce_1;
|
|
1556
|
+
hasRequiredCoerce = 1;
|
|
1557
|
+
|
|
1558
|
+
const SemVer = requireSemver$1();
|
|
1559
|
+
const parse = requireParse();
|
|
1560
|
+
const {
|
|
1561
|
+
safeRe: re,
|
|
1562
|
+
t
|
|
1563
|
+
} = requireRe();
|
|
1564
|
+
const coerce = (version, options) => {
|
|
1565
|
+
if (version instanceof SemVer) {
|
|
1566
|
+
return version;
|
|
1567
|
+
}
|
|
1568
|
+
if (typeof version === 'number') {
|
|
1569
|
+
version = String(version);
|
|
1570
|
+
}
|
|
1571
|
+
if (typeof version !== 'string') {
|
|
1572
|
+
return null;
|
|
1573
|
+
}
|
|
1574
|
+
options = options || {};
|
|
1575
|
+
let match = null;
|
|
1576
|
+
if (!options.rtl) {
|
|
1577
|
+
match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
|
|
1578
|
+
} else {
|
|
1579
|
+
// Find the right-most coercible string that does not share
|
|
1580
|
+
// a terminus with a more left-ward coercible string.
|
|
1581
|
+
// Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
|
|
1582
|
+
// With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4'
|
|
1583
|
+
//
|
|
1584
|
+
// Walk through the string checking with a /g regexp
|
|
1585
|
+
// Manually set the index so as to pick up overlapping matches.
|
|
1586
|
+
// Stop when we get a match that ends at the string end, since no
|
|
1587
|
+
// coercible string can be more right-ward without the same terminus.
|
|
1588
|
+
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
|
|
1589
|
+
let next;
|
|
1590
|
+
while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
|
|
1591
|
+
if (!match || next.index + next[0].length !== match.index + match[0].length) {
|
|
1592
|
+
match = next;
|
|
1593
|
+
}
|
|
1594
|
+
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
|
|
1595
|
+
}
|
|
1596
|
+
// leave it in a clean state
|
|
1597
|
+
coerceRtlRegex.lastIndex = -1;
|
|
1598
|
+
}
|
|
1599
|
+
if (match === null) {
|
|
1600
|
+
return null;
|
|
1601
|
+
}
|
|
1602
|
+
const major = match[2];
|
|
1603
|
+
const minor = match[3] || '0';
|
|
1604
|
+
const patch = match[4] || '0';
|
|
1605
|
+
const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : '';
|
|
1606
|
+
const build = options.includePrerelease && match[6] ? `+${match[6]}` : '';
|
|
1607
|
+
return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
|
|
1608
|
+
};
|
|
1609
|
+
coerce_1 = coerce;
|
|
1610
|
+
return coerce_1;
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
var lrucache;
|
|
1614
|
+
var hasRequiredLrucache;
|
|
1615
|
+
|
|
1616
|
+
function requireLrucache () {
|
|
1617
|
+
if (hasRequiredLrucache) return lrucache;
|
|
1618
|
+
hasRequiredLrucache = 1;
|
|
1619
|
+
|
|
1620
|
+
class LRUCache {
|
|
1621
|
+
constructor() {
|
|
1622
|
+
this.max = 1000;
|
|
1623
|
+
this.map = new Map();
|
|
1624
|
+
}
|
|
1625
|
+
get(key) {
|
|
1626
|
+
const value = this.map.get(key);
|
|
1627
|
+
if (value === undefined) {
|
|
1628
|
+
return undefined;
|
|
1629
|
+
} else {
|
|
1630
|
+
// Remove the key from the map and add it to the end
|
|
1631
|
+
this.map.delete(key);
|
|
1632
|
+
this.map.set(key, value);
|
|
1633
|
+
return value;
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
delete(key) {
|
|
1637
|
+
return this.map.delete(key);
|
|
1638
|
+
}
|
|
1639
|
+
set(key, value) {
|
|
1640
|
+
const deleted = this.delete(key);
|
|
1641
|
+
if (!deleted && value !== undefined) {
|
|
1642
|
+
// If cache is full, delete the least recently used item
|
|
1643
|
+
if (this.map.size >= this.max) {
|
|
1644
|
+
const firstKey = this.map.keys().next().value;
|
|
1645
|
+
this.delete(firstKey);
|
|
1646
|
+
}
|
|
1647
|
+
this.map.set(key, value);
|
|
1648
|
+
}
|
|
1649
|
+
return this;
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
lrucache = LRUCache;
|
|
1653
|
+
return lrucache;
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
var range;
|
|
1657
|
+
var hasRequiredRange;
|
|
1658
|
+
|
|
1659
|
+
function requireRange () {
|
|
1660
|
+
if (hasRequiredRange) return range;
|
|
1661
|
+
hasRequiredRange = 1;
|
|
1662
|
+
|
|
1663
|
+
const SPACE_CHARACTERS = /\s+/g;
|
|
1664
|
+
|
|
1665
|
+
// hoisted class for cyclic dependency
|
|
1666
|
+
class Range {
|
|
1667
|
+
constructor(range, options) {
|
|
1668
|
+
options = parseOptions(options);
|
|
1669
|
+
if (range instanceof Range) {
|
|
1670
|
+
if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
|
|
1671
|
+
return range;
|
|
1672
|
+
} else {
|
|
1673
|
+
return new Range(range.raw, options);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
if (range instanceof Comparator) {
|
|
1677
|
+
// just put it in the set and return
|
|
1678
|
+
this.raw = range.value;
|
|
1679
|
+
this.set = [[range]];
|
|
1680
|
+
this.formatted = undefined;
|
|
1681
|
+
return this;
|
|
1682
|
+
}
|
|
1683
|
+
this.options = options;
|
|
1684
|
+
this.loose = !!options.loose;
|
|
1685
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
1686
|
+
|
|
1687
|
+
// First reduce all whitespace as much as possible so we do not have to rely
|
|
1688
|
+
// on potentially slow regexes like \s*. This is then stored and used for
|
|
1689
|
+
// future error messages as well.
|
|
1690
|
+
this.raw = range.trim().replace(SPACE_CHARACTERS, ' ');
|
|
1691
|
+
|
|
1692
|
+
// First, split on ||
|
|
1693
|
+
this.set = this.raw.split('||')
|
|
1694
|
+
// map the range to a 2d array of comparators
|
|
1695
|
+
.map(r => this.parseRange(r.trim()))
|
|
1696
|
+
// throw out any comparator lists that are empty
|
|
1697
|
+
// this generally means that it was not a valid range, which is allowed
|
|
1698
|
+
// in loose mode, but will still throw if the WHOLE range is invalid.
|
|
1699
|
+
.filter(c => c.length);
|
|
1700
|
+
if (!this.set.length) {
|
|
1701
|
+
throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
// if we have any that are not the null set, throw out null sets.
|
|
1705
|
+
if (this.set.length > 1) {
|
|
1706
|
+
// keep the first one, in case they're all null sets
|
|
1707
|
+
const first = this.set[0];
|
|
1708
|
+
this.set = this.set.filter(c => !isNullSet(c[0]));
|
|
1709
|
+
if (this.set.length === 0) {
|
|
1710
|
+
this.set = [first];
|
|
1711
|
+
} else if (this.set.length > 1) {
|
|
1712
|
+
// if we have any that are *, then the range is just *
|
|
1713
|
+
for (const c of this.set) {
|
|
1714
|
+
if (c.length === 1 && isAny(c[0])) {
|
|
1715
|
+
this.set = [c];
|
|
1716
|
+
break;
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
this.formatted = undefined;
|
|
1722
|
+
}
|
|
1723
|
+
get range() {
|
|
1724
|
+
if (this.formatted === undefined) {
|
|
1725
|
+
this.formatted = '';
|
|
1726
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
1727
|
+
if (i > 0) {
|
|
1728
|
+
this.formatted += '||';
|
|
1729
|
+
}
|
|
1730
|
+
const comps = this.set[i];
|
|
1731
|
+
for (let k = 0; k < comps.length; k++) {
|
|
1732
|
+
if (k > 0) {
|
|
1733
|
+
this.formatted += ' ';
|
|
1734
|
+
}
|
|
1735
|
+
this.formatted += comps[k].toString().trim();
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
return this.formatted;
|
|
1740
|
+
}
|
|
1741
|
+
format() {
|
|
1742
|
+
return this.range;
|
|
1743
|
+
}
|
|
1744
|
+
toString() {
|
|
1745
|
+
return this.range;
|
|
1746
|
+
}
|
|
1747
|
+
parseRange(range) {
|
|
1748
|
+
// memoize range parsing for performance.
|
|
1749
|
+
// this is a very hot path, and fully deterministic.
|
|
1750
|
+
const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
|
|
1751
|
+
const memoKey = memoOpts + ':' + range;
|
|
1752
|
+
const cached = cache.get(memoKey);
|
|
1753
|
+
if (cached) {
|
|
1754
|
+
return cached;
|
|
1755
|
+
}
|
|
1756
|
+
const loose = this.options.loose;
|
|
1757
|
+
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
|
1758
|
+
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
1759
|
+
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
1760
|
+
debug('hyphen replace', range);
|
|
1761
|
+
|
|
1762
|
+
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
|
1763
|
+
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
1764
|
+
debug('comparator trim', range);
|
|
1765
|
+
|
|
1766
|
+
// `~ 1.2.3` => `~1.2.3`
|
|
1767
|
+
range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
1768
|
+
debug('tilde trim', range);
|
|
1769
|
+
|
|
1770
|
+
// `^ 1.2.3` => `^1.2.3`
|
|
1771
|
+
range = range.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
1772
|
+
debug('caret trim', range);
|
|
1773
|
+
|
|
1774
|
+
// At this point, the range is completely trimmed and
|
|
1775
|
+
// ready to be split into comparators.
|
|
1776
|
+
|
|
1777
|
+
let rangeList = range.split(' ').map(comp => parseComparator(comp, this.options)).join(' ').split(/\s+/)
|
|
1778
|
+
// >=0.0.0 is equivalent to *
|
|
1779
|
+
.map(comp => replaceGTE0(comp, this.options));
|
|
1780
|
+
if (loose) {
|
|
1781
|
+
// in loose mode, throw out any that are not valid comparators
|
|
1782
|
+
rangeList = rangeList.filter(comp => {
|
|
1783
|
+
debug('loose invalid filter', comp, this.options);
|
|
1784
|
+
return !!comp.match(re[t.COMPARATORLOOSE]);
|
|
1785
|
+
});
|
|
1786
|
+
}
|
|
1787
|
+
debug('range list', rangeList);
|
|
1788
|
+
|
|
1789
|
+
// if any comparators are the null set, then replace with JUST null set
|
|
1790
|
+
// if more than one comparator, remove any * comparators
|
|
1791
|
+
// also, don't include the same comparator more than once
|
|
1792
|
+
const rangeMap = new Map();
|
|
1793
|
+
const comparators = rangeList.map(comp => new Comparator(comp, this.options));
|
|
1794
|
+
for (const comp of comparators) {
|
|
1795
|
+
if (isNullSet(comp)) {
|
|
1796
|
+
return [comp];
|
|
1797
|
+
}
|
|
1798
|
+
rangeMap.set(comp.value, comp);
|
|
1799
|
+
}
|
|
1800
|
+
if (rangeMap.size > 1 && rangeMap.has('')) {
|
|
1801
|
+
rangeMap.delete('');
|
|
1802
|
+
}
|
|
1803
|
+
const result = [...rangeMap.values()];
|
|
1804
|
+
cache.set(memoKey, result);
|
|
1805
|
+
return result;
|
|
1806
|
+
}
|
|
1807
|
+
intersects(range, options) {
|
|
1808
|
+
if (!(range instanceof Range)) {
|
|
1809
|
+
throw new TypeError('a Range is required');
|
|
1810
|
+
}
|
|
1811
|
+
return this.set.some(thisComparators => {
|
|
1812
|
+
return isSatisfiable(thisComparators, options) && range.set.some(rangeComparators => {
|
|
1813
|
+
return isSatisfiable(rangeComparators, options) && thisComparators.every(thisComparator => {
|
|
1814
|
+
return rangeComparators.every(rangeComparator => {
|
|
1815
|
+
return thisComparator.intersects(rangeComparator, options);
|
|
1816
|
+
});
|
|
1817
|
+
});
|
|
1818
|
+
});
|
|
1819
|
+
});
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
// if ANY of the sets match ALL of its comparators, then pass
|
|
1823
|
+
test(version) {
|
|
1824
|
+
if (!version) {
|
|
1825
|
+
return false;
|
|
1826
|
+
}
|
|
1827
|
+
if (typeof version === 'string') {
|
|
1828
|
+
try {
|
|
1829
|
+
version = new SemVer(version, this.options);
|
|
1830
|
+
} catch (er) {
|
|
1831
|
+
return false;
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
1835
|
+
if (testSet(this.set[i], version, this.options)) {
|
|
1836
|
+
return true;
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
return false;
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
range = Range;
|
|
1843
|
+
const LRU = requireLrucache();
|
|
1844
|
+
const cache = new LRU();
|
|
1845
|
+
const parseOptions = requireParseOptions();
|
|
1846
|
+
const Comparator = requireComparator();
|
|
1847
|
+
const debug = requireDebug();
|
|
1848
|
+
const SemVer = requireSemver$1();
|
|
1849
|
+
const {
|
|
1850
|
+
safeRe: re,
|
|
1851
|
+
t,
|
|
1852
|
+
comparatorTrimReplace,
|
|
1853
|
+
tildeTrimReplace,
|
|
1854
|
+
caretTrimReplace
|
|
1855
|
+
} = requireRe();
|
|
1856
|
+
const {
|
|
1857
|
+
FLAG_INCLUDE_PRERELEASE,
|
|
1858
|
+
FLAG_LOOSE
|
|
1859
|
+
} = requireConstants();
|
|
1860
|
+
const isNullSet = c => c.value === '<0.0.0-0';
|
|
1861
|
+
const isAny = c => c.value === '';
|
|
1862
|
+
|
|
1863
|
+
// take a set of comparators and determine whether there
|
|
1864
|
+
// exists a version which can satisfy it
|
|
1865
|
+
const isSatisfiable = (comparators, options) => {
|
|
1866
|
+
let result = true;
|
|
1867
|
+
const remainingComparators = comparators.slice();
|
|
1868
|
+
let testComparator = remainingComparators.pop();
|
|
1869
|
+
while (result && remainingComparators.length) {
|
|
1870
|
+
result = remainingComparators.every(otherComparator => {
|
|
1871
|
+
return testComparator.intersects(otherComparator, options);
|
|
1872
|
+
});
|
|
1873
|
+
testComparator = remainingComparators.pop();
|
|
1874
|
+
}
|
|
1875
|
+
return result;
|
|
1876
|
+
};
|
|
1877
|
+
|
|
1878
|
+
// comprised of xranges, tildes, stars, and gtlt's at this point.
|
|
1879
|
+
// already replaced the hyphen ranges
|
|
1880
|
+
// turn into a set of JUST comparators.
|
|
1881
|
+
const parseComparator = (comp, options) => {
|
|
1882
|
+
debug('comp', comp, options);
|
|
1883
|
+
comp = replaceCarets(comp, options);
|
|
1884
|
+
debug('caret', comp);
|
|
1885
|
+
comp = replaceTildes(comp, options);
|
|
1886
|
+
debug('tildes', comp);
|
|
1887
|
+
comp = replaceXRanges(comp, options);
|
|
1888
|
+
debug('xrange', comp);
|
|
1889
|
+
comp = replaceStars(comp, options);
|
|
1890
|
+
debug('stars', comp);
|
|
1891
|
+
return comp;
|
|
1892
|
+
};
|
|
1893
|
+
const isX = id => !id || id.toLowerCase() === 'x' || id === '*';
|
|
1894
|
+
|
|
1895
|
+
// ~, ~> --> * (any, kinda silly)
|
|
1896
|
+
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
|
|
1897
|
+
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
|
|
1898
|
+
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
|
|
1899
|
+
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
|
|
1900
|
+
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
|
|
1901
|
+
// ~0.0.1 --> >=0.0.1 <0.1.0-0
|
|
1902
|
+
const replaceTildes = (comp, options) => {
|
|
1903
|
+
return comp.trim().split(/\s+/).map(c => replaceTilde(c, options)).join(' ');
|
|
1904
|
+
};
|
|
1905
|
+
const replaceTilde = (comp, options) => {
|
|
1906
|
+
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
1907
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1908
|
+
debug('tilde', comp, _, M, m, p, pr);
|
|
1909
|
+
let ret;
|
|
1910
|
+
if (isX(M)) {
|
|
1911
|
+
ret = '';
|
|
1912
|
+
} else if (isX(m)) {
|
|
1913
|
+
ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
|
|
1914
|
+
} else if (isX(p)) {
|
|
1915
|
+
// ~1.2 == >=1.2.0 <1.3.0-0
|
|
1916
|
+
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
|
|
1917
|
+
} else if (pr) {
|
|
1918
|
+
debug('replaceTilde pr', pr);
|
|
1919
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
1920
|
+
} else {
|
|
1921
|
+
// ~1.2.3 == >=1.2.3 <1.3.0-0
|
|
1922
|
+
ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
1923
|
+
}
|
|
1924
|
+
debug('tilde return', ret);
|
|
1925
|
+
return ret;
|
|
1926
|
+
});
|
|
1927
|
+
};
|
|
1928
|
+
|
|
1929
|
+
// ^ --> * (any, kinda silly)
|
|
1930
|
+
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
|
|
1931
|
+
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
|
|
1932
|
+
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
|
|
1933
|
+
// ^1.2.3 --> >=1.2.3 <2.0.0-0
|
|
1934
|
+
// ^1.2.0 --> >=1.2.0 <2.0.0-0
|
|
1935
|
+
// ^0.0.1 --> >=0.0.1 <0.0.2-0
|
|
1936
|
+
// ^0.1.0 --> >=0.1.0 <0.2.0-0
|
|
1937
|
+
const replaceCarets = (comp, options) => {
|
|
1938
|
+
return comp.trim().split(/\s+/).map(c => replaceCaret(c, options)).join(' ');
|
|
1939
|
+
};
|
|
1940
|
+
const replaceCaret = (comp, options) => {
|
|
1941
|
+
debug('caret', comp, options);
|
|
1942
|
+
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
1943
|
+
const z = options.includePrerelease ? '-0' : '';
|
|
1944
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1945
|
+
debug('caret', comp, _, M, m, p, pr);
|
|
1946
|
+
let ret;
|
|
1947
|
+
if (isX(M)) {
|
|
1948
|
+
ret = '';
|
|
1949
|
+
} else if (isX(m)) {
|
|
1950
|
+
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
1951
|
+
} else if (isX(p)) {
|
|
1952
|
+
if (M === '0') {
|
|
1953
|
+
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
1954
|
+
} else {
|
|
1955
|
+
ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
|
|
1956
|
+
}
|
|
1957
|
+
} else if (pr) {
|
|
1958
|
+
debug('replaceCaret pr', pr);
|
|
1959
|
+
if (M === '0') {
|
|
1960
|
+
if (m === '0') {
|
|
1961
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
|
|
1962
|
+
} else {
|
|
1963
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
1964
|
+
}
|
|
1965
|
+
} else {
|
|
1966
|
+
ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
|
|
1967
|
+
}
|
|
1968
|
+
} else {
|
|
1969
|
+
debug('no pr');
|
|
1970
|
+
if (M === '0') {
|
|
1971
|
+
if (m === '0') {
|
|
1972
|
+
ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`;
|
|
1973
|
+
} else {
|
|
1974
|
+
ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`;
|
|
1975
|
+
}
|
|
1976
|
+
} else {
|
|
1977
|
+
ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
debug('caret return', ret);
|
|
1981
|
+
return ret;
|
|
1982
|
+
});
|
|
1983
|
+
};
|
|
1984
|
+
const replaceXRanges = (comp, options) => {
|
|
1985
|
+
debug('replaceXRanges', comp, options);
|
|
1986
|
+
return comp.split(/\s+/).map(c => replaceXRange(c, options)).join(' ');
|
|
1987
|
+
};
|
|
1988
|
+
const replaceXRange = (comp, options) => {
|
|
1989
|
+
comp = comp.trim();
|
|
1990
|
+
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
1991
|
+
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
1992
|
+
debug('xRange', comp, ret, gtlt, M, m, p, pr);
|
|
1993
|
+
const xM = isX(M);
|
|
1994
|
+
const xm = xM || isX(m);
|
|
1995
|
+
const xp = xm || isX(p);
|
|
1996
|
+
const anyX = xp;
|
|
1997
|
+
if (gtlt === '=' && anyX) {
|
|
1998
|
+
gtlt = '';
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
// if we're including prereleases in the match, then we need
|
|
2002
|
+
// to fix this to -0, the lowest possible prerelease value
|
|
2003
|
+
pr = options.includePrerelease ? '-0' : '';
|
|
2004
|
+
if (xM) {
|
|
2005
|
+
if (gtlt === '>' || gtlt === '<') {
|
|
2006
|
+
// nothing is allowed
|
|
2007
|
+
ret = '<0.0.0-0';
|
|
2008
|
+
} else {
|
|
2009
|
+
// nothing is forbidden
|
|
2010
|
+
ret = '*';
|
|
2011
|
+
}
|
|
2012
|
+
} else if (gtlt && anyX) {
|
|
2013
|
+
// we know patch is an x, because we have any x at all.
|
|
2014
|
+
// replace X with 0
|
|
2015
|
+
if (xm) {
|
|
2016
|
+
m = 0;
|
|
2017
|
+
}
|
|
2018
|
+
p = 0;
|
|
2019
|
+
if (gtlt === '>') {
|
|
2020
|
+
// >1 => >=2.0.0
|
|
2021
|
+
// >1.2 => >=1.3.0
|
|
2022
|
+
gtlt = '>=';
|
|
2023
|
+
if (xm) {
|
|
2024
|
+
M = +M + 1;
|
|
2025
|
+
m = 0;
|
|
2026
|
+
p = 0;
|
|
2027
|
+
} else {
|
|
2028
|
+
m = +m + 1;
|
|
2029
|
+
p = 0;
|
|
2030
|
+
}
|
|
2031
|
+
} else if (gtlt === '<=') {
|
|
2032
|
+
// <=0.7.x is actually <0.8.0, since any 0.7.x should
|
|
2033
|
+
// pass. Similarly, <=7.x is actually <8.0.0, etc.
|
|
2034
|
+
gtlt = '<';
|
|
2035
|
+
if (xm) {
|
|
2036
|
+
M = +M + 1;
|
|
2037
|
+
} else {
|
|
2038
|
+
m = +m + 1;
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
if (gtlt === '<') {
|
|
2042
|
+
pr = '-0';
|
|
2043
|
+
}
|
|
2044
|
+
ret = `${gtlt + M}.${m}.${p}${pr}`;
|
|
2045
|
+
} else if (xm) {
|
|
2046
|
+
ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
|
|
2047
|
+
} else if (xp) {
|
|
2048
|
+
ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
|
|
2049
|
+
}
|
|
2050
|
+
debug('xRange return', ret);
|
|
2051
|
+
return ret;
|
|
2052
|
+
});
|
|
2053
|
+
};
|
|
2054
|
+
|
|
2055
|
+
// Because * is AND-ed with everything else in the comparator,
|
|
2056
|
+
// and '' means "any version", just remove the *s entirely.
|
|
2057
|
+
const replaceStars = (comp, options) => {
|
|
2058
|
+
debug('replaceStars', comp, options);
|
|
2059
|
+
// Looseness is ignored here. star is always as loose as it gets!
|
|
2060
|
+
return comp.trim().replace(re[t.STAR], '');
|
|
2061
|
+
};
|
|
2062
|
+
const replaceGTE0 = (comp, options) => {
|
|
2063
|
+
debug('replaceGTE0', comp, options);
|
|
2064
|
+
return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '');
|
|
2065
|
+
};
|
|
2066
|
+
|
|
2067
|
+
// This function is passed to string.replace(re[t.HYPHENRANGE])
|
|
2068
|
+
// M, m, patch, prerelease, build
|
|
2069
|
+
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
|
2070
|
+
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
|
|
2071
|
+
// 1.2 - 3.4 => >=1.2.0 <3.5.0-0
|
|
2072
|
+
// TODO build?
|
|
2073
|
+
const hyphenReplace = incPr => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
|
|
2074
|
+
if (isX(fM)) {
|
|
2075
|
+
from = '';
|
|
2076
|
+
} else if (isX(fm)) {
|
|
2077
|
+
from = `>=${fM}.0.0${incPr ? '-0' : ''}`;
|
|
2078
|
+
} else if (isX(fp)) {
|
|
2079
|
+
from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`;
|
|
2080
|
+
} else if (fpr) {
|
|
2081
|
+
from = `>=${from}`;
|
|
2082
|
+
} else {
|
|
2083
|
+
from = `>=${from}${incPr ? '-0' : ''}`;
|
|
2084
|
+
}
|
|
2085
|
+
if (isX(tM)) {
|
|
2086
|
+
to = '';
|
|
2087
|
+
} else if (isX(tm)) {
|
|
2088
|
+
to = `<${+tM + 1}.0.0-0`;
|
|
2089
|
+
} else if (isX(tp)) {
|
|
2090
|
+
to = `<${tM}.${+tm + 1}.0-0`;
|
|
2091
|
+
} else if (tpr) {
|
|
2092
|
+
to = `<=${tM}.${tm}.${tp}-${tpr}`;
|
|
2093
|
+
} else if (incPr) {
|
|
2094
|
+
to = `<${tM}.${tm}.${+tp + 1}-0`;
|
|
2095
|
+
} else {
|
|
2096
|
+
to = `<=${to}`;
|
|
2097
|
+
}
|
|
2098
|
+
return `${from} ${to}`.trim();
|
|
2099
|
+
};
|
|
2100
|
+
const testSet = (set, version, options) => {
|
|
2101
|
+
for (let i = 0; i < set.length; i++) {
|
|
2102
|
+
if (!set[i].test(version)) {
|
|
2103
|
+
return false;
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
if (version.prerelease.length && !options.includePrerelease) {
|
|
2107
|
+
// Find the set of versions that are allowed to have prereleases
|
|
2108
|
+
// For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
|
|
2109
|
+
// That should allow `1.2.3-pr.2` to pass.
|
|
2110
|
+
// However, `1.2.4-alpha.notready` should NOT be allowed,
|
|
2111
|
+
// even though it's within the range set by the comparators.
|
|
2112
|
+
for (let i = 0; i < set.length; i++) {
|
|
2113
|
+
debug(set[i].semver);
|
|
2114
|
+
if (set[i].semver === Comparator.ANY) {
|
|
2115
|
+
continue;
|
|
2116
|
+
}
|
|
2117
|
+
if (set[i].semver.prerelease.length > 0) {
|
|
2118
|
+
const allowed = set[i].semver;
|
|
2119
|
+
if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
|
|
2120
|
+
return true;
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
// Version has a -pre, but it's not one of the ones we like.
|
|
2126
|
+
return false;
|
|
2127
|
+
}
|
|
2128
|
+
return true;
|
|
2129
|
+
};
|
|
2130
|
+
return range;
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
var comparator;
|
|
2134
|
+
var hasRequiredComparator;
|
|
2135
|
+
|
|
2136
|
+
function requireComparator () {
|
|
2137
|
+
if (hasRequiredComparator) return comparator;
|
|
2138
|
+
hasRequiredComparator = 1;
|
|
2139
|
+
|
|
2140
|
+
const ANY = Symbol('SemVer ANY');
|
|
2141
|
+
// hoisted class for cyclic dependency
|
|
2142
|
+
class Comparator {
|
|
2143
|
+
static get ANY() {
|
|
2144
|
+
return ANY;
|
|
2145
|
+
}
|
|
2146
|
+
constructor(comp, options) {
|
|
2147
|
+
options = parseOptions(options);
|
|
2148
|
+
if (comp instanceof Comparator) {
|
|
2149
|
+
if (comp.loose === !!options.loose) {
|
|
2150
|
+
return comp;
|
|
2151
|
+
} else {
|
|
2152
|
+
comp = comp.value;
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
comp = comp.trim().split(/\s+/).join(' ');
|
|
2156
|
+
debug('comparator', comp, options);
|
|
2157
|
+
this.options = options;
|
|
2158
|
+
this.loose = !!options.loose;
|
|
2159
|
+
this.parse(comp);
|
|
2160
|
+
if (this.semver === ANY) {
|
|
2161
|
+
this.value = '';
|
|
2162
|
+
} else {
|
|
2163
|
+
this.value = this.operator + this.semver.version;
|
|
2164
|
+
}
|
|
2165
|
+
debug('comp', this);
|
|
2166
|
+
}
|
|
2167
|
+
parse(comp) {
|
|
2168
|
+
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
2169
|
+
const m = comp.match(r);
|
|
2170
|
+
if (!m) {
|
|
2171
|
+
throw new TypeError(`Invalid comparator: ${comp}`);
|
|
2172
|
+
}
|
|
2173
|
+
this.operator = m[1] !== undefined ? m[1] : '';
|
|
2174
|
+
if (this.operator === '=') {
|
|
2175
|
+
this.operator = '';
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
// if it literally is just '>' or '' then allow anything.
|
|
2179
|
+
if (!m[2]) {
|
|
2180
|
+
this.semver = ANY;
|
|
2181
|
+
} else {
|
|
2182
|
+
this.semver = new SemVer(m[2], this.options.loose);
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
toString() {
|
|
2186
|
+
return this.value;
|
|
2187
|
+
}
|
|
2188
|
+
test(version) {
|
|
2189
|
+
debug('Comparator.test', version, this.options.loose);
|
|
2190
|
+
if (this.semver === ANY || version === ANY) {
|
|
2191
|
+
return true;
|
|
2192
|
+
}
|
|
2193
|
+
if (typeof version === 'string') {
|
|
2194
|
+
try {
|
|
2195
|
+
version = new SemVer(version, this.options);
|
|
2196
|
+
} catch (er) {
|
|
2197
|
+
return false;
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
return cmp(version, this.operator, this.semver, this.options);
|
|
2201
|
+
}
|
|
2202
|
+
intersects(comp, options) {
|
|
2203
|
+
if (!(comp instanceof Comparator)) {
|
|
2204
|
+
throw new TypeError('a Comparator is required');
|
|
2205
|
+
}
|
|
2206
|
+
if (this.operator === '') {
|
|
2207
|
+
if (this.value === '') {
|
|
2208
|
+
return true;
|
|
2209
|
+
}
|
|
2210
|
+
return new Range(comp.value, options).test(this.value);
|
|
2211
|
+
} else if (comp.operator === '') {
|
|
2212
|
+
if (comp.value === '') {
|
|
2213
|
+
return true;
|
|
2214
|
+
}
|
|
2215
|
+
return new Range(this.value, options).test(comp.semver);
|
|
2216
|
+
}
|
|
2217
|
+
options = parseOptions(options);
|
|
2218
|
+
|
|
2219
|
+
// Special cases where nothing can possibly be lower
|
|
2220
|
+
if (options.includePrerelease && (this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {
|
|
2221
|
+
return false;
|
|
2222
|
+
}
|
|
2223
|
+
if (!options.includePrerelease && (this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {
|
|
2224
|
+
return false;
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
// Same direction increasing (> or >=)
|
|
2228
|
+
if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {
|
|
2229
|
+
return true;
|
|
2230
|
+
}
|
|
2231
|
+
// Same direction decreasing (< or <=)
|
|
2232
|
+
if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {
|
|
2233
|
+
return true;
|
|
2234
|
+
}
|
|
2235
|
+
// same SemVer and both sides are inclusive (<= or >=)
|
|
2236
|
+
if (this.semver.version === comp.semver.version && this.operator.includes('=') && comp.operator.includes('=')) {
|
|
2237
|
+
return true;
|
|
2238
|
+
}
|
|
2239
|
+
// opposite directions less than
|
|
2240
|
+
if (cmp(this.semver, '<', comp.semver, options) && this.operator.startsWith('>') && comp.operator.startsWith('<')) {
|
|
2241
|
+
return true;
|
|
2242
|
+
}
|
|
2243
|
+
// opposite directions greater than
|
|
2244
|
+
if (cmp(this.semver, '>', comp.semver, options) && this.operator.startsWith('<') && comp.operator.startsWith('>')) {
|
|
2245
|
+
return true;
|
|
2246
|
+
}
|
|
2247
|
+
return false;
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
comparator = Comparator;
|
|
2251
|
+
const parseOptions = requireParseOptions();
|
|
2252
|
+
const {
|
|
2253
|
+
safeRe: re,
|
|
2254
|
+
t
|
|
2255
|
+
} = requireRe();
|
|
2256
|
+
const cmp = requireCmp();
|
|
2257
|
+
const debug = requireDebug();
|
|
2258
|
+
const SemVer = requireSemver$1();
|
|
2259
|
+
const Range = requireRange();
|
|
2260
|
+
return comparator;
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
var satisfies_1;
|
|
2264
|
+
var hasRequiredSatisfies;
|
|
2265
|
+
|
|
2266
|
+
function requireSatisfies () {
|
|
2267
|
+
if (hasRequiredSatisfies) return satisfies_1;
|
|
2268
|
+
hasRequiredSatisfies = 1;
|
|
2269
|
+
|
|
2270
|
+
const Range = requireRange();
|
|
2271
|
+
const satisfies = (version, range, options) => {
|
|
2272
|
+
try {
|
|
2273
|
+
range = new Range(range, options);
|
|
2274
|
+
} catch (er) {
|
|
2275
|
+
return false;
|
|
2276
|
+
}
|
|
2277
|
+
return range.test(version);
|
|
2278
|
+
};
|
|
2279
|
+
satisfies_1 = satisfies;
|
|
2280
|
+
return satisfies_1;
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
var toComparators_1;
|
|
2284
|
+
var hasRequiredToComparators;
|
|
2285
|
+
|
|
2286
|
+
function requireToComparators () {
|
|
2287
|
+
if (hasRequiredToComparators) return toComparators_1;
|
|
2288
|
+
hasRequiredToComparators = 1;
|
|
2289
|
+
|
|
2290
|
+
const Range = requireRange();
|
|
2291
|
+
|
|
2292
|
+
// Mostly just for testing and legacy API reasons
|
|
2293
|
+
const toComparators = (range, options) => new Range(range, options).set.map(comp => comp.map(c => c.value).join(' ').trim().split(' '));
|
|
2294
|
+
toComparators_1 = toComparators;
|
|
2295
|
+
return toComparators_1;
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
var maxSatisfying_1;
|
|
2299
|
+
var hasRequiredMaxSatisfying;
|
|
2300
|
+
|
|
2301
|
+
function requireMaxSatisfying () {
|
|
2302
|
+
if (hasRequiredMaxSatisfying) return maxSatisfying_1;
|
|
2303
|
+
hasRequiredMaxSatisfying = 1;
|
|
2304
|
+
|
|
2305
|
+
const SemVer = requireSemver$1();
|
|
2306
|
+
const Range = requireRange();
|
|
2307
|
+
const maxSatisfying = (versions, range, options) => {
|
|
2308
|
+
let max = null;
|
|
2309
|
+
let maxSV = null;
|
|
2310
|
+
let rangeObj = null;
|
|
2311
|
+
try {
|
|
2312
|
+
rangeObj = new Range(range, options);
|
|
2313
|
+
} catch (er) {
|
|
2314
|
+
return null;
|
|
2315
|
+
}
|
|
2316
|
+
versions.forEach(v => {
|
|
2317
|
+
if (rangeObj.test(v)) {
|
|
2318
|
+
// satisfies(v, range, options)
|
|
2319
|
+
if (!max || maxSV.compare(v) === -1) {
|
|
2320
|
+
// compare(max, v, true)
|
|
2321
|
+
max = v;
|
|
2322
|
+
maxSV = new SemVer(max, options);
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2325
|
+
});
|
|
2326
|
+
return max;
|
|
2327
|
+
};
|
|
2328
|
+
maxSatisfying_1 = maxSatisfying;
|
|
2329
|
+
return maxSatisfying_1;
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
var minSatisfying_1;
|
|
2333
|
+
var hasRequiredMinSatisfying;
|
|
2334
|
+
|
|
2335
|
+
function requireMinSatisfying () {
|
|
2336
|
+
if (hasRequiredMinSatisfying) return minSatisfying_1;
|
|
2337
|
+
hasRequiredMinSatisfying = 1;
|
|
2338
|
+
|
|
2339
|
+
const SemVer = requireSemver$1();
|
|
2340
|
+
const Range = requireRange();
|
|
2341
|
+
const minSatisfying = (versions, range, options) => {
|
|
2342
|
+
let min = null;
|
|
2343
|
+
let minSV = null;
|
|
2344
|
+
let rangeObj = null;
|
|
2345
|
+
try {
|
|
2346
|
+
rangeObj = new Range(range, options);
|
|
2347
|
+
} catch (er) {
|
|
2348
|
+
return null;
|
|
2349
|
+
}
|
|
2350
|
+
versions.forEach(v => {
|
|
2351
|
+
if (rangeObj.test(v)) {
|
|
2352
|
+
// satisfies(v, range, options)
|
|
2353
|
+
if (!min || minSV.compare(v) === 1) {
|
|
2354
|
+
// compare(min, v, true)
|
|
2355
|
+
min = v;
|
|
2356
|
+
minSV = new SemVer(min, options);
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
});
|
|
2360
|
+
return min;
|
|
2361
|
+
};
|
|
2362
|
+
minSatisfying_1 = minSatisfying;
|
|
2363
|
+
return minSatisfying_1;
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2366
|
+
var minVersion_1;
|
|
2367
|
+
var hasRequiredMinVersion;
|
|
2368
|
+
|
|
2369
|
+
function requireMinVersion () {
|
|
2370
|
+
if (hasRequiredMinVersion) return minVersion_1;
|
|
2371
|
+
hasRequiredMinVersion = 1;
|
|
2372
|
+
|
|
2373
|
+
const SemVer = requireSemver$1();
|
|
2374
|
+
const Range = requireRange();
|
|
2375
|
+
const gt = requireGt();
|
|
2376
|
+
const minVersion = (range, loose) => {
|
|
2377
|
+
range = new Range(range, loose);
|
|
2378
|
+
let minver = new SemVer('0.0.0');
|
|
2379
|
+
if (range.test(minver)) {
|
|
2380
|
+
return minver;
|
|
2381
|
+
}
|
|
2382
|
+
minver = new SemVer('0.0.0-0');
|
|
2383
|
+
if (range.test(minver)) {
|
|
2384
|
+
return minver;
|
|
2385
|
+
}
|
|
2386
|
+
minver = null;
|
|
2387
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
2388
|
+
const comparators = range.set[i];
|
|
2389
|
+
let setMin = null;
|
|
2390
|
+
comparators.forEach(comparator => {
|
|
2391
|
+
// Clone to avoid manipulating the comparator's semver object.
|
|
2392
|
+
const compver = new SemVer(comparator.semver.version);
|
|
2393
|
+
switch (comparator.operator) {
|
|
2394
|
+
case '>':
|
|
2395
|
+
if (compver.prerelease.length === 0) {
|
|
2396
|
+
compver.patch++;
|
|
2397
|
+
} else {
|
|
2398
|
+
compver.prerelease.push(0);
|
|
2399
|
+
}
|
|
2400
|
+
compver.raw = compver.format();
|
|
2401
|
+
/* fallthrough */
|
|
2402
|
+
case '':
|
|
2403
|
+
case '>=':
|
|
2404
|
+
if (!setMin || gt(compver, setMin)) {
|
|
2405
|
+
setMin = compver;
|
|
2406
|
+
}
|
|
2407
|
+
break;
|
|
2408
|
+
case '<':
|
|
2409
|
+
case '<=':
|
|
2410
|
+
/* Ignore maximum versions */
|
|
2411
|
+
break;
|
|
2412
|
+
/* istanbul ignore next */
|
|
2413
|
+
default:
|
|
2414
|
+
throw new Error(`Unexpected operation: ${comparator.operator}`);
|
|
2415
|
+
}
|
|
2416
|
+
});
|
|
2417
|
+
if (setMin && (!minver || gt(minver, setMin))) {
|
|
2418
|
+
minver = setMin;
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
if (minver && range.test(minver)) {
|
|
2422
|
+
return minver;
|
|
2423
|
+
}
|
|
2424
|
+
return null;
|
|
2425
|
+
};
|
|
2426
|
+
minVersion_1 = minVersion;
|
|
2427
|
+
return minVersion_1;
|
|
2428
|
+
}
|
|
2429
|
+
|
|
2430
|
+
var valid;
|
|
2431
|
+
var hasRequiredValid;
|
|
2432
|
+
|
|
2433
|
+
function requireValid () {
|
|
2434
|
+
if (hasRequiredValid) return valid;
|
|
2435
|
+
hasRequiredValid = 1;
|
|
2436
|
+
|
|
2437
|
+
const Range = requireRange();
|
|
2438
|
+
const validRange = (range, options) => {
|
|
2439
|
+
try {
|
|
2440
|
+
// Return '*' instead of '' so that truthiness works.
|
|
2441
|
+
// This will throw if it's invalid anyway
|
|
2442
|
+
return new Range(range, options).range || '*';
|
|
2443
|
+
} catch (er) {
|
|
2444
|
+
return null;
|
|
2445
|
+
}
|
|
2446
|
+
};
|
|
2447
|
+
valid = validRange;
|
|
2448
|
+
return valid;
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
var outside_1;
|
|
2452
|
+
var hasRequiredOutside;
|
|
2453
|
+
|
|
2454
|
+
function requireOutside () {
|
|
2455
|
+
if (hasRequiredOutside) return outside_1;
|
|
2456
|
+
hasRequiredOutside = 1;
|
|
2457
|
+
|
|
2458
|
+
const SemVer = requireSemver$1();
|
|
2459
|
+
const Comparator = requireComparator();
|
|
2460
|
+
const {
|
|
2461
|
+
ANY
|
|
2462
|
+
} = Comparator;
|
|
2463
|
+
const Range = requireRange();
|
|
2464
|
+
const satisfies = requireSatisfies();
|
|
2465
|
+
const gt = requireGt();
|
|
2466
|
+
const lt = requireLt();
|
|
2467
|
+
const lte = requireLte();
|
|
2468
|
+
const gte = requireGte();
|
|
2469
|
+
const outside = (version, range, hilo, options) => {
|
|
2470
|
+
version = new SemVer(version, options);
|
|
2471
|
+
range = new Range(range, options);
|
|
2472
|
+
let gtfn, ltefn, ltfn, comp, ecomp;
|
|
2473
|
+
switch (hilo) {
|
|
2474
|
+
case '>':
|
|
2475
|
+
gtfn = gt;
|
|
2476
|
+
ltefn = lte;
|
|
2477
|
+
ltfn = lt;
|
|
2478
|
+
comp = '>';
|
|
2479
|
+
ecomp = '>=';
|
|
2480
|
+
break;
|
|
2481
|
+
case '<':
|
|
2482
|
+
gtfn = lt;
|
|
2483
|
+
ltefn = gte;
|
|
2484
|
+
ltfn = gt;
|
|
2485
|
+
comp = '<';
|
|
2486
|
+
ecomp = '<=';
|
|
2487
|
+
break;
|
|
2488
|
+
default:
|
|
2489
|
+
throw new TypeError('Must provide a hilo val of "<" or ">"');
|
|
2490
|
+
}
|
|
2491
|
+
|
|
2492
|
+
// If it satisfies the range it is not outside
|
|
2493
|
+
if (satisfies(version, range, options)) {
|
|
2494
|
+
return false;
|
|
2495
|
+
}
|
|
2496
|
+
|
|
2497
|
+
// From now on, variable terms are as if we're in "gtr" mode.
|
|
2498
|
+
// but note that everything is flipped for the "ltr" function.
|
|
2499
|
+
|
|
2500
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
2501
|
+
const comparators = range.set[i];
|
|
2502
|
+
let high = null;
|
|
2503
|
+
let low = null;
|
|
2504
|
+
comparators.forEach(comparator => {
|
|
2505
|
+
if (comparator.semver === ANY) {
|
|
2506
|
+
comparator = new Comparator('>=0.0.0');
|
|
2507
|
+
}
|
|
2508
|
+
high = high || comparator;
|
|
2509
|
+
low = low || comparator;
|
|
2510
|
+
if (gtfn(comparator.semver, high.semver, options)) {
|
|
2511
|
+
high = comparator;
|
|
2512
|
+
} else if (ltfn(comparator.semver, low.semver, options)) {
|
|
2513
|
+
low = comparator;
|
|
2514
|
+
}
|
|
2515
|
+
});
|
|
2516
|
+
|
|
2517
|
+
// If the edge version comparator has a operator then our version
|
|
2518
|
+
// isn't outside it
|
|
2519
|
+
if (high.operator === comp || high.operator === ecomp) {
|
|
2520
|
+
return false;
|
|
2521
|
+
}
|
|
2522
|
+
|
|
2523
|
+
// If the lowest version comparator has an operator and our version
|
|
2524
|
+
// is less than it then it isn't higher than the range
|
|
2525
|
+
if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
|
|
2526
|
+
return false;
|
|
2527
|
+
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
|
|
2528
|
+
return false;
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
return true;
|
|
2532
|
+
};
|
|
2533
|
+
outside_1 = outside;
|
|
2534
|
+
return outside_1;
|
|
2535
|
+
}
|
|
2536
|
+
|
|
2537
|
+
var gtr_1;
|
|
2538
|
+
var hasRequiredGtr;
|
|
2539
|
+
|
|
2540
|
+
function requireGtr () {
|
|
2541
|
+
if (hasRequiredGtr) return gtr_1;
|
|
2542
|
+
hasRequiredGtr = 1;
|
|
2543
|
+
|
|
2544
|
+
// Determine if version is greater than all the versions possible in the range.
|
|
2545
|
+
const outside = requireOutside();
|
|
2546
|
+
const gtr = (version, range, options) => outside(version, range, '>', options);
|
|
2547
|
+
gtr_1 = gtr;
|
|
2548
|
+
return gtr_1;
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2551
|
+
var ltr_1;
|
|
2552
|
+
var hasRequiredLtr;
|
|
2553
|
+
|
|
2554
|
+
function requireLtr () {
|
|
2555
|
+
if (hasRequiredLtr) return ltr_1;
|
|
2556
|
+
hasRequiredLtr = 1;
|
|
2557
|
+
|
|
2558
|
+
const outside = requireOutside();
|
|
2559
|
+
// Determine if version is less than all the versions possible in the range
|
|
2560
|
+
const ltr = (version, range, options) => outside(version, range, '<', options);
|
|
2561
|
+
ltr_1 = ltr;
|
|
2562
|
+
return ltr_1;
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
var intersects_1;
|
|
2566
|
+
var hasRequiredIntersects;
|
|
2567
|
+
|
|
2568
|
+
function requireIntersects () {
|
|
2569
|
+
if (hasRequiredIntersects) return intersects_1;
|
|
2570
|
+
hasRequiredIntersects = 1;
|
|
2571
|
+
|
|
2572
|
+
const Range = requireRange();
|
|
2573
|
+
const intersects = (r1, r2, options) => {
|
|
2574
|
+
r1 = new Range(r1, options);
|
|
2575
|
+
r2 = new Range(r2, options);
|
|
2576
|
+
return r1.intersects(r2, options);
|
|
2577
|
+
};
|
|
2578
|
+
intersects_1 = intersects;
|
|
2579
|
+
return intersects_1;
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
var simplify;
|
|
2583
|
+
var hasRequiredSimplify;
|
|
2584
|
+
|
|
2585
|
+
function requireSimplify () {
|
|
2586
|
+
if (hasRequiredSimplify) return simplify;
|
|
2587
|
+
hasRequiredSimplify = 1;
|
|
2588
|
+
|
|
2589
|
+
// given a set of versions and a range, create a "simplified" range
|
|
2590
|
+
// that includes the same versions that the original range does
|
|
2591
|
+
// If the original range is shorter than the simplified one, return that.
|
|
2592
|
+
const satisfies = requireSatisfies();
|
|
2593
|
+
const compare = requireCompare();
|
|
2594
|
+
simplify = (versions, range, options) => {
|
|
2595
|
+
const set = [];
|
|
2596
|
+
let first = null;
|
|
2597
|
+
let prev = null;
|
|
2598
|
+
const v = versions.sort((a, b) => compare(a, b, options));
|
|
2599
|
+
for (const version of v) {
|
|
2600
|
+
const included = satisfies(version, range, options);
|
|
2601
|
+
if (included) {
|
|
2602
|
+
prev = version;
|
|
2603
|
+
if (!first) {
|
|
2604
|
+
first = version;
|
|
2605
|
+
}
|
|
2606
|
+
} else {
|
|
2607
|
+
if (prev) {
|
|
2608
|
+
set.push([first, prev]);
|
|
2609
|
+
}
|
|
2610
|
+
prev = null;
|
|
2611
|
+
first = null;
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
if (first) {
|
|
2615
|
+
set.push([first, null]);
|
|
2616
|
+
}
|
|
2617
|
+
const ranges = [];
|
|
2618
|
+
for (const [min, max] of set) {
|
|
2619
|
+
if (min === max) {
|
|
2620
|
+
ranges.push(min);
|
|
2621
|
+
} else if (!max && min === v[0]) {
|
|
2622
|
+
ranges.push('*');
|
|
2623
|
+
} else if (!max) {
|
|
2624
|
+
ranges.push(`>=${min}`);
|
|
2625
|
+
} else if (min === v[0]) {
|
|
2626
|
+
ranges.push(`<=${max}`);
|
|
2627
|
+
} else {
|
|
2628
|
+
ranges.push(`${min} - ${max}`);
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
const simplified = ranges.join(' || ');
|
|
2632
|
+
const original = typeof range.raw === 'string' ? range.raw : String(range);
|
|
2633
|
+
return simplified.length < original.length ? simplified : range;
|
|
2634
|
+
};
|
|
2635
|
+
return simplify;
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2638
|
+
var subset_1;
|
|
2639
|
+
var hasRequiredSubset;
|
|
2640
|
+
|
|
2641
|
+
function requireSubset () {
|
|
2642
|
+
if (hasRequiredSubset) return subset_1;
|
|
2643
|
+
hasRequiredSubset = 1;
|
|
2644
|
+
|
|
2645
|
+
const Range = requireRange();
|
|
2646
|
+
const Comparator = requireComparator();
|
|
2647
|
+
const {
|
|
2648
|
+
ANY
|
|
2649
|
+
} = Comparator;
|
|
2650
|
+
const satisfies = requireSatisfies();
|
|
2651
|
+
const compare = requireCompare();
|
|
2652
|
+
|
|
2653
|
+
// Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff:
|
|
2654
|
+
// - Every simple range `r1, r2, ...` is a null set, OR
|
|
2655
|
+
// - Every simple range `r1, r2, ...` which is not a null set is a subset of
|
|
2656
|
+
// some `R1, R2, ...`
|
|
2657
|
+
//
|
|
2658
|
+
// Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff:
|
|
2659
|
+
// - If c is only the ANY comparator
|
|
2660
|
+
// - If C is only the ANY comparator, return true
|
|
2661
|
+
// - Else if in prerelease mode, return false
|
|
2662
|
+
// - else replace c with `[>=0.0.0]`
|
|
2663
|
+
// - If C is only the ANY comparator
|
|
2664
|
+
// - if in prerelease mode, return true
|
|
2665
|
+
// - else replace C with `[>=0.0.0]`
|
|
2666
|
+
// - Let EQ be the set of = comparators in c
|
|
2667
|
+
// - If EQ is more than one, return true (null set)
|
|
2668
|
+
// - Let GT be the highest > or >= comparator in c
|
|
2669
|
+
// - Let LT be the lowest < or <= comparator in c
|
|
2670
|
+
// - If GT and LT, and GT.semver > LT.semver, return true (null set)
|
|
2671
|
+
// - If any C is a = range, and GT or LT are set, return false
|
|
2672
|
+
// - If EQ
|
|
2673
|
+
// - If GT, and EQ does not satisfy GT, return true (null set)
|
|
2674
|
+
// - If LT, and EQ does not satisfy LT, return true (null set)
|
|
2675
|
+
// - If EQ satisfies every C, return true
|
|
2676
|
+
// - Else return false
|
|
2677
|
+
// - If GT
|
|
2678
|
+
// - If GT.semver is lower than any > or >= comp in C, return false
|
|
2679
|
+
// - If GT is >=, and GT.semver does not satisfy every C, return false
|
|
2680
|
+
// - If GT.semver has a prerelease, and not in prerelease mode
|
|
2681
|
+
// - If no C has a prerelease and the GT.semver tuple, return false
|
|
2682
|
+
// - If LT
|
|
2683
|
+
// - If LT.semver is greater than any < or <= comp in C, return false
|
|
2684
|
+
// - If LT is <=, and LT.semver does not satisfy every C, return false
|
|
2685
|
+
// - If GT.semver has a prerelease, and not in prerelease mode
|
|
2686
|
+
// - If no C has a prerelease and the LT.semver tuple, return false
|
|
2687
|
+
// - Else return true
|
|
2688
|
+
|
|
2689
|
+
const subset = (sub, dom, options = {}) => {
|
|
2690
|
+
if (sub === dom) {
|
|
2691
|
+
return true;
|
|
2692
|
+
}
|
|
2693
|
+
sub = new Range(sub, options);
|
|
2694
|
+
dom = new Range(dom, options);
|
|
2695
|
+
let sawNonNull = false;
|
|
2696
|
+
OUTER: for (const simpleSub of sub.set) {
|
|
2697
|
+
for (const simpleDom of dom.set) {
|
|
2698
|
+
const isSub = simpleSubset(simpleSub, simpleDom, options);
|
|
2699
|
+
sawNonNull = sawNonNull || isSub !== null;
|
|
2700
|
+
if (isSub) {
|
|
2701
|
+
continue OUTER;
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
// the null set is a subset of everything, but null simple ranges in
|
|
2705
|
+
// a complex range should be ignored. so if we saw a non-null range,
|
|
2706
|
+
// then we know this isn't a subset, but if EVERY simple range was null,
|
|
2707
|
+
// then it is a subset.
|
|
2708
|
+
if (sawNonNull) {
|
|
2709
|
+
return false;
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
return true;
|
|
2713
|
+
};
|
|
2714
|
+
const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')];
|
|
2715
|
+
const minimumVersion = [new Comparator('>=0.0.0')];
|
|
2716
|
+
const simpleSubset = (sub, dom, options) => {
|
|
2717
|
+
if (sub === dom) {
|
|
2718
|
+
return true;
|
|
2719
|
+
}
|
|
2720
|
+
if (sub.length === 1 && sub[0].semver === ANY) {
|
|
2721
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
2722
|
+
return true;
|
|
2723
|
+
} else if (options.includePrerelease) {
|
|
2724
|
+
sub = minimumVersionWithPreRelease;
|
|
2725
|
+
} else {
|
|
2726
|
+
sub = minimumVersion;
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
2730
|
+
if (options.includePrerelease) {
|
|
2731
|
+
return true;
|
|
2732
|
+
} else {
|
|
2733
|
+
dom = minimumVersion;
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
const eqSet = new Set();
|
|
2737
|
+
let gt, lt;
|
|
2738
|
+
for (const c of sub) {
|
|
2739
|
+
if (c.operator === '>' || c.operator === '>=') {
|
|
2740
|
+
gt = higherGT(gt, c, options);
|
|
2741
|
+
} else if (c.operator === '<' || c.operator === '<=') {
|
|
2742
|
+
lt = lowerLT(lt, c, options);
|
|
2743
|
+
} else {
|
|
2744
|
+
eqSet.add(c.semver);
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2747
|
+
if (eqSet.size > 1) {
|
|
2748
|
+
return null;
|
|
2749
|
+
}
|
|
2750
|
+
let gtltComp;
|
|
2751
|
+
if (gt && lt) {
|
|
2752
|
+
gtltComp = compare(gt.semver, lt.semver, options);
|
|
2753
|
+
if (gtltComp > 0) {
|
|
2754
|
+
return null;
|
|
2755
|
+
} else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) {
|
|
2756
|
+
return null;
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
|
|
2760
|
+
// will iterate one or zero times
|
|
2761
|
+
for (const eq of eqSet) {
|
|
2762
|
+
if (gt && !satisfies(eq, String(gt), options)) {
|
|
2763
|
+
return null;
|
|
2764
|
+
}
|
|
2765
|
+
if (lt && !satisfies(eq, String(lt), options)) {
|
|
2766
|
+
return null;
|
|
2767
|
+
}
|
|
2768
|
+
for (const c of dom) {
|
|
2769
|
+
if (!satisfies(eq, String(c), options)) {
|
|
2770
|
+
return false;
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
return true;
|
|
2774
|
+
}
|
|
2775
|
+
let higher, lower;
|
|
2776
|
+
let hasDomLT, hasDomGT;
|
|
2777
|
+
// if the subset has a prerelease, we need a comparator in the superset
|
|
2778
|
+
// with the same tuple and a prerelease, or it's not a subset
|
|
2779
|
+
let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
|
|
2780
|
+
let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
|
|
2781
|
+
// exception: <1.2.3-0 is the same as <1.2.3
|
|
2782
|
+
if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === '<' && needDomLTPre.prerelease[0] === 0) {
|
|
2783
|
+
needDomLTPre = false;
|
|
2784
|
+
}
|
|
2785
|
+
for (const c of dom) {
|
|
2786
|
+
hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>=';
|
|
2787
|
+
hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<=';
|
|
2788
|
+
if (gt) {
|
|
2789
|
+
if (needDomGTPre) {
|
|
2790
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
|
|
2791
|
+
needDomGTPre = false;
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
if (c.operator === '>' || c.operator === '>=') {
|
|
2795
|
+
higher = higherGT(gt, c, options);
|
|
2796
|
+
if (higher === c && higher !== gt) {
|
|
2797
|
+
return false;
|
|
2798
|
+
}
|
|
2799
|
+
} else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) {
|
|
2800
|
+
return false;
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
if (lt) {
|
|
2804
|
+
if (needDomLTPre) {
|
|
2805
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
|
|
2806
|
+
needDomLTPre = false;
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
if (c.operator === '<' || c.operator === '<=') {
|
|
2810
|
+
lower = lowerLT(lt, c, options);
|
|
2811
|
+
if (lower === c && lower !== lt) {
|
|
2812
|
+
return false;
|
|
2813
|
+
}
|
|
2814
|
+
} else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) {
|
|
2815
|
+
return false;
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
if (!c.operator && (lt || gt) && gtltComp !== 0) {
|
|
2819
|
+
return false;
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
// if there was a < or >, and nothing in the dom, then must be false
|
|
2824
|
+
// UNLESS it was limited by another range in the other direction.
|
|
2825
|
+
// Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0
|
|
2826
|
+
if (gt && hasDomLT && !lt && gtltComp !== 0) {
|
|
2827
|
+
return false;
|
|
2828
|
+
}
|
|
2829
|
+
if (lt && hasDomGT && !gt && gtltComp !== 0) {
|
|
2830
|
+
return false;
|
|
2831
|
+
}
|
|
2832
|
+
|
|
2833
|
+
// we needed a prerelease range in a specific tuple, but didn't get one
|
|
2834
|
+
// then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0,
|
|
2835
|
+
// because it includes prereleases in the 1.2.3 tuple
|
|
2836
|
+
if (needDomGTPre || needDomLTPre) {
|
|
2837
|
+
return false;
|
|
2838
|
+
}
|
|
2839
|
+
return true;
|
|
2840
|
+
};
|
|
2841
|
+
|
|
2842
|
+
// >=1.2.3 is lower than >1.2.3
|
|
2843
|
+
const higherGT = (a, b, options) => {
|
|
2844
|
+
if (!a) {
|
|
2845
|
+
return b;
|
|
2846
|
+
}
|
|
2847
|
+
const comp = compare(a.semver, b.semver, options);
|
|
2848
|
+
return comp > 0 ? a : comp < 0 ? b : b.operator === '>' && a.operator === '>=' ? b : a;
|
|
2849
|
+
};
|
|
2850
|
+
|
|
2851
|
+
// <=1.2.3 is higher than <1.2.3
|
|
2852
|
+
const lowerLT = (a, b, options) => {
|
|
2853
|
+
if (!a) {
|
|
2854
|
+
return b;
|
|
2855
|
+
}
|
|
2856
|
+
const comp = compare(a.semver, b.semver, options);
|
|
2857
|
+
return comp < 0 ? a : comp > 0 ? b : b.operator === '<' && a.operator === '<=' ? b : a;
|
|
2858
|
+
};
|
|
2859
|
+
subset_1 = subset;
|
|
2860
|
+
return subset_1;
|
|
2861
|
+
}
|
|
2862
|
+
|
|
2863
|
+
var semver;
|
|
2864
|
+
var hasRequiredSemver;
|
|
2865
|
+
|
|
2866
|
+
function requireSemver () {
|
|
2867
|
+
if (hasRequiredSemver) return semver;
|
|
2868
|
+
hasRequiredSemver = 1;
|
|
2869
|
+
|
|
2870
|
+
// just pre-load all the stuff that index.js lazily exports
|
|
2871
|
+
const internalRe = requireRe();
|
|
2872
|
+
const constants = requireConstants();
|
|
2873
|
+
const SemVer = requireSemver$1();
|
|
2874
|
+
const identifiers = requireIdentifiers();
|
|
2875
|
+
const parse = requireParse();
|
|
2876
|
+
const valid = requireValid$1();
|
|
2877
|
+
const clean = requireClean();
|
|
2878
|
+
const inc = requireInc();
|
|
2879
|
+
const diff = requireDiff();
|
|
2880
|
+
const major = requireMajor();
|
|
2881
|
+
const minor = requireMinor();
|
|
2882
|
+
const patch = requirePatch();
|
|
2883
|
+
const prerelease = requirePrerelease();
|
|
2884
|
+
const compare = requireCompare();
|
|
2885
|
+
const rcompare = requireRcompare();
|
|
2886
|
+
const compareLoose = requireCompareLoose();
|
|
2887
|
+
const compareBuild = requireCompareBuild();
|
|
2888
|
+
const sort = requireSort();
|
|
2889
|
+
const rsort = requireRsort();
|
|
2890
|
+
const gt = requireGt();
|
|
2891
|
+
const lt = requireLt();
|
|
2892
|
+
const eq = requireEq();
|
|
2893
|
+
const neq = requireNeq();
|
|
2894
|
+
const gte = requireGte();
|
|
2895
|
+
const lte = requireLte();
|
|
2896
|
+
const cmp = requireCmp();
|
|
2897
|
+
const coerce = requireCoerce();
|
|
2898
|
+
const Comparator = requireComparator();
|
|
2899
|
+
const Range = requireRange();
|
|
2900
|
+
const satisfies = requireSatisfies();
|
|
2901
|
+
const toComparators = requireToComparators();
|
|
2902
|
+
const maxSatisfying = requireMaxSatisfying();
|
|
2903
|
+
const minSatisfying = requireMinSatisfying();
|
|
2904
|
+
const minVersion = requireMinVersion();
|
|
2905
|
+
const validRange = requireValid();
|
|
2906
|
+
const outside = requireOutside();
|
|
2907
|
+
const gtr = requireGtr();
|
|
2908
|
+
const ltr = requireLtr();
|
|
2909
|
+
const intersects = requireIntersects();
|
|
2910
|
+
const simplifyRange = requireSimplify();
|
|
2911
|
+
const subset = requireSubset();
|
|
2912
|
+
semver = {
|
|
2913
|
+
parse,
|
|
2914
|
+
valid,
|
|
2915
|
+
clean,
|
|
2916
|
+
inc,
|
|
2917
|
+
diff,
|
|
2918
|
+
major,
|
|
2919
|
+
minor,
|
|
2920
|
+
patch,
|
|
2921
|
+
prerelease,
|
|
2922
|
+
compare,
|
|
2923
|
+
rcompare,
|
|
2924
|
+
compareLoose,
|
|
2925
|
+
compareBuild,
|
|
2926
|
+
sort,
|
|
2927
|
+
rsort,
|
|
2928
|
+
gt,
|
|
2929
|
+
lt,
|
|
2930
|
+
eq,
|
|
2931
|
+
neq,
|
|
2932
|
+
gte,
|
|
2933
|
+
lte,
|
|
2934
|
+
cmp,
|
|
2935
|
+
coerce,
|
|
2936
|
+
Comparator,
|
|
2937
|
+
Range,
|
|
2938
|
+
satisfies,
|
|
2939
|
+
toComparators,
|
|
2940
|
+
maxSatisfying,
|
|
2941
|
+
minSatisfying,
|
|
2942
|
+
minVersion,
|
|
2943
|
+
validRange,
|
|
2944
|
+
outside,
|
|
2945
|
+
gtr,
|
|
2946
|
+
ltr,
|
|
2947
|
+
intersects,
|
|
2948
|
+
simplifyRange,
|
|
2949
|
+
subset,
|
|
2950
|
+
SemVer,
|
|
2951
|
+
re: internalRe.re,
|
|
2952
|
+
src: internalRe.src,
|
|
2953
|
+
tokens: internalRe.t,
|
|
2954
|
+
SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
|
|
2955
|
+
RELEASE_TYPES: constants.RELEASE_TYPES,
|
|
2956
|
+
compareIdentifiers: identifiers.compareIdentifiers,
|
|
2957
|
+
rcompareIdentifiers: identifiers.rcompareIdentifiers
|
|
2958
|
+
};
|
|
2959
|
+
return semver;
|
|
2960
|
+
}
|
|
2961
|
+
|
|
2962
|
+
var hasRequiredNormalizeOptions;
|
|
2963
|
+
|
|
2964
|
+
function requireNormalizeOptions () {
|
|
2965
|
+
if (hasRequiredNormalizeOptions) return normalizeOptions;
|
|
2966
|
+
hasRequiredNormalizeOptions = 1;
|
|
2967
|
+
|
|
2968
|
+
Object.defineProperty(normalizeOptions, "__esModule", {
|
|
2969
|
+
value: true
|
|
2970
|
+
});
|
|
2971
|
+
normalizeOptions.normalizeOptions = void 0;
|
|
2972
|
+
const semver_1 = requireSemver();
|
|
2973
|
+
function parseDebugTools(options) {
|
|
2974
|
+
let debugTools = options.debugTools || {
|
|
2975
|
+
isDebug: false,
|
|
2976
|
+
source: '',
|
|
2977
|
+
assertPredicateIndex: undefined
|
|
2978
|
+
};
|
|
2979
|
+
let isDebug = debugTools.isDebug;
|
|
2980
|
+
let debugToolsImport = debugTools.source;
|
|
2981
|
+
let assertPredicateIndex = debugTools.assertPredicateIndex;
|
|
2982
|
+
return {
|
|
2983
|
+
isDebug,
|
|
2984
|
+
debugToolsImport,
|
|
2985
|
+
assertPredicateIndex
|
|
2986
|
+
};
|
|
2987
|
+
}
|
|
2988
|
+
function evaluateFlagValue(options, name, flagName, flagValue) {
|
|
2989
|
+
let svelte = options.svelte;
|
|
2990
|
+
if (typeof flagValue === 'string' && name) {
|
|
2991
|
+
if (svelte && svelte[name]) {
|
|
2992
|
+
return (0, semver_1.gt)(flagValue, svelte[name]);
|
|
2993
|
+
} else {
|
|
2994
|
+
return null;
|
|
2995
|
+
}
|
|
2996
|
+
} else if (typeof flagValue === 'boolean' || flagValue === null) {
|
|
2997
|
+
return flagValue;
|
|
2998
|
+
} else if (flagValue === '@embroider/macros') {
|
|
2999
|
+
return flagValue;
|
|
3000
|
+
} else {
|
|
3001
|
+
throw new Error(`Invalid value specified (${flagValue}) for ${flagName} by ${name}`);
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
function parseFlags(options) {
|
|
3005
|
+
let flagsProvided = options.flags || [];
|
|
3006
|
+
let combinedFlags = {};
|
|
3007
|
+
flagsProvided.forEach(flagsDefinition => {
|
|
3008
|
+
let source = flagsDefinition.source;
|
|
3009
|
+
let flagsForSource = combinedFlags[source] = combinedFlags[source] || {};
|
|
3010
|
+
for (let flagName in flagsDefinition.flags) {
|
|
3011
|
+
let flagValue = flagsDefinition.flags[flagName];
|
|
3012
|
+
flagsForSource[flagName] = evaluateFlagValue(options, flagsDefinition.name, flagName, flagValue);
|
|
3013
|
+
}
|
|
3014
|
+
});
|
|
3015
|
+
return combinedFlags;
|
|
3016
|
+
}
|
|
3017
|
+
function normalizeOptions$1(options) {
|
|
3018
|
+
return {
|
|
3019
|
+
externalizeHelpers: options.externalizeHelpers,
|
|
3020
|
+
flags: parseFlags(options),
|
|
3021
|
+
debugTools: parseDebugTools(options)
|
|
3022
|
+
};
|
|
3023
|
+
}
|
|
3024
|
+
normalizeOptions.normalizeOptions = normalizeOptions$1;
|
|
3025
|
+
return normalizeOptions;
|
|
3026
|
+
}
|
|
3027
|
+
|
|
3028
|
+
var src = {};
|
|
3029
|
+
|
|
3030
|
+
var hasRequiredSrc$1;
|
|
3031
|
+
|
|
3032
|
+
function requireSrc$1 () {
|
|
3033
|
+
if (hasRequiredSrc$1) return src;
|
|
3034
|
+
hasRequiredSrc$1 = 1;
|
|
3035
|
+
|
|
3036
|
+
Object.defineProperty(src, "__esModule", {
|
|
3037
|
+
value: true
|
|
3038
|
+
});
|
|
3039
|
+
src.ImportUtil = void 0;
|
|
3040
|
+
class ImportUtil {
|
|
3041
|
+
constructor(t, program) {
|
|
3042
|
+
this.t = t;
|
|
3043
|
+
this.program = program;
|
|
3044
|
+
}
|
|
3045
|
+
// remove one imported binding. If this is the last thing imported from the
|
|
3046
|
+
// given moduleSpecifier, the whole statement will also be removed.
|
|
3047
|
+
removeImport(moduleSpecifier, exportedName) {
|
|
3048
|
+
for (let topLevelPath of this.program.get('body')) {
|
|
3049
|
+
if (!matchModule(topLevelPath, moduleSpecifier)) {
|
|
3050
|
+
continue;
|
|
3051
|
+
}
|
|
3052
|
+
let importSpecifierPath = topLevelPath.get('specifiers').find(specifierPath => matchSpecifier(specifierPath, exportedName));
|
|
3053
|
+
if (importSpecifierPath) {
|
|
3054
|
+
if (topLevelPath.node.specifiers.length === 1) {
|
|
3055
|
+
topLevelPath.remove();
|
|
3056
|
+
} else {
|
|
3057
|
+
importSpecifierPath.remove();
|
|
3058
|
+
}
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
}
|
|
3062
|
+
// remove all imports from the given moduleSpecifier
|
|
3063
|
+
removeAllImports(moduleSpecifier) {
|
|
3064
|
+
for (let topLevelPath of this.program.get('body')) {
|
|
3065
|
+
if (matchModule(topLevelPath, moduleSpecifier)) {
|
|
3066
|
+
topLevelPath.remove();
|
|
3067
|
+
}
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
// Import the given value (if needed) and return an Identifier representing
|
|
3071
|
+
// it.
|
|
3072
|
+
import(
|
|
3073
|
+
// the spot at which you will insert the Identifier we return to you
|
|
3074
|
+
target,
|
|
3075
|
+
// the path to the module you're importing from
|
|
3076
|
+
moduleSpecifier,
|
|
3077
|
+
// the name you're importing from that module. Use "default" for the default
|
|
3078
|
+
// export. Use "*" for the namespace.
|
|
3079
|
+
exportedName,
|
|
3080
|
+
// Optional hint for helping us pick a name for the imported binding
|
|
3081
|
+
nameHint) {
|
|
3082
|
+
var _a;
|
|
3083
|
+
let isNamespaceImport = exportedName === '*';
|
|
3084
|
+
let isDefaultImport = exportedName === 'default';
|
|
3085
|
+
let isNamedImport = !isDefaultImport && !isNamespaceImport;
|
|
3086
|
+
let declaration = this.findImportFrom(moduleSpecifier);
|
|
3087
|
+
let hasNamespaceSpecifier = declaration === null || declaration === void 0 ? void 0 : declaration.node.specifiers.find(s => s.type === 'ImportNamespaceSpecifier');
|
|
3088
|
+
let hasNamedSpecifiers = declaration === null || declaration === void 0 ? void 0 : declaration.node.specifiers.find(s => s.type === 'ImportSpecifier');
|
|
3089
|
+
/**
|
|
3090
|
+
* the file has a preexisting non-namespace import and a transform tries to add a namespace import, so they don't get combined
|
|
3091
|
+
* the file has a preexisting namespace import and a transform tries to add a non-namespace import, so they don't get combined
|
|
3092
|
+
* the file has a preexisting namespace import and a transform tries to add a namespace import, so they don't get combined
|
|
3093
|
+
*/
|
|
3094
|
+
let cannotUseExistingDeclaration = hasNamedSpecifiers && isNamespaceImport || hasNamespaceSpecifier && isNamedImport || hasNamespaceSpecifier && isNamespaceImport;
|
|
3095
|
+
if (!cannotUseExistingDeclaration && declaration) {
|
|
3096
|
+
let specifier = declaration.get('specifiers').find(spec => matchSpecifier(spec, exportedName));
|
|
3097
|
+
if (specifier && ((_a = target.scope.getBinding(specifier.node.local.name)) === null || _a === void 0 ? void 0 : _a.kind) === 'module') {
|
|
3098
|
+
return this.t.identifier(specifier.node.local.name);
|
|
3099
|
+
} else {
|
|
3100
|
+
return this.addSpecifier(target, declaration, exportedName, nameHint);
|
|
3101
|
+
}
|
|
3102
|
+
} else {
|
|
3103
|
+
let declaration = this.insertAfterExistingImports(this.t.importDeclaration([], this.t.stringLiteral(moduleSpecifier)));
|
|
3104
|
+
return this.addSpecifier(target, declaration, exportedName, nameHint);
|
|
3105
|
+
}
|
|
3106
|
+
}
|
|
3107
|
+
importForSideEffect(moduleSpecifier) {
|
|
3108
|
+
let declaration = this.findImportFrom(moduleSpecifier);
|
|
3109
|
+
if (!declaration) {
|
|
3110
|
+
this.insertAfterExistingImports(this.t.importDeclaration([], this.t.stringLiteral(moduleSpecifier)));
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
addSpecifier(target, declaration, exportedName, nameHint) {
|
|
3114
|
+
let local = this.t.identifier(unusedNameLike(target, desiredName(nameHint, exportedName, target)));
|
|
3115
|
+
let specifier = this.buildSpecifier(exportedName, local);
|
|
3116
|
+
if (specifier.type === 'ImportDefaultSpecifier') {
|
|
3117
|
+
declaration.node.specifiers.unshift(specifier);
|
|
3118
|
+
} else {
|
|
3119
|
+
declaration.node.specifiers.push(specifier);
|
|
3120
|
+
}
|
|
3121
|
+
declaration.scope.registerBinding('module', declaration.get(`specifiers.${declaration.node.specifiers.length - 1}`));
|
|
3122
|
+
return local;
|
|
3123
|
+
}
|
|
3124
|
+
buildSpecifier(exportedName, localName) {
|
|
3125
|
+
switch (exportedName) {
|
|
3126
|
+
case 'default':
|
|
3127
|
+
return this.t.importDefaultSpecifier(localName);
|
|
3128
|
+
case '*':
|
|
3129
|
+
return this.t.importNamespaceSpecifier(localName);
|
|
3130
|
+
default:
|
|
3131
|
+
return this.t.importSpecifier(localName, this.t.identifier(exportedName));
|
|
3132
|
+
}
|
|
3133
|
+
}
|
|
3134
|
+
findImportFrom(moduleSpecifier) {
|
|
3135
|
+
for (let path of this.program.get('body')) {
|
|
3136
|
+
if (path.isImportDeclaration() && path.node.source.value === moduleSpecifier && path.node.importKind !== 'type') {
|
|
3137
|
+
return path;
|
|
3138
|
+
}
|
|
3139
|
+
}
|
|
3140
|
+
return undefined;
|
|
3141
|
+
}
|
|
3142
|
+
insertAfterExistingImports(statement) {
|
|
3143
|
+
let lastIndex;
|
|
3144
|
+
for (let [index, node] of this.program.node.body.entries()) {
|
|
3145
|
+
if (node.type === 'ImportDeclaration') {
|
|
3146
|
+
lastIndex = index;
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
if (lastIndex == null) {
|
|
3150
|
+
// we are intentionally not using babel's container-aware methods, because
|
|
3151
|
+
// while in theory it's nice that they schedule other plugins to run on
|
|
3152
|
+
// our nodes, in practice those nodes might get mutated or removed by some
|
|
3153
|
+
// other plugin in the intervening time causing failures.
|
|
3154
|
+
this.program.node.body.unshift(statement);
|
|
3155
|
+
return this.program.get('body.0');
|
|
3156
|
+
} else {
|
|
3157
|
+
this.program.node.body.splice(lastIndex + 1, 0, statement);
|
|
3158
|
+
return this.program.get(`body.${lastIndex + 1}`);
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3162
|
+
src.ImportUtil = ImportUtil;
|
|
3163
|
+
function unusedNameLike(path, name) {
|
|
3164
|
+
let candidate = name;
|
|
3165
|
+
let counter = 0;
|
|
3166
|
+
while (path.scope.hasBinding(candidate)) {
|
|
3167
|
+
candidate = `${name}${counter++}`;
|
|
3168
|
+
}
|
|
3169
|
+
return candidate;
|
|
3170
|
+
}
|
|
3171
|
+
function name(node) {
|
|
3172
|
+
if (node.type === 'StringLiteral') {
|
|
3173
|
+
return node.value;
|
|
3174
|
+
} else {
|
|
3175
|
+
return node.name;
|
|
3176
|
+
}
|
|
3177
|
+
}
|
|
3178
|
+
function desiredName(nameHint, exportedName, target) {
|
|
3179
|
+
if (nameHint) {
|
|
3180
|
+
// first we opportunistically do camelization when an illegal character is
|
|
3181
|
+
// followed by a lowercase letter, in an effort to aid readability of the
|
|
3182
|
+
// output.
|
|
3183
|
+
let cleaned = nameHint.replace(/[^a-zA-Z_]([a-z])/g, (_m, letter) => letter.toUpperCase());
|
|
3184
|
+
// then we unliterally strip all remaining illegal characters.
|
|
3185
|
+
cleaned = cleaned.replace(/[^a-zA-Z_]/g, '');
|
|
3186
|
+
return cleaned;
|
|
3187
|
+
}
|
|
3188
|
+
if (exportedName === 'default' || exportedName === '*') {
|
|
3189
|
+
if (target.isIdentifier()) {
|
|
3190
|
+
return target.node.name;
|
|
3191
|
+
} else {
|
|
3192
|
+
return target.scope.generateUidIdentifierBasedOnNode(target.node).name;
|
|
3193
|
+
}
|
|
3194
|
+
} else {
|
|
3195
|
+
return exportedName;
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3198
|
+
function matchSpecifier(spec, exportedName) {
|
|
3199
|
+
switch (exportedName) {
|
|
3200
|
+
case 'default':
|
|
3201
|
+
return spec.isImportDefaultSpecifier();
|
|
3202
|
+
case '*':
|
|
3203
|
+
return spec.isImportNamespaceSpecifier();
|
|
3204
|
+
default:
|
|
3205
|
+
return spec.isImportSpecifier() && name(spec.node.imported) === exportedName;
|
|
3206
|
+
}
|
|
3207
|
+
}
|
|
3208
|
+
function matchModule(path, moduleSpecifier) {
|
|
3209
|
+
return path.isImportDeclaration() && path.get('source').node.value === moduleSpecifier;
|
|
3210
|
+
}
|
|
3211
|
+
return src;
|
|
3212
|
+
}
|
|
3213
|
+
|
|
3214
|
+
var hasRequiredSrc;
|
|
3215
|
+
|
|
3216
|
+
function requireSrc () {
|
|
3217
|
+
if (hasRequiredSrc) return src$1;
|
|
3218
|
+
hasRequiredSrc = 1;
|
|
3219
|
+
|
|
3220
|
+
var __importDefault = src$1 && src$1.__importDefault || function (mod) {
|
|
3221
|
+
return mod && mod.__esModule ? mod : {
|
|
3222
|
+
"default": mod
|
|
3223
|
+
};
|
|
3224
|
+
};
|
|
3225
|
+
Object.defineProperty(src$1, "__esModule", {
|
|
3226
|
+
value: true
|
|
3227
|
+
});
|
|
3228
|
+
const path_1 = __importDefault(require$$0);
|
|
3229
|
+
const macros_1 = __importDefault(requireMacros());
|
|
3230
|
+
const normalize_options_1 = requireNormalizeOptions();
|
|
3231
|
+
const babel_import_util_1 = requireSrc$1();
|
|
3232
|
+
function macros(babel) {
|
|
3233
|
+
let t = babel.types;
|
|
3234
|
+
function buildIdentifier(value, name) {
|
|
3235
|
+
let replacement = t.booleanLiteral(value);
|
|
3236
|
+
t.addComment(replacement, 'trailing', ` ${name} `);
|
|
3237
|
+
return replacement;
|
|
3238
|
+
}
|
|
3239
|
+
return {
|
|
3240
|
+
name: 'babel-feature-flags-and-debug-macros',
|
|
3241
|
+
visitor: {
|
|
3242
|
+
ImportSpecifier(path, state) {
|
|
3243
|
+
let importPath = path.parent.source.value;
|
|
3244
|
+
let flagsForImport = state.opts.flags[importPath];
|
|
3245
|
+
if (flagsForImport) {
|
|
3246
|
+
let flagName = t.isIdentifier(path.node.imported) ? path.node.imported.name : path.node.imported.value;
|
|
3247
|
+
let localBindingName = path.node.local.name;
|
|
3248
|
+
if (!(flagName in flagsForImport)) {
|
|
3249
|
+
throw new Error(`Imported ${flagName} from ${importPath} which is not a supported flag.`);
|
|
3250
|
+
}
|
|
3251
|
+
let flagValue = flagsForImport[flagName];
|
|
3252
|
+
if (flagValue === null) {
|
|
3253
|
+
return;
|
|
3254
|
+
}
|
|
3255
|
+
let binding = path.scope.getBinding(localBindingName);
|
|
3256
|
+
binding.referencePaths.forEach(p => {
|
|
3257
|
+
if (flagValue === '@embroider/macros') {
|
|
3258
|
+
p.replaceWith(t.callExpression(state.util.import(p, "@embroider/macros", "isDevelopingApp"), []));
|
|
3259
|
+
p.scope.crawl();
|
|
3260
|
+
} else {
|
|
3261
|
+
p.replaceWith(buildIdentifier(flagValue, flagName));
|
|
3262
|
+
}
|
|
3263
|
+
});
|
|
3264
|
+
path.remove();
|
|
3265
|
+
path.scope.removeOwnBinding(localBindingName);
|
|
3266
|
+
}
|
|
3267
|
+
},
|
|
3268
|
+
ImportDeclaration: {
|
|
3269
|
+
exit(path, state) {
|
|
3270
|
+
let importPath = path.node.source.value;
|
|
3271
|
+
let flagsForImport = state.opts.flags[importPath];
|
|
3272
|
+
// remove flag source imports when no specifiers are left
|
|
3273
|
+
if (flagsForImport && path.get('specifiers').length === 0) {
|
|
3274
|
+
path.remove();
|
|
3275
|
+
}
|
|
3276
|
+
}
|
|
3277
|
+
},
|
|
3278
|
+
Program: {
|
|
3279
|
+
enter(path, state) {
|
|
3280
|
+
// most of our plugin declares state.opts as already being normalized.
|
|
3281
|
+
// This is the spot where we force it become so.
|
|
3282
|
+
state.opts = (0, normalize_options_1.normalizeOptions)(state.opts);
|
|
3283
|
+
state.util = new babel_import_util_1.ImportUtil(t, path);
|
|
3284
|
+
this.macroBuilder = new macros_1.default(babel, state.opts, state.util);
|
|
3285
|
+
let body = path.get('body');
|
|
3286
|
+
body.forEach(item => {
|
|
3287
|
+
if (item.isImportDeclaration()) {
|
|
3288
|
+
let importPath = item.node.source.value;
|
|
3289
|
+
let debugToolsImport = state.opts.debugTools.debugToolsImport;
|
|
3290
|
+
if (debugToolsImport && debugToolsImport === importPath) {
|
|
3291
|
+
if (!item.node.specifiers.length) {
|
|
3292
|
+
item.remove();
|
|
3293
|
+
} else {
|
|
3294
|
+
this.macroBuilder.collectDebugToolsSpecifiers(item.get('specifiers'));
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
}
|
|
3298
|
+
});
|
|
3299
|
+
},
|
|
3300
|
+
exit() {
|
|
3301
|
+
this.macroBuilder.expand();
|
|
3302
|
+
}
|
|
3303
|
+
},
|
|
3304
|
+
ExpressionStatement(path) {
|
|
3305
|
+
this.macroBuilder.build(path);
|
|
3306
|
+
}
|
|
3307
|
+
}
|
|
3308
|
+
};
|
|
3309
|
+
}
|
|
3310
|
+
src$1.default = macros;
|
|
3311
|
+
macros.baseDir = function () {
|
|
3312
|
+
return path_1.default.resolve(__dirname, '..', '..');
|
|
3313
|
+
};
|
|
3314
|
+
return src$1;
|
|
3315
|
+
}
|
|
3316
|
+
|
|
3317
|
+
var babelPluginDebugMacros;
|
|
3318
|
+
var hasRequiredBabelPluginDebugMacros;
|
|
3319
|
+
|
|
3320
|
+
function requireBabelPluginDebugMacros () {
|
|
3321
|
+
if (hasRequiredBabelPluginDebugMacros) return babelPluginDebugMacros;
|
|
3322
|
+
hasRequiredBabelPluginDebugMacros = 1;
|
|
3323
|
+
babelPluginDebugMacros = requireSrc().default;
|
|
3324
|
+
return babelPluginDebugMacros;
|
|
3325
|
+
}
|
|
3326
|
+
|
|
3327
|
+
var babelPluginDebugMacrosExports = requireBabelPluginDebugMacros();
|
|
3328
|
+
var index = /*@__PURE__*/getDefaultExportFromCjs(babelPluginDebugMacrosExports);
|
|
3329
|
+
|
|
3330
|
+
var index$1 = /*#__PURE__*/_mergeNamespaces({
|
|
3331
|
+
__proto__: null,
|
|
3332
|
+
default: index
|
|
3333
|
+
}, [babelPluginDebugMacrosExports]);
|
|
3334
|
+
|
|
3335
|
+
export { index$1 as i };
|
|
3336
|
+
//# sourceMappingURL=index-DxolpiGq.js.map
|