@circi/cypress 0.1.0 → 0.1.1

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.mjs CHANGED
@@ -1,3317 +1,12 @@
1
- import ro, { mkdir, readFile, readdir, realpath, rm, stat, writeFile } from "node:fs/promises";
2
- import Pr, { basename, dirname, join, posix, relative, resolve, sep, win32 } from "node:path";
3
- import { createHash, randomBytes, randomUUID } from "node:crypto";
1
+ import { mkdir, readFile, readdir, realpath, rm, stat, writeFile } from "node:fs/promises";
2
+ import { dirname, join, relative, resolve, sep } from "node:path";
3
+ import { createHash, randomUUID } from "node:crypto";
4
4
  import { setTimeout } from "node:timers/promises";
5
- import Qr, { EventEmitter } from "events";
6
- import I from "fs";
7
- import { EventEmitter as EventEmitter$1 } from "node:events";
8
- import Cs from "node:stream";
9
- import { StringDecoder } from "node:string_decoder";
10
- import Br, { createReadStream, readFileSync } from "node:fs";
11
- import ar, { dirname as dirname$1, parse } from "path";
12
- import zi from "assert";
13
- import { Buffer as Buffer$1 } from "buffer";
14
- import en, * as Ps from "zlib";
15
- import co from "node:assert";
5
+ import "tar";
6
+ import { createReadStream, readFileSync } from "node:fs";
16
7
  import { execFile } from "node:child_process";
17
8
  import { promisify } from "node:util";
18
9
  import { i as toolDir, r as capturePath } from "./names-D1laAiFj.mjs";
19
- // ../../node_modules/.pnpm/tar@7.5.23/node_modules/tar/dist/esm/index.min.js
20
- var zr = Object.defineProperty;
21
- var Ur = (s, t) => {
22
- for (var e in t) zr(s, e, {
23
- get: t[e],
24
- enumerable: !0
25
- });
26
- };
27
- var Ds = typeof process == "object" && process ? process : {
28
- stdout: null,
29
- stderr: null
30
- };
31
- var Wr = (s) => !!s && typeof s == "object" && (s instanceof A || s instanceof Cs || Gr(s) || Zr(s));
32
- var Gr = (s) => !!s && typeof s == "object" && s instanceof EventEmitter$1 && typeof s.pipe == "function" && s.pipe !== Cs.Writable.prototype.pipe;
33
- var Zr = (s) => !!s && typeof s == "object" && s instanceof EventEmitter$1 && typeof s.write == "function" && typeof s.end == "function";
34
- var Q = Symbol("EOF");
35
- var J = Symbol("maybeEmitEnd");
36
- var nt = Symbol("emittedEnd");
37
- var De = Symbol("emittingEnd");
38
- var qt = Symbol("emittedError");
39
- var Ne = Symbol("closed");
40
- var Ns = Symbol("read");
41
- var Ae = Symbol("flush");
42
- var As = Symbol("flushChunk");
43
- var z = Symbol("encoding");
44
- var Mt = Symbol("decoder");
45
- var g = Symbol("flowing");
46
- var Qt = Symbol("paused");
47
- var Bt = Symbol("resume");
48
- var b = Symbol("buffer");
49
- var N = Symbol("pipes");
50
- var _ = Symbol("bufferLength");
51
- var bi = Symbol("bufferPush");
52
- var Ie = Symbol("bufferShift");
53
- var L = Symbol("objectMode");
54
- var S = Symbol("destroyed");
55
- var _i = Symbol("error");
56
- var Oi = Symbol("emitData");
57
- var Is = Symbol("emitEnd");
58
- var Ti = Symbol("emitEnd2");
59
- var Z = Symbol("async");
60
- var xi = Symbol("abort");
61
- var Ce = Symbol("aborted");
62
- var Jt = Symbol("signal");
63
- var Rt = Symbol("dataListeners");
64
- var C = Symbol("discarded");
65
- var jt = (s) => Promise.resolve().then(s);
66
- var Yr = (s) => s();
67
- var Kr = (s) => s === "end" || s === "finish" || s === "prefinish";
68
- var Vr = (s) => s instanceof ArrayBuffer || !!s && typeof s == "object" && s.constructor && s.constructor.name === "ArrayBuffer" && s.byteLength >= 0;
69
- var $r = (s) => !Buffer.isBuffer(s) && ArrayBuffer.isView(s);
70
- var Fe = class {
71
- src;
72
- dest;
73
- opts;
74
- ondrain;
75
- constructor(t, e, i) {
76
- this.src = t, this.dest = e, this.opts = i, this.ondrain = () => t[Bt](), this.dest.on("drain", this.ondrain);
77
- }
78
- unpipe() {
79
- this.dest.removeListener("drain", this.ondrain);
80
- }
81
- proxyErrors(t) {}
82
- end() {
83
- this.unpipe(), this.opts.end && this.dest.end();
84
- }
85
- };
86
- var Li = class extends Fe {
87
- unpipe() {
88
- this.src.removeListener("error", this.proxyErrors), super.unpipe();
89
- }
90
- constructor(t, e, i) {
91
- super(t, e, i), this.proxyErrors = (r) => this.dest.emit("error", r), t.on("error", this.proxyErrors);
92
- }
93
- };
94
- var Xr = (s) => !!s.objectMode;
95
- var qr = (s) => !s.objectMode && !!s.encoding && s.encoding !== "buffer";
96
- var A = class extends EventEmitter$1 {
97
- [g] = !1;
98
- [Qt] = !1;
99
- [N] = [];
100
- [b] = [];
101
- [L];
102
- [z];
103
- [Z];
104
- [Mt];
105
- [Q] = !1;
106
- [nt] = !1;
107
- [De] = !1;
108
- [Ne] = !1;
109
- [qt] = null;
110
- [_] = 0;
111
- [S] = !1;
112
- [Jt];
113
- [Ce] = !1;
114
- [Rt] = 0;
115
- [C] = !1;
116
- writable = !0;
117
- readable = !0;
118
- constructor(...t) {
119
- let e = t[0] || {};
120
- if (super(), e.objectMode && typeof e.encoding == "string") throw new TypeError("Encoding and objectMode may not be used together");
121
- Xr(e) ? (this[L] = !0, this[z] = null) : qr(e) ? (this[z] = e.encoding, this[L] = !1) : (this[L] = !1, this[z] = null), this[Z] = !!e.async, this[Mt] = this[z] ? new StringDecoder(this[z]) : null, e && e.debugExposeBuffer === !0 && Object.defineProperty(this, "buffer", { get: () => this[b] }), e && e.debugExposePipes === !0 && Object.defineProperty(this, "pipes", { get: () => this[N] });
122
- let { signal: i } = e;
123
- i && (this[Jt] = i, i.aborted ? this[xi]() : i.addEventListener("abort", () => this[xi]()));
124
- }
125
- get bufferLength() {
126
- return this[_];
127
- }
128
- get encoding() {
129
- return this[z];
130
- }
131
- set encoding(t) {
132
- throw new Error("Encoding must be set at instantiation time");
133
- }
134
- setEncoding(t) {
135
- throw new Error("Encoding must be set at instantiation time");
136
- }
137
- get objectMode() {
138
- return this[L];
139
- }
140
- set objectMode(t) {
141
- throw new Error("objectMode must be set at instantiation time");
142
- }
143
- get async() {
144
- return this[Z];
145
- }
146
- set async(t) {
147
- this[Z] = this[Z] || !!t;
148
- }
149
- [xi]() {
150
- this[Ce] = !0, this.emit("abort", this[Jt]?.reason), this.destroy(this[Jt]?.reason);
151
- }
152
- get aborted() {
153
- return this[Ce];
154
- }
155
- set aborted(t) {}
156
- write(t, e, i) {
157
- if (this[Ce]) return !1;
158
- if (this[Q]) throw new Error("write after end");
159
- if (this[S]) return this.emit("error", Object.assign(/* @__PURE__ */ new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), !0;
160
- typeof e == "function" && (i = e, e = "utf8"), e || (e = "utf8");
161
- let r = this[Z] ? jt : Yr;
162
- if (!this[L] && !Buffer.isBuffer(t)) {
163
- if ($r(t)) t = Buffer.from(t.buffer, t.byteOffset, t.byteLength);
164
- else if (Vr(t)) t = Buffer.from(t);
165
- else if (typeof t != "string") throw new Error("Non-contiguous data written to non-objectMode stream");
166
- }
167
- return this[L] ? (this[g] && this[_] !== 0 && this[Ae](!0), this[g] ? this.emit("data", t) : this[bi](t), this[_] !== 0 && this.emit("readable"), i && r(i), this[g]) : t.length ? (typeof t == "string" && (e !== this[z] || this[Mt]?.lastNeed) && (t = Buffer.from(t, e)), Buffer.isBuffer(t) && this[z] && (t = this[Mt].write(t)), this[g] && this[_] !== 0 && this[Ae](!0), this[g] ? this.emit("data", t) : this[bi](t), this[_] !== 0 && this.emit("readable"), i && r(i), this[g]) : (this[_] !== 0 && this.emit("readable"), i && r(i), this[g]);
168
- }
169
- read(t) {
170
- if (this[S]) return null;
171
- if (this[C] = !1, this[_] === 0 || t === 0 || t && t > this[_]) return this[J](), null;
172
- this[L] && (t = null), this[b].length > 1 && !this[L] && (this[b] = [this[z] ? this[b].join("") : Buffer.concat(this[b], this[_])]);
173
- let e = this[Ns](t || null, this[b][0]);
174
- return this[J](), e;
175
- }
176
- [Ns](t, e) {
177
- if (this[L]) this[Ie]();
178
- else {
179
- let i = e;
180
- t === i.length || t === null ? this[Ie]() : typeof i == "string" ? (this[b][0] = i.slice(t), e = i.slice(0, t), this[_] -= t) : (this[b][0] = i.subarray(t), e = i.subarray(0, t), this[_] -= t);
181
- }
182
- return this.emit("data", e), !this[b].length && !this[Q] && this.emit("drain"), e;
183
- }
184
- end(t, e, i) {
185
- return typeof t == "function" && (i = t, t = void 0), typeof e == "function" && (i = e, e = "utf8"), t !== void 0 && this.write(t, e), i && this.once("end", i), this[Q] = !0, this.writable = !1, (this[g] || !this[Qt]) && this[J](), this;
186
- }
187
- [Bt]() {
188
- this[S] || (!this[Rt] && !this[N].length && (this[C] = !0), this[Qt] = !1, this[g] = !0, this.emit("resume"), this[b].length ? this[Ae]() : this[Q] ? this[J]() : this.emit("drain"));
189
- }
190
- resume() {
191
- return this[Bt]();
192
- }
193
- pause() {
194
- this[g] = !1, this[Qt] = !0, this[C] = !1;
195
- }
196
- get destroyed() {
197
- return this[S];
198
- }
199
- get flowing() {
200
- return this[g];
201
- }
202
- get paused() {
203
- return this[Qt];
204
- }
205
- [bi](t) {
206
- this[L] ? this[_] += 1 : this[_] += t.length, this[b].push(t);
207
- }
208
- [Ie]() {
209
- return this[L] ? this[_] -= 1 : this[_] -= this[b][0].length, this[b].shift();
210
- }
211
- [Ae](t = !1) {
212
- do;
213
- while (this[As](this[Ie]()) && this[b].length);
214
- !t && !this[b].length && !this[Q] && this.emit("drain");
215
- }
216
- [As](t) {
217
- return this.emit("data", t), this[g];
218
- }
219
- pipe(t, e) {
220
- if (this[S]) return t;
221
- this[C] = !1;
222
- let i = this[nt];
223
- return e = e || {}, t === Ds.stdout || t === Ds.stderr ? e.end = !1 : e.end = e.end !== !1, e.proxyErrors = !!e.proxyErrors, i ? e.end && t.end() : (this[N].push(e.proxyErrors ? new Li(this, t, e) : new Fe(this, t, e)), this[Z] ? jt(() => this[Bt]()) : this[Bt]()), t;
224
- }
225
- unpipe(t) {
226
- let e = this[N].find((i) => i.dest === t);
227
- e && (this[N].length === 1 ? (this[g] && this[Rt] === 0 && (this[g] = !1), this[N] = []) : this[N].splice(this[N].indexOf(e), 1), e.unpipe());
228
- }
229
- addListener(t, e) {
230
- return this.on(t, e);
231
- }
232
- on(t, e) {
233
- let i = super.on(t, e);
234
- if (t === "data") this[C] = !1, this[Rt]++, !this[N].length && !this[g] && this[Bt]();
235
- else if (t === "readable" && this[_] !== 0) super.emit("readable");
236
- else if (Kr(t) && this[nt]) super.emit(t), this.removeAllListeners(t);
237
- else if (t === "error" && this[qt]) {
238
- let r = e;
239
- this[Z] ? jt(() => r.call(this, this[qt])) : r.call(this, this[qt]);
240
- }
241
- return i;
242
- }
243
- removeListener(t, e) {
244
- return this.off(t, e);
245
- }
246
- off(t, e) {
247
- let i = super.off(t, e);
248
- return t === "data" && (this[Rt] = this.listeners("data").length, this[Rt] === 0 && !this[C] && !this[N].length && (this[g] = !1)), i;
249
- }
250
- removeAllListeners(t) {
251
- let e = super.removeAllListeners(t);
252
- return (t === "data" || t === void 0) && (this[Rt] = 0, !this[C] && !this[N].length && (this[g] = !1)), e;
253
- }
254
- get emittedEnd() {
255
- return this[nt];
256
- }
257
- [J]() {
258
- !this[De] && !this[nt] && !this[S] && this[b].length === 0 && this[Q] && (this[De] = !0, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[Ne] && this.emit("close"), this[De] = !1);
259
- }
260
- emit(t, ...e) {
261
- let i = e[0];
262
- if (t !== "error" && t !== "close" && t !== S && this[S]) return !1;
263
- if (t === "data") return !this[L] && !i ? !1 : this[Z] ? (jt(() => this[Oi](i)), !0) : this[Oi](i);
264
- if (t === "end") return this[Is]();
265
- if (t === "close") {
266
- if (this[Ne] = !0, !this[nt] && !this[S]) return !1;
267
- let n = super.emit("close");
268
- return this.removeAllListeners("close"), n;
269
- } else if (t === "error") {
270
- this[qt] = i, super.emit(_i, i);
271
- let n = !this[Jt] || this.listeners("error").length ? super.emit("error", i) : !1;
272
- return this[J](), n;
273
- } else if (t === "resume") {
274
- let n = super.emit("resume");
275
- return this[J](), n;
276
- } else if (t === "finish" || t === "prefinish") {
277
- let n = super.emit(t);
278
- return this.removeAllListeners(t), n;
279
- }
280
- let r = super.emit(t, ...e);
281
- return this[J](), r;
282
- }
283
- [Oi](t) {
284
- for (let i of this[N]) i.dest.write(t) === !1 && this.pause();
285
- let e = this[C] ? !1 : super.emit("data", t);
286
- return this[J](), e;
287
- }
288
- [Is]() {
289
- return this[nt] ? !1 : (this[nt] = !0, this.readable = !1, this[Z] ? (jt(() => this[Ti]()), !0) : this[Ti]());
290
- }
291
- [Ti]() {
292
- if (this[Mt]) {
293
- let e = this[Mt].end();
294
- if (e) {
295
- for (let i of this[N]) i.dest.write(e);
296
- this[C] || super.emit("data", e);
297
- }
298
- }
299
- for (let e of this[N]) e.end();
300
- let t = super.emit("end");
301
- return this.removeAllListeners("end"), t;
302
- }
303
- async collect() {
304
- let t = Object.assign([], { dataLength: 0 });
305
- this[L] || (t.dataLength = 0);
306
- let e = this.promise();
307
- return this.on("data", (i) => {
308
- t.push(i), this[L] || (t.dataLength += i.length);
309
- }), await e, t;
310
- }
311
- async concat() {
312
- if (this[L]) throw new Error("cannot concat in objectMode");
313
- let t = await this.collect();
314
- return this[z] ? t.join("") : Buffer.concat(t, t.dataLength);
315
- }
316
- async promise() {
317
- return new Promise((t, e) => {
318
- this.on(S, () => e(/* @__PURE__ */ new Error("stream destroyed"))), this.on("error", (i) => e(i)), this.on("end", () => t());
319
- });
320
- }
321
- [Symbol.asyncIterator]() {
322
- this[C] = !1;
323
- let t = !1, e = async () => (this.pause(), t = !0, {
324
- value: void 0,
325
- done: !0
326
- });
327
- return {
328
- next: () => {
329
- if (t) return e();
330
- let r = this.read();
331
- if (r !== null) return Promise.resolve({
332
- done: !1,
333
- value: r
334
- });
335
- if (this[Q]) return e();
336
- let n, o, h = (d) => {
337
- this.off("data", a), this.off("end", l), this.off(S, c), e(), o(d);
338
- }, a = (d) => {
339
- this.off("error", h), this.off("end", l), this.off(S, c), this.pause(), n({
340
- value: d,
341
- done: !!this[Q]
342
- });
343
- }, l = () => {
344
- this.off("error", h), this.off("data", a), this.off(S, c), e(), n({
345
- done: !0,
346
- value: void 0
347
- });
348
- }, c = () => h(/* @__PURE__ */ new Error("stream destroyed"));
349
- return new Promise((d, y) => {
350
- o = y, n = d, this.once(S, c), this.once("error", h), this.once("end", l), this.once("data", a);
351
- });
352
- },
353
- throw: e,
354
- return: e,
355
- [Symbol.asyncIterator]() {
356
- return this;
357
- },
358
- [Symbol.asyncDispose]: async () => {}
359
- };
360
- }
361
- [Symbol.iterator]() {
362
- this[C] = !1;
363
- let t = !1, e = () => (this.pause(), this.off(_i, e), this.off(S, e), this.off("end", e), t = !0, {
364
- done: !0,
365
- value: void 0
366
- }), i = () => {
367
- if (t) return e();
368
- let r = this.read();
369
- return r === null ? e() : {
370
- done: !1,
371
- value: r
372
- };
373
- };
374
- return this.once("end", e), this.once(_i, e), this.once(S, e), {
375
- next: i,
376
- throw: e,
377
- return: e,
378
- [Symbol.iterator]() {
379
- return this;
380
- },
381
- [Symbol.dispose]: () => {}
382
- };
383
- }
384
- destroy(t) {
385
- if (this[S]) return t ? this.emit("error", t) : this.emit(S), this;
386
- this[S] = !0, this[C] = !0, this[b].length = 0, this[_] = 0;
387
- let e = this;
388
- return typeof e.close == "function" && !this[Ne] && e.close(), t ? this.emit("error", t) : this.emit(S), this;
389
- }
390
- static get isStream() {
391
- return Wr;
392
- }
393
- };
394
- var Jr = I.writev;
395
- var ht = Symbol("_autoClose");
396
- var H = Symbol("_close");
397
- var te = Symbol("_ended");
398
- var m = Symbol("_fd");
399
- var Ni = Symbol("_finished");
400
- var tt = Symbol("_flags");
401
- var Ai = Symbol("_flush");
402
- var ki = Symbol("_handleChunk");
403
- var vi = Symbol("_makeBuf");
404
- var ie = Symbol("_mode");
405
- var ke = Symbol("_needDrain");
406
- var Ut = Symbol("_onerror");
407
- var Ht = Symbol("_onopen");
408
- var Ii = Symbol("_onread");
409
- var Pt = Symbol("_onwrite");
410
- var at = Symbol("_open");
411
- var U = Symbol("_path");
412
- var ot = Symbol("_pos");
413
- var Y = Symbol("_queue");
414
- var zt = Symbol("_read");
415
- var Ci = Symbol("_readSize");
416
- var j = Symbol("_reading");
417
- var ee = Symbol("_remain");
418
- var Fi = Symbol("_size");
419
- var ve = Symbol("_write");
420
- var gt = Symbol("_writing");
421
- var Me = Symbol("_defaultFlag");
422
- var bt = Symbol("_errored");
423
- var _t = class extends A {
424
- [bt] = !1;
425
- [m];
426
- [U];
427
- [Ci];
428
- [j] = !1;
429
- [Fi];
430
- [ee];
431
- [ht];
432
- constructor(t, e) {
433
- if (e = e || {}, super(e), this.readable = !0, this.writable = !1, typeof t != "string") throw new TypeError("path must be a string");
434
- this[bt] = !1, this[m] = typeof e.fd == "number" ? e.fd : void 0, this[U] = t, this[Ci] = e.readSize || 16777216, this[j] = !1, this[Fi] = typeof e.size == "number" ? e.size : 1 / 0, this[ee] = this[Fi], this[ht] = typeof e.autoClose == "boolean" ? e.autoClose : !0, typeof this[m] == "number" ? this[zt]() : this[at]();
435
- }
436
- get fd() {
437
- return this[m];
438
- }
439
- get path() {
440
- return this[U];
441
- }
442
- write() {
443
- throw new TypeError("this is a readable stream");
444
- }
445
- end() {
446
- throw new TypeError("this is a readable stream");
447
- }
448
- [at]() {
449
- I.open(this[U], "r", (t, e) => this[Ht](t, e));
450
- }
451
- [Ht](t, e) {
452
- t ? this[Ut](t) : (this[m] = e, this.emit("open", e), this[zt]());
453
- }
454
- [vi]() {
455
- return Buffer.allocUnsafe(Math.min(this[Ci], this[ee]));
456
- }
457
- [zt]() {
458
- if (!this[j]) {
459
- this[j] = !0;
460
- let t = this[vi]();
461
- if (t.length === 0) return process.nextTick(() => this[Ii](null, 0, t));
462
- I.read(this[m], t, 0, t.length, null, (e, i, r) => this[Ii](e, i, r));
463
- }
464
- }
465
- [Ii](t, e, i) {
466
- this[j] = !1, t ? this[Ut](t) : this[ki](e, i) && this[zt]();
467
- }
468
- [H]() {
469
- if (this[ht] && typeof this[m] == "number") {
470
- let t = this[m];
471
- this[m] = void 0, I.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
472
- }
473
- }
474
- [Ut](t) {
475
- this[j] = !0, this[H](), this.emit("error", t);
476
- }
477
- [ki](t, e) {
478
- let i = !1;
479
- return this[ee] -= t, t > 0 && (i = super.write(t < e.length ? e.subarray(0, t) : e)), (t === 0 || this[ee] <= 0) && (i = !1, this[H](), super.end()), i;
480
- }
481
- emit(t, ...e) {
482
- switch (t) {
483
- case "prefinish":
484
- case "finish": return !1;
485
- case "drain": return typeof this[m] == "number" && this[zt](), !1;
486
- case "error": return this[bt] ? !1 : (this[bt] = !0, super.emit(t, ...e));
487
- default: return super.emit(t, ...e);
488
- }
489
- }
490
- };
491
- var Be = class extends _t {
492
- [at]() {
493
- let t = !0;
494
- try {
495
- this[Ht](null, I.openSync(this[U], "r")), t = !1;
496
- } finally {
497
- t && this[H]();
498
- }
499
- }
500
- [zt]() {
501
- let t = !0;
502
- try {
503
- if (!this[j]) {
504
- this[j] = !0;
505
- do {
506
- let e = this[vi](), i = e.length === 0 ? 0 : I.readSync(this[m], e, 0, e.length, null);
507
- if (!this[ki](i, e)) break;
508
- } while (!0);
509
- this[j] = !1;
510
- }
511
- t = !1;
512
- } finally {
513
- t && this[H]();
514
- }
515
- }
516
- [H]() {
517
- if (this[ht] && typeof this[m] == "number") {
518
- let t = this[m];
519
- this[m] = void 0, I.closeSync(t), this.emit("close");
520
- }
521
- }
522
- };
523
- var et = class extends Qr {
524
- readable = !1;
525
- writable = !0;
526
- [bt] = !1;
527
- [gt] = !1;
528
- [te] = !1;
529
- [Y] = [];
530
- [ke] = !1;
531
- [U];
532
- [ie];
533
- [ht];
534
- [m];
535
- [Me];
536
- [tt];
537
- [Ni] = !1;
538
- [ot];
539
- constructor(t, e) {
540
- e = e || {}, super(e), this[U] = t, this[m] = typeof e.fd == "number" ? e.fd : void 0, this[ie] = e.mode === void 0 ? 438 : e.mode, this[ot] = typeof e.start == "number" ? e.start : void 0, this[ht] = typeof e.autoClose == "boolean" ? e.autoClose : !0;
541
- let i = this[ot] !== void 0 ? "r+" : "w";
542
- this[Me] = e.flags === void 0, this[tt] = e.flags === void 0 ? i : e.flags, this[m] === void 0 && this[at]();
543
- }
544
- emit(t, ...e) {
545
- if (t === "error") {
546
- if (this[bt]) return !1;
547
- this[bt] = !0;
548
- }
549
- return super.emit(t, ...e);
550
- }
551
- get fd() {
552
- return this[m];
553
- }
554
- get path() {
555
- return this[U];
556
- }
557
- [Ut](t) {
558
- this[H](), this[gt] = !0, this.emit("error", t);
559
- }
560
- [at]() {
561
- I.open(this[U], this[tt], this[ie], (t, e) => this[Ht](t, e));
562
- }
563
- [Ht](t, e) {
564
- this[Me] && this[tt] === "r+" && t && t.code === "ENOENT" ? (this[tt] = "w", this[at]()) : t ? this[Ut](t) : (this[m] = e, this.emit("open", e), this[gt] || this[Ai]());
565
- }
566
- end(t, e) {
567
- return t && this.write(t, e), this[te] = !0, !this[gt] && !this[Y].length && typeof this[m] == "number" && this[Pt](null, 0), this;
568
- }
569
- write(t, e) {
570
- return typeof t == "string" && (t = Buffer.from(t, e)), this[te] ? (this.emit("error", /* @__PURE__ */ new Error("write() after end()")), !1) : this[m] === void 0 || this[gt] || this[Y].length ? (this[Y].push(t), this[ke] = !0, !1) : (this[gt] = !0, this[ve](t), !0);
571
- }
572
- [ve](t) {
573
- I.write(this[m], t, 0, t.length, this[ot], (e, i) => this[Pt](e, i));
574
- }
575
- [Pt](t, e) {
576
- t ? this[Ut](t) : (this[ot] !== void 0 && typeof e == "number" && (this[ot] += e), this[Y].length ? this[Ai]() : (this[gt] = !1, this[te] && !this[Ni] ? (this[Ni] = !0, this[H](), this.emit("finish")) : this[ke] && (this[ke] = !1, this.emit("drain"))));
577
- }
578
- [Ai]() {
579
- if (this[Y].length === 0) this[te] && this[Pt](null, 0);
580
- else if (this[Y].length === 1) this[ve](this[Y].pop());
581
- else {
582
- let t = this[Y];
583
- this[Y] = [], Jr(this[m], t, this[ot], (e, i) => this[Pt](e, i));
584
- }
585
- }
586
- [H]() {
587
- if (this[ht] && typeof this[m] == "number") {
588
- let t = this[m];
589
- this[m] = void 0, I.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
590
- }
591
- }
592
- };
593
- var Wt = class extends et {
594
- [at]() {
595
- let t;
596
- if (this[Me] && this[tt] === "r+") try {
597
- t = I.openSync(this[U], this[tt], this[ie]);
598
- } catch (e) {
599
- if (e?.code === "ENOENT") return this[tt] = "w", this[at]();
600
- throw e;
601
- }
602
- else t = I.openSync(this[U], this[tt], this[ie]);
603
- this[Ht](null, t);
604
- }
605
- [H]() {
606
- if (this[ht] && typeof this[m] == "number") {
607
- let t = this[m];
608
- this[m] = void 0, I.closeSync(t), this.emit("close");
609
- }
610
- }
611
- [ve](t) {
612
- let e = !0;
613
- try {
614
- this[Pt](null, I.writeSync(this[m], t, 0, t.length, this[ot])), e = !1;
615
- } finally {
616
- if (e) try {
617
- this[H]();
618
- } catch {}
619
- }
620
- }
621
- };
622
- var jr = /* @__PURE__ */ new Map([
623
- ["C", "cwd"],
624
- ["f", "file"],
625
- ["z", "gzip"],
626
- ["P", "preservePaths"],
627
- ["U", "unlink"],
628
- ["strip-components", "strip"],
629
- ["stripComponents", "strip"],
630
- ["keep-newer", "newer"],
631
- ["keepNewer", "newer"],
632
- ["keep-newer-files", "newer"],
633
- ["keepNewerFiles", "newer"],
634
- ["k", "keep"],
635
- ["keep-existing", "keep"],
636
- ["keepExisting", "keep"],
637
- ["m", "noMtime"],
638
- ["no-mtime", "noMtime"],
639
- ["p", "preserveOwner"],
640
- ["L", "follow"],
641
- ["h", "follow"],
642
- ["onentry", "onReadEntry"]
643
- ]);
644
- var Fs = (s) => !!s.sync && !!s.file;
645
- var ks = (s) => !s.sync && !!s.file;
646
- var vs = (s) => !!s.sync && !s.file;
647
- var Ms = (s) => !s.sync && !s.file;
648
- var Bs = (s) => !!s.file;
649
- var tn = (s) => {
650
- return jr.get(s) || s;
651
- };
652
- var se = (s = {}) => {
653
- if (!s) return {};
654
- let t = {};
655
- for (let [e, i] of Object.entries(s)) {
656
- let r = tn(e);
657
- t[r] = i;
658
- }
659
- return t.chmod === void 0 && t.noChmod === !1 && (t.chmod = !0), delete t.noChmod, t;
660
- };
661
- var K = (s, t, e, i, r) => Object.assign((n = [], o, h) => {
662
- Array.isArray(n) && (o = n, n = {}), typeof o == "function" && (h = o, o = void 0), o = o ? Array.from(o) : [];
663
- let a = se(n);
664
- if (r?.(a, o), Fs(a)) {
665
- if (typeof h == "function") throw new TypeError("callback not supported for sync tar functions");
666
- return s(a, o);
667
- } else if (ks(a)) {
668
- let l = t(a, o);
669
- return h ? l.then(() => h(), h) : l;
670
- } else if (vs(a)) {
671
- if (typeof h == "function") throw new TypeError("callback not supported for sync tar functions");
672
- return e(a, o);
673
- } else if (Ms(a)) {
674
- if (typeof h == "function") throw new TypeError("callback only supported with file option");
675
- return i(a, o);
676
- }
677
- throw new Error("impossible options??");
678
- }, {
679
- syncFile: s,
680
- asyncFile: t,
681
- syncNoFile: e,
682
- asyncNoFile: i,
683
- validate: r
684
- });
685
- var sn = en.constants || { ZLIB_VERNUM: 4736 };
686
- var M = Object.freeze(Object.assign(Object.create(null), {
687
- Z_NO_FLUSH: 0,
688
- Z_PARTIAL_FLUSH: 1,
689
- Z_SYNC_FLUSH: 2,
690
- Z_FULL_FLUSH: 3,
691
- Z_FINISH: 4,
692
- Z_BLOCK: 5,
693
- Z_OK: 0,
694
- Z_STREAM_END: 1,
695
- Z_NEED_DICT: 2,
696
- Z_ERRNO: -1,
697
- Z_STREAM_ERROR: -2,
698
- Z_DATA_ERROR: -3,
699
- Z_MEM_ERROR: -4,
700
- Z_BUF_ERROR: -5,
701
- Z_VERSION_ERROR: -6,
702
- Z_NO_COMPRESSION: 0,
703
- Z_BEST_SPEED: 1,
704
- Z_BEST_COMPRESSION: 9,
705
- Z_DEFAULT_COMPRESSION: -1,
706
- Z_FILTERED: 1,
707
- Z_HUFFMAN_ONLY: 2,
708
- Z_RLE: 3,
709
- Z_FIXED: 4,
710
- Z_DEFAULT_STRATEGY: 0,
711
- DEFLATE: 1,
712
- INFLATE: 2,
713
- GZIP: 3,
714
- GUNZIP: 4,
715
- DEFLATERAW: 5,
716
- INFLATERAW: 6,
717
- UNZIP: 7,
718
- BROTLI_DECODE: 8,
719
- BROTLI_ENCODE: 9,
720
- Z_MIN_WINDOWBITS: 8,
721
- Z_MAX_WINDOWBITS: 15,
722
- Z_DEFAULT_WINDOWBITS: 15,
723
- Z_MIN_CHUNK: 64,
724
- Z_MAX_CHUNK: 1 / 0,
725
- Z_DEFAULT_CHUNK: 16384,
726
- Z_MIN_MEMLEVEL: 1,
727
- Z_MAX_MEMLEVEL: 9,
728
- Z_DEFAULT_MEMLEVEL: 8,
729
- Z_MIN_LEVEL: -1,
730
- Z_MAX_LEVEL: 9,
731
- Z_DEFAULT_LEVEL: -1,
732
- BROTLI_OPERATION_PROCESS: 0,
733
- BROTLI_OPERATION_FLUSH: 1,
734
- BROTLI_OPERATION_FINISH: 2,
735
- BROTLI_OPERATION_EMIT_METADATA: 3,
736
- BROTLI_MODE_GENERIC: 0,
737
- BROTLI_MODE_TEXT: 1,
738
- BROTLI_MODE_FONT: 2,
739
- BROTLI_DEFAULT_MODE: 0,
740
- BROTLI_MIN_QUALITY: 0,
741
- BROTLI_MAX_QUALITY: 11,
742
- BROTLI_DEFAULT_QUALITY: 11,
743
- BROTLI_MIN_WINDOW_BITS: 10,
744
- BROTLI_MAX_WINDOW_BITS: 24,
745
- BROTLI_LARGE_MAX_WINDOW_BITS: 30,
746
- BROTLI_DEFAULT_WINDOW: 22,
747
- BROTLI_MIN_INPUT_BLOCK_BITS: 16,
748
- BROTLI_MAX_INPUT_BLOCK_BITS: 24,
749
- BROTLI_PARAM_MODE: 0,
750
- BROTLI_PARAM_QUALITY: 1,
751
- BROTLI_PARAM_LGWIN: 2,
752
- BROTLI_PARAM_LGBLOCK: 3,
753
- BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: 4,
754
- BROTLI_PARAM_SIZE_HINT: 5,
755
- BROTLI_PARAM_LARGE_WINDOW: 6,
756
- BROTLI_PARAM_NPOSTFIX: 7,
757
- BROTLI_PARAM_NDIRECT: 8,
758
- BROTLI_DECODER_RESULT_ERROR: 0,
759
- BROTLI_DECODER_RESULT_SUCCESS: 1,
760
- BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: 2,
761
- BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: 3,
762
- BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: 0,
763
- BROTLI_DECODER_PARAM_LARGE_WINDOW: 1,
764
- BROTLI_DECODER_NO_ERROR: 0,
765
- BROTLI_DECODER_SUCCESS: 1,
766
- BROTLI_DECODER_NEEDS_MORE_INPUT: 2,
767
- BROTLI_DECODER_NEEDS_MORE_OUTPUT: 3,
768
- BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: -1,
769
- BROTLI_DECODER_ERROR_FORMAT_RESERVED: -2,
770
- BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: -3,
771
- BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: -4,
772
- BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: -5,
773
- BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: -6,
774
- BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: -7,
775
- BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: -8,
776
- BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: -9,
777
- BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: -10,
778
- BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: -11,
779
- BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: -12,
780
- BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: -13,
781
- BROTLI_DECODER_ERROR_FORMAT_PADDING_1: -14,
782
- BROTLI_DECODER_ERROR_FORMAT_PADDING_2: -15,
783
- BROTLI_DECODER_ERROR_FORMAT_DISTANCE: -16,
784
- BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: -19,
785
- BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: -20,
786
- BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: -21,
787
- BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: -22,
788
- BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: -25,
789
- BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: -26,
790
- BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: -27,
791
- BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: -30,
792
- BROTLI_DECODER_ERROR_UNREACHABLE: -31
793
- }, sn));
794
- var rn = Buffer$1.concat;
795
- var zs = Object.getOwnPropertyDescriptor(Buffer$1, "concat");
796
- var nn = (s) => s;
797
- var Bi = zs?.writable === !0 || zs?.set !== void 0 ? (s) => {
798
- Buffer$1.concat = s ? nn : rn;
799
- } : (s) => {};
800
- var Tt = Symbol("_superWrite");
801
- var Gt = class extends Error {
802
- code;
803
- errno;
804
- constructor(t, e) {
805
- super("zlib: " + t.message, { cause: t }), this.code = t.code, this.errno = t.errno, this.code || (this.code = "ZLIB_ERROR"), this.message = "zlib: " + t.message, Error.captureStackTrace(this, e ?? this.constructor);
806
- }
807
- get name() {
808
- return "ZlibError";
809
- }
810
- };
811
- var Pi = Symbol("flushFlag");
812
- var re = class extends A {
813
- #t = !1;
814
- #i = !1;
815
- #s;
816
- #n;
817
- #r;
818
- #e;
819
- #o;
820
- get sawError() {
821
- return this.#t;
822
- }
823
- get handle() {
824
- return this.#e;
825
- }
826
- get flushFlag() {
827
- return this.#s;
828
- }
829
- constructor(t, e) {
830
- if (!t || typeof t != "object") throw new TypeError("invalid options for ZlibBase constructor");
831
- if (super(t), this.#s = t.flush ?? 0, this.#n = t.finishFlush ?? 0, this.#r = t.fullFlushFlag ?? 0, typeof Ps[e] != "function") throw new TypeError("Compression method not supported: " + e);
832
- try {
833
- this.#e = new Ps[e](t);
834
- } catch (i) {
835
- throw new Gt(i, this.constructor);
836
- }
837
- this.#o = (i) => {
838
- this.#t || (this.#t = !0, this.close(), this.emit("error", i));
839
- }, this.#e?.on("error", (i) => this.#o(new Gt(i))), this.once("end", () => this.close);
840
- }
841
- close() {
842
- this.#e && (this.#e.close(), this.#e = void 0, this.emit("close"));
843
- }
844
- reset() {
845
- if (!this.#t) return zi(this.#e, "zlib binding closed"), this.#e.reset?.();
846
- }
847
- flush(t) {
848
- this.ended || (typeof t != "number" && (t = this.#r), this.write(Object.assign(Buffer$1.alloc(0), { [Pi]: t })));
849
- }
850
- end(t, e, i) {
851
- return typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), t && (e ? this.write(t, e) : this.write(t)), this.flush(this.#n), this.#i = !0, super.end(i);
852
- }
853
- get ended() {
854
- return this.#i;
855
- }
856
- [Tt](t) {
857
- return super.write(t);
858
- }
859
- write(t, e, i) {
860
- if (typeof e == "function" && (i = e, e = "utf8"), typeof t == "string" && (t = Buffer$1.from(t, e)), this.#t) return;
861
- zi(this.#e, "zlib binding closed");
862
- let r = this.#e._handle, n = r.close;
863
- r.close = () => {};
864
- let o = this.#e.close;
865
- this.#e.close = () => {}, Bi(!0);
866
- let h;
867
- try {
868
- let l = typeof t[Pi] == "number" ? t[Pi] : this.#s;
869
- h = this.#e._processChunk(t, l), Bi(!1);
870
- } catch (l) {
871
- Bi(!1), this.#o(new Gt(l, this.write));
872
- } finally {
873
- this.#e && (this.#e._handle = r, r.close = n, this.#e.close = o, this.#e.removeAllListeners("error"));
874
- }
875
- this.#e && this.#e.on("error", (l) => this.#o(new Gt(l, this.write)));
876
- let a;
877
- if (h) if (Array.isArray(h) && h.length > 0) {
878
- let l = h[0];
879
- a = this[Tt](Buffer$1.from(l));
880
- for (let c = 1; c < h.length; c++) a = this[Tt](h[c]);
881
- } else a = this[Tt](Buffer$1.from(h));
882
- return i && i(), a;
883
- }
884
- };
885
- var Pe = class extends re {
886
- #t;
887
- #i;
888
- constructor(t, e) {
889
- t = t || {}, t.flush = t.flush || M.Z_NO_FLUSH, t.finishFlush = t.finishFlush || M.Z_FINISH, t.fullFlushFlag = M.Z_FULL_FLUSH, super(t, e), this.#t = t.level, this.#i = t.strategy;
890
- }
891
- params(t, e) {
892
- if (!this.sawError) {
893
- if (!this.handle) throw new Error("cannot switch params when binding is closed");
894
- if (!this.handle.params) throw new Error("not supported in this implementation");
895
- if (this.#t !== t || this.#i !== e) {
896
- this.flush(M.Z_SYNC_FLUSH), zi(this.handle, "zlib binding closed");
897
- let i = this.handle.flush;
898
- this.handle.flush = (r, n) => {
899
- typeof r == "function" && (n = r, r = this.flushFlag), this.flush(r), n?.();
900
- };
901
- try {
902
- this.handle.params(t, e);
903
- } finally {
904
- this.handle.flush = i;
905
- }
906
- this.handle && (this.#t = t, this.#i = e);
907
- }
908
- }
909
- }
910
- };
911
- var ze = class extends Pe {
912
- #t;
913
- constructor(t) {
914
- super(t, "Gzip"), this.#t = t && !!t.portable;
915
- }
916
- [Tt](t) {
917
- return this.#t ? (this.#t = !1, t[9] = 255, super[Tt](t)) : super[Tt](t);
918
- }
919
- };
920
- var Ue = class extends Pe {
921
- constructor(t) {
922
- super(t, "Unzip");
923
- }
924
- };
925
- var He = class extends re {
926
- constructor(t, e) {
927
- t = t || {}, t.flush = t.flush || M.BROTLI_OPERATION_PROCESS, t.finishFlush = t.finishFlush || M.BROTLI_OPERATION_FINISH, t.fullFlushFlag = M.BROTLI_OPERATION_FLUSH, super(t, e);
928
- }
929
- };
930
- var We = class extends He {
931
- constructor(t) {
932
- super(t, "BrotliCompress");
933
- }
934
- };
935
- var Ge = class extends He {
936
- constructor(t) {
937
- super(t, "BrotliDecompress");
938
- }
939
- };
940
- var Ze = class extends re {
941
- constructor(t, e) {
942
- t = t || {}, t.flush = t.flush || M.ZSTD_e_continue, t.finishFlush = t.finishFlush || M.ZSTD_e_end, t.fullFlushFlag = M.ZSTD_e_flush, super(t, e);
943
- }
944
- };
945
- var Ye = class extends Ze {
946
- constructor(t) {
947
- super(t, "ZstdCompress");
948
- }
949
- };
950
- var Ke = class extends Ze {
951
- constructor(t) {
952
- super(t, "ZstdDecompress");
953
- }
954
- };
955
- var Us = (s, t) => {
956
- if (Number.isSafeInteger(s)) s < 0 ? an(s, t) : hn(s, t);
957
- else throw Error("cannot encode number outside of javascript safe integer range");
958
- return t;
959
- };
960
- var hn = (s, t) => {
961
- t[0] = 128;
962
- for (var e = t.length; e > 1; e--) t[e - 1] = s & 255, s = Math.floor(s / 256);
963
- };
964
- var an = (s, t) => {
965
- t[0] = 255;
966
- var e = !1;
967
- s = s * -1;
968
- for (var i = t.length; i > 1; i--) {
969
- var r = s & 255;
970
- s = Math.floor(s / 256), e ? t[i - 1] = Ws(r) : r === 0 ? t[i - 1] = 0 : (e = !0, t[i - 1] = Gs(r));
971
- }
972
- };
973
- var Hs = (s) => {
974
- let t = s[0], e = t === 128 ? cn(s.subarray(1, s.length)) : t === 255 ? ln(s) : null;
975
- if (e === null) throw Error("invalid base256 encoding");
976
- if (!Number.isSafeInteger(e)) throw Error("parsed number outside of javascript safe integer range");
977
- return e;
978
- };
979
- var ln = (s) => {
980
- for (var t = s.length, e = 0, i = !1, r = t - 1; r > -1; r--) {
981
- var n = Number(s[r]), o;
982
- i ? o = Ws(n) : n === 0 ? o = n : (i = !0, o = Gs(n)), o !== 0 && (e -= o * Math.pow(256, t - r - 1));
983
- }
984
- return e;
985
- };
986
- var cn = (s) => {
987
- for (var t = s.length, e = 0, i = t - 1; i > -1; i--) {
988
- var r = Number(s[i]);
989
- r !== 0 && (e += r * Math.pow(256, t - i - 1));
990
- }
991
- return e;
992
- };
993
- var Ws = (s) => (255 ^ s) & 255;
994
- var Gs = (s) => (255 ^ s) + 1 & 255;
995
- Ur({}, {
996
- code: () => Ve,
997
- isCode: () => ne,
998
- isName: () => dn,
999
- name: () => oe,
1000
- normalFsTypes: () => Ui
1001
- });
1002
- var ne = (s) => oe.has(s);
1003
- var dn = (s) => Ve.has(s);
1004
- var Ui = /* @__PURE__ */ new Set([
1005
- "0",
1006
- "",
1007
- "1",
1008
- "2",
1009
- "3",
1010
- "4",
1011
- "5",
1012
- "6",
1013
- "7",
1014
- "D"
1015
- ]);
1016
- var oe = /* @__PURE__ */ new Map([
1017
- ["0", "File"],
1018
- ["", "OldFile"],
1019
- ["1", "Link"],
1020
- ["2", "SymbolicLink"],
1021
- ["3", "CharacterDevice"],
1022
- ["4", "BlockDevice"],
1023
- ["5", "Directory"],
1024
- ["6", "FIFO"],
1025
- ["7", "ContiguousFile"],
1026
- ["g", "GlobalExtendedHeader"],
1027
- ["x", "ExtendedHeader"],
1028
- ["A", "SolarisACL"],
1029
- ["D", "GNUDumpDir"],
1030
- ["I", "Inode"],
1031
- ["K", "NextFileHasLongLinkpath"],
1032
- ["L", "NextFileHasLongPath"],
1033
- ["M", "ContinuationFile"],
1034
- ["N", "OldGnuLongPath"],
1035
- ["S", "SparseFile"],
1036
- ["V", "TapeVolumeHeader"],
1037
- ["X", "OldExtendedHeader"]
1038
- ]);
1039
- var Ve = new Map(Array.from(oe).map((s) => [s[1], s[0]]));
1040
- var un = (s) => s === void 0 || s < 0 ? void 0 : s;
1041
- var F = class {
1042
- cksumValid = !1;
1043
- needPax = !1;
1044
- nullBlock = !1;
1045
- block;
1046
- path;
1047
- mode;
1048
- uid;
1049
- gid;
1050
- size;
1051
- cksum;
1052
- #t = "Unsupported";
1053
- linkpath;
1054
- uname;
1055
- gname;
1056
- devmaj = 0;
1057
- devmin = 0;
1058
- atime;
1059
- ctime;
1060
- mtime;
1061
- charset;
1062
- comment;
1063
- constructor(t, e = 0, i, r) {
1064
- Buffer.isBuffer(t) ? this.decode(t, e || 0, i, r) : t && this.#i(t);
1065
- }
1066
- decode(t, e, i, r) {
1067
- if (e || (e = 0), !t || !(t.length >= e + 512)) throw new Error("need 512 bytes for header");
1068
- let n = xt(t, e + 156, 1), o = Ui.has(n), h = o ? i : void 0, a = o ? r : void 0;
1069
- if (this.path = h?.path ?? xt(t, e, 100), this.mode = h?.mode ?? a?.mode ?? lt(t, e + 100, 8), this.uid = h?.uid ?? a?.uid ?? lt(t, e + 108, 8), this.gid = h?.gid ?? a?.gid ?? lt(t, e + 116, 8), this.size = un(h?.size ?? a?.size ?? lt(t, e + 124, 12)), this.mtime = h?.mtime ?? a?.mtime ?? Wi(t, e + 136, 12), this.cksum = lt(t, e + 148, 12), a && this.#i(a, !0), h && this.#i(h), ne(n) && (this.#t = n || "0"), this.#t === "0" && this.path.slice(-1) === "/" && (this.#t = "5"), this.#t === "5" && (this.size = 0), this.linkpath = xt(t, e + 157, 100), t.subarray(e + 257, e + 265).toString() === "ustar\x0000") if (this.uname = h?.uname ?? a?.uname ?? xt(t, e + 265, 32), this.gname = h?.gname ?? a?.gname ?? xt(t, e + 297, 32), this.devmaj = h?.devmaj ?? a?.devmaj ?? lt(t, e + 329, 8) ?? 0, this.devmin = h?.devmin ?? a?.devmin ?? lt(t, e + 337, 8) ?? 0, t[e + 475] !== 0) {
1070
- let c = xt(t, e + 345, 155);
1071
- this.path = c + "/" + this.path;
1072
- } else {
1073
- let c = xt(t, e + 345, 130);
1074
- c && (this.path = c + "/" + this.path), this.atime = i?.atime ?? r?.atime ?? Wi(t, e + 476, 12), this.ctime = i?.ctime ?? r?.ctime ?? Wi(t, e + 488, 12);
1075
- }
1076
- let l = 256;
1077
- for (let c = e; c < e + 148; c++) l += t[c];
1078
- for (let c = e + 156; c < e + 512; c++) l += t[c];
1079
- this.cksumValid = l === this.cksum, this.cksum === void 0 && l === 256 && (this.nullBlock = !0);
1080
- }
1081
- #i(t, e = !1) {
1082
- Object.assign(this, Object.fromEntries(Object.entries(t).filter(([i, r]) => !(r == null || i === "size" && Number(r) < 0 || i === "path" && e || i === "linkpath" && e || i === "global"))));
1083
- }
1084
- encode(t, e = 0) {
1085
- if (t || (t = this.block = Buffer.alloc(512)), this.#t === "Unsupported" && (this.#t = "0"), !(t.length >= e + 512)) throw new Error("need 512 bytes for header");
1086
- let i = this.ctime || this.atime ? 130 : 155, r = mn(this.path || "", i), n = r[0], o = r[1];
1087
- this.needPax = !!r[2], this.needPax = Lt(t, e, 100, n) || this.needPax, this.needPax = ct(t, e + 100, 8, this.mode) || this.needPax, this.needPax = ct(t, e + 108, 8, this.uid) || this.needPax, this.needPax = ct(t, e + 116, 8, this.gid) || this.needPax, this.needPax = ct(t, e + 124, 12, this.size) || this.needPax, this.needPax = Gi(t, e + 136, 12, this.mtime) || this.needPax, t[e + 156] = Number(this.#t.codePointAt(0)), this.needPax = Lt(t, e + 157, 100, this.linkpath) || this.needPax, t.write("ustar\x0000", e + 257, 8), this.needPax = Lt(t, e + 265, 32, this.uname) || this.needPax, this.needPax = Lt(t, e + 297, 32, this.gname) || this.needPax, this.needPax = ct(t, e + 329, 8, this.devmaj) || this.needPax, this.needPax = ct(t, e + 337, 8, this.devmin) || this.needPax, this.needPax = Lt(t, e + 345, i, o) || this.needPax, t[e + 475] !== 0 ? this.needPax = Lt(t, e + 345, 155, o) || this.needPax : (this.needPax = Lt(t, e + 345, 130, o) || this.needPax, this.needPax = Gi(t, e + 476, 12, this.atime) || this.needPax, this.needPax = Gi(t, e + 488, 12, this.ctime) || this.needPax);
1088
- let h = 256;
1089
- for (let a = e; a < e + 148; a++) h += t[a];
1090
- for (let a = e + 156; a < e + 512; a++) h += t[a];
1091
- return this.cksum = h, ct(t, e + 148, 8, this.cksum), this.cksumValid = !0, this.needPax;
1092
- }
1093
- get type() {
1094
- return this.#t === "Unsupported" ? this.#t : oe.get(this.#t);
1095
- }
1096
- get typeKey() {
1097
- return this.#t;
1098
- }
1099
- set type(t) {
1100
- let e = String(Ve.get(t));
1101
- if (ne(e) || e === "Unsupported") this.#t = e;
1102
- else if (ne(t)) this.#t = t;
1103
- else throw new TypeError("invalid entry type: " + t);
1104
- }
1105
- };
1106
- var mn = (s, t) => {
1107
- let i = s, r = "", n, o = posix.parse(s).root || ".";
1108
- if (Buffer.byteLength(i) < 100) n = [
1109
- i,
1110
- r,
1111
- !1
1112
- ];
1113
- else {
1114
- r = posix.dirname(i), i = posix.basename(i);
1115
- do
1116
- Buffer.byteLength(i) <= 100 && Buffer.byteLength(r) <= t ? n = [
1117
- i,
1118
- r,
1119
- !1
1120
- ] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r) <= t ? n = [
1121
- i.slice(0, 99),
1122
- r,
1123
- !0
1124
- ] : (i = posix.join(posix.basename(r), i), r = posix.dirname(r));
1125
- while (r !== o && n === void 0);
1126
- n || (n = [
1127
- s.slice(0, 99),
1128
- "",
1129
- !0
1130
- ]);
1131
- }
1132
- return n;
1133
- };
1134
- var xt = (s, t, e) => s.subarray(t, t + e).toString("utf8").replace(/\0.*/, "");
1135
- var Wi = (s, t, e) => pn(lt(s, t, e));
1136
- var pn = (s) => s === void 0 ? void 0 : /* @__PURE__ */ new Date(s * 1e3);
1137
- var lt = (s, t, e) => Number(s[t]) & 128 ? Hs(s.subarray(t, t + e)) : wn(s, t, e);
1138
- var En = (s) => isNaN(s) ? void 0 : s;
1139
- var wn = (s, t, e) => En(parseInt(s.subarray(t, t + e).toString("utf8").replace(/\0.*$/, "").trim(), 8));
1140
- var Sn = {
1141
- 12: 8589934591,
1142
- 8: 2097151
1143
- };
1144
- var ct = (s, t, e, i) => i === void 0 ? !1 : i > Sn[e] || i < 0 ? (Us(i, s.subarray(t, t + e)), !0) : (yn(s, t, e, i), !1);
1145
- var yn = (s, t, e, i) => s.write(Rn(i, e), t, e, "ascii");
1146
- var Rn = (s, t) => gn(Math.floor(s).toString(8), t);
1147
- var gn = (s, t) => (s.length === t - 1 ? s : new Array(t - s.length - 1).join("0") + s + " ") + "\0";
1148
- var Gi = (s, t, e, i) => i === void 0 ? !1 : ct(s, t, e, i.getTime() / 1e3);
1149
- var bn = new Array(156).join("\0");
1150
- var Lt = (s, t, e, i) => i === void 0 ? !1 : (s.write(i + bn, t, e, "utf8"), i.length !== Buffer.byteLength(i) || i.length > e);
1151
- var ft = class s {
1152
- atime;
1153
- mtime;
1154
- ctime;
1155
- charset;
1156
- comment;
1157
- gid;
1158
- uid;
1159
- gname;
1160
- uname;
1161
- linkpath;
1162
- dev;
1163
- ino;
1164
- nlink;
1165
- path;
1166
- size;
1167
- mode;
1168
- global;
1169
- constructor(t, e = !1) {
1170
- this.atime = t.atime, this.charset = t.charset, this.comment = t.comment, this.ctime = t.ctime, this.dev = t.dev, this.gid = t.gid, this.global = e, this.gname = t.gname, this.ino = t.ino, this.linkpath = t.linkpath, this.mtime = t.mtime, this.nlink = t.nlink, this.path = t.path, this.size = t.size, this.uid = t.uid, this.uname = t.uname;
1171
- }
1172
- encode() {
1173
- let t = this.encodeBody();
1174
- if (t === "") return Buffer.allocUnsafe(0);
1175
- let e = Buffer.byteLength(t), i = 512 * Math.ceil(1 + e / 512), r = Buffer.allocUnsafe(i);
1176
- for (let n = 0; n < 512; n++) r[n] = 0;
1177
- new F({
1178
- path: ("PaxHeader/" + basename(this.path ?? "")).slice(0, 99),
1179
- mode: this.mode || 420,
1180
- uid: this.uid,
1181
- gid: this.gid,
1182
- size: e,
1183
- mtime: this.mtime,
1184
- type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader",
1185
- linkpath: "",
1186
- uname: this.uname || "",
1187
- gname: this.gname || "",
1188
- devmaj: 0,
1189
- devmin: 0,
1190
- atime: this.atime,
1191
- ctime: this.ctime
1192
- }).encode(r), r.write(t, 512, e, "utf8");
1193
- for (let n = e + 512; n < r.length; n++) r[n] = 0;
1194
- return r;
1195
- }
1196
- encodeBody() {
1197
- return this.encodeField("path") + this.encodeField("ctime") + this.encodeField("atime") + this.encodeField("dev") + this.encodeField("ino") + this.encodeField("nlink") + this.encodeField("charset") + this.encodeField("comment") + this.encodeField("gid") + this.encodeField("gname") + this.encodeField("linkpath") + this.encodeField("mtime") + this.encodeField("size") + this.encodeField("uid") + this.encodeField("uname");
1198
- }
1199
- encodeField(t) {
1200
- if (this[t] === void 0) return "";
1201
- let e = this[t], i = e instanceof Date ? e.getTime() / 1e3 : e, r = " " + (t === "dev" || t === "ino" || t === "nlink" ? "SCHILY." : "") + t + "=" + i + `
1202
- `, n = Buffer.byteLength(r), o = Math.floor(Math.log(n) / Math.log(10)) + 1;
1203
- return n + o >= Math.pow(10, o) && (o += 1), o + n + r;
1204
- }
1205
- static parse(t, e, i = !1) {
1206
- return new s(On(Tn(t), e), i);
1207
- }
1208
- };
1209
- var On = (s, t) => t ? Object.assign({}, t, s) : s;
1210
- var Tn = (s) => s.replace(/\n$/, "").split(`
1211
- `).reduce(xn, Object.create(null));
1212
- var xn = (s, t) => {
1213
- let e = parseInt(t, 10);
1214
- if (e !== Buffer.byteLength(t) + 1) return s;
1215
- t = t.slice((e + " ").length);
1216
- let i = t.split("="), r = i.shift();
1217
- if (!r) return s;
1218
- let n = r.replace(/^SCHILY\.(dev|ino|nlink)/, "$1"), o = i.join("=").replace(/\0.*/, "");
1219
- switch (n) {
1220
- case "path":
1221
- case "linkpath":
1222
- case "type":
1223
- case "charset":
1224
- case "comment":
1225
- case "gname":
1226
- case "uname":
1227
- s[n] = o;
1228
- break;
1229
- case "ctime":
1230
- case "atime":
1231
- case "mtime":
1232
- s[n] = /* @__PURE__ */ new Date(Number(o) * 1e3);
1233
- break;
1234
- case "size":
1235
- let h = +o;
1236
- h >= 0 && (s[n] = h);
1237
- break;
1238
- case "gid":
1239
- case "uid":
1240
- case "dev":
1241
- case "ino":
1242
- case "nlink":
1243
- case "mode": s[n] = +o;
1244
- }
1245
- return s;
1246
- };
1247
- var f = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) !== "win32" ? (s) => String(s) : (s) => String(s).replaceAll(/\\/g, "/");
1248
- var $e = class extends A {
1249
- extended;
1250
- globalExtended;
1251
- header;
1252
- startBlockSize;
1253
- blockRemain;
1254
- remain;
1255
- type;
1256
- meta = !1;
1257
- ignore = !1;
1258
- path;
1259
- mode;
1260
- uid;
1261
- gid;
1262
- uname;
1263
- gname;
1264
- size = 0;
1265
- mtime;
1266
- atime;
1267
- ctime;
1268
- linkpath;
1269
- dev;
1270
- ino;
1271
- nlink;
1272
- invalid = !1;
1273
- absolute;
1274
- unsupported = !1;
1275
- constructor(t, e, i) {
1276
- switch (super({}), this.pause(), this.extended = e, this.globalExtended = i, this.header = t, this.remain = t.size ?? 0, this.startBlockSize = 512 * Math.ceil(this.remain / 512), this.blockRemain = this.startBlockSize, this.type = t.type, this.type) {
1277
- case "File":
1278
- case "OldFile":
1279
- case "Link":
1280
- case "SymbolicLink":
1281
- case "CharacterDevice":
1282
- case "BlockDevice":
1283
- case "Directory":
1284
- case "FIFO":
1285
- case "ContiguousFile":
1286
- case "GNUDumpDir": break;
1287
- case "NextFileHasLongLinkpath":
1288
- case "NextFileHasLongPath":
1289
- case "OldGnuLongPath":
1290
- case "GlobalExtendedHeader":
1291
- case "ExtendedHeader":
1292
- case "OldExtendedHeader":
1293
- this.meta = !0;
1294
- break;
1295
- default: this.ignore = !0;
1296
- }
1297
- if (!t.path) throw new Error("no path provided for tar.ReadEntry");
1298
- this.path = f(t.path), this.mode = t.mode, this.mode && (this.mode = this.mode & 4095), this.uid = t.uid, this.gid = t.gid, this.uname = t.uname, this.gname = t.gname, this.size = this.remain, this.mtime = t.mtime, this.atime = t.atime, this.ctime = t.ctime, this.linkpath = t.linkpath ? f(t.linkpath) : void 0, this.uname = t.uname, this.gname = t.gname, e && this.#t(e), i && this.#t(i, !0);
1299
- }
1300
- write(t) {
1301
- let e = t.length;
1302
- if (e > this.blockRemain) throw new Error("writing more to entry than is appropriate");
1303
- let i = this.remain, r = this.blockRemain;
1304
- return this.remain = Math.max(0, i - e), this.blockRemain = Math.max(0, r - e), this.ignore ? !0 : i >= e ? super.write(t) : super.write(t.subarray(0, i));
1305
- }
1306
- #t(t, e = !1) {
1307
- t.path && (t.path = f(t.path)), t.linkpath && (t.linkpath = f(t.linkpath)), Object.assign(this, Object.fromEntries(Object.entries(t).filter(([i, r]) => !(r == null || i === "path" && e))));
1308
- }
1309
- };
1310
- var Dt = (s, t, e, i = {}) => {
1311
- s.file && (i.file = s.file), s.cwd && (i.cwd = s.cwd), i.code = e instanceof Error && e.code || t, i.tarCode = t, !s.strict && i.recoverable !== !1 ? (e instanceof Error && (i = Object.assign(e, i), e = e.message), s.emit("warn", t, e, i)) : e instanceof Error ? s.emit("error", Object.assign(e, i)) : s.emit("error", Object.assign(/* @__PURE__ */ new Error(`${t}: ${e}`), i));
1312
- };
1313
- var Nn = 1048576;
1314
- var Xi = Buffer.from([31, 139]);
1315
- var qi = Buffer.from([
1316
- 40,
1317
- 181,
1318
- 47,
1319
- 253
1320
- ]);
1321
- var An = Math.max(Xi.length, qi.length);
1322
- var B = Symbol("state");
1323
- var Nt = Symbol("writeEntry");
1324
- var it = Symbol("readEntry");
1325
- var Zi = Symbol("nextEntry");
1326
- var Zs = Symbol("processEntry");
1327
- var V = Symbol("extendedHeader");
1328
- var he = Symbol("globalExtendedHeader");
1329
- var dt = Symbol("meta");
1330
- var Ys = Symbol("emitMeta");
1331
- var p = Symbol("buffer");
1332
- var st = Symbol("queue");
1333
- var ut = Symbol("ended");
1334
- var Yi = Symbol("emittedEnd");
1335
- var At = Symbol("emit");
1336
- var w = Symbol("unzip");
1337
- var Xe = Symbol("consumeChunk");
1338
- var qe = Symbol("consumeChunkSub");
1339
- var Ki = Symbol("consumeBody");
1340
- var Ks = Symbol("consumeMeta");
1341
- var Vs = Symbol("consumeHeader");
1342
- var ae = Symbol("consuming");
1343
- var Vi = Symbol("bufferConcat");
1344
- var Qe = Symbol("maybeEnd");
1345
- var Yt = Symbol("writing");
1346
- var $ = Symbol("aborted");
1347
- var Je = Symbol("onDone");
1348
- var It = Symbol("sawValidEntry");
1349
- var je = Symbol("sawNullBlock");
1350
- var ti = Symbol("sawEOF");
1351
- var $s = Symbol("closeStream");
1352
- var In = 1e3;
1353
- var le = Symbol("compressedBytesRead");
1354
- var $i = Symbol("decompressedBytesRead");
1355
- var Xs = Symbol("checkDecompressionRatio");
1356
- var Cn = () => !0;
1357
- var rt = class extends EventEmitter {
1358
- file;
1359
- strict;
1360
- maxMetaEntrySize;
1361
- filter;
1362
- brotli;
1363
- zstd;
1364
- maxDecompressionRatio;
1365
- writable = !0;
1366
- readable = !1;
1367
- [st] = [];
1368
- [p];
1369
- [it];
1370
- [Nt];
1371
- [B] = "begin";
1372
- [dt] = "";
1373
- [V];
1374
- [he];
1375
- [ut] = !1;
1376
- [w];
1377
- [$] = !1;
1378
- [It];
1379
- [je] = !1;
1380
- [ti] = !1;
1381
- [Yt] = !1;
1382
- [ae] = !1;
1383
- [Yi] = !1;
1384
- [le] = 0;
1385
- [$i] = 0;
1386
- constructor(t = {}) {
1387
- super(), this.file = t.file || "", this.on(Je, () => {
1388
- (this[B] === "begin" || this[It] === !1) && this.warn("TAR_BAD_ARCHIVE", "Unrecognized archive format");
1389
- }), t.ondone ? this.on(Je, t.ondone) : this.on(Je, () => {
1390
- this.emit("prefinish"), this.emit("finish"), this.emit("end");
1391
- }), this.strict = !!t.strict, this.maxDecompressionRatio = typeof t.maxDecompressionRatio == "number" ? t.maxDecompressionRatio : In, this.maxMetaEntrySize = t.maxMetaEntrySize || Nn, this.filter = typeof t.filter == "function" ? t.filter : Cn;
1392
- let e = t.file && (t.file.endsWith(".tar.br") || t.file.endsWith(".tbr"));
1393
- this.brotli = !(t.gzip || t.zstd) && t.brotli !== void 0 ? t.brotli : e ? void 0 : !1;
1394
- let i = t.file && (t.file.endsWith(".tar.zst") || t.file.endsWith(".tzst"));
1395
- this.zstd = !(t.gzip || t.brotli) && t.zstd !== void 0 ? t.zstd : i ? !0 : void 0, this.on("end", () => this[$s]()), typeof t.onwarn == "function" && this.on("warn", t.onwarn), typeof t.onReadEntry == "function" && this.on("entry", t.onReadEntry);
1396
- }
1397
- warn(t, e, i = {}) {
1398
- Dt(this, t, e, i);
1399
- }
1400
- [Vs](t, e) {
1401
- this[It] === void 0 && (this[It] = !1);
1402
- let i;
1403
- try {
1404
- i = new F(t, e, this[V], this[he]);
1405
- } catch (r) {
1406
- return this.warn("TAR_ENTRY_INVALID", r);
1407
- }
1408
- if (i.nullBlock) this[je] ? (this[ti] = !0, this[B] === "begin" && (this[B] = "header"), this[At]("eof")) : (this[je] = !0, this[At]("nullBlock"));
1409
- else if (this[je] = !1, !i.cksumValid) this.warn("TAR_ENTRY_INVALID", "checksum failure", { header: i });
1410
- else if (!i.path) this.warn("TAR_ENTRY_INVALID", "path is required", { header: i });
1411
- else {
1412
- let r = i.type;
1413
- if (/^(Symbolic)?Link$/.test(r) && !i.linkpath) this.warn("TAR_ENTRY_INVALID", "linkpath required", { header: i });
1414
- else if (!/^(Symbolic)?Link$/.test(r) && !/^(Global)?ExtendedHeader$/.test(r) && i.linkpath) this.warn("TAR_ENTRY_INVALID", "linkpath forbidden", { header: i });
1415
- else {
1416
- let n = this[Nt] = new $e(i, this[V], this[he]);
1417
- if (!this[It]) if (n.remain) {
1418
- let o = () => {
1419
- n.invalid || (this[It] = !0);
1420
- };
1421
- n.on("end", o);
1422
- } else this[It] = !0;
1423
- n.meta ? n.size > this.maxMetaEntrySize ? (n.ignore = !0, this[At]("ignoredEntry", n), this[B] = "ignore", n.resume()) : n.size > 0 && (this[dt] = "", n.on("data", (o) => this[dt] += o), this[B] = "meta") : (this[V] = void 0, n.ignore = n.ignore || !this.filter(n.path, n), n.ignore ? (this[At]("ignoredEntry", n), this[B] = n.remain ? "ignore" : "header", n.resume()) : (n.remain ? this[B] = "body" : (this[B] = "header", n.end()), this[it] ? this[st].push(n) : (this[st].push(n), this[Zi]())));
1424
- }
1425
- }
1426
- }
1427
- [$s]() {
1428
- queueMicrotask(() => this.emit("close"));
1429
- }
1430
- [Zs](t) {
1431
- let e = !0;
1432
- if (!t) this[it] = void 0, e = !1;
1433
- else if (Array.isArray(t)) {
1434
- let [i, ...r] = t;
1435
- this.emit(i, ...r);
1436
- } else this[it] = t, this.emit("entry", t), t.emittedEnd || (t.on("end", () => this[Zi]()), e = !1);
1437
- return e;
1438
- }
1439
- [Zi]() {
1440
- do;
1441
- while (this[Zs](this[st].shift()));
1442
- if (this[st].length === 0) {
1443
- let t = this[it];
1444
- !t || t.flowing || t.size === t.remain ? this[Yt] || this.emit("drain") : t.once("drain", () => this.emit("drain"));
1445
- }
1446
- }
1447
- [Ki](t, e) {
1448
- let i = this[Nt];
1449
- if (!i) throw new Error("attempt to consume body without entry??");
1450
- let r = i.blockRemain ?? 0, n = r >= t.length && e === 0 ? t : t.subarray(e, e + r);
1451
- return i.write(n), i.blockRemain || (this[B] = "header", this[Nt] = void 0, i.end()), n.length;
1452
- }
1453
- [Ks](t, e) {
1454
- let i = this[Nt], r = this[Ki](t, e);
1455
- return !this[Nt] && i && this[Ys](i), r;
1456
- }
1457
- [At](t, e, i) {
1458
- this[st].length === 0 && !this[it] ? this.emit(t, e, i) : this[st].push([
1459
- t,
1460
- e,
1461
- i
1462
- ]);
1463
- }
1464
- [Ys](t) {
1465
- switch (this[At]("meta", this[dt]), t.type) {
1466
- case "ExtendedHeader":
1467
- case "OldExtendedHeader":
1468
- this[V] = ft.parse(this[dt], this[V], !1);
1469
- break;
1470
- case "GlobalExtendedHeader":
1471
- this[he] = ft.parse(this[dt], this[he], !0);
1472
- break;
1473
- case "NextFileHasLongPath":
1474
- case "OldGnuLongPath": {
1475
- let e = this[V] ?? Object.create(null);
1476
- this[V] = e, e.path = this[dt].replace(/\0.*/, "");
1477
- break;
1478
- }
1479
- case "NextFileHasLongLinkpath": {
1480
- let e = this[V] || Object.create(null);
1481
- this[V] = e, e.linkpath = this[dt].replace(/\0.*/, "");
1482
- break;
1483
- }
1484
- default: throw new Error("unknown meta: " + t.type);
1485
- }
1486
- }
1487
- abort(t) {
1488
- if (!this[$]) {
1489
- if (this[w]) {
1490
- let e = this[w];
1491
- e.write = () => !0, e.end = () => e, e.emit = () => !1, e.destroy?.();
1492
- }
1493
- this[$] = !0, this.emit("abort", t), this.warn("TAR_ABORT", t, { recoverable: !1 });
1494
- }
1495
- }
1496
- [Xs](t) {
1497
- this[$i] += t.length;
1498
- let e = this[$i] / this[le];
1499
- return e > this.maxDecompressionRatio ? (this.abort(/* @__PURE__ */ new Error(`max decompression ratio exceeded: ${e.toFixed(2)} > ${this.maxDecompressionRatio}`)), !1) : !0;
1500
- }
1501
- write(t, e, i) {
1502
- if (typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8")), this[$]) return i?.(), !1;
1503
- if ((this[w] === void 0 || this.brotli === void 0 && this[w] === !1) && t) {
1504
- if (this[p] && (t = Buffer.concat([this[p], t]), this[p] = void 0), t.length < An) return this[p] = t, i?.(), !0;
1505
- for (let a = 0; this[w] === void 0 && a < Xi.length; a++) t[a] !== Xi[a] && (this[w] = !1);
1506
- let o = !1;
1507
- if (this[w] === !1 && this.zstd !== !1) {
1508
- o = !0;
1509
- for (let a = 0; a < qi.length; a++) if (t[a] !== qi[a]) {
1510
- o = !1;
1511
- break;
1512
- }
1513
- }
1514
- let h = this.brotli === void 0 && !o;
1515
- if (this[w] === !1 && h) if (t.length < 512) if (this[ut]) this.brotli = !0;
1516
- else return this[p] = t, i?.(), !0;
1517
- else try {
1518
- new F(t.subarray(0, 512)), this.brotli = !1;
1519
- } catch {
1520
- this.brotli = !0;
1521
- }
1522
- if (this[w] === void 0 || this[w] === !1 && (this.brotli || o)) {
1523
- let a = this[ut];
1524
- this[ut] = !1, this[w] = this[w] === void 0 ? new Ue({}) : o ? new Ke({}) : new Ge({}), this[w].on("data", (c) => {
1525
- this[Xs](c) && this[Xe](c);
1526
- }), this[w].on("error", (c) => {
1527
- this[$] || this.abort(c);
1528
- }), this[w].on("end", () => {
1529
- this[ut] = !0, this[Xe]();
1530
- }), this[Yt] = !0, this[le] += t.length;
1531
- let l = !!this[w][a ? "end" : "write"](t);
1532
- return this[Yt] = !1, i?.(), l;
1533
- }
1534
- }
1535
- this[Yt] = !0, this[w] ? (this[le] += t.length, this[w].write(t)) : this[Xe](t), this[Yt] = !1;
1536
- let n = this[st].length > 0 ? !1 : this[it] ? this[it].flowing : !0;
1537
- return !n && this[st].length === 0 && this[it]?.once("drain", () => this.emit("drain")), i?.(), n;
1538
- }
1539
- [Vi](t) {
1540
- t && !this[$] && (this[p] = this[p] ? Buffer.concat([this[p], t]) : t);
1541
- }
1542
- [Qe]() {
1543
- if (this[ut] && !this[Yi] && !this[$] && !this[ae]) {
1544
- this[Yi] = !0;
1545
- let t = this[Nt];
1546
- if (t?.blockRemain) {
1547
- let e = this[p] ? this[p].length : 0;
1548
- this.warn("TAR_BAD_ARCHIVE", `Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`, { entry: t }), this[p] && t.write(this[p]), t.end();
1549
- }
1550
- this[At](Je);
1551
- }
1552
- }
1553
- [Xe](t) {
1554
- if (this[ae] && t) this[Vi](t);
1555
- else if (!t && !this[p]) this[Qe]();
1556
- else if (t) {
1557
- if (this[ae] = !0, this[p]) {
1558
- this[Vi](t);
1559
- let e = this[p];
1560
- this[p] = void 0, this[qe](e);
1561
- } else this[qe](t);
1562
- for (; this[p] && this[p]?.length >= 512 && !this[$] && !this[ti];) {
1563
- let e = this[p];
1564
- this[p] = void 0, this[qe](e);
1565
- }
1566
- this[ae] = !1;
1567
- }
1568
- (!this[p] || this[ut]) && this[Qe]();
1569
- }
1570
- [qe](t) {
1571
- let e = 0, i = t.length;
1572
- for (; e + 512 <= i && !this[$] && !this[ti];) switch (this[B]) {
1573
- case "begin":
1574
- case "header":
1575
- this[Vs](t, e), e += 512;
1576
- break;
1577
- case "ignore":
1578
- case "body":
1579
- e += this[Ki](t, e);
1580
- break;
1581
- case "meta":
1582
- e += this[Ks](t, e);
1583
- break;
1584
- default: throw new Error("invalid state: " + this[B]);
1585
- }
1586
- e < i && (this[p] = this[p] ? Buffer.concat([t.subarray(e), this[p]]) : t.subarray(e));
1587
- }
1588
- end(t, e, i) {
1589
- return typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, e)), i && this.once("finish", i), this[$] || (this[w] ? (t && (this[le] += t.length, this[w].write(t)), this[w].end()) : (this[ut] = !0, (this.brotli === void 0 || this.zstd === void 0) && (t = t || Buffer.alloc(0)), t && this.write(t), this[Qe]())), this;
1590
- }
1591
- };
1592
- var mt = (s) => {
1593
- let t = s.length - 1, e = -1;
1594
- for (; t > -1 && s.charAt(t) === "/";) e = t, t--;
1595
- return e === -1 ? s : s.slice(0, e);
1596
- };
1597
- var vn = (s) => {
1598
- let t = s.onReadEntry;
1599
- s.onReadEntry = t ? (e) => {
1600
- t(e), e.resume();
1601
- } : (e) => e.resume();
1602
- };
1603
- var Qi = (s, t) => {
1604
- let e = new Map(t.map((o) => [mt(o), !0])), i = s.filter, r = 100, n = (o, h = "", a = 0) => {
1605
- if (a >= r) return e.set(o, !1), !1;
1606
- let l = h || parse(o).root || ".", c;
1607
- if (o === l) c = !1;
1608
- else {
1609
- let d = e.get(o);
1610
- c = d !== void 0 ? d : n(dirname$1(o), l, a + 1);
1611
- }
1612
- return e.set(o, c), c;
1613
- };
1614
- s.filter = i ? (o, h) => i(o, h) && n(mt(o)) : (o) => n(mt(o));
1615
- };
1616
- var Mn = (s) => {
1617
- let t = new rt(s), e = s.file, i;
1618
- try {
1619
- i = Br.openSync(e, "r");
1620
- let r = Br.fstatSync(i), n = s.maxReadSize || 16777216;
1621
- if (r.size < n) {
1622
- let o = Buffer.allocUnsafe(r.size), h = Br.readSync(i, o, 0, r.size, 0);
1623
- t.end(h === o.byteLength ? o : o.subarray(0, h));
1624
- } else {
1625
- let o = 0, h = Buffer.allocUnsafe(n);
1626
- for (; o < r.size;) {
1627
- let a = Br.readSync(i, h, 0, n, o);
1628
- if (a === 0) break;
1629
- o += a, t.write(h.subarray(0, a));
1630
- }
1631
- t.end();
1632
- }
1633
- } finally {
1634
- if (typeof i == "number") try {
1635
- Br.closeSync(i);
1636
- } catch {}
1637
- }
1638
- };
1639
- var Bn = (s, t) => {
1640
- let e = new rt(s), i = s.maxReadSize || 16777216, r = s.file;
1641
- return new Promise((o, h) => {
1642
- e.on("error", h), e.on("end", o), Br.stat(r, (a, l) => {
1643
- if (a) h(a);
1644
- else {
1645
- let c = new _t(r, {
1646
- readSize: i,
1647
- size: l.size
1648
- });
1649
- c.on("error", h), c.pipe(e);
1650
- }
1651
- });
1652
- });
1653
- };
1654
- var Ct = K(Mn, Bn, (s) => new rt(s), (s) => new rt(s), (s, t) => {
1655
- t?.length && Qi(s, t), s.noResume || vn(s);
1656
- });
1657
- var Ji = (s, t, e) => (s &= 4095, e && (s = (s | 384) & -19), t && (s & 256 && (s |= 64), s & 32 && (s |= 8), s & 4 && (s |= 1)), s);
1658
- var { isAbsolute: zn, parse: qs } = win32, ce = (s) => {
1659
- let t = "", e = qs(s);
1660
- for (; zn(s) || e.root;) {
1661
- let i = s.charAt(0) === "/" && s.slice(0, 4) !== "//?/" ? "/" : e.root;
1662
- s = s.slice(i.length), t += i, e = qs(s);
1663
- }
1664
- return [t, s];
1665
- };
1666
- var ei = [
1667
- "|",
1668
- "<",
1669
- ">",
1670
- "?",
1671
- ":"
1672
- ];
1673
- var ji = ei.map((s) => String.fromCodePoint(61440 + Number(s.codePointAt(0))));
1674
- var Un = new Map(ei.map((s, t) => [s, ji[t]]));
1675
- var Hn = new Map(ji.map((s, t) => [s, ei[t]]));
1676
- var ts = (s) => ei.reduce((t, e) => t.split(e).join(Un.get(e)), s);
1677
- var Qs = (s) => ji.reduce((t, e) => t.split(e).join(Hn.get(e)), s);
1678
- var rr = (s, t) => t ? (s = f(s).replace(/^\.(\/|$)/, ""), mt(t) + "/" + s) : f(s);
1679
- var Wn = 16777216;
1680
- var tr = Symbol("process");
1681
- var er = Symbol("file");
1682
- var ir = Symbol("directory");
1683
- var is = Symbol("symlink");
1684
- var sr = Symbol("hardlink");
1685
- var fe = Symbol("header");
1686
- var ii = Symbol("read");
1687
- var ss = Symbol("lstat");
1688
- var si = Symbol("onlstat");
1689
- var rs = Symbol("onread");
1690
- var ns = Symbol("onreadlink");
1691
- var os = Symbol("openfile");
1692
- var hs = Symbol("onopenfile");
1693
- var pt = Symbol("close");
1694
- var ri = Symbol("mode");
1695
- var as = Symbol("awaitDrain");
1696
- var es = Symbol("ondrain");
1697
- var q = Symbol("prefix");
1698
- var de = class extends A {
1699
- path;
1700
- portable;
1701
- myuid = process.getuid && process.getuid() || 0;
1702
- myuser = process.env.USER || "";
1703
- maxReadSize;
1704
- linkCache;
1705
- statCache;
1706
- preservePaths;
1707
- cwd;
1708
- strict;
1709
- mtime;
1710
- noPax;
1711
- noMtime;
1712
- prefix;
1713
- fd;
1714
- blockLen = 0;
1715
- blockRemain = 0;
1716
- buf;
1717
- pos = 0;
1718
- remain = 0;
1719
- length = 0;
1720
- offset = 0;
1721
- win32;
1722
- absolute;
1723
- header;
1724
- type;
1725
- linkpath;
1726
- stat;
1727
- onWriteEntry;
1728
- #t = !1;
1729
- constructor(t, e = {}) {
1730
- let i = se(e);
1731
- super(), this.path = f(t), this.portable = !!i.portable, this.maxReadSize = i.maxReadSize || Wn, this.linkCache = i.linkCache || /* @__PURE__ */ new Map(), this.statCache = i.statCache || /* @__PURE__ */ new Map(), this.preservePaths = !!i.preservePaths, this.cwd = f(i.cwd || process.cwd()), this.strict = !!i.strict, this.noPax = !!i.noPax, this.noMtime = !!i.noMtime, this.mtime = i.mtime, this.prefix = i.prefix ? f(i.prefix) : void 0, this.onWriteEntry = i.onWriteEntry, typeof i.onwarn == "function" && this.on("warn", i.onwarn);
1732
- let r = !1;
1733
- if (!this.preservePaths) {
1734
- let [o, h] = ce(this.path);
1735
- o && typeof h == "string" && (this.path = h, r = o);
1736
- }
1737
- this.win32 = !!i.win32 || process.platform === "win32", this.win32 && (this.path = Qs(this.path.replaceAll(/\\/g, "/")), t = t.replaceAll(/\\/g, "/")), this.absolute = f(i.absolute || ar.resolve(this.cwd, t)), this.path === "" && (this.path = "./"), r && this.warn("TAR_ENTRY_INFO", `stripping ${r} from absolute path`, {
1738
- entry: this,
1739
- path: r + this.path
1740
- });
1741
- let n = this.statCache.get(this.absolute);
1742
- n ? this[si](n) : this[ss]();
1743
- }
1744
- warn(t, e, i = {}) {
1745
- return Dt(this, t, e, i);
1746
- }
1747
- emit(t, ...e) {
1748
- return t === "error" && (this.#t = !0), super.emit(t, ...e);
1749
- }
1750
- [ss]() {
1751
- I.lstat(this.absolute, (t, e) => {
1752
- if (t) return this.emit("error", t);
1753
- this[si](e);
1754
- });
1755
- }
1756
- [si](t) {
1757
- this.statCache.set(this.absolute, t), this.stat = t, t.isFile() || (t.size = 0), this.type = Gn(t), this.emit("stat", t), this[tr]();
1758
- }
1759
- [tr]() {
1760
- switch (this.type) {
1761
- case "File": return this[er]();
1762
- case "Directory": return this[ir]();
1763
- case "SymbolicLink": return this[is]();
1764
- default: return this.end();
1765
- }
1766
- }
1767
- [ri](t) {
1768
- return Ji(t, this.type === "Directory", this.portable);
1769
- }
1770
- [q](t) {
1771
- return rr(t, this.prefix);
1772
- }
1773
- [fe]() {
1774
- if (!this.stat) throw new Error("cannot write header before stat");
1775
- this.type === "Directory" && this.portable && (this.noMtime = !0), this.onWriteEntry?.(this), this.header = new F({
1776
- path: this[q](this.path),
1777
- linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[q](this.linkpath) : this.linkpath,
1778
- mode: this[ri](this.stat.mode),
1779
- uid: this.portable ? void 0 : this.stat.uid,
1780
- gid: this.portable ? void 0 : this.stat.gid,
1781
- size: this.stat.size,
1782
- mtime: this.noMtime ? void 0 : this.mtime || this.stat.mtime,
1783
- type: this.type === "Unsupported" ? void 0 : this.type,
1784
- uname: this.portable ? void 0 : this.stat.uid === this.myuid ? this.myuser : "",
1785
- atime: this.portable ? void 0 : this.stat.atime,
1786
- ctime: this.portable ? void 0 : this.stat.ctime
1787
- }), this.header.encode() && !this.noPax && super.write(new ft({
1788
- atime: this.portable ? void 0 : this.header.atime,
1789
- ctime: this.portable ? void 0 : this.header.ctime,
1790
- gid: this.portable ? void 0 : this.header.gid,
1791
- mtime: this.noMtime ? void 0 : this.mtime || this.header.mtime,
1792
- path: this[q](this.path),
1793
- linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[q](this.linkpath) : this.linkpath,
1794
- size: this.header.size,
1795
- uid: this.portable ? void 0 : this.header.uid,
1796
- uname: this.portable ? void 0 : this.header.uname,
1797
- dev: this.portable ? void 0 : this.stat.dev,
1798
- ino: this.portable ? void 0 : this.stat.ino,
1799
- nlink: this.portable ? void 0 : this.stat.nlink
1800
- }).encode());
1801
- let t = this.header?.block;
1802
- if (!t) throw new Error("failed to encode header");
1803
- super.write(t);
1804
- }
1805
- [ir]() {
1806
- if (!this.stat) throw new Error("cannot create directory entry without stat");
1807
- this.path.slice(-1) !== "/" && (this.path += "/"), this.stat.size = 0, this[fe](), this.end();
1808
- }
1809
- [is]() {
1810
- I.readlink(this.absolute, (t, e) => {
1811
- if (t) return this.emit("error", t);
1812
- this[ns](e);
1813
- });
1814
- }
1815
- [ns](t) {
1816
- this.linkpath = f(t), this[fe](), this.end();
1817
- }
1818
- [sr](t) {
1819
- if (!this.stat) throw new Error("cannot create link entry without stat");
1820
- this.type = "Link", this.linkpath = f(ar.relative(this.cwd, t)), this.stat.size = 0, this[fe](), this.end();
1821
- }
1822
- [er]() {
1823
- if (!this.stat) throw new Error("cannot create file entry without stat");
1824
- if (this.stat.nlink > 1) {
1825
- let t = `${this.stat.dev}:${this.stat.ino}`, e = this.linkCache.get(t);
1826
- if (e?.indexOf(this.cwd) === 0) return this[sr](e);
1827
- this.linkCache.set(t, this.absolute);
1828
- }
1829
- if (this[fe](), this.stat.size === 0) return this.end();
1830
- this[os]();
1831
- }
1832
- [os]() {
1833
- I.open(this.absolute, "r", (t, e) => {
1834
- if (t) return this.emit("error", t);
1835
- this[hs](e);
1836
- });
1837
- }
1838
- [hs](t) {
1839
- if (this.fd = t, this.#t) return this[pt]();
1840
- if (!this.stat) throw new Error("should stat before calling onopenfile");
1841
- this.blockLen = 512 * Math.ceil(this.stat.size / 512), this.blockRemain = this.blockLen;
1842
- let e = Math.min(this.blockLen, this.maxReadSize);
1843
- this.buf = Buffer.allocUnsafe(e), this.offset = 0, this.pos = 0, this.remain = this.stat.size, this.length = this.buf.length, this[ii]();
1844
- }
1845
- [ii]() {
1846
- let { fd: t, buf: e, offset: i, length: r, pos: n } = this;
1847
- if (t === void 0 || e === void 0) throw new Error("cannot read file without first opening");
1848
- I.read(t, e, i, r, n, (o, h) => {
1849
- if (o) return this[pt](() => this.emit("error", o));
1850
- this[rs](h);
1851
- });
1852
- }
1853
- [pt](t = () => {}) {
1854
- this.fd !== void 0 && I.close(this.fd, t);
1855
- }
1856
- [rs](t) {
1857
- if (t <= 0 && this.remain > 0) {
1858
- let r = Object.assign(/* @__PURE__ */ new Error("encountered unexpected EOF"), {
1859
- path: this.absolute,
1860
- syscall: "read",
1861
- code: "EOF"
1862
- });
1863
- return this[pt](() => this.emit("error", r));
1864
- }
1865
- if (t > this.remain) {
1866
- let r = Object.assign(/* @__PURE__ */ new Error("did not encounter expected EOF"), {
1867
- path: this.absolute,
1868
- syscall: "read",
1869
- code: "EOF"
1870
- });
1871
- return this[pt](() => this.emit("error", r));
1872
- }
1873
- if (!this.buf) throw new Error("should have created buffer prior to reading");
1874
- if (t === this.remain) for (let r = t; r < this.length && t < this.blockRemain; r++) this.buf[r + this.offset] = 0, t++, this.remain++;
1875
- let e = this.offset === 0 && t === this.buf.length ? this.buf : this.buf.subarray(this.offset, this.offset + t);
1876
- this.write(e) ? this[es]() : this[as](() => this[es]());
1877
- }
1878
- [as](t) {
1879
- this.once("drain", t);
1880
- }
1881
- write(t, e, i) {
1882
- if (typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8")), this.blockRemain < t.length) {
1883
- let r = Object.assign(/* @__PURE__ */ new Error("writing more data than expected"), { path: this.absolute });
1884
- return this.emit("error", r);
1885
- }
1886
- return this.remain -= t.length, this.blockRemain -= t.length, this.pos += t.length, this.offset += t.length, super.write(t, null, i);
1887
- }
1888
- [es]() {
1889
- if (!this.remain) return this.blockRemain && super.write(Buffer.alloc(this.blockRemain)), this[pt]((t) => t ? this.emit("error", t) : this.end());
1890
- if (!this.buf) throw new Error("buffer lost somehow in ONDRAIN");
1891
- this.offset >= this.length && (this.buf = Buffer.allocUnsafe(Math.min(this.blockRemain, this.buf.length)), this.offset = 0), this.length = this.buf.length - this.offset, this[ii]();
1892
- }
1893
- };
1894
- var ni = class extends de {
1895
- sync = !0;
1896
- [ss]() {
1897
- this[si](I.lstatSync(this.absolute));
1898
- }
1899
- [is]() {
1900
- this[ns](I.readlinkSync(this.absolute));
1901
- }
1902
- [os]() {
1903
- this[hs](I.openSync(this.absolute, "r"));
1904
- }
1905
- [ii]() {
1906
- let t = !0;
1907
- try {
1908
- let { fd: e, buf: i, offset: r, length: n, pos: o } = this;
1909
- if (e === void 0 || i === void 0) throw new Error("fd and buf must be set in READ method");
1910
- let h = I.readSync(e, i, r, n, o);
1911
- this[rs](h), t = !1;
1912
- } finally {
1913
- if (t) try {
1914
- this[pt](() => {});
1915
- } catch {}
1916
- }
1917
- }
1918
- [as](t) {
1919
- t();
1920
- }
1921
- [pt](t = () => {}) {
1922
- this.fd !== void 0 && I.closeSync(this.fd), t();
1923
- }
1924
- };
1925
- var oi = class extends A {
1926
- blockLen = 0;
1927
- blockRemain = 0;
1928
- buf = 0;
1929
- pos = 0;
1930
- remain = 0;
1931
- length = 0;
1932
- preservePaths;
1933
- portable;
1934
- strict;
1935
- noPax;
1936
- noMtime;
1937
- readEntry;
1938
- type;
1939
- prefix;
1940
- path;
1941
- mode;
1942
- uid;
1943
- gid;
1944
- uname;
1945
- gname;
1946
- header;
1947
- mtime;
1948
- atime;
1949
- ctime;
1950
- linkpath;
1951
- size;
1952
- onWriteEntry;
1953
- warn(t, e, i = {}) {
1954
- return Dt(this, t, e, i);
1955
- }
1956
- constructor(t, e = {}) {
1957
- let i = se(e);
1958
- super(), this.preservePaths = !!i.preservePaths, this.portable = !!i.portable, this.strict = !!i.strict, this.noPax = !!i.noPax, this.noMtime = !!i.noMtime, this.onWriteEntry = i.onWriteEntry, this.readEntry = t;
1959
- let { type: r } = t;
1960
- if (r === "Unsupported") throw new Error("writing entry that should be ignored");
1961
- this.type = r, this.type === "Directory" && this.portable && (this.noMtime = !0), this.prefix = i.prefix, this.path = f(t.path), this.mode = t.mode !== void 0 ? this[ri](t.mode) : void 0, this.uid = this.portable ? void 0 : t.uid, this.gid = this.portable ? void 0 : t.gid, this.uname = this.portable ? void 0 : t.uname, this.gname = this.portable ? void 0 : t.gname, this.size = t.size, this.mtime = this.noMtime ? void 0 : i.mtime || t.mtime, this.atime = this.portable ? void 0 : t.atime, this.ctime = this.portable ? void 0 : t.ctime, this.linkpath = t.linkpath !== void 0 ? f(t.linkpath) : void 0, typeof i.onwarn == "function" && this.on("warn", i.onwarn);
1962
- let n = !1;
1963
- if (!this.preservePaths) {
1964
- let [h, a] = ce(this.path);
1965
- h && typeof a == "string" && (this.path = a, n = h);
1966
- }
1967
- this.remain = t.size, this.blockRemain = t.startBlockSize, this.onWriteEntry?.(this), this.header = new F({
1968
- path: this[q](this.path),
1969
- linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[q](this.linkpath) : this.linkpath,
1970
- mode: this.mode,
1971
- uid: this.portable ? void 0 : this.uid,
1972
- gid: this.portable ? void 0 : this.gid,
1973
- size: this.size,
1974
- mtime: this.noMtime ? void 0 : this.mtime,
1975
- type: this.type,
1976
- uname: this.portable ? void 0 : this.uname,
1977
- atime: this.portable ? void 0 : this.atime,
1978
- ctime: this.portable ? void 0 : this.ctime
1979
- }), n && this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute path`, {
1980
- entry: this,
1981
- path: n + this.path
1982
- }), this.header.encode() && !this.noPax && super.write(new ft({
1983
- atime: this.portable ? void 0 : this.atime,
1984
- ctime: this.portable ? void 0 : this.ctime,
1985
- gid: this.portable ? void 0 : this.gid,
1986
- mtime: this.noMtime ? void 0 : this.mtime,
1987
- path: this[q](this.path),
1988
- linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[q](this.linkpath) : this.linkpath,
1989
- size: this.size,
1990
- uid: this.portable ? void 0 : this.uid,
1991
- uname: this.portable ? void 0 : this.uname,
1992
- dev: this.portable ? void 0 : this.readEntry.dev,
1993
- ino: this.portable ? void 0 : this.readEntry.ino,
1994
- nlink: this.portable ? void 0 : this.readEntry.nlink
1995
- }).encode());
1996
- let o = this.header?.block;
1997
- if (!o) throw new Error("failed to encode header");
1998
- super.write(o), t.pipe(this);
1999
- }
2000
- [q](t) {
2001
- return rr(t, this.prefix);
2002
- }
2003
- [ri](t) {
2004
- return Ji(t, this.type === "Directory", this.portable);
2005
- }
2006
- write(t, e, i) {
2007
- typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8"));
2008
- let r = t.length;
2009
- if (r > this.blockRemain) throw new Error("writing more to entry than is appropriate");
2010
- return this.blockRemain -= r, super.write(t, i);
2011
- }
2012
- end(t, e, i) {
2013
- return this.blockRemain && super.write(Buffer.alloc(this.blockRemain)), typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, e ?? "utf8")), i && this.once("finish", i), t ? super.end(t, i) : super.end(i), this;
2014
- }
2015
- };
2016
- var Gn = (s) => s.isFile() ? "File" : s.isDirectory() ? "Directory" : s.isSymbolicLink() ? "SymbolicLink" : "Unsupported";
2017
- var hi = class s {
2018
- tail;
2019
- head;
2020
- length = 0;
2021
- static create(t = []) {
2022
- return new s(t);
2023
- }
2024
- constructor(t = []) {
2025
- for (let e of t) this.push(e);
2026
- }
2027
- *[Symbol.iterator]() {
2028
- for (let t = this.head; t; t = t.next) yield t.value;
2029
- }
2030
- removeNode(t) {
2031
- if (t.list !== this) throw new Error("removing node which does not belong to this list");
2032
- let e = t.next, i = t.prev;
2033
- return e && (e.prev = i), i && (i.next = e), t === this.head && (this.head = e), t === this.tail && (this.tail = i), this.length--, t.next = void 0, t.prev = void 0, t.list = void 0, e;
2034
- }
2035
- unshiftNode(t) {
2036
- if (t === this.head) return;
2037
- t.list && t.list.removeNode(t);
2038
- let e = this.head;
2039
- t.list = this, t.next = e, e && (e.prev = t), this.head = t, this.tail || (this.tail = t), this.length++;
2040
- }
2041
- pushNode(t) {
2042
- if (t === this.tail) return;
2043
- t.list && t.list.removeNode(t);
2044
- let e = this.tail;
2045
- t.list = this, t.prev = e, e && (e.next = t), this.tail = t, this.head || (this.head = t), this.length++;
2046
- }
2047
- push(...t) {
2048
- for (let e = 0, i = t.length; e < i; e++) Yn(this, t[e]);
2049
- return this.length;
2050
- }
2051
- unshift(...t) {
2052
- for (var e = 0, i = t.length; e < i; e++) Kn(this, t[e]);
2053
- return this.length;
2054
- }
2055
- pop() {
2056
- if (!this.tail) return;
2057
- let t = this.tail.value, e = this.tail;
2058
- return this.tail = this.tail.prev, this.tail ? this.tail.next = void 0 : this.head = void 0, e.list = void 0, this.length--, t;
2059
- }
2060
- shift() {
2061
- if (!this.head) return;
2062
- let t = this.head.value, e = this.head;
2063
- return this.head = this.head.next, this.head ? this.head.prev = void 0 : this.tail = void 0, e.list = void 0, this.length--, t;
2064
- }
2065
- forEach(t, e) {
2066
- e = e || this;
2067
- for (let i = this.head, r = 0; i; r++) t.call(e, i.value, r, this), i = i.next;
2068
- }
2069
- forEachReverse(t, e) {
2070
- e = e || this;
2071
- for (let i = this.tail, r = this.length - 1; i; r--) t.call(e, i.value, r, this), i = i.prev;
2072
- }
2073
- get(t) {
2074
- let e = 0, i = this.head;
2075
- for (; i && e < t; e++) i = i.next;
2076
- if (e === t && i) return i.value;
2077
- }
2078
- getReverse(t) {
2079
- let e = 0, i = this.tail;
2080
- for (; i && e < t; e++) i = i.prev;
2081
- if (e === t && i) return i.value;
2082
- }
2083
- map(t, e) {
2084
- e = e || this;
2085
- let i = new s();
2086
- for (let r = this.head; r;) i.push(t.call(e, r.value, this)), r = r.next;
2087
- return i;
2088
- }
2089
- mapReverse(t, e) {
2090
- e = e || this;
2091
- var i = new s();
2092
- for (let r = this.tail; r;) i.push(t.call(e, r.value, this)), r = r.prev;
2093
- return i;
2094
- }
2095
- reduce(t, e) {
2096
- let i, r = this.head;
2097
- if (arguments.length > 1) i = e;
2098
- else if (this.head) r = this.head.next, i = this.head.value;
2099
- else throw new TypeError("Reduce of empty list with no initial value");
2100
- for (var n = 0; r; n++) i = t(i, r.value, n), r = r.next;
2101
- return i;
2102
- }
2103
- reduceReverse(t, e) {
2104
- let i, r = this.tail;
2105
- if (arguments.length > 1) i = e;
2106
- else if (this.tail) r = this.tail.prev, i = this.tail.value;
2107
- else throw new TypeError("Reduce of empty list with no initial value");
2108
- for (let n = this.length - 1; r; n--) i = t(i, r.value, n), r = r.prev;
2109
- return i;
2110
- }
2111
- toArray() {
2112
- let t = new Array(this.length);
2113
- for (let e = 0, i = this.head; i; e++) t[e] = i.value, i = i.next;
2114
- return t;
2115
- }
2116
- toArrayReverse() {
2117
- let t = new Array(this.length);
2118
- for (let e = 0, i = this.tail; i; e++) t[e] = i.value, i = i.prev;
2119
- return t;
2120
- }
2121
- slice(t = 0, e = this.length) {
2122
- e < 0 && (e += this.length), t < 0 && (t += this.length);
2123
- let i = new s();
2124
- if (e < t || e < 0) return i;
2125
- t < 0 && (t = 0), e > this.length && (e = this.length);
2126
- let r = this.head, n = 0;
2127
- for (n = 0; r && n < t; n++) r = r.next;
2128
- for (; r && n < e; n++, r = r.next) i.push(r.value);
2129
- return i;
2130
- }
2131
- sliceReverse(t = 0, e = this.length) {
2132
- e < 0 && (e += this.length), t < 0 && (t += this.length);
2133
- let i = new s();
2134
- if (e < t || e < 0) return i;
2135
- t < 0 && (t = 0), e > this.length && (e = this.length);
2136
- let r = this.length, n = this.tail;
2137
- for (; n && r > e; r--) n = n.prev;
2138
- for (; n && r > t; r--, n = n.prev) i.push(n.value);
2139
- return i;
2140
- }
2141
- splice(t, e = 0, ...i) {
2142
- t > this.length && (t = this.length - 1), t < 0 && (t = this.length + t);
2143
- let r = this.head;
2144
- for (let o = 0; r && o < t; o++) r = r.next;
2145
- let n = [];
2146
- for (let o = 0; r && o < e; o++) n.push(r.value), r = this.removeNode(r);
2147
- r ? r !== this.tail && (r = r.prev) : r = this.tail;
2148
- for (let o of i) r = Zn(this, r, o);
2149
- return n;
2150
- }
2151
- reverse() {
2152
- let t = this.head, e = this.tail;
2153
- for (let i = t; i; i = i.prev) {
2154
- let r = i.prev;
2155
- i.prev = i.next, i.next = r;
2156
- }
2157
- return this.head = e, this.tail = t, this;
2158
- }
2159
- };
2160
- function Zn(s, t, e) {
2161
- let n = new ue(e, t, t ? t.next : s.head, s);
2162
- return n.next === void 0 && (s.tail = n), n.prev === void 0 && (s.head = n), s.length++, n;
2163
- }
2164
- function Yn(s, t) {
2165
- s.tail = new ue(t, s.tail, void 0, s), s.head || (s.head = s.tail), s.length++;
2166
- }
2167
- function Kn(s, t) {
2168
- s.head = new ue(t, void 0, s.head, s), s.tail || (s.tail = s.head), s.length++;
2169
- }
2170
- var ue = class {
2171
- list;
2172
- next;
2173
- prev;
2174
- value;
2175
- constructor(t, e, i, r) {
2176
- this.list = r, this.value = t, e ? (e.next = this, this.prev = e) : this.prev = void 0, i ? (i.prev = this, this.next = i) : this.next = void 0;
2177
- }
2178
- };
2179
- var pi = class {
2180
- path;
2181
- absolute;
2182
- entry;
2183
- stat;
2184
- readdir;
2185
- pending = !1;
2186
- pendingLink = !1;
2187
- ignore = !1;
2188
- piped = !1;
2189
- constructor(t, e) {
2190
- this.path = t || "./", this.absolute = e;
2191
- }
2192
- };
2193
- var nr = Buffer.alloc(1024);
2194
- var li = Symbol("onStat");
2195
- var me = Symbol("ended");
2196
- var W = Symbol("queue");
2197
- var pe = Symbol("pendingLinks");
2198
- var Et = Symbol("current");
2199
- var Ft = Symbol("process");
2200
- var Ee = Symbol("processing");
2201
- var ai = Symbol("processJob");
2202
- var G = Symbol("jobs");
2203
- var ls = Symbol("jobDone");
2204
- var ci = Symbol("addFSEntry");
2205
- var or = Symbol("addTarEntry");
2206
- var ds = Symbol("stat");
2207
- var us = Symbol("readdir");
2208
- var fi = Symbol("onreaddir");
2209
- var di = Symbol("pipe");
2210
- var hr = Symbol("entry");
2211
- var cs = Symbol("entryOpt");
2212
- var ui = Symbol("writeEntryClass");
2213
- var lr = Symbol("write");
2214
- var fs = Symbol("ondrain");
2215
- var wt = class extends A {
2216
- sync = !1;
2217
- opt;
2218
- cwd;
2219
- maxReadSize;
2220
- preservePaths;
2221
- strict;
2222
- noPax;
2223
- prefix;
2224
- linkCache;
2225
- statCache;
2226
- file;
2227
- portable;
2228
- zip;
2229
- readdirCache;
2230
- noDirRecurse;
2231
- follow;
2232
- noMtime;
2233
- mtime;
2234
- filter;
2235
- jobs;
2236
- [ui];
2237
- onWriteEntry;
2238
- [W];
2239
- [pe] = /* @__PURE__ */ new Map();
2240
- [G] = 0;
2241
- [Ee] = !1;
2242
- [me] = !1;
2243
- constructor(t = {}) {
2244
- if (super(), this.opt = t, this.file = t.file || "", this.cwd = t.cwd || process.cwd(), this.maxReadSize = t.maxReadSize, this.preservePaths = !!t.preservePaths, this.strict = !!t.strict, this.noPax = !!t.noPax, this.prefix = f(t.prefix || ""), this.linkCache = t.linkCache || /* @__PURE__ */ new Map(), this.statCache = t.statCache || /* @__PURE__ */ new Map(), this.readdirCache = t.readdirCache || /* @__PURE__ */ new Map(), this.onWriteEntry = t.onWriteEntry, this[ui] = de, typeof t.onwarn == "function" && this.on("warn", t.onwarn), this.portable = !!t.portable, t.gzip || t.brotli || t.zstd) {
2245
- if ((t.gzip ? 1 : 0) + (t.brotli ? 1 : 0) + (t.zstd ? 1 : 0) > 1) throw new TypeError("gzip, brotli, zstd are mutually exclusive");
2246
- if (t.gzip && (typeof t.gzip != "object" && (t.gzip = {}), this.portable && (t.gzip.portable = !0), this.zip = new ze(t.gzip)), t.brotli && (typeof t.brotli != "object" && (t.brotli = {}), this.zip = new We(t.brotli)), t.zstd && (typeof t.zstd != "object" && (t.zstd = {}), this.zip = new Ye(t.zstd)), !this.zip) throw new Error("impossible");
2247
- let e = this.zip;
2248
- e.on("data", (i) => super.write(i)), e.on("end", () => super.end()), e.on("drain", () => this[fs]()), this.on("resume", () => e.resume());
2249
- } else this.on("drain", this[fs]);
2250
- this.noDirRecurse = !!t.noDirRecurse, this.follow = !!t.follow, this.noMtime = !!t.noMtime, t.mtime && (this.mtime = t.mtime), this.filter = typeof t.filter == "function" ? t.filter : () => !0, this[W] = new hi(), this[G] = 0, this.jobs = Number(t.jobs) || 4, this[Ee] = !1, this[me] = !1;
2251
- }
2252
- [lr](t) {
2253
- return super.write(t);
2254
- }
2255
- add(t) {
2256
- return this.write(t), this;
2257
- }
2258
- end(t, e, i) {
2259
- return typeof t == "function" && (i = t, t = void 0), typeof e == "function" && (i = e, e = void 0), t && this.add(t), this[me] = !0, this[Ft](), i && i(), this;
2260
- }
2261
- write(t) {
2262
- if (this[me]) throw new Error("write after end");
2263
- return typeof t == "string" ? this[ci](t) : this[or](t), this.flowing;
2264
- }
2265
- [or](t) {
2266
- let e = f(ar.resolve(this.cwd, t.path));
2267
- if (!this.filter(t.path, t)) t.resume();
2268
- else {
2269
- let i = new pi(t.path, e);
2270
- i.entry = new oi(t, this[cs](i)), i.entry.on("end", () => this[ls](i)), this[G] += 1, this[W].push(i);
2271
- }
2272
- this[Ft]();
2273
- }
2274
- [ci](t) {
2275
- let e = f(ar.resolve(this.cwd, t));
2276
- this[W].push(new pi(t, e)), this[Ft]();
2277
- }
2278
- [ds](t) {
2279
- t.pending = !0, this[G] += 1;
2280
- let e = this.follow ? "stat" : "lstat";
2281
- I[e](t.absolute, (i, r) => {
2282
- t.pending = !1, this[G] -= 1, i ? this.emit("error", i) : this[li](t, r);
2283
- });
2284
- }
2285
- [li](t, e) {
2286
- if (this.statCache.set(t.absolute, e), t.stat = e, !this.filter(t.path, e)) t.ignore = !0;
2287
- else if (e.isFile() && e.nlink > 1 && !this.linkCache.get(`${e.dev}:${e.ino}`) && !this.sync) if (t === this[Et]) this[ai](t);
2288
- else {
2289
- let i = `${e.dev}:${e.ino}`, r = this[pe].get(i);
2290
- r ? r.push(t) : this[pe].set(i, [t]), t.pendingLink = !0, t.pending = !0;
2291
- }
2292
- this[Ft]();
2293
- }
2294
- [us](t) {
2295
- t.pending = !0, this[G] += 1, I.readdir(t.absolute, (e, i) => {
2296
- if (t.pending = !1, this[G] -= 1, e) return this.emit("error", e);
2297
- this[fi](t, i);
2298
- });
2299
- }
2300
- [fi](t, e) {
2301
- this.readdirCache.set(t.absolute, e), t.readdir = e, this[Ft]();
2302
- }
2303
- [Ft]() {
2304
- if (!this[Ee]) {
2305
- this[Ee] = !0;
2306
- for (let t = this[W].head; t && this[G] < this.jobs; t = t.next) if (this[ai](t.value), t.value.ignore) {
2307
- let e = t.next;
2308
- this[W].removeNode(t), t.next = e;
2309
- }
2310
- this[Ee] = !1, this[me] && this[W].length === 0 && this[G] === 0 && (this.zip ? this.zip.end(nr) : (super.write(nr), super.end()));
2311
- }
2312
- }
2313
- get [Et]() {
2314
- return this[W] && this[W].head && this[W].head.value;
2315
- }
2316
- [ls](t) {
2317
- this[W].shift(), this[G] -= 1;
2318
- let { stat: e } = t;
2319
- if (e && e.isFile() && e.nlink > 1) {
2320
- let i = `${e.dev}:${e.ino}`, r = this[pe].get(i);
2321
- if (r) {
2322
- this[pe].delete(i);
2323
- for (let n of r) n.pending = !1, this[ai](n);
2324
- }
2325
- }
2326
- this[Ft]();
2327
- }
2328
- [ai](t) {
2329
- if (t.pending && t.pendingLink && t === this[Et] && (t.pending = !1, t.pendingLink = !1), !t.pending) {
2330
- if (t.entry) {
2331
- t === this[Et] && !t.piped && this[di](t);
2332
- return;
2333
- }
2334
- if (!t.stat) {
2335
- let e = this.statCache.get(t.absolute);
2336
- e ? this[li](t, e) : this[ds](t);
2337
- }
2338
- if (t.stat && !t.ignore) {
2339
- if (!this.noDirRecurse && t.stat.isDirectory() && !t.readdir) {
2340
- let e = this.readdirCache.get(t.absolute);
2341
- if (e ? this[fi](t, e) : this[us](t), !t.readdir) return;
2342
- }
2343
- if (t.entry = this[hr](t), !t.entry) {
2344
- t.ignore = !0;
2345
- return;
2346
- }
2347
- t === this[Et] && !t.piped && this[di](t);
2348
- }
2349
- }
2350
- }
2351
- [cs](t) {
2352
- return {
2353
- onwarn: (e, i, r) => this.warn(e, i, r),
2354
- noPax: this.noPax,
2355
- cwd: this.cwd,
2356
- absolute: t.absolute,
2357
- preservePaths: this.preservePaths,
2358
- maxReadSize: this.maxReadSize,
2359
- strict: this.strict,
2360
- portable: this.portable,
2361
- linkCache: this.linkCache,
2362
- statCache: this.statCache,
2363
- noMtime: this.noMtime,
2364
- mtime: this.mtime,
2365
- prefix: this.prefix,
2366
- onWriteEntry: this.onWriteEntry
2367
- };
2368
- }
2369
- [hr](t) {
2370
- this[G] += 1;
2371
- try {
2372
- return new this[ui](t.path, this[cs](t)).on("end", () => this[ls](t)).on("error", (i) => this.emit("error", i));
2373
- } catch (e) {
2374
- this.emit("error", e);
2375
- }
2376
- }
2377
- [fs]() {
2378
- this[Et] && this[Et].entry && this[Et].entry.resume();
2379
- }
2380
- [di](t) {
2381
- t.piped = !0, t.readdir && t.readdir.forEach((r) => {
2382
- let n = t.path, o = n === "./" ? "" : n.replace(/\/*$/, "/");
2383
- this[ci](o + r);
2384
- });
2385
- let e = t.entry, i = this.zip;
2386
- if (!e) throw new Error("cannot pipe without source");
2387
- i ? e.on("data", (r) => {
2388
- i.write(r) || e.pause();
2389
- }) : e.on("data", (r) => {
2390
- super.write(r) || e.pause();
2391
- });
2392
- }
2393
- pause() {
2394
- return this.zip && this.zip.pause(), super.pause();
2395
- }
2396
- warn(t, e, i = {}) {
2397
- Dt(this, t, e, i);
2398
- }
2399
- };
2400
- var kt = class extends wt {
2401
- sync = !0;
2402
- constructor(t) {
2403
- super(t), this[ui] = ni;
2404
- }
2405
- pause() {}
2406
- resume() {}
2407
- [ds](t) {
2408
- let e = this.follow ? "statSync" : "lstatSync";
2409
- this[li](t, I[e](t.absolute));
2410
- }
2411
- [us](t) {
2412
- this[fi](t, I.readdirSync(t.absolute));
2413
- }
2414
- [di](t) {
2415
- let e = t.entry, i = this.zip;
2416
- if (t.readdir && t.readdir.forEach((r) => {
2417
- let n = t.path, o = n === "./" ? "" : n.replace(/\/*$/, "/");
2418
- this[ci](o + r);
2419
- }), !e) throw new Error("Cannot pipe without source");
2420
- i ? e.on("data", (r) => {
2421
- i.write(r);
2422
- }) : e.on("data", (r) => {
2423
- super[lr](r);
2424
- });
2425
- }
2426
- };
2427
- var Vn = (s, t) => {
2428
- let e = new kt(s), i = new Wt(s.file, { mode: s.mode || 438 });
2429
- e.pipe(i), fr(e, t);
2430
- };
2431
- var $n = (s, t) => {
2432
- let e = new wt(s), i = new et(s.file, { mode: s.mode || 438 });
2433
- e.pipe(i);
2434
- let r = new Promise((n, o) => {
2435
- i.on("error", o), i.on("close", n), e.on("error", o);
2436
- });
2437
- return dr(e, t).catch((n) => e.emit("error", n)), r;
2438
- };
2439
- var fr = (s, t) => {
2440
- t.forEach((e) => {
2441
- e.charAt(0) === "@" ? Ct({
2442
- file: Pr.resolve(s.cwd, e.slice(1)),
2443
- sync: !0,
2444
- noResume: !0,
2445
- onReadEntry: (i) => s.add(i)
2446
- }) : s.add(e);
2447
- }), s.end();
2448
- };
2449
- var dr = async (s, t) => {
2450
- for (let e of t) e.charAt(0) === "@" ? await Ct({
2451
- file: Pr.resolve(String(s.cwd), e.slice(1)),
2452
- noResume: !0,
2453
- onReadEntry: (i) => {
2454
- s.add(i);
2455
- }
2456
- }) : s.add(e);
2457
- s.end();
2458
- };
2459
- var Xn = (s, t) => {
2460
- let e = new kt(s);
2461
- return fr(e, t), e;
2462
- };
2463
- var qn = (s, t) => {
2464
- let e = new wt(s);
2465
- return dr(e, t).catch((i) => e.emit("error", i)), e;
2466
- };
2467
- K(Vn, $n, Xn, qn, (s, t) => {
2468
- if (!t?.length) throw new TypeError("no paths specified to add to archive");
2469
- });
2470
- var Er = (process.env.__FAKE_PLATFORM__ || process.platform) === "win32", { O_CREAT: wr, O_NOFOLLOW: ur, O_TRUNC: Sr, O_WRONLY: yr } = I.constants, Rr = Number(process.env.__FAKE_FS_O_FILENAME__) || I.constants.UV_FS_O_FILEMAP || 0, jn = Er && !!Rr, to = 524288, eo = Rr | Sr | wr | yr, mr = !Er && typeof ur == "number" ? ur | Sr | wr | yr : null, ms = mr !== null ? () => mr : jn ? (s) => s < to ? eo : "w" : () => "w";
2471
- var ps = (s, t, e) => {
2472
- try {
2473
- return Br.lchownSync(s, t, e);
2474
- } catch (i) {
2475
- if (i?.code !== "ENOENT") throw i;
2476
- }
2477
- };
2478
- var Ei = (s, t, e, i) => {
2479
- Br.lchown(s, t, e, (r) => {
2480
- i(r && r?.code !== "ENOENT" ? r : null);
2481
- });
2482
- };
2483
- var io = (s, t, e, i, r) => {
2484
- if (t.isDirectory()) Es(Pr.resolve(s, t.name), e, i, (n) => {
2485
- if (n) return r(n);
2486
- Ei(Pr.resolve(s, t.name), e, i, r);
2487
- });
2488
- else Ei(Pr.resolve(s, t.name), e, i, r);
2489
- };
2490
- var Es = (s, t, e, i) => {
2491
- Br.readdir(s, { withFileTypes: !0 }, (r, n) => {
2492
- if (r) {
2493
- if (r.code === "ENOENT") return i();
2494
- if (r.code !== "ENOTDIR" && r.code !== "ENOTSUP") return i(r);
2495
- }
2496
- if (r || !n.length) return Ei(s, t, e, i);
2497
- let o = n.length, h = null, a = (l) => {
2498
- if (!h) {
2499
- if (l) return i(h = l);
2500
- if (--o === 0) return Ei(s, t, e, i);
2501
- }
2502
- };
2503
- for (let l of n) io(s, l, t, e, a);
2504
- });
2505
- };
2506
- var so = (s, t, e, i) => {
2507
- t.isDirectory() && ws(Pr.resolve(s, t.name), e, i), ps(Pr.resolve(s, t.name), e, i);
2508
- };
2509
- var ws = (s, t, e) => {
2510
- let i;
2511
- try {
2512
- i = Br.readdirSync(s, { withFileTypes: !0 });
2513
- } catch (r) {
2514
- let n = r;
2515
- if (n?.code === "ENOENT") return;
2516
- if (n?.code === "ENOTDIR" || n?.code === "ENOTSUP") return ps(s, t, e);
2517
- throw n;
2518
- }
2519
- for (let r of i) so(s, r, t, e);
2520
- return ps(s, t, e);
2521
- };
2522
- var Se = class extends Error {
2523
- path;
2524
- code;
2525
- syscall = "chdir";
2526
- constructor(t, e) {
2527
- super(`${e}: Cannot cd into '${t}'`), this.path = t, this.code = e;
2528
- }
2529
- get name() {
2530
- return "CwdError";
2531
- }
2532
- };
2533
- var St = class extends Error {
2534
- path;
2535
- symlink;
2536
- syscall = "symlink";
2537
- code = "TAR_SYMLINK_ERROR";
2538
- constructor(t, e) {
2539
- super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"), this.symlink = t, this.path = e;
2540
- }
2541
- get name() {
2542
- return "SymlinkError";
2543
- }
2544
- };
2545
- var no = (s, t) => {
2546
- Br.stat(s, (e, i) => {
2547
- (e || !i.isDirectory()) && (e = new Se(s, e?.code || "ENOTDIR")), t(e);
2548
- });
2549
- };
2550
- var gr = (s, t, e) => {
2551
- s = f(s);
2552
- let i = t.umask ?? 18, r = t.mode | 448, n = (r & i) !== 0, o = t.uid, h = t.gid, a = typeof o == "number" && typeof h == "number" && (o !== t.processUid || h !== t.processGid), l = t.preserve, c = t.unlink, d = f(t.cwd), y = (E, x) => {
2553
- E ? e(E) : x && a ? Es(x, o, h, (Le) => y(Le)) : n ? Br.chmod(s, r, e) : e();
2554
- };
2555
- if (s === d) return no(s, y);
2556
- if (l) return ro.mkdir(s, {
2557
- mode: r,
2558
- recursive: !0
2559
- }).then((E) => y(null, E ?? void 0), y);
2560
- Ss(d, f(Pr.relative(d, s)).split("/"), r, c, d, void 0, y);
2561
- };
2562
- var Ss = (s, t, e, i, r, n, o) => {
2563
- if (t.length === 0) return o(null, n);
2564
- let h = t.shift(), a = f(Pr.resolve(s + "/" + h));
2565
- Br.mkdir(a, e, br(a, t, e, i, r, n, o));
2566
- };
2567
- var br = (s, t, e, i, r, n, o) => (h) => {
2568
- h ? Br.lstat(s, (a, l) => {
2569
- if (a) a.path = a.path && f(a.path), o(a);
2570
- else if (l.isDirectory()) Ss(s, t, e, i, r, n, o);
2571
- else if (i) Br.unlink(s, (c) => {
2572
- if (c) return o(c);
2573
- Br.mkdir(s, e, br(s, t, e, i, r, n, o));
2574
- });
2575
- else {
2576
- if (l.isSymbolicLink()) return o(new St(s, s + "/" + t.join("/")));
2577
- o(h);
2578
- }
2579
- }) : (n = n || s, Ss(s, t, e, i, r, n, o));
2580
- };
2581
- var oo = (s) => {
2582
- let t = !1, e;
2583
- try {
2584
- t = Br.statSync(s).isDirectory();
2585
- } catch (i) {
2586
- e = i?.code;
2587
- } finally {
2588
- if (!t) throw new Se(s, e ?? "ENOTDIR");
2589
- }
2590
- };
2591
- var _r = (s, t) => {
2592
- s = f(s);
2593
- let e = t.umask ?? 18, i = t.mode | 448, r = (i & e) !== 0, n = t.uid, o = t.gid, h = typeof n == "number" && typeof o == "number" && (n !== t.processUid || o !== t.processGid), a = t.preserve, l = t.unlink, c = f(t.cwd), d = (E) => {
2594
- E && h && ws(E, n, o), r && Br.chmodSync(s, i);
2595
- };
2596
- if (s === c) return oo(c), d();
2597
- if (a) return d(Br.mkdirSync(s, {
2598
- mode: i,
2599
- recursive: !0
2600
- }) ?? void 0);
2601
- let T = f(Pr.relative(c, s)).split("/"), D;
2602
- for (let E = T.shift(), x = c; E && (x += "/" + E); E = T.shift()) {
2603
- x = f(Pr.resolve(x));
2604
- try {
2605
- Br.mkdirSync(x, i), D = D || x;
2606
- } catch {
2607
- let Le = Br.lstatSync(x);
2608
- if (Le.isDirectory()) continue;
2609
- if (l) {
2610
- Br.unlinkSync(x), Br.mkdirSync(x, i), D = D || x;
2611
- continue;
2612
- } else if (Le.isSymbolicLink()) return new St(x, x + "/" + T.join("/"));
2613
- }
2614
- }
2615
- return d(D);
2616
- };
2617
- var ys = Object.create(null);
2618
- var Or = 1e4;
2619
- var Vt = /* @__PURE__ */ new Set();
2620
- var Tr = (s) => {
2621
- Vt.has(s) ? Vt.delete(s) : ys[s] = s.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"), Vt.add(s);
2622
- let t = ys[s], e = Vt.size - Or;
2623
- if (e > Or / 10) {
2624
- for (let i of Vt) if (Vt.delete(i), delete ys[i], --e <= 0) break;
2625
- }
2626
- return t;
2627
- };
2628
- var ao = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) === "win32";
2629
- var lo = (s) => s.split("/").slice(0, -1).reduce((e, i) => {
2630
- let r = e.at(-1);
2631
- return r !== void 0 && (i = join(r, i)), e.push(i || "/"), e;
2632
- }, []);
2633
- var yi = class {
2634
- #t = /* @__PURE__ */ new Map();
2635
- #i = /* @__PURE__ */ new Map();
2636
- #s = /* @__PURE__ */ new Set();
2637
- reserve(t, e) {
2638
- t = ao ? ["win32 parallelization disabled"] : t.map((r) => mt(join(Tr(r))));
2639
- let i = new Set(t.map((r) => lo(r)).reduce((r, n) => r.concat(n)));
2640
- this.#i.set(e, {
2641
- dirs: i,
2642
- paths: t
2643
- });
2644
- for (let r of t) {
2645
- let n = this.#t.get(r);
2646
- n ? n.push(e) : this.#t.set(r, [e]);
2647
- }
2648
- for (let r of i) {
2649
- let n = this.#t.get(r);
2650
- if (!n) this.#t.set(r, [/* @__PURE__ */ new Set([e])]);
2651
- else {
2652
- let o = n.at(-1);
2653
- o instanceof Set ? o.add(e) : n.push(/* @__PURE__ */ new Set([e]));
2654
- }
2655
- }
2656
- return this.#r(e);
2657
- }
2658
- #n(t) {
2659
- let e = this.#i.get(t);
2660
- if (!e) throw new Error("function does not have any path reservations");
2661
- return {
2662
- paths: e.paths.map((i) => this.#t.get(i)),
2663
- dirs: [...e.dirs].map((i) => this.#t.get(i))
2664
- };
2665
- }
2666
- check(t) {
2667
- let { paths: e, dirs: i } = this.#n(t);
2668
- return e.every((r) => r && r[0] === t) && i.every((r) => r && r[0] instanceof Set && r[0].has(t));
2669
- }
2670
- #r(t) {
2671
- return this.#s.has(t) || !this.check(t) ? !1 : (this.#s.add(t), t(() => this.#e(t)), !0);
2672
- }
2673
- #e(t) {
2674
- if (!this.#s.has(t)) return !1;
2675
- let e = this.#i.get(t);
2676
- if (!e) throw new Error("invalid reservation");
2677
- let { paths: i, dirs: r } = e, n = /* @__PURE__ */ new Set();
2678
- for (let o of i) {
2679
- let h = this.#t.get(o);
2680
- if (!h || h?.[0] !== t) continue;
2681
- let a = h[1];
2682
- if (!a) {
2683
- this.#t.delete(o);
2684
- continue;
2685
- }
2686
- if (h.shift(), typeof a == "function") n.add(a);
2687
- else for (let l of a) n.add(l);
2688
- }
2689
- for (let o of r) {
2690
- let h = this.#t.get(o), a = h?.[0];
2691
- if (!(!h || !(a instanceof Set))) if (a.size === 1 && h.length === 1) {
2692
- this.#t.delete(o);
2693
- continue;
2694
- } else if (a.size === 1) {
2695
- h.shift();
2696
- let l = h[0];
2697
- typeof l == "function" && n.add(l);
2698
- } else a.delete(t);
2699
- }
2700
- return this.#s.delete(t), n.forEach((o) => this.#r(o)), !0;
2701
- }
2702
- };
2703
- var Lr = () => process.umask();
2704
- var Dr = Symbol("onEntry");
2705
- var _s = Symbol("checkFs");
2706
- var Nr = Symbol("checkFs2");
2707
- var Os = Symbol("isReusable");
2708
- var P = Symbol("makeFs");
2709
- var Ts = Symbol("file");
2710
- var xs = Symbol("directory");
2711
- var gi = Symbol("link");
2712
- var Ar = Symbol("symlink");
2713
- var Ir = Symbol("hardlink");
2714
- var Re = Symbol("ensureNoSymlink");
2715
- var Cr = Symbol("unsupported");
2716
- var Fr = Symbol("checkPath");
2717
- var Rs = Symbol("stripAbsolutePath");
2718
- var yt = Symbol("mkdir");
2719
- var O = Symbol("onError");
2720
- var Ri = Symbol("pending");
2721
- var kr = Symbol("pend");
2722
- var $t = Symbol("unpend");
2723
- var gs = Symbol("ended");
2724
- var bs = Symbol("maybeClose");
2725
- var Ls = Symbol("skip");
2726
- var ge = Symbol("doChown");
2727
- var be = Symbol("uid");
2728
- var _e = Symbol("gid");
2729
- var Oe = Symbol("checkedCwd");
2730
- var Te = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) === "win32";
2731
- var uo = 1024;
2732
- var mo = (s, t) => {
2733
- if (!Te) return Br.unlink(s, t);
2734
- let e = s + ".DELETE." + randomBytes(16).toString("hex");
2735
- Br.rename(s, e, (i) => {
2736
- if (i) return t(i);
2737
- Br.unlink(e, t);
2738
- });
2739
- };
2740
- var po = (s) => {
2741
- if (!Te) return Br.unlinkSync(s);
2742
- let t = s + ".DELETE." + randomBytes(16).toString("hex");
2743
- Br.renameSync(s, t), Br.unlinkSync(t);
2744
- };
2745
- var vr = (s, t, e) => s !== void 0 && s === s >>> 0 ? s : t !== void 0 && t === t >>> 0 ? t : e;
2746
- var Xt = class extends rt {
2747
- [gs] = !1;
2748
- [Oe] = !1;
2749
- [Ri] = 0;
2750
- reservations = new yi();
2751
- transform;
2752
- writable = !0;
2753
- readable = !1;
2754
- uid;
2755
- gid;
2756
- setOwner;
2757
- preserveOwner;
2758
- processGid;
2759
- processUid;
2760
- maxDepth;
2761
- forceChown;
2762
- win32;
2763
- newer;
2764
- keep;
2765
- noMtime;
2766
- preservePaths;
2767
- unlink;
2768
- cwd;
2769
- strip;
2770
- processUmask;
2771
- umask;
2772
- dmode;
2773
- fmode;
2774
- chmod;
2775
- constructor(t = {}) {
2776
- if (t.ondone = () => {
2777
- this[gs] = !0, this[bs]();
2778
- }, super(t), this.transform = t.transform, this.chmod = !!t.chmod, typeof t.uid == "number" || typeof t.gid == "number") {
2779
- if (typeof t.uid != "number" || typeof t.gid != "number") throw new TypeError("cannot set owner without number uid and gid");
2780
- if (t.preserveOwner) throw new TypeError("cannot preserve owner in archive and also set owner explicitly");
2781
- this.uid = t.uid, this.gid = t.gid, this.setOwner = !0;
2782
- } else this.uid = void 0, this.gid = void 0, this.setOwner = !1;
2783
- this.preserveOwner = t.preserveOwner === void 0 && typeof t.uid != "number" ? process.getuid?.() === 0 : !!t.preserveOwner, this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0, this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0, this.maxDepth = typeof t.maxDepth == "number" ? t.maxDepth : uo, this.forceChown = t.forceChown === !0, this.win32 = !!t.win32 || Te, this.newer = !!t.newer, this.keep = !!t.keep, this.noMtime = !!t.noMtime, this.preservePaths = !!t.preservePaths, this.unlink = !!t.unlink, this.cwd = f(Pr.resolve(t.cwd || process.cwd())), this.strip = Number(t.strip) || 0, this.processUmask = this.chmod ? typeof t.processUmask == "number" ? t.processUmask : Lr() : 0, this.umask = typeof t.umask == "number" ? t.umask : this.processUmask, this.dmode = t.dmode || 511 & ~this.umask, this.fmode = t.fmode || 438 & ~this.umask, this.on("entry", (e) => this[Dr](e));
2784
- }
2785
- warn(t, e, i = {}) {
2786
- return (t === "TAR_BAD_ARCHIVE" || t === "TAR_ABORT") && (i.recoverable = !1), super.warn(t, e, i);
2787
- }
2788
- [bs]() {
2789
- this[gs] && this[Ri] === 0 && (this.emit("prefinish"), this.emit("finish"), this.emit("end"));
2790
- }
2791
- [Rs](t, e) {
2792
- let i = t[e], { type: r } = t;
2793
- if (!i || this.preservePaths) return !0;
2794
- let [n, o] = ce(i), h = o.replaceAll(/\\/g, "/").split("/");
2795
- if (h.includes("..") || Te && /^[a-z]:\.\.$/i.test(h[0] ?? "")) {
2796
- if (e === "path" || r === "Link") return this.warn("TAR_ENTRY_ERROR", `${e} contains '..'`, {
2797
- entry: t,
2798
- [e]: i
2799
- }), !1;
2800
- let a = Pr.posix.dirname(t.path), l = Pr.posix.normalize(Pr.posix.join(a, h.join("/")));
2801
- if (l.startsWith("../") || l === "..") return this.warn("TAR_ENTRY_ERROR", `${e} escapes extraction directory`, {
2802
- entry: t,
2803
- [e]: i
2804
- }), !1;
2805
- }
2806
- return n && (t[e] = String(o), this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute ${e}`, {
2807
- entry: t,
2808
- [e]: i
2809
- })), !0;
2810
- }
2811
- [Fr](t) {
2812
- let e = f(t.path), i = e.split("/");
2813
- if (this.strip) {
2814
- if (i.length < this.strip) return !1;
2815
- if (t.type === "Link") {
2816
- let r = f(String(t.linkpath)).split("/");
2817
- if (r.length >= this.strip) t.linkpath = r.slice(this.strip).join("/");
2818
- else return !1;
2819
- }
2820
- i.splice(0, this.strip), t.path = i.join("/");
2821
- }
2822
- if (isFinite(this.maxDepth) && i.length > this.maxDepth) return this.warn("TAR_ENTRY_ERROR", "path excessively deep", {
2823
- entry: t,
2824
- path: e,
2825
- depth: i.length,
2826
- maxDepth: this.maxDepth
2827
- }), !1;
2828
- if (!this[Rs](t, "path") || !this[Rs](t, "linkpath")) return !1;
2829
- if (t.absolute = Pr.isAbsolute(t.path) ? f(Pr.resolve(t.path)) : f(Pr.resolve(this.cwd, t.path)), !this.preservePaths && typeof t.absolute == "string" && t.absolute.indexOf(this.cwd + "/") !== 0 && t.absolute !== this.cwd) return this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", {
2830
- entry: t,
2831
- path: f(t.path),
2832
- resolvedPath: t.absolute,
2833
- cwd: this.cwd
2834
- }), !1;
2835
- if (t.absolute === this.cwd && t.type !== "Directory" && t.type !== "GNUDumpDir") return !1;
2836
- if (this.win32) {
2837
- let { root: r } = Pr.win32.parse(String(t.absolute));
2838
- t.absolute = r + ts(String(t.absolute).slice(r.length));
2839
- let { root: n } = Pr.win32.parse(t.path);
2840
- t.path = n + ts(t.path.slice(n.length));
2841
- }
2842
- return !0;
2843
- }
2844
- [Dr](t) {
2845
- if (!this[Fr](t)) return t.resume();
2846
- switch (co.equal(typeof t.absolute, "string"), t.type) {
2847
- case "Directory":
2848
- case "GNUDumpDir": t.mode && (t.mode = t.mode | 448);
2849
- case "File":
2850
- case "OldFile":
2851
- case "ContiguousFile":
2852
- case "Link":
2853
- case "SymbolicLink": return this[_s](t);
2854
- default: return this[Cr](t);
2855
- }
2856
- }
2857
- [O](t, e) {
2858
- t.name === "CwdError" ? this.emit("error", t) : (this.warn("TAR_ENTRY_ERROR", t, { entry: e }), this[$t](), e.resume());
2859
- }
2860
- [yt](t, e, i) {
2861
- gr(f(t), {
2862
- uid: this.uid,
2863
- gid: this.gid,
2864
- processUid: this.processUid,
2865
- processGid: this.processGid,
2866
- umask: this.processUmask,
2867
- preserve: this.preservePaths,
2868
- unlink: this.unlink,
2869
- cwd: this.cwd,
2870
- mode: e
2871
- }, i);
2872
- }
2873
- [ge](t) {
2874
- return this.forceChown || this.preserveOwner && (typeof t.uid == "number" && t.uid !== this.processUid || typeof t.gid == "number" && t.gid !== this.processGid) || typeof this.uid == "number" && this.uid !== this.processUid || typeof this.gid == "number" && this.gid !== this.processGid;
2875
- }
2876
- [be](t) {
2877
- return vr(this.uid, t.uid, this.processUid);
2878
- }
2879
- [_e](t) {
2880
- return vr(this.gid, t.gid, this.processGid);
2881
- }
2882
- [Ts](t, e) {
2883
- let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = new et(String(t.absolute), {
2884
- flags: ms(t.size),
2885
- mode: i,
2886
- autoClose: !1
2887
- });
2888
- r.on("error", (a) => {
2889
- r.fd && Br.close(r.fd, () => {}), r.write = () => !0, this[O](a, t), e();
2890
- });
2891
- let n = 1, o = (a) => {
2892
- if (a) {
2893
- r.fd && Br.close(r.fd, () => {}), this[O](a, t), e();
2894
- return;
2895
- }
2896
- --n === 0 && r.fd !== void 0 && Br.close(r.fd, (l) => {
2897
- l ? this[O](l, t) : this[$t](), e();
2898
- });
2899
- };
2900
- r.on("finish", () => {
2901
- let a = String(t.absolute), l = r.fd;
2902
- if (typeof l == "number" && t.mtime && !this.noMtime) {
2903
- n++;
2904
- let c = t.atime || /* @__PURE__ */ new Date(), d = t.mtime;
2905
- Br.futimes(l, c, d, (y) => y ? Br.utimes(a, c, d, (T) => o(T && y)) : o());
2906
- }
2907
- if (typeof l == "number" && this[ge](t)) {
2908
- n++;
2909
- let c = this[be](t), d = this[_e](t);
2910
- typeof c == "number" && typeof d == "number" && Br.fchown(l, c, d, (y) => y ? Br.chown(a, c, d, (T) => o(T && y)) : o());
2911
- }
2912
- o();
2913
- });
2914
- let h = this.transform && this.transform(t) || t;
2915
- h !== t && (h.on("error", (a) => {
2916
- this[O](a, t), e();
2917
- }), t.pipe(h)), h.pipe(r);
2918
- }
2919
- [xs](t, e) {
2920
- let i = typeof t.mode == "number" ? t.mode & 4095 : this.dmode;
2921
- this[yt](String(t.absolute), i, (r) => {
2922
- if (r) {
2923
- this[O](r, t), e();
2924
- return;
2925
- }
2926
- let n = 1, o = () => {
2927
- --n === 0 && (e(), this[$t](), t.resume());
2928
- };
2929
- t.mtime && !this.noMtime && (n++, Br.utimes(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime, o)), this[ge](t) && (n++, Br.chown(String(t.absolute), Number(this[be](t)), Number(this[_e](t)), o)), o();
2930
- });
2931
- }
2932
- [Cr](t) {
2933
- t.unsupported = !0, this.warn("TAR_ENTRY_UNSUPPORTED", `unsupported entry type: ${t.type}`, { entry: t }), t.resume();
2934
- }
2935
- [Ar](t, e) {
2936
- let i = f(Pr.relative(this.cwd, Pr.resolve(Pr.dirname(String(t.absolute)), String(t.linkpath)))).split("/");
2937
- this[Re](t, this.cwd, i, () => this[gi](t, String(t.linkpath), "symlink", e), (r) => {
2938
- this[O](r, t), e();
2939
- });
2940
- }
2941
- [Ir](t, e) {
2942
- let i = f(Pr.resolve(this.cwd, String(t.linkpath))), r = f(String(t.linkpath)).split("/");
2943
- this[Re](t, this.cwd, r, () => this[gi](t, i, "link", e), (n) => {
2944
- this[O](n, t), e();
2945
- });
2946
- }
2947
- [Re](t, e, i, r, n) {
2948
- let o = i.shift();
2949
- if (this.preservePaths || o === void 0) return r();
2950
- let h = Pr.resolve(e, o);
2951
- Br.lstat(h, (a, l) => {
2952
- if (a) return r();
2953
- if (l?.isSymbolicLink()) return n(new St(h, Pr.resolve(h, i.join("/"))));
2954
- this[Re](t, h, i, r, n);
2955
- });
2956
- }
2957
- [kr]() {
2958
- this[Ri]++;
2959
- }
2960
- [$t]() {
2961
- this[Ri]--, this[bs]();
2962
- }
2963
- [Ls](t) {
2964
- this[$t](), t.resume();
2965
- }
2966
- [Os](t, e) {
2967
- return t.type === "File" && !this.unlink && e.isFile() && e.nlink <= 1 && !Te;
2968
- }
2969
- [_s](t) {
2970
- this[kr]();
2971
- let e = [t.path];
2972
- t.linkpath && e.push(t.linkpath), this.reservations.reserve(e, (i) => this[Nr](t, i));
2973
- }
2974
- [Nr](t, e) {
2975
- let i = (h) => {
2976
- e(h);
2977
- }, r = () => {
2978
- this[yt](this.cwd, this.dmode, (h) => {
2979
- if (h) {
2980
- this[O](h, t), i();
2981
- return;
2982
- }
2983
- this[Oe] = !0, n();
2984
- });
2985
- }, n = () => {
2986
- if (t.absolute !== this.cwd) {
2987
- let h = f(Pr.dirname(String(t.absolute)));
2988
- if (h !== this.cwd) return this[yt](h, this.dmode, (a) => {
2989
- if (a) {
2990
- this[O](a, t), i();
2991
- return;
2992
- }
2993
- o();
2994
- });
2995
- }
2996
- o();
2997
- }, o = () => {
2998
- Br.lstat(String(t.absolute), (h, a) => {
2999
- if (a && (this.keep || this.newer && a.mtime > (t.mtime ?? a.mtime))) {
3000
- this[Ls](t), i();
3001
- return;
3002
- }
3003
- if (h || this[Os](t, a)) return this[P](null, t, i);
3004
- if (a.isDirectory()) {
3005
- if (t.type === "Directory") {
3006
- let l = this.chmod && t.mode && (a.mode & 4095) !== t.mode, c = (d) => this[P](d ?? null, t, i);
3007
- return l ? Br.chmod(String(t.absolute), Number(t.mode), c) : c();
3008
- }
3009
- if (t.absolute !== this.cwd) return Br.rmdir(String(t.absolute), (l) => this[P](l ?? null, t, i));
3010
- }
3011
- if (t.absolute === this.cwd) return this[P](null, t, i);
3012
- mo(String(t.absolute), (l) => this[P](l ?? null, t, i));
3013
- });
3014
- };
3015
- this[Oe] ? n() : r();
3016
- }
3017
- [P](t, e, i) {
3018
- if (t) {
3019
- this[O](t, e), i();
3020
- return;
3021
- }
3022
- switch (e.type) {
3023
- case "File":
3024
- case "OldFile":
3025
- case "ContiguousFile": return this[Ts](e, i);
3026
- case "Link": return this[Ir](e, i);
3027
- case "SymbolicLink": return this[Ar](e, i);
3028
- case "Directory":
3029
- case "GNUDumpDir": return this[xs](e, i);
3030
- }
3031
- }
3032
- [gi](t, e, i, r) {
3033
- Br[i](e, String(t.absolute), (n) => {
3034
- n ? this[O](n, t) : (this[$t](), t.resume()), r();
3035
- });
3036
- }
3037
- };
3038
- var ye = (s) => {
3039
- try {
3040
- return [null, s()];
3041
- } catch (t) {
3042
- return [t, null];
3043
- }
3044
- };
3045
- var xe = class extends Xt {
3046
- sync = !0;
3047
- [P](t, e) {
3048
- return super[P](t, e, () => {});
3049
- }
3050
- [_s](t) {
3051
- if (!this[Oe]) {
3052
- let n = this[yt](this.cwd, this.dmode);
3053
- if (n) return this[O](n, t);
3054
- this[Oe] = !0;
3055
- }
3056
- if (t.absolute !== this.cwd) {
3057
- let n = f(Pr.dirname(String(t.absolute)));
3058
- if (n !== this.cwd) {
3059
- let o = this[yt](n, this.dmode);
3060
- if (o) return this[O](o, t);
3061
- }
3062
- }
3063
- let [e, i] = ye(() => Br.lstatSync(String(t.absolute)));
3064
- if (i && (this.keep || this.newer && i.mtime > (t.mtime ?? i.mtime))) return this[Ls](t);
3065
- if (e || this[Os](t, i)) return this[P](null, t);
3066
- if (i.isDirectory()) {
3067
- if (t.type === "Directory") {
3068
- let [h] = this.chmod && t.mode && (i.mode & 4095) !== t.mode ? ye(() => {
3069
- Br.chmodSync(String(t.absolute), Number(t.mode));
3070
- }) : [];
3071
- return this[P](h, t);
3072
- }
3073
- let [n] = ye(() => Br.rmdirSync(String(t.absolute)));
3074
- this[P](n, t);
3075
- }
3076
- let [r] = t.absolute === this.cwd ? [] : ye(() => po(String(t.absolute)));
3077
- this[P](r, t);
3078
- }
3079
- [Ts](t, e) {
3080
- let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = (h) => {
3081
- let a;
3082
- try {
3083
- Br.closeSync(n);
3084
- } catch (l) {
3085
- a = l;
3086
- }
3087
- (h || a) && this[O](h || a, t), e();
3088
- }, n;
3089
- try {
3090
- n = Br.openSync(String(t.absolute), ms(t.size), i);
3091
- } catch (h) {
3092
- return r(h);
3093
- }
3094
- let o = this.transform && this.transform(t) || t;
3095
- o !== t && (o.on("error", (h) => this[O](h, t)), t.pipe(o)), o.on("data", (h) => {
3096
- try {
3097
- Br.writeSync(n, h, 0, h.length);
3098
- } catch (a) {
3099
- r(a);
3100
- }
3101
- }), o.on("end", () => {
3102
- let h = null;
3103
- if (t.mtime && !this.noMtime) {
3104
- let a = t.atime || /* @__PURE__ */ new Date(), l = t.mtime;
3105
- try {
3106
- Br.futimesSync(n, a, l);
3107
- } catch (c) {
3108
- try {
3109
- Br.utimesSync(String(t.absolute), a, l);
3110
- } catch {
3111
- h = c;
3112
- }
3113
- }
3114
- }
3115
- if (this[ge](t)) {
3116
- let a = this[be](t), l = this[_e](t);
3117
- try {
3118
- Br.fchownSync(n, Number(a), Number(l));
3119
- } catch (c) {
3120
- try {
3121
- Br.chownSync(String(t.absolute), Number(a), Number(l));
3122
- } catch {
3123
- h = h || c;
3124
- }
3125
- }
3126
- }
3127
- r(h);
3128
- });
3129
- }
3130
- [xs](t, e) {
3131
- let i = typeof t.mode == "number" ? t.mode & 4095 : this.dmode, r = this[yt](String(t.absolute), i);
3132
- if (r) {
3133
- this[O](r, t), e();
3134
- return;
3135
- }
3136
- if (t.mtime && !this.noMtime) try {
3137
- Br.utimesSync(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime);
3138
- } catch {}
3139
- if (this[ge](t)) try {
3140
- Br.chownSync(String(t.absolute), Number(this[be](t)), Number(this[_e](t)));
3141
- } catch {}
3142
- e(), t.resume();
3143
- }
3144
- [yt](t, e) {
3145
- try {
3146
- return _r(f(t), {
3147
- uid: this.uid,
3148
- gid: this.gid,
3149
- processUid: this.processUid,
3150
- processGid: this.processGid,
3151
- umask: this.processUmask,
3152
- preserve: this.preservePaths,
3153
- unlink: this.unlink,
3154
- cwd: this.cwd,
3155
- mode: e
3156
- });
3157
- } catch (i) {
3158
- return i;
3159
- }
3160
- }
3161
- [Re](t, e, i, r, n) {
3162
- if (this.preservePaths || i.length === 0) return r();
3163
- let o = e;
3164
- for (let h of i) {
3165
- o = Pr.resolve(o, h);
3166
- let [a, l] = ye(() => Br.lstatSync(o));
3167
- if (a) return r();
3168
- if (l.isSymbolicLink()) return n(new St(o, Pr.resolve(e, i.join("/"))));
3169
- }
3170
- r();
3171
- }
3172
- [gi](t, e, i, r) {
3173
- let n = `${i}Sync`;
3174
- try {
3175
- Br[n](e, String(t.absolute)), r(), t.resume();
3176
- } catch (o) {
3177
- return this[O](o, t);
3178
- }
3179
- }
3180
- };
3181
- var Eo = (s) => {
3182
- let t = new xe(s), e = s.file, i = Br.statSync(e);
3183
- new Be(e, {
3184
- readSize: s.maxReadSize || 16777216,
3185
- size: i.size
3186
- }).pipe(t);
3187
- };
3188
- var wo = (s, t) => {
3189
- let e = new Xt(s), i = s.maxReadSize || 16777216, r = s.file;
3190
- return new Promise((o, h) => {
3191
- e.on("error", h), e.on("close", o), Br.stat(r, (a, l) => {
3192
- if (a) h(a);
3193
- else {
3194
- let c = new _t(r, {
3195
- readSize: i,
3196
- size: l.size
3197
- });
3198
- c.on("error", h), c.pipe(e);
3199
- }
3200
- });
3201
- });
3202
- };
3203
- K(Eo, wo, (s) => new xe(s), (s) => new Xt(s), (s, t) => {
3204
- t?.length && Qi(s, t);
3205
- });
3206
- var yo = (s, t) => {
3207
- let e = new kt(s), i = !0, r, n;
3208
- try {
3209
- try {
3210
- r = Br.openSync(s.file, "r+");
3211
- } catch (a) {
3212
- if (a?.code === "ENOENT") r = Br.openSync(s.file, "w+");
3213
- else throw a;
3214
- }
3215
- let o = Br.fstatSync(r), h = Buffer.alloc(512);
3216
- t: for (n = 0; n < o.size; n += 512) {
3217
- for (let c = 0, d = 0; c < 512; c += d) {
3218
- if (d = Br.readSync(r, h, c, h.length - c, n + c), n === 0 && h[0] === 31 && h[1] === 139) throw new Error("cannot append to compressed archives");
3219
- if (!d) break t;
3220
- }
3221
- let a = new F(h);
3222
- if (!a.cksumValid) break;
3223
- let l = 512 * Math.ceil((a.size || 0) / 512);
3224
- if (n + l + 512 > o.size) break;
3225
- n += l, s.mtimeCache && a.mtime && s.mtimeCache.set(String(a.path), a.mtime);
3226
- }
3227
- i = !1, Ro(s, e, n, r, t);
3228
- } finally {
3229
- if (i) try {
3230
- Br.closeSync(r);
3231
- } catch {}
3232
- }
3233
- };
3234
- var Ro = (s, t, e, i, r) => {
3235
- let n = new Wt(s.file, {
3236
- fd: i,
3237
- start: e
3238
- });
3239
- t.pipe(n), bo(t, r);
3240
- };
3241
- var go = (s, t) => {
3242
- t = Array.from(t);
3243
- let e = new wt(s), i = (n, o, h) => {
3244
- let a = (T, D) => {
3245
- T ? Br.close(n, (E) => h(T)) : h(null, D);
3246
- }, l = 0;
3247
- if (o === 0) return a(null, 0);
3248
- let c = 0, d = Buffer.alloc(512), y = (T, D) => {
3249
- if (T || D === void 0) return a(T);
3250
- if (c += D, c < 512 && D) return Br.read(n, d, c, d.length - c, l + c, y);
3251
- if (l === 0 && d[0] === 31 && d[1] === 139) return a(/* @__PURE__ */ new Error("cannot append to compressed archives"));
3252
- if (c < 512) return a(null, l);
3253
- let E = new F(d);
3254
- if (!E.cksumValid) return a(null, l);
3255
- let x = 512 * Math.ceil((E.size ?? 0) / 512);
3256
- if (l + x + 512 > o || (l += x + 512, l >= o)) return a(null, l);
3257
- s.mtimeCache && E.mtime && s.mtimeCache.set(String(E.path), E.mtime), c = 0, Br.read(n, d, 0, 512, l, y);
3258
- };
3259
- Br.read(n, d, 0, 512, l, y);
3260
- };
3261
- return new Promise((n, o) => {
3262
- e.on("error", o);
3263
- let h = "r+", a = (l, c) => {
3264
- if (l && l.code === "ENOENT" && h === "r+") return h = "w+", Br.open(s.file, h, a);
3265
- if (l || !c) return o(l);
3266
- Br.fstat(c, (d, y) => {
3267
- if (d) return Br.close(c, () => o(d));
3268
- i(c, y.size, (T, D) => {
3269
- if (T) return o(T);
3270
- let E = new et(s.file, {
3271
- fd: c,
3272
- start: D
3273
- });
3274
- e.pipe(E), E.on("error", o), E.on("close", n), _o(e, t);
3275
- });
3276
- });
3277
- };
3278
- Br.open(s.file, h, a);
3279
- });
3280
- };
3281
- var bo = (s, t) => {
3282
- t.forEach((e) => {
3283
- e.charAt(0) === "@" ? Ct({
3284
- file: Pr.resolve(s.cwd, e.slice(1)),
3285
- sync: !0,
3286
- noResume: !0,
3287
- onReadEntry: (i) => s.add(i)
3288
- }) : s.add(e);
3289
- }), s.end();
3290
- };
3291
- var _o = async (s, t) => {
3292
- for (let e of t) e.charAt(0) === "@" ? await Ct({
3293
- file: Pr.resolve(String(s.cwd), e.slice(1)),
3294
- noResume: !0,
3295
- onReadEntry: (i) => s.add(i)
3296
- }) : s.add(e);
3297
- s.end();
3298
- };
3299
- var vt = K(yo, go, () => {
3300
- throw new TypeError("file is required");
3301
- }, () => {
3302
- throw new TypeError("file is required");
3303
- }, (s, t) => {
3304
- if (!Bs(s)) throw new TypeError("file is required");
3305
- if (s.gzip || s.brotli || s.zstd || s.file.endsWith(".br") || s.file.endsWith(".tbr")) throw new TypeError("cannot append to compressed archives");
3306
- if (!t?.length) throw new TypeError("no paths specified to add/replace");
3307
- });
3308
- K(vt.syncFile, vt.asyncFile, vt.syncNoFile, vt.asyncNoFile, (s, t = []) => {
3309
- vt.validate?.(s, t), To(s);
3310
- });
3311
- var To = (s) => {
3312
- let t = s.filter;
3313
- s.mtimeCache || (s.mtimeCache = /* @__PURE__ */ new Map()), s.filter = t ? (e, i) => t(e, i) && !((s.mtimeCache?.get(e) ?? i.mtime ?? 0) > (i.mtime ?? 0)) : (e, i) => !((s.mtimeCache?.get(e) ?? i.mtime ?? 0) > (i.mtime ?? 0));
3314
- };
3315
10
  // ../cli/dist/shard-BqmjvX9r.mjs
3316
11
  var ApiError = class extends Error {
3317
12
  status;