@loaders.gl/core 3.1.0-alpha.5 → 3.1.0-beta.1
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/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +3380 -0
- package/dist/core-addons/write-file-browser.d.ts +1 -0
- package/dist/core-addons/write-file-browser.d.ts.map +1 -0
- package/dist/core-addons/write-file-browser.js +60 -0
- package/dist/es5/lib/api/register-loaders.js.map +1 -1
- package/dist/es5/lib/init.js +1 -1
- package/dist/es5/lib/init.js.map +1 -1
- package/dist/es5/null-loader.js +1 -1
- package/dist/es5/null-loader.js.map +1 -1
- package/dist/esm/lib/api/register-loaders.js.map +1 -1
- package/dist/esm/lib/init.js +1 -1
- package/dist/esm/lib/init.js.map +1 -1
- package/dist/esm/null-loader.js +1 -1
- package/dist/esm/null-loader.js.map +1 -1
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +106 -0
- package/dist/iterators/batch-iterators/timed-batch-iterator.d.ts +5 -0
- package/dist/iterators/batch-iterators/timed-batch-iterator.d.ts.map +1 -0
- package/dist/iterators/batch-iterators/timed-batch-iterator.js +22 -0
- package/dist/iterators/make-iterator/make-array-buffer-iterator.d.ts +9 -0
- package/dist/iterators/make-iterator/make-array-buffer-iterator.d.ts.map +1 -0
- package/dist/iterators/make-iterator/make-array-buffer-iterator.js +27 -0
- package/dist/iterators/make-iterator/make-blob-iterator.d.ts +9 -0
- package/dist/iterators/make-iterator/make-blob-iterator.d.ts.map +1 -0
- package/dist/iterators/make-iterator/make-blob-iterator.js +21 -0
- package/dist/iterators/make-iterator/make-iterator.d.ts +19 -0
- package/dist/iterators/make-iterator/make-iterator.d.ts.map +1 -0
- package/dist/iterators/make-iterator/make-iterator.js +37 -0
- package/dist/iterators/make-iterator/make-stream-iterator.d.ts +11 -0
- package/dist/iterators/make-iterator/make-stream-iterator.d.ts.map +1 -0
- package/dist/iterators/make-iterator/make-stream-iterator.js +96 -0
- package/dist/iterators/make-iterator/make-string-iterator.d.ts +9 -0
- package/dist/iterators/make-iterator/make-string-iterator.d.ts.map +1 -0
- package/dist/iterators/make-iterator/make-string-iterator.js +24 -0
- package/dist/iterators/make-stream/make-dom-stream.d.ts +9 -0
- package/dist/iterators/make-stream/make-dom-stream.d.ts.map +1 -0
- package/dist/iterators/make-stream/make-dom-stream.js +41 -0
- package/dist/iterators/make-stream/make-node-stream.d.ts +7 -0
- package/dist/iterators/make-stream/make-node-stream.d.ts.map +1 -0
- package/dist/iterators/make-stream/make-node-stream.js +58 -0
- package/dist/iterators/make-stream/make-stream.d.ts +9 -0
- package/dist/iterators/make-stream/make-stream.d.ts.map +1 -0
- package/dist/iterators/make-stream/make-stream.js +16 -0
- package/dist/javascript-utils/is-type.d.ts +22 -0
- package/dist/javascript-utils/is-type.d.ts.map +1 -0
- package/dist/javascript-utils/is-type.js +41 -0
- package/dist/lib/api/encode.d.ts +26 -0
- package/dist/lib/api/encode.d.ts.map +1 -0
- package/dist/lib/api/encode.js +111 -0
- package/dist/lib/api/load-in-batches.d.ts +13 -0
- package/dist/lib/api/load-in-batches.d.ts.map +1 -0
- package/dist/lib/api/load-in-batches.js +33 -0
- package/dist/lib/api/load.d.ts +12 -0
- package/dist/lib/api/load.d.ts.map +1 -0
- package/dist/lib/api/load.js +41 -0
- package/dist/lib/api/parse-in-batches.d.ts +10 -0
- package/dist/lib/api/parse-in-batches.d.ts.map +1 -0
- package/dist/lib/api/parse-in-batches.js +120 -0
- package/dist/lib/api/parse-sync.d.ts +10 -0
- package/dist/lib/api/parse-sync.d.ts.map +1 -0
- package/dist/lib/api/parse-sync.js +59 -0
- package/dist/lib/api/parse.d.ts +10 -0
- package/dist/lib/api/parse.d.ts.map +1 -0
- package/dist/lib/api/parse.js +74 -0
- package/dist/lib/api/register-loaders.d.ts +7 -0
- package/dist/lib/api/register-loaders.d.ts.map +1 -0
- package/dist/lib/api/register-loaders.js +35 -0
- package/dist/lib/api/save.d.ts +4 -0
- package/dist/lib/api/save.d.ts.map +1 -0
- package/dist/lib/api/save.js +15 -0
- package/dist/lib/api/select-loader.d.ts +22 -0
- package/dist/lib/api/select-loader.d.ts.map +1 -0
- package/dist/lib/api/select-loader.js +239 -0
- package/dist/lib/api/set-loader-options.d.ts +6 -0
- package/dist/lib/api/set-loader-options.d.ts.map +1 -0
- package/dist/lib/api/set-loader-options.js +12 -0
- package/dist/lib/common.d.ts +2 -0
- package/dist/lib/common.d.ts.map +1 -0
- package/dist/lib/common.js +2 -0
- package/dist/lib/fetch/fetch-error-message.d.ts +3 -0
- package/dist/lib/fetch/fetch-error-message.d.ts.map +1 -0
- package/dist/lib/fetch/fetch-error-message.js +25 -0
- package/dist/lib/fetch/fetch-file.d.ts +13 -0
- package/dist/lib/fetch/fetch-file.d.ts.map +1 -0
- package/dist/lib/fetch/fetch-file.js +27 -0
- package/dist/lib/fetch/read-array-buffer.d.ts +17 -0
- package/dist/lib/fetch/read-array-buffer.d.ts.map +1 -0
- package/dist/lib/fetch/read-array-buffer.js +41 -0
- package/dist/lib/fetch/read-file.d.ts +5 -0
- package/dist/lib/fetch/read-file.d.ts.map +1 -0
- package/dist/lib/fetch/read-file.js +29 -0
- package/dist/lib/fetch/write-file.d.ts +3 -0
- package/dist/lib/fetch/write-file.d.ts.map +1 -0
- package/dist/lib/fetch/write-file.js +22 -0
- package/dist/lib/filesystems/browser-filesystem.d.ts +58 -0
- package/dist/lib/filesystems/browser-filesystem.d.ts.map +1 -0
- package/dist/lib/filesystems/browser-filesystem.js +126 -0
- package/dist/lib/filesystems/filesystem.d.ts +46 -0
- package/dist/lib/filesystems/filesystem.d.ts.map +1 -0
- package/dist/lib/filesystems/filesystem.js +2 -0
- package/dist/lib/filesystems/read-array-buffer.d.ts +19 -0
- package/dist/lib/filesystems/read-array-buffer.d.ts.map +1 -0
- package/dist/lib/filesystems/read-array-buffer.js +29 -0
- package/dist/lib/init.d.ts +3 -0
- package/dist/lib/init.d.ts.map +1 -0
- package/dist/lib/init.js +10 -0
- package/dist/lib/loader-utils/check-errors.d.ts +3 -0
- package/dist/lib/loader-utils/check-errors.d.ts.map +1 -0
- package/dist/lib/loader-utils/check-errors.js +30 -0
- package/dist/lib/loader-utils/get-data.d.ts +6 -0
- package/dist/lib/loader-utils/get-data.d.ts.map +1 -0
- package/dist/lib/loader-utils/get-data.js +129 -0
- package/dist/lib/loader-utils/loader-context.d.ts +13 -0
- package/dist/lib/loader-utils/loader-context.d.ts.map +1 -0
- package/dist/lib/loader-utils/loader-context.js +49 -0
- package/dist/lib/loader-utils/loggers.d.ts +16 -0
- package/dist/lib/loader-utils/loggers.d.ts.map +1 -0
- package/dist/lib/loader-utils/loggers.js +41 -0
- package/dist/lib/loader-utils/normalize-loader.d.ts +4 -0
- package/dist/lib/loader-utils/normalize-loader.d.ts.map +1 -0
- package/dist/lib/loader-utils/normalize-loader.js +52 -0
- package/dist/lib/loader-utils/option-defaults.d.ts +20 -0
- package/dist/lib/loader-utils/option-defaults.d.ts.map +1 -0
- package/dist/lib/loader-utils/option-defaults.js +41 -0
- package/dist/lib/loader-utils/option-utils.d.ts +36 -0
- package/dist/lib/loader-utils/option-utils.d.ts.map +1 -0
- package/dist/lib/loader-utils/option-utils.js +177 -0
- package/dist/lib/progress/fetch-progress.d.ts +6 -0
- package/dist/lib/progress/fetch-progress.d.ts.map +1 -0
- package/dist/lib/progress/fetch-progress.js +59 -0
- package/dist/lib/utils/mime-type-utils.d.ts +20 -0
- package/dist/lib/utils/mime-type-utils.d.ts.map +1 -0
- package/dist/lib/utils/mime-type-utils.js +42 -0
- package/dist/lib/utils/resource-utils.d.ts +21 -0
- package/dist/lib/utils/resource-utils.d.ts.map +1 -0
- package/dist/lib/utils/resource-utils.js +78 -0
- package/dist/lib/utils/response-utils.d.ts +18 -0
- package/dist/lib/utils/response-utils.d.ts.map +1 -0
- package/dist/lib/utils/response-utils.js +114 -0
- package/dist/null-loader.d.ts +10 -0
- package/dist/null-loader.d.ts.map +1 -0
- package/dist/null-loader.js +44 -0
- package/dist/null-worker.js +178 -2
- package/dist/workers/null-worker.d.ts +2 -0
- package/dist/workers/null-worker.d.ts.map +1 -0
- package/dist/workers/null-worker.js +5 -0
- package/package.json +7 -7
- package/src/lib/api/register-loaders.ts +2 -1
- package/src/lib/{init.js → init.ts} +0 -0
- package/dist/dist.min.js +0 -2
- package/dist/dist.min.js.map +0 -1
- package/dist/null-worker.js.map +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IteratorOptions } from './make-iterator';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an iterator that breaks a big string into chunks and yields them one-by-one as ArrayBuffers
|
|
4
|
+
* @param blob string to iterate over
|
|
5
|
+
* @param options
|
|
6
|
+
* @param options.chunkSize
|
|
7
|
+
*/
|
|
8
|
+
export declare function makeStringIterator(string: string, options?: IteratorOptions): Iterable<ArrayBuffer>;
|
|
9
|
+
//# sourceMappingURL=make-string-iterator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-string-iterator.d.ts","sourceRoot":"","sources":["../../../src/iterators/make-iterator/make-string-iterator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAC;AAIrD;;;;;GAKG;AACH,wBAAiB,kBAAkB,CACjC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,eAAe,GACxB,QAAQ,CAAC,WAAW,CAAC,CAcvB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeStringIterator = void 0;
|
|
4
|
+
const DEFAULT_CHUNK_SIZE = 256 * 1024;
|
|
5
|
+
/**
|
|
6
|
+
* Returns an iterator that breaks a big string into chunks and yields them one-by-one as ArrayBuffers
|
|
7
|
+
* @param blob string to iterate over
|
|
8
|
+
* @param options
|
|
9
|
+
* @param options.chunkSize
|
|
10
|
+
*/
|
|
11
|
+
function* makeStringIterator(string, options) {
|
|
12
|
+
const chunkSize = options?.chunkSize || DEFAULT_CHUNK_SIZE;
|
|
13
|
+
let offset = 0;
|
|
14
|
+
const textEncoder = new TextEncoder();
|
|
15
|
+
while (offset < string.length) {
|
|
16
|
+
// Create a chunk of the right size
|
|
17
|
+
const chunkLength = Math.min(string.length - offset, chunkSize);
|
|
18
|
+
const chunk = string.slice(offset, offset + chunkLength);
|
|
19
|
+
offset += chunkLength;
|
|
20
|
+
// yield an ArrayBuffer chunk
|
|
21
|
+
yield textEncoder.encode(chunk);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.makeStringIterator = makeStringIterator;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare type MakeDOMStreamOptions = {
|
|
2
|
+
/** Stream allocates an arrayBuffer. Enables use of a default reader. */
|
|
3
|
+
autoAllocateChunkSize?: number;
|
|
4
|
+
/** Total number of chunks in queue before back pressure is applied */
|
|
5
|
+
highWaterMark?: number;
|
|
6
|
+
};
|
|
7
|
+
/** Builds a DOM stream from an iterator */
|
|
8
|
+
export declare function makeDOMStream<ArrayBuffer>(source: Iterable<ArrayBuffer> | AsyncIterable<ArrayBuffer>, options?: MakeDOMStreamOptions): ReadableStream;
|
|
9
|
+
//# sourceMappingURL=make-dom-stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-dom-stream.d.ts","sourceRoot":"","sources":["../../../src/iterators/make-stream/make-dom-stream.ts"],"names":[],"mappings":"AAAA,oBAAY,oBAAoB,GAAG;IACjC,wEAAwE;IACxE,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,sEAAsE;IACtE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,2CAA2C;AAC3C,wBAAgB,aAAa,CAAC,WAAW,EACvC,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,EAC1D,OAAO,CAAC,EAAE,oBAAoB,GAC7B,cAAc,CAsChB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeDOMStream = void 0;
|
|
4
|
+
/** Builds a DOM stream from an iterator */
|
|
5
|
+
function makeDOMStream(source, options) {
|
|
6
|
+
const iterator = source[Symbol.asyncIterator]
|
|
7
|
+
? source[Symbol.asyncIterator]()
|
|
8
|
+
: source[Symbol.iterator]();
|
|
9
|
+
return new ReadableStream({
|
|
10
|
+
// Create a byte stream (enables `Response(stream).arrayBuffer()`)
|
|
11
|
+
// Only supported on Chrome
|
|
12
|
+
// See: https://developer.mozilla.org/en-US/docs/Web/API/ReadableByteStreamController
|
|
13
|
+
// @ts-expect-error Only Chrome supports byte streams
|
|
14
|
+
type: 'bytes',
|
|
15
|
+
async pull(controller) {
|
|
16
|
+
try {
|
|
17
|
+
const { done, value } = await iterator.next();
|
|
18
|
+
if (done) {
|
|
19
|
+
controller.close();
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
// TODO - ignores controller.desiredSize
|
|
23
|
+
controller.enqueue(new Uint8Array(value));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
controller.error(error);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
async cancel() {
|
|
31
|
+
await iterator?.return?.();
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
// options: QueingStrategy<Uint8Array>
|
|
35
|
+
{
|
|
36
|
+
// This is bytes, not chunks
|
|
37
|
+
highWaterMark: 2 ** 24,
|
|
38
|
+
...options
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
exports.makeDOMStream = makeDOMStream;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Readable, ReadableOptions } from 'stream';
|
|
3
|
+
export declare type MakeNodeStreamOptions = ReadableOptions;
|
|
4
|
+
/** Builds a node stream from an iterator */
|
|
5
|
+
declare function makeNodeStream<ArrayBuffer>(source: Iterable<ArrayBuffer> | AsyncIterable<ArrayBuffer>, options?: ReadableOptions): Readable;
|
|
6
|
+
export default makeNodeStream;
|
|
7
|
+
//# sourceMappingURL=make-node-stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-node-stream.d.ts","sourceRoot":"","sources":["../../../src/iterators/make-stream/make-node-stream.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAC,MAAM,QAAQ,CAAC;AAEjD,oBAAY,qBAAqB,GAAG,eAAe,CAAC;AAEpD,4CAA4C;AAC5C,iBAAS,cAAc,CAAC,WAAW,EACjC,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,EAC1D,OAAO,CAAC,EAAE,eAAe,GACxB,QAAQ,CAKV;AAwDD,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const stream_1 = require("stream");
|
|
4
|
+
/** Builds a node stream from an iterator */
|
|
5
|
+
function makeNodeStream(source, options) {
|
|
6
|
+
const iterator = source[Symbol.asyncIterator]
|
|
7
|
+
? source[Symbol.asyncIterator]()
|
|
8
|
+
: source[Symbol.iterator]();
|
|
9
|
+
return new AsyncIterableReadable(iterator, options);
|
|
10
|
+
}
|
|
11
|
+
class AsyncIterableReadable extends stream_1.Readable {
|
|
12
|
+
constructor(it, options) {
|
|
13
|
+
super(options);
|
|
14
|
+
this._iterator = it;
|
|
15
|
+
this._pulling = false;
|
|
16
|
+
this._bytesMode = !options || !options.objectMode;
|
|
17
|
+
}
|
|
18
|
+
async _read(size) {
|
|
19
|
+
if (!this._pulling) {
|
|
20
|
+
this._pulling = true;
|
|
21
|
+
this._pulling = await this._pull(size, this._iterator);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async _destroy(error, cb) {
|
|
25
|
+
if (!this._iterator) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (error) {
|
|
29
|
+
await this._iterator?.throw?.(error);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
await this._iterator?.return?.(error);
|
|
33
|
+
}
|
|
34
|
+
cb?.(null);
|
|
35
|
+
}
|
|
36
|
+
// eslint-disable-next-line complexity
|
|
37
|
+
async _pull(size, it) {
|
|
38
|
+
const bm = this._bytesMode;
|
|
39
|
+
let r = null;
|
|
40
|
+
// while (this.readable && !(r = await it.next(bm ? size : null)).done) {
|
|
41
|
+
while (this.readable && !(r = await it.next()).done) {
|
|
42
|
+
if (size !== null) {
|
|
43
|
+
size -= bm && ArrayBuffer.isView(r.value) ? r.value.byteLength : 1;
|
|
44
|
+
}
|
|
45
|
+
if (!this.push(new Uint8Array(r.value)) || size <= 0) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if ((r?.done || !this.readable) && (this.push(null) || true)) {
|
|
50
|
+
it?.return?.();
|
|
51
|
+
}
|
|
52
|
+
return !this.readable;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// This module is marked `false` in the the "browser" field of the `package.json` for
|
|
56
|
+
// `@loaders.gl/core`. We avoid using named exports so that bundlers have an easier
|
|
57
|
+
// time resolving this "empty" module.
|
|
58
|
+
exports.default = makeNodeStream;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReadableStreamType } from '../../javascript-utils/is-type';
|
|
2
|
+
import type { MakeDOMStreamOptions } from './make-dom-stream';
|
|
3
|
+
import type { MakeNodeStreamOptions } from './make-node-stream';
|
|
4
|
+
export declare type MakeStreamOptions = MakeDOMStreamOptions | MakeNodeStreamOptions;
|
|
5
|
+
/**
|
|
6
|
+
* Returns a stream for an (async) iterator (works in both Node.js and browsers)
|
|
7
|
+
*/
|
|
8
|
+
export declare function makeStream(data: Iterable<ArrayBuffer> | AsyncIterable<ArrayBuffer>, options?: MakeStreamOptions): ReadableStreamType;
|
|
9
|
+
//# sourceMappingURL=make-stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-stream.d.ts","sourceRoot":"","sources":["../../../src/iterators/make-stream/make-stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAC;AACvE,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AAM9D,oBAAY,iBAAiB,GAAG,oBAAoB,GAAG,qBAAqB,CAAC;AAE7E;;GAEG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,EACxD,OAAO,CAAC,EAAE,iBAAiB,GAC1B,kBAAkB,CAEpB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.makeStream = void 0;
|
|
7
|
+
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
8
|
+
const make_dom_stream_1 = require("./make-dom-stream");
|
|
9
|
+
const make_node_stream_1 = __importDefault(require("./make-node-stream"));
|
|
10
|
+
/**
|
|
11
|
+
* Returns a stream for an (async) iterator (works in both Node.js and browsers)
|
|
12
|
+
*/
|
|
13
|
+
function makeStream(data, options) {
|
|
14
|
+
return loader_utils_1.isBrowser ? (0, make_dom_stream_1.makeDOMStream)(data, options) : (0, make_node_stream_1.default)(data, options);
|
|
15
|
+
}
|
|
16
|
+
exports.makeStream = makeStream;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Readable } from 'stream';
|
|
3
|
+
/** A DOM or Node readable stream */
|
|
4
|
+
export declare type ReadableStreamType = ReadableStream | Readable;
|
|
5
|
+
export declare const isObject: (x: any) => boolean;
|
|
6
|
+
export declare const isPureObject: (x: any) => boolean;
|
|
7
|
+
export declare const isPromise: (x: any) => boolean;
|
|
8
|
+
export declare const isIterable: (x: any) => boolean;
|
|
9
|
+
export declare const isAsyncIterable: (x: any) => boolean;
|
|
10
|
+
export declare const isIterator: (x: any) => boolean;
|
|
11
|
+
export declare const isResponse: (x: any) => boolean;
|
|
12
|
+
export declare const isFile: (x: any) => boolean;
|
|
13
|
+
export declare const isBlob: (x: any) => boolean;
|
|
14
|
+
/** Check for Node.js `Buffer` without triggering bundler to include buffer polyfill */
|
|
15
|
+
export declare const isBuffer: (x: any) => boolean;
|
|
16
|
+
export declare const isWritableDOMStream: (x: any) => boolean;
|
|
17
|
+
export declare const isReadableDOMStream: (x: any) => boolean;
|
|
18
|
+
export declare const isWritableNodeStream: (x: any) => boolean;
|
|
19
|
+
export declare const isReadableNodeStream: (x: any) => boolean;
|
|
20
|
+
export declare const isReadableStream: (x: any) => boolean;
|
|
21
|
+
export declare const isWritableStream: (x: any) => boolean;
|
|
22
|
+
//# sourceMappingURL=is-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-type.d.ts","sourceRoot":"","sources":["../../src/javascript-utils/is-type.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAErC,oCAAoC;AACpC,oBAAY,kBAAkB,GAAG,cAAc,GAAG,QAAQ,CAAC;AAK3D,eAAO,MAAM,QAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OAAoD,CAAC;AACxF,eAAO,MAAM,YAAY,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OACU,CAAC;AAClD,eAAO,MAAM,SAAS,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OAAkD,CAAC;AAEvF,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OAA8D,CAAC;AACpG,eAAO,MAAM,eAAe,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OACU,CAAC;AACrD,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OAAwC,CAAC;AAE9E,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OAEK,CAAC;AAE3C,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OAAiE,CAAC;AACnG,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OAAiE,CAAC;AAEnG,uFAAuF;AACvF,eAAO,MAAM,QAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OAAyD,CAAC;AAE7F,eAAO,MAAM,mBAAmB,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OACiB,CAAC;AAEhE,eAAO,MAAM,mBAAmB,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OAEyC,CAAC;AAGxF,eAAO,MAAM,oBAAoB,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OACmC,CAAC;AACnF,eAAO,MAAM,oBAAoB,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OACmC,CAAC;AACnF,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OACQ,CAAC;AACpD,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OACQ,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isWritableStream = exports.isReadableStream = exports.isReadableNodeStream = exports.isWritableNodeStream = exports.isReadableDOMStream = exports.isWritableDOMStream = exports.isBuffer = exports.isBlob = exports.isFile = exports.isResponse = exports.isIterator = exports.isAsyncIterable = exports.isIterable = exports.isPromise = exports.isPureObject = exports.isObject = void 0;
|
|
4
|
+
const isBoolean = (x) => typeof x === 'boolean';
|
|
5
|
+
const isFunction = (x) => typeof x === 'function';
|
|
6
|
+
const isObject = (x) => x !== null && typeof x === 'object';
|
|
7
|
+
exports.isObject = isObject;
|
|
8
|
+
const isPureObject = (x) => (0, exports.isObject)(x) && x.constructor === {}.constructor;
|
|
9
|
+
exports.isPureObject = isPureObject;
|
|
10
|
+
const isPromise = (x) => (0, exports.isObject)(x) && isFunction(x.then);
|
|
11
|
+
exports.isPromise = isPromise;
|
|
12
|
+
const isIterable = (x) => x && typeof x[Symbol.iterator] === 'function';
|
|
13
|
+
exports.isIterable = isIterable;
|
|
14
|
+
const isAsyncIterable = (x) => x && typeof x[Symbol.asyncIterator] === 'function';
|
|
15
|
+
exports.isAsyncIterable = isAsyncIterable;
|
|
16
|
+
const isIterator = (x) => x && isFunction(x.next);
|
|
17
|
+
exports.isIterator = isIterator;
|
|
18
|
+
const isResponse = (x) => (typeof Response !== 'undefined' && x instanceof Response) ||
|
|
19
|
+
(x && x.arrayBuffer && x.text && x.json);
|
|
20
|
+
exports.isResponse = isResponse;
|
|
21
|
+
const isFile = (x) => typeof File !== 'undefined' && x instanceof File;
|
|
22
|
+
exports.isFile = isFile;
|
|
23
|
+
const isBlob = (x) => typeof Blob !== 'undefined' && x instanceof Blob;
|
|
24
|
+
exports.isBlob = isBlob;
|
|
25
|
+
/** Check for Node.js `Buffer` without triggering bundler to include buffer polyfill */
|
|
26
|
+
const isBuffer = (x) => x && typeof x === 'object' && x.isBuffer;
|
|
27
|
+
exports.isBuffer = isBuffer;
|
|
28
|
+
const isWritableDOMStream = (x) => (0, exports.isObject)(x) && isFunction(x.abort) && isFunction(x.getWriter);
|
|
29
|
+
exports.isWritableDOMStream = isWritableDOMStream;
|
|
30
|
+
const isReadableDOMStream = (x) => (typeof ReadableStream !== 'undefined' && x instanceof ReadableStream) ||
|
|
31
|
+
((0, exports.isObject)(x) && isFunction(x.tee) && isFunction(x.cancel) && isFunction(x.getReader));
|
|
32
|
+
exports.isReadableDOMStream = isReadableDOMStream;
|
|
33
|
+
// Not implemented in Firefox: && isFunction(x.pipeTo)
|
|
34
|
+
const isWritableNodeStream = (x) => (0, exports.isObject)(x) && isFunction(x.end) && isFunction(x.write) && isBoolean(x.writable);
|
|
35
|
+
exports.isWritableNodeStream = isWritableNodeStream;
|
|
36
|
+
const isReadableNodeStream = (x) => (0, exports.isObject)(x) && isFunction(x.read) && isFunction(x.pipe) && isBoolean(x.readable);
|
|
37
|
+
exports.isReadableNodeStream = isReadableNodeStream;
|
|
38
|
+
const isReadableStream = (x) => (0, exports.isReadableDOMStream)(x) || (0, exports.isReadableNodeStream)(x);
|
|
39
|
+
exports.isReadableStream = isReadableStream;
|
|
40
|
+
const isWritableStream = (x) => (0, exports.isWritableDOMStream)(x) || (0, exports.isWritableNodeStream)(x);
|
|
41
|
+
exports.isWritableStream = isWritableStream;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Writer, LoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
|
+
/**
|
|
3
|
+
* Encode loaded data into a binary ArrayBuffer using the specified Writer.
|
|
4
|
+
*/
|
|
5
|
+
export declare function encode(data: any, writer: Writer, options?: LoaderOptions): Promise<ArrayBuffer>;
|
|
6
|
+
/**
|
|
7
|
+
* Encode loaded data into a binary ArrayBuffer using the specified Writer.
|
|
8
|
+
*/
|
|
9
|
+
export declare function encodeSync(data: any, writer: Writer, options?: LoaderOptions): ArrayBuffer;
|
|
10
|
+
/**
|
|
11
|
+
* Encode loaded data to text using the specified Writer
|
|
12
|
+
* @note This is a convenience function not intended for production use on large input data.
|
|
13
|
+
* It is not optimized for performance. Data maybe converted from text to binary and back.
|
|
14
|
+
* @throws if the writer does not generate text output
|
|
15
|
+
*/
|
|
16
|
+
export declare function encodeText(data: any, writer: Writer, options?: LoaderOptions): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Encode loaded data into a sequence (iterator) of binary ArrayBuffers using the specified Writer.
|
|
19
|
+
*/
|
|
20
|
+
export declare function encodeInBatches(data: any, writer: Writer, options?: LoaderOptions): AsyncIterable<ArrayBuffer>;
|
|
21
|
+
/**
|
|
22
|
+
* Encode data stored in a file (on disk) to another file.
|
|
23
|
+
* @note Node.js only. This function enables using command-line converters as "writers".
|
|
24
|
+
*/
|
|
25
|
+
export declare function encodeURLtoURL(inputUrl: any, outputUrl: any, writer: Writer, options: any): Promise<string>;
|
|
26
|
+
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../../src/lib/api/encode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAMpE;;GAEG;AACH,wBAAsB,MAAM,CAC1B,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,WAAW,CAAC,CA+CtB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,WAAW,CAK1F;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,MAAM,CAAC,CAWjB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,aAAa,GACtB,aAAa,CAAC,WAAW,CAAC,CAO5B;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,QAAQ,KAAA,EACR,SAAS,KAAA,EACT,MAAM,EAAE,MAAM,EACd,OAAO,KAAA,GACN,OAAO,CAAC,MAAM,CAAC,CAQjB"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeURLtoURL = exports.encodeInBatches = exports.encodeText = exports.encodeSync = exports.encode = void 0;
|
|
4
|
+
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
5
|
+
const loader_utils_2 = require("@loaders.gl/loader-utils");
|
|
6
|
+
const write_file_1 = require("../fetch/write-file");
|
|
7
|
+
const fetch_file_1 = require("../fetch/fetch-file");
|
|
8
|
+
/**
|
|
9
|
+
* Encode loaded data into a binary ArrayBuffer using the specified Writer.
|
|
10
|
+
*/
|
|
11
|
+
async function encode(data, writer, options) {
|
|
12
|
+
// TODO Merge default writer options with options argument like it is done in load module.
|
|
13
|
+
if (writer.encode) {
|
|
14
|
+
return await writer.encode(data, options);
|
|
15
|
+
}
|
|
16
|
+
if (writer.encodeSync) {
|
|
17
|
+
return writer.encodeSync(data, options);
|
|
18
|
+
}
|
|
19
|
+
if (writer.encodeText) {
|
|
20
|
+
return new TextEncoder().encode(await writer.encodeText(data, options));
|
|
21
|
+
}
|
|
22
|
+
if (writer.encodeInBatches) {
|
|
23
|
+
// Create an iterator representing the data
|
|
24
|
+
// TODO - Assumes this is a table
|
|
25
|
+
const batches = encodeInBatches(data, writer, options);
|
|
26
|
+
// Concatenate the output
|
|
27
|
+
const chunks = [];
|
|
28
|
+
for await (const batch of batches) {
|
|
29
|
+
chunks.push(batch);
|
|
30
|
+
}
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
return (0, loader_utils_1.concatenateArrayBuffers)(...chunks);
|
|
33
|
+
}
|
|
34
|
+
if (!loader_utils_2.isBrowser && writer.encodeURLtoURL) {
|
|
35
|
+
// TODO - how to generate filenames with correct extensions?
|
|
36
|
+
const tmpInputFilename = getTemporaryFilename('input');
|
|
37
|
+
await (0, write_file_1.writeFile)(tmpInputFilename, data);
|
|
38
|
+
const tmpOutputFilename = getTemporaryFilename('output');
|
|
39
|
+
const outputFilename = await encodeURLtoURL(tmpInputFilename, tmpOutputFilename, writer, options);
|
|
40
|
+
const response = await (0, fetch_file_1.fetchFile)(outputFilename);
|
|
41
|
+
return response.arrayBuffer();
|
|
42
|
+
}
|
|
43
|
+
throw new Error('Writer could not encode data');
|
|
44
|
+
}
|
|
45
|
+
exports.encode = encode;
|
|
46
|
+
/**
|
|
47
|
+
* Encode loaded data into a binary ArrayBuffer using the specified Writer.
|
|
48
|
+
*/
|
|
49
|
+
function encodeSync(data, writer, options) {
|
|
50
|
+
if (writer.encodeSync) {
|
|
51
|
+
return writer.encodeSync(data, options);
|
|
52
|
+
}
|
|
53
|
+
throw new Error('Writer could not synchronously encode data');
|
|
54
|
+
}
|
|
55
|
+
exports.encodeSync = encodeSync;
|
|
56
|
+
/**
|
|
57
|
+
* Encode loaded data to text using the specified Writer
|
|
58
|
+
* @note This is a convenience function not intended for production use on large input data.
|
|
59
|
+
* It is not optimized for performance. Data maybe converted from text to binary and back.
|
|
60
|
+
* @throws if the writer does not generate text output
|
|
61
|
+
*/
|
|
62
|
+
async function encodeText(data, writer, options) {
|
|
63
|
+
if (writer.text && writer.encodeText) {
|
|
64
|
+
return await writer.encodeText(data, options);
|
|
65
|
+
}
|
|
66
|
+
if (writer.text && (writer.encode || writer.encodeInBatches)) {
|
|
67
|
+
const arrayBuffer = await encode(data, writer, options);
|
|
68
|
+
return new TextDecoder().decode(arrayBuffer);
|
|
69
|
+
}
|
|
70
|
+
throw new Error('Writer could not encode data as text');
|
|
71
|
+
}
|
|
72
|
+
exports.encodeText = encodeText;
|
|
73
|
+
/**
|
|
74
|
+
* Encode loaded data into a sequence (iterator) of binary ArrayBuffers using the specified Writer.
|
|
75
|
+
*/
|
|
76
|
+
function encodeInBatches(data, writer, options) {
|
|
77
|
+
if (writer.encodeInBatches) {
|
|
78
|
+
const dataIterator = getIterator(data);
|
|
79
|
+
return writer.encodeInBatches(dataIterator, options);
|
|
80
|
+
}
|
|
81
|
+
// TODO -fall back to atomic encode?
|
|
82
|
+
throw new Error('Writer could not encode data in batches');
|
|
83
|
+
}
|
|
84
|
+
exports.encodeInBatches = encodeInBatches;
|
|
85
|
+
/**
|
|
86
|
+
* Encode data stored in a file (on disk) to another file.
|
|
87
|
+
* @note Node.js only. This function enables using command-line converters as "writers".
|
|
88
|
+
*/
|
|
89
|
+
async function encodeURLtoURL(inputUrl, outputUrl, writer, options) {
|
|
90
|
+
inputUrl = (0, loader_utils_1.resolvePath)(inputUrl);
|
|
91
|
+
outputUrl = (0, loader_utils_1.resolvePath)(outputUrl);
|
|
92
|
+
if (loader_utils_2.isBrowser || !writer.encodeURLtoURL) {
|
|
93
|
+
throw new Error();
|
|
94
|
+
}
|
|
95
|
+
const outputFilename = await writer.encodeURLtoURL(inputUrl, outputUrl, options);
|
|
96
|
+
return outputFilename;
|
|
97
|
+
}
|
|
98
|
+
exports.encodeURLtoURL = encodeURLtoURL;
|
|
99
|
+
/**
|
|
100
|
+
* @todo TODO - this is an unacceptable hack!!!
|
|
101
|
+
*/
|
|
102
|
+
function getIterator(data) {
|
|
103
|
+
const dataIterator = [{ table: data, start: 0, end: data.length }];
|
|
104
|
+
return dataIterator;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* @todo Move to utils
|
|
108
|
+
*/
|
|
109
|
+
function getTemporaryFilename(filename) {
|
|
110
|
+
return `/tmp/${filename}`;
|
|
111
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { LoaderWithParser, LoaderOptions, LoaderContext } from '@loaders.gl/loader-utils';
|
|
2
|
+
declare type FileType = string | File | Blob | Response | (string | File | Blob | Response)[] | FileList;
|
|
3
|
+
/**
|
|
4
|
+
* Parses `data` using a specified loader
|
|
5
|
+
* @param data
|
|
6
|
+
* @param loaders
|
|
7
|
+
* @param options
|
|
8
|
+
* @param context
|
|
9
|
+
*/
|
|
10
|
+
export declare function loadInBatches(files: FileType, loaders?: LoaderWithParser | LoaderWithParser[] | LoaderOptions, options?: LoaderOptions, context?: LoaderContext): Promise<AsyncIterable<any>>;
|
|
11
|
+
export declare function loadInBatches(files: FileType[] | FileList, loaders?: LoaderWithParser | LoaderWithParser[] | LoaderOptions, options?: LoaderOptions, context?: LoaderContext): Promise<AsyncIterable<any>>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=load-in-batches.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-in-batches.d.ts","sourceRoot":"","sources":["../../../src/lib/api/load-in-batches.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAM7F,aAAK,QAAQ,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,QAAQ,GAAG,CAAC,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,QAAQ,CAAC,EAAE,GAAG,QAAQ,CAAC;AAEjG;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,QAAQ,EACf,OAAO,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,GAAG,aAAa,EAC/D,OAAO,CAAC,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/B,wBAAgB,aAAa,CAC3B,KAAK,EAAE,QAAQ,EAAE,GAAG,QAAQ,EAC5B,OAAO,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,GAAG,aAAa,EAC/D,OAAO,CAAC,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadInBatches = void 0;
|
|
4
|
+
const normalize_loader_1 = require("../loader-utils/normalize-loader");
|
|
5
|
+
const option_utils_1 = require("../loader-utils/option-utils");
|
|
6
|
+
const parse_in_batches_1 = require("./parse-in-batches");
|
|
7
|
+
function loadInBatches(files, loaders, options, context) {
|
|
8
|
+
// Signature: load(url, options)
|
|
9
|
+
if (!Array.isArray(loaders) && !(0, normalize_loader_1.isLoaderObject)(loaders)) {
|
|
10
|
+
context = undefined; // context not supported in short signature
|
|
11
|
+
options = loaders;
|
|
12
|
+
loaders = null;
|
|
13
|
+
}
|
|
14
|
+
// Select fetch function
|
|
15
|
+
const fetch = (0, option_utils_1.getFetchFunction)(options || {});
|
|
16
|
+
// Single url/file
|
|
17
|
+
if (!Array.isArray(files)) {
|
|
18
|
+
return loadOneFileInBatches(files, loaders, options, fetch);
|
|
19
|
+
}
|
|
20
|
+
// Multiple URLs / files
|
|
21
|
+
const promises = files.map((file) => loadOneFileInBatches(file, loaders, options, fetch));
|
|
22
|
+
// No point in waiting here for all responses before starting to stream individual streams?
|
|
23
|
+
return promises;
|
|
24
|
+
}
|
|
25
|
+
exports.loadInBatches = loadInBatches;
|
|
26
|
+
async function loadOneFileInBatches(file, loaders, options, fetch) {
|
|
27
|
+
if (typeof file === 'string') {
|
|
28
|
+
const url = file;
|
|
29
|
+
const response = await fetch(url);
|
|
30
|
+
return await (0, parse_in_batches_1.parseInBatches)(response, loaders, options);
|
|
31
|
+
}
|
|
32
|
+
return await (0, parse_in_batches_1.parseInBatches)(file, loaders, options);
|
|
33
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DataType, Loader, LoaderContext, LoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
|
+
/**
|
|
3
|
+
* Parses `data` using a specified loader
|
|
4
|
+
* Note: Load does duplicate a lot of parse.
|
|
5
|
+
* it can also call fetchFile on string urls, which `parse` won't do.
|
|
6
|
+
* @param data
|
|
7
|
+
* @param loaders
|
|
8
|
+
* @param options
|
|
9
|
+
* @param context
|
|
10
|
+
*/
|
|
11
|
+
export declare function load(url: string | DataType, loaders?: Loader | Loader[] | LoaderOptions, options?: LoaderOptions, context?: LoaderContext): Promise<any>;
|
|
12
|
+
//# sourceMappingURL=load.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/lib/api/load.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAO7F;;;;;;;;GAQG;AAEH,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,GAAG,QAAQ,EACtB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,aAAa,EAC3C,OAAO,CAAC,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,GAAG,CAAC,CA0Bd"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.load = void 0;
|
|
4
|
+
const is_type_1 = require("../../javascript-utils/is-type");
|
|
5
|
+
const normalize_loader_1 = require("../loader-utils/normalize-loader");
|
|
6
|
+
const option_utils_1 = require("../loader-utils/option-utils");
|
|
7
|
+
const parse_1 = require("./parse");
|
|
8
|
+
/**
|
|
9
|
+
* Parses `data` using a specified loader
|
|
10
|
+
* Note: Load does duplicate a lot of parse.
|
|
11
|
+
* it can also call fetchFile on string urls, which `parse` won't do.
|
|
12
|
+
* @param data
|
|
13
|
+
* @param loaders
|
|
14
|
+
* @param options
|
|
15
|
+
* @param context
|
|
16
|
+
*/
|
|
17
|
+
// implementation signature
|
|
18
|
+
async function load(url, loaders, options, context) {
|
|
19
|
+
// Signature: load(url, options)
|
|
20
|
+
if (!Array.isArray(loaders) && !(0, normalize_loader_1.isLoaderObject)(loaders)) {
|
|
21
|
+
context = undefined; // context not supported in short signature
|
|
22
|
+
options = loaders;
|
|
23
|
+
loaders = undefined;
|
|
24
|
+
}
|
|
25
|
+
// Select fetch function
|
|
26
|
+
const fetch = (0, option_utils_1.getFetchFunction)(options);
|
|
27
|
+
// at this point, `url` could be already loaded binary data
|
|
28
|
+
let data = url;
|
|
29
|
+
// url is a string, fetch the url
|
|
30
|
+
if (typeof url === 'string') {
|
|
31
|
+
data = await fetch(url);
|
|
32
|
+
// URL is Blob or File, fetchFile handles it (alt: we could generate ObjectURL here)
|
|
33
|
+
}
|
|
34
|
+
if ((0, is_type_1.isBlob)(url)) {
|
|
35
|
+
// The fetch response object will contain blob.name
|
|
36
|
+
data = await fetch(url);
|
|
37
|
+
}
|
|
38
|
+
// Data is loaded (at least we have a `Response` object) so time to hand over to `parse`
|
|
39
|
+
return await (0, parse_1.parse)(data, loaders, options);
|
|
40
|
+
}
|
|
41
|
+
exports.load = load;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BatchableDataType, Loader, LoaderContext, LoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
|
+
/**
|
|
3
|
+
* Parses `data` using a specified loader
|
|
4
|
+
* @param data
|
|
5
|
+
* @param loaders
|
|
6
|
+
* @param options
|
|
7
|
+
* @param context
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseInBatches(data: BatchableDataType, loaders?: Loader | Loader[] | LoaderOptions, options?: LoaderOptions, context?: LoaderContext): Promise<AsyncIterable<any>>;
|
|
10
|
+
//# sourceMappingURL=parse-in-batches.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-in-batches.d.ts","sourceRoot":"","sources":["../../../src/lib/api/parse-in-batches.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EACjB,MAAM,EAEN,aAAa,EACb,aAAa,EACd,MAAM,0BAA0B,CAAC;AAYlC;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,iBAAiB,EACvB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,aAAa,EAC3C,OAAO,CAAC,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAqC7B"}
|