@loaders.gl/i3s 4.0.0-alpha.10 → 4.0.0-alpha.11

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 (72) hide show
  1. package/dist/dist.min.js +4500 -261
  2. package/dist/es5/arcgis-webscene-loader.js +1 -1
  3. package/dist/es5/i3s-attribute-loader.js +1 -1
  4. package/dist/es5/i3s-building-scene-layer-loader.js +1 -1
  5. package/dist/es5/i3s-content-loader.js +1 -1
  6. package/dist/es5/i3s-loader.js +1 -1
  7. package/dist/es5/i3s-node-page-loader.js +1 -1
  8. package/dist/es5/i3s-slpk-loader.js +1 -1
  9. package/dist/es5/index.js +14 -0
  10. package/dist/es5/index.js.map +1 -1
  11. package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js +25 -12
  12. package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js.map +1 -1
  13. package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js +62 -33
  14. package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js.map +1 -1
  15. package/dist/es5/lib/parsers/parse-zip/buffer-file-provider.js +46 -0
  16. package/dist/es5/lib/parsers/parse-zip/buffer-file-provider.js.map +1 -0
  17. package/dist/es5/lib/parsers/parse-zip/cd-file-header.js +75 -35
  18. package/dist/es5/lib/parsers/parse-zip/cd-file-header.js.map +1 -1
  19. package/dist/es5/lib/parsers/parse-zip/file-provider.js +2 -0
  20. package/dist/es5/lib/parsers/parse-zip/file-provider.js.map +1 -0
  21. package/dist/es5/lib/parsers/parse-zip/local-file-header.js +63 -17
  22. package/dist/es5/lib/parsers/parse-zip/local-file-header.js.map +1 -1
  23. package/dist/esm/arcgis-webscene-loader.js +1 -1
  24. package/dist/esm/i3s-attribute-loader.js +1 -1
  25. package/dist/esm/i3s-building-scene-layer-loader.js +1 -1
  26. package/dist/esm/i3s-content-loader.js +1 -1
  27. package/dist/esm/i3s-loader.js +1 -1
  28. package/dist/esm/i3s-node-page-loader.js +1 -1
  29. package/dist/esm/i3s-slpk-loader.js +1 -1
  30. package/dist/esm/index.js +2 -0
  31. package/dist/esm/index.js.map +1 -1
  32. package/dist/esm/lib/parsers/parse-slpk/parse-slpk.js +8 -4
  33. package/dist/esm/lib/parsers/parse-slpk/parse-slpk.js.map +1 -1
  34. package/dist/esm/lib/parsers/parse-slpk/slpk-archieve.js +11 -12
  35. package/dist/esm/lib/parsers/parse-slpk/slpk-archieve.js.map +1 -1
  36. package/dist/esm/lib/parsers/parse-zip/buffer-file-provider.js +23 -0
  37. package/dist/esm/lib/parsers/parse-zip/buffer-file-provider.js.map +1 -0
  38. package/dist/esm/lib/parsers/parse-zip/cd-file-header.js +7 -7
  39. package/dist/esm/lib/parsers/parse-zip/cd-file-header.js.map +1 -1
  40. package/dist/esm/lib/parsers/parse-zip/file-provider.js +2 -0
  41. package/dist/esm/lib/parsers/parse-zip/file-provider.js.map +1 -0
  42. package/dist/esm/lib/parsers/parse-zip/local-file-header.js +16 -10
  43. package/dist/esm/lib/parsers/parse-zip/local-file-header.js.map +1 -1
  44. package/dist/i3s-content-worker-node.js +2 -2
  45. package/dist/i3s-content-worker.js +8 -8
  46. package/dist/index.d.ts +2 -0
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +3 -1
  49. package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts.map +1 -1
  50. package/dist/lib/parsers/parse-slpk/parse-slpk.js +8 -4
  51. package/dist/lib/parsers/parse-slpk/slpk-archieve.d.ts.map +1 -1
  52. package/dist/lib/parsers/parse-slpk/slpk-archieve.js +12 -12
  53. package/dist/lib/parsers/parse-zip/buffer-file-provider.d.ts +37 -0
  54. package/dist/lib/parsers/parse-zip/buffer-file-provider.d.ts.map +1 -0
  55. package/dist/lib/parsers/parse-zip/buffer-file-provider.js +47 -0
  56. package/dist/lib/parsers/parse-zip/cd-file-header.d.ts +9 -20
  57. package/dist/lib/parsers/parse-zip/cd-file-header.d.ts.map +1 -1
  58. package/dist/lib/parsers/parse-zip/cd-file-header.js +7 -7
  59. package/dist/lib/parsers/parse-zip/file-provider.d.ts +31 -0
  60. package/dist/lib/parsers/parse-zip/file-provider.d.ts.map +1 -0
  61. package/dist/lib/parsers/parse-zip/file-provider.js +2 -0
  62. package/dist/lib/parsers/parse-zip/local-file-header.d.ts +8 -13
  63. package/dist/lib/parsers/parse-zip/local-file-header.d.ts.map +1 -1
  64. package/dist/lib/parsers/parse-zip/local-file-header.js +16 -10
  65. package/package.json +9 -9
  66. package/src/index.ts +2 -0
  67. package/src/lib/parsers/parse-slpk/parse-slpk.ts +12 -4
  68. package/src/lib/parsers/parse-slpk/slpk-archieve.ts +14 -13
  69. package/src/lib/parsers/parse-zip/buffer-file-provider.ts +55 -0
  70. package/src/lib/parsers/parse-zip/cd-file-header.ts +25 -32
  71. package/src/lib/parsers/parse-zip/file-provider.ts +34 -0
  72. package/src/lib/parsers/parse-zip/local-file-header.ts +33 -24
@@ -55,7 +55,7 @@
55
55
  var nodeVersion = matches && parseFloat(matches[1]) || 0;
56
56
 
57
57
  // ../worker-utils/src/lib/env-utils/version.ts
58
- var VERSION = true ? "4.0.0-alpha.10" : DEFAULT_VERSION;
58
+ var VERSION = true ? "4.0.0-alpha.11" : DEFAULT_VERSION;
59
59
  if (false) {
60
60
  console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
61
61
  }
@@ -1234,7 +1234,7 @@
1234
1234
  var navigator_ = globalThis.navigator || {};
1235
1235
 
1236
1236
  // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js
1237
- var VERSION3 = true ? "4.0.0-alpha.10" : "untranspiled source";
1237
+ var VERSION3 = true ? "4.0.0-alpha.11" : "untranspiled source";
1238
1238
  var isBrowser4 = isBrowser3();
1239
1239
 
1240
1240
  // ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
@@ -4582,7 +4582,7 @@
4582
4582
  _defineProperty(Ellipsoid, "WGS84", new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z));
4583
4583
 
4584
4584
  // ../images/src/lib/utils/version.ts
4585
- var VERSION4 = true ? "4.0.0-alpha.10" : "latest";
4585
+ var VERSION4 = true ? "4.0.0-alpha.11" : "latest";
4586
4586
 
4587
4587
  // ../images/src/lib/category-api/image-type.ts
4588
4588
  var { _parseImageNode } = globalThis;
@@ -4979,7 +4979,7 @@
4979
4979
  };
4980
4980
 
4981
4981
  // ../draco/src/lib/utils/version.ts
4982
- var VERSION5 = true ? "4.0.0-alpha.10" : "latest";
4982
+ var VERSION5 = true ? "4.0.0-alpha.11" : "latest";
4983
4983
 
4984
4984
  // ../draco/src/draco-loader.ts
4985
4985
  var DEFAULT_DRACO_OPTIONS = {
@@ -5524,10 +5524,10 @@
5524
5524
  }
5525
5525
 
5526
5526
  // ../textures/src/lib/utils/version.ts
5527
- var VERSION6 = true ? "4.0.0-alpha.10" : "beta";
5527
+ var VERSION6 = true ? "4.0.0-alpha.11" : "beta";
5528
5528
 
5529
5529
  // ../textures/src/lib/parsers/basis-module-loader.ts
5530
- var VERSION7 = true ? "4.0.0-alpha.10" : "beta";
5530
+ var VERSION7 = true ? "4.0.0-alpha.11" : "beta";
5531
5531
  var BASIS_CDN_ENCODER_WASM = `https://unpkg.com/@loaders.gl/textures@${VERSION7}/dist/libs/basis_encoder.wasm`;
5532
5532
  var BASIS_CDN_ENCODER_JS = `https://unpkg.com/@loaders.gl/textures@${VERSION7}/dist/libs/basis_encoder.js`;
5533
5533
  var loadBasisTranscoderPromise;
@@ -7225,7 +7225,7 @@
7225
7225
  }
7226
7226
 
7227
7227
  // src/i3s-attribute-loader.ts
7228
- var VERSION8 = true ? "4.0.0-alpha.10" : "latest";
7228
+ var VERSION8 = true ? "4.0.0-alpha.11" : "latest";
7229
7229
  var I3SAttributeLoader = {
7230
7230
  name: "I3S Attribute",
7231
7231
  id: "i3s-attribute",
@@ -7688,7 +7688,7 @@
7688
7688
  }
7689
7689
 
7690
7690
  // src/i3s-content-loader.ts
7691
- var VERSION9 = true ? "4.0.0-alpha.10" : "beta";
7691
+ var VERSION9 = true ? "4.0.0-alpha.11" : "beta";
7692
7692
  var I3SContentLoader = {
7693
7693
  name: "I3S Content (Indexed Scene Layers)",
7694
7694
  id: "i3s-content",
package/dist/index.d.ts CHANGED
@@ -7,4 +7,6 @@ export { I3SAttributeLoader, loadFeatureAttributes } from './i3s-attribute-loade
7
7
  export { I3SBuildingSceneLayerLoader } from './i3s-building-scene-layer-loader';
8
8
  export { I3SNodePageLoader } from './i3s-node-page-loader';
9
9
  export { ArcGisWebSceneLoader } from './arcgis-webscene-loader';
10
+ export { parseZipLocalFileHeader } from './lib/parsers/parse-zip/local-file-header';
11
+ export { FileProvider } from './lib/parsers/parse-zip/file-provider';
10
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,eAAe,EACf,GAAG,EACH,GAAG,EACH,YAAY,EACZ,oBAAoB,EACpB,KAAK,EACL,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,SAAS,EACT,MAAM,EACN,gBAAgB,EAChB,SAAS,EACT,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,UAAU,EACV,cAAc,EACd,SAAS,EACT,SAAS,EACT,UAAU,EACV,qBAAqB,EACrB,SAAS,EACT,gBAAgB,EAChB,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAE,qBAAqB,EAAC,MAAM,wBAAwB,CAAC;AACjF,OAAO,EAAC,2BAA2B,EAAC,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,eAAe,EACf,GAAG,EACH,GAAG,EACH,YAAY,EACZ,oBAAoB,EACpB,KAAK,EACL,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,SAAS,EACT,MAAM,EACN,gBAAgB,EAChB,SAAS,EACT,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,UAAU,EACV,cAAc,EACd,SAAS,EACT,SAAS,EACT,UAAU,EACV,qBAAqB,EACrB,SAAS,EACT,gBAAgB,EAChB,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAE,qBAAqB,EAAC,MAAM,wBAAwB,CAAC;AACjF,OAAO,EAAC,2BAA2B,EAAC,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAC,uBAAuB,EAAC,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAAC,YAAY,EAAC,MAAM,uCAAuC,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // loaders.gl, MIT license
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.ArcGisWebSceneLoader = exports.I3SNodePageLoader = exports.I3SBuildingSceneLayerLoader = exports.loadFeatureAttributes = exports.I3SAttributeLoader = exports.I3SContentLoader = exports.SLPKLoader = exports.I3SLoader = exports.COORDINATE_SYSTEM = void 0;
4
+ exports.parseZipLocalFileHeader = exports.ArcGisWebSceneLoader = exports.I3SNodePageLoader = exports.I3SBuildingSceneLayerLoader = exports.loadFeatureAttributes = exports.I3SAttributeLoader = exports.I3SContentLoader = exports.SLPKLoader = exports.I3SLoader = exports.COORDINATE_SYSTEM = void 0;
5
5
  var constants_1 = require("./lib/parsers/constants");
6
6
  Object.defineProperty(exports, "COORDINATE_SYSTEM", { enumerable: true, get: function () { return constants_1.COORDINATE_SYSTEM; } });
7
7
  var i3s_loader_1 = require("./i3s-loader");
@@ -19,3 +19,5 @@ var i3s_node_page_loader_1 = require("./i3s-node-page-loader");
19
19
  Object.defineProperty(exports, "I3SNodePageLoader", { enumerable: true, get: function () { return i3s_node_page_loader_1.I3SNodePageLoader; } });
20
20
  var arcgis_webscene_loader_1 = require("./arcgis-webscene-loader");
21
21
  Object.defineProperty(exports, "ArcGisWebSceneLoader", { enumerable: true, get: function () { return arcgis_webscene_loader_1.ArcGisWebSceneLoader; } });
22
+ var local_file_header_1 = require("./lib/parsers/parse-zip/local-file-header");
23
+ Object.defineProperty(exports, "parseZipLocalFileHeader", { enumerable: true, get: function () { return local_file_header_1.parseZipLocalFileHeader; } });
@@ -1 +1 @@
1
- {"version":3,"file":"parse-slpk.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-slpk/parse-slpk.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;AAehE,wBAAsB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,GAAE,iBAAsB,mBAgDjF"}
1
+ {"version":3,"file":"parse-slpk.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-slpk/parse-slpk.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;AAgBhE,wBAAsB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,GAAE,iBAAsB,mBAuDjF"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseSLPK = void 0;
4
+ const buffer_file_provider_1 = require("../parse-zip/buffer-file-provider");
4
5
  const cd_file_header_1 = require("../parse-zip/cd-file-header");
5
6
  const local_file_header_1 = require("../parse-zip/local-file-header");
6
7
  const slpk_archieve_1 = require("./slpk-archieve");
@@ -34,12 +35,15 @@ async function parseSLPK(data, options = {}) {
34
35
  break;
35
36
  }
36
37
  }
37
- const cdFileHeader = (0, cd_file_header_1.parseZipCDFileHeader)(hashCDOffset, archive);
38
- const textDecoder = new TextDecoder();
39
- if (textDecoder.decode(cdFileHeader.fileName) !== '@specialIndexFileHASH128@') {
38
+ const fileProvider = new buffer_file_provider_1.DataViewFileProvider(archive);
39
+ const cdFileHeader = await (0, cd_file_header_1.parseZipCDFileHeader)(hashCDOffset, fileProvider);
40
+ if (cdFileHeader.fileName !== '@specialIndexFileHASH128@') {
41
+ throw new Error('No hash file in slpk');
42
+ }
43
+ const localFileHeader = await (0, local_file_header_1.parseZipLocalFileHeader)(cdFileHeader.localHeaderOffset, fileProvider);
44
+ if (!localFileHeader) {
40
45
  throw new Error('No hash file in slpk');
41
46
  }
42
- const localFileHeader = (0, local_file_header_1.parseZipLocalFileHeader)(cdFileHeader.localHeaderOffset, archive);
43
47
  const fileDataOffset = localFileHeader.fileDataOffset;
44
48
  const hashFile = archive.buffer.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
45
49
  if (!hashFile) {
@@ -1 +1 @@
1
- {"version":3,"file":"slpk-archieve.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-slpk/slpk-archieve.ts"],"names":[],"mappings":";AAoDA;;GAEG;AACH,qBAAa,WAAW;IACtB,WAAW,EAAE,QAAQ,CAAC;IACtB,SAAS,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC;gBAChC,iBAAiB,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW;IAKjE;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAqBrB;;;;;OAKG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,GAAG,KAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IA8B1E;;;;OAIG;YACW,aAAa;IAiB3B;;;;OAIG;IACH,OAAO,CAAC,YAAY;CAmBrB"}
1
+ {"version":3,"file":"slpk-archieve.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-slpk/slpk-archieve.ts"],"names":[],"mappings":";AAqDA;;GAEG;AACH,qBAAa,WAAW;IACtB,WAAW,EAAE,QAAQ,CAAC;IACtB,SAAS,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC;gBAChC,iBAAiB,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW;IAKjE;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAqBrB;;;;;OAKG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,GAAG,KAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IA8B1E;;;;OAIG;YACW,aAAa;IAc3B;;;;OAIG;YACW,YAAY;CAsB3B"}
@@ -4,10 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.SLPKArchive = void 0;
7
- const worker_utils_1 = require("@loaders.gl/worker-utils");
8
7
  const md5_1 = __importDefault(require("md5"));
9
- const compression_1 = require("@loaders.gl/compression");
10
8
  const local_file_header_1 = require("../parse-zip/local-file-header");
9
+ const buffer_file_provider_1 = require("../parse-zip/buffer-file-provider");
10
+ const compression_1 = require("@loaders.gl/compression");
11
+ /** Description of real paths for different file types */
11
12
  const PATH_DESCRIPTIONS = [
12
13
  {
13
14
  test: /^$/,
@@ -95,7 +96,7 @@ class SLPKArchive {
95
96
  if (decompressedFile) {
96
97
  return Buffer.from(decompressedFile);
97
98
  }
98
- const fileWithoutCompression = this.getFileBytes(path);
99
+ const fileWithoutCompression = await this.getFileBytes(path);
99
100
  if (fileWithoutCompression) {
100
101
  return Buffer.from(fileWithoutCompression);
101
102
  }
@@ -108,17 +109,13 @@ class SLPKArchive {
108
109
  * @returns buffer with the file data
109
110
  */
110
111
  async getDataByPath(path) {
111
- const data = this.getFileBytes(path);
112
+ const data = await this.getFileBytes(path);
112
113
  if (!data) {
113
114
  return undefined;
114
115
  }
115
116
  if (/\.gz$/.test(path)) {
116
- const decompressedData = await (0, worker_utils_1.processOnWorker)(compression_1.CompressionWorker, data, {
117
- compression: 'gzip',
118
- operation: 'decompress',
119
- _workerType: 'test',
120
- gzip: {}
121
- });
117
+ const compression = new compression_1.GZipCompression();
118
+ const decompressedData = await compression.decompress(data);
122
119
  return decompressedData;
123
120
  }
124
121
  return Buffer.from(data);
@@ -128,13 +125,16 @@ class SLPKArchive {
128
125
  * @param path - path inside the archive
129
126
  * @returns buffer with the raw file data
130
127
  */
131
- getFileBytes(path) {
128
+ async getFileBytes(path) {
132
129
  const nameHash = Buffer.from((0, md5_1.default)(path), 'hex');
133
130
  const fileInfo = this.hashArray.find((val) => Buffer.compare(val.hash, nameHash) === 0);
134
131
  if (!fileInfo) {
135
132
  return undefined;
136
133
  }
137
- const localFileHeader = (0, local_file_header_1.parseZipLocalFileHeader)(this.slpkArchive.byteOffset + fileInfo?.offset, this.slpkArchive);
134
+ const localFileHeader = await (0, local_file_header_1.parseZipLocalFileHeader)(this.slpkArchive.byteOffset + fileInfo?.offset, new buffer_file_provider_1.DataViewFileProvider(this.slpkArchive));
135
+ if (!localFileHeader) {
136
+ return undefined;
137
+ }
138
138
  const compressedFile = this.slpkArchive.buffer.slice(localFileHeader.fileDataOffset, localFileHeader.fileDataOffset + localFileHeader.compressedSize);
139
139
  return compressedFile;
140
140
  }
@@ -0,0 +1,37 @@
1
+ import { FileProvider } from './file-provider';
2
+ /**
3
+ * Provides file data using DataView
4
+ */
5
+ export declare class DataViewFileProvider implements FileProvider {
6
+ /**
7
+ * The DataView from which data is provided
8
+ */
9
+ private file;
10
+ constructor(file: DataView);
11
+ /**
12
+ * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
13
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
14
+ */
15
+ getUint8(offset: number): Promise<number>;
16
+ /**
17
+ * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
18
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
19
+ */
20
+ getUint16(offset: number): Promise<number>;
21
+ /**
22
+ * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
23
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
24
+ */
25
+ getUint32(offset: number): Promise<number>;
26
+ /**
27
+ * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
28
+ * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
29
+ * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
30
+ */
31
+ slice(startOffset: number, endOffset: number): Promise<ArrayBuffer>;
32
+ /**
33
+ * the length (in bytes) of the data.
34
+ */
35
+ get length(): number;
36
+ }
37
+ //# sourceMappingURL=buffer-file-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffer-file-provider.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-zip/buffer-file-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IACvD;;OAEG;IACH,OAAO,CAAC,IAAI,CAAW;gBAEX,IAAI,EAAE,QAAQ;IAI1B;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIzC;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI1C;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI1C;;;;OAIG;IACH,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAInE;;OAEG;IACH,IAAI,MAAM,WAET;CACF"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataViewFileProvider = void 0;
4
+ /**
5
+ * Provides file data using DataView
6
+ */
7
+ class DataViewFileProvider {
8
+ constructor(file) {
9
+ this.file = file;
10
+ }
11
+ /**
12
+ * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
13
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
14
+ */
15
+ getUint8(offset) {
16
+ return Promise.resolve(this.file.getUint8(offset));
17
+ }
18
+ /**
19
+ * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
20
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
21
+ */
22
+ getUint16(offset) {
23
+ return Promise.resolve(this.file.getUint16(offset, true));
24
+ }
25
+ /**
26
+ * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
27
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
28
+ */
29
+ getUint32(offset) {
30
+ return Promise.resolve(this.file.getUint32(offset, true));
31
+ }
32
+ /**
33
+ * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
34
+ * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
35
+ * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
36
+ */
37
+ slice(startOffset, endOffset) {
38
+ return Promise.resolve(this.file.buffer.slice(startOffset, endOffset));
39
+ }
40
+ /**
41
+ * the length (in bytes) of the data.
42
+ */
43
+ get length() {
44
+ return this.file.byteLength;
45
+ }
46
+ }
47
+ exports.DataViewFileProvider = DataViewFileProvider;
@@ -1,31 +1,20 @@
1
+ import { FileProvider } from './file-provider';
1
2
  /**
2
3
  * zip central directory file header info
3
4
  * according to https://en.wikipedia.org/wiki/ZIP_(file_format)
4
5
  */
5
6
  export type ZipCDFileHeader = {
6
- /**
7
- * Compressed size
8
- */
7
+ /** Compressed size */
9
8
  compressedSize: number;
10
- /**
11
- * Uncompressed size
12
- */
9
+ /** Uncompressed size */
13
10
  uncompressedSize: number;
14
- /**
15
- * File name length
16
- */
11
+ /** File name length */
17
12
  fileNameLength: number;
18
- /**
19
- * File name
20
- */
21
- fileName: ArrayBuffer;
22
- /**
23
- * Extra field offset
24
- */
13
+ /** File name */
14
+ fileName: string;
15
+ /** Extra field offset */
25
16
  extraOffset: number;
26
- /**
27
- * Relative offset of local file header
28
- */
17
+ /** Relative offset of local file header */
29
18
  localHeaderOffset: number;
30
19
  };
31
20
  /**
@@ -34,5 +23,5 @@ export type ZipCDFileHeader = {
34
23
  * @param buffer - buffer containing whole array
35
24
  * @returns Info from the header
36
25
  */
37
- export declare const parseZipCDFileHeader: (headerOffset: number, buffer: DataView) => ZipCDFileHeader;
26
+ export declare const parseZipCDFileHeader: (headerOffset: number, buffer: FileProvider) => Promise<ZipCDFileHeader>;
38
27
  //# sourceMappingURL=cd-file-header.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cd-file-header.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-zip/cd-file-header.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,QAAQ,EAAE,WAAW,CAAC;IACtB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,iBAAkB,MAAM,UAAU,QAAQ,KAAG,eAuD7E,CAAC"}
1
+ {"version":3,"file":"cd-file-header.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-zip/cd-file-header.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,wBAAwB;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,uBAAuB;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,iBACjB,MAAM,UACZ,YAAY,KACnB,QAAQ,eAAe,CAuDzB,CAAC"}
@@ -7,7 +7,7 @@ exports.parseZipCDFileHeader = void 0;
7
7
  * @param buffer - buffer containing whole array
8
8
  * @returns Info from the header
9
9
  */
10
- const parseZipCDFileHeader = (headerOffset, buffer) => {
10
+ const parseZipCDFileHeader = async (headerOffset, buffer) => {
11
11
  const offsets = {
12
12
  CD_COMPRESSED_SIZE_OFFSET: 20,
13
13
  CD_UNCOMPRESSED_SIZE_OFFSET: 24,
@@ -16,12 +16,12 @@ const parseZipCDFileHeader = (headerOffset, buffer) => {
16
16
  CD_LOCAL_HEADER_OFFSET_OFFSET: 42,
17
17
  CD_FILE_NAME_OFFSET: 46
18
18
  };
19
- const compressedSize = buffer.getUint32(headerOffset + offsets.CD_COMPRESSED_SIZE_OFFSET, true);
20
- const uncompressedSize = buffer.getUint32(headerOffset + offsets.CD_UNCOMPRESSED_SIZE_OFFSET, true);
21
- const fileNameLength = buffer.getUint16(headerOffset + offsets.CD_FILE_NAME_LENGTH_OFFSET, true);
22
- const fileName = buffer.buffer.slice(headerOffset + offsets.CD_FILE_NAME_OFFSET, headerOffset + offsets.CD_FILE_NAME_OFFSET + fileNameLength);
19
+ const compressedSize = await buffer.getUint32(headerOffset + offsets.CD_COMPRESSED_SIZE_OFFSET);
20
+ const uncompressedSize = await buffer.getUint32(headerOffset + offsets.CD_UNCOMPRESSED_SIZE_OFFSET);
21
+ const fileNameLength = await buffer.getUint16(headerOffset + offsets.CD_FILE_NAME_LENGTH_OFFSET);
22
+ const fileName = new TextDecoder().decode(await buffer.slice(headerOffset + offsets.CD_FILE_NAME_OFFSET, headerOffset + offsets.CD_FILE_NAME_OFFSET + fileNameLength));
23
23
  const extraOffset = headerOffset + offsets.CD_FILE_NAME_OFFSET + fileNameLength;
24
- const oldFormatOffset = buffer.getUint32(headerOffset + offsets.CD_LOCAL_HEADER_OFFSET_OFFSET, true);
24
+ const oldFormatOffset = await buffer.getUint32(headerOffset + offsets.CD_LOCAL_HEADER_OFFSET_OFFSET);
25
25
  let fileDataOffset = oldFormatOffset;
26
26
  if (fileDataOffset === 0xffffffff) {
27
27
  let offsetInZip64Data = 4;
@@ -33,7 +33,7 @@ const parseZipCDFileHeader = (headerOffset, buffer) => {
33
33
  offsetInZip64Data += 8;
34
34
  }
35
35
  // getUint32 needs to be replaced with getBigUint64 for archieves bigger than 2gb
36
- fileDataOffset = buffer.getUint32(extraOffset + offsetInZip64Data, true); // setting it to the one from zip64
36
+ fileDataOffset = await buffer.getUint32(extraOffset + offsetInZip64Data); // setting it to the one from zip64
37
37
  }
38
38
  const localHeaderOffset = fileDataOffset;
39
39
  return {
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Interface for providing file data
3
+ */
4
+ export interface FileProvider {
5
+ /**
6
+ * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
7
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
8
+ */
9
+ getUint8(offset: number): Promise<number>;
10
+ /**
11
+ * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
12
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
13
+ */
14
+ getUint16(offset: number): Promise<number>;
15
+ /**
16
+ * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
17
+ * @param offset The offset, in bytes, from the file of the view where to read the data.
18
+ */
19
+ getUint32(offset: number): Promise<number>;
20
+ /**
21
+ * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
22
+ * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
23
+ * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
24
+ */
25
+ slice(startOffset: number, endOffset: number): Promise<ArrayBuffer>;
26
+ /**
27
+ * the length (in bytes) of the data.
28
+ */
29
+ length: number;
30
+ }
31
+ //# sourceMappingURL=file-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-provider.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-zip/file-provider.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1C;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3C;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3C;;;;OAIG;IACH,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAEpE;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,23 +1,18 @@
1
+ import { FileProvider } from './file-provider';
1
2
  /**
2
3
  * zip local file header info
3
4
  * according to https://en.wikipedia.org/wiki/ZIP_(file_format)
4
5
  */
5
6
  export type ZipLocalFileHeader = {
6
- /**
7
- * File name length
8
- */
7
+ /** File name length */
9
8
  fileNameLength: number;
10
- /**
11
- * Extra field length
12
- */
9
+ /** File name */
10
+ fileName: string;
11
+ /** Extra field length */
13
12
  extraFieldLength: number;
14
- /**
15
- * Offset of the file data
16
- */
13
+ /** Offset of the file data */
17
14
  fileDataOffset: number;
18
- /**
19
- * Compressed size
20
- */
15
+ /** Compressed size */
21
16
  compressedSize: number;
22
17
  };
23
18
  /**
@@ -26,5 +21,5 @@ export type ZipLocalFileHeader = {
26
21
  * @param buffer - buffer containing whole array
27
22
  * @returns Info from the header
28
23
  */
29
- export declare const parseZipLocalFileHeader: (headerOffset: number, buffer: DataView) => ZipLocalFileHeader;
24
+ export declare const parseZipLocalFileHeader: (headerOffset: number, buffer: FileProvider) => Promise<ZipLocalFileHeader | undefined>;
30
25
  //# sourceMappingURL=local-file-header.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"local-file-header.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-zip/local-file-header.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,iBACpB,MAAM,UACZ,QAAQ,KACf,kBAuBF,CAAC"}
1
+ {"version":3,"file":"local-file-header.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-zip/local-file-header.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,uBAAuB;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,8BAA8B;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAWF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,iBACpB,MAAM,UACZ,YAAY,KACnB,QAAQ,kBAAkB,GAAG,SAAS,CA2BxC,CAAC"}
@@ -1,25 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseZipLocalFileHeader = void 0;
4
+ const offsets = {
5
+ COMPRESSED_SIZE_OFFSET: 18,
6
+ FILE_NAME_LENGTH_OFFSET: 26,
7
+ EXTRA_FIELD_LENGTH_OFFSET: 28,
8
+ FILE_NAME_OFFSET: 30
9
+ };
10
+ const signature = Buffer.from([0x50, 0x4b, 0x03, 0x04]);
4
11
  /**
5
12
  * Parses local file header of zip file
6
13
  * @param headerOffset - offset in the archive where header starts
7
14
  * @param buffer - buffer containing whole array
8
15
  * @returns Info from the header
9
16
  */
10
- const parseZipLocalFileHeader = (headerOffset, buffer) => {
11
- const offsets = {
12
- COMPRESSED_SIZE_OFFSET: 18,
13
- FILE_NAME_LENGTH_OFFSET: 26,
14
- EXTRA_FIELD_LENGTH_OFFSET: 28,
15
- FILE_NAME_OFFSET: 30
16
- };
17
- const fileNameLength = buffer.getUint16(headerOffset + offsets.FILE_NAME_LENGTH_OFFSET, true);
18
- const extraFieldLength = buffer.getUint16(headerOffset + offsets.EXTRA_FIELD_LENGTH_OFFSET, true);
17
+ const parseZipLocalFileHeader = async (headerOffset, buffer) => {
18
+ if (Buffer.from(await buffer.slice(headerOffset, headerOffset + 4)).compare(signature) !== 0) {
19
+ return Promise.resolve(undefined);
20
+ }
21
+ const fileNameLength = await buffer.getUint16(headerOffset + offsets.FILE_NAME_LENGTH_OFFSET);
22
+ const fileName = new TextDecoder().decode(await buffer.slice(headerOffset + offsets.FILE_NAME_OFFSET, headerOffset + offsets.FILE_NAME_OFFSET + fileNameLength));
23
+ const extraFieldLength = await buffer.getUint16(headerOffset + offsets.EXTRA_FIELD_LENGTH_OFFSET);
19
24
  const fileDataOffset = headerOffset + offsets.FILE_NAME_OFFSET + fileNameLength + extraFieldLength;
20
- const compressedSize = buffer.getUint32(headerOffset + offsets.COMPRESSED_SIZE_OFFSET, true);
25
+ const compressedSize = await buffer.getUint32(headerOffset + offsets.COMPRESSED_SIZE_OFFSET);
21
26
  return {
22
27
  fileNameLength,
28
+ fileName,
23
29
  extraFieldLength,
24
30
  fileDataOffset,
25
31
  compressedSize
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/i3s",
3
- "version": "4.0.0-alpha.10",
3
+ "version": "4.0.0-alpha.11",
4
4
  "description": "i3s .",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -33,13 +33,13 @@
33
33
  "build-worker-node": "esbuild src/workers/i3s-content-worker-node.ts --outfile=dist/i3s-content-worker-node.js --platform=node --target=node16 --minify --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\""
34
34
  },
35
35
  "dependencies": {
36
- "@loaders.gl/compression": "4.0.0-alpha.10",
37
- "@loaders.gl/draco": "4.0.0-alpha.10",
38
- "@loaders.gl/images": "4.0.0-alpha.10",
39
- "@loaders.gl/loader-utils": "4.0.0-alpha.10",
40
- "@loaders.gl/schema": "4.0.0-alpha.10",
41
- "@loaders.gl/textures": "4.0.0-alpha.10",
42
- "@loaders.gl/tiles": "4.0.0-alpha.10",
36
+ "@loaders.gl/compression": "4.0.0-alpha.11",
37
+ "@loaders.gl/draco": "4.0.0-alpha.11",
38
+ "@loaders.gl/images": "4.0.0-alpha.11",
39
+ "@loaders.gl/loader-utils": "4.0.0-alpha.11",
40
+ "@loaders.gl/schema": "4.0.0-alpha.11",
41
+ "@loaders.gl/textures": "4.0.0-alpha.11",
42
+ "@loaders.gl/tiles": "4.0.0-alpha.11",
43
43
  "@luma.gl/constants": "^8.5.4",
44
44
  "@math.gl/core": "^3.5.1",
45
45
  "@math.gl/culling": "^3.5.1",
@@ -49,5 +49,5 @@
49
49
  "peerDependencies": {
50
50
  "@loaders.gl/core": "^4.0.0-alpha.8"
51
51
  },
52
- "gitHead": "7efdbe09e02098aad6d985e4d6465d08806e19a9"
52
+ "gitHead": "bc680098cfea790c67b7fb95bab96e8d9288d34f"
53
53
  }
package/src/index.ts CHANGED
@@ -43,3 +43,5 @@ export {I3SAttributeLoader, loadFeatureAttributes} from './i3s-attribute-loader'
43
43
  export {I3SBuildingSceneLayerLoader} from './i3s-building-scene-layer-loader';
44
44
  export {I3SNodePageLoader} from './i3s-node-page-loader';
45
45
  export {ArcGisWebSceneLoader} from './arcgis-webscene-loader';
46
+ export {parseZipLocalFileHeader} from './lib/parsers/parse-zip/local-file-header';
47
+ export {FileProvider} from './lib/parsers/parse-zip/file-provider';
@@ -1,4 +1,5 @@
1
1
  import type {SLPKLoaderOptions} from '../../../i3s-slpk-loader';
2
+ import {DataViewFileProvider} from '../parse-zip/buffer-file-provider';
2
3
  import {parseZipCDFileHeader} from '../parse-zip/cd-file-header';
3
4
  import {parseZipLocalFileHeader} from '../parse-zip/local-file-header';
4
5
  import {SLPKArchive} from './slpk-archieve';
@@ -38,14 +39,21 @@ export async function parseSLPK(data: ArrayBuffer, options: SLPKLoaderOptions =
38
39
  }
39
40
  }
40
41
 
41
- const cdFileHeader = parseZipCDFileHeader(hashCDOffset, archive);
42
+ const fileProvider = new DataViewFileProvider(archive);
42
43
 
43
- const textDecoder = new TextDecoder();
44
- if (textDecoder.decode(cdFileHeader.fileName) !== '@specialIndexFileHASH128@') {
44
+ const cdFileHeader = await parseZipCDFileHeader(hashCDOffset, fileProvider);
45
+
46
+ if (cdFileHeader.fileName !== '@specialIndexFileHASH128@') {
45
47
  throw new Error('No hash file in slpk');
46
48
  }
47
49
 
48
- const localFileHeader = parseZipLocalFileHeader(cdFileHeader.localHeaderOffset, archive);
50
+ const localFileHeader = await parseZipLocalFileHeader(
51
+ cdFileHeader.localHeaderOffset,
52
+ fileProvider
53
+ );
54
+ if (!localFileHeader) {
55
+ throw new Error('No hash file in slpk');
56
+ }
49
57
 
50
58
  const fileDataOffset = localFileHeader.fileDataOffset;
51
59
  const hashFile = archive.buffer.slice(