@loaders.gl/3d-tiles 4.0.0-beta.8 → 4.0.1

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.
Files changed (2) hide show
  1. package/dist/dist.dev.js +64 -22
  2. package/package.json +9 -9
package/dist/dist.dev.js CHANGED
@@ -4409,14 +4409,14 @@ var __exports__ = (() => {
4409
4409
  return null;
4410
4410
  }
4411
4411
  async function loadAsArrayBuffer(url) {
4412
- if (!void 0 || url.startsWith("http")) {
4412
+ if (isBrowser2 || !void 0 || url.startsWith("http")) {
4413
4413
  const response = await fetch(url);
4414
4414
  return await response.arrayBuffer();
4415
4415
  }
4416
4416
  return await (void 0)(url);
4417
4417
  }
4418
4418
  async function loadAsText(url) {
4419
- if (!void 0 || url.startsWith("http")) {
4419
+ if (isBrowser2 || !void 0 || url.startsWith("http")) {
4420
4420
  const response = await fetch(url);
4421
4421
  return await response.text();
4422
4422
  }
@@ -18305,6 +18305,7 @@ var __exports__ = (() => {
18305
18305
  var CD_UNCOMPRESSED_SIZE_OFFSET = 24n;
18306
18306
  var CD_FILE_NAME_LENGTH_OFFSET = 28n;
18307
18307
  var CD_EXTRA_FIELD_LENGTH_OFFSET = 30n;
18308
+ var CD_START_DISK_OFFSET = 32n;
18308
18309
  var CD_LOCAL_HEADER_OFFSET_OFFSET = 42n;
18309
18310
  var CD_FILE_NAME_OFFSET = 46n;
18310
18311
  var signature = new Uint8Array([80, 75, 1, 2]);
@@ -18313,36 +18314,31 @@ var __exports__ = (() => {
18313
18314
  if (!compareArrayBuffers(magicBytes, signature.buffer)) {
18314
18315
  return null;
18315
18316
  }
18316
- let compressedSize = BigInt(await file.getUint32(headerOffset + CD_COMPRESSED_SIZE_OFFSET));
18317
- let uncompressedSize = BigInt(await file.getUint32(headerOffset + CD_UNCOMPRESSED_SIZE_OFFSET));
18317
+ const compressedSize = BigInt(await file.getUint32(headerOffset + CD_COMPRESSED_SIZE_OFFSET));
18318
+ const uncompressedSize = BigInt(await file.getUint32(headerOffset + CD_UNCOMPRESSED_SIZE_OFFSET));
18318
18319
  const extraFieldLength = await file.getUint16(headerOffset + CD_EXTRA_FIELD_LENGTH_OFFSET);
18320
+ const startDisk = BigInt(await file.getUint16(headerOffset + CD_START_DISK_OFFSET));
18319
18321
  const fileNameLength = await file.getUint16(headerOffset + CD_FILE_NAME_LENGTH_OFFSET);
18320
18322
  const filenameBytes = await file.slice(headerOffset + CD_FILE_NAME_OFFSET, headerOffset + CD_FILE_NAME_OFFSET + BigInt(fileNameLength));
18321
18323
  const fileName = new TextDecoder().decode(filenameBytes);
18322
18324
  const extraOffset = headerOffset + CD_FILE_NAME_OFFSET + BigInt(fileNameLength);
18323
18325
  const oldFormatOffset = await file.getUint32(headerOffset + CD_LOCAL_HEADER_OFFSET_OFFSET);
18324
- let fileDataOffset = BigInt(oldFormatOffset);
18325
- let offsetInZip64Data = 4n;
18326
- if (uncompressedSize === BigInt(4294967295)) {
18327
- uncompressedSize = await file.getBigUint64(extraOffset + offsetInZip64Data);
18328
- offsetInZip64Data += 8n;
18329
- }
18330
- if (compressedSize === BigInt(4294967295)) {
18331
- compressedSize = await file.getBigUint64(extraOffset + offsetInZip64Data);
18332
- offsetInZip64Data += 8n;
18333
- }
18334
- if (fileDataOffset === BigInt(4294967295)) {
18335
- fileDataOffset = await file.getBigUint64(extraOffset + offsetInZip64Data);
18336
- }
18337
- const localHeaderOffset = fileDataOffset;
18338
- return {
18339
- compressedSize,
18326
+ const localHeaderOffset = BigInt(oldFormatOffset);
18327
+ const extraField = new DataView(await file.slice(extraOffset, extraOffset + BigInt(extraFieldLength)));
18328
+ const zip64data = {
18340
18329
  uncompressedSize,
18330
+ compressedSize,
18331
+ localHeaderOffset,
18332
+ startDisk
18333
+ };
18334
+ const res = findZip64DataInExtra(zip64data, extraField);
18335
+ return {
18336
+ ...zip64data,
18337
+ ...res,
18341
18338
  extraFieldLength,
18342
18339
  fileNameLength,
18343
18340
  fileName,
18344
- extraOffset,
18345
- localHeaderOffset
18341
+ extraOffset
18346
18342
  };
18347
18343
  };
18348
18344
  async function* makeZipCDHeaderIterator(fileProvider) {
@@ -18355,6 +18351,52 @@ var __exports__ = (() => {
18355
18351
  cdHeader = await parseZipCDFileHeader(cdHeader.extraOffset + BigInt(cdHeader.extraFieldLength), fileProvider);
18356
18352
  }
18357
18353
  }
18354
+ var getUint16 = (...bytes) => {
18355
+ return bytes[0] + bytes[1] * 16;
18356
+ };
18357
+ var findZip64DataInExtra = (zip64data, extraField) => {
18358
+ const zip64dataList = findExpectedData(zip64data);
18359
+ const zip64DataRes = {};
18360
+ if (zip64dataList.length > 0) {
18361
+ const zip64chunkSize = zip64dataList.reduce((sum, curr) => sum + curr.length, 0);
18362
+ 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);
18363
+ let bytesRead = 0;
18364
+ for (const note of zip64dataList) {
18365
+ const offset = bytesRead;
18366
+ zip64DataRes[note.name] = extraField.getBigUint64(offsetInExtraData + 4 + offset, true);
18367
+ bytesRead = offset + note.length;
18368
+ }
18369
+ }
18370
+ return zip64DataRes;
18371
+ };
18372
+ var findExpectedData = (zip64data) => {
18373
+ const zip64dataList = [];
18374
+ if (zip64data.uncompressedSize === BigInt(4294967295)) {
18375
+ zip64dataList.push({
18376
+ name: "uncompressedSize",
18377
+ length: 8
18378
+ });
18379
+ }
18380
+ if (zip64data.compressedSize === BigInt(4294967295)) {
18381
+ zip64dataList.push({
18382
+ name: "compressedSize",
18383
+ length: 8
18384
+ });
18385
+ }
18386
+ if (zip64data.localHeaderOffset === BigInt(4294967295)) {
18387
+ zip64dataList.push({
18388
+ name: "localHeaderOffset",
18389
+ length: 8
18390
+ });
18391
+ }
18392
+ if (zip64data.startDisk === BigInt(4294967295)) {
18393
+ zip64dataList.push({
18394
+ name: "startDisk",
18395
+ length: 4
18396
+ });
18397
+ }
18398
+ return zip64dataList;
18399
+ };
18358
18400
 
18359
18401
  // ../zip/src/parse-zip/local-file-header.ts
18360
18402
  var COMPRESSION_METHOD_OFFSET = 8n;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/3d-tiles",
3
- "version": "4.0.0-beta.8",
3
+ "version": "4.0.1",
4
4
  "description": "3D Tiles, an open standard for streaming massive heterogeneous 3D geospatial datasets.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -42,19 +42,19 @@
42
42
  "build-bundle": "ocular-bundle ./src/index.ts"
43
43
  },
44
44
  "dependencies": {
45
- "@loaders.gl/draco": "4.0.0-beta.8",
46
- "@loaders.gl/gltf": "4.0.0-beta.8",
47
- "@loaders.gl/loader-utils": "4.0.0-beta.8",
48
- "@loaders.gl/math": "4.0.0-beta.8",
49
- "@loaders.gl/tiles": "4.0.0-beta.8",
50
- "@loaders.gl/zip": "4.0.0-beta.8",
45
+ "@loaders.gl/draco": "4.0.1",
46
+ "@loaders.gl/gltf": "4.0.1",
47
+ "@loaders.gl/loader-utils": "4.0.1",
48
+ "@loaders.gl/math": "4.0.1",
49
+ "@loaders.gl/tiles": "4.0.1",
50
+ "@loaders.gl/zip": "4.0.1",
51
51
  "@math.gl/core": "^4.0.0",
52
52
  "@math.gl/geospatial": "^4.0.0",
53
53
  "@probe.gl/log": "^4.0.4",
54
54
  "long": "^5.2.1"
55
55
  },
56
56
  "peerDependencies": {
57
- "@loaders.gl/core": "4.0.0-beta.6"
57
+ "@loaders.gl/core": "4.0.0-beta.8"
58
58
  },
59
- "gitHead": "ec3d1747b4c01c52a235455d6462680e711b4e19"
59
+ "gitHead": "765e5a26a6bf3f2cc02cabffc4a1e3665ec92a53"
60
60
  }