@loaders.gl/loader-utils 4.0.0-alpha.22 → 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 (64) hide show
  1. package/dist/es5/index.js +30 -2
  2. package/dist/es5/index.js.map +1 -1
  3. package/dist/es5/json-loader.js +1 -1
  4. package/dist/es5/lib/file-provider/data-view-file.js +146 -0
  5. package/dist/es5/lib/file-provider/data-view-file.js.map +1 -0
  6. package/dist/es5/lib/file-provider/file-handle-file.js +236 -0
  7. package/dist/es5/lib/file-provider/file-handle-file.js.map +1 -0
  8. package/dist/es5/lib/file-provider/file-handle.js +104 -0
  9. package/dist/es5/lib/file-provider/file-handle.js.map +1 -0
  10. package/dist/es5/lib/file-provider/file-provider.js +11 -0
  11. package/dist/es5/lib/file-provider/file-provider.js.map +1 -0
  12. package/dist/es5/lib/filesystems/filesystem.js +2 -0
  13. package/dist/es5/lib/filesystems/filesystem.js.map +1 -0
  14. package/dist/es5/lib/filesystems/node-filesystem.js +2 -2
  15. package/dist/es5/lib/filesystems/node-filesystem.js.map +1 -1
  16. package/dist/es5/types.js.map +1 -1
  17. package/dist/esm/index.js +5 -1
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/json-loader.js +1 -1
  20. package/dist/esm/lib/file-provider/data-view-file.js +33 -0
  21. package/dist/esm/lib/file-provider/data-view-file.js.map +1 -0
  22. package/dist/esm/lib/file-provider/file-handle-file.js +59 -0
  23. package/dist/esm/lib/file-provider/file-handle-file.js.map +1 -0
  24. package/dist/esm/lib/file-provider/file-handle.js +37 -0
  25. package/dist/esm/lib/file-provider/file-handle.js.map +1 -0
  26. package/dist/esm/lib/file-provider/file-provider.js +4 -0
  27. package/dist/esm/lib/file-provider/file-provider.js.map +1 -0
  28. package/dist/esm/lib/filesystems/filesystem.js +2 -0
  29. package/dist/esm/lib/filesystems/filesystem.js.map +1 -0
  30. package/dist/esm/lib/filesystems/node-filesystem.js +1 -1
  31. package/dist/esm/lib/filesystems/node-filesystem.js.map +1 -1
  32. package/dist/esm/types.js.map +1 -1
  33. package/dist/index.d.ts +8 -2
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +11 -3
  36. package/dist/lib/file-provider/data-view-file.d.ts +37 -0
  37. package/dist/lib/file-provider/data-view-file.d.ts.map +1 -0
  38. package/dist/lib/file-provider/data-view-file.js +63 -0
  39. package/dist/lib/file-provider/file-handle-file.d.ts +53 -0
  40. package/dist/lib/file-provider/file-handle-file.d.ts.map +1 -0
  41. package/dist/lib/file-provider/file-handle-file.js +92 -0
  42. package/dist/lib/file-provider/file-handle.d.ts +40 -0
  43. package/dist/lib/file-provider/file-handle.d.ts.map +1 -0
  44. package/dist/lib/file-provider/file-handle.js +55 -0
  45. package/dist/lib/file-provider/file-provider.d.ts +45 -0
  46. package/dist/lib/file-provider/file-provider.d.ts.map +1 -0
  47. package/dist/lib/file-provider/file-provider.js +13 -0
  48. package/dist/lib/filesystems/filesystem.d.ts +81 -0
  49. package/dist/lib/filesystems/filesystem.d.ts.map +1 -0
  50. package/dist/lib/filesystems/filesystem.js +37 -0
  51. package/dist/lib/filesystems/node-filesystem.d.ts +2 -2
  52. package/dist/lib/filesystems/node-filesystem.d.ts.map +1 -1
  53. package/dist/lib/filesystems/node-filesystem.js +3 -2
  54. package/dist/types.d.ts +0 -44
  55. package/dist/types.d.ts.map +1 -1
  56. package/package.json +3 -3
  57. package/src/index.ts +10 -4
  58. package/src/lib/file-provider/data-view-file.ts +72 -0
  59. package/src/lib/file-provider/file-handle-file.ts +116 -0
  60. package/src/lib/file-provider/file-handle.ts +74 -0
  61. package/src/lib/file-provider/file-provider.ts +56 -0
  62. package/src/lib/filesystems/filesystem.ts +87 -0
  63. package/src/lib/filesystems/node-filesystem.ts +3 -3
  64. package/src/types.ts +0 -34
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isFileProvider = void 0;
7
+ var isFileProvider = function isFileProvider(fileProvider) {
8
+ 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);
9
+ };
10
+ exports.isFileProvider = isFileProvider;
11
+ //# sourceMappingURL=file-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-provider.js","names":["isFileProvider","fileProvider","getUint8","slice","length","exports"],"sources":["../../../../src/lib/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":";;;;;;AAiDO,IAAMA,cAAc,GAAG,SAAjBA,cAAcA,CAAIC,YAAqB,EAAK;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;AAACC,OAAA,CAAAL,cAAA,GAAAA,cAAA"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=filesystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem.js","names":[],"sources":["../../../../src/lib/filesystems/filesystem.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nexport type ReadOptions = {};\n\nexport type Stat = {\n size: number;\n isDirectory: () => boolean;\n};\n\n/**\n * A FileSystem interface can encapsulate various file sources,\n * a FileList, a ZipFile, a GoogleDrive etc.\n */\nexport interface FileSystem {\n /**\n * Return a list of file names\n * @param dirname directory name. file system root directory if omitted\n */\n readdir(dirname?: string, options?: {recursive?: boolean}): Promise<string[]>;\n\n /**\n * Gets information from a local file from the filesystem\n * @param filename file name to stat\n * @param options currently unused\n * @throws if filename is not in local filesystem\n */\n stat(filename: string, options?: object): Promise<{size: number}>;\n\n /**\n * Fetches a local file from the filesystem (or a URL)\n * @param filename\n * @param options\n */\n fetch(filename: RequestInfo, options?: RequestInit): Promise<Response>;\n}\n\n/**\n * A random access file system\n */\nexport interface RandomAccessReadFileSystem extends FileSystem {\n open(path: string, flags: unknown, mode?: unknown): Promise<any>;\n close(fd: unknown): Promise<void>;\n fstat(fd: unknown): Promise<Stat>;\n read(fd: any, options?: ReadOptions): Promise<{bytesRead: number; buffer: Buffer}>;\n // read(\n // fd: any,\n // buffer: ArrayBuffer | ArrayBufferView,\n // offset?: number,\n // length?: number,\n // position?: number\n // ): Promise<{bytesRead: number; buffer: ArrayBuffer}>;\n}\n\n/**\n * A FileSystem interface can encapsulate a FileList, a ZipFile, a GoogleDrive etc.\n *\nexport interface IFileSystem {\n /**\n * Return a list of file names\n * @param dirname directory name. file system root directory if omitted\n *\n readdir(dirname?: string, options?: {recursive?: boolean}): Promise<string[]>;\n\n /**\n * Gets information from a local file from the filesystem\n * @param filename file name to stat\n * @param options currently unused\n * @throws if filename is not in local filesystem\n *\n stat(filename: string, options?: object): Promise<{size: number}>;\n\n /**\n * Fetches a local file from the filesystem (or a URL)\n * @param filename\n * @param options\n *\n fetch(filename: string, options?: object): Promise<Response>;\n}\n\ntype ReadOptions = {buffer?: ArrayBuffer; offset?: number; length?: number; position?: number};\nexport interface IRandomAccessReadFileSystem extends IFileSystem {\n open(path: string, flags: string | number, mode?: any): Promise<any>;\n close(fd: any): Promise<void>;\n fstat(fd: any): Promise<object>;\n read(fd: any, options?: ReadOptions): Promise<{bytesRead: number; buffer: Buffer}>;\n}\n*/\n"],"mappings":""}
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = void 0;
8
+ exports.NodeFileSystem = void 0;
9
9
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
@@ -206,5 +206,5 @@ var NodeFileSystem = function () {
206
206
  }]);
207
207
  return NodeFileSystem;
208
208
  }();
209
- exports.default = NodeFileSystem;
209
+ exports.NodeFileSystem = NodeFileSystem;
210
210
  //# sourceMappingURL=node-filesystem.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-filesystem.js","names":["fs","_interopRequireWildcard","require","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","NodeFileSystem","options","_classCallCheck2","fetch","_fetch","_createClass2","value","_readdir","_asyncToGenerator2","_regenerator","mark","_callee","dirname","_args","arguments","wrap","_callee$","_context","prev","next","length","undefined","readdir","abrupt","sent","stop","apply","_stat","_callee2","path","info","_callee2$","_context2","stat","size","Number","isDirectory","_x","_x2","_callee3","fallbackFetch","_callee3$","_context3","_x3","_x4","_open","_callee4","flags","mode","_callee4$","_context4","open","_x5","_x6","_x7","_close","_callee5","fd","_callee5$","_context5","close","_x8","_fstat","_callee6","_callee6$","_context6","fstat","_x9","_read","_callee7","_ref","_ref$buffer","buffer","_ref$offset","offset","_ref$length","_ref$position","position","totalBytesRead","_yield$fs$read","bytesRead","_callee7$","_context7","byteLength","read","_x10","_x11","exports"],"sources":["../../../../src/lib/filesystems/node-filesystem.ts"],"sourcesContent":["import * as fs from '../node/fs';\nimport {IFileSystem, IRandomAccessReadFileSystem} from '../../types';\n// import {fetchFile} from \"../fetch/fetch-file\"\n// import {selectLoader} from \"../api/select-loader\";\n\ntype Stat = {\n size: number;\n isDirectory: () => boolean;\n info?: fs.Stats;\n};\n\ntype ReadOptions = {\n buffer?: Buffer;\n offset?: number;\n length?: number;\n position?: number;\n};\n\n/**\n * FileSystem pass-through for Node.js\n * Compatible with BrowserFileSystem.\n * @param options\n */\nexport default class NodeFileSystem implements IFileSystem, IRandomAccessReadFileSystem {\n // implements IFileSystem\n constructor(options: {[key: string]: any}) {\n this.fetch = options._fetch;\n }\n\n async readdir(dirname = '.', options?: {}): Promise<any[]> {\n return await fs.readdir(dirname, options);\n }\n\n async stat(path: string, options?: {}): Promise<Stat> {\n const info = await fs.stat(path, options);\n return {size: Number(info.size), isDirectory: () => false, info};\n }\n\n async fetch(path: string, options: {[key: string]: any}) {\n // Falls back to handle https:/http:/data: etc fetches\n // eslint-disable-next-line\n const fallbackFetch = options.fetch || this.fetch;\n return fallbackFetch(path, options);\n }\n\n // implements IRandomAccessFileSystem\n async open(path: string, flags: string | number, mode?: any): Promise<number> {\n return await fs.open(path, flags);\n }\n\n async close(fd: number): Promise<void> {\n return await fs.close(fd);\n }\n\n async fstat(fd: number): Promise<Stat> {\n const info = await fs.fstat(fd);\n return info;\n }\n\n async read(\n fd: number,\n // @ts-ignore Possibly null\n {buffer = null, offset = 0, length = buffer.byteLength, position = null}: ReadOptions\n ): Promise<{bytesRead: number; buffer: Buffer}> {\n let totalBytesRead = 0;\n // Read in loop until we get required number of bytes\n while (totalBytesRead < length) {\n const {bytesRead} = await fs.read(\n fd,\n buffer,\n offset + totalBytesRead,\n length - totalBytesRead,\n position + totalBytesRead\n );\n totalBytesRead += bytesRead;\n }\n return {bytesRead: totalBytesRead, buffer};\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,EAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAiC,SAAAC,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,aAAAE,OAAA,CAAAF,GAAA,yBAAAA,GAAA,4BAAAG,OAAA,EAAAH,GAAA,UAAAI,KAAA,GAAAT,wBAAA,CAAAC,WAAA,OAAAQ,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAL,GAAA,YAAAI,KAAA,CAAAE,GAAA,CAAAN,GAAA,SAAAO,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAZ,GAAA,QAAAY,GAAA,kBAAAH,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cAAc,EACvBD,QAAQ,GAAGC,cACb,CAAC;YAAA;cAAAC,cAAA,GAAAG,SAAA,CAAA1D,IAAA;cANMwD,SAAS,GAAAD,cAAA,CAATC,SAAS;cAOhBF,cAAc,IAAIE,SAAS;cAACE,SAAA,CAAA/D,IAAA;cAAA;YAAA;cAAA,OAAA+D,SAAA,CAAA3D,MAAA,WAEvB;gBAACyD,SAAS,EAAEF,cAAc;gBAAEN,MAAM,EAANA;cAAM,CAAC;YAAA;YAAA;cAAA,OAAAU,SAAA,CAAAzD,IAAA;UAAA;QAAA,GAAA4C,QAAA;MAAA,CAC3C;MAAA,SAAAe,KAAAC,IAAA,EAAAC,IAAA;QAAA,OAAAlB,KAAA,CAAA1C,KAAA,OAAAZ,SAAA;MAAA;MAAA,OAAAsE,IAAA;IAAA;EAAA;EAAA,OAAApF,cAAA;AAAA;AAAAuF,OAAA,CAAAtG,OAAA,GAAAe,cAAA"}
1
+ {"version":3,"file":"node-filesystem.js","names":["fs","_interopRequireWildcard","require","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","NodeFileSystem","options","_classCallCheck2","fetch","_fetch","_createClass2","value","_readdir","_asyncToGenerator2","_regenerator","mark","_callee","dirname","_args","arguments","wrap","_callee$","_context","prev","next","length","undefined","readdir","abrupt","sent","stop","apply","_stat","_callee2","path","info","_callee2$","_context2","stat","size","Number","isDirectory","_x","_x2","_callee3","fallbackFetch","_callee3$","_context3","_x3","_x4","_open","_callee4","flags","mode","_callee4$","_context4","open","_x5","_x6","_x7","_close","_callee5","fd","_callee5$","_context5","close","_x8","_fstat","_callee6","_callee6$","_context6","fstat","_x9","_read","_callee7","_ref","_ref$buffer","buffer","_ref$offset","offset","_ref$length","_ref$position","position","totalBytesRead","_yield$fs$read","bytesRead","_callee7$","_context7","byteLength","read","_x10","_x11","exports"],"sources":["../../../../src/lib/filesystems/node-filesystem.ts"],"sourcesContent":["import * as fs from '../node/fs';\nimport {FileSystem, RandomAccessReadFileSystem} from './filesystem';\n// import {fetchFile} from \"../fetch/fetch-file\"\n// import {selectLoader} from \"../api/select-loader\";\n\ntype Stat = {\n size: number;\n isDirectory: () => boolean;\n info?: fs.Stats;\n};\n\ntype ReadOptions = {\n buffer?: Buffer;\n offset?: number;\n length?: number;\n position?: number;\n};\n\n/**\n * FileSystem pass-through for Node.js\n * Compatible with BrowserFileSystem.\n * @param options\n */\nexport class NodeFileSystem implements FileSystem, RandomAccessReadFileSystem {\n // implements FileSystem\n constructor(options: {[key: string]: any}) {\n this.fetch = options._fetch;\n }\n\n async readdir(dirname = '.', options?: {}): Promise<any[]> {\n return await fs.readdir(dirname, options);\n }\n\n async stat(path: string, options?: {}): Promise<Stat> {\n const info = await fs.stat(path, options);\n return {size: Number(info.size), isDirectory: () => false, info};\n }\n\n async fetch(path: string, options: {[key: string]: any}) {\n // Falls back to handle https:/http:/data: etc fetches\n // eslint-disable-next-line\n const fallbackFetch = options.fetch || this.fetch;\n return fallbackFetch(path, options);\n }\n\n // implements IRandomAccessFileSystem\n async open(path: string, flags: string | number, mode?: any): Promise<number> {\n return await fs.open(path, flags);\n }\n\n async close(fd: number): Promise<void> {\n return await fs.close(fd);\n }\n\n async fstat(fd: number): Promise<Stat> {\n const info = await fs.fstat(fd);\n return info;\n }\n\n async read(\n fd: number,\n // @ts-ignore Possibly null\n {buffer = null, offset = 0, length = buffer.byteLength, position = null}: ReadOptions\n ): Promise<{bytesRead: number; buffer: Buffer}> {\n let totalBytesRead = 0;\n // Read in loop until we get required number of bytes\n while (totalBytesRead < length) {\n const {bytesRead} = await fs.read(\n fd,\n buffer,\n offset + totalBytesRead,\n length - totalBytesRead,\n position + totalBytesRead\n );\n totalBytesRead += bytesRead;\n }\n return {bytesRead: totalBytesRead, buffer};\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAA,IA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AAAvF,cAAA,GAAAA,cAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/types.ts"],"sourcesContent":["// Typed arrays\n\nexport type TypedIntArray =\n | Int8Array\n | Uint8Array\n | Uint8ClampedArray\n | Int16Array\n | Uint16Array\n | Int32Array\n | Uint32Array\n | Int32Array\n | Uint32Array;\n\nexport type TypedFloatArray = Uint16Array | Float32Array | Float64Array;\n\nexport type TypedArray = TypedIntArray | TypedFloatArray;\n\nexport type BigTypedArray = TypedArray | BigInt64Array | BigUint64Array;\n\nexport type TypedArrayConstructor =\n | Int8ArrayConstructor\n | Uint8ArrayConstructor\n | Int16ArrayConstructor\n | Uint16ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Float32ArrayConstructor\n | Float64ArrayConstructor;\n\nexport type BigTypedArrayConstructor =\n | TypedArrayConstructor\n | BigInt64ArrayConstructor\n | BigUint64ArrayConstructor;\n\n/** Any numeric array: typed array or `number[]` */\nexport type NumberArray = number[] | TypedArray;\n\nexport type NumericArray = number[] | TypedArray;\n\n// FETCH\n\nexport type FetchLike = (url: string, options?: RequestInit) => Promise<Response>;\n\n// MISC TYPES\n\nexport type TransformBatches = (\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>\n) => AsyncIterable<ArrayBuffer>;\n\n/** Types that can be synchronously parsed */\nexport type SyncDataType = string | ArrayBuffer; // TODO File | Blob can be read synchronously...\n\n/** Types that can be parsed async */\nexport type DataType =\n | string\n | ArrayBuffer\n | File\n | Blob\n | Response\n | ReadableStream\n | Iterable<ArrayBuffer>\n | AsyncIterable<ArrayBuffer>;\n\n/** Types that can be parsed in batches */\nexport type BatchableDataType =\n | DataType\n | Iterable<ArrayBuffer>\n | AsyncIterable<ArrayBuffer>\n | Promise<AsyncIterable<ArrayBuffer>>;\n\n/**\n * A FileSystem interface can encapsulate a FileList, a ZipFile, a GoogleDrive etc.\n */\nexport interface IFileSystem {\n /**\n * Return a list of file names\n * @param dirname directory name. file system root directory if omitted\n */\n readdir(dirname?: string, options?: {recursive?: boolean}): Promise<string[]>;\n\n /**\n * Gets information from a local file from the filesystem\n * @param filename file name to stat\n * @param options currently unused\n * @throws if filename is not in local filesystem\n */\n stat(filename: string, options?: object): Promise<{size: number}>;\n\n /**\n * Fetches a local file from the filesystem (or a URL)\n * @param filename\n * @param options\n */\n fetch(filename: string, options?: object): Promise<Response>;\n}\n\ntype ReadOptions = {buffer?: ArrayBuffer; offset?: number; length?: number; position?: number};\nexport interface IRandomAccessReadFileSystem extends IFileSystem {\n open(path: string, flags: string | number, mode?: any): Promise<any>;\n close(fd: any): Promise<void>;\n fstat(fd: any): Promise<object>;\n read(fd: any, options?: ReadOptions): Promise<{bytesRead: number; buffer: Buffer}>;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/types.ts"],"sourcesContent":["// Typed arrays\n\nexport type TypedIntArray =\n | Int8Array\n | Uint8Array\n | Uint8ClampedArray\n | Int16Array\n | Uint16Array\n | Int32Array\n | Uint32Array\n | Int32Array\n | Uint32Array;\n\nexport type TypedFloatArray = Uint16Array | Float32Array | Float64Array;\n\nexport type TypedArray = TypedIntArray | TypedFloatArray;\n\nexport type BigTypedArray = TypedArray | BigInt64Array | BigUint64Array;\n\nexport type TypedArrayConstructor =\n | Int8ArrayConstructor\n | Uint8ArrayConstructor\n | Int16ArrayConstructor\n | Uint16ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Float32ArrayConstructor\n | Float64ArrayConstructor;\n\nexport type BigTypedArrayConstructor =\n | TypedArrayConstructor\n | BigInt64ArrayConstructor\n | BigUint64ArrayConstructor;\n\n/** Any numeric array: typed array or `number[]` */\nexport type NumberArray = number[] | TypedArray;\n\nexport type NumericArray = number[] | TypedArray;\n\n// FETCH\n\nexport type FetchLike = (url: string, options?: RequestInit) => Promise<Response>;\n\n// MISC TYPES\n\nexport type TransformBatches = (\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>\n) => AsyncIterable<ArrayBuffer>;\n\n/** Types that can be synchronously parsed */\nexport type SyncDataType = string | ArrayBuffer; // TODO File | Blob can be read synchronously...\n\n/** Types that can be parsed async */\nexport type DataType =\n | string\n | ArrayBuffer\n | File\n | Blob\n | Response\n | ReadableStream\n | Iterable<ArrayBuffer>\n | AsyncIterable<ArrayBuffer>;\n\n/** Types that can be parsed in batches */\nexport type BatchableDataType =\n | DataType\n | Iterable<ArrayBuffer>\n | AsyncIterable<ArrayBuffer>\n | Promise<AsyncIterable<ArrayBuffer>>;\n"],"mappings":""}
package/dist/esm/index.js CHANGED
@@ -24,7 +24,11 @@ import * as fs from './lib/node/fs';
24
24
  export { fs };
25
25
  import * as stream from './lib/node/stream';
26
26
  export { stream };
27
+ export { NodeFileSystem as _NodeFileSystem } from './lib/filesystems/node-filesystem';
28
+ export { isFileProvider } from './lib/file-provider/file-provider';
29
+ export { FileHandle } from './lib/file-provider/file-handle';
30
+ export { FileHandleFile } from './lib/file-provider/file-handle-file';
31
+ export { DataViewFile } from './lib/file-provider/data-view-file';
27
32
  export { makeReadableFile } from './lib/filesystems/readable-file';
28
33
  export { makeWritableFile } from './lib/filesystems/writable-file';
29
- export { default as _NodeFileSystem } from './lib/filesystems/node-filesystem';
30
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["parseFromContext","parseSyncFromContext","parseInBatchesFromContext","assert","isBrowser","isWorker","nodeVersion","self","window","global","document","mergeLoaderOptions","createLoaderWorker","parseWithWorker","canParseWithWorker","canEncodeWithWorker","parseJSON","sliceArrayBuffer","concatenateArrayBuffers","concatenateTypedArrays","compareArrayBuffers","padToNBytes","copyToArray","copyArrayBuffer","padStringToByteAlignment","copyStringToDataView","copyBinaryToDataView","copyPaddedArrayBufferToDataView","copyPaddedStringToDataView","getFirstCharacters","getMagicString","makeTextEncoderIterator","makeTextDecoderIterator","makeLineIterator","makeNumberedLineIterator","forEach","concatenateArrayBuffersAsync","default","RequestScheduler","setPathPrefix","getPathPrefix","resolvePath","addAliases","_addAliases","JSONLoader","isBuffer","toBuffer","toArrayBuffer","promisify1","promisify2","path","fs","stream","makeReadableFile","makeWritableFile","_NodeFileSystem"],"sources":["../../src/index.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n// TYPES\n\nexport type {\n // misc\n DataType,\n SyncDataType,\n BatchableDataType,\n IFileSystem,\n IRandomAccessReadFileSystem,\n // numeric array types\n TypedArray,\n BigTypedArray,\n TypedArrayConstructor,\n BigTypedArrayConstructor,\n NumberArray,\n NumericArray,\n // fetch\n FetchLike\n} from './types';\n\n// loaders\n\nexport type {\n Loader,\n LoaderWithParser,\n LoaderContext,\n LoaderOptions,\n LoaderOptionsType,\n LoaderReturnType,\n LoaderBatchType\n} from './loader-types';\n\nexport {parseFromContext, parseSyncFromContext, parseInBatchesFromContext} from './loader-types';\n\n// writers\n\nexport type {Writer, WriterOptions, WriterOptionsType} from './writer-types';\n\n// GENERAL UTILS\nexport {assert} from './lib/env-utils/assert';\nexport {\n isBrowser,\n isWorker,\n nodeVersion,\n self,\n window,\n global,\n document\n} from './lib/env-utils/globals';\n\nexport {mergeLoaderOptions} from './lib/option-utils/merge-loader-options';\n\n// LOADERS.GL-SPECIFIC WORKER UTILS\nexport {createLoaderWorker} from './lib/worker-loader-utils/create-loader-worker';\nexport {parseWithWorker, canParseWithWorker} from './lib/worker-loader-utils/parse-with-worker';\nexport {canEncodeWithWorker} from './lib/worker-loader-utils/encode-with-worker';\n\n// PARSER UTILS\nexport {parseJSON} from './lib/parser-utils/parse-json';\n\n// MEMORY COPY UTILS\nexport {\n sliceArrayBuffer,\n concatenateArrayBuffers,\n concatenateTypedArrays,\n compareArrayBuffers\n} from './lib/binary-utils/array-buffer-utils';\nexport {padToNBytes, copyToArray, copyArrayBuffer} from './lib/binary-utils/memory-copy-utils';\nexport {\n padStringToByteAlignment,\n copyStringToDataView,\n copyBinaryToDataView,\n copyPaddedArrayBufferToDataView,\n copyPaddedStringToDataView\n} from './lib/binary-utils/dataview-copy-utils';\nexport {getFirstCharacters, getMagicString} from './lib/binary-utils/get-first-characters';\n\n// ITERATOR UTILS\nexport {\n makeTextEncoderIterator,\n makeTextDecoderIterator,\n makeLineIterator,\n makeNumberedLineIterator\n} from './lib/iterators/text-iterators';\nexport {forEach, concatenateArrayBuffersAsync} from './lib/iterators/async-iteration';\n\n// REQUEST UTILS\nexport {default as RequestScheduler} from './lib/request-utils/request-scheduler';\n\n// PATH HELPERS\nexport {setPathPrefix, getPathPrefix, resolvePath} from './lib/path-utils/file-aliases';\nexport {addAliases as _addAliases} from './lib/path-utils/file-aliases';\n\n// MICRO LOADERS\nexport {JSONLoader} from './json-loader';\n\n// NODE support\n\n// Node.js emulation (can be used in browser)\n\n// Avoid direct use of `Buffer` which pulls in 50KB polyfill\nexport {isBuffer, toBuffer, toArrayBuffer} from './lib/binary-utils/memory-conversion-utils';\n\n// Note.js wrappers (can be safely imported, but not used in browser)\n\n// Use instead of importing 'util' to avoid node dependencies\nexport {promisify1, promisify2} from './lib/node/promisify';\n\n// `path` replacement (avoids bundling big path polyfill)\nimport * as path from './lib/path-utils/path';\nexport {path};\n\n// Use instead of importing 'fs' to avoid node dependencies`\nimport * as fs from './lib/node/fs';\nexport {fs};\n\n// Use instead of importing 'stream' to avoid node dependencies`\nimport * as stream from './lib/node/stream';\nexport {stream};\n\n// EXPERIMENTAL\nexport type {ReadableFile} from './lib/filesystems/readable-file';\nexport {makeReadableFile} from './lib/filesystems/readable-file';\n\nexport type {WritableFile} from './lib/filesystems/writable-file';\nexport {makeWritableFile} from './lib/filesystems/writable-file';\n\nexport {default as _NodeFileSystem} from './lib/filesystems/node-filesystem';\n"],"mappings":"AAkCA,SAAQA,gBAAgB,EAAEC,oBAAoB,EAAEC,yBAAyB,QAAO,gBAAgB;AAOhG,S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MAAM;AAId,SAAQC,gBAAgB,QAAO,iCAAiC;AAGhE,SAAQC,gBAAgB,QAAO,iCAAiC;AAEhE,SAAQjB,OAAO,IAAIkB,eAAe,QAAO,mCAAmC"}
1
+ {"version":3,"file":"index.js","names":["parseFromContext","parseSyncFromContext","parseInBatchesFromContext","assert","isBrowser","isWorker","nodeVersion","self","window","global","document","mergeLoaderOptions","createLoaderWorker","parseWithWorker","canParseWithWorker","canEncodeWithWorker","parseJSON","sliceArrayBuffer","concatenateArrayBuffers","concatenateTypedArrays","compareArrayBuffers","padToNBytes","copyToArray","copyArrayBuffer","padStringToByteAlignment","copyStringToDataView","copyBinaryToDataView","copyPaddedArrayBufferToDataView","copyPaddedStringToDataView","getFirstCharacters","getMagicString","makeTextEncoderIterator","makeTextDecoderIterator","makeLineIterator","makeNumberedLineIterator","forEach","concatenateArrayBuffersAsync","default","RequestScheduler","setPathPrefix","getPathPrefix","resolvePath","addAliases","_addAliases","JSONLoader","isBuffer","toBuffer","toArrayBuffer","promisify1","promisify2","path","fs","stream","NodeFileSystem","_NodeFileSystem","isFileProvider","FileHandle","FileHandleFile","DataViewFile","makeReadableFile","makeWritableFile"],"sources":["../../src/index.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n// TYPES\n\nexport type {\n // misc\n DataType,\n SyncDataType,\n BatchableDataType,\n // numeric array types\n TypedArray,\n BigTypedArray,\n TypedArrayConstructor,\n BigTypedArrayConstructor,\n NumberArray,\n NumericArray,\n // fetch\n FetchLike\n} from './types';\n\n// loaders\n\nexport type {\n Loader,\n LoaderWithParser,\n LoaderContext,\n LoaderOptions,\n LoaderOptionsType,\n LoaderReturnType,\n LoaderBatchType\n} from './loader-types';\n\nexport {parseFromContext, parseSyncFromContext, parseInBatchesFromContext} from './loader-types';\n\n// writers\n\nexport type {Writer, WriterOptions, WriterOptionsType} from './writer-types';\n\n// GENERAL UTILS\nexport {assert} from './lib/env-utils/assert';\nexport {\n isBrowser,\n isWorker,\n nodeVersion,\n self,\n window,\n global,\n document\n} from './lib/env-utils/globals';\n\nexport {mergeLoaderOptions} from './lib/option-utils/merge-loader-options';\n\n// LOADERS.GL-SPECIFIC WORKER UTILS\nexport {createLoaderWorker} from './lib/worker-loader-utils/create-loader-worker';\nexport {parseWithWorker, canParseWithWorker} from './lib/worker-loader-utils/parse-with-worker';\nexport {canEncodeWithWorker} from './lib/worker-loader-utils/encode-with-worker';\n\n// PARSER UTILS\nexport {parseJSON} from './lib/parser-utils/parse-json';\n\n// MEMORY COPY UTILS\nexport {\n sliceArrayBuffer,\n concatenateArrayBuffers,\n concatenateTypedArrays,\n compareArrayBuffers\n} from './lib/binary-utils/array-buffer-utils';\nexport {padToNBytes, copyToArray, copyArrayBuffer} from './lib/binary-utils/memory-copy-utils';\nexport {\n padStringToByteAlignment,\n copyStringToDataView,\n copyBinaryToDataView,\n copyPaddedArrayBufferToDataView,\n copyPaddedStringToDataView\n} from './lib/binary-utils/dataview-copy-utils';\nexport {getFirstCharacters, getMagicString} from './lib/binary-utils/get-first-characters';\n\n// ITERATOR UTILS\nexport {\n makeTextEncoderIterator,\n makeTextDecoderIterator,\n makeLineIterator,\n makeNumberedLineIterator\n} from './lib/iterators/text-iterators';\nexport {forEach, concatenateArrayBuffersAsync} from './lib/iterators/async-iteration';\n\n// REQUEST UTILS\nexport {default as RequestScheduler} from './lib/request-utils/request-scheduler';\n\n// PATH HELPERS\nexport {setPathPrefix, getPathPrefix, resolvePath} from './lib/path-utils/file-aliases';\nexport {addAliases as _addAliases} from './lib/path-utils/file-aliases';\n\n// MICRO LOADERS\nexport {JSONLoader} from './json-loader';\n\n// NODE support\n\n// Node.js emulation (can be used in browser)\n\n// Avoid direct use of `Buffer` which pulls in 50KB polyfill\nexport {isBuffer, toBuffer, toArrayBuffer} from './lib/binary-utils/memory-conversion-utils';\n\n// Note.js wrappers (can be safely imported, but not used in browser)\n\n// Use instead of importing 'util' to avoid node dependencies\nexport {promisify1, promisify2} from './lib/node/promisify';\n\n// `path` replacement (avoids bundling big path polyfill)\nimport * as path from './lib/path-utils/path';\nexport {path};\n\n// Use instead of importing 'fs' to avoid node dependencies`\nimport * as fs from './lib/node/fs';\nexport {fs};\n\n// Use instead of importing 'stream' to avoid node dependencies`\nimport * as stream from './lib/node/stream';\nexport {stream};\n\n// EXPERIMENTAL\nexport type {FileSystem, RandomAccessReadFileSystem} from './lib/filesystems/filesystem';\nexport {NodeFileSystem as _NodeFileSystem} from './lib/filesystems/node-filesystem';\n\nexport type {FileProvider} from './lib/file-provider/file-provider';\nexport {isFileProvider} from './lib/file-provider/file-provider';\n\nexport {FileHandle} from './lib/file-provider/file-handle';\nexport {FileHandleFile} from './lib/file-provider/file-handle-file';\nexport {DataViewFile} from './lib/file-provider/data-view-file';\n\nexport type {ReadableFile} from './lib/filesystems/readable-file';\nexport {makeReadableFile} from './lib/filesystems/readable-file';\n\nexport type {WritableFile} from './lib/filesystems/writable-file';\nexport {makeWritableFile} from './lib/filesystems/writable-file';\n"],"mappings":"AAgCA,SAAQA,gBAAgB,EAAEC,oBAAoB,EAAEC,yBAAyB,QAAO,gBAAgB;AAOhG,SAAQC,MAAM,QAAO,wBAAwB;AAC7C,SACEC,SAAS,EACTC,QAAQ,EACRC,WAAW,EACXC,IAAI,EACJC,MAAM,EACNC,MAAM,EACNC,QAAQ,QACH,yBAAyB;AAEhC,SAAQC,kBAAkB,QAAO,yCAAyC;AAG1E,SAAQC,kBAAkB,QAAO,gDAAgD;AACjF,SAAQC,eAAe,EAAEC,kBAAkB,QAAO,6CAA6C;AAC/F,SAAQC,mBAAmB,QAAO,8CAA8C;AAGhF,SAAQC,SAAS,QAAO,+BAA+B;AAGvD,SACEC,gBAAgB,EAChBC,uBAAuB,EACvBC,sBAAsB,EACtBC,mBAAmB,QACd,uCAAuC;AAC9C,SAAQC,WAAW,EAAEC,WAAW,EAAEC,eAAe,QAAO,sCAAsC;AAC9F,SACEC,wBAAwB,EACxBC,oBAAoB,EACpBC,oBAAoB,EACpBC,+BAA+B,EAC/BC,0BAA0B,QACrB,wCAAwC;AAC/C,SAAQC,kBAAkB,EAAEC,cAAc,QAAO,yCAAyC;AAG1F,SACEC,uBAAuB,EACvBC,uBAAuB,EACvBC,gBAAgB,EAChBC,wBAAwB,QACnB,gCAAgC;AACvC,SAAQC,OAAO,EAAEC,4BAA4B,QAAO,iCAAiC;AAGrF,SAAQC,OAAO,IAAIC,gBAAgB,QAAO,uCAAuC;AAGjF,SAAQC,aAAa,EAAEC,aAAa,EAAEC,WAAW,QAAO,+BAA+B;AACvF,SAAQC,UAAU,IAAIC,WAAW,QAAO,+BAA+B;AAGvE,SAAQC,UAAU,QAAO,eAAe;AAOxC,SAAQC,QAAQ,EAAEC,QAAQ,EAAEC,aAAa,QAAO,4CAA4C;AAK5F,SAAQC,UAAU,EAAEC,UAAU,QAAO,sBAAsB;AAG3D,OAAO,KAAKC,IAAI,MAAM,uBAAuB;AAC7C,SAAQA,IAAI;AAGZ,OAAO,KAAKC,EAAE,MAAM,eAAe;AACnC,SAAQA,EAAE;AAGV,OAAO,KAAKC,MAAM,MAAM,mBAAmB;AAC3C,SAAQA,MAAM;AAId,SAAQC,cAAc,IAAIC,eAAe,QAAO,mCAAmC;AAGnF,SAAQC,cAAc,QAAO,mCAAmC;AAEhE,SAAQC,UAAU,QAAO,iCAAiC;AAC1D,SAAQC,cAAc,QAAO,sCAAsC;AACnE,SAAQC,YAAY,QAAO,oCAAoC;AAG/D,SAAQC,gBAAgB,QAAO,iCAAiC;AAGhE,SAAQC,gBAAgB,QAAO,iCAAiC"}
@@ -1,4 +1,4 @@
1
- const VERSION = typeof "4.0.0-alpha.22" !== 'undefined' ? "4.0.0-alpha.22" : 'latest';
1
+ const VERSION = typeof "4.0.0-alpha.23" !== 'undefined' ? "4.0.0-alpha.23" : 'latest';
2
2
  export const JSONLoader = {
3
3
  name: 'JSON',
4
4
  id: 'json',
@@ -0,0 +1,33 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ const toNumber = bigint => {
3
+ if (bigint > Number.MAX_SAFE_INTEGER) {
4
+ throw new Error('Offset is out of bounds');
5
+ }
6
+ return Number(bigint);
7
+ };
8
+ export class DataViewFile {
9
+ constructor(file) {
10
+ _defineProperty(this, "file", void 0);
11
+ this.file = file;
12
+ }
13
+ async destroy() {}
14
+ async getUint8(offset) {
15
+ return this.file.getUint8(toNumber(offset));
16
+ }
17
+ async getUint16(offset) {
18
+ return this.file.getUint16(toNumber(offset), true);
19
+ }
20
+ async getUint32(offset) {
21
+ return this.file.getUint32(toNumber(offset), true);
22
+ }
23
+ async getBigUint64(offset) {
24
+ return this.file.getBigUint64(toNumber(offset), true);
25
+ }
26
+ async slice(startOffset, endOffset) {
27
+ return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));
28
+ }
29
+ get length() {
30
+ return BigInt(this.file.byteLength);
31
+ }
32
+ }
33
+ //# sourceMappingURL=data-view-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-view-file.js","names":["toNumber","bigint","Number","MAX_SAFE_INTEGER","Error","DataViewFile","constructor","file","_defineProperty","destroy","getUint8","offset","getUint16","getUint32","getBigUint64","slice","startOffset","endOffset","buffer","length","BigInt","byteLength"],"sources":["../../../../src/lib/file-provider/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 // eslint-disable-next-line @typescript-eslint/no-empty-function\n async destroy(): Promise<void> {}\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;EAGA,MAAME,OAAOA,CAAA,EAAkB,CAAC;EAMhC,MAAMC,QAAQA,CAACC,MAAc,EAAmB;IAC9C,OAAO,IAAI,CAACJ,IAAI,CAACG,QAAQ,CAACV,QAAQ,CAACW,MAAM,CAAC,CAAC;EAC7C;EAMA,MAAMC,SAASA,CAACD,MAAc,EAAmB;IAC/C,OAAO,IAAI,CAACJ,IAAI,CAACK,SAAS,CAACZ,QAAQ,CAACW,MAAM,CAAC,EAAE,IAAI,CAAC;EACpD;EAMA,MAAME,SAASA,CAACF,MAAc,EAAmB;IAC/C,OAAO,IAAI,CAACJ,IAAI,CAACM,SAAS,CAACb,QAAQ,CAACW,MAAM,CAAC,EAAE,IAAI,CAAC;EACpD;EAMA,MAAMG,YAAYA,CAACH,MAAc,EAAmB;IAClD,OAAO,IAAI,CAACJ,IAAI,CAACO,YAAY,CAACd,QAAQ,CAACW,MAAM,CAAC,EAAE,IAAI,CAAC;EACvD;EAOA,MAAMI,KAAKA,CAACC,WAAmB,EAAEC,SAAiB,EAAwB;IACxE,OAAO,IAAI,CAACV,IAAI,CAACW,MAAM,CAACH,KAAK,CAACf,QAAQ,CAACgB,WAAW,CAAC,EAAEhB,QAAQ,CAACiB,SAAS,CAAC,CAAC;EAC3E;EAGA,IAAIE,MAAMA,CAAA,EAAG;IACX,OAAOC,MAAM,CAAC,IAAI,CAACb,IAAI,CAACc,UAAU,CAAC;EACrC;AACF"}
@@ -0,0 +1,59 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import { FileHandle } from './file-handle';
3
+ import { resolvePath } from '../path-utils/file-aliases';
4
+ export class FileHandleFile {
5
+ static async from(path) {
6
+ path = resolvePath(path);
7
+ const fileDescriptor = await FileHandle.open(path);
8
+ return new FileHandleFile(fileDescriptor, fileDescriptor.stat.size);
9
+ }
10
+ constructor(fileDescriptor, size) {
11
+ _defineProperty(this, "fileDescriptor", void 0);
12
+ _defineProperty(this, "size", void 0);
13
+ this.fileDescriptor = fileDescriptor;
14
+ this.size = size;
15
+ }
16
+ async destroy() {
17
+ await this.fileDescriptor.close();
18
+ }
19
+ async getUint8(offset) {
20
+ const val = new Uint8Array((await this.fileDescriptor.read(Buffer.alloc(1), 0, 1, offset)).buffer.buffer).at(0);
21
+ if (val === undefined) {
22
+ throw new Error('something went wrong');
23
+ }
24
+ return val;
25
+ }
26
+ async getUint16(offset) {
27
+ const val = new Uint16Array((await this.fileDescriptor.read(Buffer.alloc(2), 0, 2, offset)).buffer.buffer).at(0);
28
+ if (val === undefined) {
29
+ throw new Error('something went wrong');
30
+ }
31
+ return val;
32
+ }
33
+ async getUint32(offset) {
34
+ const val = new Uint32Array((await this.fileDescriptor.read(Buffer.alloc(4), 0, 4, offset)).buffer.buffer).at(0);
35
+ if (val === undefined) {
36
+ throw new Error('something went wrong');
37
+ }
38
+ return val;
39
+ }
40
+ async getBigUint64(offset) {
41
+ const val = new BigInt64Array((await this.fileDescriptor.read(Buffer.alloc(8), 0, 8, offset)).buffer.buffer).at(0);
42
+ if (val === undefined) {
43
+ throw new Error('something went wrong');
44
+ }
45
+ return val;
46
+ }
47
+ async slice(startOffsset, endOffset) {
48
+ const bigLength = endOffset - startOffsset;
49
+ if (bigLength > Number.MAX_SAFE_INTEGER) {
50
+ throw new Error('too big slice');
51
+ }
52
+ const length = Number(bigLength);
53
+ return (await this.fileDescriptor.read(Buffer.alloc(length), 0, length, startOffsset)).buffer.buffer;
54
+ }
55
+ get length() {
56
+ return this.size;
57
+ }
58
+ }
59
+ //# sourceMappingURL=file-handle-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-handle-file.js","names":["FileHandle","resolvePath","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/lib/file-provider/file-handle-file.ts"],"sourcesContent":["import {FileProvider} from './file-provider';\nimport {FileHandle} from './file-handle';\nimport {resolvePath} from '../path-utils/file-aliases';\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 path = resolvePath(path);\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":";AACA,SAAQA,UAAU,QAAO,eAAe;AACxC,SAAQC,WAAW,QAAO,4BAA4B;AAKtD,OAAO,MAAMC,cAAc,CAAyB;EAKlD,aAAaC,IAAIA,CAACC,IAAY,EAA2B;IACvDA,IAAI,GAAGH,WAAW,CAACG,IAAI,CAAC;IACxB,MAAMC,cAAc,GAAG,MAAML,UAAU,CAACM,IAAI,CAACF,IAAI,CAAC;IAClD,OAAO,IAAIF,cAAc,CAACG,cAAc,EAAEA,cAAc,CAACE,IAAI,CAACC,IAAI,CAAC;EACrE;EAYQC,WAAWA,CAACJ,cAA0B,EAAEG,IAAY,EAAE;IAAAE,eAAA;IAAAA,eAAA;IAC5D,IAAI,CAACL,cAAc,GAAGA,cAAc;IACpC,IAAI,CAACG,IAAI,GAAGA,IAAI;EAClB;EAGA,MAAMG,OAAOA,CAAA,EAAkB;IAC7B,MAAM,IAAI,CAACN,cAAc,CAACO,KAAK,CAAC,CAAC;EACnC;EAMA,MAAMC,QAAQA,CAACC,MAAc,EAAmB;IAC9C,MAAMC,GAAG,GAAG,IAAIC,UAAU,CACxB,CAAC,MAAM,IAAI,CAACX,cAAc,CAACY,IAAI,CAACC,MA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AM,CAAC,EAAEM,MAAM,CAACA,MACzE,CAAC,CAACC,EAAE,CAAC,CAAC,CAAC;IACP,IAAIN,GAAG,KAAKO,SAAS,EAAE;MACrB,MAAM,IAAIC,KAAK,CAAC,sBAAsB,CAAC;IACzC;IACA,OAAOR,GAAG;EACZ;EAOA,MAAMe,KAAKA,CAACC,YAAoB,EAAEC,SAAiB,EAAwB;IACzE,MAAMC,SAAS,GAAGD,SAAS,GAAGD,YAAY;IAC1C,IAAIE,SAAS,GAAGC,MAAM,CAACC,gBAAgB,EAAE;MACvC,MAAM,IAAIZ,KAAK,CAAC,eAAe,CAAC;IAClC;IACA,MAAMa,MAAM,GAAGF,MAAM,CAACD,SAAS,CAAC;IAChC,OAAO,CAAC,MAAM,IAAI,CAAC5B,cAAc,CAACY,IAAI,CAACC,MAAM,CAACC,KAAK,CAACiB,MAAM,CAAC,EAAE,CAAC,EAAEA,MAAM,EAAEL,YAAY,CAAC,EAAEX,MAAM,CAC1FA,MAAM;EACX;EAKA,IAAIgB,MAAMA,CAAA,EAAW;IACnB,OAAO,IAAI,CAAC5B,IAAI;EAClB;AACF"}
@@ -0,0 +1,37 @@
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
+ static async open(path) {
19
+ const [fd, stats] = await Promise.all([new Promise((resolve, reject) => {
20
+ open(path, undefined, undefined, (_err, fd) => _err ? reject(_err) : resolve(fd));
21
+ }), new Promise((resolve, reject) => {
22
+ stat(path, {
23
+ bigint: true
24
+ }, (_err, stats) => _err ? reject(_err) : resolve(stats));
25
+ })]);
26
+ return new FileHandle(fd, stats);
27
+ }
28
+ async close() {
29
+ return new Promise(resolve => {
30
+ close(this.fileDescriptor, _err => resolve());
31
+ });
32
+ }
33
+ get stat() {
34
+ return this.stats;
35
+ }
36
+ }
37
+ //# sourceMappingURL=file-handle.js.map
@@ -0,0 +1 @@
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","path","fd","all","resolve","reject","undefined","bigint"],"sources":["../../../../src/lib/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\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 async open(path: string): Promise<FileHandle> {\n const [fd, stats] = await Promise.all([\n new Promise<number>((resolve, reject) => {\n open(path, undefined, undefined, (_err, fd) => (_err ? reject(_err) : resolve(fd)));\n }),\n new Promise<BigIntStats>((resolve, reject) => {\n stat(path, {bigint: true}, (_err, stats) => (_err ? reject(_err) : resolve(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;EAIdC,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;EAQA,aAAaN,IAAIA,CAACgB,IAAY,EAAuB;IACnD,MAAM,CAACC,EAAE,EAAEX,KAAK,CAAC,GAAG,MAAMM,OAAO,CAACM,GAAG,CAAC,CACpC,IAAIN,OAAO,CAAS,CAACO,OAAO,EAAEC,MAAM,KAAK;MACvCpB,IAAI,CAACgB,IAAI,EAAEK,SAAS,EAAEA,SAAS,EAAE,CAACP,IAAI,EAAEG,EAAE,KAAMH,IAAI,GAAGM,MAAM,CAACN,IAAI,CAAC,GAAGK,OAAO,CAACF,EAAE,CAAE,CAAC;IACrF,CAAC,CAAC,EACF,IAAIL,OAAO,CAAc,CAACO,OAAO,EAAEC,MAAM,KAAK;MAC5ClB,IAAI,CAACc,IAAI,EAAE;QAACM,MAAM,EAAE;MAAI,CAAC,EAAE,CAACR,IAAI,EAAER,KAAK,KAAMQ,IAAI,GAAGM,MAAM,CAACN,IAAI,CAAC,GAAGK,OAAO,CAACb,KAAK,CAAE,CAAC;IACrF,CAAC,CAAC,CACH,CAAC;IACF,OAAO,IAAIH,UAAU,CAACc,EAAE,EAAEX,KAAK,CAAC;EAClC;EAGA,MAAML,KAAKA,CAAA,EAAkB;IAC3B,OAAO,IAAIW,OAAO,CAAQO,OAAO,IAAK;MACpClB,KAAK,CAAC,IAAI,CAACI,cAAc,EAAGS,IAAI,IAAKK,OAAO,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC;EACJ;EA2BA,IAAIjB,IAAIA,CAAA,EAAgB;IACtB,OAAO,IAAI,CAACI,KAAK;EACnB;AACF"}
@@ -0,0 +1,4 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-provider.js","names":["isFileProvider","fileProvider","getUint8","slice","length"],"sources":["../../../../src/lib/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"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=filesystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem.js","names":[],"sources":["../../../../src/lib/filesystems/filesystem.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nexport type ReadOptions = {};\n\nexport type Stat = {\n size: number;\n isDirectory: () => boolean;\n};\n\n/**\n * A FileSystem interface can encapsulate various file sources,\n * a FileList, a ZipFile, a GoogleDrive etc.\n */\nexport interface FileSystem {\n /**\n * Return a list of file names\n * @param dirname directory name. file system root directory if omitted\n */\n readdir(dirname?: string, options?: {recursive?: boolean}): Promise<string[]>;\n\n /**\n * Gets information from a local file from the filesystem\n * @param filename file name to stat\n * @param options currently unused\n * @throws if filename is not in local filesystem\n */\n stat(filename: string, options?: object): Promise<{size: number}>;\n\n /**\n * Fetches a local file from the filesystem (or a URL)\n * @param filename\n * @param options\n */\n fetch(filename: RequestInfo, options?: RequestInit): Promise<Response>;\n}\n\n/**\n * A random access file system\n */\nexport interface RandomAccessReadFileSystem extends FileSystem {\n open(path: string, flags: unknown, mode?: unknown): Promise<any>;\n close(fd: unknown): Promise<void>;\n fstat(fd: unknown): Promise<Stat>;\n read(fd: any, options?: ReadOptions): Promise<{bytesRead: number; buffer: Buffer}>;\n // read(\n // fd: any,\n // buffer: ArrayBuffer | ArrayBufferView,\n // offset?: number,\n // length?: number,\n // position?: number\n // ): Promise<{bytesRead: number; buffer: ArrayBuffer}>;\n}\n\n/**\n * A FileSystem interface can encapsulate a FileList, a ZipFile, a GoogleDrive etc.\n *\nexport interface IFileSystem {\n /**\n * Return a list of file names\n * @param dirname directory name. file system root directory if omitted\n *\n readdir(dirname?: string, options?: {recursive?: boolean}): Promise<string[]>;\n\n /**\n * Gets information from a local file from the filesystem\n * @param filename file name to stat\n * @param options currently unused\n * @throws if filename is not in local filesystem\n *\n stat(filename: string, options?: object): Promise<{size: number}>;\n\n /**\n * Fetches a local file from the filesystem (or a URL)\n * @param filename\n * @param options\n *\n fetch(filename: string, options?: object): Promise<Response>;\n}\n\ntype ReadOptions = {buffer?: ArrayBuffer; offset?: number; length?: number; position?: number};\nexport interface IRandomAccessReadFileSystem extends IFileSystem {\n open(path: string, flags: string | number, mode?: any): Promise<any>;\n close(fd: any): Promise<void>;\n fstat(fd: any): Promise<object>;\n read(fd: any, options?: ReadOptions): Promise<{bytesRead: number; buffer: Buffer}>;\n}\n*/\n"],"mappings":""}
@@ -1,5 +1,5 @@
1
1
  import * as fs from '../node/fs';
2
- export default class NodeFileSystem {
2
+ export class NodeFileSystem {
3
3
  constructor(options) {
4
4
  this.fetch = options._fetch;
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"node-filesystem.js","names":["fs","NodeFileSystem","constructor","options","fetch","_fetch","readdir","dirname","arguments","length","undefined","stat","path","info","size","Number","isDirectory","fallbackFetch","open","flags","mode","close","fd","fstat","read","_ref","buffer","offset","byteLength","position","totalBytesRead","bytesRead"],"sources":["../../../../src/lib/filesystems/node-filesystem.ts"],"sourcesContent":["import * as fs from '../node/fs';\nimport {IFileSystem, IRandomAccessReadFileSystem} from '../../types';\n// import {fetchFile} from \"../fetch/fetch-file\"\n// import {selectLoader} from \"../api/select-loader\";\n\ntype Stat = {\n size: number;\n isDirectory: () => boolean;\n info?: fs.Stats;\n};\n\ntype ReadOptions = {\n buffer?: Buffer;\n offset?: number;\n length?: number;\n position?: number;\n};\n\n/**\n * FileSystem pass-through for Node.js\n * Compatible with BrowserFileSystem.\n * @param options\n */\nexport default class NodeFileSystem implements IFileSystem, IRandomAccessReadFileSystem {\n // implements IFileSystem\n constructor(options: {[key: string]: any}) {\n this.fetch = options._fetch;\n }\n\n async readdir(dirname = '.', options?: {}): Promise<any[]> {\n return await fs.readdir(dirname, options);\n }\n\n async stat(path: string, options?: {}): Promise<Stat> {\n const info = await fs.stat(path, options);\n return {size: Number(info.size), isDirectory: () => false, info};\n }\n\n async fetch(path: string, options: {[key: string]: any}) {\n // Falls back to handle https:/http:/data: etc fetches\n // eslint-disable-next-line\n const fallbackFetch = options.fetch || this.fetch;\n return fallbackFetch(path, options);\n }\n\n // implements IRandomAccessFileSystem\n async open(path: string, flags: string | number, mode?: any): Promise<number> {\n return await fs.open(path, flags);\n }\n\n async close(fd: number): Promise<void> {\n return await fs.close(fd);\n }\n\n async fstat(fd: number): Promise<Stat> {\n const info = await fs.fstat(fd);\n return info;\n }\n\n async read(\n fd: number,\n // @ts-ignore Possibly null\n {buffer = null, offset = 0, length = buffer.byteLength, position = null}: ReadOptions\n ): Promise<{bytesRead: number; buffer: Buffer}> {\n let totalBytesRead = 0;\n // Read in loop until we get required number of bytes\n while (totalBytesRead < length) {\n const {bytesRead} = await fs.read(\n fd,\n buffer,\n offset + totalBytesRead,\n length - totalBytesRead,\n position + totalBytesRead\n );\n totalBytesRead += bytesRead;\n }\n return {bytesRead: totalBytesRead, buffer};\n }\n}\n"],"mappings":"AAAA,OAAO,KAAKA,EAAE,MAAM,YAAY;AAuBhC,eAAe,MAAMC,cAAc,CAAqD;EAEtFC,WAAWA,CAACC,OAA6B,EAAE;IACzC,IAAI,CAACC,KAAK,GAAGD,OAAO,CAACE,MAAM;EAC7B;EAEA,MAAMC,OAAOA,CAAA,EAA8C;IAAA,IAA7CC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,GAAG;IAAA,IAAEL,OAAY,GAAAK,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IACvC,OAAO,MAAMV,EAAE,CAACM,OAAO,CAACC,OAAO,EAAEJ,OAAO,CAAC;EAC3C;EAEA,MAAMQ,IAAIA,CAACC,IAAY,EAAET,OAAY,EAAiB;IACpD,MAAMU,IAAI,GAAG,MAAMb,EAAE,CAACW,IAAI,CAACC,IAAI,EAAET,OAAO,CAAC;IACzC,OAAO;MAACW,IAAI,EAAEC,MAAM,CAACF,IAAI,CAACC,IAAI,CAAC;MAAEE,WAAW,EAAEA,CAAA,KAAM,KAAK;MAAEH;IAAI,CAAC;EAClE;EAEA,MAAMT,KAAKA,CAACQ,IAAY,EAAET,OAA6B,EAAE;IAGvD,MAAMc,aAAa,GAAGd,OAAO,CAACC,KAAK,IAAI,IAAI,CAACA,KAAK;IACjD,OAAOa,aAAa,CAACL,IAAI,EAAET,OAAO,CAAC;EACrC;EAGA,MAAMe,IAAIA,CAACN,IAAY,EAAEO,KAAsB,EAAEC,IAAU,EAAmB;IAC5E,OAAO,MAAMpB,EAAE,CAACkB,IAAI,CAACN,IAAI,EAAEO,KAAK,CAAC;EACnC;EAEA,MAAME,KAAKA,CAACC,EAAU,EAAiB;IACrC,OAAO,MAAMtB,EAAE,CAACqB,KAAK,CAACC,EAAE,CAAC;EAC3B;EAEA,MAAMC,KAAKA,CAACD,EAAU,EAAiB;IACrC,MAAMT,IAAI,GAAG,MAAMb,EAAE,CAACuB,KAAK,CAACD,EAAE,CAAC;IAC/B,OAAOT,IAAI;EACb;EAEA,MAAMW,IAAIA,CACRF,EAAU,EAAAG,IAAA,EAGoC;IAAA,IAD9C;MAACC,MAAM,GAAG,IAAI;MAAEC,MAAM,GAAG,CAAC;MAAElB,MAAM,GAAGiB,MAAM,CAACE,UAAU;MAAEC,QAAQ,GAAG;IAAiB,CAAC,GAAAJ,IAAA;IAErF,IAAIK,cAAc,GAAG,CAAC;IAEtB,OAAOA,cAAc,GAAGrB,MAAM,EAAE;MAC9B,MAAM;QAACsB;MAAS,CAAC,GAAG,MAAM/B,EAAE,CAACwB,IAAI,CAC/BF,EAAE,EACFI,MAAM,EACNC,MAAM,GAAGG,cAAc,EACvBrB,MAAM,GAAGqB,cAAc,EACvBD,QAAQ,GAAGC,cACb,CAAC;MACDA,cAAc,IAAIC,SAAS;IAC7B;IACA,OAAO;MAACA,SAAS,EAAED,cAAc;MAAEJ;IAAM,CAAC;EAC5C;AACF"}
1
+ {"version":3,"file":"node-filesystem.js","names":["fs","NodeFileSystem","constructor","options","fetch","_fetch","readdir","dirname","arguments","length","undefined","stat","path","info","size","Number","isDirectory","fallbackFetch","open","flags","mode","close","fd","fstat","read","_ref","buffer","offset","byteLength","position","totalBytesRead","bytesRead"],"sources":["../../../../src/lib/filesystems/node-filesystem.ts"],"sourcesContent":["import * as fs from '../node/fs';\nimport {FileSystem, RandomAccessReadFileSystem} from './filesystem';\n// import {fetchFile} from \"../fetch/fetch-file\"\n// import {selectLoader} from \"../api/select-loader\";\n\ntype Stat = {\n size: number;\n isDirectory: () => boolean;\n info?: fs.Stats;\n};\n\ntype ReadOptions = {\n buffer?: Buffer;\n offset?: number;\n length?: number;\n position?: number;\n};\n\n/**\n * FileSystem pass-through for Node.js\n * Compatible with BrowserFileSystem.\n * @param options\n */\nexport class NodeFileSystem implements FileSystem, RandomAccessReadFileSystem {\n // implements FileSystem\n constructor(options: {[key: string]: any}) {\n this.fetch = options._fetch;\n }\n\n async readdir(dirname = '.', options?: {}): Promise<any[]> {\n return await fs.readdir(dirname, options);\n }\n\n async stat(path: string, options?: {}): Promise<Stat> {\n const info = await fs.stat(path, options);\n return {size: Number(info.size), isDirectory: () => false, info};\n }\n\n async fetch(path: string, options: {[key: string]: any}) {\n // Falls back to handle https:/http:/data: etc fetches\n // eslint-disable-next-line\n const fallbackFetch = options.fetch || this.fetch;\n return fallbackFetch(path, options);\n }\n\n // implements IRandomAccessFileSystem\n async open(path: string, flags: string | number, mode?: any): Promise<number> {\n return await fs.open(path, flags);\n }\n\n async close(fd: number): Promise<void> {\n return await fs.close(fd);\n }\n\n async fstat(fd: number): Promise<Stat> {\n const info = await fs.fstat(fd);\n return info;\n }\n\n async read(\n fd: number,\n // @ts-ignore Possibly null\n {buffer = null, offset = 0, length = buffer.byteLength, position = null}: ReadOptions\n ): Promise<{bytesRead: number; buffer: Buffer}> {\n let totalBytesRead = 0;\n // Read in loop until we get required number of bytes\n while (totalBytesRead < length) {\n const {bytesRead} = await fs.read(\n fd,\n buffer,\n offset + totalBytesRead,\n length - totalBytesRead,\n position + totalBytesRead\n );\n totalBytesRead += bytesRead;\n }\n return {bytesRead: totalBytesRead, buffer};\n }\n}\n"],"mappings":"AAAA,OAAO,KAAKA,EAAE,MAAM,YAAY;AAuBhC,OAAO,MAAMC,cAAc,CAAmD;EAE5EC,WAAWA,CAACC,OAA6B,EAAE;IACzC,IAAI,CAACC,KAAK,GAAGD,OAAO,CAACE,MAAM;EAC7B;EAEA,MAAMC,OAAOA,CAAA,EAA8C;IAAA,IAA7CC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD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AAIK,cAAc,GAAG,CAAC;IAEtB,OAAOA,cAAc,GAAGrB,MAAM,EAAE;MAC9B,MAAM;QAACsB;MAAS,CAAC,GAAG,MAAM/B,EAAE,CAACwB,IAAI,CAC/BF,EAAE,EACFI,MAAM,EACNC,MAAM,GAAGG,cAAc,EACvBrB,MAAM,GAAGqB,cAAc,EACvBD,QAAQ,GAAGC,cACb,CAAC;MACDA,cAAc,IAAIC,SAAS;IAC7B;IACA,OAAO;MAACA,SAAS,EAAED,cAAc;MAAEJ;IAAM,CAAC;EAC5C;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/types.ts"],"sourcesContent":["// Typed arrays\n\nexport type TypedIntArray =\n | Int8Array\n | Uint8Array\n | Uint8ClampedArray\n | Int16Array\n | Uint16Array\n | Int32Array\n | Uint32Array\n | Int32Array\n | Uint32Array;\n\nexport type TypedFloatArray = Uint16Array | Float32Array | Float64Array;\n\nexport type TypedArray = TypedIntArray | TypedFloatArray;\n\nexport type BigTypedArray = TypedArray | BigInt64Array | BigUint64Array;\n\nexport type TypedArrayConstructor =\n | Int8ArrayConstructor\n | Uint8ArrayConstructor\n | Int16ArrayConstructor\n | Uint16ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Float32ArrayConstructor\n | Float64ArrayConstructor;\n\nexport type BigTypedArrayConstructor =\n | TypedArrayConstructor\n | BigInt64ArrayConstructor\n | BigUint64ArrayConstructor;\n\n/** Any numeric array: typed array or `number[]` */\nexport type NumberArray = number[] | TypedArray;\n\nexport type NumericArray = number[] | TypedArray;\n\n// FETCH\n\nexport type FetchLike = (url: string, options?: RequestInit) => Promise<Response>;\n\n// MISC TYPES\n\nexport type TransformBatches = (\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>\n) => AsyncIterable<ArrayBuffer>;\n\n/** Types that can be synchronously parsed */\nexport type SyncDataType = string | ArrayBuffer; // TODO File | Blob can be read synchronously...\n\n/** Types that can be parsed async */\nexport type DataType =\n | string\n | ArrayBuffer\n | File\n | Blob\n | Response\n | ReadableStream\n | Iterable<ArrayBuffer>\n | AsyncIterable<ArrayBuffer>;\n\n/** Types that can be parsed in batches */\nexport type BatchableDataType =\n | DataType\n | Iterable<ArrayBuffer>\n | AsyncIterable<ArrayBuffer>\n | Promise<AsyncIterable<ArrayBuffer>>;\n\n/**\n * A FileSystem interface can encapsulate a FileList, a ZipFile, a GoogleDrive etc.\n */\nexport interface IFileSystem {\n /**\n * Return a list of file names\n * @param dirname directory name. file system root directory if omitted\n */\n readdir(dirname?: string, options?: {recursive?: boolean}): Promise<string[]>;\n\n /**\n * Gets information from a local file from the filesystem\n * @param filename file name to stat\n * @param options currently unused\n * @throws if filename is not in local filesystem\n */\n stat(filename: string, options?: object): Promise<{size: number}>;\n\n /**\n * Fetches a local file from the filesystem (or a URL)\n * @param filename\n * @param options\n */\n fetch(filename: string, options?: object): Promise<Response>;\n}\n\ntype ReadOptions = {buffer?: ArrayBuffer; offset?: number; length?: number; position?: number};\nexport interface IRandomAccessReadFileSystem extends IFileSystem {\n open(path: string, flags: string | number, mode?: any): Promise<any>;\n close(fd: any): Promise<void>;\n fstat(fd: any): Promise<object>;\n read(fd: any, options?: ReadOptions): Promise<{bytesRead: number; buffer: Buffer}>;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/types.ts"],"sourcesContent":["// Typed arrays\n\nexport type TypedIntArray =\n | Int8Array\n | Uint8Array\n | Uint8ClampedArray\n | Int16Array\n | Uint16Array\n | Int32Array\n | Uint32Array\n | Int32Array\n | Uint32Array;\n\nexport type TypedFloatArray = Uint16Array | Float32Array | Float64Array;\n\nexport type TypedArray = TypedIntArray | TypedFloatArray;\n\nexport type BigTypedArray = TypedArray | BigInt64Array | BigUint64Array;\n\nexport type TypedArrayConstructor =\n | Int8ArrayConstructor\n | Uint8ArrayConstructor\n | Int16ArrayConstructor\n | Uint16ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Float32ArrayConstructor\n | Float64ArrayConstructor;\n\nexport type BigTypedArrayConstructor =\n | TypedArrayConstructor\n | BigInt64ArrayConstructor\n | BigUint64ArrayConstructor;\n\n/** Any numeric array: typed array or `number[]` */\nexport type NumberArray = number[] | TypedArray;\n\nexport type NumericArray = number[] | TypedArray;\n\n// FETCH\n\nexport type FetchLike = (url: string, options?: RequestInit) => Promise<Response>;\n\n// MISC TYPES\n\nexport type TransformBatches = (\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>\n) => AsyncIterable<ArrayBuffer>;\n\n/** Types that can be synchronously parsed */\nexport type SyncDataType = string | ArrayBuffer; // TODO File | Blob can be read synchronously...\n\n/** Types that can be parsed async */\nexport type DataType =\n | string\n | ArrayBuffer\n | File\n | Blob\n | Response\n | ReadableStream\n | Iterable<ArrayBuffer>\n | AsyncIterable<ArrayBuffer>;\n\n/** Types that can be parsed in batches */\nexport type BatchableDataType =\n | DataType\n | Iterable<ArrayBuffer>\n | AsyncIterable<ArrayBuffer>\n | Promise<AsyncIterable<ArrayBuffer>>;\n"],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { DataType, SyncDataType, BatchableDataType, IFileSystem, IRandomAccessReadFileSystem, TypedArray, BigTypedArray, TypedArrayConstructor, BigTypedArrayConstructor, NumberArray, NumericArray, FetchLike } from './types';
1
+ export type { DataType, SyncDataType, BatchableDataType, TypedArray, BigTypedArray, TypedArrayConstructor, BigTypedArrayConstructor, NumberArray, NumericArray, FetchLike } from './types';
2
2
  export type { Loader, LoaderWithParser, LoaderContext, LoaderOptions, LoaderOptionsType, LoaderReturnType, LoaderBatchType } from './loader-types';
3
3
  export { parseFromContext, parseSyncFromContext, parseInBatchesFromContext } from './loader-types';
4
4
  export type { Writer, WriterOptions, WriterOptionsType } from './writer-types';
@@ -27,9 +27,15 @@ import * as fs from './lib/node/fs';
27
27
  export { fs };
28
28
  import * as stream from './lib/node/stream';
29
29
  export { stream };
30
+ export type { FileSystem, RandomAccessReadFileSystem } from './lib/filesystems/filesystem';
31
+ export { NodeFileSystem as _NodeFileSystem } from './lib/filesystems/node-filesystem';
32
+ export type { FileProvider } from './lib/file-provider/file-provider';
33
+ export { isFileProvider } from './lib/file-provider/file-provider';
34
+ export { FileHandle } from './lib/file-provider/file-handle';
35
+ export { FileHandleFile } from './lib/file-provider/file-handle-file';
36
+ export { DataViewFile } from './lib/file-provider/data-view-file';
30
37
  export type { ReadableFile } from './lib/filesystems/readable-file';
31
38
  export { makeReadableFile } from './lib/filesystems/readable-file';
32
39
  export type { WritableFile } from './lib/filesystems/writable-file';
33
40
  export { makeWritableFile } from './lib/filesystems/writable-file';
34
- export { default as _NodeFileSystem } from './lib/filesystems/node-filesystem';
35
41
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,YAAY,EAEV,QAAQ,EACR,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,2BAA2B,EAE3B,UAAU,EACV,aAAa,EACb,qBAAqB,EACrB,wBAAwB,EACxB,WAAW,EACX,YAAY,EAEZ,SAAS,EACV,MAAM,SAAS,CAAC;AAIjB,YAAY,EACV,MAAM,EACN,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAC,gBAAgB,EAAE,oBAAoB,EAAE,yBAAyB,EAAC,MAAM,gBAAgB,CAAC;AAIjG,YAAY,EAAC,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AAG7E,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EACL,SAAS,EACT,QAAQ,EACR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AAC9C,OAAO,EAAC,IAAI,EAAC,CAAC;AAGd,OAAO,KAAK,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAC,EAAE,EAAC,CAAC;AAGZ,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAC,MAAM,EAAC,CAAC;AAGhB,YAAY,EAAC,UAAU,EAAE,0BAA0B,EAAC,MAAM,8BAA8B,CAAC;AACzF,OAAO,EAAC,cAAc,IAAI,eAAe,EAAC,MAAM,mCAAmC,CAAC;AAEpF,YAAY,EAAC,YAAY,EAAC,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAC,cAAc,EAAC,MAAM,mCAAmC,CAAC;AAEjE,OAAO,EAAC,UAAU,EAAC,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAC,cAAc,EAAC,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAC,YAAY,EAAC,MAAM,oCAAoC,CAAC;AAEhE,YAAY,EAAC,YAAY,EAAC,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAC,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AAEjE,YAAY,EAAC,YAAY,EAAC,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAC,gBAAgB,EAAC,MAAM,iCAAiC,CAAC"}
package/dist/index.js CHANGED
@@ -28,7 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
30
  exports.fs = exports.path = exports.promisify2 = exports.promisify1 = exports.toArrayBuffer = exports.toBuffer = exports.isBuffer = exports.JSONLoader = exports._addAliases = exports.resolvePath = exports.getPathPrefix = exports.setPathPrefix = exports.RequestScheduler = exports.concatenateArrayBuffersAsync = exports.forEach = exports.makeNumberedLineIterator = exports.makeLineIterator = exports.makeTextDecoderIterator = exports.makeTextEncoderIterator = exports.getMagicString = exports.getFirstCharacters = exports.copyPaddedStringToDataView = exports.copyPaddedArrayBufferToDataView = exports.copyBinaryToDataView = exports.copyStringToDataView = exports.padStringToByteAlignment = exports.copyArrayBuffer = exports.copyToArray = exports.padToNBytes = exports.compareArrayBuffers = exports.concatenateTypedArrays = exports.concatenateArrayBuffers = exports.sliceArrayBuffer = exports.parseJSON = exports.canEncodeWithWorker = exports.canParseWithWorker = exports.parseWithWorker = exports.createLoaderWorker = exports.mergeLoaderOptions = exports.document = exports.global = exports.window = exports.self = exports.nodeVersion = exports.isWorker = exports.isBrowser = exports.assert = exports.parseInBatchesFromContext = exports.parseSyncFromContext = exports.parseFromContext = void 0;
31
- exports._NodeFileSystem = exports.makeWritableFile = exports.makeReadableFile = exports.stream = void 0;
31
+ exports.makeWritableFile = exports.makeReadableFile = exports.DataViewFile = exports.FileHandleFile = exports.FileHandle = exports.isFileProvider = exports._NodeFileSystem = exports.stream = void 0;
32
32
  var loader_types_1 = require("./loader-types");
33
33
  Object.defineProperty(exports, "parseFromContext", { enumerable: true, get: function () { return loader_types_1.parseFromContext; } });
34
34
  Object.defineProperty(exports, "parseSyncFromContext", { enumerable: true, get: function () { return loader_types_1.parseSyncFromContext; } });
@@ -119,9 +119,17 @@ exports.fs = fs;
119
119
  // Use instead of importing 'stream' to avoid node dependencies`
120
120
  const stream = __importStar(require("./lib/node/stream"));
121
121
  exports.stream = stream;
122
+ var node_filesystem_1 = require("./lib/filesystems/node-filesystem");
123
+ Object.defineProperty(exports, "_NodeFileSystem", { enumerable: true, get: function () { return node_filesystem_1.NodeFileSystem; } });
124
+ var file_provider_1 = require("./lib/file-provider/file-provider");
125
+ Object.defineProperty(exports, "isFileProvider", { enumerable: true, get: function () { return file_provider_1.isFileProvider; } });
126
+ var file_handle_1 = require("./lib/file-provider/file-handle");
127
+ Object.defineProperty(exports, "FileHandle", { enumerable: true, get: function () { return file_handle_1.FileHandle; } });
128
+ var file_handle_file_1 = require("./lib/file-provider/file-handle-file");
129
+ Object.defineProperty(exports, "FileHandleFile", { enumerable: true, get: function () { return file_handle_file_1.FileHandleFile; } });
130
+ var data_view_file_1 = require("./lib/file-provider/data-view-file");
131
+ Object.defineProperty(exports, "DataViewFile", { enumerable: true, get: function () { return data_view_file_1.DataViewFile; } });
122
132
  var readable_file_1 = require("./lib/filesystems/readable-file");
123
133
  Object.defineProperty(exports, "makeReadableFile", { enumerable: true, get: function () { return readable_file_1.makeReadableFile; } });
124
134
  var writable_file_1 = require("./lib/filesystems/writable-file");
125
135
  Object.defineProperty(exports, "makeWritableFile", { enumerable: true, get: function () { return writable_file_1.makeWritableFile; } });
126
- var node_filesystem_1 = require("./lib/filesystems/node-filesystem");
127
- Object.defineProperty(exports, "_NodeFileSystem", { enumerable: true, get: function () { return __importDefault(node_filesystem_1).default; } });
@@ -0,0 +1,37 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-view-file.d.ts","sourceRoot":"","sources":["../../../src/lib/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"}