@vltpkg/cli-js 1.3.2 → 1.3.4

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 (76) hide show
  1. package/{access-M5BOAKLX.js → access-AY2CIGVN.js} +4 -4
  2. package/{bugs-QZ5NURDC.js → bugs-6PTC6V7S.js} +12 -12
  3. package/{build-CEAMZG7H.js → build-R6OJNJDU.js} +6 -6
  4. package/{cache-ILCET6EY.js → cache-NVLCCVWQ.js} +6 -6
  5. package/{chunk-NAVFU65Z.js → chunk-4XTUCYBW.js} +1 -1
  6. package/{chunk-MC6CESRA.js → chunk-AFUXQ3P4.js} +1 -1
  7. package/{chunk-4FHGRT4J.js → chunk-B5AKQ5TS.js} +3 -3
  8. package/{chunk-CU752KW7.js → chunk-BCANUHR3.js} +1 -1
  9. package/{chunk-EJFGJ543.js → chunk-BFR3XHEM.js} +3 -3
  10. package/{chunk-HBB2ECAT.js → chunk-CYN4ADWK.js} +2 -2
  11. package/{chunk-USLE2NXK.js → chunk-D4KNFORN.js} +1 -1
  12. package/{chunk-4QYSZZZQ.js → chunk-DK6HGJCF.js} +4 -4
  13. package/chunk-DM2XRLCS.js +75 -0
  14. package/{chunk-O63K3ZP6.js → chunk-GCLZEI3R.js} +173 -50
  15. package/{chunk-BUKZHMMK.js → chunk-INEKXXUQ.js} +1 -0
  16. package/{chunk-I6QGYSB4.js → chunk-LHIDMYN2.js} +1 -1
  17. package/{chunk-4WQ76RJD.js → chunk-MVD5AUNS.js} +1 -1
  18. package/{chunk-E53Z7AF6.js → chunk-MWAWPY3P.js} +3 -3
  19. package/chunk-OFHNSAQ5.js +2155 -0
  20. package/{chunk-2UW4UIVL.js → chunk-QEWKCTQY.js} +4 -4
  21. package/{chunk-IIXKXSLE.js → chunk-QGFDMXDH.js} +313 -171
  22. package/{chunk-QX6KMBTX.js → chunk-QZIC3WVP.js} +3 -3
  23. package/{chunk-ZWKI5OSF.js → chunk-SRWDPPLX.js} +0 -1377
  24. package/{chunk-ZMRJRQDK.js → chunk-TL5SYXSC.js} +292 -45
  25. package/{chunk-CSZTT7QN.js → chunk-TOKUDCSW.js} +2 -2
  26. package/{chunk-3NWCWTIU.js → chunk-WXRS5PRL.js} +1 -1
  27. package/{chunk-ENSGPOLR.js → chunk-XU5WNX4S.js} +3 -1
  28. package/{ci-4AI6XHRE.js → ci-FEZ6B33S.js} +7 -7
  29. package/cli-package.json +1 -1
  30. package/{config-PJVA5HZQ.js → config-EV5S74AA.js} +5 -5
  31. package/{config-UHPA5FHX.js → config-VVPVV36W.js} +6 -6
  32. package/{create-NQNFYWOC.js → create-VGCARZLU.js} +13 -13
  33. package/{deprecate-35D4AZFD.js → deprecate-3E27QREJ.js} +7 -7
  34. package/{dist-tag-W3AJECYB.js → dist-tag-ZIDIGEIM.js} +4 -4
  35. package/{docs-OFRPTPOG.js → docs-GESU73FF.js} +12 -12
  36. package/{exec-UTWGYF3B.js → exec-3SE4PRXY.js} +13 -13
  37. package/{exec-cache-VLPJMK7E.js → exec-cache-7QOIKCYP.js} +11 -11
  38. package/{exec-local-JKBHBKJZ.js → exec-local-EVAI6IYM.js} +10 -10
  39. package/{help-YRQQVODA.js → help-H54DUW2F.js} +4 -4
  40. package/{init-2QZ5TITF.js → init-JOAMKEKV.js} +7 -7
  41. package/{install-QBVAEHTO.js → install-WHOVSLKH.js} +12 -12
  42. package/{list-P4UQWDX7.js → list-7X2RIDA4.js} +12 -12
  43. package/{login-6KPWMFG4.js → login-P5NRTQDS.js} +8 -8
  44. package/{logout-KCYMUY6H.js → logout-5PCTGCJZ.js} +4 -4
  45. package/{pack-WQLFLOE2.js → pack-MLOVKXJZ.js} +9 -9
  46. package/package.json +1 -1
  47. package/{ping-GYFPW4F5.js → ping-6D6EEICV.js} +4 -4
  48. package/{pkg-KVQ6QMQH.js → pkg-HC6N3DDH.js} +8 -8
  49. package/{profile-APD6X27T.js → profile-C3MNVMAE.js} +4 -4
  50. package/{publish-EYKECRD3.js → publish-3KUMQXKT.js} +12 -12
  51. package/{query-3N5D2ZZW.js → query-HNBW2ZGX.js} +12 -12
  52. package/{registry-MXAA4HVJ.js → registry-PY2L5ZWC.js} +2 -2
  53. package/registry-client-src-revalidate.js +173 -50
  54. package/{repo-6B5W7Q2C.js → repo-VWEPCUXK.js} +12 -12
  55. package/{reporter-ZEDO2YIG.js → reporter-UUDMEN4E.js} +6 -6
  56. package/{run-INZMUBF2.js → run-OFW4MPAV.js} +10 -10
  57. package/{run-exec-RVYS73II.js → run-exec-ACGX23HX.js} +10 -10
  58. package/security-archive-src-update-expired.js +1 -1
  59. package/{setup-Q7JD6XJV.js → setup-5C56O3S3.js} +10 -10
  60. package/{src-EJSVFFXB.js → src-3MEJQYBG.js} +21 -7
  61. package/{src-3UQFZRM3.js → src-LH2HZ6FT.js} +2 -2
  62. package/{src-527GIT4Y.js → src-SI5YMOJI.js} +9 -9
  63. package/{token-5HFD3COV.js → token-RPQP6BV5.js} +4 -4
  64. package/{uninstall-4R7Z2FD7.js → uninstall-HDUNLNAD.js} +8 -8
  65. package/{unpublish-RBRQE53F.js → unpublish-SB647KPY.js} +4 -4
  66. package/{update-7LXJAEJN.js → update-PAIZPQPH.js} +11 -11
  67. package/{version-UHRS2KJX.js → version-5O2P2ROI.js} +7 -7
  68. package/{view-BNQKJF5L.js → view-3YVL4M7Z.js} +7 -7
  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-GYAT6NWM.js → whoami-KFXNKZOX.js} +4 -4
  75. package/chunk-KH3ERNCA.js +0 -783
  76. package/chunk-TGOC27YZ.js +0 -75
@@ -0,0 +1,2155 @@
1
+ var global = globalThis;
2
+ import {Buffer} from "node:buffer";
3
+ import {setTimeout as _vlt_setTimeout,clearTimeout as _vlt_clearTimeout,setImmediate as _vlt_setImmediate,clearImmediate as _vlt_clearImmediate,setInterval as _vlt_setInterval,clearInterval as _vlt_clearInterval} from "node:timers";
4
+ globalThis.setTimeout = _vlt_setTimeout;
5
+ globalThis.clearTimeout = _vlt_clearTimeout;
6
+ globalThis.setImmediate = _vlt_setImmediate;
7
+ globalThis.clearImmediate = _vlt_clearImmediate;
8
+ globalThis.setInterval = _vlt_setInterval;
9
+ globalThis.clearInterval = _vlt_clearInterval;
10
+ import {createRequire as _vlt_createRequire} from "node:module";
11
+ var require = _vlt_createRequire(import.meta.filename);
12
+ import {
13
+ Ct,
14
+ Qn
15
+ } from "./chunk-SRWDPPLX.js";
16
+ import {
17
+ minimatch
18
+ } from "./chunk-INEKXXUQ.js";
19
+ import {
20
+ Spec
21
+ } from "./chunk-64VFL4WI.js";
22
+ import {
23
+ parse,
24
+ stringify
25
+ } from "./chunk-HTOTG4TS.js";
26
+ import {
27
+ error
28
+ } from "./chunk-WZWDS3W4.js";
29
+ import {
30
+ __commonJS,
31
+ __require,
32
+ __toESM
33
+ } from "./chunk-PZLD7RTK.js";
34
+
35
+ // ../../node_modules/.vlt/~npm~minipass@7.1.3/node_modules/minipass/dist/commonjs/index.js
36
+ var require_commonjs = __commonJS({
37
+ "../../node_modules/.vlt/~npm~minipass@7.1.3/node_modules/minipass/dist/commonjs/index.js"(exports) {
38
+ "use strict";
39
+ var __importDefault = exports && exports.__importDefault || function(mod) {
40
+ return mod && mod.__esModule ? mod : { "default": mod };
41
+ };
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.Minipass = exports.isWritable = exports.isReadable = exports.isStream = void 0;
44
+ var proc = typeof process === "object" && process ? process : {
45
+ stdout: null,
46
+ stderr: null
47
+ };
48
+ var node_events_1 = __require("node:events");
49
+ var node_stream_1 = __importDefault(__require("node:stream"));
50
+ var node_string_decoder_1 = __require("node:string_decoder");
51
+ var isStream = (s) => !!s && typeof s === "object" && (s instanceof Minipass || s instanceof node_stream_1.default || (0, exports.isReadable)(s) || (0, exports.isWritable)(s));
52
+ exports.isStream = isStream;
53
+ var isReadable = (s) => !!s && typeof s === "object" && s instanceof node_events_1.EventEmitter && typeof s.pipe === "function" && // node core Writable streams have a pipe() method, but it throws
54
+ s.pipe !== node_stream_1.default.Writable.prototype.pipe;
55
+ exports.isReadable = isReadable;
56
+ var isWritable = (s) => !!s && typeof s === "object" && s instanceof node_events_1.EventEmitter && typeof s.write === "function" && typeof s.end === "function";
57
+ exports.isWritable = isWritable;
58
+ var EOF = /* @__PURE__ */ Symbol("EOF");
59
+ var MAYBE_EMIT_END = /* @__PURE__ */ Symbol("maybeEmitEnd");
60
+ var EMITTED_END = /* @__PURE__ */ Symbol("emittedEnd");
61
+ var EMITTING_END = /* @__PURE__ */ Symbol("emittingEnd");
62
+ var EMITTED_ERROR = /* @__PURE__ */ Symbol("emittedError");
63
+ var CLOSED = /* @__PURE__ */ Symbol("closed");
64
+ var READ = /* @__PURE__ */ Symbol("read");
65
+ var FLUSH = /* @__PURE__ */ Symbol("flush");
66
+ var FLUSHCHUNK = /* @__PURE__ */ Symbol("flushChunk");
67
+ var ENCODING = /* @__PURE__ */ Symbol("encoding");
68
+ var DECODER = /* @__PURE__ */ Symbol("decoder");
69
+ var FLOWING = /* @__PURE__ */ Symbol("flowing");
70
+ var PAUSED = /* @__PURE__ */ Symbol("paused");
71
+ var RESUME = /* @__PURE__ */ Symbol("resume");
72
+ var BUFFER = /* @__PURE__ */ Symbol("buffer");
73
+ var PIPES = /* @__PURE__ */ Symbol("pipes");
74
+ var BUFFERLENGTH = /* @__PURE__ */ Symbol("bufferLength");
75
+ var BUFFERPUSH = /* @__PURE__ */ Symbol("bufferPush");
76
+ var BUFFERSHIFT = /* @__PURE__ */ Symbol("bufferShift");
77
+ var OBJECTMODE = /* @__PURE__ */ Symbol("objectMode");
78
+ var DESTROYED = /* @__PURE__ */ Symbol("destroyed");
79
+ var ERROR = /* @__PURE__ */ Symbol("error");
80
+ var EMITDATA = /* @__PURE__ */ Symbol("emitData");
81
+ var EMITEND = /* @__PURE__ */ Symbol("emitEnd");
82
+ var EMITEND2 = /* @__PURE__ */ Symbol("emitEnd2");
83
+ var ASYNC = /* @__PURE__ */ Symbol("async");
84
+ var ABORT = /* @__PURE__ */ Symbol("abort");
85
+ var ABORTED = /* @__PURE__ */ Symbol("aborted");
86
+ var SIGNAL = /* @__PURE__ */ Symbol("signal");
87
+ var DATALISTENERS = /* @__PURE__ */ Symbol("dataListeners");
88
+ var DISCARDED = /* @__PURE__ */ Symbol("discarded");
89
+ var defer = (fn) => Promise.resolve().then(fn);
90
+ var nodefer = (fn) => fn();
91
+ var isEndish = (ev) => ev === "end" || ev === "finish" || ev === "prefinish";
92
+ var isArrayBufferLike = (b) => b instanceof ArrayBuffer || !!b && typeof b === "object" && b.constructor && b.constructor.name === "ArrayBuffer" && b.byteLength >= 0;
93
+ var isArrayBufferView = (b) => !Buffer.isBuffer(b) && ArrayBuffer.isView(b);
94
+ var Pipe = class {
95
+ src;
96
+ dest;
97
+ opts;
98
+ ondrain;
99
+ constructor(src, dest, opts) {
100
+ this.src = src;
101
+ this.dest = dest;
102
+ this.opts = opts;
103
+ this.ondrain = () => src[RESUME]();
104
+ this.dest.on("drain", this.ondrain);
105
+ }
106
+ unpipe() {
107
+ this.dest.removeListener("drain", this.ondrain);
108
+ }
109
+ // only here for the prototype
110
+ /* c8 ignore start */
111
+ proxyErrors(_er) {
112
+ }
113
+ /* c8 ignore stop */
114
+ end() {
115
+ this.unpipe();
116
+ if (this.opts.end)
117
+ this.dest.end();
118
+ }
119
+ };
120
+ var PipeProxyErrors = class extends Pipe {
121
+ unpipe() {
122
+ this.src.removeListener("error", this.proxyErrors);
123
+ super.unpipe();
124
+ }
125
+ constructor(src, dest, opts) {
126
+ super(src, dest, opts);
127
+ this.proxyErrors = (er) => this.dest.emit("error", er);
128
+ src.on("error", this.proxyErrors);
129
+ }
130
+ };
131
+ var isObjectModeOptions = (o) => !!o.objectMode;
132
+ var isEncodingOptions = (o) => !o.objectMode && !!o.encoding && o.encoding !== "buffer";
133
+ var Minipass = class extends node_events_1.EventEmitter {
134
+ [FLOWING] = false;
135
+ [PAUSED] = false;
136
+ [PIPES] = [];
137
+ [BUFFER] = [];
138
+ [OBJECTMODE];
139
+ [ENCODING];
140
+ [ASYNC];
141
+ [DECODER];
142
+ [EOF] = false;
143
+ [EMITTED_END] = false;
144
+ [EMITTING_END] = false;
145
+ [CLOSED] = false;
146
+ [EMITTED_ERROR] = null;
147
+ [BUFFERLENGTH] = 0;
148
+ [DESTROYED] = false;
149
+ [SIGNAL];
150
+ [ABORTED] = false;
151
+ [DATALISTENERS] = 0;
152
+ [DISCARDED] = false;
153
+ /**
154
+ * true if the stream can be written
155
+ */
156
+ writable = true;
157
+ /**
158
+ * true if the stream can be read
159
+ */
160
+ readable = true;
161
+ /**
162
+ * If `RType` is Buffer, then options do not need to be provided.
163
+ * Otherwise, an options object must be provided to specify either
164
+ * {@link Minipass.SharedOptions.objectMode} or
165
+ * {@link Minipass.SharedOptions.encoding}, as appropriate.
166
+ */
167
+ constructor(...args) {
168
+ const options = args[0] || {};
169
+ super();
170
+ if (options.objectMode && typeof options.encoding === "string") {
171
+ throw new TypeError("Encoding and objectMode may not be used together");
172
+ }
173
+ if (isObjectModeOptions(options)) {
174
+ this[OBJECTMODE] = true;
175
+ this[ENCODING] = null;
176
+ } else if (isEncodingOptions(options)) {
177
+ this[ENCODING] = options.encoding;
178
+ this[OBJECTMODE] = false;
179
+ } else {
180
+ this[OBJECTMODE] = false;
181
+ this[ENCODING] = null;
182
+ }
183
+ this[ASYNC] = !!options.async;
184
+ this[DECODER] = this[ENCODING] ? new node_string_decoder_1.StringDecoder(this[ENCODING]) : null;
185
+ if (options && options.debugExposeBuffer === true) {
186
+ Object.defineProperty(this, "buffer", { get: () => this[BUFFER] });
187
+ }
188
+ if (options && options.debugExposePipes === true) {
189
+ Object.defineProperty(this, "pipes", { get: () => this[PIPES] });
190
+ }
191
+ const { signal } = options;
192
+ if (signal) {
193
+ this[SIGNAL] = signal;
194
+ if (signal.aborted) {
195
+ this[ABORT]();
196
+ } else {
197
+ signal.addEventListener("abort", () => this[ABORT]());
198
+ }
199
+ }
200
+ }
201
+ /**
202
+ * The amount of data stored in the buffer waiting to be read.
203
+ *
204
+ * For Buffer strings, this will be the total byte length.
205
+ * For string encoding streams, this will be the string character length,
206
+ * according to JavaScript's `string.length` logic.
207
+ * For objectMode streams, this is a count of the items waiting to be
208
+ * emitted.
209
+ */
210
+ get bufferLength() {
211
+ return this[BUFFERLENGTH];
212
+ }
213
+ /**
214
+ * The `BufferEncoding` currently in use, or `null`
215
+ */
216
+ get encoding() {
217
+ return this[ENCODING];
218
+ }
219
+ /**
220
+ * @deprecated - This is a read only property
221
+ */
222
+ set encoding(_enc) {
223
+ throw new Error("Encoding must be set at instantiation time");
224
+ }
225
+ /**
226
+ * @deprecated - Encoding may only be set at instantiation time
227
+ */
228
+ setEncoding(_enc) {
229
+ throw new Error("Encoding must be set at instantiation time");
230
+ }
231
+ /**
232
+ * True if this is an objectMode stream
233
+ */
234
+ get objectMode() {
235
+ return this[OBJECTMODE];
236
+ }
237
+ /**
238
+ * @deprecated - This is a read-only property
239
+ */
240
+ set objectMode(_om) {
241
+ throw new Error("objectMode must be set at instantiation time");
242
+ }
243
+ /**
244
+ * true if this is an async stream
245
+ */
246
+ get ["async"]() {
247
+ return this[ASYNC];
248
+ }
249
+ /**
250
+ * Set to true to make this stream async.
251
+ *
252
+ * Once set, it cannot be unset, as this would potentially cause incorrect
253
+ * behavior. Ie, a sync stream can be made async, but an async stream
254
+ * cannot be safely made sync.
255
+ */
256
+ set ["async"](a) {
257
+ this[ASYNC] = this[ASYNC] || !!a;
258
+ }
259
+ // drop everything and get out of the flow completely
260
+ [ABORT]() {
261
+ this[ABORTED] = true;
262
+ this.emit("abort", this[SIGNAL]?.reason);
263
+ this.destroy(this[SIGNAL]?.reason);
264
+ }
265
+ /**
266
+ * True if the stream has been aborted.
267
+ */
268
+ get aborted() {
269
+ return this[ABORTED];
270
+ }
271
+ /**
272
+ * No-op setter. Stream aborted status is set via the AbortSignal provided
273
+ * in the constructor options.
274
+ */
275
+ set aborted(_) {
276
+ }
277
+ write(chunk, encoding, cb) {
278
+ if (this[ABORTED])
279
+ return false;
280
+ if (this[EOF])
281
+ throw new Error("write after end");
282
+ if (this[DESTROYED]) {
283
+ this.emit("error", Object.assign(new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" }));
284
+ return true;
285
+ }
286
+ if (typeof encoding === "function") {
287
+ cb = encoding;
288
+ encoding = "utf8";
289
+ }
290
+ if (!encoding)
291
+ encoding = "utf8";
292
+ const fn = this[ASYNC] ? defer : nodefer;
293
+ if (!this[OBJECTMODE] && !Buffer.isBuffer(chunk)) {
294
+ if (isArrayBufferView(chunk)) {
295
+ chunk = Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength);
296
+ } else if (isArrayBufferLike(chunk)) {
297
+ chunk = Buffer.from(chunk);
298
+ } else if (typeof chunk !== "string") {
299
+ throw new Error("Non-contiguous data written to non-objectMode stream");
300
+ }
301
+ }
302
+ if (this[OBJECTMODE]) {
303
+ if (this[FLOWING] && this[BUFFERLENGTH] !== 0)
304
+ this[FLUSH](true);
305
+ if (this[FLOWING])
306
+ this.emit("data", chunk);
307
+ else
308
+ this[BUFFERPUSH](chunk);
309
+ if (this[BUFFERLENGTH] !== 0)
310
+ this.emit("readable");
311
+ if (cb)
312
+ fn(cb);
313
+ return this[FLOWING];
314
+ }
315
+ if (!chunk.length) {
316
+ if (this[BUFFERLENGTH] !== 0)
317
+ this.emit("readable");
318
+ if (cb)
319
+ fn(cb);
320
+ return this[FLOWING];
321
+ }
322
+ if (typeof chunk === "string" && // unless it is a string already ready for us to use
323
+ !(encoding === this[ENCODING] && !this[DECODER]?.lastNeed)) {
324
+ chunk = Buffer.from(chunk, encoding);
325
+ }
326
+ if (Buffer.isBuffer(chunk) && this[ENCODING]) {
327
+ chunk = this[DECODER].write(chunk);
328
+ }
329
+ if (this[FLOWING] && this[BUFFERLENGTH] !== 0)
330
+ this[FLUSH](true);
331
+ if (this[FLOWING])
332
+ this.emit("data", chunk);
333
+ else
334
+ this[BUFFERPUSH](chunk);
335
+ if (this[BUFFERLENGTH] !== 0)
336
+ this.emit("readable");
337
+ if (cb)
338
+ fn(cb);
339
+ return this[FLOWING];
340
+ }
341
+ /**
342
+ * Low-level explicit read method.
343
+ *
344
+ * In objectMode, the argument is ignored, and one item is returned if
345
+ * available.
346
+ *
347
+ * `n` is the number of bytes (or in the case of encoding streams,
348
+ * characters) to consume. If `n` is not provided, then the entire buffer
349
+ * is returned, or `null` is returned if no data is available.
350
+ *
351
+ * If `n` is greater that the amount of data in the internal buffer,
352
+ * then `null` is returned.
353
+ */
354
+ read(n) {
355
+ if (this[DESTROYED])
356
+ return null;
357
+ this[DISCARDED] = false;
358
+ if (this[BUFFERLENGTH] === 0 || n === 0 || n && n > this[BUFFERLENGTH]) {
359
+ this[MAYBE_EMIT_END]();
360
+ return null;
361
+ }
362
+ if (this[OBJECTMODE])
363
+ n = null;
364
+ if (this[BUFFER].length > 1 && !this[OBJECTMODE]) {
365
+ this[BUFFER] = [
366
+ this[ENCODING] ? this[BUFFER].join("") : Buffer.concat(this[BUFFER], this[BUFFERLENGTH])
367
+ ];
368
+ }
369
+ const ret = this[READ](n || null, this[BUFFER][0]);
370
+ this[MAYBE_EMIT_END]();
371
+ return ret;
372
+ }
373
+ [READ](n, chunk) {
374
+ if (this[OBJECTMODE])
375
+ this[BUFFERSHIFT]();
376
+ else {
377
+ const c = chunk;
378
+ if (n === c.length || n === null)
379
+ this[BUFFERSHIFT]();
380
+ else if (typeof c === "string") {
381
+ this[BUFFER][0] = c.slice(n);
382
+ chunk = c.slice(0, n);
383
+ this[BUFFERLENGTH] -= n;
384
+ } else {
385
+ this[BUFFER][0] = c.subarray(n);
386
+ chunk = c.subarray(0, n);
387
+ this[BUFFERLENGTH] -= n;
388
+ }
389
+ }
390
+ this.emit("data", chunk);
391
+ if (!this[BUFFER].length && !this[EOF])
392
+ this.emit("drain");
393
+ return chunk;
394
+ }
395
+ end(chunk, encoding, cb) {
396
+ if (typeof chunk === "function") {
397
+ cb = chunk;
398
+ chunk = void 0;
399
+ }
400
+ if (typeof encoding === "function") {
401
+ cb = encoding;
402
+ encoding = "utf8";
403
+ }
404
+ if (chunk !== void 0)
405
+ this.write(chunk, encoding);
406
+ if (cb)
407
+ this.once("end", cb);
408
+ this[EOF] = true;
409
+ this.writable = false;
410
+ if (this[FLOWING] || !this[PAUSED])
411
+ this[MAYBE_EMIT_END]();
412
+ return this;
413
+ }
414
+ // don't let the internal resume be overwritten
415
+ [RESUME]() {
416
+ if (this[DESTROYED])
417
+ return;
418
+ if (!this[DATALISTENERS] && !this[PIPES].length) {
419
+ this[DISCARDED] = true;
420
+ }
421
+ this[PAUSED] = false;
422
+ this[FLOWING] = true;
423
+ this.emit("resume");
424
+ if (this[BUFFER].length)
425
+ this[FLUSH]();
426
+ else if (this[EOF])
427
+ this[MAYBE_EMIT_END]();
428
+ else
429
+ this.emit("drain");
430
+ }
431
+ /**
432
+ * Resume the stream if it is currently in a paused state
433
+ *
434
+ * If called when there are no pipe destinations or `data` event listeners,
435
+ * this will place the stream in a "discarded" state, where all data will
436
+ * be thrown away. The discarded state is removed if a pipe destination or
437
+ * data handler is added, if pause() is called, or if any synchronous or
438
+ * asynchronous iteration is started.
439
+ */
440
+ resume() {
441
+ return this[RESUME]();
442
+ }
443
+ /**
444
+ * Pause the stream
445
+ */
446
+ pause() {
447
+ this[FLOWING] = false;
448
+ this[PAUSED] = true;
449
+ this[DISCARDED] = false;
450
+ }
451
+ /**
452
+ * true if the stream has been forcibly destroyed
453
+ */
454
+ get destroyed() {
455
+ return this[DESTROYED];
456
+ }
457
+ /**
458
+ * true if the stream is currently in a flowing state, meaning that
459
+ * any writes will be immediately emitted.
460
+ */
461
+ get flowing() {
462
+ return this[FLOWING];
463
+ }
464
+ /**
465
+ * true if the stream is currently in a paused state
466
+ */
467
+ get paused() {
468
+ return this[PAUSED];
469
+ }
470
+ [BUFFERPUSH](chunk) {
471
+ if (this[OBJECTMODE])
472
+ this[BUFFERLENGTH] += 1;
473
+ else
474
+ this[BUFFERLENGTH] += chunk.length;
475
+ this[BUFFER].push(chunk);
476
+ }
477
+ [BUFFERSHIFT]() {
478
+ if (this[OBJECTMODE])
479
+ this[BUFFERLENGTH] -= 1;
480
+ else
481
+ this[BUFFERLENGTH] -= this[BUFFER][0].length;
482
+ return this[BUFFER].shift();
483
+ }
484
+ [FLUSH](noDrain = false) {
485
+ do {
486
+ } while (this[FLUSHCHUNK](this[BUFFERSHIFT]()) && this[BUFFER].length);
487
+ if (!noDrain && !this[BUFFER].length && !this[EOF])
488
+ this.emit("drain");
489
+ }
490
+ [FLUSHCHUNK](chunk) {
491
+ this.emit("data", chunk);
492
+ return this[FLOWING];
493
+ }
494
+ /**
495
+ * Pipe all data emitted by this stream into the destination provided.
496
+ *
497
+ * Triggers the flow of data.
498
+ */
499
+ pipe(dest, opts) {
500
+ if (this[DESTROYED])
501
+ return dest;
502
+ this[DISCARDED] = false;
503
+ const ended = this[EMITTED_END];
504
+ opts = opts || {};
505
+ if (dest === proc.stdout || dest === proc.stderr)
506
+ opts.end = false;
507
+ else
508
+ opts.end = opts.end !== false;
509
+ opts.proxyErrors = !!opts.proxyErrors;
510
+ if (ended) {
511
+ if (opts.end)
512
+ dest.end();
513
+ } else {
514
+ this[PIPES].push(!opts.proxyErrors ? new Pipe(this, dest, opts) : new PipeProxyErrors(this, dest, opts));
515
+ if (this[ASYNC])
516
+ defer(() => this[RESUME]());
517
+ else
518
+ this[RESUME]();
519
+ }
520
+ return dest;
521
+ }
522
+ /**
523
+ * Fully unhook a piped destination stream.
524
+ *
525
+ * If the destination stream was the only consumer of this stream (ie,
526
+ * there are no other piped destinations or `'data'` event listeners)
527
+ * then the flow of data will stop until there is another consumer or
528
+ * {@link Minipass#resume} is explicitly called.
529
+ */
530
+ unpipe(dest) {
531
+ const p = this[PIPES].find((p2) => p2.dest === dest);
532
+ if (p) {
533
+ if (this[PIPES].length === 1) {
534
+ if (this[FLOWING] && this[DATALISTENERS] === 0) {
535
+ this[FLOWING] = false;
536
+ }
537
+ this[PIPES] = [];
538
+ } else
539
+ this[PIPES].splice(this[PIPES].indexOf(p), 1);
540
+ p.unpipe();
541
+ }
542
+ }
543
+ /**
544
+ * Alias for {@link Minipass#on}
545
+ */
546
+ addListener(ev, handler) {
547
+ return this.on(ev, handler);
548
+ }
549
+ /**
550
+ * Mostly identical to `EventEmitter.on`, with the following
551
+ * behavior differences to prevent data loss and unnecessary hangs:
552
+ *
553
+ * - Adding a 'data' event handler will trigger the flow of data
554
+ *
555
+ * - Adding a 'readable' event handler when there is data waiting to be read
556
+ * will cause 'readable' to be emitted immediately.
557
+ *
558
+ * - Adding an 'endish' event handler ('end', 'finish', etc.) which has
559
+ * already passed will cause the event to be emitted immediately and all
560
+ * handlers removed.
561
+ *
562
+ * - Adding an 'error' event handler after an error has been emitted will
563
+ * cause the event to be re-emitted immediately with the error previously
564
+ * raised.
565
+ */
566
+ on(ev, handler) {
567
+ const ret = super.on(ev, handler);
568
+ if (ev === "data") {
569
+ this[DISCARDED] = false;
570
+ this[DATALISTENERS]++;
571
+ if (!this[PIPES].length && !this[FLOWING]) {
572
+ this[RESUME]();
573
+ }
574
+ } else if (ev === "readable" && this[BUFFERLENGTH] !== 0) {
575
+ super.emit("readable");
576
+ } else if (isEndish(ev) && this[EMITTED_END]) {
577
+ super.emit(ev);
578
+ this.removeAllListeners(ev);
579
+ } else if (ev === "error" && this[EMITTED_ERROR]) {
580
+ const h = handler;
581
+ if (this[ASYNC])
582
+ defer(() => h.call(this, this[EMITTED_ERROR]));
583
+ else
584
+ h.call(this, this[EMITTED_ERROR]);
585
+ }
586
+ return ret;
587
+ }
588
+ /**
589
+ * Alias for {@link Minipass#off}
590
+ */
591
+ removeListener(ev, handler) {
592
+ return this.off(ev, handler);
593
+ }
594
+ /**
595
+ * Mostly identical to `EventEmitter.off`
596
+ *
597
+ * If a 'data' event handler is removed, and it was the last consumer
598
+ * (ie, there are no pipe destinations or other 'data' event listeners),
599
+ * then the flow of data will stop until there is another consumer or
600
+ * {@link Minipass#resume} is explicitly called.
601
+ */
602
+ off(ev, handler) {
603
+ const ret = super.off(ev, handler);
604
+ if (ev === "data") {
605
+ this[DATALISTENERS] = this.listeners("data").length;
606
+ if (this[DATALISTENERS] === 0 && !this[DISCARDED] && !this[PIPES].length) {
607
+ this[FLOWING] = false;
608
+ }
609
+ }
610
+ return ret;
611
+ }
612
+ /**
613
+ * Mostly identical to `EventEmitter.removeAllListeners`
614
+ *
615
+ * If all 'data' event handlers are removed, and they were the last consumer
616
+ * (ie, there are no pipe destinations), then the flow of data will stop
617
+ * until there is another consumer or {@link Minipass#resume} is explicitly
618
+ * called.
619
+ */
620
+ removeAllListeners(ev) {
621
+ const ret = super.removeAllListeners(ev);
622
+ if (ev === "data" || ev === void 0) {
623
+ this[DATALISTENERS] = 0;
624
+ if (!this[DISCARDED] && !this[PIPES].length) {
625
+ this[FLOWING] = false;
626
+ }
627
+ }
628
+ return ret;
629
+ }
630
+ /**
631
+ * true if the 'end' event has been emitted
632
+ */
633
+ get emittedEnd() {
634
+ return this[EMITTED_END];
635
+ }
636
+ [MAYBE_EMIT_END]() {
637
+ if (!this[EMITTING_END] && !this[EMITTED_END] && !this[DESTROYED] && this[BUFFER].length === 0 && this[EOF]) {
638
+ this[EMITTING_END] = true;
639
+ this.emit("end");
640
+ this.emit("prefinish");
641
+ this.emit("finish");
642
+ if (this[CLOSED])
643
+ this.emit("close");
644
+ this[EMITTING_END] = false;
645
+ }
646
+ }
647
+ /**
648
+ * Mostly identical to `EventEmitter.emit`, with the following
649
+ * behavior differences to prevent data loss and unnecessary hangs:
650
+ *
651
+ * If the stream has been destroyed, and the event is something other
652
+ * than 'close' or 'error', then `false` is returned and no handlers
653
+ * are called.
654
+ *
655
+ * If the event is 'end', and has already been emitted, then the event
656
+ * is ignored. If the stream is in a paused or non-flowing state, then
657
+ * the event will be deferred until data flow resumes. If the stream is
658
+ * async, then handlers will be called on the next tick rather than
659
+ * immediately.
660
+ *
661
+ * If the event is 'close', and 'end' has not yet been emitted, then
662
+ * the event will be deferred until after 'end' is emitted.
663
+ *
664
+ * If the event is 'error', and an AbortSignal was provided for the stream,
665
+ * and there are no listeners, then the event is ignored, matching the
666
+ * behavior of node core streams in the presense of an AbortSignal.
667
+ *
668
+ * If the event is 'finish' or 'prefinish', then all listeners will be
669
+ * removed after emitting the event, to prevent double-firing.
670
+ */
671
+ emit(ev, ...args) {
672
+ const data = args[0];
673
+ if (ev !== "error" && ev !== "close" && ev !== DESTROYED && this[DESTROYED]) {
674
+ return false;
675
+ } else if (ev === "data") {
676
+ return !this[OBJECTMODE] && !data ? false : this[ASYNC] ? (defer(() => this[EMITDATA](data)), true) : this[EMITDATA](data);
677
+ } else if (ev === "end") {
678
+ return this[EMITEND]();
679
+ } else if (ev === "close") {
680
+ this[CLOSED] = true;
681
+ if (!this[EMITTED_END] && !this[DESTROYED])
682
+ return false;
683
+ const ret2 = super.emit("close");
684
+ this.removeAllListeners("close");
685
+ return ret2;
686
+ } else if (ev === "error") {
687
+ this[EMITTED_ERROR] = data;
688
+ super.emit(ERROR, data);
689
+ const ret2 = !this[SIGNAL] || this.listeners("error").length ? super.emit("error", data) : false;
690
+ this[MAYBE_EMIT_END]();
691
+ return ret2;
692
+ } else if (ev === "resume") {
693
+ const ret2 = super.emit("resume");
694
+ this[MAYBE_EMIT_END]();
695
+ return ret2;
696
+ } else if (ev === "finish" || ev === "prefinish") {
697
+ const ret2 = super.emit(ev);
698
+ this.removeAllListeners(ev);
699
+ return ret2;
700
+ }
701
+ const ret = super.emit(ev, ...args);
702
+ this[MAYBE_EMIT_END]();
703
+ return ret;
704
+ }
705
+ [EMITDATA](data) {
706
+ for (const p of this[PIPES]) {
707
+ if (p.dest.write(data) === false)
708
+ this.pause();
709
+ }
710
+ const ret = this[DISCARDED] ? false : super.emit("data", data);
711
+ this[MAYBE_EMIT_END]();
712
+ return ret;
713
+ }
714
+ [EMITEND]() {
715
+ if (this[EMITTED_END])
716
+ return false;
717
+ this[EMITTED_END] = true;
718
+ this.readable = false;
719
+ return this[ASYNC] ? (defer(() => this[EMITEND2]()), true) : this[EMITEND2]();
720
+ }
721
+ [EMITEND2]() {
722
+ if (this[DECODER]) {
723
+ const data = this[DECODER].end();
724
+ if (data) {
725
+ for (const p of this[PIPES]) {
726
+ p.dest.write(data);
727
+ }
728
+ if (!this[DISCARDED])
729
+ super.emit("data", data);
730
+ }
731
+ }
732
+ for (const p of this[PIPES]) {
733
+ p.end();
734
+ }
735
+ const ret = super.emit("end");
736
+ this.removeAllListeners("end");
737
+ return ret;
738
+ }
739
+ /**
740
+ * Return a Promise that resolves to an array of all emitted data once
741
+ * the stream ends.
742
+ */
743
+ async collect() {
744
+ const buf = Object.assign([], {
745
+ dataLength: 0
746
+ });
747
+ if (!this[OBJECTMODE])
748
+ buf.dataLength = 0;
749
+ const p = this.promise();
750
+ this.on("data", (c) => {
751
+ buf.push(c);
752
+ if (!this[OBJECTMODE])
753
+ buf.dataLength += c.length;
754
+ });
755
+ await p;
756
+ return buf;
757
+ }
758
+ /**
759
+ * Return a Promise that resolves to the concatenation of all emitted data
760
+ * once the stream ends.
761
+ *
762
+ * Not allowed on objectMode streams.
763
+ */
764
+ async concat() {
765
+ if (this[OBJECTMODE]) {
766
+ throw new Error("cannot concat in objectMode");
767
+ }
768
+ const buf = await this.collect();
769
+ return this[ENCODING] ? buf.join("") : Buffer.concat(buf, buf.dataLength);
770
+ }
771
+ /**
772
+ * Return a void Promise that resolves once the stream ends.
773
+ */
774
+ async promise() {
775
+ return new Promise((resolve, reject) => {
776
+ this.on(DESTROYED, () => reject(new Error("stream destroyed")));
777
+ this.on("error", (er) => reject(er));
778
+ this.on("end", () => resolve());
779
+ });
780
+ }
781
+ /**
782
+ * Asynchronous `for await of` iteration.
783
+ *
784
+ * This will continue emitting all chunks until the stream terminates.
785
+ */
786
+ [Symbol.asyncIterator]() {
787
+ this[DISCARDED] = false;
788
+ let stopped = false;
789
+ const stop = async () => {
790
+ this.pause();
791
+ stopped = true;
792
+ return { value: void 0, done: true };
793
+ };
794
+ const next = () => {
795
+ if (stopped)
796
+ return stop();
797
+ const res = this.read();
798
+ if (res !== null)
799
+ return Promise.resolve({ done: false, value: res });
800
+ if (this[EOF])
801
+ return stop();
802
+ let resolve;
803
+ let reject;
804
+ const onerr = (er) => {
805
+ this.off("data", ondata);
806
+ this.off("end", onend);
807
+ this.off(DESTROYED, ondestroy);
808
+ stop();
809
+ reject(er);
810
+ };
811
+ const ondata = (value) => {
812
+ this.off("error", onerr);
813
+ this.off("end", onend);
814
+ this.off(DESTROYED, ondestroy);
815
+ this.pause();
816
+ resolve({ value, done: !!this[EOF] });
817
+ };
818
+ const onend = () => {
819
+ this.off("error", onerr);
820
+ this.off("data", ondata);
821
+ this.off(DESTROYED, ondestroy);
822
+ stop();
823
+ resolve({ done: true, value: void 0 });
824
+ };
825
+ const ondestroy = () => onerr(new Error("stream destroyed"));
826
+ return new Promise((res2, rej) => {
827
+ reject = rej;
828
+ resolve = res2;
829
+ this.once(DESTROYED, ondestroy);
830
+ this.once("error", onerr);
831
+ this.once("end", onend);
832
+ this.once("data", ondata);
833
+ });
834
+ };
835
+ return {
836
+ next,
837
+ throw: stop,
838
+ return: stop,
839
+ [Symbol.asyncIterator]() {
840
+ return this;
841
+ },
842
+ [Symbol.asyncDispose]: async () => {
843
+ }
844
+ };
845
+ }
846
+ /**
847
+ * Synchronous `for of` iteration.
848
+ *
849
+ * The iteration will terminate when the internal buffer runs out, even
850
+ * if the stream has not yet terminated.
851
+ */
852
+ [Symbol.iterator]() {
853
+ this[DISCARDED] = false;
854
+ let stopped = false;
855
+ const stop = () => {
856
+ this.pause();
857
+ this.off(ERROR, stop);
858
+ this.off(DESTROYED, stop);
859
+ this.off("end", stop);
860
+ stopped = true;
861
+ return { done: true, value: void 0 };
862
+ };
863
+ const next = () => {
864
+ if (stopped)
865
+ return stop();
866
+ const value = this.read();
867
+ return value === null ? stop() : { done: false, value };
868
+ };
869
+ this.once("end", stop);
870
+ this.once(ERROR, stop);
871
+ this.once(DESTROYED, stop);
872
+ return {
873
+ next,
874
+ throw: stop,
875
+ return: stop,
876
+ [Symbol.iterator]() {
877
+ return this;
878
+ },
879
+ [Symbol.dispose]: () => {
880
+ }
881
+ };
882
+ }
883
+ /**
884
+ * Destroy a stream, preventing it from being used for any further purpose.
885
+ *
886
+ * If the stream has a `close()` method, then it will be called on
887
+ * destruction.
888
+ *
889
+ * After destruction, any attempt to write data, read data, or emit most
890
+ * events will be ignored.
891
+ *
892
+ * If an error argument is provided, then it will be emitted in an
893
+ * 'error' event.
894
+ */
895
+ destroy(er) {
896
+ if (this[DESTROYED]) {
897
+ if (er)
898
+ this.emit("error", er);
899
+ else
900
+ this.emit(DESTROYED);
901
+ return this;
902
+ }
903
+ this[DESTROYED] = true;
904
+ this[DISCARDED] = true;
905
+ this[BUFFER].length = 0;
906
+ this[BUFFERLENGTH] = 0;
907
+ const wc = this;
908
+ if (typeof wc.close === "function" && !this[CLOSED])
909
+ wc.close();
910
+ if (er)
911
+ this.emit("error", er);
912
+ else
913
+ this.emit(DESTROYED);
914
+ return this;
915
+ }
916
+ /**
917
+ * Alias for {@link isStream}
918
+ *
919
+ * Former export location, maintained for backwards compatibility.
920
+ *
921
+ * @deprecated
922
+ */
923
+ static get isStream() {
924
+ return exports.isStream;
925
+ }
926
+ };
927
+ exports.Minipass = Minipass;
928
+ }
929
+ });
930
+
931
+ // ../../node_modules/.vlt/~npm~ssri@13.0.1/node_modules/ssri/lib/index.js
932
+ var require_lib = __commonJS({
933
+ "../../node_modules/.vlt/~npm~ssri@13.0.1/node_modules/ssri/lib/index.js"(exports, module) {
934
+ "use strict";
935
+ var crypto = __require("node:crypto");
936
+ var { Minipass } = require_commonjs();
937
+ var SPEC_ALGORITHMS = ["sha512", "sha384", "sha256"];
938
+ var DEFAULT_ALGORITHMS = ["sha512"];
939
+ var NODE_HASHES = crypto.getHashes();
940
+ var BASE64_REGEX = /^[a-z0-9+/]+(?:=?=?)$/i;
941
+ var SRI_REGEX = /^([a-z0-9]+)-([^?]+)(\?[?\S*]*)?$/;
942
+ var STRICT_SRI_REGEX = /^([a-z0-9]+)-([A-Za-z0-9+/=]{44,88})(\?[\x21-\x7E]*)?$/;
943
+ var VCHAR_REGEX = /^[\x21-\x7E]+$/;
944
+ var DEFAULT_PRIORITY = [
945
+ "md5",
946
+ "whirlpool",
947
+ "sha1",
948
+ "sha224",
949
+ "sha256",
950
+ "sha384",
951
+ "sha512",
952
+ // TODO - it's unclear _which_ of these Node will actually use as its name for the algorithm, so we guesswork it based on the OpenSSL names.
953
+ "sha3",
954
+ "sha3-256",
955
+ "sha3-384",
956
+ "sha3-512",
957
+ "sha3_256",
958
+ "sha3_384",
959
+ "sha3_512"
960
+ ].filter((algo) => NODE_HASHES.includes(algo));
961
+ var getOptString = (options) => options?.length ? `?${options.join("?")}` : "";
962
+ var IntegrityStream = class extends Minipass {
963
+ #emittedIntegrity;
964
+ #emittedSize;
965
+ #emittedVerified;
966
+ constructor(opts) {
967
+ super();
968
+ this.size = 0;
969
+ this.opts = opts;
970
+ this.#getOptions();
971
+ if (opts?.algorithms) {
972
+ this.algorithms = [...opts.algorithms];
973
+ } else {
974
+ this.algorithms = [...DEFAULT_ALGORITHMS];
975
+ }
976
+ if (this.algorithm !== null && !this.algorithms.includes(this.algorithm)) {
977
+ this.algorithms.push(this.algorithm);
978
+ }
979
+ this.hashes = this.algorithms.map(crypto.createHash);
980
+ }
981
+ #getOptions() {
982
+ this.sri = this.opts?.integrity ? parse2(this.opts?.integrity, this.opts) : null;
983
+ this.expectedSize = this.opts?.size;
984
+ if (!this.sri) {
985
+ this.algorithm = null;
986
+ } else if (this.sri.isHash) {
987
+ this.goodSri = true;
988
+ this.algorithm = this.sri.algorithm;
989
+ } else {
990
+ this.goodSri = !this.sri.isEmpty();
991
+ this.algorithm = this.sri.pickAlgorithm(this.opts);
992
+ }
993
+ this.digests = this.goodSri ? this.sri[this.algorithm] : null;
994
+ this.optString = getOptString(this.opts?.options);
995
+ }
996
+ on(ev, handler) {
997
+ if (ev === "size" && this.#emittedSize) {
998
+ return handler(this.#emittedSize);
999
+ }
1000
+ if (ev === "integrity" && this.#emittedIntegrity) {
1001
+ return handler(this.#emittedIntegrity);
1002
+ }
1003
+ if (ev === "verified" && this.#emittedVerified) {
1004
+ return handler(this.#emittedVerified);
1005
+ }
1006
+ return super.on(ev, handler);
1007
+ }
1008
+ emit(ev, data) {
1009
+ if (ev === "end") {
1010
+ this.#onEnd();
1011
+ }
1012
+ return super.emit(ev, data);
1013
+ }
1014
+ write(data) {
1015
+ this.size += data.length;
1016
+ this.hashes.forEach((h) => h.update(data));
1017
+ return super.write(data);
1018
+ }
1019
+ #onEnd() {
1020
+ if (!this.goodSri) {
1021
+ this.#getOptions();
1022
+ }
1023
+ const newSri = parse2(this.hashes.map((h, i) => {
1024
+ return `${this.algorithms[i]}-${h.digest("base64")}${this.optString}`;
1025
+ }).join(" "), this.opts);
1026
+ const match = this.goodSri && newSri.match(this.sri, this.opts);
1027
+ if (typeof this.expectedSize === "number" && this.size !== this.expectedSize) {
1028
+ const err = new Error(`stream size mismatch when checking ${this.sri}.
1029
+ Wanted: ${this.expectedSize}
1030
+ Found: ${this.size}`);
1031
+ err.code = "EBADSIZE";
1032
+ err.found = this.size;
1033
+ err.expected = this.expectedSize;
1034
+ err.sri = this.sri;
1035
+ this.emit("error", err);
1036
+ } else if (this.sri && !match) {
1037
+ const err = new Error(`${this.sri} integrity checksum failed when using ${this.algorithm}: wanted ${this.digests} but got ${newSri}. (${this.size} bytes)`);
1038
+ err.code = "EINTEGRITY";
1039
+ err.found = newSri;
1040
+ err.expected = this.digests;
1041
+ err.algorithm = this.algorithm;
1042
+ err.sri = this.sri;
1043
+ this.emit("error", err);
1044
+ } else {
1045
+ this.#emittedSize = this.size;
1046
+ this.emit("size", this.size);
1047
+ this.#emittedIntegrity = newSri;
1048
+ this.emit("integrity", newSri);
1049
+ if (match) {
1050
+ this.#emittedVerified = match;
1051
+ this.emit("verified", match);
1052
+ }
1053
+ }
1054
+ }
1055
+ };
1056
+ var Hash = class {
1057
+ get isHash() {
1058
+ return true;
1059
+ }
1060
+ constructor(hash, opts) {
1061
+ const strict = opts?.strict;
1062
+ this.source = hash.trim();
1063
+ this.digest = "";
1064
+ this.algorithm = "";
1065
+ this.options = [];
1066
+ const match = this.source.match(
1067
+ strict ? STRICT_SRI_REGEX : SRI_REGEX
1068
+ );
1069
+ if (!match) {
1070
+ return;
1071
+ }
1072
+ if (strict && !SPEC_ALGORITHMS.includes(match[1])) {
1073
+ return;
1074
+ }
1075
+ if (!NODE_HASHES.includes(match[1])) {
1076
+ return;
1077
+ }
1078
+ this.algorithm = match[1];
1079
+ this.digest = match[2];
1080
+ const rawOpts = match[3];
1081
+ if (rawOpts) {
1082
+ this.options = rawOpts.slice(1).split("?");
1083
+ }
1084
+ }
1085
+ hexDigest() {
1086
+ return this.digest && Buffer.from(this.digest, "base64").toString("hex");
1087
+ }
1088
+ toJSON() {
1089
+ return this.toString();
1090
+ }
1091
+ match(integrity, opts) {
1092
+ const other = parse2(integrity, opts);
1093
+ if (!other) {
1094
+ return false;
1095
+ }
1096
+ if (other.isIntegrity) {
1097
+ const algo = other.pickAlgorithm(opts, [this.algorithm]);
1098
+ if (!algo) {
1099
+ return false;
1100
+ }
1101
+ const foundHash = other[algo].find((hash) => hash.digest === this.digest);
1102
+ if (foundHash) {
1103
+ return foundHash;
1104
+ }
1105
+ return false;
1106
+ }
1107
+ return other.digest === this.digest ? other : false;
1108
+ }
1109
+ toString(opts) {
1110
+ if (opts?.strict) {
1111
+ if (!// The spec has very restricted productions for algorithms.
1112
+ // https://www.w3.org/TR/CSP2/#source-list-syntax
1113
+ (SPEC_ALGORITHMS.includes(this.algorithm) && // Usually, if someone insists on using a "different" base64, we leave it as-is, since there are multiple standards, and the specified is not a URL-safe variant.
1114
+ // https://www.w3.org/TR/CSP2/#base64_value
1115
+ this.digest.match(BASE64_REGEX) && // Option syntax is strictly visual chars.
1116
+ // https://w3c.github.io/webappsec-subresource-integrity/#grammardef-option-expression
1117
+ // https://tools.ietf.org/html/rfc5234#appendix-B.1
1118
+ this.options.every((opt) => opt.match(VCHAR_REGEX)))) {
1119
+ return "";
1120
+ }
1121
+ }
1122
+ return `${this.algorithm}-${this.digest}${getOptString(this.options)}`;
1123
+ }
1124
+ };
1125
+ function integrityHashToString(toString, sep, opts, hashes) {
1126
+ const toStringIsNotEmpty = toString !== "";
1127
+ let shouldAddFirstSep = false;
1128
+ let complement = "";
1129
+ const lastIndex = hashes.length - 1;
1130
+ for (let i = 0; i < lastIndex; i++) {
1131
+ const hashString = Hash.prototype.toString.call(hashes[i], opts);
1132
+ if (hashString) {
1133
+ shouldAddFirstSep = true;
1134
+ complement += hashString;
1135
+ complement += sep;
1136
+ }
1137
+ }
1138
+ const finalHashString = Hash.prototype.toString.call(hashes[lastIndex], opts);
1139
+ if (finalHashString) {
1140
+ shouldAddFirstSep = true;
1141
+ complement += finalHashString;
1142
+ }
1143
+ if (toStringIsNotEmpty && shouldAddFirstSep) {
1144
+ return toString + sep + complement;
1145
+ }
1146
+ return toString + complement;
1147
+ }
1148
+ var Integrity = class {
1149
+ get isIntegrity() {
1150
+ return true;
1151
+ }
1152
+ toJSON() {
1153
+ return this.toString();
1154
+ }
1155
+ isEmpty() {
1156
+ return Object.keys(this).length === 0;
1157
+ }
1158
+ toString(opts) {
1159
+ let sep = opts?.sep || " ";
1160
+ let toString = "";
1161
+ if (opts?.strict) {
1162
+ sep = sep.replace(/\S+/g, " ");
1163
+ for (const hash of SPEC_ALGORITHMS) {
1164
+ if (this[hash]) {
1165
+ toString = integrityHashToString(toString, sep, opts, this[hash]);
1166
+ }
1167
+ }
1168
+ } else {
1169
+ for (const hash of Object.keys(this)) {
1170
+ toString = integrityHashToString(toString, sep, opts, this[hash]);
1171
+ }
1172
+ }
1173
+ return toString;
1174
+ }
1175
+ concat(integrity, opts) {
1176
+ const other = typeof integrity === "string" ? integrity : stringify2(integrity, opts);
1177
+ return parse2(`${this.toString(opts)} ${other}`, opts);
1178
+ }
1179
+ hexDigest() {
1180
+ return parse2(this, { single: true }).hexDigest();
1181
+ }
1182
+ // add additional hashes to an integrity value, but prevent *changing* an existing integrity hash.
1183
+ merge(integrity, opts) {
1184
+ const other = parse2(integrity, opts);
1185
+ for (const algo in other) {
1186
+ if (this[algo]) {
1187
+ if (!this[algo].find((hash) => other[algo].find((otherhash) => hash.digest === otherhash.digest))) {
1188
+ throw new Error("hashes do not match, cannot update integrity");
1189
+ }
1190
+ } else {
1191
+ this[algo] = other[algo];
1192
+ }
1193
+ }
1194
+ }
1195
+ match(integrity, opts) {
1196
+ const other = parse2(integrity, opts);
1197
+ if (!other) {
1198
+ return false;
1199
+ }
1200
+ const algo = other.pickAlgorithm(opts, Object.keys(this));
1201
+ return !!algo && this[algo].find(
1202
+ (hash) => other[algo].find(
1203
+ (otherhash) => hash.digest === otherhash.digest
1204
+ )
1205
+ ) || false;
1206
+ }
1207
+ // Pick the highest priority algorithm present, optionally also limited to a set of hashes found in another integrity.
1208
+ // When limiting it may return nothing.
1209
+ pickAlgorithm(opts, hashes) {
1210
+ const pickAlgorithm = opts?.pickAlgorithm || getPrioritizedHash;
1211
+ let keys = Object.keys(this);
1212
+ if (hashes?.length) {
1213
+ keys = keys.filter((k) => hashes.includes(k));
1214
+ }
1215
+ if (keys.length) {
1216
+ return keys.reduce((acc, algo) => pickAlgorithm(acc, algo) || acc);
1217
+ }
1218
+ return null;
1219
+ }
1220
+ };
1221
+ module.exports.parse = parse2;
1222
+ function parse2(sri, opts) {
1223
+ if (!sri) {
1224
+ return null;
1225
+ }
1226
+ if (typeof sri === "string") {
1227
+ return _parse(sri, opts);
1228
+ } else if (sri.algorithm && sri.digest) {
1229
+ const fullSri = new Integrity();
1230
+ fullSri[sri.algorithm] = [sri];
1231
+ return _parse(stringify2(fullSri, opts), opts);
1232
+ } else {
1233
+ return _parse(stringify2(sri, opts), opts);
1234
+ }
1235
+ }
1236
+ function _parse(integrity, opts) {
1237
+ if (opts?.single) {
1238
+ return new Hash(integrity, opts);
1239
+ }
1240
+ const hashes = integrity.trim().split(/\s+/).reduce((acc, string) => {
1241
+ const hash = new Hash(string, opts);
1242
+ if (hash.algorithm && hash.digest) {
1243
+ const algo = hash.algorithm;
1244
+ if (!Object.keys(acc).includes(algo)) {
1245
+ acc[algo] = [];
1246
+ }
1247
+ acc[algo].push(hash);
1248
+ }
1249
+ return acc;
1250
+ }, new Integrity());
1251
+ return hashes.isEmpty() ? null : hashes;
1252
+ }
1253
+ module.exports.stringify = stringify2;
1254
+ function stringify2(obj, opts) {
1255
+ if (obj.algorithm && obj.digest) {
1256
+ return Hash.prototype.toString.call(obj, opts);
1257
+ } else if (typeof obj === "string") {
1258
+ return stringify2(parse2(obj, opts), opts);
1259
+ } else {
1260
+ return Integrity.prototype.toString.call(obj, opts);
1261
+ }
1262
+ }
1263
+ module.exports.fromHex = fromHex;
1264
+ function fromHex(hexDigest, algorithm, opts) {
1265
+ const optString = getOptString(opts?.options);
1266
+ return parse2(
1267
+ `${algorithm}-${Buffer.from(hexDigest, "hex").toString("base64")}${optString}`,
1268
+ opts
1269
+ );
1270
+ }
1271
+ module.exports.fromData = fromData2;
1272
+ function fromData2(data, opts) {
1273
+ const algorithms = opts?.algorithms || [...DEFAULT_ALGORITHMS];
1274
+ const optString = getOptString(opts?.options);
1275
+ return algorithms.reduce((acc, algo) => {
1276
+ const digest = crypto.createHash(algo).update(data).digest("base64");
1277
+ const hash = new Hash(
1278
+ `${algo}-${digest}${optString}`,
1279
+ opts
1280
+ );
1281
+ if (hash.algorithm && hash.digest) {
1282
+ const hashAlgo = hash.algorithm;
1283
+ if (!acc[hashAlgo]) {
1284
+ acc[hashAlgo] = [];
1285
+ }
1286
+ acc[hashAlgo].push(hash);
1287
+ }
1288
+ return acc;
1289
+ }, new Integrity());
1290
+ }
1291
+ module.exports.fromStream = fromStream;
1292
+ function fromStream(stream, opts) {
1293
+ const istream = integrityStream(opts);
1294
+ return new Promise((resolve, reject) => {
1295
+ stream.pipe(istream);
1296
+ stream.on("error", reject);
1297
+ istream.on("error", reject);
1298
+ let sri;
1299
+ istream.on("integrity", (s) => {
1300
+ sri = s;
1301
+ });
1302
+ istream.on("end", () => resolve(sri));
1303
+ istream.resume();
1304
+ });
1305
+ }
1306
+ module.exports.checkData = checkData;
1307
+ function checkData(data, sri, opts) {
1308
+ sri = parse2(sri, opts);
1309
+ if (!sri || !Object.keys(sri).length) {
1310
+ if (opts?.error) {
1311
+ throw Object.assign(
1312
+ new Error("No valid integrity hashes to check against"),
1313
+ {
1314
+ code: "EINTEGRITY"
1315
+ }
1316
+ );
1317
+ } else {
1318
+ return false;
1319
+ }
1320
+ }
1321
+ const algorithm = sri.pickAlgorithm(opts);
1322
+ const digest = crypto.createHash(algorithm).update(data).digest("base64");
1323
+ const newSri = parse2({ algorithm, digest });
1324
+ const match = newSri.match(sri, opts);
1325
+ opts = opts || {};
1326
+ if (match || !opts.error) {
1327
+ return match;
1328
+ } else if (typeof opts.size === "number" && data.length !== opts.size) {
1329
+ const err = new Error(`data size mismatch when checking ${sri}.
1330
+ Wanted: ${opts.size}
1331
+ Found: ${data.length}`);
1332
+ err.code = "EBADSIZE";
1333
+ err.found = data.length;
1334
+ err.expected = opts.size;
1335
+ err.sri = sri;
1336
+ throw err;
1337
+ } else {
1338
+ const err = new Error(`Integrity checksum failed when using ${algorithm}: Wanted ${sri}, but got ${newSri}. (${data.length} bytes)`);
1339
+ err.code = "EINTEGRITY";
1340
+ err.found = newSri;
1341
+ err.expected = sri;
1342
+ err.algorithm = algorithm;
1343
+ err.sri = sri;
1344
+ throw err;
1345
+ }
1346
+ }
1347
+ module.exports.checkStream = checkStream;
1348
+ function checkStream(stream, sri, opts) {
1349
+ opts = opts || /* @__PURE__ */ Object.create(null);
1350
+ opts.integrity = sri;
1351
+ sri = parse2(sri, opts);
1352
+ if (!sri || !Object.keys(sri).length) {
1353
+ return Promise.reject(Object.assign(
1354
+ new Error("No valid integrity hashes to check against"),
1355
+ {
1356
+ code: "EINTEGRITY"
1357
+ }
1358
+ ));
1359
+ }
1360
+ const checker = integrityStream(opts);
1361
+ return new Promise((resolve, reject) => {
1362
+ stream.pipe(checker);
1363
+ stream.on("error", reject);
1364
+ checker.on("error", reject);
1365
+ let verified;
1366
+ checker.on("verified", (s) => {
1367
+ verified = s;
1368
+ });
1369
+ checker.on("end", () => resolve(verified));
1370
+ checker.resume();
1371
+ });
1372
+ }
1373
+ module.exports.integrityStream = integrityStream;
1374
+ function integrityStream(opts = /* @__PURE__ */ Object.create(null)) {
1375
+ return new IntegrityStream(opts);
1376
+ }
1377
+ module.exports.create = createIntegrity;
1378
+ function createIntegrity(opts) {
1379
+ const algorithms = opts?.algorithms || [...DEFAULT_ALGORITHMS];
1380
+ const optString = getOptString(opts?.options);
1381
+ const hashes = algorithms.map(crypto.createHash);
1382
+ return {
1383
+ update: function(chunk, enc) {
1384
+ hashes.forEach((h) => h.update(chunk, enc));
1385
+ return this;
1386
+ },
1387
+ digest: function() {
1388
+ const integrity = algorithms.reduce((acc, algo) => {
1389
+ const digest = hashes.shift().digest("base64");
1390
+ const hash = new Hash(`${algo}-${digest}${optString}`, opts);
1391
+ if (!acc[hash.algorithm]) {
1392
+ acc[hash.algorithm] = [];
1393
+ }
1394
+ acc[hash.algorithm].push(hash);
1395
+ return acc;
1396
+ }, new Integrity());
1397
+ return integrity;
1398
+ }
1399
+ };
1400
+ }
1401
+ function getPrioritizedHash(algo1, algo2) {
1402
+ return DEFAULT_PRIORITY.indexOf(algo1.toLowerCase()) >= DEFAULT_PRIORITY.indexOf(algo2.toLowerCase()) ? algo1 : algo2;
1403
+ }
1404
+ }
1405
+ });
1406
+
1407
+ // ../../node_modules/.vlt/~npm~ignore@7.0.6/node_modules/ignore/index.js
1408
+ var require_ignore = __commonJS({
1409
+ "../../node_modules/.vlt/~npm~ignore@7.0.6/node_modules/ignore/index.js"(exports, module) {
1410
+ function makeArray(subject) {
1411
+ return Array.isArray(subject) ? subject : [subject];
1412
+ }
1413
+ var UNDEFINED = void 0;
1414
+ var EMPTY = "";
1415
+ var SPACE = " ";
1416
+ var ESCAPE = "\\";
1417
+ var REGEX_TEST_BLANK_LINE = /^\s+$/;
1418
+ var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
1419
+ var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
1420
+ var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
1421
+ var REGEX_SPLITALL_CRLF = /\r?\n/g;
1422
+ var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
1423
+ var REGEX_TEST_TRAILING_SLASH = /\/$/;
1424
+ var SLASH = "/";
1425
+ var TMP_KEY_IGNORE = "node-ignore";
1426
+ if (typeof Symbol !== "undefined") {
1427
+ TMP_KEY_IGNORE = /* @__PURE__ */ Symbol.for("node-ignore");
1428
+ }
1429
+ var KEY_IGNORE = TMP_KEY_IGNORE;
1430
+ var define = (object, key, value) => {
1431
+ Object.defineProperty(object, key, { value });
1432
+ return value;
1433
+ };
1434
+ var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
1435
+ var RETURN_FALSE = () => false;
1436
+ var sanitizeRange = (range) => range.replace(
1437
+ REGEX_REGEXP_RANGE,
1438
+ (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY
1439
+ );
1440
+ var negateRange = (range) => range.startsWith("!") || range.startsWith("\\^") ? `^${range.slice(range[0] === "!" ? 1 : 2)}` : range;
1441
+ var cleanRangeBackSlash = (slashes) => {
1442
+ const { length } = slashes;
1443
+ return slashes.slice(0, length - length % 2);
1444
+ };
1445
+ var REPLACERS = [
1446
+ [
1447
+ // Remove BOM
1448
+ // TODO:
1449
+ // Other similar zero-width characters?
1450
+ /^\uFEFF/,
1451
+ () => EMPTY
1452
+ ],
1453
+ // > Trailing spaces are ignored unless they are quoted with backslash ("\")
1454
+ [
1455
+ // (a\ ) -> (a )
1456
+ // (a ) -> (a)
1457
+ // (a ) -> (a)
1458
+ // (a \ ) -> (a )
1459
+ /((?:\\\\)*?)(\\?\s+)$/,
1460
+ (_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)
1461
+ ],
1462
+ // Replace (\ ) with ' '
1463
+ // (\ ) -> ' '
1464
+ // (\\ ) -> '\\ '
1465
+ // (\\\ ) -> '\\ '
1466
+ [
1467
+ /(\\+?)\s/g,
1468
+ (_, m1) => {
1469
+ const { length } = m1;
1470
+ return m1.slice(0, length - length % 2) + SPACE;
1471
+ }
1472
+ ],
1473
+ // Escape metacharacters
1474
+ // which is written down by users but means special for regular expressions.
1475
+ // > There are 12 characters with special meanings:
1476
+ // > - the backslash \,
1477
+ // > - the caret ^,
1478
+ // > - the dollar sign $,
1479
+ // > - the period or dot .,
1480
+ // > - the vertical bar or pipe symbol |,
1481
+ // > - the question mark ?,
1482
+ // > - the asterisk or star *,
1483
+ // > - the plus sign +,
1484
+ // > - the opening parenthesis (,
1485
+ // > - the closing parenthesis ),
1486
+ // > - and the opening square bracket [,
1487
+ // > - the opening curly brace {,
1488
+ // > These special characters are often called "metacharacters".
1489
+ [
1490
+ /[\\$.|*+(){^]/g,
1491
+ (match) => `\\${match}`
1492
+ ],
1493
+ [
1494
+ // > a question mark (?) matches a single character
1495
+ /(?!\\)\?/g,
1496
+ () => "[^/]"
1497
+ ],
1498
+ // leading slash
1499
+ [
1500
+ // > A leading slash matches the beginning of the pathname.
1501
+ // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
1502
+ // A leading slash matches the beginning of the pathname
1503
+ /^\//,
1504
+ () => "^"
1505
+ ],
1506
+ // replace special metacharacter slash after the leading slash
1507
+ [
1508
+ /\//g,
1509
+ () => "\\/"
1510
+ ],
1511
+ [
1512
+ // > A leading "**" followed by a slash means match in all directories.
1513
+ // > For example, "**/foo" matches file or directory "foo" anywhere,
1514
+ // > the same as pattern "foo".
1515
+ // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
1516
+ // > under directory "foo".
1517
+ // Notice that the '*'s have been replaced as '\\*'
1518
+ /^\^*(?:\\\*\\\*\\\/)+/,
1519
+ // '**/foo' <-> 'foo'
1520
+ () => "^(?:.*\\/)?"
1521
+ ],
1522
+ // starting
1523
+ [
1524
+ // there will be no leading '/'
1525
+ // (which has been replaced by section "leading slash")
1526
+ // If starts with '**', adding a '^' to the regular expression also works
1527
+ /^(?=[^^])/,
1528
+ function startingReplacer() {
1529
+ return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^";
1530
+ }
1531
+ ],
1532
+ // two globstars
1533
+ [
1534
+ // Use lookahead assertions so that we could match more than one `'/**'`
1535
+ /\\\/\\\*\\\*(?=\\\/|$)/g,
1536
+ // Zero, one or several directories
1537
+ // should not use '*', or it will be replaced by the next replacer
1538
+ // Check if it is not the last `'/**'`
1539
+ (_, index, str) => index + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+"
1540
+ ],
1541
+ // normal intermediate wildcards
1542
+ [
1543
+ // Never replace escaped '*'
1544
+ // ignore rule '\*' will match the path '*'
1545
+ // 'abc.*/' -> go
1546
+ // 'abc.*' -> skip this rule,
1547
+ // coz trailing single wildcard will be handed by [trailing wildcard]
1548
+ /(^|[^\\]+)(\\\*)+(?=.+)/g,
1549
+ // '*.js' matches '.js'
1550
+ // '*.js' doesn't match 'abc'
1551
+ (_, p1, p2) => {
1552
+ const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
1553
+ return p1 + unescaped;
1554
+ }
1555
+ ],
1556
+ [
1557
+ // unescape, revert step 3 except for back slash
1558
+ // For example, if a user escape a '\\*',
1559
+ // after step 3, the result will be '\\\\\\*'
1560
+ /\\\\\\(?=[$.|*+(){^])/g,
1561
+ () => ESCAPE
1562
+ ],
1563
+ [
1564
+ // '\\\\' -> '\\'
1565
+ /\\\\/g,
1566
+ () => ESCAPE
1567
+ ],
1568
+ [
1569
+ // > The range notation, e.g. [a-zA-Z],
1570
+ // > can be used to match one of the characters in a range.
1571
+ // `\` is escaped by step 3
1572
+ /(\\)?\[([^\]/]*?)(\\*)($|\])/g,
1573
+ (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${negateRange(sanitizeRange(range))}${endEscape}]` : "[]" : "[]"
1574
+ ],
1575
+ // ending
1576
+ [
1577
+ // 'js' will not match 'js.'
1578
+ // 'ab' will not match 'abc'
1579
+ /(?:[^*])$/,
1580
+ // WTF!
1581
+ // https://git-scm.com/docs/gitignore
1582
+ // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
1583
+ // which re-fixes #24, #38
1584
+ // > If there is a separator at the end of the pattern then the pattern
1585
+ // > will only match directories, otherwise the pattern can match both
1586
+ // > files and directories.
1587
+ // 'js*' will not match 'a.js'
1588
+ // 'js/' will not match 'a.js'
1589
+ // 'js' will match 'a.js' and 'a.js/'
1590
+ (match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)`
1591
+ ]
1592
+ ];
1593
+ var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\\\*$/;
1594
+ var MODE_IGNORE = "regex";
1595
+ var MODE_CHECK_IGNORE = "checkRegex";
1596
+ var UNDERSCORE = "_";
1597
+ var TRAILING_WILD_CARD_REPLACERS = {
1598
+ [MODE_IGNORE](_, p1) {
1599
+ const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
1600
+ return `${prefix}(?=$|\\/$)`;
1601
+ },
1602
+ [MODE_CHECK_IGNORE](_, p1) {
1603
+ const prefix = p1 ? `${p1}[^/]*` : "[^/]*";
1604
+ return `${prefix}(?=$|\\/$)`;
1605
+ }
1606
+ };
1607
+ var makeRegexPrefix = (pattern) => REPLACERS.reduce(
1608
+ (prev, [matcher, replacer]) => prev.replace(matcher, replacer.bind(pattern)),
1609
+ pattern
1610
+ );
1611
+ var isString = (subject) => typeof subject === "string";
1612
+ var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
1613
+ var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
1614
+ var IgnoreRule = class {
1615
+ constructor(pattern, mark, body, ignoreCase, negative, prefix) {
1616
+ this.pattern = pattern;
1617
+ this.mark = mark;
1618
+ this.negative = negative;
1619
+ define(this, "body", body);
1620
+ define(this, "ignoreCase", ignoreCase);
1621
+ define(this, "regexPrefix", prefix);
1622
+ }
1623
+ get regex() {
1624
+ const key = UNDERSCORE + MODE_IGNORE;
1625
+ if (this[key]) {
1626
+ return this[key];
1627
+ }
1628
+ return this._make(MODE_IGNORE, key);
1629
+ }
1630
+ get checkRegex() {
1631
+ const key = UNDERSCORE + MODE_CHECK_IGNORE;
1632
+ if (this[key]) {
1633
+ return this[key];
1634
+ }
1635
+ return this._make(MODE_CHECK_IGNORE, key);
1636
+ }
1637
+ _make(mode, key) {
1638
+ const str = this.regexPrefix.replace(
1639
+ REGEX_REPLACE_TRAILING_WILDCARD,
1640
+ // It does not need to bind pattern
1641
+ TRAILING_WILD_CARD_REPLACERS[mode]
1642
+ );
1643
+ const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
1644
+ return define(this, key, regex);
1645
+ }
1646
+ };
1647
+ var createRule = ({
1648
+ pattern,
1649
+ mark
1650
+ }, ignoreCase) => {
1651
+ let negative = false;
1652
+ let body = pattern;
1653
+ if (body.indexOf("!") === 0) {
1654
+ negative = true;
1655
+ body = body.substr(1);
1656
+ }
1657
+ body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
1658
+ const regexPrefix = makeRegexPrefix(body);
1659
+ return new IgnoreRule(
1660
+ pattern,
1661
+ mark,
1662
+ body,
1663
+ ignoreCase,
1664
+ negative,
1665
+ regexPrefix
1666
+ );
1667
+ };
1668
+ var RuleManager = class {
1669
+ constructor(ignoreCase) {
1670
+ this._ignoreCase = ignoreCase;
1671
+ this._rules = [];
1672
+ }
1673
+ _add(pattern) {
1674
+ if (pattern && pattern[KEY_IGNORE]) {
1675
+ this._rules = this._rules.concat(pattern._rules._rules);
1676
+ this._added = true;
1677
+ return;
1678
+ }
1679
+ if (isString(pattern)) {
1680
+ pattern = {
1681
+ pattern
1682
+ };
1683
+ }
1684
+ if (checkPattern(pattern.pattern)) {
1685
+ const rule = createRule(pattern, this._ignoreCase);
1686
+ this._added = true;
1687
+ this._rules.push(rule);
1688
+ }
1689
+ }
1690
+ // @param {Array<string> | string | Ignore} pattern
1691
+ add(pattern) {
1692
+ this._added = false;
1693
+ makeArray(
1694
+ isString(pattern) ? splitPattern(pattern) : pattern
1695
+ ).forEach(this._add, this);
1696
+ return this._added;
1697
+ }
1698
+ // Test one single path without recursively checking parent directories
1699
+ //
1700
+ // - checkUnignored `boolean` whether should check if the path is unignored,
1701
+ // setting `checkUnignored` to `false` could reduce additional
1702
+ // path matching.
1703
+ // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
1704
+ // @returns {TestResult} true if a file is ignored
1705
+ test(path, checkUnignored, mode) {
1706
+ let ignored = false;
1707
+ let unignored = false;
1708
+ let matchedRule;
1709
+ this._rules.forEach((rule) => {
1710
+ const { negative } = rule;
1711
+ if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
1712
+ return;
1713
+ }
1714
+ const matched = rule[mode].test(path);
1715
+ if (!matched) {
1716
+ return;
1717
+ }
1718
+ ignored = !negative;
1719
+ unignored = negative;
1720
+ matchedRule = negative ? UNDEFINED : rule;
1721
+ });
1722
+ const ret = {
1723
+ ignored,
1724
+ unignored
1725
+ };
1726
+ if (matchedRule) {
1727
+ ret.rule = matchedRule;
1728
+ }
1729
+ return ret;
1730
+ }
1731
+ };
1732
+ var throwError = (message, Ctor) => {
1733
+ throw new Ctor(message);
1734
+ };
1735
+ var checkPath = (path, originalPath, doThrow) => {
1736
+ if (!isString(path)) {
1737
+ return doThrow(
1738
+ `path must be a string, but got \`${originalPath}\``,
1739
+ TypeError
1740
+ );
1741
+ }
1742
+ if (!path) {
1743
+ return doThrow(`path must not be empty`, TypeError);
1744
+ }
1745
+ if (checkPath.isNotRelative(path)) {
1746
+ const r = "`path.relative()`d";
1747
+ return doThrow(
1748
+ `path should be a ${r} string, but got "${originalPath}"`,
1749
+ RangeError
1750
+ );
1751
+ }
1752
+ return true;
1753
+ };
1754
+ var isNotRelative = (path) => REGEX_TEST_INVALID_PATH.test(path);
1755
+ checkPath.isNotRelative = isNotRelative;
1756
+ checkPath.convert = (p) => p;
1757
+ var Ignore = class {
1758
+ constructor({
1759
+ ignorecase = true,
1760
+ ignoreCase = ignorecase,
1761
+ allowRelativePaths = false
1762
+ } = {}) {
1763
+ define(this, KEY_IGNORE, true);
1764
+ this._rules = new RuleManager(ignoreCase);
1765
+ this._strictPathCheck = !allowRelativePaths;
1766
+ this._initCache();
1767
+ }
1768
+ _initCache() {
1769
+ this._ignoreCache = /* @__PURE__ */ Object.create(null);
1770
+ this._testCache = /* @__PURE__ */ Object.create(null);
1771
+ }
1772
+ add(pattern) {
1773
+ if (this._rules.add(pattern)) {
1774
+ this._initCache();
1775
+ }
1776
+ return this;
1777
+ }
1778
+ // legacy
1779
+ addPattern(pattern) {
1780
+ return this.add(pattern);
1781
+ }
1782
+ // @returns {TestResult}
1783
+ _test(originalPath, cache, checkUnignored, slices) {
1784
+ const path = originalPath && checkPath.convert(originalPath);
1785
+ checkPath(
1786
+ path,
1787
+ originalPath,
1788
+ this._strictPathCheck ? throwError : RETURN_FALSE
1789
+ );
1790
+ return this._t(path, cache, checkUnignored, slices);
1791
+ }
1792
+ checkIgnore(path) {
1793
+ if (!REGEX_TEST_TRAILING_SLASH.test(path)) {
1794
+ return this.test(path);
1795
+ }
1796
+ const slices = path.split(SLASH).filter(Boolean);
1797
+ slices.pop();
1798
+ if (slices.length) {
1799
+ const parent = this._t(
1800
+ slices.join(SLASH) + SLASH,
1801
+ this._testCache,
1802
+ true,
1803
+ slices
1804
+ );
1805
+ if (parent.ignored) {
1806
+ return parent;
1807
+ }
1808
+ }
1809
+ return this._rules.test(path, false, MODE_CHECK_IGNORE);
1810
+ }
1811
+ _t(path, cache, checkUnignored, slices) {
1812
+ if (path in cache) {
1813
+ return cache[path];
1814
+ }
1815
+ if (!slices) {
1816
+ slices = path.split(SLASH).filter(Boolean);
1817
+ }
1818
+ slices.pop();
1819
+ if (!slices.length) {
1820
+ return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE);
1821
+ }
1822
+ const parent = this._t(
1823
+ slices.join(SLASH) + SLASH,
1824
+ cache,
1825
+ checkUnignored,
1826
+ slices
1827
+ );
1828
+ return cache[path] = parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
1829
+ }
1830
+ ignores(path) {
1831
+ return this._test(path, this._ignoreCache, false).ignored;
1832
+ }
1833
+ createFilter() {
1834
+ return (path) => !this.ignores(path);
1835
+ }
1836
+ filter(paths) {
1837
+ return makeArray(paths).filter(this.createFilter());
1838
+ }
1839
+ // @returns {TestResult}
1840
+ test(path) {
1841
+ return this._test(path, this._testCache, true);
1842
+ }
1843
+ };
1844
+ var factory = (options) => new Ignore(options);
1845
+ var isPathValid = (path) => checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
1846
+ var setupWindows = () => {
1847
+ const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
1848
+ checkPath.convert = makePosix;
1849
+ const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
1850
+ checkPath.isNotRelative = (path) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
1851
+ };
1852
+ if (
1853
+ // Detect `process` so that it can run in browsers.
1854
+ typeof process !== "undefined" && process.platform === "win32"
1855
+ ) {
1856
+ setupWindows();
1857
+ }
1858
+ module.exports = factory;
1859
+ factory.default = factory;
1860
+ module.exports.isPathValid = isPathValid;
1861
+ define(module.exports, /* @__PURE__ */ Symbol.for("setupWindows"), setupWindows);
1862
+ }
1863
+ });
1864
+
1865
+ // ../../src/cli-sdk/src/pack-tarball.ts
1866
+ var ssri = __toESM(require_lib(), 1);
1867
+ import assert from "node:assert";
1868
+ import { existsSync, readFileSync, statSync } from "node:fs";
1869
+ import { join } from "node:path";
1870
+ var import_ignore = __toESM(require_ignore(), 1);
1871
+ var replaceWorkspaceAndCatalogSpecs = (manifest_, config) => {
1872
+ const manifest = parse(stringify(manifest_));
1873
+ const { monorepo, catalog = {}, catalogs = {} } = config.options;
1874
+ const depTypes = [
1875
+ "dependencies",
1876
+ "devDependencies",
1877
+ "optionalDependencies",
1878
+ "peerDependencies"
1879
+ ];
1880
+ for (const depType of depTypes) {
1881
+ const deps = manifest[depType];
1882
+ if (!deps || typeof deps !== "object") continue;
1883
+ const depsObj = deps;
1884
+ for (const [depName, depSpec] of Object.entries(depsObj)) {
1885
+ if (typeof depSpec !== "string") continue;
1886
+ const spec = Spec.parse(`${depName}@${depSpec}`, {
1887
+ catalog,
1888
+ catalogs
1889
+ });
1890
+ switch (spec.type) {
1891
+ case "workspace": {
1892
+ assert(
1893
+ monorepo,
1894
+ error(`No workspace configuration found for ${depName}`, {
1895
+ found: depName
1896
+ })
1897
+ );
1898
+ const workspaceName = spec.workspace;
1899
+ assert(
1900
+ workspaceName,
1901
+ error(`No workspace name found for ${depName}`, {
1902
+ found: depName
1903
+ })
1904
+ );
1905
+ const workspace = monorepo.get(workspaceName);
1906
+ assert(
1907
+ workspace,
1908
+ error(`Workspace '${workspaceName}' not found`, {
1909
+ found: workspaceName,
1910
+ validOptions: Array.from(monorepo.keys())
1911
+ })
1912
+ );
1913
+ const actualVersion = workspace.manifest.version;
1914
+ assert(
1915
+ actualVersion,
1916
+ error(
1917
+ `No version found for workspace '${workspaceName}'`,
1918
+ {
1919
+ found: workspaceName,
1920
+ wanted: "package version"
1921
+ }
1922
+ )
1923
+ );
1924
+ depsObj[depName] = actualVersion;
1925
+ break;
1926
+ }
1927
+ case "catalog": {
1928
+ const catalogName = spec.catalog || "";
1929
+ const targetCatalog = catalogName ? catalogs[catalogName] : catalog;
1930
+ assert(
1931
+ targetCatalog,
1932
+ error(`Catalog '${catalogName}' not found`, {
1933
+ found: catalogName,
1934
+ validOptions: Object.keys(catalogs)
1935
+ })
1936
+ );
1937
+ const actualVersion = targetCatalog[depName];
1938
+ assert(
1939
+ actualVersion,
1940
+ error(
1941
+ `Package '${depName}' not found in catalog '${catalogName || "default"}'`,
1942
+ {
1943
+ found: depName,
1944
+ validOptions: Object.keys(targetCatalog)
1945
+ }
1946
+ )
1947
+ );
1948
+ depsObj[depName] = actualVersion;
1949
+ break;
1950
+ }
1951
+ }
1952
+ }
1953
+ }
1954
+ return manifest;
1955
+ };
1956
+ var alwaysExcludePatterns = [
1957
+ /^\.?\/?\.git(\/|$)/,
1958
+ /^\.?\/?node_modules(\/|$)/,
1959
+ /^\.?\/?\.nyc_output(\/|$)/,
1960
+ /^\.?\/?coverage(\/|$)/,
1961
+ /^\.?\/?\.vscode(\/|$)/,
1962
+ /^\.?\/?\.idea(\/|$)/,
1963
+ /^\.?\/?\.DS_Store$/,
1964
+ /^\.?\/?\.npmrc$/,
1965
+ /^\.?\/?\.gitignore$/,
1966
+ /^\.?\/?\.npmignore$/,
1967
+ /^\.?\/?\.editorconfig$/,
1968
+ /^\.?\/?package-lock\.json$/,
1969
+ /^\.?\/?yarn\.lock$/,
1970
+ /^\.?\/?pnpm-lock\.yaml$/,
1971
+ /^\.?\/?bun\.lockb$/,
1972
+ /^\.?\/?bun\.lock$/,
1973
+ /^\.?\/?vlt-lock\.json$/,
1974
+ /^\.?\/?vlt\.json$/,
1975
+ /~$/,
1976
+ /\.swp$/,
1977
+ /\.tgz$/
1978
+ ];
1979
+ var alwaysIncludePatterns = [
1980
+ /^README(\..*)?$/i,
1981
+ /^CHANGELOG(\..*)?$/i,
1982
+ /^HISTORY(\..*)?$/i,
1983
+ /^LICENSE(\..*)?$/i,
1984
+ /^LICENCE(\..*)?$/i
1985
+ ];
1986
+ var readIgnoreFile = (dir, name) => {
1987
+ const filePath = join(dir, name);
1988
+ if (!existsSync(filePath)) return void 0;
1989
+ return readFileSync(filePath, "utf8");
1990
+ };
1991
+ var buildPackFilter = (manifest, packDir) => {
1992
+ const manifestWithFiles = manifest;
1993
+ const hasFilesField = Array.isArray(manifestWithFiles.files) && manifestWithFiles.files.length > 0;
1994
+ const hasEmptyFilesField = Array.isArray(manifestWithFiles.files) && manifestWithFiles.files.length === 0;
1995
+ let ig;
1996
+ if (!hasFilesField && !hasEmptyFilesField) {
1997
+ const npmignoreContent = readIgnoreFile(packDir, ".npmignore");
1998
+ if (npmignoreContent !== void 0) {
1999
+ ig = (0, import_ignore.default)().add(npmignoreContent);
2000
+ } else {
2001
+ const gitignoreContent = readIgnoreFile(packDir, ".gitignore");
2002
+ if (gitignoreContent !== void 0) {
2003
+ ig = (0, import_ignore.default)().add(gitignoreContent);
2004
+ }
2005
+ }
2006
+ }
2007
+ return (path) => {
2008
+ const normalizedPath = path.replace(/^\.\//, "");
2009
+ if (path === "." || normalizedPath === "") {
2010
+ return true;
2011
+ }
2012
+ if (alwaysExcludePatterns.some(
2013
+ (pattern) => pattern.test(normalizedPath)
2014
+ )) {
2015
+ return false;
2016
+ }
2017
+ if (alwaysIncludePatterns.some(
2018
+ (pattern) => pattern.test(normalizedPath)
2019
+ )) {
2020
+ return true;
2021
+ }
2022
+ if (normalizedPath === "package.json") {
2023
+ return true;
2024
+ }
2025
+ if (hasEmptyFilesField) {
2026
+ return false;
2027
+ }
2028
+ if (hasFilesField && manifestWithFiles.files) {
2029
+ return manifestWithFiles.files.some((pattern) => {
2030
+ if (pattern.endsWith("/")) {
2031
+ const dirName = pattern.slice(0, -1);
2032
+ const globPattern = pattern.replace(/\/$/, "/**");
2033
+ const matchesDir = normalizedPath === dirName;
2034
+ const matchesContents = minimatch(
2035
+ normalizedPath,
2036
+ globPattern,
2037
+ { dot: true }
2038
+ );
2039
+ return matchesDir || matchesContents;
2040
+ }
2041
+ const directMatch = minimatch(normalizedPath, pattern, {
2042
+ dot: true
2043
+ });
2044
+ const isParentDir = pattern.includes("/") && pattern.startsWith(normalizedPath + "/");
2045
+ const isChildOfPattern = minimatch(
2046
+ normalizedPath,
2047
+ pattern + "/**",
2048
+ { dot: true }
2049
+ );
2050
+ return directMatch || isParentDir || isChildOfPattern;
2051
+ });
2052
+ }
2053
+ if (ig?.ignores(normalizedPath)) {
2054
+ return false;
2055
+ }
2056
+ return true;
2057
+ };
2058
+ };
2059
+ var packTarball = async (manifest, dir, config) => {
2060
+ let packDir = dir;
2061
+ const cliPublishDir = config.get("publish-directory");
2062
+ const manifestPublishDir = manifest.publishConfig?.directory;
2063
+ const publishDirectory = cliPublishDir ?? manifestPublishDir;
2064
+ if (publishDirectory) {
2065
+ const resolvedPublishDir = cliPublishDir ? publishDirectory : join(dir, publishDirectory);
2066
+ assert(
2067
+ existsSync(resolvedPublishDir),
2068
+ error(
2069
+ `Publish directory does not exist: ${resolvedPublishDir}`,
2070
+ {
2071
+ found: resolvedPublishDir
2072
+ }
2073
+ )
2074
+ );
2075
+ assert(
2076
+ statSync(resolvedPublishDir).isDirectory(),
2077
+ error(
2078
+ `Publish directory is not a directory: ${resolvedPublishDir}`,
2079
+ {
2080
+ found: resolvedPublishDir,
2081
+ wanted: "directory"
2082
+ }
2083
+ )
2084
+ );
2085
+ if (existsSync(join(resolvedPublishDir, "package.json"))) {
2086
+ manifest = config.options.packageJson.read(resolvedPublishDir);
2087
+ }
2088
+ packDir = resolvedPublishDir;
2089
+ }
2090
+ assert(
2091
+ manifest.name && manifest.version,
2092
+ error("Package must have a name and version")
2093
+ );
2094
+ const processedManifest = replaceWorkspaceAndCatalogSpecs(
2095
+ manifest,
2096
+ config
2097
+ );
2098
+ const filename = `${manifest.name.replace("@", "").replace("/", "-")}-${manifest.version}.tgz`;
2099
+ const tarballName = `${manifest.name}-${manifest.version}.tgz`;
2100
+ try {
2101
+ config.options.packageJson.write(packDir, processedManifest);
2102
+ const packFilter = buildPackFilter(manifest, packDir);
2103
+ const tarballData = await Qn(
2104
+ {
2105
+ cwd: packDir,
2106
+ gzip: true,
2107
+ portable: true,
2108
+ prefix: "package/",
2109
+ filter: packFilter
2110
+ },
2111
+ ["."]
2112
+ ).concat();
2113
+ let unpackedSize = 0;
2114
+ const files = [];
2115
+ await new Promise((resolve, reject) => {
2116
+ const stream = Ct({
2117
+ onentry: (entry) => {
2118
+ if (entry.type === "File") {
2119
+ unpackedSize += entry.size;
2120
+ const cleanPath = entry.path.replace(/^[^/]+\//, "");
2121
+ if (cleanPath) {
2122
+ files.push(cleanPath);
2123
+ }
2124
+ }
2125
+ }
2126
+ });
2127
+ stream.on("end", () => resolve()).on("error", reject).write(tarballData);
2128
+ stream.end();
2129
+ });
2130
+ const integrityMap = ssri.fromData(tarballData, {
2131
+ algorithms: [.../* @__PURE__ */ new Set(["sha1", "sha512"])]
2132
+ });
2133
+ const integrity = integrityMap.sha512?.[0]?.toString();
2134
+ const shasum = integrityMap.sha1?.[0]?.hexDigest();
2135
+ return {
2136
+ name: manifest.name,
2137
+ version: manifest.version,
2138
+ filename,
2139
+ tarballName,
2140
+ tarballData,
2141
+ unpackedSize,
2142
+ files,
2143
+ integrity,
2144
+ shasum,
2145
+ resolvedManifest: processedManifest,
2146
+ packDir
2147
+ };
2148
+ } finally {
2149
+ config.options.packageJson.write(packDir, manifest);
2150
+ }
2151
+ };
2152
+
2153
+ export {
2154
+ packTarball
2155
+ };