create-expo 5.0.0 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- exports.id = 525;
2
- exports.ids = [525];
1
+ exports.id = 223;
2
+ exports.ids = [223];
3
3
  exports.modules = {
4
4
 
5
5
  /***/ 2671:
@@ -11726,12 +11726,12 @@ globstar while`,t,d,e,f,m),this.matchOne(t.slice(d),e.slice(f),s))return this.de
11726
11726
 
11727
11727
  /***/ }),
11728
11728
 
11729
- /***/ 912:
11729
+ /***/ 6378:
11730
11730
  /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
11731
11731
 
11732
11732
  "use strict";
11733
11733
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11734
- /* harmony export */ Aq: () => (/* binding */ y),
11734
+ /* harmony export */ Aq: () => (/* binding */ p),
11735
11735
  /* harmony export */ PJ: () => (/* binding */ untar),
11736
11736
  /* harmony export */ WT: () => (/* binding */ streamToAsyncIterable)
11737
11737
  /* harmony export */ });
@@ -11744,15 +11744,18 @@ function createReadableStream(t) {
11744
11744
  const {pull: n, cancel: i} = t;
11745
11745
  if (n && i) {
11746
11746
  let e;
11747
+ let a;
11747
11748
  t.pull = function wrappedPull(t) {
11748
11749
  return e = n(t);
11749
11750
  };
11750
11751
  t.cancel = function wrappedCancel() {
11751
- if (null != e) {
11752
+ if (null != a) {
11753
+ return a;
11754
+ } else if (null != e) {
11752
11755
  const settle = () => i();
11753
- return Promise.resolve(e).then(settle, settle);
11756
+ return a = Promise.resolve(e).then(settle, settle);
11754
11757
  }
11755
- return i();
11758
+ return a = Promise.resolve(i());
11756
11759
  };
11757
11760
  }
11758
11761
  const a = new ReadableStream(t, e);
@@ -11769,12 +11772,24 @@ function streamToAsyncIterable(e) {
11769
11772
  if (!e[Symbol.asyncIterator]) {
11770
11773
  return async function*() {
11771
11774
  const t = e.getReader();
11772
- while (1) {
11773
- const e = await t.read();
11774
- if (e.done) {
11775
- return e.value;
11775
+ let n = !1;
11776
+ try {
11777
+ while (1) {
11778
+ const e = await t.read();
11779
+ if (e.done) {
11780
+ n = !0;
11781
+ return e.value;
11782
+ }
11783
+ yield e.value;
11784
+ }
11785
+ } finally {
11786
+ try {
11787
+ if (!n) {
11788
+ await t.cancel();
11789
+ }
11790
+ } finally {
11791
+ t.releaseLock();
11776
11792
  }
11777
- yield e.value;
11778
11793
  }
11779
11794
  }();
11780
11795
  } else {
@@ -11782,20 +11797,75 @@ function streamToAsyncIterable(e) {
11782
11797
  }
11783
11798
  }
11784
11799
 
11785
- function streamLikeToIterator(e) {
11786
- if ("getReader" in e && "function" == typeof e.getReader) {
11787
- const t = e.getReader();
11788
- return async function read() {
11789
- return await t.read();
11790
- };
11800
+ async function* streamToSizedAsyncIterable(e, t, n) {
11801
+ if (null == t) {
11802
+ yield* streamToAsyncIterable(e);
11791
11803
  } else {
11792
- const t = e[Symbol.asyncIterator] ? e[Symbol.asyncIterator]() : e[Symbol.iterator]();
11793
- return async function next() {
11794
- return await t.next();
11795
- };
11804
+ const i = e.getReader();
11805
+ let a = t;
11806
+ let r = !1;
11807
+ try {
11808
+ while (1) {
11809
+ const e = await i.read();
11810
+ if (e.done) {
11811
+ r = !0;
11812
+ break;
11813
+ }
11814
+ a -= e.value.byteLength;
11815
+ if (a < 0) {
11816
+ throw new Error(`${n} body exceeds declared size`);
11817
+ }
11818
+ yield e.value;
11819
+ }
11820
+ if (a > 0) {
11821
+ throw new Error(`${n} body is shorter than declared size`);
11822
+ }
11823
+ } finally {
11824
+ try {
11825
+ if (!r) {
11826
+ await i.cancel();
11827
+ }
11828
+ } finally {
11829
+ i.releaseLock();
11830
+ }
11831
+ }
11796
11832
  }
11797
11833
  }
11798
11834
 
11835
+ function streamLikeToIterator(e) {
11836
+ const t = "getReader" in e && "function" == typeof e.getReader ? streamToAsyncIterable(e) : e;
11837
+ const n = t[Symbol.asyncIterator] ? t[Symbol.asyncIterator]() : t[Symbol.iterator]();
11838
+ let i = !1;
11839
+ const a = {
11840
+ [Symbol.asyncIterator]: () => a,
11841
+ async next() {
11842
+ if (i) {
11843
+ return {
11844
+ done: !0,
11845
+ value: void 0
11846
+ };
11847
+ }
11848
+ const e = await n.next();
11849
+ i = !!e.done;
11850
+ return e.done ? {
11851
+ done: !0,
11852
+ value: void 0
11853
+ } : e;
11854
+ },
11855
+ async return() {
11856
+ if (!i) {
11857
+ i = !0;
11858
+ await (n.return?.());
11859
+ }
11860
+ return {
11861
+ done: !0,
11862
+ value: void 0
11863
+ };
11864
+ }
11865
+ };
11866
+ return a;
11867
+ }
11868
+
11799
11869
  function iterableToStream(e, t) {
11800
11870
  const n = t?.signal;
11801
11871
  const i = new AbortController;
@@ -11941,6 +12011,9 @@ class ReadableStreamBlockReader {
11941
12011
  this.block = new Uint8Array(t);
11942
12012
  this.buffer = null;
11943
12013
  }
12014
+ async close() {
12015
+ await this.next.return();
12016
+ }
11944
12017
  async read() {
11945
12018
  const {blockSize: e, block: t} = this;
11946
12019
  let n = 0;
@@ -11962,7 +12035,7 @@ class ReadableStreamBlockReader {
11962
12035
  }
11963
12036
  }
11964
12037
  while ((i = e - n) > 0) {
11965
- const {done: e, value: a} = await this.next();
12038
+ const {done: e, value: a} = await this.next.next();
11966
12039
  if (e || !a?.byteLength) {
11967
12040
  break;
11968
12041
  } else if (a.byteLength > i) {
@@ -12000,7 +12073,7 @@ class ReadableStreamBlockReader {
12000
12073
  }
12001
12074
  }
12002
12075
  this.blockLocked = !1;
12003
- const {done: i, value: a} = await this.next();
12076
+ const {done: i, value: a} = await this.next.next();
12004
12077
  if (i) {
12005
12078
  return null;
12006
12079
  } else if (a.byteLength > e) {
@@ -12030,7 +12103,7 @@ class ReadableStreamBlockReader {
12030
12103
  }
12031
12104
  }
12032
12105
  while (t > 0) {
12033
- const {done: e, value: n} = await this.next();
12106
+ const {done: e, value: n} = await this.next.next();
12034
12107
  if (e) {
12035
12108
  return t;
12036
12109
  } else if (n.byteLength > t) {
@@ -12260,29 +12333,34 @@ async function expectTrailer(e, t) {
12260
12333
  async function decodeHeaders(e) {
12261
12334
  let t = 0;
12262
12335
  const n = Object.create(null);
12263
- while (t < 32e3) {
12336
+ while (t <= 32e3) {
12264
12337
  let i = "";
12338
+ let a = 0;
12265
12339
  for await (const n of readUntilBoundary(e, s, l)) {
12266
12340
  if (null == n) {
12267
12341
  throw new Error("Invalid Multipart Headers: Unexpected EOF");
12268
12342
  } else if (!t && !i && 45 === n[0] && 45 === n[1]) {
12269
12343
  return null;
12270
12344
  } else {
12271
- i += d.decode(n);
12272
- if (i.length > 16e3) {
12345
+ a += n.byteLength;
12346
+ if (a > 16e3) {
12273
12347
  throw new Error("Invalid Multipart Headers: A header exceeded its maximum length of 16kB");
12274
12348
  }
12349
+ i += d.decode(n, {
12350
+ stream: !0
12351
+ });
12275
12352
  }
12276
12353
  }
12354
+ i += d.decode();
12277
12355
  if (i) {
12278
12356
  const e = i.indexOf(":");
12279
12357
  if (e > -1) {
12280
- const a = i.slice(0, e).trim().toLowerCase();
12281
- const r = i.slice(e + 1).trim();
12282
- if (r) {
12283
- n[a] = r;
12358
+ const r = i.slice(0, e).trim().toLowerCase();
12359
+ const o = i.slice(e + 1).trim();
12360
+ if (o) {
12361
+ n[r] = o;
12284
12362
  }
12285
- t += i.length + s.byteLength;
12363
+ t += a + s.byteLength;
12286
12364
  } else {
12287
12365
  throw new Error("Invalid Multipart Headers: Invalid header value missing `:`");
12288
12366
  }
@@ -12290,113 +12368,119 @@ async function decodeHeaders(e) {
12290
12368
  break;
12291
12369
  }
12292
12370
  }
12293
- if (t > 16e3) {
12371
+ if (t > 32e3) {
12294
12372
  throw new Error("Invalid Multipart Headers: Headers exceeded their maximum length of 32kB");
12295
12373
  }
12296
12374
  return n;
12297
12375
  }
12298
12376
 
12299
12377
  async function* parseMultipart(e, t) {
12300
- const n = function convertToBoundaryBytes(e) {
12301
- const t = e.match(c);
12302
- const n = `--${t?.[1] || "-"}`;
12303
- const i = `\r\n${n}`;
12304
- const a = utf8Encode(n);
12305
- const r = utf8Encode(i);
12306
- return {
12307
- raw: a,
12308
- rawSkipTable: bytesToSkipTable(a),
12309
- trailer: r,
12310
- trailerSkipTable: bytesToSkipTable(r)
12311
- };
12312
- }(t.contentType);
12313
- const i = new ReadableStreamBlockReader(e, 4096);
12314
- await async function expectPreamble(e, t) {
12315
- let n = 0;
12316
- for await (const i of readUntilBoundary(e, t.raw, t.rawSkipTable)) {
12317
- if (null == i) {
12318
- throw new Error("Invalid Multipart Preamble: Unexpected EOF");
12319
- } else if ((n += i?.byteLength) > 16e3) {
12320
- throw new Error("Invalid Multipart Preamble: Boundary not found within the first 16kB");
12321
- }
12322
- }
12323
- }(i, n);
12324
- let a;
12325
- while (a = await decodeHeaders(i)) {
12326
- const e = a["content-type"];
12327
- const t = parseContentDisposition(a["content-disposition"]);
12328
- const r = t?.filename || t?.name;
12329
- const o = parseContentLength(a["content-length"]);
12330
- if (!r) {
12331
- throw new Error("Invalid Multipart Part: Missing Content-Disposition name or filename parameter");
12332
- }
12333
- let s = !1;
12334
- let l = 0;
12335
- let c;
12336
- if (null !== o) {
12337
- l = o;
12338
- c = createReadableStream({
12339
- expectedLength: o,
12340
- async cancel() {
12341
- if (l > 0) {
12342
- l = await i.skip(l);
12343
- if (l > 0) {
12344
- throw new Error("Invalid Multipart Part: Unexpected EOF");
12345
- }
12346
- }
12347
- if (!s) {
12348
- await expectTrailer(i, n);
12349
- s = !0;
12350
- }
12351
- },
12352
- async pull(e) {
12353
- if (l) {
12354
- const t = await i.pull(l);
12355
- if (!t) {
12356
- throw new Error("Invalid Multipart Part: Unexpected EOF");
12357
- }
12358
- l -= t.byteLength;
12359
- e.enqueue(i.blockLocked ? t.slice() : t);
12360
- }
12361
- if (!l) {
12362
- await expectTrailer(i, n);
12363
- s = !0;
12364
- e.close();
12378
+ const n = new ReadableStreamBlockReader(e, 4096);
12379
+ try {
12380
+ yield* async function* readMultipart(e, t) {
12381
+ const n = function convertToBoundaryBytes(e) {
12382
+ const t = e.match(c);
12383
+ const n = `--${t?.[1] || "-"}`;
12384
+ const i = `\r\n${n}`;
12385
+ const a = utf8Encode(n);
12386
+ const r = utf8Encode(i);
12387
+ return {
12388
+ raw: a,
12389
+ rawSkipTable: bytesToSkipTable(a),
12390
+ trailer: r,
12391
+ trailerSkipTable: bytesToSkipTable(r)
12392
+ };
12393
+ }(t.contentType);
12394
+ await async function expectPreamble(e, t) {
12395
+ let n = 0;
12396
+ for await (const i of readUntilBoundary(e, t.raw, t.rawSkipTable)) {
12397
+ if (null == i) {
12398
+ throw new Error("Invalid Multipart Preamble: Unexpected EOF");
12399
+ } else if ((n += i?.byteLength) > 16e3) {
12400
+ throw new Error("Invalid Multipart Preamble: Boundary not found within the first 16kB");
12365
12401
  }
12366
12402
  }
12367
- });
12368
- } else {
12369
- const e = readUntilBoundary(i, n.trailer, n.trailerSkipTable);
12370
- c = createReadableStream({
12371
- async cancel() {
12372
- for await (const t of e) {
12373
- if (!t) {
12374
- throw new Error("Invalid Multipart Part: Unexpected EOF");
12403
+ }(e, n);
12404
+ let i;
12405
+ while (i = await decodeHeaders(e)) {
12406
+ const t = i["content-type"];
12407
+ const a = parseContentDisposition(i["content-disposition"]);
12408
+ const r = a?.filename || a?.name;
12409
+ const o = parseContentLength(i["content-length"]);
12410
+ if (!r) {
12411
+ throw new Error("Invalid Multipart Part: Missing Content-Disposition name or filename parameter");
12412
+ }
12413
+ let s = !1;
12414
+ let l = 0;
12415
+ let c;
12416
+ if (null !== o) {
12417
+ l = o;
12418
+ c = createReadableStream({
12419
+ expectedLength: o,
12420
+ async cancel() {
12421
+ if (l > 0) {
12422
+ l = await e.skip(l);
12423
+ if (l > 0) {
12424
+ throw new Error("Invalid Multipart Part: Unexpected EOF");
12425
+ }
12426
+ }
12427
+ if (!s) {
12428
+ await expectTrailer(e, n);
12429
+ s = !0;
12430
+ }
12431
+ },
12432
+ async pull(t) {
12433
+ if (l) {
12434
+ const n = await e.pull(l);
12435
+ if (!n) {
12436
+ throw new Error("Invalid Multipart Part: Unexpected EOF");
12437
+ }
12438
+ l -= n.byteLength;
12439
+ t.enqueue(e.blockLocked ? n.slice() : n);
12440
+ }
12441
+ if (!l) {
12442
+ await expectTrailer(e, n);
12443
+ s = !0;
12444
+ t.close();
12445
+ }
12375
12446
  }
12376
- }
12377
- s = !0;
12378
- },
12379
- async pull(t) {
12380
- const n = await e.next();
12381
- if (n.done) {
12382
- t.close();
12383
- s = !0;
12384
- } else if (!n.value) {
12385
- throw new Error("Invalid Multipart Part: Unexpected EOF");
12386
- } else {
12387
- t.enqueue(n.value.slice());
12388
- }
12447
+ });
12448
+ } else {
12449
+ const t = readUntilBoundary(e, n.trailer, n.trailerSkipTable);
12450
+ c = createReadableStream({
12451
+ async cancel() {
12452
+ for await (const e of t) {
12453
+ if (!e) {
12454
+ throw new Error("Invalid Multipart Part: Unexpected EOF");
12455
+ }
12456
+ }
12457
+ s = !0;
12458
+ },
12459
+ async pull(e) {
12460
+ const n = await t.next();
12461
+ if (n.done) {
12462
+ e.close();
12463
+ s = !0;
12464
+ } else if (!n.value) {
12465
+ throw new Error("Invalid Multipart Part: Unexpected EOF");
12466
+ } else {
12467
+ e.enqueue(n.value.slice());
12468
+ }
12469
+ }
12470
+ });
12389
12471
  }
12390
- });
12391
- }
12392
- yield new MultipartPart(c, r, {
12393
- type: e ?? void 0,
12394
- size: o ?? void 0,
12395
- headers: a
12396
- });
12397
- if (l > 0 || !s) {
12398
- await c.cancel();
12399
- }
12472
+ yield new MultipartPart(c, r, {
12473
+ type: t ?? void 0,
12474
+ size: o ?? void 0,
12475
+ headers: i
12476
+ });
12477
+ if (l > 0 || !s) {
12478
+ await c.cancel();
12479
+ }
12480
+ }
12481
+ }(n, t);
12482
+ } finally {
12483
+ await n.close();
12400
12484
  }
12401
12485
  }
12402
12486
 
@@ -12410,9 +12494,10 @@ const isBlob = e => "object" == typeof e && null != e && (e instanceof Multipart
12410
12494
 
12411
12495
  const makeFormHeader = (e, t) => {
12412
12496
  let n = f + i + u;
12413
- n += `Content-Disposition: form-data; name="${encodeName(e.name)}"`;
12497
+ const a = encodeName(e.name);
12498
+ n += `Content-Disposition: form-data; name="${a}"`;
12414
12499
  if (null != e.filename) {
12415
- n += `; filename="${encodeName(e.filename)}"`;
12500
+ n += `; filename="${e.filename === e.name ? a : encodeName(e.filename)}"`;
12416
12501
  }
12417
12502
  if (t) {
12418
12503
  if (t.type) {
@@ -12434,39 +12519,36 @@ const makeFormHeader = (e, t) => {
12434
12519
  return n;
12435
12520
  };
12436
12521
 
12437
- const m = (/* unused pure expression or super */ null && (`multipart/form-data; boundary=${i}`));
12522
+ const y = (/* unused pure expression or super */ null && (`multipart/form-data; boundary=${i}`));
12438
12523
 
12439
12524
  async function* streamMultipart(e) {
12440
- const n = streamLikeToIterator(e);
12441
- let i;
12442
- while (!(i = await n()).done && i.value) {
12443
- const e = i.value[0];
12444
- const n = i.value[1];
12445
- if (isBlob(n)) {
12525
+ for await (const [n, i] of streamLikeToIterator(e)) {
12526
+ if (isBlob(i)) {
12446
12527
  yield t.encode(makeFormHeader({
12447
- name: e,
12448
- filename: "name" in n ? n.name : e
12449
- }, n));
12450
- yield* streamToAsyncIterable(n.stream());
12528
+ name: n,
12529
+ filename: "name" in i ? i.name : n
12530
+ }, i));
12531
+ const e = i.stream();
12532
+ yield* streamToSizedAsyncIterable(e, i.size || null, "Invalid Multipart: Part");
12451
12533
  } else {
12452
12534
  yield t.encode(makeFormHeader({
12453
- name: e
12535
+ name: n
12454
12536
  }, void 0));
12455
- yield "string" == typeof n ? t.encode(n) : n;
12537
+ yield "string" == typeof i ? t.encode(i) : i;
12456
12538
  }
12457
12539
  yield t.encode(u);
12458
12540
  }
12459
12541
  yield t.encode(h);
12460
12542
  }
12461
12543
 
12462
- const p = 512;
12544
+ const m = 512;
12463
12545
 
12464
12546
  function blockPad(e) {
12465
12547
  const t = 511 & e;
12466
- return t && p - t;
12548
+ return t && m - t;
12467
12549
  }
12468
12550
 
12469
- let y = function(e) {
12551
+ let p = function(e) {
12470
12552
  e[e.FILE = 48] = "FILE";
12471
12553
  e[e.LINK = 49] = "LINK";
12472
12554
  e[e.SYMLINK = 50] = "SYMLINK";
@@ -12482,12 +12564,13 @@ function initTarHeader(e) {
12482
12564
  gid: e?.gid || 0,
12483
12565
  size: e?.size || 0,
12484
12566
  mtime: e?.mtime || 0,
12485
- typeflag: e?.typeflag || y.FILE,
12567
+ typeflag: e?.typeflag || p.FILE,
12486
12568
  linkname: e?.linkname || null,
12487
12569
  uname: e?.uname || null,
12488
12570
  gname: e?.gname || null,
12489
12571
  devmajor: e?.devmajor || 0,
12490
- devminor: e?.devminor || 0
12572
+ devminor: e?.devminor || 0,
12573
+ _paxSize: e?._paxSize
12491
12574
  };
12492
12575
  }
12493
12576
 
@@ -12503,7 +12586,7 @@ const getTarName = e => {
12503
12586
  }
12504
12587
  };
12505
12588
 
12506
- const getTarSize = e => e._paxSize || e.size;
12589
+ const getTarSize = e => e._paxSize ?? e.size;
12507
12590
 
12508
12591
  class TarChunk extends StreamFile {
12509
12592
  constructor(e, t) {
@@ -12541,7 +12624,7 @@ class TarFile extends StreamFile {
12541
12624
  this.uid = t.uid;
12542
12625
  this.gid = t.gid;
12543
12626
  this.mtime = t.mtime;
12544
- this.typeflag = y.FILE;
12627
+ this.typeflag = p.FILE;
12545
12628
  this.linkname = null;
12546
12629
  this.uname = t.uname;
12547
12630
  this.gname = t.gname;
@@ -12552,59 +12635,60 @@ class TarFile extends StreamFile {
12552
12635
 
12553
12636
  async function decodePax(e, t, i) {
12554
12637
  let a = i.size;
12555
- let r = "";
12638
+ const r = [];
12556
12639
  while (a > 0) {
12557
- let t = await e.read();
12640
+ const t = await e.read();
12558
12641
  if (!t || t.byteLength !== e.blockSize) {
12559
12642
  throw new Error("Invalid Tar: Unexpected EOF while parsing PAX data");
12560
12643
  }
12561
- a -= t.byteLength;
12562
- if (a < 0) {
12563
- t = t.subarray(0, a);
12564
- }
12565
- r += n.decode(t, {
12566
- stream: !0
12567
- });
12644
+ const n = Math.min(a, t.byteLength);
12645
+ r.push(t.slice(0, n));
12646
+ a -= n;
12647
+ }
12648
+ const o = new Uint8Array(i.size);
12649
+ for (let e = 0, t = 0; e < r.length; e++) {
12650
+ o.set(r[e], t);
12651
+ t += r[e].byteLength;
12568
12652
  }
12569
- for (let e = 0, n = 0; e < r.length; n = 0) {
12570
- while (n < r.length && 32 !== r.charCodeAt(n)) {
12571
- n++;
12653
+ for (let e = 0, a = 0; e < o.byteLength; a = e) {
12654
+ while (a < o.byteLength && 32 !== o[a]) {
12655
+ a++;
12572
12656
  }
12573
- const a = parseInt(r.slice(e, n), 10);
12574
- if (!a || a != a) {
12657
+ const r = parseInt(n.decode(o.subarray(e, a)), 10);
12658
+ if (!r || r != r) {
12575
12659
  break;
12576
12660
  }
12577
- if (10 !== r.charCodeAt(e + a - 1)) {
12661
+ if (10 !== o[e + r - 1]) {
12578
12662
  break;
12579
12663
  }
12580
- const o = r.slice(n + 1, e + a - 1);
12581
- const s = o.indexOf("=");
12582
- if (-1 === s) {
12664
+ const s = n.decode(o.subarray(a + 1, e + r - 1));
12665
+ const l = s.indexOf("=");
12666
+ if (-1 === l) {
12583
12667
  break;
12584
12668
  }
12585
- const l = o.slice(0, s);
12586
- const c = o.slice(s + 1);
12587
- e += a;
12588
- switch (l) {
12669
+ const c = s.slice(0, l);
12670
+ const d = s.slice(l + 1);
12671
+ e += r;
12672
+ switch (c) {
12589
12673
  case "path":
12590
12674
  if (t) {
12591
- t._paxName = c;
12675
+ t._paxName = d;
12592
12676
  }
12593
- i._paxName = c;
12677
+ i._paxName = d;
12594
12678
  break;
12595
12679
 
12596
12680
  case "linkpath":
12597
12681
  if (t) {
12598
- t._paxLinkName = c;
12682
+ t._paxLinkName = d;
12599
12683
  }
12600
- i._paxLinkName = c;
12684
+ i._paxLinkName = d;
12601
12685
  break;
12602
12686
 
12603
12687
  case "size":
12604
12688
  if (t) {
12605
- t._paxSize = +c;
12689
+ t._paxSize = +d;
12606
12690
  }
12607
- i._paxSize = +c;
12691
+ i._paxSize = +d;
12608
12692
  break;
12609
12693
 
12610
12694
  case "gid":
@@ -12612,17 +12696,17 @@ async function decodePax(e, t, i) {
12612
12696
  case "mode":
12613
12697
  case "mtime":
12614
12698
  if (t) {
12615
- t[l] = +c;
12699
+ t[c] = +d;
12616
12700
  }
12617
- i[l] = +c;
12701
+ i[c] = +d;
12618
12702
  break;
12619
12703
 
12620
12704
  case "uname":
12621
12705
  case "gname":
12622
12706
  if (t) {
12623
- t[l] = c;
12707
+ t[c] = d;
12624
12708
  }
12625
- i[l] = c;
12709
+ i[c] = d;
12626
12710
  }
12627
12711
  }
12628
12712
  }
@@ -12730,7 +12814,7 @@ function decodeBase(e, t) {
12730
12814
  e._prefix = decodeString(t, 345, 500);
12731
12815
  }
12732
12816
  if (0 === e.typeflag && e.name.endsWith("/")) {
12733
- e.typeflag = y.DIRECTORY;
12817
+ e.typeflag = p.DIRECTORY;
12734
12818
  }
12735
12819
  }
12736
12820
 
@@ -12765,10 +12849,10 @@ async function decodeHeader(e, t) {
12765
12849
 
12766
12850
  case 0:
12767
12851
  case 55:
12768
- case y.FILE:
12769
- case y.LINK:
12770
- case y.SYMLINK:
12771
- case y.DIRECTORY:
12852
+ case p.FILE:
12853
+ case p.LINK:
12854
+ case p.SYMLINK:
12855
+ case p.DIRECTORY:
12772
12856
  decodeBase(i, n);
12773
12857
  return i;
12774
12858
 
@@ -12789,79 +12873,91 @@ async function decodeHeader(e, t) {
12789
12873
  }
12790
12874
 
12791
12875
  async function* untar(e) {
12792
- const t = initTarHeader(null);
12793
- const n = new ReadableStreamBlockReader(e, p);
12794
- let i;
12795
- while (null != (i = await decodeHeader(n, t))) {
12796
- const e = blockPad(i.size);
12797
- let t = 0 === e;
12798
- let a = i._paxSize || i.size;
12799
- const r = createReadableStream({
12800
- expectedLength: i.size,
12801
- async cancel() {
12802
- if (!t) {
12803
- t = !0;
12804
- a += e;
12805
- }
12806
- if (a > 0) {
12807
- if (await n.skip(a) > 0) {
12808
- throw new Error("Invalid Tar: Unexpected EOF");
12809
- }
12810
- a = 0;
12811
- }
12812
- },
12813
- async pull(i) {
12814
- if (a) {
12815
- const e = await n.pull(a);
12816
- if (!e) {
12817
- throw new Error("Invalid Tar: Unexpected EOF");
12818
- }
12819
- a -= e.byteLength;
12820
- i.enqueue(n.blockLocked ? e.slice() : e);
12876
+ const t = new ReadableStreamBlockReader(e, m);
12877
+ try {
12878
+ yield* async function* readTar(e) {
12879
+ const t = initTarHeader(null);
12880
+ let n;
12881
+ while (null != (n = await decodeHeader(e, t))) {
12882
+ const t = n._paxSize ?? n.size;
12883
+ if (!Number.isSafeInteger(t) || t < 0) {
12884
+ throw new Error(`Invalid Tar: Invalid entry size ${t}`);
12821
12885
  }
12822
- if (!a) {
12823
- if (!t) {
12824
- t = !0;
12825
- if (await n.skip(e) > 0) {
12826
- throw new Error("Invalid Tar: Unexpected EOF");
12886
+ const i = blockPad(t);
12887
+ let a = 0 === i;
12888
+ let r = t;
12889
+ const o = createReadableStream({
12890
+ expectedLength: t,
12891
+ async cancel() {
12892
+ if (!a) {
12893
+ r += i;
12894
+ }
12895
+ if (r > 0) {
12896
+ if (await e.skip(r) > 0) {
12897
+ throw new Error("Invalid Tar: Unexpected EOF");
12898
+ }
12899
+ r = 0;
12900
+ }
12901
+ a = !0;
12902
+ },
12903
+ async pull(t) {
12904
+ if (r) {
12905
+ const n = await e.pull(r);
12906
+ if (!n) {
12907
+ throw new Error("Invalid Tar: Unexpected EOF");
12908
+ }
12909
+ r -= n.byteLength;
12910
+ t.enqueue(e.blockLocked ? n.slice() : n);
12911
+ }
12912
+ if (!r) {
12913
+ if (!a) {
12914
+ if (await e.skip(i) > 0) {
12915
+ throw new Error("Invalid Tar: Unexpected EOF");
12916
+ }
12917
+ a = !0;
12918
+ }
12919
+ t.close();
12827
12920
  }
12828
12921
  }
12829
- i.close();
12830
- }
12831
- }
12832
- });
12833
- let o;
12834
- switch (i.typeflag) {
12835
- case 0:
12836
- case 55:
12837
- case y.FILE:
12838
- o = new TarFile(r, i);
12839
- break;
12922
+ });
12923
+ let s;
12924
+ switch (n.typeflag) {
12925
+ case 0:
12926
+ case 55:
12927
+ case p.FILE:
12928
+ s = new TarFile(o, n);
12929
+ break;
12840
12930
 
12841
- case y.LINK:
12842
- case y.SYMLINK:
12843
- case y.DIRECTORY:
12844
- o = new TarChunk(r, i);
12845
- break;
12931
+ case p.LINK:
12932
+ case p.SYMLINK:
12933
+ case p.DIRECTORY:
12934
+ s = new TarChunk(o, n);
12935
+ break;
12846
12936
 
12847
- default:
12848
- await r.cancel();
12849
- continue;
12850
- }
12851
- yield o;
12852
- if (a > 0 || !t) {
12853
- await r.cancel();
12854
- }
12937
+ default:
12938
+ await o.cancel();
12939
+ continue;
12940
+ }
12941
+ yield s;
12942
+ if (r > 0 || !a) {
12943
+ await o.cancel();
12944
+ }
12945
+ }
12946
+ }(t);
12947
+ } finally {
12948
+ await t.close();
12855
12949
  }
12856
12950
  }
12857
12951
 
12858
12952
  const b = 100;
12859
12953
 
12860
- const w = new Uint8Array(p);
12954
+ const w = new Uint8Array(m);
12955
+
12956
+ const g = /[^\x00-\x7f]/;
12861
12957
 
12862
12958
  function encodeString(e, n, i, a) {
12863
12959
  if (a) {
12864
- t.encodeInto(`${a}\0`, e.subarray(n, i));
12960
+ t.encodeInto(a, e.subarray(n, i));
12865
12961
  }
12866
12962
  }
12867
12963
 
@@ -12899,28 +12995,9 @@ function encodeOctal(e, t, n, i) {
12899
12995
  }
12900
12996
  }
12901
12997
 
12902
- function indexOfPrefixEnd(e) {
12903
- if (e.length <= 255) {
12904
- let t = e.length - 1;
12905
- while ((t = e.lastIndexOf("/", t - 1)) > -1) {
12906
- if (t < 155 && e.length - t - 1 < b) {
12907
- return t;
12908
- }
12909
- }
12910
- }
12911
- return -1;
12912
- }
12913
-
12914
12998
  function encodeHeader(e) {
12915
- const t = new Uint8Array(p);
12999
+ const t = new Uint8Array(m);
12916
13000
  !function encodeBase(e, t) {
12917
- let n = t.name;
12918
- if (!t._paxName && !t._longName && n.length > b) {
12919
- const e = indexOfPrefixEnd(n);
12920
- if (e > -1) {
12921
- n = n.slice(e + 1);
12922
- }
12923
- }
12924
13001
  if (!t.typeflag) {
12925
13002
  t.typeflag = function modeToType(e) {
12926
13003
  switch (61440 & e) {
@@ -12931,26 +13008,26 @@ function encodeHeader(e) {
12931
13008
  return 51;
12932
13009
 
12933
13010
  case 16384:
12934
- return y.DIRECTORY;
13011
+ return p.DIRECTORY;
12935
13012
 
12936
13013
  case 4096:
12937
13014
  return 54;
12938
13015
 
12939
13016
  case 40960:
12940
- return y.SYMLINK;
13017
+ return p.SYMLINK;
12941
13018
 
12942
13019
  default:
12943
- return y.FILE;
13020
+ return p.FILE;
12944
13021
  }
12945
13022
  }(t.mode);
12946
13023
  }
12947
13024
  if (!t.mode) {
12948
- t.mode = t.typeflag === y.DIRECTORY ? 493 : 420;
13025
+ t.mode = t.typeflag === p.DIRECTORY ? 493 : 420;
12949
13026
  }
12950
13027
  if (!t.mtime) {
12951
13028
  t.mtime = Math.floor(Date.now() / 1e3);
12952
13029
  }
12953
- encodeString(e, 0, 100, n);
13030
+ encodeString(e, 0, 100, t.name);
12954
13031
  encodeOctal(e, 100, 108, 4095 & t.mode);
12955
13032
  encodeOctal(e, 108, 116, t.uid);
12956
13033
  encodeOctal(e, 116, 124, t.gid);
@@ -12979,15 +13056,15 @@ function encodeHeader(e) {
12979
13056
  }
12980
13057
 
12981
13058
  function encodePax(e) {
12982
- function encodePaxEntry(e, t) {
12983
- const n = ` ${e}=${t}\n`;
12984
- let i = n.length;
12985
- const a = `${i}`;
12986
- i += a.length;
12987
- if (1 + Math.floor(Math.log10(i)) > a.length) {
12988
- i += 1;
13059
+ function encodePaxEntry(e, n) {
13060
+ const i = ` ${e}=${n}\n`;
13061
+ let a = t.encode(i).byteLength;
13062
+ const r = `${a}`;
13063
+ a += r.length;
13064
+ if (1 + Math.floor(Math.log10(a)) > r.length) {
13065
+ a += 1;
12989
13066
  }
12990
- return `${i}${n}`;
13067
+ return `${a}${i}`;
12991
13068
  }
12992
13069
  let n = "";
12993
13070
  if (e._paxName) {
@@ -12999,64 +13076,84 @@ function encodePax(e) {
12999
13076
  return n ? t.encode(n) : null;
13000
13077
  }
13001
13078
 
13002
- function paxName(e) {
13003
- const t = e.lastIndexOf("/");
13004
- return `PaxHeader/${(t > -1 ? e.slice(t) : e).slice(-99)}`;
13079
+ function truncateHeaderString(e) {
13080
+ let t = 99;
13081
+ while (128 == (192 & e[t])) {
13082
+ t--;
13083
+ }
13084
+ return n.decode(e.subarray(0, t));
13005
13085
  }
13006
13086
 
13007
- async function* tar(e) {
13008
- const t = streamLikeToIterator(e);
13009
- let n;
13010
- while (!(n = await t()).done && n.value) {
13011
- const {value: e} = n;
13012
- const t = initTarHeader(e);
13013
- if (!Number.isSafeInteger(t.size) || t.size < 0) {
13014
- throw new Error(`Invalid Tar: Cannot safely encode part with size ${t.size}`);
13015
- }
13016
- if (e.lastModified && !t.mtime) {
13017
- t.mtime = Math.floor(e.lastModified / 1e3);
13018
- }
13019
- if (t.typeflag === y.DIRECTORY && !t.name.endsWith("/")) {
13020
- t.name += "/";
13021
- } else if (t.typeflag === y.SYMLINK) {
13022
- t.size = 0;
13023
- }
13024
- if (t.name.length > b) {
13025
- const e = indexOfPrefixEnd(t.name);
13026
- if (e > -1) {
13027
- t._prefix = t.name.slice(0, e);
13028
- t.name = t.name.slice(e + 1);
13087
+ function prepareHeaderStrings(e) {
13088
+ if (e.name.length > 33 && (e.name.length > b || g.test(e.name))) {
13089
+ const i = t.encode(e.name);
13090
+ if (i.byteLength > b) {
13091
+ const t = function indexOfPrefixEnd(e) {
13092
+ if (e.byteLength <= 255) {
13093
+ let t = e.byteLength;
13094
+ while ((t = e.lastIndexOf(47, t - 1)) > 0) {
13095
+ if (t < 155 && e.byteLength - t - 1 < b) {
13096
+ return t;
13097
+ }
13098
+ }
13099
+ }
13100
+ return -1;
13101
+ }(i);
13102
+ if (t > -1) {
13103
+ e._prefix = n.decode(i.subarray(0, t));
13104
+ e.name = n.decode(i.subarray(t + 1));
13029
13105
  } else {
13030
- t._paxName = t.name;
13031
- t.name = paxName(t.name);
13106
+ e._paxName = e.name;
13107
+ e.name = truncateHeaderString(i);
13032
13108
  }
13033
13109
  }
13034
- if (t.linkname && t.linkname.length > b) {
13035
- t._paxLinkName = t.linkname;
13036
- t.linkname = paxName(t.name);
13110
+ }
13111
+ if (e.linkname && e.linkname.length > 33 && (e.linkname.length > b || g.test(e.linkname))) {
13112
+ const n = t.encode(e.linkname);
13113
+ if (n.byteLength > b) {
13114
+ e._paxLinkName = e.linkname;
13115
+ e.linkname = truncateHeaderString(n);
13037
13116
  }
13038
- const i = encodePax(t);
13039
- if (i) {
13117
+ }
13118
+ }
13119
+
13120
+ async function* tar(e) {
13121
+ for await (const t of streamLikeToIterator(e)) {
13122
+ const e = initTarHeader(t);
13123
+ if (!Number.isSafeInteger(e.size) || e.size < 0) {
13124
+ throw new Error(`Invalid Tar: Cannot safely encode part with size ${e.size}`);
13125
+ }
13126
+ if (t.lastModified && !e.mtime) {
13127
+ e.mtime = Math.floor(t.lastModified / 1e3);
13128
+ }
13129
+ if (e.typeflag === p.DIRECTORY && !e.name.endsWith("/")) {
13130
+ e.name += "/";
13131
+ } else if (e.typeflag === p.SYMLINK) {
13132
+ e.size = 0;
13133
+ }
13134
+ prepareHeaderStrings(e);
13135
+ const n = encodePax(e);
13136
+ if (n) {
13040
13137
  const e = initTarHeader(null);
13041
13138
  e.typeflag = 120;
13042
- e.size = i.byteLength;
13139
+ e.size = n.byteLength;
13043
13140
  yield encodeHeader(e);
13044
- yield i;
13045
- const t = blockPad(i.byteLength);
13141
+ yield n;
13142
+ const t = blockPad(n.byteLength);
13046
13143
  if (t) {
13047
13144
  yield w.subarray(0, t);
13048
13145
  }
13049
13146
  }
13050
- yield encodeHeader(t);
13051
- const a = e.stream();
13052
- if (t.size) {
13053
- yield* streamToAsyncIterable(a);
13054
- } else if (!a.locked) {
13055
- await a.cancel();
13147
+ yield encodeHeader(e);
13148
+ const i = t.stream();
13149
+ if (e.size) {
13150
+ yield* streamToSizedAsyncIterable(i, e.size, "Invalid Tar: Entry");
13151
+ } else if (!i.locked) {
13152
+ await i.cancel();
13056
13153
  }
13057
- const r = blockPad(e.size);
13058
- if (r) {
13059
- yield w.subarray(0, r);
13154
+ const a = blockPad(e.size);
13155
+ if (a) {
13156
+ yield w.subarray(0, a);
13060
13157
  }
13061
13158
  }
13062
13159
  yield new Uint8Array(1024);