@vltpkg/cli-js 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/{access-YYMAAPHV.js → access-FTHPFPUJ.js} +8 -8
  2. package/{bugs-RK5JBPSC.js → bugs-QS6HQUO2.js} +17 -17
  3. package/{build-DVJSYCNF.js → build-H27SXMAS.js} +11 -11
  4. package/{cache-JKQNGZ7L.js → cache-IB4HMFDT.js} +143 -14
  5. package/cache-unzip-src-unzip.js +2934 -164
  6. package/{chunk-BWEH7DHQ.js → chunk-3CUFJPBK.js} +1 -1
  7. package/{chunk-CBASIDQH.js → chunk-55DYW2MP.js} +1 -1
  8. package/{chunk-6FT6K5YN.js → chunk-5BD4QGW2.js} +25 -7
  9. package/{chunk-WE2TQN32.js → chunk-5PP77V44.js} +2 -2
  10. package/{chunk-LN2A74PF.js → chunk-5YB6UIC3.js} +247 -37
  11. package/{chunk-CEHPRPGQ.js → chunk-6A3XS52F.js} +33 -0
  12. package/{chunk-X2AWQGYG.js → chunk-6G7MTZGS.js} +6 -6
  13. package/{chunk-V4YCZZHY.js → chunk-7KFMQ3BR.js} +16 -8
  14. package/{chunk-JZJWASXL.js → chunk-B2FK2HHL.js} +79 -58
  15. package/{chunk-DF5K4CYR.js → chunk-FOJCK57G.js} +5 -5
  16. package/{chunk-GDT6KI4I.js → chunk-FSZF2RSQ.js} +4 -4
  17. package/{chunk-VFBCWAOC.js → chunk-G5BSQ6DP.js} +7 -0
  18. package/{chunk-XKVU23NC.js → chunk-G5NJ7CYI.js} +1 -1
  19. package/{chunk-34TE4HZS.js → chunk-GUATFMMU.js} +2 -2
  20. package/{chunk-YBVTY6ZW.js → chunk-JTUZP2OD.js} +1 -1
  21. package/{chunk-MZA6N2TA.js → chunk-LD4BQJBG.js} +4 -4
  22. package/{chunk-KDF7PEBY.js → chunk-LEGPLJWK.js} +5 -5
  23. package/{chunk-XIF734VO.js → chunk-LKQ5R4VX.js} +4 -4
  24. package/{chunk-DR4Z63B6.js → chunk-NJZSCUD4.js} +3 -3
  25. package/{chunk-2PWSMJD7.js → chunk-O44Z6MAV.js} +1 -1
  26. package/{chunk-DS7YMIHP.js → chunk-OE6VHHN4.js} +135 -36
  27. package/{src-MOKZQTH2.js → chunk-QA6RE2GS.js} +249 -28
  28. package/chunk-SPRVRSEL.js +75 -0
  29. package/{chunk-YOE3VZFX.js → chunk-SYGF27W7.js} +2 -2
  30. package/{chunk-LR42WTKN.js → chunk-UNWQVOLY.js} +14 -12
  31. package/{chunk-SNOBGFNM.js → chunk-UQUIO7LW.js} +47 -6
  32. package/{chunk-QQYTPGIL.js → chunk-VHHLO5L6.js} +1 -1
  33. package/{chunk-3LUM7NX5.js → chunk-YFNQ6HZ3.js} +3 -3
  34. package/{chunk-GDJ7JT2R.js → chunk-YTT3UHUB.js} +1 -1
  35. package/{ci-WVYVR4XK.js → ci-XJBYXFFJ.js} +10 -10
  36. package/cli-package.json +2 -1
  37. package/{config-VYOTYBGS.js → config-4Y46SH5K.js} +8 -8
  38. package/{config-2MFZVP2N.js → config-H2Q4ABSS.js} +12 -12
  39. package/{create-OJPLHBRR.js → create-LUYL2QI4.js} +18 -18
  40. package/{deprecate-V4PKGFF7.js → deprecate-5ANCI2L6.js} +13 -13
  41. package/{dist-tag-DNLV4VDE.js → dist-tag-SD2CRWIL.js} +8 -8
  42. package/{docs-LXHDCGL5.js → docs-B6LVNWTP.js} +17 -17
  43. package/{exec-P32YSP44.js → exec-CJ5KQA72.js} +18 -18
  44. package/{exec-cache-JZ5PDTOY.js → exec-cache-EE7DAOW2.js} +16 -16
  45. package/{exec-local-HHA464H4.js → exec-local-HT3VBN6S.js} +15 -15
  46. package/{help-GVTTOYUL.js → help-GZ44WYDS.js} +4 -4
  47. package/{init-RENGG74N.js → init-HVXRXFVY.js} +10 -10
  48. package/{install-V6VXOBH2.js → install-E2C7EE6P.js} +16 -16
  49. package/{list-7N7Y5OXB.js → list-V4V6SHJP.js} +18 -18
  50. package/{login-D2QSAUJC.js → login-VRFV7MCE.js} +12 -12
  51. package/{logout-QPOYBQNF.js → logout-SU75R7BN.js} +8 -8
  52. package/{pack-4YYGXP3A.js → pack-IVGKUXTL.js} +11 -11
  53. package/package.json +1 -1
  54. package/{ping-QYRIZONU.js → ping-WB222SDT.js} +8 -8
  55. package/{pkg-WQTNABKT.js → pkg-LAAFNONA.js} +11 -11
  56. package/{profile-PRI7WXK7.js → profile-P3AVHRDI.js} +8 -8
  57. package/{publish-PSBYJQS7.js → publish-IUNB3KH5.js} +17 -17
  58. package/{query-UFYLQW4N.js → query-XCN55INS.js} +18 -18
  59. package/{registry-YTJZ3AQD.js → registry-QQLWJHJI.js} +5 -5
  60. package/registry-client-src-revalidate.js +5940 -5804
  61. package/{repo-4S6ETFXX.js → repo-BQDWUCX5.js} +17 -17
  62. package/{reporter-GLWYHI2Y.js → reporter-5BVUNWQ6.js} +13 -13
  63. package/{run-OU7NUB7A.js → run-QT7DX243.js} +15 -15
  64. package/{run-exec-QPBY7ULE.js → run-exec-XYUI7GLN.js} +15 -15
  65. package/security-archive-src-update-expired.js +1 -1
  66. package/{setup-23QXG473.js → setup-CXDJXRAG.js} +18 -18
  67. package/{src-3GN7TDNH.js → src-2BUT4WYP.js} +7 -5
  68. package/src-OKMGXMAD.js +212 -0
  69. package/{src-575IYJOL.js → src-UBAERP25.js} +14 -14
  70. package/{token-FCIA3RGD.js → token-CBOK6DMT.js} +8 -8
  71. package/{uninstall-BQVZVKB5.js → uninstall-27VP46KJ.js} +12 -12
  72. package/{unpublish-YGJ5HEYF.js → unpublish-F4637OQX.js} +8 -8
  73. package/{update-WCGV66JK.js → update-NGWLJJ22.js} +15 -15
  74. package/{version-7EA3UQG7.js → version-WPD2KNVC.js} +13 -13
  75. package/{view-5FWIENVE.js → view-YKFTRRPD.js} +11 -11
  76. package/vlr.js +1 -1
  77. package/vlrx.js +1 -1
  78. package/vlt.js +1 -1
  79. package/vlx.js +1 -1
  80. package/vlxl.js +1 -1
  81. package/{whoami-O4ZTBIC4.js → whoami-I5Q6RTAP.js} +8 -8
  82. package/chunk-WD74RJXW.js +0 -75
@@ -20,6 +20,1771 @@ function create(cls, defaultFrom, message, cause, from = defaultFrom) {
20
20
  function error(message, cause, from) {
21
21
  return create(Error, error, message, cause, from);
22
22
  }
23
+ function typeError(message, cause, from) {
24
+ return create(TypeError, typeError, message, cause, from);
25
+ }
26
+ function syntaxError(message, cause, from) {
27
+ return create(
28
+ SyntaxError,
29
+ syntaxError,
30
+ message,
31
+ cause,
32
+ from
33
+ );
34
+ }
35
+
36
+ // ../../src/fast-split/src/index.ts
37
+ function fastSplit(str, delim, limit = -1, onPart) {
38
+ let i = 0;
39
+ let p = 0;
40
+ const l = delim.length;
41
+ const parts = [];
42
+ while (i !== -1) {
43
+ i = str.indexOf(delim, p);
44
+ const part = i === -1 || parts.length === limit - 1 ? str.substring(p) : str.substring(p, i);
45
+ parts.push(onPart?.(part, parts, i) ?? part);
46
+ if (parts.length === limit) {
47
+ return parts;
48
+ }
49
+ p = i + l;
50
+ }
51
+ return parts;
52
+ }
53
+
54
+ // ../../src/semver/src/version.ts
55
+ var maybeNumber = (s) => {
56
+ if (!/^[0-9]+$/.test(s)) return s;
57
+ const n7 = Number(s);
58
+ return n7 <= Number.MAX_SAFE_INTEGER ? n7 : s;
59
+ };
60
+ var safeNumber = (s, version, field) => {
61
+ const n7 = Number(s);
62
+ if (n7 > Number.MAX_SAFE_INTEGER) {
63
+ throw invalidVersion(
64
+ version,
65
+ `invalid ${field}, must be <= ${Number.MAX_SAFE_INTEGER}`
66
+ );
67
+ }
68
+ return n7;
69
+ };
70
+ var re = {
71
+ prefix: /^[ v=]+/,
72
+ main: /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)/,
73
+ prerelease: /-([0-9a-zA-Z_.-]+)(?:$|\+)/,
74
+ build: /\+([0-9a-zA-Z_.-]+)$/,
75
+ full: /^[ v=]*(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9a-zA-Z_.-]+))?(?:\+([0-9a-zA-Z_.-]+))?$/
76
+ };
77
+ var invalidVersion = (version, message) => {
78
+ const er = syntaxError(
79
+ `invalid version: ${message}`,
80
+ { version },
81
+ Version
82
+ );
83
+ return er;
84
+ };
85
+ var Version = class _Version {
86
+ /** raw string provided to create this Version */
87
+ raw;
88
+ /** major version number */
89
+ major;
90
+ /** minor version number */
91
+ minor;
92
+ /** patch version number */
93
+ patch;
94
+ /**
95
+ * List of `'.'`-separated strings and numbers indicating that this
96
+ * version is a prerelease.
97
+ *
98
+ * This is undefined if the version does not have a prerelease section.
99
+ */
100
+ prerelease;
101
+ /**
102
+ * List of `'.'`-separated strings in the `build` section.
103
+ *
104
+ * This is undefined if the version does not have a build.
105
+ */
106
+ build;
107
+ /** Canonical strict form of this version */
108
+ toString() {
109
+ return `${this.major}.${this.minor}.${this.patch}${this.prerelease ? "-" + this.prerelease.join(".") : ""}${this.build ? "+" + this.build.join(".") : ""}`;
110
+ }
111
+ /** Generate a `Version` object from a SemVer string */
112
+ static parse(version) {
113
+ version = version.replace(re.prefix, "").trim();
114
+ if (version.length > 256) {
115
+ throw invalidVersion(
116
+ version,
117
+ "must be less than 256 characters"
118
+ );
119
+ }
120
+ const parsed = re.full.exec(version);
121
+ if (!parsed) {
122
+ const main2 = re.main.exec(version);
123
+ if (!main2) {
124
+ throw invalidVersion(
125
+ version,
126
+ "no Major.minor.patch tuple present"
127
+ );
128
+ } else {
129
+ throw invalidVersion(
130
+ version,
131
+ "invalid build or patch section"
132
+ );
133
+ }
134
+ }
135
+ const [_2, major_, minor_, patch_, prerelease, build] = parsed;
136
+ const major2 = safeNumber(major_, version, "major");
137
+ const minor2 = safeNumber(minor_, version, "minor");
138
+ const patch = safeNumber(patch_, version, "patch");
139
+ return new _Version(
140
+ version,
141
+ major2,
142
+ minor2,
143
+ patch,
144
+ prerelease,
145
+ build
146
+ );
147
+ }
148
+ constructor(version, major2, minor2, patch, prerelease, build) {
149
+ this.raw = version;
150
+ this.major = major2;
151
+ this.minor = minor2;
152
+ this.patch = patch;
153
+ if (prerelease) {
154
+ this.prerelease = fastSplit(prerelease, ".", -1, (c) => {
155
+ if (!c) {
156
+ throw invalidVersion(
157
+ version,
158
+ "invalid prerelease, empty identifiers not allowed"
159
+ );
160
+ }
161
+ return maybeNumber(c);
162
+ });
163
+ }
164
+ if (build) {
165
+ this.build = fastSplit(build, ".", -1, (c) => {
166
+ if (!c) {
167
+ throw invalidVersion(
168
+ version,
169
+ "invalid build metadata, empty identifiers not allowed"
170
+ );
171
+ }
172
+ });
173
+ }
174
+ }
175
+ /**
176
+ * Return 1 if this is > the provided version, -1 if we're less, or 0 if
177
+ * they are equal.
178
+ *
179
+ * No special handling for prerelease versions, this is just a precedence
180
+ * comparison.
181
+ *
182
+ * This can be used to sort a list of versions by precedence:
183
+ *
184
+ * ```ts
185
+ * const versions: Version[] = getVersionsSomehow()
186
+ * const sorted = versions.sort((a, b) => a.compare(b))
187
+ * ```
188
+ */
189
+ compare(v2) {
190
+ if (this.major > v2.major) return 1;
191
+ if (this.major < v2.major) return -1;
192
+ if (this.minor > v2.minor) return 1;
193
+ if (this.minor < v2.minor) return -1;
194
+ if (this.patch > v2.patch) return 1;
195
+ if (this.patch < v2.patch) return -1;
196
+ if (!v2.prerelease?.length)
197
+ return !this.prerelease?.length ? 0 : -1;
198
+ if (!this.prerelease?.length) return 1;
199
+ const len = Math.max(this.prerelease.length, v2.prerelease.length);
200
+ const me2 = this.prerelease;
201
+ const thee = v2.prerelease;
202
+ for (let i = 0; i < len; i++) {
203
+ const m = me2[i];
204
+ const t = thee[i];
205
+ if (m === t) continue;
206
+ if (t === void 0) return 1;
207
+ if (m === void 0) return -1;
208
+ if (typeof m !== typeof t) {
209
+ return typeof m === "string" ? 1 : -1;
210
+ }
211
+ return m > t ? 1 : -1;
212
+ }
213
+ return 0;
214
+ }
215
+ /**
216
+ * The inverse of compare, for sorting version lists in reverse order
217
+ */
218
+ rcompare(v2) {
219
+ return -1 * this.compare(v2);
220
+ }
221
+ /** true if this version is > the argument */
222
+ greaterThan(v2) {
223
+ return this.compare(v2) === 1;
224
+ }
225
+ /** true if this version is >= the argument */
226
+ greaterThanEqual(v2) {
227
+ return this.compare(v2) > -1;
228
+ }
229
+ /** true if this version is < the argument */
230
+ lessThan(v2) {
231
+ return this.compare(v2) === -1;
232
+ }
233
+ /** true if this version is &lt;= the argument */
234
+ lessThanEqual(v2) {
235
+ return this.compare(v2) < 1;
236
+ }
237
+ /** true if these two versions have equal SemVer precedence */
238
+ equals(v2) {
239
+ return this.compare(v2) === 0;
240
+ }
241
+ /** just compare the M.m.p parts of the version */
242
+ tupleEquals(v2) {
243
+ return this.major === v2.major && this.minor === v2.minor && this.patch === v2.patch;
244
+ }
245
+ /** true if this version satisfies the range */
246
+ satisfies(r) {
247
+ return r.test(this);
248
+ }
249
+ /**
250
+ * Increment the version in place, in the manner specified.
251
+ *
252
+ * Part behaviors:
253
+ *
254
+ * - `'major'` If the version is a `M.0.0-...` version with a prerelease, then
255
+ * simply drop the prerelease. Otherwise, set the minor and patch to 0, and
256
+ * increment the major. So `1.0.0-beta` becomes `1.0.0`, and `1.2.3` becomes
257
+ * `2.0.0`
258
+ *
259
+ * - `'minor'` If the version is a `M.m.0-...` version with a prerelease, then
260
+ * simply drop the prerelease. Otherwise, set the patch to 0, and increment the
261
+ * minor. So `1.2.0-beta` becomes `1.2.0`, and `1.2.3` becomes `1.3.0`.
262
+ *
263
+ * - `'patch'` If the version has a prerelease, then simply drop the
264
+ * prerelease. Otherwise, increment the patch value. So `1.2.3-beta` becomes
265
+ * `1.2.3` and `1.2.3` becomes `1.2.4`.
266
+ *
267
+ * - `'premajor'` Set the patch and minor versions to `0`, increment the major
268
+ * version, and add a prerelease, using the optional identifier.
269
+ *
270
+ * - `'preminor'` Set the patch version to `0`, increment the minor version,
271
+ * and add a prerelease, using the optional identifier.
272
+ *
273
+ * - `'prepatch'` If a prerelease is already present, increment the patch
274
+ * version, otherwise leave it untouched, and add a prerelease, using the
275
+ * optional identifier.
276
+ *
277
+ * - `'prerelease'` If a prerelease version is present, then behave the same as
278
+ * `'prepatch'`. Otherwise, add a prerelease, using the optional identifier.
279
+ *
280
+ * - `'pre'` This is mostly for use by the other prerelease incrementers.
281
+ *
282
+ * - If a prerelease identifier is provided:
283
+ *
284
+ * Update that named portion of the prerelease. For example,
285
+ * `inc('1.2.3-beta.4', 'pre', 'beta')` would result in `1.2.3-beta.5`.
286
+ *
287
+ * If there is no prerelease identifier by that name, then replace the
288
+ * prerelease with `[name]`. So `inc('1.2.3-alpha.4', 'pre', 'beta')`
289
+ * would result in `1.2.3-beta`.
290
+ *
291
+ * If the prerelease identifer is present, but has no numeric value
292
+ * following it, then add `0`. So `inc('1.2.3-beta', 'pre', 'beta')`
293
+ * would result in `1.2.3-beta.0`.
294
+ *
295
+ * - If no prerelease identifier is provided:
296
+ *
297
+ * If there is no current prerelease, then set the prerelease to `0`. So,
298
+ * `inc('1.2.3', 'pre')` becomes `1.2.3-0`.
299
+ *
300
+ * If the last item in the prerelease is numeric, then increment it. So,
301
+ * `inc('1.2.3-beta.3', 'pre')` becomes `1.2.3-beta.4`.
302
+ */
303
+ inc(part, prereleaseIdentifier) {
304
+ switch (part) {
305
+ case "premajor":
306
+ this.prerelease = void 0;
307
+ this.patch = 0;
308
+ this.minor = 0;
309
+ this.major++;
310
+ this.inc("pre", prereleaseIdentifier);
311
+ break;
312
+ case "preminor":
313
+ this.prerelease = void 0;
314
+ this.patch = 0;
315
+ this.minor++;
316
+ this.inc("pre", prereleaseIdentifier);
317
+ break;
318
+ case "prepatch":
319
+ this.prerelease = void 0;
320
+ this.inc("patch");
321
+ this.inc("pre", prereleaseIdentifier);
322
+ break;
323
+ case "prerelease":
324
+ if (!this.prerelease?.length)
325
+ this.inc("patch", prereleaseIdentifier);
326
+ this.inc("pre", prereleaseIdentifier);
327
+ break;
328
+ case "pre": {
329
+ if (!prereleaseIdentifier) {
330
+ if (!this.prerelease?.length) {
331
+ this.prerelease = [0];
332
+ break;
333
+ }
334
+ const last = this.prerelease[this.prerelease.length - 1];
335
+ if (typeof last === "number") {
336
+ this.prerelease[this.prerelease.length - 1] = last + 1;
337
+ } else {
338
+ this.prerelease.push(0);
339
+ }
340
+ break;
341
+ }
342
+ if (!this.prerelease?.length) {
343
+ this.prerelease = [prereleaseIdentifier];
344
+ break;
345
+ }
346
+ const i = this.prerelease.indexOf(
347
+ maybeNumber(prereleaseIdentifier)
348
+ );
349
+ if (i === -1) {
350
+ this.prerelease = [prereleaseIdentifier];
351
+ break;
352
+ }
353
+ const baseValue = this.prerelease[i + 1];
354
+ if (typeof baseValue === "number") {
355
+ this.prerelease[i + 1] = baseValue + 1;
356
+ break;
357
+ }
358
+ if (i === this.prerelease.length - 1) {
359
+ this.prerelease.push(0);
360
+ break;
361
+ }
362
+ this.prerelease.splice(i + 1, 0, 0);
363
+ break;
364
+ }
365
+ case "major":
366
+ if (!this.prerelease?.length || this.minor || this.patch)
367
+ this.major++;
368
+ this.prerelease = void 0;
369
+ this.patch = 0;
370
+ this.minor = 0;
371
+ break;
372
+ case "minor":
373
+ if (!this.prerelease?.length || this.patch) this.minor++;
374
+ this.prerelease = void 0;
375
+ this.patch = 0;
376
+ break;
377
+ case "patch":
378
+ if (!this.prerelease?.length) this.patch++;
379
+ this.prerelease = void 0;
380
+ break;
381
+ default:
382
+ throw typeError(
383
+ "Invalid increment identifier",
384
+ {
385
+ version: this,
386
+ found: part,
387
+ validOptions: [
388
+ "major",
389
+ "minor",
390
+ "patch",
391
+ "premajor",
392
+ "preminor",
393
+ "prepatch",
394
+ "prerelease",
395
+ "pre"
396
+ ]
397
+ },
398
+ this.inc
399
+ );
400
+ }
401
+ this.raw = this.toString();
402
+ return this;
403
+ }
404
+ };
405
+
406
+ // ../../src/semver/src/comparator.ts
407
+ var isOperator = (o) => !!o && (o === ">" || o === "<" || o === ">=" || o === "<=" || o === "" || o === "~" || o === "^" || o === "~>");
408
+ var preJunk = new Set("=v ");
409
+ var invalidComp = (c, message) => syntaxError(
410
+ `invalid comparator: '${c}' ${message}`,
411
+ { found: c },
412
+ Comparator
413
+ );
414
+ var assertNumber = (value, c, field) => {
415
+ const n7 = Number(value);
416
+ if (n7 !== n7) {
417
+ throw invalidComp(
418
+ c,
419
+ `${field} must be numeric or 'x', got: '${value}'`
420
+ );
421
+ }
422
+ return n7;
423
+ };
424
+ var assertVersion = (v2, comp) => {
425
+ if (!v2) {
426
+ throw invalidComp(comp, "no value provided for operator");
427
+ }
428
+ };
429
+ var assertMissing = (value, c, field) => {
430
+ if (value && !isX(value)) {
431
+ throw invalidComp(
432
+ c,
433
+ `cannot omit '${field}' and include subsequent fields`
434
+ );
435
+ }
436
+ };
437
+ var MAJOR = 0;
438
+ var MINOR = 1;
439
+ var PATCH = 2;
440
+ var isX = (c) => !c || c === "X" || c === "x" || c === "*";
441
+ var isFullVersion = (parsed) => void 0 !== parsed[PATCH];
442
+ var isXPatch = (parsed) => void 0 !== parsed[MINOR] && void 0 === parsed[PATCH];
443
+ var isXMinor = (parsed) => void 0 !== parsed[MAJOR] && void 0 === parsed[MINOR];
444
+ var isXMajor = (parsed) => void 0 === parsed[MAJOR];
445
+ var Comparator = class {
446
+ /**
447
+ * does this range include prereleases, even when they do not
448
+ * match the tuple in the comparator?
449
+ */
450
+ includePrerelease;
451
+ /** raw string used to create this comparator */
452
+ raw;
453
+ /** tokens extracted from the raw string input */
454
+ tokens;
455
+ /**
456
+ * Either the `any` comparator, the `none` comparator, or an operator
457
+ * and a {@link ParsedXRange}
458
+ */
459
+ tuples = [];
460
+ /** true if this comparator can not match anything */
461
+ isNone = false;
462
+ /**
463
+ * true if this comparator is a `'*'` type of range.
464
+ *
465
+ * Note that it still will not match versions with a prerelease value,
466
+ * unless the tuple in the version matches the tuple provided to the
467
+ * comparator, and the comparator version also has a prerelease value,
468
+ * unless `includePrerelease` is set.
469
+ */
470
+ isAny = false;
471
+ /** the canonical strict simplified parsed form of this constructor */
472
+ toString() {
473
+ return this.isNone ? "<0.0.0-0" : this.isAny ? "*" : (
474
+ /* c8 ignore next */
475
+ this.tuples.map((c) => isAny(c) ? "*" : c.join("")).join(" ")
476
+ );
477
+ }
478
+ constructor(comp, includePrerelease = false) {
479
+ this.includePrerelease = includePrerelease;
480
+ comp = comp.trim();
481
+ this.raw = comp;
482
+ let hyphen = false;
483
+ const rawComps = fastSplit(comp, " ", -1, (part, parts, i) => {
484
+ if (part === "-") {
485
+ if (hyphen) {
486
+ throw invalidComp(
487
+ comp,
488
+ "multiple hyphen ranges not allowed"
489
+ );
490
+ }
491
+ if (parts.length !== 1 || i === -1) {
492
+ throw invalidComp(
493
+ comp,
494
+ "hyphen must be between two versions"
495
+ );
496
+ }
497
+ hyphen = true;
498
+ } else if (hyphen && parts.length !== 2) {
499
+ throw invalidComp(comp, "hyphen range must be alone");
500
+ }
501
+ });
502
+ const comps = [];
503
+ let followingOperator = false;
504
+ let l = 0;
505
+ for (const c of rawComps) {
506
+ if (c === "") continue;
507
+ if (!followingOperator) {
508
+ followingOperator = isOperator(c);
509
+ comps.push(c);
510
+ l++;
511
+ continue;
512
+ }
513
+ comps[l - 1] += c;
514
+ followingOperator = false;
515
+ }
516
+ if (hyphen) {
517
+ const [min, _2, max] = comps;
518
+ if (!min || !max) {
519
+ throw invalidComp(comp, "hyphen must be between two versions");
520
+ }
521
+ this.#parseHyphenRange(min, max);
522
+ } else if (!comps.length || comps.length === 1 && isX(comps[0])) {
523
+ this.tuples.push(this.#getComparatorAny());
524
+ } else {
525
+ for (const c of comps) {
526
+ this.#parse(c);
527
+ if (this.isNone) break;
528
+ }
529
+ }
530
+ this.tokens = comps;
531
+ this.isAny = true;
532
+ for (const c of this.tuples) {
533
+ if (Array.isArray(c) || !c.isAny) {
534
+ this.isAny = false;
535
+ break;
536
+ }
537
+ }
538
+ }
539
+ // inclusive min
540
+ #xInclusiveMin(raw) {
541
+ const z = this.includePrerelease ? "0" : void 0;
542
+ const [M3, m = 0, p = 0, pr = z, build] = this.#parseX(raw);
543
+ return M3 === void 0 ? this.#getComparatorAny() : [">=", new Version(raw, M3, m, p, pr, build)];
544
+ }
545
+ // exclusive min
546
+ #xExclusiveMin(raw) {
547
+ const parsed = this.#parseX(raw);
548
+ if (isFullVersion(parsed)) {
549
+ return [">", new Version(raw, ...parsed)];
550
+ }
551
+ const z = this.includePrerelease ? "0" : void 0;
552
+ if (isXPatch(parsed)) {
553
+ return [
554
+ ">=",
555
+ new Version(
556
+ raw,
557
+ parsed[MAJOR],
558
+ parsed[MINOR] + 1,
559
+ 0,
560
+ z,
561
+ void 0
562
+ )
563
+ ];
564
+ }
565
+ if (isXMinor(parsed)) {
566
+ return [
567
+ ">=",
568
+ new Version(raw, parsed[MAJOR] + 1, 0, 0, z, void 0)
569
+ ];
570
+ }
571
+ this.isNone = true;
572
+ this.tuples.length = 0;
573
+ return comparatorNone;
574
+ }
575
+ #xInclusiveMax(raw) {
576
+ const parsed = this.#parseX(raw);
577
+ return isFullVersion(parsed) ? ["<=", new Version(raw, ...parsed)] : isXPatch(parsed) ? [
578
+ "<",
579
+ new Version(
580
+ raw,
581
+ parsed[MAJOR],
582
+ parsed[MINOR] + 1,
583
+ 0,
584
+ "0",
585
+ void 0
586
+ )
587
+ ] : isXMinor(parsed) ? [
588
+ "<",
589
+ new Version(raw, parsed[MAJOR] + 1, 0, 0, "0", void 0)
590
+ ] : this.#getComparatorAny();
591
+ }
592
+ #xExclusiveMax(raw) {
593
+ const z = this.includePrerelease ? "0" : void 0;
594
+ const [M3 = 0, m = 0, p = 0, pr = z, build] = this.#parseX(raw);
595
+ if (M3 === 0 && m === 0 && p === 0 && pr === "0") {
596
+ this.isNone = true;
597
+ this.tuples.length = 0;
598
+ return comparatorNone;
599
+ }
600
+ return ["<", new Version(raw, M3, m, p, pr, build)];
601
+ }
602
+ #validXM(raw, m, p) {
603
+ assertMissing(m, raw, "major");
604
+ assertMissing(p, raw, "major");
605
+ if (m === "" || p === "") {
606
+ throw invalidComp(raw, `(Did you mean '*'?)`);
607
+ }
608
+ return [];
609
+ }
610
+ #validXm(raw, M3, m, p) {
611
+ assertMissing(p, raw, "major");
612
+ if (m === "" || p === "") {
613
+ throw invalidComp(raw, `(Did you mean '${M3}'?)`);
614
+ }
615
+ return [assertNumber(M3, raw, "major")];
616
+ }
617
+ #validXp(raw, M3, m, p) {
618
+ if (p === "") {
619
+ throw invalidComp(raw, `(Did you mean '${M3}.${m}'?)`);
620
+ }
621
+ return [
622
+ assertNumber(M3, raw, "major"),
623
+ assertNumber(m, raw, "minor")
624
+ ];
625
+ }
626
+ #validTuple(raw, M3, m, p) {
627
+ return [
628
+ assertNumber(M3, raw, "major"),
629
+ assertNumber(m, raw, "minor"),
630
+ assertNumber(p, raw, "patch")
631
+ ];
632
+ }
633
+ #validXbuild(raw, M3, m, p, pl) {
634
+ const patch = p.substring(0, pl);
635
+ const build = p.substring(pl + 1);
636
+ if (!patch) {
637
+ throw invalidComp(raw, "cannot specify build without patch");
638
+ }
639
+ if (!build) {
640
+ throw invalidComp(raw, `encountered '+', but no build value`);
641
+ }
642
+ return [
643
+ assertNumber(M3, raw, "major"),
644
+ assertNumber(m, raw, "minor"),
645
+ assertNumber(patch, raw, "patch"),
646
+ void 0,
647
+ build
648
+ ];
649
+ }
650
+ #validXpr(raw, M3, m, p, hy) {
651
+ {
652
+ const patch = p.substring(0, hy);
653
+ const pr = p.substring(hy + 1);
654
+ if (!patch) {
655
+ throw invalidComp(
656
+ raw,
657
+ "cannot specify prerelease without patch"
658
+ );
659
+ }
660
+ if (!pr) {
661
+ throw invalidComp(
662
+ raw,
663
+ `encountered '-', but no prerelease value`
664
+ );
665
+ }
666
+ return [
667
+ assertNumber(M3, raw, "major"),
668
+ assertNumber(m, raw, "minor"),
669
+ assertNumber(patch, raw, "patch"),
670
+ pr,
671
+ void 0
672
+ ];
673
+ }
674
+ }
675
+ #validXprbuild(raw, M3, m, p, hy, pl) {
676
+ const patch = p.substring(0, hy);
677
+ const pr = p.substring(hy + 1, pl);
678
+ const build = p.substring(pl + 1);
679
+ if (!patch) {
680
+ throw invalidComp(
681
+ raw,
682
+ "cannot specify prerelease without patch"
683
+ );
684
+ }
685
+ if (!pr) {
686
+ throw invalidComp(
687
+ raw,
688
+ `encountered '-', but no prerelease value`
689
+ );
690
+ }
691
+ if (!build) {
692
+ throw invalidComp(raw, `encountered '+', but no build value`);
693
+ }
694
+ return [
695
+ assertNumber(M3, raw, "major"),
696
+ assertNumber(m, raw, "minor"),
697
+ assertNumber(patch, raw, "patch"),
698
+ pr,
699
+ build
700
+ ];
701
+ }
702
+ // pull the relevant values out of an X-range or version
703
+ // return the fields for creating a Version object.
704
+ // only call once operator is stripped off
705
+ #parseX(raw) {
706
+ let [M3, m, p] = fastSplit(raw, ".", 3);
707
+ let prune = 0;
708
+ while (M3 && preJunk.has(M3.charAt(prune))) prune++;
709
+ if (M3 !== void 0 && prune !== 0) M3 = M3.substring(prune);
710
+ if (!M3 || isX(M3)) return this.#validXM(raw, m, p);
711
+ if (!m || isX(m)) return this.#validXm(raw, M3, m, p);
712
+ if (!p || isX(p)) return this.#validXp(raw, M3, m, p);
713
+ const hy = p.indexOf("-");
714
+ const pl = p.indexOf("+");
715
+ if (pl === -1 && hy === -1) return this.#validTuple(raw, M3, m, p);
716
+ if (pl === -1) return this.#validXpr(raw, M3, m, p, hy);
717
+ if (hy === -1) return this.#validXbuild(raw, M3, m, p, pl);
718
+ return this.#validXprbuild(raw, M3, m, p, hy, pl);
719
+ }
720
+ #parseHyphenRange(min, max) {
721
+ const minv = this.#xInclusiveMin(min);
722
+ const maxv = this.#xInclusiveMax(max);
723
+ const minAny = isAny(minv);
724
+ const maxAny = isAny(maxv);
725
+ if (minAny && maxAny) this.tuples.push(this.#getComparatorAny());
726
+ else if (minAny) this.tuples.push(maxv);
727
+ else if (maxAny) this.tuples.push(minv);
728
+ else this.tuples.push(minv, maxv);
729
+ }
730
+ #parse(comp) {
731
+ const first = comp.charAt(0);
732
+ const first2 = comp.substring(0, 2);
733
+ const v1 = comp.substring(1);
734
+ const v2 = comp.substring(2);
735
+ switch (first2) {
736
+ case "~>":
737
+ assertVersion(v2, comp);
738
+ return this.#parseTilde(v2);
739
+ case ">=":
740
+ assertVersion(v2, comp);
741
+ return this.tuples.push(this.#xInclusiveMin(v2));
742
+ case "<=":
743
+ assertVersion(v2, comp);
744
+ return this.tuples.push(this.#xInclusiveMax(v2));
745
+ }
746
+ switch (first) {
747
+ case "~":
748
+ assertVersion(v1, comp);
749
+ return this.#parseTilde(v1);
750
+ case "^":
751
+ assertVersion(v1, comp);
752
+ return this.#parseCaret(v1);
753
+ case ">":
754
+ assertVersion(v1, comp);
755
+ return this.tuples.push(this.#xExclusiveMin(v1));
756
+ case "<":
757
+ assertVersion(v1, comp);
758
+ return this.tuples.push(this.#xExclusiveMax(v1));
759
+ }
760
+ return this.#parseEq(comp);
761
+ }
762
+ #parseTilde(comp) {
763
+ const parsed = this.#parseX(comp);
764
+ if (isXMajor(parsed)) {
765
+ this.tuples.push(this.#getComparatorAny());
766
+ return;
767
+ }
768
+ const z = this.includePrerelease ? "0" : void 0;
769
+ if (isXMinor(parsed)) {
770
+ const [M4] = parsed;
771
+ this.tuples.push(
772
+ [">=", new Version(comp, M4, 0, 0, z, void 0)],
773
+ ["<", new Version(comp, M4 + 1, 0, 0, "0", void 0)]
774
+ );
775
+ return;
776
+ }
777
+ if (isXPatch(parsed)) {
778
+ const [M4, m2] = parsed;
779
+ const z2 = this.includePrerelease ? "0" : void 0;
780
+ this.tuples.push(
781
+ [">=", new Version(comp, M4, m2, 0, z2, void 0)],
782
+ ["<", new Version(comp, M4, m2 + 1, 0, "0", void 0)]
783
+ );
784
+ return;
785
+ }
786
+ const [M3, m, p, pr = z, build] = parsed;
787
+ this.tuples.push(
788
+ [">=", new Version(comp, M3, m, p, pr, build)],
789
+ ["<", new Version(comp, M3, m + 1, 0, "0", build)]
790
+ );
791
+ }
792
+ #parseCaret(comp) {
793
+ const min = this.#xInclusiveMin(comp);
794
+ if (isAny(min)) {
795
+ this.tuples.push(min);
796
+ return;
797
+ }
798
+ const minv = min[1];
799
+ if (minv.major !== 0) {
800
+ this.tuples.push(min, [
801
+ "<",
802
+ new Version(comp, minv.major + 1, 0, 0, "0", void 0)
803
+ ]);
804
+ } else if (minv.minor !== 0) {
805
+ this.tuples.push(min, [
806
+ "<",
807
+ new Version(
808
+ comp,
809
+ minv.major,
810
+ minv.minor + 1,
811
+ 0,
812
+ "0",
813
+ void 0
814
+ )
815
+ ]);
816
+ } else if (!minv.prerelease?.length) {
817
+ this.tuples.push(["", minv]);
818
+ } else {
819
+ this.tuples.push(min, [
820
+ "<",
821
+ new Version(
822
+ comp,
823
+ minv.major,
824
+ minv.minor,
825
+ minv.patch + 1,
826
+ "0",
827
+ void 0
828
+ )
829
+ ]);
830
+ }
831
+ }
832
+ #parseEq(comp) {
833
+ const parsed = this.#parseX(comp);
834
+ const z = this.includePrerelease ? "0" : void 0;
835
+ if (isFullVersion(parsed)) {
836
+ this.tuples.push(["", new Version(comp, ...parsed)]);
837
+ } else if (isXMajor(parsed)) {
838
+ this.tuples.push(this.#getComparatorAny());
839
+ } else if (isXMinor(parsed)) {
840
+ this.tuples.push([
841
+ ">=",
842
+ new Version(comp, parsed[MAJOR], 0, 0, z, void 0)
843
+ ]);
844
+ this.tuples.push([
845
+ "<",
846
+ new Version(comp, parsed[MAJOR] + 1, 0, 0, "0", void 0)
847
+ ]);
848
+ } else if (isXPatch(parsed)) {
849
+ this.tuples.push(
850
+ [
851
+ ">=",
852
+ new Version(
853
+ comp,
854
+ parsed[MAJOR],
855
+ parsed[MINOR],
856
+ 0,
857
+ z,
858
+ void 0
859
+ )
860
+ ],
861
+ [
862
+ "<",
863
+ new Version(
864
+ comp,
865
+ parsed[MAJOR],
866
+ parsed[MINOR] + 1,
867
+ 0,
868
+ "0",
869
+ void 0
870
+ )
871
+ ]
872
+ );
873
+ }
874
+ }
875
+ /** return true if the version is a match for this comparator */
876
+ test(v2) {
877
+ if (this.isNone) return false;
878
+ const ip = this.includePrerelease;
879
+ const hasPR = !!v2.prerelease?.length;
880
+ let prOK = ip || !hasPR;
881
+ for (const c of this.tuples) {
882
+ if (isAny(c)) {
883
+ continue;
884
+ }
885
+ const [op, cv] = c;
886
+ prOK ||= !!cv.prerelease?.length && v2.tupleEquals(cv);
887
+ switch (op) {
888
+ case "":
889
+ if (!v2.equals(cv)) return false;
890
+ continue;
891
+ case ">":
892
+ if (!v2.greaterThan(cv)) return false;
893
+ continue;
894
+ case ">=":
895
+ if (!v2.greaterThanEqual(cv)) return false;
896
+ continue;
897
+ case "<":
898
+ if (!v2.lessThan(cv)) return false;
899
+ continue;
900
+ case "<=":
901
+ if (!v2.lessThanEqual(cv)) return false;
902
+ continue;
903
+ }
904
+ }
905
+ return prOK;
906
+ }
907
+ #getComparatorAny() {
908
+ return this.includePrerelease ? comparatorAnyPR : comparatorAny;
909
+ }
910
+ };
911
+ var isAny = (c) => c === comparatorAny || c === comparatorAnyPR;
912
+ var comparatorAny = {
913
+ isAny: true,
914
+ toString: () => "*",
915
+ includePrerelease: false,
916
+ test: (v2) => !v2.prerelease?.length
917
+ };
918
+ var comparatorAnyPR = {
919
+ isAny: true,
920
+ toString: () => "*",
921
+ includePrerelease: true,
922
+ test: (_2) => true
923
+ };
924
+ var comparatorNone = {
925
+ isNone: true,
926
+ toString: () => "<0.0.0-0",
927
+ includePrerelease: false,
928
+ test: (_2) => false
929
+ };
930
+
931
+ // ../../src/semver/src/range.ts
932
+ var Range = class {
933
+ /** raw string used to create this Range */
934
+ raw;
935
+ /** true if the range is `*` */
936
+ isAny;
937
+ /** true if the range is a single semver version */
938
+ isSingle;
939
+ /** true if the range cannot match anything */
940
+ /**
941
+ * set of {@link Comparator} objects representing the `||`-separated sections
942
+ * of the range. If at least one of these matches, then the version is a
943
+ * match.
944
+ */
945
+ set = [];
946
+ /** true if all prerelease versions should be included */
947
+ includePrerelease;
948
+ /** cached toString */
949
+ #toString;
950
+ constructor(range, includePrerelease = false) {
951
+ this.raw = range;
952
+ this.includePrerelease = includePrerelease;
953
+ this.isAny = false;
954
+ let isFirst = true;
955
+ this.isSingle = false;
956
+ const comparatorErrors = [];
957
+ fastSplit(range, "||", -1, (part) => {
958
+ if (this.isAny) return;
959
+ const cmp = this.#maybeComparator(part, this.includePrerelease);
960
+ if (cmp instanceof Error) {
961
+ comparatorErrors.push(cmp);
962
+ return;
963
+ }
964
+ if (cmp.isAny) {
965
+ this.set = [cmp];
966
+ this.isAny = true;
967
+ return;
968
+ }
969
+ this.set.push(cmp);
970
+ if (!isFirst) this.isSingle = false;
971
+ else if (Array.isArray(cmp.tuples) && cmp.tuples.length === 1 && Array.isArray(cmp.tuples[0]) && cmp.tuples[0][0] === "") {
972
+ this.isSingle = true;
973
+ }
974
+ isFirst = false;
975
+ });
976
+ if (!this.set.length && comparatorErrors.length) {
977
+ if (comparatorErrors.length === 1 && comparatorErrors[0]) {
978
+ throw comparatorErrors[0];
979
+ }
980
+ throw new AggregateError(comparatorErrors);
981
+ }
982
+ }
983
+ #maybeComparator(part, includePrerelease) {
984
+ try {
985
+ return new Comparator(part, includePrerelease);
986
+ } catch (er) {
987
+ return asError(er);
988
+ }
989
+ }
990
+ /**
991
+ * test a {@link Version} against the range
992
+ */
993
+ test(v2) {
994
+ return this.set.some((c) => c.test(v2));
995
+ }
996
+ /** return the simplified canonical form of this range */
997
+ toString() {
998
+ if (this.#toString) return this.#toString;
999
+ if (this.isSingle) {
1000
+ this.#toString = String(this.set[0]);
1001
+ return this.#toString;
1002
+ }
1003
+ this.#toString = this.set.map((c) => String(c)).join(" || ");
1004
+ return this.#toString;
1005
+ }
1006
+ };
1007
+
1008
+ // ../../src/semver/src/index.ts
1009
+ var rangeCache = /* @__PURE__ */ new Map();
1010
+ var MAX_RANGE_CACHE = 4096;
1011
+ var parseRange = (range, includePrerelease = false) => {
1012
+ if (typeof range === "object") {
1013
+ if (range.includePrerelease === includePrerelease) return range;
1014
+ range = range.raw;
1015
+ }
1016
+ const key = `${+includePrerelease}\0${range}`;
1017
+ const cached = rangeCache.get(key);
1018
+ if (cached !== void 0 || rangeCache.has(key)) return cached;
1019
+ let parsed;
1020
+ try {
1021
+ parsed = new Range(range, includePrerelease);
1022
+ } catch {
1023
+ parsed = void 0;
1024
+ }
1025
+ if (rangeCache.size >= MAX_RANGE_CACHE) rangeCache.clear();
1026
+ rangeCache.set(key, parsed);
1027
+ return parsed;
1028
+ };
1029
+
1030
+ // ../../src/spec/src/valid-name.ts
1031
+ var pathSafeName = /^(?!(?:node_modules|\.vlt)$)(?![A-Za-z]:)(?:@(?!\.\.?\/)[^/\\\x00-\x1f\x7f]+\/)?(?!\.\.?$)[^/\\\x00-\x1f\x7f]+$/i;
1032
+ var isPathSafeName = (name2) => typeof name2 === "string" && pathSafeName.test(name2);
1033
+ var assertPathSafeName = (name2, from) => {
1034
+ if (isPathSafeName(name2)) return;
1035
+ throw error(
1036
+ "Invalid package name: not usable as a path segment",
1037
+ {
1038
+ code: "EINVALIDNAME",
1039
+ found: name2,
1040
+ from,
1041
+ wanted: "a single path segment, or a well-formed @scope/name"
1042
+ },
1043
+ assertPathSafeName
1044
+ );
1045
+ };
1046
+
1047
+ // ../../src/spec/src/browser.ts
1048
+ var kCustomInspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
1049
+ var defaultRegistryName = "npm";
1050
+ var defaultRegistries = {
1051
+ gh: "https://npm.pkg.github.com/"
1052
+ };
1053
+ var defaultJsrRegistries = { jsr: "https://npm.jsr.io/" };
1054
+ var defaultGitHosts = {
1055
+ github: "git+ssh://git@github.com:$1/$2.git",
1056
+ bitbucket: "git+ssh://git@bitbucket.org:$1/$2.git",
1057
+ gitlab: "git+ssh://git@gitlab.com:$1/$2.git",
1058
+ gist: "git+ssh://git@gist.github.com/$1.git"
1059
+ };
1060
+ var defaultGitHostArchives = {
1061
+ github: "https://api.github.com/repos/$1/$2/tarball/$committish",
1062
+ bitbucket: "https://bitbucket.org/$1/$2/get/$committish.tar.gz",
1063
+ gist: "https://codeload.github.com/gist/$1/tar.gz/$committish",
1064
+ gitlab: "https://gitlab.com/$1/$2/repository/archive.tar.gz?ref=$committish"
1065
+ };
1066
+ var gitHostWebsites = {
1067
+ github: "https://github.com/",
1068
+ bitbucket: "https://bitbucket.org/",
1069
+ gist: "https://gist.github.com/",
1070
+ gitlab: "https://gitlab.com/"
1071
+ };
1072
+ var getOptions = (options) => ({
1073
+ catalog: {},
1074
+ catalogs: {},
1075
+ ...options,
1076
+ // built-in aliases are user/service-overridable: user config wins
1077
+ "jsr-registries": {
1078
+ ...defaultJsrRegistries,
1079
+ ...options?.["jsr-registries"] ?? {}
1080
+ },
1081
+ registry: options?.registry,
1082
+ "default-registry-alias": options?.["default-registry-alias"] ?? defaultRegistryName,
1083
+ "scoped-registries": options?.["scoped-registries"] ?? {},
1084
+ "git-hosts": options?.["git-hosts"] ? {
1085
+ ...defaultGitHosts,
1086
+ ...options["git-hosts"]
1087
+ } : defaultGitHosts,
1088
+ registries: {
1089
+ ...defaultRegistries,
1090
+ ...options?.registries ?? {}
1091
+ },
1092
+ "git-host-archives": options?.["git-host-archives"] ? {
1093
+ ...defaultGitHostArchives,
1094
+ ...options["git-host-archives"]
1095
+ } : defaultGitHostArchives
1096
+ });
1097
+ var protocolRE = /^([a-zA-Z][a-zA-Z0-9+-]+):/;
1098
+ var builtinProtocols = /* @__PURE__ */ new Set([
1099
+ "catalog",
1100
+ "workspace",
1101
+ "registry",
1102
+ "file",
1103
+ "http",
1104
+ "https",
1105
+ "git",
1106
+ "git+ssh",
1107
+ "git+http",
1108
+ "git+https",
1109
+ "git+file"
1110
+ ]);
1111
+ var unknownProtocol = (str, options) => {
1112
+ const p = protocolRE.exec(str)?.[1];
1113
+ return p === void 0 || builtinProtocols.has(p) || p === options["default-registry-alias"] || options.registries[p] !== void 0 || options["git-hosts"][p] !== void 0 || options["jsr-registries"][p] !== void 0 ? void 0 : p;
1114
+ };
1115
+ var startsWithSpecIdentifier = (spec, options) => spec.startsWith("/") || spec.startsWith("./") || spec.startsWith("../") || spec.startsWith("file:") || spec.startsWith("http:") || spec.startsWith("https:") || spec.startsWith("workspace:") || spec.startsWith("catalog:") || spec.startsWith("git@") || spec.startsWith("git://") || spec.startsWith("git+ssh://") || spec.startsWith("git+http://") || spec.startsWith("git+https://") || spec.startsWith("git+file://") || spec.startsWith("git@github.com") || spec.startsWith("registry:") || spec.startsWith("npm:") || spec.startsWith("jsr:") || spec.startsWith("gh:") || // anything that starts with a known git host key, or a
1116
+ // custom registered registry protocol e.g: `github:`, `custom:`
1117
+ [
1118
+ ...Object.keys(options["git-hosts"]),
1119
+ ...Object.keys(options.registries),
1120
+ ...Object.keys(options["jsr-registries"])
1121
+ ].some((key) => spec.startsWith(`${key}:`)) || unknownProtocol(spec, options) !== void 0;
1122
+ var findFirstAt = (spec, hasScope) => spec.indexOf("@", hasScope ? 1 : 0);
1123
+ var findGitIdentifier = (spec) => spec.indexOf("#") > 2;
1124
+ var findFileIdentifier = (spec) => spec.includes("/");
1125
+ var Spec = class _Spec {
1126
+ static parse(spec, bareOrOptions, options) {
1127
+ return typeof spec === "object" ? spec : new this(spec, bareOrOptions, options);
1128
+ }
1129
+ static parseArgs(specOrBareSpec, opts) {
1130
+ const options = getOptions(opts ?? {});
1131
+ if (startsWithSpecIdentifier(specOrBareSpec, options)) {
1132
+ const parsed = this.parse("(unknown)", specOrBareSpec, options);
1133
+ if (parsed.subspec) {
1134
+ const { namedJsrRegistry: jsrHost } = parsed;
1135
+ if (!jsrHost) {
1136
+ parsed.name = parsed.subspec.name;
1137
+ }
1138
+ parsed.spec = `${parsed.name}@${parsed.bareSpec}`;
1139
+ assertPathSafeName(parsed.name, parsed.spec);
1140
+ }
1141
+ return parsed;
1142
+ } else {
1143
+ const hasScope = specOrBareSpec.startsWith("@");
1144
+ const at2 = findFirstAt(specOrBareSpec, hasScope);
1145
+ if (at2 > -1) {
1146
+ return this.parse(
1147
+ specOrBareSpec.substring(0, at2),
1148
+ specOrBareSpec.substring(at2 + 1),
1149
+ options
1150
+ );
1151
+ } else if (findGitIdentifier(specOrBareSpec) || !hasScope && findFileIdentifier(specOrBareSpec)) {
1152
+ return this.parse("(unknown)", specOrBareSpec, options);
1153
+ } else {
1154
+ return this.parse(`${specOrBareSpec}@`, options);
1155
+ }
1156
+ }
1157
+ }
1158
+ static nodejsDependencies;
1159
+ type;
1160
+ spec;
1161
+ options;
1162
+ name;
1163
+ scope;
1164
+ scopeRegistry;
1165
+ bareSpec;
1166
+ gitRemote;
1167
+ gitSelector;
1168
+ gitSelectorParsed;
1169
+ gitCommittish;
1170
+ namedGitHost;
1171
+ namedGitHostPath;
1172
+ workspaceSpec;
1173
+ workspace;
1174
+ namedRegistry;
1175
+ namedJsrRegistry;
1176
+ registry;
1177
+ registrySpec;
1178
+ conventionalRegistryTarball;
1179
+ semver;
1180
+ range;
1181
+ distTag;
1182
+ remoteURL;
1183
+ file;
1184
+ catalog;
1185
+ subspec;
1186
+ overridden = false;
1187
+ #final;
1188
+ #toString;
1189
+ /**
1190
+ * Return the final entry in the chain of subspecs
1191
+ * When deciding which thing to actually fetch, spec.final is the thing
1192
+ * to look at.
1193
+ */
1194
+ get final() {
1195
+ if (this.#final) return this.#final;
1196
+ const final = this.subspec ? this.subspec.final : this;
1197
+ if (final.type === "catalog") {
1198
+ throw error('invalid Spec.final value, type is "catalog"');
1199
+ }
1200
+ return this.#final = final;
1201
+ }
1202
+ /**
1203
+ * Normally, the string value of a Spec is just the string passed in to
1204
+ * be parsed. However, in the case of a chain of subspecs, like
1205
+ * `foo@npm:bar@npm:baz@npm:quux@latest`, this simplifies out the middle
1206
+ * parts of the chain, returning just `foo@npm:quux@latest`
1207
+ */
1208
+ toString() {
1209
+ if (this.#toString !== void 0) return this.#toString;
1210
+ let sub = this;
1211
+ while (sub.subspec?.subspec) sub = sub.subspec;
1212
+ if (sub.subspec && sub.subspec.type !== "registry")
1213
+ sub = sub.subspec;
1214
+ return this.#toString = this.name + "@" + sub.bareSpec;
1215
+ }
1216
+ constructor(spec, bareOrOptions, options = {}) {
1217
+ if (bareOrOptions && typeof bareOrOptions === "object") {
1218
+ options = bareOrOptions;
1219
+ bareOrOptions = void 0;
1220
+ }
1221
+ this.options = getOptions(options);
1222
+ if (typeof bareOrOptions === "string") {
1223
+ this.name = spec;
1224
+ this.#parseScope(spec);
1225
+ this.bareSpec = bareOrOptions;
1226
+ this.spec = `${this.name}@${bareOrOptions}`;
1227
+ assertPathSafeName(this.name, this.spec);
1228
+ } else {
1229
+ this.spec = spec;
1230
+ this.#assertKnownProtocol(spec);
1231
+ if (!spec.startsWith("git@") && startsWithSpecIdentifier(spec, this.options) && spec.includes(":") && [
1232
+ ...Object.keys(this.options.registries),
1233
+ ...Object.keys(defaultRegistries)
1234
+ ].some((key) => spec.startsWith(`${key}:`))) {
1235
+ this.name = spec;
1236
+ this.bareSpec = spec;
1237
+ } else {
1238
+ const hasScope = spec.startsWith("@");
1239
+ let at2 = findFirstAt(spec, hasScope);
1240
+ if (at2 === -1) {
1241
+ at2 = spec.length;
1242
+ spec += "@";
1243
+ }
1244
+ this.name = spec.substring(0, at2);
1245
+ assertPathSafeName(this.name, spec);
1246
+ if (hasScope) this.#parseScope(this.name);
1247
+ this.bareSpec = spec.substring(at2 + 1);
1248
+ }
1249
+ }
1250
+ if (this.bareSpec.startsWith("catalog:")) {
1251
+ this.catalog = this.bareSpec.substring("catalog:".length);
1252
+ const catalog = this.catalog ? this.options.catalogs?.[this.catalog] : this.options.catalog;
1253
+ if (!catalog) {
1254
+ throw this.#error("Named catalog not found", {
1255
+ name: this.catalog,
1256
+ validOptions: this.options.catalogs && Object.keys(this.options.catalogs)
1257
+ });
1258
+ }
1259
+ const sub = catalog[this.name];
1260
+ if (!sub) {
1261
+ throw this.#error("Name not found in catalog", {
1262
+ name: this.name,
1263
+ validOptions: Object.keys(catalog)
1264
+ });
1265
+ }
1266
+ this.subspec = _Spec.parse(this.name, sub, this.options);
1267
+ this.type = "catalog";
1268
+ this.registry = this.subspec.final.registry;
1269
+ return;
1270
+ }
1271
+ if (this.bareSpec.startsWith("https://")) {
1272
+ for (const [name2, origin] of Object.entries(gitHostWebsites)) {
1273
+ if (this.bareSpec.startsWith(origin)) {
1274
+ const parsed = new URL(this.bareSpec);
1275
+ const [user, project] = parsed.pathname.replace(/\.git$/, "").replace(/\/+/g, " ").trim().split(" ");
1276
+ if (user && project) {
1277
+ this.bareSpec = `${name2}:${user}/${project}${parsed.hash}`;
1278
+ this.spec = `${this.name}@${this.bareSpec}`;
1279
+ break;
1280
+ }
1281
+ }
1282
+ }
1283
+ }
1284
+ if (this.bareSpec.startsWith("workspace:")) {
1285
+ this.type = "workspace";
1286
+ const ws2 = this.bareSpec.substring("workspace:".length).trim();
1287
+ const w = ws2.lastIndexOf("@");
1288
+ if (w === -1) {
1289
+ this.workspace = this.name;
1290
+ } else {
1291
+ const wsName = ws2.substring(0, w);
1292
+ if (!wsName || wsName === "*" || wsName === "~" || wsName === "^" || (wsName.startsWith("@") ? wsName.split("/").length !== 2 || wsName.substring(1).includes("@") : wsName.includes("@"))) {
1293
+ throw this.#error(
1294
+ "workspace: name must be a path or valid package name",
1295
+ { found: wsName }
1296
+ );
1297
+ }
1298
+ this.workspace = wsName;
1299
+ }
1300
+ const wss = w === -1 ? ws2 : ws2.substring(w + 1) || "*";
1301
+ const range2 = wss === "*" ? void 0 : parseRange(wss);
1302
+ if (wss !== "*" && wss !== "~" && wss !== "^" && !range2) {
1303
+ throw this.#error(
1304
+ "workspace: spec must be one of *, ~, or ^, or a valid semver range",
1305
+ {
1306
+ found: wss,
1307
+ wanted: `'*'|'~'|'^'|SemverRange`
1308
+ }
1309
+ );
1310
+ }
1311
+ this.workspaceSpec = wss;
1312
+ if (range2) {
1313
+ this.semver = wss;
1314
+ this.range = range2;
1315
+ }
1316
+ return;
1317
+ }
1318
+ if (this.bareSpec.startsWith("git://") || this.bareSpec.startsWith("git+ssh://") || this.bareSpec.startsWith("git+http://") || this.bareSpec.startsWith("git+https://") || this.bareSpec.startsWith("git+file://") || // legacy affordance
1319
+ this.bareSpec.startsWith("git@github.com")) {
1320
+ if (this.bareSpec.startsWith("git@")) {
1321
+ this.bareSpec = `git+ssh://${this.bareSpec}`;
1322
+ this.spec = `${this.name}@${this.bareSpec}`;
1323
+ }
1324
+ this.type = "git";
1325
+ for (const [name2, host] of Object.entries(
1326
+ this.options["git-hosts"]
1327
+ )) {
1328
+ const s = host.indexOf("$");
1329
+ if (s > 0 && this.bareSpec.startsWith(host.substring(0, s))) {
1330
+ const p = this.bareSpec.substring(s).replace(/\.git(#.*)?$/, "$1");
1331
+ this.bareSpec = `${name2}:${p}`;
1332
+ this.spec = `${this.name}@${this.bareSpec}`;
1333
+ this.#parseHostedGit(name2, host);
1334
+ this.type = "git";
1335
+ return;
1336
+ }
1337
+ }
1338
+ this.#parseGitSelector(this.bareSpec);
1339
+ return;
1340
+ }
1341
+ const regs = Object.entries(this.options.registries);
1342
+ if (this.bareSpec.startsWith("registry:")) {
1343
+ const reg = this.bareSpec.substring("registry:".length);
1344
+ const h = reg.indexOf("#");
1345
+ if (h === -1) {
1346
+ throw this.#error("registry: must include name/version");
1347
+ }
1348
+ this.type = "registry";
1349
+ let url = reg.substring(0, h);
1350
+ if (!url.endsWith("/")) url += "/";
1351
+ const regSpec = reg.substring(h + 1);
1352
+ for (let [name2, u] of regs) {
1353
+ if (!u.endsWith("/")) {
1354
+ u += "/";
1355
+ this.options.registries[name2] = u;
1356
+ }
1357
+ if (u === url) this.namedRegistry = name2;
1358
+ }
1359
+ this.#parseRegistrySpec(regSpec, url);
1360
+ this.#guessRegistryTarball();
1361
+ return;
1362
+ }
1363
+ for (const [host, url] of regs) {
1364
+ const h = `${host}:`;
1365
+ if (this.bareSpec.startsWith(h)) {
1366
+ this.type = "registry";
1367
+ this.namedRegistry = host;
1368
+ this.#parseRegistrySpec(
1369
+ this.bareSpec.substring(h.length),
1370
+ url
1371
+ ).namedRegistry ??= host;
1372
+ if (this.subspec && this.name === this.bareSpec) {
1373
+ this.name = this.subspec.name;
1374
+ this.spec = `${this.name}@${this.bareSpec}`;
1375
+ assertPathSafeName(this.name, this.spec);
1376
+ }
1377
+ this.#guessRegistryTarball();
1378
+ return;
1379
+ }
1380
+ }
1381
+ const ghosts = Object.entries(this.options["git-hosts"]);
1382
+ for (const [name2, template] of ghosts) {
1383
+ if (this.#parseHostedGit(name2, template)) {
1384
+ this.type = "git";
1385
+ return;
1386
+ }
1387
+ }
1388
+ const jsrs = Object.entries(this.options["jsr-registries"]);
1389
+ for (const [host, url] of jsrs) {
1390
+ const h = `${host}:`;
1391
+ if (this.bareSpec.startsWith(h)) {
1392
+ this.type = "registry";
1393
+ this.namedJsrRegistry = host;
1394
+ this.#parseJsrRegistrySpec(
1395
+ this.bareSpec.substring(h.length),
1396
+ url
1397
+ ).namedJsrRegistry ??= host;
1398
+ return;
1399
+ }
1400
+ }
1401
+ if (this.bareSpec.startsWith("https://") || this.bareSpec.startsWith("http://")) {
1402
+ this.remoteURL = this.bareSpec;
1403
+ this.type = "remote";
1404
+ return;
1405
+ }
1406
+ if (this.bareSpec.startsWith("file:")) {
1407
+ this.type = "file";
1408
+ const [path, uri] = getNormalizeFile(
1409
+ this.constructor.nodejsDependencies
1410
+ )(this.bareSpec, this);
1411
+ this.file = path;
1412
+ this.bareSpec = uri.replace(/\/+$/, "");
1413
+ this.spec = `${this.name}@${this.bareSpec}`;
1414
+ return;
1415
+ }
1416
+ this.#assertKnownProtocol(this.bareSpec);
1417
+ if (!this.bareSpec.startsWith("./") && !this.bareSpec.startsWith("../") && this.options["git-hosts"].github) {
1418
+ const hash2 = this.bareSpec.indexOf("#");
1419
+ const up = hash2 === -1 ? this.bareSpec : this.bareSpec.substring(0, hash2);
1420
+ if (up.split("/").length === 2) {
1421
+ this.bareSpec = `github:${this.bareSpec}`;
1422
+ this.spec = `${this.name}@${this.bareSpec}`;
1423
+ this.#parseHostedGit(
1424
+ "github",
1425
+ this.options["git-hosts"].github
1426
+ );
1427
+ this.type = "git";
1428
+ return;
1429
+ }
1430
+ }
1431
+ if (this.bareSpec.includes("/") || this.bareSpec === "." || this.bareSpec === "..") {
1432
+ this.type = "file";
1433
+ const [file, uri] = getNormalizeFile(
1434
+ this.constructor.nodejsDependencies
1435
+ )(`file:${this.bareSpec}`, this);
1436
+ this.bareSpec = uri;
1437
+ this.spec = `${this.name}@${this.bareSpec}`;
1438
+ this.file = file;
1439
+ return;
1440
+ }
1441
+ this.type = "registry";
1442
+ const range = parseRange(this.bareSpec);
1443
+ if (range) {
1444
+ this.semver = this.bareSpec.trim();
1445
+ this.range = range;
1446
+ } else {
1447
+ this.distTag = this.bareSpec;
1448
+ }
1449
+ this.registrySpec = this.bareSpec;
1450
+ const {
1451
+ "scoped-registries": scopeRegs,
1452
+ registry,
1453
+ registries,
1454
+ "default-registry-alias": defaultAlias
1455
+ } = this.options;
1456
+ const scopeReg = this.scope && scopeRegs[this.scope];
1457
+ this.registry = scopeReg ?? registry ?? registries[defaultAlias];
1458
+ for (const r of Object.values(this.options["jsr-registries"])) {
1459
+ if (this.registry === r) return;
1460
+ }
1461
+ this.#guessRegistryTarball();
1462
+ }
1463
+ #parseScope(name2) {
1464
+ if (!name2.startsWith("@")) return;
1465
+ const s = name2.indexOf("/");
1466
+ if (s > 1 && s < name2.length - 1) {
1467
+ const scope = name2.substring(0, s);
1468
+ this.registry = this.scopeRegistry = this.options["scoped-registries"][scope];
1469
+ this.scope = scope;
1470
+ }
1471
+ }
1472
+ #parseHostedGit(name2, template) {
1473
+ if (this.bareSpec.startsWith(`${name2}:`)) {
1474
+ const h = this.bareSpec.indexOf("#");
1475
+ const bare = h === -1 ? this.bareSpec : this.bareSpec.substring(0, h);
1476
+ const hash2 = h === -1 ? "" : this.bareSpec.substring(h);
1477
+ const hostPath = bare.substring(name2.length + 1);
1478
+ if (!hostPath) {
1479
+ throw this.#error("invalid named git host specifier");
1480
+ }
1481
+ const split = hostPath.split("/");
1482
+ let t = template;
1483
+ for (let i = 0; i < split.length; i++) {
1484
+ t = t.split(`$${i + 1}`).join(split[i]);
1485
+ }
1486
+ t += hash2;
1487
+ this.namedGitHost = name2;
1488
+ this.namedGitHostPath = hostPath;
1489
+ this.#parseGitSelector(t);
1490
+ if (this.gitCommittish && !this.gitSelectorParsed?.path) {
1491
+ const archiveHost = this.options["git-host-archives"][name2];
1492
+ if (name2 === "github" && this.gitCommittish.startsWith("pull/") && this.gitCommittish.match(/\//g)?.length === 1) {
1493
+ this.gitCommittish += "/head";
1494
+ }
1495
+ if (archiveHost) {
1496
+ this.type = "remote";
1497
+ let t2 = archiveHost;
1498
+ t2 = t2.split("$committish").join(this.gitCommittish);
1499
+ for (let i = 0; i < split.length; i++) {
1500
+ t2 = t2.split(`$${i + 1}`).join(split[i]);
1501
+ }
1502
+ this.remoteURL = t2;
1503
+ }
1504
+ }
1505
+ return true;
1506
+ }
1507
+ return false;
1508
+ }
1509
+ /* c8 ignore start */
1510
+ [kCustomInspect]() {
1511
+ return `@vltpkg/spec.Spec ${String(this)}`;
1512
+ }
1513
+ /* c8 ignore stop */
1514
+ #guessRegistryTarball() {
1515
+ const { name: name2, registry, range } = this.final;
1516
+ if (!registry || !range?.isSingle) return;
1517
+ const stripScope = /^@[^/]+\//;
1518
+ const base = registry.endsWith("/") ? registry : registry + "/";
1519
+ this.conventionalRegistryTarball = String(
1520
+ new URL(
1521
+ `${name2}/-/${name2.replace(stripScope, "")}-${range}.tgz`,
1522
+ base
1523
+ )
1524
+ );
1525
+ }
1526
+ #parseRegistrySpec(s, url) {
1527
+ this.registry = url;
1528
+ this.subspec = this.constructor.parse(s, {
1529
+ ...this.options,
1530
+ registry: url
1531
+ });
1532
+ return this.subspec;
1533
+ }
1534
+ #parseJsrRegistrySpec(s, url) {
1535
+ this.registry = url;
1536
+ if (!s.startsWith("@")) s = `${this.name}@${s}`;
1537
+ const name2 = s.startsWith("@jsr/") ? s : `@jsr/${s.replace(/^@/, "").replace(/\//, "__")}`;
1538
+ this.subspec = this.constructor.parse(name2, {
1539
+ ...this.options,
1540
+ "scoped-registries": {
1541
+ ...this.options["scoped-registries"],
1542
+ "@jsr": url
1543
+ }
1544
+ });
1545
+ if (this.name === "(unknown)") {
1546
+ const nextAt = s.indexOf("@", 1);
1547
+ if (nextAt === -1) {
1548
+ this.name = s;
1549
+ } else {
1550
+ this.name = s.substring(0, s.indexOf("@", 1));
1551
+ }
1552
+ assertPathSafeName(this.name, s);
1553
+ }
1554
+ const reg = `${this.namedJsrRegistry}:`;
1555
+ const n7 = `${reg}${this.name}`;
1556
+ if (this.bareSpec.startsWith(n7 + "@")) {
1557
+ this.bareSpec = reg + this.bareSpec.substring(n7.length + 1);
1558
+ } else if (this.bareSpec === n7) {
1559
+ this.bareSpec = reg;
1560
+ }
1561
+ this.spec = this.name + "@" + this.bareSpec;
1562
+ return this.subspec;
1563
+ }
1564
+ #assertKnownProtocol(str) {
1565
+ const proto = unknownProtocol(str, this.options);
1566
+ if (proto === void 0) return;
1567
+ throw this.#error(`Protocol ${proto}: is not defined`, {
1568
+ found: `${proto}:`,
1569
+ validOptions: [
1570
+ .../* @__PURE__ */ new Set([
1571
+ ...builtinProtocols,
1572
+ this.options["default-registry-alias"],
1573
+ ...Object.keys(this.options.registries),
1574
+ ...Object.keys(this.options["git-hosts"]),
1575
+ ...Object.keys(this.options["jsr-registries"])
1576
+ ])
1577
+ ].map((p) => `${p}:`)
1578
+ });
1579
+ }
1580
+ #error(message, extra = {}) {
1581
+ return error(message, { spec: this.spec, ...extra }, this.#error);
1582
+ }
1583
+ #parseGitSelector(s) {
1584
+ const h = s.indexOf("#");
1585
+ if (h === -1) {
1586
+ this.gitRemote = s;
1587
+ return;
1588
+ }
1589
+ this.gitRemote = s.substring(0, h);
1590
+ this.gitSelector = s.substring(h + 1);
1591
+ const [selectorParsed, committish, range] = this.constructor.parseGitSelector(this.gitSelector, this);
1592
+ this.range = range;
1593
+ this.gitCommittish = committish;
1594
+ this.gitSelectorParsed = selectorParsed;
1595
+ }
1596
+ /**
1597
+ * Should only ever be called with the bit that comes AFTER the #
1598
+ * in the git remote url.
1599
+ */
1600
+ static parseGitSelector(selector, spec) {
1601
+ if (!selector) return [{}];
1602
+ const split = selector.split("::");
1603
+ const first = split[0];
1604
+ let committish = void 0;
1605
+ let range = void 0;
1606
+ const parsed = {};
1607
+ if (typeof first !== "string") {
1608
+ throw typeError("impossible", {
1609
+ found: first,
1610
+ wanted: String
1611
+ });
1612
+ }
1613
+ if (!first.includes(":")) {
1614
+ committish = first;
1615
+ split.shift();
1616
+ }
1617
+ for (const kv of split) {
1618
+ const c = kv.indexOf(":");
1619
+ if (c === -1) continue;
1620
+ const k3 = kv.substring(0, c);
1621
+ const v2 = kv.substring(c + 1);
1622
+ if (k3 === "semver") {
1623
+ if (committish) {
1624
+ throw error(
1625
+ "Cannot specify a semver range and committish value",
1626
+ { spec }
1627
+ );
1628
+ }
1629
+ range = parseRange(v2);
1630
+ if (!range) {
1631
+ throw error(`Invalid git tag semver range: ${v2}`, { spec });
1632
+ }
1633
+ }
1634
+ if (k3 === "semver" || k3 === "path") {
1635
+ if (k3 === "path") {
1636
+ if (
1637
+ /* c8 ignore next */
1638
+ this.nodejsDependencies?.isAbsolute(
1639
+ v2
1640
+ ) || /(^|\/|\\)\.\.($|\\|\/)/.test(v2)
1641
+ ) {
1642
+ throw error("Invalid path in git selector", { spec });
1643
+ }
1644
+ parsed.path = (this.nodejsDependencies ? this.nodejsDependencies.join("/", v2).substring(1) : v2).replace(/\\/g, "/");
1645
+ } else {
1646
+ parsed[k3] = v2;
1647
+ }
1648
+ }
1649
+ }
1650
+ return [parsed, committish, range];
1651
+ }
1652
+ };
1653
+ var getNormalizeFile = (opts) => (bareSpec, spec) => {
1654
+ const slashes = bareSpec.substring(
1655
+ "file:".length,
1656
+ "file://".length
1657
+ );
1658
+ const pref = `file:${slashes === "//" ? slashes : ""}`;
1659
+ const rest = bareSpec.substring(pref.length);
1660
+ const [a = "", b = "/", c = "/", d3 = "/"] = rest.split("", 4);
1661
+ if (!a) {
1662
+ return [".", "file:."];
1663
+ }
1664
+ if (a === "/" && b === "~" && c !== "/" || a === "~" && b !== "/") {
1665
+ throw error(
1666
+ `invalid file: specifier. '~username' not supported`,
1667
+ { spec }
1668
+ );
1669
+ }
1670
+ if (a === "~") {
1671
+ return (
1672
+ /* c8 ignore start */
1673
+ opts ? [
1674
+ opts.resolve(opts.homedir(), rest.substring(2)),
1675
+ `file:${rest}`
1676
+ ] : [rest, `file:${rest}`]
1677
+ );
1678
+ }
1679
+ if (a === "/" && b === "~") {
1680
+ return opts ? [
1681
+ opts.resolve(opts.homedir(), rest.substring(3)),
1682
+ `file:${rest.substring(1)}`
1683
+ ] : (
1684
+ /* c8 ignore stop */
1685
+ [rest.substring(1), `file:${rest.substring(1)}`]
1686
+ );
1687
+ }
1688
+ if (a === "/" && b === "." && (c === "/" || c === "." && d3 === "/")) {
1689
+ return [rest.substring(1), `file:${rest.substring(1)}`];
1690
+ }
1691
+ if (a === "." && (b === "/" || b === "." && c === "/")) {
1692
+ return [rest, `file:${rest}`];
1693
+ }
1694
+ if (slashes === "//") {
1695
+ try {
1696
+ const parsed = new URL(bareSpec);
1697
+ if (parsed.host) {
1698
+ if (parsed.host !== "localhost") {
1699
+ throw error(
1700
+ `invalid file:// specifier. host must be empty or 'localhost'`,
1701
+ {
1702
+ spec,
1703
+ found: parsed.host,
1704
+ validOptions: ["", "localhost"]
1705
+ }
1706
+ );
1707
+ }
1708
+ }
1709
+ return [
1710
+ parsed.pathname.replace(/^\/([a-zA-Z]:\/)/, "$1"),
1711
+ `file://${parsed.pathname}`
1712
+ ];
1713
+ } catch (er) {
1714
+ throw error("invalid file:// specifier", {
1715
+ spec,
1716
+ cause: er
1717
+ });
1718
+ }
1719
+ }
1720
+ if (opts?.winPath.isAbsolute(rest)) {
1721
+ return [rest, `file://${rest}`];
1722
+ }
1723
+ return [`./${rest}`, `file:./${rest}`];
1724
+ };
1725
+
1726
+ // ../../src/types/src/index.ts
1727
+ import { posix } from "node:path";
1728
+ import { debuglog } from "node:util";
1729
+ var debug = debuglog("vlt");
1730
+ var unixify = (ref) => ref.replace(/[\\:]/g, "/");
1731
+ var secure = (ref) => {
1732
+ const s = unixify(posix.join(".", posix.join("/", unixify(ref))));
1733
+ return s === "./" ? "" : s;
1734
+ };
1735
+ var secureBinPaths = (bin) => {
1736
+ const res = {};
1737
+ for (const [key, val] of Object.entries(bin)) {
1738
+ const v2 = typeof val === "string" ? secure(val) : "";
1739
+ const k3 = posix.basename(secure(key));
1740
+ if (!k3 || !v2) {
1741
+ debug("dropped unusable bin entry", key, val);
1742
+ continue;
1743
+ }
1744
+ if (k3 !== key || v2 !== val) {
1745
+ debug("rewrote unsafe bin entry", key, val, "->", k3, v2);
1746
+ }
1747
+ res[k3] = v2;
1748
+ }
1749
+ return res;
1750
+ };
1751
+ var normalizeBinPaths = (manifest) => {
1752
+ const { name: name2, bin } = manifest;
1753
+ if (bin) {
1754
+ if (name2 && typeof bin === "string") {
1755
+ const [_scope, pkg] = parseScope(name2);
1756
+ return secureBinPaths({ [pkg]: bin });
1757
+ } else if (typeof bin === "object") {
1758
+ return secureBinPaths(bin);
1759
+ }
1760
+ }
1761
+ };
1762
+ var integrityRE = /^sha512-[a-zA-Z0-9/+]{86}==$/;
1763
+ var isIntegrity = (i) => typeof i === "string" && integrityRE.test(i);
1764
+ var integrityHex = (i) => isIntegrity(i) ? Buffer.from(i.slice(7), "base64").toString("hex") : void 0;
1765
+ var asError = (er, fallbackMessage = "Unknown error") => er instanceof Error ? er : new Error(String(er) || fallbackMessage);
1766
+ var isObject = (v2) => !!v2 && typeof v2 === "object" && (v2.constructor === Object || v2.constructor === void 0);
1767
+ var maybeRecordStringString = (o) => o === void 0 || isRecordStringString(o);
1768
+ var isRecordStringString = (o) => isRecordStringT(o, (s) => typeof s === "string");
1769
+ var isRecordStringT = (o, check) => isObject(o) && Object.entries(o).every(
1770
+ ([k3, v2]) => typeof k3 === "string" && check(v2)
1771
+ );
1772
+ var maybePeerDependenciesMetaSet = (o) => o === void 0 || isRecordStringT(
1773
+ o,
1774
+ (v2) => isPeerDependenciesMetaValue(v2)
1775
+ );
1776
+ var maybeBoolean = (o) => o === void 0 || typeof o === "boolean";
1777
+ var isPeerDependenciesMetaValue = (o) => isObject(o) && maybeBoolean(o.optional);
1778
+ var maybeString = (a) => a === void 0 || typeof a === "string";
1779
+ var maybeDist = (a) => a === void 0 || isObject(a) && maybeString(a.tarball);
1780
+ var isManifest = (m) => isObject(m) && !Array.isArray(m) && maybeString(m.name) && maybeString(m.version) && maybeRecordStringString(m.dependencies) && maybeRecordStringString(m.devDependencies) && maybeRecordStringString(m.optionalDependencies) && maybeRecordStringString(m.peerDependencies) && maybeRecordStringString(m.acceptDependencies) && maybePeerDependenciesMetaSet(m.peerDependenciesMeta) && maybeDist(m.dist);
1781
+ var parseScope = (scoped) => {
1782
+ if (scoped.startsWith("@")) {
1783
+ const [scope, name2, ...rest] = scoped.split("/");
1784
+ if (scope && name2 && rest.length === 0) return [scope, name2];
1785
+ }
1786
+ return [void 0, scoped];
1787
+ };
23
1788
 
24
1789
  // ../../src/cache/src/index.ts
25
1790
  import { createHash, randomBytes } from "node:crypto";
@@ -624,7 +2389,7 @@ import { resolve as resolve6, dirname } from "node:path";
624
2389
 
625
2390
  // ../../node_modules/.vlt/~npm~glob@13.0.6/node_modules/glob/dist/esm/index.min.js
626
2391
  import { fileURLToPath as Wi } from "node:url";
627
- import { posix as mi, win32 as re } from "node:path";
2392
+ import { posix as mi, win32 as re2 } from "node:path";
628
2393
  import { fileURLToPath as gi } from "node:url";
629
2394
  import { lstatSync as wi, readdir as yi, readdirSync as bi, readlinkSync as Si, realpathSync as Ei } from "node:fs";
630
2395
  import * as xi from "node:fs";
@@ -2748,7 +4513,7 @@ var Pt = class n2 extends R2 {
2748
4513
  return new n2(t, e, this.root, this.roots, this.nocase, this.childrenCache(), s);
2749
4514
  }
2750
4515
  getRootString(t) {
2751
- return re.parse(t).root;
4516
+ return re2.parse(t).root;
2752
4517
  }
2753
4518
  getRoot(t) {
2754
4519
  if (t = Ri(t.toUpperCase()), t === this.root.name) return this.root;
@@ -3020,11 +4785,11 @@ var it = class extends It {
3020
4785
  sep = "\\";
3021
4786
  constructor(t = process.cwd(), e = {}) {
3022
4787
  let { nocase: s = true } = e;
3023
- super(t, re, "\\", { ...e, nocase: s }), this.nocase = s;
4788
+ super(t, re2, "\\", { ...e, nocase: s }), this.nocase = s;
3024
4789
  for (let i = this.cwd; i; i = i.parent) i.nocase = this.nocase;
3025
4790
  }
3026
4791
  parseRootPath(t) {
3027
- return re.parse(t).root.toUpperCase();
4792
+ return re2.parse(t).root.toUpperCase();
3028
4793
  }
3029
4794
  newRoot(t) {
3030
4795
  return new Pt(this.rootPath, U2, void 0, this.roots, this.nocase, this.childrenCache(), { fs: t });
@@ -3916,10 +5681,10 @@ var isDirSync = (path) => {
3916
5681
  var isDir = (path) => stat(path).then((st2) => st2.isDirectory(), () => false);
3917
5682
  var win32DefaultTmp = async (path) => {
3918
5683
  const { root } = parse3(path);
3919
- const tmp = tmpdir();
3920
- const { root: tmpRoot } = parse3(tmp);
5684
+ const tmp2 = tmpdir();
5685
+ const { root: tmpRoot } = parse3(tmp2);
3921
5686
  if (root.toLowerCase() === tmpRoot.toLowerCase()) {
3922
- return tmp;
5687
+ return tmp2;
3923
5688
  }
3924
5689
  const driveTmp = resolve3(root, "/temp");
3925
5690
  if (await isDir(driveTmp)) {
@@ -3929,10 +5694,10 @@ var win32DefaultTmp = async (path) => {
3929
5694
  };
3930
5695
  var win32DefaultTmpSync = (path) => {
3931
5696
  const { root } = parse3(path);
3932
- const tmp = tmpdir();
3933
- const { root: tmpRoot } = parse3(tmp);
5697
+ const tmp2 = tmpdir();
5698
+ const { root: tmpRoot } = parse3(tmp2);
3934
5699
  if (root.toLowerCase() === tmpRoot.toLowerCase()) {
3935
- return tmp;
5700
+ return tmp2;
3936
5701
  }
3937
5702
  const driveTmp = resolve3(root, "/temp");
3938
5703
  if (isDirSync(driveTmp)) {
@@ -3991,10 +5756,10 @@ var rimrafMoveRemoveDir = async (path, opt, ent) => {
3991
5756
  await ignoreENOENT(tmpUnlink(path, opt.tmp, rmdir2));
3992
5757
  return true;
3993
5758
  };
3994
- var tmpUnlink = async (path, tmp, rm2) => {
3995
- const tmpFile = resolve4(tmp, uniqueFilename(path));
5759
+ var tmpUnlink = async (path, tmp2, rm3) => {
5760
+ const tmpFile = resolve4(tmp2, uniqueFilename(path));
3996
5761
  await rename(path, tmpFile);
3997
- return await rm2(tmpFile);
5762
+ return await rm3(tmpFile);
3998
5763
  };
3999
5764
  var rimrafMoveRemoveSync = (path, opt) => {
4000
5765
  opt?.signal?.throwIfAborted();
@@ -4005,7 +5770,7 @@ var rimrafMoveRemoveDirSync = (path, opt, ent) => {
4005
5770
  if (!opt.tmp) {
4006
5771
  return rimrafMoveRemoveDirSync(path, { ...opt, tmp: defaultTmpSync(path) }, ent);
4007
5772
  }
4008
- const tmp = opt.tmp;
5773
+ const tmp2 = opt.tmp;
4009
5774
  if (path === opt.tmp && parse4(path).root !== path) {
4010
5775
  throw new Error("cannot delete temp directory used for deletion");
4011
5776
  }
@@ -4022,7 +5787,7 @@ var rimrafMoveRemoveDirSync = (path, opt, ent) => {
4022
5787
  if (opt.filter && !opt.filter(path, ent)) {
4023
5788
  return false;
4024
5789
  }
4025
- ignoreENOENTSync(() => tmpUnlinkSync(path, tmp, unlinkFixEPERMSync));
5790
+ ignoreENOENTSync(() => tmpUnlinkSync(path, tmp2, unlinkFixEPERMSync));
4026
5791
  return true;
4027
5792
  }
4028
5793
  let removedAll = true;
@@ -4039,13 +5804,13 @@ var rimrafMoveRemoveDirSync = (path, opt, ent) => {
4039
5804
  if (opt.filter && !opt.filter(path, ent)) {
4040
5805
  return false;
4041
5806
  }
4042
- ignoreENOENTSync(() => tmpUnlinkSync(path, tmp, rmdirSync));
5807
+ ignoreENOENTSync(() => tmpUnlinkSync(path, tmp2, rmdirSync));
4043
5808
  return true;
4044
5809
  };
4045
- var tmpUnlinkSync = (path, tmp, rmSync2) => {
4046
- const tmpFile = resolve4(tmp, uniqueFilename(path));
5810
+ var tmpUnlinkSync = (path, tmp2, rmSync3) => {
5811
+ const tmpFile = resolve4(tmp2, uniqueFilename(path));
4047
5812
  renameSync(path, tmpFile);
4048
- return rmSync2(tmpFile);
5813
+ return rmSync3(tmpFile);
4049
5814
  };
4050
5815
 
4051
5816
  // ../../node_modules/.vlt/~npm~rimraf@6.1.3/node_modules/rimraf/dist/esm/rimraf-windows.js
@@ -4230,7 +5995,7 @@ var windows = Object.assign(wrap(rimrafWindows), {
4230
5995
  sync: windowsSync
4231
5996
  });
4232
5997
  var posixSync = wrapSync(rimrafPosixSync);
4233
- var posix = Object.assign(wrap(rimrafPosix), { sync: posixSync });
5998
+ var posix2 = Object.assign(wrap(rimrafPosix), { sync: posixSync });
4234
5999
  var moveRemoveSync = wrapSync(rimrafMoveRemoveSync);
4235
6000
  var moveRemove = Object.assign(wrap(rimrafMoveRemove), {
4236
6001
  sync: moveRemoveSync
@@ -4245,7 +6010,7 @@ var rimraf = Object.assign(rimraf_, {
4245
6010
  manualSync,
4246
6011
  native,
4247
6012
  nativeSync,
4248
- posix,
6013
+ posix: posix2,
4249
6014
  posixSync,
4250
6015
  windows,
4251
6016
  windowsSync,
@@ -4269,6 +6034,7 @@ var Cache = class _Cache extends I {
4269
6034
  #pending = /* @__PURE__ */ new Set();
4270
6035
  onDiskWrite;
4271
6036
  onDiskDelete;
6037
+ store;
4272
6038
  /**
4273
6039
  * A list of the actions currently happening in the background
4274
6040
  */
@@ -4287,6 +6053,7 @@ var Cache = class _Cache extends I {
4287
6053
  onDiskWrite,
4288
6054
  onDiskDelete,
4289
6055
  path,
6056
+ store,
4290
6057
  fetchMethod: _2,
4291
6058
  sizeCalculation = options.maxSize || options.maxEntrySize ? (v2, k3) => v2.length + k3.length : void 0,
4292
6059
  ...lruOpts
@@ -4310,6 +6077,7 @@ var Cache = class _Cache extends I {
4310
6077
  });
4311
6078
  this.onDiskWrite = onDiskWrite;
4312
6079
  this.onDiskDelete = onDiskDelete;
6080
+ this.store = store;
4313
6081
  this.#path = path;
4314
6082
  }
4315
6083
  /**
@@ -4435,16 +6203,14 @@ var Cache = class _Cache extends I {
4435
6203
  */
4436
6204
  integrityPath(integrity) {
4437
6205
  if (!integrity) return void 0;
4438
- const m = /^sha512-([a-zA-Z0-9/+]{86}==)$/.exec(integrity);
4439
- const hash2 = m?.[1];
4440
- if (!hash2) {
6206
+ const hex = integrityHex(integrity);
6207
+ if (!hex) {
4441
6208
  throw error("invalid integrity value", {
4442
6209
  found: integrity,
4443
- wanted: /^sha512-([a-zA-Z0-9/+]{86}==)$/
6210
+ wanted: integrityRE
4444
6211
  });
4445
6212
  }
4446
- const base = Buffer.from(hash2, "base64").toString("hex");
4447
- return resolve6(this.#path, base);
6213
+ return resolve6(this.#path, hex);
4448
6214
  }
4449
6215
  /**
4450
6216
  * Read synchronously from the fs cache storage if not already
@@ -4471,13 +6237,20 @@ var Cache = class _Cache extends I {
4471
6237
  }
4472
6238
  /* c8 ignore stop */
4473
6239
  /**
4474
- * Delete path and path + '.key'
6240
+ * Delete path and path + '.key', and with an integrity, its
6241
+ * integrity link and global store entry
4475
6242
  */
4476
6243
  async #diskDelete(path, integrity) {
4477
- const intPath = this.#maybeIntegrityPath(integrity);
4478
6244
  const paths = [path, path + ".key"];
4479
- if (intPath) paths.push(intPath);
4480
- return await rimraf(paths);
6245
+ const hex = integrityHex(integrity);
6246
+ if (hex) paths.push(resolve6(this.#path, hex));
6247
+ const deleted = await rimraf(paths);
6248
+ if (hex && this.store) {
6249
+ const entry = resolve6(this.store, hex);
6250
+ await rimraf(entry);
6251
+ await rimraf([entry + ".json", entry + ".copied"]);
6252
+ }
6253
+ return deleted;
4481
6254
  }
4482
6255
  #maybeIntegrityPath(i) {
4483
6256
  try {
@@ -4486,14 +6259,14 @@ var Cache = class _Cache extends I {
4486
6259
  }
4487
6260
  }
4488
6261
  async #writeFileAtomic(file, data) {
4489
- const tmp = `${file}.${this.#random}.${this.#i++}`;
4490
- await writeFile(tmp, data);
4491
- await rename2(tmp, file);
6262
+ const tmp2 = `${file}.${this.#random}.${this.#i++}`;
6263
+ await writeFile(tmp2, data);
6264
+ await rename2(tmp2, file);
4492
6265
  }
4493
6266
  async #linkAtomic(src, dest) {
4494
- const tmp = `${dest}.${this.#random}.${this.#i++}`;
4495
- await link(src, tmp);
4496
- await rename2(tmp, dest);
6267
+ const tmp2 = `${dest}.${this.#random}.${this.#i++}`;
6268
+ await link(src, tmp2);
6269
+ await rename2(tmp2, dest);
4497
6270
  }
4498
6271
  async #diskWrite(valFile, key, val, integrity) {
4499
6272
  const dir = dirname(valFile);
@@ -4543,9 +6316,595 @@ var Cache = class _Cache extends I {
4543
6316
  };
4544
6317
 
4545
6318
  // ../../src/cache-unzip/src/unzip.ts
6319
+ import { setPriority } from "node:os";
4546
6320
  import { pathToFileURL } from "node:url";
6321
+ import { debuglog as debuglog4 } from "node:util";
4547
6322
  import { gunzipSync } from "node:zlib";
4548
- var __CODE_SPLIT_SCRIPT_NAME = import.meta.filename;
6323
+
6324
+ // ../../src/tar/src/store-index.ts
6325
+ import { readFileSync as readFileSync2 } from "node:fs";
6326
+ import { debuglog as debuglog2 } from "node:util";
6327
+ var debug2 = debuglog2("vlt");
6328
+ var storeIndexPath = (storeEntry) => storeEntry + ".json";
6329
+ var isRecord2 = (x3) => !!x3 && typeof x3 === "object" && !Array.isArray(x3);
6330
+ var isOptString = (x3) => x3 === void 0 || typeof x3 === "string";
6331
+ var unsafePath = /(?:^|\/)\.{0,2}(?:\/|$)|\\/;
6332
+ var isRelPath = (p) => typeof p === "string" && !unsafePath.test(p);
6333
+ var isIndexFile = (f) => Array.isArray(f) && f.length === 3 && isRelPath(f[0]) && typeof f[1] === "number" && (f[2] === 0 || f[2] === 1);
6334
+ var isStoreIndex = (x3) => isRecord2(x3) && x3.v === 1 && typeof x3.scripts === "boolean" && isOptString(x3.name) && isOptString(x3.version) && (x3.bins === void 0 || isRecord2(x3.bins) && Object.values(x3.bins).every((b) => typeof b === "string")) && Array.isArray(x3.dirs) && x3.dirs.every(isRelPath) && Array.isArray(x3.files) && x3.files.every(isIndexFile) && isOptString(x3.manifest);
6335
+ var readStoreIndex = (storeEntry) => {
6336
+ let index;
6337
+ try {
6338
+ index = JSON.parse(
6339
+ readFileSync2(storeIndexPath(storeEntry), "utf8")
6340
+ );
6341
+ } catch (er) {
6342
+ if (er.code !== "ENOENT") {
6343
+ debug2("global store: invalid index", storeEntry);
6344
+ }
6345
+ return void 0;
6346
+ }
6347
+ if (isStoreIndex(index)) return index;
6348
+ debug2("global store: invalid index", storeEntry);
6349
+ return void 0;
6350
+ };
6351
+ var storeIndexManifest = (packageJson, bindingGyp) => {
6352
+ let pkg;
6353
+ try {
6354
+ pkg = JSON.parse(
6355
+ packageJson.toString("utf8").replace(/^\uFEFF/, "")
6356
+ );
6357
+ } catch (cause) {
6358
+ throw error("invalid package.json in tarball", { cause });
6359
+ }
6360
+ if (!isRecord2(pkg)) {
6361
+ throw error("invalid package.json in tarball", { found: pkg });
6362
+ }
6363
+ const { name: name2, version, scripts, bin } = pkg;
6364
+ const s = isRecord2(scripts) ? scripts : {};
6365
+ const result = {
6366
+ scripts: !!(s.install || s.preinstall || s.postinstall) || bindingGyp
6367
+ };
6368
+ const bins = normalizeBinPaths({
6369
+ name: typeof name2 === "string" ? name2 : void 0,
6370
+ bin
6371
+ });
6372
+ if (bins && Object.keys(bins).length) result.bins = bins;
6373
+ if (typeof name2 === "string") result.name = name2;
6374
+ if (typeof version === "string") result.version = version;
6375
+ if (isManifest(pkg)) result.manifest = JSON.stringify(pkg);
6376
+ return result;
6377
+ };
6378
+
6379
+ // ../../src/tar/src/unpack.ts
6380
+ import { randomBytes as randomBytes2 } from "node:crypto";
6381
+ import {
6382
+ chmodSync as chmodSync2,
6383
+ lstatSync as lstatSync2,
6384
+ mkdirSync as mkdirSync2,
6385
+ readFileSync as readFileSync3,
6386
+ renameSync as renameSync2,
6387
+ statSync as statSync2,
6388
+ writeFileSync
6389
+ } from "node:fs";
6390
+ import {
6391
+ basename as basename3,
6392
+ dirname as dirname2,
6393
+ isAbsolute,
6394
+ join,
6395
+ relative,
6396
+ resolve as resolve7,
6397
+ sep
6398
+ } from "node:path";
6399
+
6400
+ // ../../node_modules/.vlt/~npm~tar@7.5.22/node_modules/tar/dist/esm/header.js
6401
+ import { posix as pathModule } from "node:path";
6402
+
6403
+ // ../../node_modules/.vlt/~npm~tar@7.5.22/node_modules/tar/dist/esm/large-numbers.js
6404
+ var encode = (num, buf) => {
6405
+ if (!Number.isSafeInteger(num)) {
6406
+ throw Error("cannot encode number outside of javascript safe integer range");
6407
+ } else if (num < 0) {
6408
+ encodeNegative(num, buf);
6409
+ } else {
6410
+ encodePositive(num, buf);
6411
+ }
6412
+ return buf;
6413
+ };
6414
+ var encodePositive = (num, buf) => {
6415
+ buf[0] = 128;
6416
+ for (var i = buf.length; i > 1; i--) {
6417
+ buf[i - 1] = num & 255;
6418
+ num = Math.floor(num / 256);
6419
+ }
6420
+ };
6421
+ var encodeNegative = (num, buf) => {
6422
+ buf[0] = 255;
6423
+ var flipped = false;
6424
+ num = num * -1;
6425
+ for (var i = buf.length; i > 1; i--) {
6426
+ var byte = num & 255;
6427
+ num = Math.floor(num / 256);
6428
+ if (flipped) {
6429
+ buf[i - 1] = onesComp(byte);
6430
+ } else if (byte === 0) {
6431
+ buf[i - 1] = 0;
6432
+ } else {
6433
+ flipped = true;
6434
+ buf[i - 1] = twosComp(byte);
6435
+ }
6436
+ }
6437
+ };
6438
+ var parse6 = (buf) => {
6439
+ const pre = buf[0];
6440
+ const value = pre === 128 ? pos(buf.subarray(1, buf.length)) : pre === 255 ? twos(buf) : null;
6441
+ if (value === null) {
6442
+ throw Error("invalid base256 encoding");
6443
+ }
6444
+ if (!Number.isSafeInteger(value)) {
6445
+ throw Error("parsed number outside of javascript safe integer range");
6446
+ }
6447
+ return value;
6448
+ };
6449
+ var twos = (buf) => {
6450
+ var len = buf.length;
6451
+ var sum = 0;
6452
+ var flipped = false;
6453
+ for (var i = len - 1; i > -1; i--) {
6454
+ var byte = Number(buf[i]);
6455
+ var f;
6456
+ if (flipped) {
6457
+ f = onesComp(byte);
6458
+ } else if (byte === 0) {
6459
+ f = byte;
6460
+ } else {
6461
+ flipped = true;
6462
+ f = twosComp(byte);
6463
+ }
6464
+ if (f !== 0) {
6465
+ sum -= f * Math.pow(256, len - i - 1);
6466
+ }
6467
+ }
6468
+ return sum;
6469
+ };
6470
+ var pos = (buf) => {
6471
+ var len = buf.length;
6472
+ var sum = 0;
6473
+ for (var i = len - 1; i > -1; i--) {
6474
+ var byte = Number(buf[i]);
6475
+ if (byte !== 0) {
6476
+ sum += byte * Math.pow(256, len - i - 1);
6477
+ }
6478
+ }
6479
+ return sum;
6480
+ };
6481
+ var onesComp = (byte) => (255 ^ byte) & 255;
6482
+ var twosComp = (byte) => (255 ^ byte) + 1 & 255;
6483
+
6484
+ // ../../node_modules/.vlt/~npm~tar@7.5.22/node_modules/tar/dist/esm/types.js
6485
+ var isCode = (c) => name.has(c);
6486
+ var normalFsTypes = /* @__PURE__ */ new Set([
6487
+ "0",
6488
+ "",
6489
+ "1",
6490
+ "2",
6491
+ "3",
6492
+ "4",
6493
+ "5",
6494
+ "6",
6495
+ "7",
6496
+ "D"
6497
+ ]);
6498
+ var name = /* @__PURE__ */ new Map([
6499
+ ["0", "File"],
6500
+ // same as File
6501
+ ["", "OldFile"],
6502
+ ["1", "Link"],
6503
+ ["2", "SymbolicLink"],
6504
+ // Devices and FIFOs aren't fully supported
6505
+ // they are parsed, but skipped when unpacking
6506
+ ["3", "CharacterDevice"],
6507
+ ["4", "BlockDevice"],
6508
+ ["5", "Directory"],
6509
+ ["6", "FIFO"],
6510
+ // same as File
6511
+ ["7", "ContiguousFile"],
6512
+ // pax headers
6513
+ ["g", "GlobalExtendedHeader"],
6514
+ ["x", "ExtendedHeader"],
6515
+ // vendor-specific stuff
6516
+ // skip
6517
+ ["A", "SolarisACL"],
6518
+ // like 5, but with data, which should be skipped
6519
+ ["D", "GNUDumpDir"],
6520
+ // metadata only, skip
6521
+ ["I", "Inode"],
6522
+ // data = link path of next file
6523
+ ["K", "NextFileHasLongLinkpath"],
6524
+ // data = path of next file
6525
+ ["L", "NextFileHasLongPath"],
6526
+ // skip
6527
+ ["M", "ContinuationFile"],
6528
+ // like L
6529
+ ["N", "OldGnuLongPath"],
6530
+ // skip
6531
+ ["S", "SparseFile"],
6532
+ // skip
6533
+ ["V", "TapeVolumeHeader"],
6534
+ // like x
6535
+ ["X", "OldExtendedHeader"]
6536
+ ]);
6537
+ var code = new Map(Array.from(name).map((kv) => [kv[1], kv[0]]));
6538
+
6539
+ // ../../node_modules/.vlt/~npm~tar@7.5.22/node_modules/tar/dist/esm/header.js
6540
+ var notNegative = (n7) => n7 === void 0 || n7 < 0 ? void 0 : n7;
6541
+ var Header = class {
6542
+ cksumValid = false;
6543
+ needPax = false;
6544
+ nullBlock = false;
6545
+ block;
6546
+ path;
6547
+ mode;
6548
+ uid;
6549
+ gid;
6550
+ size;
6551
+ cksum;
6552
+ #type = "Unsupported";
6553
+ linkpath;
6554
+ uname;
6555
+ gname;
6556
+ devmaj = 0;
6557
+ devmin = 0;
6558
+ atime;
6559
+ ctime;
6560
+ mtime;
6561
+ charset;
6562
+ comment;
6563
+ constructor(data, off = 0, ex, gex) {
6564
+ if (Buffer.isBuffer(data)) {
6565
+ this.decode(data, off || 0, ex, gex);
6566
+ } else if (data) {
6567
+ this.#slurp(data);
6568
+ }
6569
+ }
6570
+ decode(buf, off, ex, gex) {
6571
+ if (!off) {
6572
+ off = 0;
6573
+ }
6574
+ if (!buf || !(buf.length >= off + 512)) {
6575
+ throw new Error("need 512 bytes for header");
6576
+ }
6577
+ const t = decString(buf, off + 156, 1);
6578
+ const isNormalFS = normalFsTypes.has(t);
6579
+ const exForFields = isNormalFS ? ex : void 0;
6580
+ const gexForFields = isNormalFS ? gex : void 0;
6581
+ this.path = exForFields?.path ?? decString(buf, off, 100);
6582
+ this.mode = exForFields?.mode ?? gexForFields?.mode ?? decNumber(buf, off + 100, 8);
6583
+ this.uid = exForFields?.uid ?? gexForFields?.uid ?? decNumber(buf, off + 108, 8);
6584
+ this.gid = exForFields?.gid ?? gexForFields?.gid ?? decNumber(buf, off + 116, 8);
6585
+ this.size = notNegative(exForFields?.size ?? gexForFields?.size ?? decNumber(buf, off + 124, 12));
6586
+ this.mtime = exForFields?.mtime ?? gexForFields?.mtime ?? decDate(buf, off + 136, 12);
6587
+ this.cksum = decNumber(buf, off + 148, 12);
6588
+ if (gexForFields)
6589
+ this.#slurp(gexForFields, true);
6590
+ if (exForFields)
6591
+ this.#slurp(exForFields);
6592
+ if (isCode(t)) {
6593
+ this.#type = t || "0";
6594
+ }
6595
+ if (this.#type === "0" && this.path.slice(-1) === "/") {
6596
+ this.#type = "5";
6597
+ }
6598
+ if (this.#type === "5") {
6599
+ this.size = 0;
6600
+ }
6601
+ this.linkpath = decString(buf, off + 157, 100);
6602
+ if (buf.subarray(off + 257, off + 265).toString() === "ustar\x0000") {
6603
+ this.uname = exForFields?.uname ?? gexForFields?.uname ?? decString(buf, off + 265, 32);
6604
+ this.gname = exForFields?.gname ?? gexForFields?.gname ?? decString(buf, off + 297, 32);
6605
+ this.devmaj = exForFields?.devmaj ?? gexForFields?.devmaj ?? decNumber(buf, off + 329, 8) ?? 0;
6606
+ this.devmin = exForFields?.devmin ?? gexForFields?.devmin ?? decNumber(buf, off + 337, 8) ?? 0;
6607
+ if (buf[off + 475] !== 0) {
6608
+ const prefix = decString(buf, off + 345, 155);
6609
+ this.path = prefix + "/" + this.path;
6610
+ } else {
6611
+ const prefix = decString(buf, off + 345, 130);
6612
+ if (prefix) {
6613
+ this.path = prefix + "/" + this.path;
6614
+ }
6615
+ this.atime = ex?.atime ?? gex?.atime ?? decDate(buf, off + 476, 12);
6616
+ this.ctime = ex?.ctime ?? gex?.ctime ?? decDate(buf, off + 488, 12);
6617
+ }
6618
+ }
6619
+ let sum = 8 * 32;
6620
+ for (let i = off; i < off + 148; i++) {
6621
+ sum += buf[i];
6622
+ }
6623
+ for (let i = off + 156; i < off + 512; i++) {
6624
+ sum += buf[i];
6625
+ }
6626
+ this.cksumValid = sum === this.cksum;
6627
+ if (this.cksum === void 0 && sum === 8 * 32) {
6628
+ this.nullBlock = true;
6629
+ }
6630
+ }
6631
+ #slurp(ex, gex = false) {
6632
+ Object.assign(this, Object.fromEntries(Object.entries(ex).filter(([k3, v2]) => {
6633
+ return !(v2 === null || v2 === void 0 || k3 === "size" && Number(v2) < 0 || k3 === "path" && gex || k3 === "linkpath" && gex || k3 === "global");
6634
+ })));
6635
+ }
6636
+ encode(buf, off = 0) {
6637
+ if (!buf) {
6638
+ buf = this.block = Buffer.alloc(512);
6639
+ }
6640
+ if (this.#type === "Unsupported") {
6641
+ this.#type = "0";
6642
+ }
6643
+ if (!(buf.length >= off + 512)) {
6644
+ throw new Error("need 512 bytes for header");
6645
+ }
6646
+ const prefixSize = this.ctime || this.atime ? 130 : 155;
6647
+ const split = splitPrefix(this.path || "", prefixSize);
6648
+ const path = split[0];
6649
+ const prefix = split[1];
6650
+ this.needPax = !!split[2];
6651
+ this.needPax = encString(buf, off, 100, path) || this.needPax;
6652
+ this.needPax = encNumber(buf, off + 100, 8, this.mode) || this.needPax;
6653
+ this.needPax = encNumber(buf, off + 108, 8, this.uid) || this.needPax;
6654
+ this.needPax = encNumber(buf, off + 116, 8, this.gid) || this.needPax;
6655
+ this.needPax = encNumber(buf, off + 124, 12, this.size) || this.needPax;
6656
+ this.needPax = encDate(buf, off + 136, 12, this.mtime) || this.needPax;
6657
+ buf[off + 156] = Number(this.#type.codePointAt(0));
6658
+ this.needPax = encString(buf, off + 157, 100, this.linkpath) || this.needPax;
6659
+ buf.write("ustar\x0000", off + 257, 8);
6660
+ this.needPax = encString(buf, off + 265, 32, this.uname) || this.needPax;
6661
+ this.needPax = encString(buf, off + 297, 32, this.gname) || this.needPax;
6662
+ this.needPax = encNumber(buf, off + 329, 8, this.devmaj) || this.needPax;
6663
+ this.needPax = encNumber(buf, off + 337, 8, this.devmin) || this.needPax;
6664
+ this.needPax = encString(buf, off + 345, prefixSize, prefix) || this.needPax;
6665
+ if (buf[off + 475] !== 0) {
6666
+ this.needPax = encString(buf, off + 345, 155, prefix) || this.needPax;
6667
+ } else {
6668
+ this.needPax = encString(buf, off + 345, 130, prefix) || this.needPax;
6669
+ this.needPax = encDate(buf, off + 476, 12, this.atime) || this.needPax;
6670
+ this.needPax = encDate(buf, off + 488, 12, this.ctime) || this.needPax;
6671
+ }
6672
+ let sum = 8 * 32;
6673
+ for (let i = off; i < off + 148; i++) {
6674
+ sum += buf[i];
6675
+ }
6676
+ for (let i = off + 156; i < off + 512; i++) {
6677
+ sum += buf[i];
6678
+ }
6679
+ this.cksum = sum;
6680
+ encNumber(buf, off + 148, 8, this.cksum);
6681
+ this.cksumValid = true;
6682
+ return this.needPax;
6683
+ }
6684
+ get type() {
6685
+ return this.#type === "Unsupported" ? this.#type : name.get(this.#type);
6686
+ }
6687
+ get typeKey() {
6688
+ return this.#type;
6689
+ }
6690
+ set type(type) {
6691
+ const c = String(code.get(type));
6692
+ if (isCode(c) || c === "Unsupported") {
6693
+ this.#type = c;
6694
+ } else if (isCode(type)) {
6695
+ this.#type = type;
6696
+ } else {
6697
+ throw new TypeError("invalid entry type: " + type);
6698
+ }
6699
+ }
6700
+ };
6701
+ var splitPrefix = (p, prefixSize) => {
6702
+ const pathSize = 100;
6703
+ let pp = p;
6704
+ let prefix = "";
6705
+ let ret = void 0;
6706
+ const root = pathModule.parse(p).root || ".";
6707
+ if (Buffer.byteLength(pp) < pathSize) {
6708
+ ret = [pp, prefix, false];
6709
+ } else {
6710
+ prefix = pathModule.dirname(pp);
6711
+ pp = pathModule.basename(pp);
6712
+ do {
6713
+ if (Buffer.byteLength(pp) <= pathSize && Buffer.byteLength(prefix) <= prefixSize) {
6714
+ ret = [pp, prefix, false];
6715
+ } else if (Buffer.byteLength(pp) > pathSize && Buffer.byteLength(prefix) <= prefixSize) {
6716
+ ret = [pp.slice(0, pathSize - 1), prefix, true];
6717
+ } else {
6718
+ pp = pathModule.join(pathModule.basename(prefix), pp);
6719
+ prefix = pathModule.dirname(prefix);
6720
+ }
6721
+ } while (prefix !== root && ret === void 0);
6722
+ if (!ret) {
6723
+ ret = [p.slice(0, pathSize - 1), "", true];
6724
+ }
6725
+ }
6726
+ return ret;
6727
+ };
6728
+ var decString = (buf, off, size) => buf.subarray(off, off + size).toString("utf8").replace(/\0.*/, "");
6729
+ var decDate = (buf, off, size) => numToDate(decNumber(buf, off, size));
6730
+ var numToDate = (num) => num === void 0 ? void 0 : new Date(num * 1e3);
6731
+ var decNumber = (buf, off, size) => Number(buf[off]) & 128 ? parse6(buf.subarray(off, off + size)) : decSmallNumber(buf, off, size);
6732
+ var nanUndef = (value) => isNaN(value) ? void 0 : value;
6733
+ var decSmallNumber = (buf, off, size) => nanUndef(parseInt(buf.subarray(off, off + size).toString("utf8").replace(/\0.*$/, "").trim(), 8));
6734
+ var MAXNUM = {
6735
+ 12: 8589934591,
6736
+ 8: 2097151
6737
+ };
6738
+ var encNumber = (buf, off, size, num) => num === void 0 ? false : num > MAXNUM[size] || num < 0 ? (encode(num, buf.subarray(off, off + size)), true) : (encSmallNumber(buf, off, size, num), false);
6739
+ var encSmallNumber = (buf, off, size, num) => buf.write(octalString(num, size), off, size, "ascii");
6740
+ var octalString = (num, size) => padOctal(Math.floor(num).toString(8), size);
6741
+ var padOctal = (str, size) => (str.length === size - 1 ? str : new Array(size - str.length - 1).join("0") + str + " ") + "\0";
6742
+ var encDate = (buf, off, size, date) => date === void 0 ? false : encNumber(buf, off, size, date.getTime() / 1e3);
6743
+ var NULLS = new Array(156).join("\0");
6744
+ var encString = (buf, off, size, str) => str === void 0 ? false : (buf.write(str + NULLS, off, size, "utf8"), str.length !== Buffer.byteLength(str) || str.length > size);
6745
+
6746
+ // ../../node_modules/.vlt/~npm~tar@7.5.22/node_modules/tar/dist/esm/pax.js
6747
+ import { basename as basename2 } from "node:path";
6748
+ var Pax = class _Pax {
6749
+ atime;
6750
+ mtime;
6751
+ ctime;
6752
+ charset;
6753
+ comment;
6754
+ gid;
6755
+ uid;
6756
+ gname;
6757
+ uname;
6758
+ linkpath;
6759
+ dev;
6760
+ ino;
6761
+ nlink;
6762
+ path;
6763
+ size;
6764
+ mode;
6765
+ global;
6766
+ constructor(obj, global = false) {
6767
+ this.atime = obj.atime;
6768
+ this.charset = obj.charset;
6769
+ this.comment = obj.comment;
6770
+ this.ctime = obj.ctime;
6771
+ this.dev = obj.dev;
6772
+ this.gid = obj.gid;
6773
+ this.global = global;
6774
+ this.gname = obj.gname;
6775
+ this.ino = obj.ino;
6776
+ this.linkpath = obj.linkpath;
6777
+ this.mtime = obj.mtime;
6778
+ this.nlink = obj.nlink;
6779
+ this.path = obj.path;
6780
+ this.size = obj.size;
6781
+ this.uid = obj.uid;
6782
+ this.uname = obj.uname;
6783
+ }
6784
+ encode() {
6785
+ const body = this.encodeBody();
6786
+ if (body === "") {
6787
+ return Buffer.allocUnsafe(0);
6788
+ }
6789
+ const bodyLen = Buffer.byteLength(body);
6790
+ const bufLen = 512 * Math.ceil(1 + bodyLen / 512);
6791
+ const buf = Buffer.allocUnsafe(bufLen);
6792
+ for (let i = 0; i < 512; i++) {
6793
+ buf[i] = 0;
6794
+ }
6795
+ new Header({
6796
+ // XXX split the path
6797
+ // then the path should be PaxHeader + basename, but less than 99,
6798
+ // prepend with the dirname
6799
+ /* c8 ignore start */
6800
+ path: ("PaxHeader/" + basename2(this.path ?? "")).slice(0, 99),
6801
+ /* c8 ignore stop */
6802
+ mode: this.mode || 420,
6803
+ uid: this.uid,
6804
+ gid: this.gid,
6805
+ size: bodyLen,
6806
+ mtime: this.mtime,
6807
+ type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader",
6808
+ linkpath: "",
6809
+ uname: this.uname || "",
6810
+ gname: this.gname || "",
6811
+ devmaj: 0,
6812
+ devmin: 0,
6813
+ atime: this.atime,
6814
+ ctime: this.ctime
6815
+ }).encode(buf);
6816
+ buf.write(body, 512, bodyLen, "utf8");
6817
+ for (let i = bodyLen + 512; i < buf.length; i++) {
6818
+ buf[i] = 0;
6819
+ }
6820
+ return buf;
6821
+ }
6822
+ encodeBody() {
6823
+ return this.encodeField("path") + this.encodeField("ctime") + this.encodeField("atime") + this.encodeField("dev") + this.encodeField("ino") + this.encodeField("nlink") + this.encodeField("charset") + this.encodeField("comment") + this.encodeField("gid") + this.encodeField("gname") + this.encodeField("linkpath") + this.encodeField("mtime") + this.encodeField("size") + this.encodeField("uid") + this.encodeField("uname");
6824
+ }
6825
+ encodeField(field) {
6826
+ if (this[field] === void 0) {
6827
+ return "";
6828
+ }
6829
+ const r = this[field];
6830
+ const v2 = r instanceof Date ? r.getTime() / 1e3 : r;
6831
+ const s = " " + (field === "dev" || field === "ino" || field === "nlink" ? "SCHILY." : "") + field + "=" + v2 + "\n";
6832
+ const byteLen = Buffer.byteLength(s);
6833
+ let digits = Math.floor(Math.log(byteLen) / Math.log(10)) + 1;
6834
+ if (byteLen + digits >= Math.pow(10, digits)) {
6835
+ digits += 1;
6836
+ }
6837
+ const len = digits + byteLen;
6838
+ return len + s;
6839
+ }
6840
+ static parse(str, ex, g = false) {
6841
+ return new _Pax(merge(parseKV(str), ex), g);
6842
+ }
6843
+ };
6844
+ var merge = (a, b) => b ? Object.assign({}, b, a) : a;
6845
+ var parseKV = (str) => str.replace(/\n$/, "").split("\n").reduce(parseKVLine, /* @__PURE__ */ Object.create(null));
6846
+ var parseKVLine = (set, line) => {
6847
+ const n7 = parseInt(line, 10);
6848
+ if (n7 !== Buffer.byteLength(line) + 1) {
6849
+ return set;
6850
+ }
6851
+ line = line.slice((n7 + " ").length);
6852
+ const kv = line.split("=");
6853
+ const r = kv.shift();
6854
+ if (!r) {
6855
+ return set;
6856
+ }
6857
+ const k3 = r.replace(/^SCHILY\.(dev|ino|nlink)/, "$1");
6858
+ const v2 = kv.join("=").replace(/\0.*/, "");
6859
+ switch (k3) {
6860
+ case "path":
6861
+ case "linkpath":
6862
+ case "type":
6863
+ case "charset":
6864
+ case "comment":
6865
+ case "gname":
6866
+ case "uname":
6867
+ set[k3] = v2;
6868
+ break;
6869
+ case "ctime":
6870
+ case "atime":
6871
+ case "mtime":
6872
+ set[k3] = new Date(Number(v2) * 1e3);
6873
+ break;
6874
+ case "size":
6875
+ const s = +v2;
6876
+ if (s >= 0)
6877
+ set[k3] = s;
6878
+ break;
6879
+ case "gid":
6880
+ case "uid":
6881
+ case "dev":
6882
+ case "ino":
6883
+ case "nlink":
6884
+ case "mode":
6885
+ set[k3] = +v2;
6886
+ break;
6887
+ }
6888
+ return set;
6889
+ };
6890
+
6891
+ // ../../src/tar/src/unpack.ts
6892
+ import { unzip as unzipCB, unzipSync as unzipSyncCB } from "node:zlib";
6893
+
6894
+ // ../../src/tar/src/find-tar-dir.ts
6895
+ var findTarDir = (path, tarDir) => {
6896
+ if (tarDir !== void 0) return tarDir;
6897
+ if (!path) return void 0;
6898
+ const i = path.indexOf("/", path.startsWith("./") ? 2 : 0);
6899
+ if (i === -1) return void 0;
6900
+ const chomp = path.substring(0, i);
6901
+ if (chomp === "." || chomp === ".." || chomp === "" || chomp === "./." || chomp === "./.." || chomp === "./") {
6902
+ return void 0;
6903
+ }
6904
+ return chomp + "/";
6905
+ };
6906
+
6907
+ // ../../src/tar/src/unpack.ts
4549
6908
  var MAX_DECOMPRESSION_RATIO = 1e3;
4550
6909
  var defaultMaxUnpackedBytes = 2 * 1024 * 1024 * 1024;
4551
6910
  var parseMaxUnpackedBytes = (raw) => {
@@ -4555,12 +6914,396 @@ var parseMaxUnpackedBytes = (raw) => {
4555
6914
  var maxUnpackedBytes = parseMaxUnpackedBytes(
4556
6915
  process.env.VLT_TAR_MAX_UNPACKED_BYTES
4557
6916
  );
6917
+ var unzipMax = (len) => Math.min(maxUnpackedBytes, len * MAX_DECOMPRESSION_RATIO);
6918
+ var unzipError = (er, found, max) => er.code === "ERR_BUFFER_TOO_LARGE" ? error("tarball exceeds maximum unpacked size", {
6919
+ found,
6920
+ max,
6921
+ cause: er
6922
+ }) : er;
6923
+ var unzipSync = (input) => {
6924
+ const max = unzipMax(input.length);
6925
+ try {
6926
+ return unzipSyncCB(input, { maxOutputLength: max });
6927
+ } catch (er) {
6928
+ throw unzipError(er, input.length, max);
6929
+ }
6930
+ };
6931
+ var tmp = randomBytes2(6).toString("hex") + ".";
6932
+ var foldKeys = process.platform === "darwin" || process.platform === "win32";
6933
+ var entryKey = (p) => foldKeys ? p.toLowerCase() : p;
6934
+ var parseWriteLanes = (raw) => {
6935
+ const n7 = Number(raw);
6936
+ return Number.isFinite(n7) && n7 >= 1 ? Math.floor(n7) : 64;
6937
+ };
6938
+ var writeLaneLimit = parseWriteLanes(
6939
+ process.env.VLT_TAR_WRITE_LANES
6940
+ );
6941
+ var isClearlySafeRelPath = (sub) => {
6942
+ const len = sub.length;
6943
+ if (len === 0) return true;
6944
+ if (sub.charCodeAt(0) === 47) return false;
6945
+ if (len >= 2 && sub.charCodeAt(1) === 58) {
6946
+ const c = sub.charCodeAt(0);
6947
+ if (c >= 65 && c <= 90 || c >= 97 && c <= 122) {
6948
+ return false;
6949
+ }
6950
+ }
6951
+ let i = 0;
6952
+ while (i < len) {
6953
+ let j3 = i;
6954
+ while (j3 < len && sub.charCodeAt(j3) !== 47) j3++;
6955
+ const slen = j3 - i;
6956
+ if (slen === 1 && sub.charCodeAt(i) === 46) return false;
6957
+ if (slen === 2 && sub.charCodeAt(i) === 46 && sub.charCodeAt(i + 1) === 46) {
6958
+ return false;
6959
+ }
6960
+ i = j3 + 1;
6961
+ }
6962
+ return true;
6963
+ };
6964
+ var checkFs = (h, tarDir, target) => {
6965
+ if (!h.path) return false;
6966
+ if (!tarDir) return false;
6967
+ h.path = h.path.replace(/[\\/]+/g, "/");
6968
+ if (!h.path.startsWith(tarDir)) return false;
6969
+ const sub = h.path.slice(tarDir.length);
6970
+ if (isClearlySafeRelPath(sub)) return true;
6971
+ const rel = relative(target, resolve7(target, sub));
6972
+ if (rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {
6973
+ return false;
6974
+ }
6975
+ return true;
6976
+ };
6977
+ var parseTarball = (buffer, tmp2) => {
6978
+ const isGzip = buffer[0] === 31 && buffer[1] === 139;
6979
+ if (isGzip) {
6980
+ throw error("still gzipped after unzipping", {
6981
+ found: isGzip,
6982
+ wanted: false
6983
+ });
6984
+ }
6985
+ if (buffer.length % 512 !== 0) {
6986
+ throw error("Invalid tarball: length not divisible by 512", {
6987
+ found: buffer.length
6988
+ });
6989
+ }
6990
+ if (buffer.length < 1024) {
6991
+ throw error(
6992
+ "Invalid tarball: not terminated by 1024 null bytes",
6993
+ {
6994
+ found: buffer.length
6995
+ }
6996
+ );
6997
+ }
6998
+ for (let i = buffer.length - 1024; i < buffer.length; i++) {
6999
+ if (buffer[i] !== 0) {
7000
+ throw error(
7001
+ "Invalid tarball: not terminated by 1024 null bytes",
7002
+ { found: buffer.subarray(i, i + 10) }
7003
+ );
7004
+ }
7005
+ }
7006
+ const entries = /* @__PURE__ */ new Map();
7007
+ let tarDir = void 0;
7008
+ let offset = 0;
7009
+ let h;
7010
+ let ex = void 0;
7011
+ let gex = void 0;
7012
+ while (offset < buffer.length && !(h = new Header(buffer, offset, ex, gex)).nullBlock) {
7013
+ offset += 512;
7014
+ ex = void 0;
7015
+ gex = void 0;
7016
+ const size = h.size ?? 0;
7017
+ const body = buffer.subarray(offset, offset + size);
7018
+ if (!h.cksumValid) continue;
7019
+ offset += 512 * Math.ceil(size / 512);
7020
+ switch (h.type) {
7021
+ case "File":
7022
+ if (!tarDir) tarDir = findTarDir(h.path, tarDir);
7023
+ if (!tarDir) continue;
7024
+ if (!checkFs(h, tarDir, tmp2)) continue;
7025
+ {
7026
+ const dest = resolve7(tmp2, h.path.substring(tarDir.length));
7027
+ const key = entryKey(dest);
7028
+ if (entries.get(key)?.dir === true) {
7029
+ throw error("file/directory collision in tarball", {
7030
+ path: dest
7031
+ });
7032
+ }
7033
+ entries.set(key, {
7034
+ path: dest,
7035
+ body,
7036
+ executable: 1 === ((h.mode ?? 1638) & 1),
7037
+ dir: false
7038
+ });
7039
+ }
7040
+ break;
7041
+ case "Directory":
7042
+ if (!tarDir) tarDir = findTarDir(h.path, tarDir);
7043
+ if (!tarDir) continue;
7044
+ if (!checkFs(h, tarDir, tmp2)) continue;
7045
+ {
7046
+ const dest = resolve7(tmp2, h.path.substring(tarDir.length));
7047
+ const key = entryKey(dest);
7048
+ if (entries.get(key)?.dir === false) {
7049
+ throw error("file/directory collision in tarball", {
7050
+ path: dest
7051
+ });
7052
+ }
7053
+ entries.set(key, {
7054
+ path: dest,
7055
+ dir: true
7056
+ });
7057
+ }
7058
+ break;
7059
+ case "GlobalExtendedHeader":
7060
+ gex = Pax.parse(body.toString(), gex, true);
7061
+ break;
7062
+ case "ExtendedHeader":
7063
+ case "OldExtendedHeader":
7064
+ ex = Pax.parse(body.toString(), ex, false);
7065
+ break;
7066
+ case "NextFileHasLongPath":
7067
+ case "OldGnuLongPath":
7068
+ ex ??= /* @__PURE__ */ Object.create(null);
7069
+ ex.path = body.toString().replace(/\0.*/, "");
7070
+ break;
7071
+ }
7072
+ }
7073
+ const dirs = /* @__PURE__ */ new Set();
7074
+ const files = [];
7075
+ for (const e of entries.values()) {
7076
+ if (e.dir) dirs.add(e.path);
7077
+ else {
7078
+ dirs.add(dirname2(e.path));
7079
+ files.push(e);
7080
+ }
7081
+ }
7082
+ return { dirs, files };
7083
+ };
7084
+ var storeLayout = (tarData, dir) => {
7085
+ const isGzip = tarData[0] === 31 && tarData[1] === 139;
7086
+ const { dirs, files } = parseTarball(
7087
+ isGzip ? unzipSync(tarData) : tarData,
7088
+ dir
7089
+ );
7090
+ const rel = (p) => relative(dir, p).replace(/\\/g, "/");
7091
+ const list = files.map((f) => [rel(f.path), f]);
7092
+ const pj = list.find(([p]) => p === "package.json")?.[1];
7093
+ if (!pj) throw error("no package.json in tarball", { path: dir });
7094
+ const manifest = storeIndexManifest(
7095
+ pj.body,
7096
+ list.some(([p]) => p === "binding.gyp")
7097
+ );
7098
+ const bins = new Set(
7099
+ Object.values(manifest.bins ?? {}).map(entryKey)
7100
+ );
7101
+ const indexFiles = [];
7102
+ const binFiles = [];
7103
+ for (const [p, f] of list) {
7104
+ if (bins.has(entryKey(p))) {
7105
+ f.executable = true;
7106
+ binFiles.push(f.path);
7107
+ }
7108
+ indexFiles.push([p, f.body.length, f.executable ? 1 : 0]);
7109
+ }
7110
+ const allDirs = /* @__PURE__ */ new Set();
7111
+ for (const d3 of dirs) {
7112
+ for (let p = rel(d3); p && !allDirs.has(p); ) {
7113
+ allDirs.add(p);
7114
+ p = p.slice(0, Math.max(0, p.lastIndexOf("/")));
7115
+ }
7116
+ }
7117
+ const indexDirs = [...allDirs].sort().sort((a, b) => a.length - b.length);
7118
+ return {
7119
+ index: {
7120
+ v: 1,
7121
+ files: indexFiles.sort((a, b) => a[0] < b[0] ? -1 : 1),
7122
+ dirs: indexDirs,
7123
+ ...manifest
7124
+ },
7125
+ files,
7126
+ binFiles
7127
+ };
7128
+ };
7129
+ var unpackToStoreSync = (tarData, dir) => {
7130
+ const { index, files, binFiles } = storeLayout(tarData, dir);
7131
+ mkdirSync2(dirname2(dir), { recursive: true });
7132
+ mkdirSync2(dir, { mode: 511 });
7133
+ let succeeded = false;
7134
+ try {
7135
+ for (const d3 of index.dirs) {
7136
+ mkdirSync2(join(dir, d3), { recursive: true, mode: 511 });
7137
+ }
7138
+ for (const f of files) {
7139
+ writeFileSync(f.path, f.body, {
7140
+ mode: f.executable ? 511 : 438
7141
+ });
7142
+ }
7143
+ let binMode = 0;
7144
+ for (const p of binFiles) {
7145
+ binMode ||= statSync2(p).mode & 511 | 73;
7146
+ chmodSync2(p, binMode);
7147
+ }
7148
+ succeeded = true;
7149
+ } finally {
7150
+ if (!succeeded) rimrafSync(dir);
7151
+ }
7152
+ return { index };
7153
+ };
7154
+
7155
+ // ../../src/cache-unzip/src/explode.ts
7156
+ import {
7157
+ lstatSync as lstatSync3,
7158
+ readdirSync as readdirSync2,
7159
+ renameSync as renameSync3,
7160
+ rmSync as rmSync2,
7161
+ writeFileSync as writeFileSync2
7162
+ } from "node:fs";
7163
+ import { join as join2 } from "node:path";
7164
+ import { performance as performance2 } from "node:perf_hooks";
7165
+ import { debuglog as debuglog3 } from "node:util";
7166
+ var debug3 = debuglog3("vlt");
7167
+ var linkers = /* @__PURE__ */ new Set(["auto", "hardlink", "copy"]);
7168
+ var storeEnabled = () => linkers.has(process.env.VLT_STORE_LINKER ?? "");
7169
+ var STALE_MS = 60 * 60 * 1e3;
7170
+ var parseConcurrency = (raw) => {
7171
+ const n7 = Number(raw);
7172
+ return Number.isFinite(n7) && n7 >= 1 ? Math.floor(n7) : 1;
7173
+ };
7174
+ var rm2 = (path) => rmSync2(path, { recursive: true, force: true });
7175
+ var entryIntegrity = (buf) => {
7176
+ const headSize = buf.readUInt32BE(0);
7177
+ let key;
7178
+ for (let i = 7, size = 4; i + 4 <= headSize; i += size) {
7179
+ size = Math.max(4, buf.readUInt32BE(i));
7180
+ const h = buf.toString("utf8", i + 4, i + size);
7181
+ if (key === void 0) key = h.toLowerCase();
7182
+ else if (key === "integrity") return h;
7183
+ else key = void 0;
7184
+ }
7185
+ };
7186
+ var sweep = (tmp2) => {
7187
+ let names;
7188
+ try {
7189
+ names = readdirSync2(tmp2);
7190
+ } catch {
7191
+ return;
7192
+ }
7193
+ const now = Date.now();
7194
+ for (const name2 of names) {
7195
+ const p = join2(tmp2, name2);
7196
+ try {
7197
+ if (now - lstatSync3(p).mtimeMs > STALE_MS) rm2(p);
7198
+ } catch {
7199
+ }
7200
+ }
7201
+ };
7202
+ var seq = 0;
7203
+ var explodeEntry = (store, buf) => {
7204
+ const hex = integrityHex(entryIntegrity(buf));
7205
+ if (!hex) return "ignored";
7206
+ const entry = join2(store, hex);
7207
+ if (lstatSync3(entry, { throwIfNoEntry: false })) {
7208
+ if (readStoreIndex(entry)) return "skipped";
7209
+ rm2(entry);
7210
+ }
7211
+ const n7 = `${process.pid}.${seq++}`;
7212
+ const tmp2 = join2(store, ".tmp", `${hex}.${n7}`);
7213
+ const sideTmp = join2(store, ".tmp", `${hex}.json.${n7}`);
7214
+ const { index } = unpackToStoreSync(
7215
+ buf.subarray(buf.readUInt32BE(0)),
7216
+ tmp2
7217
+ );
7218
+ try {
7219
+ writeFileSync2(sideTmp, JSON.stringify(index));
7220
+ renameSync3(sideTmp, storeIndexPath(entry));
7221
+ renameSync3(tmp2, entry);
7222
+ } catch (er) {
7223
+ rm2(tmp2);
7224
+ rm2(sideTmp);
7225
+ if (lstatSync3(entry, { throwIfNoEntry: false })) return "skipped";
7226
+ throw er;
7227
+ }
7228
+ let bytes = 0;
7229
+ for (const [, size] of index.files) bytes += size;
7230
+ return bytes;
7231
+ };
7232
+ var explode = async (cache, store, keys, integrities) => {
7233
+ if (!storeEnabled()) return;
7234
+ const start = performance2.now();
7235
+ const s = {
7236
+ exploded: /* @__PURE__ */ new Set(),
7237
+ written: 0,
7238
+ skipped: 0,
7239
+ ignored: 0,
7240
+ failed: 0,
7241
+ bytes: 0,
7242
+ ms: 0
7243
+ };
7244
+ sweep(join2(store, ".tmp"));
7245
+ let next = 0;
7246
+ const lane = async () => {
7247
+ for (; ; ) {
7248
+ const key = keys[next++];
7249
+ if (key === void 0) return;
7250
+ const buf = await cache.fetch(key, {
7251
+ context: { integrity: integrities?.get(key) }
7252
+ });
7253
+ cache.delete(key);
7254
+ if (!buf) {
7255
+ s.ignored++;
7256
+ continue;
7257
+ }
7258
+ try {
7259
+ const res = explodeEntry(store, buf);
7260
+ if (typeof res === "number") {
7261
+ s.exploded.add(key);
7262
+ s.written++;
7263
+ s.bytes += res;
7264
+ } else s[res]++;
7265
+ } catch (er) {
7266
+ s.failed++;
7267
+ debug3("global store: explode failed", key, er);
7268
+ }
7269
+ }
7270
+ };
7271
+ const lanes = Math.min(
7272
+ parseConcurrency(process.env.VLT_CACHE_EXPLODE_CONCURRENCY),
7273
+ keys.length
7274
+ );
7275
+ await Promise.all(Array.from({ length: lanes }, lane));
7276
+ s.ms = Math.round(performance2.now() - start);
7277
+ debug3(
7278
+ "global store: explode written=%d skipped=%d ignored=%d failed=%d bytes=%d ms=%d",
7279
+ s.written,
7280
+ s.skipped,
7281
+ s.ignored,
7282
+ s.failed,
7283
+ s.bytes,
7284
+ s.ms
7285
+ );
7286
+ return s;
7287
+ };
7288
+
7289
+ // ../../src/cache-unzip/src/unzip.ts
7290
+ var __CODE_SPLIT_SCRIPT_NAME = import.meta.filename;
7291
+ var debug4 = debuglog4("vlt");
7292
+ var MAX_DECOMPRESSION_RATIO2 = 1e3;
7293
+ var defaultMaxUnpackedBytes2 = 2 * 1024 * 1024 * 1024;
7294
+ var parseMaxUnpackedBytes2 = (raw) => {
7295
+ const n7 = Number(raw);
7296
+ return Number.isFinite(n7) && n7 >= 1 ? Math.floor(n7) : defaultMaxUnpackedBytes2;
7297
+ };
7298
+ var maxUnpackedBytes2 = parseMaxUnpackedBytes2(
7299
+ process.env.VLT_TAR_MAX_UNPACKED_BYTES
7300
+ );
4558
7301
  var isMain = (path) => path === __CODE_SPLIT_SCRIPT_NAME || path === pathToFileURL(__CODE_SPLIT_SCRIPT_NAME).toString();
4559
- var main = async (path, input = process.stdin) => {
7302
+ var main = async (path, input = process.stdin, store) => {
4560
7303
  if (!path) {
4561
7304
  return false;
4562
7305
  }
4563
- const keys = await new Promise((res) => {
7306
+ const items = await new Promise((res) => {
4564
7307
  const chunks = [];
4565
7308
  let chunkLen = 0;
4566
7309
  input.on("data", (chunk) => {
@@ -4573,142 +7316,169 @@ var main = async (path, input = process.stdin) => {
4573
7316
  );
4574
7317
  });
4575
7318
  });
7319
+ const integrities = /* @__PURE__ */ new Map();
7320
+ const keys = items.map((item) => {
7321
+ const [key, integrity] = item.split(" ");
7322
+ if (integrity) integrities.set(key, integrity);
7323
+ return key;
7324
+ });
4576
7325
  if (!keys.length) {
4577
- return false;
7326
+ return true;
4578
7327
  }
4579
7328
  const cache = new Cache({ path });
4580
- const readSize = (buf, offset) => {
4581
- const a = buf[offset];
4582
- const b = buf[offset + 1];
4583
- const c = buf[offset + 2];
4584
- const d3 = buf[offset + 3];
4585
- if (a === void 0 || b === void 0 || c === void 0 || d3 === void 0) {
4586
- throw error("Invalid buffer, not long enough to readSize", {
4587
- found: buf,
4588
- offset
4589
- });
7329
+ const mode = process.env.VLT_CACHE_UNZIP;
7330
+ const unzip = async (ks2) => mode === "0" ? [] : Promise.allSettled(
7331
+ ks2.map((k3) => unzipEntry(cache, k3, integrities.get(k3)))
7332
+ );
7333
+ const all = mode === "1" ? await unzip(keys) : void 0;
7334
+ const s = store ? await explode(cache, store, keys, integrities) : void 0;
7335
+ const results = all ?? await unzip(keys.filter((k3) => !s?.exploded.has(k3)));
7336
+ await cache.promise();
7337
+ let unzipped = 0;
7338
+ let rejected;
7339
+ for (const r of results) {
7340
+ if (r.status === "rejected") rejected ??= r;
7341
+ else if (r.value) unzipped++;
7342
+ }
7343
+ debug4(
7344
+ "cache-unzip: keys=%d exploded=%d unzipped=%d",
7345
+ keys.length,
7346
+ s?.written ?? 0,
7347
+ unzipped
7348
+ );
7349
+ if (rejected) throw rejected.reason;
7350
+ return !s?.failed;
7351
+ };
7352
+ var readSize = (buf, offset) => {
7353
+ const a = buf[offset];
7354
+ const b = buf[offset + 1];
7355
+ const c = buf[offset + 2];
7356
+ const d3 = buf[offset + 3];
7357
+ if (a === void 0 || b === void 0 || c === void 0 || d3 === void 0) {
7358
+ throw error("Invalid buffer, not long enough to readSize", {
7359
+ found: buf,
7360
+ offset
7361
+ });
7362
+ }
7363
+ return a << 24 | b << 16 | c << 8 | d3;
7364
+ };
7365
+ var unzipEntry = async (cache, key, under) => {
7366
+ const buffer = await cache.fetch(key, {
7367
+ context: { integrity: under }
7368
+ });
7369
+ if (!buffer || buffer.length < 4) return false;
7370
+ const headSizeOriginal = readSize(buffer, 0);
7371
+ const body = buffer.subarray(headSizeOriginal);
7372
+ if (body[0] !== 31 || body[1] !== 139) return false;
7373
+ let unz;
7374
+ try {
7375
+ unz = gunzipSync(body, {
7376
+ maxOutputLength: Math.min(
7377
+ maxUnpackedBytes2,
7378
+ body.length * MAX_DECOMPRESSION_RATIO2
7379
+ )
7380
+ });
7381
+ } catch (er) {
7382
+ if (er.code !== "ERR_BUFFER_TOO_LARGE") {
7383
+ throw er;
4590
7384
  }
4591
- return a << 24 | b << 16 | c << 8 | d3;
4592
- };
4593
- const results = await Promise.all(
4594
- keys.map(async (key) => {
4595
- const buffer = await cache.fetch(key);
4596
- if (!buffer || buffer.length < 4) return null;
4597
- const headSizeOriginal = readSize(buffer, 0);
4598
- const body = buffer.subarray(headSizeOriginal);
4599
- if (body[0] === 31 && body[1] === 139) {
4600
- let unz;
4601
- try {
4602
- unz = gunzipSync(body, {
4603
- maxOutputLength: Math.min(
4604
- maxUnpackedBytes,
4605
- body.length * MAX_DECOMPRESSION_RATIO
4606
- )
4607
- });
4608
- } catch (er) {
4609
- if (er.code !== "ERR_BUFFER_TOO_LARGE") {
4610
- throw er;
4611
- }
4612
- return null;
4613
- }
4614
- const headersBuffer = buffer.subarray(7, headSizeOriginal);
4615
- const headers = [];
4616
- let i = 0;
4617
- let sawEncoding = false;
4618
- let isEncoding = false;
4619
- let isContentLength = false;
4620
- let isIntegrity = false;
4621
- let integrity = void 0;
4622
- while (i < headersBuffer.length - 4) {
4623
- const size = readSize(headersBuffer, i);
4624
- const h = headersBuffer.subarray(i + 4, i + size);
4625
- if (isEncoding) {
4626
- isEncoding = false;
4627
- headers.push(Buffer.from("identity"));
4628
- } else if (isContentLength) {
4629
- isContentLength = false;
4630
- i += size;
4631
- continue;
4632
- } else if (isIntegrity) {
4633
- isIntegrity = false;
4634
- integrity = h.toString();
4635
- headers.push(h);
4636
- } else {
4637
- if (headers.length % 2 === 0) {
4638
- if (h.toString().toLowerCase() === "content-length") {
4639
- isContentLength = true;
4640
- i += size;
4641
- continue;
4642
- }
4643
- if (!sawEncoding && h.toString().toLowerCase() === "content-encoding") {
4644
- sawEncoding = true;
4645
- isEncoding = true;
4646
- } else if (!integrity && h.toString().toLowerCase() === "integrity") {
4647
- isIntegrity = true;
4648
- }
4649
- }
4650
- headers.push(h);
4651
- }
7385
+ return false;
7386
+ }
7387
+ const headersBuffer = buffer.subarray(7, headSizeOriginal);
7388
+ const headers = [];
7389
+ let i = 0;
7390
+ let sawEncoding = false;
7391
+ let isEncoding = false;
7392
+ let isContentLength = false;
7393
+ let isIntegrity2 = false;
7394
+ let integrity = void 0;
7395
+ while (i < headersBuffer.length - 4) {
7396
+ const size = readSize(headersBuffer, i);
7397
+ const h = headersBuffer.subarray(i + 4, i + size);
7398
+ if (isEncoding) {
7399
+ isEncoding = false;
7400
+ headers.push(Buffer.from("identity"));
7401
+ } else if (isContentLength) {
7402
+ isContentLength = false;
7403
+ i += size;
7404
+ continue;
7405
+ } else if (isIntegrity2) {
7406
+ isIntegrity2 = false;
7407
+ integrity = h.toString();
7408
+ headers.push(h);
7409
+ } else {
7410
+ if (headers.length % 2 === 0) {
7411
+ if (h.toString().toLowerCase() === "content-length") {
7412
+ isContentLength = true;
4652
7413
  i += size;
7414
+ continue;
4653
7415
  }
4654
- if (!sawEncoding) {
4655
- headers.push(
4656
- Buffer.from("content-encoding"),
4657
- Buffer.from("identity")
4658
- );
4659
- }
4660
- headers.push(
4661
- Buffer.from("content-length"),
4662
- Buffer.from(String(unz.byteLength))
4663
- );
4664
- const sb = buffer.subarray(4, 7);
4665
- const chunks = [sb];
4666
- let headLength = sb.byteLength + 4;
4667
- for (const h of headers) {
4668
- const hlBuf2 = Buffer.allocUnsafe(4);
4669
- const hl = h.byteLength + 4;
4670
- headLength += hl;
4671
- hlBuf2.set(
4672
- [
4673
- hl >> 24 & 255,
4674
- hl >> 16 & 255,
4675
- hl >> 8 & 255,
4676
- hl & 255
4677
- ],
4678
- 0
4679
- );
4680
- chunks.push(hlBuf2, h);
7416
+ if (!sawEncoding && h.toString().toLowerCase() === "content-encoding") {
7417
+ sawEncoding = true;
7418
+ isEncoding = true;
7419
+ } else if (!integrity && h.toString().toLowerCase() === "integrity") {
7420
+ isIntegrity2 = true;
4681
7421
  }
4682
- const hlBuf = Buffer.allocUnsafe(4);
4683
- hlBuf.set(
4684
- [
4685
- headLength >> 24 & 255,
4686
- headLength >> 16 & 255,
4687
- headLength >> 8 & 255,
4688
- headLength & 255
4689
- ],
4690
- 0
4691
- );
4692
- chunks.unshift(hlBuf);
4693
- chunks.push(unz);
4694
- cache.set(
4695
- key,
4696
- Buffer.concat(chunks, headLength + unz.length),
4697
- {
4698
- integrity
4699
- }
4700
- );
4701
7422
  }
4702
- return true;
4703
- })
7423
+ headers.push(h);
7424
+ }
7425
+ i += size;
7426
+ }
7427
+ if (!sawEncoding) {
7428
+ headers.push(
7429
+ Buffer.from("content-encoding"),
7430
+ Buffer.from("identity")
7431
+ );
7432
+ }
7433
+ headers.push(
7434
+ Buffer.from("content-length"),
7435
+ Buffer.from(String(unz.byteLength))
4704
7436
  );
4705
- await cache.promise();
4706
- return results.some(Boolean);
7437
+ const sb = buffer.subarray(4, 7);
7438
+ const chunks = [sb];
7439
+ let headLength = sb.byteLength + 4;
7440
+ for (const h of headers) {
7441
+ const hlBuf2 = Buffer.allocUnsafe(4);
7442
+ const hl = h.byteLength + 4;
7443
+ headLength += hl;
7444
+ hlBuf2.set(
7445
+ [
7446
+ hl >> 24 & 255,
7447
+ hl >> 16 & 255,
7448
+ hl >> 8 & 255,
7449
+ hl & 255
7450
+ ],
7451
+ 0
7452
+ );
7453
+ chunks.push(hlBuf2, h);
7454
+ }
7455
+ const hlBuf = Buffer.allocUnsafe(4);
7456
+ hlBuf.set(
7457
+ [
7458
+ headLength >> 24 & 255,
7459
+ headLength >> 16 & 255,
7460
+ headLength >> 8 & 255,
7461
+ headLength & 255
7462
+ ],
7463
+ 0
7464
+ );
7465
+ chunks.unshift(hlBuf);
7466
+ chunks.push(unz);
7467
+ cache.set(key, Buffer.concat(chunks, headLength + unz.length), {
7468
+ integrity
7469
+ });
7470
+ return true;
4707
7471
  };
4708
7472
  if (isMain(process.argv[1])) {
4709
7473
  process.title = "vlt-cache-unzip";
4710
- const path = process.argv.length === 2 ? void 0 : process.argv.at(-1);
4711
- const res = await main(path, process.stdin);
7474
+ const [, , path, store] = process.argv;
7475
+ if (store && storeEnabled()) {
7476
+ try {
7477
+ setPriority(19);
7478
+ } catch {
7479
+ }
7480
+ }
7481
+ const res = await main(path, process.stdin, store);
4712
7482
  if (!res) {
4713
7483
  process.exit(1);
4714
7484
  }