@loaders.gl/i3s 4.0.0 → 4.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.
package/dist/dist.dev.js CHANGED
@@ -4435,14 +4435,14 @@ var __exports__ = (() => {
4435
4435
  return null;
4436
4436
  }
4437
4437
  async function loadAsArrayBuffer(url) {
4438
- if (!void 0 || url.startsWith("http")) {
4438
+ if (isBrowser2 || !void 0 || url.startsWith("http")) {
4439
4439
  const response = await fetch(url);
4440
4440
  return await response.arrayBuffer();
4441
4441
  }
4442
4442
  return await (void 0)(url);
4443
4443
  }
4444
4444
  async function loadAsText(url) {
4445
- if (!void 0 || url.startsWith("http")) {
4445
+ if (isBrowser2 || !void 0 || url.startsWith("http")) {
4446
4446
  const response = await fetch(url);
4447
4447
  return await response.text();
4448
4448
  }
@@ -12410,6 +12410,7 @@ var __exports__ = (() => {
12410
12410
  var CD_UNCOMPRESSED_SIZE_OFFSET = 24n;
12411
12411
  var CD_FILE_NAME_LENGTH_OFFSET = 28n;
12412
12412
  var CD_EXTRA_FIELD_LENGTH_OFFSET = 30n;
12413
+ var CD_START_DISK_OFFSET = 32n;
12413
12414
  var CD_LOCAL_HEADER_OFFSET_OFFSET = 42n;
12414
12415
  var CD_FILE_NAME_OFFSET = 46n;
12415
12416
  var signature = new Uint8Array([80, 75, 1, 2]);
@@ -12418,36 +12419,31 @@ var __exports__ = (() => {
12418
12419
  if (!compareArrayBuffers(magicBytes, signature.buffer)) {
12419
12420
  return null;
12420
12421
  }
12421
- let compressedSize = BigInt(await file.getUint32(headerOffset + CD_COMPRESSED_SIZE_OFFSET));
12422
- let uncompressedSize = BigInt(await file.getUint32(headerOffset + CD_UNCOMPRESSED_SIZE_OFFSET));
12422
+ const compressedSize = BigInt(await file.getUint32(headerOffset + CD_COMPRESSED_SIZE_OFFSET));
12423
+ const uncompressedSize = BigInt(await file.getUint32(headerOffset + CD_UNCOMPRESSED_SIZE_OFFSET));
12423
12424
  const extraFieldLength = await file.getUint16(headerOffset + CD_EXTRA_FIELD_LENGTH_OFFSET);
12425
+ const startDisk = BigInt(await file.getUint16(headerOffset + CD_START_DISK_OFFSET));
12424
12426
  const fileNameLength = await file.getUint16(headerOffset + CD_FILE_NAME_LENGTH_OFFSET);
12425
12427
  const filenameBytes = await file.slice(headerOffset + CD_FILE_NAME_OFFSET, headerOffset + CD_FILE_NAME_OFFSET + BigInt(fileNameLength));
12426
12428
  const fileName = new TextDecoder().decode(filenameBytes);
12427
12429
  const extraOffset = headerOffset + CD_FILE_NAME_OFFSET + BigInt(fileNameLength);
12428
12430
  const oldFormatOffset = await file.getUint32(headerOffset + CD_LOCAL_HEADER_OFFSET_OFFSET);
12429
- let fileDataOffset = BigInt(oldFormatOffset);
12430
- let offsetInZip64Data = 4n;
12431
- if (uncompressedSize === BigInt(4294967295)) {
12432
- uncompressedSize = await file.getBigUint64(extraOffset + offsetInZip64Data);
12433
- offsetInZip64Data += 8n;
12434
- }
12435
- if (compressedSize === BigInt(4294967295)) {
12436
- compressedSize = await file.getBigUint64(extraOffset + offsetInZip64Data);
12437
- offsetInZip64Data += 8n;
12438
- }
12439
- if (fileDataOffset === BigInt(4294967295)) {
12440
- fileDataOffset = await file.getBigUint64(extraOffset + offsetInZip64Data);
12441
- }
12442
- const localHeaderOffset = fileDataOffset;
12443
- return {
12444
- compressedSize,
12431
+ const localHeaderOffset = BigInt(oldFormatOffset);
12432
+ const extraField = new DataView(await file.slice(extraOffset, extraOffset + BigInt(extraFieldLength)));
12433
+ const zip64data = {
12445
12434
  uncompressedSize,
12435
+ compressedSize,
12436
+ localHeaderOffset,
12437
+ startDisk
12438
+ };
12439
+ const res = findZip64DataInExtra(zip64data, extraField);
12440
+ return {
12441
+ ...zip64data,
12442
+ ...res,
12446
12443
  extraFieldLength,
12447
12444
  fileNameLength,
12448
12445
  fileName,
12449
- extraOffset,
12450
- localHeaderOffset
12446
+ extraOffset
12451
12447
  };
12452
12448
  };
12453
12449
  async function* makeZipCDHeaderIterator(fileProvider) {
@@ -12460,6 +12456,52 @@ var __exports__ = (() => {
12460
12456
  cdHeader = await parseZipCDFileHeader(cdHeader.extraOffset + BigInt(cdHeader.extraFieldLength), fileProvider);
12461
12457
  }
12462
12458
  }
12459
+ var getUint16 = (...bytes) => {
12460
+ return bytes[0] + bytes[1] * 16;
12461
+ };
12462
+ var findZip64DataInExtra = (zip64data, extraField) => {
12463
+ const zip64dataList = findExpectedData(zip64data);
12464
+ const zip64DataRes = {};
12465
+ if (zip64dataList.length > 0) {
12466
+ const zip64chunkSize = zip64dataList.reduce((sum, curr) => sum + curr.length, 0);
12467
+ const offsetInExtraData = new Uint8Array(extraField.buffer).findIndex((_val, i2, arr) => getUint16(arr[i2], arr[i2 + 1]) === 1 && getUint16(arr[i2 + 2], arr[i2 + 3]) === zip64chunkSize);
12468
+ let bytesRead = 0;
12469
+ for (const note of zip64dataList) {
12470
+ const offset = bytesRead;
12471
+ zip64DataRes[note.name] = extraField.getBigUint64(offsetInExtraData + 4 + offset, true);
12472
+ bytesRead = offset + note.length;
12473
+ }
12474
+ }
12475
+ return zip64DataRes;
12476
+ };
12477
+ var findExpectedData = (zip64data) => {
12478
+ const zip64dataList = [];
12479
+ if (zip64data.uncompressedSize === BigInt(4294967295)) {
12480
+ zip64dataList.push({
12481
+ name: "uncompressedSize",
12482
+ length: 8
12483
+ });
12484
+ }
12485
+ if (zip64data.compressedSize === BigInt(4294967295)) {
12486
+ zip64dataList.push({
12487
+ name: "compressedSize",
12488
+ length: 8
12489
+ });
12490
+ }
12491
+ if (zip64data.localHeaderOffset === BigInt(4294967295)) {
12492
+ zip64dataList.push({
12493
+ name: "localHeaderOffset",
12494
+ length: 8
12495
+ });
12496
+ }
12497
+ if (zip64data.startDisk === BigInt(4294967295)) {
12498
+ zip64dataList.push({
12499
+ name: "startDisk",
12500
+ length: 4
12501
+ });
12502
+ }
12503
+ return zip64dataList;
12504
+ };
12463
12505
 
12464
12506
  // ../zip/src/parse-zip/local-file-header.ts
12465
12507
  var COMPRESSION_METHOD_OFFSET = 8n;