@loaders.gl/i3s 4.0.0-alpha.14 → 4.0.0-alpha.15

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 (91) hide show
  1. package/dist/dist.min.js +139 -102
  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 +30 -2
  9. package/dist/es5/i3s-slpk-loader.js.map +1 -1
  10. package/dist/es5/index.js +7 -7
  11. package/dist/es5/index.js.map +1 -1
  12. package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js +30 -69
  13. package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js.map +1 -1
  14. package/dist/es5/lib/parsers/parse-slpk/search-from-the-end.js +69 -0
  15. package/dist/es5/lib/parsers/parse-slpk/search-from-the-end.js.map +1 -0
  16. package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js +5 -6
  17. package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js.map +1 -1
  18. package/dist/es5/lib/parsers/parse-zip/cd-file-header.js +53 -35
  19. package/dist/es5/lib/parsers/parse-zip/cd-file-header.js.map +1 -1
  20. package/dist/es5/lib/parsers/parse-zip/data-view-file-provider.js +129 -0
  21. package/dist/es5/lib/parsers/parse-zip/data-view-file-provider.js.map +1 -0
  22. package/dist/es5/lib/parsers/parse-zip/file-provider.js.map +1 -1
  23. package/dist/es5/lib/parsers/parse-zip/local-file-header.js +54 -13
  24. package/dist/es5/lib/parsers/parse-zip/local-file-header.js.map +1 -1
  25. package/dist/esm/arcgis-webscene-loader.js +1 -1
  26. package/dist/esm/i3s-attribute-loader.js +1 -1
  27. package/dist/esm/i3s-building-scene-layer-loader.js +1 -1
  28. package/dist/esm/i3s-content-loader.js +1 -1
  29. package/dist/esm/i3s-loader.js +1 -1
  30. package/dist/esm/i3s-node-page-loader.js +1 -1
  31. package/dist/esm/i3s-slpk-loader.js +8 -2
  32. package/dist/esm/i3s-slpk-loader.js.map +1 -1
  33. package/dist/esm/index.js +1 -1
  34. package/dist/esm/index.js.map +1 -1
  35. package/dist/esm/lib/parsers/parse-slpk/parse-slpk.js +7 -25
  36. package/dist/esm/lib/parsers/parse-slpk/parse-slpk.js.map +1 -1
  37. package/dist/esm/lib/parsers/parse-slpk/search-from-the-end.js +16 -0
  38. package/dist/esm/lib/parsers/parse-slpk/search-from-the-end.js.map +1 -0
  39. package/dist/esm/lib/parsers/parse-slpk/slpk-archieve.js +5 -6
  40. package/dist/esm/lib/parsers/parse-slpk/slpk-archieve.js.map +1 -1
  41. package/dist/esm/lib/parsers/parse-zip/cd-file-header.js +22 -20
  42. package/dist/esm/lib/parsers/parse-zip/cd-file-header.js.map +1 -1
  43. package/dist/esm/lib/parsers/parse-zip/data-view-file-provider.js +32 -0
  44. package/dist/esm/lib/parsers/parse-zip/data-view-file-provider.js.map +1 -0
  45. package/dist/esm/lib/parsers/parse-zip/file-provider.js.map +1 -1
  46. package/dist/esm/lib/parsers/parse-zip/local-file-header.js +24 -9
  47. package/dist/esm/lib/parsers/parse-zip/local-file-header.js.map +1 -1
  48. package/dist/i3s-content-worker-node.js +2 -2
  49. package/dist/i3s-content-worker.js +8 -8
  50. package/dist/i3s-slpk-loader.d.ts +3 -0
  51. package/dist/i3s-slpk-loader.d.ts.map +1 -1
  52. package/dist/i3s-slpk-loader.js +11 -1
  53. package/dist/index.d.ts +2 -1
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +3 -1
  56. package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts +8 -3
  57. package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts.map +1 -1
  58. package/dist/lib/parsers/parse-slpk/parse-slpk.js +10 -33
  59. package/dist/lib/parsers/parse-slpk/search-from-the-end.d.ts +11 -0
  60. package/dist/lib/parsers/parse-slpk/search-from-the-end.d.ts.map +1 -0
  61. package/dist/lib/parsers/parse-slpk/search-from-the-end.js +31 -0
  62. package/dist/lib/parsers/parse-slpk/slpk-archieve.d.ts +4 -3
  63. package/dist/lib/parsers/parse-slpk/slpk-archieve.d.ts.map +1 -1
  64. package/dist/lib/parsers/parse-slpk/slpk-archieve.js +5 -6
  65. package/dist/lib/parsers/parse-zip/cd-file-header.d.ts +5 -5
  66. package/dist/lib/parsers/parse-zip/cd-file-header.d.ts.map +1 -1
  67. package/dist/lib/parsers/parse-zip/cd-file-header.js +23 -22
  68. package/dist/lib/parsers/parse-zip/{buffer-file-provider.d.ts → data-view-file-provider.d.ts} +15 -16
  69. package/dist/lib/parsers/parse-zip/data-view-file-provider.d.ts.map +1 -0
  70. package/dist/lib/parsers/parse-zip/{buffer-file-provider.js → data-view-file-provider.js} +28 -14
  71. package/dist/lib/parsers/parse-zip/file-provider.d.ts +10 -5
  72. package/dist/lib/parsers/parse-zip/file-provider.d.ts.map +1 -1
  73. package/dist/lib/parsers/parse-zip/local-file-header.d.ts +5 -3
  74. package/dist/lib/parsers/parse-zip/local-file-header.d.ts.map +1 -1
  75. package/dist/lib/parsers/parse-zip/local-file-header.js +29 -10
  76. package/package.json +9 -9
  77. package/src/i3s-slpk-loader.ts +19 -1
  78. package/src/index.ts +2 -1
  79. package/src/lib/parsers/parse-slpk/parse-slpk.ts +11 -40
  80. package/src/lib/parsers/parse-slpk/search-from-the-end.ts +38 -0
  81. package/src/lib/parsers/parse-slpk/slpk-archieve.ts +9 -12
  82. package/src/lib/parsers/parse-zip/cd-file-header.ts +31 -29
  83. package/src/lib/parsers/parse-zip/data-view-file-provider.ts +69 -0
  84. package/src/lib/parsers/parse-zip/file-provider.ts +11 -5
  85. package/src/lib/parsers/parse-zip/local-file-header.ts +43 -17
  86. package/dist/es5/lib/parsers/parse-zip/buffer-file-provider.js +0 -46
  87. package/dist/es5/lib/parsers/parse-zip/buffer-file-provider.js.map +0 -1
  88. package/dist/esm/lib/parsers/parse-zip/buffer-file-provider.js +0 -23
  89. package/dist/esm/lib/parsers/parse-zip/buffer-file-provider.js.map +0 -1
  90. package/dist/lib/parsers/parse-zip/buffer-file-provider.d.ts.map +0 -1
  91. package/src/lib/parsers/parse-zip/buffer-file-provider.ts +0 -55
@@ -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.14" : DEFAULT_VERSION;
58
+ var VERSION = true ? "4.0.0-alpha.15" : 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.14" : "untranspiled source";
1237
+ var VERSION3 = true ? "4.0.0-alpha.15" : "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.14" : "latest";
4585
+ var VERSION4 = true ? "4.0.0-alpha.15" : "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.14" : "latest";
4982
+ var VERSION5 = true ? "4.0.0-alpha.15" : "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.14" : "beta";
5527
+ var VERSION6 = true ? "4.0.0-alpha.15" : "beta";
5528
5528
 
5529
5529
  // ../textures/src/lib/parsers/basis-module-loader.ts
5530
- var VERSION7 = true ? "4.0.0-alpha.14" : "beta";
5530
+ var VERSION7 = true ? "4.0.0-alpha.15" : "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.14" : "latest";
7228
+ var VERSION8 = true ? "4.0.0-alpha.15" : "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.14" : "beta";
7691
+ var VERSION9 = true ? "4.0.0-alpha.15" : "beta";
7692
7692
  var I3SContentLoader = {
7693
7693
  name: "I3S Content (Indexed Scene Layers)",
7694
7694
  id: "i3s-content",
@@ -1,8 +1,11 @@
1
1
  /// <reference types="node" />
2
2
  import { LoaderOptions, LoaderWithParser } from '@loaders.gl/loader-utils';
3
+ /** options to load data from SLPK */
3
4
  export type SLPKLoaderOptions = LoaderOptions & {
4
5
  slpk?: {
6
+ /** path inside the slpk archive */
5
7
  path?: string;
8
+ /** mode of the path */
6
9
  pathMode?: 'http' | 'raw';
7
10
  };
8
11
  };
@@ -1 +1 @@
1
- {"version":3,"file":"i3s-slpk-loader.d.ts","sourceRoot":"","sources":["../src/i3s-slpk-loader.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAOzE,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG;IAC9C,IAAI,CAAC,EAAE;QACL,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;KAC3B,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,gBAAgB,CAAC,MAAM,EAAE,KAAK,EAAE,iBAAiB,CASzE,CAAC"}
1
+ {"version":3,"file":"i3s-slpk-loader.d.ts","sourceRoot":"","sources":["../src/i3s-slpk-loader.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAQzE,qCAAqC;AACrC,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG;IAC9C,IAAI,CAAC,EAAE;QACL,mCAAmC;QACnC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,uBAAuB;QACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;KAC3B,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,gBAAgB,CAAC,MAAM,EAAE,KAAK,EAAE,iBAAiB,CASzE,CAAC"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SLPKLoader = void 0;
4
4
  const parse_slpk_1 = require("./lib/parsers/parse-slpk/parse-slpk");
5
+ const data_view_file_provider_1 = require("./lib/parsers/parse-zip/data-view-file-provider");
5
6
  // __VERSION__ is injected by babel-plugin-version-inline
6
7
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
8
  const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
@@ -14,7 +15,16 @@ exports.SLPKLoader = {
14
15
  module: 'i3s',
15
16
  version: VERSION,
16
17
  mimeTypes: ['application/octet-stream'],
17
- parse: parse_slpk_1.parseSLPK,
18
+ parse: parseSLPK,
18
19
  extensions: ['slpk'],
19
20
  options: {}
20
21
  };
22
+ /**
23
+ * returns a single file from the slpk archive
24
+ * @param data slpk archive data
25
+ * @param options options
26
+ * @returns requested file
27
+ */
28
+ async function parseSLPK(data, options = {}) {
29
+ return (await (0, parse_slpk_1.parseSLPK)(new data_view_file_provider_1.DataViewFileProvider(new DataView(data)))).getFile(options.slpk?.path ?? '', options.slpk?.pathMode);
30
+ }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export type { BoundingVolumes, Mbs, Obb, SceneLayer3D, AttributeStorageInfo, Field, ESRIField, PopupInfo, Node3DIndexDocument, LodSelection, NodeReference, Resource, MaxScreenThresholdSQ, NodeInPage, SharedResources, Attribute, Extent, FeatureAttribute, FieldInfo, I3SMaterialDefinition, TextureDefinitionInfo, MaterialDefinitionInfo, FullExtent, StatisticsInfo, StatsInfo, Histogram, ValueCount, BuildingSceneSublayer, DATA_TYPE, OperationalLayer, TextureSetDefinitionFormats } from './types';
2
+ export type { FileProvider } from './lib/parsers/parse-zip/file-provider';
2
3
  export { COORDINATE_SYSTEM } from './lib/parsers/constants';
3
4
  export { I3SLoader } from './i3s-loader';
4
5
  export { SLPKLoader } from './i3s-slpk-loader';
@@ -8,5 +9,5 @@ export { I3SBuildingSceneLayerLoader } from './i3s-building-scene-layer-loader';
8
9
  export { I3SNodePageLoader } from './i3s-node-page-loader';
9
10
  export { ArcGisWebSceneLoader } from './arcgis-webscene-loader';
10
11
  export { parseZipLocalFileHeader } from './lib/parsers/parse-zip/local-file-header';
11
- export { FileProvider } from './lib/parsers/parse-zip/file-provider';
12
+ export { parseSLPK } from './lib/parsers/parse-slpk/parse-slpk';
12
13
  //# 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;AAC9D,OAAO,EAAC,uBAAuB,EAAC,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAAC,YAAY,EAAC,MAAM,uCAAuC,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;AACjB,YAAY,EAAC,YAAY,EAAC,MAAM,uCAAuC,CAAC;AAExE,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,SAAS,EAAC,MAAM,qCAAqC,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.parseZipLocalFileHeader = exports.ArcGisWebSceneLoader = exports.I3SNodePageLoader = exports.I3SBuildingSceneLayerLoader = exports.loadFeatureAttributes = exports.I3SAttributeLoader = exports.I3SContentLoader = exports.SLPKLoader = exports.I3SLoader = exports.COORDINATE_SYSTEM = void 0;
4
+ exports.parseSLPK = 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");
@@ -21,3 +21,5 @@ 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
22
  var local_file_header_1 = require("./lib/parsers/parse-zip/local-file-header");
23
23
  Object.defineProperty(exports, "parseZipLocalFileHeader", { enumerable: true, get: function () { return local_file_header_1.parseZipLocalFileHeader; } });
24
+ var parse_slpk_1 = require("./lib/parsers/parse-slpk/parse-slpk");
25
+ Object.defineProperty(exports, "parseSLPK", { enumerable: true, get: function () { return parse_slpk_1.parseSLPK; } });
@@ -1,4 +1,9 @@
1
- /// <reference types="node" />
2
- import type { SLPKLoaderOptions } from '../../../i3s-slpk-loader';
3
- export declare function parseSLPK(data: ArrayBuffer, options?: SLPKLoaderOptions): Promise<Buffer>;
1
+ import { FileProvider } from '../parse-zip/file-provider';
2
+ import { SLPKArchive } from './slpk-archieve';
3
+ /**
4
+ * Creates slpk file handler from raw file
5
+ * @param fileProvider raw file data
6
+ * @returns slpk file handler
7
+ */
8
+ export declare const parseSLPK: (fileProvider: FileProvider) => Promise<SLPKArchive>;
4
9
  //# sourceMappingURL=parse-slpk.d.ts.map
@@ -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;AAgBhE,wBAAsB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,GAAE,iBAAsB,mBAuDjF"}
1
+ {"version":3,"file":"parse-slpk.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-slpk/parse-slpk.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,4BAA4B,CAAC;AAGxD,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAE5C;;;;GAIG;AAEH,eAAO,MAAM,SAAS,iBAAwB,YAAY,KAAG,QAAQ,WAAW,CA8B/E,CAAC"}
@@ -1,41 +1,18 @@
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");
5
4
  const cd_file_header_1 = require("../parse-zip/cd-file-header");
6
5
  const local_file_header_1 = require("../parse-zip/local-file-header");
6
+ const search_from_the_end_1 = require("./search-from-the-end");
7
7
  const slpk_archieve_1 = require("./slpk-archieve");
8
8
  /**
9
- * Returns one byte from the provided buffer at the provided position
10
- * @param offset - position where to read
11
- * @param buffer - buffer to read
12
- * @returns one byte from the provided buffer at the provided position
9
+ * Creates slpk file handler from raw file
10
+ * @param fileProvider raw file data
11
+ * @returns slpk file handler
13
12
  */
14
- const getByteAt = (offset, buffer) => {
15
- return buffer.getUint8(buffer.byteOffset + offset);
16
- };
17
- async function parseSLPK(data, options = {}) {
18
- const archive = new DataView(data);
19
- const cdFileHeaderSignature = [80, 75, 1, 2];
20
- const searchWindow = [
21
- getByteAt(archive.byteLength - 1, archive),
22
- getByteAt(archive.byteLength - 2, archive),
23
- getByteAt(archive.byteLength - 3, archive),
24
- undefined
25
- ];
26
- let hashCDOffset = 0;
27
- // looking for the last record in the central directory
28
- for (let i = archive.byteLength - 4; i > -1; i--) {
29
- searchWindow[3] = searchWindow[2];
30
- searchWindow[2] = searchWindow[1];
31
- searchWindow[1] = searchWindow[0];
32
- searchWindow[0] = getByteAt(i, archive);
33
- if (searchWindow.every((val, index) => val === cdFileHeaderSignature[index])) {
34
- hashCDOffset = i;
35
- break;
36
- }
37
- }
38
- const fileProvider = new buffer_file_provider_1.DataViewFileProvider(archive);
13
+ const parseSLPK = async (fileProvider) => {
14
+ const cdFileHeaderSignature = [0x50, 0x4b, 0x01, 0x02];
15
+ const hashCDOffset = await (0, search_from_the_end_1.searchFromTheEnd)(fileProvider, cdFileHeaderSignature);
39
16
  const cdFileHeader = await (0, cd_file_header_1.parseZipCDFileHeader)(hashCDOffset, fileProvider);
40
17
  if (cdFileHeader.fileName !== '@specialIndexFileHASH128@') {
41
18
  throw new Error('No hash file in slpk');
@@ -45,10 +22,10 @@ async function parseSLPK(data, options = {}) {
45
22
  throw new Error('No hash file in slpk');
46
23
  }
47
24
  const fileDataOffset = localFileHeader.fileDataOffset;
48
- const hashFile = archive.buffer.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
25
+ const hashFile = await fileProvider.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
49
26
  if (!hashFile) {
50
27
  throw new Error('No hash file in slpk');
51
28
  }
52
- return await new slpk_archieve_1.SLPKArchive(data, hashFile).getFile(options.slpk?.path ?? '', options.slpk?.pathMode);
53
- }
29
+ return new slpk_archieve_1.SLPKArchive(fileProvider, hashFile);
30
+ };
54
31
  exports.parseSLPK = parseSLPK;
@@ -0,0 +1,11 @@
1
+ import { FileProvider } from 'modules/i3s/src/lib/parsers/parse-zip/file-provider';
2
+ /** Description of zip signature type */
3
+ export type ZipSignature = [number, number, number, number];
4
+ /**
5
+ * looking for the last occurrence of the provided
6
+ * @param file
7
+ * @param target
8
+ * @returns
9
+ */
10
+ export declare const searchFromTheEnd: (file: FileProvider, target: ZipSignature) => Promise<bigint>;
11
+ //# sourceMappingURL=search-from-the-end.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-from-the-end.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-slpk/search-from-the-end.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,qDAAqD,CAAC;AAEjF,wCAAwC;AACxC,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,SACrB,YAAY,2BAEjB,QAAQ,MAAM,CAuBhB,CAAC"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchFromTheEnd = void 0;
4
+ /**
5
+ * looking for the last occurrence of the provided
6
+ * @param file
7
+ * @param target
8
+ * @returns
9
+ */
10
+ const searchFromTheEnd = async (file, target) => {
11
+ const searchWindow = [
12
+ await file.getUint8(file.length - 1n),
13
+ await file.getUint8(file.length - 2n),
14
+ await file.getUint8(file.length - 3n),
15
+ undefined
16
+ ];
17
+ let targetOffset = 0n;
18
+ // looking for the last record in the central directory
19
+ for (let i = file.length - 4n; i > -1; i--) {
20
+ searchWindow[3] = searchWindow[2];
21
+ searchWindow[2] = searchWindow[1];
22
+ searchWindow[1] = searchWindow[0];
23
+ searchWindow[0] = await file.getUint8(i);
24
+ if (searchWindow.every((val, index) => val === target[index])) {
25
+ targetOffset = i;
26
+ break;
27
+ }
28
+ }
29
+ return targetOffset;
30
+ };
31
+ exports.searchFromTheEnd = searchFromTheEnd;
@@ -1,14 +1,15 @@
1
1
  /// <reference types="node" />
2
+ import { FileProvider } from '../parse-zip/file-provider';
2
3
  /**
3
4
  * Class for handling information about slpk file
4
5
  */
5
6
  export declare class SLPKArchive {
6
- slpkArchive: DataView;
7
+ slpkArchive: FileProvider;
7
8
  hashArray: {
8
9
  hash: Buffer;
9
- offset: number;
10
+ offset: bigint;
10
11
  }[];
11
- constructor(slpkArchiveBuffer: ArrayBuffer, hashFile: ArrayBuffer);
12
+ constructor(slpkArchive: FileProvider, hashFile: ArrayBuffer);
12
13
  /**
13
14
  * Reads hash file from buffer and returns it in ready-to-use form
14
15
  * @param hashFile - bufer containing hash file
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"slpk-archieve.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-slpk/slpk-archieve.ts"],"names":[],"mappings":";AAGA,OAAO,EAAC,YAAY,EAAC,MAAM,4BAA4B,CAAC;AAkDxD;;GAEG;AACH,qBAAa,WAAW;IACtB,WAAW,EAAE,YAAY,CAAC;IAC1B,SAAS,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC;gBAChC,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW;IAK5D;;;;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;CAmB3B"}
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.SLPKArchive = void 0;
7
7
  const md5_1 = __importDefault(require("md5"));
8
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
9
  const compression_1 = require("@loaders.gl/compression");
11
10
  /** Description of real paths for different file types */
12
11
  const PATH_DESCRIPTIONS = [
@@ -47,8 +46,8 @@ const PATH_DESCRIPTIONS = [
47
46
  * Class for handling information about slpk file
48
47
  */
49
48
  class SLPKArchive {
50
- constructor(slpkArchiveBuffer, hashFile) {
51
- this.slpkArchive = new DataView(slpkArchiveBuffer);
49
+ constructor(slpkArchive, hashFile) {
50
+ this.slpkArchive = slpkArchive;
52
51
  this.hashArray = this.parseHashFile(hashFile);
53
52
  }
54
53
  /**
@@ -61,7 +60,7 @@ class SLPKArchive {
61
60
  const hashArray = [];
62
61
  for (let i = 0; i < hashFileBuffer.buffer.byteLength; i = i + 24) {
63
62
  const offsetBuffer = new DataView(hashFileBuffer.buffer.slice(hashFileBuffer.byteOffset + i + 16, hashFileBuffer.byteOffset + i + 24));
64
- const offset = offsetBuffer.getUint32(offsetBuffer.byteOffset, true);
63
+ const offset = offsetBuffer.getBigUint64(offsetBuffer.byteOffset, true);
65
64
  hashArray.push({
66
65
  hash: Buffer.from(hashFileBuffer.subarray(hashFileBuffer.byteOffset + i, hashFileBuffer.byteOffset + i + 16)),
67
66
  offset
@@ -131,11 +130,11 @@ class SLPKArchive {
131
130
  if (!fileInfo) {
132
131
  return undefined;
133
132
  }
134
- const localFileHeader = await (0, local_file_header_1.parseZipLocalFileHeader)(this.slpkArchive.byteOffset + fileInfo?.offset, new buffer_file_provider_1.DataViewFileProvider(this.slpkArchive));
133
+ const localFileHeader = await (0, local_file_header_1.parseZipLocalFileHeader)(fileInfo?.offset, this.slpkArchive);
135
134
  if (!localFileHeader) {
136
135
  return undefined;
137
136
  }
138
- const compressedFile = this.slpkArchive.buffer.slice(localFileHeader.fileDataOffset, localFileHeader.fileDataOffset + localFileHeader.compressedSize);
137
+ const compressedFile = this.slpkArchive.slice(localFileHeader.fileDataOffset, localFileHeader.fileDataOffset + localFileHeader.compressedSize);
139
138
  return compressedFile;
140
139
  }
141
140
  }
@@ -5,17 +5,17 @@ import { FileProvider } from './file-provider';
5
5
  */
6
6
  export type ZipCDFileHeader = {
7
7
  /** Compressed size */
8
- compressedSize: number;
8
+ compressedSize: bigint;
9
9
  /** Uncompressed size */
10
- uncompressedSize: number;
10
+ uncompressedSize: bigint;
11
11
  /** File name length */
12
12
  fileNameLength: number;
13
13
  /** File name */
14
14
  fileName: string;
15
15
  /** Extra field offset */
16
- extraOffset: number;
16
+ extraOffset: bigint;
17
17
  /** Relative offset of local file header */
18
- localHeaderOffset: number;
18
+ localHeaderOffset: bigint;
19
19
  };
20
20
  /**
21
21
  * Parses central directory file header of zip file
@@ -23,5 +23,5 @@ export type ZipCDFileHeader = {
23
23
  * @param buffer - buffer containing whole array
24
24
  * @returns Info from the header
25
25
  */
26
- export declare const parseZipCDFileHeader: (headerOffset: number, buffer: FileProvider) => Promise<ZipCDFileHeader>;
26
+ export declare const parseZipCDFileHeader: (headerOffset: bigint, buffer: FileProvider) => Promise<ZipCDFileHeader>;
27
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,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"}
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,CAyDzB,CAAC"}
@@ -9,31 +9,32 @@ exports.parseZipCDFileHeader = void 0;
9
9
  */
10
10
  const parseZipCDFileHeader = async (headerOffset, buffer) => {
11
11
  const offsets = {
12
- CD_COMPRESSED_SIZE_OFFSET: 20,
13
- CD_UNCOMPRESSED_SIZE_OFFSET: 24,
14
- CD_FILE_NAME_LENGTH_OFFSET: 28,
15
- CD_EXTRA_FIELD_LENGTH_OFFSET: 30,
16
- CD_LOCAL_HEADER_OFFSET_OFFSET: 42,
17
- CD_FILE_NAME_OFFSET: 46
12
+ CD_COMPRESSED_SIZE_OFFSET: 20n,
13
+ CD_UNCOMPRESSED_SIZE_OFFSET: 24n,
14
+ CD_FILE_NAME_LENGTH_OFFSET: 28n,
15
+ CD_EXTRA_FIELD_LENGTH_OFFSET: 30n,
16
+ CD_LOCAL_HEADER_OFFSET_OFFSET: 42n,
17
+ CD_FILE_NAME_OFFSET: 46n
18
18
  };
19
- const compressedSize = await buffer.getUint32(headerOffset + offsets.CD_COMPRESSED_SIZE_OFFSET);
20
- const uncompressedSize = await buffer.getUint32(headerOffset + offsets.CD_UNCOMPRESSED_SIZE_OFFSET);
19
+ let compressedSize = BigInt(await buffer.getUint32(headerOffset + offsets.CD_COMPRESSED_SIZE_OFFSET));
20
+ let uncompressedSize = BigInt(await buffer.getUint32(headerOffset + offsets.CD_UNCOMPRESSED_SIZE_OFFSET));
21
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
- const extraOffset = headerOffset + offsets.CD_FILE_NAME_OFFSET + fileNameLength;
22
+ const fileName = new TextDecoder().decode(await buffer.slice(headerOffset + offsets.CD_FILE_NAME_OFFSET, headerOffset + offsets.CD_FILE_NAME_OFFSET + BigInt(fileNameLength)));
23
+ const extraOffset = headerOffset + offsets.CD_FILE_NAME_OFFSET + BigInt(fileNameLength);
24
24
  const oldFormatOffset = await buffer.getUint32(headerOffset + offsets.CD_LOCAL_HEADER_OFFSET_OFFSET);
25
- let fileDataOffset = oldFormatOffset;
26
- if (fileDataOffset === 0xffffffff) {
27
- let offsetInZip64Data = 4;
28
- // looking for info that might be also be in zip64 extra field
29
- if (compressedSize === 0xffffffff) {
30
- offsetInZip64Data += 8;
31
- }
32
- if (uncompressedSize === 0xffffffff) {
33
- offsetInZip64Data += 8;
34
- }
35
- // getUint32 needs to be replaced with getBigUint64 for archieves bigger than 2gb
36
- fileDataOffset = await buffer.getUint32(extraOffset + offsetInZip64Data); // setting it to the one from zip64
25
+ let fileDataOffset = BigInt(oldFormatOffset);
26
+ let offsetInZip64Data = 4n;
27
+ // looking for info that might be also be in zip64 extra field
28
+ if (uncompressedSize === BigInt(0xffffffff)) {
29
+ uncompressedSize = await buffer.getBigUint64(extraOffset + offsetInZip64Data);
30
+ offsetInZip64Data += 8n;
31
+ }
32
+ if (compressedSize === BigInt(0xffffffff)) {
33
+ compressedSize = await buffer.getBigUint64(extraOffset + offsetInZip64Data);
34
+ offsetInZip64Data += 8n;
35
+ }
36
+ if (fileDataOffset === BigInt(0xffffffff)) {
37
+ fileDataOffset = await buffer.getBigUint64(extraOffset + offsetInZip64Data); // setting it to the one from zip64
37
38
  }
38
39
  const localHeaderOffset = fileDataOffset;
39
40
  return {
@@ -1,37 +1,36 @@
1
1
  import { FileProvider } from './file-provider';
2
- /**
3
- * Provides file data using DataView
4
- */
2
+ /** Provides file data using DataView */
5
3
  export declare class DataViewFileProvider implements FileProvider {
6
- /**
7
- * The DataView from which data is provided
8
- */
4
+ /** The DataView from which data is provided */
9
5
  private file;
10
6
  constructor(file: DataView);
11
7
  /**
12
8
  * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
13
9
  * @param offset The offset, in bytes, from the start of the file where to read the data.
14
10
  */
15
- getUint8(offset: number): Promise<number>;
11
+ getUint8(offset: bigint): Promise<number>;
16
12
  /**
17
- * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
13
+ * Gets an unsigned 16-bit intege at the specified byte offset from the start of the file.
18
14
  * @param offset The offset, in bytes, from the start of the file where to read the data.
19
15
  */
20
- getUint16(offset: number): Promise<number>;
16
+ getUint16(offset: bigint): Promise<number>;
21
17
  /**
22
18
  * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
23
19
  * @param offset The offset, in bytes, from the start of the file where to read the data.
24
20
  */
25
- getUint32(offset: number): Promise<number>;
21
+ getUint32(offset: bigint): Promise<number>;
22
+ /**
23
+ * Gets an unsigned 64-bit integer at the specified byte offset from the start of the file.
24
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
25
+ */
26
+ getBigUint64(offset: bigint): Promise<bigint>;
26
27
  /**
27
28
  * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
28
29
  * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
29
30
  * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
30
31
  */
31
- slice(startOffset: number, endOffset: number): Promise<ArrayBuffer>;
32
- /**
33
- * the length (in bytes) of the data.
34
- */
35
- get length(): number;
32
+ slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer>;
33
+ /** the length (in bytes) of the data. */
34
+ get length(): bigint;
36
35
  }
37
- //# sourceMappingURL=buffer-file-provider.d.ts.map
36
+ //# sourceMappingURL=data-view-file-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-view-file-provider.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-zip/data-view-file-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAc7C,wCAAwC;AACxC,qBAAa,oBAAqB,YAAW,YAAY;IACvD,+CAA+C;IAC/C,OAAO,CAAC,IAAI,CAAW;gBAEX,IAAI,EAAE,QAAQ;IAI1B;;;OAGG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI/C;;;OAGG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIhD;;;OAGG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIhD;;;OAGG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAInD;;;;OAIG;IACG,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAIzE,yCAAyC;IACzC,IAAI,MAAM,WAET;CACF"}
@@ -2,8 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DataViewFileProvider = void 0;
4
4
  /**
5
- * Provides file data using DataView
5
+ * Checks if bigint can be converted to number and convert it if possible
6
+ * @param bigint bigint to be converted
7
+ * @returns number
6
8
  */
9
+ const toNumber = (bigint) => {
10
+ if (bigint > Number.MAX_SAFE_INTEGER) {
11
+ throw new Error('Offset is out of bounds');
12
+ }
13
+ return Number(bigint);
14
+ };
15
+ /** Provides file data using DataView */
7
16
  class DataViewFileProvider {
8
17
  constructor(file) {
9
18
  this.file = file;
@@ -12,36 +21,41 @@ class DataViewFileProvider {
12
21
  * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
13
22
  * @param offset The offset, in bytes, from the start of the file where to read the data.
14
23
  */
15
- getUint8(offset) {
16
- return Promise.resolve(this.file.getUint8(offset));
24
+ async getUint8(offset) {
25
+ return this.file.getUint8(toNumber(offset));
17
26
  }
18
27
  /**
19
- * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
28
+ * Gets an unsigned 16-bit intege at the specified byte offset from the start of the file.
20
29
  * @param offset The offset, in bytes, from the start of the file where to read the data.
21
30
  */
22
- getUint16(offset) {
23
- return Promise.resolve(this.file.getUint16(offset, true));
31
+ async getUint16(offset) {
32
+ return this.file.getUint16(toNumber(offset), true);
24
33
  }
25
34
  /**
26
35
  * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
27
36
  * @param offset The offset, in bytes, from the start of the file where to read the data.
28
37
  */
29
- getUint32(offset) {
30
- return Promise.resolve(this.file.getUint32(offset, true));
38
+ async getUint32(offset) {
39
+ return this.file.getUint32(toNumber(offset), true);
40
+ }
41
+ /**
42
+ * Gets an unsigned 64-bit integer at the specified byte offset from the start of the file.
43
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
44
+ */
45
+ async getBigUint64(offset) {
46
+ return this.file.getBigUint64(toNumber(offset), true);
31
47
  }
32
48
  /**
33
49
  * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
34
50
  * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
35
51
  * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
36
52
  */
37
- slice(startOffset, endOffset) {
38
- return Promise.resolve(this.file.buffer.slice(startOffset, endOffset));
53
+ async slice(startOffset, endOffset) {
54
+ return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));
39
55
  }
40
- /**
41
- * the length (in bytes) of the data.
42
- */
56
+ /** the length (in bytes) of the data. */
43
57
  get length() {
44
- return this.file.byteLength;
58
+ return BigInt(this.file.byteLength);
45
59
  }
46
60
  }
47
61
  exports.DataViewFileProvider = DataViewFileProvider;
@@ -6,26 +6,31 @@ export interface FileProvider {
6
6
  * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
7
7
  * @param offset The offset, in bytes, from the start of the file where to read the data.
8
8
  */
9
- getUint8(offset: number): Promise<number>;
9
+ getUint8(offset: bigint): Promise<number>;
10
10
  /**
11
11
  * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
12
12
  * @param offset The offset, in bytes, from the start of the file where to read the data.
13
13
  */
14
- getUint16(offset: number): Promise<number>;
14
+ getUint16(offset: bigint): Promise<number>;
15
15
  /**
16
16
  * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
17
17
  * @param offset The offset, in bytes, from the file of the view where to read the data.
18
18
  */
19
- getUint32(offset: number): Promise<number>;
19
+ getUint32(offset: bigint): Promise<number>;
20
+ /**
21
+ * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
22
+ * @param offset The offset, in byte, from the file of the view where to read the data.
23
+ */
24
+ getBigUint64(offset: bigint): Promise<bigint>;
20
25
  /**
21
26
  * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
22
27
  * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
23
28
  * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
24
29
  */
25
- slice(startOffset: number, endOffset: number): Promise<ArrayBuffer>;
30
+ slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer>;
26
31
  /**
27
32
  * the length (in bytes) of the data.
28
33
  */
29
- length: number;
34
+ length: bigint;
30
35
  }
31
36
  //# sourceMappingURL=file-provider.d.ts.map
@@ -1 +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"}
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;;;OAGG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE9C;;;;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"}