create-vuetify 3.2.0-beta.1 → 3.2.0-beta.2

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