@loaders.gl/i3s 4.2.0-alpha.5 → 4.2.0-alpha.6

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,7 +1,7 @@
1
1
  import { parseWebscene } from "./lib/parsers/parse-arcgis-webscene.js";
2
2
  // __VERSION__ is injected by babel-plugin-version-inline
3
3
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
4
- const VERSION = typeof "4.2.0-alpha.4" !== 'undefined' ? "4.2.0-alpha.4" : 'latest';
4
+ const VERSION = typeof "4.2.0-alpha.5" !== 'undefined' ? "4.2.0-alpha.5" : 'latest';
5
5
  /**
6
6
  * Loader for ArcGIS WebScene
7
7
  * Spec - https://developers.arcgis.com/web-scene-specification/objects/webscene/
package/dist/dist.dev.js CHANGED
@@ -4600,10 +4600,11 @@ var __exports__ = (() => {
4600
4600
  // ../loader-utils/src/lib/files/node-file-facade.ts
4601
4601
  var NOT_IMPLEMENTED = new Error("Not implemented");
4602
4602
  var NodeFileFacade = class {
4603
+ handle;
4604
+ size = 0;
4605
+ bigsize = 0n;
4606
+ url = "";
4603
4607
  constructor(url, flags, mode) {
4604
- this.size = 0;
4605
- this.bigsize = 0n;
4606
- this.url = "";
4607
4608
  if (globalThis.loaders?.NodeFile) {
4608
4609
  return new globalThis.loaders.NodeFile(url, flags, mode);
4609
4610
  }
@@ -4644,6 +4645,8 @@ var __exports__ = (() => {
4644
4645
 
4645
4646
  // ../loader-utils/src/lib/file-provider/file-handle-file.ts
4646
4647
  var FileHandleFile = class {
4648
+ /** The FileHandle from which data is provided */
4649
+ file;
4647
4650
  /** Create a new FileHandleFile */
4648
4651
  constructor(path, append = false) {
4649
4652
  this.file = new NodeFileFacade(path, append ? "a+" : "r");
@@ -4743,6 +4746,8 @@ var __exports__ = (() => {
4743
4746
  return Number(bigint);
4744
4747
  };
4745
4748
  var DataViewFile = class {
4749
+ /** The DataView from which data is provided */
4750
+ file;
4746
4751
  constructor(file) {
4747
4752
  this.file = file;
4748
4753
  }
@@ -9865,6 +9870,9 @@ var __exports__ = (() => {
9865
9870
  };
9866
9871
  var INDEX_ITEM_SIZE = 4;
9867
9872
  var DracoParser = class {
9873
+ draco;
9874
+ decoder;
9875
+ metadataQuerier;
9868
9876
  // draco - the draco decoder, either import `draco3d` or load dynamically
9869
9877
  constructor(draco) {
9870
9878
  this.draco = draco;
@@ -11492,11 +11500,7 @@ var __exports__ = (() => {
11492
11500
  texture: null
11493
11501
  };
11494
11502
  if (tileOptions.textureUrl) {
11495
- const url = getUrlWithToken(
11496
- getInternalPathFromUrl(tileOptions.textureUrl),
11497
- // @ts-expect-error options is not properly typed
11498
- options?.i3s?.token
11499
- );
11503
+ const url = getUrlWithToken(tileOptions.textureUrl, options?.i3s?.token);
11500
11504
  const loader = getLoaderForTextureFormat(tileOptions.textureFormat);
11501
11505
  const fetchFunc = context?.fetch || fetch;
11502
11506
  const response = await fetchFunc(url);
@@ -11534,18 +11538,6 @@ var __exports__ = (() => {
11534
11538
  }
11535
11539
  return await parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options);
11536
11540
  }
11537
- function getInternalPathFromUrl(url) {
11538
- const slpkUrlParts = url.split(".slpk");
11539
- let filename;
11540
- if (slpkUrlParts.length === 1) {
11541
- filename = url;
11542
- } else if (slpkUrlParts.length === 2) {
11543
- filename = slpkUrlParts[1].slice(1);
11544
- } else {
11545
- filename = url;
11546
- }
11547
- return filename;
11548
- }
11549
11541
  async function parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options) {
11550
11542
  const contentByteLength = arrayBuffer.byteLength;
11551
11543
  let attributes;
@@ -11673,11 +11665,11 @@ var __exports__ = (() => {
11673
11665
  for (const { property, type } of options.store.defaultGeometrySchema.header) {
11674
11666
  const TypedArrayTypeHeader = getConstructorForDataFormat(type);
11675
11667
  switch (property) {
11676
- case "vertexCount" /* vertexCount */:
11668
+ case "vertexCount" /* vertexCount */.toString():
11677
11669
  vertexCount = new TypedArrayTypeHeader(arrayBuffer, 0, 4)[0];
11678
11670
  byteOffset += sizeOf(type);
11679
11671
  break;
11680
- case "featureCount" /* featureCount */:
11672
+ case "featureCount" /* featureCount */.toString():
11681
11673
  featureCount = new TypedArrayTypeHeader(arrayBuffer, 4, 4)[0];
11682
11674
  byteOffset += sizeOf(type);
11683
11675
  break;
@@ -12381,6 +12373,16 @@ var __exports__ = (() => {
12381
12373
 
12382
12374
  // src/lib/helpers/i3s-nodepages-tiles.ts
12383
12375
  var I3SNodePagesTiles = class {
12376
+ tileset;
12377
+ nodePages = [];
12378
+ pendingNodePages = [];
12379
+ nodesPerPage;
12380
+ options;
12381
+ lodSelectionMetricType;
12382
+ textureDefinitionsSelectedFormats = [];
12383
+ nodesInNodePages;
12384
+ url;
12385
+ textureLoaderOptions = {};
12384
12386
  /**
12385
12387
  * @constructs
12386
12388
  * Create a I3SNodePagesTiles instance.
@@ -12389,10 +12391,6 @@ var __exports__ = (() => {
12389
12391
  * @param options - i3s loader options
12390
12392
  */
12391
12393
  constructor(tileset, url = "", options) {
12392
- this.nodePages = [];
12393
- this.pendingNodePages = [];
12394
- this.textureDefinitionsSelectedFormats = [];
12395
- this.textureLoaderOptions = {};
12396
12394
  this.tileset = { ...tileset };
12397
12395
  this.url = url;
12398
12396
  this.nodesPerPage = tileset.nodePages?.nodesPerPage || 64;
@@ -12409,7 +12407,7 @@ var __exports__ = (() => {
12409
12407
  const pageIndex = Math.floor(id / this.nodesPerPage);
12410
12408
  if (!this.nodePages[pageIndex] && !this.pendingNodePages[pageIndex]) {
12411
12409
  const nodePageUrl = getUrlWithToken(
12412
- this.url.indexOf(".slpk") !== -1 ? `nodepages/${pageIndex}` : `${this.url}/nodepages/${pageIndex}`,
12410
+ `${this.url}/nodepages/${pageIndex}`,
12413
12411
  // @ts-expect-error this.options is not properly typed
12414
12412
  this.options.i3s?.token
12415
12413
  );
@@ -12712,6 +12710,7 @@ var __exports__ = (() => {
12712
12710
  // src/i3s-loader.ts
12713
12711
  var VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
12714
12712
  var TILESET_REGEX = /layers\/[0-9]+$/;
12713
+ var LOCAL_SLPK_REGEX = /\.slpk$/;
12715
12714
  var TILE_HEADER_REGEX = /nodes\/([0-9-]+|root)$/;
12716
12715
  var SLPK_HEX = "504b0304";
12717
12716
  var POINT_CLOUD = "PointCloud";
@@ -12749,7 +12748,7 @@ var __exports__ = (() => {
12749
12748
  const urlWithoutParams = getUrlWithoutParams(url);
12750
12749
  let isTileset;
12751
12750
  if (options.i3s.isTileset === "auto") {
12752
- isTileset = TILESET_REGEX.test(urlWithoutParams);
12751
+ isTileset = TILESET_REGEX.test(urlWithoutParams) || LOCAL_SLPK_REGEX.test(urlWithoutParams);
12753
12752
  } else {
12754
12753
  isTileset = options.i3s.isTileset;
12755
12754
  }
@@ -13810,9 +13809,10 @@ var __exports__ = (() => {
13810
13809
 
13811
13810
  // ../crypto/src/lib/md5-hash.ts
13812
13811
  var MD5Hash = class extends Hash {
13812
+ name = "md5";
13813
+ options;
13813
13814
  constructor(options = {}) {
13814
13815
  super();
13815
- this.name = "md5";
13816
13816
  this.options = options;
13817
13817
  }
13818
13818
  /**
@@ -13885,13 +13885,14 @@ var __exports__ = (() => {
13885
13885
  var import_pako = __toESM(require_pako(), 1);
13886
13886
  var import_zlib = __toESM(require_zlib(), 1);
13887
13887
  var DeflateCompression = class extends Compression {
13888
+ name = "deflate";
13889
+ extensions = [];
13890
+ contentEncodings = ["deflate"];
13891
+ isSupported = true;
13892
+ options;
13893
+ _chunks = [];
13888
13894
  constructor(options = {}) {
13889
13895
  super(options);
13890
- this.name = "deflate";
13891
- this.extensions = [];
13892
- this.contentEncodings = ["deflate"];
13893
- this.isSupported = true;
13894
- this._chunks = [];
13895
13896
  this.options = options;
13896
13897
  }
13897
13898
  async compress(input) {
@@ -13998,12 +13999,12 @@ var __exports__ = (() => {
13998
13999
 
13999
14000
  // ../compression/src/lib/gzip-compression.ts
14000
14001
  var GZipCompression = class extends DeflateCompression {
14002
+ name = "gzip";
14003
+ extensions = ["gz", "gzip"];
14004
+ contentEncodings = ["gzip", "x-gzip"];
14005
+ isSupported = true;
14001
14006
  constructor(options) {
14002
14007
  super({ ...options, deflate: { ...options?.gzip, gzip: true } });
14003
- this.name = "gzip";
14004
- this.extensions = ["gz", "gzip"];
14005
- this.contentEncodings = ["gzip", "x-gzip"];
14006
- this.isSupported = true;
14007
14008
  }
14008
14009
  };
14009
14010
 
@@ -14019,14 +14020,15 @@ var __exports__ = (() => {
14019
14020
  }
14020
14021
  };
14021
14022
  var ZipFileSystem = class {
14023
+ /** FileProvider instance promise */
14024
+ fileProvider = null;
14025
+ fileName;
14026
+ archive = null;
14022
14027
  /**
14023
14028
  * Constructor
14024
14029
  * @param file - instance of FileProvider or file path string
14025
14030
  */
14026
14031
  constructor(file) {
14027
- /** FileProvider instance promise */
14028
- this.fileProvider = null;
14029
- this.archive = null;
14030
14032
  if (typeof file === "string") {
14031
14033
  this.fileName = file;
14032
14034
  if (!isBrowser) {
@@ -14078,6 +14080,9 @@ var __exports__ = (() => {
14078
14080
  * @returns - Response with file data
14079
14081
  */
14080
14082
  async fetch(filename) {
14083
+ if (this.fileName && filename.indexOf(this.fileName) === 0) {
14084
+ filename = filename.substring(this.fileName.length + 1);
14085
+ }
14081
14086
  let uncompressedFile;
14082
14087
  if (this.archive) {
14083
14088
  uncompressedFile = await this.archive.getFile(filename, "http");
@@ -14135,6 +14140,8 @@ var __exports__ = (() => {
14135
14140
 
14136
14141
  // ../zip/src/filesystems/IndexedArchive.ts
14137
14142
  var IndexedArchive = class {
14143
+ fileProvider;
14144
+ fileName;
14138
14145
  /**
14139
14146
  * Constructor
14140
14147
  * @param fileProvider - instance of a binary data reader
@@ -14224,6 +14231,11 @@ var __exports__ = (() => {
14224
14231
  }
14225
14232
  ];
14226
14233
  var SLPKArchive = class extends IndexedArchive {
14234
+ // Maps hex-encoded md5 filename hashes to bigint offsets into the archive
14235
+ hashTable;
14236
+ _textEncoder = new TextEncoder();
14237
+ _textDecoder = new TextDecoder();
14238
+ _md5Hash = new MD5Hash();
14227
14239
  /**
14228
14240
  * Constructor
14229
14241
  * @param fileProvider - instance of a binary data reader
@@ -14232,9 +14244,6 @@ var __exports__ = (() => {
14232
14244
  */
14233
14245
  constructor(fileProvider, hashTable, fileName) {
14234
14246
  super(fileProvider, hashTable, fileName);
14235
- this._textEncoder = new TextEncoder();
14236
- this._textDecoder = new TextDecoder();
14237
- this._md5Hash = new MD5Hash();
14238
14247
  this.hashTable = hashTable;
14239
14248
  }
14240
14249
  /**