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

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 +4650 -176
  2. package/dist/es5/filesystems/zip-filesystem.js +134 -102
  3. package/dist/es5/filesystems/zip-filesystem.js.map +1 -1
  4. package/dist/es5/hash-file-utility.js.map +1 -1
  5. package/dist/es5/index.js +6 -14
  6. package/dist/es5/index.js.map +1 -1
  7. package/dist/es5/parse-zip/cd-file-header.js.map +1 -1
  8. package/dist/es5/parse-zip/end-of-central-directory.js.map +1 -1
  9. package/dist/es5/parse-zip/local-file-header.js.map +1 -1
  10. package/dist/es5/parse-zip/search-from-the-end.js.map +1 -1
  11. package/dist/es5/tar-builder.js +8 -8
  12. package/dist/es5/tar-builder.js.map +1 -1
  13. package/dist/es5/zip-loader.js +2 -4
  14. package/dist/es5/zip-loader.js.map +1 -1
  15. package/dist/esm/filesystems/zip-filesystem.js +18 -5
  16. package/dist/esm/filesystems/zip-filesystem.js.map +1 -1
  17. package/dist/esm/hash-file-utility.js.map +1 -1
  18. package/dist/esm/index.js +2 -3
  19. package/dist/esm/index.js.map +1 -1
  20. package/dist/esm/parse-zip/cd-file-header.js.map +1 -1
  21. package/dist/esm/parse-zip/end-of-central-directory.js.map +1 -1
  22. package/dist/esm/parse-zip/local-file-header.js.map +1 -1
  23. package/dist/esm/parse-zip/search-from-the-end.js.map +1 -1
  24. package/dist/esm/tar-builder.js +2 -2
  25. package/dist/esm/tar-builder.js.map +1 -1
  26. package/dist/esm/zip-loader.js +1 -2
  27. package/dist/esm/zip-loader.js.map +1 -1
  28. package/dist/filesystems/zip-filesystem.d.ts +4 -3
  29. package/dist/filesystems/zip-filesystem.d.ts.map +1 -1
  30. package/dist/filesystems/zip-filesystem.js +17 -8
  31. package/dist/hash-file-utility.d.ts +1 -1
  32. package/dist/hash-file-utility.d.ts.map +1 -1
  33. package/dist/index.d.ts +2 -4
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +5 -9
  36. package/dist/parse-zip/cd-file-header.d.ts +1 -1
  37. package/dist/parse-zip/cd-file-header.d.ts.map +1 -1
  38. package/dist/parse-zip/end-of-central-directory.d.ts +1 -1
  39. package/dist/parse-zip/end-of-central-directory.d.ts.map +1 -1
  40. package/dist/parse-zip/local-file-header.d.ts +1 -1
  41. package/dist/parse-zip/local-file-header.d.ts.map +1 -1
  42. package/dist/parse-zip/search-from-the-end.d.ts +1 -1
  43. package/dist/parse-zip/search-from-the-end.d.ts.map +1 -1
  44. package/dist/tar-builder.d.ts +2 -2
  45. package/dist/tar-builder.d.ts.map +1 -1
  46. package/dist/tar-builder.js +4 -3
  47. package/dist/zip-loader.d.ts +0 -1
  48. package/dist/zip-loader.d.ts.map +1 -1
  49. package/dist/zip-loader.js +1 -2
  50. package/package.json +4 -9
  51. package/src/filesystems/zip-filesystem.ts +16 -6
  52. package/src/hash-file-utility.ts +1 -1
  53. package/src/index.ts +5 -5
  54. package/src/parse-zip/cd-file-header.ts +1 -1
  55. package/src/parse-zip/end-of-central-directory.ts +1 -1
  56. package/src/parse-zip/local-file-header.ts +1 -1
  57. package/src/parse-zip/search-from-the-end.ts +1 -1
  58. package/src/tar-builder.ts +2 -2
  59. package/src/zip-loader.ts +0 -2
  60. package/dist/es5/file-provider/data-view-file.js +0 -146
  61. package/dist/es5/file-provider/data-view-file.js.map +0 -1
  62. package/dist/es5/file-provider/file-handle-file.js +0 -234
  63. package/dist/es5/file-provider/file-handle-file.js.map +0 -1
  64. package/dist/es5/file-provider/file-handle.js +0 -101
  65. package/dist/es5/file-provider/file-handle.js.map +0 -1
  66. package/dist/es5/file-provider/file-provider.js +0 -11
  67. package/dist/es5/file-provider/file-provider.js.map +0 -1
  68. package/dist/esm/file-provider/data-view-file.js +0 -33
  69. package/dist/esm/file-provider/data-view-file.js.map +0 -1
  70. package/dist/esm/file-provider/file-handle-file.js +0 -57
  71. package/dist/esm/file-provider/file-handle-file.js.map +0 -1
  72. package/dist/esm/file-provider/file-handle.js +0 -37
  73. package/dist/esm/file-provider/file-handle.js.map +0 -1
  74. package/dist/esm/file-provider/file-provider.js +0 -4
  75. package/dist/esm/file-provider/file-provider.js.map +0 -1
  76. package/dist/file-provider/data-view-file.d.ts +0 -37
  77. package/dist/file-provider/data-view-file.d.ts.map +0 -1
  78. package/dist/file-provider/data-view-file.js +0 -63
  79. package/dist/file-provider/file-handle-file.d.ts +0 -53
  80. package/dist/file-provider/file-handle-file.d.ts.map +0 -1
  81. package/dist/file-provider/file-handle-file.js +0 -90
  82. package/dist/file-provider/file-handle.d.ts +0 -40
  83. package/dist/file-provider/file-handle.d.ts.map +0 -1
  84. package/dist/file-provider/file-handle.js +0 -57
  85. package/dist/file-provider/file-provider.d.ts +0 -45
  86. package/dist/file-provider/file-provider.d.ts.map +0 -1
  87. package/dist/file-provider/file-provider.js +0 -13
  88. package/src/file-provider/data-view-file.ts +0 -72
  89. package/src/file-provider/file-handle-file.ts +0 -114
  90. package/src/file-provider/file-handle.ts +0 -73
  91. package/src/file-provider/file-provider.ts +0 -56
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-handle-file.js","names":["FileHandle","FileHandleFile","from","path","fileDescriptor","open","stat","size","constructor","_defineProperty","destroy","close","getUint8","offset","val","Uint8Array","read","Buffer","alloc","buffer","at","undefined","Error","getUint16","Uint16Array","getUint32","Uint32Array","getBigUint64","BigInt64Array","slice","startOffsset","endOffset","bigLength","Number","MAX_SAFE_INTEGER","length"],"sources":["../../../src/file-provider/file-handle-file.ts"],"sourcesContent":["import {FileProvider} from '@loaders.gl/zip';\nimport {FileHandle} from './file-handle';\n\n/**\n * Provides file data using node fs library\n */\nexport class FileHandleFile implements FileProvider {\n /**\n * Returns a new copy of FileHandleFile\n * @param path The path to the file in file system\n */\n static async from(path: string): Promise<FileHandleFile> {\n const fileDescriptor = await FileHandle.open(path);\n return new FileHandleFile(fileDescriptor, fileDescriptor.stat.size);\n }\n\n /**\n * The FileHandle from which data is provided\n */\n private fileDescriptor: FileHandle;\n\n /**\n * The file length in bytes\n */\n private size: bigint;\n\n private constructor(fileDescriptor: FileHandle, size: bigint) {\n this.fileDescriptor = fileDescriptor;\n this.size = size;\n }\n\n /** Close file */\n async destroy(): Promise<void> {\n await this.fileDescriptor.close();\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 const val = new Uint8Array(\n (await this.fileDescriptor.read(Buffer.alloc(1), 0, 1, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\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 async getUint16(offset: bigint): Promise<number> {\n const val = new Uint16Array(\n (await this.fileDescriptor.read(Buffer.alloc(2), 0, 2, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\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 const val = new Uint32Array(\n (await this.fileDescriptor.read(Buffer.alloc(4), 0, 4, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\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 getBigUint64(offset: bigint): Promise<bigint> {\n const val = new BigInt64Array(\n (await this.fileDescriptor.read(Buffer.alloc(8), 0, 8, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\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 startOffsset The offset, in byte, 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(startOffsset: bigint, endOffset: bigint): Promise<ArrayBuffer> {\n const bigLength = endOffset - startOffsset;\n if (bigLength > Number.MAX_SAFE_INTEGER) {\n throw new Error('too big slice');\n }\n const length = Number(bigLength);\n return (await this.fileDescriptor.read(Buffer.alloc(length), 0, length, startOffsset)).buffer\n .buffer;\n }\n\n /**\n * the length (in bytes) of the data.\n */\n get length(): bigint {\n return this.size;\n }\n}\n"],"mappings":"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"}
@@ -1,37 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { read, open, close, stat } from 'fs';
3
- export class FileHandle {
4
- constructor(fileDescriptor, stats) {
5
- _defineProperty(this, "fileDescriptor", void 0);
6
- _defineProperty(this, "stats", void 0);
7
- _defineProperty(this, "read", (buffer, offset, length, position) => {
8
- return new Promise(s => {
9
- read(this.fileDescriptor, buffer, offset, length, position, (_err, bytesRead, buffer) => s({
10
- bytesRead,
11
- buffer
12
- }));
13
- });
14
- });
15
- this.fileDescriptor = fileDescriptor;
16
- this.stats = stats;
17
- }
18
- async close() {
19
- return new Promise(resolve => {
20
- close(this.fileDescriptor, _err => resolve());
21
- });
22
- }
23
- get stat() {
24
- return this.stats;
25
- }
26
- }
27
- _defineProperty(FileHandle, "open", async path => {
28
- const [fd, stats] = await Promise.all([new Promise(s => {
29
- open(path, undefined, undefined, (_err, fd) => s(fd));
30
- }), new Promise(s => {
31
- stat(path, {
32
- bigint: true
33
- }, (_err, stats) => s(stats));
34
- })]);
35
- return new FileHandle(fd, stats);
36
- });
37
- //# sourceMappingURL=file-handle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-handle.js","names":["read","open","close","stat","FileHandle","constructor","fileDescriptor","stats","_defineProperty","buffer","offset","length","position","Promise","s","_err","bytesRead","resolve","path","fd","all","undefined","bigint"],"sources":["../../../src/file-provider/file-handle.ts"],"sourcesContent":["import {read, open, close, stat, BigIntStats} from 'fs';\n\n/** file reading result */\nexport type FileReadResult = {\n /** amount of the bytes read */\n bytesRead: number;\n /** the buffer filled with data from file*/\n buffer: Buffer;\n};\n\n/** Object handling file info */\nexport class FileHandle {\n private fileDescriptor: number;\n private stats: BigIntStats;\n private constructor(fileDescriptor: number, stats: BigIntStats) {\n this.fileDescriptor = fileDescriptor;\n this.stats = stats;\n }\n /**\n * Opens a `FileHandle`.\n *\n * @param path path to the file\n * @return Fulfills with a {FileHandle} object.\n */\n\n static open = async (path: string): Promise<FileHandle> => {\n const [fd, stats] = await Promise.all([\n new Promise<number>((s) => {\n open(path, undefined, undefined, (_err, fd) => s(fd));\n }),\n new Promise<BigIntStats>((s) => {\n stat(path, {bigint: true}, (_err, stats) => s(stats));\n })\n ]);\n return new FileHandle(fd, stats);\n };\n\n /** Close file */\n async close(): Promise<void> {\n return new Promise<void>((resolve) => {\n close(this.fileDescriptor, (_err) => resolve());\n });\n }\n\n /**\n * Reads data from the file and stores that in the given buffer.\n *\n * If the file is not modified concurrently, the end-of-file is reached when the\n * number of bytes read is zero.\n * @param buffer A buffer that will be filled with the file data read.\n * @param offset The location in the buffer at which to start filling.\n * @param length The number of bytes to read.\n * @param position The location where to begin reading data from the file. If `null`, data will be read from the current file position, and the position will be updated. If `position` is an\n * integer, the current file position will remain unchanged.\n * @return Fulfills upon success with a FileReadResult object\n */\n read = (\n buffer: Buffer,\n offset: number,\n length: number,\n position: number | bigint\n ): Promise<FileReadResult> => {\n return new Promise((s) => {\n read(this.fileDescriptor, buffer, offset, length, position, (_err, bytesRead, buffer) =>\n s({bytesRead, buffer})\n );\n });\n };\n\n get stat(): BigIntStats {\n return this.stats;\n }\n}\n"],"mappings":";AAAA,SAAQA,IAAI,EAAEC,IAAI,EAAEC,KAAK,EAAEC,IAAI,QAAoB,IAAI;AAWvD,OAAO,MAAMC,UAAU,CAAC;EAGdC,WAAWA,CAACC,cAAsB,EAAEC,KAAkB,EAAE;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA,eA0CzD,CACLC,MAAc,EACdC,MAAc,EACdC,MAAc,EACdC,QAAyB,KACG;MAC5B,OAAO,IAAIC,OAAO,CAAEC,CAAC,IAAK;QACxBd,IAAI,CAAC,IAAI,CAACM,cAAc,EAAEG,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAE,CAACG,IAAI,EAAEC,SAAS,EAAEP,MAAM,KAClFK,CAAC,CAAC;UAACE,SAAS;UAAEP;QAAM,CAAC,CACvB,CAAC;MACH,CAAC,CAAC;IACJ,CAAC;IApDC,IAAI,CAACH,cAAc,GAAGA,cAAc;IACpC,IAAI,CAACC,KAAK,GAAGA,KAAK;EACpB;EAqBA,MAAML,KAAKA,CAAA,EAAkB;IAC3B,OAAO,IAAIW,OAAO,CAAQI,OAAO,IAAK;MACpCf,KAAK,CAAC,IAAI,CAACI,cAAc,EAAGS,IAAI,IAAKE,OAAO,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC;EACJ;EA2BA,IAAId,IAAIA,CAAA,EAAgB;IACtB,OAAO,IAAI,CAACI,KAAK;EACnB;AACF;AAACC,eAAA,CA7DYJ,UAAU,UAcP,MAAOc,IAAY,IAA0B;EACzD,MAAM,CAACC,EAAE,EAAEZ,KAAK,CAAC,GAAG,MAAMM,OAAO,CAACO,GAAG,CAAC,CACpC,IAAIP,OAAO,CAAUC,CAAC,IAAK;IACzBb,IAAI,CAACiB,IAAI,EAAEG,SAAS,EAAEA,SAAS,EAAE,CAACN,IAAI,EAAEI,EAAE,KAAKL,CAAC,CAACK,EAAE,CAAC,CAAC;EACvD,CAAC,CAAC,EACF,IAAIN,OAAO,CAAeC,CAAC,IAAK;IAC9BX,IAAI,CAACe,IAAI,EAAE;MAACI,MAAM,EAAE;IAAI,CAAC,EAAE,CAACP,IAAI,EAAER,KAAK,KAAKO,CAAC,CAACP,KAAK,CAAC,CAAC;EACvD,CAAC,CAAC,CACH,CAAC;EACF,OAAO,IAAIH,UAAU,CAACe,EAAE,EAAEZ,KAAK,CAAC;AAClC,CAAC"}
@@ -1,4 +0,0 @@
1
- export const isFileProvider = fileProvider => {
2
- return (fileProvider === null || fileProvider === void 0 ? void 0 : fileProvider.getUint8) && (fileProvider === null || fileProvider === void 0 ? void 0 : fileProvider.slice) && (fileProvider === null || fileProvider === void 0 ? void 0 : fileProvider.length);
3
- };
4
- //# sourceMappingURL=file-provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-provider.js","names":["isFileProvider","fileProvider","getUint8","slice","length"],"sources":["../../../src/file-provider/file-provider.ts"],"sourcesContent":["/**\n * Interface for providing file data\n */\nexport interface FileProvider {\n /**\n * Cleanup class data\n */\n destroy(): Promise<void>;\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\n/**\n * Check is the object has FileProvider members\n * @param fileProvider - tested object\n */\nexport const isFileProvider = (fileProvider: unknown) => {\n return (\n (fileProvider as FileProvider)?.getUint8 &&\n (fileProvider as FileProvider)?.slice &&\n (fileProvider as FileProvider)?.length\n );\n};\n"],"mappings":"AAiDA,OAAO,MAAMA,cAAc,GAAIC,YAAqB,IAAK;EACvD,OACE,CAACA,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAmBC,QAAQ,MACvCD,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAmBE,KAAK,MACpCF,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAmBG,MAAM;AAE1C,CAAC"}
@@ -1,37 +0,0 @@
1
- import { FileProvider } from './file-provider';
2
- /** Provides file data using DataView */
3
- export declare class DataViewFile implements FileProvider {
4
- /** The DataView from which data is provided */
5
- private file;
6
- constructor(file: DataView);
7
- destroy(): Promise<void>;
8
- /**
9
- * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
10
- * @param offset The offset, in bytes, from the start of the file where to read the data.
11
- */
12
- getUint8(offset: bigint): Promise<number>;
13
- /**
14
- * Gets an unsigned 16-bit intege at the specified byte offset from the start of the file.
15
- * @param offset The offset, in bytes, from the start of the file where to read the data.
16
- */
17
- getUint16(offset: bigint): Promise<number>;
18
- /**
19
- * Gets an unsigned 32-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
- getUint32(offset: bigint): Promise<number>;
23
- /**
24
- * Gets an unsigned 64-bit integer at the specified byte offset from the start of the file.
25
- * @param offset The offset, in bytes, from the start of the file where to read the data.
26
- */
27
- getBigUint64(offset: bigint): Promise<bigint>;
28
- /**
29
- * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
30
- * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
31
- * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
32
- */
33
- slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer>;
34
- /** the length (in bytes) of the data. */
35
- get length(): bigint;
36
- }
37
- //# sourceMappingURL=data-view-file.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-view-file.d.ts","sourceRoot":"","sources":["../../src/file-provider/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;IAKpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;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,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DataViewFile = void 0;
4
- /**
5
- * Checks if bigint can be converted to number and convert it if possible
6
- * @param bigint bigint to be converted
7
- * @returns number
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 */
16
- class DataViewFile {
17
- constructor(file) {
18
- this.file = file;
19
- }
20
- // eslint-disable-next-line @typescript-eslint/no-empty-function
21
- async destroy() { }
22
- /**
23
- * Gets an unsigned 8-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
- async getUint8(offset) {
27
- return this.file.getUint8(toNumber(offset));
28
- }
29
- /**
30
- * Gets an unsigned 16-bit intege at the specified byte offset from the start of the file.
31
- * @param offset The offset, in bytes, from the start of the file where to read the data.
32
- */
33
- async getUint16(offset) {
34
- return this.file.getUint16(toNumber(offset), true);
35
- }
36
- /**
37
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
38
- * @param offset The offset, in bytes, from the start of the file where to read the data.
39
- */
40
- async getUint32(offset) {
41
- return this.file.getUint32(toNumber(offset), true);
42
- }
43
- /**
44
- * Gets an unsigned 64-bit integer at the specified byte offset from the start of the file.
45
- * @param offset The offset, in bytes, from the start of the file where to read the data.
46
- */
47
- async getBigUint64(offset) {
48
- return this.file.getBigUint64(toNumber(offset), true);
49
- }
50
- /**
51
- * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
52
- * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
53
- * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
54
- */
55
- async slice(startOffset, endOffset) {
56
- return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));
57
- }
58
- /** the length (in bytes) of the data. */
59
- get length() {
60
- return BigInt(this.file.byteLength);
61
- }
62
- }
63
- exports.DataViewFile = DataViewFile;
@@ -1,53 +0,0 @@
1
- import { FileProvider } from '@loaders.gl/zip';
2
- /**
3
- * Provides file data using node fs library
4
- */
5
- export declare class FileHandleFile implements FileProvider {
6
- /**
7
- * Returns a new copy of FileHandleFile
8
- * @param path The path to the file in file system
9
- */
10
- static from(path: string): Promise<FileHandleFile>;
11
- /**
12
- * The FileHandle from which data is provided
13
- */
14
- private fileDescriptor;
15
- /**
16
- * The file length in bytes
17
- */
18
- private size;
19
- private constructor();
20
- /** Close file */
21
- destroy(): Promise<void>;
22
- /**
23
- * Gets an unsigned 8-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
- getUint8(offset: bigint): Promise<number>;
27
- /**
28
- * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
29
- * @param offset The offset, in bytes, from the start of the file where to read the data.
30
- */
31
- getUint16(offset: bigint): Promise<number>;
32
- /**
33
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
34
- * @param offset The offset, in bytes, from the start of the file where to read the data.
35
- */
36
- getUint32(offset: bigint): Promise<number>;
37
- /**
38
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
39
- * @param offset The offset, in bytes, from the start of the file where to read the data.
40
- */
41
- getBigUint64(offset: bigint): Promise<bigint>;
42
- /**
43
- * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
44
- * @param startOffsset The offset, in byte, from the start of the file where to start reading the data.
45
- * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
46
- */
47
- slice(startOffsset: bigint, endOffset: bigint): Promise<ArrayBuffer>;
48
- /**
49
- * the length (in bytes) of the data.
50
- */
51
- get length(): bigint;
52
- }
53
- //# sourceMappingURL=file-handle-file.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-handle-file.d.ts","sourceRoot":"","sources":["../../src/file-provider/file-handle-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAG7C;;GAEG;AACH,qBAAa,cAAe,YAAW,YAAY;IACjD;;;OAGG;WACU,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAKxD;;OAEG;IACH,OAAO,CAAC,cAAc,CAAa;IAEnC;;OAEG;IACH,OAAO,CAAC,IAAI,CAAS;IAErB,OAAO;IAKP,iBAAiB;IACX,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B;;;OAGG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAU/C;;;OAGG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAUhD;;;OAGG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAUhD;;;OAGG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAUnD;;;;OAIG;IACG,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAU1E;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;CACF"}
@@ -1,90 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileHandleFile = void 0;
4
- const file_handle_1 = require("./file-handle");
5
- /**
6
- * Provides file data using node fs library
7
- */
8
- class FileHandleFile {
9
- /**
10
- * Returns a new copy of FileHandleFile
11
- * @param path The path to the file in file system
12
- */
13
- static async from(path) {
14
- const fileDescriptor = await file_handle_1.FileHandle.open(path);
15
- return new FileHandleFile(fileDescriptor, fileDescriptor.stat.size);
16
- }
17
- constructor(fileDescriptor, size) {
18
- this.fileDescriptor = fileDescriptor;
19
- this.size = size;
20
- }
21
- /** Close file */
22
- async destroy() {
23
- await this.fileDescriptor.close();
24
- }
25
- /**
26
- * Gets an unsigned 8-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
- async getUint8(offset) {
30
- const val = new Uint8Array((await this.fileDescriptor.read(Buffer.alloc(1), 0, 1, offset)).buffer.buffer).at(0);
31
- if (val === undefined) {
32
- throw new Error('something went wrong');
33
- }
34
- return val;
35
- }
36
- /**
37
- * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
38
- * @param offset The offset, in bytes, from the start of the file where to read the data.
39
- */
40
- async getUint16(offset) {
41
- const val = new Uint16Array((await this.fileDescriptor.read(Buffer.alloc(2), 0, 2, offset)).buffer.buffer).at(0);
42
- if (val === undefined) {
43
- throw new Error('something went wrong');
44
- }
45
- return val;
46
- }
47
- /**
48
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
49
- * @param offset The offset, in bytes, from the start of the file where to read the data.
50
- */
51
- async getUint32(offset) {
52
- const val = new Uint32Array((await this.fileDescriptor.read(Buffer.alloc(4), 0, 4, offset)).buffer.buffer).at(0);
53
- if (val === undefined) {
54
- throw new Error('something went wrong');
55
- }
56
- return val;
57
- }
58
- /**
59
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
60
- * @param offset The offset, in bytes, from the start of the file where to read the data.
61
- */
62
- async getBigUint64(offset) {
63
- const val = new BigInt64Array((await this.fileDescriptor.read(Buffer.alloc(8), 0, 8, offset)).buffer.buffer).at(0);
64
- if (val === undefined) {
65
- throw new Error('something went wrong');
66
- }
67
- return val;
68
- }
69
- /**
70
- * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
71
- * @param startOffsset The offset, in byte, from the start of the file where to start reading the data.
72
- * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
73
- */
74
- async slice(startOffsset, endOffset) {
75
- const bigLength = endOffset - startOffsset;
76
- if (bigLength > Number.MAX_SAFE_INTEGER) {
77
- throw new Error('too big slice');
78
- }
79
- const length = Number(bigLength);
80
- return (await this.fileDescriptor.read(Buffer.alloc(length), 0, length, startOffsset)).buffer
81
- .buffer;
82
- }
83
- /**
84
- * the length (in bytes) of the data.
85
- */
86
- get length() {
87
- return this.size;
88
- }
89
- }
90
- exports.FileHandleFile = FileHandleFile;
@@ -1,40 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { BigIntStats } from 'fs';
4
- /** file reading result */
5
- export type FileReadResult = {
6
- /** amount of the bytes read */
7
- bytesRead: number;
8
- /** the buffer filled with data from file*/
9
- buffer: Buffer;
10
- };
11
- /** Object handling file info */
12
- export declare class FileHandle {
13
- private fileDescriptor;
14
- private stats;
15
- private constructor();
16
- /**
17
- * Opens a `FileHandle`.
18
- *
19
- * @param path path to the file
20
- * @return Fulfills with a {FileHandle} object.
21
- */
22
- static open: (path: string) => Promise<FileHandle>;
23
- /** Close file */
24
- close(): Promise<void>;
25
- /**
26
- * Reads data from the file and stores that in the given buffer.
27
- *
28
- * If the file is not modified concurrently, the end-of-file is reached when the
29
- * number of bytes read is zero.
30
- * @param buffer A buffer that will be filled with the file data read.
31
- * @param offset The location in the buffer at which to start filling.
32
- * @param length The number of bytes to read.
33
- * @param position The location where to begin reading data from the file. If `null`, data will be read from the current file position, and the position will be updated. If `position` is an
34
- * integer, the current file position will remain unchanged.
35
- * @return Fulfills upon success with a FileReadResult object
36
- */
37
- read: (buffer: Buffer, offset: number, length: number, position: number | bigint) => Promise<FileReadResult>;
38
- get stat(): BigIntStats;
39
- }
40
- //# sourceMappingURL=file-handle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-handle.d.ts","sourceRoot":"","sources":["../../src/file-provider/file-handle.ts"],"names":[],"mappings":";;AAAA,OAAO,EAA0B,WAAW,EAAC,MAAM,IAAI,CAAC;AAExD,0BAA0B;AAC1B,MAAM,MAAM,cAAc,GAAG;IAC3B,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,gCAAgC;AAChC,qBAAa,UAAU;IACrB,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO;IAIP;;;;;OAKG;IAEH,MAAM,CAAC,IAAI,SAAgB,MAAM,KAAG,QAAQ,UAAU,CAAC,CAUrD;IAEF,iBAAiB;IACX,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAM5B;;;;;;;;;;;OAWG;IACH,IAAI,WACM,MAAM,UACN,MAAM,UACN,MAAM,YACJ,MAAM,GAAG,MAAM,KACxB,QAAQ,cAAc,CAAC,CAMxB;IAEF,IAAI,IAAI,IAAI,WAAW,CAEtB;CACF"}
@@ -1,57 +0,0 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.FileHandle = void 0;
5
- const fs_1 = require("fs");
6
- /** Object handling file info */
7
- class FileHandle {
8
- constructor(fileDescriptor, stats) {
9
- /**
10
- * Reads data from the file and stores that in the given buffer.
11
- *
12
- * If the file is not modified concurrently, the end-of-file is reached when the
13
- * number of bytes read is zero.
14
- * @param buffer A buffer that will be filled with the file data read.
15
- * @param offset The location in the buffer at which to start filling.
16
- * @param length The number of bytes to read.
17
- * @param position The location where to begin reading data from the file. If `null`, data will be read from the current file position, and the position will be updated. If `position` is an
18
- * integer, the current file position will remain unchanged.
19
- * @return Fulfills upon success with a FileReadResult object
20
- */
21
- this.read = (buffer, offset, length, position) => {
22
- return new Promise((s) => {
23
- (0, fs_1.read)(this.fileDescriptor, buffer, offset, length, position, (_err, bytesRead, buffer) => s({ bytesRead, buffer }));
24
- });
25
- };
26
- this.fileDescriptor = fileDescriptor;
27
- this.stats = stats;
28
- }
29
- /** Close file */
30
- async close() {
31
- return new Promise((resolve) => {
32
- (0, fs_1.close)(this.fileDescriptor, (_err) => resolve());
33
- });
34
- }
35
- get stat() {
36
- return this.stats;
37
- }
38
- }
39
- exports.FileHandle = FileHandle;
40
- _a = FileHandle;
41
- /**
42
- * Opens a `FileHandle`.
43
- *
44
- * @param path path to the file
45
- * @return Fulfills with a {FileHandle} object.
46
- */
47
- FileHandle.open = async (path) => {
48
- const [fd, stats] = await Promise.all([
49
- new Promise((s) => {
50
- (0, fs_1.open)(path, undefined, undefined, (_err, fd) => s(fd));
51
- }),
52
- new Promise((s) => {
53
- (0, fs_1.stat)(path, { bigint: true }, (_err, stats) => s(stats));
54
- })
55
- ]);
56
- return new FileHandle(fd, stats);
57
- };
@@ -1,45 +0,0 @@
1
- /**
2
- * Interface for providing file data
3
- */
4
- export interface FileProvider {
5
- /**
6
- * Cleanup class data
7
- */
8
- destroy(): Promise<void>;
9
- /**
10
- * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
11
- * @param offset The offset, in bytes, from the start of the file where to read the data.
12
- */
13
- getUint8(offset: bigint): Promise<number>;
14
- /**
15
- * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
16
- * @param offset The offset, in bytes, from the start of the file where to read the data.
17
- */
18
- getUint16(offset: bigint): Promise<number>;
19
- /**
20
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
21
- * @param offset The offset, in bytes, from the file of the view where to read the data.
22
- */
23
- getUint32(offset: bigint): Promise<number>;
24
- /**
25
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
26
- * @param offset The offset, in byte, from the file of the view where to read the data.
27
- */
28
- getBigUint64(offset: bigint): Promise<bigint>;
29
- /**
30
- * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
31
- * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
32
- * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
33
- */
34
- slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer>;
35
- /**
36
- * the length (in bytes) of the data.
37
- */
38
- length: bigint;
39
- }
40
- /**
41
- * Check is the object has FileProvider members
42
- * @param fileProvider - tested object
43
- */
44
- export declare const isFileProvider: (fileProvider: unknown) => bigint;
45
- //# sourceMappingURL=file-provider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-provider.d.ts","sourceRoot":"","sources":["../../src/file-provider/file-provider.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB;;;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;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,iBAAkB,OAAO,WAMnD,CAAC"}
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isFileProvider = void 0;
4
- /**
5
- * Check is the object has FileProvider members
6
- * @param fileProvider - tested object
7
- */
8
- const isFileProvider = (fileProvider) => {
9
- return (fileProvider?.getUint8 &&
10
- fileProvider?.slice &&
11
- fileProvider?.length);
12
- };
13
- exports.isFileProvider = isFileProvider;
@@ -1,72 +0,0 @@
1
- import {FileProvider} from './file-provider';
2
-
3
- /**
4
- * Checks if bigint can be converted to number and convert it if possible
5
- * @param bigint bigint to be converted
6
- * @returns number
7
- */
8
- const toNumber = (bigint: bigint) => {
9
- if (bigint > Number.MAX_SAFE_INTEGER) {
10
- throw new Error('Offset is out of bounds');
11
- }
12
- return Number(bigint);
13
- };
14
-
15
- /** Provides file data using DataView */
16
- export class DataViewFile implements FileProvider {
17
- /** The DataView from which data is provided */
18
- private file: DataView;
19
-
20
- constructor(file: DataView) {
21
- this.file = file;
22
- }
23
-
24
- // eslint-disable-next-line @typescript-eslint/no-empty-function
25
- async destroy(): Promise<void> {}
26
-
27
- /**
28
- * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
29
- * @param offset The offset, in bytes, from the start of the file where to read the data.
30
- */
31
- async getUint8(offset: bigint): Promise<number> {
32
- return this.file.getUint8(toNumber(offset));
33
- }
34
-
35
- /**
36
- * Gets an unsigned 16-bit intege at the specified byte offset from the start of the file.
37
- * @param offset The offset, in bytes, from the start of the file where to read the data.
38
- */
39
- async getUint16(offset: bigint): Promise<number> {
40
- return this.file.getUint16(toNumber(offset), true);
41
- }
42
-
43
- /**
44
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
45
- * @param offset The offset, in bytes, from the start of the file where to read the data.
46
- */
47
- async getUint32(offset: bigint): Promise<number> {
48
- return this.file.getUint32(toNumber(offset), true);
49
- }
50
-
51
- /**
52
- * Gets an unsigned 64-bit integer at the specified byte offset from the start of the file.
53
- * @param offset The offset, in bytes, from the start of the file where to read the data.
54
- */
55
- async getBigUint64(offset: bigint): Promise<bigint> {
56
- return this.file.getBigUint64(toNumber(offset), true);
57
- }
58
-
59
- /**
60
- * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
61
- * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
62
- * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
63
- */
64
- async slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer> {
65
- return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));
66
- }
67
-
68
- /** the length (in bytes) of the data. */
69
- get length() {
70
- return BigInt(this.file.byteLength);
71
- }
72
- }