create-book 11.0.1 → 11.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5039 @@
1
+ import path, { dirname, parse, resolve } from "path";
2
+ import fs from "node:fs";
3
+ import fs$1, { mkdir, mkdirSync, stat, statSync as statSync$1 } from "fs";
4
+ import EE, { EventEmitter } from "events";
5
+ import * as realZlib$1 from "zlib";
6
+ import realZlib from "zlib";
7
+ import assert from "assert";
8
+ import path$1, { basename, join, posix as posix$1, win32 } from "node:path";
9
+ import me from "node:stream";
10
+ import { Buffer as Buffer$1 } from "buffer";
11
+ import assert$1 from "node:assert";
12
+ import { EventEmitter as EventEmitter$1 } from "node:events";
13
+ import { randomBytes } from "node:crypto";
14
+ import { StringDecoder } from "node:string_decoder";
15
+ //#region ../../node_modules/.pnpm/minipass@7.1.2/node_modules/minipass/dist/esm/index.js
16
+ const proc = typeof process === "object" && process ? process : {
17
+ stdout: null,
18
+ stderr: null
19
+ };
20
+ /**
21
+ * Return true if the argument is a Minipass stream, Node stream, or something
22
+ * else that Minipass can interact with.
23
+ */
24
+ const isStream = (s) => !!s && typeof s === "object" && (s instanceof Minipass || s instanceof me || isReadable(s) || isWritable(s));
25
+ /**
26
+ * Return true if the argument is a valid {@link Minipass.Readable}
27
+ */
28
+ const isReadable = (s) => !!s && typeof s === "object" && s instanceof EventEmitter$1 && typeof s.pipe === "function" && s.pipe !== me.Writable.prototype.pipe;
29
+ /**
30
+ * Return true if the argument is a valid {@link Minipass.Writable}
31
+ */
32
+ const isWritable = (s) => !!s && typeof s === "object" && s instanceof EventEmitter$1 && typeof s.write === "function" && typeof s.end === "function";
33
+ const EOF$1 = Symbol("EOF");
34
+ const MAYBE_EMIT_END = Symbol("maybeEmitEnd");
35
+ const EMITTED_END = Symbol("emittedEnd");
36
+ const EMITTING_END = Symbol("emittingEnd");
37
+ const EMITTED_ERROR = Symbol("emittedError");
38
+ const CLOSED = Symbol("closed");
39
+ const READ$1 = Symbol("read");
40
+ const FLUSH = Symbol("flush");
41
+ const FLUSHCHUNK = Symbol("flushChunk");
42
+ const ENCODING = Symbol("encoding");
43
+ const DECODER = Symbol("decoder");
44
+ const FLOWING = Symbol("flowing");
45
+ const PAUSED = Symbol("paused");
46
+ const RESUME = Symbol("resume");
47
+ const BUFFER$1 = Symbol("buffer");
48
+ const PIPES = Symbol("pipes");
49
+ const BUFFERLENGTH = Symbol("bufferLength");
50
+ const BUFFERPUSH = Symbol("bufferPush");
51
+ const BUFFERSHIFT = Symbol("bufferShift");
52
+ const OBJECTMODE = Symbol("objectMode");
53
+ const DESTROYED = Symbol("destroyed");
54
+ const ERROR = Symbol("error");
55
+ const EMITDATA = Symbol("emitData");
56
+ const EMITEND = Symbol("emitEnd");
57
+ const EMITEND2 = Symbol("emitEnd2");
58
+ const ASYNC = Symbol("async");
59
+ const ABORT = Symbol("abort");
60
+ const ABORTED$1 = Symbol("aborted");
61
+ const SIGNAL = Symbol("signal");
62
+ const DATALISTENERS = Symbol("dataListeners");
63
+ const DISCARDED = Symbol("discarded");
64
+ const defer = (fn) => Promise.resolve().then(fn);
65
+ const nodefer = (fn) => fn();
66
+ const isEndish = (ev) => ev === "end" || ev === "finish" || ev === "prefinish";
67
+ const isArrayBufferLike = (b) => b instanceof ArrayBuffer || !!b && typeof b === "object" && b.constructor && b.constructor.name === "ArrayBuffer" && b.byteLength >= 0;
68
+ const isArrayBufferView = (b) => !Buffer.isBuffer(b) && ArrayBuffer.isView(b);
69
+ /**
70
+ * Internal class representing a pipe to a destination stream.
71
+ *
72
+ * @internal
73
+ */
74
+ var Pipe = class {
75
+ src;
76
+ dest;
77
+ opts;
78
+ ondrain;
79
+ constructor(src, dest, opts) {
80
+ this.src = src;
81
+ this.dest = dest;
82
+ this.opts = opts;
83
+ this.ondrain = () => src[RESUME]();
84
+ this.dest.on("drain", this.ondrain);
85
+ }
86
+ unpipe() {
87
+ this.dest.removeListener("drain", this.ondrain);
88
+ }
89
+ /* c8 ignore start */
90
+ proxyErrors(_er) {}
91
+ /* c8 ignore stop */
92
+ end() {
93
+ this.unpipe();
94
+ if (this.opts.end) this.dest.end();
95
+ }
96
+ };
97
+ /**
98
+ * Internal class representing a pipe to a destination stream where
99
+ * errors are proxied.
100
+ *
101
+ * @internal
102
+ */
103
+ var PipeProxyErrors = class extends Pipe {
104
+ unpipe() {
105
+ this.src.removeListener("error", this.proxyErrors);
106
+ super.unpipe();
107
+ }
108
+ constructor(src, dest, opts) {
109
+ super(src, dest, opts);
110
+ this.proxyErrors = (er) => dest.emit("error", er);
111
+ src.on("error", this.proxyErrors);
112
+ }
113
+ };
114
+ const isObjectModeOptions = (o) => !!o.objectMode;
115
+ const isEncodingOptions = (o) => !o.objectMode && !!o.encoding && o.encoding !== "buffer";
116
+ /**
117
+ * Main export, the Minipass class
118
+ *
119
+ * `RType` is the type of data emitted, defaults to Buffer
120
+ *
121
+ * `WType` is the type of data to be written, if RType is buffer or string,
122
+ * then any {@link Minipass.ContiguousData} is allowed.
123
+ *
124
+ * `Events` is the set of event handler signatures that this object
125
+ * will emit, see {@link Minipass.Events}
126
+ */
127
+ var Minipass = class extends EventEmitter$1 {
128
+ [FLOWING] = false;
129
+ [PAUSED] = false;
130
+ [PIPES] = [];
131
+ [BUFFER$1] = [];
132
+ [OBJECTMODE];
133
+ [ENCODING];
134
+ [ASYNC];
135
+ [DECODER];
136
+ [EOF$1] = false;
137
+ [EMITTED_END] = false;
138
+ [EMITTING_END] = false;
139
+ [CLOSED] = false;
140
+ [EMITTED_ERROR] = null;
141
+ [BUFFERLENGTH] = 0;
142
+ [DESTROYED] = false;
143
+ [SIGNAL];
144
+ [ABORTED$1] = false;
145
+ [DATALISTENERS] = 0;
146
+ [DISCARDED] = false;
147
+ /**
148
+ * true if the stream can be written
149
+ */
150
+ writable = true;
151
+ /**
152
+ * true if the stream can be read
153
+ */
154
+ readable = true;
155
+ /**
156
+ * If `RType` is Buffer, then options do not need to be provided.
157
+ * Otherwise, an options object must be provided to specify either
158
+ * {@link Minipass.SharedOptions.objectMode} or
159
+ * {@link Minipass.SharedOptions.encoding}, as appropriate.
160
+ */
161
+ constructor(...args) {
162
+ const options = args[0] || {};
163
+ super();
164
+ if (options.objectMode && typeof options.encoding === "string") throw new TypeError("Encoding and objectMode may not be used together");
165
+ if (isObjectModeOptions(options)) {
166
+ this[OBJECTMODE] = true;
167
+ this[ENCODING] = null;
168
+ } else if (isEncodingOptions(options)) {
169
+ this[ENCODING] = options.encoding;
170
+ this[OBJECTMODE] = false;
171
+ } else {
172
+ this[OBJECTMODE] = false;
173
+ this[ENCODING] = null;
174
+ }
175
+ this[ASYNC] = !!options.async;
176
+ this[DECODER] = this[ENCODING] ? new StringDecoder(this[ENCODING]) : null;
177
+ if (options && options.debugExposeBuffer === true) Object.defineProperty(this, "buffer", { get: () => this[BUFFER$1] });
178
+ if (options && options.debugExposePipes === true) Object.defineProperty(this, "pipes", { get: () => this[PIPES] });
179
+ const { signal } = options;
180
+ if (signal) {
181
+ this[SIGNAL] = signal;
182
+ if (signal.aborted) this[ABORT]();
183
+ else signal.addEventListener("abort", () => this[ABORT]());
184
+ }
185
+ }
186
+ /**
187
+ * The amount of data stored in the buffer waiting to be read.
188
+ *
189
+ * For Buffer strings, this will be the total byte length.
190
+ * For string encoding streams, this will be the string character length,
191
+ * according to JavaScript's `string.length` logic.
192
+ * For objectMode streams, this is a count of the items waiting to be
193
+ * emitted.
194
+ */
195
+ get bufferLength() {
196
+ return this[BUFFERLENGTH];
197
+ }
198
+ /**
199
+ * The `BufferEncoding` currently in use, or `null`
200
+ */
201
+ get encoding() {
202
+ return this[ENCODING];
203
+ }
204
+ /**
205
+ * @deprecated - This is a read only property
206
+ */
207
+ set encoding(_enc) {
208
+ throw new Error("Encoding must be set at instantiation time");
209
+ }
210
+ /**
211
+ * @deprecated - Encoding may only be set at instantiation time
212
+ */
213
+ setEncoding(_enc) {
214
+ throw new Error("Encoding must be set at instantiation time");
215
+ }
216
+ /**
217
+ * True if this is an objectMode stream
218
+ */
219
+ get objectMode() {
220
+ return this[OBJECTMODE];
221
+ }
222
+ /**
223
+ * @deprecated - This is a read-only property
224
+ */
225
+ set objectMode(_om) {
226
+ throw new Error("objectMode must be set at instantiation time");
227
+ }
228
+ /**
229
+ * true if this is an async stream
230
+ */
231
+ get ["async"]() {
232
+ return this[ASYNC];
233
+ }
234
+ /**
235
+ * Set to true to make this stream async.
236
+ *
237
+ * Once set, it cannot be unset, as this would potentially cause incorrect
238
+ * behavior. Ie, a sync stream can be made async, but an async stream
239
+ * cannot be safely made sync.
240
+ */
241
+ set ["async"](a) {
242
+ this[ASYNC] = this[ASYNC] || !!a;
243
+ }
244
+ [ABORT]() {
245
+ this[ABORTED$1] = true;
246
+ this.emit("abort", this[SIGNAL]?.reason);
247
+ this.destroy(this[SIGNAL]?.reason);
248
+ }
249
+ /**
250
+ * True if the stream has been aborted.
251
+ */
252
+ get aborted() {
253
+ return this[ABORTED$1];
254
+ }
255
+ /**
256
+ * No-op setter. Stream aborted status is set via the AbortSignal provided
257
+ * in the constructor options.
258
+ */
259
+ set aborted(_) {}
260
+ write(chunk, encoding, cb) {
261
+ if (this[ABORTED$1]) return false;
262
+ if (this[EOF$1]) throw new Error("write after end");
263
+ if (this[DESTROYED]) {
264
+ this.emit("error", Object.assign(/* @__PURE__ */ new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" }));
265
+ return true;
266
+ }
267
+ if (typeof encoding === "function") {
268
+ cb = encoding;
269
+ encoding = "utf8";
270
+ }
271
+ if (!encoding) encoding = "utf8";
272
+ const fn = this[ASYNC] ? defer : nodefer;
273
+ if (!this[OBJECTMODE] && !Buffer.isBuffer(chunk)) {
274
+ if (isArrayBufferView(chunk)) chunk = Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength);
275
+ else if (isArrayBufferLike(chunk)) chunk = Buffer.from(chunk);
276
+ else if (typeof chunk !== "string") throw new Error("Non-contiguous data written to non-objectMode stream");
277
+ }
278
+ if (this[OBJECTMODE]) {
279
+ /* c8 ignore start */
280
+ if (this[FLOWING] && this[BUFFERLENGTH] !== 0) this[FLUSH](true);
281
+ /* c8 ignore stop */
282
+ if (this[FLOWING]) this.emit("data", chunk);
283
+ else this[BUFFERPUSH](chunk);
284
+ if (this[BUFFERLENGTH] !== 0) this.emit("readable");
285
+ if (cb) fn(cb);
286
+ return this[FLOWING];
287
+ }
288
+ if (!chunk.length) {
289
+ if (this[BUFFERLENGTH] !== 0) this.emit("readable");
290
+ if (cb) fn(cb);
291
+ return this[FLOWING];
292
+ }
293
+ if (typeof chunk === "string" && !(encoding === this[ENCODING] && !this[DECODER]?.lastNeed)) chunk = Buffer.from(chunk, encoding);
294
+ if (Buffer.isBuffer(chunk) && this[ENCODING]) chunk = this[DECODER].write(chunk);
295
+ if (this[FLOWING] && this[BUFFERLENGTH] !== 0) this[FLUSH](true);
296
+ if (this[FLOWING]) this.emit("data", chunk);
297
+ else this[BUFFERPUSH](chunk);
298
+ if (this[BUFFERLENGTH] !== 0) this.emit("readable");
299
+ if (cb) fn(cb);
300
+ return this[FLOWING];
301
+ }
302
+ /**
303
+ * Low-level explicit read method.
304
+ *
305
+ * In objectMode, the argument is ignored, and one item is returned if
306
+ * available.
307
+ *
308
+ * `n` is the number of bytes (or in the case of encoding streams,
309
+ * characters) to consume. If `n` is not provided, then the entire buffer
310
+ * is returned, or `null` is returned if no data is available.
311
+ *
312
+ * If `n` is greater that the amount of data in the internal buffer,
313
+ * then `null` is returned.
314
+ */
315
+ read(n) {
316
+ if (this[DESTROYED]) return null;
317
+ this[DISCARDED] = false;
318
+ if (this[BUFFERLENGTH] === 0 || n === 0 || n && n > this[BUFFERLENGTH]) {
319
+ this[MAYBE_EMIT_END]();
320
+ return null;
321
+ }
322
+ if (this[OBJECTMODE]) n = null;
323
+ if (this[BUFFER$1].length > 1 && !this[OBJECTMODE]) this[BUFFER$1] = [this[ENCODING] ? this[BUFFER$1].join("") : Buffer.concat(this[BUFFER$1], this[BUFFERLENGTH])];
324
+ const ret = this[READ$1](n || null, this[BUFFER$1][0]);
325
+ this[MAYBE_EMIT_END]();
326
+ return ret;
327
+ }
328
+ [READ$1](n, chunk) {
329
+ if (this[OBJECTMODE]) this[BUFFERSHIFT]();
330
+ else {
331
+ const c = chunk;
332
+ if (n === c.length || n === null) this[BUFFERSHIFT]();
333
+ else if (typeof c === "string") {
334
+ this[BUFFER$1][0] = c.slice(n);
335
+ chunk = c.slice(0, n);
336
+ this[BUFFERLENGTH] -= n;
337
+ } else {
338
+ this[BUFFER$1][0] = c.subarray(n);
339
+ chunk = c.subarray(0, n);
340
+ this[BUFFERLENGTH] -= n;
341
+ }
342
+ }
343
+ this.emit("data", chunk);
344
+ if (!this[BUFFER$1].length && !this[EOF$1]) this.emit("drain");
345
+ return chunk;
346
+ }
347
+ end(chunk, encoding, cb) {
348
+ if (typeof chunk === "function") {
349
+ cb = chunk;
350
+ chunk = void 0;
351
+ }
352
+ if (typeof encoding === "function") {
353
+ cb = encoding;
354
+ encoding = "utf8";
355
+ }
356
+ if (chunk !== void 0) this.write(chunk, encoding);
357
+ if (cb) this.once("end", cb);
358
+ this[EOF$1] = true;
359
+ this.writable = false;
360
+ if (this[FLOWING] || !this[PAUSED]) this[MAYBE_EMIT_END]();
361
+ return this;
362
+ }
363
+ [RESUME]() {
364
+ if (this[DESTROYED]) return;
365
+ if (!this[DATALISTENERS] && !this[PIPES].length) this[DISCARDED] = true;
366
+ this[PAUSED] = false;
367
+ this[FLOWING] = true;
368
+ this.emit("resume");
369
+ if (this[BUFFER$1].length) this[FLUSH]();
370
+ else if (this[EOF$1]) this[MAYBE_EMIT_END]();
371
+ else this.emit("drain");
372
+ }
373
+ /**
374
+ * Resume the stream if it is currently in a paused state
375
+ *
376
+ * If called when there are no pipe destinations or `data` event listeners,
377
+ * this will place the stream in a "discarded" state, where all data will
378
+ * be thrown away. The discarded state is removed if a pipe destination or
379
+ * data handler is added, if pause() is called, or if any synchronous or
380
+ * asynchronous iteration is started.
381
+ */
382
+ resume() {
383
+ return this[RESUME]();
384
+ }
385
+ /**
386
+ * Pause the stream
387
+ */
388
+ pause() {
389
+ this[FLOWING] = false;
390
+ this[PAUSED] = true;
391
+ this[DISCARDED] = false;
392
+ }
393
+ /**
394
+ * true if the stream has been forcibly destroyed
395
+ */
396
+ get destroyed() {
397
+ return this[DESTROYED];
398
+ }
399
+ /**
400
+ * true if the stream is currently in a flowing state, meaning that
401
+ * any writes will be immediately emitted.
402
+ */
403
+ get flowing() {
404
+ return this[FLOWING];
405
+ }
406
+ /**
407
+ * true if the stream is currently in a paused state
408
+ */
409
+ get paused() {
410
+ return this[PAUSED];
411
+ }
412
+ [BUFFERPUSH](chunk) {
413
+ if (this[OBJECTMODE]) this[BUFFERLENGTH] += 1;
414
+ else this[BUFFERLENGTH] += chunk.length;
415
+ this[BUFFER$1].push(chunk);
416
+ }
417
+ [BUFFERSHIFT]() {
418
+ if (this[OBJECTMODE]) this[BUFFERLENGTH] -= 1;
419
+ else this[BUFFERLENGTH] -= this[BUFFER$1][0].length;
420
+ return this[BUFFER$1].shift();
421
+ }
422
+ [FLUSH](noDrain = false) {
423
+ do ;
424
+ while (this[FLUSHCHUNK](this[BUFFERSHIFT]()) && this[BUFFER$1].length);
425
+ if (!noDrain && !this[BUFFER$1].length && !this[EOF$1]) this.emit("drain");
426
+ }
427
+ [FLUSHCHUNK](chunk) {
428
+ this.emit("data", chunk);
429
+ return this[FLOWING];
430
+ }
431
+ /**
432
+ * Pipe all data emitted by this stream into the destination provided.
433
+ *
434
+ * Triggers the flow of data.
435
+ */
436
+ pipe(dest, opts) {
437
+ if (this[DESTROYED]) return dest;
438
+ this[DISCARDED] = false;
439
+ const ended = this[EMITTED_END];
440
+ opts = opts || {};
441
+ if (dest === proc.stdout || dest === proc.stderr) opts.end = false;
442
+ else opts.end = opts.end !== false;
443
+ opts.proxyErrors = !!opts.proxyErrors;
444
+ if (ended) {
445
+ if (opts.end) dest.end();
446
+ } else {
447
+ this[PIPES].push(!opts.proxyErrors ? new Pipe(this, dest, opts) : new PipeProxyErrors(this, dest, opts));
448
+ if (this[ASYNC]) defer(() => this[RESUME]());
449
+ else this[RESUME]();
450
+ }
451
+ return dest;
452
+ }
453
+ /**
454
+ * Fully unhook a piped destination stream.
455
+ *
456
+ * If the destination stream was the only consumer of this stream (ie,
457
+ * there are no other piped destinations or `'data'` event listeners)
458
+ * then the flow of data will stop until there is another consumer or
459
+ * {@link Minipass#resume} is explicitly called.
460
+ */
461
+ unpipe(dest) {
462
+ const p = this[PIPES].find((p) => p.dest === dest);
463
+ if (p) {
464
+ if (this[PIPES].length === 1) {
465
+ if (this[FLOWING] && this[DATALISTENERS] === 0) this[FLOWING] = false;
466
+ this[PIPES] = [];
467
+ } else this[PIPES].splice(this[PIPES].indexOf(p), 1);
468
+ p.unpipe();
469
+ }
470
+ }
471
+ /**
472
+ * Alias for {@link Minipass#on}
473
+ */
474
+ addListener(ev, handler) {
475
+ return this.on(ev, handler);
476
+ }
477
+ /**
478
+ * Mostly identical to `EventEmitter.on`, with the following
479
+ * behavior differences to prevent data loss and unnecessary hangs:
480
+ *
481
+ * - Adding a 'data' event handler will trigger the flow of data
482
+ *
483
+ * - Adding a 'readable' event handler when there is data waiting to be read
484
+ * will cause 'readable' to be emitted immediately.
485
+ *
486
+ * - Adding an 'endish' event handler ('end', 'finish', etc.) which has
487
+ * already passed will cause the event to be emitted immediately and all
488
+ * handlers removed.
489
+ *
490
+ * - Adding an 'error' event handler after an error has been emitted will
491
+ * cause the event to be re-emitted immediately with the error previously
492
+ * raised.
493
+ */
494
+ on(ev, handler) {
495
+ const ret = super.on(ev, handler);
496
+ if (ev === "data") {
497
+ this[DISCARDED] = false;
498
+ this[DATALISTENERS]++;
499
+ if (!this[PIPES].length && !this[FLOWING]) this[RESUME]();
500
+ } else if (ev === "readable" && this[BUFFERLENGTH] !== 0) super.emit("readable");
501
+ else if (isEndish(ev) && this[EMITTED_END]) {
502
+ super.emit(ev);
503
+ this.removeAllListeners(ev);
504
+ } else if (ev === "error" && this[EMITTED_ERROR]) {
505
+ const h = handler;
506
+ if (this[ASYNC]) defer(() => h.call(this, this[EMITTED_ERROR]));
507
+ else h.call(this, this[EMITTED_ERROR]);
508
+ }
509
+ return ret;
510
+ }
511
+ /**
512
+ * Alias for {@link Minipass#off}
513
+ */
514
+ removeListener(ev, handler) {
515
+ return this.off(ev, handler);
516
+ }
517
+ /**
518
+ * Mostly identical to `EventEmitter.off`
519
+ *
520
+ * If a 'data' event handler is removed, and it was the last consumer
521
+ * (ie, there are no pipe destinations or other 'data' event listeners),
522
+ * then the flow of data will stop until there is another consumer or
523
+ * {@link Minipass#resume} is explicitly called.
524
+ */
525
+ off(ev, handler) {
526
+ const ret = super.off(ev, handler);
527
+ if (ev === "data") {
528
+ this[DATALISTENERS] = this.listeners("data").length;
529
+ if (this[DATALISTENERS] === 0 && !this[DISCARDED] && !this[PIPES].length) this[FLOWING] = false;
530
+ }
531
+ return ret;
532
+ }
533
+ /**
534
+ * Mostly identical to `EventEmitter.removeAllListeners`
535
+ *
536
+ * If all 'data' event handlers are removed, and they were the last consumer
537
+ * (ie, there are no pipe destinations), then the flow of data will stop
538
+ * until there is another consumer or {@link Minipass#resume} is explicitly
539
+ * called.
540
+ */
541
+ removeAllListeners(ev) {
542
+ const ret = super.removeAllListeners(ev);
543
+ if (ev === "data" || ev === void 0) {
544
+ this[DATALISTENERS] = 0;
545
+ if (!this[DISCARDED] && !this[PIPES].length) this[FLOWING] = false;
546
+ }
547
+ return ret;
548
+ }
549
+ /**
550
+ * true if the 'end' event has been emitted
551
+ */
552
+ get emittedEnd() {
553
+ return this[EMITTED_END];
554
+ }
555
+ [MAYBE_EMIT_END]() {
556
+ if (!this[EMITTING_END] && !this[EMITTED_END] && !this[DESTROYED] && this[BUFFER$1].length === 0 && this[EOF$1]) {
557
+ this[EMITTING_END] = true;
558
+ this.emit("end");
559
+ this.emit("prefinish");
560
+ this.emit("finish");
561
+ if (this[CLOSED]) this.emit("close");
562
+ this[EMITTING_END] = false;
563
+ }
564
+ }
565
+ /**
566
+ * Mostly identical to `EventEmitter.emit`, with the following
567
+ * behavior differences to prevent data loss and unnecessary hangs:
568
+ *
569
+ * If the stream has been destroyed, and the event is something other
570
+ * than 'close' or 'error', then `false` is returned and no handlers
571
+ * are called.
572
+ *
573
+ * If the event is 'end', and has already been emitted, then the event
574
+ * is ignored. If the stream is in a paused or non-flowing state, then
575
+ * the event will be deferred until data flow resumes. If the stream is
576
+ * async, then handlers will be called on the next tick rather than
577
+ * immediately.
578
+ *
579
+ * If the event is 'close', and 'end' has not yet been emitted, then
580
+ * the event will be deferred until after 'end' is emitted.
581
+ *
582
+ * If the event is 'error', and an AbortSignal was provided for the stream,
583
+ * and there are no listeners, then the event is ignored, matching the
584
+ * behavior of node core streams in the presense of an AbortSignal.
585
+ *
586
+ * If the event is 'finish' or 'prefinish', then all listeners will be
587
+ * removed after emitting the event, to prevent double-firing.
588
+ */
589
+ emit(ev, ...args) {
590
+ const data = args[0];
591
+ if (ev !== "error" && ev !== "close" && ev !== DESTROYED && this[DESTROYED]) return false;
592
+ else if (ev === "data") return !this[OBJECTMODE] && !data ? false : this[ASYNC] ? (defer(() => this[EMITDATA](data)), true) : this[EMITDATA](data);
593
+ else if (ev === "end") return this[EMITEND]();
594
+ else if (ev === "close") {
595
+ this[CLOSED] = true;
596
+ if (!this[EMITTED_END] && !this[DESTROYED]) return false;
597
+ const ret = super.emit("close");
598
+ this.removeAllListeners("close");
599
+ return ret;
600
+ } else if (ev === "error") {
601
+ this[EMITTED_ERROR] = data;
602
+ super.emit(ERROR, data);
603
+ const ret = !this[SIGNAL] || this.listeners("error").length ? super.emit("error", data) : false;
604
+ this[MAYBE_EMIT_END]();
605
+ return ret;
606
+ } else if (ev === "resume") {
607
+ const ret = super.emit("resume");
608
+ this[MAYBE_EMIT_END]();
609
+ return ret;
610
+ } else if (ev === "finish" || ev === "prefinish") {
611
+ const ret = super.emit(ev);
612
+ this.removeAllListeners(ev);
613
+ return ret;
614
+ }
615
+ const ret = super.emit(ev, ...args);
616
+ this[MAYBE_EMIT_END]();
617
+ return ret;
618
+ }
619
+ [EMITDATA](data) {
620
+ for (const p of this[PIPES]) if (p.dest.write(data) === false) this.pause();
621
+ const ret = this[DISCARDED] ? false : super.emit("data", data);
622
+ this[MAYBE_EMIT_END]();
623
+ return ret;
624
+ }
625
+ [EMITEND]() {
626
+ if (this[EMITTED_END]) return false;
627
+ this[EMITTED_END] = true;
628
+ this.readable = false;
629
+ return this[ASYNC] ? (defer(() => this[EMITEND2]()), true) : this[EMITEND2]();
630
+ }
631
+ [EMITEND2]() {
632
+ if (this[DECODER]) {
633
+ const data = this[DECODER].end();
634
+ if (data) {
635
+ for (const p of this[PIPES]) p.dest.write(data);
636
+ if (!this[DISCARDED]) super.emit("data", data);
637
+ }
638
+ }
639
+ for (const p of this[PIPES]) p.end();
640
+ const ret = super.emit("end");
641
+ this.removeAllListeners("end");
642
+ return ret;
643
+ }
644
+ /**
645
+ * Return a Promise that resolves to an array of all emitted data once
646
+ * the stream ends.
647
+ */
648
+ async collect() {
649
+ const buf = Object.assign([], { dataLength: 0 });
650
+ if (!this[OBJECTMODE]) buf.dataLength = 0;
651
+ const p = this.promise();
652
+ this.on("data", (c) => {
653
+ buf.push(c);
654
+ if (!this[OBJECTMODE]) buf.dataLength += c.length;
655
+ });
656
+ await p;
657
+ return buf;
658
+ }
659
+ /**
660
+ * Return a Promise that resolves to the concatenation of all emitted data
661
+ * once the stream ends.
662
+ *
663
+ * Not allowed on objectMode streams.
664
+ */
665
+ async concat() {
666
+ if (this[OBJECTMODE]) throw new Error("cannot concat in objectMode");
667
+ const buf = await this.collect();
668
+ return this[ENCODING] ? buf.join("") : Buffer.concat(buf, buf.dataLength);
669
+ }
670
+ /**
671
+ * Return a void Promise that resolves once the stream ends.
672
+ */
673
+ async promise() {
674
+ return new Promise((resolve, reject) => {
675
+ this.on(DESTROYED, () => reject(/* @__PURE__ */ new Error("stream destroyed")));
676
+ this.on("error", (er) => reject(er));
677
+ this.on("end", () => resolve());
678
+ });
679
+ }
680
+ /**
681
+ * Asynchronous `for await of` iteration.
682
+ *
683
+ * This will continue emitting all chunks until the stream terminates.
684
+ */
685
+ [Symbol.asyncIterator]() {
686
+ this[DISCARDED] = false;
687
+ let stopped = false;
688
+ const stop = async () => {
689
+ this.pause();
690
+ stopped = true;
691
+ return {
692
+ value: void 0,
693
+ done: true
694
+ };
695
+ };
696
+ const next = () => {
697
+ if (stopped) return stop();
698
+ const res = this.read();
699
+ if (res !== null) return Promise.resolve({
700
+ done: false,
701
+ value: res
702
+ });
703
+ if (this[EOF$1]) return stop();
704
+ let resolve;
705
+ let reject;
706
+ const onerr = (er) => {
707
+ this.off("data", ondata);
708
+ this.off("end", onend);
709
+ this.off(DESTROYED, ondestroy);
710
+ stop();
711
+ reject(er);
712
+ };
713
+ const ondata = (value) => {
714
+ this.off("error", onerr);
715
+ this.off("end", onend);
716
+ this.off(DESTROYED, ondestroy);
717
+ this.pause();
718
+ resolve({
719
+ value,
720
+ done: !!this[EOF$1]
721
+ });
722
+ };
723
+ const onend = () => {
724
+ this.off("error", onerr);
725
+ this.off("data", ondata);
726
+ this.off(DESTROYED, ondestroy);
727
+ stop();
728
+ resolve({
729
+ done: true,
730
+ value: void 0
731
+ });
732
+ };
733
+ const ondestroy = () => onerr(/* @__PURE__ */ new Error("stream destroyed"));
734
+ return new Promise((res, rej) => {
735
+ reject = rej;
736
+ resolve = res;
737
+ this.once(DESTROYED, ondestroy);
738
+ this.once("error", onerr);
739
+ this.once("end", onend);
740
+ this.once("data", ondata);
741
+ });
742
+ };
743
+ return {
744
+ next,
745
+ throw: stop,
746
+ return: stop,
747
+ [Symbol.asyncIterator]() {
748
+ return this;
749
+ }
750
+ };
751
+ }
752
+ /**
753
+ * Synchronous `for of` iteration.
754
+ *
755
+ * The iteration will terminate when the internal buffer runs out, even
756
+ * if the stream has not yet terminated.
757
+ */
758
+ [Symbol.iterator]() {
759
+ this[DISCARDED] = false;
760
+ let stopped = false;
761
+ const stop = () => {
762
+ this.pause();
763
+ this.off(ERROR, stop);
764
+ this.off(DESTROYED, stop);
765
+ this.off("end", stop);
766
+ stopped = true;
767
+ return {
768
+ done: true,
769
+ value: void 0
770
+ };
771
+ };
772
+ const next = () => {
773
+ if (stopped) return stop();
774
+ const value = this.read();
775
+ return value === null ? stop() : {
776
+ done: false,
777
+ value
778
+ };
779
+ };
780
+ this.once("end", stop);
781
+ this.once(ERROR, stop);
782
+ this.once(DESTROYED, stop);
783
+ return {
784
+ next,
785
+ throw: stop,
786
+ return: stop,
787
+ [Symbol.iterator]() {
788
+ return this;
789
+ }
790
+ };
791
+ }
792
+ /**
793
+ * Destroy a stream, preventing it from being used for any further purpose.
794
+ *
795
+ * If the stream has a `close()` method, then it will be called on
796
+ * destruction.
797
+ *
798
+ * After destruction, any attempt to write data, read data, or emit most
799
+ * events will be ignored.
800
+ *
801
+ * If an error argument is provided, then it will be emitted in an
802
+ * 'error' event.
803
+ */
804
+ destroy(er) {
805
+ if (this[DESTROYED]) {
806
+ if (er) this.emit("error", er);
807
+ else this.emit(DESTROYED);
808
+ return this;
809
+ }
810
+ this[DESTROYED] = true;
811
+ this[DISCARDED] = true;
812
+ this[BUFFER$1].length = 0;
813
+ this[BUFFERLENGTH] = 0;
814
+ const wc = this;
815
+ if (typeof wc.close === "function" && !this[CLOSED]) wc.close();
816
+ if (er) this.emit("error", er);
817
+ else this.emit(DESTROYED);
818
+ return this;
819
+ }
820
+ /**
821
+ * Alias for {@link isStream}
822
+ *
823
+ * Former export location, maintained for backwards compatibility.
824
+ *
825
+ * @deprecated
826
+ */
827
+ static get isStream() {
828
+ return isStream;
829
+ }
830
+ };
831
+ //#endregion
832
+ //#region ../../node_modules/.pnpm/@isaacs+fs-minipass@4.0.1/node_modules/@isaacs/fs-minipass/dist/esm/index.js
833
+ const writev = fs$1.writev;
834
+ const _autoClose = Symbol("_autoClose");
835
+ const _close = Symbol("_close");
836
+ const _ended = Symbol("_ended");
837
+ const _fd = Symbol("_fd");
838
+ const _finished = Symbol("_finished");
839
+ const _flags = Symbol("_flags");
840
+ const _flush = Symbol("_flush");
841
+ const _handleChunk = Symbol("_handleChunk");
842
+ const _makeBuf = Symbol("_makeBuf");
843
+ const _mode = Symbol("_mode");
844
+ const _needDrain = Symbol("_needDrain");
845
+ const _onerror = Symbol("_onerror");
846
+ const _onopen = Symbol("_onopen");
847
+ const _onread = Symbol("_onread");
848
+ const _onwrite = Symbol("_onwrite");
849
+ const _open = Symbol("_open");
850
+ const _path = Symbol("_path");
851
+ const _pos = Symbol("_pos");
852
+ const _queue = Symbol("_queue");
853
+ const _read = Symbol("_read");
854
+ const _readSize = Symbol("_readSize");
855
+ const _reading = Symbol("_reading");
856
+ const _remain = Symbol("_remain");
857
+ const _size = Symbol("_size");
858
+ const _write = Symbol("_write");
859
+ const _writing = Symbol("_writing");
860
+ const _defaultFlag = Symbol("_defaultFlag");
861
+ const _errored = Symbol("_errored");
862
+ var ReadStream = class extends Minipass {
863
+ [_errored] = false;
864
+ [_fd];
865
+ [_path];
866
+ [_readSize];
867
+ [_reading] = false;
868
+ [_size];
869
+ [_remain];
870
+ [_autoClose];
871
+ constructor(path, opt) {
872
+ opt = opt || {};
873
+ super(opt);
874
+ this.readable = true;
875
+ this.writable = false;
876
+ if (typeof path !== "string") throw new TypeError("path must be a string");
877
+ this[_errored] = false;
878
+ this[_fd] = typeof opt.fd === "number" ? opt.fd : void 0;
879
+ this[_path] = path;
880
+ this[_readSize] = opt.readSize || 16 * 1024 * 1024;
881
+ this[_reading] = false;
882
+ this[_size] = typeof opt.size === "number" ? opt.size : Infinity;
883
+ this[_remain] = this[_size];
884
+ this[_autoClose] = typeof opt.autoClose === "boolean" ? opt.autoClose : true;
885
+ if (typeof this[_fd] === "number") this[_read]();
886
+ else this[_open]();
887
+ }
888
+ get fd() {
889
+ return this[_fd];
890
+ }
891
+ get path() {
892
+ return this[_path];
893
+ }
894
+ write() {
895
+ throw new TypeError("this is a readable stream");
896
+ }
897
+ end() {
898
+ throw new TypeError("this is a readable stream");
899
+ }
900
+ [_open]() {
901
+ fs$1.open(this[_path], "r", (er, fd) => this[_onopen](er, fd));
902
+ }
903
+ [_onopen](er, fd) {
904
+ if (er) this[_onerror](er);
905
+ else {
906
+ this[_fd] = fd;
907
+ this.emit("open", fd);
908
+ this[_read]();
909
+ }
910
+ }
911
+ [_makeBuf]() {
912
+ return Buffer.allocUnsafe(Math.min(this[_readSize], this[_remain]));
913
+ }
914
+ [_read]() {
915
+ if (!this[_reading]) {
916
+ this[_reading] = true;
917
+ const buf = this[_makeBuf]();
918
+ /* c8 ignore start */
919
+ if (buf.length === 0) return process.nextTick(() => this[_onread](null, 0, buf));
920
+ /* c8 ignore stop */
921
+ fs$1.read(this[_fd], buf, 0, buf.length, null, (er, br, b) => this[_onread](er, br, b));
922
+ }
923
+ }
924
+ [_onread](er, br, buf) {
925
+ this[_reading] = false;
926
+ if (er) this[_onerror](er);
927
+ else if (this[_handleChunk](br, buf)) this[_read]();
928
+ }
929
+ [_close]() {
930
+ if (this[_autoClose] && typeof this[_fd] === "number") {
931
+ const fd = this[_fd];
932
+ this[_fd] = void 0;
933
+ fs$1.close(fd, (er) => er ? this.emit("error", er) : this.emit("close"));
934
+ }
935
+ }
936
+ [_onerror](er) {
937
+ this[_reading] = true;
938
+ this[_close]();
939
+ this.emit("error", er);
940
+ }
941
+ [_handleChunk](br, buf) {
942
+ let ret = false;
943
+ this[_remain] -= br;
944
+ if (br > 0) ret = super.write(br < buf.length ? buf.subarray(0, br) : buf);
945
+ if (br === 0 || this[_remain] <= 0) {
946
+ ret = false;
947
+ this[_close]();
948
+ super.end();
949
+ }
950
+ return ret;
951
+ }
952
+ emit(ev, ...args) {
953
+ switch (ev) {
954
+ case "prefinish":
955
+ case "finish": return false;
956
+ case "drain":
957
+ if (typeof this[_fd] === "number") this[_read]();
958
+ return false;
959
+ case "error":
960
+ if (this[_errored]) return false;
961
+ this[_errored] = true;
962
+ return super.emit(ev, ...args);
963
+ default: return super.emit(ev, ...args);
964
+ }
965
+ }
966
+ };
967
+ var ReadStreamSync = class extends ReadStream {
968
+ [_open]() {
969
+ let threw = true;
970
+ try {
971
+ this[_onopen](null, fs$1.openSync(this[_path], "r"));
972
+ threw = false;
973
+ } finally {
974
+ if (threw) this[_close]();
975
+ }
976
+ }
977
+ [_read]() {
978
+ let threw = true;
979
+ try {
980
+ if (!this[_reading]) {
981
+ this[_reading] = true;
982
+ do {
983
+ const buf = this[_makeBuf]();
984
+ /* c8 ignore start */
985
+ const br = buf.length === 0 ? 0 : fs$1.readSync(this[_fd], buf, 0, buf.length, null);
986
+ /* c8 ignore stop */
987
+ if (!this[_handleChunk](br, buf)) break;
988
+ } while (true);
989
+ this[_reading] = false;
990
+ }
991
+ threw = false;
992
+ } finally {
993
+ if (threw) this[_close]();
994
+ }
995
+ }
996
+ [_close]() {
997
+ if (this[_autoClose] && typeof this[_fd] === "number") {
998
+ const fd = this[_fd];
999
+ this[_fd] = void 0;
1000
+ fs$1.closeSync(fd);
1001
+ this.emit("close");
1002
+ }
1003
+ }
1004
+ };
1005
+ var WriteStream = class extends EE {
1006
+ readable = false;
1007
+ writable = true;
1008
+ [_errored] = false;
1009
+ [_writing] = false;
1010
+ [_ended] = false;
1011
+ [_queue] = [];
1012
+ [_needDrain] = false;
1013
+ [_path];
1014
+ [_mode];
1015
+ [_autoClose];
1016
+ [_fd];
1017
+ [_defaultFlag];
1018
+ [_flags];
1019
+ [_finished] = false;
1020
+ [_pos];
1021
+ constructor(path, opt) {
1022
+ opt = opt || {};
1023
+ super(opt);
1024
+ this[_path] = path;
1025
+ this[_fd] = typeof opt.fd === "number" ? opt.fd : void 0;
1026
+ this[_mode] = opt.mode === void 0 ? 438 : opt.mode;
1027
+ this[_pos] = typeof opt.start === "number" ? opt.start : void 0;
1028
+ this[_autoClose] = typeof opt.autoClose === "boolean" ? opt.autoClose : true;
1029
+ const defaultFlag = this[_pos] !== void 0 ? "r+" : "w";
1030
+ this[_defaultFlag] = opt.flags === void 0;
1031
+ this[_flags] = opt.flags === void 0 ? defaultFlag : opt.flags;
1032
+ if (this[_fd] === void 0) this[_open]();
1033
+ }
1034
+ emit(ev, ...args) {
1035
+ if (ev === "error") {
1036
+ if (this[_errored]) return false;
1037
+ this[_errored] = true;
1038
+ }
1039
+ return super.emit(ev, ...args);
1040
+ }
1041
+ get fd() {
1042
+ return this[_fd];
1043
+ }
1044
+ get path() {
1045
+ return this[_path];
1046
+ }
1047
+ [_onerror](er) {
1048
+ this[_close]();
1049
+ this[_writing] = true;
1050
+ this.emit("error", er);
1051
+ }
1052
+ [_open]() {
1053
+ fs$1.open(this[_path], this[_flags], this[_mode], (er, fd) => this[_onopen](er, fd));
1054
+ }
1055
+ [_onopen](er, fd) {
1056
+ if (this[_defaultFlag] && this[_flags] === "r+" && er && er.code === "ENOENT") {
1057
+ this[_flags] = "w";
1058
+ this[_open]();
1059
+ } else if (er) this[_onerror](er);
1060
+ else {
1061
+ this[_fd] = fd;
1062
+ this.emit("open", fd);
1063
+ if (!this[_writing]) this[_flush]();
1064
+ }
1065
+ }
1066
+ end(buf, enc) {
1067
+ if (buf) this.write(buf, enc);
1068
+ this[_ended] = true;
1069
+ if (!this[_writing] && !this[_queue].length && typeof this[_fd] === "number") this[_onwrite](null, 0);
1070
+ return this;
1071
+ }
1072
+ write(buf, enc) {
1073
+ if (typeof buf === "string") buf = Buffer.from(buf, enc);
1074
+ if (this[_ended]) {
1075
+ this.emit("error", /* @__PURE__ */ new Error("write() after end()"));
1076
+ return false;
1077
+ }
1078
+ if (this[_fd] === void 0 || this[_writing] || this[_queue].length) {
1079
+ this[_queue].push(buf);
1080
+ this[_needDrain] = true;
1081
+ return false;
1082
+ }
1083
+ this[_writing] = true;
1084
+ this[_write](buf);
1085
+ return true;
1086
+ }
1087
+ [_write](buf) {
1088
+ fs$1.write(this[_fd], buf, 0, buf.length, this[_pos], (er, bw) => this[_onwrite](er, bw));
1089
+ }
1090
+ [_onwrite](er, bw) {
1091
+ if (er) this[_onerror](er);
1092
+ else {
1093
+ if (this[_pos] !== void 0 && typeof bw === "number") this[_pos] += bw;
1094
+ if (this[_queue].length) this[_flush]();
1095
+ else {
1096
+ this[_writing] = false;
1097
+ if (this[_ended] && !this[_finished]) {
1098
+ this[_finished] = true;
1099
+ this[_close]();
1100
+ this.emit("finish");
1101
+ } else if (this[_needDrain]) {
1102
+ this[_needDrain] = false;
1103
+ this.emit("drain");
1104
+ }
1105
+ }
1106
+ }
1107
+ }
1108
+ [_flush]() {
1109
+ if (this[_queue].length === 0) {
1110
+ if (this[_ended]) this[_onwrite](null, 0);
1111
+ } else if (this[_queue].length === 1) this[_write](this[_queue].pop());
1112
+ else {
1113
+ const iovec = this[_queue];
1114
+ this[_queue] = [];
1115
+ writev(this[_fd], iovec, this[_pos], (er, bw) => this[_onwrite](er, bw));
1116
+ }
1117
+ }
1118
+ [_close]() {
1119
+ if (this[_autoClose] && typeof this[_fd] === "number") {
1120
+ const fd = this[_fd];
1121
+ this[_fd] = void 0;
1122
+ fs$1.close(fd, (er) => er ? this.emit("error", er) : this.emit("close"));
1123
+ }
1124
+ }
1125
+ };
1126
+ var WriteStreamSync = class extends WriteStream {
1127
+ [_open]() {
1128
+ let fd;
1129
+ if (this[_defaultFlag] && this[_flags] === "r+") try {
1130
+ fd = fs$1.openSync(this[_path], this[_flags], this[_mode]);
1131
+ } catch (er) {
1132
+ if (er?.code === "ENOENT") {
1133
+ this[_flags] = "w";
1134
+ return this[_open]();
1135
+ } else throw er;
1136
+ }
1137
+ else fd = fs$1.openSync(this[_path], this[_flags], this[_mode]);
1138
+ this[_onopen](null, fd);
1139
+ }
1140
+ [_close]() {
1141
+ if (this[_autoClose] && typeof this[_fd] === "number") {
1142
+ const fd = this[_fd];
1143
+ this[_fd] = void 0;
1144
+ fs$1.closeSync(fd);
1145
+ this.emit("close");
1146
+ }
1147
+ }
1148
+ [_write](buf) {
1149
+ let threw = true;
1150
+ try {
1151
+ this[_onwrite](null, fs$1.writeSync(this[_fd], buf, 0, buf.length, this[_pos]));
1152
+ threw = false;
1153
+ } finally {
1154
+ if (threw) try {
1155
+ this[_close]();
1156
+ } catch {}
1157
+ }
1158
+ }
1159
+ };
1160
+ //#endregion
1161
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/options.js
1162
+ const argmap = /* @__PURE__ */ new Map([
1163
+ ["C", "cwd"],
1164
+ ["f", "file"],
1165
+ ["z", "gzip"],
1166
+ ["P", "preservePaths"],
1167
+ ["U", "unlink"],
1168
+ ["strip-components", "strip"],
1169
+ ["stripComponents", "strip"],
1170
+ ["keep-newer", "newer"],
1171
+ ["keepNewer", "newer"],
1172
+ ["keep-newer-files", "newer"],
1173
+ ["keepNewerFiles", "newer"],
1174
+ ["k", "keep"],
1175
+ ["keep-existing", "keep"],
1176
+ ["keepExisting", "keep"],
1177
+ ["m", "noMtime"],
1178
+ ["no-mtime", "noMtime"],
1179
+ ["p", "preserveOwner"],
1180
+ ["L", "follow"],
1181
+ ["h", "follow"],
1182
+ ["onentry", "onReadEntry"]
1183
+ ]);
1184
+ const isSyncFile = (o) => !!o.sync && !!o.file;
1185
+ const isAsyncFile = (o) => !o.sync && !!o.file;
1186
+ const isSyncNoFile = (o) => !!o.sync && !o.file;
1187
+ const isAsyncNoFile = (o) => !o.sync && !o.file;
1188
+ const isFile = (o) => !!o.file;
1189
+ const dealiasKey = (k) => {
1190
+ const d = argmap.get(k);
1191
+ if (d) return d;
1192
+ return k;
1193
+ };
1194
+ const dealias = (opt = {}) => {
1195
+ if (!opt) return {};
1196
+ const result = {};
1197
+ for (const [key, v] of Object.entries(opt)) {
1198
+ const k = dealiasKey(key);
1199
+ result[k] = v;
1200
+ }
1201
+ if (result.chmod === void 0 && result.noChmod === false) result.chmod = true;
1202
+ delete result.noChmod;
1203
+ return result;
1204
+ };
1205
+ //#endregion
1206
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/make-command.js
1207
+ const makeCommand = (syncFile, asyncFile, syncNoFile, asyncNoFile, validate) => {
1208
+ return Object.assign((opt_ = [], entries, cb) => {
1209
+ if (Array.isArray(opt_)) {
1210
+ entries = opt_;
1211
+ opt_ = {};
1212
+ }
1213
+ if (typeof entries === "function") {
1214
+ cb = entries;
1215
+ entries = void 0;
1216
+ }
1217
+ if (!entries) entries = [];
1218
+ else entries = Array.from(entries);
1219
+ const opt = dealias(opt_);
1220
+ validate?.(opt, entries);
1221
+ if (isSyncFile(opt)) {
1222
+ if (typeof cb === "function") throw new TypeError("callback not supported for sync tar functions");
1223
+ return syncFile(opt, entries);
1224
+ } else if (isAsyncFile(opt)) {
1225
+ const p = asyncFile(opt, entries);
1226
+ const c = cb ? cb : void 0;
1227
+ return c ? p.then(() => c(), c) : p;
1228
+ } else if (isSyncNoFile(opt)) {
1229
+ if (typeof cb === "function") throw new TypeError("callback not supported for sync tar functions");
1230
+ return syncNoFile(opt, entries);
1231
+ } else if (isAsyncNoFile(opt)) {
1232
+ if (typeof cb === "function") throw new TypeError("callback only supported with file option");
1233
+ return asyncNoFile(opt, entries);
1234
+ } else throw new Error("impossible options??");
1235
+ /* c8 ignore stop */
1236
+ }, {
1237
+ syncFile,
1238
+ asyncFile,
1239
+ syncNoFile,
1240
+ asyncNoFile,
1241
+ validate
1242
+ });
1243
+ };
1244
+ //#endregion
1245
+ //#region ../../node_modules/.pnpm/minizlib@3.0.2/node_modules/minizlib/dist/esm/constants.js
1246
+ /* c8 ignore start */
1247
+ const realZlibConstants = realZlib.constants || { ZLIB_VERNUM: 4736 };
1248
+ /* c8 ignore stop */
1249
+ const constants = Object.freeze(Object.assign(Object.create(null), {
1250
+ Z_NO_FLUSH: 0,
1251
+ Z_PARTIAL_FLUSH: 1,
1252
+ Z_SYNC_FLUSH: 2,
1253
+ Z_FULL_FLUSH: 3,
1254
+ Z_FINISH: 4,
1255
+ Z_BLOCK: 5,
1256
+ Z_OK: 0,
1257
+ Z_STREAM_END: 1,
1258
+ Z_NEED_DICT: 2,
1259
+ Z_ERRNO: -1,
1260
+ Z_STREAM_ERROR: -2,
1261
+ Z_DATA_ERROR: -3,
1262
+ Z_MEM_ERROR: -4,
1263
+ Z_BUF_ERROR: -5,
1264
+ Z_VERSION_ERROR: -6,
1265
+ Z_NO_COMPRESSION: 0,
1266
+ Z_BEST_SPEED: 1,
1267
+ Z_BEST_COMPRESSION: 9,
1268
+ Z_DEFAULT_COMPRESSION: -1,
1269
+ Z_FILTERED: 1,
1270
+ Z_HUFFMAN_ONLY: 2,
1271
+ Z_RLE: 3,
1272
+ Z_FIXED: 4,
1273
+ Z_DEFAULT_STRATEGY: 0,
1274
+ DEFLATE: 1,
1275
+ INFLATE: 2,
1276
+ GZIP: 3,
1277
+ GUNZIP: 4,
1278
+ DEFLATERAW: 5,
1279
+ INFLATERAW: 6,
1280
+ UNZIP: 7,
1281
+ BROTLI_DECODE: 8,
1282
+ BROTLI_ENCODE: 9,
1283
+ Z_MIN_WINDOWBITS: 8,
1284
+ Z_MAX_WINDOWBITS: 15,
1285
+ Z_DEFAULT_WINDOWBITS: 15,
1286
+ Z_MIN_CHUNK: 64,
1287
+ Z_MAX_CHUNK: Infinity,
1288
+ Z_DEFAULT_CHUNK: 16384,
1289
+ Z_MIN_MEMLEVEL: 1,
1290
+ Z_MAX_MEMLEVEL: 9,
1291
+ Z_DEFAULT_MEMLEVEL: 8,
1292
+ Z_MIN_LEVEL: -1,
1293
+ Z_MAX_LEVEL: 9,
1294
+ Z_DEFAULT_LEVEL: -1,
1295
+ BROTLI_OPERATION_PROCESS: 0,
1296
+ BROTLI_OPERATION_FLUSH: 1,
1297
+ BROTLI_OPERATION_FINISH: 2,
1298
+ BROTLI_OPERATION_EMIT_METADATA: 3,
1299
+ BROTLI_MODE_GENERIC: 0,
1300
+ BROTLI_MODE_TEXT: 1,
1301
+ BROTLI_MODE_FONT: 2,
1302
+ BROTLI_DEFAULT_MODE: 0,
1303
+ BROTLI_MIN_QUALITY: 0,
1304
+ BROTLI_MAX_QUALITY: 11,
1305
+ BROTLI_DEFAULT_QUALITY: 11,
1306
+ BROTLI_MIN_WINDOW_BITS: 10,
1307
+ BROTLI_MAX_WINDOW_BITS: 24,
1308
+ BROTLI_LARGE_MAX_WINDOW_BITS: 30,
1309
+ BROTLI_DEFAULT_WINDOW: 22,
1310
+ BROTLI_MIN_INPUT_BLOCK_BITS: 16,
1311
+ BROTLI_MAX_INPUT_BLOCK_BITS: 24,
1312
+ BROTLI_PARAM_MODE: 0,
1313
+ BROTLI_PARAM_QUALITY: 1,
1314
+ BROTLI_PARAM_LGWIN: 2,
1315
+ BROTLI_PARAM_LGBLOCK: 3,
1316
+ BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: 4,
1317
+ BROTLI_PARAM_SIZE_HINT: 5,
1318
+ BROTLI_PARAM_LARGE_WINDOW: 6,
1319
+ BROTLI_PARAM_NPOSTFIX: 7,
1320
+ BROTLI_PARAM_NDIRECT: 8,
1321
+ BROTLI_DECODER_RESULT_ERROR: 0,
1322
+ BROTLI_DECODER_RESULT_SUCCESS: 1,
1323
+ BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: 2,
1324
+ BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: 3,
1325
+ BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: 0,
1326
+ BROTLI_DECODER_PARAM_LARGE_WINDOW: 1,
1327
+ BROTLI_DECODER_NO_ERROR: 0,
1328
+ BROTLI_DECODER_SUCCESS: 1,
1329
+ BROTLI_DECODER_NEEDS_MORE_INPUT: 2,
1330
+ BROTLI_DECODER_NEEDS_MORE_OUTPUT: 3,
1331
+ BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: -1,
1332
+ BROTLI_DECODER_ERROR_FORMAT_RESERVED: -2,
1333
+ BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: -3,
1334
+ BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: -4,
1335
+ BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: -5,
1336
+ BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: -6,
1337
+ BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: -7,
1338
+ BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: -8,
1339
+ BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: -9,
1340
+ BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: -10,
1341
+ BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: -11,
1342
+ BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: -12,
1343
+ BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: -13,
1344
+ BROTLI_DECODER_ERROR_FORMAT_PADDING_1: -14,
1345
+ BROTLI_DECODER_ERROR_FORMAT_PADDING_2: -15,
1346
+ BROTLI_DECODER_ERROR_FORMAT_DISTANCE: -16,
1347
+ BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: -19,
1348
+ BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: -20,
1349
+ BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: -21,
1350
+ BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: -22,
1351
+ BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: -25,
1352
+ BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: -26,
1353
+ BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: -27,
1354
+ BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: -30,
1355
+ BROTLI_DECODER_ERROR_UNREACHABLE: -31
1356
+ }, realZlibConstants));
1357
+ //#endregion
1358
+ //#region ../../node_modules/.pnpm/minizlib@3.0.2/node_modules/minizlib/dist/esm/index.js
1359
+ const OriginalBufferConcat = Buffer$1.concat;
1360
+ const desc = Object.getOwnPropertyDescriptor(Buffer$1, "concat");
1361
+ const noop$1 = (args) => args;
1362
+ const passthroughBufferConcat = desc?.writable === true || desc?.set !== void 0 ? (makeNoOp) => {
1363
+ Buffer$1.concat = makeNoOp ? noop$1 : OriginalBufferConcat;
1364
+ } : (_) => {};
1365
+ const _superWrite = Symbol("_superWrite");
1366
+ var ZlibError = class extends Error {
1367
+ code;
1368
+ errno;
1369
+ constructor(err) {
1370
+ super("zlib: " + err.message);
1371
+ this.code = err.code;
1372
+ this.errno = err.errno;
1373
+ /* c8 ignore next */
1374
+ if (!this.code) this.code = "ZLIB_ERROR";
1375
+ this.message = "zlib: " + err.message;
1376
+ Error.captureStackTrace(this, this.constructor);
1377
+ }
1378
+ get name() {
1379
+ return "ZlibError";
1380
+ }
1381
+ };
1382
+ const _flushFlag = Symbol("flushFlag");
1383
+ var ZlibBase = class extends Minipass {
1384
+ #sawError = false;
1385
+ #ended = false;
1386
+ #flushFlag;
1387
+ #finishFlushFlag;
1388
+ #fullFlushFlag;
1389
+ #handle;
1390
+ #onError;
1391
+ get sawError() {
1392
+ return this.#sawError;
1393
+ }
1394
+ get handle() {
1395
+ return this.#handle;
1396
+ }
1397
+ /* c8 ignore start */
1398
+ get flushFlag() {
1399
+ return this.#flushFlag;
1400
+ }
1401
+ /* c8 ignore stop */
1402
+ constructor(opts, mode) {
1403
+ if (!opts || typeof opts !== "object") throw new TypeError("invalid options for ZlibBase constructor");
1404
+ super(opts);
1405
+ /* c8 ignore start */
1406
+ this.#flushFlag = opts.flush ?? 0;
1407
+ this.#finishFlushFlag = opts.finishFlush ?? 0;
1408
+ this.#fullFlushFlag = opts.fullFlushFlag ?? 0;
1409
+ /* c8 ignore stop */
1410
+ try {
1411
+ this.#handle = new realZlib$1[mode](opts);
1412
+ } catch (er) {
1413
+ throw new ZlibError(er);
1414
+ }
1415
+ this.#onError = (err) => {
1416
+ if (this.#sawError) return;
1417
+ this.#sawError = true;
1418
+ this.close();
1419
+ this.emit("error", err);
1420
+ };
1421
+ this.#handle?.on("error", (er) => this.#onError(new ZlibError(er)));
1422
+ this.once("end", () => this.close);
1423
+ }
1424
+ close() {
1425
+ if (this.#handle) {
1426
+ this.#handle.close();
1427
+ this.#handle = void 0;
1428
+ this.emit("close");
1429
+ }
1430
+ }
1431
+ reset() {
1432
+ if (!this.#sawError) {
1433
+ assert(this.#handle, "zlib binding closed");
1434
+ return this.#handle.reset?.();
1435
+ }
1436
+ }
1437
+ flush(flushFlag) {
1438
+ if (this.ended) return;
1439
+ if (typeof flushFlag !== "number") flushFlag = this.#fullFlushFlag;
1440
+ this.write(Object.assign(Buffer$1.alloc(0), { [_flushFlag]: flushFlag }));
1441
+ }
1442
+ end(chunk, encoding, cb) {
1443
+ /* c8 ignore start */
1444
+ if (typeof chunk === "function") {
1445
+ cb = chunk;
1446
+ encoding = void 0;
1447
+ chunk = void 0;
1448
+ }
1449
+ if (typeof encoding === "function") {
1450
+ cb = encoding;
1451
+ encoding = void 0;
1452
+ }
1453
+ /* c8 ignore stop */
1454
+ if (chunk) if (encoding) this.write(chunk, encoding);
1455
+ else this.write(chunk);
1456
+ this.flush(this.#finishFlushFlag);
1457
+ this.#ended = true;
1458
+ return super.end(cb);
1459
+ }
1460
+ get ended() {
1461
+ return this.#ended;
1462
+ }
1463
+ [_superWrite](data) {
1464
+ return super.write(data);
1465
+ }
1466
+ write(chunk, encoding, cb) {
1467
+ if (typeof encoding === "function") cb = encoding, encoding = "utf8";
1468
+ if (typeof chunk === "string") chunk = Buffer$1.from(chunk, encoding);
1469
+ if (this.#sawError) return;
1470
+ assert(this.#handle, "zlib binding closed");
1471
+ const nativeHandle = this.#handle._handle;
1472
+ const originalNativeClose = nativeHandle.close;
1473
+ nativeHandle.close = () => {};
1474
+ const originalClose = this.#handle.close;
1475
+ this.#handle.close = () => {};
1476
+ passthroughBufferConcat(true);
1477
+ let result = void 0;
1478
+ try {
1479
+ const flushFlag = typeof chunk[_flushFlag] === "number" ? chunk[_flushFlag] : this.#flushFlag;
1480
+ result = this.#handle._processChunk(chunk, flushFlag);
1481
+ passthroughBufferConcat(false);
1482
+ } catch (err) {
1483
+ passthroughBufferConcat(false);
1484
+ this.#onError(new ZlibError(err));
1485
+ } finally {
1486
+ if (this.#handle) {
1487
+ this.#handle._handle = nativeHandle;
1488
+ nativeHandle.close = originalNativeClose;
1489
+ this.#handle.close = originalClose;
1490
+ this.#handle.removeAllListeners("error");
1491
+ }
1492
+ }
1493
+ if (this.#handle) this.#handle.on("error", (er) => this.#onError(new ZlibError(er)));
1494
+ let writeReturn;
1495
+ if (result) if (Array.isArray(result) && result.length > 0) {
1496
+ const r = result[0];
1497
+ writeReturn = this[_superWrite](Buffer$1.from(r));
1498
+ for (let i = 1; i < result.length; i++) writeReturn = this[_superWrite](result[i]);
1499
+ } else writeReturn = this[_superWrite](Buffer$1.from(result));
1500
+ if (cb) cb();
1501
+ return writeReturn;
1502
+ }
1503
+ };
1504
+ var Zlib = class extends ZlibBase {
1505
+ #level;
1506
+ #strategy;
1507
+ constructor(opts, mode) {
1508
+ opts = opts || {};
1509
+ opts.flush = opts.flush || constants.Z_NO_FLUSH;
1510
+ opts.finishFlush = opts.finishFlush || constants.Z_FINISH;
1511
+ opts.fullFlushFlag = constants.Z_FULL_FLUSH;
1512
+ super(opts, mode);
1513
+ this.#level = opts.level;
1514
+ this.#strategy = opts.strategy;
1515
+ }
1516
+ params(level, strategy) {
1517
+ if (this.sawError) return;
1518
+ if (!this.handle) throw new Error("cannot switch params when binding is closed");
1519
+ /* c8 ignore start */
1520
+ if (!this.handle.params) throw new Error("not supported in this implementation");
1521
+ /* c8 ignore stop */
1522
+ if (this.#level !== level || this.#strategy !== strategy) {
1523
+ this.flush(constants.Z_SYNC_FLUSH);
1524
+ assert(this.handle, "zlib binding closed");
1525
+ const origFlush = this.handle.flush;
1526
+ this.handle.flush = (flushFlag, cb) => {
1527
+ /* c8 ignore start */
1528
+ if (typeof flushFlag === "function") {
1529
+ cb = flushFlag;
1530
+ flushFlag = this.flushFlag;
1531
+ }
1532
+ /* c8 ignore stop */
1533
+ this.flush(flushFlag);
1534
+ cb?.();
1535
+ };
1536
+ try {
1537
+ this.handle.params(level, strategy);
1538
+ } finally {
1539
+ this.handle.flush = origFlush;
1540
+ }
1541
+ /* c8 ignore start */
1542
+ if (this.handle) {
1543
+ this.#level = level;
1544
+ this.#strategy = strategy;
1545
+ }
1546
+ }
1547
+ }
1548
+ };
1549
+ var Gzip = class extends Zlib {
1550
+ #portable;
1551
+ constructor(opts) {
1552
+ super(opts, "Gzip");
1553
+ this.#portable = opts && !!opts.portable;
1554
+ }
1555
+ [_superWrite](data) {
1556
+ if (!this.#portable) return super[_superWrite](data);
1557
+ this.#portable = false;
1558
+ data[9] = 255;
1559
+ return super[_superWrite](data);
1560
+ }
1561
+ };
1562
+ var Unzip = class extends Zlib {
1563
+ constructor(opts) {
1564
+ super(opts, "Unzip");
1565
+ }
1566
+ };
1567
+ var Brotli = class extends ZlibBase {
1568
+ constructor(opts, mode) {
1569
+ opts = opts || {};
1570
+ opts.flush = opts.flush || constants.BROTLI_OPERATION_PROCESS;
1571
+ opts.finishFlush = opts.finishFlush || constants.BROTLI_OPERATION_FINISH;
1572
+ opts.fullFlushFlag = constants.BROTLI_OPERATION_FLUSH;
1573
+ super(opts, mode);
1574
+ }
1575
+ };
1576
+ var BrotliCompress = class extends Brotli {
1577
+ constructor(opts) {
1578
+ super(opts, "BrotliCompress");
1579
+ }
1580
+ };
1581
+ var BrotliDecompress = class extends Brotli {
1582
+ constructor(opts) {
1583
+ super(opts, "BrotliDecompress");
1584
+ }
1585
+ };
1586
+ //#endregion
1587
+ //#region ../../node_modules/.pnpm/yallist@5.0.0/node_modules/yallist/dist/esm/index.js
1588
+ var Yallist = class Yallist {
1589
+ tail;
1590
+ head;
1591
+ length = 0;
1592
+ static create(list = []) {
1593
+ return new Yallist(list);
1594
+ }
1595
+ constructor(list = []) {
1596
+ for (const item of list) this.push(item);
1597
+ }
1598
+ *[Symbol.iterator]() {
1599
+ for (let walker = this.head; walker; walker = walker.next) yield walker.value;
1600
+ }
1601
+ removeNode(node) {
1602
+ if (node.list !== this) throw new Error("removing node which does not belong to this list");
1603
+ const next = node.next;
1604
+ const prev = node.prev;
1605
+ if (next) next.prev = prev;
1606
+ if (prev) prev.next = next;
1607
+ if (node === this.head) this.head = next;
1608
+ if (node === this.tail) this.tail = prev;
1609
+ this.length--;
1610
+ node.next = void 0;
1611
+ node.prev = void 0;
1612
+ node.list = void 0;
1613
+ return next;
1614
+ }
1615
+ unshiftNode(node) {
1616
+ if (node === this.head) return;
1617
+ if (node.list) node.list.removeNode(node);
1618
+ const head = this.head;
1619
+ node.list = this;
1620
+ node.next = head;
1621
+ if (head) head.prev = node;
1622
+ this.head = node;
1623
+ if (!this.tail) this.tail = node;
1624
+ this.length++;
1625
+ }
1626
+ pushNode(node) {
1627
+ if (node === this.tail) return;
1628
+ if (node.list) node.list.removeNode(node);
1629
+ const tail = this.tail;
1630
+ node.list = this;
1631
+ node.prev = tail;
1632
+ if (tail) tail.next = node;
1633
+ this.tail = node;
1634
+ if (!this.head) this.head = node;
1635
+ this.length++;
1636
+ }
1637
+ push(...args) {
1638
+ for (let i = 0, l = args.length; i < l; i++) push(this, args[i]);
1639
+ return this.length;
1640
+ }
1641
+ unshift(...args) {
1642
+ for (var i = 0, l = args.length; i < l; i++) unshift(this, args[i]);
1643
+ return this.length;
1644
+ }
1645
+ pop() {
1646
+ if (!this.tail) return;
1647
+ const res = this.tail.value;
1648
+ const t = this.tail;
1649
+ this.tail = this.tail.prev;
1650
+ if (this.tail) this.tail.next = void 0;
1651
+ else this.head = void 0;
1652
+ t.list = void 0;
1653
+ this.length--;
1654
+ return res;
1655
+ }
1656
+ shift() {
1657
+ if (!this.head) return;
1658
+ const res = this.head.value;
1659
+ const h = this.head;
1660
+ this.head = this.head.next;
1661
+ if (this.head) this.head.prev = void 0;
1662
+ else this.tail = void 0;
1663
+ h.list = void 0;
1664
+ this.length--;
1665
+ return res;
1666
+ }
1667
+ forEach(fn, thisp) {
1668
+ thisp = thisp || this;
1669
+ for (let walker = this.head, i = 0; !!walker; i++) {
1670
+ fn.call(thisp, walker.value, i, this);
1671
+ walker = walker.next;
1672
+ }
1673
+ }
1674
+ forEachReverse(fn, thisp) {
1675
+ thisp = thisp || this;
1676
+ for (let walker = this.tail, i = this.length - 1; !!walker; i--) {
1677
+ fn.call(thisp, walker.value, i, this);
1678
+ walker = walker.prev;
1679
+ }
1680
+ }
1681
+ get(n) {
1682
+ let i = 0;
1683
+ let walker = this.head;
1684
+ for (; !!walker && i < n; i++) walker = walker.next;
1685
+ if (i === n && !!walker) return walker.value;
1686
+ }
1687
+ getReverse(n) {
1688
+ let i = 0;
1689
+ let walker = this.tail;
1690
+ for (; !!walker && i < n; i++) walker = walker.prev;
1691
+ if (i === n && !!walker) return walker.value;
1692
+ }
1693
+ map(fn, thisp) {
1694
+ thisp = thisp || this;
1695
+ const res = new Yallist();
1696
+ for (let walker = this.head; !!walker;) {
1697
+ res.push(fn.call(thisp, walker.value, this));
1698
+ walker = walker.next;
1699
+ }
1700
+ return res;
1701
+ }
1702
+ mapReverse(fn, thisp) {
1703
+ thisp = thisp || this;
1704
+ var res = new Yallist();
1705
+ for (let walker = this.tail; !!walker;) {
1706
+ res.push(fn.call(thisp, walker.value, this));
1707
+ walker = walker.prev;
1708
+ }
1709
+ return res;
1710
+ }
1711
+ reduce(fn, initial) {
1712
+ let acc;
1713
+ let walker = this.head;
1714
+ if (arguments.length > 1) acc = initial;
1715
+ else if (this.head) {
1716
+ walker = this.head.next;
1717
+ acc = this.head.value;
1718
+ } else throw new TypeError("Reduce of empty list with no initial value");
1719
+ for (var i = 0; !!walker; i++) {
1720
+ acc = fn(acc, walker.value, i);
1721
+ walker = walker.next;
1722
+ }
1723
+ return acc;
1724
+ }
1725
+ reduceReverse(fn, initial) {
1726
+ let acc;
1727
+ let walker = this.tail;
1728
+ if (arguments.length > 1) acc = initial;
1729
+ else if (this.tail) {
1730
+ walker = this.tail.prev;
1731
+ acc = this.tail.value;
1732
+ } else throw new TypeError("Reduce of empty list with no initial value");
1733
+ for (let i = this.length - 1; !!walker; i--) {
1734
+ acc = fn(acc, walker.value, i);
1735
+ walker = walker.prev;
1736
+ }
1737
+ return acc;
1738
+ }
1739
+ toArray() {
1740
+ const arr = new Array(this.length);
1741
+ for (let i = 0, walker = this.head; !!walker; i++) {
1742
+ arr[i] = walker.value;
1743
+ walker = walker.next;
1744
+ }
1745
+ return arr;
1746
+ }
1747
+ toArrayReverse() {
1748
+ const arr = new Array(this.length);
1749
+ for (let i = 0, walker = this.tail; !!walker; i++) {
1750
+ arr[i] = walker.value;
1751
+ walker = walker.prev;
1752
+ }
1753
+ return arr;
1754
+ }
1755
+ slice(from = 0, to = this.length) {
1756
+ if (to < 0) to += this.length;
1757
+ if (from < 0) from += this.length;
1758
+ const ret = new Yallist();
1759
+ if (to < from || to < 0) return ret;
1760
+ if (from < 0) from = 0;
1761
+ if (to > this.length) to = this.length;
1762
+ let walker = this.head;
1763
+ let i = 0;
1764
+ for (i = 0; !!walker && i < from; i++) walker = walker.next;
1765
+ for (; !!walker && i < to; i++, walker = walker.next) ret.push(walker.value);
1766
+ return ret;
1767
+ }
1768
+ sliceReverse(from = 0, to = this.length) {
1769
+ if (to < 0) to += this.length;
1770
+ if (from < 0) from += this.length;
1771
+ const ret = new Yallist();
1772
+ if (to < from || to < 0) return ret;
1773
+ if (from < 0) from = 0;
1774
+ if (to > this.length) to = this.length;
1775
+ let i = this.length;
1776
+ let walker = this.tail;
1777
+ for (; !!walker && i > to; i--) walker = walker.prev;
1778
+ for (; !!walker && i > from; i--, walker = walker.prev) ret.push(walker.value);
1779
+ return ret;
1780
+ }
1781
+ splice(start, deleteCount = 0, ...nodes) {
1782
+ if (start > this.length) start = this.length - 1;
1783
+ if (start < 0) start = this.length + start;
1784
+ let walker = this.head;
1785
+ for (let i = 0; !!walker && i < start; i++) walker = walker.next;
1786
+ const ret = [];
1787
+ for (let i = 0; !!walker && i < deleteCount; i++) {
1788
+ ret.push(walker.value);
1789
+ walker = this.removeNode(walker);
1790
+ }
1791
+ if (!walker) walker = this.tail;
1792
+ else if (walker !== this.tail) walker = walker.prev;
1793
+ for (const v of nodes) walker = insertAfter(this, walker, v);
1794
+ return ret;
1795
+ }
1796
+ reverse() {
1797
+ const head = this.head;
1798
+ const tail = this.tail;
1799
+ for (let walker = head; !!walker; walker = walker.prev) {
1800
+ const p = walker.prev;
1801
+ walker.prev = walker.next;
1802
+ walker.next = p;
1803
+ }
1804
+ this.head = tail;
1805
+ this.tail = head;
1806
+ return this;
1807
+ }
1808
+ };
1809
+ function insertAfter(self, node, value) {
1810
+ const inserted = new Node(value, node, node ? node.next : self.head, self);
1811
+ if (inserted.next === void 0) self.tail = inserted;
1812
+ if (inserted.prev === void 0) self.head = inserted;
1813
+ self.length++;
1814
+ return inserted;
1815
+ }
1816
+ function push(self, item) {
1817
+ self.tail = new Node(item, self.tail, void 0, self);
1818
+ if (!self.head) self.head = self.tail;
1819
+ self.length++;
1820
+ }
1821
+ function unshift(self, item) {
1822
+ self.head = new Node(item, void 0, self.head, self);
1823
+ if (!self.tail) self.tail = self.head;
1824
+ self.length++;
1825
+ }
1826
+ var Node = class {
1827
+ list;
1828
+ next;
1829
+ prev;
1830
+ value;
1831
+ constructor(value, prev, next, list) {
1832
+ this.list = list;
1833
+ this.value = value;
1834
+ if (prev) {
1835
+ prev.next = this;
1836
+ this.prev = prev;
1837
+ } else this.prev = void 0;
1838
+ if (next) {
1839
+ next.prev = this;
1840
+ this.next = next;
1841
+ } else this.next = void 0;
1842
+ }
1843
+ };
1844
+ //#endregion
1845
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/large-numbers.js
1846
+ const encode$1 = (num, buf) => {
1847
+ if (!Number.isSafeInteger(num)) throw Error("cannot encode number outside of javascript safe integer range");
1848
+ else if (num < 0) encodeNegative(num, buf);
1849
+ else encodePositive(num, buf);
1850
+ return buf;
1851
+ };
1852
+ const encodePositive = (num, buf) => {
1853
+ buf[0] = 128;
1854
+ for (var i = buf.length; i > 1; i--) {
1855
+ buf[i - 1] = num & 255;
1856
+ num = Math.floor(num / 256);
1857
+ }
1858
+ };
1859
+ const encodeNegative = (num, buf) => {
1860
+ buf[0] = 255;
1861
+ var flipped = false;
1862
+ num = num * -1;
1863
+ for (var i = buf.length; i > 1; i--) {
1864
+ var byte = num & 255;
1865
+ num = Math.floor(num / 256);
1866
+ if (flipped) buf[i - 1] = onesComp(byte);
1867
+ else if (byte === 0) buf[i - 1] = 0;
1868
+ else {
1869
+ flipped = true;
1870
+ buf[i - 1] = twosComp(byte);
1871
+ }
1872
+ }
1873
+ };
1874
+ const parse$2 = (buf) => {
1875
+ const pre = buf[0];
1876
+ const value = pre === 128 ? pos(buf.subarray(1, buf.length)) : pre === 255 ? twos(buf) : null;
1877
+ if (value === null) throw Error("invalid base256 encoding");
1878
+ if (!Number.isSafeInteger(value)) throw Error("parsed number outside of javascript safe integer range");
1879
+ return value;
1880
+ };
1881
+ const twos = (buf) => {
1882
+ var len = buf.length;
1883
+ var sum = 0;
1884
+ var flipped = false;
1885
+ for (var i = len - 1; i > -1; i--) {
1886
+ var byte = Number(buf[i]);
1887
+ var f;
1888
+ if (flipped) f = onesComp(byte);
1889
+ else if (byte === 0) f = byte;
1890
+ else {
1891
+ flipped = true;
1892
+ f = twosComp(byte);
1893
+ }
1894
+ if (f !== 0) sum -= f * Math.pow(256, len - i - 1);
1895
+ }
1896
+ return sum;
1897
+ };
1898
+ const pos = (buf) => {
1899
+ var len = buf.length;
1900
+ var sum = 0;
1901
+ for (var i = len - 1; i > -1; i--) {
1902
+ var byte = Number(buf[i]);
1903
+ if (byte !== 0) sum += byte * Math.pow(256, len - i - 1);
1904
+ }
1905
+ return sum;
1906
+ };
1907
+ const onesComp = (byte) => (255 ^ byte) & 255;
1908
+ const twosComp = (byte) => (255 ^ byte) + 1 & 255;
1909
+ //#endregion
1910
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/types.js
1911
+ const isCode = (c) => name.has(c);
1912
+ const name = /* @__PURE__ */ new Map([
1913
+ ["0", "File"],
1914
+ ["", "OldFile"],
1915
+ ["1", "Link"],
1916
+ ["2", "SymbolicLink"],
1917
+ ["3", "CharacterDevice"],
1918
+ ["4", "BlockDevice"],
1919
+ ["5", "Directory"],
1920
+ ["6", "FIFO"],
1921
+ ["7", "ContiguousFile"],
1922
+ ["g", "GlobalExtendedHeader"],
1923
+ ["x", "ExtendedHeader"],
1924
+ ["A", "SolarisACL"],
1925
+ ["D", "GNUDumpDir"],
1926
+ ["I", "Inode"],
1927
+ ["K", "NextFileHasLongLinkpath"],
1928
+ ["L", "NextFileHasLongPath"],
1929
+ ["M", "ContinuationFile"],
1930
+ ["N", "OldGnuLongPath"],
1931
+ ["S", "SparseFile"],
1932
+ ["V", "TapeVolumeHeader"],
1933
+ ["X", "OldExtendedHeader"]
1934
+ ]);
1935
+ const code = new Map(Array.from(name).map((kv) => [kv[1], kv[0]]));
1936
+ //#endregion
1937
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/header.js
1938
+ var Header = class {
1939
+ cksumValid = false;
1940
+ needPax = false;
1941
+ nullBlock = false;
1942
+ block;
1943
+ path;
1944
+ mode;
1945
+ uid;
1946
+ gid;
1947
+ size;
1948
+ cksum;
1949
+ #type = "Unsupported";
1950
+ linkpath;
1951
+ uname;
1952
+ gname;
1953
+ devmaj = 0;
1954
+ devmin = 0;
1955
+ atime;
1956
+ ctime;
1957
+ mtime;
1958
+ charset;
1959
+ comment;
1960
+ constructor(data, off = 0, ex, gex) {
1961
+ if (Buffer.isBuffer(data)) this.decode(data, off || 0, ex, gex);
1962
+ else if (data) this.#slurp(data);
1963
+ }
1964
+ decode(buf, off, ex, gex) {
1965
+ if (!off) off = 0;
1966
+ if (!buf || !(buf.length >= off + 512)) throw new Error("need 512 bytes for header");
1967
+ this.path = decString(buf, off, 100);
1968
+ this.mode = decNumber(buf, off + 100, 8);
1969
+ this.uid = decNumber(buf, off + 108, 8);
1970
+ this.gid = decNumber(buf, off + 116, 8);
1971
+ this.size = decNumber(buf, off + 124, 12);
1972
+ this.mtime = decDate(buf, off + 136, 12);
1973
+ this.cksum = decNumber(buf, off + 148, 12);
1974
+ if (gex) this.#slurp(gex, true);
1975
+ if (ex) this.#slurp(ex);
1976
+ const t = decString(buf, off + 156, 1);
1977
+ if (isCode(t)) this.#type = t || "0";
1978
+ if (this.#type === "0" && this.path.slice(-1) === "/") this.#type = "5";
1979
+ if (this.#type === "5") this.size = 0;
1980
+ this.linkpath = decString(buf, off + 157, 100);
1981
+ if (buf.subarray(off + 257, off + 265).toString() === "ustar\x0000") {
1982
+ this.uname = decString(buf, off + 265, 32);
1983
+ this.gname = decString(buf, off + 297, 32);
1984
+ /* c8 ignore start */
1985
+ this.devmaj = decNumber(buf, off + 329, 8) ?? 0;
1986
+ this.devmin = decNumber(buf, off + 337, 8) ?? 0;
1987
+ /* c8 ignore stop */
1988
+ if (buf[off + 475] !== 0) {
1989
+ const prefix = decString(buf, off + 345, 155);
1990
+ this.path = prefix + "/" + this.path;
1991
+ } else {
1992
+ const prefix = decString(buf, off + 345, 130);
1993
+ if (prefix) this.path = prefix + "/" + this.path;
1994
+ this.atime = decDate(buf, off + 476, 12);
1995
+ this.ctime = decDate(buf, off + 488, 12);
1996
+ }
1997
+ }
1998
+ let sum = 256;
1999
+ for (let i = off; i < off + 148; i++) sum += buf[i];
2000
+ for (let i = off + 156; i < off + 512; i++) sum += buf[i];
2001
+ this.cksumValid = sum === this.cksum;
2002
+ if (this.cksum === void 0 && sum === 256) this.nullBlock = true;
2003
+ }
2004
+ #slurp(ex, gex = false) {
2005
+ Object.assign(this, Object.fromEntries(Object.entries(ex).filter(([k, v]) => {
2006
+ return !(v === null || v === void 0 || k === "path" && gex || k === "linkpath" && gex || k === "global");
2007
+ })));
2008
+ }
2009
+ encode(buf, off = 0) {
2010
+ if (!buf) buf = this.block = Buffer.alloc(512);
2011
+ if (this.#type === "Unsupported") this.#type = "0";
2012
+ if (!(buf.length >= off + 512)) throw new Error("need 512 bytes for header");
2013
+ const prefixSize = this.ctime || this.atime ? 130 : 155;
2014
+ const split = splitPrefix(this.path || "", prefixSize);
2015
+ const path = split[0];
2016
+ const prefix = split[1];
2017
+ this.needPax = !!split[2];
2018
+ this.needPax = encString(buf, off, 100, path) || this.needPax;
2019
+ this.needPax = encNumber(buf, off + 100, 8, this.mode) || this.needPax;
2020
+ this.needPax = encNumber(buf, off + 108, 8, this.uid) || this.needPax;
2021
+ this.needPax = encNumber(buf, off + 116, 8, this.gid) || this.needPax;
2022
+ this.needPax = encNumber(buf, off + 124, 12, this.size) || this.needPax;
2023
+ this.needPax = encDate(buf, off + 136, 12, this.mtime) || this.needPax;
2024
+ buf[off + 156] = this.#type.charCodeAt(0);
2025
+ this.needPax = encString(buf, off + 157, 100, this.linkpath) || this.needPax;
2026
+ buf.write("ustar\x0000", off + 257, 8);
2027
+ this.needPax = encString(buf, off + 265, 32, this.uname) || this.needPax;
2028
+ this.needPax = encString(buf, off + 297, 32, this.gname) || this.needPax;
2029
+ this.needPax = encNumber(buf, off + 329, 8, this.devmaj) || this.needPax;
2030
+ this.needPax = encNumber(buf, off + 337, 8, this.devmin) || this.needPax;
2031
+ this.needPax = encString(buf, off + 345, prefixSize, prefix) || this.needPax;
2032
+ if (buf[off + 475] !== 0) this.needPax = encString(buf, off + 345, 155, prefix) || this.needPax;
2033
+ else {
2034
+ this.needPax = encString(buf, off + 345, 130, prefix) || this.needPax;
2035
+ this.needPax = encDate(buf, off + 476, 12, this.atime) || this.needPax;
2036
+ this.needPax = encDate(buf, off + 488, 12, this.ctime) || this.needPax;
2037
+ }
2038
+ let sum = 256;
2039
+ for (let i = off; i < off + 148; i++) sum += buf[i];
2040
+ for (let i = off + 156; i < off + 512; i++) sum += buf[i];
2041
+ this.cksum = sum;
2042
+ encNumber(buf, off + 148, 8, this.cksum);
2043
+ this.cksumValid = true;
2044
+ return this.needPax;
2045
+ }
2046
+ get type() {
2047
+ return this.#type === "Unsupported" ? this.#type : name.get(this.#type);
2048
+ }
2049
+ get typeKey() {
2050
+ return this.#type;
2051
+ }
2052
+ set type(type) {
2053
+ const c = String(code.get(type));
2054
+ if (isCode(c) || c === "Unsupported") this.#type = c;
2055
+ else if (isCode(type)) this.#type = type;
2056
+ else throw new TypeError("invalid entry type: " + type);
2057
+ }
2058
+ };
2059
+ const splitPrefix = (p, prefixSize) => {
2060
+ const pathSize = 100;
2061
+ let pp = p;
2062
+ let prefix = "";
2063
+ let ret = void 0;
2064
+ const root = posix$1.parse(p).root || ".";
2065
+ if (Buffer.byteLength(pp) < pathSize) ret = [
2066
+ pp,
2067
+ prefix,
2068
+ false
2069
+ ];
2070
+ else {
2071
+ prefix = posix$1.dirname(pp);
2072
+ pp = posix$1.basename(pp);
2073
+ do
2074
+ if (Buffer.byteLength(pp) <= pathSize && Buffer.byteLength(prefix) <= prefixSize) ret = [
2075
+ pp,
2076
+ prefix,
2077
+ false
2078
+ ];
2079
+ else if (Buffer.byteLength(pp) > pathSize && Buffer.byteLength(prefix) <= prefixSize) ret = [
2080
+ pp.slice(0, pathSize - 1),
2081
+ prefix,
2082
+ true
2083
+ ];
2084
+ else {
2085
+ pp = posix$1.join(posix$1.basename(prefix), pp);
2086
+ prefix = posix$1.dirname(prefix);
2087
+ }
2088
+ while (prefix !== root && ret === void 0);
2089
+ if (!ret) ret = [
2090
+ p.slice(0, pathSize - 1),
2091
+ "",
2092
+ true
2093
+ ];
2094
+ }
2095
+ return ret;
2096
+ };
2097
+ const decString = (buf, off, size) => buf.subarray(off, off + size).toString("utf8").replace(/\0.*/, "");
2098
+ const decDate = (buf, off, size) => numToDate(decNumber(buf, off, size));
2099
+ const numToDate = (num) => num === void 0 ? void 0 : /* @__PURE__ */ new Date(num * 1e3);
2100
+ const decNumber = (buf, off, size) => Number(buf[off]) & 128 ? parse$2(buf.subarray(off, off + size)) : decSmallNumber(buf, off, size);
2101
+ const nanUndef = (value) => isNaN(value) ? void 0 : value;
2102
+ const decSmallNumber = (buf, off, size) => nanUndef(parseInt(buf.subarray(off, off + size).toString("utf8").replace(/\0.*$/, "").trim(), 8));
2103
+ const MAXNUM = {
2104
+ 12: 8589934591,
2105
+ 8: 2097151
2106
+ };
2107
+ const encNumber = (buf, off, size, num) => num === void 0 ? false : num > MAXNUM[size] || num < 0 ? (encode$1(num, buf.subarray(off, off + size)), true) : (encSmallNumber(buf, off, size, num), false);
2108
+ const encSmallNumber = (buf, off, size, num) => buf.write(octalString(num, size), off, size, "ascii");
2109
+ const octalString = (num, size) => padOctal(Math.floor(num).toString(8), size);
2110
+ const padOctal = (str, size) => (str.length === size - 1 ? str : new Array(size - str.length - 1).join("0") + str + " ") + "\0";
2111
+ const encDate = (buf, off, size, date) => date === void 0 ? false : encNumber(buf, off, size, date.getTime() / 1e3);
2112
+ const NULLS = new Array(156).join("\0");
2113
+ const encString = (buf, off, size, str) => str === void 0 ? false : (buf.write(str + NULLS, off, size, "utf8"), str.length !== Buffer.byteLength(str) || str.length > size);
2114
+ //#endregion
2115
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/pax.js
2116
+ var Pax = class Pax {
2117
+ atime;
2118
+ mtime;
2119
+ ctime;
2120
+ charset;
2121
+ comment;
2122
+ gid;
2123
+ uid;
2124
+ gname;
2125
+ uname;
2126
+ linkpath;
2127
+ dev;
2128
+ ino;
2129
+ nlink;
2130
+ path;
2131
+ size;
2132
+ mode;
2133
+ global;
2134
+ constructor(obj, global = false) {
2135
+ this.atime = obj.atime;
2136
+ this.charset = obj.charset;
2137
+ this.comment = obj.comment;
2138
+ this.ctime = obj.ctime;
2139
+ this.dev = obj.dev;
2140
+ this.gid = obj.gid;
2141
+ this.global = global;
2142
+ this.gname = obj.gname;
2143
+ this.ino = obj.ino;
2144
+ this.linkpath = obj.linkpath;
2145
+ this.mtime = obj.mtime;
2146
+ this.nlink = obj.nlink;
2147
+ this.path = obj.path;
2148
+ this.size = obj.size;
2149
+ this.uid = obj.uid;
2150
+ this.uname = obj.uname;
2151
+ }
2152
+ encode() {
2153
+ const body = this.encodeBody();
2154
+ if (body === "") return Buffer.allocUnsafe(0);
2155
+ const bodyLen = Buffer.byteLength(body);
2156
+ const bufLen = 512 * Math.ceil(1 + bodyLen / 512);
2157
+ const buf = Buffer.allocUnsafe(bufLen);
2158
+ for (let i = 0; i < 512; i++) buf[i] = 0;
2159
+ new Header({
2160
+ /* c8 ignore start */
2161
+ path: ("PaxHeader/" + basename(this.path ?? "")).slice(0, 99),
2162
+ /* c8 ignore stop */
2163
+ mode: this.mode || 420,
2164
+ uid: this.uid,
2165
+ gid: this.gid,
2166
+ size: bodyLen,
2167
+ mtime: this.mtime,
2168
+ type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader",
2169
+ linkpath: "",
2170
+ uname: this.uname || "",
2171
+ gname: this.gname || "",
2172
+ devmaj: 0,
2173
+ devmin: 0,
2174
+ atime: this.atime,
2175
+ ctime: this.ctime
2176
+ }).encode(buf);
2177
+ buf.write(body, 512, bodyLen, "utf8");
2178
+ for (let i = bodyLen + 512; i < buf.length; i++) buf[i] = 0;
2179
+ return buf;
2180
+ }
2181
+ encodeBody() {
2182
+ 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");
2183
+ }
2184
+ encodeField(field) {
2185
+ if (this[field] === void 0) return "";
2186
+ const r = this[field];
2187
+ const v = r instanceof Date ? r.getTime() / 1e3 : r;
2188
+ const s = " " + (field === "dev" || field === "ino" || field === "nlink" ? "SCHILY." : "") + field + "=" + v + "\n";
2189
+ const byteLen = Buffer.byteLength(s);
2190
+ let digits = Math.floor(Math.log(byteLen) / Math.log(10)) + 1;
2191
+ if (byteLen + digits >= Math.pow(10, digits)) digits += 1;
2192
+ return digits + byteLen + s;
2193
+ }
2194
+ static parse(str, ex, g = false) {
2195
+ return new Pax(merge(parseKV(str), ex), g);
2196
+ }
2197
+ };
2198
+ const merge = (a, b) => b ? Object.assign({}, b, a) : a;
2199
+ const parseKV = (str) => str.replace(/\n$/, "").split("\n").reduce(parseKVLine, Object.create(null));
2200
+ const parseKVLine = (set, line) => {
2201
+ const n = parseInt(line, 10);
2202
+ if (n !== Buffer.byteLength(line) + 1) return set;
2203
+ line = line.slice((n + " ").length);
2204
+ const kv = line.split("=");
2205
+ const r = kv.shift();
2206
+ if (!r) return set;
2207
+ const k = r.replace(/^SCHILY\.(dev|ino|nlink)/, "$1");
2208
+ const v = kv.join("=");
2209
+ set[k] = /^([A-Z]+\.)?([mac]|birth|creation)time$/.test(k) ? /* @__PURE__ */ new Date(Number(v) * 1e3) : /^[0-9]+$/.test(v) ? +v : v;
2210
+ return set;
2211
+ };
2212
+ const normalizeWindowsPath = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) !== "win32" ? (p) => p : (p) => p && p.replace(/\\/g, "/");
2213
+ //#endregion
2214
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/read-entry.js
2215
+ var ReadEntry = class extends Minipass {
2216
+ extended;
2217
+ globalExtended;
2218
+ header;
2219
+ startBlockSize;
2220
+ blockRemain;
2221
+ remain;
2222
+ type;
2223
+ meta = false;
2224
+ ignore = false;
2225
+ path;
2226
+ mode;
2227
+ uid;
2228
+ gid;
2229
+ uname;
2230
+ gname;
2231
+ size = 0;
2232
+ mtime;
2233
+ atime;
2234
+ ctime;
2235
+ linkpath;
2236
+ dev;
2237
+ ino;
2238
+ nlink;
2239
+ invalid = false;
2240
+ absolute;
2241
+ unsupported = false;
2242
+ constructor(header, ex, gex) {
2243
+ super({});
2244
+ this.pause();
2245
+ this.extended = ex;
2246
+ this.globalExtended = gex;
2247
+ this.header = header;
2248
+ /* c8 ignore start */
2249
+ this.remain = header.size ?? 0;
2250
+ /* c8 ignore stop */
2251
+ this.startBlockSize = 512 * Math.ceil(this.remain / 512);
2252
+ this.blockRemain = this.startBlockSize;
2253
+ this.type = header.type;
2254
+ switch (this.type) {
2255
+ case "File":
2256
+ case "OldFile":
2257
+ case "Link":
2258
+ case "SymbolicLink":
2259
+ case "CharacterDevice":
2260
+ case "BlockDevice":
2261
+ case "Directory":
2262
+ case "FIFO":
2263
+ case "ContiguousFile":
2264
+ case "GNUDumpDir": break;
2265
+ case "NextFileHasLongLinkpath":
2266
+ case "NextFileHasLongPath":
2267
+ case "OldGnuLongPath":
2268
+ case "GlobalExtendedHeader":
2269
+ case "ExtendedHeader":
2270
+ case "OldExtendedHeader":
2271
+ this.meta = true;
2272
+ break;
2273
+ default: this.ignore = true;
2274
+ }
2275
+ /* c8 ignore start */
2276
+ if (!header.path) throw new Error("no path provided for tar.ReadEntry");
2277
+ /* c8 ignore stop */
2278
+ this.path = normalizeWindowsPath(header.path);
2279
+ this.mode = header.mode;
2280
+ if (this.mode) this.mode = this.mode & 4095;
2281
+ this.uid = header.uid;
2282
+ this.gid = header.gid;
2283
+ this.uname = header.uname;
2284
+ this.gname = header.gname;
2285
+ this.size = this.remain;
2286
+ this.mtime = header.mtime;
2287
+ this.atime = header.atime;
2288
+ this.ctime = header.ctime;
2289
+ /* c8 ignore start */
2290
+ this.linkpath = header.linkpath ? normalizeWindowsPath(header.linkpath) : void 0;
2291
+ /* c8 ignore stop */
2292
+ this.uname = header.uname;
2293
+ this.gname = header.gname;
2294
+ if (ex) this.#slurp(ex);
2295
+ if (gex) this.#slurp(gex, true);
2296
+ }
2297
+ write(data) {
2298
+ const writeLen = data.length;
2299
+ if (writeLen > this.blockRemain) throw new Error("writing more to entry than is appropriate");
2300
+ const r = this.remain;
2301
+ const br = this.blockRemain;
2302
+ this.remain = Math.max(0, r - writeLen);
2303
+ this.blockRemain = Math.max(0, br - writeLen);
2304
+ if (this.ignore) return true;
2305
+ if (r >= writeLen) return super.write(data);
2306
+ return super.write(data.subarray(0, r));
2307
+ }
2308
+ #slurp(ex, gex = false) {
2309
+ if (ex.path) ex.path = normalizeWindowsPath(ex.path);
2310
+ if (ex.linkpath) ex.linkpath = normalizeWindowsPath(ex.linkpath);
2311
+ Object.assign(this, Object.fromEntries(Object.entries(ex).filter(([k, v]) => {
2312
+ return !(v === null || v === void 0 || k === "path" && gex);
2313
+ })));
2314
+ }
2315
+ };
2316
+ //#endregion
2317
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/warn-method.js
2318
+ const warnMethod = (self, code, message, data = {}) => {
2319
+ if (self.file) data.file = self.file;
2320
+ if (self.cwd) data.cwd = self.cwd;
2321
+ data.code = message instanceof Error && message.code || code;
2322
+ data.tarCode = code;
2323
+ if (!self.strict && data.recoverable !== false) {
2324
+ if (message instanceof Error) {
2325
+ data = Object.assign(message, data);
2326
+ message = message.message;
2327
+ }
2328
+ self.emit("warn", code, message, data);
2329
+ } else if (message instanceof Error) self.emit("error", Object.assign(message, data));
2330
+ else self.emit("error", Object.assign(/* @__PURE__ */ new Error(`${code}: ${message}`), data));
2331
+ };
2332
+ //#endregion
2333
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/parse.js
2334
+ const maxMetaEntrySize = 1024 * 1024;
2335
+ const gzipHeader = Buffer.from([31, 139]);
2336
+ const STATE = Symbol("state");
2337
+ const WRITEENTRY = Symbol("writeEntry");
2338
+ const READENTRY = Symbol("readEntry");
2339
+ const NEXTENTRY = Symbol("nextEntry");
2340
+ const PROCESSENTRY = Symbol("processEntry");
2341
+ const EX = Symbol("extendedHeader");
2342
+ const GEX = Symbol("globalExtendedHeader");
2343
+ const META = Symbol("meta");
2344
+ const EMITMETA = Symbol("emitMeta");
2345
+ const BUFFER = Symbol("buffer");
2346
+ const QUEUE$1 = Symbol("queue");
2347
+ const ENDED$2 = Symbol("ended");
2348
+ const EMITTEDEND = Symbol("emittedEnd");
2349
+ const EMIT = Symbol("emit");
2350
+ const UNZIP = Symbol("unzip");
2351
+ const CONSUMECHUNK = Symbol("consumeChunk");
2352
+ const CONSUMECHUNKSUB = Symbol("consumeChunkSub");
2353
+ const CONSUMEBODY = Symbol("consumeBody");
2354
+ const CONSUMEMETA = Symbol("consumeMeta");
2355
+ const CONSUMEHEADER = Symbol("consumeHeader");
2356
+ const CONSUMING = Symbol("consuming");
2357
+ const BUFFERCONCAT = Symbol("bufferConcat");
2358
+ const MAYBEEND = Symbol("maybeEnd");
2359
+ const WRITING = Symbol("writing");
2360
+ const ABORTED = Symbol("aborted");
2361
+ const DONE = Symbol("onDone");
2362
+ const SAW_VALID_ENTRY = Symbol("sawValidEntry");
2363
+ const SAW_NULL_BLOCK = Symbol("sawNullBlock");
2364
+ const SAW_EOF = Symbol("sawEOF");
2365
+ const CLOSESTREAM = Symbol("closeStream");
2366
+ const noop = () => true;
2367
+ var Parser = class extends EventEmitter {
2368
+ file;
2369
+ strict;
2370
+ maxMetaEntrySize;
2371
+ filter;
2372
+ brotli;
2373
+ writable = true;
2374
+ readable = false;
2375
+ [QUEUE$1] = new Yallist();
2376
+ [BUFFER];
2377
+ [READENTRY];
2378
+ [WRITEENTRY];
2379
+ [STATE] = "begin";
2380
+ [META] = "";
2381
+ [EX];
2382
+ [GEX];
2383
+ [ENDED$2] = false;
2384
+ [UNZIP];
2385
+ [ABORTED] = false;
2386
+ [SAW_VALID_ENTRY];
2387
+ [SAW_NULL_BLOCK] = false;
2388
+ [SAW_EOF] = false;
2389
+ [WRITING] = false;
2390
+ [CONSUMING] = false;
2391
+ [EMITTEDEND] = false;
2392
+ constructor(opt = {}) {
2393
+ super();
2394
+ this.file = opt.file || "";
2395
+ this.on(DONE, () => {
2396
+ if (this[STATE] === "begin" || this[SAW_VALID_ENTRY] === false) this.warn("TAR_BAD_ARCHIVE", "Unrecognized archive format");
2397
+ });
2398
+ if (opt.ondone) this.on(DONE, opt.ondone);
2399
+ else this.on(DONE, () => {
2400
+ this.emit("prefinish");
2401
+ this.emit("finish");
2402
+ this.emit("end");
2403
+ });
2404
+ this.strict = !!opt.strict;
2405
+ this.maxMetaEntrySize = opt.maxMetaEntrySize || maxMetaEntrySize;
2406
+ this.filter = typeof opt.filter === "function" ? opt.filter : noop;
2407
+ const isTBR = opt.file && (opt.file.endsWith(".tar.br") || opt.file.endsWith(".tbr"));
2408
+ this.brotli = !opt.gzip && opt.brotli !== void 0 ? opt.brotli : isTBR ? void 0 : false;
2409
+ this.on("end", () => this[CLOSESTREAM]());
2410
+ if (typeof opt.onwarn === "function") this.on("warn", opt.onwarn);
2411
+ if (typeof opt.onReadEntry === "function") this.on("entry", opt.onReadEntry);
2412
+ }
2413
+ warn(code, message, data = {}) {
2414
+ warnMethod(this, code, message, data);
2415
+ }
2416
+ [CONSUMEHEADER](chunk, position) {
2417
+ if (this[SAW_VALID_ENTRY] === void 0) this[SAW_VALID_ENTRY] = false;
2418
+ let header;
2419
+ try {
2420
+ header = new Header(chunk, position, this[EX], this[GEX]);
2421
+ } catch (er) {
2422
+ return this.warn("TAR_ENTRY_INVALID", er);
2423
+ }
2424
+ if (header.nullBlock) if (this[SAW_NULL_BLOCK]) {
2425
+ this[SAW_EOF] = true;
2426
+ if (this[STATE] === "begin") this[STATE] = "header";
2427
+ this[EMIT]("eof");
2428
+ } else {
2429
+ this[SAW_NULL_BLOCK] = true;
2430
+ this[EMIT]("nullBlock");
2431
+ }
2432
+ else {
2433
+ this[SAW_NULL_BLOCK] = false;
2434
+ if (!header.cksumValid) this.warn("TAR_ENTRY_INVALID", "checksum failure", { header });
2435
+ else if (!header.path) this.warn("TAR_ENTRY_INVALID", "path is required", { header });
2436
+ else {
2437
+ const type = header.type;
2438
+ if (/^(Symbolic)?Link$/.test(type) && !header.linkpath) this.warn("TAR_ENTRY_INVALID", "linkpath required", { header });
2439
+ else if (!/^(Symbolic)?Link$/.test(type) && !/^(Global)?ExtendedHeader$/.test(type) && header.linkpath) this.warn("TAR_ENTRY_INVALID", "linkpath forbidden", { header });
2440
+ else {
2441
+ const entry = this[WRITEENTRY] = new ReadEntry(header, this[EX], this[GEX]);
2442
+ if (!this[SAW_VALID_ENTRY]) if (entry.remain) {
2443
+ const onend = () => {
2444
+ if (!entry.invalid) this[SAW_VALID_ENTRY] = true;
2445
+ };
2446
+ entry.on("end", onend);
2447
+ } else this[SAW_VALID_ENTRY] = true;
2448
+ if (entry.meta) {
2449
+ if (entry.size > this.maxMetaEntrySize) {
2450
+ entry.ignore = true;
2451
+ this[EMIT]("ignoredEntry", entry);
2452
+ this[STATE] = "ignore";
2453
+ entry.resume();
2454
+ } else if (entry.size > 0) {
2455
+ this[META] = "";
2456
+ entry.on("data", (c) => this[META] += c);
2457
+ this[STATE] = "meta";
2458
+ }
2459
+ } else {
2460
+ this[EX] = void 0;
2461
+ entry.ignore = entry.ignore || !this.filter(entry.path, entry);
2462
+ if (entry.ignore) {
2463
+ this[EMIT]("ignoredEntry", entry);
2464
+ this[STATE] = entry.remain ? "ignore" : "header";
2465
+ entry.resume();
2466
+ } else {
2467
+ if (entry.remain) this[STATE] = "body";
2468
+ else {
2469
+ this[STATE] = "header";
2470
+ entry.end();
2471
+ }
2472
+ if (!this[READENTRY]) {
2473
+ this[QUEUE$1].push(entry);
2474
+ this[NEXTENTRY]();
2475
+ } else this[QUEUE$1].push(entry);
2476
+ }
2477
+ }
2478
+ }
2479
+ }
2480
+ }
2481
+ }
2482
+ [CLOSESTREAM]() {
2483
+ queueMicrotask(() => this.emit("close"));
2484
+ }
2485
+ [PROCESSENTRY](entry) {
2486
+ let go = true;
2487
+ if (!entry) {
2488
+ this[READENTRY] = void 0;
2489
+ go = false;
2490
+ } else if (Array.isArray(entry)) {
2491
+ const [ev, ...args] = entry;
2492
+ this.emit(ev, ...args);
2493
+ } else {
2494
+ this[READENTRY] = entry;
2495
+ this.emit("entry", entry);
2496
+ if (!entry.emittedEnd) {
2497
+ entry.on("end", () => this[NEXTENTRY]());
2498
+ go = false;
2499
+ }
2500
+ }
2501
+ return go;
2502
+ }
2503
+ [NEXTENTRY]() {
2504
+ do ;
2505
+ while (this[PROCESSENTRY](this[QUEUE$1].shift()));
2506
+ if (!this[QUEUE$1].length) {
2507
+ const re = this[READENTRY];
2508
+ if (!re || re.flowing || re.size === re.remain) {
2509
+ if (!this[WRITING]) this.emit("drain");
2510
+ } else re.once("drain", () => this.emit("drain"));
2511
+ }
2512
+ }
2513
+ [CONSUMEBODY](chunk, position) {
2514
+ const entry = this[WRITEENTRY];
2515
+ /* c8 ignore start */
2516
+ if (!entry) throw new Error("attempt to consume body without entry??");
2517
+ const br = entry.blockRemain ?? 0;
2518
+ /* c8 ignore stop */
2519
+ const c = br >= chunk.length && position === 0 ? chunk : chunk.subarray(position, position + br);
2520
+ entry.write(c);
2521
+ if (!entry.blockRemain) {
2522
+ this[STATE] = "header";
2523
+ this[WRITEENTRY] = void 0;
2524
+ entry.end();
2525
+ }
2526
+ return c.length;
2527
+ }
2528
+ [CONSUMEMETA](chunk, position) {
2529
+ const entry = this[WRITEENTRY];
2530
+ const ret = this[CONSUMEBODY](chunk, position);
2531
+ if (!this[WRITEENTRY] && entry) this[EMITMETA](entry);
2532
+ return ret;
2533
+ }
2534
+ [EMIT](ev, data, extra) {
2535
+ if (!this[QUEUE$1].length && !this[READENTRY]) this.emit(ev, data, extra);
2536
+ else this[QUEUE$1].push([
2537
+ ev,
2538
+ data,
2539
+ extra
2540
+ ]);
2541
+ }
2542
+ [EMITMETA](entry) {
2543
+ this[EMIT]("meta", this[META]);
2544
+ switch (entry.type) {
2545
+ case "ExtendedHeader":
2546
+ case "OldExtendedHeader":
2547
+ this[EX] = Pax.parse(this[META], this[EX], false);
2548
+ break;
2549
+ case "GlobalExtendedHeader":
2550
+ this[GEX] = Pax.parse(this[META], this[GEX], true);
2551
+ break;
2552
+ case "NextFileHasLongPath":
2553
+ case "OldGnuLongPath": {
2554
+ const ex = this[EX] ?? Object.create(null);
2555
+ this[EX] = ex;
2556
+ ex.path = this[META].replace(/\0.*/, "");
2557
+ break;
2558
+ }
2559
+ case "NextFileHasLongLinkpath": {
2560
+ const ex = this[EX] || Object.create(null);
2561
+ this[EX] = ex;
2562
+ ex.linkpath = this[META].replace(/\0.*/, "");
2563
+ break;
2564
+ }
2565
+ /* c8 ignore start */
2566
+ default: throw new Error("unknown meta: " + entry.type);
2567
+ }
2568
+ }
2569
+ abort(error) {
2570
+ this[ABORTED] = true;
2571
+ this.emit("abort", error);
2572
+ this.warn("TAR_ABORT", error, { recoverable: false });
2573
+ }
2574
+ write(chunk, encoding, cb) {
2575
+ if (typeof encoding === "function") {
2576
+ cb = encoding;
2577
+ encoding = void 0;
2578
+ }
2579
+ if (typeof chunk === "string") chunk = Buffer.from(
2580
+ chunk,
2581
+ /* c8 ignore next */
2582
+ typeof encoding === "string" ? encoding : "utf8"
2583
+ );
2584
+ if (this[ABORTED]) {
2585
+ /* c8 ignore next */
2586
+ cb?.();
2587
+ return false;
2588
+ }
2589
+ if ((this[UNZIP] === void 0 || this.brotli === void 0 && this[UNZIP] === false) && chunk) {
2590
+ if (this[BUFFER]) {
2591
+ chunk = Buffer.concat([this[BUFFER], chunk]);
2592
+ this[BUFFER] = void 0;
2593
+ }
2594
+ if (chunk.length < gzipHeader.length) {
2595
+ this[BUFFER] = chunk;
2596
+ /* c8 ignore next */
2597
+ cb?.();
2598
+ return true;
2599
+ }
2600
+ for (let i = 0; this[UNZIP] === void 0 && i < gzipHeader.length; i++) if (chunk[i] !== gzipHeader[i]) this[UNZIP] = false;
2601
+ const maybeBrotli = this.brotli === void 0;
2602
+ if (this[UNZIP] === false && maybeBrotli) if (chunk.length < 512) if (this[ENDED$2]) this.brotli = true;
2603
+ else {
2604
+ this[BUFFER] = chunk;
2605
+ /* c8 ignore next */
2606
+ cb?.();
2607
+ return true;
2608
+ }
2609
+ else try {
2610
+ new Header(chunk.subarray(0, 512));
2611
+ this.brotli = false;
2612
+ } catch (_) {
2613
+ this.brotli = true;
2614
+ }
2615
+ if (this[UNZIP] === void 0 || this[UNZIP] === false && this.brotli) {
2616
+ const ended = this[ENDED$2];
2617
+ this[ENDED$2] = false;
2618
+ this[UNZIP] = this[UNZIP] === void 0 ? new Unzip({}) : new BrotliDecompress({});
2619
+ this[UNZIP].on("data", (chunk) => this[CONSUMECHUNK](chunk));
2620
+ this[UNZIP].on("error", (er) => this.abort(er));
2621
+ this[UNZIP].on("end", () => {
2622
+ this[ENDED$2] = true;
2623
+ this[CONSUMECHUNK]();
2624
+ });
2625
+ this[WRITING] = true;
2626
+ const ret = !!this[UNZIP][ended ? "end" : "write"](chunk);
2627
+ this[WRITING] = false;
2628
+ cb?.();
2629
+ return ret;
2630
+ }
2631
+ }
2632
+ this[WRITING] = true;
2633
+ if (this[UNZIP]) this[UNZIP].write(chunk);
2634
+ else this[CONSUMECHUNK](chunk);
2635
+ this[WRITING] = false;
2636
+ const ret = this[QUEUE$1].length ? false : this[READENTRY] ? this[READENTRY].flowing : true;
2637
+ if (!ret && !this[QUEUE$1].length) this[READENTRY]?.once("drain", () => this.emit("drain"));
2638
+ /* c8 ignore next */
2639
+ cb?.();
2640
+ return ret;
2641
+ }
2642
+ [BUFFERCONCAT](c) {
2643
+ if (c && !this[ABORTED]) this[BUFFER] = this[BUFFER] ? Buffer.concat([this[BUFFER], c]) : c;
2644
+ }
2645
+ [MAYBEEND]() {
2646
+ if (this[ENDED$2] && !this[EMITTEDEND] && !this[ABORTED] && !this[CONSUMING]) {
2647
+ this[EMITTEDEND] = true;
2648
+ const entry = this[WRITEENTRY];
2649
+ if (entry && entry.blockRemain) {
2650
+ const have = this[BUFFER] ? this[BUFFER].length : 0;
2651
+ this.warn("TAR_BAD_ARCHIVE", `Truncated input (needed ${entry.blockRemain} more bytes, only ${have} available)`, { entry });
2652
+ if (this[BUFFER]) entry.write(this[BUFFER]);
2653
+ entry.end();
2654
+ }
2655
+ this[EMIT](DONE);
2656
+ }
2657
+ }
2658
+ [CONSUMECHUNK](chunk) {
2659
+ if (this[CONSUMING] && chunk) this[BUFFERCONCAT](chunk);
2660
+ else if (!chunk && !this[BUFFER]) this[MAYBEEND]();
2661
+ else if (chunk) {
2662
+ this[CONSUMING] = true;
2663
+ if (this[BUFFER]) {
2664
+ this[BUFFERCONCAT](chunk);
2665
+ const c = this[BUFFER];
2666
+ this[BUFFER] = void 0;
2667
+ this[CONSUMECHUNKSUB](c);
2668
+ } else this[CONSUMECHUNKSUB](chunk);
2669
+ while (this[BUFFER] && this[BUFFER]?.length >= 512 && !this[ABORTED] && !this[SAW_EOF]) {
2670
+ const c = this[BUFFER];
2671
+ this[BUFFER] = void 0;
2672
+ this[CONSUMECHUNKSUB](c);
2673
+ }
2674
+ this[CONSUMING] = false;
2675
+ }
2676
+ if (!this[BUFFER] || this[ENDED$2]) this[MAYBEEND]();
2677
+ }
2678
+ [CONSUMECHUNKSUB](chunk) {
2679
+ let position = 0;
2680
+ const length = chunk.length;
2681
+ while (position + 512 <= length && !this[ABORTED] && !this[SAW_EOF]) switch (this[STATE]) {
2682
+ case "begin":
2683
+ case "header":
2684
+ this[CONSUMEHEADER](chunk, position);
2685
+ position += 512;
2686
+ break;
2687
+ case "ignore":
2688
+ case "body":
2689
+ position += this[CONSUMEBODY](chunk, position);
2690
+ break;
2691
+ case "meta":
2692
+ position += this[CONSUMEMETA](chunk, position);
2693
+ break;
2694
+ /* c8 ignore start */
2695
+ default: throw new Error("invalid state: " + this[STATE]);
2696
+ }
2697
+ if (position < length) if (this[BUFFER]) this[BUFFER] = Buffer.concat([chunk.subarray(position), this[BUFFER]]);
2698
+ else this[BUFFER] = chunk.subarray(position);
2699
+ }
2700
+ end(chunk, encoding, cb) {
2701
+ if (typeof chunk === "function") {
2702
+ cb = chunk;
2703
+ encoding = void 0;
2704
+ chunk = void 0;
2705
+ }
2706
+ if (typeof encoding === "function") {
2707
+ cb = encoding;
2708
+ encoding = void 0;
2709
+ }
2710
+ if (typeof chunk === "string") chunk = Buffer.from(chunk, encoding);
2711
+ if (cb) this.once("finish", cb);
2712
+ if (!this[ABORTED]) if (this[UNZIP]) {
2713
+ /* c8 ignore start */
2714
+ if (chunk) this[UNZIP].write(chunk);
2715
+ /* c8 ignore stop */
2716
+ this[UNZIP].end();
2717
+ } else {
2718
+ this[ENDED$2] = true;
2719
+ if (this.brotli === void 0) chunk = chunk || Buffer.alloc(0);
2720
+ if (chunk) this.write(chunk);
2721
+ this[MAYBEEND]();
2722
+ }
2723
+ return this;
2724
+ }
2725
+ };
2726
+ //#endregion
2727
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/strip-trailing-slashes.js
2728
+ const stripTrailingSlashes = (str) => {
2729
+ let i = str.length - 1;
2730
+ let slashesStart = -1;
2731
+ while (i > -1 && str.charAt(i) === "/") {
2732
+ slashesStart = i;
2733
+ i--;
2734
+ }
2735
+ return slashesStart === -1 ? str : str.slice(0, slashesStart);
2736
+ };
2737
+ //#endregion
2738
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/list.js
2739
+ const onReadEntryFunction = (opt) => {
2740
+ const onReadEntry = opt.onReadEntry;
2741
+ opt.onReadEntry = onReadEntry ? (e) => {
2742
+ onReadEntry(e);
2743
+ e.resume();
2744
+ } : (e) => e.resume();
2745
+ };
2746
+ const filesFilter = (opt, files) => {
2747
+ const map = new Map(files.map((f) => [stripTrailingSlashes(f), true]));
2748
+ const filter = opt.filter;
2749
+ const mapHas = (file, r = "") => {
2750
+ const root = r || parse(file).root || ".";
2751
+ let ret;
2752
+ if (file === root) ret = false;
2753
+ else {
2754
+ const m = map.get(file);
2755
+ if (m !== void 0) ret = m;
2756
+ else ret = mapHas(dirname(file), root);
2757
+ }
2758
+ map.set(file, ret);
2759
+ return ret;
2760
+ };
2761
+ opt.filter = filter ? (file, entry) => filter(file, entry) && mapHas(stripTrailingSlashes(file)) : (file) => mapHas(stripTrailingSlashes(file));
2762
+ };
2763
+ const listFileSync = (opt) => {
2764
+ const p = new Parser(opt);
2765
+ const file = opt.file;
2766
+ let fd;
2767
+ try {
2768
+ const stat = fs.statSync(file);
2769
+ const readSize = opt.maxReadSize || 16 * 1024 * 1024;
2770
+ if (stat.size < readSize) p.end(fs.readFileSync(file));
2771
+ else {
2772
+ let pos = 0;
2773
+ const buf = Buffer.allocUnsafe(readSize);
2774
+ fd = fs.openSync(file, "r");
2775
+ while (pos < stat.size) {
2776
+ const bytesRead = fs.readSync(fd, buf, 0, readSize, pos);
2777
+ pos += bytesRead;
2778
+ p.write(buf.subarray(0, bytesRead));
2779
+ }
2780
+ p.end();
2781
+ }
2782
+ } finally {
2783
+ if (typeof fd === "number") try {
2784
+ fs.closeSync(fd);
2785
+ } catch (er) {}
2786
+ }
2787
+ };
2788
+ const listFile = (opt, _files) => {
2789
+ const parse = new Parser(opt);
2790
+ const readSize = opt.maxReadSize || 16 * 1024 * 1024;
2791
+ const file = opt.file;
2792
+ return new Promise((resolve, reject) => {
2793
+ parse.on("error", reject);
2794
+ parse.on("end", resolve);
2795
+ fs.stat(file, (er, stat) => {
2796
+ if (er) reject(er);
2797
+ else {
2798
+ const stream = new ReadStream(file, {
2799
+ readSize,
2800
+ size: stat.size
2801
+ });
2802
+ stream.on("error", reject);
2803
+ stream.pipe(parse);
2804
+ }
2805
+ });
2806
+ });
2807
+ };
2808
+ const list = makeCommand(listFileSync, listFile, (opt) => new Parser(opt), (opt) => new Parser(opt), (opt, files) => {
2809
+ if (files?.length) filesFilter(opt, files);
2810
+ if (!opt.noResume) onReadEntryFunction(opt);
2811
+ });
2812
+ //#endregion
2813
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/mode-fix.js
2814
+ const modeFix = (mode, isDir, portable) => {
2815
+ mode &= 4095;
2816
+ if (portable) mode = (mode | 384) & -19;
2817
+ if (isDir) {
2818
+ if (mode & 256) mode |= 64;
2819
+ if (mode & 32) mode |= 8;
2820
+ if (mode & 4) mode |= 1;
2821
+ }
2822
+ return mode;
2823
+ };
2824
+ //#endregion
2825
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/strip-absolute-path.js
2826
+ const { isAbsolute, parse: parse$1 } = win32;
2827
+ const stripAbsolutePath = (path) => {
2828
+ let r = "";
2829
+ let parsed = parse$1(path);
2830
+ while (isAbsolute(path) || parsed.root) {
2831
+ const root = path.charAt(0) === "/" && path.slice(0, 4) !== "//?/" ? "/" : parsed.root;
2832
+ path = path.slice(root.length);
2833
+ r += root;
2834
+ parsed = parse$1(path);
2835
+ }
2836
+ return [r, path];
2837
+ };
2838
+ //#endregion
2839
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/winchars.js
2840
+ const raw = [
2841
+ "|",
2842
+ "<",
2843
+ ">",
2844
+ "?",
2845
+ ":"
2846
+ ];
2847
+ const win = raw.map((char) => String.fromCharCode(61440 + char.charCodeAt(0)));
2848
+ const toWin = new Map(raw.map((char, i) => [char, win[i]]));
2849
+ const toRaw = new Map(win.map((char, i) => [char, raw[i]]));
2850
+ const encode = (s) => raw.reduce((s, c) => s.split(c).join(toWin.get(c)), s);
2851
+ const decode = (s) => win.reduce((s, c) => s.split(c).join(toRaw.get(c)), s);
2852
+ //#endregion
2853
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/write-entry.js
2854
+ const prefixPath = (path, prefix) => {
2855
+ if (!prefix) return normalizeWindowsPath(path);
2856
+ path = normalizeWindowsPath(path).replace(/^\.(\/|$)/, "");
2857
+ return stripTrailingSlashes(prefix) + "/" + path;
2858
+ };
2859
+ const maxReadSize = 16 * 1024 * 1024;
2860
+ const PROCESS$1 = Symbol("process");
2861
+ const FILE$1 = Symbol("file");
2862
+ const DIRECTORY$1 = Symbol("directory");
2863
+ const SYMLINK$1 = Symbol("symlink");
2864
+ const HARDLINK$1 = Symbol("hardlink");
2865
+ const HEADER = Symbol("header");
2866
+ const READ = Symbol("read");
2867
+ const LSTAT = Symbol("lstat");
2868
+ const ONLSTAT = Symbol("onlstat");
2869
+ const ONREAD = Symbol("onread");
2870
+ const ONREADLINK = Symbol("onreadlink");
2871
+ const OPENFILE = Symbol("openfile");
2872
+ const ONOPENFILE = Symbol("onopenfile");
2873
+ const CLOSE = Symbol("close");
2874
+ const MODE = Symbol("mode");
2875
+ const AWAITDRAIN = Symbol("awaitDrain");
2876
+ const ONDRAIN$1 = Symbol("ondrain");
2877
+ const PREFIX = Symbol("prefix");
2878
+ var WriteEntry = class extends Minipass {
2879
+ path;
2880
+ portable;
2881
+ myuid = process.getuid && process.getuid() || 0;
2882
+ myuser = process.env.USER || "";
2883
+ maxReadSize;
2884
+ linkCache;
2885
+ statCache;
2886
+ preservePaths;
2887
+ cwd;
2888
+ strict;
2889
+ mtime;
2890
+ noPax;
2891
+ noMtime;
2892
+ prefix;
2893
+ fd;
2894
+ blockLen = 0;
2895
+ blockRemain = 0;
2896
+ buf;
2897
+ pos = 0;
2898
+ remain = 0;
2899
+ length = 0;
2900
+ offset = 0;
2901
+ win32;
2902
+ absolute;
2903
+ header;
2904
+ type;
2905
+ linkpath;
2906
+ stat;
2907
+ onWriteEntry;
2908
+ #hadError = false;
2909
+ constructor(p, opt_ = {}) {
2910
+ const opt = dealias(opt_);
2911
+ super();
2912
+ this.path = normalizeWindowsPath(p);
2913
+ this.portable = !!opt.portable;
2914
+ this.maxReadSize = opt.maxReadSize || maxReadSize;
2915
+ this.linkCache = opt.linkCache || /* @__PURE__ */ new Map();
2916
+ this.statCache = opt.statCache || /* @__PURE__ */ new Map();
2917
+ this.preservePaths = !!opt.preservePaths;
2918
+ this.cwd = normalizeWindowsPath(opt.cwd || process.cwd());
2919
+ this.strict = !!opt.strict;
2920
+ this.noPax = !!opt.noPax;
2921
+ this.noMtime = !!opt.noMtime;
2922
+ this.mtime = opt.mtime;
2923
+ this.prefix = opt.prefix ? normalizeWindowsPath(opt.prefix) : void 0;
2924
+ this.onWriteEntry = opt.onWriteEntry;
2925
+ if (typeof opt.onwarn === "function") this.on("warn", opt.onwarn);
2926
+ let pathWarn = false;
2927
+ if (!this.preservePaths) {
2928
+ const [root, stripped] = stripAbsolutePath(this.path);
2929
+ if (root && typeof stripped === "string") {
2930
+ this.path = stripped;
2931
+ pathWarn = root;
2932
+ }
2933
+ }
2934
+ this.win32 = !!opt.win32 || process.platform === "win32";
2935
+ if (this.win32) {
2936
+ this.path = decode(this.path.replace(/\\/g, "/"));
2937
+ p = p.replace(/\\/g, "/");
2938
+ }
2939
+ this.absolute = normalizeWindowsPath(opt.absolute || path.resolve(this.cwd, p));
2940
+ if (this.path === "") this.path = "./";
2941
+ if (pathWarn) this.warn("TAR_ENTRY_INFO", `stripping ${pathWarn} from absolute path`, {
2942
+ entry: this,
2943
+ path: pathWarn + this.path
2944
+ });
2945
+ const cs = this.statCache.get(this.absolute);
2946
+ if (cs) this[ONLSTAT](cs);
2947
+ else this[LSTAT]();
2948
+ }
2949
+ warn(code, message, data = {}) {
2950
+ return warnMethod(this, code, message, data);
2951
+ }
2952
+ emit(ev, ...data) {
2953
+ if (ev === "error") this.#hadError = true;
2954
+ return super.emit(ev, ...data);
2955
+ }
2956
+ [LSTAT]() {
2957
+ fs$1.lstat(this.absolute, (er, stat) => {
2958
+ if (er) return this.emit("error", er);
2959
+ this[ONLSTAT](stat);
2960
+ });
2961
+ }
2962
+ [ONLSTAT](stat) {
2963
+ this.statCache.set(this.absolute, stat);
2964
+ this.stat = stat;
2965
+ if (!stat.isFile()) stat.size = 0;
2966
+ this.type = getType(stat);
2967
+ this.emit("stat", stat);
2968
+ this[PROCESS$1]();
2969
+ }
2970
+ [PROCESS$1]() {
2971
+ switch (this.type) {
2972
+ case "File": return this[FILE$1]();
2973
+ case "Directory": return this[DIRECTORY$1]();
2974
+ case "SymbolicLink": return this[SYMLINK$1]();
2975
+ default: return this.end();
2976
+ }
2977
+ }
2978
+ [MODE](mode) {
2979
+ return modeFix(mode, this.type === "Directory", this.portable);
2980
+ }
2981
+ [PREFIX](path) {
2982
+ return prefixPath(path, this.prefix);
2983
+ }
2984
+ [HEADER]() {
2985
+ /* c8 ignore start */
2986
+ if (!this.stat) throw new Error("cannot write header before stat");
2987
+ /* c8 ignore stop */
2988
+ if (this.type === "Directory" && this.portable) this.noMtime = true;
2989
+ this.onWriteEntry?.(this);
2990
+ this.header = new Header({
2991
+ path: this[PREFIX](this.path),
2992
+ linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[PREFIX](this.linkpath) : this.linkpath,
2993
+ mode: this[MODE](this.stat.mode),
2994
+ uid: this.portable ? void 0 : this.stat.uid,
2995
+ gid: this.portable ? void 0 : this.stat.gid,
2996
+ size: this.stat.size,
2997
+ mtime: this.noMtime ? void 0 : this.mtime || this.stat.mtime,
2998
+ /* c8 ignore next */
2999
+ type: this.type === "Unsupported" ? void 0 : this.type,
3000
+ uname: this.portable ? void 0 : this.stat.uid === this.myuid ? this.myuser : "",
3001
+ atime: this.portable ? void 0 : this.stat.atime,
3002
+ ctime: this.portable ? void 0 : this.stat.ctime
3003
+ });
3004
+ if (this.header.encode() && !this.noPax) super.write(new Pax({
3005
+ atime: this.portable ? void 0 : this.header.atime,
3006
+ ctime: this.portable ? void 0 : this.header.ctime,
3007
+ gid: this.portable ? void 0 : this.header.gid,
3008
+ mtime: this.noMtime ? void 0 : this.mtime || this.header.mtime,
3009
+ path: this[PREFIX](this.path),
3010
+ linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[PREFIX](this.linkpath) : this.linkpath,
3011
+ size: this.header.size,
3012
+ uid: this.portable ? void 0 : this.header.uid,
3013
+ uname: this.portable ? void 0 : this.header.uname,
3014
+ dev: this.portable ? void 0 : this.stat.dev,
3015
+ ino: this.portable ? void 0 : this.stat.ino,
3016
+ nlink: this.portable ? void 0 : this.stat.nlink
3017
+ }).encode());
3018
+ const block = this.header?.block;
3019
+ /* c8 ignore start */
3020
+ if (!block) throw new Error("failed to encode header");
3021
+ /* c8 ignore stop */
3022
+ super.write(block);
3023
+ }
3024
+ [DIRECTORY$1]() {
3025
+ /* c8 ignore start */
3026
+ if (!this.stat) throw new Error("cannot create directory entry without stat");
3027
+ /* c8 ignore stop */
3028
+ if (this.path.slice(-1) !== "/") this.path += "/";
3029
+ this.stat.size = 0;
3030
+ this[HEADER]();
3031
+ this.end();
3032
+ }
3033
+ [SYMLINK$1]() {
3034
+ fs$1.readlink(this.absolute, (er, linkpath) => {
3035
+ if (er) return this.emit("error", er);
3036
+ this[ONREADLINK](linkpath);
3037
+ });
3038
+ }
3039
+ [ONREADLINK](linkpath) {
3040
+ this.linkpath = normalizeWindowsPath(linkpath);
3041
+ this[HEADER]();
3042
+ this.end();
3043
+ }
3044
+ [HARDLINK$1](linkpath) {
3045
+ /* c8 ignore start */
3046
+ if (!this.stat) throw new Error("cannot create link entry without stat");
3047
+ /* c8 ignore stop */
3048
+ this.type = "Link";
3049
+ this.linkpath = normalizeWindowsPath(path.relative(this.cwd, linkpath));
3050
+ this.stat.size = 0;
3051
+ this[HEADER]();
3052
+ this.end();
3053
+ }
3054
+ [FILE$1]() {
3055
+ /* c8 ignore start */
3056
+ if (!this.stat) throw new Error("cannot create file entry without stat");
3057
+ /* c8 ignore stop */
3058
+ if (this.stat.nlink > 1) {
3059
+ const linkKey = `${this.stat.dev}:${this.stat.ino}`;
3060
+ const linkpath = this.linkCache.get(linkKey);
3061
+ if (linkpath?.indexOf(this.cwd) === 0) return this[HARDLINK$1](linkpath);
3062
+ this.linkCache.set(linkKey, this.absolute);
3063
+ }
3064
+ this[HEADER]();
3065
+ if (this.stat.size === 0) return this.end();
3066
+ this[OPENFILE]();
3067
+ }
3068
+ [OPENFILE]() {
3069
+ fs$1.open(this.absolute, "r", (er, fd) => {
3070
+ if (er) return this.emit("error", er);
3071
+ this[ONOPENFILE](fd);
3072
+ });
3073
+ }
3074
+ [ONOPENFILE](fd) {
3075
+ this.fd = fd;
3076
+ if (this.#hadError) return this[CLOSE]();
3077
+ /* c8 ignore start */
3078
+ if (!this.stat) throw new Error("should stat before calling onopenfile");
3079
+ /* c8 ignore start */
3080
+ this.blockLen = 512 * Math.ceil(this.stat.size / 512);
3081
+ this.blockRemain = this.blockLen;
3082
+ const bufLen = Math.min(this.blockLen, this.maxReadSize);
3083
+ this.buf = Buffer.allocUnsafe(bufLen);
3084
+ this.offset = 0;
3085
+ this.pos = 0;
3086
+ this.remain = this.stat.size;
3087
+ this.length = this.buf.length;
3088
+ this[READ]();
3089
+ }
3090
+ [READ]() {
3091
+ const { fd, buf, offset, length, pos } = this;
3092
+ if (fd === void 0 || buf === void 0) throw new Error("cannot read file without first opening");
3093
+ fs$1.read(fd, buf, offset, length, pos, (er, bytesRead) => {
3094
+ if (er) return this[CLOSE](() => this.emit("error", er));
3095
+ this[ONREAD](bytesRead);
3096
+ });
3097
+ }
3098
+ /* c8 ignore start */
3099
+ [CLOSE](cb = () => {}) {
3100
+ /* c8 ignore stop */
3101
+ if (this.fd !== void 0) fs$1.close(this.fd, cb);
3102
+ }
3103
+ [ONREAD](bytesRead) {
3104
+ if (bytesRead <= 0 && this.remain > 0) {
3105
+ const er = Object.assign(/* @__PURE__ */ new Error("encountered unexpected EOF"), {
3106
+ path: this.absolute,
3107
+ syscall: "read",
3108
+ code: "EOF"
3109
+ });
3110
+ return this[CLOSE](() => this.emit("error", er));
3111
+ }
3112
+ if (bytesRead > this.remain) {
3113
+ const er = Object.assign(/* @__PURE__ */ new Error("did not encounter expected EOF"), {
3114
+ path: this.absolute,
3115
+ syscall: "read",
3116
+ code: "EOF"
3117
+ });
3118
+ return this[CLOSE](() => this.emit("error", er));
3119
+ }
3120
+ /* c8 ignore start */
3121
+ if (!this.buf) throw new Error("should have created buffer prior to reading");
3122
+ /* c8 ignore stop */
3123
+ if (bytesRead === this.remain) for (let i = bytesRead; i < this.length && bytesRead < this.blockRemain; i++) {
3124
+ this.buf[i + this.offset] = 0;
3125
+ bytesRead++;
3126
+ this.remain++;
3127
+ }
3128
+ const chunk = this.offset === 0 && bytesRead === this.buf.length ? this.buf : this.buf.subarray(this.offset, this.offset + bytesRead);
3129
+ if (!this.write(chunk)) this[AWAITDRAIN](() => this[ONDRAIN$1]());
3130
+ else this[ONDRAIN$1]();
3131
+ }
3132
+ [AWAITDRAIN](cb) {
3133
+ this.once("drain", cb);
3134
+ }
3135
+ write(chunk, encoding, cb) {
3136
+ /* c8 ignore start - just junk to comply with NodeJS.WritableStream */
3137
+ if (typeof encoding === "function") {
3138
+ cb = encoding;
3139
+ encoding = void 0;
3140
+ }
3141
+ if (typeof chunk === "string") chunk = Buffer.from(chunk, typeof encoding === "string" ? encoding : "utf8");
3142
+ /* c8 ignore stop */
3143
+ if (this.blockRemain < chunk.length) {
3144
+ const er = Object.assign(/* @__PURE__ */ new Error("writing more data than expected"), { path: this.absolute });
3145
+ return this.emit("error", er);
3146
+ }
3147
+ this.remain -= chunk.length;
3148
+ this.blockRemain -= chunk.length;
3149
+ this.pos += chunk.length;
3150
+ this.offset += chunk.length;
3151
+ return super.write(chunk, null, cb);
3152
+ }
3153
+ [ONDRAIN$1]() {
3154
+ if (!this.remain) {
3155
+ if (this.blockRemain) super.write(Buffer.alloc(this.blockRemain));
3156
+ return this[CLOSE]((er) => er ? this.emit("error", er) : this.end());
3157
+ }
3158
+ /* c8 ignore start */
3159
+ if (!this.buf) throw new Error("buffer lost somehow in ONDRAIN");
3160
+ /* c8 ignore stop */
3161
+ if (this.offset >= this.length) {
3162
+ this.buf = Buffer.allocUnsafe(Math.min(this.blockRemain, this.buf.length));
3163
+ this.offset = 0;
3164
+ }
3165
+ this.length = this.buf.length - this.offset;
3166
+ this[READ]();
3167
+ }
3168
+ };
3169
+ var WriteEntrySync = class extends WriteEntry {
3170
+ sync = true;
3171
+ [LSTAT]() {
3172
+ this[ONLSTAT](fs$1.lstatSync(this.absolute));
3173
+ }
3174
+ [SYMLINK$1]() {
3175
+ this[ONREADLINK](fs$1.readlinkSync(this.absolute));
3176
+ }
3177
+ [OPENFILE]() {
3178
+ this[ONOPENFILE](fs$1.openSync(this.absolute, "r"));
3179
+ }
3180
+ [READ]() {
3181
+ let threw = true;
3182
+ try {
3183
+ const { fd, buf, offset, length, pos } = this;
3184
+ /* c8 ignore start */
3185
+ if (fd === void 0 || buf === void 0) throw new Error("fd and buf must be set in READ method");
3186
+ /* c8 ignore stop */
3187
+ const bytesRead = fs$1.readSync(fd, buf, offset, length, pos);
3188
+ this[ONREAD](bytesRead);
3189
+ threw = false;
3190
+ } finally {
3191
+ if (threw) try {
3192
+ this[CLOSE](() => {});
3193
+ } catch (er) {}
3194
+ }
3195
+ }
3196
+ [AWAITDRAIN](cb) {
3197
+ cb();
3198
+ }
3199
+ /* c8 ignore start */
3200
+ [CLOSE](cb = () => {}) {
3201
+ /* c8 ignore stop */
3202
+ if (this.fd !== void 0) fs$1.closeSync(this.fd);
3203
+ cb();
3204
+ }
3205
+ };
3206
+ var WriteEntryTar = class extends Minipass {
3207
+ blockLen = 0;
3208
+ blockRemain = 0;
3209
+ buf = 0;
3210
+ pos = 0;
3211
+ remain = 0;
3212
+ length = 0;
3213
+ preservePaths;
3214
+ portable;
3215
+ strict;
3216
+ noPax;
3217
+ noMtime;
3218
+ readEntry;
3219
+ type;
3220
+ prefix;
3221
+ path;
3222
+ mode;
3223
+ uid;
3224
+ gid;
3225
+ uname;
3226
+ gname;
3227
+ header;
3228
+ mtime;
3229
+ atime;
3230
+ ctime;
3231
+ linkpath;
3232
+ size;
3233
+ onWriteEntry;
3234
+ warn(code, message, data = {}) {
3235
+ return warnMethod(this, code, message, data);
3236
+ }
3237
+ constructor(readEntry, opt_ = {}) {
3238
+ const opt = dealias(opt_);
3239
+ super();
3240
+ this.preservePaths = !!opt.preservePaths;
3241
+ this.portable = !!opt.portable;
3242
+ this.strict = !!opt.strict;
3243
+ this.noPax = !!opt.noPax;
3244
+ this.noMtime = !!opt.noMtime;
3245
+ this.onWriteEntry = opt.onWriteEntry;
3246
+ this.readEntry = readEntry;
3247
+ const { type } = readEntry;
3248
+ /* c8 ignore start */
3249
+ if (type === "Unsupported") throw new Error("writing entry that should be ignored");
3250
+ /* c8 ignore stop */
3251
+ this.type = type;
3252
+ if (this.type === "Directory" && this.portable) this.noMtime = true;
3253
+ this.prefix = opt.prefix;
3254
+ this.path = normalizeWindowsPath(readEntry.path);
3255
+ this.mode = readEntry.mode !== void 0 ? this[MODE](readEntry.mode) : void 0;
3256
+ this.uid = this.portable ? void 0 : readEntry.uid;
3257
+ this.gid = this.portable ? void 0 : readEntry.gid;
3258
+ this.uname = this.portable ? void 0 : readEntry.uname;
3259
+ this.gname = this.portable ? void 0 : readEntry.gname;
3260
+ this.size = readEntry.size;
3261
+ this.mtime = this.noMtime ? void 0 : opt.mtime || readEntry.mtime;
3262
+ this.atime = this.portable ? void 0 : readEntry.atime;
3263
+ this.ctime = this.portable ? void 0 : readEntry.ctime;
3264
+ this.linkpath = readEntry.linkpath !== void 0 ? normalizeWindowsPath(readEntry.linkpath) : void 0;
3265
+ if (typeof opt.onwarn === "function") this.on("warn", opt.onwarn);
3266
+ let pathWarn = false;
3267
+ if (!this.preservePaths) {
3268
+ const [root, stripped] = stripAbsolutePath(this.path);
3269
+ if (root && typeof stripped === "string") {
3270
+ this.path = stripped;
3271
+ pathWarn = root;
3272
+ }
3273
+ }
3274
+ this.remain = readEntry.size;
3275
+ this.blockRemain = readEntry.startBlockSize;
3276
+ this.onWriteEntry?.(this);
3277
+ this.header = new Header({
3278
+ path: this[PREFIX](this.path),
3279
+ linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[PREFIX](this.linkpath) : this.linkpath,
3280
+ mode: this.mode,
3281
+ uid: this.portable ? void 0 : this.uid,
3282
+ gid: this.portable ? void 0 : this.gid,
3283
+ size: this.size,
3284
+ mtime: this.noMtime ? void 0 : this.mtime,
3285
+ type: this.type,
3286
+ uname: this.portable ? void 0 : this.uname,
3287
+ atime: this.portable ? void 0 : this.atime,
3288
+ ctime: this.portable ? void 0 : this.ctime
3289
+ });
3290
+ if (pathWarn) this.warn("TAR_ENTRY_INFO", `stripping ${pathWarn} from absolute path`, {
3291
+ entry: this,
3292
+ path: pathWarn + this.path
3293
+ });
3294
+ if (this.header.encode() && !this.noPax) super.write(new Pax({
3295
+ atime: this.portable ? void 0 : this.atime,
3296
+ ctime: this.portable ? void 0 : this.ctime,
3297
+ gid: this.portable ? void 0 : this.gid,
3298
+ mtime: this.noMtime ? void 0 : this.mtime,
3299
+ path: this[PREFIX](this.path),
3300
+ linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[PREFIX](this.linkpath) : this.linkpath,
3301
+ size: this.size,
3302
+ uid: this.portable ? void 0 : this.uid,
3303
+ uname: this.portable ? void 0 : this.uname,
3304
+ dev: this.portable ? void 0 : this.readEntry.dev,
3305
+ ino: this.portable ? void 0 : this.readEntry.ino,
3306
+ nlink: this.portable ? void 0 : this.readEntry.nlink
3307
+ }).encode());
3308
+ const b = this.header?.block;
3309
+ /* c8 ignore start */
3310
+ if (!b) throw new Error("failed to encode header");
3311
+ /* c8 ignore stop */
3312
+ super.write(b);
3313
+ readEntry.pipe(this);
3314
+ }
3315
+ [PREFIX](path) {
3316
+ return prefixPath(path, this.prefix);
3317
+ }
3318
+ [MODE](mode) {
3319
+ return modeFix(mode, this.type === "Directory", this.portable);
3320
+ }
3321
+ write(chunk, encoding, cb) {
3322
+ /* c8 ignore start - just junk to comply with NodeJS.WritableStream */
3323
+ if (typeof encoding === "function") {
3324
+ cb = encoding;
3325
+ encoding = void 0;
3326
+ }
3327
+ if (typeof chunk === "string") chunk = Buffer.from(chunk, typeof encoding === "string" ? encoding : "utf8");
3328
+ /* c8 ignore stop */
3329
+ const writeLen = chunk.length;
3330
+ if (writeLen > this.blockRemain) throw new Error("writing more to entry than is appropriate");
3331
+ this.blockRemain -= writeLen;
3332
+ return super.write(chunk, cb);
3333
+ }
3334
+ end(chunk, encoding, cb) {
3335
+ if (this.blockRemain) super.write(Buffer.alloc(this.blockRemain));
3336
+ /* c8 ignore start - just junk to comply with NodeJS.WritableStream */
3337
+ if (typeof chunk === "function") {
3338
+ cb = chunk;
3339
+ encoding = void 0;
3340
+ chunk = void 0;
3341
+ }
3342
+ if (typeof encoding === "function") {
3343
+ cb = encoding;
3344
+ encoding = void 0;
3345
+ }
3346
+ if (typeof chunk === "string") chunk = Buffer.from(chunk, encoding ?? "utf8");
3347
+ if (cb) this.once("finish", cb);
3348
+ chunk ? super.end(chunk, cb) : super.end(cb);
3349
+ /* c8 ignore stop */
3350
+ return this;
3351
+ }
3352
+ };
3353
+ const getType = (stat) => stat.isFile() ? "File" : stat.isDirectory() ? "Directory" : stat.isSymbolicLink() ? "SymbolicLink" : "Unsupported";
3354
+ //#endregion
3355
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/pack.js
3356
+ var PackJob = class {
3357
+ path;
3358
+ absolute;
3359
+ entry;
3360
+ stat;
3361
+ readdir;
3362
+ pending = false;
3363
+ ignore = false;
3364
+ piped = false;
3365
+ constructor(path, absolute) {
3366
+ this.path = path || "./";
3367
+ this.absolute = absolute;
3368
+ }
3369
+ };
3370
+ const EOF = Buffer.alloc(1024);
3371
+ const ONSTAT = Symbol("onStat");
3372
+ const ENDED$1 = Symbol("ended");
3373
+ const QUEUE = Symbol("queue");
3374
+ const CURRENT = Symbol("current");
3375
+ const PROCESS = Symbol("process");
3376
+ const PROCESSING = Symbol("processing");
3377
+ const PROCESSJOB = Symbol("processJob");
3378
+ const JOBS = Symbol("jobs");
3379
+ const JOBDONE = Symbol("jobDone");
3380
+ const ADDFSENTRY = Symbol("addFSEntry");
3381
+ const ADDTARENTRY = Symbol("addTarEntry");
3382
+ const STAT = Symbol("stat");
3383
+ const READDIR = Symbol("readdir");
3384
+ const ONREADDIR = Symbol("onreaddir");
3385
+ const PIPE = Symbol("pipe");
3386
+ const ENTRY = Symbol("entry");
3387
+ const ENTRYOPT = Symbol("entryOpt");
3388
+ const WRITEENTRYCLASS = Symbol("writeEntryClass");
3389
+ const WRITE = Symbol("write");
3390
+ const ONDRAIN = Symbol("ondrain");
3391
+ var Pack = class extends Minipass {
3392
+ opt;
3393
+ cwd;
3394
+ maxReadSize;
3395
+ preservePaths;
3396
+ strict;
3397
+ noPax;
3398
+ prefix;
3399
+ linkCache;
3400
+ statCache;
3401
+ file;
3402
+ portable;
3403
+ zip;
3404
+ readdirCache;
3405
+ noDirRecurse;
3406
+ follow;
3407
+ noMtime;
3408
+ mtime;
3409
+ filter;
3410
+ jobs;
3411
+ [WRITEENTRYCLASS];
3412
+ onWriteEntry;
3413
+ [QUEUE];
3414
+ [JOBS] = 0;
3415
+ [PROCESSING] = false;
3416
+ [ENDED$1] = false;
3417
+ constructor(opt = {}) {
3418
+ super();
3419
+ this.opt = opt;
3420
+ this.file = opt.file || "";
3421
+ this.cwd = opt.cwd || process.cwd();
3422
+ this.maxReadSize = opt.maxReadSize;
3423
+ this.preservePaths = !!opt.preservePaths;
3424
+ this.strict = !!opt.strict;
3425
+ this.noPax = !!opt.noPax;
3426
+ this.prefix = normalizeWindowsPath(opt.prefix || "");
3427
+ this.linkCache = opt.linkCache || /* @__PURE__ */ new Map();
3428
+ this.statCache = opt.statCache || /* @__PURE__ */ new Map();
3429
+ this.readdirCache = opt.readdirCache || /* @__PURE__ */ new Map();
3430
+ this.onWriteEntry = opt.onWriteEntry;
3431
+ this[WRITEENTRYCLASS] = WriteEntry;
3432
+ if (typeof opt.onwarn === "function") this.on("warn", opt.onwarn);
3433
+ this.portable = !!opt.portable;
3434
+ if (opt.gzip || opt.brotli) {
3435
+ if (opt.gzip && opt.brotli) throw new TypeError("gzip and brotli are mutually exclusive");
3436
+ if (opt.gzip) {
3437
+ if (typeof opt.gzip !== "object") opt.gzip = {};
3438
+ if (this.portable) opt.gzip.portable = true;
3439
+ this.zip = new Gzip(opt.gzip);
3440
+ }
3441
+ if (opt.brotli) {
3442
+ if (typeof opt.brotli !== "object") opt.brotli = {};
3443
+ this.zip = new BrotliCompress(opt.brotli);
3444
+ }
3445
+ /* c8 ignore next */
3446
+ if (!this.zip) throw new Error("impossible");
3447
+ const zip = this.zip;
3448
+ zip.on("data", (chunk) => super.write(chunk));
3449
+ zip.on("end", () => super.end());
3450
+ zip.on("drain", () => this[ONDRAIN]());
3451
+ this.on("resume", () => zip.resume());
3452
+ } else this.on("drain", this[ONDRAIN]);
3453
+ this.noDirRecurse = !!opt.noDirRecurse;
3454
+ this.follow = !!opt.follow;
3455
+ this.noMtime = !!opt.noMtime;
3456
+ if (opt.mtime) this.mtime = opt.mtime;
3457
+ this.filter = typeof opt.filter === "function" ? opt.filter : () => true;
3458
+ this[QUEUE] = new Yallist();
3459
+ this[JOBS] = 0;
3460
+ this.jobs = Number(opt.jobs) || 4;
3461
+ this[PROCESSING] = false;
3462
+ this[ENDED$1] = false;
3463
+ }
3464
+ [WRITE](chunk) {
3465
+ return super.write(chunk);
3466
+ }
3467
+ add(path) {
3468
+ this.write(path);
3469
+ return this;
3470
+ }
3471
+ end(path, encoding, cb) {
3472
+ /* c8 ignore start */
3473
+ if (typeof path === "function") {
3474
+ cb = path;
3475
+ path = void 0;
3476
+ }
3477
+ if (typeof encoding === "function") {
3478
+ cb = encoding;
3479
+ encoding = void 0;
3480
+ }
3481
+ /* c8 ignore stop */
3482
+ if (path) this.add(path);
3483
+ this[ENDED$1] = true;
3484
+ this[PROCESS]();
3485
+ /* c8 ignore next */
3486
+ if (cb) cb();
3487
+ return this;
3488
+ }
3489
+ write(path) {
3490
+ if (this[ENDED$1]) throw new Error("write after end");
3491
+ if (path instanceof ReadEntry) this[ADDTARENTRY](path);
3492
+ else this[ADDFSENTRY](path);
3493
+ return this.flowing;
3494
+ }
3495
+ [ADDTARENTRY](p) {
3496
+ const absolute = normalizeWindowsPath(path.resolve(this.cwd, p.path));
3497
+ if (!this.filter(p.path, p)) p.resume();
3498
+ else {
3499
+ const job = new PackJob(p.path, absolute);
3500
+ job.entry = new WriteEntryTar(p, this[ENTRYOPT](job));
3501
+ job.entry.on("end", () => this[JOBDONE](job));
3502
+ this[JOBS] += 1;
3503
+ this[QUEUE].push(job);
3504
+ }
3505
+ this[PROCESS]();
3506
+ }
3507
+ [ADDFSENTRY](p) {
3508
+ const absolute = normalizeWindowsPath(path.resolve(this.cwd, p));
3509
+ this[QUEUE].push(new PackJob(p, absolute));
3510
+ this[PROCESS]();
3511
+ }
3512
+ [STAT](job) {
3513
+ job.pending = true;
3514
+ this[JOBS] += 1;
3515
+ fs$1[this.follow ? "stat" : "lstat"](job.absolute, (er, stat) => {
3516
+ job.pending = false;
3517
+ this[JOBS] -= 1;
3518
+ if (er) this.emit("error", er);
3519
+ else this[ONSTAT](job, stat);
3520
+ });
3521
+ }
3522
+ [ONSTAT](job, stat) {
3523
+ this.statCache.set(job.absolute, stat);
3524
+ job.stat = stat;
3525
+ if (!this.filter(job.path, stat)) job.ignore = true;
3526
+ this[PROCESS]();
3527
+ }
3528
+ [READDIR](job) {
3529
+ job.pending = true;
3530
+ this[JOBS] += 1;
3531
+ fs$1.readdir(job.absolute, (er, entries) => {
3532
+ job.pending = false;
3533
+ this[JOBS] -= 1;
3534
+ if (er) return this.emit("error", er);
3535
+ this[ONREADDIR](job, entries);
3536
+ });
3537
+ }
3538
+ [ONREADDIR](job, entries) {
3539
+ this.readdirCache.set(job.absolute, entries);
3540
+ job.readdir = entries;
3541
+ this[PROCESS]();
3542
+ }
3543
+ [PROCESS]() {
3544
+ if (this[PROCESSING]) return;
3545
+ this[PROCESSING] = true;
3546
+ for (let w = this[QUEUE].head; !!w && this[JOBS] < this.jobs; w = w.next) {
3547
+ this[PROCESSJOB](w.value);
3548
+ if (w.value.ignore) {
3549
+ const p = w.next;
3550
+ this[QUEUE].removeNode(w);
3551
+ w.next = p;
3552
+ }
3553
+ }
3554
+ this[PROCESSING] = false;
3555
+ if (this[ENDED$1] && !this[QUEUE].length && this[JOBS] === 0) if (this.zip) this.zip.end(EOF);
3556
+ else {
3557
+ super.write(EOF);
3558
+ super.end();
3559
+ }
3560
+ }
3561
+ get [CURRENT]() {
3562
+ return this[QUEUE] && this[QUEUE].head && this[QUEUE].head.value;
3563
+ }
3564
+ [JOBDONE](_job) {
3565
+ this[QUEUE].shift();
3566
+ this[JOBS] -= 1;
3567
+ this[PROCESS]();
3568
+ }
3569
+ [PROCESSJOB](job) {
3570
+ if (job.pending) return;
3571
+ if (job.entry) {
3572
+ if (job === this[CURRENT] && !job.piped) this[PIPE](job);
3573
+ return;
3574
+ }
3575
+ if (!job.stat) {
3576
+ const sc = this.statCache.get(job.absolute);
3577
+ if (sc) this[ONSTAT](job, sc);
3578
+ else this[STAT](job);
3579
+ }
3580
+ if (!job.stat) return;
3581
+ if (job.ignore) return;
3582
+ if (!this.noDirRecurse && job.stat.isDirectory() && !job.readdir) {
3583
+ const rc = this.readdirCache.get(job.absolute);
3584
+ if (rc) this[ONREADDIR](job, rc);
3585
+ else this[READDIR](job);
3586
+ if (!job.readdir) return;
3587
+ }
3588
+ job.entry = this[ENTRY](job);
3589
+ if (!job.entry) {
3590
+ job.ignore = true;
3591
+ return;
3592
+ }
3593
+ if (job === this[CURRENT] && !job.piped) this[PIPE](job);
3594
+ }
3595
+ [ENTRYOPT](job) {
3596
+ return {
3597
+ onwarn: (code, msg, data) => this.warn(code, msg, data),
3598
+ noPax: this.noPax,
3599
+ cwd: this.cwd,
3600
+ absolute: job.absolute,
3601
+ preservePaths: this.preservePaths,
3602
+ maxReadSize: this.maxReadSize,
3603
+ strict: this.strict,
3604
+ portable: this.portable,
3605
+ linkCache: this.linkCache,
3606
+ statCache: this.statCache,
3607
+ noMtime: this.noMtime,
3608
+ mtime: this.mtime,
3609
+ prefix: this.prefix,
3610
+ onWriteEntry: this.onWriteEntry
3611
+ };
3612
+ }
3613
+ [ENTRY](job) {
3614
+ this[JOBS] += 1;
3615
+ try {
3616
+ return new this[WRITEENTRYCLASS](job.path, this[ENTRYOPT](job)).on("end", () => this[JOBDONE](job)).on("error", (er) => this.emit("error", er));
3617
+ } catch (er) {
3618
+ this.emit("error", er);
3619
+ }
3620
+ }
3621
+ [ONDRAIN]() {
3622
+ if (this[CURRENT] && this[CURRENT].entry) this[CURRENT].entry.resume();
3623
+ }
3624
+ [PIPE](job) {
3625
+ job.piped = true;
3626
+ if (job.readdir) job.readdir.forEach((entry) => {
3627
+ const p = job.path;
3628
+ const base = p === "./" ? "" : p.replace(/\/*$/, "/");
3629
+ this[ADDFSENTRY](base + entry);
3630
+ });
3631
+ const source = job.entry;
3632
+ const zip = this.zip;
3633
+ /* c8 ignore start */
3634
+ if (!source) throw new Error("cannot pipe without source");
3635
+ /* c8 ignore stop */
3636
+ if (zip) source.on("data", (chunk) => {
3637
+ if (!zip.write(chunk)) source.pause();
3638
+ });
3639
+ else source.on("data", (chunk) => {
3640
+ if (!super.write(chunk)) source.pause();
3641
+ });
3642
+ }
3643
+ pause() {
3644
+ if (this.zip) this.zip.pause();
3645
+ return super.pause();
3646
+ }
3647
+ warn(code, message, data = {}) {
3648
+ warnMethod(this, code, message, data);
3649
+ }
3650
+ };
3651
+ var PackSync = class extends Pack {
3652
+ sync = true;
3653
+ constructor(opt) {
3654
+ super(opt);
3655
+ this[WRITEENTRYCLASS] = WriteEntrySync;
3656
+ }
3657
+ pause() {}
3658
+ resume() {}
3659
+ [STAT](job) {
3660
+ const stat = this.follow ? "statSync" : "lstatSync";
3661
+ this[ONSTAT](job, fs$1[stat](job.absolute));
3662
+ }
3663
+ [READDIR](job) {
3664
+ this[ONREADDIR](job, fs$1.readdirSync(job.absolute));
3665
+ }
3666
+ [PIPE](job) {
3667
+ const source = job.entry;
3668
+ const zip = this.zip;
3669
+ if (job.readdir) job.readdir.forEach((entry) => {
3670
+ const p = job.path;
3671
+ const base = p === "./" ? "" : p.replace(/\/*$/, "/");
3672
+ this[ADDFSENTRY](base + entry);
3673
+ });
3674
+ /* c8 ignore start */
3675
+ if (!source) throw new Error("Cannot pipe without source");
3676
+ /* c8 ignore stop */
3677
+ if (zip) source.on("data", (chunk) => {
3678
+ zip.write(chunk);
3679
+ });
3680
+ else source.on("data", (chunk) => {
3681
+ super[WRITE](chunk);
3682
+ });
3683
+ }
3684
+ };
3685
+ //#endregion
3686
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/create.js
3687
+ const createFileSync = (opt, files) => {
3688
+ const p = new PackSync(opt);
3689
+ const stream = new WriteStreamSync(opt.file, { mode: opt.mode || 438 });
3690
+ p.pipe(stream);
3691
+ addFilesSync$1(p, files);
3692
+ };
3693
+ const createFile = (opt, files) => {
3694
+ const p = new Pack(opt);
3695
+ const stream = new WriteStream(opt.file, { mode: opt.mode || 438 });
3696
+ p.pipe(stream);
3697
+ const promise = new Promise((res, rej) => {
3698
+ stream.on("error", rej);
3699
+ stream.on("close", res);
3700
+ p.on("error", rej);
3701
+ });
3702
+ addFilesAsync$1(p, files);
3703
+ return promise;
3704
+ };
3705
+ const addFilesSync$1 = (p, files) => {
3706
+ files.forEach((file) => {
3707
+ if (file.charAt(0) === "@") list({
3708
+ file: path$1.resolve(p.cwd, file.slice(1)),
3709
+ sync: true,
3710
+ noResume: true,
3711
+ onReadEntry: (entry) => p.add(entry)
3712
+ });
3713
+ else p.add(file);
3714
+ });
3715
+ p.end();
3716
+ };
3717
+ const addFilesAsync$1 = async (p, files) => {
3718
+ for (let i = 0; i < files.length; i++) {
3719
+ const file = String(files[i]);
3720
+ if (file.charAt(0) === "@") await list({
3721
+ file: path$1.resolve(String(p.cwd), file.slice(1)),
3722
+ noResume: true,
3723
+ onReadEntry: (entry) => {
3724
+ p.add(entry);
3725
+ }
3726
+ });
3727
+ else p.add(file);
3728
+ }
3729
+ p.end();
3730
+ };
3731
+ const createSync = (opt, files) => {
3732
+ const p = new PackSync(opt);
3733
+ addFilesSync$1(p, files);
3734
+ return p;
3735
+ };
3736
+ const createAsync = (opt, files) => {
3737
+ const p = new Pack(opt);
3738
+ addFilesAsync$1(p, files);
3739
+ return p;
3740
+ };
3741
+ makeCommand(createFileSync, createFile, createSync, createAsync, (_opt, files) => {
3742
+ if (!files?.length) throw new TypeError("no paths specified to add to archive");
3743
+ });
3744
+ //#endregion
3745
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/get-write-flag.js
3746
+ const isWindows$2 = (process.env.__FAKE_PLATFORM__ || process.platform) === "win32";
3747
+ /* c8 ignore start */
3748
+ const { O_CREAT, O_TRUNC, O_WRONLY } = fs$1.constants;
3749
+ const UV_FS_O_FILEMAP = Number(process.env.__FAKE_FS_O_FILENAME__) || fs$1.constants.UV_FS_O_FILEMAP || 0;
3750
+ /* c8 ignore stop */
3751
+ const fMapEnabled = isWindows$2 && !!UV_FS_O_FILEMAP;
3752
+ const fMapLimit = 512 * 1024;
3753
+ const fMapFlag = UV_FS_O_FILEMAP | O_TRUNC | O_CREAT | O_WRONLY;
3754
+ const getWriteFlag = !fMapEnabled ? () => "w" : (size) => size < fMapLimit ? fMapFlag : "w";
3755
+ //#endregion
3756
+ //#region ../../node_modules/.pnpm/chownr@3.0.0/node_modules/chownr/dist/esm/index.js
3757
+ const lchownSync = (path, uid, gid) => {
3758
+ try {
3759
+ return fs.lchownSync(path, uid, gid);
3760
+ } catch (er) {
3761
+ if (er?.code !== "ENOENT") throw er;
3762
+ }
3763
+ };
3764
+ const chown = (cpath, uid, gid, cb) => {
3765
+ fs.lchown(cpath, uid, gid, (er) => {
3766
+ cb(er && er?.code !== "ENOENT" ? er : null);
3767
+ });
3768
+ };
3769
+ const chownrKid = (p, child, uid, gid, cb) => {
3770
+ if (child.isDirectory()) chownr(path$1.resolve(p, child.name), uid, gid, (er) => {
3771
+ if (er) return cb(er);
3772
+ chown(path$1.resolve(p, child.name), uid, gid, cb);
3773
+ });
3774
+ else chown(path$1.resolve(p, child.name), uid, gid, cb);
3775
+ };
3776
+ const chownr = (p, uid, gid, cb) => {
3777
+ fs.readdir(p, { withFileTypes: true }, (er, children) => {
3778
+ if (er) {
3779
+ if (er.code === "ENOENT") return cb();
3780
+ else if (er.code !== "ENOTDIR" && er.code !== "ENOTSUP") return cb(er);
3781
+ }
3782
+ if (er || !children.length) return chown(p, uid, gid, cb);
3783
+ let len = children.length;
3784
+ let errState = null;
3785
+ const then = (er) => {
3786
+ /* c8 ignore start */
3787
+ if (errState) return;
3788
+ /* c8 ignore stop */
3789
+ if (er) return cb(errState = er);
3790
+ if (--len === 0) return chown(p, uid, gid, cb);
3791
+ };
3792
+ for (const child of children) chownrKid(p, child, uid, gid, then);
3793
+ });
3794
+ };
3795
+ const chownrKidSync = (p, child, uid, gid) => {
3796
+ if (child.isDirectory()) chownrSync(path$1.resolve(p, child.name), uid, gid);
3797
+ lchownSync(path$1.resolve(p, child.name), uid, gid);
3798
+ };
3799
+ const chownrSync = (p, uid, gid) => {
3800
+ let children;
3801
+ try {
3802
+ children = fs.readdirSync(p, { withFileTypes: true });
3803
+ } catch (er) {
3804
+ const e = er;
3805
+ if (e?.code === "ENOENT") return;
3806
+ else if (e?.code === "ENOTDIR" || e?.code === "ENOTSUP") return lchownSync(p, uid, gid);
3807
+ else throw e;
3808
+ }
3809
+ for (const child of children) chownrKidSync(p, child, uid, gid);
3810
+ return lchownSync(p, uid, gid);
3811
+ };
3812
+ //#endregion
3813
+ //#region ../../node_modules/.pnpm/mkdirp@3.0.1/node_modules/mkdirp/dist/mjs/opts-arg.js
3814
+ const optsArg = (opts) => {
3815
+ if (!opts) opts = { mode: 511 };
3816
+ else if (typeof opts === "object") opts = {
3817
+ mode: 511,
3818
+ ...opts
3819
+ };
3820
+ else if (typeof opts === "number") opts = { mode: opts };
3821
+ else if (typeof opts === "string") opts = { mode: parseInt(opts, 8) };
3822
+ else throw new TypeError("invalid options argument");
3823
+ const resolved = opts;
3824
+ const optsFs = opts.fs || {};
3825
+ opts.mkdir = opts.mkdir || optsFs.mkdir || mkdir;
3826
+ opts.mkdirAsync = opts.mkdirAsync ? opts.mkdirAsync : async (path, options) => {
3827
+ return new Promise((res, rej) => resolved.mkdir(path, options, (er, made) => er ? rej(er) : res(made)));
3828
+ };
3829
+ opts.stat = opts.stat || optsFs.stat || stat;
3830
+ opts.statAsync = opts.statAsync ? opts.statAsync : async (path) => new Promise((res, rej) => resolved.stat(path, (err, stats) => err ? rej(err) : res(stats)));
3831
+ opts.statSync = opts.statSync || optsFs.statSync || statSync$1;
3832
+ opts.mkdirSync = opts.mkdirSync || optsFs.mkdirSync || mkdirSync;
3833
+ return resolved;
3834
+ };
3835
+ //#endregion
3836
+ //#region ../../node_modules/.pnpm/mkdirp@3.0.1/node_modules/mkdirp/dist/mjs/mkdirp-manual.js
3837
+ const mkdirpManualSync = (path, options, made) => {
3838
+ const parent = dirname(path);
3839
+ const opts = {
3840
+ ...optsArg(options),
3841
+ recursive: false
3842
+ };
3843
+ if (parent === path) try {
3844
+ return opts.mkdirSync(path, opts);
3845
+ } catch (er) {
3846
+ const fer = er;
3847
+ if (fer && fer.code !== "EISDIR") throw er;
3848
+ return;
3849
+ }
3850
+ try {
3851
+ opts.mkdirSync(path, opts);
3852
+ return made || path;
3853
+ } catch (er) {
3854
+ const fer = er;
3855
+ if (fer && fer.code === "ENOENT") return mkdirpManualSync(path, opts, mkdirpManualSync(parent, opts, made));
3856
+ if (fer && fer.code !== "EEXIST" && fer && fer.code !== "EROFS") throw er;
3857
+ try {
3858
+ if (!opts.statSync(path).isDirectory()) throw er;
3859
+ } catch (_) {
3860
+ throw er;
3861
+ }
3862
+ }
3863
+ };
3864
+ const mkdirpManual = Object.assign(async (path, options, made) => {
3865
+ const opts = optsArg(options);
3866
+ opts.recursive = false;
3867
+ const parent = dirname(path);
3868
+ if (parent === path) return opts.mkdirAsync(path, opts).catch((er) => {
3869
+ const fer = er;
3870
+ if (fer && fer.code !== "EISDIR") throw er;
3871
+ });
3872
+ return opts.mkdirAsync(path, opts).then(() => made || path, async (er) => {
3873
+ const fer = er;
3874
+ if (fer && fer.code === "ENOENT") return mkdirpManual(parent, opts).then((made) => mkdirpManual(path, opts, made));
3875
+ if (fer && fer.code !== "EEXIST" && fer.code !== "EROFS") throw er;
3876
+ return opts.statAsync(path).then((st) => {
3877
+ if (st.isDirectory()) return made;
3878
+ else throw er;
3879
+ }, () => {
3880
+ throw er;
3881
+ });
3882
+ });
3883
+ }, { sync: mkdirpManualSync });
3884
+ //#endregion
3885
+ //#region ../../node_modules/.pnpm/mkdirp@3.0.1/node_modules/mkdirp/dist/mjs/find-made.js
3886
+ const findMade = async (opts, parent, path) => {
3887
+ if (path === parent) return;
3888
+ return opts.statAsync(parent).then((st) => st.isDirectory() ? path : void 0, (er) => {
3889
+ const fer = er;
3890
+ return fer && fer.code === "ENOENT" ? findMade(opts, dirname(parent), parent) : void 0;
3891
+ });
3892
+ };
3893
+ const findMadeSync = (opts, parent, path) => {
3894
+ if (path === parent) return;
3895
+ try {
3896
+ return opts.statSync(parent).isDirectory() ? path : void 0;
3897
+ } catch (er) {
3898
+ const fer = er;
3899
+ return fer && fer.code === "ENOENT" ? findMadeSync(opts, dirname(parent), parent) : void 0;
3900
+ }
3901
+ };
3902
+ //#endregion
3903
+ //#region ../../node_modules/.pnpm/mkdirp@3.0.1/node_modules/mkdirp/dist/mjs/mkdirp-native.js
3904
+ const mkdirpNativeSync = (path, options) => {
3905
+ const opts = optsArg(options);
3906
+ opts.recursive = true;
3907
+ if (dirname(path) === path) return opts.mkdirSync(path, opts);
3908
+ const made = findMadeSync(opts, path);
3909
+ try {
3910
+ opts.mkdirSync(path, opts);
3911
+ return made;
3912
+ } catch (er) {
3913
+ const fer = er;
3914
+ if (fer && fer.code === "ENOENT") return mkdirpManualSync(path, opts);
3915
+ else throw er;
3916
+ }
3917
+ };
3918
+ const mkdirpNative = Object.assign(async (path, options) => {
3919
+ const opts = {
3920
+ ...optsArg(options),
3921
+ recursive: true
3922
+ };
3923
+ if (dirname(path) === path) return await opts.mkdirAsync(path, opts);
3924
+ return findMade(opts, path).then((made) => opts.mkdirAsync(path, opts).then((m) => made || m).catch((er) => {
3925
+ const fer = er;
3926
+ if (fer && fer.code === "ENOENT") return mkdirpManual(path, opts);
3927
+ else throw er;
3928
+ }));
3929
+ }, { sync: mkdirpNativeSync });
3930
+ //#endregion
3931
+ //#region ../../node_modules/.pnpm/mkdirp@3.0.1/node_modules/mkdirp/dist/mjs/path-arg.js
3932
+ const platform = process.env.__TESTING_MKDIRP_PLATFORM__ || process.platform;
3933
+ const pathArg = (path) => {
3934
+ if (/\0/.test(path)) throw Object.assign(/* @__PURE__ */ new TypeError("path must be a string without null bytes"), {
3935
+ path,
3936
+ code: "ERR_INVALID_ARG_VALUE"
3937
+ });
3938
+ path = resolve(path);
3939
+ if (platform === "win32") {
3940
+ const badWinChars = /[*|"<>?:]/;
3941
+ const { root } = parse(path);
3942
+ if (badWinChars.test(path.substring(root.length))) throw Object.assign(/* @__PURE__ */ new Error("Illegal characters in path."), {
3943
+ path,
3944
+ code: "EINVAL"
3945
+ });
3946
+ }
3947
+ return path;
3948
+ };
3949
+ //#endregion
3950
+ //#region ../../node_modules/.pnpm/mkdirp@3.0.1/node_modules/mkdirp/dist/mjs/use-native.js
3951
+ const versArr = (process.env.__TESTING_MKDIRP_NODE_VERSION__ || process.version).replace(/^v/, "").split(".");
3952
+ const hasNative = +versArr[0] > 10 || +versArr[0] === 10 && +versArr[1] >= 12;
3953
+ const useNativeSync = !hasNative ? () => false : (opts) => optsArg(opts).mkdirSync === mkdirSync;
3954
+ const useNative = Object.assign(!hasNative ? () => false : (opts) => optsArg(opts).mkdir === mkdir, { sync: useNativeSync });
3955
+ //#endregion
3956
+ //#region ../../node_modules/.pnpm/mkdirp@3.0.1/node_modules/mkdirp/dist/mjs/index.js
3957
+ /* c8 ignore stop */
3958
+ const mkdirpSync = (path, opts) => {
3959
+ path = pathArg(path);
3960
+ const resolved = optsArg(opts);
3961
+ return useNativeSync(resolved) ? mkdirpNativeSync(path, resolved) : mkdirpManualSync(path, resolved);
3962
+ };
3963
+ const mkdirp = Object.assign(async (path, opts) => {
3964
+ path = pathArg(path);
3965
+ const resolved = optsArg(opts);
3966
+ return useNative(resolved) ? mkdirpNative(path, resolved) : mkdirpManual(path, resolved);
3967
+ }, {
3968
+ mkdirpSync,
3969
+ mkdirpNative,
3970
+ mkdirpNativeSync,
3971
+ mkdirpManual,
3972
+ mkdirpManualSync,
3973
+ sync: mkdirpSync,
3974
+ native: mkdirpNative,
3975
+ nativeSync: mkdirpNativeSync,
3976
+ manual: mkdirpManual,
3977
+ manualSync: mkdirpManualSync,
3978
+ useNative,
3979
+ useNativeSync
3980
+ });
3981
+ //#endregion
3982
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/cwd-error.js
3983
+ var CwdError = class extends Error {
3984
+ path;
3985
+ code;
3986
+ syscall = "chdir";
3987
+ constructor(path, code) {
3988
+ super(`${code}: Cannot cd into '${path}'`);
3989
+ this.path = path;
3990
+ this.code = code;
3991
+ }
3992
+ get name() {
3993
+ return "CwdError";
3994
+ }
3995
+ };
3996
+ //#endregion
3997
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/symlink-error.js
3998
+ var SymlinkError = class extends Error {
3999
+ path;
4000
+ symlink;
4001
+ syscall = "symlink";
4002
+ code = "TAR_SYMLINK_ERROR";
4003
+ constructor(symlink, path) {
4004
+ super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link");
4005
+ this.symlink = symlink;
4006
+ this.path = path;
4007
+ }
4008
+ get name() {
4009
+ return "SymlinkError";
4010
+ }
4011
+ };
4012
+ //#endregion
4013
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/mkdir.js
4014
+ const cGet = (cache, key) => cache.get(normalizeWindowsPath(key));
4015
+ const cSet = (cache, key, val) => cache.set(normalizeWindowsPath(key), val);
4016
+ const checkCwd = (dir, cb) => {
4017
+ fs$1.stat(dir, (er, st) => {
4018
+ if (er || !st.isDirectory()) er = new CwdError(dir, er?.code || "ENOTDIR");
4019
+ cb(er);
4020
+ });
4021
+ };
4022
+ /**
4023
+ * Wrapper around mkdirp for tar's needs.
4024
+ *
4025
+ * The main purpose is to avoid creating directories if we know that
4026
+ * they already exist (and track which ones exist for this purpose),
4027
+ * and prevent entries from being extracted into symlinked folders,
4028
+ * if `preservePaths` is not set.
4029
+ */
4030
+ const mkdir$1 = (dir, opt, cb) => {
4031
+ dir = normalizeWindowsPath(dir);
4032
+ /* c8 ignore next */
4033
+ const umask = opt.umask ?? 18;
4034
+ const mode = opt.mode | 448;
4035
+ const needChmod = (mode & umask) !== 0;
4036
+ const uid = opt.uid;
4037
+ const gid = opt.gid;
4038
+ const doChown = typeof uid === "number" && typeof gid === "number" && (uid !== opt.processUid || gid !== opt.processGid);
4039
+ const preserve = opt.preserve;
4040
+ const unlink = opt.unlink;
4041
+ const cache = opt.cache;
4042
+ const cwd = normalizeWindowsPath(opt.cwd);
4043
+ const done = (er, created) => {
4044
+ if (er) cb(er);
4045
+ else {
4046
+ cSet(cache, dir, true);
4047
+ if (created && doChown) chownr(created, uid, gid, (er) => done(er));
4048
+ else if (needChmod) fs$1.chmod(dir, mode, cb);
4049
+ else cb();
4050
+ }
4051
+ };
4052
+ if (cache && cGet(cache, dir) === true) return done();
4053
+ if (dir === cwd) return checkCwd(dir, done);
4054
+ if (preserve) return mkdirp(dir, { mode }).then((made) => done(null, made ?? void 0), done);
4055
+ mkdir_(cwd, normalizeWindowsPath(path$1.relative(cwd, dir)).split("/"), mode, cache, unlink, cwd, void 0, done);
4056
+ };
4057
+ const mkdir_ = (base, parts, mode, cache, unlink, cwd, created, cb) => {
4058
+ if (!parts.length) return cb(null, created);
4059
+ const p = parts.shift();
4060
+ const part = normalizeWindowsPath(path$1.resolve(base + "/" + p));
4061
+ if (cGet(cache, part)) return mkdir_(part, parts, mode, cache, unlink, cwd, created, cb);
4062
+ fs$1.mkdir(part, mode, onmkdir(part, parts, mode, cache, unlink, cwd, created, cb));
4063
+ };
4064
+ const onmkdir = (part, parts, mode, cache, unlink, cwd, created, cb) => (er) => {
4065
+ if (er) fs$1.lstat(part, (statEr, st) => {
4066
+ if (statEr) {
4067
+ statEr.path = statEr.path && normalizeWindowsPath(statEr.path);
4068
+ cb(statEr);
4069
+ } else if (st.isDirectory()) mkdir_(part, parts, mode, cache, unlink, cwd, created, cb);
4070
+ else if (unlink) fs$1.unlink(part, (er) => {
4071
+ if (er) return cb(er);
4072
+ fs$1.mkdir(part, mode, onmkdir(part, parts, mode, cache, unlink, cwd, created, cb));
4073
+ });
4074
+ else if (st.isSymbolicLink()) return cb(new SymlinkError(part, part + "/" + parts.join("/")));
4075
+ else cb(er);
4076
+ });
4077
+ else {
4078
+ created = created || part;
4079
+ mkdir_(part, parts, mode, cache, unlink, cwd, created, cb);
4080
+ }
4081
+ };
4082
+ const checkCwdSync = (dir) => {
4083
+ let ok = false;
4084
+ let code = void 0;
4085
+ try {
4086
+ ok = fs$1.statSync(dir).isDirectory();
4087
+ } catch (er) {
4088
+ code = er?.code;
4089
+ } finally {
4090
+ if (!ok) throw new CwdError(dir, code ?? "ENOTDIR");
4091
+ }
4092
+ };
4093
+ const mkdirSync$1 = (dir, opt) => {
4094
+ dir = normalizeWindowsPath(dir);
4095
+ /* c8 ignore next */
4096
+ const umask = opt.umask ?? 18;
4097
+ const mode = opt.mode | 448;
4098
+ const needChmod = (mode & umask) !== 0;
4099
+ const uid = opt.uid;
4100
+ const gid = opt.gid;
4101
+ const doChown = typeof uid === "number" && typeof gid === "number" && (uid !== opt.processUid || gid !== opt.processGid);
4102
+ const preserve = opt.preserve;
4103
+ const unlink = opt.unlink;
4104
+ const cache = opt.cache;
4105
+ const cwd = normalizeWindowsPath(opt.cwd);
4106
+ const done = (created) => {
4107
+ cSet(cache, dir, true);
4108
+ if (created && doChown) chownrSync(created, uid, gid);
4109
+ if (needChmod) fs$1.chmodSync(dir, mode);
4110
+ };
4111
+ if (cache && cGet(cache, dir) === true) return done();
4112
+ if (dir === cwd) {
4113
+ checkCwdSync(cwd);
4114
+ return done();
4115
+ }
4116
+ if (preserve) return done(mkdirpSync(dir, mode) ?? void 0);
4117
+ const parts = normalizeWindowsPath(path$1.relative(cwd, dir)).split("/");
4118
+ let created = void 0;
4119
+ for (let p = parts.shift(), part = cwd; p && (part += "/" + p); p = parts.shift()) {
4120
+ part = normalizeWindowsPath(path$1.resolve(part));
4121
+ if (cGet(cache, part)) continue;
4122
+ try {
4123
+ fs$1.mkdirSync(part, mode);
4124
+ created = created || part;
4125
+ cSet(cache, part, true);
4126
+ } catch (er) {
4127
+ const st = fs$1.lstatSync(part);
4128
+ if (st.isDirectory()) {
4129
+ cSet(cache, part, true);
4130
+ continue;
4131
+ } else if (unlink) {
4132
+ fs$1.unlinkSync(part);
4133
+ fs$1.mkdirSync(part, mode);
4134
+ created = created || part;
4135
+ cSet(cache, part, true);
4136
+ continue;
4137
+ } else if (st.isSymbolicLink()) return new SymlinkError(part, part + "/" + parts.join("/"));
4138
+ }
4139
+ }
4140
+ return done(created);
4141
+ };
4142
+ //#endregion
4143
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/normalize-unicode.js
4144
+ const normalizeCache = Object.create(null);
4145
+ const { hasOwnProperty } = Object.prototype;
4146
+ const normalizeUnicode = (s) => {
4147
+ if (!hasOwnProperty.call(normalizeCache, s)) normalizeCache[s] = s.normalize("NFD");
4148
+ return normalizeCache[s];
4149
+ };
4150
+ //#endregion
4151
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/path-reservations.js
4152
+ const isWindows$1 = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) === "win32";
4153
+ const getDirs = (path) => {
4154
+ return path.split("/").slice(0, -1).reduce((set, path) => {
4155
+ const s = set[set.length - 1];
4156
+ if (s !== void 0) path = join(s, path);
4157
+ set.push(path || "/");
4158
+ return set;
4159
+ }, []);
4160
+ };
4161
+ var PathReservations = class {
4162
+ #queues = /* @__PURE__ */ new Map();
4163
+ #reservations = /* @__PURE__ */ new Map();
4164
+ #running = /* @__PURE__ */ new Set();
4165
+ reserve(paths, fn) {
4166
+ paths = isWindows$1 ? ["win32 parallelization disabled"] : paths.map((p) => {
4167
+ return stripTrailingSlashes(join(normalizeUnicode(p))).toLowerCase();
4168
+ });
4169
+ const dirs = new Set(paths.map((path) => getDirs(path)).reduce((a, b) => a.concat(b)));
4170
+ this.#reservations.set(fn, {
4171
+ dirs,
4172
+ paths
4173
+ });
4174
+ for (const p of paths) {
4175
+ const q = this.#queues.get(p);
4176
+ if (!q) this.#queues.set(p, [fn]);
4177
+ else q.push(fn);
4178
+ }
4179
+ for (const dir of dirs) {
4180
+ const q = this.#queues.get(dir);
4181
+ if (!q) this.#queues.set(dir, [/* @__PURE__ */ new Set([fn])]);
4182
+ else {
4183
+ const l = q[q.length - 1];
4184
+ if (l instanceof Set) l.add(fn);
4185
+ else q.push(/* @__PURE__ */ new Set([fn]));
4186
+ }
4187
+ }
4188
+ return this.#run(fn);
4189
+ }
4190
+ #getQueues(fn) {
4191
+ const res = this.#reservations.get(fn);
4192
+ /* c8 ignore start */
4193
+ if (!res) throw new Error("function does not have any path reservations");
4194
+ /* c8 ignore stop */
4195
+ return {
4196
+ paths: res.paths.map((path) => this.#queues.get(path)),
4197
+ dirs: [...res.dirs].map((path) => this.#queues.get(path))
4198
+ };
4199
+ }
4200
+ check(fn) {
4201
+ const { paths, dirs } = this.#getQueues(fn);
4202
+ return paths.every((q) => q && q[0] === fn) && dirs.every((q) => q && q[0] instanceof Set && q[0].has(fn));
4203
+ }
4204
+ #run(fn) {
4205
+ if (this.#running.has(fn) || !this.check(fn)) return false;
4206
+ this.#running.add(fn);
4207
+ fn(() => this.#clear(fn));
4208
+ return true;
4209
+ }
4210
+ #clear(fn) {
4211
+ if (!this.#running.has(fn)) return false;
4212
+ const res = this.#reservations.get(fn);
4213
+ /* c8 ignore start */
4214
+ if (!res) throw new Error("invalid reservation");
4215
+ /* c8 ignore stop */
4216
+ const { paths, dirs } = res;
4217
+ const next = /* @__PURE__ */ new Set();
4218
+ for (const path of paths) {
4219
+ const q = this.#queues.get(path);
4220
+ /* c8 ignore start */
4221
+ if (!q || q?.[0] !== fn) continue;
4222
+ /* c8 ignore stop */
4223
+ const q0 = q[1];
4224
+ if (!q0) {
4225
+ this.#queues.delete(path);
4226
+ continue;
4227
+ }
4228
+ q.shift();
4229
+ if (typeof q0 === "function") next.add(q0);
4230
+ else for (const f of q0) next.add(f);
4231
+ }
4232
+ for (const dir of dirs) {
4233
+ const q = this.#queues.get(dir);
4234
+ const q0 = q?.[0];
4235
+ /* c8 ignore next - type safety only */
4236
+ if (!q || !(q0 instanceof Set)) continue;
4237
+ if (q0.size === 1 && q.length === 1) {
4238
+ this.#queues.delete(dir);
4239
+ continue;
4240
+ } else if (q0.size === 1) {
4241
+ q.shift();
4242
+ const n = q[0];
4243
+ if (typeof n === "function") next.add(n);
4244
+ } else q0.delete(fn);
4245
+ }
4246
+ this.#running.delete(fn);
4247
+ next.forEach((fn) => this.#run(fn));
4248
+ return true;
4249
+ }
4250
+ };
4251
+ //#endregion
4252
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/unpack.js
4253
+ const ONENTRY = Symbol("onEntry");
4254
+ const CHECKFS = Symbol("checkFs");
4255
+ const CHECKFS2 = Symbol("checkFs2");
4256
+ const PRUNECACHE = Symbol("pruneCache");
4257
+ const ISREUSABLE = Symbol("isReusable");
4258
+ const MAKEFS = Symbol("makeFs");
4259
+ const FILE = Symbol("file");
4260
+ const DIRECTORY = Symbol("directory");
4261
+ const LINK = Symbol("link");
4262
+ const SYMLINK = Symbol("symlink");
4263
+ const HARDLINK = Symbol("hardlink");
4264
+ const UNSUPPORTED = Symbol("unsupported");
4265
+ const CHECKPATH = Symbol("checkPath");
4266
+ const MKDIR = Symbol("mkdir");
4267
+ const ONERROR = Symbol("onError");
4268
+ const PENDING = Symbol("pending");
4269
+ const PEND = Symbol("pend");
4270
+ const UNPEND = Symbol("unpend");
4271
+ const ENDED = Symbol("ended");
4272
+ const MAYBECLOSE = Symbol("maybeClose");
4273
+ const SKIP = Symbol("skip");
4274
+ const DOCHOWN = Symbol("doChown");
4275
+ const UID = Symbol("uid");
4276
+ const GID = Symbol("gid");
4277
+ const CHECKED_CWD = Symbol("checkedCwd");
4278
+ const isWindows = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) === "win32";
4279
+ const DEFAULT_MAX_DEPTH = 1024;
4280
+ /* c8 ignore start */
4281
+ const unlinkFile = (path, cb) => {
4282
+ if (!isWindows) return fs.unlink(path, cb);
4283
+ const name = path + ".DELETE." + randomBytes(16).toString("hex");
4284
+ fs.rename(path, name, (er) => {
4285
+ if (er) return cb(er);
4286
+ fs.unlink(name, cb);
4287
+ });
4288
+ };
4289
+ /* c8 ignore stop */
4290
+ /* c8 ignore start */
4291
+ const unlinkFileSync = (path) => {
4292
+ if (!isWindows) return fs.unlinkSync(path);
4293
+ const name = path + ".DELETE." + randomBytes(16).toString("hex");
4294
+ fs.renameSync(path, name);
4295
+ fs.unlinkSync(name);
4296
+ };
4297
+ /* c8 ignore stop */
4298
+ const uint32 = (a, b, c) => a !== void 0 && a === a >>> 0 ? a : b !== void 0 && b === b >>> 0 ? b : c;
4299
+ const cacheKeyNormalize = (path) => stripTrailingSlashes(normalizeWindowsPath(normalizeUnicode(path))).toLowerCase();
4300
+ const pruneCache = (cache, abs) => {
4301
+ abs = cacheKeyNormalize(abs);
4302
+ for (const path of cache.keys()) {
4303
+ const pnorm = cacheKeyNormalize(path);
4304
+ if (pnorm === abs || pnorm.indexOf(abs + "/") === 0) cache.delete(path);
4305
+ }
4306
+ };
4307
+ const dropCache = (cache) => {
4308
+ for (const key of cache.keys()) cache.delete(key);
4309
+ };
4310
+ var Unpack = class extends Parser {
4311
+ [ENDED] = false;
4312
+ [CHECKED_CWD] = false;
4313
+ [PENDING] = 0;
4314
+ reservations = new PathReservations();
4315
+ transform;
4316
+ writable = true;
4317
+ readable = false;
4318
+ dirCache;
4319
+ uid;
4320
+ gid;
4321
+ setOwner;
4322
+ preserveOwner;
4323
+ processGid;
4324
+ processUid;
4325
+ maxDepth;
4326
+ forceChown;
4327
+ win32;
4328
+ newer;
4329
+ keep;
4330
+ noMtime;
4331
+ preservePaths;
4332
+ unlink;
4333
+ cwd;
4334
+ strip;
4335
+ processUmask;
4336
+ umask;
4337
+ dmode;
4338
+ fmode;
4339
+ chmod;
4340
+ constructor(opt = {}) {
4341
+ opt.ondone = () => {
4342
+ this[ENDED] = true;
4343
+ this[MAYBECLOSE]();
4344
+ };
4345
+ super(opt);
4346
+ this.transform = opt.transform;
4347
+ this.dirCache = opt.dirCache || /* @__PURE__ */ new Map();
4348
+ this.chmod = !!opt.chmod;
4349
+ if (typeof opt.uid === "number" || typeof opt.gid === "number") {
4350
+ if (typeof opt.uid !== "number" || typeof opt.gid !== "number") throw new TypeError("cannot set owner without number uid and gid");
4351
+ if (opt.preserveOwner) throw new TypeError("cannot preserve owner in archive and also set owner explicitly");
4352
+ this.uid = opt.uid;
4353
+ this.gid = opt.gid;
4354
+ this.setOwner = true;
4355
+ } else {
4356
+ this.uid = void 0;
4357
+ this.gid = void 0;
4358
+ this.setOwner = false;
4359
+ }
4360
+ if (opt.preserveOwner === void 0 && typeof opt.uid !== "number") this.preserveOwner = !!(process.getuid && process.getuid() === 0);
4361
+ else this.preserveOwner = !!opt.preserveOwner;
4362
+ this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0;
4363
+ this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0;
4364
+ this.maxDepth = typeof opt.maxDepth === "number" ? opt.maxDepth : DEFAULT_MAX_DEPTH;
4365
+ this.forceChown = opt.forceChown === true;
4366
+ this.win32 = !!opt.win32 || isWindows;
4367
+ this.newer = !!opt.newer;
4368
+ this.keep = !!opt.keep;
4369
+ this.noMtime = !!opt.noMtime;
4370
+ this.preservePaths = !!opt.preservePaths;
4371
+ this.unlink = !!opt.unlink;
4372
+ this.cwd = normalizeWindowsPath(path$1.resolve(opt.cwd || process.cwd()));
4373
+ this.strip = Number(opt.strip) || 0;
4374
+ this.processUmask = !this.chmod ? 0 : typeof opt.processUmask === "number" ? opt.processUmask : process.umask();
4375
+ this.umask = typeof opt.umask === "number" ? opt.umask : this.processUmask;
4376
+ this.dmode = opt.dmode || 511 & ~this.umask;
4377
+ this.fmode = opt.fmode || 438 & ~this.umask;
4378
+ this.on("entry", (entry) => this[ONENTRY](entry));
4379
+ }
4380
+ warn(code, msg, data = {}) {
4381
+ if (code === "TAR_BAD_ARCHIVE" || code === "TAR_ABORT") data.recoverable = false;
4382
+ return super.warn(code, msg, data);
4383
+ }
4384
+ [MAYBECLOSE]() {
4385
+ if (this[ENDED] && this[PENDING] === 0) {
4386
+ this.emit("prefinish");
4387
+ this.emit("finish");
4388
+ this.emit("end");
4389
+ }
4390
+ }
4391
+ [CHECKPATH](entry) {
4392
+ const p = normalizeWindowsPath(entry.path);
4393
+ const parts = p.split("/");
4394
+ if (this.strip) {
4395
+ if (parts.length < this.strip) return false;
4396
+ if (entry.type === "Link") {
4397
+ const linkparts = normalizeWindowsPath(String(entry.linkpath)).split("/");
4398
+ if (linkparts.length >= this.strip) entry.linkpath = linkparts.slice(this.strip).join("/");
4399
+ else return false;
4400
+ }
4401
+ parts.splice(0, this.strip);
4402
+ entry.path = parts.join("/");
4403
+ }
4404
+ if (isFinite(this.maxDepth) && parts.length > this.maxDepth) {
4405
+ this.warn("TAR_ENTRY_ERROR", "path excessively deep", {
4406
+ entry,
4407
+ path: p,
4408
+ depth: parts.length,
4409
+ maxDepth: this.maxDepth
4410
+ });
4411
+ return false;
4412
+ }
4413
+ if (!this.preservePaths) {
4414
+ if (parts.includes("..") || isWindows && /^[a-z]:\.\.$/i.test(parts[0] ?? "")) {
4415
+ this.warn("TAR_ENTRY_ERROR", `path contains '..'`, {
4416
+ entry,
4417
+ path: p
4418
+ });
4419
+ return false;
4420
+ }
4421
+ const [root, stripped] = stripAbsolutePath(p);
4422
+ if (root) {
4423
+ entry.path = String(stripped);
4424
+ this.warn("TAR_ENTRY_INFO", `stripping ${root} from absolute path`, {
4425
+ entry,
4426
+ path: p
4427
+ });
4428
+ }
4429
+ }
4430
+ if (path$1.isAbsolute(entry.path)) entry.absolute = normalizeWindowsPath(path$1.resolve(entry.path));
4431
+ else entry.absolute = normalizeWindowsPath(path$1.resolve(this.cwd, entry.path));
4432
+ /* c8 ignore start - defense in depth */
4433
+ if (!this.preservePaths && typeof entry.absolute === "string" && entry.absolute.indexOf(this.cwd + "/") !== 0 && entry.absolute !== this.cwd) {
4434
+ this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", {
4435
+ entry,
4436
+ path: normalizeWindowsPath(entry.path),
4437
+ resolvedPath: entry.absolute,
4438
+ cwd: this.cwd
4439
+ });
4440
+ return false;
4441
+ }
4442
+ /* c8 ignore stop */
4443
+ if (entry.absolute === this.cwd && entry.type !== "Directory" && entry.type !== "GNUDumpDir") return false;
4444
+ if (this.win32) {
4445
+ const { root: aRoot } = path$1.win32.parse(String(entry.absolute));
4446
+ entry.absolute = aRoot + encode(String(entry.absolute).slice(aRoot.length));
4447
+ const { root: pRoot } = path$1.win32.parse(entry.path);
4448
+ entry.path = pRoot + encode(entry.path.slice(pRoot.length));
4449
+ }
4450
+ return true;
4451
+ }
4452
+ [ONENTRY](entry) {
4453
+ if (!this[CHECKPATH](entry)) return entry.resume();
4454
+ assert$1.equal(typeof entry.absolute, "string");
4455
+ switch (entry.type) {
4456
+ case "Directory":
4457
+ case "GNUDumpDir": if (entry.mode) entry.mode = entry.mode | 448;
4458
+ case "File":
4459
+ case "OldFile":
4460
+ case "ContiguousFile":
4461
+ case "Link":
4462
+ case "SymbolicLink": return this[CHECKFS](entry);
4463
+ default: return this[UNSUPPORTED](entry);
4464
+ }
4465
+ }
4466
+ [ONERROR](er, entry) {
4467
+ if (er.name === "CwdError") this.emit("error", er);
4468
+ else {
4469
+ this.warn("TAR_ENTRY_ERROR", er, { entry });
4470
+ this[UNPEND]();
4471
+ entry.resume();
4472
+ }
4473
+ }
4474
+ [MKDIR](dir, mode, cb) {
4475
+ mkdir$1(normalizeWindowsPath(dir), {
4476
+ uid: this.uid,
4477
+ gid: this.gid,
4478
+ processUid: this.processUid,
4479
+ processGid: this.processGid,
4480
+ umask: this.processUmask,
4481
+ preserve: this.preservePaths,
4482
+ unlink: this.unlink,
4483
+ cache: this.dirCache,
4484
+ cwd: this.cwd,
4485
+ mode
4486
+ }, cb);
4487
+ }
4488
+ [DOCHOWN](entry) {
4489
+ return this.forceChown || this.preserveOwner && (typeof entry.uid === "number" && entry.uid !== this.processUid || typeof entry.gid === "number" && entry.gid !== this.processGid) || typeof this.uid === "number" && this.uid !== this.processUid || typeof this.gid === "number" && this.gid !== this.processGid;
4490
+ }
4491
+ [UID](entry) {
4492
+ return uint32(this.uid, entry.uid, this.processUid);
4493
+ }
4494
+ [GID](entry) {
4495
+ return uint32(this.gid, entry.gid, this.processGid);
4496
+ }
4497
+ [FILE](entry, fullyDone) {
4498
+ const mode = typeof entry.mode === "number" ? entry.mode & 4095 : this.fmode;
4499
+ const stream = new WriteStream(String(entry.absolute), {
4500
+ flags: getWriteFlag(entry.size),
4501
+ mode,
4502
+ autoClose: false
4503
+ });
4504
+ stream.on("error", (er) => {
4505
+ if (stream.fd) fs.close(stream.fd, () => {});
4506
+ stream.write = () => true;
4507
+ this[ONERROR](er, entry);
4508
+ fullyDone();
4509
+ });
4510
+ let actions = 1;
4511
+ const done = (er) => {
4512
+ if (er) {
4513
+ /* c8 ignore start - we should always have a fd by now */
4514
+ if (stream.fd) fs.close(stream.fd, () => {});
4515
+ /* c8 ignore stop */
4516
+ this[ONERROR](er, entry);
4517
+ fullyDone();
4518
+ return;
4519
+ }
4520
+ if (--actions === 0) {
4521
+ if (stream.fd !== void 0) fs.close(stream.fd, (er) => {
4522
+ if (er) this[ONERROR](er, entry);
4523
+ else this[UNPEND]();
4524
+ fullyDone();
4525
+ });
4526
+ }
4527
+ };
4528
+ stream.on("finish", () => {
4529
+ const abs = String(entry.absolute);
4530
+ const fd = stream.fd;
4531
+ if (typeof fd === "number" && entry.mtime && !this.noMtime) {
4532
+ actions++;
4533
+ const atime = entry.atime || /* @__PURE__ */ new Date();
4534
+ const mtime = entry.mtime;
4535
+ fs.futimes(fd, atime, mtime, (er) => er ? fs.utimes(abs, atime, mtime, (er2) => done(er2 && er)) : done());
4536
+ }
4537
+ if (typeof fd === "number" && this[DOCHOWN](entry)) {
4538
+ actions++;
4539
+ const uid = this[UID](entry);
4540
+ const gid = this[GID](entry);
4541
+ if (typeof uid === "number" && typeof gid === "number") fs.fchown(fd, uid, gid, (er) => er ? fs.chown(abs, uid, gid, (er2) => done(er2 && er)) : done());
4542
+ }
4543
+ done();
4544
+ });
4545
+ const tx = this.transform ? this.transform(entry) || entry : entry;
4546
+ if (tx !== entry) {
4547
+ tx.on("error", (er) => {
4548
+ this[ONERROR](er, entry);
4549
+ fullyDone();
4550
+ });
4551
+ entry.pipe(tx);
4552
+ }
4553
+ tx.pipe(stream);
4554
+ }
4555
+ [DIRECTORY](entry, fullyDone) {
4556
+ const mode = typeof entry.mode === "number" ? entry.mode & 4095 : this.dmode;
4557
+ this[MKDIR](String(entry.absolute), mode, (er) => {
4558
+ if (er) {
4559
+ this[ONERROR](er, entry);
4560
+ fullyDone();
4561
+ return;
4562
+ }
4563
+ let actions = 1;
4564
+ const done = () => {
4565
+ if (--actions === 0) {
4566
+ fullyDone();
4567
+ this[UNPEND]();
4568
+ entry.resume();
4569
+ }
4570
+ };
4571
+ if (entry.mtime && !this.noMtime) {
4572
+ actions++;
4573
+ fs.utimes(String(entry.absolute), entry.atime || /* @__PURE__ */ new Date(), entry.mtime, done);
4574
+ }
4575
+ if (this[DOCHOWN](entry)) {
4576
+ actions++;
4577
+ fs.chown(String(entry.absolute), Number(this[UID](entry)), Number(this[GID](entry)), done);
4578
+ }
4579
+ done();
4580
+ });
4581
+ }
4582
+ [UNSUPPORTED](entry) {
4583
+ entry.unsupported = true;
4584
+ this.warn("TAR_ENTRY_UNSUPPORTED", `unsupported entry type: ${entry.type}`, { entry });
4585
+ entry.resume();
4586
+ }
4587
+ [SYMLINK](entry, done) {
4588
+ this[LINK](entry, String(entry.linkpath), "symlink", done);
4589
+ }
4590
+ [HARDLINK](entry, done) {
4591
+ const linkpath = normalizeWindowsPath(path$1.resolve(this.cwd, String(entry.linkpath)));
4592
+ this[LINK](entry, linkpath, "link", done);
4593
+ }
4594
+ [PEND]() {
4595
+ this[PENDING]++;
4596
+ }
4597
+ [UNPEND]() {
4598
+ this[PENDING]--;
4599
+ this[MAYBECLOSE]();
4600
+ }
4601
+ [SKIP](entry) {
4602
+ this[UNPEND]();
4603
+ entry.resume();
4604
+ }
4605
+ [ISREUSABLE](entry, st) {
4606
+ return entry.type === "File" && !this.unlink && st.isFile() && st.nlink <= 1 && !isWindows;
4607
+ }
4608
+ [CHECKFS](entry) {
4609
+ this[PEND]();
4610
+ const paths = [entry.path];
4611
+ if (entry.linkpath) paths.push(entry.linkpath);
4612
+ this.reservations.reserve(paths, (done) => this[CHECKFS2](entry, done));
4613
+ }
4614
+ [PRUNECACHE](entry) {
4615
+ if (entry.type === "SymbolicLink") dropCache(this.dirCache);
4616
+ else if (entry.type !== "Directory") pruneCache(this.dirCache, String(entry.absolute));
4617
+ }
4618
+ [CHECKFS2](entry, fullyDone) {
4619
+ this[PRUNECACHE](entry);
4620
+ const done = (er) => {
4621
+ this[PRUNECACHE](entry);
4622
+ fullyDone(er);
4623
+ };
4624
+ const checkCwd = () => {
4625
+ this[MKDIR](this.cwd, this.dmode, (er) => {
4626
+ if (er) {
4627
+ this[ONERROR](er, entry);
4628
+ done();
4629
+ return;
4630
+ }
4631
+ this[CHECKED_CWD] = true;
4632
+ start();
4633
+ });
4634
+ };
4635
+ const start = () => {
4636
+ if (entry.absolute !== this.cwd) {
4637
+ const parent = normalizeWindowsPath(path$1.dirname(String(entry.absolute)));
4638
+ if (parent !== this.cwd) return this[MKDIR](parent, this.dmode, (er) => {
4639
+ if (er) {
4640
+ this[ONERROR](er, entry);
4641
+ done();
4642
+ return;
4643
+ }
4644
+ afterMakeParent();
4645
+ });
4646
+ }
4647
+ afterMakeParent();
4648
+ };
4649
+ const afterMakeParent = () => {
4650
+ fs.lstat(String(entry.absolute), (lstatEr, st) => {
4651
+ if (st && (this.keep || this.newer && st.mtime > (entry.mtime ?? st.mtime))) {
4652
+ this[SKIP](entry);
4653
+ done();
4654
+ return;
4655
+ }
4656
+ if (lstatEr || this[ISREUSABLE](entry, st)) return this[MAKEFS](null, entry, done);
4657
+ if (st.isDirectory()) {
4658
+ if (entry.type === "Directory") {
4659
+ const needChmod = this.chmod && entry.mode && (st.mode & 4095) !== entry.mode;
4660
+ const afterChmod = (er) => this[MAKEFS](er ?? null, entry, done);
4661
+ if (!needChmod) return afterChmod();
4662
+ return fs.chmod(String(entry.absolute), Number(entry.mode), afterChmod);
4663
+ }
4664
+ if (entry.absolute !== this.cwd) return fs.rmdir(String(entry.absolute), (er) => this[MAKEFS](er ?? null, entry, done));
4665
+ }
4666
+ if (entry.absolute === this.cwd) return this[MAKEFS](null, entry, done);
4667
+ unlinkFile(String(entry.absolute), (er) => this[MAKEFS](er ?? null, entry, done));
4668
+ });
4669
+ };
4670
+ if (this[CHECKED_CWD]) start();
4671
+ else checkCwd();
4672
+ }
4673
+ [MAKEFS](er, entry, done) {
4674
+ if (er) {
4675
+ this[ONERROR](er, entry);
4676
+ done();
4677
+ return;
4678
+ }
4679
+ switch (entry.type) {
4680
+ case "File":
4681
+ case "OldFile":
4682
+ case "ContiguousFile": return this[FILE](entry, done);
4683
+ case "Link": return this[HARDLINK](entry, done);
4684
+ case "SymbolicLink": return this[SYMLINK](entry, done);
4685
+ case "Directory":
4686
+ case "GNUDumpDir": return this[DIRECTORY](entry, done);
4687
+ }
4688
+ }
4689
+ [LINK](entry, linkpath, link, done) {
4690
+ fs[link](linkpath, String(entry.absolute), (er) => {
4691
+ if (er) this[ONERROR](er, entry);
4692
+ else {
4693
+ this[UNPEND]();
4694
+ entry.resume();
4695
+ }
4696
+ done();
4697
+ });
4698
+ }
4699
+ };
4700
+ const callSync = (fn) => {
4701
+ try {
4702
+ return [null, fn()];
4703
+ } catch (er) {
4704
+ return [er, null];
4705
+ }
4706
+ };
4707
+ var UnpackSync = class extends Unpack {
4708
+ sync = true;
4709
+ [MAKEFS](er, entry) {
4710
+ return super[MAKEFS](er, entry, () => {});
4711
+ }
4712
+ [CHECKFS](entry) {
4713
+ this[PRUNECACHE](entry);
4714
+ if (!this[CHECKED_CWD]) {
4715
+ const er = this[MKDIR](this.cwd, this.dmode);
4716
+ if (er) return this[ONERROR](er, entry);
4717
+ this[CHECKED_CWD] = true;
4718
+ }
4719
+ if (entry.absolute !== this.cwd) {
4720
+ const parent = normalizeWindowsPath(path$1.dirname(String(entry.absolute)));
4721
+ if (parent !== this.cwd) {
4722
+ const mkParent = this[MKDIR](parent, this.dmode);
4723
+ if (mkParent) return this[ONERROR](mkParent, entry);
4724
+ }
4725
+ }
4726
+ const [lstatEr, st] = callSync(() => fs.lstatSync(String(entry.absolute)));
4727
+ if (st && (this.keep || this.newer && st.mtime > (entry.mtime ?? st.mtime))) return this[SKIP](entry);
4728
+ if (lstatEr || this[ISREUSABLE](entry, st)) return this[MAKEFS](null, entry);
4729
+ if (st.isDirectory()) {
4730
+ if (entry.type === "Directory") {
4731
+ const [er] = this.chmod && entry.mode && (st.mode & 4095) !== entry.mode ? callSync(() => {
4732
+ fs.chmodSync(String(entry.absolute), Number(entry.mode));
4733
+ }) : [];
4734
+ return this[MAKEFS](er, entry);
4735
+ }
4736
+ const [er] = callSync(() => fs.rmdirSync(String(entry.absolute)));
4737
+ this[MAKEFS](er, entry);
4738
+ }
4739
+ const [er] = entry.absolute === this.cwd ? [] : callSync(() => unlinkFileSync(String(entry.absolute)));
4740
+ this[MAKEFS](er, entry);
4741
+ }
4742
+ [FILE](entry, done) {
4743
+ const mode = typeof entry.mode === "number" ? entry.mode & 4095 : this.fmode;
4744
+ const oner = (er) => {
4745
+ let closeError;
4746
+ try {
4747
+ fs.closeSync(fd);
4748
+ } catch (e) {
4749
+ closeError = e;
4750
+ }
4751
+ if (er || closeError) this[ONERROR](er || closeError, entry);
4752
+ done();
4753
+ };
4754
+ let fd;
4755
+ try {
4756
+ fd = fs.openSync(String(entry.absolute), getWriteFlag(entry.size), mode);
4757
+ } catch (er) {
4758
+ return oner(er);
4759
+ }
4760
+ const tx = this.transform ? this.transform(entry) || entry : entry;
4761
+ if (tx !== entry) {
4762
+ tx.on("error", (er) => this[ONERROR](er, entry));
4763
+ entry.pipe(tx);
4764
+ }
4765
+ tx.on("data", (chunk) => {
4766
+ try {
4767
+ fs.writeSync(fd, chunk, 0, chunk.length);
4768
+ } catch (er) {
4769
+ oner(er);
4770
+ }
4771
+ });
4772
+ tx.on("end", () => {
4773
+ let er = null;
4774
+ if (entry.mtime && !this.noMtime) {
4775
+ const atime = entry.atime || /* @__PURE__ */ new Date();
4776
+ const mtime = entry.mtime;
4777
+ try {
4778
+ fs.futimesSync(fd, atime, mtime);
4779
+ } catch (futimeser) {
4780
+ try {
4781
+ fs.utimesSync(String(entry.absolute), atime, mtime);
4782
+ } catch (utimeser) {
4783
+ er = futimeser;
4784
+ }
4785
+ }
4786
+ }
4787
+ if (this[DOCHOWN](entry)) {
4788
+ const uid = this[UID](entry);
4789
+ const gid = this[GID](entry);
4790
+ try {
4791
+ fs.fchownSync(fd, Number(uid), Number(gid));
4792
+ } catch (fchowner) {
4793
+ try {
4794
+ fs.chownSync(String(entry.absolute), Number(uid), Number(gid));
4795
+ } catch (chowner) {
4796
+ er = er || fchowner;
4797
+ }
4798
+ }
4799
+ }
4800
+ oner(er);
4801
+ });
4802
+ }
4803
+ [DIRECTORY](entry, done) {
4804
+ const mode = typeof entry.mode === "number" ? entry.mode & 4095 : this.dmode;
4805
+ const er = this[MKDIR](String(entry.absolute), mode);
4806
+ if (er) {
4807
+ this[ONERROR](er, entry);
4808
+ done();
4809
+ return;
4810
+ }
4811
+ if (entry.mtime && !this.noMtime) try {
4812
+ fs.utimesSync(String(entry.absolute), entry.atime || /* @__PURE__ */ new Date(), entry.mtime);
4813
+ } catch (er) {}
4814
+ if (this[DOCHOWN](entry)) try {
4815
+ fs.chownSync(String(entry.absolute), Number(this[UID](entry)), Number(this[GID](entry)));
4816
+ } catch (er) {}
4817
+ done();
4818
+ entry.resume();
4819
+ }
4820
+ [MKDIR](dir, mode) {
4821
+ try {
4822
+ return mkdirSync$1(normalizeWindowsPath(dir), {
4823
+ uid: this.uid,
4824
+ gid: this.gid,
4825
+ processUid: this.processUid,
4826
+ processGid: this.processGid,
4827
+ umask: this.processUmask,
4828
+ preserve: this.preservePaths,
4829
+ unlink: this.unlink,
4830
+ cache: this.dirCache,
4831
+ cwd: this.cwd,
4832
+ mode
4833
+ });
4834
+ } catch (er) {
4835
+ return er;
4836
+ }
4837
+ }
4838
+ [LINK](entry, linkpath, link, done) {
4839
+ const ls = `${link}Sync`;
4840
+ try {
4841
+ fs[ls](linkpath, String(entry.absolute));
4842
+ done();
4843
+ entry.resume();
4844
+ } catch (er) {
4845
+ return this[ONERROR](er, entry);
4846
+ }
4847
+ }
4848
+ };
4849
+ //#endregion
4850
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/extract.js
4851
+ const extractFileSync = (opt) => {
4852
+ const u = new UnpackSync(opt);
4853
+ const file = opt.file;
4854
+ const stat = fs.statSync(file);
4855
+ new ReadStreamSync(file, {
4856
+ readSize: opt.maxReadSize || 16 * 1024 * 1024,
4857
+ size: stat.size
4858
+ }).pipe(u);
4859
+ };
4860
+ const extractFile = (opt, _) => {
4861
+ const u = new Unpack(opt);
4862
+ const readSize = opt.maxReadSize || 16 * 1024 * 1024;
4863
+ const file = opt.file;
4864
+ return new Promise((resolve, reject) => {
4865
+ u.on("error", reject);
4866
+ u.on("close", resolve);
4867
+ fs.stat(file, (er, stat) => {
4868
+ if (er) reject(er);
4869
+ else {
4870
+ const stream = new ReadStream(file, {
4871
+ readSize,
4872
+ size: stat.size
4873
+ });
4874
+ stream.on("error", reject);
4875
+ stream.pipe(u);
4876
+ }
4877
+ });
4878
+ });
4879
+ };
4880
+ const extract = makeCommand(extractFileSync, extractFile, (opt) => new UnpackSync(opt), (opt) => new Unpack(opt), (opt, files) => {
4881
+ if (files?.length) filesFilter(opt, files);
4882
+ });
4883
+ //#endregion
4884
+ //#region ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/replace.js
4885
+ const replaceSync = (opt, files) => {
4886
+ const p = new PackSync(opt);
4887
+ let threw = true;
4888
+ let fd;
4889
+ let position;
4890
+ try {
4891
+ try {
4892
+ fd = fs.openSync(opt.file, "r+");
4893
+ } catch (er) {
4894
+ if (er?.code === "ENOENT") fd = fs.openSync(opt.file, "w+");
4895
+ else throw er;
4896
+ }
4897
+ const st = fs.fstatSync(fd);
4898
+ const headBuf = Buffer.alloc(512);
4899
+ POSITION: for (position = 0; position < st.size; position += 512) {
4900
+ for (let bufPos = 0, bytes = 0; bufPos < 512; bufPos += bytes) {
4901
+ bytes = fs.readSync(fd, headBuf, bufPos, headBuf.length - bufPos, position + bufPos);
4902
+ if (position === 0 && headBuf[0] === 31 && headBuf[1] === 139) throw new Error("cannot append to compressed archives");
4903
+ if (!bytes) break POSITION;
4904
+ }
4905
+ const h = new Header(headBuf);
4906
+ if (!h.cksumValid) break;
4907
+ const entryBlockSize = 512 * Math.ceil((h.size || 0) / 512);
4908
+ if (position + entryBlockSize + 512 > st.size) break;
4909
+ position += entryBlockSize;
4910
+ if (opt.mtimeCache && h.mtime) opt.mtimeCache.set(String(h.path), h.mtime);
4911
+ }
4912
+ threw = false;
4913
+ streamSync(opt, p, position, fd, files);
4914
+ } finally {
4915
+ if (threw) try {
4916
+ fs.closeSync(fd);
4917
+ } catch (er) {}
4918
+ }
4919
+ };
4920
+ const streamSync = (opt, p, position, fd, files) => {
4921
+ const stream = new WriteStreamSync(opt.file, {
4922
+ fd,
4923
+ start: position
4924
+ });
4925
+ p.pipe(stream);
4926
+ addFilesSync(p, files);
4927
+ };
4928
+ const replaceAsync = (opt, files) => {
4929
+ files = Array.from(files);
4930
+ const p = new Pack(opt);
4931
+ const getPos = (fd, size, cb_) => {
4932
+ const cb = (er, pos) => {
4933
+ if (er) fs.close(fd, (_) => cb_(er));
4934
+ else cb_(null, pos);
4935
+ };
4936
+ let position = 0;
4937
+ if (size === 0) return cb(null, 0);
4938
+ let bufPos = 0;
4939
+ const headBuf = Buffer.alloc(512);
4940
+ const onread = (er, bytes) => {
4941
+ if (er || typeof bytes === "undefined") return cb(er);
4942
+ bufPos += bytes;
4943
+ if (bufPos < 512 && bytes) return fs.read(fd, headBuf, bufPos, headBuf.length - bufPos, position + bufPos, onread);
4944
+ if (position === 0 && headBuf[0] === 31 && headBuf[1] === 139) return cb(/* @__PURE__ */ new Error("cannot append to compressed archives"));
4945
+ if (bufPos < 512) return cb(null, position);
4946
+ const h = new Header(headBuf);
4947
+ if (!h.cksumValid) return cb(null, position);
4948
+ /* c8 ignore next */
4949
+ const entryBlockSize = 512 * Math.ceil((h.size ?? 0) / 512);
4950
+ if (position + entryBlockSize + 512 > size) return cb(null, position);
4951
+ position += entryBlockSize + 512;
4952
+ if (position >= size) return cb(null, position);
4953
+ if (opt.mtimeCache && h.mtime) opt.mtimeCache.set(String(h.path), h.mtime);
4954
+ bufPos = 0;
4955
+ fs.read(fd, headBuf, 0, 512, position, onread);
4956
+ };
4957
+ fs.read(fd, headBuf, 0, 512, position, onread);
4958
+ };
4959
+ return new Promise((resolve, reject) => {
4960
+ p.on("error", reject);
4961
+ let flag = "r+";
4962
+ const onopen = (er, fd) => {
4963
+ if (er && er.code === "ENOENT" && flag === "r+") {
4964
+ flag = "w+";
4965
+ return fs.open(opt.file, flag, onopen);
4966
+ }
4967
+ if (er || !fd) return reject(er);
4968
+ fs.fstat(fd, (er, st) => {
4969
+ if (er) return fs.close(fd, () => reject(er));
4970
+ getPos(fd, st.size, (er, position) => {
4971
+ if (er) return reject(er);
4972
+ const stream = new WriteStream(opt.file, {
4973
+ fd,
4974
+ start: position
4975
+ });
4976
+ p.pipe(stream);
4977
+ stream.on("error", reject);
4978
+ stream.on("close", resolve);
4979
+ addFilesAsync(p, files);
4980
+ });
4981
+ });
4982
+ };
4983
+ fs.open(opt.file, flag, onopen);
4984
+ });
4985
+ };
4986
+ const addFilesSync = (p, files) => {
4987
+ files.forEach((file) => {
4988
+ if (file.charAt(0) === "@") list({
4989
+ file: path$1.resolve(p.cwd, file.slice(1)),
4990
+ sync: true,
4991
+ noResume: true,
4992
+ onReadEntry: (entry) => p.add(entry)
4993
+ });
4994
+ else p.add(file);
4995
+ });
4996
+ p.end();
4997
+ };
4998
+ const addFilesAsync = async (p, files) => {
4999
+ for (let i = 0; i < files.length; i++) {
5000
+ const file = String(files[i]);
5001
+ if (file.charAt(0) === "@") await list({
5002
+ file: path$1.resolve(String(p.cwd), file.slice(1)),
5003
+ noResume: true,
5004
+ onReadEntry: (entry) => p.add(entry)
5005
+ });
5006
+ else p.add(file);
5007
+ }
5008
+ p.end();
5009
+ };
5010
+ const replace = makeCommand(
5011
+ replaceSync,
5012
+ replaceAsync,
5013
+ /* c8 ignore start */
5014
+ () => {
5015
+ throw new TypeError("file is required");
5016
+ },
5017
+ () => {
5018
+ throw new TypeError("file is required");
5019
+ },
5020
+ /* c8 ignore stop */
5021
+ (opt, entries) => {
5022
+ if (!isFile(opt)) throw new TypeError("file is required");
5023
+ if (opt.gzip || opt.brotli || opt.file.endsWith(".br") || opt.file.endsWith(".tbr")) throw new TypeError("cannot append to compressed archives");
5024
+ if (!entries?.length) throw new TypeError("no paths specified to add/replace");
5025
+ }
5026
+ );
5027
+ makeCommand(replace.syncFile, replace.asyncFile, replace.syncNoFile, replace.asyncNoFile, (opt, entries = []) => {
5028
+ replace.validate?.(opt, entries);
5029
+ mtimeFilter(opt);
5030
+ });
5031
+ const mtimeFilter = (opt) => {
5032
+ const filter = opt.filter;
5033
+ if (!opt.mtimeCache) opt.mtimeCache = /* @__PURE__ */ new Map();
5034
+ opt.filter = filter ? (path, stat) => filter(path, stat) && !((opt.mtimeCache?.get(path) ?? stat.mtime ?? 0) > (stat.mtime ?? 0)) : (path, stat) => !((opt.mtimeCache?.get(path) ?? stat.mtime ?? 0) > (stat.mtime ?? 0));
5035
+ };
5036
+ //#endregion
5037
+ export { extract };
5038
+
5039
+ //# sourceMappingURL=esm-BlS2QDIo.js.map