@loaders.gl/3d-tiles 4.4.0-alpha.2 → 4.4.0-alpha.9

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 (121) hide show
  1. package/README.md +1 -1
  2. package/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts +3 -3
  3. package/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts.map +1 -1
  4. package/dist/3d-tiles-archive/3d-tiles-archive-archive.js +5 -4
  5. package/dist/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -0
  6. package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts +3 -3
  7. package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts.map +1 -1
  8. package/dist/3d-tiles-archive/3d-tiles-archive-parser.js +4 -3
  9. package/dist/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -0
  10. package/dist/3d-tiles-archive-loader.d.ts.map +1 -1
  11. package/dist/3d-tiles-archive-loader.js +4 -3
  12. package/dist/3d-tiles-archive-loader.js.map +1 -0
  13. package/dist/cesium-ion-loader.d.ts +2 -2
  14. package/dist/cesium-ion-loader.d.ts.map +1 -1
  15. package/dist/cesium-ion-loader.js +1 -0
  16. package/dist/cesium-ion-loader.js.map +1 -0
  17. package/dist/dist.dev.js +463 -321
  18. package/dist/dist.min.js +1 -1
  19. package/dist/index.cjs +37 -27
  20. package/dist/index.cjs.map +4 -4
  21. package/dist/index.js +1 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/lib/classes/helpers/tile-3d-accessor-utils.js +1 -0
  24. package/dist/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -0
  25. package/dist/lib/classes/tile-3d-batch-table-hierarchy.js +1 -0
  26. package/dist/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -0
  27. package/dist/lib/classes/tile-3d-batch-table.js +1 -0
  28. package/dist/lib/classes/tile-3d-batch-table.js.map +1 -0
  29. package/dist/lib/classes/tile-3d-feature-table.d.ts.map +1 -1
  30. package/dist/lib/classes/tile-3d-feature-table.js +14 -1
  31. package/dist/lib/classes/tile-3d-feature-table.js.map +1 -0
  32. package/dist/lib/constants.js +1 -0
  33. package/dist/lib/constants.js.map +1 -0
  34. package/dist/lib/encoders/encode-3d-tile-batched-model.js +1 -0
  35. package/dist/lib/encoders/encode-3d-tile-batched-model.js.map +1 -0
  36. package/dist/lib/encoders/encode-3d-tile-composite.js +1 -0
  37. package/dist/lib/encoders/encode-3d-tile-composite.js.map +1 -0
  38. package/dist/lib/encoders/encode-3d-tile-instanced-model.js +1 -0
  39. package/dist/lib/encoders/encode-3d-tile-instanced-model.js.map +1 -0
  40. package/dist/lib/encoders/encode-3d-tile-point-cloud.js +1 -0
  41. package/dist/lib/encoders/encode-3d-tile-point-cloud.js.map +1 -0
  42. package/dist/lib/encoders/encode-3d-tile.js +1 -0
  43. package/dist/lib/encoders/encode-3d-tile.js.map +1 -0
  44. package/dist/lib/encoders/helpers/encode-3d-tile-header.js +1 -0
  45. package/dist/lib/encoders/helpers/encode-3d-tile-header.js.map +1 -0
  46. package/dist/lib/ion/ion.js +1 -0
  47. package/dist/lib/ion/ion.js.map +1 -0
  48. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js +1 -0
  49. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -0
  50. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js +1 -0
  51. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -0
  52. package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js +1 -0
  53. package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -0
  54. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js +1 -0
  55. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -0
  56. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts.map +1 -1
  57. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +3 -1
  58. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -0
  59. package/dist/lib/parsers/helpers/parse-3d-tile-header.js +1 -0
  60. package/dist/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -0
  61. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +1 -0
  62. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -0
  63. package/dist/lib/parsers/helpers/parse-3d-tile-tables.js +1 -0
  64. package/dist/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -0
  65. package/dist/lib/parsers/helpers/parse-utils.js +1 -0
  66. package/dist/lib/parsers/helpers/parse-utils.js.map +1 -0
  67. package/dist/lib/parsers/parse-3d-tile-batched-model.js +1 -0
  68. package/dist/lib/parsers/parse-3d-tile-batched-model.js.map +1 -0
  69. package/dist/lib/parsers/parse-3d-tile-composite.js +1 -0
  70. package/dist/lib/parsers/parse-3d-tile-composite.js.map +1 -0
  71. package/dist/lib/parsers/parse-3d-tile-gltf.js +1 -0
  72. package/dist/lib/parsers/parse-3d-tile-gltf.js.map +1 -0
  73. package/dist/lib/parsers/parse-3d-tile-header.d.ts +2 -2
  74. package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
  75. package/dist/lib/parsers/parse-3d-tile-header.js +1 -0
  76. package/dist/lib/parsers/parse-3d-tile-header.js.map +1 -0
  77. package/dist/lib/parsers/parse-3d-tile-instanced-model.js +1 -0
  78. package/dist/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -0
  79. package/dist/lib/parsers/parse-3d-tile-point-cloud.js +1 -0
  80. package/dist/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -0
  81. package/dist/lib/parsers/parse-3d-tile.js +1 -0
  82. package/dist/lib/parsers/parse-3d-tile.js.map +1 -0
  83. package/dist/lib/utils/obb/s2-corners-to-obb.js +1 -0
  84. package/dist/lib/utils/obb/s2-corners-to-obb.js.map +1 -0
  85. package/dist/lib/utils/s2/converters/s2-to-boundary.js +1 -0
  86. package/dist/lib/utils/s2/converters/s2-to-boundary.js.map +1 -0
  87. package/dist/lib/utils/s2/converters/s2-to-obb-points.js +1 -0
  88. package/dist/lib/utils/s2/converters/s2-to-obb-points.js.map +1 -0
  89. package/dist/lib/utils/s2/converters/s2-to-region.js +1 -0
  90. package/dist/lib/utils/s2/converters/s2-to-region.js.map +1 -0
  91. package/dist/lib/utils/s2/index.js +1 -0
  92. package/dist/lib/utils/s2/index.js.map +1 -0
  93. package/dist/lib/utils/s2/s2-geometry-functions.js +1 -0
  94. package/dist/lib/utils/s2/s2-geometry-functions.js.map +1 -0
  95. package/dist/lib/utils/s2/s2-token-functions.js +1 -0
  96. package/dist/lib/utils/s2/s2-token-functions.js.map +1 -0
  97. package/dist/lib/utils/s2/s2geometry/s2-cell-utils.js +1 -0
  98. package/dist/lib/utils/s2/s2geometry/s2-cell-utils.js.map +1 -0
  99. package/dist/lib/utils/s2/s2geometry/s2-geometry.js +1 -0
  100. package/dist/lib/utils/s2/s2geometry/s2-geometry.js.map +1 -0
  101. package/dist/lib/utils/version.js +2 -1
  102. package/dist/lib/utils/version.js.map +1 -0
  103. package/dist/tile-3d-subtree-loader.js +1 -0
  104. package/dist/tile-3d-subtree-loader.js.map +1 -0
  105. package/dist/tile-3d-writer.js +1 -0
  106. package/dist/tile-3d-writer.js.map +1 -0
  107. package/dist/tiles-3d-loader.d.ts +2 -2
  108. package/dist/tiles-3d-loader.d.ts.map +1 -1
  109. package/dist/tiles-3d-loader.js +1 -0
  110. package/dist/tiles-3d-loader.js.map +1 -0
  111. package/dist/types.js +1 -0
  112. package/dist/types.js.map +1 -0
  113. package/package.json +11 -11
  114. package/src/3d-tiles-archive/3d-tiles-archive-archive.ts +7 -10
  115. package/src/3d-tiles-archive/3d-tiles-archive-parser.ts +7 -5
  116. package/src/3d-tiles-archive-loader.ts +4 -2
  117. package/src/cesium-ion-loader.ts +2 -2
  118. package/src/lib/classes/tile-3d-feature-table.ts +11 -1
  119. package/src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts +2 -1
  120. package/src/lib/parsers/parse-3d-tile-header.ts +2 -2
  121. package/src/tiles-3d-loader.ts +2 -2
package/dist/dist.dev.js CHANGED
@@ -4730,6 +4730,9 @@ var __exports__ = (() => {
4730
4730
  // ../../node_modules/@probe.gl/log/dist/index.js
4731
4731
  var dist_default = new Log({ id: "@probe.gl/log" });
4732
4732
 
4733
+ // ../loader-utils/src/lib/javascript-utils/is-type.ts
4734
+ var isSharedArrayBuffer = (value) => typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer;
4735
+
4733
4736
  // ../loader-utils/src/lib/module-utils/js-module-utils.ts
4734
4737
  function registerJSModules(modules) {
4735
4738
  globalThis.loaders ||= {};
@@ -4745,14 +4748,16 @@ var __exports__ = (() => {
4745
4748
  var NPM_TAG = "beta";
4746
4749
 
4747
4750
  // ../worker-utils/src/lib/env-utils/version.ts
4751
+ var warningIssued = false;
4748
4752
  function getVersion() {
4749
4753
  if (!globalThis._loadersgl_?.version) {
4750
4754
  globalThis._loadersgl_ = globalThis._loadersgl_ || {};
4751
- if (typeof __VERSION__ === "undefined") {
4755
+ if (typeof __VERSION__ === "undefined" && !warningIssued) {
4752
4756
  console.warn(
4753
4757
  "loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN."
4754
4758
  );
4755
4759
  globalThis._loadersgl_.version = NPM_TAG;
4760
+ warningIssued = true;
4756
4761
  } else {
4757
4762
  globalThis._loadersgl_.version = __VERSION__;
4758
4763
  }
@@ -4799,6 +4804,9 @@ var __exports__ = (() => {
4799
4804
  return await loadLibraryPromises[libraryUrl];
4800
4805
  }
4801
4806
  function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
4807
+ if (options?.core) {
4808
+ throw new Error("loadLibrary: options.core must be pre-normalized");
4809
+ }
4802
4810
  if (!options.useLocalLibraries && library.startsWith("http")) {
4803
4811
  return library;
4804
4812
  }
@@ -4824,10 +4832,20 @@ var __exports__ = (() => {
4824
4832
  return await loadAsArrayBuffer(libraryUrl);
4825
4833
  }
4826
4834
  if (!isBrowser3) {
4835
+ const { requireFromFile } = globalThis.loaders || {};
4827
4836
  try {
4828
- const { requireFromFile } = globalThis.loaders || {};
4829
- return await requireFromFile?.(libraryUrl);
4837
+ const result = await requireFromFile?.(libraryUrl);
4838
+ if (result || !libraryUrl.includes("/dist/libs/")) {
4839
+ return result;
4840
+ }
4841
+ return await requireFromFile?.(libraryUrl.replace("/dist/libs/", "/src/libs/"));
4830
4842
  } catch (error) {
4843
+ if (libraryUrl.includes("/dist/libs/")) {
4844
+ try {
4845
+ return await requireFromFile?.(libraryUrl.replace("/dist/libs/", "/src/libs/"));
4846
+ } catch {
4847
+ }
4848
+ }
4831
4849
  console.error(error);
4832
4850
  return null;
4833
4851
  }
@@ -4863,7 +4881,14 @@ var __exports__ = (() => {
4863
4881
  const response = await fetch(url);
4864
4882
  return await response.arrayBuffer();
4865
4883
  }
4866
- return await readFileAsArrayBuffer(url);
4884
+ try {
4885
+ return await readFileAsArrayBuffer(url);
4886
+ } catch {
4887
+ if (url.includes("/dist/libs/")) {
4888
+ return await readFileAsArrayBuffer(url.replace("/dist/libs/", "/src/libs/"));
4889
+ }
4890
+ throw new Error(`Failed to load ArrayBuffer from ${url}`);
4891
+ }
4867
4892
  }
4868
4893
  async function loadAsText(url) {
4869
4894
  const { readFileAsText } = globalThis.loaders || {};
@@ -4871,7 +4896,14 @@ var __exports__ = (() => {
4871
4896
  const response = await fetch(url);
4872
4897
  return await response.text();
4873
4898
  }
4874
- return await readFileAsText(url);
4899
+ try {
4900
+ return await readFileAsText(url);
4901
+ } catch {
4902
+ if (url.includes("/dist/libs/")) {
4903
+ return await readFileAsText(url.replace("/dist/libs/", "/src/libs/"));
4904
+ }
4905
+ throw new Error(`Failed to load text from ${url}`);
4906
+ }
4875
4907
  }
4876
4908
 
4877
4909
  // ../loader-utils/src/lib/binary-utils/get-first-characters.ts
@@ -5019,10 +5051,26 @@ var __exports__ = (() => {
5019
5051
  async function concatenateArrayBuffersAsync(asyncIterator) {
5020
5052
  const arrayBuffers = [];
5021
5053
  for await (const chunk of asyncIterator) {
5022
- arrayBuffers.push(chunk);
5054
+ arrayBuffers.push(copyToArrayBuffer(chunk));
5023
5055
  }
5024
5056
  return concatenateArrayBuffers(...arrayBuffers);
5025
5057
  }
5058
+ function copyToArrayBuffer(chunk) {
5059
+ if (chunk instanceof ArrayBuffer) {
5060
+ return chunk;
5061
+ }
5062
+ if (ArrayBuffer.isView(chunk)) {
5063
+ const { buffer, byteOffset, byteLength } = chunk;
5064
+ return copyFromBuffer(buffer, byteOffset, byteLength);
5065
+ }
5066
+ return copyFromBuffer(chunk);
5067
+ }
5068
+ function copyFromBuffer(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
5069
+ const view = new Uint8Array(buffer, byteOffset, byteLength);
5070
+ const copy4 = new Uint8Array(view.length);
5071
+ copy4.set(view);
5072
+ return copy4.buffer;
5073
+ }
5026
5074
 
5027
5075
  // ../loader-utils/src/lib/node/buffer.browser.ts
5028
5076
  function toArrayBuffer(buffer) {
@@ -5040,11 +5088,15 @@ var __exports__ = (() => {
5040
5088
  if (data instanceof ArrayBuffer) {
5041
5089
  return data;
5042
5090
  }
5091
+ if (isSharedArrayBuffer(data)) {
5092
+ return copyToArrayBuffer2(data);
5093
+ }
5043
5094
  if (ArrayBuffer.isView(data)) {
5095
+ const buffer = data.buffer;
5044
5096
  if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
5045
- return data.buffer;
5097
+ return buffer;
5046
5098
  }
5047
- return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
5099
+ return buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
5048
5100
  }
5049
5101
  if (typeof data === "string") {
5050
5102
  const text = data;
@@ -5056,6 +5108,25 @@ var __exports__ = (() => {
5056
5108
  }
5057
5109
  throw new Error("toArrayBuffer");
5058
5110
  }
5111
+ function ensureArrayBuffer(bufferSource) {
5112
+ if (bufferSource instanceof ArrayBuffer) {
5113
+ return bufferSource;
5114
+ }
5115
+ if (isSharedArrayBuffer(bufferSource)) {
5116
+ return copyToArrayBuffer2(bufferSource);
5117
+ }
5118
+ const { buffer, byteOffset, byteLength } = bufferSource;
5119
+ if (buffer instanceof ArrayBuffer && byteOffset === 0 && byteLength === buffer.byteLength) {
5120
+ return buffer;
5121
+ }
5122
+ return copyToArrayBuffer2(buffer, byteOffset, byteLength);
5123
+ }
5124
+ function copyToArrayBuffer2(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
5125
+ const view = new Uint8Array(buffer, byteOffset, byteLength);
5126
+ const copy4 = new Uint8Array(view.length);
5127
+ copy4.set(view);
5128
+ return copy4.buffer;
5129
+ }
5059
5130
 
5060
5131
  // ../loader-utils/src/lib/node/promisify.ts
5061
5132
  function promisify1(fn) {
@@ -5085,7 +5156,7 @@ var __exports__ = (() => {
5085
5156
  // ../loader-utils/src/lib/path-utils/path.ts
5086
5157
  function filename(url) {
5087
5158
  const slashIndex = url ? url.lastIndexOf("/") : -1;
5088
- return slashIndex >= 0 ? url.substr(slashIndex + 1) : "";
5159
+ return slashIndex >= 0 ? url.substr(slashIndex + 1) : url;
5089
5160
  }
5090
5161
  function dirname(url) {
5091
5162
  const slashIndex = url ? url.lastIndexOf("/") : -1;
@@ -5207,6 +5278,33 @@ var __exports__ = (() => {
5207
5278
  return res;
5208
5279
  }
5209
5280
 
5281
+ // ../loader-utils/src/lib/files/blob-file.ts
5282
+ var BlobFile = class {
5283
+ handle;
5284
+ size;
5285
+ bigsize;
5286
+ url;
5287
+ constructor(blob) {
5288
+ this.handle = blob instanceof ArrayBuffer ? new Blob([blob]) : blob;
5289
+ this.size = blob instanceof ArrayBuffer ? blob.byteLength : blob.size;
5290
+ this.bigsize = BigInt(this.size);
5291
+ this.url = blob instanceof File ? blob.name : "";
5292
+ }
5293
+ async close() {
5294
+ }
5295
+ async stat() {
5296
+ return {
5297
+ size: this.handle.size,
5298
+ bigsize: BigInt(this.handle.size),
5299
+ isDirectory: false
5300
+ };
5301
+ }
5302
+ async read(start, length4) {
5303
+ const arrayBuffer = await this.handle.slice(Number(start), Number(start) + Number(length4)).arrayBuffer();
5304
+ return arrayBuffer;
5305
+ }
5306
+ };
5307
+
5210
5308
  // ../loader-utils/src/lib/files/node-file-facade.ts
5211
5309
  var NOT_IMPLEMENTED = new Error("Not implemented");
5212
5310
  var NodeFileFacade = class {
@@ -5248,163 +5346,6 @@ var __exports__ = (() => {
5248
5346
  }
5249
5347
  };
5250
5348
 
5251
- // ../loader-utils/src/lib/file-provider/file-provider-interface.ts
5252
- var isFileProvider = (fileProvider) => {
5253
- return fileProvider?.getUint8 && fileProvider?.slice && fileProvider?.length;
5254
- };
5255
-
5256
- // ../loader-utils/src/lib/file-provider/file-handle-file.ts
5257
- var FileHandleFile = class {
5258
- /** The FileHandle from which data is provided */
5259
- file;
5260
- /** Create a new FileHandleFile */
5261
- constructor(path, append = false) {
5262
- this.file = new NodeFileFacade(path, append ? "a+" : "r");
5263
- }
5264
- /**
5265
- * Truncates the file descriptor.
5266
- * @param length desired file lenght
5267
- */
5268
- async truncate(length4) {
5269
- await this.file.truncate(length4);
5270
- }
5271
- /**
5272
- * Append data to a file.
5273
- * @param buffer data to append
5274
- */
5275
- async append(buffer) {
5276
- await this.file.append(buffer);
5277
- }
5278
- /** Close file */
5279
- async destroy() {
5280
- await this.file.close();
5281
- }
5282
- /**
5283
- * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
5284
- * @param offset The offset, in bytes, from the start of the file where to read the data.
5285
- */
5286
- async getUint8(offset) {
5287
- const arrayBuffer = await this.file.read(offset, 1);
5288
- const val = new Uint8Array(arrayBuffer).at(0);
5289
- if (val === void 0) {
5290
- throw new Error("something went wrong");
5291
- }
5292
- return val;
5293
- }
5294
- /**
5295
- * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
5296
- * @param offset The offset, in bytes, from the start of the file where to read the data.
5297
- */
5298
- async getUint16(offset) {
5299
- const arrayBuffer = await this.file.read(offset, 2);
5300
- const val = new Uint16Array(arrayBuffer).at(0);
5301
- if (val === void 0) {
5302
- throw new Error("something went wrong");
5303
- }
5304
- return val;
5305
- }
5306
- /**
5307
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
5308
- * @param offset The offset, in bytes, from the start of the file where to read the data.
5309
- */
5310
- async getUint32(offset) {
5311
- const arrayBuffer = await this.file.read(offset, 4);
5312
- const val = new Uint32Array(arrayBuffer).at(0);
5313
- if (val === void 0) {
5314
- throw new Error("something went wrong");
5315
- }
5316
- return val;
5317
- }
5318
- /**
5319
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
5320
- * @param offset The offset, in bytes, from the start of the file where to read the data.
5321
- */
5322
- async getBigUint64(offset) {
5323
- const arrayBuffer = await this.file.read(offset, 8);
5324
- const val = new BigInt64Array(arrayBuffer).at(0);
5325
- if (val === void 0) {
5326
- throw new Error("something went wrong");
5327
- }
5328
- return val;
5329
- }
5330
- /**
5331
- * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
5332
- * @param startOffset The offset, in byte, from the start of the file where to start reading the data.
5333
- * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
5334
- */
5335
- async slice(startOffset, endOffset) {
5336
- const bigLength = endOffset - startOffset;
5337
- if (bigLength > Number.MAX_SAFE_INTEGER) {
5338
- throw new Error("too big slice");
5339
- }
5340
- const length4 = Number(bigLength);
5341
- return await this.file.read(startOffset, length4);
5342
- }
5343
- /**
5344
- * the length (in bytes) of the data.
5345
- */
5346
- get length() {
5347
- return this.file.bigsize;
5348
- }
5349
- };
5350
-
5351
- // ../loader-utils/src/lib/file-provider/data-view-file.ts
5352
- var toNumber = (bigint) => {
5353
- if (bigint > Number.MAX_SAFE_INTEGER) {
5354
- throw new Error("Offset is out of bounds");
5355
- }
5356
- return Number(bigint);
5357
- };
5358
- var DataViewFile = class {
5359
- /** The DataView from which data is provided */
5360
- file;
5361
- constructor(file) {
5362
- this.file = file;
5363
- }
5364
- async destroy() {
5365
- }
5366
- /**
5367
- * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
5368
- * @param offset The offset, in bytes, from the start of the file where to read the data.
5369
- */
5370
- async getUint8(offset) {
5371
- return this.file.getUint8(toNumber(offset));
5372
- }
5373
- /**
5374
- * Gets an unsigned 16-bit intege at the specified byte offset from the start of the file.
5375
- * @param offset The offset, in bytes, from the start of the file where to read the data.
5376
- */
5377
- async getUint16(offset) {
5378
- return this.file.getUint16(toNumber(offset), true);
5379
- }
5380
- /**
5381
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
5382
- * @param offset The offset, in bytes, from the start of the file where to read the data.
5383
- */
5384
- async getUint32(offset) {
5385
- return this.file.getUint32(toNumber(offset), true);
5386
- }
5387
- /**
5388
- * Gets an unsigned 64-bit integer at the specified byte offset from the start of the file.
5389
- * @param offset The offset, in bytes, from the start of the file where to read the data.
5390
- */
5391
- async getBigUint64(offset) {
5392
- return this.file.getBigUint64(toNumber(offset), true);
5393
- }
5394
- /**
5395
- * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
5396
- * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
5397
- * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
5398
- */
5399
- async slice(startOffset, endOffset) {
5400
- return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));
5401
- }
5402
- /** the length (in bytes) of the data. */
5403
- get length() {
5404
- return BigInt(this.file.byteLength);
5405
- }
5406
- };
5407
-
5408
5349
  // ../../node_modules/@math.gl/core/dist/lib/common.js
5409
5350
  var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
5410
5351
  var DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
@@ -10936,21 +10877,32 @@ var __exports__ = (() => {
10936
10877
  [DRACO_EXTERNAL_LIBRARIES.ENCODER]: `https://raw.githubusercontent.com/google/draco/${DRACO_ENCODER_VERSION}/javascript/${DRACO_EXTERNAL_LIBRARIES.ENCODER}`
10937
10878
  };
10938
10879
  var loadDecoderPromise;
10939
- async function loadDracoDecoderModule(options) {
10880
+ async function loadDracoDecoderModule(options = {}, type) {
10940
10881
  const modules = options.modules || {};
10941
10882
  if (modules.draco3d) {
10942
10883
  loadDecoderPromise ||= modules.draco3d.createDecoderModule({}).then((draco) => {
10943
10884
  return { draco };
10944
10885
  });
10945
10886
  } else {
10946
- loadDecoderPromise ||= loadDracoDecoder(options);
10887
+ loadDecoderPromise ||= loadDracoDecoder(options, type);
10947
10888
  }
10948
10889
  return await loadDecoderPromise;
10949
10890
  }
10950
- async function loadDracoDecoder(options) {
10891
+ function getLibraryExport(library, exportName) {
10892
+ if (library && typeof library === "object") {
10893
+ if (library.default) {
10894
+ return library.default;
10895
+ }
10896
+ if (library[exportName]) {
10897
+ return library[exportName];
10898
+ }
10899
+ }
10900
+ return library;
10901
+ }
10902
+ async function loadDracoDecoder(options, type) {
10951
10903
  let DracoDecoderModule;
10952
10904
  let wasmBinary;
10953
- switch (options.draco && options.draco.decoderType) {
10905
+ switch (type) {
10954
10906
  case "js":
10955
10907
  DracoDecoderModule = await loadLibrary(
10956
10908
  DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER],
@@ -10961,25 +10913,52 @@ var __exports__ = (() => {
10961
10913
  break;
10962
10914
  case "wasm":
10963
10915
  default:
10964
- [DracoDecoderModule, wasmBinary] = await Promise.all([
10965
- await loadLibrary(
10966
- DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER],
10967
- "draco",
10968
- options,
10969
- DRACO_EXTERNAL_LIBRARIES.DECODER
10970
- ),
10971
- await loadLibrary(
10972
- DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM],
10973
- "draco",
10974
- options,
10975
- DRACO_EXTERNAL_LIBRARIES.DECODER_WASM
10976
- )
10977
- ]);
10978
- }
10916
+ try {
10917
+ [DracoDecoderModule, wasmBinary] = await Promise.all([
10918
+ await loadLibrary(
10919
+ DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER],
10920
+ "draco",
10921
+ options,
10922
+ DRACO_EXTERNAL_LIBRARIES.DECODER
10923
+ ),
10924
+ await loadLibrary(
10925
+ DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM],
10926
+ "draco",
10927
+ options,
10928
+ DRACO_EXTERNAL_LIBRARIES.DECODER_WASM
10929
+ )
10930
+ ]);
10931
+ } catch {
10932
+ DracoDecoderModule = null;
10933
+ wasmBinary = null;
10934
+ }
10935
+ }
10936
+ DracoDecoderModule = getLibraryExport(DracoDecoderModule, "DracoDecoderModule");
10979
10937
  DracoDecoderModule = DracoDecoderModule || globalThis.DracoDecoderModule;
10938
+ if (!DracoDecoderModule && !isBrowser3) {
10939
+ [DracoDecoderModule, wasmBinary] = await Promise.all([
10940
+ await loadLibrary(
10941
+ DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER],
10942
+ "draco",
10943
+ { ...options, useLocalLibraries: true },
10944
+ DRACO_EXTERNAL_LIBRARIES.DECODER
10945
+ ),
10946
+ await loadLibrary(
10947
+ DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM],
10948
+ "draco",
10949
+ { ...options, useLocalLibraries: true },
10950
+ DRACO_EXTERNAL_LIBRARIES.DECODER_WASM
10951
+ )
10952
+ ]);
10953
+ DracoDecoderModule = getLibraryExport(DracoDecoderModule, "DracoDecoderModule");
10954
+ DracoDecoderModule = DracoDecoderModule || globalThis.DracoDecoderModule;
10955
+ }
10980
10956
  return await initializeDracoDecoder(DracoDecoderModule, wasmBinary);
10981
10957
  }
10982
10958
  function initializeDracoDecoder(DracoDecoderModule, wasmBinary) {
10959
+ if (typeof DracoDecoderModule !== "function") {
10960
+ throw new Error("DracoDecoderModule could not be loaded");
10961
+ }
10983
10962
  const options = {};
10984
10963
  if (wasmBinary) {
10985
10964
  options.wasmBinary = wasmBinary;
@@ -11599,7 +11578,10 @@ var __exports__ = (() => {
11599
11578
  parse
11600
11579
  };
11601
11580
  async function parse(arrayBuffer, options) {
11602
- const { draco } = await loadDracoDecoderModule(options);
11581
+ const { draco } = await loadDracoDecoderModule(
11582
+ options?.core,
11583
+ options?.draco?.decoderType || "wasm"
11584
+ );
11603
11585
  const dracoParser = new DracoParser(draco);
11604
11586
  try {
11605
11587
  return dracoParser.parseSync(arrayBuffer, options?.draco);
@@ -11738,8 +11720,9 @@ var __exports__ = (() => {
11738
11720
  if (length4 === void 0) {
11739
11721
  length4 = (buffer.byteLength - byteOffset) / GLType.getByteSize(glType);
11740
11722
  }
11723
+ const arrayBuffer = buffer instanceof ArrayBuffer ? buffer : buffer.buffer;
11741
11724
  const ArrayType = GLType.getArrayType(glType);
11742
- return new ArrayType(buffer, byteOffset, length4);
11725
+ return new ArrayType(arrayBuffer, byteOffset, length4);
11743
11726
  }
11744
11727
  };
11745
11728
 
@@ -11871,7 +11854,17 @@ var __exports__ = (() => {
11871
11854
  const cachedTypedArrays = this._cachedTypedArrays;
11872
11855
  let typedArray = cachedTypedArrays[propertyName];
11873
11856
  if (!typedArray) {
11874
- typedArray = GLType.createTypedArray(componentType, array);
11857
+ if (ArrayBuffer.isView(array)) {
11858
+ const byteOffset = array.byteOffset;
11859
+ const byteLength = array.byteLength;
11860
+ const elementCount = byteLength / GLType.getByteSize(componentType);
11861
+ typedArray = GLType.createTypedArray(componentType, array.buffer, byteOffset, elementCount);
11862
+ } else if (array instanceof ArrayBuffer) {
11863
+ typedArray = GLType.createTypedArray(componentType, array);
11864
+ } else {
11865
+ const ArrayType = GLType.getArrayType(componentType);
11866
+ typedArray = new ArrayType(array);
11867
+ }
11875
11868
  cachedTypedArrays[propertyName] = typedArray;
11876
11869
  }
11877
11870
  return typedArray;
@@ -13003,7 +12996,6 @@ var __exports__ = (() => {
13003
12996
  }
13004
12997
 
13005
12998
  // ../images/src/lib/parsers/parse-to-image-bitmap.ts
13006
- var EMPTY_OBJECT = {};
13007
12999
  var imagebitmapOptionsSupported = true;
13008
13000
  async function parseToImageBitmap(arrayBuffer, options, url) {
13009
13001
  let blob;
@@ -13031,8 +13023,13 @@ var __exports__ = (() => {
13031
13023
  return await createImageBitmap(blob);
13032
13024
  }
13033
13025
  function isEmptyObject(object) {
13034
- for (const key in object || EMPTY_OBJECT) {
13035
- return false;
13026
+ if (!object) {
13027
+ return true;
13028
+ }
13029
+ for (const key in object) {
13030
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
13031
+ return false;
13032
+ }
13036
13033
  }
13037
13034
  return true;
13038
13035
  }
@@ -14053,7 +14050,7 @@ var __exports__ = (() => {
14053
14050
  buffer = bufferArray.slice(offset, offset + byteLength).buffer;
14054
14051
  offset = 0;
14055
14052
  }
14056
- return new ArrayType(buffer, offset, length4);
14053
+ return new ArrayType(ensureArrayBuffer(buffer), offset, length4);
14057
14054
  }
14058
14055
  function getPrimitiveTextureData(scenegraph, textureInfo, primitive) {
14059
14056
  const texCoordAccessorKey = `TEXCOORD_${textureInfo.texCoord || 0}`;
@@ -14811,7 +14808,7 @@ var __exports__ = (() => {
14811
14808
  }
14812
14809
  function createBufferView(typedArray, scenegraph) {
14813
14810
  scenegraph.gltf.buffers.push({
14814
- arrayBuffer: typedArray.buffer,
14811
+ arrayBuffer: ensureArrayBuffer(typedArray.buffer),
14815
14812
  byteOffset: typedArray.byteOffset,
14816
14813
  byteLength: typedArray.byteLength
14817
14814
  });
@@ -15334,18 +15331,18 @@ var __exports__ = (() => {
15334
15331
  bgr565: { basisFormat: 15, compressed: false },
15335
15332
  rgba4444: { basisFormat: 16, compressed: false }
15336
15333
  };
15337
- async function parseBasis(data, options) {
15338
- if (options.basis.containerFormat === "auto") {
15334
+ async function parseBasis(data, options = {}) {
15335
+ if (!options.basis?.containerFormat || options.basis.containerFormat === "auto") {
15339
15336
  if (isKTX(data)) {
15340
- const fileConstructors = await loadBasisEncoderModule(options);
15337
+ const fileConstructors = await loadBasisEncoderModule(options?.core || {});
15341
15338
  return parseKTX2File(fileConstructors.KTX2File, data, options);
15342
15339
  }
15343
- const { BasisFile } = await loadBasisTranscoderModule(options);
15340
+ const { BasisFile } = await loadBasisTranscoderModule(options?.core || {});
15344
15341
  return parseBasisFile(BasisFile, data, options);
15345
15342
  }
15346
15343
  switch (options.basis.module) {
15347
15344
  case "encoder":
15348
- const fileConstructors = await loadBasisEncoderModule(options);
15345
+ const fileConstructors = await loadBasisEncoderModule(options?.core || {});
15349
15346
  switch (options.basis.containerFormat) {
15350
15347
  case "ktx2":
15351
15348
  return parseKTX2File(fileConstructors.KTX2File, data, options);
@@ -15355,7 +15352,7 @@ var __exports__ = (() => {
15355
15352
  }
15356
15353
  case "transcoder":
15357
15354
  default:
15358
- const { BasisFile } = await loadBasisTranscoderModule(options);
15355
+ const { BasisFile } = await loadBasisTranscoderModule(options.core || {});
15359
15356
  return parseBasisFile(BasisFile, data, options);
15360
15357
  }
15361
15358
  }
@@ -15458,7 +15455,7 @@ var __exports__ = (() => {
15458
15455
  };
15459
15456
  }
15460
15457
  function getBasisOptions(options, hasAlpha) {
15461
- let format = options && options.basis && options.basis.format;
15458
+ let format = options.basis?.format;
15462
15459
  if (format === "auto") {
15463
15460
  format = selectSupportedBasisFormat();
15464
15461
  }
@@ -15633,7 +15630,7 @@ var __exports__ = (() => {
15633
15630
  if (absolute) {
15634
15631
  return url;
15635
15632
  }
15636
- const baseUrl = options.baseUri || options.uri;
15633
+ const baseUrl = options?.core?.baseUri || options.baseUri || options.uri;
15637
15634
  if (!baseUrl) {
15638
15635
  throw new Error(`'baseUri' must be provided to resolve relative url ${url}`);
15639
15636
  }
@@ -16187,7 +16184,7 @@ var __exports__ = (() => {
16187
16184
  const texCoordAccessor = primitive.attributes[`TEXCOORD_${originalTexCoord}`];
16188
16185
  if (Number.isFinite(texCoordAccessor)) {
16189
16186
  const accessor = gltfData.json.accessors?.[texCoordAccessor];
16190
- if (accessor && accessor.bufferView) {
16187
+ if (accessor && accessor.bufferView !== void 0) {
16191
16188
  const bufferView = gltfData.json.bufferViews?.[accessor.bufferView];
16192
16189
  if (bufferView) {
16193
16190
  const { arrayBuffer, byteOffset: bufferByteOffset } = gltfData.buffers[bufferView.buffer];
@@ -16204,7 +16201,7 @@ var __exports__ = (() => {
16204
16201
  result.set([scratchVector8[0], scratchVector8[1]], i * components);
16205
16202
  }
16206
16203
  if (originalTexCoord === texCoord) {
16207
- updateGltf(accessor, bufferView, gltfData.buffers, result);
16204
+ updateGltf(accessor, gltfData, result, accessor.bufferView);
16208
16205
  } else {
16209
16206
  createAttribute(texCoord, accessor, primitive, gltfData, result);
16210
16207
  }
@@ -16212,28 +16209,49 @@ var __exports__ = (() => {
16212
16209
  }
16213
16210
  }
16214
16211
  }
16215
- function updateGltf(accessor, bufferView, buffers, newTexCoordArray) {
16212
+ function updateGltf(accessor, gltfData, newTexCoordArray, originalBufferViewIndex) {
16216
16213
  accessor.componentType = 5126;
16217
- buffers.push({
16218
- arrayBuffer: newTexCoordArray.buffer,
16214
+ accessor.byteOffset = 0;
16215
+ const accessors = gltfData.json.accessors || [];
16216
+ const bufferViewReferenceCount = accessors.reduce((count, currentAccessor) => {
16217
+ return currentAccessor.bufferView === originalBufferViewIndex ? count + 1 : count;
16218
+ }, 0);
16219
+ const shouldCreateNewBufferView = bufferViewReferenceCount > 1;
16220
+ gltfData.buffers.push({
16221
+ arrayBuffer: ensureArrayBuffer(newTexCoordArray.buffer),
16219
16222
  byteOffset: 0,
16220
16223
  byteLength: newTexCoordArray.buffer.byteLength
16221
16224
  });
16222
- bufferView.buffer = buffers.length - 1;
16223
- bufferView.byteLength = newTexCoordArray.buffer.byteLength;
16225
+ const newBufferIndex = gltfData.buffers.length - 1;
16226
+ gltfData.json.bufferViews = gltfData.json.bufferViews || [];
16227
+ if (shouldCreateNewBufferView) {
16228
+ gltfData.json.bufferViews.push({
16229
+ buffer: newBufferIndex,
16230
+ byteLength: newTexCoordArray.buffer.byteLength,
16231
+ byteOffset: 0
16232
+ });
16233
+ accessor.bufferView = gltfData.json.bufferViews.length - 1;
16234
+ return;
16235
+ }
16236
+ const bufferView = gltfData.json.bufferViews[originalBufferViewIndex];
16237
+ if (!bufferView) {
16238
+ return;
16239
+ }
16240
+ bufferView.buffer = newBufferIndex;
16224
16241
  bufferView.byteOffset = 0;
16225
- delete bufferView.byteStride;
16242
+ bufferView.byteLength = newTexCoordArray.buffer.byteLength;
16243
+ if (bufferView.byteStride !== void 0) {
16244
+ delete bufferView.byteStride;
16245
+ }
16226
16246
  }
16227
16247
  function createAttribute(newTexCoord, originalAccessor, primitive, gltfData, newTexCoordArray) {
16228
16248
  gltfData.buffers.push({
16229
- arrayBuffer: newTexCoordArray.buffer,
16249
+ arrayBuffer: ensureArrayBuffer(newTexCoordArray.buffer),
16230
16250
  byteOffset: 0,
16231
16251
  byteLength: newTexCoordArray.buffer.byteLength
16232
16252
  });
16253
+ gltfData.json.bufferViews = gltfData.json.bufferViews || [];
16233
16254
  const bufferViews = gltfData.json.bufferViews;
16234
- if (!bufferViews) {
16235
- return;
16236
- }
16237
16255
  bufferViews.push({
16238
16256
  buffer: gltfData.buffers.length - 1,
16239
16257
  byteLength: newTexCoordArray.buffer.byteLength,
@@ -16702,10 +16720,10 @@ var __exports__ = (() => {
16702
16720
  return gltf;
16703
16721
  }
16704
16722
  function parseGLTFContainerSync(gltf, data, byteOffset, options) {
16705
- if (options.uri) {
16706
- gltf.baseUri = options.uri;
16723
+ if (options.core?.baseUri) {
16724
+ gltf.baseUri = options.core?.baseUri;
16707
16725
  }
16708
- if (data instanceof ArrayBuffer && !isGLB(data, byteOffset, options)) {
16726
+ if (data instanceof ArrayBuffer && !isGLB(data, byteOffset, options.glb)) {
16709
16727
  const textDecoder = new TextDecoder();
16710
16728
  data = textDecoder.decode(data);
16711
16729
  }
@@ -16793,14 +16811,16 @@ var __exports__ = (() => {
16793
16811
  arrayBuffer = sliceArrayBuffer(array.buffer, array.byteOffset, array.byteLength);
16794
16812
  }
16795
16813
  assert7(arrayBuffer, "glTF image has no data");
16814
+ const strictOptions = options;
16815
+ const gltfOptions = {
16816
+ ...strictOptions,
16817
+ core: { ...strictOptions?.core, mimeType: image.mimeType },
16818
+ basis: strictOptions.basis || { format: selectSupportedBasisFormat() }
16819
+ };
16796
16820
  let parsedImage = await parseFromContext(
16797
16821
  arrayBuffer,
16798
16822
  [ImageLoader, BasisLoader],
16799
- {
16800
- ...options,
16801
- mimeType: image.mimeType,
16802
- basis: options.basis || { format: selectSupportedBasisFormat() }
16803
- },
16823
+ gltfOptions,
16804
16824
  context
16805
16825
  );
16806
16826
  if (parsedImage && parsedImage[0]) {
@@ -16841,18 +16861,15 @@ var __exports__ = (() => {
16841
16861
  // Create image objects
16842
16862
  decompressMeshes: true
16843
16863
  // Decompress Draco encoded meshes
16844
- },
16845
- // common?
16846
- log: console
16847
- // eslint-disable-line
16864
+ }
16848
16865
  }
16849
16866
  };
16850
16867
  async function parse2(arrayBuffer, options = {}, context) {
16851
- options = { ...GLTFLoader.options, ...options };
16852
- options.gltf = { ...GLTFLoader.options.gltf, ...options.gltf };
16853
- const { byteOffset = 0 } = options;
16868
+ const mergedOptions = { ...GLTFLoader.options, ...options };
16869
+ mergedOptions.gltf = { ...GLTFLoader.options.gltf, ...mergedOptions.gltf };
16870
+ const byteOffset = options?.glb?.byteOffset || 0;
16854
16871
  const gltf = {};
16855
- return await parseGLTF(gltf, arrayBuffer, byteOffset, options, context);
16872
+ return await parseGLTF(gltf, arrayBuffer, byteOffset, mergedOptions, context);
16856
16873
  }
16857
16874
 
16858
16875
  // ../gltf/src/lib/api/post-process-gltf.ts
@@ -17158,7 +17175,7 @@ var __exports__ = (() => {
17158
17175
  const buffer = accessor.bufferView.buffer;
17159
17176
  const { ArrayType, byteLength } = getAccessorArrayTypeAndLength(accessor, accessor.bufferView);
17160
17177
  const byteOffset = (accessor.bufferView.byteOffset || 0) + (accessor.byteOffset || 0) + buffer.byteOffset;
17161
- let cutBuffer = buffer.arrayBuffer.slice(byteOffset, byteOffset + byteLength);
17178
+ let cutBuffer = copyToArrayBuffer2(buffer.arrayBuffer, byteOffset, byteLength);
17162
17179
  if (accessor.bufferView.byteStride) {
17163
17180
  cutBuffer = this._getValueFromInterleavedBuffer(
17164
17181
  buffer,
@@ -17298,7 +17315,7 @@ var __exports__ = (() => {
17298
17315
  }
17299
17316
  if (tile.gltfUrl) {
17300
17317
  const { fetch: fetch2 } = context;
17301
- const response = await fetch2(tile.gltfUrl, options);
17318
+ const response = await fetch2(tile.gltfUrl, options?.core);
17302
17319
  tile.gltfArrayBuffer = await response.arrayBuffer();
17303
17320
  tile.gltfByteOffset = 0;
17304
17321
  }
@@ -18115,7 +18132,7 @@ var __exports__ = (() => {
18115
18132
  LongPrototype.toInt = function toInt() {
18116
18133
  return this.unsigned ? this.low >>> 0 : this.low;
18117
18134
  };
18118
- LongPrototype.toNumber = function toNumber2() {
18135
+ LongPrototype.toNumber = function toNumber() {
18119
18136
  if (this.unsigned)
18120
18137
  return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0);
18121
18138
  return this.high * TWO_PWR_32_DBL + (this.low >>> 0);
@@ -19456,22 +19473,109 @@ var __exports__ = (() => {
19456
19473
  }
19457
19474
  };
19458
19475
 
19476
+ // ../zip/src/parse-zip/readable-file-utils.ts
19477
+ function toBigInt(value) {
19478
+ return typeof value === "bigint" ? value : BigInt(value);
19479
+ }
19480
+ function toNumber2(value) {
19481
+ const numberValue = Number(value);
19482
+ if (!Number.isFinite(numberValue)) {
19483
+ throw new Error("Offset is out of bounds");
19484
+ }
19485
+ return numberValue;
19486
+ }
19487
+ function normalizeOffset(offset, size) {
19488
+ if (offset < 0) {
19489
+ return Math.max(size + offset, 0);
19490
+ }
19491
+ return Math.min(offset, size);
19492
+ }
19493
+ async function readRange(file, start, end) {
19494
+ const startOffset = toBigInt(start);
19495
+ const endOffset = toBigInt(end);
19496
+ const length4 = endOffset - startOffset;
19497
+ if (length4 < 0) {
19498
+ throw new Error("Invalid range requested");
19499
+ }
19500
+ return await file.read(startOffset, toNumber2(length4));
19501
+ }
19502
+ async function readDataView(file, start, end) {
19503
+ const arrayBuffer = await readRange(file, start, end);
19504
+ return new DataView(arrayBuffer);
19505
+ }
19506
+ async function readUint16(file, offset) {
19507
+ const dataView = await readDataView(file, offset, toBigInt(offset) + 2n);
19508
+ return dataView.getUint16(0, true);
19509
+ }
19510
+ async function readUint32(file, offset) {
19511
+ const dataView = await readDataView(file, offset, toBigInt(offset) + 4n);
19512
+ return dataView.getUint32(0, true);
19513
+ }
19514
+ async function readBigUint64(file, offset) {
19515
+ const dataView = await readDataView(file, offset, toBigInt(offset) + 8n);
19516
+ return dataView.getBigUint64(0, true);
19517
+ }
19518
+ async function getReadableFileSize(file) {
19519
+ if (file.bigsize > 0n) {
19520
+ return file.bigsize;
19521
+ }
19522
+ if (file.size > 0) {
19523
+ return BigInt(file.size);
19524
+ }
19525
+ if (file.stat) {
19526
+ const stats = await file.stat();
19527
+ if (stats?.bigsize !== void 0) {
19528
+ return stats.bigsize;
19529
+ }
19530
+ if (stats?.size !== void 0) {
19531
+ return BigInt(stats.size);
19532
+ }
19533
+ }
19534
+ return 0n;
19535
+ }
19536
+ var DataViewReadableFile = class {
19537
+ handle;
19538
+ size;
19539
+ bigsize;
19540
+ url;
19541
+ constructor(dataView, url = "") {
19542
+ this.handle = dataView;
19543
+ this.size = dataView.byteLength;
19544
+ this.bigsize = BigInt(dataView.byteLength);
19545
+ this.url = url;
19546
+ }
19547
+ async close() {
19548
+ }
19549
+ async stat() {
19550
+ return { size: this.size, bigsize: this.bigsize, isDirectory: false };
19551
+ }
19552
+ async read(start = 0, length4) {
19553
+ const offset = toNumber2(start);
19554
+ const end = length4 ? offset + length4 : this.size;
19555
+ const normalizedStart = normalizeOffset(offset, this.size);
19556
+ const normalizedEnd = normalizeOffset(end, this.size);
19557
+ const clampedEnd = Math.max(normalizedEnd, normalizedStart);
19558
+ const lengthToRead = clampedEnd - normalizedStart;
19559
+ if (lengthToRead <= 0) {
19560
+ return new ArrayBuffer(0);
19561
+ }
19562
+ return copyToArrayBuffer2(this.handle.buffer, normalizedStart, lengthToRead);
19563
+ }
19564
+ };
19565
+
19459
19566
  // ../zip/src/parse-zip/search-from-the-end.ts
19460
19567
  var buffLength = 1024;
19461
19568
  var searchFromTheEnd = async (file, target) => {
19462
- const searchWindow = [
19463
- await file.getUint8(file.length - 1n),
19464
- await file.getUint8(file.length - 2n),
19465
- await file.getUint8(file.length - 3n),
19466
- void 0
19467
- ];
19569
+ const fileLength = await getReadableFileSize(file);
19570
+ const lastBytes = new Uint8Array(await readRange(file, fileLength - 3n, fileLength + 1n));
19571
+ const searchWindow = [lastBytes[3], lastBytes[2], lastBytes[1], void 0];
19468
19572
  let targetOffset = -1;
19469
- let point = file.length - 4n;
19573
+ let point = fileLength - 4n;
19470
19574
  do {
19471
19575
  const prevPoint = point;
19472
19576
  point -= BigInt(buffLength);
19473
19577
  point = point >= 0n ? point : 0n;
19474
- const buff = new Uint8Array(await file.slice(point, prevPoint));
19578
+ const buff = new Uint8Array(await readRange(file, point, prevPoint));
19475
19579
  for (let i = buff.length - 1; i > -1; i--) {
19476
19580
  searchWindow[3] = searchWindow[2];
19477
19581
  searchWindow[2] = searchWindow[1];
@@ -19499,23 +19603,24 @@ var __exports__ = (() => {
19499
19603
  var ZIP64_CD_START_OFFSET_OFFSET = 48n;
19500
19604
  var parseEoCDRecord = async (file) => {
19501
19605
  const zipEoCDOffset = await searchFromTheEnd(file, eoCDSignature);
19502
- let cdRecordsNumber = BigInt(await file.getUint16(zipEoCDOffset + CD_RECORDS_NUMBER_OFFSET));
19503
- let cdByteSize = BigInt(await file.getUint32(zipEoCDOffset + CD_CD_BYTE_SIZE_OFFSET));
19504
- let cdStartOffset = BigInt(await file.getUint32(zipEoCDOffset + CD_START_OFFSET_OFFSET));
19606
+ let cdRecordsNumber = BigInt(await readUint16(file, zipEoCDOffset + CD_RECORDS_NUMBER_OFFSET));
19607
+ let cdByteSize = BigInt(await readUint32(file, zipEoCDOffset + CD_CD_BYTE_SIZE_OFFSET));
19608
+ let cdStartOffset = BigInt(await readUint32(file, zipEoCDOffset + CD_START_OFFSET_OFFSET));
19505
19609
  let zip64EoCDLocatorOffset = zipEoCDOffset - 20n;
19506
19610
  let zip64EoCDOffset = 0n;
19507
- const magicBytes = await file.slice(zip64EoCDLocatorOffset, zip64EoCDLocatorOffset + 4n);
19508
- if (compareArrayBuffers(magicBytes, zip64EoCDLocatorSignature)) {
19509
- zip64EoCDOffset = await file.getBigUint64(
19611
+ const magicBytes = await readRange(file, zip64EoCDLocatorOffset, zip64EoCDLocatorOffset + 4n);
19612
+ if (compareArrayBuffers(magicBytes, zip64EoCDLocatorSignature.buffer)) {
19613
+ zip64EoCDOffset = await readBigUint64(
19614
+ file,
19510
19615
  zip64EoCDLocatorOffset + ZIP64_EOCD_START_OFFSET_OFFSET
19511
19616
  );
19512
- const endOfCDMagicBytes = await file.slice(zip64EoCDOffset, zip64EoCDOffset + 4n);
19617
+ const endOfCDMagicBytes = await readRange(file, zip64EoCDOffset, zip64EoCDOffset + 4n);
19513
19618
  if (!compareArrayBuffers(endOfCDMagicBytes, zip64EoCDSignature.buffer)) {
19514
19619
  throw new Error("zip64 EoCD not found");
19515
19620
  }
19516
- cdRecordsNumber = await file.getBigUint64(zip64EoCDOffset + ZIP64_CD_RECORDS_NUMBER_OFFSET);
19517
- cdByteSize = await file.getBigUint64(zip64EoCDOffset + ZIP64_CD_CD_BYTE_SIZE_OFFSET);
19518
- cdStartOffset = await file.getBigUint64(zip64EoCDOffset + ZIP64_CD_START_OFFSET_OFFSET);
19621
+ cdRecordsNumber = await readBigUint64(file, zip64EoCDOffset + ZIP64_CD_RECORDS_NUMBER_OFFSET);
19622
+ cdByteSize = await readBigUint64(file, zip64EoCDOffset + ZIP64_CD_CD_BYTE_SIZE_OFFSET);
19623
+ cdStartOffset = await readBigUint64(file, zip64EoCDOffset + ZIP64_CD_START_OFFSET_OFFSET);
19519
19624
  } else {
19520
19625
  zip64EoCDLocatorOffset = 0n;
19521
19626
  }
@@ -19679,12 +19784,11 @@ var __exports__ = (() => {
19679
19784
  var CD_FILE_NAME_OFFSET = 46n;
19680
19785
  var signature = new Uint8Array([80, 75, 1, 2]);
19681
19786
  var parseZipCDFileHeader = async (headerOffset, file) => {
19682
- if (headerOffset >= file.length) {
19787
+ const fileLength = await getReadableFileSize(file);
19788
+ if (headerOffset >= fileLength) {
19683
19789
  return null;
19684
19790
  }
19685
- const mainHeader = new DataView(
19686
- await file.slice(headerOffset, headerOffset + CD_FILE_NAME_OFFSET)
19687
- );
19791
+ const mainHeader = await readDataView(file, headerOffset, headerOffset + CD_FILE_NAME_OFFSET);
19688
19792
  const magicBytes = mainHeader.buffer.slice(0, 4);
19689
19793
  if (!compareArrayBuffers(magicBytes, signature.buffer)) {
19690
19794
  return null;
@@ -19694,7 +19798,8 @@ var __exports__ = (() => {
19694
19798
  const extraFieldLength = mainHeader.getUint16(CD_EXTRA_FIELD_LENGTH_OFFSET, true);
19695
19799
  const startDisk = BigInt(mainHeader.getUint16(CD_START_DISK_OFFSET, true));
19696
19800
  const fileNameLength = mainHeader.getUint16(CD_FILE_NAME_LENGTH_OFFSET, true);
19697
- const additionalHeader = await file.slice(
19801
+ const additionalHeader = await readRange(
19802
+ file,
19698
19803
  headerOffset + CD_FILE_NAME_OFFSET,
19699
19804
  headerOffset + CD_FILE_NAME_OFFSET + BigInt(fileNameLength + extraFieldLength)
19700
19805
  );
@@ -19724,8 +19829,8 @@ var __exports__ = (() => {
19724
19829
  };
19725
19830
  async function* makeZipCDHeaderIterator(fileProvider) {
19726
19831
  const { cdStartOffset, cdByteSize } = await parseEoCDRecord(fileProvider);
19727
- const centralDirectory = new DataViewFile(
19728
- new DataView(await fileProvider.slice(cdStartOffset, cdStartOffset + cdByteSize))
19832
+ const centralDirectory = new DataViewReadableFile(
19833
+ new DataView(await readRange(fileProvider, cdStartOffset, cdStartOffset + cdByteSize))
19729
19834
  );
19730
19835
  let cdHeader = await parseZipCDFileHeader(0n, centralDirectory);
19731
19836
  while (cdHeader) {
@@ -19887,14 +19992,15 @@ var __exports__ = (() => {
19887
19992
  var FILE_NAME_OFFSET = 30n;
19888
19993
  var signature2 = new Uint8Array([80, 75, 3, 4]);
19889
19994
  var parseZipLocalFileHeader = async (headerOffset, file) => {
19890
- const mainHeader = new DataView(await file.slice(headerOffset, headerOffset + FILE_NAME_OFFSET));
19995
+ const mainHeader = await readDataView(file, headerOffset, headerOffset + FILE_NAME_OFFSET);
19891
19996
  const magicBytes = mainHeader.buffer.slice(0, 4);
19892
- if (!compareArrayBuffers(magicBytes, signature2)) {
19997
+ if (!compareArrayBuffers(magicBytes, signature2.buffer)) {
19893
19998
  return null;
19894
19999
  }
19895
20000
  const fileNameLength = mainHeader.getUint16(FILE_NAME_LENGTH_OFFSET, true);
19896
20001
  const extraFieldLength = mainHeader.getUint16(EXTRA_FIELD_LENGTH_OFFSET, true);
19897
- const additionalHeader = await file.slice(
20002
+ const additionalHeader = await readRange(
20003
+ file,
19898
20004
  headerOffset + FILE_NAME_OFFSET,
19899
20005
  headerOffset + FILE_NAME_OFFSET + BigInt(fileNameLength + extraFieldLength)
19900
20006
  );
@@ -20093,16 +20199,16 @@ var __exports__ = (() => {
20093
20199
  }
20094
20200
 
20095
20201
  // ../crypto/src/lib/algorithms/md5-wasm.ts
20096
- var atb = typeof atob === "function" ? atob : typeof Buffer === "function" ? nodeATOB : identity4;
20097
- var wasmB64 = atb(
20202
+ var BASE64_LOOKUP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
20203
+ var wasmB64Bytes = decodeBase64Safely(
20098
20204
  "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"
20099
20205
  );
20100
- var wasm2 = WebAssembly && atb !== identity4 ? str2AB(wasmB64).buffer : false;
20206
+ var wasm2 = typeof WebAssembly !== "undefined" && wasmB64Bytes ? wasmB64Bytes.buffer : false;
20101
20207
  var crypt = makeCrypt();
20102
20208
  var biteSize = 240 * 16 * 16;
20103
20209
  var bounder = Math.floor(biteSize * 16 * 1.066666667);
20104
20210
  var upperLimit = 268435456 - 65536;
20105
- var parmTypeErrStr = "Parameter must be Buffer, ArrayBuffer or Uint8Array";
20211
+ var parmTypeErrStr = "Parameter must be ArrayBuffer, ArrayBufferView or string";
20106
20212
  var tooBigErrStr = "Parameter exceeds max size of 255.9 Mbytes";
20107
20213
  if (!wasm2) {
20108
20214
  console.log(
@@ -20121,20 +20227,9 @@ var __exports__ = (() => {
20121
20227
  catchFun = fun;
20122
20228
  return returnObj;
20123
20229
  };
20124
- if (true) {
20125
- if (data && typeof data === "object") {
20126
- if (typeof Buffer === "function" && data.constructor === Buffer) {
20127
- buff = data;
20128
- } else {
20129
- if (data.constructor === Uint8Array || data.constructor === ArrayBuffer) {
20130
- buff = data.constructor === ArrayBuffer ? new Uint8Array(data) : data;
20131
- } else {
20132
- getCatch(new TypeError(parmTypeErrStr));
20133
- }
20134
- }
20135
- } else {
20136
- getCatch(new TypeError(parmTypeErrStr));
20137
- }
20230
+ buff = normalizeInput(data);
20231
+ if (!buff) {
20232
+ getCatch(new TypeError(parmTypeErrStr));
20138
20233
  }
20139
20234
  if (buff) {
20140
20235
  len2 = buff.length;
@@ -20450,21 +20545,62 @@ var __exports__ = (() => {
20450
20545
  return result;
20451
20546
  };
20452
20547
  }
20453
- function str2AB(str3) {
20454
- var l, buff, buffView, i = -1;
20455
- l = str3.length - 1;
20456
- buff = new ArrayBuffer(str3.length);
20457
- buffView = new Uint8Array(buff);
20458
- while (l > i++) {
20459
- buffView[i] = str3.charCodeAt(i);
20548
+ function decodeBase64Safely(str3) {
20549
+ try {
20550
+ return decodeBase64ToUint8Array(str3);
20551
+ } catch (error) {
20552
+ return null;
20460
20553
  }
20461
- return buffView;
20462
20554
  }
20463
- function nodeATOB(str3) {
20464
- return Buffer.from(str3, "base64").toString("binary");
20555
+ function decodeBase64ToUint8Array(base64) {
20556
+ var sanitized = base64.replace(/-/g, "+").replace(/_/g, "/");
20557
+ if (typeof atob === "function") {
20558
+ return binaryStringToUint8Array(atob(sanitized));
20559
+ }
20560
+ return decodeBase64WithoutAtob(sanitized);
20465
20561
  }
20466
- function identity4(x) {
20467
- return x;
20562
+ function decodeBase64WithoutAtob(base64) {
20563
+ var paddingLength = base64.endsWith("==") ? 2 : base64.endsWith("=") ? 1 : 0, byteLength = base64.length * 3 / 4 - paddingLength, bytes = new Uint8Array(byteLength), byteIndex = 0, i = 0, enc1, enc2, enc3, enc4;
20564
+ while (i < base64.length) {
20565
+ enc1 = BASE64_LOOKUP.indexOf(base64.charAt(i++));
20566
+ enc2 = BASE64_LOOKUP.indexOf(base64.charAt(i++));
20567
+ enc3 = BASE64_LOOKUP.indexOf(base64.charAt(i++));
20568
+ enc4 = BASE64_LOOKUP.indexOf(base64.charAt(i++));
20569
+ if (enc1 < 0 || enc2 < 0 || enc3 < 0 || enc4 < 0) {
20570
+ throw new TypeError("Invalid base64 input");
20571
+ }
20572
+ bytes[byteIndex++] = enc1 << 2 | enc2 >> 4;
20573
+ if (enc3 < 64 && byteIndex < byteLength) {
20574
+ bytes[byteIndex++] = (enc2 & 15) << 4 | enc3 >> 2;
20575
+ }
20576
+ if (enc4 < 64 && byteIndex < byteLength) {
20577
+ bytes[byteIndex++] = (enc3 & 3) << 6 | enc4;
20578
+ }
20579
+ }
20580
+ return bytes;
20581
+ }
20582
+ function binaryStringToUint8Array(str3) {
20583
+ var length4 = str3.length, view = new Uint8Array(length4), i = 0;
20584
+ while (i < length4) {
20585
+ view[i] = str3.charCodeAt(i);
20586
+ i++;
20587
+ }
20588
+ return view;
20589
+ }
20590
+ function normalizeInput(data) {
20591
+ if (data instanceof Uint8Array) {
20592
+ return data;
20593
+ }
20594
+ if (typeof ArrayBuffer !== "undefined" && data instanceof ArrayBuffer) {
20595
+ return new Uint8Array(data);
20596
+ }
20597
+ if (data && typeof data === "object" && ArrayBuffer.isView(data)) {
20598
+ return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
20599
+ }
20600
+ if (typeof data === "string") {
20601
+ return new TextEncoder().encode(data);
20602
+ }
20603
+ return null;
20468
20604
  }
20469
20605
  function makeCrypt() {
20470
20606
  var base64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -20636,7 +20772,7 @@ var __exports__ = (() => {
20636
20772
  const pakoOptions = this.options?.deflate || {};
20637
20773
  const inputArray = new Uint8Array(input);
20638
20774
  const deflate = this.options?.raw ? import_pako.default.deflateRaw : import_pako.default.deflate;
20639
- return deflate(inputArray, pakoOptions).buffer;
20775
+ return toArrayBuffer2(deflate(inputArray, pakoOptions).buffer);
20640
20776
  }
20641
20777
  decompressSync(input) {
20642
20778
  if (!isBrowser && this.options.deflate?.useZlib) {
@@ -20646,7 +20782,7 @@ var __exports__ = (() => {
20646
20782
  const pakoOptions = this.options?.deflate || {};
20647
20783
  const inputArray = new Uint8Array(input);
20648
20784
  const inflate = this.options?.raw ? import_pako.default.inflateRaw : import_pako.default.inflate;
20649
- return inflate(inputArray, pakoOptions).buffer;
20785
+ return toArrayBuffer2(inflate(inputArray, pakoOptions).buffer);
20650
20786
  }
20651
20787
  async *compressBatches(asyncIterator) {
20652
20788
  const pakoOptions = this.options?.deflate || {};
@@ -20728,34 +20864,35 @@ var __exports__ = (() => {
20728
20864
  }
20729
20865
  };
20730
20866
  var ZipFileSystem = class {
20731
- /** FileProvider instance promise */
20732
- fileProvider = null;
20867
+ /** File instance */
20868
+ file = null;
20733
20869
  fileName;
20734
20870
  archive = null;
20735
20871
  /**
20736
20872
  * Constructor
20737
- * @param file - instance of FileProvider or file path string
20873
+ * @param file - instance of ReadableFile or file path string
20738
20874
  */
20739
20875
  constructor(file) {
20740
20876
  if (typeof file === "string") {
20741
20877
  this.fileName = file;
20742
- if (!isBrowser) {
20743
- this.fileProvider = new FileHandleFile(file);
20744
- } else {
20745
- throw new Error("Cannot open file for random access in a WEB browser");
20878
+ if (isBrowser) {
20879
+ throw new Error("ZipFileSystem cannot open file paths in browser environments");
20746
20880
  }
20881
+ this.file = new NodeFileFacade(file);
20882
+ } else if (file instanceof Blob || file instanceof ArrayBuffer) {
20883
+ this.file = new BlobFile(file);
20747
20884
  } else if (file instanceof IndexedArchive) {
20748
- this.fileProvider = file.fileProvider;
20885
+ this.file = file.file;
20749
20886
  this.archive = file;
20750
20887
  this.fileName = file.fileName;
20751
- } else if (isFileProvider(file)) {
20752
- this.fileProvider = file;
20888
+ } else {
20889
+ this.file = file;
20753
20890
  }
20754
20891
  }
20755
20892
  /** Clean up resources */
20756
20893
  async destroy() {
20757
- if (this.fileProvider) {
20758
- await this.fileProvider.destroy();
20894
+ if (this.file) {
20895
+ await this.file.close();
20759
20896
  }
20760
20897
  }
20761
20898
  /**
@@ -20763,11 +20900,11 @@ var __exports__ = (() => {
20763
20900
  * @returns array of file names
20764
20901
  */
20765
20902
  async readdir() {
20766
- if (!this.fileProvider) {
20903
+ if (!this.file) {
20767
20904
  throw new Error("No data detected in the zip archive");
20768
20905
  }
20769
20906
  const fileNames = [];
20770
- const zipCDIterator = makeZipCDHeaderIterator(this.fileProvider);
20907
+ const zipCDIterator = makeZipCDHeaderIterator(this.file);
20771
20908
  for await (const cdHeader of zipCDIterator) {
20772
20909
  fileNames.push(cdHeader.fileName);
20773
20910
  }
@@ -20795,13 +20932,13 @@ var __exports__ = (() => {
20795
20932
  if (this.archive) {
20796
20933
  uncompressedFile = await this.archive.getFile(filename2, "http");
20797
20934
  } else {
20798
- if (!this.fileProvider) {
20935
+ if (!this.file) {
20799
20936
  throw new Error("No data detected in the zip archive");
20800
20937
  }
20801
20938
  const cdFileHeader = await this.getCDFileHeader(filename2);
20802
20939
  const localFileHeader = await parseZipLocalFileHeader(
20803
20940
  cdFileHeader.localHeaderOffset,
20804
- this.fileProvider
20941
+ this.file
20805
20942
  );
20806
20943
  if (!localFileHeader) {
20807
20944
  throw new Error("Local file header has not been found in the zip archive`");
@@ -20810,7 +20947,8 @@ var __exports__ = (() => {
20810
20947
  if (!compressionHandler) {
20811
20948
  throw Error("Only Deflation compression is supported");
20812
20949
  }
20813
- const compressedFile = await this.fileProvider.slice(
20950
+ const compressedFile = await readRange(
20951
+ this.file,
20814
20952
  localFileHeader.fileDataOffset,
20815
20953
  localFileHeader.fileDataOffset + localFileHeader.compressedSize
20816
20954
  );
@@ -20828,10 +20966,10 @@ var __exports__ = (() => {
20828
20966
  * @returns central directory file header
20829
20967
  */
20830
20968
  async getCDFileHeader(filename2) {
20831
- if (!this.fileProvider) {
20969
+ if (!this.file) {
20832
20970
  throw new Error("No data detected in the zip archive");
20833
20971
  }
20834
- const zipCDIterator = makeZipCDHeaderIterator(this.fileProvider);
20972
+ const zipCDIterator = makeZipCDHeaderIterator(this.file);
20835
20973
  let result = null;
20836
20974
  for await (const cdHeader of zipCDIterator) {
20837
20975
  if (cdHeader.fileName === filename2) {
@@ -20848,16 +20986,16 @@ var __exports__ = (() => {
20848
20986
 
20849
20987
  // ../zip/src/filesystems/IndexedArchive.ts
20850
20988
  var IndexedArchive = class {
20851
- fileProvider;
20989
+ file;
20852
20990
  fileName;
20853
20991
  /**
20854
20992
  * Constructor
20855
- * @param fileProvider - instance of a binary data reader
20993
+ * @param fileProvider - readable file instance for random access
20856
20994
  * @param hashTable - pre-loaded hashTable. If presented, getFile will skip reading the hash file
20857
20995
  * @param fileName - name of the archive. It is used to add to an URL of a loader context
20858
20996
  */
20859
- constructor(fileProvider, hashTable, fileName) {
20860
- this.fileProvider = fileProvider;
20997
+ constructor(file, hashTable, fileName) {
20998
+ this.file = file;
20861
20999
  this.fileName = fileName;
20862
21000
  }
20863
21001
  /**
@@ -20866,7 +21004,7 @@ var __exports__ = (() => {
20866
21004
  * @returns
20867
21005
  */
20868
21006
  async getFileWithoutHash(filename2) {
20869
- const zipFS = new ZipFileSystem(this.fileProvider);
21007
+ const zipFS = new ZipFileSystem(this.file);
20870
21008
  const response = await zipFS.fetch(filename2);
20871
21009
  return await response.arrayBuffer();
20872
21010
  }
@@ -20915,7 +21053,7 @@ var __exports__ = (() => {
20915
21053
  hashTable;
20916
21054
  /**
20917
21055
  * creates Tiles3DArchive handler
20918
- * @param fileProvider - FileProvider with the whole file
21056
+ * @param fileProvider - readable file handle with the whole archive
20919
21057
  * @param hashTable - hash info
20920
21058
  */
20921
21059
  constructor(fileProvider, hashTable, fileName) {
@@ -20951,11 +21089,12 @@ var __exports__ = (() => {
20951
21089
  if (byteOffset === void 0) {
20952
21090
  return null;
20953
21091
  }
20954
- const localFileHeader = await parseZipLocalFileHeader(byteOffset, this.fileProvider);
21092
+ const localFileHeader = await parseZipLocalFileHeader(byteOffset, this.file);
20955
21093
  if (!localFileHeader) {
20956
21094
  return null;
20957
21095
  }
20958
- const compressedFile = await this.fileProvider.slice(
21096
+ const compressedFile = await readRange(
21097
+ this.file,
20959
21098
  localFileHeader.fileDataOffset,
20960
21099
  localFileHeader.fileDataOffset + localFileHeader.compressedSize
20961
21100
  );
@@ -20990,7 +21129,8 @@ var __exports__ = (() => {
20990
21129
  throw new Error("corrupted 3tz zip archive");
20991
21130
  }
20992
21131
  const fileDataOffset = localFileHeader.fileDataOffset;
20993
- const hashFile = await fileProvider.slice(
21132
+ const hashFile = await readRange(
21133
+ fileProvider,
20994
21134
  fileDataOffset,
20995
21135
  fileDataOffset + localFileHeader.compressedSize
20996
21136
  );
@@ -21014,7 +21154,9 @@ var __exports__ = (() => {
21014
21154
  options: {}
21015
21155
  };
21016
21156
  async function parse3DTilesArchive2(data, options = {}) {
21017
- const archive = await parse3DTilesArchive(new DataViewFile(new DataView(data)));
21157
+ const archive = await parse3DTilesArchive(
21158
+ new DataViewReadableFile(new DataView(data))
21159
+ );
21018
21160
  return archive.getFile(options["3d-tiles-archive"]?.path ?? "");
21019
21161
  }
21020
21162