@vltpkg/registry-client 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cache-entry.js +7 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +11 -3
- package/package.json +10 -10
package/dist/cache-entry.js
CHANGED
|
@@ -390,6 +390,13 @@ export class CacheEntry {
|
|
|
390
390
|
*/
|
|
391
391
|
setHeader(h, value) {
|
|
392
392
|
this.#headers = setRawHeader(this.#headers, h, value);
|
|
393
|
+
// validity is memoized off the date header
|
|
394
|
+
if (h.toLowerCase() === 'date') {
|
|
395
|
+
this.#date = undefined;
|
|
396
|
+
this.#valid = undefined;
|
|
397
|
+
this.#validUntil = undefined;
|
|
398
|
+
this.#staleUntil = undefined;
|
|
399
|
+
}
|
|
393
400
|
}
|
|
394
401
|
/**
|
|
395
402
|
* Remove a header, if present
|
package/dist/index.d.ts
CHANGED
|
@@ -137,9 +137,11 @@ export type RegistryClientRequestOptions = Omit<Dispatcher.RequestOptions, 'meth
|
|
|
137
137
|
/**
|
|
138
138
|
* Revalidate a cached response even when it is still within max-age.
|
|
139
139
|
* Conditional request headers are still sent when available.
|
|
140
|
+
* `'background'`: serve an entry still within max-age and revalidate
|
|
141
|
+
* it after exit; older entries revalidate first.
|
|
140
142
|
* @internal
|
|
141
143
|
*/
|
|
142
|
-
forceRevalidate?: boolean;
|
|
144
|
+
forceRevalidate?: boolean | 'background';
|
|
143
145
|
};
|
|
144
146
|
/**
|
|
145
147
|
* The `User-Agent` header sent with every request. Re-exported from
|
package/dist/index.js
CHANGED
|
@@ -521,7 +521,11 @@ export class RegistryClient {
|
|
|
521
521
|
await this.cache.fetch(key, { context: { integrity } })
|
|
522
522
|
: undefined;
|
|
523
523
|
const entry = buffer ? this.#decodeCached(buffer) : undefined;
|
|
524
|
-
if (entry?.valid &&
|
|
524
|
+
if (entry?.valid && forceRevalidate !== true) {
|
|
525
|
+
// 'background': serve it, revalidate after exit
|
|
526
|
+
if (forceRevalidate === 'background' && m) {
|
|
527
|
+
register(dirname(this.cache.path()), m, url, getHeader(options.headers, 'accept'));
|
|
528
|
+
}
|
|
525
529
|
logRequest(url, 'cache', { method });
|
|
526
530
|
return entry;
|
|
527
531
|
}
|
|
@@ -645,8 +649,12 @@ export class RegistryClient {
|
|
|
645
649
|
(result.statusCode === 200 && !result.isJSON ?
|
|
646
650
|
result.integrityActual
|
|
647
651
|
: undefined);
|
|
648
|
-
const
|
|
649
|
-
|
|
652
|
+
const encoded = result.encode();
|
|
653
|
+
const stored = Buffer.from(encoded.buffer, encoded.byteOffset, encoded.byteLength);
|
|
654
|
+
this.cache.set(key, stored, { integrity });
|
|
655
|
+
// a 304 keeps the parsed entry
|
|
656
|
+
if (result === entry && entry.isJSON)
|
|
657
|
+
this.#decoded.set(stored, entry);
|
|
650
658
|
}
|
|
651
659
|
return result;
|
|
652
660
|
}
|
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.3.
|
|
4
|
+
"version": "1.3.3",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
"url": "http://vlt.sh"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@vltpkg/cache": "1.3.
|
|
17
|
-
"@vltpkg/cache-unzip": "1.3.
|
|
18
|
-
"@vltpkg/error-cause": "1.3.
|
|
19
|
-
"@vltpkg/keychain": "1.3.
|
|
20
|
-
"@vltpkg/output": "1.3.
|
|
21
|
-
"@vltpkg/types": "1.3.
|
|
22
|
-
"@vltpkg/url-open": "1.3.
|
|
23
|
-
"@vltpkg/user-agent": "1.3.
|
|
24
|
-
"@vltpkg/xdg": "1.3.
|
|
16
|
+
"@vltpkg/cache": "1.3.3",
|
|
17
|
+
"@vltpkg/cache-unzip": "1.3.3",
|
|
18
|
+
"@vltpkg/error-cause": "1.3.3",
|
|
19
|
+
"@vltpkg/keychain": "1.3.3",
|
|
20
|
+
"@vltpkg/output": "1.3.3",
|
|
21
|
+
"@vltpkg/types": "1.3.3",
|
|
22
|
+
"@vltpkg/url-open": "1.3.3",
|
|
23
|
+
"@vltpkg/user-agent": "1.3.3",
|
|
24
|
+
"@vltpkg/xdg": "1.3.3",
|
|
25
25
|
"cache-control-parser": "^2.0.6",
|
|
26
26
|
"undici": "^7.16.0"
|
|
27
27
|
},
|