@vltpkg/package-info 1.3.7 → 1.3.8
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/index.d.ts +7 -0
- package/dist/index.js +37 -7
- package/package.json +14 -14
package/dist/index.d.ts
CHANGED
|
@@ -114,6 +114,13 @@ export declare class PackageInfoClient {
|
|
|
114
114
|
options: PackageInfoClientOptions;
|
|
115
115
|
packageJson: PackageJson;
|
|
116
116
|
monorepo?: Monorepo;
|
|
117
|
+
/**
|
|
118
|
+
* Wind the client down: abort open resolve streams, settle background
|
|
119
|
+
* work (manifest cache writes, capabilities, hedges), drain the registry
|
|
120
|
+
* client (in-flight requests, cache writes). Await before removing the
|
|
121
|
+
* cache dir or exiting.
|
|
122
|
+
*/
|
|
123
|
+
drain(): Promise<void>;
|
|
117
124
|
getRegistryClient(): Promise<RegistryClient>;
|
|
118
125
|
/**
|
|
119
126
|
* The vlt extensions `registry` serves, from its
|
package/dist/index.js
CHANGED
|
@@ -209,6 +209,37 @@ export class PackageInfoClient {
|
|
|
209
209
|
#resolveWaiters = new Map();
|
|
210
210
|
#registryClientPromise;
|
|
211
211
|
#tarPoolPromise;
|
|
212
|
+
// fire-and-forget work, settled by drain()
|
|
213
|
+
#background = new Set();
|
|
214
|
+
#inBackground(p) {
|
|
215
|
+
const done = () => {
|
|
216
|
+
this.#background.delete(tracked);
|
|
217
|
+
};
|
|
218
|
+
const tracked = p.then(done, done);
|
|
219
|
+
this.#background.add(tracked);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Wind the client down: abort open resolve streams, settle background
|
|
223
|
+
* work (manifest cache writes, capabilities, hedges), drain the registry
|
|
224
|
+
* client (in-flight requests, cache writes). Await before removing the
|
|
225
|
+
* cache dir or exiting.
|
|
226
|
+
*/
|
|
227
|
+
async drain() {
|
|
228
|
+
for (const [sent, owner] of this.#resolveOwners) {
|
|
229
|
+
this.#resolveOwners.delete(sent);
|
|
230
|
+
this.#resolveSent.delete(sent);
|
|
231
|
+
owner.controller.abort();
|
|
232
|
+
}
|
|
233
|
+
while (this.#background.size) {
|
|
234
|
+
await Promise.all(this.#background);
|
|
235
|
+
}
|
|
236
|
+
if (this.#registryClientPromise) {
|
|
237
|
+
await (await this.#registryClientPromise).drain();
|
|
238
|
+
}
|
|
239
|
+
/* c8 ignore next - work started while the cache flushed */
|
|
240
|
+
if (this.#background.size)
|
|
241
|
+
await this.drain();
|
|
242
|
+
}
|
|
212
243
|
async getRegistryClient() {
|
|
213
244
|
if (this.#registryClient)
|
|
214
245
|
return this.#registryClient;
|
|
@@ -247,7 +278,7 @@ export class PackageInfoClient {
|
|
|
247
278
|
if (!client) {
|
|
248
279
|
// the registry client is built lazily, so the first caller starts it
|
|
249
280
|
// and the document along with it, and asks optimistically meanwhile
|
|
250
|
-
|
|
281
|
+
this.#inBackground(this.capabilities(registry));
|
|
251
282
|
return true;
|
|
252
283
|
}
|
|
253
284
|
const caps = peekCapabilities(client, registry);
|
|
@@ -296,10 +327,6 @@ export class PackageInfoClient {
|
|
|
296
327
|
const linker = options['store-linker'];
|
|
297
328
|
this.#storeLinker =
|
|
298
329
|
linker && storeLinkers.has(linker) ? linker : 'unpack';
|
|
299
|
-
// optionally create its cache directory if it doesn't exist
|
|
300
|
-
void mkdir(pathResolve(this.#cachePath, 'package-info'), {
|
|
301
|
-
recursive: true,
|
|
302
|
-
}).catch(() => { });
|
|
303
330
|
}
|
|
304
331
|
async extract(spec, target, options = {}) {
|
|
305
332
|
if (typeof spec === 'string')
|
|
@@ -910,6 +937,7 @@ export class PackageInfoClient {
|
|
|
910
937
|
inflight.lastRecordAt = Date.now();
|
|
911
938
|
const promise = this.#runResolve(registry, request, owner.controller.signal, inflight);
|
|
912
939
|
inflight.requests.add(promise);
|
|
940
|
+
this.#inBackground(promise);
|
|
913
941
|
// dropped once settled, so manifest() stops waiting on a request that
|
|
914
942
|
// has already delivered everything it is going to
|
|
915
943
|
const clear = () => {
|
|
@@ -1010,6 +1038,8 @@ export class PackageInfoClient {
|
|
|
1010
1038
|
return early ?? (await fetch());
|
|
1011
1039
|
debug('resolve hedge %s', key);
|
|
1012
1040
|
const hedge = fetch();
|
|
1041
|
+
// stream may answer first; then nobody awaits the hedge
|
|
1042
|
+
this.#inBackground(hedge);
|
|
1013
1043
|
const outcome = await Promise.race([
|
|
1014
1044
|
arrival,
|
|
1015
1045
|
settled,
|
|
@@ -1073,7 +1103,7 @@ export class PackageInfoClient {
|
|
|
1073
1103
|
if (st.mtimeMs < this.#manifestCacheMinAge ||
|
|
1074
1104
|
json.__VLT_MANIFEST_CACHE_TIMESTAMP !== undefined) {
|
|
1075
1105
|
this.#manifestWritePaths.delete(cachePath);
|
|
1076
|
-
|
|
1106
|
+
this.#inBackground(unlink(cachePath));
|
|
1077
1107
|
throw new Error('manifest cache expired');
|
|
1078
1108
|
}
|
|
1079
1109
|
// the tarball digest stays required across processes
|
|
@@ -1097,7 +1127,7 @@ export class PackageInfoClient {
|
|
|
1097
1127
|
if (cachePath && !this.#manifestWritePaths.has(cachePath)) {
|
|
1098
1128
|
this.#manifestWritePaths.add(cachePath);
|
|
1099
1129
|
const vlt = this.#vltPackuments.has(`${f.registry}${f.name}`);
|
|
1100
|
-
|
|
1130
|
+
this.#inBackground(this.#writeManifestCache(cachePath, JSON.stringify(vlt ? { ...mani, __VLT_PACKUMENT: true } : mani)));
|
|
1101
1131
|
}
|
|
1102
1132
|
return mani;
|
|
1103
1133
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/package-info",
|
|
3
3
|
"description": "Resolve and fetch package metadata and tarballs",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.8",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
@@ -13,17 +13,17 @@
|
|
|
13
13
|
"url": "http://vlt.sh"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@vltpkg/error-cause": "1.3.
|
|
17
|
-
"@vltpkg/git": "1.3.
|
|
18
|
-
"@vltpkg/output": "1.3.
|
|
19
|
-
"@vltpkg/package-json": "1.3.
|
|
20
|
-
"@vltpkg/pick-manifest": "1.3.
|
|
21
|
-
"@vltpkg/registry-client": "1.3.
|
|
22
|
-
"@vltpkg/spec": "1.3.
|
|
23
|
-
"@vltpkg/tar": "1.3.
|
|
24
|
-
"@vltpkg/types": "1.3.
|
|
25
|
-
"@vltpkg/workspaces": "1.3.
|
|
26
|
-
"@vltpkg/xdg": "1.3.
|
|
16
|
+
"@vltpkg/error-cause": "1.3.8",
|
|
17
|
+
"@vltpkg/git": "1.3.8",
|
|
18
|
+
"@vltpkg/output": "1.3.8",
|
|
19
|
+
"@vltpkg/package-json": "1.3.8",
|
|
20
|
+
"@vltpkg/pick-manifest": "1.3.8",
|
|
21
|
+
"@vltpkg/registry-client": "1.3.8",
|
|
22
|
+
"@vltpkg/spec": "1.3.8",
|
|
23
|
+
"@vltpkg/tar": "1.3.8",
|
|
24
|
+
"@vltpkg/types": "1.3.8",
|
|
25
|
+
"@vltpkg/workspaces": "1.3.8",
|
|
26
|
+
"@vltpkg/xdg": "1.3.8",
|
|
27
27
|
"tar": "^7.5.2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"@types/node": "^22.19.2",
|
|
32
32
|
"@types/pacote": "^11.1.8",
|
|
33
33
|
"@vltpkg/benchmark": "0.0.0",
|
|
34
|
-
"@vltpkg/cache-unzip": "1.3.
|
|
35
|
-
"@vltpkg/vlt-json": "1.3.
|
|
34
|
+
"@vltpkg/cache-unzip": "1.3.8",
|
|
35
|
+
"@vltpkg/vlt-json": "1.3.8",
|
|
36
36
|
"eslint": "^9.39.1",
|
|
37
37
|
"pacote": "^21.0.4",
|
|
38
38
|
"prettier": "^3.7.4",
|