@loaders.gl/zip 4.0.0-alpha.20 → 4.0.0-alpha.21

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 (98) hide show
  1. package/dist/dist.min.js +494 -119
  2. package/dist/es5/{parse-zip → file-provider}/data-view-file.js +46 -29
  3. package/dist/es5/file-provider/data-view-file.js.map +1 -0
  4. package/dist/es5/file-provider/file-handle-file.js +234 -0
  5. package/dist/es5/file-provider/file-handle-file.js.map +1 -0
  6. package/dist/es5/file-provider/file-handle.js +101 -0
  7. package/dist/es5/file-provider/file-handle.js.map +1 -0
  8. package/dist/es5/file-provider/file-provider.js +11 -0
  9. package/dist/es5/file-provider/file-provider.js.map +1 -0
  10. package/dist/es5/filesystems/zip-filesystem.js +340 -0
  11. package/dist/es5/filesystems/zip-filesystem.js.map +1 -0
  12. package/dist/es5/hash-file-utility.js +81 -1
  13. package/dist/es5/hash-file-utility.js.map +1 -1
  14. package/dist/es5/index.js +20 -1
  15. package/dist/es5/index.js.map +1 -1
  16. package/dist/es5/parse-zip/cd-file-header.js +58 -16
  17. package/dist/es5/parse-zip/cd-file-header.js.map +1 -1
  18. package/dist/es5/parse-zip/end-of-central-directory.js +10 -12
  19. package/dist/es5/parse-zip/end-of-central-directory.js.map +1 -1
  20. package/dist/es5/parse-zip/local-file-header.js +37 -33
  21. package/dist/es5/parse-zip/local-file-header.js.map +1 -1
  22. package/dist/es5/parse-zip/search-from-the-end.js.map +1 -1
  23. package/dist/es5/zip-loader.js +1 -1
  24. package/dist/esm/{parse-zip → file-provider}/data-view-file.js +1 -0
  25. package/dist/esm/file-provider/data-view-file.js.map +1 -0
  26. package/dist/esm/file-provider/file-handle-file.js +57 -0
  27. package/dist/esm/file-provider/file-handle-file.js.map +1 -0
  28. package/dist/esm/file-provider/file-handle.js +37 -0
  29. package/dist/esm/file-provider/file-handle.js.map +1 -0
  30. package/dist/esm/file-provider/file-provider.js +4 -0
  31. package/dist/esm/file-provider/file-provider.js.map +1 -0
  32. package/dist/esm/filesystems/zip-filesystem.js +86 -0
  33. package/dist/esm/filesystems/zip-filesystem.js.map +1 -0
  34. package/dist/esm/hash-file-utility.js +14 -0
  35. package/dist/esm/hash-file-utility.js.map +1 -1
  36. package/dist/esm/index.js +4 -3
  37. package/dist/esm/index.js.map +1 -1
  38. package/dist/esm/parse-zip/cd-file-header.js +24 -15
  39. package/dist/esm/parse-zip/cd-file-header.js.map +1 -1
  40. package/dist/esm/parse-zip/end-of-central-directory.js +10 -12
  41. package/dist/esm/parse-zip/end-of-central-directory.js.map +1 -1
  42. package/dist/esm/parse-zip/local-file-header.js +16 -15
  43. package/dist/esm/parse-zip/local-file-header.js.map +1 -1
  44. package/dist/esm/parse-zip/search-from-the-end.js.map +1 -1
  45. package/dist/esm/zip-loader.js +1 -1
  46. package/dist/{parse-zip → file-provider}/data-view-file.d.ts +1 -0
  47. package/dist/file-provider/data-view-file.d.ts.map +1 -0
  48. package/dist/{parse-zip → file-provider}/data-view-file.js +2 -0
  49. package/dist/file-provider/file-handle-file.d.ts +53 -0
  50. package/dist/file-provider/file-handle-file.d.ts.map +1 -0
  51. package/dist/file-provider/file-handle-file.js +90 -0
  52. package/dist/file-provider/file-handle.d.ts +40 -0
  53. package/dist/file-provider/file-handle.d.ts.map +1 -0
  54. package/dist/file-provider/file-handle.js +57 -0
  55. package/dist/{parse-zip → file-provider}/file-provider.d.ts +9 -0
  56. package/dist/file-provider/file-provider.d.ts.map +1 -0
  57. package/dist/file-provider/file-provider.js +13 -0
  58. package/dist/filesystems/zip-filesystem.d.ts +44 -0
  59. package/dist/filesystems/zip-filesystem.d.ts.map +1 -0
  60. package/dist/filesystems/zip-filesystem.js +119 -0
  61. package/dist/hash-file-utility.d.ts +7 -0
  62. package/dist/hash-file-utility.d.ts.map +1 -1
  63. package/dist/hash-file-utility.js +24 -1
  64. package/dist/index.d.ts +5 -4
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +7 -3
  67. package/dist/parse-zip/cd-file-header.d.ts +6 -1
  68. package/dist/parse-zip/cd-file-header.d.ts.map +1 -1
  69. package/dist/parse-zip/cd-file-header.js +29 -16
  70. package/dist/parse-zip/end-of-central-directory.d.ts +1 -1
  71. package/dist/parse-zip/end-of-central-directory.d.ts.map +1 -1
  72. package/dist/parse-zip/end-of-central-directory.js +11 -12
  73. package/dist/parse-zip/local-file-header.d.ts +3 -1
  74. package/dist/parse-zip/local-file-header.d.ts.map +1 -1
  75. package/dist/parse-zip/local-file-header.js +17 -15
  76. package/dist/parse-zip/search-from-the-end.d.ts +1 -1
  77. package/dist/parse-zip/search-from-the-end.d.ts.map +1 -1
  78. package/package.json +9 -2
  79. package/src/{parse-zip → file-provider}/data-view-file.ts +3 -0
  80. package/src/file-provider/file-handle-file.ts +114 -0
  81. package/src/file-provider/file-handle.ts +73 -0
  82. package/src/{parse-zip → file-provider}/file-provider.ts +16 -0
  83. package/src/filesystems/zip-filesystem.ts +132 -0
  84. package/src/hash-file-utility.ts +22 -0
  85. package/src/index.ts +10 -4
  86. package/src/parse-zip/cd-file-header.ts +33 -25
  87. package/src/parse-zip/end-of-central-directory.ts +12 -19
  88. package/src/parse-zip/local-file-header.ts +22 -22
  89. package/src/parse-zip/search-from-the-end.ts +1 -1
  90. package/dist/es5/parse-zip/data-view-file.js.map +0 -1
  91. package/dist/es5/parse-zip/file-provider.js +0 -2
  92. package/dist/es5/parse-zip/file-provider.js.map +0 -1
  93. package/dist/esm/parse-zip/data-view-file.js.map +0 -1
  94. package/dist/esm/parse-zip/file-provider.js +0 -2
  95. package/dist/esm/parse-zip/file-provider.js.map +0 -1
  96. package/dist/parse-zip/data-view-file.d.ts.map +0 -1
  97. package/dist/parse-zip/file-provider.d.ts.map +0 -1
  98. package/dist/parse-zip/file-provider.js +0 -2
@@ -1,4 +1,4 @@
1
- import {FileProvider} from './file-provider';
1
+ import {FileProvider} from '../file-provider/file-provider';
2
2
  import {ZipSignature, searchFromTheEnd} from './search-from-the-end';
3
3
 
4
4
  /**
@@ -16,15 +16,12 @@ const eoCDSignature: ZipSignature = [0x50, 0x4b, 0x05, 0x06];
16
16
  const zip64EoCDLocatorSignature = Buffer.from([0x50, 0x4b, 0x06, 0x07]);
17
17
  const zip64EoCDSignature = Buffer.from([0x50, 0x4b, 0x06, 0x06]);
18
18
 
19
- const offsets = {
20
- CD_RECORDS_NUMBER_OFFSET: 8n,
21
- CD_START_OFFSET_OFFSET: 16n,
22
-
23
- ZIP64_EOCD_START_OFFSET_OFFSET: 8n,
24
-
25
- ZIP64_CD_RECORDS_NUMBER_OFFSET: 24n,
26
- ZIP64_CD_START_OFFSET_OFFSET: 48n
27
- };
19
+ // offsets accroding to https://en.wikipedia.org/wiki/ZIP_(file_format)
20
+ const CD_RECORDS_NUMBER_OFFSET = 8n;
21
+ const CD_START_OFFSET_OFFSET = 16n;
22
+ const ZIP64_EOCD_START_OFFSET_OFFSET = 8n;
23
+ const ZIP64_CD_RECORDS_NUMBER_OFFSET = 24n;
24
+ const ZIP64_CD_START_OFFSET_OFFSET = 48n;
28
25
 
29
26
  /**
30
27
  * Parses end of central directory record of zip file
@@ -35,11 +32,9 @@ export const parseEoCDRecord = async (fileProvider: FileProvider): Promise<ZipEo
35
32
  const zipEoCDOffset = await searchFromTheEnd(fileProvider, eoCDSignature);
36
33
 
37
34
  let cdRecordsNumber = BigInt(
38
- await fileProvider.getUint16(zipEoCDOffset + offsets.CD_RECORDS_NUMBER_OFFSET)
39
- );
40
- let cdStartOffset = BigInt(
41
- await fileProvider.getUint32(zipEoCDOffset + offsets.CD_START_OFFSET_OFFSET)
35
+ await fileProvider.getUint16(zipEoCDOffset + CD_RECORDS_NUMBER_OFFSET)
42
36
  );
37
+ let cdStartOffset = BigInt(await fileProvider.getUint32(zipEoCDOffset + CD_START_OFFSET_OFFSET));
43
38
 
44
39
  if (cdStartOffset === BigInt(0xffffffff) || cdRecordsNumber === BigInt(0xffffffff)) {
45
40
  const zip64EoCDLocatorOffset = zipEoCDOffset - 20n;
@@ -52,7 +47,7 @@ export const parseEoCDRecord = async (fileProvider: FileProvider): Promise<ZipEo
52
47
  throw new Error('zip64 EoCD locator not found');
53
48
  }
54
49
  const zip64EoCDOffset = await fileProvider.getBigUint64(
55
- zip64EoCDLocatorOffset + offsets.ZIP64_EOCD_START_OFFSET_OFFSET
50
+ zip64EoCDLocatorOffset + ZIP64_EOCD_START_OFFSET_OFFSET
56
51
  );
57
52
 
58
53
  if (
@@ -64,11 +59,9 @@ export const parseEoCDRecord = async (fileProvider: FileProvider): Promise<ZipEo
64
59
  }
65
60
 
66
61
  cdRecordsNumber = await fileProvider.getBigUint64(
67
- zip64EoCDOffset + offsets.ZIP64_CD_RECORDS_NUMBER_OFFSET
68
- );
69
- cdStartOffset = await fileProvider.getBigUint64(
70
- zip64EoCDOffset + offsets.ZIP64_CD_START_OFFSET_OFFSET
62
+ zip64EoCDOffset + ZIP64_CD_RECORDS_NUMBER_OFFSET
71
63
  );
64
+ cdStartOffset = await fileProvider.getBigUint64(zip64EoCDOffset + ZIP64_CD_START_OFFSET_OFFSET);
72
65
  }
73
66
 
74
67
  return {
@@ -1,4 +1,4 @@
1
- import {FileProvider} from './file-provider';
1
+ import {FileProvider} from '../file-provider/file-provider';
2
2
 
3
3
  /**
4
4
  * zip local file header info
@@ -15,15 +15,17 @@ export type ZipLocalFileHeader = {
15
15
  fileDataOffset: bigint;
16
16
  /** Compressed size */
17
17
  compressedSize: bigint;
18
+ /** Compression method */
19
+ compressionMethod: number;
18
20
  };
19
21
 
20
- const offsets = {
21
- COMPRESSED_SIZE_OFFSET: 18n,
22
- UNCOMPRESSED_SIZE_OFFSET: 22n,
23
- FILE_NAME_LENGTH_OFFSET: 26n,
24
- EXTRA_FIELD_LENGTH_OFFSET: 28n,
25
- FILE_NAME_OFFSET: 30n
26
- };
22
+ // offsets accroding to https://en.wikipedia.org/wiki/ZIP_(file_format)
23
+ const COMPRESSION_METHOD_OFFSET = 8n;
24
+ const COMPRESSED_SIZE_OFFSET = 18n;
25
+ const UNCOMPRESSED_SIZE_OFFSET = 22n;
26
+ const FILE_NAME_LENGTH_OFFSET = 26n;
27
+ const EXTRA_FIELD_LENGTH_OFFSET = 28n;
28
+ const FILE_NAME_OFFSET = 30n;
27
29
 
28
30
  export const signature = Buffer.from([0x50, 0x4b, 0x03, 0x04]);
29
31
 
@@ -41,31 +43,28 @@ export const parseZipLocalFileHeader = async (
41
43
  return null;
42
44
  }
43
45
 
44
- const fileNameLength = await buffer.getUint16(headerOffset + offsets.FILE_NAME_LENGTH_OFFSET);
46
+ const fileNameLength = await buffer.getUint16(headerOffset + FILE_NAME_LENGTH_OFFSET);
45
47
 
46
48
  const fileName = new TextDecoder()
47
49
  .decode(
48
50
  await buffer.slice(
49
- headerOffset + offsets.FILE_NAME_OFFSET,
50
- headerOffset + offsets.FILE_NAME_OFFSET + BigInt(fileNameLength)
51
+ headerOffset + FILE_NAME_OFFSET,
52
+ headerOffset + FILE_NAME_OFFSET + BigInt(fileNameLength)
51
53
  )
52
54
  )
53
55
  .split('\\')
54
56
  .join('/');
55
- const extraFieldLength = await buffer.getUint16(headerOffset + offsets.EXTRA_FIELD_LENGTH_OFFSET);
57
+ const extraFieldLength = await buffer.getUint16(headerOffset + EXTRA_FIELD_LENGTH_OFFSET);
58
+
59
+ let fileDataOffset = headerOffset + FILE_NAME_OFFSET + BigInt(fileNameLength + extraFieldLength);
56
60
 
57
- let fileDataOffset =
58
- headerOffset + offsets.FILE_NAME_OFFSET + BigInt(fileNameLength + extraFieldLength);
61
+ const compressionMethod = await buffer.getUint16(headerOffset + COMPRESSION_METHOD_OFFSET);
59
62
 
60
- let compressedSize = BigInt(
61
- await buffer.getUint32(headerOffset + offsets.COMPRESSED_SIZE_OFFSET)
62
- ); // add zip 64 logic
63
+ let compressedSize = BigInt(await buffer.getUint32(headerOffset + COMPRESSED_SIZE_OFFSET)); // add zip 64 logic
63
64
 
64
- let uncompressedSize = BigInt(
65
- await buffer.getUint32(headerOffset + offsets.UNCOMPRESSED_SIZE_OFFSET)
66
- ); // add zip 64 logic
65
+ let uncompressedSize = BigInt(await buffer.getUint32(headerOffset + UNCOMPRESSED_SIZE_OFFSET)); // add zip 64 logic
67
66
 
68
- const extraOffset = headerOffset + offsets.FILE_NAME_OFFSET + BigInt(fileNameLength);
67
+ const extraOffset = headerOffset + FILE_NAME_OFFSET + BigInt(fileNameLength);
69
68
 
70
69
  let offsetInZip64Data = 4n;
71
70
  // looking for info that might be also be in zip64 extra field
@@ -86,6 +85,7 @@ export const parseZipLocalFileHeader = async (
86
85
  fileName,
87
86
  extraFieldLength,
88
87
  fileDataOffset,
89
- compressedSize
88
+ compressedSize,
89
+ compressionMethod
90
90
  };
91
91
  };
@@ -1,4 +1,4 @@
1
- import {FileProvider} from './file-provider';
1
+ import {FileProvider} from '../file-provider/file-provider';
2
2
 
3
3
  /** Description of zip signature type */
4
4
  export type ZipSignature = [number, number, number, number];
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-view-file.js","names":["toNumber","bigint","Number","MAX_SAFE_INTEGER","Error","DataViewFile","file","_classCallCheck2","default","_defineProperty2","_createClass2","key","value","_getUint","_asyncToGenerator2","_regenerator","mark","_callee","offset","wrap","_callee$","_context","prev","next","abrupt","getUint8","stop","_x","apply","arguments","_getUint2","_callee2","_callee2$","_context2","getUint16","_x2","_getUint3","_callee3","_callee3$","_context3","getUint32","_x3","_getBigUint","_callee4","_callee4$","_context4","getBigUint64","_x4","_slice","_callee5","startOffset","endOffset","_callee5$","_context5","buffer","slice","_x5","_x6","get","BigInt","byteLength","exports"],"sources":["../../../src/parse-zip/data-view-file.ts"],"sourcesContent":["import {FileProvider} from './file-provider';\n\n/**\n * Checks if bigint can be converted to number and convert it if possible\n * @param bigint bigint to be converted\n * @returns number\n */\nconst toNumber = (bigint: bigint) => {\n if (bigint > Number.MAX_SAFE_INTEGER) {\n throw new Error('Offset is out of bounds');\n }\n return Number(bigint);\n};\n\n/** Provides file data using DataView */\nexport class DataViewFile implements FileProvider {\n /** The DataView from which data is provided */\n private file: DataView;\n\n constructor(file: DataView) {\n this.file = file;\n }\n\n /**\n * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint8(offset: bigint): Promise<number> {\n return this.file.getUint8(toNumber(offset));\n }\n\n /**\n * Gets an unsigned 16-bit intege at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint16(offset: bigint): Promise<number> {\n return this.file.getUint16(toNumber(offset), true);\n }\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint32(offset: bigint): Promise<number> {\n return this.file.getUint32(toNumber(offset), true);\n }\n\n /**\n * Gets an unsigned 64-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getBigUint64(offset: bigint): Promise<bigint> {\n return this.file.getBigUint64(toNumber(offset), true);\n }\n\n /**\n * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.\n * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.\n * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.\n */\n async slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer> {\n return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));\n }\n\n /** the length (in bytes) of the data. */\n get length() {\n return BigInt(this.file.byteLength);\n }\n}\n"],"mappings":";;;;;;;;;;;;AAOA,IAAMA,QAAQ,GAAG,SAAXA,QAAQA,CAAIC,MAAc,EAAK;EACnC,IAAIA,MAAM,GAAGC,MAAM,CAACC,gBAAgB,EAAE;IACpC,MAAM,IAAIC,KAAK,CAAC,yBAAyB,CAAC;EAC5C;EACA,OAAOF,MAAM,CAACD,MAAM,CAAC;AACvB,CAAC;AAAC,IAGWI,YAAY;EAIvB,SAAAA,aAAYC,IAAc,EAAE;IAA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AAA,OAAAL,WAAA,CAAAd,KAAA,OAAAC,SAAA;MAAA;MAAA,OAAAiB,YAAA;IAAA;EAAA;IAAAnC,GAAA;IAAAC,KAAA;MAAA,IAAAoC,MAAA,OAAAlC,kBAAA,CAAAN,OAAA,EAAAO,YAAA,CAAAP,OAAA,CAAAQ,IAAA,CAOD,SAAAiC,SAAYC,WAAmB,EAAEC,SAAiB;QAAA,OAAApC,YAAA,CAAAP,OAAA,CAAAW,IAAA,UAAAiC,UAAAC,SAAA;UAAA,kBAAAA,SAAA,CAAA/B,IAAA,GAAA+B,SAAA,CAAA9B,IAAA;YAAA;cAAA,OAAA8B,SAAA,CAAA7B,MAAA,WACzC,IAAI,CAAClB,IAAI,CAACgD,MAAM,CAACC,KAAK,CAACvD,QAAQ,CAACkD,WAAW,CAAC,EAAElD,QAAQ,CAACmD,SAAS,CAAC,CAAC;YAAA;YAAA;cAAA,OAAAE,SAAA,CAAA3B,IAAA;UAAA;QAAA,GAAAuB,QAAA;MAAA,CAC1E;MAAA,SAAAM,MAAAC,GAAA,EAAAC,GAAA;QAAA,OAAAT,MAAA,CAAApB,KAAA,OAAAC,SAAA;MAAA;MAAA,OAAA0B,KAAA;IAAA;EAAA;IAAA5C,GAAA;IAAA+C,GAAA,EAGD,SAAAA,IAAA,EAAa;MACX,OAAOC,MAAM,CAAC,IAAI,CAACrD,IAAI,CAACsD,UAAU,CAAC;IACrC;EAAC;EAAA,OAAAvD,YAAA;AAAA;AAAAwD,OAAA,CAAAxD,YAAA,GAAAA,YAAA"}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=file-provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-provider.js","names":[],"sources":["../../../src/parse-zip/file-provider.ts"],"sourcesContent":["/**\n * Interface for providing file data\n */\nexport interface FileProvider {\n /**\n * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n getUint8(offset: bigint): Promise<number>;\n\n /**\n * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n getUint16(offset: bigint): Promise<number>;\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the file of the view where to read the data.\n */\n getUint32(offset: bigint): Promise<number>;\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in byte, from the file of the view where to read the data.\n */\n getBigUint64(offset: bigint): Promise<bigint>;\n\n /**\n * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.\n * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.\n * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.\n */\n slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer>;\n\n /**\n * the length (in bytes) of the data.\n */\n length: bigint;\n}\n"],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-view-file.js","names":["toNumber","bigint","Number","MAX_SAFE_INTEGER","Error","DataViewFile","constructor","file","_defineProperty","getUint8","offset","getUint16","getUint32","getBigUint64","slice","startOffset","endOffset","buffer","length","BigInt","byteLength"],"sources":["../../../src/parse-zip/data-view-file.ts"],"sourcesContent":["import {FileProvider} from './file-provider';\n\n/**\n * Checks if bigint can be converted to number and convert it if possible\n * @param bigint bigint to be converted\n * @returns number\n */\nconst toNumber = (bigint: bigint) => {\n if (bigint > Number.MAX_SAFE_INTEGER) {\n throw new Error('Offset is out of bounds');\n }\n return Number(bigint);\n};\n\n/** Provides file data using DataView */\nexport class DataViewFile implements FileProvider {\n /** The DataView from which data is provided */\n private file: DataView;\n\n constructor(file: DataView) {\n this.file = file;\n }\n\n /**\n * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint8(offset: bigint): Promise<number> {\n return this.file.getUint8(toNumber(offset));\n }\n\n /**\n * Gets an unsigned 16-bit intege at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint16(offset: bigint): Promise<number> {\n return this.file.getUint16(toNumber(offset), true);\n }\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint32(offset: bigint): Promise<number> {\n return this.file.getUint32(toNumber(offset), true);\n }\n\n /**\n * Gets an unsigned 64-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getBigUint64(offset: bigint): Promise<bigint> {\n return this.file.getBigUint64(toNumber(offset), true);\n }\n\n /**\n * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.\n * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.\n * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.\n */\n async slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer> {\n return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));\n }\n\n /** the length (in bytes) of the data. */\n get length() {\n return BigInt(this.file.byteLength);\n }\n}\n"],"mappings":";AAOA,MAAMA,QAAQ,GAAIC,MAAc,IAAK;EACnC,IAAIA,MAAM,GAAGC,MAAM,CAACC,gBAAgB,EAAE;IACpC,MAAM,IAAIC,KAAK,CAAC,yBAAyB,CAAC;EAC5C;EACA,OAAOF,MAAM,CAACD,MAAM,CAAC;AACvB,CAAC;AAGD,OAAO,MAAMI,YAAY,CAAyB;EAIhDC,WAAWA,CAACC,IAAc,EAAE;IAAAC,eAAA;IAC1B,IAAI,CAACD,IAAI,GAAGA,IAAI;EAClB;EAMA,MAAME,QAAQA,CAACC,MAAc,EAAmB;IAC9C,OAAO,IAAI,CAACH,IAAI,CAACE,QAAQ,CAACT,QAAQ,CAACU,MAAM,CAAC,CAAC;EAC7C;EAMA,MAAMC,SAASA,CAACD,MAAc,EAAmB;IAC/C,OAAO,IAAI,CAACH,IAAI,CAACI,SAAS,CAACX,QAAQ,CAACU,MAAM,CAAC,EAAE,IAAI,CAAC;EACpD;EAMA,MAAME,SAASA,CAACF,MAAc,EAAmB;IAC/C,OAAO,IAAI,CAACH,IAAI,CAACK,SAAS,CAACZ,QAAQ,CAACU,MAAM,CAAC,EAAE,IAAI,CAAC;EACpD;EAMA,MAAMG,YAAYA,CAACH,MAAc,EAAmB;IAClD,OAAO,IAAI,CAACH,IAAI,CAACM,YAAY,CAACb,QAAQ,CAACU,MAAM,CAAC,EAAE,IAAI,CAAC;EACvD;EAOA,MAAMI,KAAKA,CAACC,WAAmB,EAAEC,SAAiB,EAAwB;IACxE,OAAO,IAAI,CAACT,IAAI,CAACU,MAAM,CAACH,KAAK,CAACd,QAAQ,CAACe,WAAW,CAAC,EAAEf,QAAQ,CAACgB,SAAS,CAAC,CAAC;EAC3E;EAGA,IAAIE,MAAMA,CAAA,EAAG;IACX,OAAOC,MAAM,CAAC,IAAI,CAACZ,IAAI,CAACa,UAAU,CAAC;EACrC;AACF"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=file-provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-provider.js","names":[],"sources":["../../../src/parse-zip/file-provider.ts"],"sourcesContent":["/**\n * Interface for providing file data\n */\nexport interface FileProvider {\n /**\n * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n getUint8(offset: bigint): Promise<number>;\n\n /**\n * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n getUint16(offset: bigint): Promise<number>;\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the file of the view where to read the data.\n */\n getUint32(offset: bigint): Promise<number>;\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in byte, from the file of the view where to read the data.\n */\n getBigUint64(offset: bigint): Promise<bigint>;\n\n /**\n * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.\n * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.\n * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.\n */\n slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer>;\n\n /**\n * the length (in bytes) of the data.\n */\n length: bigint;\n}\n"],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-view-file.d.ts","sourceRoot":"","sources":["../../src/parse-zip/data-view-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAc7C,wCAAwC;AACxC,qBAAa,YAAa,YAAW,YAAY;IAC/C,+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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-provider.d.ts","sourceRoot":"","sources":["../../src/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"}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });