@loaders.gl/loader-utils 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 (108) hide show
  1. package/dist/es5/index.js +49 -2
  2. package/dist/es5/index.js.map +1 -1
  3. package/dist/es5/json-loader.js +1 -1
  4. package/dist/es5/json-loader.js.map +1 -1
  5. package/dist/es5/lib/file-provider/data-view-file.js +146 -0
  6. package/dist/es5/lib/file-provider/data-view-file.js.map +1 -0
  7. package/dist/es5/lib/file-provider/file-handle-file.js +236 -0
  8. package/dist/es5/lib/file-provider/file-handle-file.js.map +1 -0
  9. package/dist/es5/lib/file-provider/file-handle.js +104 -0
  10. package/dist/es5/lib/file-provider/file-handle.js.map +1 -0
  11. package/dist/es5/lib/file-provider/file-provider.js +11 -0
  12. package/dist/es5/lib/file-provider/file-provider.js.map +1 -0
  13. package/dist/es5/lib/filesystems/filesystem.js +2 -0
  14. package/dist/es5/lib/filesystems/filesystem.js.map +1 -0
  15. package/dist/es5/lib/filesystems/node-filesystem.js +2 -2
  16. package/dist/es5/lib/filesystems/node-filesystem.js.map +1 -1
  17. package/dist/es5/lib/option-utils/merge-loader-options.js.map +1 -1
  18. package/dist/es5/lib/worker-loader-utils/create-loader-worker.js +2 -2
  19. package/dist/es5/lib/worker-loader-utils/create-loader-worker.js.map +1 -1
  20. package/dist/es5/lib/worker-loader-utils/encode-with-worker.js.map +1 -1
  21. package/dist/es5/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
  22. package/dist/es5/loader-types.js +58 -0
  23. package/dist/es5/loader-types.js.map +1 -0
  24. package/dist/es5/types.js.map +1 -1
  25. package/dist/es5/writer-types.js +2 -0
  26. package/dist/es5/writer-types.js.map +1 -0
  27. package/dist/esm/index.js +6 -1
  28. package/dist/esm/index.js.map +1 -1
  29. package/dist/esm/json-loader.js +1 -1
  30. package/dist/esm/json-loader.js.map +1 -1
  31. package/dist/esm/lib/file-provider/data-view-file.js +33 -0
  32. package/dist/esm/lib/file-provider/data-view-file.js.map +1 -0
  33. package/dist/esm/lib/file-provider/file-handle-file.js +59 -0
  34. package/dist/esm/lib/file-provider/file-handle-file.js.map +1 -0
  35. package/dist/esm/lib/file-provider/file-handle.js +37 -0
  36. package/dist/esm/lib/file-provider/file-handle.js.map +1 -0
  37. package/dist/esm/lib/file-provider/file-provider.js +4 -0
  38. package/dist/esm/lib/file-provider/file-provider.js.map +1 -0
  39. package/dist/esm/lib/filesystems/filesystem.js +2 -0
  40. package/dist/esm/lib/filesystems/filesystem.js.map +1 -0
  41. package/dist/esm/lib/filesystems/node-filesystem.js +1 -1
  42. package/dist/esm/lib/filesystems/node-filesystem.js.map +1 -1
  43. package/dist/esm/lib/option-utils/merge-loader-options.js.map +1 -1
  44. package/dist/esm/lib/worker-loader-utils/create-loader-worker.js +2 -2
  45. package/dist/esm/lib/worker-loader-utils/create-loader-worker.js.map +1 -1
  46. package/dist/esm/lib/worker-loader-utils/encode-with-worker.js.map +1 -1
  47. package/dist/esm/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
  48. package/dist/esm/loader-types.js +16 -0
  49. package/dist/esm/loader-types.js.map +1 -0
  50. package/dist/esm/types.js.map +1 -1
  51. package/dist/esm/writer-types.js +2 -0
  52. package/dist/esm/writer-types.js.map +1 -0
  53. package/dist/index.d.ts +11 -2
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +17 -4
  56. package/dist/json-loader.d.ts +1 -1
  57. package/dist/json-loader.d.ts.map +1 -1
  58. package/dist/lib/file-provider/data-view-file.d.ts +37 -0
  59. package/dist/lib/file-provider/data-view-file.d.ts.map +1 -0
  60. package/dist/lib/file-provider/data-view-file.js +63 -0
  61. package/dist/lib/file-provider/file-handle-file.d.ts +53 -0
  62. package/dist/lib/file-provider/file-handle-file.d.ts.map +1 -0
  63. package/dist/lib/file-provider/file-handle-file.js +92 -0
  64. package/dist/lib/file-provider/file-handle.d.ts +40 -0
  65. package/dist/lib/file-provider/file-handle.d.ts.map +1 -0
  66. package/dist/lib/file-provider/file-handle.js +55 -0
  67. package/dist/lib/file-provider/file-provider.d.ts +45 -0
  68. package/dist/lib/file-provider/file-provider.d.ts.map +1 -0
  69. package/dist/lib/file-provider/file-provider.js +13 -0
  70. package/dist/lib/filesystems/filesystem.d.ts +81 -0
  71. package/dist/lib/filesystems/filesystem.d.ts.map +1 -0
  72. package/dist/lib/filesystems/filesystem.js +37 -0
  73. package/dist/lib/filesystems/node-filesystem.d.ts +2 -2
  74. package/dist/lib/filesystems/node-filesystem.d.ts.map +1 -1
  75. package/dist/lib/filesystems/node-filesystem.js +3 -2
  76. package/dist/lib/option-utils/merge-loader-options.d.ts +1 -1
  77. package/dist/lib/option-utils/merge-loader-options.d.ts.map +1 -1
  78. package/dist/lib/worker-loader-utils/create-loader-worker.d.ts +1 -1
  79. package/dist/lib/worker-loader-utils/create-loader-worker.d.ts.map +1 -1
  80. package/dist/lib/worker-loader-utils/create-loader-worker.js +3 -2
  81. package/dist/lib/worker-loader-utils/encode-with-worker.d.ts +1 -1
  82. package/dist/lib/worker-loader-utils/encode-with-worker.d.ts.map +1 -1
  83. package/dist/lib/worker-loader-utils/parse-with-worker.d.ts +1 -1
  84. package/dist/lib/worker-loader-utils/parse-with-worker.d.ts.map +1 -1
  85. package/dist/loader-types.d.ts +208 -0
  86. package/dist/loader-types.d.ts.map +1 -0
  87. package/dist/loader-types.js +36 -0
  88. package/dist/types.d.ts +0 -259
  89. package/dist/types.d.ts.map +1 -1
  90. package/dist/writer-types.d.ts +36 -0
  91. package/dist/writer-types.d.ts.map +1 -0
  92. package/dist/writer-types.js +3 -0
  93. package/package.json +3 -3
  94. package/src/index.ts +31 -16
  95. package/src/json-loader.ts +1 -1
  96. package/src/lib/file-provider/data-view-file.ts +72 -0
  97. package/src/lib/file-provider/file-handle-file.ts +116 -0
  98. package/src/lib/file-provider/file-handle.ts +74 -0
  99. package/src/lib/file-provider/file-provider.ts +56 -0
  100. package/src/lib/filesystems/filesystem.ts +87 -0
  101. package/src/lib/filesystems/node-filesystem.ts +3 -3
  102. package/src/lib/option-utils/merge-loader-options.ts +1 -1
  103. package/src/lib/worker-loader-utils/create-loader-worker.ts +20 -4
  104. package/src/lib/worker-loader-utils/encode-with-worker.ts +1 -1
  105. package/src/lib/worker-loader-utils/parse-with-worker.ts +1 -1
  106. package/src/loader-types.ts +366 -0
  107. package/src/types.ts +0 -366
  108. package/src/writer-types.ts +61 -0
@@ -1 +1 @@
1
- {"version":3,"file":"json-loader.js","names":["VERSION","JSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parseTextSync","parse","arrayBuffer","TextDecoder","decode","options","JSON"],"sources":["../../src/json-loader.ts"],"sourcesContent":["import type {LoaderWithParser, LoaderOptions} from './types';\nimport type {Table, TableBatch} from '@loaders.gl/schema';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type JSONLoaderOptions = LoaderOptions;\n\n/**\n * A JSON Micro loader (minimal bundle size)\n * Alternative to `@loaders.gl/json`\n */\nexport const JSONLoader: LoaderWithParser<Table, TableBatch, JSONLoaderOptions> = {\n name: 'JSON',\n id: 'json',\n module: 'json',\n version: VERSION,\n extensions: ['json', 'geojson'],\n mimeTypes: ['application/json'],\n category: 'json',\n text: true,\n parseTextSync,\n parse: async (arrayBuffer) => parseTextSync(new TextDecoder().decode(arrayBuffer)),\n options: {}\n};\n\n// TODO - deprecated\nfunction parseTextSync(text) {\n return JSON.parse(text);\n}\n"],"mappings":"AAKA,MAAMA,OAAO,GAAG,uBAAkB,KAAK,WAAW,sBAAiB,QAAQ;AAQ3E,OAAO,MAAMC,UAAkE,GAAG;EAChFC,IAAI,EAAE,MAAM;EACZC,EAAE,EAAE,MAAM;EACVC,MAAM,EAAE,MAAM;EACdC,OAAO,EAAEL,OAAO;EAChBM,UAAU,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;EAC/BC,SAAS,EAAE,CAAC,kBAAkB,CAAC;EAC/BC,QAAQ,EAAE,MAAM;EAChBC,IAAI,EAAE,IAAI;EACVC,aAAa;EACbC,KAAK,EAAE,MAAOC,WAAW,IAAKF,aAAa,CAAC,IAAIG,WAAW,CAAC,CAAC,CAACC,MAAM,CAACF,WAAW,CAAC,CAAC;EAClFG,OAAO,EAAE,CAAC;AACZ,CAAC;AAGD,SAASL,aAAaA,CAACD,IAAI,EAAE;EAC3B,OAAOO,IAAI,CAACL,KAAK,CAACF,IAAI,CAAC;AACzB"}
1
+ {"version":3,"file":"json-loader.js","names":["VERSION","JSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parseTextSync","parse","arrayBuffer","TextDecoder","decode","options","JSON"],"sources":["../../src/json-loader.ts"],"sourcesContent":["import type {LoaderWithParser, LoaderOptions} from './loader-types';\nimport type {Table, TableBatch} from '@loaders.gl/schema';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type JSONLoaderOptions = LoaderOptions;\n\n/**\n * A JSON Micro loader (minimal bundle size)\n * Alternative to `@loaders.gl/json`\n */\nexport const JSONLoader: LoaderWithParser<Table, TableBatch, JSONLoaderOptions> = {\n name: 'JSON',\n id: 'json',\n module: 'json',\n version: VERSION,\n extensions: ['json', 'geojson'],\n mimeTypes: ['application/json'],\n category: 'json',\n text: true,\n parseTextSync,\n parse: async (arrayBuffer) => parseTextSync(new TextDecoder().decode(arrayBuffer)),\n options: {}\n};\n\n// TODO - deprecated\nfunction parseTextSync(text) {\n return JSON.parse(text);\n}\n"],"mappings":"AAKA,MAAMA,OAAO,GAAG,uBAAkB,KAAK,WAAW,sBAAiB,QAAQ;AAQ3E,OAAO,MAAMC,UAAkE,GAAG;EAChFC,IAAI,EAAE,MAAM;EACZC,EAAE,EAAE,MAAM;EACVC,MAAM,EAAE,MAAM;EACdC,OAAO,EAAEL,OAAO;EAChBM,UAAU,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;EAC/BC,SAAS,EAAE,CAAC,kBAAkB,CAAC;EAC/BC,QAAQ,EAAE,MAAM;EAChBC,IAAI,EAAE,IAAI;EACVC,aAAa;EACbC,KAAK,EAAE,MAAOC,WAAW,IAAKF,aAAa,CAAC,IAAIG,WAAW,CAAC,CAAC,CAACC,MAAM,CAACF,WAAW,CAAC,CAAC;EAClFG,OAAO,EAAE,CAAC;AACZ,CAAC;AAGD,SAASL,aAAaA,CAACD,IAAI,EAAE;EAC3B,OAAOO,IAAI,CAACL,KAAK,CAACF,IAAI,CAAC;AACzB"}
@@ -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,cA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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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vider === 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,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D,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,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 +1 @@
1
- {"version":3,"file":"merge-loader-options.js","names":["mergeLoaderOptions","baseOptions","newOptions","mergeOptionsRecursively","options","key","newValue","Object","entries"],"sources":["../../../../src/lib/option-utils/merge-loader-options.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {LoaderOptions} from '../../types';\n\n/**\n *\n * @param baseOptions Can be undefined, in which case a fresh options object will be minted\n * @param newOptions\n * @returns\n */\nexport function mergeLoaderOptions<Options extends LoaderOptions>(\n baseOptions: Options | undefined,\n newOptions: Options\n): Options {\n return mergeOptionsRecursively(baseOptions || {}, newOptions) as Options;\n}\n\nfunction mergeOptionsRecursively(\n baseOptions: Record<string, unknown>,\n newOptions: Record<string, unknown>\n): Record<string, unknown> {\n const options = {...baseOptions};\n for (const [key, newValue] of Object.entries(newOptions)) {\n if (newValue && typeof newValue === 'object') {\n options[key] = mergeOptionsRecursively(\n (options[key] as Record<string, unknown>) || {},\n newOptions[key] as Record<string, unknown>\n );\n // Object.assign(options[key] as object, newOptions[key]);\n } else {\n options[key] = newOptions[key];\n }\n }\n return options as Record<string, unknown>;\n}\n"],"mappings":"AAUA,OAAO,SAASA,kBAAkBA,CAChCC,WAAgC,EAChCC,UAAmB,EACV;EACT,OAAOC,uBAAuB,CAACF,WAAW,IAAI,CAAC,CAAC,EAAEC,UAAU,CAAC;AAC/D;AAEA,SAASC,uBAAuBA,CAC9BF,WAAoC,EACpCC,UAAmC,EACV;EACzB,MAAME,OAAO,GAAG;IAAC,GAAGH;EAAW,CAAC;EAChC,KAAK,MAAM,CAACI,GAAG,EAAEC,QAAQ,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACN,UAAU,CAAC,EAAE;IACxD,IAAII,QAAQ,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE;MAC5CF,OAAO,CAACC,GAAG,CAAC,GAAGF,uBAAuB,CACnCC,OAAO,CAACC,GAAG,CAAC,IAAgC,CAAC,CAAC,EAC/CH,UAAU,CAACG,GAAG,CAChB,CAAC;IAEH,CAAC,MAAM;MACLD,OAAO,CAACC,GAAG,CAAC,GAAGH,UAAU,CAACG,GAAG,CAAC;IAChC;EACF;EACA,OAAOD,OAAO;AAChB"}
1
+ {"version":3,"file":"merge-loader-options.js","names":["mergeLoaderOptions","baseOptions","newOptions","mergeOptionsRecursively","options","key","newValue","Object","entries"],"sources":["../../../../src/lib/option-utils/merge-loader-options.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {LoaderOptions} from '../../loader-types';\n\n/**\n *\n * @param baseOptions Can be undefined, in which case a fresh options object will be minted\n * @param newOptions\n * @returns\n */\nexport function mergeLoaderOptions<Options extends LoaderOptions>(\n baseOptions: Options | undefined,\n newOptions: Options\n): Options {\n return mergeOptionsRecursively(baseOptions || {}, newOptions) as Options;\n}\n\nfunction mergeOptionsRecursively(\n baseOptions: Record<string, unknown>,\n newOptions: Record<string, unknown>\n): Record<string, unknown> {\n const options = {...baseOptions};\n for (const [key, newValue] of Object.entries(newOptions)) {\n if (newValue && typeof newValue === 'object') {\n options[key] = mergeOptionsRecursively(\n (options[key] as Record<string, unknown>) || {},\n newOptions[key] as Record<string, unknown>\n );\n // Object.assign(options[key] as object, newOptions[key]);\n } else {\n options[key] = newOptions[key];\n }\n }\n return options as Record<string, unknown>;\n}\n"],"mappings":"AAUA,OAAO,SAASA,kBAAkBA,CAChCC,WAAgC,EAChCC,UAAmB,EACV;EACT,OAAOC,uBAAuB,CAACF,WAAW,IAAI,CAAC,CAAC,EAAEC,UAAU,CAAC;AAC/D;AAEA,SAASC,uBAAuBA,CAC9BF,WAAoC,EACpCC,UAAmC,EACV;EACzB,MAAME,OAAO,GAAG;IAAC,GAAGH;EAAW,CAAC;EAChC,KAAK,MAAM,CAACI,GAAG,EAAEC,QAAQ,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACN,UAAU,CAAC,EAAE;IACxD,IAAII,QAAQ,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE;MAC5CF,OAAO,CAACC,GAAG,CAAC,GAAGF,uBAAuB,CACnCC,OAAO,CAACC,GAAG,CAAC,IAAgC,CAAC,CAAC,EAC/CH,UAAU,CAACG,GAAG,CAChB,CAAC;IAEH,CAAC,MAAM;MACLD,OAAO,CAACC,GAAG,CAAC,GAAGH,UAAU,CAACG,GAAG,CAAC;IAChC;EACF;EACA,OAAOD,OAAO;AAChB"}
@@ -19,7 +19,7 @@ export function createLoaderWorker(loader) {
19
19
  options,
20
20
  context: {
21
21
  ...context,
22
- parse: parseOnMainThread
22
+ _parse: parseOnMainThread
23
23
  }
24
24
  });
25
25
  WorkerBody.postMessage('done', {
@@ -36,7 +36,7 @@ export function createLoaderWorker(loader) {
36
36
  }
37
37
  };
38
38
  }
39
- function parseOnMainThread(arrayBuffer, options) {
39
+ function parseOnMainThread(arrayBuffer, loader, options, context) {
40
40
  return new Promise((resolve, reject) => {
41
41
  const id = requestId++;
42
42
  const onMessage = (type, payload) => {
@@ -1 +1 @@
1
- {"version":3,"file":"create-loader-worker.js","names":["WorkerBody","requestId","createLoaderWorker","loader","inWorkerThread","onmessage","type","payload","input","options","context","result","parseData","arrayBuffer","parse","parseOnMainThread","postMessage","error","message","Error","Promise","resolve","reject","id","onMessage","removeEventListener","addEventListener","_ref","data","parser","parseSync","parseTextSync","textDecoder","TextDecoder","decode","concat","name","modules","worker"],"sources":["../../../../src/lib/worker-loader-utils/create-loader-worker.ts"],"sourcesContent":["/* eslint-disable no-restricted-globals */\nimport type {LoaderWithParser} from '../../types';\nimport {WorkerBody} from '@loaders.gl/worker-utils';\n// import {validateLoaderVersion} from './validate-loader-version';\n\nlet requestId = 0;\n\n/**\n * Set up a WebWorkerGlobalScope to talk with the main thread\n * @param loader\n */\nexport function createLoaderWorker(loader: LoaderWithParser) {\n // Check that we are actually in a worker thread\n if (!WorkerBody.inWorkerThread()) {\n return;\n }\n\n WorkerBody.onmessage = async (type, payload) => {\n switch (type) {\n case 'process':\n try {\n // validateLoaderVersion(loader, data.source.split('@')[1]);\n\n const {input, options = {}, context = {}} = payload;\n\n const result = await parseData({\n loader,\n arrayBuffer: input,\n options,\n context: {\n ...context,\n parse: parseOnMainThread\n }\n });\n WorkerBody.postMessage('done', {result});\n } catch (error) {\n const message = error instanceof Error ? error.message : '';\n WorkerBody.postMessage('error', {error: message});\n }\n break;\n default:\n }\n };\n}\n\nfunction parseOnMainThread(arrayBuffer: ArrayBuffer, options: {[key: string]: any}): Promise<void> {\n return new Promise((resolve, reject) => {\n const id = requestId++;\n\n /**\n */\n const onMessage = (type, payload) => {\n if (payload.id !== id) {\n // not ours\n return;\n }\n\n switch (type) {\n case 'done':\n WorkerBody.removeEventListener(onMessage);\n resolve(payload.result);\n break;\n\n case 'error':\n WorkerBody.removeEventListener(onMessage);\n reject(payload.error);\n break;\n\n default:\n // ignore\n }\n };\n\n WorkerBody.addEventListener(onMessage);\n\n // Ask the main thread to decode data\n const payload = {id, input: arrayBuffer, options};\n WorkerBody.postMessage('process', payload);\n });\n}\n\n// TODO - Support byteOffset and byteLength (enabling parsing of embedded binaries without copies)\n// TODO - Why not support async loader.parse* funcs here?\n// TODO - Why not reuse a common function instead of reimplementing loader.parse* selection logic? Keeping loader small?\n// TODO - Lack of appropriate parser functions can be detected when we create worker, no need to wait until parse\nasync function parseData({loader, arrayBuffer, options, context}) {\n let data;\n let parser;\n if (loader.parseSync || loader.parse) {\n data = arrayBuffer;\n parser = loader.parseSync || loader.parse;\n } else if (loader.parseTextSync) {\n const textDecoder = new TextDecoder();\n data = textDecoder.decode(arrayBuffer);\n parser = loader.parseTextSync;\n } else {\n throw new Error(`Could not load data with ${loader.name} loader`);\n }\n\n // TODO - proper merge in of loader options...\n options = {\n ...options,\n modules: (loader && loader.options && loader.options.modules) || {},\n worker: false\n };\n\n return await parser(data, {...options}, context, loader);\n}\n"],"mappings":"AAEA,SAAQA,UAAU,QAAO,0BAA0B;AAGnD,IAAIC,SAAS,GAAG,CAAC;AAMjB,OAAO,SAASC,kBAAkBA,CAACC,MAAwB,EAAE;EAE3D,IAAI,CAACH,UAAU,CAACI,cAAc,CAAC,CAAC,EAAE;IAChC;EACF;EAEAJ,UAAU,CAACK,SAAS,GAAG,OAAOC,IAAI,EAAEC,OAAO,KAAK;IAC9C,QAAQD,IAAI;MACV,KAAK,SAAS;QACZ,IAAI;UAGF,MAAM;YAACE,KAAK;YAAEC,OAAO,GAAG,CAAC,CAAC;YAAEC,OAAO,GAAG,CAAC;UAAC,CAAC,GAAGH,OAAO;UAEnD,MAAMI,MAAM,GAAG,MAAMC,SAAS,CAAC;YAC7BT,MAAM;YACNU,WAAW,EAAE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ACxB,MAAM;IAAEU,WAAW;IAAEJ,OAAO;IAAEC;EAAO,CAAC,GAAAiB,IAAA;EAC9D,IAAIC,IAAI;EACR,IAAIC,MAAM;EACV,IAAI1B,MAAM,CAAC2B,SAAS,IAAI3B,MAAM,CAACW,KAAK,EAAE;IACpCc,IAAI,GAAGf,WAAW;IAClBgB,MAAM,GAAG1B,MAAM,CAAC2B,SAAS,IAAI3B,MAAM,CAACW,KAAK;EAC3C,CAAC,MAAM,IAAIX,MAAM,CAAC4B,aAAa,EAAE;IAC/B,MAAMC,WAAW,GAAG,IAAIC,WAAW,CAAC,CAAC;IACrCL,IAAI,GAAGI,WAAW,CAACE,MAAM,CAACrB,WAAW,CAAC;IACtCgB,MAAM,GAAG1B,MAAM,CAAC4B,aAAa;EAC/B,CAAC,MAAM;IACL,MAAM,IAAIZ,KAAK,6BAAAgB,MAAA,CAA6BhC,MAAM,CAACiC,IAAI,YAAS,CAAC;EACnE;EAGA3B,OAAO,GAAG;IACR,GAAGA,OAAO;IACV4B,OAAO,EAAGlC,MAAM,IAAIA,MAAM,CAACM,OAAO,IAAIN,MAAM,CAACM,OAAO,CAAC4B,OAAO,IAAK,CAAC,CAAC;IACnEC,MAAM,EAAE;EACV,CAAC;EAED,OAAO,MAAMT,MAAM,CAACD,IAAI,EAAE;IAAC,GAAGnB;EAAO,CAAC,EAAEC,OAAO,EAAEP,MAAM,CAAC;AAC1D"}
1
+ {"version":3,"file":"create-loader-worker.js","names":["WorkerBody","requestId","createLoaderWorker","loader","inWorkerThread","onmessage","type","payload","input","options","context","result","parseData","arrayBuffer","_parse","parseOnMainThread","postMessage","error","message","Error","Promise","resolve","reject","id","onMessage","removeEventListener","addEventListener","_ref","data","parser","parseSync","parse","parseTextSync","textDecoder","TextDecoder","decode","concat","name","modules","worker"],"sources":["../../../../src/lib/worker-loader-utils/create-loader-worker.ts"],"sourcesContent":["/* eslint-disable no-restricted-globals */\nimport type {LoaderWithParser, LoaderOptions, LoaderContext} from '../../loader-types';\nimport {WorkerBody} from '@loaders.gl/worker-utils';\n// import {validateLoaderVersion} from './validate-loader-version';\n\nlet requestId = 0;\n\n/**\n * Set up a WebWorkerGlobalScope to talk with the main thread\n * @param loader\n */\nexport function createLoaderWorker(loader: LoaderWithParser) {\n // Check that we are actually in a worker thread\n if (!WorkerBody.inWorkerThread()) {\n return;\n }\n\n WorkerBody.onmessage = async (type, payload) => {\n switch (type) {\n case 'process':\n try {\n // validateLoaderVersion(loader, data.source.split('@')[1]);\n\n const {input, options = {}, context = {}} = payload;\n\n const result = await parseData({\n loader,\n arrayBuffer: input,\n options,\n // @ts-expect-error fetch missing\n context: {\n ...context,\n _parse: parseOnMainThread\n }\n });\n WorkerBody.postMessage('done', {result});\n } catch (error) {\n const message = error instanceof Error ? error.message : '';\n WorkerBody.postMessage('error', {error: message});\n }\n break;\n default:\n }\n };\n}\n\nfunction parseOnMainThread(\n arrayBuffer: ArrayBuffer,\n loader: any,\n options?: LoaderOptions,\n context?: LoaderContext\n): Promise<void> {\n return new Promise((resolve, reject) => {\n const id = requestId++;\n\n /**\n */\n const onMessage = (type, payload) => {\n if (payload.id !== id) {\n // not ours\n return;\n }\n\n switch (type) {\n case 'done':\n WorkerBody.removeEventListener(onMessage);\n resolve(payload.result);\n break;\n\n case 'error':\n WorkerBody.removeEventListener(onMessage);\n reject(payload.error);\n break;\n\n default:\n // ignore\n }\n };\n\n WorkerBody.addEventListener(onMessage);\n\n // Ask the main thread to decode data\n const payload = {id, input: arrayBuffer, options};\n WorkerBody.postMessage('process', payload);\n });\n}\n\n// TODO - Support byteOffset and byteLength (enabling parsing of embedded binaries without copies)\n// TODO - Why not support async loader.parse* funcs here?\n// TODO - Why not reuse a common function instead of reimplementing loader.parse* selection logic? Keeping loader small?\n// TODO - Lack of appropriate parser functions can be detected when we create worker, no need to wait until parse\nasync function parseData({\n loader,\n arrayBuffer,\n options,\n context\n}: {\n loader: LoaderWithParser;\n arrayBuffer: ArrayBuffer;\n options: LoaderOptions;\n context: LoaderContext;\n}) {\n let data;\n let parser;\n if (loader.parseSync || loader.parse) {\n data = arrayBuffer;\n parser = loader.parseSync || loader.parse;\n } else if (loader.parseTextSync) {\n const textDecoder = new TextDecoder();\n data = textDecoder.decode(arrayBuffer);\n parser = loader.parseTextSync;\n } else {\n throw new Error(`Could not load data with ${loader.name} loader`);\n }\n\n // TODO - proper merge in of loader options...\n options = {\n ...options,\n modules: (loader && loader.options && loader.options.modules) || {},\n worker: false\n };\n\n return await parser(data, {...options}, context, loader);\n}\n"],"mappings":"AAEA,SAAQA,UAAU,QAAO,0BAA0B;AAGnD,IAAIC,SAAS,GAAG,CAAC;AAMjB,OAAO,SAASC,kBAAkBA,CAACC,MAAwB,EAAE;EAE3D,IAAI,CAACH,UAAU,CAACI,cAAc,CAAC,CAAC,EAAE;IAChC;EACF;EAEAJ,UAAU,CAACK,SAAS,GAAG,OAAOC,IAAI,EAAEC,OAAO,KAAK;IAC9C,QAAQD,IAAI;MACV,KAAK,SAAS;QACZ,IAAI;UAGF,MAAM;YAACE,KAAK;YAAEC,OAAO,GAAG,CAAC,CAAC;YAAEC,OAAO,GAAG,CAAC;UAAC,CAAC,GAAGH,OAAO;UAEnD,MAAMI,MAAM,GAAG,MAAMC,SAAS,CAAC;YAC7BT,MAAM;YACNU,WAAW,EAAEL,KAAK;YAClBC,OAAO;YAEPC,OAAO,EAAE;cACP,GAAGA,OAAO;cACVI,MAAM,EAAEC;YACV;UACF,CAAC,CAAC;UACFf,UAAU,CAACgB,WAAW,CAAC,MAAM,EAAE;YAACL;UAAM,CAAC,CAAC;QAC1C,CAAC,CAAC,OAAOM,KAAK,EAAE;UACd,MAAMC,OAAO,GAAGD,KAAK,YAAYE,KAAK,GAAGF,KAAK,CAACC,OAAO,GAAG,EAAE;UAC3DlB,UAAU,CAACgB,WAAW,CAAC,OAAO,EAAE;YAACC,KAAK,EAAEC;UAAO,CAAC,CAAC;QACnD;QACA;MACF;IACF;EACF,CAAC;AACH;AAEA,SAASH,iBA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WAAW,CAACE,MAAM,CAACtB,WAAW,CAAC;IACtCgB,MAAM,GAAG1B,MAAM,CAAC6B,aAAa;EAC/B,CAAC,MAAM;IACL,MAAM,IAAIb,KAAK,6BAAAiB,MAAA,CAA6BjC,MAAM,CAACkC,IAAI,YAAS,CAAC;EACnE;EAGA5B,OAAO,GAAG;IACR,GAAGA,OAAO;IACV6B,OAAO,EAAGnC,MAAM,IAAIA,MAAM,CAACM,OAAO,IAAIN,MAAM,CAACM,OAAO,CAAC6B,OAAO,IAAK,CAAC,CAAC;IACnEC,MAAM,EAAE;EACV,CAAC;EAED,OAAO,MAAMV,MAAM,CAACD,IAAI,EAAE;IAAC,GAAGnB;EAAO,CAAC,EAAEC,OAAO,EAAEP,MAAM,CAAC;AAC1D"}
@@ -1 +1 @@
1
- {"version":3,"file":"encode-with-worker.js","names":["WorkerFarm","isBrowser","canEncodeWithWorker","writer","options","isSupported","_nodeWorkers","worker"],"sources":["../../../../src/lib/worker-loader-utils/encode-with-worker.ts"],"sourcesContent":["import {WorkerFarm} from '@loaders.gl/worker-utils';\nimport {Writer, WriterOptions} from '../../types';\nimport {isBrowser} from '../env-utils/globals';\n\n/**\n * Determines if a loader can parse with worker\n * @param loader\n * @param options\n */\nexport function canEncodeWithWorker(writer: Writer, options?: WriterOptions) {\n if (!WorkerFarm.isSupported()) {\n return false;\n }\n\n // Node workers are still experimental\n if (!isBrowser && !options?._nodeWorkers) {\n return false;\n }\n\n return writer.worker && options?.worker;\n}\n"],"mappings":"AAAA,SAAQA,UAAU,QAAO,0BAA0B;AAEnD,SAAQC,SAAS,QAAO,sBAAsB;AAO9C,OAAO,SAASC,mBAAmBA,CAACC,MAAc,EAAEC,OAAuB,EAAE;EAC3E,IAAI,CAACJ,UAAU,CAACK,WAAW,CAAC,CAAC,EAAE;IAC7B,OAAO,KAAK;EACd;EAGA,IAAI,CAACJ,SAAS,IAAI,EAACG,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEE,YAAY,GAAE;IACxC,OAAO,KAAK;EACd;EAEA,OAAOH,MAAM,CAACI,MAAM,KAAIH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEG,MAAM;AACzC"}
1
+ {"version":3,"file":"encode-with-worker.js","names":["WorkerFarm","isBrowser","canEncodeWithWorker","writer","options","isSupported","_nodeWorkers","worker"],"sources":["../../../../src/lib/worker-loader-utils/encode-with-worker.ts"],"sourcesContent":["import {WorkerFarm} from '@loaders.gl/worker-utils';\nimport {Writer, WriterOptions} from '../../writer-types';\nimport {isBrowser} from '../env-utils/globals';\n\n/**\n * Determines if a loader can parse with worker\n * @param loader\n * @param options\n */\nexport function canEncodeWithWorker(writer: Writer, options?: WriterOptions) {\n if (!WorkerFarm.isSupported()) {\n return false;\n }\n\n // Node workers are still experimental\n if (!isBrowser && !options?._nodeWorkers) {\n return false;\n }\n\n return writer.worker && options?.worker;\n}\n"],"mappings":"AAAA,SAAQA,UAAU,QAAO,0BAA0B;AAEnD,SAAQC,SAAS,QAAO,sBAAsB;AAO9C,OAAO,SAASC,mBAAmBA,CAACC,MAAc,EAAEC,OAAuB,EAAE;EAC3E,IAAI,CAACJ,UAAU,CAACK,WAAW,CAAC,CAAC,EAAE;IAC7B,OAAO,KAAK;EACd;EAGA,IAAI,CAACJ,SAAS,IAAI,EAACG,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEE,YAAY,GAAE;IACxC,OAAO,KAAK;EACd;EAEA,OAAOH,MAAM,CAACI,MAAM,KAAIH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEG,MAAM;AACzC"}
@@ -1 +1 @@
1
- {"version":3,"file":"parse-with-worker.js","names":["isBrowser","WorkerFarm","getWorkerURL","canParseWithWorker","loader","options","isSupported","_nodeWorkers","worker","parseWithWorker","data","context","parseOnMainThread","name","id","url","workerFarm","getWorkerFarm","workerPool","getWorkerPool","JSON","parse","stringify","job","startJob","onMessage","bind","postMessage","input","result","type","payload","done","error","Error","message","console","warn","concat"],"sources":["../../../../src/lib/worker-loader-utils/parse-with-worker.ts"],"sourcesContent":["import {\n WorkerJob,\n WorkerMessageType,\n WorkerMessagePayload,\n isBrowser\n} from '@loaders.gl/worker-utils';\nimport type {Loader, LoaderOptions, LoaderContext} from '../../types';\nimport {WorkerFarm, getWorkerURL} from '@loaders.gl/worker-utils';\n\n/**\n * Determines if a loader can parse with worker\n * @param loader\n * @param options\n */\nexport function canParseWithWorker(loader: Loader, options?: LoaderOptions) {\n if (!WorkerFarm.isSupported()) {\n return false;\n }\n\n // Node workers are still experimental\n if (!isBrowser && !options?._nodeWorkers) {\n return false;\n }\n\n return loader.worker && options?.worker;\n}\n\n/**\n * this function expects that the worker function sends certain messages,\n * this can be automated if the worker is wrapper by a call to createLoaderWorker in @loaders.gl/loader-utils.\n */\nexport async function parseWithWorker(\n loader: Loader,\n data: any,\n options?: LoaderOptions,\n context?: LoaderContext,\n parseOnMainThread?: (arrayBuffer: ArrayBuffer, options: {[key: string]: any}) => Promise<unknown>\n) {\n const name = loader.id; // TODO\n const url = getWorkerURL(loader, options);\n\n const workerFarm = WorkerFarm.getWorkerFarm(options);\n const workerPool = workerFarm.getWorkerPool({name, url});\n\n // options.log object contains functions which cannot be transferred\n // context.fetch & context.parse functions cannot be transferred\n // TODO - decide how to handle logging on workers\n options = JSON.parse(JSON.stringify(options));\n context = JSON.parse(JSON.stringify(context || {}));\n\n const job = await workerPool.startJob(\n 'process-on-worker',\n // @ts-expect-error\n onMessage.bind(null, parseOnMainThread) // eslint-disable-line @typescript-eslint/no-misused-promises\n );\n\n job.postMessage('process', {\n // @ts-ignore\n input: data,\n options,\n context\n });\n\n const result = await job.result;\n // TODO - what is going on here?\n return await result.result;\n}\n\n/**\n * Handle worker's responses to the main thread\n * @param job\n * @param type\n * @param payload\n */\nasync function onMessage(\n parseOnMainThread: (arrayBuffer: ArrayBuffer, options?: {[key: string]: any}) => Promise<void>,\n job: WorkerJob,\n type: WorkerMessageType,\n payload: WorkerMessagePayload\n) {\n switch (type) {\n case 'done':\n job.done(payload);\n break;\n\n case 'error':\n job.error(new Error(payload.error));\n break;\n\n case 'process':\n // Worker is asking for main thread to parseO\n const {id, input, options} = payload;\n try {\n const result = await parseOnMainThread(input, options);\n job.postMessage('done', {id, result});\n } catch (error) {\n const message = error instanceof Error ? error.message : 'unknown error';\n job.postMessage('error', {id, error: message});\n }\n break;\n\n default:\n // eslint-disable-next-line\n console.warn(`parse-with-worker unknown message ${type}`);\n }\n}\n"],"mappings":"AAAA,SAIEA,SAAS,QACJ,0BAA0B;AAEjC,SAAQC,UAAU,EAAEC,YAAY,QAAO,0BAA0B;AAOjE,OAAO,SAASC,kBAAkBA,CAACC,MAAc,EAAEC,OAAuB,EAAE;EAC1E,IAAI,CAACJ,UAAU,CAACK,WAAW,CAAC,CAAC,EAAE;IAC7B,OAAO,KAAK;EACd;EAGA,IAAI,CAACN,SAAS,IAAI,EAACK,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEE,YAAY,GAAE;IACxC,OAAO,KAAK;EACd;EAEA,OAAOH,MAAM,CAACI,MAAM,KAAIH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEG,MAAM;AACzC;AAMA,OAAO,eAAeC,eAAeA,CACnCL,MAAc,EACdM,IAAS,EACTL,OAAuB,EACvBM,OAAuB,EACvBC,iBAAiG,EACjG;EACA,MAAMC,IAAI,GAAGT,MAAM,CAACU,EAAE;EACtB,MAAMC,GAAG,GAAGb,YAAY,CAACE,MAAM,EAAEC,OAAO,CAAC;EAEzC,MAAMW,UAAU,GAAGf,UAAU,CAACgB,aAAa,CAACZ,OAAO,CAAC;EACpD,MAAMa,UAAU,GAAGF,UAAU,CAACG,aAAa,CAAC;IAACN,IAAI;IAAEE;EAAG,CAAC,CAAC;EAKxDV,OAAO,GAAGe,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,SAAS,CAACjB,OAAO,CAAC,CAAC;EAC7CM,OAAO,GAAGS,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,SAAS,C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,"file":"parse-with-worker.js","names":["isBrowser","WorkerFarm","getWorkerURL","canParseWithWorker","loader","options","isSupported","_nodeWorkers","worker","parseWithWorker","data","context","parseOnMainThread","name","id","url","workerFarm","getWorkerFarm","workerPool","getWorkerPool","JSON","parse","stringify","job","startJob","onMessage","bind","postMessage","input","result","type","payload","done","error","Error","message","console","warn","concat"],"sources":["../../../../src/lib/worker-loader-utils/parse-with-worker.ts"],"sourcesContent":["import {\n WorkerJob,\n WorkerMessageType,\n WorkerMessagePayload,\n isBrowser\n} from '@loaders.gl/worker-utils';\nimport type {Loader, LoaderOptions, LoaderContext} from '../../loader-types';\nimport {WorkerFarm, getWorkerURL} from '@loaders.gl/worker-utils';\n\n/**\n * Determines if a loader can parse with worker\n * @param loader\n * @param options\n */\nexport function canParseWithWorker(loader: Loader, options?: LoaderOptions) {\n if (!WorkerFarm.isSupported()) {\n return false;\n }\n\n // Node workers are still experimental\n if (!isBrowser && !options?._nodeWorkers) {\n return false;\n }\n\n return loader.worker && options?.worker;\n}\n\n/**\n * this function expects that the worker function sends certain messages,\n * this can be automated if the worker is wrapper by a call to createLoaderWorker in @loaders.gl/loader-utils.\n */\nexport async function parseWithWorker(\n loader: Loader,\n data: any,\n options?: LoaderOptions,\n context?: LoaderContext,\n parseOnMainThread?: (arrayBuffer: ArrayBuffer, options: {[key: string]: any}) => Promise<unknown>\n) {\n const name = loader.id; // TODO\n const url = getWorkerURL(loader, options);\n\n const workerFarm = WorkerFarm.getWorkerFarm(options);\n const workerPool = workerFarm.getWorkerPool({name, url});\n\n // options.log object contains functions which cannot be transferred\n // context.fetch & context.parse functions cannot be transferred\n // TODO - decide how to handle logging on workers\n options = JSON.parse(JSON.stringify(options));\n context = JSON.parse(JSON.stringify(context || {}));\n\n const job = await workerPool.startJob(\n 'process-on-worker',\n // @ts-expect-error\n onMessage.bind(null, parseOnMainThread) // eslint-disable-line @typescript-eslint/no-misused-promises\n );\n\n job.postMessage('process', {\n // @ts-ignore\n input: data,\n options,\n context\n });\n\n const result = await job.result;\n // TODO - what is going on here?\n return await result.result;\n}\n\n/**\n * Handle worker's responses to the main thread\n * @param job\n * @param type\n * @param payload\n */\nasync function onMessage(\n parseOnMainThread: (arrayBuffer: ArrayBuffer, options?: {[key: string]: any}) => Promise<void>,\n job: WorkerJob,\n type: WorkerMessageType,\n payload: WorkerMessagePayload\n) {\n switch (type) {\n case 'done':\n job.done(payload);\n break;\n\n case 'error':\n job.error(new Error(payload.error));\n break;\n\n case 'process':\n // Worker is asking for main thread to parseO\n const {id, input, options} = payload;\n try {\n const result = await parseOnMainThread(input, options);\n job.postMessage('done', {id, result});\n } catch (error) {\n const message = error instanceof Error ? error.message : 'unknown error';\n job.postMessage('error', {id, error: message});\n }\n break;\n\n default:\n // eslint-disable-next-line\n console.warn(`parse-with-worker unknown message ${type}`);\n }\n}\n"],"mappings":"AAAA,SAIEA,SAAS,QACJ,0BAA0B;AAEjC,SAAQC,UAAU,EAAEC,YAAY,QAAO,0BAA0B;AAOjE,OAAO,SAASC,kBAAkBA,CAACC,MAAc,EAAEC,OAAuB,EAAE;EAC1E,IAAI,CAACJ,UAAU,CAACK,WAAW,CAAC,CAAC,EAAE;IAC7B,OAAO,KAAK;EACd;EAGA,IAAI,CAACN,SAAS,IAAI,EAACK,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEE,YAAY,GAAE;IACxC,OAAO,KAAK;EACd;EAEA,OAAOH,MAAM,CAACI,MAAM,KAAIH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEG,MAAM;AACzC;AAMA,OAAO,eAAeC,eAAeA,CACnCL,MAAc,EACdM,IAAS,EACTL,OAAuB,EACvBM,OAAuB,EACvBC,iBAAiG,EACjG;EACA,MAAMC,IAAI,GAAGT,MAAM,CAACU,EAAE;EACtB,MAAMC,GAAG,GAAGb,YAAY,CAACE,MAAM,EAAEC,OAAO,CAAC;EAEzC,MAAMW,UAAU,GAAGf,UAAU,CAACgB,aAAa,CAACZ,OAAO,CAAC;EAC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AGD,KAAK,CAACE,OAAO,GAAG,eAAe;QACxEZ,GAAG,CAACI,WAAW,CAAC,OAAO,EAAE;UAACb,EAAE;UAAEmB,KAAK,EAAEE;QAAO,CAAC,CAAC;MAChD;MACA;IAEF;MAEEC,OAAO,CAACC,IAAI,sCAAAC,MAAA,CAAsCR,IAAI,CAAE,CAAC;EAC7D;AACF"}
@@ -0,0 +1,16 @@
1
+ export async function parseFromContext(data, loaders, options, context) {
2
+ return context._parse(data, loaders, options, context);
3
+ }
4
+ export function parseSyncFromContext(data, loader, options, context) {
5
+ if (!context._parseSync) {
6
+ throw new Error('parseSync');
7
+ }
8
+ return context._parseSync(data, loader, options, context);
9
+ }
10
+ export async function parseInBatchesFromContext(data, loader, options, context) {
11
+ if (!context._parseInBatches) {
12
+ throw new Error('parseInBatches');
13
+ }
14
+ return context._parseInBatches(data, loader, options, context);
15
+ }
16
+ //# sourceMappingURL=loader-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader-types.js","names":["parseFromContext","data","loaders","options","context","_parse","parseSyncFromContext","loader","_parseSync","Error","parseInBatchesFromContext","_parseInBatches"],"sources":["../../src/loader-types.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {\n FetchLike,\n TransformBatches /* , DataType, SyncDataType, BatchableDataType */\n} from './types';\n\n// LOADERS\n\n/**\n * Core Loader Options\n */\nexport type LoaderOptions = {\n /** fetch options or a custom fetch function */\n fetch?: typeof fetch | FetchLike | RequestInit | null;\n /** Do not throw on errors */\n nothrow?: boolean;\n\n /** loader selection, search first for supplied mimeType */\n mimeType?: string;\n /** loader selection, provide fallback mimeType is server does not provide */\n fallbackMimeType?: string;\n /** loader selection, avoid searching registered loaders */\n ignoreRegisteredLoaders?: boolean;\n\n // general\n /** Experimental: Supply a logger to the parser */\n log?: any;\n /** Force to load WASM libraries from local file system in NodeJS or from loaders.gl CDN in a web browser */\n useLocalLibraries?: boolean;\n\n // batched parsing\n\n /** Size of each batch. `auto` matches batches to size of incoming chunks */\n batchSize?: number | 'auto';\n /** Minimal amount of time between batches */\n batchDebounceMs?: number;\n /** Stop loading after a given number of rows (compare SQL limit clause) */\n limit?: 0;\n /** Experimental: Stop loading after reaching */\n _limitMB?: 0;\n /** Generate metadata batches */\n metadata?: boolean;\n /** Transforms to run on incoming batches */\n transforms?: TransformBatches[];\n\n // workers\n\n /** CDN load workers from */\n CDN?: string | null;\n /** Set to `false` to disable workers */\n worker?: boolean;\n /** Number of concurrent workers (per loader) on desktop browser */\n maxConcurrency?: number;\n /** Number of concurrent workers (per loader) on mobile browsers */\n maxMobileConcurrency?: number;\n /** Set to `false` to prevent reuse workers */\n reuseWorkers?: boolean;\n /** Whether to use workers under Node.js (experimental) */\n _nodeWorkers?: boolean;\n /** set to 'test' to run local worker */\n _workerType?: string;\n\n /** @deprecated `options.batchType` removed, Use `options.<loader>.type` instead */\n batchType?: 'row' | 'columnar' | 'arrow';\n /** @deprecated `options.throw removed`, Use `options.nothrow` instead */\n throws?: boolean;\n /** @deprecated `options.dataType` no longer used */\n dataType?: never;\n /** @deprecated `options.uri` no longer used */\n uri?: never;\n /** @deprecated `options.method` removed. Use `options.fetch.method` */\n method?: never;\n /** @deprecated `options.headers` removed. Use `options.fetch.headers` */\n headers?: never;\n /** @deprecated `options.body` removed. Use `options.fetch.body` */\n body?: never;\n /** @deprecated `options.mode` removed. Use `options.fetch.mode` */\n mode?: never;\n /** @deprecated `options.credentials` removed. Use `options.fetch.credentials` */\n credentials?: never;\n /** @deprecated `options.cache` removed. Use `options.fetch.cache` */\n cache?: never;\n /** @deprecated `options.redirect` removed. Use `options.fetch.redirect` */\n redirect?: never;\n /** @deprecated `options.referrer` removed. Use `options.fetch.referrer` */\n referrer?: never;\n /** @deprecated `options.referrerPolicy` removed. Use `options.fetch.referrerPolicy` */\n referrerPolicy?: never;\n /** @deprecated `options.integrity` removed. Use `options.fetch.integrity` */\n integrity?: never;\n /** @deprecated `options.keepalive` removed. Use `options.fetch.keepalive` */\n keepalive?: never;\n /** @deprecated `options.signal` removed. Use `options.fetch.signal` */\n signal?: never;\n\n // Accept other keys (loader options objects, e.g. `options.csv`, `options.json` ...)\n [loaderId: string]: unknown;\n};\n\ntype PreloadOptions = {\n [key: string]: unknown;\n};\n\n/**\n * A worker loader definition that can be used with `@loaders.gl/core` functions\n */\nexport type Loader<DataT = any, BatchT = any, LoaderOptionsT = LoaderOptions> = {\n /** The result type of this loader */\n dataType?: DataT;\n /** The batched result type of this loader */\n batchType?: BatchT;\n\n /** Default Options */\n options: LoaderOptionsT;\n /** Deprecated Options */\n deprecatedOptions?: Record<string, string | Record<string, string>>;\n\n /** Human readable name */\n name: string;\n /** id should be the same as the field used in LoaderOptions */\n id: string;\n /** module is used to generate worker threads, need to be the module directory name */\n module: string;\n /** Version should be injected by build tools */\n version: string;\n /** A boolean, or a URL */\n worker?: string | boolean;\n // end Worker\n\n /** Which category does this loader belong to */\n category?: string;\n /** File extensions that are potential matches with this loader. */\n extensions: string[];\n /** MIMETypes that indicate a match with this loader. @note Some MIMETypes are generic and supported by many loaders */\n mimeTypes: string[];\n\n /** Is the input of this loader binary */\n binary?: boolean;\n /** Is the input of this loader text */\n text?: boolean;\n\n /** Test some initial bytes of content to see if this loader might be a match */\n tests?: (((ArrayBuffer: ArrayBuffer) => boolean) | ArrayBuffer | string)[];\n\n /** @deprecated */\n supported?: boolean;\n /** @deprecated */\n testText?: (string: string) => boolean;\n};\n\n/**\n * A \"bundled\" loader definition that can be used with `@loaders.gl/core` functions\n * If a worker loader is supported it will also be supported.\n */\nexport type LoaderWithParser<DataT = any, BatchT = any, LoaderOptionsT = LoaderOptions> = Loader<\n DataT,\n BatchT,\n LoaderOptionsT\n> & {\n /** Perform actions before load. @deprecated Not officially supported. */\n preload?: Preload;\n /** Parse atomically from an arraybuffer asynchronously */\n parse: (\n arrayBuffer: ArrayBuffer,\n options?: LoaderOptionsT,\n context?: LoaderContext\n ) => Promise<DataT>;\n /** Parse atomically from an arraybuffer synchronously */\n parseSync?: (\n arrayBuffer: ArrayBuffer,\n options?: LoaderOptionsT,\n context?: LoaderContext\n ) => DataT;\n /** Parse atomically from a string asynchronously */\n parseText?: (text: string, options?: LoaderOptionsT, context?: LoaderContext) => Promise<DataT>;\n /** Parse atomically from a string synchronously */\n parseTextSync?: (text: string, options?: LoaderOptionsT, context?: LoaderContext) => DataT;\n /** Parse batches of data from an iterator, return an iterator that yield parsed batches. */\n parseInBatches?: (\n iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n options?: LoaderOptionsT,\n context?: LoaderContext\n ) => AsyncIterable<BatchT>;\n /** Like `parseInBatches` for loaders that don't integrate with fetch. @deprecated Not officially supported. */\n parseFileInBatches?: (\n file: Blob,\n options?: LoaderOptionsT,\n context?: LoaderContext\n ) => AsyncIterable<BatchT>;\n};\n\n/**\n * A Loader context is provided as a third parameters to a loader object's\n * parse functions when that loader is called by other loaders rather then\n * directly by the application.\n *\n * - The context object allows the subloaders to be aware of the parameters and\n * options that the application provided in the top level call.\n * - The context also providedsaccess to parse functions so that the subloader\n * does not need to include the core module.\n * - In addition, the context's parse functions may also redirect loads from worker\n * threads back to main thread.\n */\nexport type LoaderContext = {\n /** Loader list provided to top-level loader call plus any sub loaders */\n loaders?: Loader[] | null;\n /** If URL is available. */\n url?: string;\n /** the file name component of the URL (leading path and query string removed) */\n filename?: string;\n /** the directory name component of the URL (leading path excluding file name and query string) */\n baseUrl?: string;\n /** Query string (characters after `?`) */\n queryString?: string;\n\n /** Provides access to any application overrides of fetch() */\n fetch: typeof fetch | FetchLike;\n\n /** TBD */\n response?: Response;\n\n /**\n * Parse function for subloaders. Avoids importing `core`. In workers, may redirect to main thread\n */\n _parse: (\n arrayBuffer: ArrayBuffer,\n loaders?: Loader | Loader[] | LoaderOptions,\n options?: LoaderOptions,\n context?: LoaderContext\n ) => Promise<any>;\n\n /**\n * ParseSync function. Avoids importing `core`. In workers, may redirect to main thread\n * @deprecated Do not call directly, use `parseSyncFromContext` instead\n */\n _parseSync?: (\n arrayBuffer: ArrayBuffer,\n loaders?: Loader | Loader[] | LoaderOptions,\n options?: LoaderOptions,\n context?: LoaderContext\n ) => any;\n\n /**\n * ParseInBatches function. Avoids importing `core`.\n * @deprecated Do not call directly, use `parseInBatchesFromContext` instead\n */\n _parseInBatches?: (\n iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n loaders?: Loader | Loader[] | LoaderOptions,\n options?: LoaderOptions,\n context?: LoaderContext\n ) => AsyncIterable<any> | Promise<AsyncIterable<any>>;\n};\n\n// type Parse = (\n// arrayBuffer: ArrayBuffer,\n// options?: LoaderOptions,\n// context?: LoaderContext\n// ) => Promise<any>;\n// type ParseSync = (\n// arrayBuffer: ArrayBuffer,\n// options?: LoaderOptions,\n// context?: LoaderContext\n// ) => any;\n// type ParseText = (text: string, options?: LoaderOptions) => Promise<any>;\n// type ParseTextSync = (text: string, options?: LoaderOptions) => any;\n// type ParseInBatches = (\n// iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n// options?: LoaderOptions,\n// context?: LoaderContext\n// ) => AsyncIterable<any>;\n// type ParseFileInBatches = (\n// file: Blob,\n// options?: LoaderOptions,\n// context?: LoaderContext\n// ) => AsyncIterable<any>;\n\ntype Preload = (url: string, options?: PreloadOptions) => any;\n\n/** Typescript helper to extract options type from a generic loader type */\nexport type LoaderOptionsType<T = Loader> = T extends Loader<any, any, infer Options>\n ? Options\n : never;\n/** Typescript helper to extract data type from a generic loader type */\nexport type LoaderReturnType<T = Loader> = T extends Loader<infer Return, any, any>\n ? Return\n : never;\n/** Typescript helper to extract batch type from a generic loader type */\nexport type LoaderBatchType<T = Loader> = T extends Loader<any, infer Batch, any> ? Batch : never;\n\n/**\n * Parses `data` asynchronously using the supplied loader, parse function provided via the loader context\n */\nexport async function parseFromContext<\n LoaderT extends Loader,\n OptionsT extends LoaderOptions = LoaderOptionsType<LoaderT>\n>(\n data: ArrayBuffer,\n loader: LoaderT,\n options: OptionsT | undefined,\n context: LoaderContext\n): Promise<LoaderReturnType<LoaderT>>;\n\n/**\n * Parses `data` asynchronously by matching one of the supplied loader\n */\nexport async function parseFromContext(\n data: ArrayBuffer,\n loaders: Loader[],\n options: LoaderOptions | undefined,\n context: LoaderContext\n): Promise<unknown>;\n\n/**\n * Parses `data` using a specified loader\n * @param data\n * @param loaders\n * @param options\n * @param context\n */\n// implementation signature\nexport async function parseFromContext(\n data: ArrayBuffer,\n loaders: Loader | Loader[],\n options: LoaderOptions | undefined,\n context: LoaderContext\n): Promise<unknown> {\n return context._parse(data, loaders, options, context);\n}\n\n/**\n * Parses `data` synchronously using the specified loader, parse function provided via the loader context\n */\nexport function parseSyncFromContext<\n LoaderT extends Loader,\n OptionsT extends LoaderOptions = LoaderOptionsType<LoaderT>\n>(\n data: ArrayBuffer,\n loader: LoaderT,\n options: OptionsT | undefined,\n context: LoaderContext\n): LoaderReturnType<LoaderT> {\n if (!context._parseSync) {\n throw new Error('parseSync');\n }\n return context._parseSync(data, loader, options, context);\n}\n\n/**\n * Parses `data` synchronously using a specified loader, parse function provided via the loader context\n */\nexport async function parseInBatchesFromContext<\n LoaderT extends Loader,\n OptionsT extends LoaderOptions = LoaderOptionsType<LoaderT>\n>(\n data: Iterable<ArrayBuffer> | AsyncIterable<ArrayBuffer>,\n loader: LoaderT,\n options: OptionsT | undefined,\n context: LoaderContext\n): Promise<AsyncIterable<LoaderBatchType<LoaderT>>> {\n if (!context._parseInBatches) {\n throw new Error('parseInBatches');\n }\n return context._parseInBatches(data, loader, options, context);\n}\n"],"mappings":"AAkUA,OAAO,eAAeA,gBAAgBA,CACpCC,IAAiB,EACjBC,OAA0B,EAC1BC,OAAkC,EAClCC,OAAsB,EACJ;EAClB,OAAOA,OAAO,CAACC,MAAM,CAACJ,IAAI,EAAEC,OAAO,EAAEC,OAAO,EAAEC,OAAO,CAAC;AACxD;AAKA,OAAO,SAASE,oBAAoBA,CAIlCL,IAAiB,EACjBM,MAAe,EACfJ,OAA6B,EAC7BC,OAAsB,EACK;EAC3B,IAAI,CAACA,OAAO,CAACI,UAAU,EAAE;IACvB,MAAM,IAAIC,KAAK,CAAC,WAAW,CAAC;EAC9B;EACA,OAAOL,OAAO,CAACI,UAAU,CAACP,IAAI,EAAEM,MAAM,EAAEJ,OAAO,EAAEC,OAAO,CAAC;AAC3D;AAKA,OAAO,eAAeM,yBAAyBA,CAI7CT,IAAwD,EACxDM,MAAe,EACfJ,OAA6B,EAC7BC,OAAsB,EAC4B;EAClD,IAAI,CAACA,OAAO,CAACO,eAAe,EAAE;IAC5B,MAAM,IAAIF,KAAK,CAAC,gBAAgB,CAAC;EACnC;EACA,OAAOL,OAAO,CAACO,eAAe,CAACV,IAAI,EAAEM,MAAM,EAAEJ,OAAO,EAAEC,OAAO,CAAC;AAChE"}
@@ -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// LOADERS\n\n/**\n * Core Loader Options\n */\nexport type LoaderOptions = {\n /** fetch options or a custom fetch function */\n fetch?: typeof fetch | FetchLike | RequestInit | null;\n /** Do not throw on errors */\n nothrow?: boolean;\n\n /** loader selection, search first for supplied mimeType */\n mimeType?: string;\n /** loader selection, provide fallback mimeType is server does not provide */\n fallbackMimeType?: string;\n /** loader selection, avoid searching registered loaders */\n ignoreRegisteredLoaders?: boolean;\n\n // general\n /** Experimental: Supply a logger to the parser */\n log?: any;\n /** Force to load WASM libraries from local file system in NodeJS or from loaders.gl CDN in a web browser */\n useLocalLibraries?: boolean;\n\n // batched parsing\n\n /** Size of each batch. `auto` matches batches to size of incoming chunks */\n batchSize?: number | 'auto';\n /** Minimal amount of time between batches */\n batchDebounceMs?: number;\n /** Stop loading after a given number of rows (compare SQL limit clause) */\n limit?: 0;\n /** Experimental: Stop loading after reaching */\n _limitMB?: 0;\n /** Generate metadata batches */\n metadata?: boolean;\n /** Transforms to run on incoming batches */\n transforms?: TransformBatches[];\n\n // workers\n\n /** CDN load workers from */\n CDN?: string | null;\n /** Set to `false` to disable workers */\n worker?: boolean;\n /** Number of concurrent workers (per loader) on desktop browser */\n maxConcurrency?: number;\n /** Number of concurrent workers (per loader) on mobile browsers */\n maxMobileConcurrency?: number;\n /** Set to `false` to prevent reuse workers */\n reuseWorkers?: boolean;\n /** Whether to use workers under Node.js (experimental) */\n _nodeWorkers?: boolean;\n /** set to 'test' to run local worker */\n _workerType?: string;\n\n /** @deprecated `options.batchType` removed, Use `options.<loader>.type` instead */\n batchType?: 'row' | 'columnar' | 'arrow';\n /** @deprecated `options.throw removed`, Use `options.nothrow` instead */\n throws?: boolean;\n /** @deprecated `options.dataType` no longer used */\n dataType?: never;\n /** @deprecated `options.uri` no longer used */\n uri?: never;\n /** @deprecated `options.method` removed. Use `options.fetch.method` */\n method?: never;\n /** @deprecated `options.headers` removed. Use `options.fetch.headers` */\n headers?: never;\n /** @deprecated `options.body` removed. Use `options.fetch.body` */\n body?: never;\n /** @deprecated `options.mode` removed. Use `options.fetch.mode` */\n mode?: never;\n /** @deprecated `options.credentials` removed. Use `options.fetch.credentials` */\n credentials?: never;\n /** @deprecated `options.cache` removed. Use `options.fetch.cache` */\n cache?: never;\n /** @deprecated `options.redirect` removed. Use `options.fetch.redirect` */\n redirect?: never;\n /** @deprecated `options.referrer` removed. Use `options.fetch.referrer` */\n referrer?: never;\n /** @deprecated `options.referrerPolicy` removed. Use `options.fetch.referrerPolicy` */\n referrerPolicy?: never;\n /** @deprecated `options.integrity` removed. Use `options.fetch.integrity` */\n integrity?: never;\n /** @deprecated `options.keepalive` removed. Use `options.fetch.keepalive` */\n keepalive?: never;\n /** @deprecated `options.signal` removed. Use `options.fetch.signal` */\n signal?: never;\n\n // Accept other keys (loader options objects, e.g. `options.csv`, `options.json` ...)\n [loaderId: string]: unknown;\n};\n\ntype PreloadOptions = {\n [key: string]: unknown;\n};\n\n/**\n * A worker loader definition that can be used with `@loaders.gl/core` functions\n */\nexport type Loader<DataT = any, BatchT = any, LoaderOptionsT = LoaderOptions> = {\n /** The result type of this loader */\n dataType?: DataT;\n /** The batched result type of this loader */\n batchType?: BatchT;\n\n /** Default Options */\n options: LoaderOptionsT;\n /** Deprecated Options */\n deprecatedOptions?: Record<string, string | Record<string, string>>;\n\n /** Human readable name */\n name: string;\n /** id should be the same as the field used in LoaderOptions */\n id: string;\n /** module is used to generate worker threads, need to be the module directory name */\n module: string;\n /** Version should be injected by build tools */\n version: string;\n /** A boolean, or a URL */\n worker?: string | boolean;\n // end Worker\n\n /** Which category does this loader belong to */\n category?: string;\n /** File extensions that are potential matches with this loader. */\n extensions: string[];\n /** MIMETypes that indicate a match with this loader. @note Some MIMETypes are generic and supported by many loaders */\n mimeTypes: string[];\n\n /** Is the input of this loader binary */\n binary?: boolean;\n /** Is the input of this loader text */\n text?: boolean;\n\n /** Test some initial bytes of content to see if this loader might be a match */\n tests?: (((ArrayBuffer: ArrayBuffer) => boolean) | ArrayBuffer | string)[];\n\n /** @deprecated */\n supported?: boolean;\n /** @deprecated */\n testText?: (string: string) => boolean;\n};\n\n/**\n * A \"bundled\" loader definition that can be used with `@loaders.gl/core` functions\n * If a worker loader is supported it will also be supported.\n */\nexport type LoaderWithParser<DataT = any, BatchT = any, LoaderOptionsT = LoaderOptions> = Loader<\n DataT,\n BatchT,\n LoaderOptionsT\n> & {\n /** Perform actions before load. @deprecated Not officially supported. */\n preload?: Preload;\n /** Parse atomically from an arraybuffer asynchronously */\n parse: (\n arrayBuffer: ArrayBuffer,\n options?: LoaderOptionsT,\n context?: LoaderContext\n ) => Promise<DataT>;\n /** Parse atomically from an arraybuffer synchronously */\n parseSync?: (\n arrayBuffer: ArrayBuffer,\n options?: LoaderOptionsT,\n context?: LoaderContext\n ) => DataT;\n /** Parse atomically from a string asynchronously */\n parseText?: (text: string, options?: LoaderOptionsT, context?: LoaderContext) => Promise<DataT>;\n /** Parse atomically from a string synchronously */\n parseTextSync?: (text: string, options?: LoaderOptionsT, context?: LoaderContext) => DataT;\n /** Parse batches of data from an iterator, return an iterator that yield parsed batches. */\n parseInBatches?: (\n iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n options?: LoaderOptionsT,\n context?: LoaderContext\n ) => AsyncIterable<BatchT>;\n /** Like `parseInBatches` for loaders that don't integrate with fetch. @deprecated Not officially supported. */\n parseFileInBatches?: (\n file: Blob,\n options?: LoaderOptionsT,\n context?: LoaderContext\n ) => AsyncIterable<BatchT>;\n};\n\n/**\n * A Loader context is provided as a third parameters to a loader object's\n * parse functions when that loader is called by other loaders rather then\n * directly by the application.\n *\n * - The context object allows the subloaders to be aware of the parameters and\n * options that the application provided in the top level call.\n * - The context also providedsaccess to parse functions so that the subloader\n * does not need to include the core module.\n * - In addition, the context's parse functions may also redirect loads from worker\n * threads back to main thread.\n */\nexport type LoaderContext = {\n /** Loader list provided to top-level loader call plus any sub loaders */\n loaders?: Loader[] | null;\n /** If URL is available. */\n url?: string;\n /** the file name component of the URL (leading path and query string removed) */\n filename?: string;\n /** the directory name component of the URL (leading path excluding file name and query string) */\n baseUrl?: string;\n /** Query string (characters after `?`) */\n queryString?: string;\n\n /** Provides access to any application overrides of fetch() */\n fetch: typeof fetch | FetchLike;\n /** TBD */\n response?: Response;\n /** Parse function. Use instead of importing `core`. In workers, may redirect to main thread */\n parse: (\n arrayBuffer: ArrayBuffer,\n loaders?: Loader | Loader[] | LoaderOptions,\n options?: LoaderOptions,\n context?: LoaderContext\n ) => Promise<any>;\n /** ParseSync function. Use instead of importing `core`. In workers, may redirect to main thread */\n parseSync?: (\n arrayBuffer: ArrayBuffer,\n loaders?: Loader | Loader[] | LoaderOptions,\n options?: LoaderOptions,\n context?: LoaderContext\n ) => any;\n /** ParseInBatches function. Use instead of importing `core`. */\n parseInBatches?: (\n iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n loaders?: Loader | Loader[] | LoaderOptions,\n options?: LoaderOptions,\n context?: LoaderContext\n ) => AsyncIterable<any> | Promise<AsyncIterable<any>>;\n};\n\n// type Parse = (\n// arrayBuffer: ArrayBuffer,\n// options?: LoaderOptions,\n// context?: LoaderContext\n// ) => Promise<any>;\n// type ParseSync = (\n// arrayBuffer: ArrayBuffer,\n// options?: LoaderOptions,\n// context?: LoaderContext\n// ) => any;\n// type ParseText = (text: string, options?: LoaderOptions) => Promise<any>;\n// type ParseTextSync = (text: string, options?: LoaderOptions) => any;\n// type ParseInBatches = (\n// iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n// options?: LoaderOptions,\n// context?: LoaderContext\n// ) => AsyncIterable<any>;\n// type ParseFileInBatches = (\n// file: Blob,\n// options?: LoaderOptions,\n// context?: LoaderContext\n// ) => AsyncIterable<any>;\n\ntype Preload = (url: string, options?: PreloadOptions) => any;\n\n/** Typescript helper to extract options type from a generic loader type */\nexport type LoaderOptionsType<T = Loader> = T extends Loader<any, any, infer Options>\n ? Options\n : never;\n/** Typescript helper to extract data type from a generic loader type */\nexport type LoaderReturnType<T = Loader> = T extends Loader<infer Return, any, any>\n ? Return\n : never;\n/** Typescript helper to extract batch type from a generic loader type */\nexport type LoaderBatchType<T = Loader> = T extends Loader<any, infer Batch, any> ? Batch : never;\n\n// WRITERS\n\n/** Options for writers */\nexport type WriterOptions = {\n /** worker source. If is set will be used instead of loading worker from the Internet */\n source?: string | null;\n /** Force to load WASM libraries from local file system in NodeJS or from loaders.gl CDN in a web browser */\n useLocalLibraries?: boolean;\n /** writer-specific options */\n [writerId: string]: any;\n};\n\n/**\n * A writer definition that can be used with `@loaders.gl/core` functions\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type Writer<DataT = unknown, BatchT = unknown, WriterOptionsT = WriterOptions> = {\n name: string;\n\n id: string;\n module: string;\n version: string;\n worker?: string | boolean;\n\n // TODO - are these are needed?\n extensions?: string[];\n mimeTypes?: string[];\n binary?: boolean;\n text?: boolean;\n\n options: WriterOptionsT;\n deprecatedOptions?: Record<string, string>;\n\n // encodeText?: EncodeText;\n // encode?: Encode;\n encodeSync?: EncodeSync;\n // encodeInBatches?: EncodeInBatches;\n encodeURLtoURL?: EncodeURLtoURL;\n\n encode?(data: DataT, options?: WriterOptionsT): Promise<ArrayBuffer>;\n encodeText?(table: DataT, options?: WriterOptionsT): Promise<string> | string;\n encodeInBatches?(data: AsyncIterable<any>, options?: WriterOptionsT): AsyncIterable<ArrayBuffer>;\n};\n\n// type Encode = (data: any, options?: WriterOptions) => Promise<ArrayBuffer>;\ntype EncodeSync = (data: any, options?: WriterOptions) => ArrayBuffer;\n// TODO\n// type EncodeText = Function;\n// type EncodeInBatches = Function;\ntype EncodeURLtoURL = (\n inputUrl: string,\n outputUrl: string,\n options?: WriterOptions\n) => Promise<string>;\n\n/** Typescript helper to extract the writer options type from a generic writer type */\nexport type WriterOptionsType<T = Writer> = T extends Writer<unknown, unknown, infer Options>\n ? Options\n : never;\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":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=writer-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer-types.js","names":[],"sources":["../../src/writer-types.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n// WRITERS\n\n/** Options for writers */\nexport type WriterOptions = {\n /** worker source. If is set will be used instead of loading worker from the Internet */\n source?: string | null;\n /** Force to load WASM libraries from local file system in NodeJS or from loaders.gl CDN in a web browser */\n useLocalLibraries?: boolean;\n /** writer-specific options */\n [writerId: string]: any;\n};\n\n/**\n * A writer definition that can be used with `@loaders.gl/core` functions\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type Writer<DataT = unknown, BatchT = unknown, WriterOptionsT = WriterOptions> = {\n name: string;\n\n id: string;\n module: string;\n version: string;\n worker?: string | boolean;\n\n // TODO - are these are needed?\n extensions?: string[];\n mimeTypes?: string[];\n binary?: boolean;\n text?: boolean;\n\n options: WriterOptionsT;\n deprecatedOptions?: Record<string, string>;\n\n // encodeText?: EncodeText;\n // encode?: Encode;\n encodeSync?: EncodeSync;\n // encodeInBatches?: EncodeInBatches;\n encodeURLtoURL?: EncodeURLtoURL;\n\n encode?(data: DataT, options?: WriterOptionsT): Promise<ArrayBuffer>;\n encodeText?(table: DataT, options?: WriterOptionsT): Promise<string> | string;\n encodeInBatches?(data: AsyncIterable<any>, options?: WriterOptionsT): AsyncIterable<ArrayBuffer>;\n};\n\n// type Encode = (data: any, options?: WriterOptions) => Promise<ArrayBuffer>;\ntype EncodeSync = (data: any, options?: WriterOptions) => ArrayBuffer;\n// TODO\n// type EncodeText = Function;\n// type EncodeInBatches = Function;\ntype EncodeURLtoURL = (\n inputUrl: string,\n outputUrl: string,\n options?: WriterOptions\n) => Promise<string>;\n\n/** Typescript helper to extract the writer options type from a generic writer type */\nexport type WriterOptionsType<T = Writer> = T extends Writer<unknown, unknown, infer Options>\n ? Options\n : never;\n"],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
- export type { Loader, LoaderWithParser, LoaderContext, LoaderOptions, LoaderOptionsType, LoaderReturnType, LoaderBatchType, Writer, WriterOptions, WriterOptionsType, 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
+ export type { Loader, LoaderWithParser, LoaderContext, LoaderOptions, LoaderOptionsType, LoaderReturnType, LoaderBatchType } from './loader-types';
3
+ export { parseFromContext, parseSyncFromContext, parseInBatchesFromContext } from './loader-types';
4
+ export type { Writer, WriterOptions, WriterOptionsType } from './writer-types';
2
5
  export { assert } from './lib/env-utils/assert';
3
6
  export { isBrowser, isWorker, nodeVersion, self, window, global, document } from './lib/env-utils/globals';
4
7
  export { mergeLoaderOptions } from './lib/option-utils/merge-loader-options';
@@ -24,9 +27,15 @@ import * as fs from './lib/node/fs';
24
27
  export { fs };
25
28
  import * as stream from './lib/node/stream';
26
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';
27
37
  export type { ReadableFile } from './lib/filesystems/readable-file';
28
38
  export { makeReadableFile } from './lib/filesystems/readable-file';
29
39
  export type { WritableFile } from './lib/filesystems/writable-file';
30
40
  export { makeWritableFile } from './lib/filesystems/writable-file';
31
- export { default as _NodeFileSystem } from './lib/filesystems/node-filesystem';
32
41
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAEV,MAAM,EACN,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAEf,MAAM,EACN,aAAa,EACb,iBAAiB,EAEjB,QAAQ,EACR,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,2BAA2B,EAE3B,UAAU,EACV,aAAa,EACb,qBAAqB,EACrB,wBAAwB,EACxB,WAAW,EACX,YA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,MAAM,4CAA4C,CAAC;AAK7F,OAAO,EAAC,UAAU,EAAE,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAG5D,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;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
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // loaders.gl, MIT license
2
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
4
  if (k2 === undefined) k2 = k;
4
5
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -26,8 +27,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
28
  };
28
29
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.makeWritableFile = exports.makeReadableFile = exports.stream = 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 = void 0;
30
- exports._NodeFileSystem = void 0;
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.makeWritableFile = exports.makeReadableFile = exports.DataViewFile = exports.FileHandleFile = exports.FileHandle = exports.isFileProvider = exports._NodeFileSystem = exports.stream = void 0;
32
+ var loader_types_1 = require("./loader-types");
33
+ Object.defineProperty(exports, "parseFromContext", { enumerable: true, get: function () { return loader_types_1.parseFromContext; } });
34
+ Object.defineProperty(exports, "parseSyncFromContext", { enumerable: true, get: function () { return loader_types_1.parseSyncFromContext; } });
35
+ Object.defineProperty(exports, "parseInBatchesFromContext", { enumerable: true, get: function () { return loader_types_1.parseInBatchesFromContext; } });
31
36
  // GENERAL UTILS
32
37
  var assert_1 = require("./lib/env-utils/assert");
33
38
  Object.defineProperty(exports, "assert", { enumerable: true, get: function () { return assert_1.assert; } });
@@ -114,9 +119,17 @@ exports.fs = fs;
114
119
  // Use instead of importing 'stream' to avoid node dependencies`
115
120
  const stream = __importStar(require("./lib/node/stream"));
116
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; } });
117
132
  var readable_file_1 = require("./lib/filesystems/readable-file");
118
133
  Object.defineProperty(exports, "makeReadableFile", { enumerable: true, get: function () { return readable_file_1.makeReadableFile; } });
119
134
  var writable_file_1 = require("./lib/filesystems/writable-file");
120
135
  Object.defineProperty(exports, "makeWritableFile", { enumerable: true, get: function () { return writable_file_1.makeWritableFile; } });
121
- var node_filesystem_1 = require("./lib/filesystems/node-filesystem");
122
- Object.defineProperty(exports, "_NodeFileSystem", { enumerable: true, get: function () { return __importDefault(node_filesystem_1).default; } });
@@ -1,4 +1,4 @@
1
- import type { LoaderWithParser, LoaderOptions } from './types';
1
+ import type { LoaderWithParser, LoaderOptions } from './loader-types';
2
2
  import type { Table, TableBatch } from '@loaders.gl/schema';
3
3
  export type JSONLoaderOptions = LoaderOptions;
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"json-loader.d.ts","sourceRoot":"","sources":["../src/json-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,SAAS,CAAC;AAC7D,OAAO,KAAK,EAAC,KAAK,EAAE,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAM1D,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,iBAAiB,CAY7E,CAAC"}
1
+ {"version":3,"file":"json-loader.d.ts","sourceRoot":"","sources":["../src/json-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,gBAAgB,CAAC;AACpE,OAAO,KAAK,EAAC,KAAK,EAAE,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAM1D,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,iBAAiB,CAY7E,CAAC"}