@vltpkg/cli-js 1.0.4 → 1.0.5

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 (75) hide show
  1. package/{access-RYNHM3DJ.js → access-AFFG4IBZ.js} +4 -4
  2. package/{bugs-ZHOC4U52.js → bugs-MCLLEJJP.js} +8 -8
  3. package/{build-HTM6Z7OQ.js → build-TKUT6V2P.js} +6 -6
  4. package/{cache-74GIE5TO.js → cache-O464JQI4.js} +7 -7
  5. package/cache-unzip-src-unzip.js +3 -1
  6. package/{chunk-AIQ7Z62O.js → chunk-34VLICEH.js} +3 -3
  7. package/{chunk-OR5LSCSK.js → chunk-3NGV7EC6.js} +26 -15
  8. package/{chunk-A2EWSQPE.js → chunk-3NWTVANS.js} +4 -4
  9. package/{chunk-OCJDISSI.js → chunk-3OPNZI6G.js} +2 -2
  10. package/{chunk-JOEHZSS7.js → chunk-4LBWNGU6.js} +2 -2
  11. package/{chunk-T4GYDWUJ.js → chunk-5JFRXIK2.js} +17 -2
  12. package/{chunk-E737X73P.js → chunk-AL42Z2D3.js} +12 -5
  13. package/{chunk-WNDUKE42.js → chunk-ED2DDTQT.js} +2 -2
  14. package/{chunk-AMDP7LYB.js → chunk-FBHWUWBW.js} +2 -2
  15. package/{chunk-VB3IWNHX.js → chunk-GDJ7JT2R.js} +1 -1
  16. package/{chunk-GXWZ5T4W.js → chunk-JFO2EQA5.js} +1 -1
  17. package/{chunk-RB6SUM6U.js → chunk-K55EFH4U.js} +5 -5
  18. package/{chunk-YRKCPGWZ.js → chunk-QWTGTFHN.js} +2 -2
  19. package/{chunk-2CLRMD5A.js → chunk-R32BJAKT.js} +157 -110
  20. package/{chunk-PDLEQEZ3.js → chunk-SVBEF5PK.js} +3 -3
  21. package/{chunk-R55OHZ2R.js → chunk-UCYLZSZ7.js} +5 -5
  22. package/{chunk-IITIX4ID.js → chunk-VFBCWAOC.js} +37 -1
  23. package/{chunk-XU5SMHXP.js → chunk-XKVU23NC.js} +1 -1
  24. package/{chunk-MZIM7X37.js → chunk-YRLO236S.js} +3 -3
  25. package/{chunk-AK3RSABL.js → chunk-YZPRRP7W.js} +5 -5
  26. package/chunk-ZBNPQDQ7.js +75 -0
  27. package/{ci-XT7IAX2Y.js → ci-GPZGE4SU.js} +9 -7
  28. package/cli-package.json +1 -1
  29. package/{config-B2LF4SJ7.js → config-WDCFW5X7.js} +7 -7
  30. package/{config-SRLA2XPZ.js → config-YEEKT7WH.js} +6 -6
  31. package/{create-VKNML6FC.js → create-TVVUUIUZ.js} +13 -13
  32. package/{deprecate-IM4HEDIP.js → deprecate-AH4LOHMI.js} +7 -7
  33. package/{dist-tag-EKVJAQ66.js → dist-tag-4R6YHSZ7.js} +4 -4
  34. package/{docs-4DHMAMOU.js → docs-7MHXAHGG.js} +8 -8
  35. package/{exec-7C74Z3WB.js → exec-FRQOPS5C.js} +15 -13
  36. package/{exec-cache-QTUCQWSA.js → exec-cache-VYVXFKA2.js} +11 -11
  37. package/{exec-local-ZCNI2JHK.js → exec-local-MXYOC2AY.js} +11 -11
  38. package/{help-IKRPBT2R.js → help-J5CYJ7BO.js} +1 -1
  39. package/{init-PCQ4YK7R.js → init-7D5MFAP5.js} +7 -7
  40. package/{install-OAQ4K3XX.js → install-T34U5HPS.js} +10 -8
  41. package/{list-WYBKBCZU.js → list-C2LX6EIY.js} +11 -11
  42. package/{login-TTRCQ43Z.js → login-6JP7WTRM.js} +4 -4
  43. package/{logout-3J77F4OO.js → logout-JYOBUHP3.js} +4 -4
  44. package/{pack-ZLFGYGVZ.js → pack-ON6BK2AI.js} +8 -8
  45. package/package.json +1 -1
  46. package/{ping-IRLV5C4D.js → ping-GUNQJ53P.js} +4 -4
  47. package/{pkg-EKOQ4XKM.js → pkg-GIH3WMUK.js} +8 -8
  48. package/{profile-7UBKGJBP.js → profile-IEIZFNOD.js} +4 -4
  49. package/{publish-2ODYT4R2.js → publish-VTRA3MIS.js} +10 -10
  50. package/{query-ADSAKEK4.js → query-KEXYDRHP.js} +11 -11
  51. package/{registry-CZPFR3OF.js → registry-43SSGAPE.js} +3 -3
  52. package/registry-client-package.json +1 -1
  53. package/registry-client-src-revalidate.js +432 -382
  54. package/{repo-3THXRT64.js → repo-LI5FOP3N.js} +8 -8
  55. package/{reporter-6BFJCFVZ.js → reporter-Y7RMSVN4.js} +1 -1
  56. package/{run-2QLSVP6M.js → run-LEWQVDWO.js} +11 -11
  57. package/{run-exec-VYD2Q4BD.js → run-exec-CLCZ47NU.js} +11 -11
  58. package/security-archive-src-update-expired.js +37 -1
  59. package/{setup-TDX5NXUN.js → setup-MPG4UQPT.js} +7 -7
  60. package/{src-AVMBIRBC.js → src-ARXB4NH5.js} +11 -11
  61. package/{src-SWL4UPPI.js → src-B4IYFLHG.js} +4 -2
  62. package/{src-X66SVM5T.js → src-U4EBFPPT.js} +8 -5
  63. package/{token-3RDRZ4AO.js → token-UD4AF4I7.js} +4 -4
  64. package/{uninstall-CNAFZTLA.js → uninstall-MSKFXGAO.js} +10 -8
  65. package/{unpublish-7YHQQYZG.js → unpublish-2RNLXZWP.js} +4 -4
  66. package/{update-3W27EZWN.js → update-3HXQLP34.js} +9 -7
  67. package/{version-K37LT6GZ.js → version-RBLKW6BQ.js} +7 -7
  68. package/{view-ZVAYKUL2.js → view-3XTRGRGJ.js} +6 -6
  69. package/vlr.js +1 -1
  70. package/vlrx.js +1 -1
  71. package/vlt.js +1 -1
  72. package/vlx.js +1 -1
  73. package/vlxl.js +1 -1
  74. package/{whoami-IOUW56D6.js → whoami-WSXDPFSQ.js} +4 -4
  75. package/chunk-SKQHW56B.js +0 -75
@@ -29,7 +29,7 @@ import {
29
29
  } from "./chunk-BJBFEQRR.js";
30
30
  import {
31
31
  asError
32
- } from "./chunk-IITIX4ID.js";
32
+ } from "./chunk-VFBCWAOC.js";
33
33
  import {
34
34
  error
35
35
  } from "./chunk-WZWDS3W4.js";
@@ -15797,18 +15797,18 @@ var require_cache = __commonJS({
15797
15797
  }
15798
15798
  }
15799
15799
  }
15800
- function makeDeduplicationKey(cacheKey, excludeHeaders) {
15800
+ function makeDeduplicationKey(cacheKey2, excludeHeaders) {
15801
15801
  const headers = {};
15802
- if (cacheKey.headers) {
15803
- const sortedHeaders = Object.keys(cacheKey.headers).sort();
15802
+ if (cacheKey2.headers) {
15803
+ const sortedHeaders = Object.keys(cacheKey2.headers).sort();
15804
15804
  for (const header of sortedHeaders) {
15805
15805
  if (excludeHeaders?.has(header.toLowerCase())) {
15806
15806
  continue;
15807
15807
  }
15808
- headers[header] = cacheKey.headers[header];
15808
+ headers[header] = cacheKey2.headers[header];
15809
15809
  }
15810
15810
  }
15811
- return JSON.stringify([cacheKey.origin, cacheKey.method, cacheKey.path, headers]);
15811
+ return JSON.stringify([cacheKey2.origin, cacheKey2.method, cacheKey2.path, headers]);
15812
15812
  }
15813
15813
  module3.exports = {
15814
15814
  makeCacheKey,
@@ -16382,7 +16382,7 @@ var require_cache_handler = __commonJS({
16382
16382
  }
16383
16383
  }
16384
16384
  }
16385
- function getSameOriginPath(cacheKey, location) {
16385
+ function getSameOriginPath(cacheKey2, location) {
16386
16386
  if (typeof location !== "string") {
16387
16387
  return void 0;
16388
16388
  }
@@ -16390,8 +16390,8 @@ var require_cache_handler = __commonJS({
16390
16390
  let requestUrl;
16391
16391
  let locationUrl;
16392
16392
  try {
16393
- originUrl = new URL(cacheKey.origin);
16394
- requestUrl = new URL(cacheKey.path, originUrl);
16393
+ originUrl = new URL(cacheKey2.origin);
16394
+ requestUrl = new URL(cacheKey2.path, originUrl);
16395
16395
  locationUrl = new URL(location, requestUrl);
16396
16396
  } catch {
16397
16397
  return void 0;
@@ -16401,38 +16401,38 @@ var require_cache_handler = __commonJS({
16401
16401
  }
16402
16402
  return locationUrl.pathname + locationUrl.search;
16403
16403
  }
16404
- function deleteCachedUri(store, cacheKey, path) {
16404
+ function deleteCachedUri(store, cacheKey2, path) {
16405
16405
  deleteCachedValue(store, {
16406
- ...cacheKey,
16406
+ ...cacheKey2,
16407
16407
  path
16408
16408
  });
16409
16409
  for (let i = 0; i < util.safeHTTPMethods.length; i++) {
16410
16410
  const method = util.safeHTTPMethods[i];
16411
- if (method !== cacheKey.method) {
16411
+ if (method !== cacheKey2.method) {
16412
16412
  deleteCachedValue(store, {
16413
- ...cacheKey,
16413
+ ...cacheKey2,
16414
16414
  method,
16415
16415
  path
16416
16416
  });
16417
16417
  }
16418
16418
  }
16419
16419
  }
16420
- function deleteLocationTargets(store, cacheKey, headerValue) {
16420
+ function deleteLocationTargets(store, cacheKey2, headerValue) {
16421
16421
  if (headerValue === void 0) {
16422
16422
  return;
16423
16423
  }
16424
16424
  const values = Array.isArray(headerValue) ? headerValue : [headerValue];
16425
16425
  for (let i = 0; i < values.length; i++) {
16426
- const path = getSameOriginPath(cacheKey, values[i]);
16426
+ const path = getSameOriginPath(cacheKey2, values[i]);
16427
16427
  if (path !== void 0) {
16428
- deleteCachedUri(store, cacheKey, path);
16428
+ deleteCachedUri(store, cacheKey2, path);
16429
16429
  }
16430
16430
  }
16431
16431
  }
16432
- function invalidateUnsafeRequest(store, cacheKey, resHeaders) {
16433
- deleteCachedUri(store, cacheKey, cacheKey.path);
16434
- deleteLocationTargets(store, cacheKey, resHeaders.location);
16435
- deleteLocationTargets(store, cacheKey, resHeaders["content-location"]);
16432
+ function invalidateUnsafeRequest(store, cacheKey2, resHeaders) {
16433
+ deleteCachedUri(store, cacheKey2, cacheKey2.path);
16434
+ deleteLocationTargets(store, cacheKey2, resHeaders.location);
16435
+ deleteLocationTargets(store, cacheKey2, resHeaders["content-location"]);
16436
16436
  }
16437
16437
  var CacheHandler = class {
16438
16438
  /**
@@ -16464,11 +16464,11 @@ var require_cache_handler = __commonJS({
16464
16464
  * @param {import('../../types/cache-interceptor.d.ts').default.CacheKey} cacheKey
16465
16465
  * @param {import('../../types/dispatcher.d.ts').default.DispatchHandler} handler
16466
16466
  */
16467
- constructor({ store, type, cacheByDefault }, cacheKey, handler) {
16467
+ constructor({ store, type, cacheByDefault }, cacheKey2, handler) {
16468
16468
  this.#store = store;
16469
16469
  this.#cacheType = type;
16470
16470
  this.#cacheByDefault = cacheByDefault;
16471
- this.#cacheKey = cacheKey;
16471
+ this.#cacheKey = cacheKey2;
16472
16472
  this.#handler = handler;
16473
16473
  }
16474
16474
  onRequestStart(controller, context) {
@@ -16657,15 +16657,15 @@ var require_cache_handler = __commonJS({
16657
16657
  this.#handler.onResponseError?.(controller, err);
16658
16658
  }
16659
16659
  };
16660
- function deleteCachedValue(store, cacheKey) {
16660
+ function deleteCachedValue(store, cacheKey2) {
16661
16661
  try {
16662
- store.delete(cacheKey)?.catch?.(noop);
16662
+ store.delete(cacheKey2)?.catch?.(noop);
16663
16663
  } catch {
16664
16664
  }
16665
16665
  }
16666
- function deleteCachedValueIfNotModified(statusCode, store, cacheKey) {
16666
+ function deleteCachedValueIfNotModified(statusCode, store, cacheKey2) {
16667
16667
  if (statusCode === 304) {
16668
- deleteCachedValue(store, cacheKey);
16668
+ deleteCachedValue(store, cacheKey2);
16669
16669
  }
16670
16670
  }
16671
16671
  function revalidationResponseDisallowsCachedReuse(cacheType, resHeaders, cacheControlDirectives) {
@@ -17228,9 +17228,9 @@ var require_cache2 = __commonJS({
17228
17228
  function revalidationResponseUpdatesCacheControl(headers) {
17229
17229
  return headers["cache-control"] !== void 0;
17230
17230
  }
17231
- function deleteCachedValue(store, cacheKey) {
17231
+ function deleteCachedValue(store, cacheKey2) {
17232
17232
  try {
17233
- store.delete(cacheKey)?.catch?.(nop);
17233
+ store.delete(cacheKey2)?.catch?.(nop);
17234
17234
  } catch {
17235
17235
  }
17236
17236
  }
@@ -17282,7 +17282,7 @@ var require_cache2 = __commonJS({
17282
17282
  const staleWhileRevalidateExpiry = result.staleAt + staleWhileRevalidate * 1e3;
17283
17283
  return now <= staleWhileRevalidateExpiry;
17284
17284
  }
17285
- function handleUncachedResponse(dispatch, globalOpts, cacheKey, handler, opts, reqCacheControl) {
17285
+ function handleUncachedResponse(dispatch, globalOpts, cacheKey2, handler, opts, reqCacheControl) {
17286
17286
  if (reqCacheControl?.["only-if-cached"]) {
17287
17287
  let aborted = false;
17288
17288
  try {
@@ -17310,7 +17310,7 @@ var require_cache2 = __commonJS({
17310
17310
  }
17311
17311
  return true;
17312
17312
  }
17313
- return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
17313
+ return dispatch(opts, new CacheHandler(globalOpts, cacheKey2, handler));
17314
17314
  }
17315
17315
  function sendCachedValue(handler, opts, result, age, context, isStale2) {
17316
17316
  const stream = util.isStream(result.body) ? result.body : Readable.from(result.body ?? []);
@@ -17366,13 +17366,13 @@ var require_cache2 = __commonJS({
17366
17366
  });
17367
17367
  }
17368
17368
  }
17369
- function handleResult(dispatch, globalOpts, cacheKey, handler, opts, reqCacheControl, result) {
17369
+ function handleResult(dispatch, globalOpts, cacheKey2, handler, opts, reqCacheControl, result) {
17370
17370
  if (!result) {
17371
- return handleUncachedResponse(dispatch, globalOpts, cacheKey, handler, opts, reqCacheControl);
17371
+ return handleUncachedResponse(dispatch, globalOpts, cacheKey2, handler, opts, reqCacheControl);
17372
17372
  }
17373
17373
  const now = Date.now();
17374
17374
  if (now > result.deleteAt) {
17375
- return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
17375
+ return dispatch(opts, new CacheHandler(globalOpts, cacheKey2, handler));
17376
17376
  }
17377
17377
  const age = Math.round((now - result.cachedAt) / 1e3);
17378
17378
  const requestMaxAgeExpired = reqCacheControl?.["max-age"] !== void 0 && age >= reqCacheControl["max-age"];
@@ -17380,7 +17380,7 @@ var require_cache2 = __commonJS({
17380
17380
  const revalidate = requestMaxAgeExpired || needsRevalidation(result, reqCacheControl, opts);
17381
17381
  if (stale || revalidate) {
17382
17382
  if (util.isStream(opts.body) && util.bodyLength(opts.body) !== 0) {
17383
- return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
17383
+ return dispatch(opts, new CacheHandler(globalOpts, cacheKey2, handler));
17384
17384
  }
17385
17385
  if (!revalidate && withinStaleWhileRevalidateWindow(result, globalOpts.type)) {
17386
17386
  sendCachedValue(handler, opts, result, age, null, true);
@@ -17391,7 +17391,7 @@ var require_cache2 = __commonJS({
17391
17391
  ...opts,
17392
17392
  headers: headers2
17393
17393
  },
17394
- new CacheHandler(globalOpts, cacheKey, {
17394
+ new CacheHandler(globalOpts, cacheKey2, {
17395
17395
  // Silent handler that just updates the cache
17396
17396
  onRequestStart() {
17397
17397
  },
@@ -17431,11 +17431,11 @@ var require_cache2 = __commonJS({
17431
17431
  if (util.isStream(result.body)) {
17432
17432
  result.body.on("error", nop).destroy();
17433
17433
  }
17434
- deleteCachedValue(globalOpts.store, cacheKey);
17435
- return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
17434
+ deleteCachedValue(globalOpts.store, cacheKey2);
17435
+ return dispatch(opts, new CacheHandler(globalOpts, cacheKey2, handler));
17436
17436
  }
17437
17437
  if (revalidationResponseUpdatesCacheControl(headers2)) {
17438
- deleteCachedValue(globalOpts.store, cacheKey);
17438
+ deleteCachedValue(globalOpts.store, cacheKey2);
17439
17439
  }
17440
17440
  }
17441
17441
  sendCachedValue(handler, opts, result, age, context, stale);
@@ -17443,7 +17443,7 @@ var require_cache2 = __commonJS({
17443
17443
  result.body.on("error", nop).destroy();
17444
17444
  }
17445
17445
  },
17446
- new CacheHandler(globalOpts, cacheKey, handler),
17446
+ new CacheHandler(globalOpts, cacheKey2, handler),
17447
17447
  withinStaleIfErrorThreshold
17448
17448
  )
17449
17449
  );
@@ -17518,13 +17518,13 @@ var require_cache2 = __commonJS({
17518
17518
  if (reqCacheControl?.["no-store"]) {
17519
17519
  return dispatch(opts2, handler);
17520
17520
  }
17521
- const cacheKey = makeCacheKey(opts2);
17522
- const result = store.get(cacheKey);
17521
+ const cacheKey2 = makeCacheKey(opts2);
17522
+ const result = store.get(cacheKey2);
17523
17523
  if (result && typeof result.then === "function") {
17524
17524
  return result.then((result2) => handleResult(
17525
17525
  dispatch,
17526
17526
  globalOpts,
17527
- cacheKey,
17527
+ cacheKey2,
17528
17528
  handler,
17529
17529
  opts2,
17530
17530
  reqCacheControl,
@@ -17534,7 +17534,7 @@ var require_cache2 = __commonJS({
17534
17534
  return handleResult(
17535
17535
  dispatch,
17536
17536
  globalOpts,
17537
- cacheKey,
17537
+ cacheKey2,
17538
17538
  handler,
17539
17539
  opts2,
17540
17540
  reqCacheControl,
@@ -18175,8 +18175,8 @@ var require_deduplicate = __commonJS({
18175
18175
  }
18176
18176
  }
18177
18177
  }
18178
- const cacheKey = makeCacheKey(opts2);
18179
- const dedupeKey = makeDeduplicationKey(cacheKey, excludeHeaderNamesSet);
18178
+ const cacheKey2 = makeCacheKey(opts2);
18179
+ const dedupeKey = makeDeduplicationKey(cacheKey2, excludeHeaderNamesSet);
18180
18180
  const pendingHandler = pendingRequests.get(dedupeKey);
18181
18181
  if (pendingHandler) {
18182
18182
  if (pendingHandler.addWaitingHandler(handler)) {
@@ -25836,7 +25836,9 @@ var Cache = class _Cache extends I {
25836
25836
  return this.#diskRead(k, v, opts.context?.integrity);
25837
25837
  },
25838
25838
  allowStaleOnFetchRejection: true,
25839
- allowStaleOnFetchAbort: true,
25839
+ // Eviction aborts in-flight fetch() placeholders. Resolving those
25840
+ // as undefined is treated as a cache miss and re-downloads tarballs.
25841
+ ignoreFetchAbort: true,
25840
25842
  allowStale: true,
25841
25843
  noDeleteOnStaleGet: true
25842
25844
  });
@@ -26444,6 +26446,7 @@ var CacheEntry = class _CacheEntry {
26444
26446
  #trustIntegrity;
26445
26447
  #staleWhileRevalidateFactor;
26446
26448
  #fromCache = false;
26449
+ #headSize;
26447
26450
  constructor(statusCode, headers, {
26448
26451
  body,
26449
26452
  integrity,
@@ -26586,6 +26589,13 @@ var CacheEntry = class _CacheEntry {
26586
26589
  get fromCache() {
26587
26590
  return this.#fromCache;
26588
26591
  }
26592
+ /**
26593
+ * Byte length of the encoded head (4-byte length prefix + status +
26594
+ * headers). Set when decoded from cache or after `encodeHead()`.
26595
+ */
26596
+ get headSize() {
26597
+ return this.#headSize;
26598
+ }
26589
26599
  get statusCode() {
26590
26600
  return this.#statusCode;
26591
26601
  }
@@ -26770,19 +26780,10 @@ var CacheEntry = class _CacheEntry {
26770
26780
  this.#json = obj;
26771
26781
  return obj;
26772
26782
  }
26773
- /**
26774
- * Pass the contents of a @vltpkg/cache.Cache object as a buffer,
26775
- * and this static method will decode it into a CacheEntry representing
26776
- * the cached response.
26777
- */
26778
- static decode(buffer) {
26779
- if (buffer.length < 4) {
26780
- return emptyCacheEntry;
26781
- }
26783
+ static #parseHead(buffer) {
26784
+ if (buffer.length < 4) return void 0;
26782
26785
  const headSize = readSize(buffer, 0);
26783
- if (buffer.length < headSize) {
26784
- return emptyCacheEntry;
26785
- }
26786
+ if (buffer.length < headSize) return void 0;
26786
26787
  const statusCode = Number(getDecodedValue(buffer.subarray(4, 7)));
26787
26788
  const headersBuffer = buffer.subarray(7, headSize);
26788
26789
  const headers = [];
@@ -26801,22 +26802,50 @@ var CacheEntry = class _CacheEntry {
26801
26802
  headers.push(val);
26802
26803
  i += size;
26803
26804
  }
26804
- const body = buffer.subarray(headSize);
26805
+ return { statusCode, headers, integrity, headSize };
26806
+ }
26807
+ /**
26808
+ * Decode only the status/headers from an encoded cache buffer.
26809
+ * The body is not read; `headSize` records how many bytes the head
26810
+ * occupies so a later `encodeHead()` can be patched in place.
26811
+ */
26812
+ static decodeHead(buffer) {
26813
+ const parsed = _CacheEntry.#parseHead(buffer);
26814
+ if (!parsed) return emptyCacheEntry;
26815
+ const c = new _CacheEntry(parsed.statusCode, parsed.headers, {
26816
+ body: new Uint8Array(0),
26817
+ integrity: parsed.integrity,
26818
+ trustIntegrity: true
26819
+ });
26820
+ c.#fromCache = true;
26821
+ c.#headSize = parsed.headSize;
26822
+ return c;
26823
+ }
26824
+ /**
26825
+ * Pass the contents of a @vltpkg/cache.Cache object as a buffer,
26826
+ * and this static method will decode it into a CacheEntry representing
26827
+ * the cached response.
26828
+ */
26829
+ static decode(buffer) {
26830
+ const parsed = _CacheEntry.#parseHead(buffer);
26831
+ if (!parsed) return emptyCacheEntry;
26832
+ const body = buffer.subarray(parsed.headSize);
26805
26833
  const c = new _CacheEntry(
26806
- statusCode,
26834
+ parsed.statusCode,
26807
26835
  setRawHeader(
26808
- headers,
26836
+ parsed.headers,
26809
26837
  "content-length",
26810
26838
  String(body.byteLength)
26811
26839
  ),
26812
26840
  {
26813
26841
  body,
26814
- integrity,
26842
+ integrity: parsed.integrity,
26815
26843
  trustIntegrity: true,
26816
26844
  contentLength: body.byteLength
26817
26845
  }
26818
26846
  );
26819
26847
  c.#fromCache = true;
26848
+ c.#headSize = parsed.headSize;
26820
26849
  try {
26821
26850
  if (c.isJSON) {
26822
26851
  c.unzip();
@@ -26834,42 +26863,49 @@ var CacheEntry = class _CacheEntry {
26834
26863
  return gzipBytes[0] === 31 && gzipBytes[1] === 139;
26835
26864
  }
26836
26865
  /**
26837
- * Encode the entry as a single Buffer for writing to the cache
26866
+ * Encode status + headers (no body) as they appear at the start of
26867
+ * an on-disk cache file.
26838
26868
  */
26839
- encode() {
26840
- if (this.isJSON) this.json();
26869
+ encodeHead() {
26841
26870
  const statusStr = String(this.#statusCode);
26842
26871
  const statusBytes = getEncondedValue(statusStr);
26843
26872
  let headLength = 4 + statusBytes.byteLength;
26844
26873
  for (const h of this.#headers) headLength += 4 + h.byteLength;
26845
- const headLenBytes = new Uint8Array(4);
26846
- headLenBytes[0] = headLength >> 24 & 255;
26847
- headLenBytes[1] = headLength >> 16 & 255;
26848
- headLenBytes[2] = headLength >> 8 & 255;
26849
- headLenBytes[3] = headLength & 255;
26850
- const headerChunks = [];
26851
- for (const h of this.#headers) {
26852
- const l = headLenBytes.byteLength + h.byteLength;
26853
- const lb = new Uint8Array(4);
26854
- lb[0] = l >> 24 & 255;
26855
- lb[1] = l >> 16 & 255;
26856
- lb[2] = l >> 8 & 255;
26857
- lb[3] = l & 255;
26858
- headerChunks.push(lb, h);
26859
- }
26860
- const total = headLenBytes.byteLength + statusBytes.byteLength + headerChunks.reduce((n, b) => n + b.byteLength, 0) + this._body.byteLength;
26861
- const outBuffer = new ArrayBuffer(total);
26862
- const out = Buffer.from(outBuffer, 0, total);
26874
+ const out = Buffer.from(
26875
+ new ArrayBuffer(headLength),
26876
+ 0,
26877
+ headLength
26878
+ );
26863
26879
  let off = 0;
26864
- out.set(headLenBytes, off);
26865
- off += headLenBytes.byteLength;
26880
+ out[off++] = headLength >> 24 & 255;
26881
+ out[off++] = headLength >> 16 & 255;
26882
+ out[off++] = headLength >> 8 & 255;
26883
+ out[off++] = headLength & 255;
26866
26884
  out.set(statusBytes, off);
26867
26885
  off += statusBytes.byteLength;
26868
- for (const chunk of headerChunks) {
26869
- out.set(chunk, off);
26870
- off += chunk.byteLength;
26871
- }
26872
- out.set(this._body, off);
26886
+ for (const h of this.#headers) {
26887
+ const l = 4 + h.byteLength;
26888
+ out[off++] = l >> 24 & 255;
26889
+ out[off++] = l >> 16 & 255;
26890
+ out[off++] = l >> 8 & 255;
26891
+ out[off++] = l & 255;
26892
+ out.set(h, off);
26893
+ off += h.byteLength;
26894
+ }
26895
+ this.#headSize = headLength;
26896
+ return out;
26897
+ }
26898
+ /**
26899
+ * Encode the entry as a single Buffer for writing to the cache
26900
+ */
26901
+ encode() {
26902
+ if (this.isJSON) this.json();
26903
+ const head = this.encodeHead();
26904
+ const body = this._body;
26905
+ const total = head.byteLength + body.byteLength;
26906
+ const out = Buffer.from(new ArrayBuffer(total), 0, total);
26907
+ out.set(head, 0);
26908
+ out.set(body, head.byteLength);
26873
26909
  return out;
26874
26910
  }
26875
26911
  };
@@ -27144,6 +27180,32 @@ var setCacheHeaders = (options, entry) => {
27144
27180
  // ../../src/registry-client/src/token-response.ts
27145
27181
  var getTokenResponse = (b) => !!b && typeof b === "object" && "token" in b && typeof b.token === "string" && b.token ? { token: b.token } : void 0;
27146
27182
 
27183
+ // ../../src/registry-client/src/response.ts
27184
+ var collectHeaders = (response) => {
27185
+ const h = [];
27186
+ for (const [key, value] of Object.entries(response.headers)) {
27187
+ if (Array.isArray(value)) {
27188
+ h.push(
27189
+ getEncondedValue(key),
27190
+ getEncondedValue(value.join(", "))
27191
+ );
27192
+ } else if (typeof value === "string") {
27193
+ h.push(getEncondedValue(key), getEncondedValue(value));
27194
+ }
27195
+ }
27196
+ return h;
27197
+ };
27198
+ var readBody = async (response, entry) => {
27199
+ response.body.on(
27200
+ "data",
27201
+ (chunk) => entry.addBody(chunk)
27202
+ );
27203
+ return await new Promise((res, rej) => {
27204
+ response.body.on("error", rej);
27205
+ response.body.on("end", () => res(entry));
27206
+ });
27207
+ };
27208
+
27147
27209
  // ../../src/registry-client/src/oidc.ts
27148
27210
  var import_undici2 = __toESM(require_undici(), 1);
27149
27211
  var log2 = (...args) => (
@@ -27294,6 +27356,7 @@ var exchangeToken = async (idToken, packageName, registry) => {
27294
27356
 
27295
27357
  // ../../src/registry-client/src/index.ts
27296
27358
  var isCacheableMethod = (m) => m === "GET" || m === "HEAD";
27359
+ var cacheKey = (method, url) => `${method !== "GET" ? method + " " : ""}${url}`;
27297
27360
  var { version } = loadPackageJson(
27298
27361
  import.meta.filename,
27299
27362
  "registry-client-package.json"
@@ -27512,7 +27575,7 @@ var RegistryClient = class {
27512
27575
  const m = isCacheableMethod(method) ? method : void 0;
27513
27576
  const { useCache = !!m } = options;
27514
27577
  signal?.throwIfAborted();
27515
- const key = `${method !== "GET" ? method + " " : ""}${u}`;
27578
+ const key = cacheKey(method, u);
27516
27579
  const buffer = useCache ? await this.cache.fetch(key, { context: { integrity } }) : void 0;
27517
27580
  const entry = buffer ? this.#decodeCached(buffer) : void 0;
27518
27581
  if (entry?.valid) {
@@ -27621,17 +27684,7 @@ var RegistryClient = class {
27621
27684
  consumedBody = otpResult.bodyConsumed;
27622
27685
  }
27623
27686
  }
27624
- const h = [];
27625
- for (const [key, value] of Object.entries(response.headers)) {
27626
- if (Array.isArray(value)) {
27627
- h.push(
27628
- getEncondedValue(key),
27629
- getEncondedValue(value.join(", "))
27630
- );
27631
- } else if (typeof value === "string") {
27632
- h.push(getEncondedValue(key), getEncondedValue(value));
27633
- }
27634
- }
27687
+ const h = collectHeaders(response);
27635
27688
  const { integrity, trustIntegrity } = options;
27636
27689
  const contentLength = consumedBody !== void 0 ? consumedBody.length : response.headers["content-length"] ? Number(response.headers["content-length"]) : (
27637
27690
  /* c8 ignore next */
@@ -27662,14 +27715,7 @@ var RegistryClient = class {
27662
27715
  }
27663
27716
  return result;
27664
27717
  }
27665
- response.body.on(
27666
- "data",
27667
- (chunk) => result.addBody(chunk)
27668
- );
27669
- return await new Promise((res, rej) => {
27670
- response.body.on("error", rej);
27671
- response.body.on("end", () => res(result));
27672
- });
27718
+ return await readBody(response, result);
27673
27719
  }
27674
27720
  };
27675
27721
 
@@ -27689,6 +27735,7 @@ export {
27689
27735
  CacheEntry,
27690
27736
  oidc,
27691
27737
  isCacheableMethod,
27738
+ cacheKey,
27692
27739
  userAgent,
27693
27740
  RegistryClient
27694
27741
  };
@@ -13,10 +13,10 @@ import {
13
13
  graphRun,
14
14
  graphRunSync,
15
15
  joinDepIDTuple
16
- } from "./chunk-OCJDISSI.js";
16
+ } from "./chunk-3OPNZI6G.js";
17
17
  import {
18
18
  Spec
19
- } from "./chunk-XU5SMHXP.js";
19
+ } from "./chunk-XKVU23NC.js";
20
20
  import {
21
21
  load,
22
22
  parse as parse2,
@@ -41,7 +41,7 @@ import {
41
41
  normalizeManifest,
42
42
  parse,
43
43
  satisfies
44
- } from "./chunk-IITIX4ID.js";
44
+ } from "./chunk-VFBCWAOC.js";
45
45
  import {
46
46
  error
47
47
  } from "./chunk-WZWDS3W4.js";
@@ -14,12 +14,12 @@ import {
14
14
  } from "./chunk-RIYFGX27.js";
15
15
  import {
16
16
  createHostContextsMap
17
- } from "./chunk-MZIM7X37.js";
17
+ } from "./chunk-YRLO236S.js";
18
18
  import {
19
19
  stderr,
20
20
  stdout,
21
21
  styleTextStdout
22
- } from "./chunk-E737X73P.js";
22
+ } from "./chunk-AL42Z2D3.js";
23
23
  import {
24
24
  require_emoji_regex
25
25
  } from "./chunk-VTEFO2FT.js";
@@ -27,13 +27,13 @@ import {
27
27
  Query,
28
28
  actual,
29
29
  isRunResult
30
- } from "./chunk-OR5LSCSK.js";
30
+ } from "./chunk-3NGV7EC6.js";
31
31
  import {
32
32
  Monorepo
33
- } from "./chunk-PDLEQEZ3.js";
33
+ } from "./chunk-SVBEF5PK.js";
34
34
  import {
35
35
  isErrorWithCause
36
- } from "./chunk-IITIX4ID.js";
36
+ } from "./chunk-VFBCWAOC.js";
37
37
  import {
38
38
  error
39
39
  } from "./chunk-WZWDS3W4.js";
@@ -990,13 +990,31 @@ var getOptions = (options) => ({
990
990
  ...options["git-host-archives"]
991
991
  } : defaultGitHostArchives
992
992
  });
993
+ var protocolRE = /^([a-zA-Z][a-zA-Z0-9+-]+):/;
994
+ var builtinProtocols = /* @__PURE__ */ new Set([
995
+ "catalog",
996
+ "workspace",
997
+ "registry",
998
+ "file",
999
+ "http",
1000
+ "https",
1001
+ "git",
1002
+ "git+ssh",
1003
+ "git+http",
1004
+ "git+https",
1005
+ "git+file"
1006
+ ]);
1007
+ var unknownProtocol = (str, options) => {
1008
+ const p = protocolRE.exec(str)?.[1];
1009
+ 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;
1010
+ };
993
1011
  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
994
1012
  // custom registered registry protocol e.g: `github:`, `custom:`
995
1013
  [
996
1014
  ...Object.keys(options["git-hosts"]),
997
1015
  ...Object.keys(options.registries),
998
1016
  ...Object.keys(options["jsr-registries"])
999
- ].some((key) => spec.startsWith(`${key}:`));
1017
+ ].some((key) => spec.startsWith(`${key}:`)) || unknownProtocol(spec, options) !== void 0;
1000
1018
  var findFirstAt = (spec, hasScope) => spec.indexOf("@", hasScope ? 1 : 0);
1001
1019
  var findGitIdentifier = (spec) => spec.indexOf("#") > 2;
1002
1020
  var findFileIdentifier = (spec) => spec.includes("/");
@@ -1117,6 +1135,7 @@ var Spec = class _Spec {
1117
1135
  assertPathSafeName(this.name, this.spec);
1118
1136
  } else {
1119
1137
  this.spec = spec;
1138
+ this.#assertKnownProtocol(spec);
1120
1139
  if (!spec.startsWith("git@") && startsWithSpecIdentifier(spec, this.options) && spec.includes(":") && [
1121
1140
  ...Object.keys(this.options.registries),
1122
1141
  ...Object.keys(defaultRegistries)
@@ -1302,6 +1321,7 @@ var Spec = class _Spec {
1302
1321
  this.spec = `${this.name}@${this.bareSpec}`;
1303
1322
  return;
1304
1323
  }
1324
+ this.#assertKnownProtocol(this.bareSpec);
1305
1325
  if (!this.bareSpec.startsWith("./") && !this.bareSpec.startsWith("../") && this.options["git-hosts"].github) {
1306
1326
  const hash = this.bareSpec.indexOf("#");
1307
1327
  const up = hash === -1 ? this.bareSpec : this.bareSpec.substring(0, hash);
@@ -1449,6 +1469,22 @@ var Spec = class _Spec {
1449
1469
  this.spec = this.name + "@" + this.bareSpec;
1450
1470
  return this.subspec;
1451
1471
  }
1472
+ #assertKnownProtocol(str) {
1473
+ const proto = unknownProtocol(str, this.options);
1474
+ if (proto === void 0) return;
1475
+ throw this.#error(`Protocol ${proto}: is not defined`, {
1476
+ found: `${proto}:`,
1477
+ validOptions: [
1478
+ .../* @__PURE__ */ new Set([
1479
+ ...builtinProtocols,
1480
+ this.options["default-registry-alias"],
1481
+ ...Object.keys(this.options.registries),
1482
+ ...Object.keys(this.options["git-hosts"]),
1483
+ ...Object.keys(this.options["jsr-registries"])
1484
+ ])
1485
+ ].map((p) => `${p}:`)
1486
+ });
1487
+ }
1452
1488
  #error(message, extra = {}) {
1453
1489
  return error(message, { spec: this.spec, ...extra }, this.#error);
1454
1490
  }
@@ -12,7 +12,7 @@ var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  Spec,
14
14
  kCustomInspect
15
- } from "./chunk-IITIX4ID.js";
15
+ } from "./chunk-VFBCWAOC.js";
16
16
 
17
17
  // ../../src/spec/src/index.ts
18
18
  import { homedir } from "node:os";