nexum-code 0.7.18 → 0.7.20

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