@loaders.gl/loader-utils 4.4.0-alpha.2 → 4.4.0-alpha.9

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 (160) hide show
  1. package/README.md +8 -0
  2. package/dist/format-types.js +1 -0
  3. package/dist/format-types.js.map +1 -0
  4. package/dist/index.cjs +165 -287
  5. package/dist/index.cjs.map +4 -4
  6. package/dist/index.d.ts +6 -9
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +4 -6
  9. package/dist/index.js.map +1 -0
  10. package/dist/json-loader.js +2 -1
  11. package/dist/json-loader.js.map +1 -0
  12. package/dist/lib/binary-utils/array-buffer-utils.d.ts +2 -2
  13. package/dist/lib/binary-utils/array-buffer-utils.d.ts.map +1 -1
  14. package/dist/lib/binary-utils/array-buffer-utils.js +1 -0
  15. package/dist/lib/binary-utils/array-buffer-utils.js.map +1 -0
  16. package/dist/lib/binary-utils/dataview-copy-utils.js +1 -0
  17. package/dist/lib/binary-utils/dataview-copy-utils.js.map +1 -0
  18. package/dist/lib/binary-utils/get-first-characters.d.ts +1 -1
  19. package/dist/lib/binary-utils/get-first-characters.d.ts.map +1 -1
  20. package/dist/lib/binary-utils/get-first-characters.js +1 -0
  21. package/dist/lib/binary-utils/get-first-characters.js.map +1 -0
  22. package/dist/lib/binary-utils/memory-conversion-utils.d.ts +10 -4
  23. package/dist/lib/binary-utils/memory-conversion-utils.d.ts.map +1 -1
  24. package/dist/lib/binary-utils/memory-conversion-utils.js +40 -4
  25. package/dist/lib/binary-utils/memory-conversion-utils.js.map +1 -0
  26. package/dist/lib/binary-utils/memory-copy-utils.js +1 -0
  27. package/dist/lib/binary-utils/memory-copy-utils.js.map +1 -0
  28. package/dist/lib/env-utils/assert.js +1 -0
  29. package/dist/lib/env-utils/assert.js.map +1 -0
  30. package/dist/lib/env-utils/globals.js +1 -0
  31. package/dist/lib/env-utils/globals.js.map +1 -0
  32. package/dist/lib/file-provider/data-view-file.d.ts.map +1 -1
  33. package/dist/lib/file-provider/data-view-file.js +3 -1
  34. package/dist/lib/file-provider/data-view-file.js.map +1 -0
  35. package/dist/lib/file-provider/file-handle-file.js +1 -0
  36. package/dist/lib/file-provider/file-handle-file.js.map +1 -0
  37. package/dist/lib/file-provider/file-provider-interface.js +1 -0
  38. package/dist/lib/file-provider/file-provider-interface.js.map +1 -0
  39. package/dist/lib/file-provider/file-provider.js +1 -0
  40. package/dist/lib/file-provider/file-provider.js.map +1 -0
  41. package/dist/lib/files/blob-file.js +1 -0
  42. package/dist/lib/files/blob-file.js.map +1 -0
  43. package/dist/lib/files/file.js +1 -0
  44. package/dist/lib/files/file.js.map +1 -0
  45. package/dist/lib/files/http-file.js +1 -0
  46. package/dist/lib/files/http-file.js.map +1 -0
  47. package/dist/lib/files/node-file-facade.js +1 -0
  48. package/dist/lib/files/node-file-facade.js.map +1 -0
  49. package/dist/lib/files/sources.js +1 -0
  50. package/dist/lib/files/sources.js.map +1 -0
  51. package/dist/lib/filesystems/filesystem.js +1 -0
  52. package/dist/lib/filesystems/filesystem.js.map +1 -0
  53. package/dist/lib/filesystems/node-filesystem-facade.js +1 -0
  54. package/dist/lib/filesystems/node-filesystem-facade.js.map +1 -0
  55. package/dist/lib/iterators/async-iteration.d.ts +14 -14
  56. package/dist/lib/iterators/async-iteration.d.ts.map +1 -1
  57. package/dist/lib/iterators/async-iteration.js +68 -16
  58. package/dist/lib/iterators/async-iteration.js.map +1 -0
  59. package/dist/lib/iterators/text-iterators.js +2 -1
  60. package/dist/lib/iterators/text-iterators.js.map +1 -0
  61. package/dist/lib/javascript-utils/is-type.d.ts +59 -0
  62. package/dist/lib/javascript-utils/is-type.d.ts.map +1 -0
  63. package/dist/lib/javascript-utils/is-type.js +68 -0
  64. package/dist/lib/javascript-utils/is-type.js.map +1 -0
  65. package/dist/lib/log-utils/log.js +2 -1
  66. package/dist/lib/log-utils/log.js.map +1 -0
  67. package/dist/lib/module-utils/js-module-utils.js +1 -0
  68. package/dist/lib/module-utils/js-module-utils.js.map +1 -0
  69. package/dist/lib/node/buffer.browser.js +1 -0
  70. package/dist/lib/node/buffer.browser.js.map +1 -0
  71. package/dist/lib/node/buffer.js +1 -0
  72. package/dist/lib/node/buffer.js.map +1 -0
  73. package/dist/lib/node/fs.browser.js +1 -0
  74. package/dist/lib/node/fs.browser.js.map +1 -0
  75. package/dist/lib/node/promisify.js +1 -0
  76. package/dist/lib/node/promisify.js.map +1 -0
  77. package/dist/lib/node/stream.browser.js +1 -0
  78. package/dist/lib/node/stream.browser.js.map +1 -0
  79. package/dist/lib/node/stream.js +1 -0
  80. package/dist/lib/node/stream.js.map +1 -0
  81. package/dist/lib/option-utils/merge-options.js +1 -0
  82. package/dist/lib/option-utils/merge-options.js.map +1 -0
  83. package/dist/lib/parser-utils/parse-json.js +1 -0
  84. package/dist/lib/parser-utils/parse-json.js.map +1 -0
  85. package/dist/lib/path-utils/file-aliases.js +1 -0
  86. package/dist/lib/path-utils/file-aliases.js.map +1 -0
  87. package/dist/lib/path-utils/get-cwd.js +1 -0
  88. package/dist/lib/path-utils/get-cwd.js.map +1 -0
  89. package/dist/lib/path-utils/path.js +2 -1
  90. package/dist/lib/path-utils/path.js.map +1 -0
  91. package/dist/lib/request-utils/request-scheduler.d.ts +4 -0
  92. package/dist/lib/request-utils/request-scheduler.d.ts.map +1 -1
  93. package/dist/lib/request-utils/request-scheduler.js +15 -0
  94. package/dist/lib/request-utils/request-scheduler.js.map +1 -0
  95. package/dist/lib/sources/data-source.d.ts +4 -4
  96. package/dist/lib/sources/data-source.d.ts.map +1 -1
  97. package/dist/lib/sources/data-source.js +2 -1
  98. package/dist/lib/sources/data-source.js.map +1 -0
  99. package/dist/lib/sources/image-source.js +1 -0
  100. package/dist/lib/sources/image-source.js.map +1 -0
  101. package/dist/lib/sources/image-tile-source.js +1 -0
  102. package/dist/lib/sources/image-tile-source.js.map +1 -0
  103. package/dist/lib/sources/tile-source-adapter.js +1 -0
  104. package/dist/lib/sources/tile-source-adapter.js.map +1 -0
  105. package/dist/lib/sources/tile-source.js +1 -0
  106. package/dist/lib/sources/tile-source.js.map +1 -0
  107. package/dist/lib/sources/utils/image-type.js +1 -0
  108. package/dist/lib/sources/utils/image-type.js.map +1 -0
  109. package/dist/lib/sources/utils/utils.js +2 -1
  110. package/dist/lib/sources/utils/utils.js.map +1 -0
  111. package/dist/lib/sources/vector-source.js +1 -0
  112. package/dist/lib/sources/vector-source.js.map +1 -0
  113. package/dist/lib/sources/vector-tile-source.js +1 -0
  114. package/dist/lib/sources/vector-tile-source.js.map +1 -0
  115. package/dist/lib/worker-loader-utils/create-loader-worker.js +5 -1
  116. package/dist/lib/worker-loader-utils/create-loader-worker.js.map +1 -0
  117. package/dist/lib/worker-loader-utils/encode-with-worker.d.ts +1 -1
  118. package/dist/lib/worker-loader-utils/encode-with-worker.d.ts.map +1 -1
  119. package/dist/lib/worker-loader-utils/encode-with-worker.js +5 -2
  120. package/dist/lib/worker-loader-utils/encode-with-worker.js.map +1 -0
  121. package/dist/lib/worker-loader-utils/parse-with-worker.d.ts +1 -1
  122. package/dist/lib/worker-loader-utils/parse-with-worker.d.ts.map +1 -1
  123. package/dist/lib/worker-loader-utils/parse-with-worker.js +6 -3
  124. package/dist/lib/worker-loader-utils/parse-with-worker.js.map +1 -0
  125. package/dist/loader-types.d.ts +91 -67
  126. package/dist/loader-types.d.ts.map +1 -1
  127. package/dist/loader-types.js +1 -0
  128. package/dist/loader-types.js.map +1 -0
  129. package/dist/source-types.js +1 -0
  130. package/dist/source-types.js.map +1 -0
  131. package/dist/types.d.ts +9 -4
  132. package/dist/types.d.ts.map +1 -1
  133. package/dist/types.js +1 -0
  134. package/dist/types.js.map +1 -0
  135. package/dist/workers/json-worker.js +1 -0
  136. package/dist/workers/json-worker.js.map +1 -0
  137. package/dist/writer-types.d.ts +14 -7
  138. package/dist/writer-types.d.ts.map +1 -1
  139. package/dist/writer-types.js +1 -0
  140. package/dist/writer-types.js.map +1 -0
  141. package/package.json +4 -4
  142. package/src/index.ts +36 -9
  143. package/src/lib/binary-utils/array-buffer-utils.ts +3 -3
  144. package/src/lib/binary-utils/get-first-characters.ts +1 -1
  145. package/src/lib/binary-utils/memory-conversion-utils.ts +58 -8
  146. package/src/lib/file-provider/data-view-file.ts +6 -1
  147. package/src/lib/iterators/async-iteration.ts +94 -19
  148. package/src/lib/iterators/text-iterators.ts +1 -1
  149. package/src/lib/javascript-utils/is-type.ts +130 -0
  150. package/src/lib/node/buffer.ts +1 -1
  151. package/src/lib/path-utils/path.ts +1 -1
  152. package/src/lib/request-utils/request-scheduler.ts +15 -0
  153. package/src/lib/sources/data-source.ts +5 -5
  154. package/src/lib/sources/utils/utils.ts +1 -1
  155. package/src/lib/worker-loader-utils/create-loader-worker.ts +4 -1
  156. package/src/lib/worker-loader-utils/encode-with-worker.ts +5 -2
  157. package/src/lib/worker-loader-utils/parse-with-worker.ts +5 -3
  158. package/src/loader-types.ts +115 -84
  159. package/src/types.ts +17 -9
  160. package/src/writer-types.ts +15 -8
package/README.md CHANGED
@@ -3,3 +3,11 @@
3
3
  This module contains shared utilities for loaders.gl, a collection of framework-independent 3D and geospatial loaders (parsers).
4
4
 
5
5
  For documentation please visit the [website](https://loaders.gl).
6
+
7
+ ## Binary iterator utilities
8
+
9
+ `@loaders.gl/loader-utils` includes helpers such as `concatenateArrayBuffersAsync` that operate
10
+ over `ArrayBuffer`, `ArrayBufferView`, and `ArrayBufferLike` inputs (including `SharedArrayBuffer`).
11
+ These utilities make it easy to normalize streamed binary data before handing it off to loaders.
12
+ Chunks backed by `SharedArrayBuffer` or typed array views are copied into standalone `ArrayBuffer`
13
+ instances so byte offsets and underlying storage quirks never corrupt concatenated output.
@@ -2,3 +2,4 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
  export {};
5
+ //# sourceMappingURL=format-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-types.js","sourceRoot":"","sources":["../src/format-types.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC"}
package/dist/index.cjs CHANGED
@@ -27,9 +27,6 @@ var dist_exports = {};
27
27
  __export(dist_exports, {
28
28
  BlobFile: () => BlobFile,
29
29
  DataSource: () => DataSource,
30
- DataViewFile: () => DataViewFile,
31
- FileHandleFile: () => FileHandleFile,
32
- FileProvider: () => FileProvider,
33
30
  HttpFile: () => HttpFile,
34
31
  ImageSource: () => ImageSource,
35
32
  JSONLoader: () => JSONLoader,
@@ -52,8 +49,10 @@ __export(dist_exports, {
52
49
  copyPaddedStringToDataView: () => copyPaddedStringToDataView,
53
50
  copyStringToDataView: () => copyStringToDataView,
54
51
  copyToArray: () => copyToArray,
52
+ copyToArrayBuffer: () => copyToArrayBuffer2,
55
53
  createLoaderWorker: () => createLoaderWorker,
56
54
  document: () => document_,
55
+ ensureArrayBuffer: () => ensureArrayBuffer,
57
56
  forEach: () => forEach,
58
57
  getFirstCharacters: () => getFirstCharacters,
59
58
  getJSModule: () => getJSModule,
@@ -62,10 +61,26 @@ __export(dist_exports, {
62
61
  getPathPrefix: () => getPathPrefix,
63
62
  getRequiredOptions: () => getRequiredOptions,
64
63
  global: () => global_,
64
+ isArrayBuffer: () => isArrayBuffer,
65
+ isArrayBufferLike: () => isArrayBufferLike,
66
+ isAsyncIterable: () => isAsyncIterable,
67
+ isBlob: () => isBlob,
65
68
  isBrowser: () => isBrowser,
66
69
  isBuffer: () => isBuffer,
67
- isFileProvider: () => isFileProvider,
70
+ isFile: () => isFile,
71
+ isIterable: () => isIterable,
72
+ isIterator: () => isIterator,
73
+ isObject: () => isObject,
74
+ isPromise: () => isPromise,
75
+ isPureObject: () => isPureObject,
76
+ isReadableDOMStream: () => isReadableDOMStream,
77
+ isReadableNodeStream: () => isReadableNodeStream,
78
+ isReadableStream: () => isReadableStream,
79
+ isResponse: () => isResponse,
68
80
  isWorker: () => isWorker,
81
+ isWritableDOMStream: () => isWritableDOMStream,
82
+ isWritableNodeStream: () => isWritableNodeStream,
83
+ isWritableStream: () => isWritableStream,
69
84
  log: () => log,
70
85
  makeLineIterator: () => makeLineIterator,
71
86
  makeNumberedLineIterator: () => makeNumberedLineIterator,
@@ -90,6 +105,8 @@ __export(dist_exports, {
90
105
  sliceArrayBuffer: () => sliceArrayBuffer,
91
106
  stream: () => stream_browser_exports,
92
107
  toArrayBuffer: () => toArrayBuffer2,
108
+ toArrayBufferIterator: () => toArrayBufferIterator,
109
+ toArrayBufferView: () => toArrayBufferView,
93
110
  toBuffer: () => toBuffer2,
94
111
  window: () => window_
95
112
  });
@@ -140,7 +157,7 @@ var nodeVersion = matches && parseFloat(matches[1]) || 0;
140
157
 
141
158
  // dist/lib/log-utils/log.js
142
159
  var import_log = require("@probe.gl/log");
143
- var VERSION = true ? "4.4.0-alpha.1" : "latest";
160
+ var VERSION = true ? "4.4.0-alpha.9" : "latest";
144
161
  var version = VERSION[0] >= "0" && VERSION[0] <= "9" ? `v${VERSION}` : "";
145
162
  function createLog() {
146
163
  const log2 = new import_log.Log({ id: "loaders.gl" });
@@ -153,6 +170,28 @@ function createLog() {
153
170
  }
154
171
  var log = createLog();
155
172
 
173
+ // dist/lib/javascript-utils/is-type.js
174
+ var isBoolean = (value) => typeof value === "boolean";
175
+ var isFunction = (value) => typeof value === "function";
176
+ var isObject = (value) => value !== null && typeof value === "object";
177
+ var isPureObject = (value) => isObject(value) && value.constructor === {}.constructor;
178
+ var isArrayBuffer = (value) => typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer;
179
+ var isSharedArrayBuffer = (value) => typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer;
180
+ var isArrayBufferLike = (value) => isObject(value) && typeof value.byteLength === "number" && typeof value.slice === "function";
181
+ var isPromise = (value) => isObject(value) && "then" in value && isFunction(value.then);
182
+ var isIterable = (value) => Boolean(value) && isFunction(value[Symbol.iterator]);
183
+ var isAsyncIterable = (value) => Boolean(value) && isFunction(value[Symbol.asyncIterator]);
184
+ var isIterator = (value) => Boolean(value) && isFunction(value.next);
185
+ var isResponse = (value) => typeof Response !== "undefined" && value instanceof Response || isObject(value) && isFunction(value.arrayBuffer) && isFunction(value.text) && isFunction(value.json);
186
+ var isFile = (value) => typeof File !== "undefined" && value instanceof File;
187
+ var isBlob = (value) => typeof Blob !== "undefined" && value instanceof Blob;
188
+ var isWritableDOMStream = (value) => isObject(value) && isFunction(value.abort) && isFunction(value.getWriter);
189
+ var isReadableDOMStream = (value) => typeof ReadableStream !== "undefined" && value instanceof ReadableStream || isObject(value) && isFunction(value.tee) && isFunction(value.cancel) && isFunction(value.getReader);
190
+ var isWritableNodeStream = (value) => isObject(value) && isFunction(value.end) && isFunction(value.write) && isBoolean(value.writable);
191
+ var isReadableNodeStream = (value) => isObject(value) && isFunction(value.read) && isFunction(value.pipe) && isBoolean(value.readable);
192
+ var isReadableStream = (value) => isReadableDOMStream(value) || isReadableNodeStream(value);
193
+ var isWritableStream = (value) => isWritableDOMStream(value) || isWritableNodeStream(value);
194
+
156
195
  // dist/lib/option-utils/merge-options.js
157
196
  function getRequiredOptions(options) {
158
197
  return options;
@@ -274,7 +313,10 @@ async function parseData({ loader, arrayBuffer, options, context }) {
274
313
  options = {
275
314
  ...options,
276
315
  modules: loader && loader.options && loader.options.modules || {},
277
- worker: false
316
+ core: {
317
+ ...options.core,
318
+ worker: false
319
+ }
278
320
  };
279
321
  return await parser(data, { ...options }, context, loader);
280
322
  }
@@ -282,18 +324,21 @@ async function parseData({ loader, arrayBuffer, options, context }) {
282
324
  // dist/lib/worker-loader-utils/parse-with-worker.js
283
325
  var import_worker_utils2 = require("@loaders.gl/worker-utils");
284
326
  function canParseWithWorker(loader, options) {
327
+ var _a, _b;
285
328
  if (!import_worker_utils2.WorkerFarm.isSupported()) {
286
329
  return false;
287
330
  }
288
- if (!import_worker_utils2.isBrowser && !(options == null ? void 0 : options._nodeWorkers)) {
331
+ const nodeWorkers = (options == null ? void 0 : options._nodeWorkers) ?? ((_a = options == null ? void 0 : options.core) == null ? void 0 : _a._nodeWorkers);
332
+ if (!import_worker_utils2.isBrowser && !nodeWorkers) {
289
333
  return false;
290
334
  }
291
- return loader.worker && (options == null ? void 0 : options.worker);
335
+ const useWorkers = (options == null ? void 0 : options.worker) ?? ((_b = options == null ? void 0 : options.core) == null ? void 0 : _b.worker);
336
+ return Boolean(loader.worker && useWorkers);
292
337
  }
293
338
  async function parseWithWorker(loader, data, options, context, parseOnMainThread2) {
294
339
  const name = loader.id;
295
340
  const url = (0, import_worker_utils2.getWorkerURL)(loader, options);
296
- const workerFarm = import_worker_utils2.WorkerFarm.getWorkerFarm(options);
341
+ const workerFarm = import_worker_utils2.WorkerFarm.getWorkerFarm(options == null ? void 0 : options.core);
297
342
  const workerPool = workerFarm.getWorkerPool({ name, url });
298
343
  options = JSON.parse(JSON.stringify(options));
299
344
  context = JSON.parse(JSON.stringify(context || {}));
@@ -338,13 +383,16 @@ async function onMessage(parseOnMainThread2, job, type, payload) {
338
383
  // dist/lib/worker-loader-utils/encode-with-worker.js
339
384
  var import_worker_utils3 = require("@loaders.gl/worker-utils");
340
385
  function canEncodeWithWorker(writer, options) {
386
+ var _a, _b;
341
387
  if (!import_worker_utils3.WorkerFarm.isSupported()) {
342
388
  return false;
343
389
  }
344
- if (!isBrowser && !(options == null ? void 0 : options._nodeWorkers)) {
390
+ const nodeWorkers = (options == null ? void 0 : options._nodeWorkers) ?? ((_a = options == null ? void 0 : options.core) == null ? void 0 : _a._nodeWorkers);
391
+ const useWorkers = (options == null ? void 0 : options.worker) ?? ((_b = options == null ? void 0 : options.core) == null ? void 0 : _b.worker);
392
+ if (!isBrowser && !nodeWorkers) {
345
393
  return false;
346
394
  }
347
- return writer.worker && (options == null ? void 0 : options.worker);
395
+ return Boolean(writer.worker && useWorkers);
348
396
  }
349
397
 
350
398
  // dist/lib/binary-utils/get-first-characters.js
@@ -513,7 +561,7 @@ async function* makeTextDecoderIterator(arrayBufferIterator, options = {}) {
513
561
  async function* makeTextEncoderIterator(textIterator) {
514
562
  const textEncoder = new TextEncoder();
515
563
  for await (const text of textIterator) {
516
- yield typeof text === "string" ? textEncoder.encode(text) : text;
564
+ yield typeof text === "string" ? textEncoder.encode(text).buffer : text;
517
565
  }
518
566
  }
519
567
  async function* makeLineIterator(textIterator) {
@@ -540,11 +588,14 @@ async function* makeNumberedLineIterator(lineIterator) {
540
588
  }
541
589
 
542
590
  // dist/lib/iterators/async-iteration.js
543
- async function forEach(iterator, visitor) {
591
+ async function forEach(iterable, visitor) {
592
+ const iterator = toAsyncIterator(iterable);
544
593
  while (true) {
545
594
  const { done, value } = await iterator.next();
546
595
  if (done) {
547
- iterator.return();
596
+ if (iterator.return) {
597
+ iterator.return();
598
+ }
548
599
  return;
549
600
  }
550
601
  const cancel = visitor(value);
@@ -556,10 +607,60 @@ async function forEach(iterator, visitor) {
556
607
  async function concatenateArrayBuffersAsync(asyncIterator) {
557
608
  const arrayBuffers = [];
558
609
  for await (const chunk of asyncIterator) {
559
- arrayBuffers.push(chunk);
610
+ arrayBuffers.push(copyToArrayBuffer(chunk));
560
611
  }
561
612
  return concatenateArrayBuffers(...arrayBuffers);
562
613
  }
614
+ async function* toArrayBufferIterator(asyncIterator) {
615
+ for await (const chunk of asyncIterator) {
616
+ yield copyToArrayBuffer(chunk);
617
+ }
618
+ }
619
+ function copyToArrayBuffer(chunk) {
620
+ if (chunk instanceof ArrayBuffer) {
621
+ return chunk;
622
+ }
623
+ if (ArrayBuffer.isView(chunk)) {
624
+ const { buffer, byteOffset, byteLength } = chunk;
625
+ return copyFromBuffer(buffer, byteOffset, byteLength);
626
+ }
627
+ return copyFromBuffer(chunk);
628
+ }
629
+ function copyFromBuffer(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
630
+ const view = new Uint8Array(buffer, byteOffset, byteLength);
631
+ const copy = new Uint8Array(view.length);
632
+ copy.set(view);
633
+ return copy.buffer;
634
+ }
635
+ function toAsyncIterator(iterable) {
636
+ if (typeof iterable[Symbol.asyncIterator] === "function") {
637
+ return iterable[Symbol.asyncIterator]();
638
+ }
639
+ if (typeof iterable[Symbol.iterator] === "function") {
640
+ const iterator = iterable[Symbol.iterator]();
641
+ return iteratorToAsyncIterator(iterator);
642
+ }
643
+ return iterable;
644
+ }
645
+ function iteratorToAsyncIterator(iterator) {
646
+ return {
647
+ next(value) {
648
+ return Promise.resolve(iterator.next(value));
649
+ },
650
+ return(value) {
651
+ if (typeof iterator.return === "function") {
652
+ return Promise.resolve(iterator.return(value));
653
+ }
654
+ return Promise.resolve({ done: true, value });
655
+ },
656
+ throw(error) {
657
+ if (typeof iterator.throw === "function") {
658
+ return Promise.resolve(iterator.throw(error));
659
+ }
660
+ return Promise.reject(error);
661
+ }
662
+ };
663
+ }
563
664
 
564
665
  // dist/lib/request-utils/request-scheduler.js
565
666
  var import_stats = require("@probe.gl/stats");
@@ -597,6 +698,20 @@ var RequestScheduler = class {
597
698
  this.stats.get(STAT_QUEUED_REQUESTS_EVER);
598
699
  this.stats.get(STAT_ACTIVE_REQUESTS_EVER);
599
700
  }
701
+ /**
702
+ * Update scheduler props. Preserves active and queued requests.
703
+ */
704
+ setProps(props) {
705
+ if (props.throttleRequests !== void 0) {
706
+ this.props.throttleRequests = props.throttleRequests;
707
+ }
708
+ if (props.maxRequests !== void 0) {
709
+ this.props.maxRequests = props.maxRequests;
710
+ }
711
+ if (props.debounceTime !== void 0) {
712
+ this.props.debounceTime = props.debounceTime;
713
+ }
714
+ }
600
715
  /**
601
716
  * Called by an application that wants to issue a request, without having it deeply queued by the browser
602
717
  *
@@ -721,7 +836,7 @@ function resolvePath(filename2) {
721
836
  }
722
837
 
723
838
  // dist/json-loader.js
724
- var VERSION2 = true ? "4.4.0-alpha.1" : "latest";
839
+ var VERSION2 = true ? "4.4.0-alpha.9" : "latest";
725
840
  var JSONLoader = {
726
841
  dataType: null,
727
842
  batchType: null,
@@ -763,11 +878,15 @@ function toArrayBuffer2(data) {
763
878
  if (data instanceof ArrayBuffer) {
764
879
  return data;
765
880
  }
881
+ if (isSharedArrayBuffer(data)) {
882
+ return copyToArrayBuffer2(data);
883
+ }
766
884
  if (ArrayBuffer.isView(data)) {
885
+ const buffer = data.buffer;
767
886
  if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
768
- return data.buffer;
887
+ return buffer;
769
888
  }
770
- return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
889
+ return buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
771
890
  }
772
891
  if (typeof data === "string") {
773
892
  const text = data;
@@ -779,6 +898,31 @@ function toArrayBuffer2(data) {
779
898
  }
780
899
  throw new Error("toArrayBuffer");
781
900
  }
901
+ function ensureArrayBuffer(bufferSource) {
902
+ if (bufferSource instanceof ArrayBuffer) {
903
+ return bufferSource;
904
+ }
905
+ if (isSharedArrayBuffer(bufferSource)) {
906
+ return copyToArrayBuffer2(bufferSource);
907
+ }
908
+ const { buffer, byteOffset, byteLength } = bufferSource;
909
+ if (buffer instanceof ArrayBuffer && byteOffset === 0 && byteLength === buffer.byteLength) {
910
+ return buffer;
911
+ }
912
+ return copyToArrayBuffer2(buffer, byteOffset, byteLength);
913
+ }
914
+ function copyToArrayBuffer2(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
915
+ const view = new Uint8Array(buffer, byteOffset, byteLength);
916
+ const copy = new Uint8Array(view.length);
917
+ copy.set(view);
918
+ return copy.buffer;
919
+ }
920
+ function toArrayBufferView(data) {
921
+ if (ArrayBuffer.isView(data)) {
922
+ return data;
923
+ }
924
+ return new Uint8Array(data);
925
+ }
782
926
 
783
927
  // dist/lib/node/promisify.js
784
928
  function promisify1(fn) {
@@ -810,7 +954,7 @@ function getCWD() {
810
954
  // dist/lib/path-utils/path.js
811
955
  function filename(url) {
812
956
  const slashIndex = url ? url.lastIndexOf("/") : -1;
813
- return slashIndex >= 0 ? url.substr(slashIndex + 1) : "";
957
+ return slashIndex >= 0 ? url.substr(slashIndex + 1) : url;
814
958
  }
815
959
  function dirname(url) {
816
960
  const slashIndex = url ? url.lastIndexOf("/") : -1;
@@ -1132,273 +1276,6 @@ var NodeFileSystemFacade = class {
1132
1276
  }
1133
1277
  };
1134
1278
 
1135
- // dist/lib/file-provider/file-provider-interface.js
1136
- var isFileProvider = (fileProvider) => {
1137
- return (fileProvider == null ? void 0 : fileProvider.getUint8) && (fileProvider == null ? void 0 : fileProvider.slice) && (fileProvider == null ? void 0 : fileProvider.length);
1138
- };
1139
-
1140
- // dist/lib/file-provider/file-provider.js
1141
- var FileProvider = class {
1142
- /** The File object from which data is provided */
1143
- file;
1144
- size;
1145
- /** Create a new BrowserFile */
1146
- constructor(file, size) {
1147
- this.file = file;
1148
- this.size = BigInt(size);
1149
- }
1150
- static async create(file) {
1151
- var _a;
1152
- let size = 0n;
1153
- if (file.bigsize > 0n) {
1154
- size = file.bigsize;
1155
- } else if (file.size > 0) {
1156
- size = file.size;
1157
- } else {
1158
- const stats = await ((_a = file.stat) == null ? void 0 : _a.call(file));
1159
- size = (stats == null ? void 0 : stats.bigsize) ?? 0n;
1160
- }
1161
- return new FileProvider(file, size);
1162
- }
1163
- /**
1164
- * Truncates the file descriptor.
1165
- * @param length desired file lenght
1166
- */
1167
- async truncate(length) {
1168
- throw new Error("file loaded via range requests cannot be changed");
1169
- }
1170
- /**
1171
- * Append data to a file.
1172
- * @param buffer data to append
1173
- */
1174
- async append(buffer) {
1175
- throw new Error("file loaded via range requests cannot be changed");
1176
- }
1177
- /** Close file */
1178
- async destroy() {
1179
- throw new Error("file loaded via range requests cannot be changed");
1180
- }
1181
- /**
1182
- * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
1183
- * @param offset The offset, in bytes, from the start of the file where to read the data.
1184
- */
1185
- async getUint8(offset) {
1186
- const arrayBuffer = await this.file.read(offset, 1);
1187
- const val = new Uint8Array(arrayBuffer).at(0);
1188
- if (val === void 0) {
1189
- throw new Error("something went wrong");
1190
- }
1191
- return val;
1192
- }
1193
- /**
1194
- * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
1195
- * @param offset The offset, in bytes, from the start of the file where to read the data.
1196
- */
1197
- async getUint16(offset) {
1198
- const arrayBuffer = await this.file.read(offset, 2);
1199
- const val = new Uint16Array(arrayBuffer).at(0);
1200
- if (val === void 0) {
1201
- throw new Error("something went wrong");
1202
- }
1203
- return val;
1204
- }
1205
- /**
1206
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
1207
- * @param offset The offset, in bytes, from the start of the file where to read the data.
1208
- */
1209
- async getUint32(offset) {
1210
- const arrayBuffer = await this.file.read(offset, 4);
1211
- const val = new Uint32Array(arrayBuffer).at(0);
1212
- if (val === void 0) {
1213
- throw new Error("something went wrong");
1214
- }
1215
- return val;
1216
- }
1217
- /**
1218
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
1219
- * @param offset The offset, in bytes, from the start of the file where to read the data.
1220
- */
1221
- async getBigUint64(offset) {
1222
- const arrayBuffer = await this.file.read(offset, 8);
1223
- const val = new BigInt64Array(arrayBuffer).at(0);
1224
- if (val === void 0) {
1225
- throw new Error("something went wrong");
1226
- }
1227
- return val;
1228
- }
1229
- /**
1230
- * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
1231
- * @param startOffset The offset, in byte, from the start of the file where to start reading the data.
1232
- * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
1233
- */
1234
- async slice(startOffset, endOffset) {
1235
- const bigLength = BigInt(endOffset) - BigInt(startOffset);
1236
- if (bigLength > Number.MAX_SAFE_INTEGER) {
1237
- throw new Error("too big slice");
1238
- }
1239
- const length = Number(bigLength);
1240
- return await this.file.read(startOffset, length);
1241
- }
1242
- /**
1243
- * the length (in bytes) of the data.
1244
- */
1245
- get length() {
1246
- return this.size;
1247
- }
1248
- };
1249
-
1250
- // dist/lib/file-provider/file-handle-file.js
1251
- var FileHandleFile = class {
1252
- /** The FileHandle from which data is provided */
1253
- file;
1254
- /** Create a new FileHandleFile */
1255
- constructor(path, append = false) {
1256
- this.file = new NodeFileFacade(path, append ? "a+" : "r");
1257
- }
1258
- /**
1259
- * Truncates the file descriptor.
1260
- * @param length desired file lenght
1261
- */
1262
- async truncate(length) {
1263
- await this.file.truncate(length);
1264
- }
1265
- /**
1266
- * Append data to a file.
1267
- * @param buffer data to append
1268
- */
1269
- async append(buffer) {
1270
- await this.file.append(buffer);
1271
- }
1272
- /** Close file */
1273
- async destroy() {
1274
- await this.file.close();
1275
- }
1276
- /**
1277
- * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
1278
- * @param offset The offset, in bytes, from the start of the file where to read the data.
1279
- */
1280
- async getUint8(offset) {
1281
- const arrayBuffer = await this.file.read(offset, 1);
1282
- const val = new Uint8Array(arrayBuffer).at(0);
1283
- if (val === void 0) {
1284
- throw new Error("something went wrong");
1285
- }
1286
- return val;
1287
- }
1288
- /**
1289
- * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
1290
- * @param offset The offset, in bytes, from the start of the file where to read the data.
1291
- */
1292
- async getUint16(offset) {
1293
- const arrayBuffer = await this.file.read(offset, 2);
1294
- const val = new Uint16Array(arrayBuffer).at(0);
1295
- if (val === void 0) {
1296
- throw new Error("something went wrong");
1297
- }
1298
- return val;
1299
- }
1300
- /**
1301
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
1302
- * @param offset The offset, in bytes, from the start of the file where to read the data.
1303
- */
1304
- async getUint32(offset) {
1305
- const arrayBuffer = await this.file.read(offset, 4);
1306
- const val = new Uint32Array(arrayBuffer).at(0);
1307
- if (val === void 0) {
1308
- throw new Error("something went wrong");
1309
- }
1310
- return val;
1311
- }
1312
- /**
1313
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
1314
- * @param offset The offset, in bytes, from the start of the file where to read the data.
1315
- */
1316
- async getBigUint64(offset) {
1317
- const arrayBuffer = await this.file.read(offset, 8);
1318
- const val = new BigInt64Array(arrayBuffer).at(0);
1319
- if (val === void 0) {
1320
- throw new Error("something went wrong");
1321
- }
1322
- return val;
1323
- }
1324
- /**
1325
- * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
1326
- * @param startOffset The offset, in byte, from the start of the file where to start reading the data.
1327
- * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
1328
- */
1329
- async slice(startOffset, endOffset) {
1330
- const bigLength = endOffset - startOffset;
1331
- if (bigLength > Number.MAX_SAFE_INTEGER) {
1332
- throw new Error("too big slice");
1333
- }
1334
- const length = Number(bigLength);
1335
- return await this.file.read(startOffset, length);
1336
- }
1337
- /**
1338
- * the length (in bytes) of the data.
1339
- */
1340
- get length() {
1341
- return this.file.bigsize;
1342
- }
1343
- };
1344
-
1345
- // dist/lib/file-provider/data-view-file.js
1346
- var toNumber = (bigint) => {
1347
- if (bigint > Number.MAX_SAFE_INTEGER) {
1348
- throw new Error("Offset is out of bounds");
1349
- }
1350
- return Number(bigint);
1351
- };
1352
- var DataViewFile = class {
1353
- /** The DataView from which data is provided */
1354
- file;
1355
- constructor(file) {
1356
- this.file = file;
1357
- }
1358
- async destroy() {
1359
- }
1360
- /**
1361
- * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
1362
- * @param offset The offset, in bytes, from the start of the file where to read the data.
1363
- */
1364
- async getUint8(offset) {
1365
- return this.file.getUint8(toNumber(offset));
1366
- }
1367
- /**
1368
- * Gets an unsigned 16-bit intege at the specified byte offset from the start of the file.
1369
- * @param offset The offset, in bytes, from the start of the file where to read the data.
1370
- */
1371
- async getUint16(offset) {
1372
- return this.file.getUint16(toNumber(offset), true);
1373
- }
1374
- /**
1375
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
1376
- * @param offset The offset, in bytes, from the start of the file where to read the data.
1377
- */
1378
- async getUint32(offset) {
1379
- return this.file.getUint32(toNumber(offset), true);
1380
- }
1381
- /**
1382
- * Gets an unsigned 64-bit integer at the specified byte offset from the start of the file.
1383
- * @param offset The offset, in bytes, from the start of the file where to read the data.
1384
- */
1385
- async getBigUint64(offset) {
1386
- return this.file.getBigUint64(toNumber(offset), true);
1387
- }
1388
- /**
1389
- * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
1390
- * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
1391
- * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
1392
- */
1393
- async slice(startOffset, endOffset) {
1394
- return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));
1395
- }
1396
- /** the length (in bytes) of the data. */
1397
- get length() {
1398
- return BigInt(this.file.byteLength);
1399
- }
1400
- };
1401
-
1402
1279
  // dist/lib/sources/data-source.js
1403
1280
  var _DataSource = class {
1404
1281
  optionsType;
@@ -1452,7 +1329,8 @@ __publicField(DataSource, "defaultOptions", {
1452
1329
  }
1453
1330
  });
1454
1331
  function getFetchFunction(options) {
1455
- const fetchFunction = options == null ? void 0 : options.fetch;
1332
+ var _a;
1333
+ const fetchFunction = (_a = options == null ? void 0 : options.core) == null ? void 0 : _a.fetch;
1456
1334
  if (fetchFunction && typeof fetchFunction === "function") {
1457
1335
  return (url, fetchOptions2) => fetchFunction(url, fetchOptions2);
1458
1336
  }