@socketsecurity/lib 3.3.1 → 3.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/agent.d.ts +0 -4
  3. package/dist/agent.js +3 -7
  4. package/dist/constants/packages.d.ts +7 -0
  5. package/dist/constants/packages.js +7 -0
  6. package/dist/dlx-package.js +27 -0
  7. package/dist/env/ci.d.ts +1 -0
  8. package/dist/env/ci.js +1 -0
  9. package/dist/env/debug.d.ts +1 -0
  10. package/dist/env/debug.js +1 -0
  11. package/dist/env/github.d.ts +8 -0
  12. package/dist/env/github.js +8 -0
  13. package/dist/env/helpers.d.ts +3 -0
  14. package/dist/env/helpers.js +3 -0
  15. package/dist/env/home.d.ts +1 -0
  16. package/dist/env/home.js +1 -0
  17. package/dist/env/locale.d.ts +3 -0
  18. package/dist/env/locale.js +3 -0
  19. package/dist/env/node-auth-token.d.ts +1 -0
  20. package/dist/env/node-auth-token.js +1 -0
  21. package/dist/env/node-env.d.ts +1 -0
  22. package/dist/env/node-env.js +1 -0
  23. package/dist/env/npm.d.ts +5 -0
  24. package/dist/env/npm.js +5 -0
  25. package/dist/env/package-manager.d.ts +3 -0
  26. package/dist/env/package-manager.js +5 -2
  27. package/dist/env/path.d.ts +1 -0
  28. package/dist/env/path.js +1 -0
  29. package/dist/env/pre-commit.d.ts +1 -0
  30. package/dist/env/pre-commit.js +1 -0
  31. package/dist/env/shell.d.ts +1 -0
  32. package/dist/env/shell.js +1 -0
  33. package/dist/env/socket-cli-shadow.d.ts +5 -0
  34. package/dist/env/socket-cli-shadow.js +5 -0
  35. package/dist/env/socket-cli.d.ts +14 -0
  36. package/dist/env/socket-cli.js +14 -0
  37. package/dist/env/socket.d.ts +15 -0
  38. package/dist/env/socket.js +15 -0
  39. package/dist/env/temp-dir.d.ts +3 -0
  40. package/dist/env/temp-dir.js +3 -0
  41. package/dist/env/term.d.ts +1 -0
  42. package/dist/env/term.js +1 -0
  43. package/dist/env/test.d.ts +3 -0
  44. package/dist/env/test.js +4 -1
  45. package/dist/env/windows.d.ts +4 -0
  46. package/dist/env/windows.js +4 -0
  47. package/dist/env/xdg.d.ts +3 -0
  48. package/dist/env/xdg.js +3 -0
  49. package/dist/external/@npmcli/arborist.js +5 -0
  50. package/dist/external/@yarnpkg/extensions.js +2 -2
  51. package/dist/external/cacache.js +4 -13036
  52. package/dist/external/libnpmpack.js +4 -67685
  53. package/dist/external/make-fetch-happen.js +4 -22639
  54. package/dist/external/normalize-package-data.js +4 -4478
  55. package/dist/external/npm-core.js +6588 -0
  56. package/dist/external/npm-pack.js +87518 -0
  57. package/dist/external/npm-package-arg.js +4 -4515
  58. package/dist/external/pacote.js +4 -50314
  59. package/dist/external/semver.js +4 -1934
  60. package/dist/fs.d.ts +0 -6
  61. package/dist/fs.js +0 -6
  62. package/dist/logger.d.ts +4 -0
  63. package/dist/logger.js +4 -1
  64. package/package.json +75 -73
@@ -1,4516 +1,5 @@
1
- "use strict";
2
- /**
3
- * Bundled from npm-package-arg
4
- * This is a zero-dependency bundle created by esbuild.
5
- */
6
- "use strict";
7
- var __defProp = Object.defineProperty;
8
- var __getOwnPropNames = Object.getOwnPropertyNames;
9
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
- var __commonJS = (cb, mod) => function __require() {
11
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
- };
1
+ 'use strict'
13
2
 
14
- // node_modules/.pnpm/lru-cache@11.2.2/node_modules/lru-cache/dist/commonjs/index.js
15
- var require_commonjs = __commonJS({
16
- "node_modules/.pnpm/lru-cache@11.2.2/node_modules/lru-cache/dist/commonjs/index.js"(exports2) {
17
- "use strict";
18
- Object.defineProperty(exports2, "__esModule", { value: true });
19
- exports2.LRUCache = void 0;
20
- var defaultPerf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
21
- var warned = /* @__PURE__ */ new Set();
22
- var PROCESS = typeof process === "object" && !!process ? process : {};
23
- var emitWarning = /* @__PURE__ */ __name((msg, type, code, fn) => {
24
- typeof PROCESS.emitWarning === "function" ? PROCESS.emitWarning(msg, type, code, fn) : void 0;
25
- }, "emitWarning");
26
- var AC = globalThis.AbortController;
27
- var AS = globalThis.AbortSignal;
28
- if (typeof AC === "undefined") {
29
- AS = class AbortSignal {
30
- static {
31
- __name(this, "AbortSignal");
32
- }
33
- onabort;
34
- _onabort = [];
35
- reason;
36
- aborted = false;
37
- addEventListener(_, fn) {
38
- this._onabort.push(fn);
39
- }
40
- };
41
- AC = class AbortController {
42
- static {
43
- __name(this, "AbortController");
44
- }
45
- constructor() {
46
- warnACPolyfill();
47
- }
48
- signal = new AS();
49
- abort(reason) {
50
- if (this.signal.aborted)
51
- return;
52
- this.signal.reason = reason;
53
- this.signal.aborted = true;
54
- for (const fn of this.signal._onabort) {
55
- fn(reason);
56
- }
57
- this.signal.onabort?.(reason);
58
- }
59
- };
60
- let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1";
61
- const warnACPolyfill = /* @__PURE__ */ __name(() => {
62
- if (!printACPolyfillWarning)
63
- return;
64
- printACPolyfillWarning = false;
65
- emitWarning("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", warnACPolyfill);
66
- }, "warnACPolyfill");
67
- }
68
- var shouldWarn = /* @__PURE__ */ __name((code) => !warned.has(code), "shouldWarn");
69
- var TYPE = Symbol("type");
70
- var isPosInt = /* @__PURE__ */ __name((n) => n && n === Math.floor(n) && n > 0 && isFinite(n), "isPosInt");
71
- var getUintArray = /* @__PURE__ */ __name((max) => !isPosInt(max) ? null : max <= Math.pow(2, 8) ? Uint8Array : max <= Math.pow(2, 16) ? Uint16Array : max <= Math.pow(2, 32) ? Uint32Array : max <= Number.MAX_SAFE_INTEGER ? ZeroArray : null, "getUintArray");
72
- var ZeroArray = class extends Array {
73
- static {
74
- __name(this, "ZeroArray");
75
- }
76
- constructor(size) {
77
- super(size);
78
- this.fill(0);
79
- }
80
- };
81
- var Stack = class _Stack {
82
- static {
83
- __name(this, "Stack");
84
- }
85
- heap;
86
- length;
87
- // private constructor
88
- static #constructing = false;
89
- static create(max) {
90
- const HeapCls = getUintArray(max);
91
- if (!HeapCls)
92
- return [];
93
- _Stack.#constructing = true;
94
- const s = new _Stack(max, HeapCls);
95
- _Stack.#constructing = false;
96
- return s;
97
- }
98
- constructor(max, HeapCls) {
99
- if (!_Stack.#constructing) {
100
- throw new TypeError("instantiate Stack using Stack.create(n)");
101
- }
102
- this.heap = new HeapCls(max);
103
- this.length = 0;
104
- }
105
- push(n) {
106
- this.heap[this.length++] = n;
107
- }
108
- pop() {
109
- return this.heap[--this.length];
110
- }
111
- };
112
- var LRUCache = class _LRUCache {
113
- static {
114
- __name(this, "LRUCache");
115
- }
116
- // options that cannot be changed without disaster
117
- #max;
118
- #maxSize;
119
- #dispose;
120
- #onInsert;
121
- #disposeAfter;
122
- #fetchMethod;
123
- #memoMethod;
124
- #perf;
125
- /**
126
- * {@link LRUCache.OptionsBase.perf}
127
- */
128
- get perf() {
129
- return this.#perf;
130
- }
131
- /**
132
- * {@link LRUCache.OptionsBase.ttl}
133
- */
134
- ttl;
135
- /**
136
- * {@link LRUCache.OptionsBase.ttlResolution}
137
- */
138
- ttlResolution;
139
- /**
140
- * {@link LRUCache.OptionsBase.ttlAutopurge}
141
- */
142
- ttlAutopurge;
143
- /**
144
- * {@link LRUCache.OptionsBase.updateAgeOnGet}
145
- */
146
- updateAgeOnGet;
147
- /**
148
- * {@link LRUCache.OptionsBase.updateAgeOnHas}
149
- */
150
- updateAgeOnHas;
151
- /**
152
- * {@link LRUCache.OptionsBase.allowStale}
153
- */
154
- allowStale;
155
- /**
156
- * {@link LRUCache.OptionsBase.noDisposeOnSet}
157
- */
158
- noDisposeOnSet;
159
- /**
160
- * {@link LRUCache.OptionsBase.noUpdateTTL}
161
- */
162
- noUpdateTTL;
163
- /**
164
- * {@link LRUCache.OptionsBase.maxEntrySize}
165
- */
166
- maxEntrySize;
167
- /**
168
- * {@link LRUCache.OptionsBase.sizeCalculation}
169
- */
170
- sizeCalculation;
171
- /**
172
- * {@link LRUCache.OptionsBase.noDeleteOnFetchRejection}
173
- */
174
- noDeleteOnFetchRejection;
175
- /**
176
- * {@link LRUCache.OptionsBase.noDeleteOnStaleGet}
177
- */
178
- noDeleteOnStaleGet;
179
- /**
180
- * {@link LRUCache.OptionsBase.allowStaleOnFetchAbort}
181
- */
182
- allowStaleOnFetchAbort;
183
- /**
184
- * {@link LRUCache.OptionsBase.allowStaleOnFetchRejection}
185
- */
186
- allowStaleOnFetchRejection;
187
- /**
188
- * {@link LRUCache.OptionsBase.ignoreFetchAbort}
189
- */
190
- ignoreFetchAbort;
191
- // computed properties
192
- #size;
193
- #calculatedSize;
194
- #keyMap;
195
- #keyList;
196
- #valList;
197
- #next;
198
- #prev;
199
- #head;
200
- #tail;
201
- #free;
202
- #disposed;
203
- #sizes;
204
- #starts;
205
- #ttls;
206
- #hasDispose;
207
- #hasFetchMethod;
208
- #hasDisposeAfter;
209
- #hasOnInsert;
210
- /**
211
- * Do not call this method unless you need to inspect the
212
- * inner workings of the cache. If anything returned by this
213
- * object is modified in any way, strange breakage may occur.
214
- *
215
- * These fields are private for a reason!
216
- *
217
- * @internal
218
- */
219
- static unsafeExposeInternals(c) {
220
- return {
221
- // properties
222
- starts: c.#starts,
223
- ttls: c.#ttls,
224
- sizes: c.#sizes,
225
- keyMap: c.#keyMap,
226
- keyList: c.#keyList,
227
- valList: c.#valList,
228
- next: c.#next,
229
- prev: c.#prev,
230
- get head() {
231
- return c.#head;
232
- },
233
- get tail() {
234
- return c.#tail;
235
- },
236
- free: c.#free,
237
- // methods
238
- isBackgroundFetch: /* @__PURE__ */ __name((p) => c.#isBackgroundFetch(p), "isBackgroundFetch"),
239
- backgroundFetch: /* @__PURE__ */ __name((k, index, options, context) => c.#backgroundFetch(k, index, options, context), "backgroundFetch"),
240
- moveToTail: /* @__PURE__ */ __name((index) => c.#moveToTail(index), "moveToTail"),
241
- indexes: /* @__PURE__ */ __name((options) => c.#indexes(options), "indexes"),
242
- rindexes: /* @__PURE__ */ __name((options) => c.#rindexes(options), "rindexes"),
243
- isStale: /* @__PURE__ */ __name((index) => c.#isStale(index), "isStale")
244
- };
245
- }
246
- // Protected read-only members
247
- /**
248
- * {@link LRUCache.OptionsBase.max} (read-only)
249
- */
250
- get max() {
251
- return this.#max;
252
- }
253
- /**
254
- * {@link LRUCache.OptionsBase.maxSize} (read-only)
255
- */
256
- get maxSize() {
257
- return this.#maxSize;
258
- }
259
- /**
260
- * The total computed size of items in the cache (read-only)
261
- */
262
- get calculatedSize() {
263
- return this.#calculatedSize;
264
- }
265
- /**
266
- * The number of items stored in the cache (read-only)
267
- */
268
- get size() {
269
- return this.#size;
270
- }
271
- /**
272
- * {@link LRUCache.OptionsBase.fetchMethod} (read-only)
273
- */
274
- get fetchMethod() {
275
- return this.#fetchMethod;
276
- }
277
- get memoMethod() {
278
- return this.#memoMethod;
279
- }
280
- /**
281
- * {@link LRUCache.OptionsBase.dispose} (read-only)
282
- */
283
- get dispose() {
284
- return this.#dispose;
285
- }
286
- /**
287
- * {@link LRUCache.OptionsBase.onInsert} (read-only)
288
- */
289
- get onInsert() {
290
- return this.#onInsert;
291
- }
292
- /**
293
- * {@link LRUCache.OptionsBase.disposeAfter} (read-only)
294
- */
295
- get disposeAfter() {
296
- return this.#disposeAfter;
297
- }
298
- constructor(options) {
299
- const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, onInsert, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, perf } = options;
300
- if (perf !== void 0) {
301
- if (typeof perf?.now !== "function") {
302
- throw new TypeError("perf option must have a now() method if specified");
303
- }
304
- }
305
- this.#perf = perf ?? defaultPerf;
306
- if (max !== 0 && !isPosInt(max)) {
307
- throw new TypeError("max option must be a nonnegative integer");
308
- }
309
- const UintArray = max ? getUintArray(max) : Array;
310
- if (!UintArray) {
311
- throw new Error("invalid max value: " + max);
312
- }
313
- this.#max = max;
314
- this.#maxSize = maxSize;
315
- this.maxEntrySize = maxEntrySize || this.#maxSize;
316
- this.sizeCalculation = sizeCalculation;
317
- if (this.sizeCalculation) {
318
- if (!this.#maxSize && !this.maxEntrySize) {
319
- throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
320
- }
321
- if (typeof this.sizeCalculation !== "function") {
322
- throw new TypeError("sizeCalculation set to non-function");
323
- }
324
- }
325
- if (memoMethod !== void 0 && typeof memoMethod !== "function") {
326
- throw new TypeError("memoMethod must be a function if defined");
327
- }
328
- this.#memoMethod = memoMethod;
329
- if (fetchMethod !== void 0 && typeof fetchMethod !== "function") {
330
- throw new TypeError("fetchMethod must be a function if specified");
331
- }
332
- this.#fetchMethod = fetchMethod;
333
- this.#hasFetchMethod = !!fetchMethod;
334
- this.#keyMap = /* @__PURE__ */ new Map();
335
- this.#keyList = new Array(max).fill(void 0);
336
- this.#valList = new Array(max).fill(void 0);
337
- this.#next = new UintArray(max);
338
- this.#prev = new UintArray(max);
339
- this.#head = 0;
340
- this.#tail = 0;
341
- this.#free = Stack.create(max);
342
- this.#size = 0;
343
- this.#calculatedSize = 0;
344
- if (typeof dispose === "function") {
345
- this.#dispose = dispose;
346
- }
347
- if (typeof onInsert === "function") {
348
- this.#onInsert = onInsert;
349
- }
350
- if (typeof disposeAfter === "function") {
351
- this.#disposeAfter = disposeAfter;
352
- this.#disposed = [];
353
- } else {
354
- this.#disposeAfter = void 0;
355
- this.#disposed = void 0;
356
- }
357
- this.#hasDispose = !!this.#dispose;
358
- this.#hasOnInsert = !!this.#onInsert;
359
- this.#hasDisposeAfter = !!this.#disposeAfter;
360
- this.noDisposeOnSet = !!noDisposeOnSet;
361
- this.noUpdateTTL = !!noUpdateTTL;
362
- this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection;
363
- this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection;
364
- this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort;
365
- this.ignoreFetchAbort = !!ignoreFetchAbort;
366
- if (this.maxEntrySize !== 0) {
367
- if (this.#maxSize !== 0) {
368
- if (!isPosInt(this.#maxSize)) {
369
- throw new TypeError("maxSize must be a positive integer if specified");
370
- }
371
- }
372
- if (!isPosInt(this.maxEntrySize)) {
373
- throw new TypeError("maxEntrySize must be a positive integer if specified");
374
- }
375
- this.#initializeSizeTracking();
376
- }
377
- this.allowStale = !!allowStale;
378
- this.noDeleteOnStaleGet = !!noDeleteOnStaleGet;
379
- this.updateAgeOnGet = !!updateAgeOnGet;
380
- this.updateAgeOnHas = !!updateAgeOnHas;
381
- this.ttlResolution = isPosInt(ttlResolution) || ttlResolution === 0 ? ttlResolution : 1;
382
- this.ttlAutopurge = !!ttlAutopurge;
383
- this.ttl = ttl || 0;
384
- if (this.ttl) {
385
- if (!isPosInt(this.ttl)) {
386
- throw new TypeError("ttl must be a positive integer if specified");
387
- }
388
- this.#initializeTTLTracking();
389
- }
390
- if (this.#max === 0 && this.ttl === 0 && this.#maxSize === 0) {
391
- throw new TypeError("At least one of max, maxSize, or ttl is required");
392
- }
393
- if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
394
- const code = "LRU_CACHE_UNBOUNDED";
395
- if (shouldWarn(code)) {
396
- warned.add(code);
397
- const msg = "TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.";
398
- emitWarning(msg, "UnboundedCacheWarning", code, _LRUCache);
399
- }
400
- }
401
- }
402
- /**
403
- * Return the number of ms left in the item's TTL. If item is not in cache,
404
- * returns `0`. Returns `Infinity` if item is in cache without a defined TTL.
405
- */
406
- getRemainingTTL(key) {
407
- return this.#keyMap.has(key) ? Infinity : 0;
408
- }
409
- #initializeTTLTracking() {
410
- const ttls = new ZeroArray(this.#max);
411
- const starts = new ZeroArray(this.#max);
412
- this.#ttls = ttls;
413
- this.#starts = starts;
414
- this.#setItemTTL = (index, ttl, start = this.#perf.now()) => {
415
- starts[index] = ttl !== 0 ? start : 0;
416
- ttls[index] = ttl;
417
- if (ttl !== 0 && this.ttlAutopurge) {
418
- const t = setTimeout(() => {
419
- if (this.#isStale(index)) {
420
- this.#delete(this.#keyList[index], "expire");
421
- }
422
- }, ttl + 1);
423
- if (t.unref) {
424
- t.unref();
425
- }
426
- }
427
- };
428
- this.#updateItemAge = (index) => {
429
- starts[index] = ttls[index] !== 0 ? this.#perf.now() : 0;
430
- };
431
- this.#statusTTL = (status, index) => {
432
- if (ttls[index]) {
433
- const ttl = ttls[index];
434
- const start = starts[index];
435
- if (!ttl || !start)
436
- return;
437
- status.ttl = ttl;
438
- status.start = start;
439
- status.now = cachedNow || getNow();
440
- const age = status.now - start;
441
- status.remainingTTL = ttl - age;
442
- }
443
- };
444
- let cachedNow = 0;
445
- const getNow = /* @__PURE__ */ __name(() => {
446
- const n = this.#perf.now();
447
- if (this.ttlResolution > 0) {
448
- cachedNow = n;
449
- const t = setTimeout(() => cachedNow = 0, this.ttlResolution);
450
- if (t.unref) {
451
- t.unref();
452
- }
453
- }
454
- return n;
455
- }, "getNow");
456
- this.getRemainingTTL = (key) => {
457
- const index = this.#keyMap.get(key);
458
- if (index === void 0) {
459
- return 0;
460
- }
461
- const ttl = ttls[index];
462
- const start = starts[index];
463
- if (!ttl || !start) {
464
- return Infinity;
465
- }
466
- const age = (cachedNow || getNow()) - start;
467
- return ttl - age;
468
- };
469
- this.#isStale = (index) => {
470
- const s = starts[index];
471
- const t = ttls[index];
472
- return !!t && !!s && (cachedNow || getNow()) - s > t;
473
- };
474
- }
475
- // conditionally set private methods related to TTL
476
- #updateItemAge = /* @__PURE__ */ __name(() => {
477
- }, "#updateItemAge");
478
- #statusTTL = /* @__PURE__ */ __name(() => {
479
- }, "#statusTTL");
480
- #setItemTTL = /* @__PURE__ */ __name(() => {
481
- }, "#setItemTTL");
482
- /* c8 ignore stop */
483
- #isStale = /* @__PURE__ */ __name(() => false, "#isStale");
484
- #initializeSizeTracking() {
485
- const sizes = new ZeroArray(this.#max);
486
- this.#calculatedSize = 0;
487
- this.#sizes = sizes;
488
- this.#removeItemSize = (index) => {
489
- this.#calculatedSize -= sizes[index];
490
- sizes[index] = 0;
491
- };
492
- this.#requireSize = (k, v, size, sizeCalculation) => {
493
- if (this.#isBackgroundFetch(v)) {
494
- return 0;
495
- }
496
- if (!isPosInt(size)) {
497
- if (sizeCalculation) {
498
- if (typeof sizeCalculation !== "function") {
499
- throw new TypeError("sizeCalculation must be a function");
500
- }
501
- size = sizeCalculation(v, k);
502
- if (!isPosInt(size)) {
503
- throw new TypeError("sizeCalculation return invalid (expect positive integer)");
504
- }
505
- } else {
506
- throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
507
- }
508
- }
509
- return size;
510
- };
511
- this.#addItemSize = (index, size, status) => {
512
- sizes[index] = size;
513
- if (this.#maxSize) {
514
- const maxSize = this.#maxSize - sizes[index];
515
- while (this.#calculatedSize > maxSize) {
516
- this.#evict(true);
517
- }
518
- }
519
- this.#calculatedSize += sizes[index];
520
- if (status) {
521
- status.entrySize = size;
522
- status.totalCalculatedSize = this.#calculatedSize;
523
- }
524
- };
525
- }
526
- #removeItemSize = /* @__PURE__ */ __name((_i) => {
527
- }, "#removeItemSize");
528
- #addItemSize = /* @__PURE__ */ __name((_i, _s, _st) => {
529
- }, "#addItemSize");
530
- #requireSize = /* @__PURE__ */ __name((_k, _v, size, sizeCalculation) => {
531
- if (size || sizeCalculation) {
532
- throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
533
- }
534
- return 0;
535
- }, "#requireSize");
536
- *#indexes({ allowStale = this.allowStale } = {}) {
537
- if (this.#size) {
538
- for (let i = this.#tail; true; ) {
539
- if (!this.#isValidIndex(i)) {
540
- break;
541
- }
542
- if (allowStale || !this.#isStale(i)) {
543
- yield i;
544
- }
545
- if (i === this.#head) {
546
- break;
547
- } else {
548
- i = this.#prev[i];
549
- }
550
- }
551
- }
552
- }
553
- *#rindexes({ allowStale = this.allowStale } = {}) {
554
- if (this.#size) {
555
- for (let i = this.#head; true; ) {
556
- if (!this.#isValidIndex(i)) {
557
- break;
558
- }
559
- if (allowStale || !this.#isStale(i)) {
560
- yield i;
561
- }
562
- if (i === this.#tail) {
563
- break;
564
- } else {
565
- i = this.#next[i];
566
- }
567
- }
568
- }
569
- }
570
- #isValidIndex(index) {
571
- return index !== void 0 && this.#keyMap.get(this.#keyList[index]) === index;
572
- }
573
- /**
574
- * Return a generator yielding `[key, value]` pairs,
575
- * in order from most recently used to least recently used.
576
- */
577
- *entries() {
578
- for (const i of this.#indexes()) {
579
- if (this.#valList[i] !== void 0 && this.#keyList[i] !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) {
580
- yield [this.#keyList[i], this.#valList[i]];
581
- }
582
- }
583
- }
584
- /**
585
- * Inverse order version of {@link LRUCache.entries}
586
- *
587
- * Return a generator yielding `[key, value]` pairs,
588
- * in order from least recently used to most recently used.
589
- */
590
- *rentries() {
591
- for (const i of this.#rindexes()) {
592
- if (this.#valList[i] !== void 0 && this.#keyList[i] !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) {
593
- yield [this.#keyList[i], this.#valList[i]];
594
- }
595
- }
596
- }
597
- /**
598
- * Return a generator yielding the keys in the cache,
599
- * in order from most recently used to least recently used.
600
- */
601
- *keys() {
602
- for (const i of this.#indexes()) {
603
- const k = this.#keyList[i];
604
- if (k !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) {
605
- yield k;
606
- }
607
- }
608
- }
609
- /**
610
- * Inverse order version of {@link LRUCache.keys}
611
- *
612
- * Return a generator yielding the keys in the cache,
613
- * in order from least recently used to most recently used.
614
- */
615
- *rkeys() {
616
- for (const i of this.#rindexes()) {
617
- const k = this.#keyList[i];
618
- if (k !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) {
619
- yield k;
620
- }
621
- }
622
- }
623
- /**
624
- * Return a generator yielding the values in the cache,
625
- * in order from most recently used to least recently used.
626
- */
627
- *values() {
628
- for (const i of this.#indexes()) {
629
- const v = this.#valList[i];
630
- if (v !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) {
631
- yield this.#valList[i];
632
- }
633
- }
634
- }
635
- /**
636
- * Inverse order version of {@link LRUCache.values}
637
- *
638
- * Return a generator yielding the values in the cache,
639
- * in order from least recently used to most recently used.
640
- */
641
- *rvalues() {
642
- for (const i of this.#rindexes()) {
643
- const v = this.#valList[i];
644
- if (v !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) {
645
- yield this.#valList[i];
646
- }
647
- }
648
- }
649
- /**
650
- * Iterating over the cache itself yields the same results as
651
- * {@link LRUCache.entries}
652
- */
653
- [Symbol.iterator]() {
654
- return this.entries();
655
- }
656
- /**
657
- * A String value that is used in the creation of the default string
658
- * description of an object. Called by the built-in method
659
- * `Object.prototype.toString`.
660
- */
661
- [Symbol.toStringTag] = "LRUCache";
662
- /**
663
- * Find a value for which the supplied fn method returns a truthy value,
664
- * similar to `Array.find()`. fn is called as `fn(value, key, cache)`.
665
- */
666
- find(fn, getOptions = {}) {
667
- for (const i of this.#indexes()) {
668
- const v = this.#valList[i];
669
- const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
670
- if (value === void 0)
671
- continue;
672
- if (fn(value, this.#keyList[i], this)) {
673
- return this.get(this.#keyList[i], getOptions);
674
- }
675
- }
676
- }
677
- /**
678
- * Call the supplied function on each item in the cache, in order from most
679
- * recently used to least recently used.
680
- *
681
- * `fn` is called as `fn(value, key, cache)`.
682
- *
683
- * If `thisp` is provided, function will be called in the `this`-context of
684
- * the provided object, or the cache if no `thisp` object is provided.
685
- *
686
- * Does not update age or recenty of use, or iterate over stale values.
687
- */
688
- forEach(fn, thisp = this) {
689
- for (const i of this.#indexes()) {
690
- const v = this.#valList[i];
691
- const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
692
- if (value === void 0)
693
- continue;
694
- fn.call(thisp, value, this.#keyList[i], this);
695
- }
696
- }
697
- /**
698
- * The same as {@link LRUCache.forEach} but items are iterated over in
699
- * reverse order. (ie, less recently used items are iterated over first.)
700
- */
701
- rforEach(fn, thisp = this) {
702
- for (const i of this.#rindexes()) {
703
- const v = this.#valList[i];
704
- const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
705
- if (value === void 0)
706
- continue;
707
- fn.call(thisp, value, this.#keyList[i], this);
708
- }
709
- }
710
- /**
711
- * Delete any stale entries. Returns true if anything was removed,
712
- * false otherwise.
713
- */
714
- purgeStale() {
715
- let deleted = false;
716
- for (const i of this.#rindexes({ allowStale: true })) {
717
- if (this.#isStale(i)) {
718
- this.#delete(this.#keyList[i], "expire");
719
- deleted = true;
720
- }
721
- }
722
- return deleted;
723
- }
724
- /**
725
- * Get the extended info about a given entry, to get its value, size, and
726
- * TTL info simultaneously. Returns `undefined` if the key is not present.
727
- *
728
- * Unlike {@link LRUCache#dump}, which is designed to be portable and survive
729
- * serialization, the `start` value is always the current timestamp, and the
730
- * `ttl` is a calculated remaining time to live (negative if expired).
731
- *
732
- * Always returns stale values, if their info is found in the cache, so be
733
- * sure to check for expirations (ie, a negative {@link LRUCache.Entry#ttl})
734
- * if relevant.
735
- */
736
- info(key) {
737
- const i = this.#keyMap.get(key);
738
- if (i === void 0)
739
- return void 0;
740
- const v = this.#valList[i];
741
- const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
742
- if (value === void 0)
743
- return void 0;
744
- const entry = { value };
745
- if (this.#ttls && this.#starts) {
746
- const ttl = this.#ttls[i];
747
- const start = this.#starts[i];
748
- if (ttl && start) {
749
- const remain = ttl - (this.#perf.now() - start);
750
- entry.ttl = remain;
751
- entry.start = Date.now();
752
- }
753
- }
754
- if (this.#sizes) {
755
- entry.size = this.#sizes[i];
756
- }
757
- return entry;
758
- }
759
- /**
760
- * Return an array of [key, {@link LRUCache.Entry}] tuples which can be
761
- * passed to {@link LRUCache#load}.
762
- *
763
- * The `start` fields are calculated relative to a portable `Date.now()`
764
- * timestamp, even if `performance.now()` is available.
765
- *
766
- * Stale entries are always included in the `dump`, even if
767
- * {@link LRUCache.OptionsBase.allowStale} is false.
768
- *
769
- * Note: this returns an actual array, not a generator, so it can be more
770
- * easily passed around.
771
- */
772
- dump() {
773
- const arr = [];
774
- for (const i of this.#indexes({ allowStale: true })) {
775
- const key = this.#keyList[i];
776
- const v = this.#valList[i];
777
- const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
778
- if (value === void 0 || key === void 0)
779
- continue;
780
- const entry = { value };
781
- if (this.#ttls && this.#starts) {
782
- entry.ttl = this.#ttls[i];
783
- const age = this.#perf.now() - this.#starts[i];
784
- entry.start = Math.floor(Date.now() - age);
785
- }
786
- if (this.#sizes) {
787
- entry.size = this.#sizes[i];
788
- }
789
- arr.unshift([key, entry]);
790
- }
791
- return arr;
792
- }
793
- /**
794
- * Reset the cache and load in the items in entries in the order listed.
795
- *
796
- * The shape of the resulting cache may be different if the same options are
797
- * not used in both caches.
798
- *
799
- * The `start` fields are assumed to be calculated relative to a portable
800
- * `Date.now()` timestamp, even if `performance.now()` is available.
801
- */
802
- load(arr) {
803
- this.clear();
804
- for (const [key, entry] of arr) {
805
- if (entry.start) {
806
- const age = Date.now() - entry.start;
807
- entry.start = this.#perf.now() - age;
808
- }
809
- this.set(key, entry.value, entry);
810
- }
811
- }
812
- /**
813
- * Add a value to the cache.
814
- *
815
- * Note: if `undefined` is specified as a value, this is an alias for
816
- * {@link LRUCache#delete}
817
- *
818
- * Fields on the {@link LRUCache.SetOptions} options param will override
819
- * their corresponding values in the constructor options for the scope
820
- * of this single `set()` operation.
821
- *
822
- * If `start` is provided, then that will set the effective start
823
- * time for the TTL calculation. Note that this must be a previous
824
- * value of `performance.now()` if supported, or a previous value of
825
- * `Date.now()` if not.
826
- *
827
- * Options object may also include `size`, which will prevent
828
- * calling the `sizeCalculation` function and just use the specified
829
- * number if it is a positive integer, and `noDisposeOnSet` which
830
- * will prevent calling a `dispose` function in the case of
831
- * overwrites.
832
- *
833
- * If the `size` (or return value of `sizeCalculation`) for a given
834
- * entry is greater than `maxEntrySize`, then the item will not be
835
- * added to the cache.
836
- *
837
- * Will update the recency of the entry.
838
- *
839
- * If the value is `undefined`, then this is an alias for
840
- * `cache.delete(key)`. `undefined` is never stored in the cache.
841
- */
842
- set(k, v, setOptions = {}) {
843
- if (v === void 0) {
844
- this.delete(k);
845
- return this;
846
- }
847
- const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status } = setOptions;
848
- let { noUpdateTTL = this.noUpdateTTL } = setOptions;
849
- const size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation);
850
- if (this.maxEntrySize && size > this.maxEntrySize) {
851
- if (status) {
852
- status.set = "miss";
853
- status.maxEntrySizeExceeded = true;
854
- }
855
- this.#delete(k, "set");
856
- return this;
857
- }
858
- let index = this.#size === 0 ? void 0 : this.#keyMap.get(k);
859
- if (index === void 0) {
860
- index = this.#size === 0 ? this.#tail : this.#free.length !== 0 ? this.#free.pop() : this.#size === this.#max ? this.#evict(false) : this.#size;
861
- this.#keyList[index] = k;
862
- this.#valList[index] = v;
863
- this.#keyMap.set(k, index);
864
- this.#next[this.#tail] = index;
865
- this.#prev[index] = this.#tail;
866
- this.#tail = index;
867
- this.#size++;
868
- this.#addItemSize(index, size, status);
869
- if (status)
870
- status.set = "add";
871
- noUpdateTTL = false;
872
- if (this.#hasOnInsert) {
873
- this.#onInsert?.(v, k, "add");
874
- }
875
- } else {
876
- this.#moveToTail(index);
877
- const oldVal = this.#valList[index];
878
- if (v !== oldVal) {
879
- if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) {
880
- oldVal.__abortController.abort(new Error("replaced"));
881
- const { __staleWhileFetching: s } = oldVal;
882
- if (s !== void 0 && !noDisposeOnSet) {
883
- if (this.#hasDispose) {
884
- this.#dispose?.(s, k, "set");
885
- }
886
- if (this.#hasDisposeAfter) {
887
- this.#disposed?.push([s, k, "set"]);
888
- }
889
- }
890
- } else if (!noDisposeOnSet) {
891
- if (this.#hasDispose) {
892
- this.#dispose?.(oldVal, k, "set");
893
- }
894
- if (this.#hasDisposeAfter) {
895
- this.#disposed?.push([oldVal, k, "set"]);
896
- }
897
- }
898
- this.#removeItemSize(index);
899
- this.#addItemSize(index, size, status);
900
- this.#valList[index] = v;
901
- if (status) {
902
- status.set = "replace";
903
- const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ? oldVal.__staleWhileFetching : oldVal;
904
- if (oldValue !== void 0)
905
- status.oldValue = oldValue;
906
- }
907
- } else if (status) {
908
- status.set = "update";
909
- }
910
- if (this.#hasOnInsert) {
911
- this.onInsert?.(v, k, v === oldVal ? "update" : "replace");
912
- }
913
- }
914
- if (ttl !== 0 && !this.#ttls) {
915
- this.#initializeTTLTracking();
916
- }
917
- if (this.#ttls) {
918
- if (!noUpdateTTL) {
919
- this.#setItemTTL(index, ttl, start);
920
- }
921
- if (status)
922
- this.#statusTTL(status, index);
923
- }
924
- if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
925
- const dt = this.#disposed;
926
- let task;
927
- while (task = dt?.shift()) {
928
- this.#disposeAfter?.(...task);
929
- }
930
- }
931
- return this;
932
- }
933
- /**
934
- * Evict the least recently used item, returning its value or
935
- * `undefined` if cache is empty.
936
- */
937
- pop() {
938
- try {
939
- while (this.#size) {
940
- const val = this.#valList[this.#head];
941
- this.#evict(true);
942
- if (this.#isBackgroundFetch(val)) {
943
- if (val.__staleWhileFetching) {
944
- return val.__staleWhileFetching;
945
- }
946
- } else if (val !== void 0) {
947
- return val;
948
- }
949
- }
950
- } finally {
951
- if (this.#hasDisposeAfter && this.#disposed) {
952
- const dt = this.#disposed;
953
- let task;
954
- while (task = dt?.shift()) {
955
- this.#disposeAfter?.(...task);
956
- }
957
- }
958
- }
959
- }
960
- #evict(free) {
961
- const head = this.#head;
962
- const k = this.#keyList[head];
963
- const v = this.#valList[head];
964
- if (this.#hasFetchMethod && this.#isBackgroundFetch(v)) {
965
- v.__abortController.abort(new Error("evicted"));
966
- } else if (this.#hasDispose || this.#hasDisposeAfter) {
967
- if (this.#hasDispose) {
968
- this.#dispose?.(v, k, "evict");
969
- }
970
- if (this.#hasDisposeAfter) {
971
- this.#disposed?.push([v, k, "evict"]);
972
- }
973
- }
974
- this.#removeItemSize(head);
975
- if (free) {
976
- this.#keyList[head] = void 0;
977
- this.#valList[head] = void 0;
978
- this.#free.push(head);
979
- }
980
- if (this.#size === 1) {
981
- this.#head = this.#tail = 0;
982
- this.#free.length = 0;
983
- } else {
984
- this.#head = this.#next[head];
985
- }
986
- this.#keyMap.delete(k);
987
- this.#size--;
988
- return head;
989
- }
990
- /**
991
- * Check if a key is in the cache, without updating the recency of use.
992
- * Will return false if the item is stale, even though it is technically
993
- * in the cache.
994
- *
995
- * Check if a key is in the cache, without updating the recency of
996
- * use. Age is updated if {@link LRUCache.OptionsBase.updateAgeOnHas} is set
997
- * to `true` in either the options or the constructor.
998
- *
999
- * Will return `false` if the item is stale, even though it is technically in
1000
- * the cache. The difference can be determined (if it matters) by using a
1001
- * `status` argument, and inspecting the `has` field.
1002
- *
1003
- * Will not update item age unless
1004
- * {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
1005
- */
1006
- has(k, hasOptions = {}) {
1007
- const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
1008
- const index = this.#keyMap.get(k);
1009
- if (index !== void 0) {
1010
- const v = this.#valList[index];
1011
- if (this.#isBackgroundFetch(v) && v.__staleWhileFetching === void 0) {
1012
- return false;
1013
- }
1014
- if (!this.#isStale(index)) {
1015
- if (updateAgeOnHas) {
1016
- this.#updateItemAge(index);
1017
- }
1018
- if (status) {
1019
- status.has = "hit";
1020
- this.#statusTTL(status, index);
1021
- }
1022
- return true;
1023
- } else if (status) {
1024
- status.has = "stale";
1025
- this.#statusTTL(status, index);
1026
- }
1027
- } else if (status) {
1028
- status.has = "miss";
1029
- }
1030
- return false;
1031
- }
1032
- /**
1033
- * Like {@link LRUCache#get} but doesn't update recency or delete stale
1034
- * items.
1035
- *
1036
- * Returns `undefined` if the item is stale, unless
1037
- * {@link LRUCache.OptionsBase.allowStale} is set.
1038
- */
1039
- peek(k, peekOptions = {}) {
1040
- const { allowStale = this.allowStale } = peekOptions;
1041
- const index = this.#keyMap.get(k);
1042
- if (index === void 0 || !allowStale && this.#isStale(index)) {
1043
- return;
1044
- }
1045
- const v = this.#valList[index];
1046
- return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
1047
- }
1048
- #backgroundFetch(k, index, options, context) {
1049
- const v = index === void 0 ? void 0 : this.#valList[index];
1050
- if (this.#isBackgroundFetch(v)) {
1051
- return v;
1052
- }
1053
- const ac = new AC();
1054
- const { signal } = options;
1055
- signal?.addEventListener("abort", () => ac.abort(signal.reason), {
1056
- signal: ac.signal
1057
- });
1058
- const fetchOpts = {
1059
- signal: ac.signal,
1060
- options,
1061
- context
1062
- };
1063
- const cb = /* @__PURE__ */ __name((v2, updateCache = false) => {
1064
- const { aborted } = ac.signal;
1065
- const ignoreAbort = options.ignoreFetchAbort && v2 !== void 0;
1066
- if (options.status) {
1067
- if (aborted && !updateCache) {
1068
- options.status.fetchAborted = true;
1069
- options.status.fetchError = ac.signal.reason;
1070
- if (ignoreAbort)
1071
- options.status.fetchAbortIgnored = true;
1072
- } else {
1073
- options.status.fetchResolved = true;
1074
- }
1075
- }
1076
- if (aborted && !ignoreAbort && !updateCache) {
1077
- return fetchFail(ac.signal.reason);
1078
- }
1079
- const bf2 = p;
1080
- const vl = this.#valList[index];
1081
- if (vl === p || ignoreAbort && updateCache && vl === void 0) {
1082
- if (v2 === void 0) {
1083
- if (bf2.__staleWhileFetching !== void 0) {
1084
- this.#valList[index] = bf2.__staleWhileFetching;
1085
- } else {
1086
- this.#delete(k, "fetch");
1087
- }
1088
- } else {
1089
- if (options.status)
1090
- options.status.fetchUpdated = true;
1091
- this.set(k, v2, fetchOpts.options);
1092
- }
1093
- }
1094
- return v2;
1095
- }, "cb");
1096
- const eb = /* @__PURE__ */ __name((er) => {
1097
- if (options.status) {
1098
- options.status.fetchRejected = true;
1099
- options.status.fetchError = er;
1100
- }
1101
- return fetchFail(er);
1102
- }, "eb");
1103
- const fetchFail = /* @__PURE__ */ __name((er) => {
1104
- const { aborted } = ac.signal;
1105
- const allowStaleAborted = aborted && options.allowStaleOnFetchAbort;
1106
- const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
1107
- const noDelete = allowStale || options.noDeleteOnFetchRejection;
1108
- const bf2 = p;
1109
- if (this.#valList[index] === p) {
1110
- const del = !noDelete || bf2.__staleWhileFetching === void 0;
1111
- if (del) {
1112
- this.#delete(k, "fetch");
1113
- } else if (!allowStaleAborted) {
1114
- this.#valList[index] = bf2.__staleWhileFetching;
1115
- }
1116
- }
1117
- if (allowStale) {
1118
- if (options.status && bf2.__staleWhileFetching !== void 0) {
1119
- options.status.returnedStale = true;
1120
- }
1121
- return bf2.__staleWhileFetching;
1122
- } else if (bf2.__returned === bf2) {
1123
- throw er;
1124
- }
1125
- }, "fetchFail");
1126
- const pcall = /* @__PURE__ */ __name((res, rej) => {
1127
- const fmp = this.#fetchMethod?.(k, v, fetchOpts);
1128
- if (fmp && fmp instanceof Promise) {
1129
- fmp.then((v2) => res(v2 === void 0 ? void 0 : v2), rej);
1130
- }
1131
- ac.signal.addEventListener("abort", () => {
1132
- if (!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) {
1133
- res(void 0);
1134
- if (options.allowStaleOnFetchAbort) {
1135
- res = /* @__PURE__ */ __name((v2) => cb(v2, true), "res");
1136
- }
1137
- }
1138
- });
1139
- }, "pcall");
1140
- if (options.status)
1141
- options.status.fetchDispatched = true;
1142
- const p = new Promise(pcall).then(cb, eb);
1143
- const bf = Object.assign(p, {
1144
- __abortController: ac,
1145
- __staleWhileFetching: v,
1146
- __returned: void 0
1147
- });
1148
- if (index === void 0) {
1149
- this.set(k, bf, { ...fetchOpts.options, status: void 0 });
1150
- index = this.#keyMap.get(k);
1151
- } else {
1152
- this.#valList[index] = bf;
1153
- }
1154
- return bf;
1155
- }
1156
- #isBackgroundFetch(p) {
1157
- if (!this.#hasFetchMethod)
1158
- return false;
1159
- const b = p;
1160
- return !!b && b instanceof Promise && b.hasOwnProperty("__staleWhileFetching") && b.__abortController instanceof AC;
1161
- }
1162
- async fetch(k, fetchOptions = {}) {
1163
- const {
1164
- // get options
1165
- allowStale = this.allowStale,
1166
- updateAgeOnGet = this.updateAgeOnGet,
1167
- noDeleteOnStaleGet = this.noDeleteOnStaleGet,
1168
- // set options
1169
- ttl = this.ttl,
1170
- noDisposeOnSet = this.noDisposeOnSet,
1171
- size = 0,
1172
- sizeCalculation = this.sizeCalculation,
1173
- noUpdateTTL = this.noUpdateTTL,
1174
- // fetch exclusive options
1175
- noDeleteOnFetchRejection = this.noDeleteOnFetchRejection,
1176
- allowStaleOnFetchRejection = this.allowStaleOnFetchRejection,
1177
- ignoreFetchAbort = this.ignoreFetchAbort,
1178
- allowStaleOnFetchAbort = this.allowStaleOnFetchAbort,
1179
- context,
1180
- forceRefresh = false,
1181
- status,
1182
- signal
1183
- } = fetchOptions;
1184
- if (!this.#hasFetchMethod) {
1185
- if (status)
1186
- status.fetch = "get";
1187
- return this.get(k, {
1188
- allowStale,
1189
- updateAgeOnGet,
1190
- noDeleteOnStaleGet,
1191
- status
1192
- });
1193
- }
1194
- const options = {
1195
- allowStale,
1196
- updateAgeOnGet,
1197
- noDeleteOnStaleGet,
1198
- ttl,
1199
- noDisposeOnSet,
1200
- size,
1201
- sizeCalculation,
1202
- noUpdateTTL,
1203
- noDeleteOnFetchRejection,
1204
- allowStaleOnFetchRejection,
1205
- allowStaleOnFetchAbort,
1206
- ignoreFetchAbort,
1207
- status,
1208
- signal
1209
- };
1210
- let index = this.#keyMap.get(k);
1211
- if (index === void 0) {
1212
- if (status)
1213
- status.fetch = "miss";
1214
- const p = this.#backgroundFetch(k, index, options, context);
1215
- return p.__returned = p;
1216
- } else {
1217
- const v = this.#valList[index];
1218
- if (this.#isBackgroundFetch(v)) {
1219
- const stale = allowStale && v.__staleWhileFetching !== void 0;
1220
- if (status) {
1221
- status.fetch = "inflight";
1222
- if (stale)
1223
- status.returnedStale = true;
1224
- }
1225
- return stale ? v.__staleWhileFetching : v.__returned = v;
1226
- }
1227
- const isStale = this.#isStale(index);
1228
- if (!forceRefresh && !isStale) {
1229
- if (status)
1230
- status.fetch = "hit";
1231
- this.#moveToTail(index);
1232
- if (updateAgeOnGet) {
1233
- this.#updateItemAge(index);
1234
- }
1235
- if (status)
1236
- this.#statusTTL(status, index);
1237
- return v;
1238
- }
1239
- const p = this.#backgroundFetch(k, index, options, context);
1240
- const hasStale = p.__staleWhileFetching !== void 0;
1241
- const staleVal = hasStale && allowStale;
1242
- if (status) {
1243
- status.fetch = isStale ? "stale" : "refresh";
1244
- if (staleVal && isStale)
1245
- status.returnedStale = true;
1246
- }
1247
- return staleVal ? p.__staleWhileFetching : p.__returned = p;
1248
- }
1249
- }
1250
- async forceFetch(k, fetchOptions = {}) {
1251
- const v = await this.fetch(k, fetchOptions);
1252
- if (v === void 0)
1253
- throw new Error("fetch() returned undefined");
1254
- return v;
1255
- }
1256
- memo(k, memoOptions = {}) {
1257
- const memoMethod = this.#memoMethod;
1258
- if (!memoMethod) {
1259
- throw new Error("no memoMethod provided to constructor");
1260
- }
1261
- const { context, forceRefresh, ...options } = memoOptions;
1262
- const v = this.get(k, options);
1263
- if (!forceRefresh && v !== void 0)
1264
- return v;
1265
- const vv = memoMethod(k, v, {
1266
- options,
1267
- context
1268
- });
1269
- this.set(k, vv, options);
1270
- return vv;
1271
- }
1272
- /**
1273
- * Return a value from the cache. Will update the recency of the cache
1274
- * entry found.
1275
- *
1276
- * If the key is not found, get() will return `undefined`.
1277
- */
1278
- get(k, getOptions = {}) {
1279
- const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status } = getOptions;
1280
- const index = this.#keyMap.get(k);
1281
- if (index !== void 0) {
1282
- const value = this.#valList[index];
1283
- const fetching = this.#isBackgroundFetch(value);
1284
- if (status)
1285
- this.#statusTTL(status, index);
1286
- if (this.#isStale(index)) {
1287
- if (status)
1288
- status.get = "stale";
1289
- if (!fetching) {
1290
- if (!noDeleteOnStaleGet) {
1291
- this.#delete(k, "expire");
1292
- }
1293
- if (status && allowStale)
1294
- status.returnedStale = true;
1295
- return allowStale ? value : void 0;
1296
- } else {
1297
- if (status && allowStale && value.__staleWhileFetching !== void 0) {
1298
- status.returnedStale = true;
1299
- }
1300
- return allowStale ? value.__staleWhileFetching : void 0;
1301
- }
1302
- } else {
1303
- if (status)
1304
- status.get = "hit";
1305
- if (fetching) {
1306
- return value.__staleWhileFetching;
1307
- }
1308
- this.#moveToTail(index);
1309
- if (updateAgeOnGet) {
1310
- this.#updateItemAge(index);
1311
- }
1312
- return value;
1313
- }
1314
- } else if (status) {
1315
- status.get = "miss";
1316
- }
1317
- }
1318
- #connect(p, n) {
1319
- this.#prev[n] = p;
1320
- this.#next[p] = n;
1321
- }
1322
- #moveToTail(index) {
1323
- if (index !== this.#tail) {
1324
- if (index === this.#head) {
1325
- this.#head = this.#next[index];
1326
- } else {
1327
- this.#connect(this.#prev[index], this.#next[index]);
1328
- }
1329
- this.#connect(this.#tail, index);
1330
- this.#tail = index;
1331
- }
1332
- }
1333
- /**
1334
- * Deletes a key out of the cache.
1335
- *
1336
- * Returns true if the key was deleted, false otherwise.
1337
- */
1338
- delete(k) {
1339
- return this.#delete(k, "delete");
1340
- }
1341
- #delete(k, reason) {
1342
- let deleted = false;
1343
- if (this.#size !== 0) {
1344
- const index = this.#keyMap.get(k);
1345
- if (index !== void 0) {
1346
- deleted = true;
1347
- if (this.#size === 1) {
1348
- this.#clear(reason);
1349
- } else {
1350
- this.#removeItemSize(index);
1351
- const v = this.#valList[index];
1352
- if (this.#isBackgroundFetch(v)) {
1353
- v.__abortController.abort(new Error("deleted"));
1354
- } else if (this.#hasDispose || this.#hasDisposeAfter) {
1355
- if (this.#hasDispose) {
1356
- this.#dispose?.(v, k, reason);
1357
- }
1358
- if (this.#hasDisposeAfter) {
1359
- this.#disposed?.push([v, k, reason]);
1360
- }
1361
- }
1362
- this.#keyMap.delete(k);
1363
- this.#keyList[index] = void 0;
1364
- this.#valList[index] = void 0;
1365
- if (index === this.#tail) {
1366
- this.#tail = this.#prev[index];
1367
- } else if (index === this.#head) {
1368
- this.#head = this.#next[index];
1369
- } else {
1370
- const pi = this.#prev[index];
1371
- this.#next[pi] = this.#next[index];
1372
- const ni = this.#next[index];
1373
- this.#prev[ni] = this.#prev[index];
1374
- }
1375
- this.#size--;
1376
- this.#free.push(index);
1377
- }
1378
- }
1379
- }
1380
- if (this.#hasDisposeAfter && this.#disposed?.length) {
1381
- const dt = this.#disposed;
1382
- let task;
1383
- while (task = dt?.shift()) {
1384
- this.#disposeAfter?.(...task);
1385
- }
1386
- }
1387
- return deleted;
1388
- }
1389
- /**
1390
- * Clear the cache entirely, throwing away all values.
1391
- */
1392
- clear() {
1393
- return this.#clear("delete");
1394
- }
1395
- #clear(reason) {
1396
- for (const index of this.#rindexes({ allowStale: true })) {
1397
- const v = this.#valList[index];
1398
- if (this.#isBackgroundFetch(v)) {
1399
- v.__abortController.abort(new Error("deleted"));
1400
- } else {
1401
- const k = this.#keyList[index];
1402
- if (this.#hasDispose) {
1403
- this.#dispose?.(v, k, reason);
1404
- }
1405
- if (this.#hasDisposeAfter) {
1406
- this.#disposed?.push([v, k, reason]);
1407
- }
1408
- }
1409
- }
1410
- this.#keyMap.clear();
1411
- this.#valList.fill(void 0);
1412
- this.#keyList.fill(void 0);
1413
- if (this.#ttls && this.#starts) {
1414
- this.#ttls.fill(0);
1415
- this.#starts.fill(0);
1416
- }
1417
- if (this.#sizes) {
1418
- this.#sizes.fill(0);
1419
- }
1420
- this.#head = 0;
1421
- this.#tail = 0;
1422
- this.#free.length = 0;
1423
- this.#calculatedSize = 0;
1424
- this.#size = 0;
1425
- if (this.#hasDisposeAfter && this.#disposed) {
1426
- const dt = this.#disposed;
1427
- let task;
1428
- while (task = dt?.shift()) {
1429
- this.#disposeAfter?.(...task);
1430
- }
1431
- }
1432
- }
1433
- };
1434
- exports2.LRUCache = LRUCache;
1435
- }
1436
- });
1437
-
1438
- // node_modules/.pnpm/hosted-git-info@9.0.2/node_modules/hosted-git-info/lib/hosts.js
1439
- var require_hosts = __commonJS({
1440
- "node_modules/.pnpm/hosted-git-info@9.0.2/node_modules/hosted-git-info/lib/hosts.js"(exports2, module2) {
1441
- "use strict";
1442
- var maybeJoin = /* @__PURE__ */ __name((...args) => args.every((arg) => arg) ? args.join("") : "", "maybeJoin");
1443
- var maybeEncode = /* @__PURE__ */ __name((arg) => arg ? encodeURIComponent(arg) : "", "maybeEncode");
1444
- var formatHashFragment = /* @__PURE__ */ __name((f) => f.toLowerCase().replace(/^\W+/g, "").replace(/(?<!\W)\W+$/, "").replace(/\//g, "").replace(/\W+/g, "-"), "formatHashFragment");
1445
- var defaults = {
1446
- sshtemplate: /* @__PURE__ */ __name(({ domain, user, project, committish }) => `git@${domain}:${user}/${project}.git${maybeJoin("#", committish)}`, "sshtemplate"),
1447
- sshurltemplate: /* @__PURE__ */ __name(({ domain, user, project, committish }) => `git+ssh://git@${domain}/${user}/${project}.git${maybeJoin("#", committish)}`, "sshurltemplate"),
1448
- edittemplate: /* @__PURE__ */ __name(({ domain, user, project, committish, editpath, path }) => `https://${domain}/${user}/${project}${maybeJoin("/", editpath, "/", maybeEncode(committish || "HEAD"), "/", path)}`, "edittemplate"),
1449
- browsetemplate: /* @__PURE__ */ __name(({ domain, user, project, committish, treepath }) => `https://${domain}/${user}/${project}${maybeJoin("/", treepath, "/", maybeEncode(committish))}`, "browsetemplate"),
1450
- browsetreetemplate: /* @__PURE__ */ __name(({ domain, user, project, committish, treepath, path, fragment, hashformat }) => `https://${domain}/${user}/${project}/${treepath}/${maybeEncode(committish || "HEAD")}/${path}${maybeJoin("#", hashformat(fragment || ""))}`, "browsetreetemplate"),
1451
- browseblobtemplate: /* @__PURE__ */ __name(({ domain, user, project, committish, blobpath, path, fragment, hashformat }) => `https://${domain}/${user}/${project}/${blobpath}/${maybeEncode(committish || "HEAD")}/${path}${maybeJoin("#", hashformat(fragment || ""))}`, "browseblobtemplate"),
1452
- docstemplate: /* @__PURE__ */ __name(({ domain, user, project, treepath, committish }) => `https://${domain}/${user}/${project}${maybeJoin("/", treepath, "/", maybeEncode(committish))}#readme`, "docstemplate"),
1453
- httpstemplate: /* @__PURE__ */ __name(({ auth, domain, user, project, committish }) => `git+https://${maybeJoin(auth, "@")}${domain}/${user}/${project}.git${maybeJoin("#", committish)}`, "httpstemplate"),
1454
- filetemplate: /* @__PURE__ */ __name(({ domain, user, project, committish, path }) => `https://${domain}/${user}/${project}/raw/${maybeEncode(committish || "HEAD")}/${path}`, "filetemplate"),
1455
- shortcuttemplate: /* @__PURE__ */ __name(({ type, user, project, committish }) => `${type}:${user}/${project}${maybeJoin("#", committish)}`, "shortcuttemplate"),
1456
- pathtemplate: /* @__PURE__ */ __name(({ user, project, committish }) => `${user}/${project}${maybeJoin("#", committish)}`, "pathtemplate"),
1457
- bugstemplate: /* @__PURE__ */ __name(({ domain, user, project }) => `https://${domain}/${user}/${project}/issues`, "bugstemplate"),
1458
- hashformat: formatHashFragment
1459
- };
1460
- var hosts = {};
1461
- hosts.github = {
1462
- // First two are insecure and generally shouldn't be used any more, but
1463
- // they are still supported.
1464
- protocols: ["git:", "http:", "git+ssh:", "git+https:", "ssh:", "https:"],
1465
- domain: "github.com",
1466
- treepath: "tree",
1467
- blobpath: "blob",
1468
- editpath: "edit",
1469
- filetemplate: /* @__PURE__ */ __name(({ auth, user, project, committish, path }) => `https://${maybeJoin(auth, "@")}raw.githubusercontent.com/${user}/${project}/${maybeEncode(committish || "HEAD")}/${path}`, "filetemplate"),
1470
- gittemplate: /* @__PURE__ */ __name(({ auth, domain, user, project, committish }) => `git://${maybeJoin(auth, "@")}${domain}/${user}/${project}.git${maybeJoin("#", committish)}`, "gittemplate"),
1471
- tarballtemplate: /* @__PURE__ */ __name(({ domain, user, project, committish }) => `https://codeload.${domain}/${user}/${project}/tar.gz/${maybeEncode(committish || "HEAD")}`, "tarballtemplate"),
1472
- extract: /* @__PURE__ */ __name((url) => {
1473
- let [, user, project, type, committish] = url.pathname.split("/", 5);
1474
- if (type && type !== "tree") {
1475
- return;
1476
- }
1477
- if (!type) {
1478
- committish = url.hash.slice(1);
1479
- }
1480
- if (project && project.endsWith(".git")) {
1481
- project = project.slice(0, -4);
1482
- }
1483
- if (!user || !project) {
1484
- return;
1485
- }
1486
- return { user, project, committish };
1487
- }, "extract")
1488
- };
1489
- hosts.bitbucket = {
1490
- protocols: ["git+ssh:", "git+https:", "ssh:", "https:"],
1491
- domain: "bitbucket.org",
1492
- treepath: "src",
1493
- blobpath: "src",
1494
- editpath: "?mode=edit",
1495
- edittemplate: /* @__PURE__ */ __name(({ domain, user, project, committish, treepath, path, editpath }) => `https://${domain}/${user}/${project}${maybeJoin("/", treepath, "/", maybeEncode(committish || "HEAD"), "/", path, editpath)}`, "edittemplate"),
1496
- tarballtemplate: /* @__PURE__ */ __name(({ domain, user, project, committish }) => `https://${domain}/${user}/${project}/get/${maybeEncode(committish || "HEAD")}.tar.gz`, "tarballtemplate"),
1497
- extract: /* @__PURE__ */ __name((url) => {
1498
- let [, user, project, aux] = url.pathname.split("/", 4);
1499
- if (["get"].includes(aux)) {
1500
- return;
1501
- }
1502
- if (project && project.endsWith(".git")) {
1503
- project = project.slice(0, -4);
1504
- }
1505
- if (!user || !project) {
1506
- return;
1507
- }
1508
- return { user, project, committish: url.hash.slice(1) };
1509
- }, "extract")
1510
- };
1511
- hosts.gitlab = {
1512
- protocols: ["git+ssh:", "git+https:", "ssh:", "https:"],
1513
- domain: "gitlab.com",
1514
- treepath: "tree",
1515
- blobpath: "tree",
1516
- editpath: "-/edit",
1517
- tarballtemplate: /* @__PURE__ */ __name(({ domain, user, project, committish }) => `https://${domain}/${user}/${project}/repository/archive.tar.gz?ref=${maybeEncode(committish || "HEAD")}`, "tarballtemplate"),
1518
- extract: /* @__PURE__ */ __name((url) => {
1519
- const path = url.pathname.slice(1);
1520
- if (path.includes("/-/") || path.includes("/archive.tar.gz")) {
1521
- return;
1522
- }
1523
- const segments = path.split("/");
1524
- let project = segments.pop();
1525
- if (project.endsWith(".git")) {
1526
- project = project.slice(0, -4);
1527
- }
1528
- const user = segments.join("/");
1529
- if (!user || !project) {
1530
- return;
1531
- }
1532
- return { user, project, committish: url.hash.slice(1) };
1533
- }, "extract")
1534
- };
1535
- hosts.gist = {
1536
- protocols: ["git:", "git+ssh:", "git+https:", "ssh:", "https:"],
1537
- domain: "gist.github.com",
1538
- editpath: "edit",
1539
- sshtemplate: /* @__PURE__ */ __name(({ domain, project, committish }) => `git@${domain}:${project}.git${maybeJoin("#", committish)}`, "sshtemplate"),
1540
- sshurltemplate: /* @__PURE__ */ __name(({ domain, project, committish }) => `git+ssh://git@${domain}/${project}.git${maybeJoin("#", committish)}`, "sshurltemplate"),
1541
- edittemplate: /* @__PURE__ */ __name(({ domain, user, project, committish, editpath }) => `https://${domain}/${user}/${project}${maybeJoin("/", maybeEncode(committish))}/${editpath}`, "edittemplate"),
1542
- browsetemplate: /* @__PURE__ */ __name(({ domain, project, committish }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}`, "browsetemplate"),
1543
- browsetreetemplate: /* @__PURE__ */ __name(({ domain, project, committish, path, hashformat }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}${maybeJoin("#", hashformat(path))}`, "browsetreetemplate"),
1544
- browseblobtemplate: /* @__PURE__ */ __name(({ domain, project, committish, path, hashformat }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}${maybeJoin("#", hashformat(path))}`, "browseblobtemplate"),
1545
- docstemplate: /* @__PURE__ */ __name(({ domain, project, committish }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}`, "docstemplate"),
1546
- httpstemplate: /* @__PURE__ */ __name(({ domain, project, committish }) => `git+https://${domain}/${project}.git${maybeJoin("#", committish)}`, "httpstemplate"),
1547
- filetemplate: /* @__PURE__ */ __name(({ user, project, committish, path }) => `https://gist.githubusercontent.com/${user}/${project}/raw${maybeJoin("/", maybeEncode(committish))}/${path}`, "filetemplate"),
1548
- shortcuttemplate: /* @__PURE__ */ __name(({ type, project, committish }) => `${type}:${project}${maybeJoin("#", committish)}`, "shortcuttemplate"),
1549
- pathtemplate: /* @__PURE__ */ __name(({ project, committish }) => `${project}${maybeJoin("#", committish)}`, "pathtemplate"),
1550
- bugstemplate: /* @__PURE__ */ __name(({ domain, project }) => `https://${domain}/${project}`, "bugstemplate"),
1551
- gittemplate: /* @__PURE__ */ __name(({ domain, project, committish }) => `git://${domain}/${project}.git${maybeJoin("#", committish)}`, "gittemplate"),
1552
- tarballtemplate: /* @__PURE__ */ __name(({ project, committish }) => `https://codeload.github.com/gist/${project}/tar.gz/${maybeEncode(committish || "HEAD")}`, "tarballtemplate"),
1553
- extract: /* @__PURE__ */ __name((url) => {
1554
- let [, user, project, aux] = url.pathname.split("/", 4);
1555
- if (aux === "raw") {
1556
- return;
1557
- }
1558
- if (!project) {
1559
- if (!user) {
1560
- return;
1561
- }
1562
- project = user;
1563
- user = null;
1564
- }
1565
- if (project.endsWith(".git")) {
1566
- project = project.slice(0, -4);
1567
- }
1568
- return { user, project, committish: url.hash.slice(1) };
1569
- }, "extract"),
1570
- hashformat: /* @__PURE__ */ __name(function(fragment) {
1571
- return fragment && "file-" + formatHashFragment(fragment);
1572
- }, "hashformat")
1573
- };
1574
- hosts.sourcehut = {
1575
- protocols: ["git+ssh:", "https:"],
1576
- domain: "git.sr.ht",
1577
- treepath: "tree",
1578
- blobpath: "tree",
1579
- filetemplate: /* @__PURE__ */ __name(({ domain, user, project, committish, path }) => `https://${domain}/${user}/${project}/blob/${maybeEncode(committish) || "HEAD"}/${path}`, "filetemplate"),
1580
- httpstemplate: /* @__PURE__ */ __name(({ domain, user, project, committish }) => `https://${domain}/${user}/${project}.git${maybeJoin("#", committish)}`, "httpstemplate"),
1581
- tarballtemplate: /* @__PURE__ */ __name(({ domain, user, project, committish }) => `https://${domain}/${user}/${project}/archive/${maybeEncode(committish) || "HEAD"}.tar.gz`, "tarballtemplate"),
1582
- bugstemplate: /* @__PURE__ */ __name(() => null, "bugstemplate"),
1583
- extract: /* @__PURE__ */ __name((url) => {
1584
- let [, user, project, aux] = url.pathname.split("/", 4);
1585
- if (["archive"].includes(aux)) {
1586
- return;
1587
- }
1588
- if (project && project.endsWith(".git")) {
1589
- project = project.slice(0, -4);
1590
- }
1591
- if (!user || !project) {
1592
- return;
1593
- }
1594
- return { user, project, committish: url.hash.slice(1) };
1595
- }, "extract")
1596
- };
1597
- for (const [name, host] of Object.entries(hosts)) {
1598
- hosts[name] = Object.assign({}, defaults, host);
1599
- }
1600
- module2.exports = hosts;
1601
- }
1602
- });
1603
-
1604
- // node_modules/.pnpm/hosted-git-info@9.0.2/node_modules/hosted-git-info/lib/parse-url.js
1605
- var require_parse_url = __commonJS({
1606
- "node_modules/.pnpm/hosted-git-info@9.0.2/node_modules/hosted-git-info/lib/parse-url.js"(exports2, module2) {
1607
- var url = require("url");
1608
- var lastIndexOfBefore = /* @__PURE__ */ __name((str, char, beforeChar) => {
1609
- const startPosition = str.indexOf(beforeChar);
1610
- return str.lastIndexOf(char, startPosition > -1 ? startPosition : Infinity);
1611
- }, "lastIndexOfBefore");
1612
- var safeUrl = /* @__PURE__ */ __name((u) => {
1613
- try {
1614
- return new url.URL(u);
1615
- } catch {
1616
- }
1617
- }, "safeUrl");
1618
- var correctProtocol = /* @__PURE__ */ __name((arg, protocols) => {
1619
- const firstColon = arg.indexOf(":");
1620
- const proto = arg.slice(0, firstColon + 1);
1621
- if (Object.prototype.hasOwnProperty.call(protocols, proto)) {
1622
- return arg;
1623
- }
1624
- if (arg.substr(firstColon, 3) === "://") {
1625
- return arg;
1626
- }
1627
- const firstAt = arg.indexOf("@");
1628
- if (firstAt > -1) {
1629
- if (firstAt > firstColon) {
1630
- return `git+ssh://${arg}`;
1631
- } else {
1632
- return arg;
1633
- }
1634
- }
1635
- return `${arg.slice(0, firstColon + 1)}//${arg.slice(firstColon + 1)}`;
1636
- }, "correctProtocol");
1637
- var correctUrl = /* @__PURE__ */ __name((giturl) => {
1638
- const firstAt = lastIndexOfBefore(giturl, "@", "#");
1639
- const lastColonBeforeHash = lastIndexOfBefore(giturl, ":", "#");
1640
- if (lastColonBeforeHash > firstAt) {
1641
- giturl = giturl.slice(0, lastColonBeforeHash) + "/" + giturl.slice(lastColonBeforeHash + 1);
1642
- }
1643
- if (lastIndexOfBefore(giturl, ":", "#") === -1 && giturl.indexOf("//") === -1) {
1644
- giturl = `git+ssh://${giturl}`;
1645
- }
1646
- return giturl;
1647
- }, "correctUrl");
1648
- module2.exports = (giturl, protocols) => {
1649
- const withProtocol = protocols ? correctProtocol(giturl, protocols) : giturl;
1650
- return safeUrl(withProtocol) || safeUrl(correctUrl(withProtocol));
1651
- };
1652
- }
1653
- });
1654
-
1655
- // node_modules/.pnpm/hosted-git-info@9.0.2/node_modules/hosted-git-info/lib/from-url.js
1656
- var require_from_url = __commonJS({
1657
- "node_modules/.pnpm/hosted-git-info@9.0.2/node_modules/hosted-git-info/lib/from-url.js"(exports2, module2) {
1658
- "use strict";
1659
- var parseUrl = require_parse_url();
1660
- var isGitHubShorthand = /* @__PURE__ */ __name((arg) => {
1661
- const firstHash = arg.indexOf("#");
1662
- const firstSlash = arg.indexOf("/");
1663
- const secondSlash = arg.indexOf("/", firstSlash + 1);
1664
- const firstColon = arg.indexOf(":");
1665
- const firstSpace = /\s/.exec(arg);
1666
- const firstAt = arg.indexOf("@");
1667
- const spaceOnlyAfterHash = !firstSpace || firstHash > -1 && firstSpace.index > firstHash;
1668
- const atOnlyAfterHash = firstAt === -1 || firstHash > -1 && firstAt > firstHash;
1669
- const colonOnlyAfterHash = firstColon === -1 || firstHash > -1 && firstColon > firstHash;
1670
- const secondSlashOnlyAfterHash = secondSlash === -1 || firstHash > -1 && secondSlash > firstHash;
1671
- const hasSlash = firstSlash > 0;
1672
- const doesNotEndWithSlash = firstHash > -1 ? arg[firstHash - 1] !== "/" : !arg.endsWith("/");
1673
- const doesNotStartWithDot = !arg.startsWith(".");
1674
- return spaceOnlyAfterHash && hasSlash && doesNotEndWithSlash && doesNotStartWithDot && atOnlyAfterHash && colonOnlyAfterHash && secondSlashOnlyAfterHash;
1675
- }, "isGitHubShorthand");
1676
- module2.exports = (giturl, opts, { gitHosts, protocols }) => {
1677
- if (!giturl) {
1678
- return;
1679
- }
1680
- const correctedUrl = isGitHubShorthand(giturl) ? `github:${giturl}` : giturl;
1681
- const parsed = parseUrl(correctedUrl, protocols);
1682
- if (!parsed) {
1683
- return;
1684
- }
1685
- const gitHostShortcut = gitHosts.byShortcut[parsed.protocol];
1686
- const gitHostDomain = gitHosts.byDomain[parsed.hostname.startsWith("www.") ? parsed.hostname.slice(4) : parsed.hostname];
1687
- const gitHostName = gitHostShortcut || gitHostDomain;
1688
- if (!gitHostName) {
1689
- return;
1690
- }
1691
- const gitHostInfo = gitHosts[gitHostShortcut || gitHostDomain];
1692
- let auth = null;
1693
- if (protocols[parsed.protocol]?.auth && (parsed.username || parsed.password)) {
1694
- auth = `${parsed.username}${parsed.password ? ":" + parsed.password : ""}`;
1695
- }
1696
- let committish = null;
1697
- let user = null;
1698
- let project = null;
1699
- let defaultRepresentation = null;
1700
- try {
1701
- if (gitHostShortcut) {
1702
- let pathname = parsed.pathname.startsWith("/") ? parsed.pathname.slice(1) : parsed.pathname;
1703
- const firstAt = pathname.indexOf("@");
1704
- if (firstAt > -1) {
1705
- pathname = pathname.slice(firstAt + 1);
1706
- }
1707
- const lastSlash = pathname.lastIndexOf("/");
1708
- if (lastSlash > -1) {
1709
- user = decodeURIComponent(pathname.slice(0, lastSlash));
1710
- if (!user) {
1711
- user = null;
1712
- }
1713
- project = decodeURIComponent(pathname.slice(lastSlash + 1));
1714
- } else {
1715
- project = decodeURIComponent(pathname);
1716
- }
1717
- if (project.endsWith(".git")) {
1718
- project = project.slice(0, -4);
1719
- }
1720
- if (parsed.hash) {
1721
- committish = decodeURIComponent(parsed.hash.slice(1));
1722
- }
1723
- defaultRepresentation = "shortcut";
1724
- } else {
1725
- if (!gitHostInfo.protocols.includes(parsed.protocol)) {
1726
- return;
1727
- }
1728
- const segments = gitHostInfo.extract(parsed);
1729
- if (!segments) {
1730
- return;
1731
- }
1732
- user = segments.user && decodeURIComponent(segments.user);
1733
- project = decodeURIComponent(segments.project);
1734
- committish = decodeURIComponent(segments.committish);
1735
- defaultRepresentation = protocols[parsed.protocol]?.name || parsed.protocol.slice(0, -1);
1736
- }
1737
- } catch (err) {
1738
- if (err instanceof URIError) {
1739
- return;
1740
- } else {
1741
- throw err;
1742
- }
1743
- }
1744
- return [gitHostName, user, auth, project, committish, defaultRepresentation, opts];
1745
- };
1746
- }
1747
- });
1748
-
1749
- // node_modules/.pnpm/hosted-git-info@9.0.2/node_modules/hosted-git-info/lib/index.js
1750
- var require_lib = __commonJS({
1751
- "node_modules/.pnpm/hosted-git-info@9.0.2/node_modules/hosted-git-info/lib/index.js"(exports2, module2) {
1752
- "use strict";
1753
- var { LRUCache } = require_commonjs();
1754
- var hosts = require_hosts();
1755
- var fromUrl = require_from_url();
1756
- var parseUrl = require_parse_url();
1757
- var cache = new LRUCache({ max: 1e3 });
1758
- function unknownHostedUrl(url) {
1759
- try {
1760
- const {
1761
- protocol,
1762
- hostname,
1763
- pathname
1764
- } = new URL(url);
1765
- if (!hostname) {
1766
- return null;
1767
- }
1768
- const proto = /(?:git\+)http:$/.test(protocol) ? "http:" : "https:";
1769
- const path = pathname.replace(/\.git$/, "");
1770
- return `${proto}//${hostname}${path}`;
1771
- } catch {
1772
- return null;
1773
- }
1774
- }
1775
- __name(unknownHostedUrl, "unknownHostedUrl");
1776
- var GitHost = class _GitHost {
1777
- static {
1778
- __name(this, "GitHost");
1779
- }
1780
- constructor(type, user, auth, project, committish, defaultRepresentation, opts = {}) {
1781
- Object.assign(this, _GitHost.#gitHosts[type], {
1782
- type,
1783
- user,
1784
- auth,
1785
- project,
1786
- committish,
1787
- default: defaultRepresentation,
1788
- opts
1789
- });
1790
- }
1791
- static #gitHosts = { byShortcut: {}, byDomain: {} };
1792
- static #protocols = {
1793
- "git+ssh:": { name: "sshurl" },
1794
- "ssh:": { name: "sshurl" },
1795
- "git+https:": { name: "https", auth: true },
1796
- "git:": { auth: true },
1797
- "http:": { auth: true },
1798
- "https:": { auth: true },
1799
- "git+http:": { auth: true }
1800
- };
1801
- static addHost(name, host) {
1802
- _GitHost.#gitHosts[name] = host;
1803
- _GitHost.#gitHosts.byDomain[host.domain] = name;
1804
- _GitHost.#gitHosts.byShortcut[`${name}:`] = name;
1805
- _GitHost.#protocols[`${name}:`] = { name };
1806
- }
1807
- static fromUrl(giturl, opts) {
1808
- if (typeof giturl !== "string") {
1809
- return;
1810
- }
1811
- const key = giturl + JSON.stringify(opts || {});
1812
- if (!cache.has(key)) {
1813
- const hostArgs = fromUrl(giturl, opts, {
1814
- gitHosts: _GitHost.#gitHosts,
1815
- protocols: _GitHost.#protocols
1816
- });
1817
- cache.set(key, hostArgs ? new _GitHost(...hostArgs) : void 0);
1818
- }
1819
- return cache.get(key);
1820
- }
1821
- static fromManifest(manifest, opts = {}) {
1822
- if (!manifest || typeof manifest !== "object") {
1823
- return;
1824
- }
1825
- const r = manifest.repository;
1826
- const rurl = r && (typeof r === "string" ? r : typeof r === "object" && typeof r.url === "string" ? r.url : null);
1827
- if (!rurl) {
1828
- throw new Error("no repository");
1829
- }
1830
- const info = rurl && _GitHost.fromUrl(rurl.replace(/^git\+/, ""), opts) || null;
1831
- if (info) {
1832
- return info;
1833
- }
1834
- const unk = unknownHostedUrl(rurl);
1835
- return _GitHost.fromUrl(unk, opts) || unk;
1836
- }
1837
- static parseUrl(url) {
1838
- return parseUrl(url);
1839
- }
1840
- #fill(template, opts) {
1841
- if (typeof template !== "function") {
1842
- return null;
1843
- }
1844
- const options = { ...this, ...this.opts, ...opts };
1845
- if (!options.path) {
1846
- options.path = "";
1847
- }
1848
- if (options.path.startsWith("/")) {
1849
- options.path = options.path.slice(1);
1850
- }
1851
- if (options.noCommittish) {
1852
- options.committish = null;
1853
- }
1854
- const result = template(options);
1855
- return options.noGitPlus && result.startsWith("git+") ? result.slice(4) : result;
1856
- }
1857
- hash() {
1858
- return this.committish ? `#${this.committish}` : "";
1859
- }
1860
- ssh(opts) {
1861
- return this.#fill(this.sshtemplate, opts);
1862
- }
1863
- sshurl(opts) {
1864
- return this.#fill(this.sshurltemplate, opts);
1865
- }
1866
- browse(path, ...args) {
1867
- if (typeof path !== "string") {
1868
- return this.#fill(this.browsetemplate, path);
1869
- }
1870
- if (typeof args[0] !== "string") {
1871
- return this.#fill(this.browsetreetemplate, { ...args[0], path });
1872
- }
1873
- return this.#fill(this.browsetreetemplate, { ...args[1], fragment: args[0], path });
1874
- }
1875
- // If the path is known to be a file, then browseFile should be used. For some hosts
1876
- // the url is the same as browse, but for others like GitHub a file can use both `/tree/`
1877
- // and `/blob/` in the path. When using a default committish of `HEAD` then the `/tree/`
1878
- // path will redirect to a specific commit. Using the `/blob/` path avoids this and
1879
- // does not redirect to a different commit.
1880
- browseFile(path, ...args) {
1881
- if (typeof args[0] !== "string") {
1882
- return this.#fill(this.browseblobtemplate, { ...args[0], path });
1883
- }
1884
- return this.#fill(this.browseblobtemplate, { ...args[1], fragment: args[0], path });
1885
- }
1886
- docs(opts) {
1887
- return this.#fill(this.docstemplate, opts);
1888
- }
1889
- bugs(opts) {
1890
- return this.#fill(this.bugstemplate, opts);
1891
- }
1892
- https(opts) {
1893
- return this.#fill(this.httpstemplate, opts);
1894
- }
1895
- git(opts) {
1896
- return this.#fill(this.gittemplate, opts);
1897
- }
1898
- shortcut(opts) {
1899
- return this.#fill(this.shortcuttemplate, opts);
1900
- }
1901
- path(opts) {
1902
- return this.#fill(this.pathtemplate, opts);
1903
- }
1904
- tarball(opts) {
1905
- return this.#fill(this.tarballtemplate, { ...opts, noCommittish: false });
1906
- }
1907
- file(path, opts) {
1908
- return this.#fill(this.filetemplate, { ...opts, path });
1909
- }
1910
- edit(path, opts) {
1911
- return this.#fill(this.edittemplate, { ...opts, path });
1912
- }
1913
- getDefaultRepresentation() {
1914
- return this.default;
1915
- }
1916
- toString(opts) {
1917
- if (this.default && typeof this[this.default] === "function") {
1918
- return this[this.default](opts);
1919
- }
1920
- return this.sshurl(opts);
1921
- }
1922
- };
1923
- for (const [name, host] of Object.entries(hosts)) {
1924
- GitHost.addHost(name, host);
1925
- }
1926
- module2.exports = GitHost;
1927
- }
1928
- });
1929
-
1930
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/constants.js
1931
- var require_constants = __commonJS({
1932
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/constants.js"(exports2, module2) {
1933
- "use strict";
1934
- var SEMVER_SPEC_VERSION = "2.0.0";
1935
- var MAX_LENGTH = 256;
1936
- var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
1937
- 9007199254740991;
1938
- var MAX_SAFE_COMPONENT_LENGTH = 16;
1939
- var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
1940
- var RELEASE_TYPES = [
1941
- "major",
1942
- "premajor",
1943
- "minor",
1944
- "preminor",
1945
- "patch",
1946
- "prepatch",
1947
- "prerelease"
1948
- ];
1949
- module2.exports = {
1950
- MAX_LENGTH,
1951
- MAX_SAFE_COMPONENT_LENGTH,
1952
- MAX_SAFE_BUILD_LENGTH,
1953
- MAX_SAFE_INTEGER,
1954
- RELEASE_TYPES,
1955
- SEMVER_SPEC_VERSION,
1956
- FLAG_INCLUDE_PRERELEASE: 1,
1957
- FLAG_LOOSE: 2
1958
- };
1959
- }
1960
- });
1961
-
1962
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/debug.js
1963
- var require_debug = __commonJS({
1964
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/debug.js"(exports2, module2) {
1965
- "use strict";
1966
- var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => void 0 : () => {
1967
- };
1968
- module2.exports = debug;
1969
- }
1970
- });
1971
-
1972
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/re.js
1973
- var require_re = __commonJS({
1974
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/re.js"(exports2, module2) {
1975
- "use strict";
1976
- var {
1977
- MAX_SAFE_COMPONENT_LENGTH,
1978
- MAX_SAFE_BUILD_LENGTH,
1979
- MAX_LENGTH
1980
- } = require_constants();
1981
- var debug = require_debug();
1982
- exports2 = module2.exports = {};
1983
- var re = exports2.re = [];
1984
- var safeRe = exports2.safeRe = [];
1985
- var src = exports2.src = [];
1986
- var safeSrc = exports2.safeSrc = [];
1987
- var t = exports2.t = {};
1988
- var R = 0;
1989
- var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
1990
- var safeRegexReplacements = [
1991
- ["\\s", 1],
1992
- ["\\d", MAX_LENGTH],
1993
- [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
1994
- ];
1995
- var makeSafeRegex = /* @__PURE__ */ __name((value) => {
1996
- for (const [token, max] of safeRegexReplacements) {
1997
- value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
1998
- }
1999
- return value;
2000
- }, "makeSafeRegex");
2001
- var createToken = /* @__PURE__ */ __name((name, value, isGlobal) => {
2002
- const safe = makeSafeRegex(value);
2003
- const index = R++;
2004
- debug(name, index, value);
2005
- t[name] = index;
2006
- src[index] = value;
2007
- safeSrc[index] = safe;
2008
- re[index] = new RegExp(value, isGlobal ? "g" : void 0);
2009
- safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
2010
- }, "createToken");
2011
- createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
2012
- createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
2013
- createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
2014
- createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
2015
- createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
2016
- createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
2017
- createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
2018
- createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
2019
- createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
2020
- createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
2021
- createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
2022
- createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
2023
- createToken("FULL", `^${src[t.FULLPLAIN]}$`);
2024
- createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
2025
- createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
2026
- createToken("GTLT", "((?:<|>)?=?)");
2027
- createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
2028
- createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
2029
- createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
2030
- createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
2031
- createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
2032
- createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
2033
- createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
2034
- createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
2035
- createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
2036
- createToken("COERCERTL", src[t.COERCE], true);
2037
- createToken("COERCERTLFULL", src[t.COERCEFULL], true);
2038
- createToken("LONETILDE", "(?:~>?)");
2039
- createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
2040
- exports2.tildeTrimReplace = "$1~";
2041
- createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
2042
- createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
2043
- createToken("LONECARET", "(?:\\^)");
2044
- createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
2045
- exports2.caretTrimReplace = "$1^";
2046
- createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
2047
- createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
2048
- createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
2049
- createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
2050
- createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
2051
- exports2.comparatorTrimReplace = "$1$2$3";
2052
- createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
2053
- createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
2054
- createToken("STAR", "(<|>)?=?\\s*\\*");
2055
- createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
2056
- createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
2057
- }
2058
- });
2059
-
2060
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/parse-options.js
2061
- var require_parse_options = __commonJS({
2062
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/parse-options.js"(exports2, module2) {
2063
- "use strict";
2064
- var looseOption = Object.freeze({ loose: true });
2065
- var emptyOpts = Object.freeze({});
2066
- var parseOptions = /* @__PURE__ */ __name((options) => {
2067
- if (!options) {
2068
- return emptyOpts;
2069
- }
2070
- if (typeof options !== "object") {
2071
- return looseOption;
2072
- }
2073
- return options;
2074
- }, "parseOptions");
2075
- module2.exports = parseOptions;
2076
- }
2077
- });
2078
-
2079
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/identifiers.js
2080
- var require_identifiers = __commonJS({
2081
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/identifiers.js"(exports2, module2) {
2082
- "use strict";
2083
- var numeric = /^[0-9]+$/;
2084
- var compareIdentifiers = /* @__PURE__ */ __name((a, b) => {
2085
- const anum = numeric.test(a);
2086
- const bnum = numeric.test(b);
2087
- if (anum && bnum) {
2088
- a = +a;
2089
- b = +b;
2090
- }
2091
- return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
2092
- }, "compareIdentifiers");
2093
- var rcompareIdentifiers = /* @__PURE__ */ __name((a, b) => compareIdentifiers(b, a), "rcompareIdentifiers");
2094
- module2.exports = {
2095
- compareIdentifiers,
2096
- rcompareIdentifiers
2097
- };
2098
- }
2099
- });
2100
-
2101
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/semver.js
2102
- var require_semver = __commonJS({
2103
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/semver.js"(exports2, module2) {
2104
- "use strict";
2105
- var debug = require_debug();
2106
- var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
2107
- var { safeRe: re, t } = require_re();
2108
- var parseOptions = require_parse_options();
2109
- var { compareIdentifiers } = require_identifiers();
2110
- var SemVer = class _SemVer {
2111
- static {
2112
- __name(this, "SemVer");
2113
- }
2114
- constructor(version, options) {
2115
- options = parseOptions(options);
2116
- if (version instanceof _SemVer) {
2117
- if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
2118
- return version;
2119
- } else {
2120
- version = version.version;
2121
- }
2122
- } else if (typeof version !== "string") {
2123
- throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
2124
- }
2125
- if (version.length > MAX_LENGTH) {
2126
- throw new TypeError(
2127
- `version is longer than ${MAX_LENGTH} characters`
2128
- );
2129
- }
2130
- debug("SemVer", version, options);
2131
- this.options = options;
2132
- this.loose = !!options.loose;
2133
- this.includePrerelease = !!options.includePrerelease;
2134
- const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
2135
- if (!m) {
2136
- throw new TypeError(`Invalid Version: ${version}`);
2137
- }
2138
- this.raw = version;
2139
- this.major = +m[1];
2140
- this.minor = +m[2];
2141
- this.patch = +m[3];
2142
- if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
2143
- throw new TypeError("Invalid major version");
2144
- }
2145
- if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
2146
- throw new TypeError("Invalid minor version");
2147
- }
2148
- if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
2149
- throw new TypeError("Invalid patch version");
2150
- }
2151
- if (!m[4]) {
2152
- this.prerelease = [];
2153
- } else {
2154
- this.prerelease = m[4].split(".").map((id) => {
2155
- if (/^[0-9]+$/.test(id)) {
2156
- const num = +id;
2157
- if (num >= 0 && num < MAX_SAFE_INTEGER) {
2158
- return num;
2159
- }
2160
- }
2161
- return id;
2162
- });
2163
- }
2164
- this.build = m[5] ? m[5].split(".") : [];
2165
- this.format();
2166
- }
2167
- format() {
2168
- this.version = `${this.major}.${this.minor}.${this.patch}`;
2169
- if (this.prerelease.length) {
2170
- this.version += `-${this.prerelease.join(".")}`;
2171
- }
2172
- return this.version;
2173
- }
2174
- toString() {
2175
- return this.version;
2176
- }
2177
- compare(other) {
2178
- debug("SemVer.compare", this.version, this.options, other);
2179
- if (!(other instanceof _SemVer)) {
2180
- if (typeof other === "string" && other === this.version) {
2181
- return 0;
2182
- }
2183
- other = new _SemVer(other, this.options);
2184
- }
2185
- if (other.version === this.version) {
2186
- return 0;
2187
- }
2188
- return this.compareMain(other) || this.comparePre(other);
2189
- }
2190
- compareMain(other) {
2191
- if (!(other instanceof _SemVer)) {
2192
- other = new _SemVer(other, this.options);
2193
- }
2194
- return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
2195
- }
2196
- comparePre(other) {
2197
- if (!(other instanceof _SemVer)) {
2198
- other = new _SemVer(other, this.options);
2199
- }
2200
- if (this.prerelease.length && !other.prerelease.length) {
2201
- return -1;
2202
- } else if (!this.prerelease.length && other.prerelease.length) {
2203
- return 1;
2204
- } else if (!this.prerelease.length && !other.prerelease.length) {
2205
- return 0;
2206
- }
2207
- let i = 0;
2208
- do {
2209
- const a = this.prerelease[i];
2210
- const b = other.prerelease[i];
2211
- debug("prerelease compare", i, a, b);
2212
- if (a === void 0 && b === void 0) {
2213
- return 0;
2214
- } else if (b === void 0) {
2215
- return 1;
2216
- } else if (a === void 0) {
2217
- return -1;
2218
- } else if (a === b) {
2219
- continue;
2220
- } else {
2221
- return compareIdentifiers(a, b);
2222
- }
2223
- } while (++i);
2224
- }
2225
- compareBuild(other) {
2226
- if (!(other instanceof _SemVer)) {
2227
- other = new _SemVer(other, this.options);
2228
- }
2229
- let i = 0;
2230
- do {
2231
- const a = this.build[i];
2232
- const b = other.build[i];
2233
- debug("build compare", i, a, b);
2234
- if (a === void 0 && b === void 0) {
2235
- return 0;
2236
- } else if (b === void 0) {
2237
- return 1;
2238
- } else if (a === void 0) {
2239
- return -1;
2240
- } else if (a === b) {
2241
- continue;
2242
- } else {
2243
- return compareIdentifiers(a, b);
2244
- }
2245
- } while (++i);
2246
- }
2247
- // preminor will bump the version up to the next minor release, and immediately
2248
- // down to pre-release. premajor and prepatch work the same way.
2249
- inc(release, identifier, identifierBase) {
2250
- if (release.startsWith("pre")) {
2251
- if (!identifier && identifierBase === false) {
2252
- throw new Error("invalid increment argument: identifier is empty");
2253
- }
2254
- if (identifier) {
2255
- const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
2256
- if (!match || match[1] !== identifier) {
2257
- throw new Error(`invalid identifier: ${identifier}`);
2258
- }
2259
- }
2260
- }
2261
- switch (release) {
2262
- case "premajor":
2263
- this.prerelease.length = 0;
2264
- this.patch = 0;
2265
- this.minor = 0;
2266
- this.major++;
2267
- this.inc("pre", identifier, identifierBase);
2268
- break;
2269
- case "preminor":
2270
- this.prerelease.length = 0;
2271
- this.patch = 0;
2272
- this.minor++;
2273
- this.inc("pre", identifier, identifierBase);
2274
- break;
2275
- case "prepatch":
2276
- this.prerelease.length = 0;
2277
- this.inc("patch", identifier, identifierBase);
2278
- this.inc("pre", identifier, identifierBase);
2279
- break;
2280
- // If the input is a non-prerelease version, this acts the same as
2281
- // prepatch.
2282
- case "prerelease":
2283
- if (this.prerelease.length === 0) {
2284
- this.inc("patch", identifier, identifierBase);
2285
- }
2286
- this.inc("pre", identifier, identifierBase);
2287
- break;
2288
- case "release":
2289
- if (this.prerelease.length === 0) {
2290
- throw new Error(`version ${this.raw} is not a prerelease`);
2291
- }
2292
- this.prerelease.length = 0;
2293
- break;
2294
- case "major":
2295
- if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
2296
- this.major++;
2297
- }
2298
- this.minor = 0;
2299
- this.patch = 0;
2300
- this.prerelease = [];
2301
- break;
2302
- case "minor":
2303
- if (this.patch !== 0 || this.prerelease.length === 0) {
2304
- this.minor++;
2305
- }
2306
- this.patch = 0;
2307
- this.prerelease = [];
2308
- break;
2309
- case "patch":
2310
- if (this.prerelease.length === 0) {
2311
- this.patch++;
2312
- }
2313
- this.prerelease = [];
2314
- break;
2315
- // This probably shouldn't be used publicly.
2316
- // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
2317
- case "pre": {
2318
- const base = Number(identifierBase) ? 1 : 0;
2319
- if (this.prerelease.length === 0) {
2320
- this.prerelease = [base];
2321
- } else {
2322
- let i = this.prerelease.length;
2323
- while (--i >= 0) {
2324
- if (typeof this.prerelease[i] === "number") {
2325
- this.prerelease[i]++;
2326
- i = -2;
2327
- }
2328
- }
2329
- if (i === -1) {
2330
- if (identifier === this.prerelease.join(".") && identifierBase === false) {
2331
- throw new Error("invalid increment argument: identifier already exists");
2332
- }
2333
- this.prerelease.push(base);
2334
- }
2335
- }
2336
- if (identifier) {
2337
- let prerelease = [identifier, base];
2338
- if (identifierBase === false) {
2339
- prerelease = [identifier];
2340
- }
2341
- if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
2342
- if (isNaN(this.prerelease[1])) {
2343
- this.prerelease = prerelease;
2344
- }
2345
- } else {
2346
- this.prerelease = prerelease;
2347
- }
2348
- }
2349
- break;
2350
- }
2351
- default:
2352
- throw new Error(`invalid increment argument: ${release}`);
2353
- }
2354
- this.raw = this.format();
2355
- if (this.build.length) {
2356
- this.raw += `+${this.build.join(".")}`;
2357
- }
2358
- return this;
2359
- }
2360
- };
2361
- module2.exports = SemVer;
2362
- }
2363
- });
2364
-
2365
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/parse.js
2366
- var require_parse = __commonJS({
2367
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/parse.js"(exports2, module2) {
2368
- "use strict";
2369
- var SemVer = require_semver();
2370
- var parse = /* @__PURE__ */ __name((version, options, throwErrors = false) => {
2371
- if (version instanceof SemVer) {
2372
- return version;
2373
- }
2374
- try {
2375
- return new SemVer(version, options);
2376
- } catch (er) {
2377
- if (!throwErrors) {
2378
- return null;
2379
- }
2380
- throw er;
2381
- }
2382
- }, "parse");
2383
- module2.exports = parse;
2384
- }
2385
- });
2386
-
2387
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/valid.js
2388
- var require_valid = __commonJS({
2389
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/valid.js"(exports2, module2) {
2390
- "use strict";
2391
- var parse = require_parse();
2392
- var valid = /* @__PURE__ */ __name((version, options) => {
2393
- const v = parse(version, options);
2394
- return v ? v.version : null;
2395
- }, "valid");
2396
- module2.exports = valid;
2397
- }
2398
- });
2399
-
2400
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/clean.js
2401
- var require_clean = __commonJS({
2402
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/clean.js"(exports2, module2) {
2403
- "use strict";
2404
- var parse = require_parse();
2405
- var clean = /* @__PURE__ */ __name((version, options) => {
2406
- const s = parse(version.trim().replace(/^[=v]+/, ""), options);
2407
- return s ? s.version : null;
2408
- }, "clean");
2409
- module2.exports = clean;
2410
- }
2411
- });
2412
-
2413
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/inc.js
2414
- var require_inc = __commonJS({
2415
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/inc.js"(exports2, module2) {
2416
- "use strict";
2417
- var SemVer = require_semver();
2418
- var inc = /* @__PURE__ */ __name((version, release, options, identifier, identifierBase) => {
2419
- if (typeof options === "string") {
2420
- identifierBase = identifier;
2421
- identifier = options;
2422
- options = void 0;
2423
- }
2424
- try {
2425
- return new SemVer(
2426
- version instanceof SemVer ? version.version : version,
2427
- options
2428
- ).inc(release, identifier, identifierBase).version;
2429
- } catch (er) {
2430
- return null;
2431
- }
2432
- }, "inc");
2433
- module2.exports = inc;
2434
- }
2435
- });
2436
-
2437
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/diff.js
2438
- var require_diff = __commonJS({
2439
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/diff.js"(exports2, module2) {
2440
- "use strict";
2441
- var parse = require_parse();
2442
- var diff = /* @__PURE__ */ __name((version1, version2) => {
2443
- const v1 = parse(version1, null, true);
2444
- const v2 = parse(version2, null, true);
2445
- const comparison = v1.compare(v2);
2446
- if (comparison === 0) {
2447
- return null;
2448
- }
2449
- const v1Higher = comparison > 0;
2450
- const highVersion = v1Higher ? v1 : v2;
2451
- const lowVersion = v1Higher ? v2 : v1;
2452
- const highHasPre = !!highVersion.prerelease.length;
2453
- const lowHasPre = !!lowVersion.prerelease.length;
2454
- if (lowHasPre && !highHasPre) {
2455
- if (!lowVersion.patch && !lowVersion.minor) {
2456
- return "major";
2457
- }
2458
- if (lowVersion.compareMain(highVersion) === 0) {
2459
- if (lowVersion.minor && !lowVersion.patch) {
2460
- return "minor";
2461
- }
2462
- return "patch";
2463
- }
2464
- }
2465
- const prefix = highHasPre ? "pre" : "";
2466
- if (v1.major !== v2.major) {
2467
- return prefix + "major";
2468
- }
2469
- if (v1.minor !== v2.minor) {
2470
- return prefix + "minor";
2471
- }
2472
- if (v1.patch !== v2.patch) {
2473
- return prefix + "patch";
2474
- }
2475
- return "prerelease";
2476
- }, "diff");
2477
- module2.exports = diff;
2478
- }
2479
- });
2480
-
2481
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/major.js
2482
- var require_major = __commonJS({
2483
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/major.js"(exports2, module2) {
2484
- "use strict";
2485
- var SemVer = require_semver();
2486
- var major = /* @__PURE__ */ __name((a, loose) => new SemVer(a, loose).major, "major");
2487
- module2.exports = major;
2488
- }
2489
- });
2490
-
2491
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/minor.js
2492
- var require_minor = __commonJS({
2493
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/minor.js"(exports2, module2) {
2494
- "use strict";
2495
- var SemVer = require_semver();
2496
- var minor = /* @__PURE__ */ __name((a, loose) => new SemVer(a, loose).minor, "minor");
2497
- module2.exports = minor;
2498
- }
2499
- });
2500
-
2501
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/patch.js
2502
- var require_patch = __commonJS({
2503
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/patch.js"(exports2, module2) {
2504
- "use strict";
2505
- var SemVer = require_semver();
2506
- var patch = /* @__PURE__ */ __name((a, loose) => new SemVer(a, loose).patch, "patch");
2507
- module2.exports = patch;
2508
- }
2509
- });
2510
-
2511
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/prerelease.js
2512
- var require_prerelease = __commonJS({
2513
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/prerelease.js"(exports2, module2) {
2514
- "use strict";
2515
- var parse = require_parse();
2516
- var prerelease = /* @__PURE__ */ __name((version, options) => {
2517
- const parsed = parse(version, options);
2518
- return parsed && parsed.prerelease.length ? parsed.prerelease : null;
2519
- }, "prerelease");
2520
- module2.exports = prerelease;
2521
- }
2522
- });
2523
-
2524
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/compare.js
2525
- var require_compare = __commonJS({
2526
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/compare.js"(exports2, module2) {
2527
- "use strict";
2528
- var SemVer = require_semver();
2529
- var compare = /* @__PURE__ */ __name((a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose)), "compare");
2530
- module2.exports = compare;
2531
- }
2532
- });
2533
-
2534
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/rcompare.js
2535
- var require_rcompare = __commonJS({
2536
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/rcompare.js"(exports2, module2) {
2537
- "use strict";
2538
- var compare = require_compare();
2539
- var rcompare = /* @__PURE__ */ __name((a, b, loose) => compare(b, a, loose), "rcompare");
2540
- module2.exports = rcompare;
2541
- }
2542
- });
2543
-
2544
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/compare-loose.js
2545
- var require_compare_loose = __commonJS({
2546
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/compare-loose.js"(exports2, module2) {
2547
- "use strict";
2548
- var compare = require_compare();
2549
- var compareLoose = /* @__PURE__ */ __name((a, b) => compare(a, b, true), "compareLoose");
2550
- module2.exports = compareLoose;
2551
- }
2552
- });
2553
-
2554
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/compare-build.js
2555
- var require_compare_build = __commonJS({
2556
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/compare-build.js"(exports2, module2) {
2557
- "use strict";
2558
- var SemVer = require_semver();
2559
- var compareBuild = /* @__PURE__ */ __name((a, b, loose) => {
2560
- const versionA = new SemVer(a, loose);
2561
- const versionB = new SemVer(b, loose);
2562
- return versionA.compare(versionB) || versionA.compareBuild(versionB);
2563
- }, "compareBuild");
2564
- module2.exports = compareBuild;
2565
- }
2566
- });
2567
-
2568
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/sort.js
2569
- var require_sort = __commonJS({
2570
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/sort.js"(exports2, module2) {
2571
- "use strict";
2572
- var compareBuild = require_compare_build();
2573
- var sort = /* @__PURE__ */ __name((list, loose) => list.sort((a, b) => compareBuild(a, b, loose)), "sort");
2574
- module2.exports = sort;
2575
- }
2576
- });
2577
-
2578
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/rsort.js
2579
- var require_rsort = __commonJS({
2580
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/rsort.js"(exports2, module2) {
2581
- "use strict";
2582
- var compareBuild = require_compare_build();
2583
- var rsort = /* @__PURE__ */ __name((list, loose) => list.sort((a, b) => compareBuild(b, a, loose)), "rsort");
2584
- module2.exports = rsort;
2585
- }
2586
- });
2587
-
2588
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/gt.js
2589
- var require_gt = __commonJS({
2590
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/gt.js"(exports2, module2) {
2591
- "use strict";
2592
- var compare = require_compare();
2593
- var gt = /* @__PURE__ */ __name((a, b, loose) => compare(a, b, loose) > 0, "gt");
2594
- module2.exports = gt;
2595
- }
2596
- });
2597
-
2598
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/lt.js
2599
- var require_lt = __commonJS({
2600
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/lt.js"(exports2, module2) {
2601
- "use strict";
2602
- var compare = require_compare();
2603
- var lt = /* @__PURE__ */ __name((a, b, loose) => compare(a, b, loose) < 0, "lt");
2604
- module2.exports = lt;
2605
- }
2606
- });
2607
-
2608
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/eq.js
2609
- var require_eq = __commonJS({
2610
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/eq.js"(exports2, module2) {
2611
- "use strict";
2612
- var compare = require_compare();
2613
- var eq = /* @__PURE__ */ __name((a, b, loose) => compare(a, b, loose) === 0, "eq");
2614
- module2.exports = eq;
2615
- }
2616
- });
2617
-
2618
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/neq.js
2619
- var require_neq = __commonJS({
2620
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/neq.js"(exports2, module2) {
2621
- "use strict";
2622
- var compare = require_compare();
2623
- var neq = /* @__PURE__ */ __name((a, b, loose) => compare(a, b, loose) !== 0, "neq");
2624
- module2.exports = neq;
2625
- }
2626
- });
2627
-
2628
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/gte.js
2629
- var require_gte = __commonJS({
2630
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/gte.js"(exports2, module2) {
2631
- "use strict";
2632
- var compare = require_compare();
2633
- var gte = /* @__PURE__ */ __name((a, b, loose) => compare(a, b, loose) >= 0, "gte");
2634
- module2.exports = gte;
2635
- }
2636
- });
2637
-
2638
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/lte.js
2639
- var require_lte = __commonJS({
2640
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/lte.js"(exports2, module2) {
2641
- "use strict";
2642
- var compare = require_compare();
2643
- var lte = /* @__PURE__ */ __name((a, b, loose) => compare(a, b, loose) <= 0, "lte");
2644
- module2.exports = lte;
2645
- }
2646
- });
2647
-
2648
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/cmp.js
2649
- var require_cmp = __commonJS({
2650
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/cmp.js"(exports2, module2) {
2651
- "use strict";
2652
- var eq = require_eq();
2653
- var neq = require_neq();
2654
- var gt = require_gt();
2655
- var gte = require_gte();
2656
- var lt = require_lt();
2657
- var lte = require_lte();
2658
- var cmp = /* @__PURE__ */ __name((a, op, b, loose) => {
2659
- switch (op) {
2660
- case "===":
2661
- if (typeof a === "object") {
2662
- a = a.version;
2663
- }
2664
- if (typeof b === "object") {
2665
- b = b.version;
2666
- }
2667
- return a === b;
2668
- case "!==":
2669
- if (typeof a === "object") {
2670
- a = a.version;
2671
- }
2672
- if (typeof b === "object") {
2673
- b = b.version;
2674
- }
2675
- return a !== b;
2676
- case "":
2677
- case "=":
2678
- case "==":
2679
- return eq(a, b, loose);
2680
- case "!=":
2681
- return neq(a, b, loose);
2682
- case ">":
2683
- return gt(a, b, loose);
2684
- case ">=":
2685
- return gte(a, b, loose);
2686
- case "<":
2687
- return lt(a, b, loose);
2688
- case "<=":
2689
- return lte(a, b, loose);
2690
- default:
2691
- throw new TypeError(`Invalid operator: ${op}`);
2692
- }
2693
- }, "cmp");
2694
- module2.exports = cmp;
2695
- }
2696
- });
2697
-
2698
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/coerce.js
2699
- var require_coerce = __commonJS({
2700
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/coerce.js"(exports2, module2) {
2701
- "use strict";
2702
- var SemVer = require_semver();
2703
- var parse = require_parse();
2704
- var { safeRe: re, t } = require_re();
2705
- var coerce = /* @__PURE__ */ __name((version, options) => {
2706
- if (version instanceof SemVer) {
2707
- return version;
2708
- }
2709
- if (typeof version === "number") {
2710
- version = String(version);
2711
- }
2712
- if (typeof version !== "string") {
2713
- return null;
2714
- }
2715
- options = options || {};
2716
- let match = null;
2717
- if (!options.rtl) {
2718
- match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
2719
- } else {
2720
- const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
2721
- let next;
2722
- while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
2723
- if (!match || next.index + next[0].length !== match.index + match[0].length) {
2724
- match = next;
2725
- }
2726
- coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
2727
- }
2728
- coerceRtlRegex.lastIndex = -1;
2729
- }
2730
- if (match === null) {
2731
- return null;
2732
- }
2733
- const major = match[2];
2734
- const minor = match[3] || "0";
2735
- const patch = match[4] || "0";
2736
- const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
2737
- const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
2738
- return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
2739
- }, "coerce");
2740
- module2.exports = coerce;
2741
- }
2742
- });
2743
-
2744
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/lrucache.js
2745
- var require_lrucache = __commonJS({
2746
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/lrucache.js"(exports2, module2) {
2747
- "use strict";
2748
- var LRUCache = class {
2749
- static {
2750
- __name(this, "LRUCache");
2751
- }
2752
- constructor() {
2753
- this.max = 1e3;
2754
- this.map = /* @__PURE__ */ new Map();
2755
- }
2756
- get(key) {
2757
- const value = this.map.get(key);
2758
- if (value === void 0) {
2759
- return void 0;
2760
- } else {
2761
- this.map.delete(key);
2762
- this.map.set(key, value);
2763
- return value;
2764
- }
2765
- }
2766
- delete(key) {
2767
- return this.map.delete(key);
2768
- }
2769
- set(key, value) {
2770
- const deleted = this.delete(key);
2771
- if (!deleted && value !== void 0) {
2772
- if (this.map.size >= this.max) {
2773
- const firstKey = this.map.keys().next().value;
2774
- this.delete(firstKey);
2775
- }
2776
- this.map.set(key, value);
2777
- }
2778
- return this;
2779
- }
2780
- };
2781
- module2.exports = LRUCache;
2782
- }
2783
- });
2784
-
2785
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/range.js
2786
- var require_range = __commonJS({
2787
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/range.js"(exports2, module2) {
2788
- "use strict";
2789
- var SPACE_CHARACTERS = /\s+/g;
2790
- var Range = class _Range {
2791
- static {
2792
- __name(this, "Range");
2793
- }
2794
- constructor(range, options) {
2795
- options = parseOptions(options);
2796
- if (range instanceof _Range) {
2797
- if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
2798
- return range;
2799
- } else {
2800
- return new _Range(range.raw, options);
2801
- }
2802
- }
2803
- if (range instanceof Comparator) {
2804
- this.raw = range.value;
2805
- this.set = [[range]];
2806
- this.formatted = void 0;
2807
- return this;
2808
- }
2809
- this.options = options;
2810
- this.loose = !!options.loose;
2811
- this.includePrerelease = !!options.includePrerelease;
2812
- this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
2813
- this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
2814
- if (!this.set.length) {
2815
- throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
2816
- }
2817
- if (this.set.length > 1) {
2818
- const first = this.set[0];
2819
- this.set = this.set.filter((c) => !isNullSet(c[0]));
2820
- if (this.set.length === 0) {
2821
- this.set = [first];
2822
- } else if (this.set.length > 1) {
2823
- for (const c of this.set) {
2824
- if (c.length === 1 && isAny(c[0])) {
2825
- this.set = [c];
2826
- break;
2827
- }
2828
- }
2829
- }
2830
- }
2831
- this.formatted = void 0;
2832
- }
2833
- get range() {
2834
- if (this.formatted === void 0) {
2835
- this.formatted = "";
2836
- for (let i = 0; i < this.set.length; i++) {
2837
- if (i > 0) {
2838
- this.formatted += "||";
2839
- }
2840
- const comps = this.set[i];
2841
- for (let k = 0; k < comps.length; k++) {
2842
- if (k > 0) {
2843
- this.formatted += " ";
2844
- }
2845
- this.formatted += comps[k].toString().trim();
2846
- }
2847
- }
2848
- }
2849
- return this.formatted;
2850
- }
2851
- format() {
2852
- return this.range;
2853
- }
2854
- toString() {
2855
- return this.range;
2856
- }
2857
- parseRange(range) {
2858
- const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
2859
- const memoKey = memoOpts + ":" + range;
2860
- const cached = cache.get(memoKey);
2861
- if (cached) {
2862
- return cached;
2863
- }
2864
- const loose = this.options.loose;
2865
- const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
2866
- range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
2867
- debug("hyphen replace", range);
2868
- range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
2869
- debug("comparator trim", range);
2870
- range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
2871
- debug("tilde trim", range);
2872
- range = range.replace(re[t.CARETTRIM], caretTrimReplace);
2873
- debug("caret trim", range);
2874
- let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
2875
- if (loose) {
2876
- rangeList = rangeList.filter((comp) => {
2877
- debug("loose invalid filter", comp, this.options);
2878
- return !!comp.match(re[t.COMPARATORLOOSE]);
2879
- });
2880
- }
2881
- debug("range list", rangeList);
2882
- const rangeMap = /* @__PURE__ */ new Map();
2883
- const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
2884
- for (const comp of comparators) {
2885
- if (isNullSet(comp)) {
2886
- return [comp];
2887
- }
2888
- rangeMap.set(comp.value, comp);
2889
- }
2890
- if (rangeMap.size > 1 && rangeMap.has("")) {
2891
- rangeMap.delete("");
2892
- }
2893
- const result = [...rangeMap.values()];
2894
- cache.set(memoKey, result);
2895
- return result;
2896
- }
2897
- intersects(range, options) {
2898
- if (!(range instanceof _Range)) {
2899
- throw new TypeError("a Range is required");
2900
- }
2901
- return this.set.some((thisComparators) => {
2902
- return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
2903
- return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
2904
- return rangeComparators.every((rangeComparator) => {
2905
- return thisComparator.intersects(rangeComparator, options);
2906
- });
2907
- });
2908
- });
2909
- });
2910
- }
2911
- // if ANY of the sets match ALL of its comparators, then pass
2912
- test(version) {
2913
- if (!version) {
2914
- return false;
2915
- }
2916
- if (typeof version === "string") {
2917
- try {
2918
- version = new SemVer(version, this.options);
2919
- } catch (er) {
2920
- return false;
2921
- }
2922
- }
2923
- for (let i = 0; i < this.set.length; i++) {
2924
- if (testSet(this.set[i], version, this.options)) {
2925
- return true;
2926
- }
2927
- }
2928
- return false;
2929
- }
2930
- };
2931
- module2.exports = Range;
2932
- var LRU = require_lrucache();
2933
- var cache = new LRU();
2934
- var parseOptions = require_parse_options();
2935
- var Comparator = require_comparator();
2936
- var debug = require_debug();
2937
- var SemVer = require_semver();
2938
- var {
2939
- safeRe: re,
2940
- t,
2941
- comparatorTrimReplace,
2942
- tildeTrimReplace,
2943
- caretTrimReplace
2944
- } = require_re();
2945
- var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
2946
- var isNullSet = /* @__PURE__ */ __name((c) => c.value === "<0.0.0-0", "isNullSet");
2947
- var isAny = /* @__PURE__ */ __name((c) => c.value === "", "isAny");
2948
- var isSatisfiable = /* @__PURE__ */ __name((comparators, options) => {
2949
- let result = true;
2950
- const remainingComparators = comparators.slice();
2951
- let testComparator = remainingComparators.pop();
2952
- while (result && remainingComparators.length) {
2953
- result = remainingComparators.every((otherComparator) => {
2954
- return testComparator.intersects(otherComparator, options);
2955
- });
2956
- testComparator = remainingComparators.pop();
2957
- }
2958
- return result;
2959
- }, "isSatisfiable");
2960
- var parseComparator = /* @__PURE__ */ __name((comp, options) => {
2961
- debug("comp", comp, options);
2962
- comp = replaceCarets(comp, options);
2963
- debug("caret", comp);
2964
- comp = replaceTildes(comp, options);
2965
- debug("tildes", comp);
2966
- comp = replaceXRanges(comp, options);
2967
- debug("xrange", comp);
2968
- comp = replaceStars(comp, options);
2969
- debug("stars", comp);
2970
- return comp;
2971
- }, "parseComparator");
2972
- var isX = /* @__PURE__ */ __name((id) => !id || id.toLowerCase() === "x" || id === "*", "isX");
2973
- var replaceTildes = /* @__PURE__ */ __name((comp, options) => {
2974
- return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
2975
- }, "replaceTildes");
2976
- var replaceTilde = /* @__PURE__ */ __name((comp, options) => {
2977
- const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
2978
- return comp.replace(r, (_, M, m, p, pr) => {
2979
- debug("tilde", comp, _, M, m, p, pr);
2980
- let ret;
2981
- if (isX(M)) {
2982
- ret = "";
2983
- } else if (isX(m)) {
2984
- ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
2985
- } else if (isX(p)) {
2986
- ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
2987
- } else if (pr) {
2988
- debug("replaceTilde pr", pr);
2989
- ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
2990
- } else {
2991
- ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
2992
- }
2993
- debug("tilde return", ret);
2994
- return ret;
2995
- });
2996
- }, "replaceTilde");
2997
- var replaceCarets = /* @__PURE__ */ __name((comp, options) => {
2998
- return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
2999
- }, "replaceCarets");
3000
- var replaceCaret = /* @__PURE__ */ __name((comp, options) => {
3001
- debug("caret", comp, options);
3002
- const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
3003
- const z = options.includePrerelease ? "-0" : "";
3004
- return comp.replace(r, (_, M, m, p, pr) => {
3005
- debug("caret", comp, _, M, m, p, pr);
3006
- let ret;
3007
- if (isX(M)) {
3008
- ret = "";
3009
- } else if (isX(m)) {
3010
- ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
3011
- } else if (isX(p)) {
3012
- if (M === "0") {
3013
- ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
3014
- } else {
3015
- ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
3016
- }
3017
- } else if (pr) {
3018
- debug("replaceCaret pr", pr);
3019
- if (M === "0") {
3020
- if (m === "0") {
3021
- ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
3022
- } else {
3023
- ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
3024
- }
3025
- } else {
3026
- ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
3027
- }
3028
- } else {
3029
- debug("no pr");
3030
- if (M === "0") {
3031
- if (m === "0") {
3032
- ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`;
3033
- } else {
3034
- ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`;
3035
- }
3036
- } else {
3037
- ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
3038
- }
3039
- }
3040
- debug("caret return", ret);
3041
- return ret;
3042
- });
3043
- }, "replaceCaret");
3044
- var replaceXRanges = /* @__PURE__ */ __name((comp, options) => {
3045
- debug("replaceXRanges", comp, options);
3046
- return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
3047
- }, "replaceXRanges");
3048
- var replaceXRange = /* @__PURE__ */ __name((comp, options) => {
3049
- comp = comp.trim();
3050
- const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
3051
- return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
3052
- debug("xRange", comp, ret, gtlt, M, m, p, pr);
3053
- const xM = isX(M);
3054
- const xm = xM || isX(m);
3055
- const xp = xm || isX(p);
3056
- const anyX = xp;
3057
- if (gtlt === "=" && anyX) {
3058
- gtlt = "";
3059
- }
3060
- pr = options.includePrerelease ? "-0" : "";
3061
- if (xM) {
3062
- if (gtlt === ">" || gtlt === "<") {
3063
- ret = "<0.0.0-0";
3064
- } else {
3065
- ret = "*";
3066
- }
3067
- } else if (gtlt && anyX) {
3068
- if (xm) {
3069
- m = 0;
3070
- }
3071
- p = 0;
3072
- if (gtlt === ">") {
3073
- gtlt = ">=";
3074
- if (xm) {
3075
- M = +M + 1;
3076
- m = 0;
3077
- p = 0;
3078
- } else {
3079
- m = +m + 1;
3080
- p = 0;
3081
- }
3082
- } else if (gtlt === "<=") {
3083
- gtlt = "<";
3084
- if (xm) {
3085
- M = +M + 1;
3086
- } else {
3087
- m = +m + 1;
3088
- }
3089
- }
3090
- if (gtlt === "<") {
3091
- pr = "-0";
3092
- }
3093
- ret = `${gtlt + M}.${m}.${p}${pr}`;
3094
- } else if (xm) {
3095
- ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
3096
- } else if (xp) {
3097
- ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
3098
- }
3099
- debug("xRange return", ret);
3100
- return ret;
3101
- });
3102
- }, "replaceXRange");
3103
- var replaceStars = /* @__PURE__ */ __name((comp, options) => {
3104
- debug("replaceStars", comp, options);
3105
- return comp.trim().replace(re[t.STAR], "");
3106
- }, "replaceStars");
3107
- var replaceGTE0 = /* @__PURE__ */ __name((comp, options) => {
3108
- debug("replaceGTE0", comp, options);
3109
- return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
3110
- }, "replaceGTE0");
3111
- var hyphenReplace = /* @__PURE__ */ __name((incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
3112
- if (isX(fM)) {
3113
- from = "";
3114
- } else if (isX(fm)) {
3115
- from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
3116
- } else if (isX(fp)) {
3117
- from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
3118
- } else if (fpr) {
3119
- from = `>=${from}`;
3120
- } else {
3121
- from = `>=${from}${incPr ? "-0" : ""}`;
3122
- }
3123
- if (isX(tM)) {
3124
- to = "";
3125
- } else if (isX(tm)) {
3126
- to = `<${+tM + 1}.0.0-0`;
3127
- } else if (isX(tp)) {
3128
- to = `<${tM}.${+tm + 1}.0-0`;
3129
- } else if (tpr) {
3130
- to = `<=${tM}.${tm}.${tp}-${tpr}`;
3131
- } else if (incPr) {
3132
- to = `<${tM}.${tm}.${+tp + 1}-0`;
3133
- } else {
3134
- to = `<=${to}`;
3135
- }
3136
- return `${from} ${to}`.trim();
3137
- }, "hyphenReplace");
3138
- var testSet = /* @__PURE__ */ __name((set, version, options) => {
3139
- for (let i = 0; i < set.length; i++) {
3140
- if (!set[i].test(version)) {
3141
- return false;
3142
- }
3143
- }
3144
- if (version.prerelease.length && !options.includePrerelease) {
3145
- for (let i = 0; i < set.length; i++) {
3146
- debug(set[i].semver);
3147
- if (set[i].semver === Comparator.ANY) {
3148
- continue;
3149
- }
3150
- if (set[i].semver.prerelease.length > 0) {
3151
- const allowed = set[i].semver;
3152
- if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
3153
- return true;
3154
- }
3155
- }
3156
- }
3157
- return false;
3158
- }
3159
- return true;
3160
- }, "testSet");
3161
- }
3162
- });
3163
-
3164
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/comparator.js
3165
- var require_comparator = __commonJS({
3166
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/comparator.js"(exports2, module2) {
3167
- "use strict";
3168
- var ANY = Symbol("SemVer ANY");
3169
- var Comparator = class _Comparator {
3170
- static {
3171
- __name(this, "Comparator");
3172
- }
3173
- static get ANY() {
3174
- return ANY;
3175
- }
3176
- constructor(comp, options) {
3177
- options = parseOptions(options);
3178
- if (comp instanceof _Comparator) {
3179
- if (comp.loose === !!options.loose) {
3180
- return comp;
3181
- } else {
3182
- comp = comp.value;
3183
- }
3184
- }
3185
- comp = comp.trim().split(/\s+/).join(" ");
3186
- debug("comparator", comp, options);
3187
- this.options = options;
3188
- this.loose = !!options.loose;
3189
- this.parse(comp);
3190
- if (this.semver === ANY) {
3191
- this.value = "";
3192
- } else {
3193
- this.value = this.operator + this.semver.version;
3194
- }
3195
- debug("comp", this);
3196
- }
3197
- parse(comp) {
3198
- const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
3199
- const m = comp.match(r);
3200
- if (!m) {
3201
- throw new TypeError(`Invalid comparator: ${comp}`);
3202
- }
3203
- this.operator = m[1] !== void 0 ? m[1] : "";
3204
- if (this.operator === "=") {
3205
- this.operator = "";
3206
- }
3207
- if (!m[2]) {
3208
- this.semver = ANY;
3209
- } else {
3210
- this.semver = new SemVer(m[2], this.options.loose);
3211
- }
3212
- }
3213
- toString() {
3214
- return this.value;
3215
- }
3216
- test(version) {
3217
- debug("Comparator.test", version, this.options.loose);
3218
- if (this.semver === ANY || version === ANY) {
3219
- return true;
3220
- }
3221
- if (typeof version === "string") {
3222
- try {
3223
- version = new SemVer(version, this.options);
3224
- } catch (er) {
3225
- return false;
3226
- }
3227
- }
3228
- return cmp(version, this.operator, this.semver, this.options);
3229
- }
3230
- intersects(comp, options) {
3231
- if (!(comp instanceof _Comparator)) {
3232
- throw new TypeError("a Comparator is required");
3233
- }
3234
- if (this.operator === "") {
3235
- if (this.value === "") {
3236
- return true;
3237
- }
3238
- return new Range(comp.value, options).test(this.value);
3239
- } else if (comp.operator === "") {
3240
- if (comp.value === "") {
3241
- return true;
3242
- }
3243
- return new Range(this.value, options).test(comp.semver);
3244
- }
3245
- options = parseOptions(options);
3246
- if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
3247
- return false;
3248
- }
3249
- if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
3250
- return false;
3251
- }
3252
- if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
3253
- return true;
3254
- }
3255
- if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
3256
- return true;
3257
- }
3258
- if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
3259
- return true;
3260
- }
3261
- if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
3262
- return true;
3263
- }
3264
- if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
3265
- return true;
3266
- }
3267
- return false;
3268
- }
3269
- };
3270
- module2.exports = Comparator;
3271
- var parseOptions = require_parse_options();
3272
- var { safeRe: re, t } = require_re();
3273
- var cmp = require_cmp();
3274
- var debug = require_debug();
3275
- var SemVer = require_semver();
3276
- var Range = require_range();
3277
- }
3278
- });
3279
-
3280
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/satisfies.js
3281
- var require_satisfies = __commonJS({
3282
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/satisfies.js"(exports2, module2) {
3283
- "use strict";
3284
- var Range = require_range();
3285
- var satisfies = /* @__PURE__ */ __name((version, range, options) => {
3286
- try {
3287
- range = new Range(range, options);
3288
- } catch (er) {
3289
- return false;
3290
- }
3291
- return range.test(version);
3292
- }, "satisfies");
3293
- module2.exports = satisfies;
3294
- }
3295
- });
3296
-
3297
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/to-comparators.js
3298
- var require_to_comparators = __commonJS({
3299
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/to-comparators.js"(exports2, module2) {
3300
- "use strict";
3301
- var Range = require_range();
3302
- var toComparators = /* @__PURE__ */ __name((range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" ")), "toComparators");
3303
- module2.exports = toComparators;
3304
- }
3305
- });
3306
-
3307
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/max-satisfying.js
3308
- var require_max_satisfying = __commonJS({
3309
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/max-satisfying.js"(exports2, module2) {
3310
- "use strict";
3311
- var SemVer = require_semver();
3312
- var Range = require_range();
3313
- var maxSatisfying = /* @__PURE__ */ __name((versions, range, options) => {
3314
- let max = null;
3315
- let maxSV = null;
3316
- let rangeObj = null;
3317
- try {
3318
- rangeObj = new Range(range, options);
3319
- } catch (er) {
3320
- return null;
3321
- }
3322
- versions.forEach((v) => {
3323
- if (rangeObj.test(v)) {
3324
- if (!max || maxSV.compare(v) === -1) {
3325
- max = v;
3326
- maxSV = new SemVer(max, options);
3327
- }
3328
- }
3329
- });
3330
- return max;
3331
- }, "maxSatisfying");
3332
- module2.exports = maxSatisfying;
3333
- }
3334
- });
3335
-
3336
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/min-satisfying.js
3337
- var require_min_satisfying = __commonJS({
3338
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/min-satisfying.js"(exports2, module2) {
3339
- "use strict";
3340
- var SemVer = require_semver();
3341
- var Range = require_range();
3342
- var minSatisfying = /* @__PURE__ */ __name((versions, range, options) => {
3343
- let min = null;
3344
- let minSV = null;
3345
- let rangeObj = null;
3346
- try {
3347
- rangeObj = new Range(range, options);
3348
- } catch (er) {
3349
- return null;
3350
- }
3351
- versions.forEach((v) => {
3352
- if (rangeObj.test(v)) {
3353
- if (!min || minSV.compare(v) === 1) {
3354
- min = v;
3355
- minSV = new SemVer(min, options);
3356
- }
3357
- }
3358
- });
3359
- return min;
3360
- }, "minSatisfying");
3361
- module2.exports = minSatisfying;
3362
- }
3363
- });
3364
-
3365
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/min-version.js
3366
- var require_min_version = __commonJS({
3367
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/min-version.js"(exports2, module2) {
3368
- "use strict";
3369
- var SemVer = require_semver();
3370
- var Range = require_range();
3371
- var gt = require_gt();
3372
- var minVersion = /* @__PURE__ */ __name((range, loose) => {
3373
- range = new Range(range, loose);
3374
- let minver = new SemVer("0.0.0");
3375
- if (range.test(minver)) {
3376
- return minver;
3377
- }
3378
- minver = new SemVer("0.0.0-0");
3379
- if (range.test(minver)) {
3380
- return minver;
3381
- }
3382
- minver = null;
3383
- for (let i = 0; i < range.set.length; ++i) {
3384
- const comparators = range.set[i];
3385
- let setMin = null;
3386
- comparators.forEach((comparator) => {
3387
- const compver = new SemVer(comparator.semver.version);
3388
- switch (comparator.operator) {
3389
- case ">":
3390
- if (compver.prerelease.length === 0) {
3391
- compver.patch++;
3392
- } else {
3393
- compver.prerelease.push(0);
3394
- }
3395
- compver.raw = compver.format();
3396
- /* fallthrough */
3397
- case "":
3398
- case ">=":
3399
- if (!setMin || gt(compver, setMin)) {
3400
- setMin = compver;
3401
- }
3402
- break;
3403
- case "<":
3404
- case "<=":
3405
- break;
3406
- /* istanbul ignore next */
3407
- default:
3408
- throw new Error(`Unexpected operation: ${comparator.operator}`);
3409
- }
3410
- });
3411
- if (setMin && (!minver || gt(minver, setMin))) {
3412
- minver = setMin;
3413
- }
3414
- }
3415
- if (minver && range.test(minver)) {
3416
- return minver;
3417
- }
3418
- return null;
3419
- }, "minVersion");
3420
- module2.exports = minVersion;
3421
- }
3422
- });
3423
-
3424
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/valid.js
3425
- var require_valid2 = __commonJS({
3426
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/valid.js"(exports2, module2) {
3427
- "use strict";
3428
- var Range = require_range();
3429
- var validRange = /* @__PURE__ */ __name((range, options) => {
3430
- try {
3431
- return new Range(range, options).range || "*";
3432
- } catch (er) {
3433
- return null;
3434
- }
3435
- }, "validRange");
3436
- module2.exports = validRange;
3437
- }
3438
- });
3439
-
3440
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/outside.js
3441
- var require_outside = __commonJS({
3442
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/outside.js"(exports2, module2) {
3443
- "use strict";
3444
- var SemVer = require_semver();
3445
- var Comparator = require_comparator();
3446
- var { ANY } = Comparator;
3447
- var Range = require_range();
3448
- var satisfies = require_satisfies();
3449
- var gt = require_gt();
3450
- var lt = require_lt();
3451
- var lte = require_lte();
3452
- var gte = require_gte();
3453
- var outside = /* @__PURE__ */ __name((version, range, hilo, options) => {
3454
- version = new SemVer(version, options);
3455
- range = new Range(range, options);
3456
- let gtfn, ltefn, ltfn, comp, ecomp;
3457
- switch (hilo) {
3458
- case ">":
3459
- gtfn = gt;
3460
- ltefn = lte;
3461
- ltfn = lt;
3462
- comp = ">";
3463
- ecomp = ">=";
3464
- break;
3465
- case "<":
3466
- gtfn = lt;
3467
- ltefn = gte;
3468
- ltfn = gt;
3469
- comp = "<";
3470
- ecomp = "<=";
3471
- break;
3472
- default:
3473
- throw new TypeError('Must provide a hilo val of "<" or ">"');
3474
- }
3475
- if (satisfies(version, range, options)) {
3476
- return false;
3477
- }
3478
- for (let i = 0; i < range.set.length; ++i) {
3479
- const comparators = range.set[i];
3480
- let high = null;
3481
- let low = null;
3482
- comparators.forEach((comparator) => {
3483
- if (comparator.semver === ANY) {
3484
- comparator = new Comparator(">=0.0.0");
3485
- }
3486
- high = high || comparator;
3487
- low = low || comparator;
3488
- if (gtfn(comparator.semver, high.semver, options)) {
3489
- high = comparator;
3490
- } else if (ltfn(comparator.semver, low.semver, options)) {
3491
- low = comparator;
3492
- }
3493
- });
3494
- if (high.operator === comp || high.operator === ecomp) {
3495
- return false;
3496
- }
3497
- if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
3498
- return false;
3499
- } else if (low.operator === ecomp && ltfn(version, low.semver)) {
3500
- return false;
3501
- }
3502
- }
3503
- return true;
3504
- }, "outside");
3505
- module2.exports = outside;
3506
- }
3507
- });
3508
-
3509
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/gtr.js
3510
- var require_gtr = __commonJS({
3511
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/gtr.js"(exports2, module2) {
3512
- "use strict";
3513
- var outside = require_outside();
3514
- var gtr = /* @__PURE__ */ __name((version, range, options) => outside(version, range, ">", options), "gtr");
3515
- module2.exports = gtr;
3516
- }
3517
- });
3518
-
3519
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/ltr.js
3520
- var require_ltr = __commonJS({
3521
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/ltr.js"(exports2, module2) {
3522
- "use strict";
3523
- var outside = require_outside();
3524
- var ltr = /* @__PURE__ */ __name((version, range, options) => outside(version, range, "<", options), "ltr");
3525
- module2.exports = ltr;
3526
- }
3527
- });
3528
-
3529
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/intersects.js
3530
- var require_intersects = __commonJS({
3531
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/intersects.js"(exports2, module2) {
3532
- "use strict";
3533
- var Range = require_range();
3534
- var intersects = /* @__PURE__ */ __name((r1, r2, options) => {
3535
- r1 = new Range(r1, options);
3536
- r2 = new Range(r2, options);
3537
- return r1.intersects(r2, options);
3538
- }, "intersects");
3539
- module2.exports = intersects;
3540
- }
3541
- });
3542
-
3543
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/simplify.js
3544
- var require_simplify = __commonJS({
3545
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/simplify.js"(exports2, module2) {
3546
- "use strict";
3547
- var satisfies = require_satisfies();
3548
- var compare = require_compare();
3549
- module2.exports = (versions, range, options) => {
3550
- const set = [];
3551
- let first = null;
3552
- let prev = null;
3553
- const v = versions.sort((a, b) => compare(a, b, options));
3554
- for (const version of v) {
3555
- const included = satisfies(version, range, options);
3556
- if (included) {
3557
- prev = version;
3558
- if (!first) {
3559
- first = version;
3560
- }
3561
- } else {
3562
- if (prev) {
3563
- set.push([first, prev]);
3564
- }
3565
- prev = null;
3566
- first = null;
3567
- }
3568
- }
3569
- if (first) {
3570
- set.push([first, null]);
3571
- }
3572
- const ranges = [];
3573
- for (const [min, max] of set) {
3574
- if (min === max) {
3575
- ranges.push(min);
3576
- } else if (!max && min === v[0]) {
3577
- ranges.push("*");
3578
- } else if (!max) {
3579
- ranges.push(`>=${min}`);
3580
- } else if (min === v[0]) {
3581
- ranges.push(`<=${max}`);
3582
- } else {
3583
- ranges.push(`${min} - ${max}`);
3584
- }
3585
- }
3586
- const simplified = ranges.join(" || ");
3587
- const original = typeof range.raw === "string" ? range.raw : String(range);
3588
- return simplified.length < original.length ? simplified : range;
3589
- };
3590
- }
3591
- });
3592
-
3593
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/subset.js
3594
- var require_subset = __commonJS({
3595
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/subset.js"(exports2, module2) {
3596
- "use strict";
3597
- var Range = require_range();
3598
- var Comparator = require_comparator();
3599
- var { ANY } = Comparator;
3600
- var satisfies = require_satisfies();
3601
- var compare = require_compare();
3602
- var subset = /* @__PURE__ */ __name((sub, dom, options = {}) => {
3603
- if (sub === dom) {
3604
- return true;
3605
- }
3606
- sub = new Range(sub, options);
3607
- dom = new Range(dom, options);
3608
- let sawNonNull = false;
3609
- OUTER: for (const simpleSub of sub.set) {
3610
- for (const simpleDom of dom.set) {
3611
- const isSub = simpleSubset(simpleSub, simpleDom, options);
3612
- sawNonNull = sawNonNull || isSub !== null;
3613
- if (isSub) {
3614
- continue OUTER;
3615
- }
3616
- }
3617
- if (sawNonNull) {
3618
- return false;
3619
- }
3620
- }
3621
- return true;
3622
- }, "subset");
3623
- var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
3624
- var minimumVersion = [new Comparator(">=0.0.0")];
3625
- var simpleSubset = /* @__PURE__ */ __name((sub, dom, options) => {
3626
- if (sub === dom) {
3627
- return true;
3628
- }
3629
- if (sub.length === 1 && sub[0].semver === ANY) {
3630
- if (dom.length === 1 && dom[0].semver === ANY) {
3631
- return true;
3632
- } else if (options.includePrerelease) {
3633
- sub = minimumVersionWithPreRelease;
3634
- } else {
3635
- sub = minimumVersion;
3636
- }
3637
- }
3638
- if (dom.length === 1 && dom[0].semver === ANY) {
3639
- if (options.includePrerelease) {
3640
- return true;
3641
- } else {
3642
- dom = minimumVersion;
3643
- }
3644
- }
3645
- const eqSet = /* @__PURE__ */ new Set();
3646
- let gt, lt;
3647
- for (const c of sub) {
3648
- if (c.operator === ">" || c.operator === ">=") {
3649
- gt = higherGT(gt, c, options);
3650
- } else if (c.operator === "<" || c.operator === "<=") {
3651
- lt = lowerLT(lt, c, options);
3652
- } else {
3653
- eqSet.add(c.semver);
3654
- }
3655
- }
3656
- if (eqSet.size > 1) {
3657
- return null;
3658
- }
3659
- let gtltComp;
3660
- if (gt && lt) {
3661
- gtltComp = compare(gt.semver, lt.semver, options);
3662
- if (gtltComp > 0) {
3663
- return null;
3664
- } else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) {
3665
- return null;
3666
- }
3667
- }
3668
- for (const eq of eqSet) {
3669
- if (gt && !satisfies(eq, String(gt), options)) {
3670
- return null;
3671
- }
3672
- if (lt && !satisfies(eq, String(lt), options)) {
3673
- return null;
3674
- }
3675
- for (const c of dom) {
3676
- if (!satisfies(eq, String(c), options)) {
3677
- return false;
3678
- }
3679
- }
3680
- return true;
3681
- }
3682
- let higher, lower;
3683
- let hasDomLT, hasDomGT;
3684
- let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
3685
- let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
3686
- if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) {
3687
- needDomLTPre = false;
3688
- }
3689
- for (const c of dom) {
3690
- hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
3691
- hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
3692
- if (gt) {
3693
- if (needDomGTPre) {
3694
- if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
3695
- needDomGTPre = false;
3696
- }
3697
- }
3698
- if (c.operator === ">" || c.operator === ">=") {
3699
- higher = higherGT(gt, c, options);
3700
- if (higher === c && higher !== gt) {
3701
- return false;
3702
- }
3703
- } else if (gt.operator === ">=" && !satisfies(gt.semver, String(c), options)) {
3704
- return false;
3705
- }
3706
- }
3707
- if (lt) {
3708
- if (needDomLTPre) {
3709
- if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
3710
- needDomLTPre = false;
3711
- }
3712
- }
3713
- if (c.operator === "<" || c.operator === "<=") {
3714
- lower = lowerLT(lt, c, options);
3715
- if (lower === c && lower !== lt) {
3716
- return false;
3717
- }
3718
- } else if (lt.operator === "<=" && !satisfies(lt.semver, String(c), options)) {
3719
- return false;
3720
- }
3721
- }
3722
- if (!c.operator && (lt || gt) && gtltComp !== 0) {
3723
- return false;
3724
- }
3725
- }
3726
- if (gt && hasDomLT && !lt && gtltComp !== 0) {
3727
- return false;
3728
- }
3729
- if (lt && hasDomGT && !gt && gtltComp !== 0) {
3730
- return false;
3731
- }
3732
- if (needDomGTPre || needDomLTPre) {
3733
- return false;
3734
- }
3735
- return true;
3736
- }, "simpleSubset");
3737
- var higherGT = /* @__PURE__ */ __name((a, b, options) => {
3738
- if (!a) {
3739
- return b;
3740
- }
3741
- const comp = compare(a.semver, b.semver, options);
3742
- return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
3743
- }, "higherGT");
3744
- var lowerLT = /* @__PURE__ */ __name((a, b, options) => {
3745
- if (!a) {
3746
- return b;
3747
- }
3748
- const comp = compare(a.semver, b.semver, options);
3749
- return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
3750
- }, "lowerLT");
3751
- module2.exports = subset;
3752
- }
3753
- });
3754
-
3755
- // node_modules/.pnpm/semver@7.7.2/node_modules/semver/index.js
3756
- var require_semver2 = __commonJS({
3757
- "node_modules/.pnpm/semver@7.7.2/node_modules/semver/index.js"(exports2, module2) {
3758
- "use strict";
3759
- var internalRe = require_re();
3760
- var constants = require_constants();
3761
- var SemVer = require_semver();
3762
- var identifiers = require_identifiers();
3763
- var parse = require_parse();
3764
- var valid = require_valid();
3765
- var clean = require_clean();
3766
- var inc = require_inc();
3767
- var diff = require_diff();
3768
- var major = require_major();
3769
- var minor = require_minor();
3770
- var patch = require_patch();
3771
- var prerelease = require_prerelease();
3772
- var compare = require_compare();
3773
- var rcompare = require_rcompare();
3774
- var compareLoose = require_compare_loose();
3775
- var compareBuild = require_compare_build();
3776
- var sort = require_sort();
3777
- var rsort = require_rsort();
3778
- var gt = require_gt();
3779
- var lt = require_lt();
3780
- var eq = require_eq();
3781
- var neq = require_neq();
3782
- var gte = require_gte();
3783
- var lte = require_lte();
3784
- var cmp = require_cmp();
3785
- var coerce = require_coerce();
3786
- var Comparator = require_comparator();
3787
- var Range = require_range();
3788
- var satisfies = require_satisfies();
3789
- var toComparators = require_to_comparators();
3790
- var maxSatisfying = require_max_satisfying();
3791
- var minSatisfying = require_min_satisfying();
3792
- var minVersion = require_min_version();
3793
- var validRange = require_valid2();
3794
- var outside = require_outside();
3795
- var gtr = require_gtr();
3796
- var ltr = require_ltr();
3797
- var intersects = require_intersects();
3798
- var simplifyRange = require_simplify();
3799
- var subset = require_subset();
3800
- module2.exports = {
3801
- parse,
3802
- valid,
3803
- clean,
3804
- inc,
3805
- diff,
3806
- major,
3807
- minor,
3808
- patch,
3809
- prerelease,
3810
- compare,
3811
- rcompare,
3812
- compareLoose,
3813
- compareBuild,
3814
- sort,
3815
- rsort,
3816
- gt,
3817
- lt,
3818
- eq,
3819
- neq,
3820
- gte,
3821
- lte,
3822
- cmp,
3823
- coerce,
3824
- Comparator,
3825
- Range,
3826
- satisfies,
3827
- toComparators,
3828
- maxSatisfying,
3829
- minSatisfying,
3830
- minVersion,
3831
- validRange,
3832
- outside,
3833
- gtr,
3834
- ltr,
3835
- intersects,
3836
- simplifyRange,
3837
- subset,
3838
- SemVer,
3839
- re: internalRe.re,
3840
- src: internalRe.src,
3841
- tokens: internalRe.t,
3842
- SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
3843
- RELEASE_TYPES: constants.RELEASE_TYPES,
3844
- compareIdentifiers: identifiers.compareIdentifiers,
3845
- rcompareIdentifiers: identifiers.rcompareIdentifiers
3846
- };
3847
- }
3848
- });
3849
-
3850
- // node_modules/.pnpm/validate-npm-package-name@6.0.2/node_modules/validate-npm-package-name/lib/index.js
3851
- var require_lib2 = __commonJS({
3852
- "node_modules/.pnpm/validate-npm-package-name@6.0.2/node_modules/validate-npm-package-name/lib/index.js"(exports2, module2) {
3853
- "use strict";
3854
- var { builtinModules: builtins } = require("module");
3855
- var scopedPackagePattern = new RegExp("^(?:@([^/]+?)[/])?([^/]+?)$");
3856
- var exclusionList = [
3857
- "node_modules",
3858
- "favicon.ico"
3859
- ];
3860
- function validate(name) {
3861
- var warnings = [];
3862
- var errors = [];
3863
- if (name === null) {
3864
- errors.push("name cannot be null");
3865
- return done(warnings, errors);
3866
- }
3867
- if (name === void 0) {
3868
- errors.push("name cannot be undefined");
3869
- return done(warnings, errors);
3870
- }
3871
- if (typeof name !== "string") {
3872
- errors.push("name must be a string");
3873
- return done(warnings, errors);
3874
- }
3875
- if (!name.length) {
3876
- errors.push("name length must be greater than zero");
3877
- }
3878
- if (name.startsWith(".")) {
3879
- errors.push("name cannot start with a period");
3880
- }
3881
- if (name.match(/^_/)) {
3882
- errors.push("name cannot start with an underscore");
3883
- }
3884
- if (name.trim() !== name) {
3885
- errors.push("name cannot contain leading or trailing spaces");
3886
- }
3887
- exclusionList.forEach(function(excludedName) {
3888
- if (name.toLowerCase() === excludedName) {
3889
- errors.push(excludedName + " is not a valid package name");
3890
- }
3891
- });
3892
- if (builtins.includes(name.toLowerCase())) {
3893
- warnings.push(name + " is a core module name");
3894
- }
3895
- if (name.length > 214) {
3896
- warnings.push("name can no longer contain more than 214 characters");
3897
- }
3898
- if (name.toLowerCase() !== name) {
3899
- warnings.push("name can no longer contain capital letters");
3900
- }
3901
- if (/[~'!()*]/.test(name.split("/").slice(-1)[0])) {
3902
- warnings.push(`name can no longer contain special characters ("~'!()*")`);
3903
- }
3904
- if (encodeURIComponent(name) !== name) {
3905
- var nameMatch = name.match(scopedPackagePattern);
3906
- if (nameMatch) {
3907
- var user = nameMatch[1];
3908
- var pkg = nameMatch[2];
3909
- if (pkg.startsWith(".")) {
3910
- errors.push("name cannot start with a period");
3911
- }
3912
- if (encodeURIComponent(user) === user && encodeURIComponent(pkg) === pkg) {
3913
- return done(warnings, errors);
3914
- }
3915
- }
3916
- errors.push("name can only contain URL-friendly characters");
3917
- }
3918
- return done(warnings, errors);
3919
- }
3920
- __name(validate, "validate");
3921
- var done = /* @__PURE__ */ __name(function(warnings, errors) {
3922
- var result = {
3923
- validForNewPackages: errors.length === 0 && warnings.length === 0,
3924
- validForOldPackages: errors.length === 0,
3925
- warnings,
3926
- errors
3927
- };
3928
- if (!result.warnings.length) {
3929
- delete result.warnings;
3930
- }
3931
- if (!result.errors.length) {
3932
- delete result.errors;
3933
- }
3934
- return result;
3935
- }, "done");
3936
- module2.exports = validate;
3937
- }
3938
- });
3939
-
3940
- // node_modules/.pnpm/proc-log@5.0.0/node_modules/proc-log/lib/index.js
3941
- var require_lib3 = __commonJS({
3942
- "node_modules/.pnpm/proc-log@5.0.0/node_modules/proc-log/lib/index.js"(exports2, module2) {
3943
- var META = Symbol("proc-log.meta");
3944
- module2.exports = {
3945
- META,
3946
- output: {
3947
- LEVELS: [
3948
- "standard",
3949
- "error",
3950
- "buffer",
3951
- "flush"
3952
- ],
3953
- KEYS: {
3954
- standard: "standard",
3955
- error: "error",
3956
- buffer: "buffer",
3957
- flush: "flush"
3958
- },
3959
- standard: /* @__PURE__ */ __name(function(...args) {
3960
- return process.emit("output", "standard", ...args);
3961
- }, "standard"),
3962
- error: /* @__PURE__ */ __name(function(...args) {
3963
- return process.emit("output", "error", ...args);
3964
- }, "error"),
3965
- buffer: /* @__PURE__ */ __name(function(...args) {
3966
- return process.emit("output", "buffer", ...args);
3967
- }, "buffer"),
3968
- flush: /* @__PURE__ */ __name(function(...args) {
3969
- return process.emit("output", "flush", ...args);
3970
- }, "flush")
3971
- },
3972
- log: {
3973
- LEVELS: [
3974
- "notice",
3975
- "error",
3976
- "warn",
3977
- "info",
3978
- "verbose",
3979
- "http",
3980
- "silly",
3981
- "timing",
3982
- "pause",
3983
- "resume"
3984
- ],
3985
- KEYS: {
3986
- notice: "notice",
3987
- error: "error",
3988
- warn: "warn",
3989
- info: "info",
3990
- verbose: "verbose",
3991
- http: "http",
3992
- silly: "silly",
3993
- timing: "timing",
3994
- pause: "pause",
3995
- resume: "resume"
3996
- },
3997
- error: /* @__PURE__ */ __name(function(...args) {
3998
- return process.emit("log", "error", ...args);
3999
- }, "error"),
4000
- notice: /* @__PURE__ */ __name(function(...args) {
4001
- return process.emit("log", "notice", ...args);
4002
- }, "notice"),
4003
- warn: /* @__PURE__ */ __name(function(...args) {
4004
- return process.emit("log", "warn", ...args);
4005
- }, "warn"),
4006
- info: /* @__PURE__ */ __name(function(...args) {
4007
- return process.emit("log", "info", ...args);
4008
- }, "info"),
4009
- verbose: /* @__PURE__ */ __name(function(...args) {
4010
- return process.emit("log", "verbose", ...args);
4011
- }, "verbose"),
4012
- http: /* @__PURE__ */ __name(function(...args) {
4013
- return process.emit("log", "http", ...args);
4014
- }, "http"),
4015
- silly: /* @__PURE__ */ __name(function(...args) {
4016
- return process.emit("log", "silly", ...args);
4017
- }, "silly"),
4018
- timing: /* @__PURE__ */ __name(function(...args) {
4019
- return process.emit("log", "timing", ...args);
4020
- }, "timing"),
4021
- pause: /* @__PURE__ */ __name(function() {
4022
- return process.emit("log", "pause");
4023
- }, "pause"),
4024
- resume: /* @__PURE__ */ __name(function() {
4025
- return process.emit("log", "resume");
4026
- }, "resume")
4027
- },
4028
- time: {
4029
- LEVELS: [
4030
- "start",
4031
- "end"
4032
- ],
4033
- KEYS: {
4034
- start: "start",
4035
- end: "end"
4036
- },
4037
- start: /* @__PURE__ */ __name(function(name, fn) {
4038
- process.emit("time", "start", name);
4039
- function end() {
4040
- return process.emit("time", "end", name);
4041
- }
4042
- __name(end, "end");
4043
- if (typeof fn === "function") {
4044
- const res = fn();
4045
- if (res && res.finally) {
4046
- return res.finally(end);
4047
- }
4048
- end();
4049
- return res;
4050
- }
4051
- return end;
4052
- }, "start"),
4053
- end: /* @__PURE__ */ __name(function(name) {
4054
- return process.emit("time", "end", name);
4055
- }, "end")
4056
- },
4057
- input: {
4058
- LEVELS: [
4059
- "start",
4060
- "end",
4061
- "read"
4062
- ],
4063
- KEYS: {
4064
- start: "start",
4065
- end: "end",
4066
- read: "read"
4067
- },
4068
- start: /* @__PURE__ */ __name(function(fn) {
4069
- process.emit("input", "start");
4070
- function end() {
4071
- return process.emit("input", "end");
4072
- }
4073
- __name(end, "end");
4074
- if (typeof fn === "function") {
4075
- const res = fn();
4076
- if (res && res.finally) {
4077
- return res.finally(end);
4078
- }
4079
- end();
4080
- return res;
4081
- }
4082
- return end;
4083
- }, "start"),
4084
- end: /* @__PURE__ */ __name(function() {
4085
- return process.emit("input", "end");
4086
- }, "end"),
4087
- read: /* @__PURE__ */ __name(function(...args) {
4088
- let resolve, reject;
4089
- const promise = new Promise((_resolve, _reject) => {
4090
- resolve = _resolve;
4091
- reject = _reject;
4092
- });
4093
- process.emit("input", "read", resolve, reject, ...args);
4094
- return promise;
4095
- }, "read")
4096
- }
4097
- };
4098
- }
4099
- });
4100
-
4101
- // node_modules/.pnpm/npm-package-arg@13.0.0/node_modules/npm-package-arg/lib/npa.js
4102
- var require_npa = __commonJS({
4103
- "node_modules/.pnpm/npm-package-arg@13.0.0/node_modules/npm-package-arg/lib/npa.js"(exports2, module2) {
4104
- "use strict";
4105
- var isWindows = process.platform === "win32";
4106
- var { URL: URL2 } = require("node:url");
4107
- var path = isWindows ? require("node:path/win32") : require("node:path");
4108
- var { homedir } = require("node:os");
4109
- var HostedGit = require_lib();
4110
- var semver = require_semver2();
4111
- var validatePackageName = require_lib2();
4112
- var { log } = require_lib3();
4113
- var hasSlashes = isWindows ? /\\|[/]/ : /[/]/;
4114
- var isURL = /^(?:git[+])?[a-z]+:/i;
4115
- var isGit = /^[^@]+@[^:.]+\.[^:]+:.+$/i;
4116
- var isFileType = /[.](?:tgz|tar.gz|tar)$/i;
4117
- var isPortNumber = /:[0-9]+(\/|$)/i;
4118
- var isWindowsFile = /^(?:[.]|~[/]|[/\\]|[a-zA-Z]:)/;
4119
- var isPosixFile = /^(?:[.]|~[/]|[/]|[a-zA-Z]:)/;
4120
- var defaultRegistry = "https://registry.npmjs.org";
4121
- function npa(arg, where) {
4122
- let name;
4123
- let spec;
4124
- if (typeof arg === "object") {
4125
- if (arg instanceof Result && (!where || where === arg.where)) {
4126
- return arg;
4127
- } else if (arg.name && arg.rawSpec) {
4128
- return npa.resolve(arg.name, arg.rawSpec, where || arg.where);
4129
- } else {
4130
- return npa(arg.raw, where || arg.where);
4131
- }
4132
- }
4133
- const nameEndsAt = arg.indexOf("@", 1);
4134
- const namePart = nameEndsAt > 0 ? arg.slice(0, nameEndsAt) : arg;
4135
- if (isURL.test(arg)) {
4136
- spec = arg;
4137
- } else if (isGit.test(arg)) {
4138
- spec = `git+ssh://${arg}`;
4139
- } else if (!namePart.startsWith("@") && (hasSlashes.test(namePart) || isFileType.test(namePart))) {
4140
- spec = arg;
4141
- } else if (nameEndsAt > 0) {
4142
- name = namePart;
4143
- spec = arg.slice(nameEndsAt + 1) || "*";
4144
- } else {
4145
- const valid = validatePackageName(arg);
4146
- if (valid.validForOldPackages) {
4147
- name = arg;
4148
- spec = "*";
4149
- } else {
4150
- spec = arg;
4151
- }
4152
- }
4153
- return resolve(name, spec, where, arg);
4154
- }
4155
- __name(npa, "npa");
4156
- function isFileSpec(spec) {
4157
- if (!spec) {
4158
- return false;
4159
- }
4160
- if (spec.toLowerCase().startsWith("file:")) {
4161
- return true;
4162
- }
4163
- if (isWindows) {
4164
- return isWindowsFile.test(spec);
4165
- }
4166
- return isPosixFile.test(spec);
4167
- }
4168
- __name(isFileSpec, "isFileSpec");
4169
- function isAliasSpec(spec) {
4170
- if (!spec) {
4171
- return false;
4172
- }
4173
- return spec.toLowerCase().startsWith("npm:");
4174
- }
4175
- __name(isAliasSpec, "isAliasSpec");
4176
- function resolve(name, spec, where, arg) {
4177
- const res = new Result({
4178
- raw: arg,
4179
- name,
4180
- rawSpec: spec,
4181
- fromArgument: arg != null
4182
- });
4183
- if (name) {
4184
- res.name = name;
4185
- }
4186
- if (!where) {
4187
- where = process.cwd();
4188
- }
4189
- if (isFileSpec(spec)) {
4190
- return fromFile(res, where);
4191
- } else if (isAliasSpec(spec)) {
4192
- return fromAlias(res, where);
4193
- }
4194
- const hosted = HostedGit.fromUrl(spec, {
4195
- noGitPlus: true,
4196
- noCommittish: true
4197
- });
4198
- if (hosted) {
4199
- return fromHostedGit(res, hosted);
4200
- } else if (spec && isURL.test(spec)) {
4201
- return fromURL(res);
4202
- } else if (spec && (hasSlashes.test(spec) || isFileType.test(spec))) {
4203
- return fromFile(res, where);
4204
- } else {
4205
- return fromRegistry(res);
4206
- }
4207
- }
4208
- __name(resolve, "resolve");
4209
- function toPurl(arg, reg = defaultRegistry) {
4210
- const res = npa(arg);
4211
- if (res.type !== "version") {
4212
- throw invalidPurlType(res.type, res.raw);
4213
- }
4214
- let purl = "pkg:npm/" + res.name.replace(/^@/, "%40") + "@" + res.rawSpec;
4215
- if (reg !== defaultRegistry) {
4216
- purl += "?repository_url=" + reg;
4217
- }
4218
- return purl;
4219
- }
4220
- __name(toPurl, "toPurl");
4221
- function invalidPackageName(name, valid, raw) {
4222
- const err = new Error(`Invalid package name "${name}" of package "${raw}": ${valid.errors.join("; ")}.`);
4223
- err.code = "EINVALIDPACKAGENAME";
4224
- return err;
4225
- }
4226
- __name(invalidPackageName, "invalidPackageName");
4227
- function invalidTagName(name, raw) {
4228
- const err = new Error(`Invalid tag name "${name}" of package "${raw}": Tags may not have any characters that encodeURIComponent encodes.`);
4229
- err.code = "EINVALIDTAGNAME";
4230
- return err;
4231
- }
4232
- __name(invalidTagName, "invalidTagName");
4233
- function invalidPurlType(type, raw) {
4234
- const err = new Error(`Invalid type "${type}" of package "${raw}": Purl can only be generated for "version" types.`);
4235
- err.code = "EINVALIDPURLTYPE";
4236
- return err;
4237
- }
4238
- __name(invalidPurlType, "invalidPurlType");
4239
- var Result = class {
4240
- static {
4241
- __name(this, "Result");
4242
- }
4243
- constructor(opts) {
4244
- this.type = opts.type;
4245
- this.registry = opts.registry;
4246
- this.where = opts.where;
4247
- if (opts.raw == null) {
4248
- this.raw = opts.name ? `${opts.name}@${opts.rawSpec}` : opts.rawSpec;
4249
- } else {
4250
- this.raw = opts.raw;
4251
- }
4252
- this.name = void 0;
4253
- this.escapedName = void 0;
4254
- this.scope = void 0;
4255
- this.rawSpec = opts.rawSpec || "";
4256
- this.saveSpec = opts.saveSpec;
4257
- this.fetchSpec = opts.fetchSpec;
4258
- if (opts.name) {
4259
- this.setName(opts.name);
4260
- }
4261
- this.gitRange = opts.gitRange;
4262
- this.gitCommittish = opts.gitCommittish;
4263
- this.gitSubdir = opts.gitSubdir;
4264
- this.hosted = opts.hosted;
4265
- }
4266
- // TODO move this to a getter/setter in a semver major
4267
- setName(name) {
4268
- const valid = validatePackageName(name);
4269
- if (!valid.validForOldPackages) {
4270
- throw invalidPackageName(name, valid, this.raw);
4271
- }
4272
- this.name = name;
4273
- this.scope = name[0] === "@" ? name.slice(0, name.indexOf("/")) : void 0;
4274
- this.escapedName = name.replace("/", "%2f");
4275
- return this;
4276
- }
4277
- toString() {
4278
- const full = [];
4279
- if (this.name != null && this.name !== "") {
4280
- full.push(this.name);
4281
- }
4282
- const spec = this.saveSpec || this.fetchSpec || this.rawSpec;
4283
- if (spec != null && spec !== "") {
4284
- full.push(spec);
4285
- }
4286
- return full.length ? full.join("@") : this.raw;
4287
- }
4288
- toJSON() {
4289
- const result = Object.assign({}, this);
4290
- delete result.hosted;
4291
- return result;
4292
- }
4293
- };
4294
- function setGitAttrs(res, committish) {
4295
- if (!committish) {
4296
- res.gitCommittish = null;
4297
- return;
4298
- }
4299
- for (const part of committish.split("::")) {
4300
- if (!part.includes(":")) {
4301
- if (res.gitRange) {
4302
- throw new Error("cannot override existing semver range with a committish");
4303
- }
4304
- if (res.gitCommittish) {
4305
- throw new Error("cannot override existing committish with a second committish");
4306
- }
4307
- res.gitCommittish = part;
4308
- continue;
4309
- }
4310
- const [name, value] = part.split(":");
4311
- if (name === "semver") {
4312
- if (res.gitCommittish) {
4313
- throw new Error("cannot override existing committish with a semver range");
4314
- }
4315
- if (res.gitRange) {
4316
- throw new Error("cannot override existing semver range with a second semver range");
4317
- }
4318
- res.gitRange = decodeURIComponent(value);
4319
- continue;
4320
- }
4321
- if (name === "path") {
4322
- if (res.gitSubdir) {
4323
- throw new Error("cannot override existing path with a second path");
4324
- }
4325
- res.gitSubdir = `/${value}`;
4326
- continue;
4327
- }
4328
- log.warn("npm-package-arg", `ignoring unknown key "${name}"`);
4329
- }
4330
- }
4331
- __name(setGitAttrs, "setGitAttrs");
4332
- var encodedPathChars = /* @__PURE__ */ new Map([
4333
- ["\0", "%00"],
4334
- [" ", "%09"],
4335
- ["\n", "%0A"],
4336
- ["\r", "%0D"],
4337
- [" ", "%20"],
4338
- ['"', "%22"],
4339
- ["#", "%23"],
4340
- ["%", "%25"],
4341
- ["?", "%3F"],
4342
- ["[", "%5B"],
4343
- ["\\", isWindows ? "/" : "%5C"],
4344
- ["]", "%5D"],
4345
- ["^", "%5E"],
4346
- ["|", "%7C"],
4347
- ["~", "%7E"]
4348
- ]);
4349
- function pathToFileURL(str) {
4350
- let result = "";
4351
- for (let i = 0; i < str.length; i++) {
4352
- result = `${result}${encodedPathChars.get(str[i]) ?? str[i]}`;
4353
- }
4354
- if (result.startsWith("file:")) {
4355
- return result;
4356
- }
4357
- return `file:${result}`;
4358
- }
4359
- __name(pathToFileURL, "pathToFileURL");
4360
- function fromFile(res, where) {
4361
- res.type = isFileType.test(res.rawSpec) ? "file" : "directory";
4362
- res.where = where;
4363
- let rawSpec = pathToFileURL(res.rawSpec);
4364
- if (rawSpec.startsWith("file:/")) {
4365
- if (/^file:\/\/[^/]/.test(rawSpec)) {
4366
- rawSpec = `file:/${rawSpec.slice(5)}`;
4367
- }
4368
- if (/^\/{1,3}\.\.?(\/|$)/.test(rawSpec.slice(5))) {
4369
- rawSpec = rawSpec.replace(/^file:\/{1,3}/, "file:");
4370
- }
4371
- }
4372
- let resolvedUrl;
4373
- let specUrl;
4374
- try {
4375
- resolvedUrl = new URL2(rawSpec, `${pathToFileURL(path.resolve(where))}/`);
4376
- specUrl = new URL2(rawSpec);
4377
- } catch (originalError) {
4378
- const er = new Error("Invalid file: URL, must comply with RFC 8089");
4379
- throw Object.assign(er, {
4380
- raw: res.rawSpec,
4381
- spec: res,
4382
- where,
4383
- originalError
4384
- });
4385
- }
4386
- let specPath = decodeURIComponent(specUrl.pathname);
4387
- let resolvedPath = decodeURIComponent(resolvedUrl.pathname);
4388
- if (isWindows) {
4389
- specPath = specPath.replace(/^\/+([a-z]:\/)/i, "$1");
4390
- resolvedPath = resolvedPath.replace(/^\/+([a-z]:\/)/i, "$1");
4391
- }
4392
- if (/^\/~(\/|$)/.test(specPath)) {
4393
- res.saveSpec = `file:${specPath.substr(1)}`;
4394
- resolvedPath = path.resolve(homedir(), specPath.substr(3));
4395
- } else if (!path.isAbsolute(rawSpec.slice(5))) {
4396
- res.saveSpec = `file:${path.relative(where, resolvedPath)}`;
4397
- } else {
4398
- res.saveSpec = `file:${path.resolve(resolvedPath)}`;
4399
- }
4400
- res.fetchSpec = path.resolve(where, resolvedPath);
4401
- res.saveSpec = res.saveSpec.split("\\").join("/");
4402
- if (res.saveSpec.startsWith("file://")) {
4403
- res.saveSpec = `file:/${res.saveSpec.slice(7)}`;
4404
- }
4405
- return res;
4406
- }
4407
- __name(fromFile, "fromFile");
4408
- function fromHostedGit(res, hosted) {
4409
- res.type = "git";
4410
- res.hosted = hosted;
4411
- res.saveSpec = hosted.toString({ noGitPlus: false, noCommittish: false });
4412
- res.fetchSpec = hosted.getDefaultRepresentation() === "shortcut" ? null : hosted.toString();
4413
- setGitAttrs(res, hosted.committish);
4414
- return res;
4415
- }
4416
- __name(fromHostedGit, "fromHostedGit");
4417
- function unsupportedURLType(protocol, spec) {
4418
- const err = new Error(`Unsupported URL Type "${protocol}": ${spec}`);
4419
- err.code = "EUNSUPPORTEDPROTOCOL";
4420
- return err;
4421
- }
4422
- __name(unsupportedURLType, "unsupportedURLType");
4423
- function fromURL(res) {
4424
- let rawSpec = res.rawSpec;
4425
- res.saveSpec = rawSpec;
4426
- if (rawSpec.startsWith("git+ssh:")) {
4427
- const matched = rawSpec.match(/^git\+ssh:\/\/([^:#]+:[^#]+(?:\.git)?)(?:#(.*))?$/i);
4428
- if (matched && !matched[1].match(isPortNumber)) {
4429
- res.type = "git";
4430
- setGitAttrs(res, matched[2]);
4431
- res.fetchSpec = matched[1];
4432
- return res;
4433
- }
4434
- } else if (rawSpec.startsWith("git+file://")) {
4435
- rawSpec = rawSpec.replace(/\\/g, "/");
4436
- }
4437
- const parsedUrl = new URL2(rawSpec);
4438
- switch (parsedUrl.protocol) {
4439
- case "git:":
4440
- case "git+http:":
4441
- case "git+https:":
4442
- case "git+rsync:":
4443
- case "git+ftp:":
4444
- case "git+file:":
4445
- case "git+ssh:":
4446
- res.type = "git";
4447
- setGitAttrs(res, parsedUrl.hash.slice(1));
4448
- if (parsedUrl.protocol === "git+file:" && /^git\+file:\/\/[a-z]:/i.test(rawSpec)) {
4449
- res.fetchSpec = `git+file://${parsedUrl.host.toLowerCase()}:${parsedUrl.pathname}`;
4450
- } else {
4451
- parsedUrl.hash = "";
4452
- res.fetchSpec = parsedUrl.toString();
4453
- }
4454
- if (res.fetchSpec.startsWith("git+")) {
4455
- res.fetchSpec = res.fetchSpec.slice(4);
4456
- }
4457
- break;
4458
- case "http:":
4459
- case "https:":
4460
- res.type = "remote";
4461
- res.fetchSpec = res.saveSpec;
4462
- break;
4463
- default:
4464
- throw unsupportedURLType(parsedUrl.protocol, rawSpec);
4465
- }
4466
- return res;
4467
- }
4468
- __name(fromURL, "fromURL");
4469
- function fromAlias(res, where) {
4470
- const subSpec = npa(res.rawSpec.substr(4), where);
4471
- if (subSpec.type === "alias") {
4472
- throw new Error("nested aliases not supported");
4473
- }
4474
- if (!subSpec.registry) {
4475
- throw new Error("aliases only work for registry deps");
4476
- }
4477
- if (!subSpec.name) {
4478
- throw new Error("aliases must have a name");
4479
- }
4480
- res.subSpec = subSpec;
4481
- res.registry = true;
4482
- res.type = "alias";
4483
- res.saveSpec = null;
4484
- res.fetchSpec = null;
4485
- return res;
4486
- }
4487
- __name(fromAlias, "fromAlias");
4488
- function fromRegistry(res) {
4489
- res.registry = true;
4490
- const spec = res.rawSpec.trim();
4491
- res.saveSpec = null;
4492
- res.fetchSpec = spec;
4493
- const version = semver.valid(spec, true);
4494
- const range = semver.validRange(spec, true);
4495
- if (version) {
4496
- res.type = "version";
4497
- } else if (range) {
4498
- res.type = "range";
4499
- } else {
4500
- if (encodeURIComponent(spec) !== spec) {
4501
- throw invalidTagName(spec, res.raw);
4502
- }
4503
- res.type = "tag";
4504
- }
4505
- return res;
4506
- }
4507
- __name(fromRegistry, "fromRegistry");
4508
- module2.exports = npa;
4509
- module2.exports.resolve = resolve;
4510
- module2.exports.toPurl = toPurl;
4511
- module2.exports.Result = Result;
4512
- }
4513
- });
4514
-
4515
- // src/external/npm-package-arg.js
4516
- module.exports = require_npa();
3
+ // Re-export from npm-core bundle for better deduplication
4
+ const { npmPackageArg } = require('./npm-core')
5
+ module.exports = npmPackageArg