@hot-updater/console 0.30.2 → 0.30.4

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,5 +1,5 @@
1
- import { i as Minipass, n as ReadStreamSync, r as WriteStream, t as ReadStream } from "./isaacs__fs-minipass+minipass.mjs";
2
- import { n as Unzip, r as ZstdDecompress, t as BrotliDecompress } from "./minizlib.mjs";
1
+ import { a as Minipass, i as WriteStreamSync, n as ReadStreamSync, r as WriteStream, t as ReadStream } from "./isaacs__fs-minipass+minipass.mjs";
2
+ import { a as ZstdCompress, i as Unzip, n as BrotliDecompress, o as ZstdDecompress, r as Gzip, t as BrotliCompress } from "./minizlib.mjs";
3
3
  import { n as chownrSync, t as chownr } from "./chownr.mjs";
4
4
  import { randomBytes } from "node:crypto";
5
5
  import fs from "node:fs";
@@ -7,7 +7,7 @@ import path, { basename, join, posix, win32 } from "node:path";
7
7
  import fs$1 from "node:fs/promises";
8
8
  import { EventEmitter } from "events";
9
9
  import fs$2 from "fs";
10
- import { dirname as dirname$1, parse } from "path";
10
+ import path$1, { dirname as dirname$1, parse } from "path";
11
11
  import assert from "node:assert";
12
12
  //#region ../../node_modules/.pnpm/tar@7.5.1/node_modules/tar/dist/esm/options.js
13
13
  var argmap = new Map([
@@ -36,6 +36,7 @@ var isSyncFile = (o) => !!o.sync && !!o.file;
36
36
  var isAsyncFile = (o) => !o.sync && !!o.file;
37
37
  var isSyncNoFile = (o) => !!o.sync && !o.file;
38
38
  var isAsyncNoFile = (o) => !o.sync && !o.file;
39
+ var isFile = (o) => !!o.file;
39
40
  var dealiasKey = (k) => {
40
41
  const d = argmap.get(k);
41
42
  if (d) return d;
@@ -596,8 +597,8 @@ var GEX = Symbol("globalExtendedHeader");
596
597
  var META = Symbol("meta");
597
598
  var EMITMETA = Symbol("emitMeta");
598
599
  var BUFFER = Symbol("buffer");
599
- var QUEUE = Symbol("queue");
600
- var ENDED$1 = Symbol("ended");
600
+ var QUEUE$1 = Symbol("queue");
601
+ var ENDED$2 = Symbol("ended");
601
602
  var EMITTEDEND = Symbol("emittedEnd");
602
603
  var EMIT = Symbol("emit");
603
604
  var UNZIP = Symbol("unzip");
@@ -626,7 +627,7 @@ var Parser = class extends EventEmitter {
626
627
  zstd;
627
628
  writable = true;
628
629
  readable = false;
629
- [QUEUE] = [];
630
+ [QUEUE$1] = [];
630
631
  [BUFFER];
631
632
  [READENTRY];
632
633
  [WRITEENTRY];
@@ -634,7 +635,7 @@ var Parser = class extends EventEmitter {
634
635
  [META] = "";
635
636
  [EX];
636
637
  [GEX];
637
- [ENDED$1] = false;
638
+ [ENDED$2] = false;
638
639
  [UNZIP];
639
640
  [ABORTED] = false;
640
641
  [SAW_VALID_ENTRY];
@@ -726,9 +727,9 @@ var Parser = class extends EventEmitter {
726
727
  entry.end();
727
728
  }
728
729
  if (!this[READENTRY]) {
729
- this[QUEUE].push(entry);
730
+ this[QUEUE$1].push(entry);
730
731
  this[NEXTENTRY]();
731
- } else this[QUEUE].push(entry);
732
+ } else this[QUEUE$1].push(entry);
732
733
  }
733
734
  }
734
735
  }
@@ -758,8 +759,8 @@ var Parser = class extends EventEmitter {
758
759
  }
759
760
  [NEXTENTRY]() {
760
761
  do ;
761
- while (this[PROCESSENTRY](this[QUEUE].shift()));
762
- if (!this[QUEUE].length) {
762
+ while (this[PROCESSENTRY](this[QUEUE$1].shift()));
763
+ if (!this[QUEUE$1].length) {
763
764
  const re = this[READENTRY];
764
765
  if (!re || re.flowing || re.size === re.remain) {
765
766
  if (!this[WRITING]) this.emit("drain");
@@ -788,8 +789,8 @@ while (this[PROCESSENTRY](this[QUEUE].shift()));
788
789
  return ret;
789
790
  }
790
791
  [EMIT](ev, data, extra) {
791
- if (!this[QUEUE].length && !this[READENTRY]) this.emit(ev, data, extra);
792
- else this[QUEUE].push([
792
+ if (!this[QUEUE$1].length && !this[READENTRY]) this.emit(ev, data, extra);
793
+ else this[QUEUE$1].push([
793
794
  ev,
794
795
  data,
795
796
  extra
@@ -863,7 +864,7 @@ while (this[PROCESSENTRY](this[QUEUE].shift()));
863
864
  }
864
865
  }
865
866
  const maybeBrotli = this.brotli === void 0 && !isZstd;
866
- if (this[UNZIP] === false && maybeBrotli) if (chunk.length < 512) if (this[ENDED$1]) this.brotli = true;
867
+ if (this[UNZIP] === false && maybeBrotli) if (chunk.length < 512) if (this[ENDED$2]) this.brotli = true;
867
868
  else {
868
869
  this[BUFFER] = chunk;
869
870
  /* c8 ignore next */
@@ -877,13 +878,13 @@ while (this[PROCESSENTRY](this[QUEUE].shift()));
877
878
  this.brotli = true;
878
879
  }
879
880
  if (this[UNZIP] === void 0 || this[UNZIP] === false && (this.brotli || isZstd)) {
880
- const ended = this[ENDED$1];
881
- this[ENDED$1] = false;
881
+ const ended = this[ENDED$2];
882
+ this[ENDED$2] = false;
882
883
  this[UNZIP] = this[UNZIP] === void 0 ? new Unzip({}) : isZstd ? new ZstdDecompress({}) : new BrotliDecompress({});
883
884
  this[UNZIP].on("data", (chunk) => this[CONSUMECHUNK](chunk));
884
885
  this[UNZIP].on("error", (er) => this.abort(er));
885
886
  this[UNZIP].on("end", () => {
886
- this[ENDED$1] = true;
887
+ this[ENDED$2] = true;
887
888
  this[CONSUMECHUNK]();
888
889
  });
889
890
  this[WRITING] = true;
@@ -897,8 +898,8 @@ while (this[PROCESSENTRY](this[QUEUE].shift()));
897
898
  if (this[UNZIP]) this[UNZIP].write(chunk);
898
899
  else this[CONSUMECHUNK](chunk);
899
900
  this[WRITING] = false;
900
- const ret = this[QUEUE].length ? false : this[READENTRY] ? this[READENTRY].flowing : true;
901
- if (!ret && !this[QUEUE].length) this[READENTRY]?.once("drain", () => this.emit("drain"));
901
+ const ret = this[QUEUE$1].length ? false : this[READENTRY] ? this[READENTRY].flowing : true;
902
+ if (!ret && !this[QUEUE$1].length) this[READENTRY]?.once("drain", () => this.emit("drain"));
902
903
  /* c8 ignore next */
903
904
  cb?.();
904
905
  return ret;
@@ -907,7 +908,7 @@ while (this[PROCESSENTRY](this[QUEUE].shift()));
907
908
  if (c && !this[ABORTED]) this[BUFFER] = this[BUFFER] ? Buffer.concat([this[BUFFER], c]) : c;
908
909
  }
909
910
  [MAYBEEND]() {
910
- if (this[ENDED$1] && !this[EMITTEDEND] && !this[ABORTED] && !this[CONSUMING]) {
911
+ if (this[ENDED$2] && !this[EMITTEDEND] && !this[ABORTED] && !this[CONSUMING]) {
911
912
  this[EMITTEDEND] = true;
912
913
  const entry = this[WRITEENTRY];
913
914
  if (entry && entry.blockRemain) {
@@ -937,7 +938,7 @@ while (this[PROCESSENTRY](this[QUEUE].shift()));
937
938
  }
938
939
  this[CONSUMING] = false;
939
940
  }
940
- if (!this[BUFFER] || this[ENDED$1]) this[MAYBEEND]();
941
+ if (!this[BUFFER] || this[ENDED$2]) this[MAYBEEND]();
941
942
  }
942
943
  [CONSUMECHUNKSUB](chunk) {
943
944
  let position = 0;
@@ -979,7 +980,7 @@ while (this[PROCESSENTRY](this[QUEUE].shift()));
979
980
  /* c8 ignore stop */
980
981
  this[UNZIP].end();
981
982
  } else {
982
- this[ENDED$1] = true;
983
+ this[ENDED$2] = true;
983
984
  if (this.brotli === void 0 || this.zstd === void 0) chunk = chunk || Buffer.alloc(0);
984
985
  if (chunk) this.write(chunk);
985
986
  this[MAYBEEND]();
@@ -1072,11 +1073,23 @@ var listFile = (opt, _files) => {
1072
1073
  });
1073
1074
  });
1074
1075
  };
1075
- makeCommand(listFileSync, listFile, (opt) => new Parser(opt), (opt) => new Parser(opt), (opt, files) => {
1076
+ var list = makeCommand(listFileSync, listFile, (opt) => new Parser(opt), (opt) => new Parser(opt), (opt, files) => {
1076
1077
  if (files?.length) filesFilter(opt, files);
1077
1078
  if (!opt.noResume) onReadEntryFunction(opt);
1078
1079
  });
1079
1080
  //#endregion
1081
+ //#region ../../node_modules/.pnpm/tar@7.5.1/node_modules/tar/dist/esm/mode-fix.js
1082
+ var modeFix = (mode, isDir, portable) => {
1083
+ mode &= 4095;
1084
+ if (portable) mode = (mode | 384) & -19;
1085
+ if (isDir) {
1086
+ if (mode & 256) mode |= 64;
1087
+ if (mode & 32) mode |= 8;
1088
+ if (mode & 4) mode |= 1;
1089
+ }
1090
+ return mode;
1091
+ };
1092
+ //#endregion
1080
1093
  //#region ../../node_modules/.pnpm/tar@7.5.1/node_modules/tar/dist/esm/strip-absolute-path.js
1081
1094
  var { isAbsolute, parse: parse$1 } = win32;
1082
1095
  var stripAbsolutePath = (path) => {
@@ -1101,8 +1114,1162 @@ var raw = [
1101
1114
  ];
1102
1115
  var win = raw.map((char) => String.fromCharCode(61440 + char.charCodeAt(0)));
1103
1116
  var toWin = new Map(raw.map((char, i) => [char, win[i]]));
1104
- new Map(win.map((char, i) => [char, raw[i]]));
1117
+ var toRaw = new Map(win.map((char, i) => [char, raw[i]]));
1105
1118
  var encode = (s) => raw.reduce((s, c) => s.split(c).join(toWin.get(c)), s);
1119
+ var decode = (s) => win.reduce((s, c) => s.split(c).join(toRaw.get(c)), s);
1120
+ //#endregion
1121
+ //#region ../../node_modules/.pnpm/tar@7.5.1/node_modules/tar/dist/esm/write-entry.js
1122
+ var prefixPath = (path, prefix) => {
1123
+ if (!prefix) return normalizeWindowsPath(path);
1124
+ path = normalizeWindowsPath(path).replace(/^\.(\/|$)/, "");
1125
+ return stripTrailingSlashes(prefix) + "/" + path;
1126
+ };
1127
+ var maxReadSize = 16 * 1024 * 1024;
1128
+ var PROCESS$1 = Symbol("process");
1129
+ var FILE$1 = Symbol("file");
1130
+ var DIRECTORY$1 = Symbol("directory");
1131
+ var SYMLINK$1 = Symbol("symlink");
1132
+ var HARDLINK$1 = Symbol("hardlink");
1133
+ var HEADER = Symbol("header");
1134
+ var READ = Symbol("read");
1135
+ var LSTAT = Symbol("lstat");
1136
+ var ONLSTAT = Symbol("onlstat");
1137
+ var ONREAD = Symbol("onread");
1138
+ var ONREADLINK = Symbol("onreadlink");
1139
+ var OPENFILE = Symbol("openfile");
1140
+ var ONOPENFILE = Symbol("onopenfile");
1141
+ var CLOSE = Symbol("close");
1142
+ var MODE = Symbol("mode");
1143
+ var AWAITDRAIN = Symbol("awaitDrain");
1144
+ var ONDRAIN$1 = Symbol("ondrain");
1145
+ var PREFIX = Symbol("prefix");
1146
+ var WriteEntry = class extends Minipass {
1147
+ path;
1148
+ portable;
1149
+ myuid = process.getuid && process.getuid() || 0;
1150
+ myuser = process.env.USER || "";
1151
+ maxReadSize;
1152
+ linkCache;
1153
+ statCache;
1154
+ preservePaths;
1155
+ cwd;
1156
+ strict;
1157
+ mtime;
1158
+ noPax;
1159
+ noMtime;
1160
+ prefix;
1161
+ fd;
1162
+ blockLen = 0;
1163
+ blockRemain = 0;
1164
+ buf;
1165
+ pos = 0;
1166
+ remain = 0;
1167
+ length = 0;
1168
+ offset = 0;
1169
+ win32;
1170
+ absolute;
1171
+ header;
1172
+ type;
1173
+ linkpath;
1174
+ stat;
1175
+ onWriteEntry;
1176
+ #hadError = false;
1177
+ constructor(p, opt_ = {}) {
1178
+ const opt = dealias(opt_);
1179
+ super();
1180
+ this.path = normalizeWindowsPath(p);
1181
+ this.portable = !!opt.portable;
1182
+ this.maxReadSize = opt.maxReadSize || maxReadSize;
1183
+ this.linkCache = opt.linkCache || /* @__PURE__ */ new Map();
1184
+ this.statCache = opt.statCache || /* @__PURE__ */ new Map();
1185
+ this.preservePaths = !!opt.preservePaths;
1186
+ this.cwd = normalizeWindowsPath(opt.cwd || process.cwd());
1187
+ this.strict = !!opt.strict;
1188
+ this.noPax = !!opt.noPax;
1189
+ this.noMtime = !!opt.noMtime;
1190
+ this.mtime = opt.mtime;
1191
+ this.prefix = opt.prefix ? normalizeWindowsPath(opt.prefix) : void 0;
1192
+ this.onWriteEntry = opt.onWriteEntry;
1193
+ if (typeof opt.onwarn === "function") this.on("warn", opt.onwarn);
1194
+ let pathWarn = false;
1195
+ if (!this.preservePaths) {
1196
+ const [root, stripped] = stripAbsolutePath(this.path);
1197
+ if (root && typeof stripped === "string") {
1198
+ this.path = stripped;
1199
+ pathWarn = root;
1200
+ }
1201
+ }
1202
+ this.win32 = !!opt.win32 || process.platform === "win32";
1203
+ if (this.win32) {
1204
+ this.path = decode(this.path.replace(/\\/g, "/"));
1205
+ p = p.replace(/\\/g, "/");
1206
+ }
1207
+ this.absolute = normalizeWindowsPath(opt.absolute || path$1.resolve(this.cwd, p));
1208
+ if (this.path === "") this.path = "./";
1209
+ if (pathWarn) this.warn("TAR_ENTRY_INFO", `stripping ${pathWarn} from absolute path`, {
1210
+ entry: this,
1211
+ path: pathWarn + this.path
1212
+ });
1213
+ const cs = this.statCache.get(this.absolute);
1214
+ if (cs) this[ONLSTAT](cs);
1215
+ else this[LSTAT]();
1216
+ }
1217
+ warn(code, message, data = {}) {
1218
+ return warnMethod(this, code, message, data);
1219
+ }
1220
+ emit(ev, ...data) {
1221
+ if (ev === "error") this.#hadError = true;
1222
+ return super.emit(ev, ...data);
1223
+ }
1224
+ [LSTAT]() {
1225
+ fs$2.lstat(this.absolute, (er, stat) => {
1226
+ if (er) return this.emit("error", er);
1227
+ this[ONLSTAT](stat);
1228
+ });
1229
+ }
1230
+ [ONLSTAT](stat) {
1231
+ this.statCache.set(this.absolute, stat);
1232
+ this.stat = stat;
1233
+ if (!stat.isFile()) stat.size = 0;
1234
+ this.type = getType(stat);
1235
+ this.emit("stat", stat);
1236
+ this[PROCESS$1]();
1237
+ }
1238
+ [PROCESS$1]() {
1239
+ switch (this.type) {
1240
+ case "File": return this[FILE$1]();
1241
+ case "Directory": return this[DIRECTORY$1]();
1242
+ case "SymbolicLink": return this[SYMLINK$1]();
1243
+ default: return this.end();
1244
+ }
1245
+ }
1246
+ [MODE](mode) {
1247
+ return modeFix(mode, this.type === "Directory", this.portable);
1248
+ }
1249
+ [PREFIX](path) {
1250
+ return prefixPath(path, this.prefix);
1251
+ }
1252
+ [HEADER]() {
1253
+ /* c8 ignore start */
1254
+ if (!this.stat) throw new Error("cannot write header before stat");
1255
+ /* c8 ignore stop */
1256
+ if (this.type === "Directory" && this.portable) this.noMtime = true;
1257
+ this.onWriteEntry?.(this);
1258
+ this.header = new Header({
1259
+ path: this[PREFIX](this.path),
1260
+ linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[PREFIX](this.linkpath) : this.linkpath,
1261
+ mode: this[MODE](this.stat.mode),
1262
+ uid: this.portable ? void 0 : this.stat.uid,
1263
+ gid: this.portable ? void 0 : this.stat.gid,
1264
+ size: this.stat.size,
1265
+ mtime: this.noMtime ? void 0 : this.mtime || this.stat.mtime,
1266
+ type: this.type === "Unsupported" ? void 0 : this.type,
1267
+ uname: this.portable ? void 0 : this.stat.uid === this.myuid ? this.myuser : "",
1268
+ atime: this.portable ? void 0 : this.stat.atime,
1269
+ ctime: this.portable ? void 0 : this.stat.ctime
1270
+ });
1271
+ if (this.header.encode() && !this.noPax) super.write(new Pax({
1272
+ atime: this.portable ? void 0 : this.header.atime,
1273
+ ctime: this.portable ? void 0 : this.header.ctime,
1274
+ gid: this.portable ? void 0 : this.header.gid,
1275
+ mtime: this.noMtime ? void 0 : this.mtime || this.header.mtime,
1276
+ path: this[PREFIX](this.path),
1277
+ linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[PREFIX](this.linkpath) : this.linkpath,
1278
+ size: this.header.size,
1279
+ uid: this.portable ? void 0 : this.header.uid,
1280
+ uname: this.portable ? void 0 : this.header.uname,
1281
+ dev: this.portable ? void 0 : this.stat.dev,
1282
+ ino: this.portable ? void 0 : this.stat.ino,
1283
+ nlink: this.portable ? void 0 : this.stat.nlink
1284
+ }).encode());
1285
+ const block = this.header?.block;
1286
+ /* c8 ignore start */
1287
+ if (!block) throw new Error("failed to encode header");
1288
+ /* c8 ignore stop */
1289
+ super.write(block);
1290
+ }
1291
+ [DIRECTORY$1]() {
1292
+ /* c8 ignore start */
1293
+ if (!this.stat) throw new Error("cannot create directory entry without stat");
1294
+ /* c8 ignore stop */
1295
+ if (this.path.slice(-1) !== "/") this.path += "/";
1296
+ this.stat.size = 0;
1297
+ this[HEADER]();
1298
+ this.end();
1299
+ }
1300
+ [SYMLINK$1]() {
1301
+ fs$2.readlink(this.absolute, (er, linkpath) => {
1302
+ if (er) return this.emit("error", er);
1303
+ this[ONREADLINK](linkpath);
1304
+ });
1305
+ }
1306
+ [ONREADLINK](linkpath) {
1307
+ this.linkpath = normalizeWindowsPath(linkpath);
1308
+ this[HEADER]();
1309
+ this.end();
1310
+ }
1311
+ [HARDLINK$1](linkpath) {
1312
+ /* c8 ignore start */
1313
+ if (!this.stat) throw new Error("cannot create link entry without stat");
1314
+ /* c8 ignore stop */
1315
+ this.type = "Link";
1316
+ this.linkpath = normalizeWindowsPath(path$1.relative(this.cwd, linkpath));
1317
+ this.stat.size = 0;
1318
+ this[HEADER]();
1319
+ this.end();
1320
+ }
1321
+ [FILE$1]() {
1322
+ /* c8 ignore start */
1323
+ if (!this.stat) throw new Error("cannot create file entry without stat");
1324
+ /* c8 ignore stop */
1325
+ if (this.stat.nlink > 1) {
1326
+ const linkKey = `${this.stat.dev}:${this.stat.ino}`;
1327
+ const linkpath = this.linkCache.get(linkKey);
1328
+ if (linkpath?.indexOf(this.cwd) === 0) return this[HARDLINK$1](linkpath);
1329
+ this.linkCache.set(linkKey, this.absolute);
1330
+ }
1331
+ this[HEADER]();
1332
+ if (this.stat.size === 0) return this.end();
1333
+ this[OPENFILE]();
1334
+ }
1335
+ [OPENFILE]() {
1336
+ fs$2.open(this.absolute, "r", (er, fd) => {
1337
+ if (er) return this.emit("error", er);
1338
+ this[ONOPENFILE](fd);
1339
+ });
1340
+ }
1341
+ [ONOPENFILE](fd) {
1342
+ this.fd = fd;
1343
+ if (this.#hadError) return this[CLOSE]();
1344
+ /* c8 ignore start */
1345
+ if (!this.stat) throw new Error("should stat before calling onopenfile");
1346
+ /* c8 ignore start */
1347
+ this.blockLen = 512 * Math.ceil(this.stat.size / 512);
1348
+ this.blockRemain = this.blockLen;
1349
+ const bufLen = Math.min(this.blockLen, this.maxReadSize);
1350
+ this.buf = Buffer.allocUnsafe(bufLen);
1351
+ this.offset = 0;
1352
+ this.pos = 0;
1353
+ this.remain = this.stat.size;
1354
+ this.length = this.buf.length;
1355
+ this[READ]();
1356
+ }
1357
+ [READ]() {
1358
+ const { fd, buf, offset, length, pos } = this;
1359
+ if (fd === void 0 || buf === void 0) throw new Error("cannot read file without first opening");
1360
+ fs$2.read(fd, buf, offset, length, pos, (er, bytesRead) => {
1361
+ if (er) return this[CLOSE](() => this.emit("error", er));
1362
+ this[ONREAD](bytesRead);
1363
+ });
1364
+ }
1365
+ /* c8 ignore start */
1366
+ [CLOSE](cb = () => {}) {
1367
+ /* c8 ignore stop */
1368
+ if (this.fd !== void 0) fs$2.close(this.fd, cb);
1369
+ }
1370
+ [ONREAD](bytesRead) {
1371
+ if (bytesRead <= 0 && this.remain > 0) {
1372
+ const er = Object.assign(/* @__PURE__ */ new Error("encountered unexpected EOF"), {
1373
+ path: this.absolute,
1374
+ syscall: "read",
1375
+ code: "EOF"
1376
+ });
1377
+ return this[CLOSE](() => this.emit("error", er));
1378
+ }
1379
+ if (bytesRead > this.remain) {
1380
+ const er = Object.assign(/* @__PURE__ */ new Error("did not encounter expected EOF"), {
1381
+ path: this.absolute,
1382
+ syscall: "read",
1383
+ code: "EOF"
1384
+ });
1385
+ return this[CLOSE](() => this.emit("error", er));
1386
+ }
1387
+ /* c8 ignore start */
1388
+ if (!this.buf) throw new Error("should have created buffer prior to reading");
1389
+ /* c8 ignore stop */
1390
+ if (bytesRead === this.remain) for (let i = bytesRead; i < this.length && bytesRead < this.blockRemain; i++) {
1391
+ this.buf[i + this.offset] = 0;
1392
+ bytesRead++;
1393
+ this.remain++;
1394
+ }
1395
+ const chunk = this.offset === 0 && bytesRead === this.buf.length ? this.buf : this.buf.subarray(this.offset, this.offset + bytesRead);
1396
+ if (!this.write(chunk)) this[AWAITDRAIN](() => this[ONDRAIN$1]());
1397
+ else this[ONDRAIN$1]();
1398
+ }
1399
+ [AWAITDRAIN](cb) {
1400
+ this.once("drain", cb);
1401
+ }
1402
+ write(chunk, encoding, cb) {
1403
+ /* c8 ignore start - just junk to comply with NodeJS.WritableStream */
1404
+ if (typeof encoding === "function") {
1405
+ cb = encoding;
1406
+ encoding = void 0;
1407
+ }
1408
+ if (typeof chunk === "string") chunk = Buffer.from(chunk, typeof encoding === "string" ? encoding : "utf8");
1409
+ /* c8 ignore stop */
1410
+ if (this.blockRemain < chunk.length) {
1411
+ const er = Object.assign(/* @__PURE__ */ new Error("writing more data than expected"), { path: this.absolute });
1412
+ return this.emit("error", er);
1413
+ }
1414
+ this.remain -= chunk.length;
1415
+ this.blockRemain -= chunk.length;
1416
+ this.pos += chunk.length;
1417
+ this.offset += chunk.length;
1418
+ return super.write(chunk, null, cb);
1419
+ }
1420
+ [ONDRAIN$1]() {
1421
+ if (!this.remain) {
1422
+ if (this.blockRemain) super.write(Buffer.alloc(this.blockRemain));
1423
+ return this[CLOSE]((er) => er ? this.emit("error", er) : this.end());
1424
+ }
1425
+ /* c8 ignore start */
1426
+ if (!this.buf) throw new Error("buffer lost somehow in ONDRAIN");
1427
+ /* c8 ignore stop */
1428
+ if (this.offset >= this.length) {
1429
+ this.buf = Buffer.allocUnsafe(Math.min(this.blockRemain, this.buf.length));
1430
+ this.offset = 0;
1431
+ }
1432
+ this.length = this.buf.length - this.offset;
1433
+ this[READ]();
1434
+ }
1435
+ };
1436
+ var WriteEntrySync = class extends WriteEntry {
1437
+ sync = true;
1438
+ [LSTAT]() {
1439
+ this[ONLSTAT](fs$2.lstatSync(this.absolute));
1440
+ }
1441
+ [SYMLINK$1]() {
1442
+ this[ONREADLINK](fs$2.readlinkSync(this.absolute));
1443
+ }
1444
+ [OPENFILE]() {
1445
+ this[ONOPENFILE](fs$2.openSync(this.absolute, "r"));
1446
+ }
1447
+ [READ]() {
1448
+ let threw = true;
1449
+ try {
1450
+ const { fd, buf, offset, length, pos } = this;
1451
+ /* c8 ignore start */
1452
+ if (fd === void 0 || buf === void 0) throw new Error("fd and buf must be set in READ method");
1453
+ /* c8 ignore stop */
1454
+ const bytesRead = fs$2.readSync(fd, buf, offset, length, pos);
1455
+ this[ONREAD](bytesRead);
1456
+ threw = false;
1457
+ } finally {
1458
+ if (threw) try {
1459
+ this[CLOSE](() => {});
1460
+ } catch (er) {}
1461
+ }
1462
+ }
1463
+ [AWAITDRAIN](cb) {
1464
+ cb();
1465
+ }
1466
+ /* c8 ignore start */
1467
+ [CLOSE](cb = () => {}) {
1468
+ /* c8 ignore stop */
1469
+ if (this.fd !== void 0) fs$2.closeSync(this.fd);
1470
+ cb();
1471
+ }
1472
+ };
1473
+ var WriteEntryTar = class extends Minipass {
1474
+ blockLen = 0;
1475
+ blockRemain = 0;
1476
+ buf = 0;
1477
+ pos = 0;
1478
+ remain = 0;
1479
+ length = 0;
1480
+ preservePaths;
1481
+ portable;
1482
+ strict;
1483
+ noPax;
1484
+ noMtime;
1485
+ readEntry;
1486
+ type;
1487
+ prefix;
1488
+ path;
1489
+ mode;
1490
+ uid;
1491
+ gid;
1492
+ uname;
1493
+ gname;
1494
+ header;
1495
+ mtime;
1496
+ atime;
1497
+ ctime;
1498
+ linkpath;
1499
+ size;
1500
+ onWriteEntry;
1501
+ warn(code, message, data = {}) {
1502
+ return warnMethod(this, code, message, data);
1503
+ }
1504
+ constructor(readEntry, opt_ = {}) {
1505
+ const opt = dealias(opt_);
1506
+ super();
1507
+ this.preservePaths = !!opt.preservePaths;
1508
+ this.portable = !!opt.portable;
1509
+ this.strict = !!opt.strict;
1510
+ this.noPax = !!opt.noPax;
1511
+ this.noMtime = !!opt.noMtime;
1512
+ this.onWriteEntry = opt.onWriteEntry;
1513
+ this.readEntry = readEntry;
1514
+ const { type } = readEntry;
1515
+ /* c8 ignore start */
1516
+ if (type === "Unsupported") throw new Error("writing entry that should be ignored");
1517
+ /* c8 ignore stop */
1518
+ this.type = type;
1519
+ if (this.type === "Directory" && this.portable) this.noMtime = true;
1520
+ this.prefix = opt.prefix;
1521
+ this.path = normalizeWindowsPath(readEntry.path);
1522
+ this.mode = readEntry.mode !== void 0 ? this[MODE](readEntry.mode) : void 0;
1523
+ this.uid = this.portable ? void 0 : readEntry.uid;
1524
+ this.gid = this.portable ? void 0 : readEntry.gid;
1525
+ this.uname = this.portable ? void 0 : readEntry.uname;
1526
+ this.gname = this.portable ? void 0 : readEntry.gname;
1527
+ this.size = readEntry.size;
1528
+ this.mtime = this.noMtime ? void 0 : opt.mtime || readEntry.mtime;
1529
+ this.atime = this.portable ? void 0 : readEntry.atime;
1530
+ this.ctime = this.portable ? void 0 : readEntry.ctime;
1531
+ this.linkpath = readEntry.linkpath !== void 0 ? normalizeWindowsPath(readEntry.linkpath) : void 0;
1532
+ if (typeof opt.onwarn === "function") this.on("warn", opt.onwarn);
1533
+ let pathWarn = false;
1534
+ if (!this.preservePaths) {
1535
+ const [root, stripped] = stripAbsolutePath(this.path);
1536
+ if (root && typeof stripped === "string") {
1537
+ this.path = stripped;
1538
+ pathWarn = root;
1539
+ }
1540
+ }
1541
+ this.remain = readEntry.size;
1542
+ this.blockRemain = readEntry.startBlockSize;
1543
+ this.onWriteEntry?.(this);
1544
+ this.header = new Header({
1545
+ path: this[PREFIX](this.path),
1546
+ linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[PREFIX](this.linkpath) : this.linkpath,
1547
+ mode: this.mode,
1548
+ uid: this.portable ? void 0 : this.uid,
1549
+ gid: this.portable ? void 0 : this.gid,
1550
+ size: this.size,
1551
+ mtime: this.noMtime ? void 0 : this.mtime,
1552
+ type: this.type,
1553
+ uname: this.portable ? void 0 : this.uname,
1554
+ atime: this.portable ? void 0 : this.atime,
1555
+ ctime: this.portable ? void 0 : this.ctime
1556
+ });
1557
+ if (pathWarn) this.warn("TAR_ENTRY_INFO", `stripping ${pathWarn} from absolute path`, {
1558
+ entry: this,
1559
+ path: pathWarn + this.path
1560
+ });
1561
+ if (this.header.encode() && !this.noPax) super.write(new Pax({
1562
+ atime: this.portable ? void 0 : this.atime,
1563
+ ctime: this.portable ? void 0 : this.ctime,
1564
+ gid: this.portable ? void 0 : this.gid,
1565
+ mtime: this.noMtime ? void 0 : this.mtime,
1566
+ path: this[PREFIX](this.path),
1567
+ linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[PREFIX](this.linkpath) : this.linkpath,
1568
+ size: this.size,
1569
+ uid: this.portable ? void 0 : this.uid,
1570
+ uname: this.portable ? void 0 : this.uname,
1571
+ dev: this.portable ? void 0 : this.readEntry.dev,
1572
+ ino: this.portable ? void 0 : this.readEntry.ino,
1573
+ nlink: this.portable ? void 0 : this.readEntry.nlink
1574
+ }).encode());
1575
+ const b = this.header?.block;
1576
+ /* c8 ignore start */
1577
+ if (!b) throw new Error("failed to encode header");
1578
+ /* c8 ignore stop */
1579
+ super.write(b);
1580
+ readEntry.pipe(this);
1581
+ }
1582
+ [PREFIX](path) {
1583
+ return prefixPath(path, this.prefix);
1584
+ }
1585
+ [MODE](mode) {
1586
+ return modeFix(mode, this.type === "Directory", this.portable);
1587
+ }
1588
+ write(chunk, encoding, cb) {
1589
+ /* c8 ignore start - just junk to comply with NodeJS.WritableStream */
1590
+ if (typeof encoding === "function") {
1591
+ cb = encoding;
1592
+ encoding = void 0;
1593
+ }
1594
+ if (typeof chunk === "string") chunk = Buffer.from(chunk, typeof encoding === "string" ? encoding : "utf8");
1595
+ /* c8 ignore stop */
1596
+ const writeLen = chunk.length;
1597
+ if (writeLen > this.blockRemain) throw new Error("writing more to entry than is appropriate");
1598
+ this.blockRemain -= writeLen;
1599
+ return super.write(chunk, cb);
1600
+ }
1601
+ end(chunk, encoding, cb) {
1602
+ if (this.blockRemain) super.write(Buffer.alloc(this.blockRemain));
1603
+ /* c8 ignore start - just junk to comply with NodeJS.WritableStream */
1604
+ if (typeof chunk === "function") {
1605
+ cb = chunk;
1606
+ encoding = void 0;
1607
+ chunk = void 0;
1608
+ }
1609
+ if (typeof encoding === "function") {
1610
+ cb = encoding;
1611
+ encoding = void 0;
1612
+ }
1613
+ if (typeof chunk === "string") chunk = Buffer.from(chunk, encoding ?? "utf8");
1614
+ if (cb) this.once("finish", cb);
1615
+ chunk ? super.end(chunk, cb) : super.end(cb);
1616
+ /* c8 ignore stop */
1617
+ return this;
1618
+ }
1619
+ };
1620
+ var getType = (stat) => stat.isFile() ? "File" : stat.isDirectory() ? "Directory" : stat.isSymbolicLink() ? "SymbolicLink" : "Unsupported";
1621
+ //#endregion
1622
+ //#region ../../node_modules/.pnpm/yallist@5.0.0/node_modules/yallist/dist/esm/index.js
1623
+ var Yallist = class Yallist {
1624
+ tail;
1625
+ head;
1626
+ length = 0;
1627
+ static create(list = []) {
1628
+ return new Yallist(list);
1629
+ }
1630
+ constructor(list = []) {
1631
+ for (const item of list) this.push(item);
1632
+ }
1633
+ *[Symbol.iterator]() {
1634
+ for (let walker = this.head; walker; walker = walker.next) yield walker.value;
1635
+ }
1636
+ removeNode(node) {
1637
+ if (node.list !== this) throw new Error("removing node which does not belong to this list");
1638
+ const next = node.next;
1639
+ const prev = node.prev;
1640
+ if (next) next.prev = prev;
1641
+ if (prev) prev.next = next;
1642
+ if (node === this.head) this.head = next;
1643
+ if (node === this.tail) this.tail = prev;
1644
+ this.length--;
1645
+ node.next = void 0;
1646
+ node.prev = void 0;
1647
+ node.list = void 0;
1648
+ return next;
1649
+ }
1650
+ unshiftNode(node) {
1651
+ if (node === this.head) return;
1652
+ if (node.list) node.list.removeNode(node);
1653
+ const head = this.head;
1654
+ node.list = this;
1655
+ node.next = head;
1656
+ if (head) head.prev = node;
1657
+ this.head = node;
1658
+ if (!this.tail) this.tail = node;
1659
+ this.length++;
1660
+ }
1661
+ pushNode(node) {
1662
+ if (node === this.tail) return;
1663
+ if (node.list) node.list.removeNode(node);
1664
+ const tail = this.tail;
1665
+ node.list = this;
1666
+ node.prev = tail;
1667
+ if (tail) tail.next = node;
1668
+ this.tail = node;
1669
+ if (!this.head) this.head = node;
1670
+ this.length++;
1671
+ }
1672
+ push(...args) {
1673
+ for (let i = 0, l = args.length; i < l; i++) push(this, args[i]);
1674
+ return this.length;
1675
+ }
1676
+ unshift(...args) {
1677
+ for (var i = 0, l = args.length; i < l; i++) unshift(this, args[i]);
1678
+ return this.length;
1679
+ }
1680
+ pop() {
1681
+ if (!this.tail) return;
1682
+ const res = this.tail.value;
1683
+ const t = this.tail;
1684
+ this.tail = this.tail.prev;
1685
+ if (this.tail) this.tail.next = void 0;
1686
+ else this.head = void 0;
1687
+ t.list = void 0;
1688
+ this.length--;
1689
+ return res;
1690
+ }
1691
+ shift() {
1692
+ if (!this.head) return;
1693
+ const res = this.head.value;
1694
+ const h = this.head;
1695
+ this.head = this.head.next;
1696
+ if (this.head) this.head.prev = void 0;
1697
+ else this.tail = void 0;
1698
+ h.list = void 0;
1699
+ this.length--;
1700
+ return res;
1701
+ }
1702
+ forEach(fn, thisp) {
1703
+ thisp = thisp || this;
1704
+ for (let walker = this.head, i = 0; !!walker; i++) {
1705
+ fn.call(thisp, walker.value, i, this);
1706
+ walker = walker.next;
1707
+ }
1708
+ }
1709
+ forEachReverse(fn, thisp) {
1710
+ thisp = thisp || this;
1711
+ for (let walker = this.tail, i = this.length - 1; !!walker; i--) {
1712
+ fn.call(thisp, walker.value, i, this);
1713
+ walker = walker.prev;
1714
+ }
1715
+ }
1716
+ get(n) {
1717
+ let i = 0;
1718
+ let walker = this.head;
1719
+ for (; !!walker && i < n; i++) walker = walker.next;
1720
+ if (i === n && !!walker) return walker.value;
1721
+ }
1722
+ getReverse(n) {
1723
+ let i = 0;
1724
+ let walker = this.tail;
1725
+ for (; !!walker && i < n; i++) walker = walker.prev;
1726
+ if (i === n && !!walker) return walker.value;
1727
+ }
1728
+ map(fn, thisp) {
1729
+ thisp = thisp || this;
1730
+ const res = new Yallist();
1731
+ for (let walker = this.head; !!walker;) {
1732
+ res.push(fn.call(thisp, walker.value, this));
1733
+ walker = walker.next;
1734
+ }
1735
+ return res;
1736
+ }
1737
+ mapReverse(fn, thisp) {
1738
+ thisp = thisp || this;
1739
+ var res = new Yallist();
1740
+ for (let walker = this.tail; !!walker;) {
1741
+ res.push(fn.call(thisp, walker.value, this));
1742
+ walker = walker.prev;
1743
+ }
1744
+ return res;
1745
+ }
1746
+ reduce(fn, initial) {
1747
+ let acc;
1748
+ let walker = this.head;
1749
+ if (arguments.length > 1) acc = initial;
1750
+ else if (this.head) {
1751
+ walker = this.head.next;
1752
+ acc = this.head.value;
1753
+ } else throw new TypeError("Reduce of empty list with no initial value");
1754
+ for (var i = 0; !!walker; i++) {
1755
+ acc = fn(acc, walker.value, i);
1756
+ walker = walker.next;
1757
+ }
1758
+ return acc;
1759
+ }
1760
+ reduceReverse(fn, initial) {
1761
+ let acc;
1762
+ let walker = this.tail;
1763
+ if (arguments.length > 1) acc = initial;
1764
+ else if (this.tail) {
1765
+ walker = this.tail.prev;
1766
+ acc = this.tail.value;
1767
+ } else throw new TypeError("Reduce of empty list with no initial value");
1768
+ for (let i = this.length - 1; !!walker; i--) {
1769
+ acc = fn(acc, walker.value, i);
1770
+ walker = walker.prev;
1771
+ }
1772
+ return acc;
1773
+ }
1774
+ toArray() {
1775
+ const arr = new Array(this.length);
1776
+ for (let i = 0, walker = this.head; !!walker; i++) {
1777
+ arr[i] = walker.value;
1778
+ walker = walker.next;
1779
+ }
1780
+ return arr;
1781
+ }
1782
+ toArrayReverse() {
1783
+ const arr = new Array(this.length);
1784
+ for (let i = 0, walker = this.tail; !!walker; i++) {
1785
+ arr[i] = walker.value;
1786
+ walker = walker.prev;
1787
+ }
1788
+ return arr;
1789
+ }
1790
+ slice(from = 0, to = this.length) {
1791
+ if (to < 0) to += this.length;
1792
+ if (from < 0) from += this.length;
1793
+ const ret = new Yallist();
1794
+ if (to < from || to < 0) return ret;
1795
+ if (from < 0) from = 0;
1796
+ if (to > this.length) to = this.length;
1797
+ let walker = this.head;
1798
+ let i = 0;
1799
+ for (i = 0; !!walker && i < from; i++) walker = walker.next;
1800
+ for (; !!walker && i < to; i++, walker = walker.next) ret.push(walker.value);
1801
+ return ret;
1802
+ }
1803
+ sliceReverse(from = 0, to = this.length) {
1804
+ if (to < 0) to += this.length;
1805
+ if (from < 0) from += this.length;
1806
+ const ret = new Yallist();
1807
+ if (to < from || to < 0) return ret;
1808
+ if (from < 0) from = 0;
1809
+ if (to > this.length) to = this.length;
1810
+ let i = this.length;
1811
+ let walker = this.tail;
1812
+ for (; !!walker && i > to; i--) walker = walker.prev;
1813
+ for (; !!walker && i > from; i--, walker = walker.prev) ret.push(walker.value);
1814
+ return ret;
1815
+ }
1816
+ splice(start, deleteCount = 0, ...nodes) {
1817
+ if (start > this.length) start = this.length - 1;
1818
+ if (start < 0) start = this.length + start;
1819
+ let walker = this.head;
1820
+ for (let i = 0; !!walker && i < start; i++) walker = walker.next;
1821
+ const ret = [];
1822
+ for (let i = 0; !!walker && i < deleteCount; i++) {
1823
+ ret.push(walker.value);
1824
+ walker = this.removeNode(walker);
1825
+ }
1826
+ if (!walker) walker = this.tail;
1827
+ else if (walker !== this.tail) walker = walker.prev;
1828
+ for (const v of nodes) walker = insertAfter(this, walker, v);
1829
+ return ret;
1830
+ }
1831
+ reverse() {
1832
+ const head = this.head;
1833
+ const tail = this.tail;
1834
+ for (let walker = head; !!walker; walker = walker.prev) {
1835
+ const p = walker.prev;
1836
+ walker.prev = walker.next;
1837
+ walker.next = p;
1838
+ }
1839
+ this.head = tail;
1840
+ this.tail = head;
1841
+ return this;
1842
+ }
1843
+ };
1844
+ function insertAfter(self, node, value) {
1845
+ const inserted = new Node(value, node, node ? node.next : self.head, self);
1846
+ if (inserted.next === void 0) self.tail = inserted;
1847
+ if (inserted.prev === void 0) self.head = inserted;
1848
+ self.length++;
1849
+ return inserted;
1850
+ }
1851
+ function push(self, item) {
1852
+ self.tail = new Node(item, self.tail, void 0, self);
1853
+ if (!self.head) self.head = self.tail;
1854
+ self.length++;
1855
+ }
1856
+ function unshift(self, item) {
1857
+ self.head = new Node(item, void 0, self.head, self);
1858
+ if (!self.tail) self.tail = self.head;
1859
+ self.length++;
1860
+ }
1861
+ var Node = class {
1862
+ list;
1863
+ next;
1864
+ prev;
1865
+ value;
1866
+ constructor(value, prev, next, list) {
1867
+ this.list = list;
1868
+ this.value = value;
1869
+ if (prev) {
1870
+ prev.next = this;
1871
+ this.prev = prev;
1872
+ } else this.prev = void 0;
1873
+ if (next) {
1874
+ next.prev = this;
1875
+ this.next = next;
1876
+ } else this.next = void 0;
1877
+ }
1878
+ };
1879
+ //#endregion
1880
+ //#region ../../node_modules/.pnpm/tar@7.5.1/node_modules/tar/dist/esm/pack.js
1881
+ var PackJob = class {
1882
+ path;
1883
+ absolute;
1884
+ entry;
1885
+ stat;
1886
+ readdir;
1887
+ pending = false;
1888
+ ignore = false;
1889
+ piped = false;
1890
+ constructor(path, absolute) {
1891
+ this.path = path || "./";
1892
+ this.absolute = absolute;
1893
+ }
1894
+ };
1895
+ var EOF = Buffer.alloc(1024);
1896
+ var ONSTAT = Symbol("onStat");
1897
+ var ENDED$1 = Symbol("ended");
1898
+ var QUEUE = Symbol("queue");
1899
+ var CURRENT = Symbol("current");
1900
+ var PROCESS = Symbol("process");
1901
+ var PROCESSING = Symbol("processing");
1902
+ var PROCESSJOB = Symbol("processJob");
1903
+ var JOBS = Symbol("jobs");
1904
+ var JOBDONE = Symbol("jobDone");
1905
+ var ADDFSENTRY = Symbol("addFSEntry");
1906
+ var ADDTARENTRY = Symbol("addTarEntry");
1907
+ var STAT = Symbol("stat");
1908
+ var READDIR = Symbol("readdir");
1909
+ var ONREADDIR = Symbol("onreaddir");
1910
+ var PIPE = Symbol("pipe");
1911
+ var ENTRY = Symbol("entry");
1912
+ var ENTRYOPT = Symbol("entryOpt");
1913
+ var WRITEENTRYCLASS = Symbol("writeEntryClass");
1914
+ var WRITE = Symbol("write");
1915
+ var ONDRAIN = Symbol("ondrain");
1916
+ var Pack = class extends Minipass {
1917
+ opt;
1918
+ cwd;
1919
+ maxReadSize;
1920
+ preservePaths;
1921
+ strict;
1922
+ noPax;
1923
+ prefix;
1924
+ linkCache;
1925
+ statCache;
1926
+ file;
1927
+ portable;
1928
+ zip;
1929
+ readdirCache;
1930
+ noDirRecurse;
1931
+ follow;
1932
+ noMtime;
1933
+ mtime;
1934
+ filter;
1935
+ jobs;
1936
+ [WRITEENTRYCLASS];
1937
+ onWriteEntry;
1938
+ [QUEUE];
1939
+ [JOBS] = 0;
1940
+ [PROCESSING] = false;
1941
+ [ENDED$1] = false;
1942
+ constructor(opt = {}) {
1943
+ super();
1944
+ this.opt = opt;
1945
+ this.file = opt.file || "";
1946
+ this.cwd = opt.cwd || process.cwd();
1947
+ this.maxReadSize = opt.maxReadSize;
1948
+ this.preservePaths = !!opt.preservePaths;
1949
+ this.strict = !!opt.strict;
1950
+ this.noPax = !!opt.noPax;
1951
+ this.prefix = normalizeWindowsPath(opt.prefix || "");
1952
+ this.linkCache = opt.linkCache || /* @__PURE__ */ new Map();
1953
+ this.statCache = opt.statCache || /* @__PURE__ */ new Map();
1954
+ this.readdirCache = opt.readdirCache || /* @__PURE__ */ new Map();
1955
+ this.onWriteEntry = opt.onWriteEntry;
1956
+ this[WRITEENTRYCLASS] = WriteEntry;
1957
+ if (typeof opt.onwarn === "function") this.on("warn", opt.onwarn);
1958
+ this.portable = !!opt.portable;
1959
+ if (opt.gzip || opt.brotli || opt.zstd) {
1960
+ if ((opt.gzip ? 1 : 0) + (opt.brotli ? 1 : 0) + (opt.zstd ? 1 : 0) > 1) throw new TypeError("gzip, brotli, zstd are mutually exclusive");
1961
+ if (opt.gzip) {
1962
+ if (typeof opt.gzip !== "object") opt.gzip = {};
1963
+ if (this.portable) opt.gzip.portable = true;
1964
+ this.zip = new Gzip(opt.gzip);
1965
+ }
1966
+ if (opt.brotli) {
1967
+ if (typeof opt.brotli !== "object") opt.brotli = {};
1968
+ this.zip = new BrotliCompress(opt.brotli);
1969
+ }
1970
+ if (opt.zstd) {
1971
+ if (typeof opt.zstd !== "object") opt.zstd = {};
1972
+ this.zip = new ZstdCompress(opt.zstd);
1973
+ }
1974
+ /* c8 ignore next */
1975
+ if (!this.zip) throw new Error("impossible");
1976
+ const zip = this.zip;
1977
+ zip.on("data", (chunk) => super.write(chunk));
1978
+ zip.on("end", () => super.end());
1979
+ zip.on("drain", () => this[ONDRAIN]());
1980
+ this.on("resume", () => zip.resume());
1981
+ } else this.on("drain", this[ONDRAIN]);
1982
+ this.noDirRecurse = !!opt.noDirRecurse;
1983
+ this.follow = !!opt.follow;
1984
+ this.noMtime = !!opt.noMtime;
1985
+ if (opt.mtime) this.mtime = opt.mtime;
1986
+ this.filter = typeof opt.filter === "function" ? opt.filter : () => true;
1987
+ this[QUEUE] = new Yallist();
1988
+ this[JOBS] = 0;
1989
+ this.jobs = Number(opt.jobs) || 4;
1990
+ this[PROCESSING] = false;
1991
+ this[ENDED$1] = false;
1992
+ }
1993
+ [WRITE](chunk) {
1994
+ return super.write(chunk);
1995
+ }
1996
+ add(path) {
1997
+ this.write(path);
1998
+ return this;
1999
+ }
2000
+ end(path, encoding, cb) {
2001
+ /* c8 ignore start */
2002
+ if (typeof path === "function") {
2003
+ cb = path;
2004
+ path = void 0;
2005
+ }
2006
+ if (typeof encoding === "function") {
2007
+ cb = encoding;
2008
+ encoding = void 0;
2009
+ }
2010
+ /* c8 ignore stop */
2011
+ if (path) this.add(path);
2012
+ this[ENDED$1] = true;
2013
+ this[PROCESS]();
2014
+ /* c8 ignore next */
2015
+ if (cb) cb();
2016
+ return this;
2017
+ }
2018
+ write(path) {
2019
+ if (this[ENDED$1]) throw new Error("write after end");
2020
+ if (path instanceof ReadEntry) this[ADDTARENTRY](path);
2021
+ else this[ADDFSENTRY](path);
2022
+ return this.flowing;
2023
+ }
2024
+ [ADDTARENTRY](p) {
2025
+ const absolute = normalizeWindowsPath(path$1.resolve(this.cwd, p.path));
2026
+ if (!this.filter(p.path, p)) p.resume();
2027
+ else {
2028
+ const job = new PackJob(p.path, absolute);
2029
+ job.entry = new WriteEntryTar(p, this[ENTRYOPT](job));
2030
+ job.entry.on("end", () => this[JOBDONE](job));
2031
+ this[JOBS] += 1;
2032
+ this[QUEUE].push(job);
2033
+ }
2034
+ this[PROCESS]();
2035
+ }
2036
+ [ADDFSENTRY](p) {
2037
+ const absolute = normalizeWindowsPath(path$1.resolve(this.cwd, p));
2038
+ this[QUEUE].push(new PackJob(p, absolute));
2039
+ this[PROCESS]();
2040
+ }
2041
+ [STAT](job) {
2042
+ job.pending = true;
2043
+ this[JOBS] += 1;
2044
+ fs$2[this.follow ? "stat" : "lstat"](job.absolute, (er, stat) => {
2045
+ job.pending = false;
2046
+ this[JOBS] -= 1;
2047
+ if (er) this.emit("error", er);
2048
+ else this[ONSTAT](job, stat);
2049
+ });
2050
+ }
2051
+ [ONSTAT](job, stat) {
2052
+ this.statCache.set(job.absolute, stat);
2053
+ job.stat = stat;
2054
+ if (!this.filter(job.path, stat)) job.ignore = true;
2055
+ this[PROCESS]();
2056
+ }
2057
+ [READDIR](job) {
2058
+ job.pending = true;
2059
+ this[JOBS] += 1;
2060
+ fs$2.readdir(job.absolute, (er, entries) => {
2061
+ job.pending = false;
2062
+ this[JOBS] -= 1;
2063
+ if (er) return this.emit("error", er);
2064
+ this[ONREADDIR](job, entries);
2065
+ });
2066
+ }
2067
+ [ONREADDIR](job, entries) {
2068
+ this.readdirCache.set(job.absolute, entries);
2069
+ job.readdir = entries;
2070
+ this[PROCESS]();
2071
+ }
2072
+ [PROCESS]() {
2073
+ if (this[PROCESSING]) return;
2074
+ this[PROCESSING] = true;
2075
+ for (let w = this[QUEUE].head; !!w && this[JOBS] < this.jobs; w = w.next) {
2076
+ this[PROCESSJOB](w.value);
2077
+ if (w.value.ignore) {
2078
+ const p = w.next;
2079
+ this[QUEUE].removeNode(w);
2080
+ w.next = p;
2081
+ }
2082
+ }
2083
+ this[PROCESSING] = false;
2084
+ if (this[ENDED$1] && !this[QUEUE].length && this[JOBS] === 0) if (this.zip) this.zip.end(EOF);
2085
+ else {
2086
+ super.write(EOF);
2087
+ super.end();
2088
+ }
2089
+ }
2090
+ get [CURRENT]() {
2091
+ return this[QUEUE] && this[QUEUE].head && this[QUEUE].head.value;
2092
+ }
2093
+ [JOBDONE](_job) {
2094
+ this[QUEUE].shift();
2095
+ this[JOBS] -= 1;
2096
+ this[PROCESS]();
2097
+ }
2098
+ [PROCESSJOB](job) {
2099
+ if (job.pending) return;
2100
+ if (job.entry) {
2101
+ if (job === this[CURRENT] && !job.piped) this[PIPE](job);
2102
+ return;
2103
+ }
2104
+ if (!job.stat) {
2105
+ const sc = this.statCache.get(job.absolute);
2106
+ if (sc) this[ONSTAT](job, sc);
2107
+ else this[STAT](job);
2108
+ }
2109
+ if (!job.stat) return;
2110
+ if (job.ignore) return;
2111
+ if (!this.noDirRecurse && job.stat.isDirectory() && !job.readdir) {
2112
+ const rc = this.readdirCache.get(job.absolute);
2113
+ if (rc) this[ONREADDIR](job, rc);
2114
+ else this[READDIR](job);
2115
+ if (!job.readdir) return;
2116
+ }
2117
+ job.entry = this[ENTRY](job);
2118
+ if (!job.entry) {
2119
+ job.ignore = true;
2120
+ return;
2121
+ }
2122
+ if (job === this[CURRENT] && !job.piped) this[PIPE](job);
2123
+ }
2124
+ [ENTRYOPT](job) {
2125
+ return {
2126
+ onwarn: (code, msg, data) => this.warn(code, msg, data),
2127
+ noPax: this.noPax,
2128
+ cwd: this.cwd,
2129
+ absolute: job.absolute,
2130
+ preservePaths: this.preservePaths,
2131
+ maxReadSize: this.maxReadSize,
2132
+ strict: this.strict,
2133
+ portable: this.portable,
2134
+ linkCache: this.linkCache,
2135
+ statCache: this.statCache,
2136
+ noMtime: this.noMtime,
2137
+ mtime: this.mtime,
2138
+ prefix: this.prefix,
2139
+ onWriteEntry: this.onWriteEntry
2140
+ };
2141
+ }
2142
+ [ENTRY](job) {
2143
+ this[JOBS] += 1;
2144
+ try {
2145
+ return new this[WRITEENTRYCLASS](job.path, this[ENTRYOPT](job)).on("end", () => this[JOBDONE](job)).on("error", (er) => this.emit("error", er));
2146
+ } catch (er) {
2147
+ this.emit("error", er);
2148
+ }
2149
+ }
2150
+ [ONDRAIN]() {
2151
+ if (this[CURRENT] && this[CURRENT].entry) this[CURRENT].entry.resume();
2152
+ }
2153
+ [PIPE](job) {
2154
+ job.piped = true;
2155
+ if (job.readdir) job.readdir.forEach((entry) => {
2156
+ const p = job.path;
2157
+ const base = p === "./" ? "" : p.replace(/\/*$/, "/");
2158
+ this[ADDFSENTRY](base + entry);
2159
+ });
2160
+ const source = job.entry;
2161
+ const zip = this.zip;
2162
+ /* c8 ignore start */
2163
+ if (!source) throw new Error("cannot pipe without source");
2164
+ /* c8 ignore stop */
2165
+ if (zip) source.on("data", (chunk) => {
2166
+ if (!zip.write(chunk)) source.pause();
2167
+ });
2168
+ else source.on("data", (chunk) => {
2169
+ if (!super.write(chunk)) source.pause();
2170
+ });
2171
+ }
2172
+ pause() {
2173
+ if (this.zip) this.zip.pause();
2174
+ return super.pause();
2175
+ }
2176
+ warn(code, message, data = {}) {
2177
+ warnMethod(this, code, message, data);
2178
+ }
2179
+ };
2180
+ var PackSync = class extends Pack {
2181
+ sync = true;
2182
+ constructor(opt) {
2183
+ super(opt);
2184
+ this[WRITEENTRYCLASS] = WriteEntrySync;
2185
+ }
2186
+ pause() {}
2187
+ resume() {}
2188
+ [STAT](job) {
2189
+ const stat = this.follow ? "statSync" : "lstatSync";
2190
+ this[ONSTAT](job, fs$2[stat](job.absolute));
2191
+ }
2192
+ [READDIR](job) {
2193
+ this[ONREADDIR](job, fs$2.readdirSync(job.absolute));
2194
+ }
2195
+ [PIPE](job) {
2196
+ const source = job.entry;
2197
+ const zip = this.zip;
2198
+ if (job.readdir) job.readdir.forEach((entry) => {
2199
+ const p = job.path;
2200
+ const base = p === "./" ? "" : p.replace(/\/*$/, "/");
2201
+ this[ADDFSENTRY](base + entry);
2202
+ });
2203
+ /* c8 ignore start */
2204
+ if (!source) throw new Error("Cannot pipe without source");
2205
+ /* c8 ignore stop */
2206
+ if (zip) source.on("data", (chunk) => {
2207
+ zip.write(chunk);
2208
+ });
2209
+ else source.on("data", (chunk) => {
2210
+ super[WRITE](chunk);
2211
+ });
2212
+ }
2213
+ };
2214
+ //#endregion
2215
+ //#region ../../node_modules/.pnpm/tar@7.5.1/node_modules/tar/dist/esm/create.js
2216
+ var createFileSync = (opt, files) => {
2217
+ const p = new PackSync(opt);
2218
+ const stream = new WriteStreamSync(opt.file, { mode: opt.mode || 438 });
2219
+ p.pipe(stream);
2220
+ addFilesSync$1(p, files);
2221
+ };
2222
+ var createFile = (opt, files) => {
2223
+ const p = new Pack(opt);
2224
+ const stream = new WriteStream(opt.file, { mode: opt.mode || 438 });
2225
+ p.pipe(stream);
2226
+ const promise = new Promise((res, rej) => {
2227
+ stream.on("error", rej);
2228
+ stream.on("close", res);
2229
+ p.on("error", rej);
2230
+ });
2231
+ addFilesAsync$1(p, files);
2232
+ return promise;
2233
+ };
2234
+ var addFilesSync$1 = (p, files) => {
2235
+ files.forEach((file) => {
2236
+ if (file.charAt(0) === "@") list({
2237
+ file: path.resolve(p.cwd, file.slice(1)),
2238
+ sync: true,
2239
+ noResume: true,
2240
+ onReadEntry: (entry) => p.add(entry)
2241
+ });
2242
+ else p.add(file);
2243
+ });
2244
+ p.end();
2245
+ };
2246
+ var addFilesAsync$1 = async (p, files) => {
2247
+ for (let i = 0; i < files.length; i++) {
2248
+ const file = String(files[i]);
2249
+ if (file.charAt(0) === "@") await list({
2250
+ file: path.resolve(String(p.cwd), file.slice(1)),
2251
+ noResume: true,
2252
+ onReadEntry: (entry) => {
2253
+ p.add(entry);
2254
+ }
2255
+ });
2256
+ else p.add(file);
2257
+ }
2258
+ p.end();
2259
+ };
2260
+ var createSync = (opt, files) => {
2261
+ const p = new PackSync(opt);
2262
+ addFilesSync$1(p, files);
2263
+ return p;
2264
+ };
2265
+ var createAsync = (opt, files) => {
2266
+ const p = new Pack(opt);
2267
+ addFilesAsync$1(p, files);
2268
+ return p;
2269
+ };
2270
+ makeCommand(createFileSync, createFile, createSync, createAsync, (_opt, files) => {
2271
+ if (!files?.length) throw new TypeError("no paths specified to add to archive");
2272
+ });
1106
2273
  //#endregion
1107
2274
  //#region ../../node_modules/.pnpm/tar@7.5.1/node_modules/tar/dist/esm/get-write-flag.js
1108
2275
  var isWindows$2 = (process.env.__FAKE_PLATFORM__ || process.platform) === "win32";
@@ -1995,4 +3162,157 @@ var extract = makeCommand(extractFileSync, extractFile, (opt) => new UnpackSync(
1995
3162
  if (files?.length) filesFilter(opt, files);
1996
3163
  });
1997
3164
  //#endregion
3165
+ //#region ../../node_modules/.pnpm/tar@7.5.1/node_modules/tar/dist/esm/replace.js
3166
+ var replaceSync = (opt, files) => {
3167
+ const p = new PackSync(opt);
3168
+ let threw = true;
3169
+ let fd;
3170
+ let position;
3171
+ try {
3172
+ try {
3173
+ fd = fs.openSync(opt.file, "r+");
3174
+ } catch (er) {
3175
+ if (er?.code === "ENOENT") fd = fs.openSync(opt.file, "w+");
3176
+ else throw er;
3177
+ }
3178
+ const st = fs.fstatSync(fd);
3179
+ const headBuf = Buffer.alloc(512);
3180
+ POSITION: for (position = 0; position < st.size; position += 512) {
3181
+ for (let bufPos = 0, bytes = 0; bufPos < 512; bufPos += bytes) {
3182
+ bytes = fs.readSync(fd, headBuf, bufPos, headBuf.length - bufPos, position + bufPos);
3183
+ if (position === 0 && headBuf[0] === 31 && headBuf[1] === 139) throw new Error("cannot append to compressed archives");
3184
+ if (!bytes) break POSITION;
3185
+ }
3186
+ const h = new Header(headBuf);
3187
+ if (!h.cksumValid) break;
3188
+ const entryBlockSize = 512 * Math.ceil((h.size || 0) / 512);
3189
+ if (position + entryBlockSize + 512 > st.size) break;
3190
+ position += entryBlockSize;
3191
+ if (opt.mtimeCache && h.mtime) opt.mtimeCache.set(String(h.path), h.mtime);
3192
+ }
3193
+ threw = false;
3194
+ streamSync(opt, p, position, fd, files);
3195
+ } finally {
3196
+ if (threw) try {
3197
+ fs.closeSync(fd);
3198
+ } catch (er) {}
3199
+ }
3200
+ };
3201
+ var streamSync = (opt, p, position, fd, files) => {
3202
+ const stream = new WriteStreamSync(opt.file, {
3203
+ fd,
3204
+ start: position
3205
+ });
3206
+ p.pipe(stream);
3207
+ addFilesSync(p, files);
3208
+ };
3209
+ var replaceAsync = (opt, files) => {
3210
+ files = Array.from(files);
3211
+ const p = new Pack(opt);
3212
+ const getPos = (fd, size, cb_) => {
3213
+ const cb = (er, pos) => {
3214
+ if (er) fs.close(fd, (_) => cb_(er));
3215
+ else cb_(null, pos);
3216
+ };
3217
+ let position = 0;
3218
+ if (size === 0) return cb(null, 0);
3219
+ let bufPos = 0;
3220
+ const headBuf = Buffer.alloc(512);
3221
+ const onread = (er, bytes) => {
3222
+ if (er || typeof bytes === "undefined") return cb(er);
3223
+ bufPos += bytes;
3224
+ if (bufPos < 512 && bytes) return fs.read(fd, headBuf, bufPos, headBuf.length - bufPos, position + bufPos, onread);
3225
+ if (position === 0 && headBuf[0] === 31 && headBuf[1] === 139) return cb(/* @__PURE__ */ new Error("cannot append to compressed archives"));
3226
+ if (bufPos < 512) return cb(null, position);
3227
+ const h = new Header(headBuf);
3228
+ if (!h.cksumValid) return cb(null, position);
3229
+ /* c8 ignore next */
3230
+ const entryBlockSize = 512 * Math.ceil((h.size ?? 0) / 512);
3231
+ if (position + entryBlockSize + 512 > size) return cb(null, position);
3232
+ position += entryBlockSize + 512;
3233
+ if (position >= size) return cb(null, position);
3234
+ if (opt.mtimeCache && h.mtime) opt.mtimeCache.set(String(h.path), h.mtime);
3235
+ bufPos = 0;
3236
+ fs.read(fd, headBuf, 0, 512, position, onread);
3237
+ };
3238
+ fs.read(fd, headBuf, 0, 512, position, onread);
3239
+ };
3240
+ return new Promise((resolve, reject) => {
3241
+ p.on("error", reject);
3242
+ let flag = "r+";
3243
+ const onopen = (er, fd) => {
3244
+ if (er && er.code === "ENOENT" && flag === "r+") {
3245
+ flag = "w+";
3246
+ return fs.open(opt.file, flag, onopen);
3247
+ }
3248
+ if (er || !fd) return reject(er);
3249
+ fs.fstat(fd, (er, st) => {
3250
+ if (er) return fs.close(fd, () => reject(er));
3251
+ getPos(fd, st.size, (er, position) => {
3252
+ if (er) return reject(er);
3253
+ const stream = new WriteStream(opt.file, {
3254
+ fd,
3255
+ start: position
3256
+ });
3257
+ p.pipe(stream);
3258
+ stream.on("error", reject);
3259
+ stream.on("close", resolve);
3260
+ addFilesAsync(p, files);
3261
+ });
3262
+ });
3263
+ };
3264
+ fs.open(opt.file, flag, onopen);
3265
+ });
3266
+ };
3267
+ var addFilesSync = (p, files) => {
3268
+ files.forEach((file) => {
3269
+ if (file.charAt(0) === "@") list({
3270
+ file: path.resolve(p.cwd, file.slice(1)),
3271
+ sync: true,
3272
+ noResume: true,
3273
+ onReadEntry: (entry) => p.add(entry)
3274
+ });
3275
+ else p.add(file);
3276
+ });
3277
+ p.end();
3278
+ };
3279
+ var addFilesAsync = async (p, files) => {
3280
+ for (let i = 0; i < files.length; i++) {
3281
+ const file = String(files[i]);
3282
+ if (file.charAt(0) === "@") await list({
3283
+ file: path.resolve(String(p.cwd), file.slice(1)),
3284
+ noResume: true,
3285
+ onReadEntry: (entry) => p.add(entry)
3286
+ });
3287
+ else p.add(file);
3288
+ }
3289
+ p.end();
3290
+ };
3291
+ var replace = makeCommand(
3292
+ replaceSync,
3293
+ replaceAsync,
3294
+ /* c8 ignore start */
3295
+ () => {
3296
+ throw new TypeError("file is required");
3297
+ },
3298
+ () => {
3299
+ throw new TypeError("file is required");
3300
+ },
3301
+ /* c8 ignore stop */
3302
+ (opt, entries) => {
3303
+ if (!isFile(opt)) throw new TypeError("file is required");
3304
+ if (opt.gzip || opt.brotli || opt.zstd || opt.file.endsWith(".br") || opt.file.endsWith(".tbr")) throw new TypeError("cannot append to compressed archives");
3305
+ if (!entries?.length) throw new TypeError("no paths specified to add/replace");
3306
+ }
3307
+ );
3308
+ makeCommand(replace.syncFile, replace.asyncFile, replace.syncNoFile, replace.asyncNoFile, (opt, entries = []) => {
3309
+ replace.validate?.(opt, entries);
3310
+ mtimeFilter(opt);
3311
+ });
3312
+ var mtimeFilter = (opt) => {
3313
+ const filter = opt.filter;
3314
+ if (!opt.mtimeCache) opt.mtimeCache = /* @__PURE__ */ new Map();
3315
+ opt.filter = filter ? (path, stat) => filter(path, stat) && !((opt.mtimeCache?.get(path) ?? stat.mtime ?? 0) > (stat.mtime ?? 0)) : (path, stat) => !((opt.mtimeCache?.get(path) ?? stat.mtime ?? 0) > (stat.mtime ?? 0));
3316
+ };
3317
+ //#endregion
1998
3318
  export { extract as t };