@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.
Files changed (83) hide show
  1. package/dist/index.cjs +31 -6
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/json-loader.js +1 -1
  5. package/dist/json-loader.js.map +1 -1
  6. package/dist/lib/binary-utils/get-first-characters.d.ts.map +1 -1
  7. package/dist/lib/binary-utils/get-first-characters.js.map +1 -1
  8. package/dist/lib/binary-utils/memory-conversion-utils.d.ts.map +1 -1
  9. package/dist/lib/binary-utils/memory-conversion-utils.js.map +1 -1
  10. package/dist/lib/file-provider/file-handle-file.d.ts +11 -3
  11. package/dist/lib/file-provider/file-handle-file.d.ts.map +1 -1
  12. package/dist/lib/file-provider/file-handle-file.js +9 -4
  13. package/dist/lib/file-provider/file-handle-file.js.map +1 -1
  14. package/dist/lib/files/blob-file.d.ts.map +1 -1
  15. package/dist/lib/files/blob-file.js.map +1 -1
  16. package/dist/lib/files/file.d.ts.map +1 -1
  17. package/dist/lib/files/file.js.map +1 -1
  18. package/dist/lib/files/http-file.d.ts.map +1 -1
  19. package/dist/lib/files/http-file.js.map +1 -1
  20. package/dist/lib/files/node-file-facade.d.ts +5 -1
  21. package/dist/lib/files/node-file-facade.d.ts.map +1 -1
  22. package/dist/lib/files/node-file-facade.js +6 -0
  23. package/dist/lib/files/node-file-facade.js.map +1 -1
  24. package/dist/lib/filesystems/filesystem.d.ts.map +1 -1
  25. package/dist/lib/filesystems/filesystem.js.map +1 -1
  26. package/dist/lib/filesystems/node-filesystem-facade.d.ts.map +1 -1
  27. package/dist/lib/filesystems/node-filesystem-facade.js.map +1 -1
  28. package/dist/lib/node/buffer.browser.d.ts.map +1 -1
  29. package/dist/lib/node/buffer.browser.js.map +1 -1
  30. package/dist/lib/node/buffer.d.ts.map +1 -1
  31. package/dist/lib/node/buffer.js.map +1 -1
  32. package/dist/lib/node/stream.d.ts.map +1 -1
  33. package/dist/lib/node/stream.js.map +1 -1
  34. package/dist/lib/option-utils/merge-loader-options.d.ts.map +1 -1
  35. package/dist/lib/option-utils/merge-loader-options.js +5 -1
  36. package/dist/lib/option-utils/merge-loader-options.js.map +1 -1
  37. package/dist/lib/sources/data-source.d.ts.map +1 -1
  38. package/dist/lib/sources/data-source.js.map +1 -1
  39. package/dist/lib/sources/image-source.d.ts.map +1 -1
  40. package/dist/lib/sources/image-source.js.map +1 -1
  41. package/dist/lib/sources/image-tile-source.d.ts.map +1 -1
  42. package/dist/lib/sources/image-tile-source.js.map +1 -1
  43. package/dist/lib/sources/tile-source-adapter.d.ts.map +1 -1
  44. package/dist/lib/sources/tile-source-adapter.js.map +1 -1
  45. package/dist/lib/sources/tile-source.d.ts.map +1 -1
  46. package/dist/lib/sources/tile-source.js.map +1 -1
  47. package/dist/lib/sources/utils/utils.d.ts.map +1 -1
  48. package/dist/lib/sources/utils/utils.js.map +1 -1
  49. package/dist/lib/sources/vector-tile-source.d.ts.map +1 -1
  50. package/dist/lib/sources/vector-tile-source.js.map +1 -1
  51. package/dist/loader-types.d.ts +4 -4
  52. package/dist/loader-types.d.ts.map +1 -1
  53. package/dist/loader-types.js.map +1 -1
  54. package/dist/service-types.d.ts.map +1 -1
  55. package/dist/service-types.js.map +1 -1
  56. package/dist/writer-types.d.ts +10 -2
  57. package/dist/writer-types.d.ts.map +1 -1
  58. package/dist/writer-types.js.map +1 -1
  59. package/package.json +3 -3
  60. package/src/index.ts +2 -1
  61. package/src/lib/binary-utils/get-first-characters.ts +2 -1
  62. package/src/lib/binary-utils/memory-conversion-utils.ts +2 -1
  63. package/src/lib/file-provider/file-handle-file.ts +21 -8
  64. package/src/lib/files/blob-file.ts +2 -1
  65. package/src/lib/files/file.ts +2 -1
  66. package/src/lib/files/http-file.ts +2 -1
  67. package/src/lib/files/node-file-facade.ts +13 -2
  68. package/src/lib/filesystems/filesystem.ts +2 -1
  69. package/src/lib/filesystems/node-filesystem-facade.ts +2 -1
  70. package/src/lib/node/buffer.browser.ts +2 -1
  71. package/src/lib/node/buffer.ts +2 -1
  72. package/src/lib/node/stream.ts +2 -1
  73. package/src/lib/option-utils/merge-loader-options.ts +11 -3
  74. package/src/lib/sources/data-source.ts +2 -1
  75. package/src/lib/sources/image-source.ts +2 -1
  76. package/src/lib/sources/image-tile-source.ts +2 -1
  77. package/src/lib/sources/tile-source-adapter.ts +2 -1
  78. package/src/lib/sources/tile-source.ts +2 -1
  79. package/src/lib/sources/utils/utils.ts +2 -1
  80. package/src/lib/sources/vector-tile-source.ts +2 -1
  81. package/src/loader-types.ts +7 -5
  82. package/src/service-types.ts +2 -1
  83. package/src/writer-types.ts +15 -4
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
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 {
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import type {LoaderOptions} from '@loaders.gl/loader-utils';
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import type {DataSourceProps} from './data-source';
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import type {ImageType} from './utils/image-type';
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
 
3
4
  import {TileSource, GetTileParameters} from './tile-source';
4
5
  import {ImageSource, ImageSourceMetadata} from './image-source';
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  /**
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import type {LoaderOptions} from '@loaders.gl/loader-utils';
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import {TileSource, TileSourceMetadata} from './tile-source';
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
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
  /**
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import type {ImageSource, ImageSourceProps} from './lib/sources/image-source';
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
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
- encode?(data: DataT, options?: WriterOptionsT): Promise<ArrayBuffer>;
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
- encodeInBatches?(data: AsyncIterable<any>, options?: WriterOptionsT): AsyncIterable<ArrayBuffer>;
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,