UNPKG

sv

Version:

A CLI for creating and updating SvelteKit projects

1,457 lines (1,455 loc) 330 kB
import { __commonJS$1 as __commonJS, __require, __toESM$1 as __toESM, addPnpmBuildDependencies, be, create } from "./package-manager-DO5R9a6p.js"; import fs from "node:fs"; import path from "node:path"; import process$1 from "node:process"; //#region node_modules/.pnpm/degit@2.8.4/node_modules/degit/dist/index-688c5d50.js var require_index_688c5d50 = __commonJS({ "node_modules/.pnpm/degit@2.8.4/node_modules/degit/dist/index-688c5d50.js"(exports) { var fs$1 = __require("fs"); var path$1 = __require("path"); var Events = __require("events"); var Stream$1$1 = __require("stream"); var require$$0 = __require("string_decoder"); var assert = __require("assert"); var require$$0$1 = __require("buffer"); var realZlib = __require("zlib"); var util$1 = __require("util"); var crypto = __require("crypto"); var os = __require("os"); var tty = __require("tty"); var constants$1 = __require("constants"); var https = __require("https"); var child_process = __require("child_process"); var require$$2 = __require("url"); var require$$0$2 = __require("net"); var require$$1 = __require("tls"); function _interopDefaultLegacy(e) { return e && typeof e === "object" && "default" in e ? e : { "default": e }; } var fs__default = /*#__PURE__*/ _interopDefaultLegacy(fs$1); var path__default = /*#__PURE__*/ _interopDefaultLegacy(path$1); var Events__default = /*#__PURE__*/ _interopDefaultLegacy(Events); var Stream__default = /*#__PURE__*/ _interopDefaultLegacy(Stream$1$1); var require$$0__default = /*#__PURE__*/ _interopDefaultLegacy(require$$0); var assert__default = /*#__PURE__*/ _interopDefaultLegacy(assert); var require$$0__default$1 = /*#__PURE__*/ _interopDefaultLegacy(require$$0$1); var realZlib__default = /*#__PURE__*/ _interopDefaultLegacy(realZlib); var util__default = /*#__PURE__*/ _interopDefaultLegacy(util$1); var crypto__default = /*#__PURE__*/ _interopDefaultLegacy(crypto); var os__default = /*#__PURE__*/ _interopDefaultLegacy(os); var tty__default = /*#__PURE__*/ _interopDefaultLegacy(tty); var constants__default = /*#__PURE__*/ _interopDefaultLegacy(constants$1); var https__default = /*#__PURE__*/ _interopDefaultLegacy(https); var child_process__default = /*#__PURE__*/ _interopDefaultLegacy(child_process); var require$$2__default = /*#__PURE__*/ _interopDefaultLegacy(require$$2); var require$$0__default$2 = /*#__PURE__*/ _interopDefaultLegacy(require$$0$2); var require$$1__default = /*#__PURE__*/ _interopDefaultLegacy(require$$1); var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; function createCommonjsModule(fn) { var module$1 = { exports: {} }; return fn(module$1, module$1.exports), module$1.exports; } const argmap = new Map([ ["C", "cwd"], ["f", "file"], ["z", "gzip"], ["P", "preservePaths"], ["U", "unlink"], ["strip-components", "strip"], ["stripComponents", "strip"], ["keep-newer", "newer"], ["keepNewer", "newer"], ["keep-newer-files", "newer"], ["keepNewerFiles", "newer"], ["k", "keep"], ["keep-existing", "keep"], ["keepExisting", "keep"], ["m", "noMtime"], ["no-mtime", "noMtime"], ["p", "preserveOwner"], ["L", "follow"], ["h", "follow"] ]); var highLevelOpt = (opt) => opt ? Object.keys(opt).map((k) => [argmap.has(k) ? argmap.get(k) : k, opt[k]]).reduce((set, kv) => (set[kv[0]] = kv[1], set), Object.create(null)) : {}; var iterator = function(Yallist$1) { Yallist$1.prototype[Symbol.iterator] = function* () { for (let walker = this.head; walker; walker = walker.next) yield walker.value; }; }; var yallist = Yallist; Yallist.Node = Node; Yallist.create = Yallist; function Yallist(list$1) { var self$1 = this; if (!(self$1 instanceof Yallist)) self$1 = new Yallist(); self$1.tail = null; self$1.head = null; self$1.length = 0; if (list$1 && typeof list$1.forEach === "function") list$1.forEach(function(item) { self$1.push(item); }); else if (arguments.length > 0) for (var i = 0, l = arguments.length; i < l; i++) self$1.push(arguments[i]); return self$1; } Yallist.prototype.removeNode = function(node$1) { if (node$1.list !== this) throw new Error("removing node which does not belong to this list"); var next = node$1.next; var prev = node$1.prev; if (next) next.prev = prev; if (prev) prev.next = next; if (node$1 === this.head) this.head = next; if (node$1 === this.tail) this.tail = prev; node$1.list.length--; node$1.next = null; node$1.prev = null; node$1.list = null; return next; }; Yallist.prototype.unshiftNode = function(node$1) { if (node$1 === this.head) return; if (node$1.list) node$1.list.removeNode(node$1); var head = this.head; node$1.list = this; node$1.next = head; if (head) head.prev = node$1; this.head = node$1; if (!this.tail) this.tail = node$1; this.length++; }; Yallist.prototype.pushNode = function(node$1) { if (node$1 === this.tail) return; if (node$1.list) node$1.list.removeNode(node$1); var tail = this.tail; node$1.list = this; node$1.prev = tail; if (tail) tail.next = node$1; this.tail = node$1; if (!this.head) this.head = node$1; this.length++; }; Yallist.prototype.push = function() { for (var i = 0, l = arguments.length; i < l; i++) push(this, arguments[i]); return this.length; }; Yallist.prototype.unshift = function() { for (var i = 0, l = arguments.length; i < l; i++) unshift(this, arguments[i]); return this.length; }; Yallist.prototype.pop = function() { if (!this.tail) return undefined; var res = this.tail.value; this.tail = this.tail.prev; if (this.tail) this.tail.next = null; else this.head = null; this.length--; return res; }; Yallist.prototype.shift = function() { if (!this.head) return undefined; var res = this.head.value; this.head = this.head.next; if (this.head) this.head.prev = null; else this.tail = null; this.length--; return res; }; Yallist.prototype.forEach = function(fn, thisp) { thisp = thisp || this; for (var walker = this.head, i = 0; walker !== null; i++) { fn.call(thisp, walker.value, i, this); walker = walker.next; } }; Yallist.prototype.forEachReverse = function(fn, thisp) { thisp = thisp || this; for (var walker = this.tail, i = this.length - 1; walker !== null; i--) { fn.call(thisp, walker.value, i, this); walker = walker.prev; } }; Yallist.prototype.get = function(n) { for (var i = 0, walker = this.head; walker !== null && i < n; i++) walker = walker.next; if (i === n && walker !== null) return walker.value; }; Yallist.prototype.getReverse = function(n) { for (var i = 0, walker = this.tail; walker !== null && i < n; i++) walker = walker.prev; if (i === n && walker !== null) return walker.value; }; Yallist.prototype.map = function(fn, thisp) { thisp = thisp || this; var res = new Yallist(); for (var walker = this.head; walker !== null;) { res.push(fn.call(thisp, walker.value, this)); walker = walker.next; } return res; }; Yallist.prototype.mapReverse = function(fn, thisp) { thisp = thisp || this; var res = new Yallist(); for (var walker = this.tail; walker !== null;) { res.push(fn.call(thisp, walker.value, this)); walker = walker.prev; } return res; }; Yallist.prototype.reduce = function(fn, initial) { var acc; var walker = this.head; if (arguments.length > 1) acc = initial; else if (this.head) { walker = this.head.next; acc = this.head.value; } else throw new TypeError("Reduce of empty list with no initial value"); for (var i = 0; walker !== null; i++) { acc = fn(acc, walker.value, i); walker = walker.next; } return acc; }; Yallist.prototype.reduceReverse = function(fn, initial) { var acc; var walker = this.tail; if (arguments.length > 1) acc = initial; else if (this.tail) { walker = this.tail.prev; acc = this.tail.value; } else throw new TypeError("Reduce of empty list with no initial value"); for (var i = this.length - 1; walker !== null; i--) { acc = fn(acc, walker.value, i); walker = walker.prev; } return acc; }; Yallist.prototype.toArray = function() { var arr = new Array(this.length); for (var i = 0, walker = this.head; walker !== null; i++) { arr[i] = walker.value; walker = walker.next; } return arr; }; Yallist.prototype.toArrayReverse = function() { var arr = new Array(this.length); for (var i = 0, walker = this.tail; walker !== null; i++) { arr[i] = walker.value; walker = walker.prev; } return arr; }; Yallist.prototype.slice = function(from$1, to) { to = to || this.length; if (to < 0) to += this.length; from$1 = from$1 || 0; if (from$1 < 0) from$1 += this.length; var ret = new Yallist(); if (to < from$1 || to < 0) return ret; if (from$1 < 0) from$1 = 0; if (to > this.length) to = this.length; for (var i = 0, walker = this.head; walker !== null && i < from$1; i++) walker = walker.next; for (; walker !== null && i < to; i++, walker = walker.next) ret.push(walker.value); return ret; }; Yallist.prototype.sliceReverse = function(from$1, to) { to = to || this.length; if (to < 0) to += this.length; from$1 = from$1 || 0; if (from$1 < 0) from$1 += this.length; var ret = new Yallist(); if (to < from$1 || to < 0) return ret; if (from$1 < 0) from$1 = 0; if (to > this.length) to = this.length; for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) walker = walker.prev; for (; walker !== null && i > from$1; i--, walker = walker.prev) ret.push(walker.value); return ret; }; Yallist.prototype.splice = function(start, deleteCount, ...nodes) { if (start > this.length) start = this.length - 1; if (start < 0) start = this.length + start; for (var i = 0, walker = this.head; walker !== null && i < start; i++) walker = walker.next; var ret = []; for (var i = 0; walker && i < deleteCount; i++) { ret.push(walker.value); walker = this.removeNode(walker); } if (walker === null) walker = this.tail; if (walker !== this.head && walker !== this.tail) walker = walker.prev; for (var i = 0; i < nodes.length; i++) walker = insert(this, walker, nodes[i]); return ret; }; Yallist.prototype.reverse = function() { var head = this.head; var tail = this.tail; for (var walker = head; walker !== null; walker = walker.prev) { var p = walker.prev; walker.prev = walker.next; walker.next = p; } this.head = tail; this.tail = head; return this; }; function insert(self$1, node$1, value) { var inserted = node$1 === self$1.head ? new Node(value, null, node$1, self$1) : new Node(value, node$1, node$1.next, self$1); if (inserted.next === null) self$1.tail = inserted; if (inserted.prev === null) self$1.head = inserted; self$1.length++; return inserted; } function push(self$1, item) { self$1.tail = new Node(item, self$1.tail, null, self$1); if (!self$1.head) self$1.head = self$1.tail; self$1.length++; } function unshift(self$1, item) { self$1.head = new Node(item, null, self$1.head, self$1); if (!self$1.tail) self$1.tail = self$1.head; self$1.length++; } function Node(value, prev, next, list$1) { if (!(this instanceof Node)) return new Node(value, prev, next, list$1); this.list = list$1; this.value = value; if (prev) { prev.next = this; this.prev = prev; } else this.prev = null; if (next) { next.prev = this; this.next = next; } else this.next = null; } try { iterator(Yallist); } catch (er) {} const SD = require$$0__default["default"].StringDecoder; const EOF$1 = Symbol("EOF"); const MAYBE_EMIT_END = Symbol("maybeEmitEnd"); const EMITTED_END = Symbol("emittedEnd"); const EMITTING_END = Symbol("emittingEnd"); const CLOSED = Symbol("closed"); const READ$1 = Symbol("read"); const FLUSH = Symbol("flush"); const FLUSHCHUNK = Symbol("flushChunk"); const ENCODING = Symbol("encoding"); const DECODER = Symbol("decoder"); const FLOWING = Symbol("flowing"); const PAUSED = Symbol("paused"); const RESUME = Symbol("resume"); const BUFFERLENGTH = Symbol("bufferLength"); const BUFFERPUSH = Symbol("bufferPush"); const BUFFERSHIFT = Symbol("bufferShift"); const OBJECTMODE = Symbol("objectMode"); const DESTROYED = Symbol("destroyed"); const doIter = commonjsGlobal._MP_NO_ITERATOR_SYMBOLS_ !== "1"; const ASYNCITERATOR = doIter && Symbol.asyncIterator || Symbol("asyncIterator not implemented"); const ITERATOR = doIter && Symbol.iterator || Symbol("iterator not implemented"); const isEndish = (ev) => ev === "end" || ev === "finish" || ev === "prefinish"; const isArrayBuffer = (b) => b instanceof ArrayBuffer || typeof b === "object" && b.constructor && b.constructor.name === "ArrayBuffer" && b.byteLength >= 0; const isArrayBufferView = (b) => !Buffer.isBuffer(b) && ArrayBuffer.isView(b); var minipass = class Minipass extends Stream__default["default"] { constructor(options) { super(); this[FLOWING] = false; this[PAUSED] = false; this.pipes = new yallist(); this.buffer = new yallist(); this[OBJECTMODE] = options && options.objectMode || false; if (this[OBJECTMODE]) this[ENCODING] = null; else this[ENCODING] = options && options.encoding || null; if (this[ENCODING] === "buffer") this[ENCODING] = null; this[DECODER] = this[ENCODING] ? new SD(this[ENCODING]) : null; this[EOF$1] = false; this[EMITTED_END] = false; this[EMITTING_END] = false; this[CLOSED] = false; this.writable = true; this.readable = true; this[BUFFERLENGTH] = 0; this[DESTROYED] = false; } get bufferLength() { return this[BUFFERLENGTH]; } get encoding() { return this[ENCODING]; } set encoding(enc) { if (this[OBJECTMODE]) throw new Error("cannot set encoding in objectMode"); if (this[ENCODING] && enc !== this[ENCODING] && (this[DECODER] && this[DECODER].lastNeed || this[BUFFERLENGTH])) throw new Error("cannot change encoding"); if (this[ENCODING] !== enc) { this[DECODER] = enc ? new SD(enc) : null; if (this.buffer.length) this.buffer = this.buffer.map((chunk) => this[DECODER].write(chunk)); } this[ENCODING] = enc; } setEncoding(enc) { this.encoding = enc; } get objectMode() { return this[OBJECTMODE]; } set objectMode(om) { this[OBJECTMODE] = this[OBJECTMODE] || !!om; } write(chunk, encoding, cb) { if (this[EOF$1]) throw new Error("write after end"); if (this[DESTROYED]) { this.emit("error", Object.assign(new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })); return true; } if (typeof encoding === "function") cb = encoding, encoding = "utf8"; if (!encoding) encoding = "utf8"; if (!this[OBJECTMODE] && !Buffer.isBuffer(chunk)) { if (isArrayBufferView(chunk)) chunk = Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength); else if (isArrayBuffer(chunk)) chunk = Buffer.from(chunk); else if (typeof chunk !== "string") this.objectMode = true; } if (!this.objectMode && !chunk.length) { if (this[BUFFERLENGTH] !== 0) this.emit("readable"); if (cb) cb(); return this.flowing; } if (typeof chunk === "string" && !this[OBJECTMODE] && !(encoding === this[ENCODING] && !this[DECODER].lastNeed)) chunk = Buffer.from(chunk, encoding); if (Buffer.isBuffer(chunk) && this[ENCODING]) chunk = this[DECODER].write(chunk); if (this.flowing) { if (this[BUFFERLENGTH] !== 0) this[FLUSH](true); this.emit("data", chunk); } else this[BUFFERPUSH](chunk); if (this[BUFFERLENGTH] !== 0) this.emit("readable"); if (cb) cb(); return this.flowing; } read(n) { if (this[DESTROYED]) return null; try { if (this[BUFFERLENGTH] === 0 || n === 0 || n > this[BUFFERLENGTH]) return null; if (this[OBJECTMODE]) n = null; if (this.buffer.length > 1 && !this[OBJECTMODE]) if (this.encoding) this.buffer = new yallist([Array.from(this.buffer).join("")]); else this.buffer = new yallist([Buffer.concat(Array.from(this.buffer), this[BUFFERLENGTH])]); return this[READ$1](n || null, this.buffer.head.value); } finally { this[MAYBE_EMIT_END](); } } [READ$1](n, chunk) { if (n === chunk.length || n === null) this[BUFFERSHIFT](); else { this.buffer.head.value = chunk.slice(n); chunk = chunk.slice(0, n); this[BUFFERLENGTH] -= n; } this.emit("data", chunk); if (!this.buffer.length && !this[EOF$1]) this.emit("drain"); return chunk; } end(chunk, encoding, cb) { if (typeof chunk === "function") cb = chunk, chunk = null; if (typeof encoding === "function") cb = encoding, encoding = "utf8"; if (chunk) this.write(chunk, encoding); if (cb) this.once("end", cb); this[EOF$1] = true; this.writable = false; if (this.flowing || !this[PAUSED]) this[MAYBE_EMIT_END](); return this; } [RESUME]() { if (this[DESTROYED]) return; this[PAUSED] = false; this[FLOWING] = true; this.emit("resume"); if (this.buffer.length) this[FLUSH](); else if (this[EOF$1]) this[MAYBE_EMIT_END](); else this.emit("drain"); } resume() { return this[RESUME](); } pause() { this[FLOWING] = false; this[PAUSED] = true; } get destroyed() { return this[DESTROYED]; } get flowing() { return this[FLOWING]; } get paused() { return this[PAUSED]; } [BUFFERPUSH](chunk) { if (this[OBJECTMODE]) this[BUFFERLENGTH] += 1; else this[BUFFERLENGTH] += chunk.length; return this.buffer.push(chunk); } [BUFFERSHIFT]() { if (this.buffer.length) if (this[OBJECTMODE]) this[BUFFERLENGTH] -= 1; else this[BUFFERLENGTH] -= this.buffer.head.value.length; return this.buffer.shift(); } [FLUSH](noDrain) { do {} while (this[FLUSHCHUNK](this[BUFFERSHIFT]())); if (!noDrain && !this.buffer.length && !this[EOF$1]) this.emit("drain"); } [FLUSHCHUNK](chunk) { return chunk ? (this.emit("data", chunk), this.flowing) : false; } pipe(dest, opts) { if (this[DESTROYED]) return; const ended = this[EMITTED_END]; opts = opts || {}; if (dest === process.stdout || dest === process.stderr) opts.end = false; else opts.end = opts.end !== false; const p = { dest, opts, ondrain: (_) => this[RESUME]() }; this.pipes.push(p); dest.on("drain", p.ondrain); this[RESUME](); if (ended && p.opts.end) p.dest.end(); return dest; } addListener(ev, fn) { return this.on(ev, fn); } on(ev, fn) { try { return super.on(ev, fn); } finally { if (ev === "data" && !this.pipes.length && !this.flowing) this[RESUME](); else if (isEndish(ev) && this[EMITTED_END]) { super.emit(ev); this.removeAllListeners(ev); } } } get emittedEnd() { return this[EMITTED_END]; } [MAYBE_EMIT_END]() { if (!this[EMITTING_END] && !this[EMITTED_END] && !this[DESTROYED] && this.buffer.length === 0 && this[EOF$1]) { this[EMITTING_END] = true; this.emit("end"); this.emit("prefinish"); this.emit("finish"); if (this[CLOSED]) this.emit("close"); this[EMITTING_END] = false; } } emit(ev, data) { if (ev !== "error" && ev !== "close" && ev !== DESTROYED && this[DESTROYED]) return; else if (ev === "data") { if (!data) return; if (this.pipes.length) this.pipes.forEach((p) => p.dest.write(data) === false && this.pause()); } else if (ev === "end") { if (this[EMITTED_END] === true) return; this[EMITTED_END] = true; this.readable = false; if (this[DECODER]) { data = this[DECODER].end(); if (data) { this.pipes.forEach((p) => p.dest.write(data)); super.emit("data", data); } } this.pipes.forEach((p) => { p.dest.removeListener("drain", p.ondrain); if (p.opts.end) p.dest.end(); }); } else if (ev === "close") { this[CLOSED] = true; if (!this[EMITTED_END] && !this[DESTROYED]) return; } const args = new Array(arguments.length); args[0] = ev; args[1] = data; if (arguments.length > 2) for (let i = 2; i < arguments.length; i++) args[i] = arguments[i]; try { return super.emit.apply(this, args); } finally { if (!isEndish(ev)) this[MAYBE_EMIT_END](); else this.removeAllListeners(ev); } } collect() { const buf = []; if (!this[OBJECTMODE]) buf.dataLength = 0; const p = this.promise(); this.on("data", (c) => { buf.push(c); if (!this[OBJECTMODE]) buf.dataLength += c.length; }); return p.then(() => buf); } concat() { return this[OBJECTMODE] ? Promise.reject(new Error("cannot concat in objectMode")) : this.collect().then((buf) => this[OBJECTMODE] ? Promise.reject(new Error("cannot concat in objectMode")) : this[ENCODING] ? buf.join("") : Buffer.concat(buf, buf.dataLength)); } promise() { return new Promise((resolve$2, reject) => { this.on(DESTROYED, () => reject(new Error("stream destroyed"))); this.on("end", () => resolve$2()); this.on("error", (er) => reject(er)); }); } [ASYNCITERATOR]() { const next = () => { const res = this.read(); if (res !== null) return Promise.resolve({ done: false, value: res }); if (this[EOF$1]) return Promise.resolve({ done: true }); let resolve$2 = null; let reject = null; const onerr = (er) => { this.removeListener("data", ondata); this.removeListener("end", onend); reject(er); }; const ondata = (value) => { this.removeListener("error", onerr); this.removeListener("end", onend); this.pause(); resolve$2({ value, done: !!this[EOF$1] }); }; const onend = () => { this.removeListener("error", onerr); this.removeListener("data", ondata); resolve$2({ done: true }); }; const ondestroy = () => onerr(new Error("stream destroyed")); return new Promise((res$1, rej) => { reject = rej; resolve$2 = res$1; this.once(DESTROYED, ondestroy); this.once("error", onerr); this.once("end", onend); this.once("data", ondata); }); }; return { next }; } [ITERATOR]() { const next = () => { const value = this.read(); const done = value === null; return { value, done }; }; return { next }; } destroy(er) { if (this[DESTROYED]) { if (er) this.emit("error", er); else this.emit(DESTROYED); return this; } this[DESTROYED] = true; this.buffer = new yallist(); this[BUFFERLENGTH] = 0; if (typeof this.close === "function" && !this[CLOSED]) this.close(); if (er) this.emit("error", er); else this.emit(DESTROYED); return this; } static isStream(s$1) { return !!s$1 && (s$1 instanceof Minipass || s$1 instanceof Stream__default["default"] || s$1 instanceof Events__default["default"] && (typeof s$1.pipe === "function" || typeof s$1.write === "function" && typeof s$1.end === "function")); } }; const realZlibConstants = realZlib__default["default"].constants || { ZLIB_VERNUM: 4736 }; var constants$2 = Object.freeze(Object.assign(Object.create(null), { Z_NO_FLUSH: 0, Z_PARTIAL_FLUSH: 1, Z_SYNC_FLUSH: 2, Z_FULL_FLUSH: 3, Z_FINISH: 4, Z_BLOCK: 5, Z_OK: 0, Z_STREAM_END: 1, Z_NEED_DICT: 2, Z_ERRNO: -1, Z_STREAM_ERROR: -2, Z_DATA_ERROR: -3, Z_MEM_ERROR: -4, Z_BUF_ERROR: -5, Z_VERSION_ERROR: -6, Z_NO_COMPRESSION: 0, Z_BEST_SPEED: 1, Z_BEST_COMPRESSION: 9, Z_DEFAULT_COMPRESSION: -1, Z_FILTERED: 1, Z_HUFFMAN_ONLY: 2, Z_RLE: 3, Z_FIXED: 4, Z_DEFAULT_STRATEGY: 0, DEFLATE: 1, INFLATE: 2, GZIP: 3, GUNZIP: 4, DEFLATERAW: 5, INFLATERAW: 6, UNZIP: 7, BROTLI_DECODE: 8, BROTLI_ENCODE: 9, Z_MIN_WINDOWBITS: 8, Z_MAX_WINDOWBITS: 15, Z_DEFAULT_WINDOWBITS: 15, Z_MIN_CHUNK: 64, Z_MAX_CHUNK: Infinity, Z_DEFAULT_CHUNK: 16384, Z_MIN_MEMLEVEL: 1, Z_MAX_MEMLEVEL: 9, Z_DEFAULT_MEMLEVEL: 8, Z_MIN_LEVEL: -1, Z_MAX_LEVEL: 9, Z_DEFAULT_LEVEL: -1, BROTLI_OPERATION_PROCESS: 0, BROTLI_OPERATION_FLUSH: 1, BROTLI_OPERATION_FINISH: 2, BROTLI_OPERATION_EMIT_METADATA: 3, BROTLI_MODE_GENERIC: 0, BROTLI_MODE_TEXT: 1, BROTLI_MODE_FONT: 2, BROTLI_DEFAULT_MODE: 0, BROTLI_MIN_QUALITY: 0, BROTLI_MAX_QUALITY: 11, BROTLI_DEFAULT_QUALITY: 11, BROTLI_MIN_WINDOW_BITS: 10, BROTLI_MAX_WINDOW_BITS: 24, BROTLI_LARGE_MAX_WINDOW_BITS: 30, BROTLI_DEFAULT_WINDOW: 22, BROTLI_MIN_INPUT_BLOCK_BITS: 16, BROTLI_MAX_INPUT_BLOCK_BITS: 24, BROTLI_PARAM_MODE: 0, BROTLI_PARAM_QUALITY: 1, BROTLI_PARAM_LGWIN: 2, BROTLI_PARAM_LGBLOCK: 3, BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: 4, BROTLI_PARAM_SIZE_HINT: 5, BROTLI_PARAM_LARGE_WINDOW: 6, BROTLI_PARAM_NPOSTFIX: 7, BROTLI_PARAM_NDIRECT: 8, BROTLI_DECODER_RESULT_ERROR: 0, BROTLI_DECODER_RESULT_SUCCESS: 1, BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: 2, BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: 3, BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: 0, BROTLI_DECODER_PARAM_LARGE_WINDOW: 1, BROTLI_DECODER_NO_ERROR: 0, BROTLI_DECODER_SUCCESS: 1, BROTLI_DECODER_NEEDS_MORE_INPUT: 2, BROTLI_DECODER_NEEDS_MORE_OUTPUT: 3, BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: -1, BROTLI_DECODER_ERROR_FORMAT_RESERVED: -2, BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: -3, BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: -4, BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: -5, BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: -6, BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: -7, BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: -8, BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: -9, BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: -10, BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: -11, BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: -12, BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: -13, BROTLI_DECODER_ERROR_FORMAT_PADDING_1: -14, BROTLI_DECODER_ERROR_FORMAT_PADDING_2: -15, BROTLI_DECODER_ERROR_FORMAT_DISTANCE: -16, BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: -19, BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: -20, BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: -21, BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: -22, BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: -25, BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: -26, BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: -27, BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: -30, BROTLI_DECODER_ERROR_UNREACHABLE: -31 }, realZlibConstants)); var minizlib = createCommonjsModule(function(module$1, exports$1) { const Buffer$1 = require$$0__default$1["default"].Buffer; const constants$1$1 = exports$1.constants = constants$2; const OriginalBufferConcat = Buffer$1.concat; const _superWrite = Symbol("_superWrite"); class ZlibError extends Error { constructor(err) { super("zlib: " + err.message); this.code = err.code; this.errno = err.errno; if (!this.code) this.code = "ZLIB_ERROR"; this.message = "zlib: " + err.message; Error.captureStackTrace(this, this.constructor); } get name() { return "ZlibError"; } } const _opts = Symbol("opts"); const _flushFlag = Symbol("flushFlag"); const _finishFlushFlag = Symbol("finishFlushFlag"); const _fullFlushFlag = Symbol("fullFlushFlag"); const _handle = Symbol("handle"); const _onError = Symbol("onError"); const _sawError = Symbol("sawError"); const _level = Symbol("level"); const _strategy = Symbol("strategy"); const _ended$1 = Symbol("ended"); class ZlibBase extends minipass { constructor(opts, mode) { if (!opts || typeof opts !== "object") throw new TypeError("invalid options for ZlibBase constructor"); super(opts); this[_sawError] = false; this[_ended$1] = false; this[_opts] = opts; this[_flushFlag] = opts.flush; this[_finishFlushFlag] = opts.finishFlush; try { this[_handle] = new realZlib__default["default"][mode](opts); } catch (er) { throw new ZlibError(er); } this[_onError] = (err) => { if (this[_sawError]) return; this[_sawError] = true; this.close(); this.emit("error", err); }; this[_handle].on("error", (er) => this[_onError](new ZlibError(er))); this.once("end", () => this.close); } close() { if (this[_handle]) { this[_handle].close(); this[_handle] = null; this.emit("close"); } } reset() { if (!this[_sawError]) { assert__default["default"](this[_handle], "zlib binding closed"); return this[_handle].reset(); } } flush(flushFlag) { if (this.ended) return; if (typeof flushFlag !== "number") flushFlag = this[_fullFlushFlag]; this.write(Object.assign(Buffer$1.alloc(0), { [_flushFlag]: flushFlag })); } end(chunk, encoding, cb) { if (chunk) this.write(chunk, encoding); this.flush(this[_finishFlushFlag]); this[_ended$1] = true; return super.end(null, null, cb); } get ended() { return this[_ended$1]; } write(chunk, encoding, cb) { if (typeof encoding === "function") cb = encoding, encoding = "utf8"; if (typeof chunk === "string") chunk = Buffer$1.from(chunk, encoding); if (this[_sawError]) return; assert__default["default"](this[_handle], "zlib binding closed"); const nativeHandle = this[_handle]._handle; const originalNativeClose = nativeHandle.close; nativeHandle.close = () => {}; const originalClose = this[_handle].close; this[_handle].close = () => {}; Buffer$1.concat = (args) => args; let result; try { const flushFlag = typeof chunk[_flushFlag] === "number" ? chunk[_flushFlag] : this[_flushFlag]; result = this[_handle]._processChunk(chunk, flushFlag); Buffer$1.concat = OriginalBufferConcat; } catch (err) { Buffer$1.concat = OriginalBufferConcat; this[_onError](new ZlibError(err)); } finally { if (this[_handle]) { this[_handle]._handle = nativeHandle; nativeHandle.close = originalNativeClose; this[_handle].close = originalClose; this[_handle].removeAllListeners("error"); } } if (this[_handle]) this[_handle].on("error", (er) => this[_onError](new ZlibError(er))); let writeReturn; if (result) if (Array.isArray(result) && result.length > 0) { writeReturn = this[_superWrite](Buffer$1.from(result[0])); for (let i = 1; i < result.length; i++) writeReturn = this[_superWrite](result[i]); } else writeReturn = this[_superWrite](Buffer$1.from(result)); if (cb) cb(); return writeReturn; } [_superWrite](data) { return super.write(data); } } class Zlib extends ZlibBase { constructor(opts, mode) { opts = opts || {}; opts.flush = opts.flush || constants$1$1.Z_NO_FLUSH; opts.finishFlush = opts.finishFlush || constants$1$1.Z_FINISH; super(opts, mode); this[_fullFlushFlag] = constants$1$1.Z_FULL_FLUSH; this[_level] = opts.level; this[_strategy] = opts.strategy; } params(level, strategy) { if (this[_sawError]) return; if (!this[_handle]) throw new Error("cannot switch params when binding is closed"); if (!this[_handle].params) throw new Error("not supported in this implementation"); if (this[_level] !== level || this[_strategy] !== strategy) { this.flush(constants$1$1.Z_SYNC_FLUSH); assert__default["default"](this[_handle], "zlib binding closed"); const origFlush = this[_handle].flush; this[_handle].flush = (flushFlag, cb) => { this.flush(flushFlag); cb(); }; try { this[_handle].params(level, strategy); } finally { this[_handle].flush = origFlush; } if (this[_handle]) { this[_level] = level; this[_strategy] = strategy; } } } } class Deflate extends Zlib { constructor(opts) { super(opts, "Deflate"); } } class Inflate extends Zlib { constructor(opts) { super(opts, "Inflate"); } } const _portable = Symbol("_portable"); class Gzip extends Zlib { constructor(opts) { super(opts, "Gzip"); this[_portable] = opts && !!opts.portable; } [_superWrite](data) { if (!this[_portable]) return super[_superWrite](data); this[_portable] = false; data[9] = 255; return super[_superWrite](data); } } class Gunzip extends Zlib { constructor(opts) { super(opts, "Gunzip"); } } class DeflateRaw extends Zlib { constructor(opts) { super(opts, "DeflateRaw"); } } class InflateRaw extends Zlib { constructor(opts) { super(opts, "InflateRaw"); } } class Unzip extends Zlib { constructor(opts) { super(opts, "Unzip"); } } class Brotli extends ZlibBase { constructor(opts, mode) { opts = opts || {}; opts.flush = opts.flush || constants$1$1.BROTLI_OPERATION_PROCESS; opts.finishFlush = opts.finishFlush || constants$1$1.BROTLI_OPERATION_FINISH; super(opts, mode); this[_fullFlushFlag] = constants$1$1.BROTLI_OPERATION_FLUSH; } } class BrotliCompress extends Brotli { constructor(opts) { super(opts, "BrotliCompress"); } } class BrotliDecompress extends Brotli { constructor(opts) { super(opts, "BrotliDecompress"); } } exports$1.Deflate = Deflate; exports$1.Inflate = Inflate; exports$1.Gzip = Gzip; exports$1.Gunzip = Gunzip; exports$1.DeflateRaw = DeflateRaw; exports$1.InflateRaw = InflateRaw; exports$1.Unzip = Unzip; if (typeof realZlib__default["default"].BrotliCompress === "function") { exports$1.BrotliCompress = BrotliCompress; exports$1.BrotliDecompress = BrotliDecompress; } else exports$1.BrotliCompress = exports$1.BrotliDecompress = class { constructor() { throw new Error("Brotli is not supported in this version of Node.js"); } }; }); const SLURP$1 = Symbol("slurp"); var readEntry = class ReadEntry extends minipass { constructor(header$1, ex, gex) { super(); this.pause(); this.extended = ex; this.globalExtended = gex; this.header = header$1; this.startBlockSize = 512 * Math.ceil(header$1.size / 512); this.blockRemain = this.startBlockSize; this.remain = header$1.size; this.type = header$1.type; this.meta = false; this.ignore = false; switch (this.type) { case "File": case "OldFile": case "Link": case "SymbolicLink": case "CharacterDevice": case "BlockDevice": case "Directory": case "FIFO": case "ContiguousFile": case "GNUDumpDir": break; case "NextFileHasLongLinkpath": case "NextFileHasLongPath": case "OldGnuLongPath": case "GlobalExtendedHeader": case "ExtendedHeader": case "OldExtendedHeader": this.meta = true; break; default: this.ignore = true; } this.path = header$1.path; this.mode = header$1.mode; if (this.mode) this.mode = this.mode & 4095; this.uid = header$1.uid; this.gid = header$1.gid; this.uname = header$1.uname; this.gname = header$1.gname; this.size = header$1.size; this.mtime = header$1.mtime; this.atime = header$1.atime; this.ctime = header$1.ctime; this.linkpath = header$1.linkpath; this.uname = header$1.uname; this.gname = header$1.gname; if (ex) this[SLURP$1](ex); if (gex) this[SLURP$1](gex, true); } write(data) { const writeLen = data.length; if (writeLen > this.blockRemain) throw new Error("writing more to entry than is appropriate"); const r = this.remain; const br = this.blockRemain; this.remain = Math.max(0, r - writeLen); this.blockRemain = Math.max(0, br - writeLen); if (this.ignore) return true; if (r >= writeLen) return super.write(data); return super.write(data.slice(0, r)); } [SLURP$1](ex, global$1) { for (const k in ex) if (ex[k] !== null && ex[k] !== undefined && !(global$1 && k === "path")) this[k] = ex[k]; } }; var types = createCommonjsModule(function(module$1, exports$1) { exports$1.name = new Map([ ["0", "File"], ["", "OldFile"], ["1", "Link"], ["2", "SymbolicLink"], ["3", "CharacterDevice"], ["4", "BlockDevice"], ["5", "Directory"], ["6", "FIFO"], ["7", "ContiguousFile"], ["g", "GlobalExtendedHeader"], ["x", "ExtendedHeader"], ["A", "SolarisACL"], ["D", "GNUDumpDir"], ["I", "Inode"], ["K", "NextFileHasLongLinkpath"], ["L", "NextFileHasLongPath"], ["M", "ContinuationFile"], ["N", "OldGnuLongPath"], ["S", "SparseFile"], ["V", "TapeVolumeHeader"], ["X", "OldExtendedHeader"] ]); exports$1.code = new Map(Array.from(exports$1.name).map((kv) => [kv[1], kv[0]])); }); const encode = (num, buf) => { if (!Number.isSafeInteger(num)) throw Error("cannot encode number outside of javascript safe integer range"); else if (num < 0) encodeNegative(num, buf); else encodePositive(num, buf); return buf; }; const encodePositive = (num, buf) => { buf[0] = 128; for (var i = buf.length; i > 1; i--) { buf[i - 1] = num & 255; num = Math.floor(num / 256); } }; const encodeNegative = (num, buf) => { buf[0] = 255; var flipped = false; num = num * -1; for (var i = buf.length; i > 1; i--) { var byte = num & 255; num = Math.floor(num / 256); if (flipped) buf[i - 1] = onesComp(byte); else if (byte === 0) buf[i - 1] = 0; else { flipped = true; buf[i - 1] = twosComp(byte); } } }; const parse$5 = (buf) => { const pre = buf[0]; const value = pre === 128 ? pos(buf.slice(1, buf.length)) : pre === 255 ? twos(buf) : null; if (value === null) throw Error("invalid base256 encoding"); if (!Number.isSafeInteger(value)) throw Error("parsed number outside of javascript safe integer range"); return value; }; const twos = (buf) => { var len = buf.length; var sum = 0; var flipped = false; for (var i = len - 1; i > -1; i--) { var byte = buf[i]; var f; if (flipped) f = onesComp(byte); else if (byte === 0) f = byte; else { flipped = true; f = twosComp(byte); } if (f !== 0) sum -= f * Math.pow(256, len - i - 1); } return sum; }; const pos = (buf) => { var len = buf.length; var sum = 0; for (var i = len - 1; i > -1; i--) { var byte = buf[i]; if (byte !== 0) sum += byte * Math.pow(256, len - i - 1); } return sum; }; const onesComp = (byte) => (255 ^ byte) & 255; const twosComp = (byte) => (255 ^ byte) + 1 & 255; var largeNumbers = { encode, parse: parse$5 }; const pathModule = path__default["default"].posix; const SLURP = Symbol("slurp"); const TYPE = Symbol("type"); var Header = class { constructor(data, off, ex, gex) { this.cksumValid = false; this.needPax = false; this.nullBlock = false; this.block = null; this.path = null; this.mode = null; this.uid = null; this.gid = null; this.size = null; this.mtime = null; this.cksum = null; this[TYPE] = "0"; this.linkpath = null; this.uname = null; this.gname = null; this.devmaj = 0; this.devmin = 0; this.atime = null; this.ctime = null; if (Buffer.isBuffer(data)) this.decode(data, off || 0, ex, gex); else if (data) this.set(data); } decode(buf, off, ex, gex) { if (!off) off = 0; if (!buf || !(buf.length >= off + 512)) throw new Error("need 512 bytes for header"); this.path = decString(buf, off, 100); this.mode = decNumber(buf, off + 100, 8); this.uid = decNumber(buf, off + 108, 8); this.gid = decNumber(buf, off + 116, 8); this.size = decNumber(buf, off + 124, 12); this.mtime = decDate(buf, off + 136, 12); this.cksum = decNumber(buf, off + 148, 12); this[SLURP](ex); this[SLURP](gex, true); this[TYPE] = decString(buf, off + 156, 1); if (this[TYPE] === "") this[TYPE] = "0"; if (this[TYPE] === "0" && this.path.substr(-1) === "/") this[TYPE] = "5"; if (this[TYPE] === "5") this.size = 0; this.linkpath = decString(buf, off + 157, 100); if (buf.slice(off + 257, off + 265).toString() === "ustar\x0000") { this.uname = decString(buf, off + 265, 32); this.gname = decString(buf, off + 297, 32); this.devmaj = decNumber(buf, off + 329, 8); this.devmin = decNumber(buf, off + 337, 8); if (buf[off + 475] !== 0) { const prefix = decString(buf, off + 345, 155); this.path = prefix + "/" + this.path; } else { const prefix = decString(buf, off + 345, 130); if (prefix) this.path = prefix + "/" + this.path; this.atime = decDate(buf, off + 476, 12); this.ctime = decDate(buf, off + 488, 12); } } let sum = 256; for (let i = off; i < off + 148; i++) sum += buf[i]; for (let i = off + 156; i < off + 512; i++) sum += buf[i]; this.cksumValid = sum === this.cksum; if (this.cksum === null && sum === 256) this.nullBlock = true; } [SLURP](ex, global$1) { for (const k in ex) if (ex[k] !== null && ex[k] !== undefined && !(global$1 && k === "path")) this[k] = ex[k]; } encode(buf, off) { if (!buf) { buf = this.block = Buffer.alloc(512); off = 0; } if (!off) off = 0; if (!(buf.length >= off + 512)) throw new Error("need 512 bytes for header"); const prefixSize = this.ctime || this.atime ? 130 : 155; const split$2 = splitPrefix(this.path || "", prefixSize); const path$3 = split$2[0]; const prefix = split$2[1]; this.needPax = split$2[2]; this.needPax = encString(buf, off, 100, path$3) || this.needPax; this.needPax = encNumber(buf, off + 100, 8, this.mode) || this.needPax; this.needPax = encNumber(buf, off + 108, 8, this.uid) || this.needPax; this.needPax = encNumber(buf, off + 116, 8, this.gid) || this.needPax; this.needPax = encNumber(buf, off + 124, 12, this.size) || this.needPax; this.needPax = encDate(buf, off + 136, 12, this.mtime) || this.needPax; buf[off + 156] = this[TYPE].charCodeAt(0); this.needPax = encString(buf, off + 157, 100, this.linkpath) || this.needPax; buf.write("ustar\x0000", off + 257, 8); this.needPax = encString(buf, off + 265, 32, this.uname) || this.needPax; this.needPax = encString(buf, off + 297, 32, this.gname) || this.needPax; this.needPax = encNumber(buf, off + 329, 8, this.devmaj) || this.needPax; this.needPax = encNumber(buf, off + 337, 8, this.devmin) || this.needPax; this.needPax = encString(buf, off + 345, prefixSize, prefix) || this.needPax; if (buf[off + 475] !== 0) this.needPax = encString(buf, off + 345, 155, prefix) || this.needPax; else { this.needPax = encString(buf, off + 345, 130, prefix) || this.needPax; this.needPax = encDate(buf, off + 476, 12, this.atime) || this.needPax; this.needPax = encDate(buf, off + 488, 12, this.ctime) || this.needPax; } let sum = 256; for (let i = off; i < off + 148; i++) sum += buf[i]; for (let i = off + 156; i < off + 512; i++) sum += buf[i]; this.cksum = sum; encNumber(buf, off + 148, 8, this.cksum); this.cksumValid = true; return this.needPax; } set(data) { for (const i in data) if (data[i] !== null && data[i] !== undefined) this[i] = data[i]; } get type() { return types.name.get(this[TYPE]) || this[TYPE]; } get typeKey() { return this[TYPE]; } set type(type) { if (types.code.has(type)) this[TYPE] = types.code.get(type); else this[TYPE] = type; } }; const splitPrefix = (p, prefixSize) => { const pathSize = 100; let pp = p; let prefix = ""; let ret; const root = pathModule.parse(p).root || "."; if (Buffer.byteLength(pp) < pathSize) ret = [ pp, prefix, false ]; else { prefix = pathModule.dirname(pp); pp = pathModule.basename(pp); do if (Buffer.byteLength(pp) <= pathSize && Buffer.byteLength(prefix) <= prefixSize) ret = [ pp, prefix, false ]; else if (Buffer.byteLength(pp) > pathSize && Buffer.byteLength(prefix) <= prefixSize) ret = [ pp.substr(0, pathSize - 1), prefix, true ]; else { pp = pathModule.join(pathModule.basename(prefix), pp); prefix = pathModule.dirname(prefix); } while (prefix !== root && !ret); if (!ret) ret = [ p.substr(0, pathSize - 1), "", true ]; } return ret; }; const decString = (buf, off, size) => buf.slice(off, off + size).toString("utf8").replace(/\0.*/, ""); const decDate = (buf, off, size) => numToDate(decNumber(buf, off, size)); const numToDate = (num) => num === null ? null : new Date(num * 1e3); const decNumber = (buf, off, size) => buf[off] & 128 ? largeNumbers.parse(buf.slice(off, off + size)) : decSmallNumber(buf, off, size); const nanNull = (value) => isNaN(value) ? null : value; const decSmallNumber = (buf, off, size) => nanNull(parseInt(buf.slice(off, off + size).toString("utf8").replace(/\0.*$/, "").trim(), 8)); const MAXNUM = { 12: 8589934591, 8: 2097151 }; const encNumber = (buf, off, size, number) => number === null ? false : number > MAXNUM[size] || number < 0 ? (largeNumbers.encode(number, buf.slice(off, off + size)), true) : (encSmallNumber(buf, off, size, number), false); const encSmallNumber = (buf, off, size, number) => buf.write(octalString(number, size), off, size, "ascii"); const octalString = (number, size) => padOctal(Math.floor(number).toString(8), size); const padOctal = (string, size) => (string.length === size - 1 ? string : new Array(size - string.length - 1).join("0") + string + " ") + "\0"; const encDate = (buf, off, size, date) => date === null ? false : encNumber(buf, off, size, date.getTime() / 1e3); const NULLS = new Array(156).join("\0"); const encString = (buf, off, size, string) => string === null ? false : (buf.write(string + NULLS, off, size, "utf8"), string.length !== Buffer.byteLength(string) || string.length > size); var header = Header; var Pax = class { constructor(obj, global$1) { this.atime = obj.atime || null; this.charset = obj.charset || null; this.comment = obj.comment || null; this.ctime = obj.ctime || null; this.gid = obj.gid || null; this.gname = obj.gname || null; this.linkpath = obj.linkpath || null; this.mtime = obj.mtime || null; this.path = obj.path || null; this.size = obj.size || null; this.uid = obj.uid || null; this.uname = obj.uname || null; this.dev = obj.dev || null; this.ino = obj.ino || null; this.nlink = obj.nlink || null; this.global = global$1 || false; } encode() { const body = this.encodeBody(); if (body === "") return null; const bodyLen = Buffer.byteLength(body); const bufLen = 512 * Math.ceil(1 + bodyLen / 512); const buf = Buffer.allocUnsafe(bufLen); for (let i = 0; i < 512; i++) buf[i] = 0; new header({ path: ("PaxHeader/" + path__default["default"].basename(this.path)).slice(0, 99), mode: this.mode || 420, uid: this.uid || null, gid: this.gid || null, size: bodyLen, mtime: this.mtime || null, type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader", linkpath: "", uname: this.uname || "", gname: this.gname || "", devmaj: 0, devmin: 0, atime: this.atime || null, ctime: this.ctime || null }).encode(buf); buf.write(body, 512, bodyLen, "utf8"); for (let i = bodyLen + 512; i < buf.length; i++) buf[i] = 0; return buf; } encodeBody() { 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"); } encodeField(field) { if (this[field] === null || this[field] === undefined) return ""; const v = this[field] instanceof Date ? this[field].getTime() / 1e3 : this[field]; const s$1 = " " + (field === "dev" || field === "ino" || field === "nlink" ? "SCHILY." : "") + field + "=" + v + "\n"; const byteLen = Buffer.byteLength(s$1); let digits = Math.floor(Math.log(byteLen) / Math.log(10)) + 1; if (byteLen + digits >= Math.pow(10, digits)) digits += 1; const len = digits + byteLen; return len + s$1; } }; Pax.parse = (string, ex, g) => new Pax(merge(parseKV(string), ex), g); const merge = (a, b) => b ? Object.keys(a).reduce((s$1, k) => (s$1[k] = a[k], s$1), b) : a; const parseKV = (string) => string.replace(/\n$/, "").split("\n").reduce(parseKVLine, Object.create(null)); const parseKVLine = (set, line) => { const n = parseInt(line, 10); if (n !== Buffer.byteLength(line) + 1) return set; line = line.substr((n + " ").length); const kv = line.split("="); const k = kv.shift().replace(/^SCHILY\.(dev|ino|nlink)/, "$1"); if (!k) return set; const v = kv.join("="); set[k] = /^([A-Z]+\.)?([mac]|birth|creation)time$/.test(k) ? new Date(v * 1e3) : /^[0-9]+$/.test(v) ? +v : v; return set; }; var pax = Pax; var warnMixin = (Base) => class extends Base { warn(code, message, data = {}) { if (this.file) data.file = this.file; if (this.cwd) data.cwd = this.cwd; data.code = message instanceof Error && message.code || code; data.tarCode = code; if (!this.strict && data.recoverable !== false) { if (message instanceof Error) { data = Object.assign(message, data); message = message.message; } this.emit("warn", data.tarCode, message, data); } else if (message instanceof Error) this.emit("error", Object.assign(message, data)); else this.emit("error", Object.assign(new Error(`${code}: ${message}`), data)); } }; const raw = [ "|", "<", ">", "?", ":" ]; const win = raw.map((char) => String.fromCharCode(61440 + char.charCodeAt(0))); const toWin = new Map(raw.map((char, i) => [char, win[i]])); const toRaw = new Map(win.map((char, i) => [char, raw[i]])); var winchars = { encode: (s$1) => raw.reduce((s$2, c) => s$2.split(c).join(toWin.get(c)), s$1), decode: (s$1) => win.reduce((s$2, c) => s$2.split(c).join(toRaw.get(c)), s$1) }; var modeFix = (mode, isDir, portable) => { mode &= 4095; if (portable) mode = (mode | 384) & -19; if (isDir) { if (mode & 256) mode |= 64; if (mode & 32) mode |= 8; if (mode & 4) mode |= 1; }