@poe-platform/safe-bash 0.1.617 → 0.1.619

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.
@@ -26688,6 +26688,30 @@ function stripZip64(bytes3) {
26688
26688
  }
26689
26689
  return result;
26690
26690
  }
26691
+ function zip64Extra(values, retained) {
26692
+ if (retained.length + 4 + values.length * 8 > 65535) fail("ZIP64 extra field limit exceeded");
26693
+ const bytes3 = new Uint8Array(4 + values.length * 8 + retained.length);
26694
+ const view = new DataView(bytes3.buffer);
26695
+ view.setUint16(0, 1, true);
26696
+ view.setUint16(2, values.length * 8, true);
26697
+ values.forEach((value2, index) => view.setBigUint64(4 + index * 8, BigInt(value2), true));
26698
+ bytes3.set(retained, 4 + values.length * 8);
26699
+ return bytes3;
26700
+ }
26701
+ function writeZip64End(view, offset, count2, size, start, recordOffset = offset) {
26702
+ view.setUint32(offset, 101075792, true);
26703
+ view.setBigUint64(offset + 4, 44n, true);
26704
+ view.setUint16(offset + 12, 813, true);
26705
+ view.setUint16(offset + 14, 45, true);
26706
+ view.setBigUint64(offset + 24, BigInt(count2), true);
26707
+ view.setBigUint64(offset + 32, BigInt(count2), true);
26708
+ view.setBigUint64(offset + 40, BigInt(size), true);
26709
+ view.setBigUint64(offset + 48, BigInt(start), true);
26710
+ view.setUint32(offset + 56, 117853008, true);
26711
+ view.setBigUint64(offset + 64, BigInt(recordOffset), true);
26712
+ view.setUint32(offset + 72, 1, true);
26713
+ return offset + 76;
26714
+ }
26691
26715
 
26692
26716
  // packages/safe-bash/src/commands/archive/zip-format.ts
26693
26717
  var encoder2 = new TextEncoder();
@@ -27031,11 +27055,43 @@ function timestampExtra(modified) {
27031
27055
  view.setInt32(5, seconds, true);
27032
27056
  return bytes3;
27033
27057
  }
27034
- async function writeZipArchive(archive, limits, signal, descriptors = false) {
27058
+ function updateZipExtras(entry, previous, mode, limits) {
27059
+ const fresh = mode === "strip" ? new Uint8Array() : timestampExtra(entry.modified);
27060
+ const retained = [];
27061
+ for (const [original, central] of [[previous?.localExtra, false], [previous?.centralExtra, true]]) {
27062
+ const fields3 = [];
27063
+ let length = fresh.length;
27064
+ if (mode === "all" && original) {
27065
+ extras(original, previous.rawName ?? pathBytes(previous.name, limits), previous.comment ?? new Uint8Array(), central, limits);
27066
+ const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
27067
+ for (let offset2 = 0; offset2 < original.length; ) {
27068
+ const identifier = view.getUint16(offset2, true);
27069
+ const next = offset2 + 4 + view.getUint16(offset2 + 2, true);
27070
+ if (identifier !== 1 && identifier !== 21589 && identifier !== 28789 && identifier !== 25461) {
27071
+ fields3.push(original.subarray(offset2, next));
27072
+ length += next - offset2;
27073
+ }
27074
+ offset2 = next;
27075
+ }
27076
+ }
27077
+ number3(length, Math.min(limits.maxPaxBytes, 65535), "extra field");
27078
+ const bytes3 = new Uint8Array(length);
27079
+ let offset = 0;
27080
+ for (const field2 of fields3) {
27081
+ bytes3.set(field2, offset);
27082
+ offset += field2.length;
27083
+ }
27084
+ bytes3.set(fresh, offset);
27085
+ retained.push(bytes3);
27086
+ }
27087
+ return { ...entry, localExtra: retained[0], centralExtra: retained[1] };
27088
+ }
27089
+ async function* streamZipArchive(archive, limits, signal, descriptors = false, forceZip64 = false) {
27035
27090
  const chunkSize2 = admit(limits, signal);
27036
27091
  number3(archive.entries.length, Math.min(limits.maxMembers, 65534), "member");
27037
27092
  number3(archive.comment.length, Math.min(limits.maxTextBytes, 65535), "archive comment");
27038
- let length = 22 + archive.comment.length;
27093
+ const wideArchive = forceZip64 || archive.entries.some((entry) => entry.zip64);
27094
+ let length = 22 + archive.comment.length + (wideArchive ? 76 : 0);
27039
27095
  let localLength = 0;
27040
27096
  let total = 0;
27041
27097
  const encoded2 = [];
@@ -27046,17 +27102,18 @@ async function writeZipArchive(archive, limits, signal, descriptors = false) {
27046
27102
  total += entry.size;
27047
27103
  number3(total, limits.maxTotalBytes, "total byte");
27048
27104
  const rawName = entry.rawName ?? pathBytes(entry.name, limits);
27049
- const descriptor = descriptors && !entry.directory;
27105
+ const descriptor = (descriptors || entry.descriptors === true) && !entry.directory;
27050
27106
  const flags3 = (entry.flags ?? 2048) & ~8 | (descriptor ? 8 : 0);
27051
27107
  const comment2 = entry.comment ?? new Uint8Array();
27052
27108
  number3(comment2.length, Math.min(limits.maxTextBytes, 65535), "entry comment");
27053
27109
  if (flags3 & 2048) text2(comment2);
27054
27110
  const originalLocalExtra = entry.localExtra ?? timestampExtra(entry.modified);
27055
27111
  extras(originalLocalExtra, rawName, comment2, false, limits);
27056
- const localExtra = stripZip64(originalLocalExtra);
27112
+ const wide2 = forceZip64 || entry.zip64 === true;
27113
+ const localExtra = wide2 ? zip64Extra([descriptor ? 0 : entry.size, descriptor ? 0 : entry.data.length], stripZip64(originalLocalExtra)) : stripZip64(originalLocalExtra);
27057
27114
  const originalCentralExtra = entry.centralExtra ?? timestampExtra(entry.modified);
27058
27115
  extras(originalCentralExtra, rawName, comment2, true, limits);
27059
- const centralExtra = stripZip64(originalCentralExtra);
27116
+ const centralExtra = wide2 ? zip64Extra([entry.size, entry.data.length, localLength], stripZip64(originalCentralExtra)) : stripZip64(originalCentralExtra);
27060
27117
  const localMetadata = extras(localExtra, rawName, comment2, false, limits);
27061
27118
  const centralMetadata = extras(centralExtra, rawName, comment2, true, limits);
27062
27119
  if (nameFrom(rawName, flags3, centralMetadata, limits) !== entry.name || localMetadata.name !== void 0 && nameFrom(rawName, flags3, localMetadata, limits) !== entry.name || entry.localName && !equal(rawName, entry.localName)) fail("ZIP retained filename metadata mismatch");
@@ -27078,71 +27135,101 @@ async function writeZipArchive(archive, limits, signal, descriptors = false) {
27078
27135
  const mode = unixMode || (entry.directory ? 16877 : 33188);
27079
27136
  if (mode !== entry.mode || Boolean(entry.externalAttributes & 16) && !entry.directory) fail("ZIP retained file attributes mismatch");
27080
27137
  }
27081
- encoded2.push({ entry, rawName, flags: flags3, localExtra, centralExtra, comment: comment2, date: date2, time, offset: localLength });
27082
- localLength += 30 + rawName.length + localExtra.length + entry.data.length + (descriptor ? 16 : 0);
27083
- length += 76 + 2 * rawName.length + localExtra.length + centralExtra.length + comment2.length + entry.data.length + (descriptor ? 16 : 0);
27138
+ encoded2.push({ entry, rawName, wide: wide2, flags: flags3, localExtra, centralExtra, comment: comment2, date: date2, time, offset: localLength });
27139
+ localLength += 30 + rawName.length + localExtra.length + entry.data.length + (descriptor ? wide2 ? 24 : 16 : 0);
27140
+ length += 76 + 2 * rawName.length + localExtra.length + centralExtra.length + comment2.length + entry.data.length + (descriptor ? wide2 ? 24 : 16 : 0);
27084
27141
  number3(length, Math.min(limits.maxArchiveBytes, 4294967294), "archive byte");
27085
27142
  }
27086
27143
  number3(length, Math.min(limits.maxArchiveBytes, 4294967294), "archive byte");
27087
- const bytes3 = new Uint8Array(length);
27088
- const view = new DataView(bytes3.buffer);
27089
- let central = localLength;
27090
27144
  for (const item of encoded2) {
27091
27145
  await yieldTurn(signal);
27092
- const { entry, rawName, flags: flags3, localExtra, centralExtra, comment: comment2, date: date2, time, offset } = item;
27093
- const version = entry.method === 8 || flags3 & 8 ? 20 : 10;
27094
- view.setUint32(offset, 67324752, true);
27095
- view.setUint16(offset + 4, version, true);
27096
- view.setUint16(offset + 6, flags3, true);
27097
- view.setUint16(offset + 8, entry.method, true);
27098
- view.setUint16(offset + 10, time, true);
27099
- view.setUint16(offset + 12, date2, true);
27100
- view.setUint32(offset + 14, flags3 & 8 ? 0 : entry.crc32, true);
27101
- view.setUint32(offset + 18, flags3 & 8 ? 0 : entry.data.length, true);
27102
- view.setUint32(offset + 22, flags3 & 8 ? 0 : entry.size, true);
27103
- view.setUint16(offset + 26, rawName.length, true);
27104
- view.setUint16(offset + 28, localExtra.length, true);
27105
- bytes3.set(rawName, offset + 30);
27106
- bytes3.set(localExtra, offset + 30 + rawName.length);
27107
- await copyBytes(entry.data, bytes3, offset + 30 + rawName.length + localExtra.length, chunkSize2, signal);
27146
+ const { entry, rawName, wide: wide2, flags: flags3, localExtra, date: date2, time } = item;
27147
+ const offset = 0;
27148
+ const bytes4 = new Uint8Array(30 + rawName.length + localExtra.length);
27149
+ const view2 = new DataView(bytes4.buffer);
27150
+ const version = wide2 ? 45 : entry.method === 8 || flags3 & 8 ? 20 : 10;
27151
+ view2.setUint32(offset, 67324752, true);
27152
+ view2.setUint16(offset + 4, version, true);
27153
+ view2.setUint16(offset + 6, flags3, true);
27154
+ view2.setUint16(offset + 8, entry.method, true);
27155
+ view2.setUint16(offset + 10, time, true);
27156
+ view2.setUint16(offset + 12, date2, true);
27157
+ view2.setUint32(offset + 14, flags3 & 8 ? 0 : entry.crc32, true);
27158
+ view2.setUint32(offset + 18, wide2 ? 4294967295 : flags3 & 8 ? 0 : entry.data.length, true);
27159
+ view2.setUint32(offset + 22, wide2 ? 4294967295 : flags3 & 8 ? 0 : entry.size, true);
27160
+ view2.setUint16(offset + 26, rawName.length, true);
27161
+ view2.setUint16(offset + 28, localExtra.length, true);
27162
+ bytes4.set(rawName, offset + 30);
27163
+ bytes4.set(localExtra, offset + 30 + rawName.length);
27164
+ yield* wireChunks(bytes4, chunkSize2, signal);
27165
+ yield* wireChunks(entry.data, chunkSize2, signal);
27108
27166
  if (flags3 & 8) {
27109
- const descriptor = offset + 30 + rawName.length + localExtra.length + entry.data.length;
27110
- view.setUint32(descriptor, 134695760, true);
27111
- view.setUint32(descriptor + 4, entry.crc32, true);
27112
- view.setUint32(descriptor + 8, entry.data.length, true);
27113
- view.setUint32(descriptor + 12, entry.size, true);
27114
- }
27115
- view.setUint32(central, 33639248, true);
27116
- view.setUint16(central + 4, entry.versionMadeBy ?? 798, true);
27117
- view.setUint16(central + 6, version, true);
27118
- view.setUint16(central + 8, flags3, true);
27119
- view.setUint16(central + 10, entry.method, true);
27120
- view.setUint16(central + 12, time, true);
27121
- view.setUint16(central + 14, date2, true);
27122
- view.setUint32(central + 16, entry.crc32, true);
27123
- view.setUint32(central + 20, entry.data.length, true);
27124
- view.setUint32(central + 24, entry.size, true);
27125
- view.setUint16(central + 28, rawName.length, true);
27126
- view.setUint16(central + 30, centralExtra.length, true);
27127
- view.setUint16(central + 32, comment2.length, true);
27128
- view.setUint16(central + 36, entry.internalAttributes ?? 0, true);
27129
- const mode = entry.mode & 61440 ? entry.mode : entry.mode | (entry.directory ? 16384 : entry.symlink ? 40960 : 32768);
27130
- view.setUint32(central + 38, entry.externalAttributes ?? mode * 65536 + (entry.directory ? 16 : 0), true);
27131
- view.setUint32(central + 42, offset, true);
27132
- bytes3.set(rawName, central + 46);
27133
- bytes3.set(centralExtra, central + 46 + rawName.length);
27134
- bytes3.set(comment2, central + 46 + rawName.length + centralExtra.length);
27135
- central += 46 + rawName.length + centralExtra.length + comment2.length;
27167
+ const descriptor = 0;
27168
+ const bytes5 = new Uint8Array(wide2 ? 24 : 16);
27169
+ const view3 = new DataView(bytes5.buffer);
27170
+ view3.setUint32(descriptor, 134695760, true);
27171
+ view3.setUint32(descriptor + 4, entry.crc32, true);
27172
+ if (wide2) {
27173
+ view3.setBigUint64(descriptor + 8, BigInt(entry.data.length), true);
27174
+ view3.setBigUint64(descriptor + 16, BigInt(entry.size), true);
27175
+ } else {
27176
+ view3.setUint32(descriptor + 8, entry.data.length, true);
27177
+ view3.setUint32(descriptor + 12, entry.size, true);
27178
+ }
27179
+ yield* wireChunks(bytes5, chunkSize2, signal);
27180
+ }
27136
27181
  }
27182
+ let centralSize = 0;
27183
+ for (const item of encoded2) {
27184
+ await yieldTurn(signal);
27185
+ const { entry, rawName, wide: wide2, flags: flags3, centralExtra, comment: comment2, date: date2, time, offset } = item;
27186
+ const version = wide2 ? 45 : entry.method === 8 || flags3 & 8 ? 20 : 10;
27187
+ const central2 = 0;
27188
+ const bytes4 = new Uint8Array(46 + rawName.length + centralExtra.length + comment2.length);
27189
+ const view2 = new DataView(bytes4.buffer);
27190
+ view2.setUint32(central2, 33639248, true);
27191
+ view2.setUint16(central2 + 4, entry.versionMadeBy ?? 798, true);
27192
+ view2.setUint16(central2 + 6, version, true);
27193
+ view2.setUint16(central2 + 8, flags3, true);
27194
+ view2.setUint16(central2 + 10, entry.method, true);
27195
+ view2.setUint16(central2 + 12, time, true);
27196
+ view2.setUint16(central2 + 14, date2, true);
27197
+ view2.setUint32(central2 + 16, entry.crc32, true);
27198
+ view2.setUint32(central2 + 20, wide2 ? 4294967295 : entry.data.length, true);
27199
+ view2.setUint32(central2 + 24, wide2 ? 4294967295 : entry.size, true);
27200
+ view2.setUint16(central2 + 28, rawName.length, true);
27201
+ view2.setUint16(central2 + 30, centralExtra.length, true);
27202
+ view2.setUint16(central2 + 32, comment2.length, true);
27203
+ view2.setUint16(central2 + 36, entry.internalAttributes ?? 0, true);
27204
+ const mode = entry.mode & 61440 ? entry.mode : entry.mode | (entry.directory ? 16384 : entry.symlink ? 40960 : 32768);
27205
+ view2.setUint32(central2 + 38, entry.externalAttributes ?? mode * 65536 + (entry.directory ? 16 : 0), true);
27206
+ view2.setUint32(central2 + 42, wide2 ? 4294967295 : offset, true);
27207
+ bytes4.set(rawName, central2 + 46);
27208
+ bytes4.set(centralExtra, central2 + 46 + rawName.length);
27209
+ bytes4.set(comment2, central2 + 46 + rawName.length + centralExtra.length);
27210
+ centralSize += bytes4.length;
27211
+ yield* wireChunks(bytes4, chunkSize2, signal);
27212
+ }
27213
+ const bytes3 = new Uint8Array((wideArchive ? 76 : 0) + 22 + archive.comment.length);
27214
+ const view = new DataView(bytes3.buffer);
27215
+ const central = wideArchive ? writeZip64End(view, 0, encoded2.length, centralSize, localLength, localLength + centralSize) : 0;
27137
27216
  view.setUint32(central, 101010256, true);
27138
27217
  view.setUint16(central + 8, encoded2.length, true);
27139
27218
  view.setUint16(central + 10, encoded2.length, true);
27140
- view.setUint32(central + 12, central - localLength, true);
27141
- view.setUint32(central + 16, localLength, true);
27219
+ view.setUint32(central + 12, centralSize, true);
27220
+ view.setUint32(central + 16, wideArchive ? 4294967295 : localLength, true);
27142
27221
  view.setUint16(central + 20, archive.comment.length, true);
27143
27222
  bytes3.set(archive.comment, central + 22);
27144
- signal.throwIfAborted();
27145
- return bytes3;
27223
+ yield* wireChunks(bytes3, chunkSize2, signal);
27224
+ }
27225
+ async function* wireChunks(bytes3, chunkSize2, signal) {
27226
+ for (let offset = 0; offset < bytes3.length; offset += chunkSize2) {
27227
+ await yieldTurn(signal);
27228
+ yield new Uint8Array(bytes3.subarray(offset, Math.min(bytes3.length, offset + chunkSize2)));
27229
+ }
27230
+ }
27231
+ async function writeZipArchive(archive, limits, signal, descriptors = false, forceZip64 = false) {
27232
+ return collectBytes(streamZipArchive(archive, limits, signal, descriptors, forceZip64), { maxBytes: limits.maxArchiveBytes, signal });
27146
27233
  }
27147
27234
 
27148
27235
  // packages/safe-bash/src/commands/archive/zip/safety.ts
@@ -27513,7 +27600,10 @@ var longOptions = {
27513
27600
  "compress-6": "6",
27514
27601
  "compress-7": "7",
27515
27602
  "compress-8": "8",
27516
- "compress-9": "9"
27603
+ "compress-9": "9",
27604
+ "force-zip64": "fz",
27605
+ "strip-extra": "X",
27606
+ "force-descriptors": "fd"
27517
27607
  };
27518
27608
  var reservedOptions = [
27519
27609
  "adjust-sfx",
@@ -27532,8 +27622,6 @@ var reservedOptions = [
27532
27622
  "fixfix",
27533
27623
  "fifo",
27534
27624
  "filesync",
27535
- "force-descriptors",
27536
- "force-zip64",
27537
27625
  "grow",
27538
27626
  "help",
27539
27627
  "more-help",
@@ -27569,23 +27657,25 @@ var reservedOptions = [
27569
27657
  "verbose",
27570
27658
  "version",
27571
27659
  "wild-stop-dirs",
27572
- "strip-extra",
27573
27660
  "archive-comment"
27574
27661
  ];
27575
27662
  function normalizeZipOption(argument2) {
27576
27663
  if (!argument2.startsWith("--") || argument2 === "--") return argument2;
27577
27664
  const equal2 = argument2.indexOf("=");
27578
- const name2 = argument2.slice(2, equal2 < 0 ? void 0 : equal2);
27665
+ const rawName = argument2.slice(2, equal2 < 0 ? void 0 : equal2);
27666
+ const negate2 = rawName.endsWith("-");
27667
+ const name2 = negate2 ? rawName.slice(0, -1) : rawName;
27579
27668
  const names = [...Object.keys(longOptions), ...reservedOptions];
27580
27669
  const matches2 = names.includes(name2) ? [name2] : names.filter((option) => option.startsWith(name2));
27581
27670
  if (matches2.length > 1) throw new ZipFailure(16, "Invalid command arguments", `long option '${name2}' ambiguous`);
27582
27671
  const matched = matches2[0];
27583
27672
  const short = matched === void 0 ? void 0 : longOptions[matched];
27584
27673
  if (!short) throw new ZipFailure(16, "Invalid command arguments", `unsupported option: ${argument2}`);
27674
+ if (negate2 && short !== "fz" && short !== "X") throw new ZipFailure(16, "Invalid command arguments", `option ${matched} is not negatable`);
27585
27675
  if (equal2 >= 0 && short !== "i" && short !== "x" && short !== "n" && short !== "Z") {
27586
27676
  throw new ZipFailure(16, "Invalid command arguments", `option '${matched}' does not allow a value`);
27587
27677
  }
27588
- return `-${short}${equal2 < 0 ? "" : argument2.slice(equal2)}`;
27678
+ return `-${short}${negate2 ? "-" : ""}${equal2 < 0 ? "" : argument2.slice(equal2)}`;
27589
27679
  }
27590
27680
 
27591
27681
  // packages/safe-bash/src/commands/archive/zip.ts
@@ -27617,6 +27707,9 @@ async function parse12(scope, limits) {
27617
27707
  let omitDirectories = false;
27618
27708
  let storeLinks = false;
27619
27709
  let test = false;
27710
+ let descriptors = false;
27711
+ let zip64;
27712
+ let metadata3 = "default";
27620
27713
  let level = 6;
27621
27714
  let method = "deflate";
27622
27715
  let suffixes = defaultStoreSuffixes;
@@ -27637,13 +27730,23 @@ async function parse12(scope, limits) {
27637
27730
  for (let offset = 1; offset < argument2.length; offset++) {
27638
27731
  const flag = argument2[offset];
27639
27732
  if (flag === "r") recursive = true;
27640
- else if (flag === "d" || flag === "u" || flag === "f") {
27733
+ else if (flag === "f" && argument2[offset + 1] === "d") {
27734
+ if (argument2[offset + 2] === "-") throw new ZipFailure(16, "Invalid command arguments", "option fd is not negatable");
27735
+ descriptors = true;
27736
+ offset++;
27737
+ } else if (flag === "f" && argument2[offset + 1] === "z") {
27738
+ zip64 = argument2[offset + 2] !== "-";
27739
+ offset += zip64 ? 1 : 2;
27740
+ } else if (flag === "d" || flag === "u" || flag === "f") {
27641
27741
  const next = flag === "d" ? "delete" : flag === "u" ? "update" : "freshen";
27642
27742
  if (action !== "add" && action !== next) throw new ZipFailure(16, "Invalid command arguments", "specify just one action");
27643
27743
  action = next;
27644
27744
  } else if (flag === "q") quiet = true;
27645
27745
  else if (flag === "j") junkPaths = true;
27646
- else if (flag === "D") omitDirectories = true;
27746
+ else if (flag === "X") {
27747
+ metadata3 = argument2[offset + 1] === "-" ? "all" : "strip";
27748
+ if (metadata3 === "all") offset++;
27749
+ } else if (flag === "D") omitDirectories = true;
27647
27750
  else if (flag === "y") storeLinks = true;
27648
27751
  else if (flag === "T") test = true;
27649
27752
  else if (flag === "@") stdinNames = true;
@@ -27732,7 +27835,7 @@ async function parse12(scope, limits) {
27732
27835
  start = end + 1;
27733
27836
  }
27734
27837
  }
27735
- return { action, archive, recursive, quiet, junkPaths, omitDirectories, storeLinks, test, includes, excludes, level, method, suffixes, operands: [...names, ...operands], firstOperand };
27838
+ return { action, archive, recursive, quiet, junkPaths, omitDirectories, storeLinks, test, descriptors, zip64, metadata: metadata3, includes, excludes, level, method, suffixes, operands: [...names, ...operands], firstOperand };
27736
27839
  }
27737
27840
  function memberName(path, limits) {
27738
27841
  if (path.startsWith("//") && !path.startsWith("///")) fail("UNC source paths are unsupported");
@@ -27813,9 +27916,12 @@ async function prepare(scope, parsed, budget) {
27813
27916
  const store = parsed.method === "store" || parsed.level !== 9 && parsed.suffixes.some((suffix2) => name2.endsWith(suffix2));
27814
27917
  if (!store && parsed.level === 0 && bytes4.length && !attributes.directory && !attributes.symlink) throw new ZipFailure(5, "Internal logic error", "bad pack level");
27815
27918
  const level = store ? 0 : parsed.level;
27816
- let entry = await makeZipEntry(name2, bytes4, attributes, limits, context2.signal, level, parsed.archive === "-" && !store);
27919
+ let entry = await makeZipEntry(name2, bytes4, attributes, limits, context2.signal, level, !store && (parsed.archive === "-" || parsed.descriptors && bytes4.length > 0));
27920
+ if (parsed.descriptors) entry.descriptors = true;
27921
+ if (parsed.zip64 === true || parsed.zip64 === void 0 && source2 === "-") entry.zip64 = true;
27817
27922
  const prior = old.get(name2);
27818
27923
  if (prior?.comment) entry = { ...entry, comment: prior.comment };
27924
+ if (parsed.metadata !== "default") entry = updateZipExtras(entry, prior, parsed.metadata, limits);
27819
27925
  if (entry.data.length > limits.maxArchiveBytes - compressedBytes) fail("archive byte limit exceeded");
27820
27926
  compressedBytes += entry.data.length;
27821
27927
  selected.set(name2, { entry, source: source2 });
@@ -27971,7 +28077,8 @@ async function prepare(scope, parsed, budget) {
27971
28077
  append(entry, false);
27972
28078
  }
27973
28079
  if (!entries2.length) queue(" zip warning: zip file empty\n");
27974
- const bytes3 = await writeZipArchive({ entries: entries2, comment: archive.comment }, limits, context2.signal, parsed.archive === "-");
28080
+ if (parsed.archive === "-") return { kind: "stream", archive: { entries: entries2, comment: archive.comment }, progress };
28081
+ const bytes3 = await writeZipArchive({ entries: entries2, comment: archive.comment }, limits, context2.signal, false, parsed.zip64 === true);
27975
28082
  if (parsed.test && parsed.archive !== "-") {
27976
28083
  for (const message3 of progress) await budget.output(message3);
27977
28084
  progress.length = 0;
@@ -27997,7 +28104,7 @@ async function prepare(scope, parsed, budget) {
27997
28104
  `);
27998
28105
  }
27999
28106
  }
28000
- return { publication, bytes: bytes3, progress };
28107
+ return { kind: "file", publication, bytes: bytes3, progress };
28001
28108
  }
28002
28109
  function createZipCommand(options2 = {}) {
28003
28110
  const limits = settings2(options2);
@@ -28011,15 +28118,18 @@ function createZipCommand(options2 = {}) {
28011
28118
  if (parsed.archive === "-") budget = new Budget14({ ...context2, stdout: context2.stderr }, limits);
28012
28119
  const prepared = await prepare(scope, parsed, budget);
28013
28120
  if (!prepared) return { exitCode: 12 };
28014
- const publication = prepared.publication;
28015
- if (publication) {
28121
+ if (prepared.kind === "file") {
28122
+ const publication = prepared.publication;
28123
+ if (!publication) fail("ZIP missing file publication");
28016
28124
  await writeFileOutput(context2, prepared.bytes, () => scope.operation(() => publishZip(scope, { ...publication, bytes: prepared.bytes })));
28017
28125
  for (const message3 of prepared.progress) await budget.output(message3);
28018
28126
  } else {
28019
28127
  for (const message3 of prepared.progress) await budget.output(message3);
28020
28128
  const output2 = createOutputOperation(context2, context2.stdout);
28021
28129
  try {
28022
- await writeBytes(output2.output, prepared.bytes, output2.signal);
28130
+ for await (const chunk of streamZipArchive(prepared.archive, limits, output2.signal, true, parsed.zip64 === true)) {
28131
+ await writeBytes(output2.output, chunk, output2.signal);
28132
+ }
28023
28133
  } finally {
28024
28134
  await output2.close();
28025
28135
  }