@loaders.gl/loader-utils 4.1.0-alpha.2 → 4.1.0-alpha.4
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.cjs +31 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/json-loader.js +1 -1
- package/dist/json-loader.js.map +1 -1
- package/dist/lib/binary-utils/get-first-characters.d.ts.map +1 -1
- package/dist/lib/binary-utils/get-first-characters.js.map +1 -1
- package/dist/lib/binary-utils/memory-conversion-utils.d.ts.map +1 -1
- package/dist/lib/binary-utils/memory-conversion-utils.js.map +1 -1
- package/dist/lib/file-provider/file-handle-file.d.ts +11 -3
- package/dist/lib/file-provider/file-handle-file.d.ts.map +1 -1
- package/dist/lib/file-provider/file-handle-file.js +9 -4
- package/dist/lib/file-provider/file-handle-file.js.map +1 -1
- package/dist/lib/files/blob-file.d.ts.map +1 -1
- package/dist/lib/files/blob-file.js.map +1 -1
- package/dist/lib/files/file.d.ts.map +1 -1
- package/dist/lib/files/file.js.map +1 -1
- package/dist/lib/files/http-file.d.ts.map +1 -1
- package/dist/lib/files/http-file.js.map +1 -1
- package/dist/lib/files/node-file-facade.d.ts +5 -1
- package/dist/lib/files/node-file-facade.d.ts.map +1 -1
- package/dist/lib/files/node-file-facade.js +6 -0
- package/dist/lib/files/node-file-facade.js.map +1 -1
- package/dist/lib/filesystems/filesystem.d.ts.map +1 -1
- package/dist/lib/filesystems/filesystem.js.map +1 -1
- package/dist/lib/filesystems/node-filesystem-facade.d.ts.map +1 -1
- package/dist/lib/filesystems/node-filesystem-facade.js.map +1 -1
- package/dist/lib/node/buffer.browser.d.ts.map +1 -1
- package/dist/lib/node/buffer.browser.js.map +1 -1
- package/dist/lib/node/buffer.d.ts.map +1 -1
- package/dist/lib/node/buffer.js.map +1 -1
- package/dist/lib/node/stream.d.ts.map +1 -1
- package/dist/lib/node/stream.js.map +1 -1
- package/dist/lib/option-utils/merge-loader-options.d.ts.map +1 -1
- package/dist/lib/option-utils/merge-loader-options.js +5 -1
- package/dist/lib/option-utils/merge-loader-options.js.map +1 -1
- package/dist/lib/sources/data-source.d.ts.map +1 -1
- package/dist/lib/sources/data-source.js.map +1 -1
- package/dist/lib/sources/image-source.d.ts.map +1 -1
- package/dist/lib/sources/image-source.js.map +1 -1
- package/dist/lib/sources/image-tile-source.d.ts.map +1 -1
- package/dist/lib/sources/image-tile-source.js.map +1 -1
- package/dist/lib/sources/tile-source-adapter.d.ts.map +1 -1
- package/dist/lib/sources/tile-source-adapter.js.map +1 -1
- package/dist/lib/sources/tile-source.d.ts.map +1 -1
- package/dist/lib/sources/tile-source.js.map +1 -1
- package/dist/lib/sources/utils/utils.d.ts.map +1 -1
- package/dist/lib/sources/utils/utils.js.map +1 -1
- package/dist/lib/sources/vector-tile-source.d.ts.map +1 -1
- package/dist/lib/sources/vector-tile-source.js.map +1 -1
- package/dist/loader-types.d.ts +4 -4
- package/dist/loader-types.d.ts.map +1 -1
- package/dist/loader-types.js.map +1 -1
- package/dist/service-types.d.ts.map +1 -1
- package/dist/service-types.js.map +1 -1
- package/dist/writer-types.d.ts +10 -2
- package/dist/writer-types.d.ts.map +1 -1
- package/dist/writer-types.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +2 -1
- package/src/lib/binary-utils/get-first-characters.ts +2 -1
- package/src/lib/binary-utils/memory-conversion-utils.ts +2 -1
- package/src/lib/file-provider/file-handle-file.ts +21 -8
- package/src/lib/files/blob-file.ts +2 -1
- package/src/lib/files/file.ts +2 -1
- package/src/lib/files/http-file.ts +2 -1
- package/src/lib/files/node-file-facade.ts +13 -2
- package/src/lib/filesystems/filesystem.ts +2 -1
- package/src/lib/filesystems/node-filesystem-facade.ts +2 -1
- package/src/lib/node/buffer.browser.ts +2 -1
- package/src/lib/node/buffer.ts +2 -1
- package/src/lib/node/stream.ts +2 -1
- package/src/lib/option-utils/merge-loader-options.ts +11 -3
- package/src/lib/sources/data-source.ts +2 -1
- package/src/lib/sources/image-source.ts +2 -1
- package/src/lib/sources/image-tile-source.ts +2 -1
- package/src/lib/sources/tile-source-adapter.ts +2 -1
- package/src/lib/sources/tile-source.ts +2 -1
- package/src/lib/sources/utils/utils.ts +2 -1
- package/src/lib/sources/vector-tile-source.ts +2 -1
- package/src/loader-types.ts +7 -5
- package/src/service-types.ts +2 -1
- package/src/writer-types.ts +15 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// loaders.gl
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {LoaderOptions} from '../../loader-types';
|
|
@@ -18,14 +19,21 @@ export function mergeLoaderOptions<Options extends LoaderOptions>(
|
|
|
18
19
|
|
|
19
20
|
function mergeOptionsRecursively(
|
|
20
21
|
baseOptions: Record<string, unknown>,
|
|
21
|
-
newOptions: Record<string, unknown
|
|
22
|
+
newOptions: Record<string, unknown>,
|
|
23
|
+
level = 0
|
|
22
24
|
): Record<string, unknown> {
|
|
25
|
+
// Sanity check (jest test runner overwrites the console object which can lead to infinite recursion)
|
|
26
|
+
if (level > 3) {
|
|
27
|
+
return newOptions;
|
|
28
|
+
}
|
|
29
|
+
|
|
23
30
|
const options = {...baseOptions};
|
|
24
31
|
for (const [key, newValue] of Object.entries(newOptions)) {
|
|
25
32
|
if (newValue && typeof newValue === 'object' && !Array.isArray(newValue)) {
|
|
26
33
|
options[key] = mergeOptionsRecursively(
|
|
27
34
|
(options[key] as Record<string, unknown>) || {},
|
|
28
|
-
newOptions[key] as Record<string, unknown
|
|
35
|
+
newOptions[key] as Record<string, unknown>,
|
|
36
|
+
level + 1
|
|
29
37
|
);
|
|
30
38
|
// Object.assign(options[key] as object, newOptions[key]);
|
|
31
39
|
} else {
|
package/src/loader-types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// loaders.gl
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {
|
|
@@ -180,10 +181,6 @@ export type LoaderWithParser<DataT = any, BatchT = any, LoaderOptionsT = LoaderO
|
|
|
180
181
|
options?: LoaderOptionsT,
|
|
181
182
|
context?: LoaderContext
|
|
182
183
|
) => DataT;
|
|
183
|
-
/** Parse atomically from a string asynchronously */
|
|
184
|
-
parseText?: (text: string, options?: LoaderOptionsT, context?: LoaderContext) => Promise<DataT>;
|
|
185
|
-
/** Parse atomically from a string synchronously */
|
|
186
|
-
parseTextSync?: (text: string, options?: LoaderOptionsT, context?: LoaderContext) => DataT;
|
|
187
184
|
/** Parse batches of data from an iterator (e.g. fetch stream), return an iterator that yield parsed batches. */
|
|
188
185
|
parseInBatches?: (
|
|
189
186
|
iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,
|
|
@@ -196,6 +193,11 @@ export type LoaderWithParser<DataT = any, BatchT = any, LoaderOptionsT = LoaderO
|
|
|
196
193
|
options?: LoaderOptionsT,
|
|
197
194
|
context?: LoaderContext
|
|
198
195
|
) => AsyncIterable<BatchT>;
|
|
196
|
+
|
|
197
|
+
/** Parse atomically from a string asynchronously */
|
|
198
|
+
parseText?: (text: string, options?: LoaderOptionsT, context?: LoaderContext) => Promise<DataT>;
|
|
199
|
+
/** Parse atomically from a string synchronously */
|
|
200
|
+
parseTextSync?: (text: string, options?: LoaderOptionsT, context?: LoaderContext) => DataT;
|
|
199
201
|
};
|
|
200
202
|
|
|
201
203
|
/**
|
package/src/service-types.ts
CHANGED
package/src/writer-types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// loaders.gl
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
// WRITERS
|
|
@@ -47,6 +48,7 @@ export type Writer<DataT = unknown, BatchT = unknown, WriterOptionsT = WriterOpt
|
|
|
47
48
|
/** Is the input of this loader text */
|
|
48
49
|
text?: boolean;
|
|
49
50
|
|
|
51
|
+
/** Default options for this writer */
|
|
50
52
|
options: WriterOptionsT;
|
|
51
53
|
deprecatedOptions?: Record<string, string>;
|
|
52
54
|
};
|
|
@@ -59,13 +61,22 @@ export type WriterWithEncoder<
|
|
|
59
61
|
BatchT = unknown,
|
|
60
62
|
WriterOptionsT = WriterOptions
|
|
61
63
|
> = Writer<DataT, BatchT, WriterOptionsT> & {
|
|
62
|
-
|
|
64
|
+
/** Encode to binary, asynchronously */
|
|
65
|
+
encode(data: DataT, options?: WriterOptionsT): Promise<ArrayBuffer>;
|
|
66
|
+
/** Encode to binary, synchronously */
|
|
63
67
|
encodeSync?(data: DataT, options?: WriterOptionsT): ArrayBuffer;
|
|
68
|
+
/** Encode to binary in batches */
|
|
69
|
+
encodeInBatches?(data: AsyncIterable<any>, options?: WriterOptionsT): AsyncIterable<ArrayBuffer>;
|
|
64
70
|
|
|
71
|
+
/** Encode to text, asynchronously. For text formats. */
|
|
65
72
|
encodeText?(table: DataT, options?: WriterOptionsT): Promise<string>;
|
|
73
|
+
/** Encode to text, synchronously. For text formats. */
|
|
66
74
|
encodeTextSync?(table: DataT, options?: WriterOptionsT): string;
|
|
67
|
-
|
|
68
|
-
|
|
75
|
+
/** Encode to text in batched. For text formats. */
|
|
76
|
+
encodeTextInBatches?(
|
|
77
|
+
data: AsyncIterable<any>,
|
|
78
|
+
options?: WriterOptionsT
|
|
79
|
+
): AsyncIterable<ArrayBuffer>;
|
|
69
80
|
|
|
70
81
|
encodeURLtoURL?: (
|
|
71
82
|
inputUrl: string,
|