@zip.js/zip.js 2.7.67 → 2.7.69

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.
package/dist/zip-fs.js CHANGED
@@ -2905,11 +2905,18 @@
2905
2905
  if (eocdCache && index == size - END_OF_CENTRAL_DIR_LENGTH && length == END_OF_CENTRAL_DIR_LENGTH) {
2906
2906
  return eocdCache;
2907
2907
  }
2908
- const response = await sendRequest(HTTP_METHOD_GET, httpReader, getRangeHeaders(httpReader, index, length));
2909
- if (response.status != 206) {
2910
- throw new Error(ERR_HTTP_RANGE);
2908
+ if (index >= size) {
2909
+ return new Uint8Array();
2910
+ } else {
2911
+ if (index + length > size) {
2912
+ length = size - index;
2913
+ }
2914
+ const response = await sendRequest(HTTP_METHOD_GET, httpReader, getRangeHeaders(httpReader, index, length));
2915
+ if (response.status != 206) {
2916
+ throw new Error(ERR_HTTP_RANGE);
2917
+ }
2918
+ return new Uint8Array(await response.arrayBuffer());
2911
2919
  }
2912
- return new Uint8Array(await response.arrayBuffer());
2913
2920
  } else {
2914
2921
  const { data } = httpReader;
2915
2922
  if (!data) {
@@ -4660,7 +4667,7 @@
4660
4667
  if (zip64) {
4661
4668
  updateZip64ExtraField(fileEntry);
4662
4669
  }
4663
- updateLocalHeader(fileEntry, localHeaderView);
4670
+ updateLocalHeader(fileEntry, localHeaderView, options);
4664
4671
  await skipDiskIfNeeded(writable);
4665
4672
  await writeData(writer, localHeaderArray);
4666
4673
  await blob.stream().pipeTo(writable, { preventClose: true, preventAbort: true, signal });
@@ -5054,6 +5061,10 @@
5054
5061
  arraySet(localHeaderArray, rawExtraFieldNTFS, localHeaderOffset);
5055
5062
  localHeaderOffset += getLength(rawExtraFieldNTFS);
5056
5063
  arraySet(localHeaderArray, rawExtraField, localHeaderOffset);
5064
+ if (dataDescriptor) {
5065
+ setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + 4, 0);
5066
+ setUint32(localHeaderView, HEADER_OFFSET_UNCOMPRESSED_SIZE + 4, 0);
5067
+ }
5057
5068
  return {
5058
5069
  localHeaderArray,
5059
5070
  localHeaderView,
@@ -5160,7 +5171,6 @@
5160
5171
 
5161
5172
  function updateLocalHeader({
5162
5173
  rawFilename,
5163
- dataDescriptor,
5164
5174
  encrypted,
5165
5175
  zip64,
5166
5176
  localExtraFieldZip64Length,
@@ -5173,7 +5183,7 @@
5173
5183
  zip64CompressedSize,
5174
5184
  zip64Offset,
5175
5185
  zip64DiskNumberStart
5176
- }, localHeaderView) {
5186
+ }, localHeaderView, { dataDescriptor }) {
5177
5187
  if (!dataDescriptor) {
5178
5188
  if (!encrypted) {
5179
5189
  setUint32(localHeaderView, HEADER_OFFSET_SIGNATURE + 4, signature);