@vltpkg/registry-client 1.0.5 → 1.0.6

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.
@@ -145,7 +145,7 @@ export declare class CacheEntry {
145
145
  * and this static method will decode it into a CacheEntry representing
146
146
  * the cached response.
147
147
  */
148
- static decode(buffer: Uint8Array): CacheEntry;
148
+ static decode(buffer: Uint8Array, options?: CacheEntryOptions): CacheEntry;
149
149
  static isGzipEntry(buffer: Uint8Array): boolean;
150
150
  /**
151
151
  * Encode status + headers (no body) as they appear at the start of
@@ -500,7 +500,7 @@ export class CacheEntry {
500
500
  * and this static method will decode it into a CacheEntry representing
501
501
  * the cached response.
502
502
  */
503
- static decode(buffer) {
503
+ static decode(buffer, options = {}) {
504
504
  const parsed = CacheEntry.#parseHead(buffer);
505
505
  if (!parsed)
506
506
  return emptyCacheEntry;
@@ -510,6 +510,7 @@ export class CacheEntry {
510
510
  integrity: parsed.integrity,
511
511
  trustIntegrity: true,
512
512
  contentLength: body.byteLength,
513
+ ...options,
513
514
  });
514
515
  c.#fromCache = true;
515
516
  c.#headSize = parsed.headSize;
@@ -22,7 +22,7 @@ const handleBeforeExit = () => {
22
22
  for (const [path, r] of registered) {
23
23
  /* c8 ignore next */
24
24
  if (!r.size)
25
- return;
25
+ continue;
26
26
  const env = { ...process.env };
27
27
  if (compileCacheDir)
28
28
  env.NODE_COMPILE_CACHE ??= compileCacheDir;
package/dist/index.js CHANGED
@@ -217,7 +217,9 @@ export class RegistryClient {
217
217
  const hit = this.#decoded.get(buffer);
218
218
  if (hit)
219
219
  return hit;
220
- const entry = CacheEntry.decode(buffer);
220
+ const entry = CacheEntry.decode(buffer, {
221
+ 'stale-while-revalidate-factor': this.staleWhileRevalidateFactor,
222
+ });
221
223
  // statusCode 0 == undecodable, and a cached JSON body that fails
222
224
  // to parse is corrupt. Treat both as a total miss: the caller
223
225
  // refetches without conditional headers, so a fresh response
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vltpkg/registry-client",
3
3
  "description": "Fetch package artifacts and metadata from registries",
4
- "version": "1.0.5",
4
+ "version": "1.0.6",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -13,14 +13,14 @@
13
13
  "url": "http://vlt.sh"
14
14
  },
15
15
  "dependencies": {
16
- "@vltpkg/cache": "1.0.5",
17
- "@vltpkg/cache-unzip": "1.0.5",
18
- "@vltpkg/error-cause": "1.0.5",
19
- "@vltpkg/keychain": "1.0.5",
20
- "@vltpkg/output": "1.0.5",
21
- "@vltpkg/types": "1.0.5",
22
- "@vltpkg/url-open": "1.0.5",
23
- "@vltpkg/xdg": "1.0.5",
16
+ "@vltpkg/cache": "1.0.6",
17
+ "@vltpkg/cache-unzip": "1.0.6",
18
+ "@vltpkg/error-cause": "1.0.6",
19
+ "@vltpkg/keychain": "1.0.6",
20
+ "@vltpkg/output": "1.0.6",
21
+ "@vltpkg/types": "1.0.6",
22
+ "@vltpkg/url-open": "1.0.6",
23
+ "@vltpkg/xdg": "1.0.6",
24
24
  "cache-control-parser": "^2.0.6",
25
25
  "package-json-from-dist": "^1.0.1",
26
26
  "undici": "^7.16.0"