@loaders.gl/loader-utils 4.0.0-alpha.4 → 4.0.0-alpha.5
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.
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/json-loader.d.ts +22 -0
- package/dist/json-loader.d.ts.map +1 -0
- package/dist/json-loader.js +1 -1
- package/dist/lib/binary-utils/array-buffer-utils.d.ts +31 -0
- package/dist/lib/binary-utils/array-buffer-utils.d.ts.map +1 -0
- package/dist/lib/binary-utils/binary-copy-utils.d.ts +24 -0
- package/dist/lib/binary-utils/binary-copy-utils.d.ts.map +1 -0
- package/dist/lib/binary-utils/buffer-utils.d.ts +16 -0
- package/dist/lib/binary-utils/buffer-utils.d.ts.map +1 -0
- package/dist/lib/binary-utils/encode-utils.d.ts +4 -0
- package/dist/lib/binary-utils/encode-utils.d.ts.map +1 -0
- package/dist/lib/binary-utils/get-first-characters.d.ts +3 -0
- package/dist/lib/binary-utils/get-first-characters.d.ts.map +1 -0
- package/dist/lib/binary-utils/memory-copy-utils.d.ts +25 -0
- package/dist/lib/binary-utils/memory-copy-utils.d.ts.map +1 -0
- package/dist/lib/env-utils/assert.d.ts +6 -0
- package/dist/lib/env-utils/assert.d.ts.map +1 -0
- package/dist/lib/env-utils/globals.d.ts +15 -0
- package/dist/lib/env-utils/globals.d.ts.map +1 -0
- package/dist/lib/filesystems/node-filesystem.d.ts +38 -0
- package/dist/lib/filesystems/node-filesystem.d.ts.map +1 -0
- package/dist/lib/iterators/async-iteration.d.ts +20 -0
- package/dist/lib/iterators/async-iteration.d.ts.map +1 -0
- package/dist/lib/iterators/text-iterators.d.ts +19 -0
- package/dist/lib/iterators/text-iterators.d.ts.map +1 -0
- package/dist/lib/node/buffer.d.ts +10 -0
- package/dist/lib/node/buffer.d.ts.map +1 -0
- package/dist/lib/node/fs.d.ts +23 -0
- package/dist/lib/node/fs.d.ts.map +1 -0
- package/dist/lib/node/fs.js +26 -11
- package/dist/lib/node/fs.js.map +1 -1
- package/dist/lib/node/util.d.ts +5 -0
- package/dist/lib/node/util.d.ts.map +1 -0
- package/dist/lib/parser-utils/parse-json.d.ts +5 -0
- package/dist/lib/parser-utils/parse-json.d.ts.map +1 -0
- package/dist/lib/path-utils/file-aliases.d.ts +17 -0
- package/dist/lib/path-utils/file-aliases.d.ts.map +1 -0
- package/dist/lib/path-utils/path.d.ts +16 -0
- package/dist/lib/path-utils/path.d.ts.map +1 -0
- package/dist/lib/request-utils/request-scheduler.d.ts +62 -0
- package/dist/lib/request-utils/request-scheduler.d.ts.map +1 -0
- package/dist/lib/worker-loader-utils/create-loader-worker.d.ts +7 -0
- package/dist/lib/worker-loader-utils/create-loader-worker.d.ts.map +1 -0
- package/dist/lib/worker-loader-utils/parse-with-worker.d.ts +15 -0
- package/dist/lib/worker-loader-utils/parse-with-worker.d.ts.map +1 -0
- package/dist/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
- package/dist/types.d.ts +207 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/workers/json-worker.d.ts +2 -0
- package/dist/workers/json-worker.d.ts.map +1 -0
- package/package.json +6 -9
- package/src/lib/node/fs.ts +44 -14
- package/src/lib/worker-loader-utils/parse-with-worker.ts +1 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type { Loader, LoaderWithParser, LoaderContext, LoaderOptions, Writer, WriterOptions, DataType, SyncDataType, BatchableDataType, IFileSystem, IRandomAccessReadFileSystem } from './types';
|
|
2
|
+
export { assert } from './lib/env-utils/assert';
|
|
3
|
+
export { isBrowser, isWorker, nodeVersion, self, window, global, document } from './lib/env-utils/globals';
|
|
4
|
+
export { createLoaderWorker } from './lib/worker-loader-utils/create-loader-worker';
|
|
5
|
+
export { parseWithWorker, canParseWithWorker } from './lib/worker-loader-utils/parse-with-worker';
|
|
6
|
+
export { parseJSON } from './lib/parser-utils/parse-json';
|
|
7
|
+
export { toArrayBuffer, sliceArrayBuffer, concatenateArrayBuffers, concatenateTypedArrays, compareArrayBuffers } from './lib/binary-utils/array-buffer-utils';
|
|
8
|
+
export { padToNBytes, copyToArray, copyArrayBuffer } from './lib/binary-utils/memory-copy-utils';
|
|
9
|
+
export { copyPaddedArrayBufferToDataView, copyPaddedStringToDataView } from './lib/binary-utils/binary-copy-utils';
|
|
10
|
+
export { padStringToByteAlignment, copyStringToDataView, copyBinaryToDataView } from './lib/binary-utils/encode-utils';
|
|
11
|
+
export { getFirstCharacters, getMagicString } from './lib/binary-utils/get-first-characters';
|
|
12
|
+
export { makeTextEncoderIterator, makeTextDecoderIterator, makeLineIterator, makeNumberedLineIterator } from './lib/iterators/text-iterators';
|
|
13
|
+
export { forEach, concatenateArrayBuffersAsync } from './lib/iterators/async-iteration';
|
|
14
|
+
export { default as RequestScheduler } from './lib/request-utils/request-scheduler';
|
|
15
|
+
export { setPathPrefix, getPathPrefix, resolvePath } from './lib/path-utils/file-aliases';
|
|
16
|
+
export { addAliases as _addAliases } from './lib/path-utils/file-aliases';
|
|
17
|
+
export { JSONLoader } from './json-loader';
|
|
18
|
+
import * as path from './lib/path-utils/path';
|
|
19
|
+
export { path };
|
|
20
|
+
export { isBuffer, toBuffer, bufferToArrayBuffer } from './lib/binary-utils/buffer-utils';
|
|
21
|
+
import * as util from './lib/node/util';
|
|
22
|
+
export { util };
|
|
23
|
+
export { promisify } from './lib/node/util';
|
|
24
|
+
import * as fs from './lib/node/fs';
|
|
25
|
+
export { fs };
|
|
26
|
+
export { default as _NodeFileSystem } from './lib/filesystems/node-filesystem';
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,MAAM,EACN,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,MAAM,EACN,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,iBAAiB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MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAC,IAAI,EAAC,CAAC;AAGd,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAE,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AAKxF,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAC,IAAI,EAAC,CAAC;AAEd,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAG1C,OAAO,KAAK,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAC,EAAE,EAAC,CAAC;AAGZ,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { LoaderWithParser } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* A JSON Micro loader (minimal bundle size)
|
|
4
|
+
* Alternative to `@loaders.gl/json`
|
|
5
|
+
*/
|
|
6
|
+
export declare const JSONLoader: {
|
|
7
|
+
name: string;
|
|
8
|
+
id: string;
|
|
9
|
+
module: string;
|
|
10
|
+
version: any;
|
|
11
|
+
extensions: string[];
|
|
12
|
+
mimeTypes: string[];
|
|
13
|
+
category: string;
|
|
14
|
+
text: boolean;
|
|
15
|
+
parseTextSync: typeof parseTextSync;
|
|
16
|
+
parse: (arrayBuffer: any) => Promise<any>;
|
|
17
|
+
options: {};
|
|
18
|
+
};
|
|
19
|
+
declare function parseTextSync(text: any): any;
|
|
20
|
+
export declare const _typecheckJSONLoader: LoaderWithParser;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=json-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-loader.d.ts","sourceRoot":"","sources":["../src/json-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,SAAS,CAAC;AAM9C;;;GAGG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;CAYtB,CAAC;AAGF,iBAAS,aAAa,CAAC,IAAI,KAAA,OAE1B;AAED,eAAO,MAAM,oBAAoB,EAAE,gBAA6B,CAAC"}
|
package/dist/json-loader.js
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert an object to an array buffer
|
|
3
|
+
*/
|
|
4
|
+
export declare function toArrayBuffer(data: any): ArrayBuffer;
|
|
5
|
+
/**
|
|
6
|
+
* compare two binary arrays for equality
|
|
7
|
+
* @param {ArrayBuffer} a
|
|
8
|
+
* @param {ArrayBuffer} b
|
|
9
|
+
* @param {number} byteLength
|
|
10
|
+
*/
|
|
11
|
+
export declare function compareArrayBuffers(arrayBuffer1: ArrayBuffer, arrayBuffer2: ArrayBuffer, byteLength?: number): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Concatenate a sequence of ArrayBuffers
|
|
14
|
+
* @return A concatenated ArrayBuffer
|
|
15
|
+
*/
|
|
16
|
+
export declare function concatenateArrayBuffers(...sources: (ArrayBuffer | Uint8Array)[]): ArrayBuffer;
|
|
17
|
+
/**
|
|
18
|
+
* Concatenate arbitrary count of typed arrays
|
|
19
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays
|
|
20
|
+
* @param {...*} arrays - list of arrays. All arrays should be the same type
|
|
21
|
+
* @return A concatenated TypedArray
|
|
22
|
+
*/
|
|
23
|
+
export declare function concatenateTypedArrays<T>(...typedArrays: T[]): T;
|
|
24
|
+
/**
|
|
25
|
+
* Copy a view of an ArrayBuffer into new ArrayBuffer with byteOffset = 0
|
|
26
|
+
* @param arrayBuffer
|
|
27
|
+
* @param byteOffset
|
|
28
|
+
* @param byteLength
|
|
29
|
+
*/
|
|
30
|
+
export declare function sliceArrayBuffer(arrayBuffer: ArrayBuffer, byteOffset: number, byteLength?: number): ArrayBuffer;
|
|
31
|
+
//# sourceMappingURL=array-buffer-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-buffer-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-utils/array-buffer-utils.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,GAAG,GAAG,WAAW,CA8BpD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,WAAW,EACzB,YAAY,EAAE,WAAW,EACzB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAaT;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,OAAO,EAAE,CAAC,WAAW,GAAG,UAAU,CAAC,EAAE,GAAG,WAAW,CAqB7F;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,GAAG,WAAW,EAAE,CAAC,EAAE,GAAG,CAAC,CAoBhE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM,GAClB,WAAW,CAOb"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TypedArray } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Copy sourceBuffer to dataView with some padding
|
|
4
|
+
*
|
|
5
|
+
* @param {DataView | null} dataView - destination data container. If null - only new offset is calculated
|
|
6
|
+
* @param {number} byteOffset - destination byte offset to copy to
|
|
7
|
+
* @param {Array | TypedArray} sourceBuffer - source data buffer
|
|
8
|
+
* @param {number} padding - pad the resulting array to multiple of "padding" bytes. Additional bytes are filled with 0x20 (ASCII space)
|
|
9
|
+
*
|
|
10
|
+
* @return new byteOffset of resulting dataView
|
|
11
|
+
*/
|
|
12
|
+
export declare function copyPaddedArrayBufferToDataView(dataView: DataView | null, byteOffset: number, sourceBuffer: TypedArray, padding: number): number;
|
|
13
|
+
/**
|
|
14
|
+
* Copy string to dataView with some padding
|
|
15
|
+
*
|
|
16
|
+
* @param {DataView | null} dataView - destination data container. If null - only new offset is calculated
|
|
17
|
+
* @param {number} byteOffset - destination byte offset to copy to
|
|
18
|
+
* @param {string} string - source string
|
|
19
|
+
* @param {number} padding - pad the resulting array to multiple of "padding" bytes. Additional bytes are filled with 0x20 (ASCII space)
|
|
20
|
+
*
|
|
21
|
+
* @return new byteOffset of resulting dataView
|
|
22
|
+
*/
|
|
23
|
+
export declare function copyPaddedStringToDataView(dataView: DataView | null, byteOffset: number, string: string, padding: number): number;
|
|
24
|
+
//# sourceMappingURL=binary-copy-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binary-copy-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-utils/binary-copy-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAGvC;;;;;;;;;GASG;AACH,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,QAAQ,GAAG,IAAI,EACzB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,UAAU,EACxB,OAAO,EAAE,MAAM,UAuBhB;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,QAAQ,GAAG,IAAI,EACzB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GACd,MAAM,CASR"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* Check for Node.js `Buffer` (without triggering bundler to include Buffer polyfill on browser)
|
|
4
|
+
*/
|
|
5
|
+
export declare function isBuffer(value: any): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Converts to Node.js `Buffer` (without triggering bundler to include Buffer polyfill on browser)
|
|
8
|
+
* @todo better data type
|
|
9
|
+
*/
|
|
10
|
+
export declare function toBuffer(data: any): Buffer;
|
|
11
|
+
/**
|
|
12
|
+
* Converts Node.js `Buffer` to `ArrayBuffer` (without triggering bundler to include Buffer polyfill on browser)
|
|
13
|
+
* @todo better data type
|
|
14
|
+
*/
|
|
15
|
+
export declare function bufferToArrayBuffer(buffer: any): ArrayBuffer;
|
|
16
|
+
//# sourceMappingURL=buffer-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-utils/buffer-utils.ts"],"names":[],"mappings":";AAEA;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAE5C;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAE1C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,GAAG,WAAW,CAM5D"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function padStringToByteAlignment(string: any, byteAlignment: any): string;
|
|
2
|
+
export declare function copyStringToDataView(dataView: any, byteOffset: any, string: any, byteLength: any): any;
|
|
3
|
+
export declare function copyBinaryToDataView(dataView: any, byteOffset: any, binary: any, byteLength: any): any;
|
|
4
|
+
//# sourceMappingURL=encode-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-utils/encode-utils.ts"],"names":[],"mappings":"AAIA,wBAAgB,wBAAwB,CAAC,MAAM,KAAA,EAAE,aAAa,KAAA,UAS7D;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,KAAA,EAAE,UAAU,KAAA,EAAE,MAAM,KAAA,EAAE,UAAU,KAAA,OAO5E;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,KAAA,EAAE,UAAU,KAAA,EAAE,MAAM,KAAA,EAAE,UAAU,KAAA,OAO5E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-first-characters.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-utils/get-first-characters.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,IAAI,KAAA,EAAE,MAAM,SAAI,GAAG,MAAM,CAW3D;AAED,wBAAgB,cAAc,CAC5B,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,MAAM,CAUR"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate new size of an arrayBuffer to be aligned to an n-byte boundary
|
|
3
|
+
* This function increases `byteLength` by the minimum delta,
|
|
4
|
+
* allowing the total length to be divided by `padding`
|
|
5
|
+
* @param byteLength
|
|
6
|
+
* @param padding
|
|
7
|
+
*/
|
|
8
|
+
export declare function padToNBytes(byteLength: number, padding: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new Uint8Array based on two different ArrayBuffers
|
|
11
|
+
* @param targetBuffer The first buffer.
|
|
12
|
+
* @param sourceBuffer The second buffer.
|
|
13
|
+
* @return The new ArrayBuffer created out of the two.
|
|
14
|
+
*/
|
|
15
|
+
export declare function copyArrayBuffer(targetBuffer: ArrayBuffer, sourceBuffer: ArrayBuffer, byteOffset: number, byteLength?: number): ArrayBuffer;
|
|
16
|
+
/**
|
|
17
|
+
* Copy from source to target at the targetOffset
|
|
18
|
+
*
|
|
19
|
+
* @param source - The data to copy
|
|
20
|
+
* @param target - The destination to copy data into
|
|
21
|
+
* @param targetOffset - The start offset into target to place the copied data
|
|
22
|
+
* @returns the new offset taking into account proper padding
|
|
23
|
+
*/
|
|
24
|
+
export declare function copyToArray(source: ArrayBuffer | any, target: any, targetOffset: number): number;
|
|
25
|
+
//# sourceMappingURL=memory-copy-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-copy-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-utils/memory-copy-utils.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAIvE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,WAAW,EACzB,YAAY,EAAE,WAAW,EACzB,UAAU,EAAE,MAAM,EAClB,UAAU,GAAE,MAAgC,GAC3C,WAAW,CAKb;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAuBhG"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throws an `Error` with the optional `message` if `condition` is falsy
|
|
3
|
+
* @note Replacement for the external assert method to reduce bundle size
|
|
4
|
+
*/
|
|
5
|
+
export declare function assert(condition: any, message?: string): void;
|
|
6
|
+
//# sourceMappingURL=assert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../src/lib/env-utils/assert.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,MAAM,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAI7D"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare type obj = {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
};
|
|
4
|
+
declare const self_: obj;
|
|
5
|
+
declare const window_: obj;
|
|
6
|
+
declare const global_: obj;
|
|
7
|
+
declare const document_: obj;
|
|
8
|
+
export { self_ as self, window_ as window, global_ as global, document_ as document };
|
|
9
|
+
/** true if running in a browser */
|
|
10
|
+
export declare const isBrowser: boolean;
|
|
11
|
+
/** true if running in a worker thread */
|
|
12
|
+
export declare const isWorker: boolean;
|
|
13
|
+
/** Major Node version (as a number) */
|
|
14
|
+
export declare const nodeVersion: number;
|
|
15
|
+
//# sourceMappingURL=globals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../../../src/lib/env-utils/globals.ts"],"names":[],"mappings":"AAWA,aAAK,GAAG,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC,CAAC;AAChC,QAAA,MAAM,KAAK,EAAE,GAA4D,CAAC;AAC1E,QAAA,MAAM,OAAO,EAAE,GAA4D,CAAC;AAC5E,QAAA,MAAM,OAAO,EAAE,GAA4D,CAAC;AAC5E,QAAA,MAAM,SAAS,EAAE,GAA4B,CAAC;AAE9C,OAAO,EAAC,KAAK,IAAI,IAAI,EAAE,OAAO,IAAI,MAAM,EAAE,OAAO,IAAI,MAAM,EAAE,SAAS,IAAI,QAAQ,EAAC,CAAC;AAEpF,mCAAmC;AACnC,eAAO,MAAM,SAAS,EAAE,OAE2E,CAAC;AAEpG,yCAAyC;AACzC,eAAO,MAAM,QAAQ,EAAE,OAA6C,CAAC;AAKrE,uCAAuC;AACvC,eAAO,MAAM,WAAW,EAAE,MAAiD,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as fs from '../node/fs';
|
|
3
|
+
import { IFileSystem, IRandomAccessReadFileSystem } from '../../types';
|
|
4
|
+
declare type Stat = {
|
|
5
|
+
size: number;
|
|
6
|
+
isDirectory: () => boolean;
|
|
7
|
+
info?: fs.Stats;
|
|
8
|
+
};
|
|
9
|
+
declare type ReadOptions = {
|
|
10
|
+
buffer?: Buffer;
|
|
11
|
+
offset?: number;
|
|
12
|
+
length?: number;
|
|
13
|
+
position?: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* FileSystem pass-through for Node.js
|
|
17
|
+
* Compatible with BrowserFileSystem.
|
|
18
|
+
* @param options
|
|
19
|
+
*/
|
|
20
|
+
export default class NodeFileSystem implements IFileSystem, IRandomAccessReadFileSystem {
|
|
21
|
+
constructor(options: {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
});
|
|
24
|
+
readdir(dirname?: string, options?: {}): Promise<any[]>;
|
|
25
|
+
stat(path: string, options?: {}): Promise<Stat>;
|
|
26
|
+
fetch(path: string, options: {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
}): Promise<any>;
|
|
29
|
+
open(path: string, flags: string | number, mode?: any): Promise<number>;
|
|
30
|
+
close(fd: number): Promise<void>;
|
|
31
|
+
fstat(fd: number): Promise<Stat>;
|
|
32
|
+
read(fd: number, { buffer, offset, length, position }: ReadOptions): Promise<{
|
|
33
|
+
bytesRead: number;
|
|
34
|
+
buffer: Buffer;
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=node-filesystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-filesystem.d.ts","sourceRoot":"","sources":["../../../src/lib/filesystems/node-filesystem.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAC,WAAW,EAAE,2BAA2B,EAAC,MAAM,aAAa,CAAC;AAIrE,aAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,OAAO,CAAC;IAC3B,IAAI,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC;CACjB,CAAC;AAEF,aAAK,WAAW,GAAG;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,YAAW,WAAW,EAAE,2BAA2B;gBAEzE,OAAO,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC;IAInC,OAAO,CAAC,OAAO,SAAM,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAIpD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/C,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC;IAQjD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAIvE,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhC,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhC,IAAI,CACR,EAAE,EAAE,MAAM,EAEV,EAAC,MAAa,EAAE,MAAU,EAAE,MAA0B,EAAE,QAAe,EAAC,EAAE,WAAW,GACpF,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,CAAC;CAehD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Iterate over async iterator, without resetting iterator if end is not reached
|
|
3
|
+
* - forEach intentionally does not reset iterator if exiting loop prematurely
|
|
4
|
+
* so that iteration can continue in a second loop
|
|
5
|
+
* - It is recommended to use a standard for-await as last loop to ensure
|
|
6
|
+
* iterator gets properly reset
|
|
7
|
+
*
|
|
8
|
+
* TODO - optimize using sync iteration if argument is an Iterable?
|
|
9
|
+
*
|
|
10
|
+
* @param iterator
|
|
11
|
+
* @param visitor
|
|
12
|
+
*/
|
|
13
|
+
export declare function forEach(iterator: any, visitor: any): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Concatenates all data chunks yielded by an (async) iterator
|
|
16
|
+
* This function can e.g. be used to enable atomic parsers to work on (async) iterator inputs
|
|
17
|
+
*/
|
|
18
|
+
export declare function concatenateArrayBuffersAsync(asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>): Promise<ArrayBuffer>;
|
|
19
|
+
export declare function concatenateStringsAsync(asyncIterator: AsyncIterable<string> | Iterable<string>): Promise<string>;
|
|
20
|
+
//# sourceMappingURL=async-iteration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-iteration.d.ts","sourceRoot":"","sources":["../../../src/lib/iterators/async-iteration.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,wBAAsB,OAAO,CAAC,QAAQ,KAAA,EAAE,OAAO,KAAA,iBAa9C;AAID;;;GAGG;AAEH,wBAAsB,4BAA4B,CAChD,aAAa,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,GAChE,OAAO,CAAC,WAAW,CAAC,CAMtB;AAED,wBAAsB,uBAAuB,CAC3C,aAAa,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,GACtD,OAAO,CAAC,MAAM,CAAC,CAMjB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare function makeTextDecoderIterator(arrayBufferIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>, options?: TextDecoderOptions): AsyncIterable<string>;
|
|
2
|
+
export declare function makeTextEncoderIterator(textIterator: AsyncIterable<string> | Iterable<ArrayBuffer>): AsyncIterable<ArrayBuffer>;
|
|
3
|
+
/**
|
|
4
|
+
* @param textIterator async iterable yielding strings
|
|
5
|
+
* @returns an async iterable over lines
|
|
6
|
+
* See http://2ality.com/2018/04/async-iter-nodejs.html
|
|
7
|
+
*/
|
|
8
|
+
export declare function makeLineIterator(textIterator: AsyncIterable<string>): AsyncIterable<string>;
|
|
9
|
+
/**
|
|
10
|
+
* @param lineIterator async iterable yielding lines
|
|
11
|
+
* @returns async iterable yielding numbered lines
|
|
12
|
+
*
|
|
13
|
+
* See http://2ality.com/2018/04/async-iter-nodejs.html
|
|
14
|
+
*/
|
|
15
|
+
export declare function makeNumberedLineIterator(lineIterator: AsyncIterable<string>): AsyncIterable<{
|
|
16
|
+
counter: number;
|
|
17
|
+
line: string;
|
|
18
|
+
}>;
|
|
19
|
+
//# sourceMappingURL=text-iterators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-iterators.d.ts","sourceRoot":"","sources":["../../../src/lib/iterators/text-iterators.ts"],"names":[],"mappings":"AAGA,wBAAuB,uBAAuB,CAC5C,mBAAmB,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,EACvE,OAAO,GAAE,kBAAuB,GAC/B,aAAa,CAAC,MAAM,CAAC,CAOvB;AAOD,wBAAuB,uBAAuB,CAC5C,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,GAC1D,aAAa,CAAC,WAAW,CAAC,CAK5B;AAED;;;;GAIG;AAEH,wBAAuB,gBAAgB,CACrC,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,GAClC,aAAa,CAAC,MAAM,CAAC,CAgBvB;AAED;;;;;GAKG;AACH,wBAAuB,wBAAwB,CAC7C,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,GAClC,aAAa,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,CAAC,CAMhD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* Convert Buffer to ArrayBuffer
|
|
4
|
+
*/
|
|
5
|
+
export declare function toArrayBuffer(buffer: any): any;
|
|
6
|
+
/**
|
|
7
|
+
* Convert (copy) ArrayBuffer to Buffer
|
|
8
|
+
*/
|
|
9
|
+
export declare function toBuffer(binaryData: any): void | Buffer;
|
|
10
|
+
//# sourceMappingURL=buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../src/lib/node/buffer.ts"],"names":[],"mappings":";AAKA;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,KAAA,OAOnC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,UAAU,KAAA,iBAelC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type { Stats } from 'fs';
|
|
2
|
+
export declare let readdir: any;
|
|
3
|
+
/** Wrapper for Node.js fs method */
|
|
4
|
+
export declare let stat: any;
|
|
5
|
+
/** Wrapper for Node.js fs method */
|
|
6
|
+
export declare let readFile: any;
|
|
7
|
+
/** Wrapper for Node.js fs method */
|
|
8
|
+
export declare let readFileSync: any;
|
|
9
|
+
/** Wrapper for Node.js fs method */
|
|
10
|
+
export declare let writeFile: any;
|
|
11
|
+
/** Wrapper for Node.js fs method */
|
|
12
|
+
export declare let writeFileSync: any;
|
|
13
|
+
/** Wrapper for Node.js fs method */
|
|
14
|
+
export declare let open: any;
|
|
15
|
+
/** Wrapper for Node.js fs method */
|
|
16
|
+
export declare let close: any;
|
|
17
|
+
/** Wrapper for Node.js fs method */
|
|
18
|
+
export declare let read: any;
|
|
19
|
+
/** Wrapper for Node.js fs method */
|
|
20
|
+
export declare let fstat: any;
|
|
21
|
+
export declare let isSupported: boolean;
|
|
22
|
+
export declare function _readToArrayBuffer(fd: number, start: number, length: number): Promise<any>;
|
|
23
|
+
//# sourceMappingURL=fs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/lib/node/fs.ts"],"names":[],"mappings":"AAKA,YAAY,EAAC,KAAK,EAAC,MAAM,IAAI,CAAC;AAE9B,eAAO,IAAI,OAAO,KAAA,CAAC;AACnB,oCAAoC;AACpC,eAAO,IAAI,IAAI,KAAA,CAAC;AAEhB,oCAAoC;AACpC,eAAO,IAAI,QAAQ,KAAA,CAAC;AACpB,oCAAoC;AACpC,eAAO,IAAI,YAAY,KAAA,CAAC;AACxB,oCAAoC;AACpC,eAAO,IAAI,SAAS,KAAA,CAAC;AACrB,oCAAoC;AACpC,eAAO,IAAI,aAAa,KAAA,CAAC;AAIzB,oCAAoC;AACpC,eAAO,IAAI,IAAI,KAAA,CAAC;AAChB,oCAAoC;AACpC,eAAO,IAAI,KAAK,KAAA,CAAC;AACjB,oCAAoC;AACpC,eAAO,IAAI,IAAI,KAAA,CAAC;AAChB,oCAAoC;AACpC,eAAO,IAAI,KAAK,KAAA,CAAC;AAEjB,eAAO,IAAI,WAAW,SAAc,CAAC;AAmCrC,wBAAsB,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAOjF"}
|
package/dist/lib/node/fs.js
CHANGED
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import { toArrayBuffer } from './buffer';
|
|
3
3
|
import { promisify } from './util';
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
4
|
+
export let readdir;
|
|
5
|
+
export let stat;
|
|
6
|
+
export let readFile;
|
|
7
|
+
export let readFileSync;
|
|
8
|
+
export let writeFile;
|
|
9
|
+
export let writeFileSync;
|
|
10
|
+
export let open;
|
|
11
|
+
export let close;
|
|
12
|
+
export let read;
|
|
13
|
+
export let fstat;
|
|
14
|
+
export let isSupported = Boolean(fs);
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
readdir = promisify(fs.readdir);
|
|
18
|
+
stat = promisify(fs.stat);
|
|
19
|
+
readFile = promisify(fs.readFile);
|
|
20
|
+
readFileSync = fs.readFileSync;
|
|
21
|
+
writeFile = promisify(fs.writeFile);
|
|
22
|
+
writeFileSync = fs.writeFileSync;
|
|
23
|
+
open = promisify(fs.open);
|
|
24
|
+
close = promisify(fs.close);
|
|
25
|
+
read = promisify(fs.read);
|
|
26
|
+
fstat = promisify(fs.fstat);
|
|
27
|
+
isSupported = Boolean(fs);
|
|
28
|
+
} catch {}
|
|
29
|
+
|
|
15
30
|
export async function _readToArrayBuffer(fd, start, length) {
|
|
16
31
|
const buffer = Buffer.alloc(length);
|
|
17
32
|
const {
|
package/dist/lib/node/fs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/node/fs.ts"],"names":["fs","toArrayBuffer","promisify","readdir","stat","readFile","readFileSync","writeFile","writeFileSync","open","close","read","fstat","isSupported","Boolean","_readToArrayBuffer","fd","start","length","buffer","Buffer","alloc","bytesRead","Error"],"mappings":"AACA,OAAOA,EAAP,MAAe,IAAf;AACA,SAAQC,aAAR,QAA4B,UAA5B;AACA,SAAQC,SAAR,QAAwB,QAAxB;
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/node/fs.ts"],"names":["fs","toArrayBuffer","promisify","readdir","stat","readFile","readFileSync","writeFile","writeFileSync","open","close","read","fstat","isSupported","Boolean","_readToArrayBuffer","fd","start","length","buffer","Buffer","alloc","bytesRead","Error"],"mappings":"AACA,OAAOA,EAAP,MAAe,IAAf;AACA,SAAQC,aAAR,QAA4B,UAA5B;AACA,SAAQC,SAAR,QAAwB,QAAxB;AAIA,OAAO,IAAIC,OAAJ;AAEP,OAAO,IAAIC,IAAJ;AAGP,OAAO,IAAIC,QAAJ;AAEP,OAAO,IAAIC,YAAJ;AAEP,OAAO,IAAIC,SAAJ;AAEP,OAAO,IAAIC,aAAJ;AAKP,OAAO,IAAIC,IAAJ;AAEP,OAAO,IAAIC,KAAJ;AAEP,OAAO,IAAIC,IAAJ;AAEP,OAAO,IAAIC,KAAJ;AAEP,OAAO,IAAIC,WAAW,GAAGC,OAAO,CAACd,EAAD,CAAzB;;AAIP,IAAI;AAEFG,EAAAA,OAAO,GAAGD,SAAS,CAACF,EAAE,CAACG,OAAJ,CAAnB;AAEAC,EAAAA,IAAI,GAAGF,SAAS,CAACF,EAAE,CAACI,IAAJ,CAAhB;AAGAC,EAAAA,QAAQ,GAAGH,SAAS,CAACF,EAAE,CAACK,QAAJ,CAApB;AAEAC,EAAAA,YAAY,GAAGN,EAAE,CAACM,YAAlB;AAEAC,EAAAA,SAAS,GAAGL,SAAS,CAACF,EAAE,CAACO,SAAJ,CAArB;AAEAC,EAAAA,aAAa,GAAGR,EAAE,CAACQ,aAAnB;AAKAC,EAAAA,IAAI,GAAGP,SAAS,CAACF,EAAE,CAACS,IAAJ,CAAhB;AAEAC,EAAAA,KAAK,GAAGR,SAAS,CAACF,EAAE,CAACU,KAAJ,CAAjB;AAEAC,EAAAA,IAAI,GAAGT,SAAS,CAACF,EAAE,CAACW,IAAJ,CAAhB;AAEAC,EAAAA,KAAK,GAAGV,SAAS,CAACF,EAAE,CAACY,KAAJ,CAAjB;AAEAC,EAAAA,WAAW,GAAGC,OAAO,CAACd,EAAD,CAArB;AACD,CA3BD,CA2BE,MAAM,CAEP;;AAED,OAAO,eAAee,kBAAf,CAAkCC,EAAlC,EAA8CC,KAA9C,EAA6DC,MAA7D,EAA6E;AAClF,QAAMC,MAAM,GAAGC,MAAM,CAACC,KAAP,CAAaH,MAAb,CAAf;AACA,QAAM;AAACI,IAAAA;AAAD,MAAc,MAAMX,IAAI,CAACK,EAAD,EAAKG,MAAL,EAAa,CAAb,EAAgBD,MAAhB,EAAwBD,KAAxB,CAA9B;;AACA,MAAIK,SAAS,KAAKJ,MAAlB,EAA0B;AACxB,UAAM,IAAIK,KAAJ,CAAU,gBAAV,CAAN;AACD;;AACD,SAAOtB,aAAa,CAACkB,MAAD,CAApB;AACD","sourcesContent":["// fs wrapper (promisified fs + avoids bundling fs in browsers)\nimport fs from 'fs';\nimport {toArrayBuffer} from './buffer';\nimport {promisify} from './util';\n\nexport type {Stats} from 'fs';\n\nexport let readdir;\n/** Wrapper for Node.js fs method */\nexport let stat;\n\n/** Wrapper for Node.js fs method */\nexport let readFile;\n/** Wrapper for Node.js fs method */\nexport let readFileSync;\n/** Wrapper for Node.js fs method */\nexport let writeFile;\n/** Wrapper for Node.js fs method */\nexport let writeFileSync;\n\n// file descriptors\n\n/** Wrapper for Node.js fs method */\nexport let open;\n/** Wrapper for Node.js fs method */\nexport let close;\n/** Wrapper for Node.js fs method */\nexport let read;\n/** Wrapper for Node.js fs method */\nexport let fstat;\n\nexport let isSupported = Boolean(fs);\n\n// paths\n\ntry {\n /** Wrapper for Node.js fs method */\n readdir = promisify(fs.readdir);\n /** Wrapper for Node.js fs method */\n stat = promisify(fs.stat);\n\n /** Wrapper for Node.js fs method */\n readFile = promisify(fs.readFile);\n /** Wrapper for Node.js fs method */\n readFileSync = fs.readFileSync;\n /** Wrapper for Node.js fs method */\n writeFile = promisify(fs.writeFile);\n /** Wrapper for Node.js fs method */\n writeFileSync = fs.writeFileSync;\n\n // file descriptors\n\n /** Wrapper for Node.js fs method */\n open = promisify(fs.open);\n /** Wrapper for Node.js fs method */\n close = promisify(fs.close);\n /** Wrapper for Node.js fs method */\n read = promisify(fs.read);\n /** Wrapper for Node.js fs method */\n fstat = promisify(fs.fstat);\n\n isSupported = Boolean(fs);\n} catch {\n // ignore\n}\n\nexport async function _readToArrayBuffer(fd: number, start: number, length: number) {\n const buffer = Buffer.alloc(length);\n const {bytesRead} = await read(fd, buffer, 0, length, start);\n if (bytesRead !== length) {\n throw new Error('fs.read failed');\n }\n return toArrayBuffer(buffer);\n}\n"],"file":"fs.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/lib/node/util.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,oCAAoC;AACpC,eAAO,MAAM,SAAS,uBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-json.d.ts","sourceRoot":"","sources":["../../../src/lib/parser-utils/parse-json.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAM7C"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare function setPathPrefix(prefix: string): void;
|
|
2
|
+
export declare function getPathPrefix(): string;
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param aliases
|
|
6
|
+
*
|
|
7
|
+
* Note: addAliases are an experimental export, they are only for testing of loaders.gl loaders
|
|
8
|
+
* not intended as a generic aliasing mechanism
|
|
9
|
+
*/
|
|
10
|
+
export declare function addAliases(aliases: {
|
|
11
|
+
[aliasPath: string]: string;
|
|
12
|
+
}): void;
|
|
13
|
+
/**
|
|
14
|
+
* Resolves aliases and adds path-prefix to paths
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolvePath(filename: string): string;
|
|
17
|
+
//# sourceMappingURL=file-aliases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-aliases.d.ts","sourceRoot":"","sources":["../../../src/lib/path-utils/file-aliases.ts"],"names":[],"mappings":"AAQA,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAElD;AAKD,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE;IAAC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC,GAAG,IAAI,CAEvE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAWpD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replacement for Node.js path.filename
|
|
3
|
+
* @param url
|
|
4
|
+
*/
|
|
5
|
+
export declare function filename(url: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Replacement for Node.js path.dirname
|
|
8
|
+
* @param url
|
|
9
|
+
*/
|
|
10
|
+
export declare function dirname(url: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Replacement for Node.js path.join
|
|
13
|
+
* @param parts
|
|
14
|
+
*/
|
|
15
|
+
export declare function join(...parts: string[]): string;
|
|
16
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/lib/path-utils/path.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG3C;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAY/C"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Stats } from '@probe.gl/stats';
|
|
2
|
+
declare type Handle = any;
|
|
3
|
+
declare type DoneFunction = () => any;
|
|
4
|
+
declare type GetPriorityFunction = () => number;
|
|
5
|
+
declare type RequestResult = {
|
|
6
|
+
done: DoneFunction;
|
|
7
|
+
} | null;
|
|
8
|
+
/** RequestScheduler Options */
|
|
9
|
+
export declare type RequestSchedulerProps = {
|
|
10
|
+
id?: string;
|
|
11
|
+
throttleRequests?: boolean;
|
|
12
|
+
maxRequests?: number;
|
|
13
|
+
};
|
|
14
|
+
/** Tracks one request */
|
|
15
|
+
declare type Request = {
|
|
16
|
+
handle: Handle;
|
|
17
|
+
priority: number;
|
|
18
|
+
getPriority: GetPriorityFunction;
|
|
19
|
+
resolve?: (value: any) => any;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Used to issue a request, without having them "deeply queued" by the browser.
|
|
23
|
+
* @todo - Track requests globally, across multiple servers
|
|
24
|
+
*/
|
|
25
|
+
export default class RequestScheduler {
|
|
26
|
+
readonly props: Required<RequestSchedulerProps>;
|
|
27
|
+
readonly stats: Stats;
|
|
28
|
+
activeRequestCount: number;
|
|
29
|
+
/** Tracks the number of active requests and prioritizes/cancels queued requests. */
|
|
30
|
+
private requestQueue;
|
|
31
|
+
private requestMap;
|
|
32
|
+
private deferredUpdate;
|
|
33
|
+
constructor(props?: RequestSchedulerProps);
|
|
34
|
+
/**
|
|
35
|
+
* Called by an application that wants to issue a request, without having it deeply queued by the browser
|
|
36
|
+
*
|
|
37
|
+
* When the returned promise resolved, it is OK for the application to issue a request.
|
|
38
|
+
* The promise resolves to an object that contains a `done` method.
|
|
39
|
+
* When the application's request has completed (or failed), the application must call the `done` function
|
|
40
|
+
*
|
|
41
|
+
* @param handle
|
|
42
|
+
* @param getPriority will be called when request "slots" open up,
|
|
43
|
+
* allowing the caller to update priority or cancel the request
|
|
44
|
+
* Highest priority executes first, priority < 0 cancels the request
|
|
45
|
+
* @returns a promise
|
|
46
|
+
* - resolves to a object (with a `done` field) when the request can be issued without queueing,
|
|
47
|
+
* - resolves to `null` if the request has been cancelled (by the callback return < 0).
|
|
48
|
+
* In this case the application should not issue the request
|
|
49
|
+
*/
|
|
50
|
+
scheduleRequest(handle: Handle, getPriority?: GetPriorityFunction): Promise<RequestResult>;
|
|
51
|
+
_issueRequest(request: Request): Promise<any>;
|
|
52
|
+
/** We check requests asynchronously, to prevent multiple updates */
|
|
53
|
+
_issueNewRequests(): void;
|
|
54
|
+
/** Refresh all requests */
|
|
55
|
+
_issueNewRequestsAsync(): void;
|
|
56
|
+
/** Ensure all requests have updated priorities, and that no longer valid requests are cancelled */
|
|
57
|
+
_updateAllRequests(): void;
|
|
58
|
+
/** Update a single request by calling the callback */
|
|
59
|
+
_updateRequest(request: any): boolean;
|
|
60
|
+
}
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=request-scheduler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-scheduler.d.ts","sourceR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IAAI,IAAI;IAMzB,4BAA4B;IAC5B,sBAAsB;IAwBtB,mGAAmG;IACnG,kBAAkB;IAgBlB,sDAAsD;IACtD,cAAc,CAAC,OAAO,KAAA;CAUvB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LoaderWithParser } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Set up a WebWorkerGlobalScope to talk with the main thread
|
|
4
|
+
* @param loader
|
|
5
|
+
*/
|
|
6
|
+
export declare function createLoaderWorker(loader: LoaderWithParser): void;
|
|
7
|
+
//# sourceMappingURL=create-loader-worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-loader-worker.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-loader-utils/create-loader-worker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,aAAa,CAAC;AAMlD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,QA+B1D"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Loader, LoaderOptions, LoaderContext } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Determines if a loader can parse with worker
|
|
4
|
+
* @param loader
|
|
5
|
+
* @param options
|
|
6
|
+
*/
|
|
7
|
+
export declare function canParseWithWorker(loader: Loader, options?: LoaderOptions): boolean | "" | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* this function expects that the worker function sends certain messages,
|
|
10
|
+
* this can be automated if the worker is wrapper by a call to createLoaderWorker in @loaders.gl/loader-utils.
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseWithWorker(loader: Loader, data: any, options?: LoaderOptions, context?: LoaderContext, parseOnMainThread?: (arrayBuffer: ArrayBuffer, options: {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}) => Promise<void>): Promise<any>;
|
|
15
|
+
//# sourceMappingURL=parse-with-worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-with-worker.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-loader-utils/parse-with-worker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAE,aAAa,EAAC,MAAM,aAAa,CAAC;AAGtE;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,4BAMzE;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,GAAG,EACT,OAAO,CAAC,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,aAAa,EACvB,iBAAiB,CAAC,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,gBA2B/F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/worker-loader-utils/parse-with-worker.ts"],"names":["WorkerFarm","getWorkerURL","canParseWithWorker","loader","options","isSupported","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"],"mappings":"AAEA,SAAQA,UAAR,EAAoBC,YAApB,QAAuC,0BAAvC;AAOA,OAAO,SAASC,kBAAT,CAA4BC,MAA5B,EAA4CC,OAA5C,EAAqE;AAC1E,MAAI,CAACJ,UAAU,CAACK,WAAX,EAAL,EAA+B;AAC7B,WAAO,KAAP;AACD;;AAED,SAAOF,MAAM,CAACG,MAAP,KAAiBF,OAAjB,aAAiBA,OAAjB,uBAAiBA,OAAO,CAAEE,MAA1B,CAAP;AACD;AAMD,OAAO,eAAeC,eAAf,CACLJ,MADK,EAELK,IAFK,EAGLJ,OAHK,EAILK,OAJK,EAKLC,iBALK,EA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CAAgB,MAAhB,EAAwB;AAACb,UAAAA,EAAD;AAAKe,UAAAA;AAAL,SAAxB;AACD,OAHD,CAGE,OAAOI,KAAP,EAAc;AACd,cAAME,OAAO,GAAGF,KAAK,YAAYC,KAAjB,GAAyBD,KAAK,CAACE,OAA/B,GAAyC,eAAzD;AACAZ,QAAAA,GAAG,CAACI,WAAJ,CAAgB,OAAhB,EAAyB;AAACb,UAAAA,EAAD;AAAKmB,UAAAA,KAAK,EAAEE;AAAZ,SAAzB;AACD;;AACD;;AAEF;AAEEC,MAAAA,OAAO,CAACC,IAAR,6CAAkDP,IAAlD;AAvBJ;AAyBD","sourcesContent":["import type {WorkerJob, WorkerMessageType, WorkerMessagePayload} 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 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<void>\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 // TODO - decide how to handle logging on workers\n options = JSON.parse(JSON.stringify(options));\n\n const job = await workerPool.startJob(\n 'process-on-worker',\n // @ts-expect-error\n onMessage.bind(null, parseOnMainThread) // eslint-disable-
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/worker-loader-utils/parse-with-worker.ts"],"names":["WorkerFarm","getWorkerURL","canParseWithWorker","loader","options","isSupported","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"],"mappings":"AAEA,SAAQA,UAAR,EAAoBC,YAApB,QAAuC,0BAAvC;AAOA,OAAO,SAASC,kBAAT,CAA4BC,MAA5B,EAA4CC,OAA5C,EAAqE;AAC1E,MAAI,CAACJ,UAAU,CAACK,WAAX,EAAL,EAA+B;AAC7B,WAAO,KAAP;AACD;;AAED,SAAOF,MAAM,CAACG,MAAP,KAAiBF,OAAjB,aAAiBA,OAAjB,uBAAiBA,OAAO,CAAEE,MAA1B,CAAP;AACD;AAMD,OAAO,eAAeC,eAAf,CACLJ,MADK,EAELK,IAFK,EAGLJ,OAHK,EAILK,OAJK,EAKLC,iBALK,EAML;AACA,QAAMC,IAAI,GAAGR,MAAM,CAACS,EAApB;AACA,QAAMC,GAAG,GAAGZ,YAAY,CAACE,MAAD,EAASC,OAAT,CAAxB;AAEA,QAAMU,UAAU,GAAGd,UAAU,CAACe,aAAX,CAAyBX,OAAzB,CAAnB;AACA,QAAMY,UAAU,GAAGF,UAAU,CAACG,aAAX,CAAyB;AAACN,IAAAA,IAAD;AAAOE,IAAAA;AAAP,GAAzB,CAAnB;AAIAT,EAAAA,OAAO,GAAGc,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,SAAL,CAAehB,OAAf,CAAX,CAAV;AAEA,QAAMiB,GAAG,GAAG,MAAML,UAAU,CAACM,QAAX,CAChB,mBADgB,EAGhBC,SAAS,CAACC,IAAV,CAAe,IAAf,EAAqBd,iBAArB,CAHgB,CAAlB;AAMAW,EAAAA,GAAG,CAACI,WAAJ,CAAgB,SAAhB,EAA2B;AAEzBC,IAAAA,KAAK,EAAElB,IAFkB;AAGzBJ,IAAAA;AAHyB,GAA3B;AAMA,QAAMuB,MAAM,GAAG,MAAMN,GAAG,CAACM,MAAzB;AAEA,SAAO,MAAMA,MAAM,CAACA,MAApB;AACD;;AAQD,eAAeJ,SAAf,CACEb,iBADF,EAEEW,GAFF,EAGEO,IAHF,EAIEC,OAJF,EAKE;AACA,UAAQD,IAAR;AACE,SAAK,MAAL;AACEP,MAAAA,GAAG,CAACS,IAAJ,CAASD,OAAT;AACA;;AAEF,SAAK,OAAL;AACER,MAAAA,GAAG,CAACU,KAAJ,CAAU,IAAIC,KAAJ,CAAUH,OAAO,CAACE,KAAlB,CAAV;AACA;;AAEF,SAAK,SAAL;AAEE,YAAM;AAACnB,QAAAA,EAAD;AAAKc,QAAAA,KAAL;AAAYtB,QAAAA;AAAZ,UAAuByB,OAA7B;;AACA,UAAI;AACF,cAAMF,MAAM,GAAG,MAAMjB,iBAAiB,CAACgB,KAAD,EAAQtB,OAAR,CAAtC;AACAiB,QAAAA,GAAG,CAACI,WAAJ,CAAgB,MAAhB,EAAwB;AAACb,UAAAA,EAAD;AAAKe,UAAAA;AAAL,SAAxB;AACD,OAHD,CAGE,OAAOI,KAAP,EAAc;AACd,cAAME,OAAO,GAAGF,KAAK,YAAYC,KAAjB,GAAyBD,KAAK,CAACE,OAA/B,GAAyC,eAAzD;AACAZ,QAAAA,GAAG,CAACI,WAAJ,CAAgB,OAAhB,EAAyB;AAACb,UAAAA,EAAD;AAAKmB,UAAAA,KAAK,EAAEE;AAAZ,SAAzB;AACD;;AACD;;AAEF;AAEEC,MAAAA,OAAO,CAACC,IAAR,6CAAkDP,IAAlD;AAvBJ;AAyBD","sourcesContent":["import type {WorkerJob, WorkerMessageType, WorkerMessagePayload} 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 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<void>\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 // TODO - decide how to handle logging on workers\n options = JSON.parse(JSON.stringify(options));\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 });\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"],"file":"parse-with-worker.js"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare type TypedIntArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Int32Array | Uint32Array;
|
|
3
|
+
export declare type TypedFloatArray = Uint16Array | Float32Array | Float64Array;
|
|
4
|
+
export declare type TypedArray = TypedIntArray | TypedFloatArray;
|
|
5
|
+
export declare type NumericArray = Array<number> | TypedIntArray | TypedFloatArray;
|
|
6
|
+
declare type FetchLike = (url: string, options?: RequestInit) => Promise<Response>;
|
|
7
|
+
export declare type LoaderOptions = {
|
|
8
|
+
/** fetch options or a custom fetch function */
|
|
9
|
+
fetch?: typeof fetch | FetchLike | RequestInit | null;
|
|
10
|
+
/** Do not throw on errors */
|
|
11
|
+
nothrow?: boolean;
|
|
12
|
+
/** loader selection, search first for supplied mimeType */
|
|
13
|
+
mimeType?: string;
|
|
14
|
+
/** loader selection, provide fallback mimeType is server does not provide */
|
|
15
|
+
fallbackMimeType?: string;
|
|
16
|
+
/** loader selection, avoid searching registered loaders */
|
|
17
|
+
ignoreRegisteredLoaders?: boolean;
|
|
18
|
+
/** Experimental: Supply a logger to the parser */
|
|
19
|
+
log?: any;
|
|
20
|
+
/** Size of each batch. `auto` matches batches to size of incoming chunks */
|
|
21
|
+
batchSize?: number | 'auto';
|
|
22
|
+
/** Minimal amount of time between batches */
|
|
23
|
+
batchDebounceMs?: number;
|
|
24
|
+
/** Stop loading after a given number of rows (compare SQL limit clause) */
|
|
25
|
+
limit?: 0;
|
|
26
|
+
/** Experimental: Stop loading after reaching */
|
|
27
|
+
_limitMB?: 0;
|
|
28
|
+
/** Generate metadata batches */
|
|
29
|
+
metadata?: boolean;
|
|
30
|
+
/** Transforms to run on incoming batches */
|
|
31
|
+
transforms?: TransformBatches[];
|
|
32
|
+
/** CDN load workers from */
|
|
33
|
+
CDN?: string;
|
|
34
|
+
/** Set to `false` to disable workers */
|
|
35
|
+
worker?: boolean;
|
|
36
|
+
/** Number of concurrent workers (per loader) on desktop browser */
|
|
37
|
+
maxConcurrency?: number;
|
|
38
|
+
/** Number of concurrent workers (per loader) on mobile browsers */
|
|
39
|
+
maxMobileConcurrency?: number;
|
|
40
|
+
/** Set to `false` to prevent reuse workers */
|
|
41
|
+
reuseWorkers?: boolean;
|
|
42
|
+
/** set to 'test' to run worker type */
|
|
43
|
+
_workerType?: string;
|
|
44
|
+
/** @deprecated `options.batchType` removed, Use `options.<loader>.type` instead */
|
|
45
|
+
batchType?: 'row' | 'columnar' | 'arrow';
|
|
46
|
+
/** @deprecated `options.throw removed`, Use `options.nothrow` instead */
|
|
47
|
+
throws?: boolean;
|
|
48
|
+
/** @deprecated `options.dataType` no longer used */
|
|
49
|
+
dataType?: any;
|
|
50
|
+
/** @deprecated `options.uri` no longer used */
|
|
51
|
+
uri?: any;
|
|
52
|
+
/** @deprecated `options.method` removed. Use `options.fetch.method` */
|
|
53
|
+
method?: any;
|
|
54
|
+
/** @deprecated `options.headers` removed. Use `options.fetch.headers` */
|
|
55
|
+
headers?: any;
|
|
56
|
+
/** @deprecated `options.body` removed. Use `options.fetch.body` */
|
|
57
|
+
body?: any;
|
|
58
|
+
/** @deprecated `options.mode` removed. Use `options.fetch.mode` */
|
|
59
|
+
mode?: any;
|
|
60
|
+
/** @deprecated `options.credentials` removed. Use `options.fetch.credentials` */
|
|
61
|
+
credentials?: any;
|
|
62
|
+
/** @deprecated `options.cache` removed. Use `options.fetch.cache` */
|
|
63
|
+
cache?: any;
|
|
64
|
+
/** @deprecated `options.redirect` removed. Use `options.fetch.redirect` */
|
|
65
|
+
redirect?: any;
|
|
66
|
+
/** @deprecated `options.referrer` removed. Use `options.fetch.referrer` */
|
|
67
|
+
referrer?: any;
|
|
68
|
+
/** @deprecated `options.referrerPolicy` removed. Use `options.fetch.referrerPolicy` */
|
|
69
|
+
referrerPolicy?: any;
|
|
70
|
+
/** @deprecated `options.integrity` removed. Use `options.fetch.integrity` */
|
|
71
|
+
integrity?: any;
|
|
72
|
+
/** @deprecated `options.keepalive` removed. Use `options.fetch.keepalive` */
|
|
73
|
+
keepalive?: any;
|
|
74
|
+
/** @deprecated `options.signal` removed. Use `options.fetch.signal` */
|
|
75
|
+
signal?: any;
|
|
76
|
+
[loaderId: string]: any;
|
|
77
|
+
};
|
|
78
|
+
declare type PreloadOptions = {
|
|
79
|
+
[key: string]: any;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* A worker loader definition that can be used with `@loaders.gl/core` functions
|
|
83
|
+
*/
|
|
84
|
+
export declare type Loader = {
|
|
85
|
+
name: string;
|
|
86
|
+
id: string;
|
|
87
|
+
module: string;
|
|
88
|
+
version: string;
|
|
89
|
+
worker?: string | boolean;
|
|
90
|
+
options: object;
|
|
91
|
+
deprecatedOptions?: object;
|
|
92
|
+
category?: string;
|
|
93
|
+
extensions: string[];
|
|
94
|
+
mimeTypes: string[];
|
|
95
|
+
binary?: boolean;
|
|
96
|
+
text?: boolean;
|
|
97
|
+
tests?: (((ArrayBuffer: any) => boolean) | ArrayBuffer | string)[];
|
|
98
|
+
supported?: boolean;
|
|
99
|
+
testText?: (string: any) => boolean;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* A "bundled" loader definition that can be used with `@loaders.gl/core` functions
|
|
103
|
+
* If a worker loader is supported it will also be supported.
|
|
104
|
+
*/
|
|
105
|
+
export declare type LoaderWithParser = Loader & {
|
|
106
|
+
testText?: (string: any) => boolean;
|
|
107
|
+
parse: Parse;
|
|
108
|
+
preload?: Preload;
|
|
109
|
+
parseSync?: ParseSync;
|
|
110
|
+
parseText?: ParseText;
|
|
111
|
+
parseTextSync?: ParseTextSync;
|
|
112
|
+
parseInBatches?: ParseInBatches;
|
|
113
|
+
parseFileInBatches?: ParseFileInBatches;
|
|
114
|
+
};
|
|
115
|
+
/** Options for writers */
|
|
116
|
+
export declare type WriterOptions = {};
|
|
117
|
+
/**
|
|
118
|
+
* A writer definition that can be used with `@loaders.gl/core` functions
|
|
119
|
+
*/
|
|
120
|
+
export declare type Writer = {
|
|
121
|
+
name: string;
|
|
122
|
+
id: string;
|
|
123
|
+
module: string;
|
|
124
|
+
version: string;
|
|
125
|
+
options: object;
|
|
126
|
+
deprecatedOptions?: object;
|
|
127
|
+
binary?: boolean;
|
|
128
|
+
extensions?: string[];
|
|
129
|
+
mimeTypes?: string[];
|
|
130
|
+
text?: boolean;
|
|
131
|
+
encode?: Encode;
|
|
132
|
+
encodeSync?: EncodeSync;
|
|
133
|
+
encodeInBatches?: EncodeInBatches;
|
|
134
|
+
encodeURLtoURL?: EncodeURLtoURL;
|
|
135
|
+
encodeText?: EncodeText;
|
|
136
|
+
};
|
|
137
|
+
export declare type LoaderContext = {
|
|
138
|
+
loaders?: Loader[] | null;
|
|
139
|
+
url?: string;
|
|
140
|
+
fetch: typeof fetch;
|
|
141
|
+
parse: (arrayBuffer: ArrayBuffer, loaders?: any, options?: LoaderOptions, context?: LoaderContext) => Promise<any>;
|
|
142
|
+
parseSync?: (arrayBuffer: ArrayBuffer, loaders?: any, options?: LoaderOptions, context?: LoaderContext) => any;
|
|
143
|
+
parseInBatches?: (iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>, loaders?: any, options?: LoaderOptions, context?: LoaderContext) => AsyncIterable<any> | Promise<AsyncIterable<any>>;
|
|
144
|
+
};
|
|
145
|
+
declare type Parse = (arrayBuffer: ArrayBuffer, options?: LoaderOptions, context?: LoaderContext) => Promise<any>;
|
|
146
|
+
declare type ParseSync = (arrayBuffer: ArrayBuffer, options?: LoaderOptions, context?: LoaderContext) => any;
|
|
147
|
+
declare type ParseText = (text: string, options?: LoaderOptions) => Promise<any>;
|
|
148
|
+
declare type ParseTextSync = (text: string, options?: LoaderOptions) => any;
|
|
149
|
+
declare type ParseInBatches = (iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>, options?: LoaderOptions, context?: LoaderContext) => AsyncIterable<any>;
|
|
150
|
+
declare type ParseFileInBatches = (file: Blob, options?: LoaderOptions, context?: LoaderContext) => AsyncIterable<any>;
|
|
151
|
+
declare type Encode = (data: any, options?: WriterOptions) => Promise<ArrayBuffer>;
|
|
152
|
+
declare type EncodeSync = (data: any, options?: WriterOptions) => ArrayBuffer;
|
|
153
|
+
declare type EncodeText = Function;
|
|
154
|
+
declare type EncodeInBatches = Function;
|
|
155
|
+
declare type EncodeURLtoURL = (inputUrl: string, outputUrl: string, options?: WriterOptions) => Promise<string>;
|
|
156
|
+
declare type Preload = (url: string, options?: PreloadOptions) => any;
|
|
157
|
+
export declare type TransformBatches = (asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>) => AsyncIterable<ArrayBuffer>;
|
|
158
|
+
/** Types that can be synchronously parsed */
|
|
159
|
+
export declare type SyncDataType = string | ArrayBuffer;
|
|
160
|
+
/** Types that can be parsed async */
|
|
161
|
+
export declare type DataType = string | ArrayBuffer | File | Blob | Response | ReadableStream | Iterable<ArrayBuffer> | AsyncIterable<ArrayBuffer>;
|
|
162
|
+
/** Types that can be parsed in batches */
|
|
163
|
+
export declare type BatchableDataType = DataType | Iterable<ArrayBuffer> | AsyncIterable<ArrayBuffer> | Promise<AsyncIterable<ArrayBuffer>>;
|
|
164
|
+
/**
|
|
165
|
+
* A FileSystem interface can encapsulate a FileList, a ZipFile, a GoogleDrive etc.
|
|
166
|
+
*/
|
|
167
|
+
export interface IFileSystem {
|
|
168
|
+
/**
|
|
169
|
+
* Return a list of file names
|
|
170
|
+
* @param dirname directory name. file system root directory if omitted
|
|
171
|
+
*/
|
|
172
|
+
readdir(dirname?: string, options?: {
|
|
173
|
+
recursive?: boolean;
|
|
174
|
+
}): Promise<string[]>;
|
|
175
|
+
/**
|
|
176
|
+
* Gets information from a local file from the filesystem
|
|
177
|
+
* @param filename file name to stat
|
|
178
|
+
* @param options currently unused
|
|
179
|
+
* @throws if filename is not in local filesystem
|
|
180
|
+
*/
|
|
181
|
+
stat(filename: string, options?: object): Promise<{
|
|
182
|
+
size: number;
|
|
183
|
+
}>;
|
|
184
|
+
/**
|
|
185
|
+
* Fetches a local file from the filesystem (or a URL)
|
|
186
|
+
* @param filename
|
|
187
|
+
* @param options
|
|
188
|
+
*/
|
|
189
|
+
fetch(filename: string, options?: object): Promise<Response>;
|
|
190
|
+
}
|
|
191
|
+
declare type ReadOptions = {
|
|
192
|
+
buffer?: ArrayBuffer;
|
|
193
|
+
offset?: number;
|
|
194
|
+
length?: number;
|
|
195
|
+
position?: number;
|
|
196
|
+
};
|
|
197
|
+
export interface IRandomAccessReadFileSystem extends IFileSystem {
|
|
198
|
+
open(path: string, flags: any, mode?: any): Promise<any>;
|
|
199
|
+
close(fd: any): Promise<void>;
|
|
200
|
+
fstat(fd: any): Promise<object>;
|
|
201
|
+
read(fd: any, options?: ReadOptions): Promise<{
|
|
202
|
+
bytesRead: number;
|
|
203
|
+
buffer: Buffer;
|
|
204
|
+
}>;
|
|
205
|
+
}
|
|
206
|
+
export {};
|
|
207
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAEA,oBAAY,aAAa,GACrB,SAAS,GACT,UAAU,GACV,iBAAiB,GACjB,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,CAAC;AAEhB,oBAAY,eAAe,GAAG,WAAW,GAAG,YAAY,GAAG,YAAY,CAAC;AAExE,oBAAY,UAAU,GAAG,aAAa,GAAG,eAAe,CAAC;AAEzD,oBAAY,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,aAAa,GAAG,eAAe,CAAC;AAE3E,aAAK,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAG3E,oBAAY,aAAa,GAAG;IAC1B,+CAA+C;IAC/C,KAAK,CAAC,EAAE,OAAO,KAAK,GAAG,SAAS,GAAG,WAAW,GAAG,IAAI,CAAC;IACtD,6BAA6B;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IA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|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/loader-utils",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.5",
|
|
4
4
|
"description": "Framework-independent loaders for 3D graphics formats",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"mesh",
|
|
18
18
|
"point cloud"
|
|
19
19
|
],
|
|
20
|
-
"types": "
|
|
20
|
+
"types": "dist/index.d.ts",
|
|
21
21
|
"main": "dist/index.js",
|
|
22
22
|
"module": "dist/index.js",
|
|
23
23
|
"sideEffects": false,
|
|
@@ -42,14 +42,11 @@
|
|
|
42
42
|
"fs": false,
|
|
43
43
|
"util": false
|
|
44
44
|
},
|
|
45
|
-
"scripts": {
|
|
46
|
-
"pre-build-disabled": "npm run build-bundle",
|
|
47
|
-
"build-bundle": "webpack --config ../../scripts/webpack/bundle.js"
|
|
48
|
-
},
|
|
45
|
+
"scripts": {},
|
|
49
46
|
"dependencies": {
|
|
50
47
|
"@babel/runtime": "^7.3.1",
|
|
51
|
-
"@loaders.gl/worker-utils": "4.0.0-alpha.
|
|
52
|
-
"@probe.gl/stats": "^3.
|
|
48
|
+
"@loaders.gl/worker-utils": "4.0.0-alpha.5",
|
|
49
|
+
"@probe.gl/stats": "^3.5.0"
|
|
53
50
|
},
|
|
54
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "7a71a54bdf1ddf985cc3af3db90b82e7fa97d025"
|
|
55
52
|
}
|
package/src/lib/node/fs.ts
CHANGED
|
@@ -5,34 +5,64 @@ import {promisify} from './util';
|
|
|
5
5
|
|
|
6
6
|
export type {Stats} from 'fs';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/** Wrapper for Node.js fs method */
|
|
11
|
-
export const readdir = promisify(fs.readdir);
|
|
8
|
+
export let readdir;
|
|
12
9
|
/** Wrapper for Node.js fs method */
|
|
13
|
-
export
|
|
10
|
+
export let stat;
|
|
14
11
|
|
|
15
12
|
/** Wrapper for Node.js fs method */
|
|
16
|
-
export
|
|
13
|
+
export let readFile;
|
|
17
14
|
/** Wrapper for Node.js fs method */
|
|
18
|
-
export
|
|
15
|
+
export let readFileSync;
|
|
19
16
|
/** Wrapper for Node.js fs method */
|
|
20
|
-
export
|
|
17
|
+
export let writeFile;
|
|
21
18
|
/** Wrapper for Node.js fs method */
|
|
22
|
-
export
|
|
19
|
+
export let writeFileSync;
|
|
23
20
|
|
|
24
21
|
// file descriptors
|
|
25
22
|
|
|
26
23
|
/** Wrapper for Node.js fs method */
|
|
27
|
-
export
|
|
24
|
+
export let open;
|
|
28
25
|
/** Wrapper for Node.js fs method */
|
|
29
|
-
export
|
|
26
|
+
export let close;
|
|
30
27
|
/** Wrapper for Node.js fs method */
|
|
31
|
-
export
|
|
28
|
+
export let read;
|
|
32
29
|
/** Wrapper for Node.js fs method */
|
|
33
|
-
export
|
|
30
|
+
export let fstat;
|
|
31
|
+
|
|
32
|
+
export let isSupported = Boolean(fs);
|
|
33
|
+
|
|
34
|
+
// paths
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
try {
|
|
37
|
+
/** Wrapper for Node.js fs method */
|
|
38
|
+
readdir = promisify(fs.readdir);
|
|
39
|
+
/** Wrapper for Node.js fs method */
|
|
40
|
+
stat = promisify(fs.stat);
|
|
41
|
+
|
|
42
|
+
/** Wrapper for Node.js fs method */
|
|
43
|
+
readFile = promisify(fs.readFile);
|
|
44
|
+
/** Wrapper for Node.js fs method */
|
|
45
|
+
readFileSync = fs.readFileSync;
|
|
46
|
+
/** Wrapper for Node.js fs method */
|
|
47
|
+
writeFile = promisify(fs.writeFile);
|
|
48
|
+
/** Wrapper for Node.js fs method */
|
|
49
|
+
writeFileSync = fs.writeFileSync;
|
|
50
|
+
|
|
51
|
+
// file descriptors
|
|
52
|
+
|
|
53
|
+
/** Wrapper for Node.js fs method */
|
|
54
|
+
open = promisify(fs.open);
|
|
55
|
+
/** Wrapper for Node.js fs method */
|
|
56
|
+
close = promisify(fs.close);
|
|
57
|
+
/** Wrapper for Node.js fs method */
|
|
58
|
+
read = promisify(fs.read);
|
|
59
|
+
/** Wrapper for Node.js fs method */
|
|
60
|
+
fstat = promisify(fs.fstat);
|
|
61
|
+
|
|
62
|
+
isSupported = Boolean(fs);
|
|
63
|
+
} catch {
|
|
64
|
+
// ignore
|
|
65
|
+
}
|
|
36
66
|
|
|
37
67
|
export async function _readToArrayBuffer(fd: number, start: number, length: number) {
|
|
38
68
|
const buffer = Buffer.alloc(length);
|
|
@@ -39,7 +39,7 @@ export async function parseWithWorker(
|
|
|
39
39
|
const job = await workerPool.startJob(
|
|
40
40
|
'process-on-worker',
|
|
41
41
|
// @ts-expect-error
|
|
42
|
-
onMessage.bind(null, parseOnMainThread) // eslint-disable-
|
|
42
|
+
onMessage.bind(null, parseOnMainThread) // eslint-disable-line @typescript-eslint/no-misused-promises
|
|
43
43
|
);
|
|
44
44
|
|
|
45
45
|
job.postMessage('process', {
|