@loaders.gl/raster 5.0.0-beta.4 → 5.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,15 +15,15 @@
15
15
  __defProp(target, name, { get: all[name], enumerable: true });
16
16
  };
17
17
 
18
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/node/worker_threads-browser.js
18
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js
19
19
  var parentPort;
20
20
  var init_worker_threads_browser = __esm({
21
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/node/worker_threads-browser.js"() {
21
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js"() {
22
22
  parentPort = globalThis.process?.getBuiltinModule?.("node:worker_threads")?.parentPort ?? null;
23
23
  }
24
24
  });
25
25
 
26
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-utils/get-transfer-list.js
26
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js
27
27
  function getTransferList(object, recursive = true, transfers) {
28
28
  const transfersSet = transfers || /* @__PURE__ */ new Set();
29
29
  const seen = /* @__PURE__ */ new Set();
@@ -74,11 +74,11 @@
74
74
  return false;
75
75
  }
76
76
  var init_get_transfer_list = __esm({
77
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-utils/get-transfer-list.js"() {
77
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js"() {
78
78
  }
79
79
  });
80
80
 
81
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-farm/worker-body.js
81
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-body.js
82
82
  async function getParentPort() {
83
83
  return parentPort;
84
84
  }
@@ -91,7 +91,7 @@
91
91
  }
92
92
  var onMessageWrapperMap, WorkerBody;
93
93
  var init_worker_body = __esm({
94
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-farm/worker-body.js"() {
94
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-body.js"() {
95
95
  init_get_transfer_list();
96
96
  init_worker_threads_browser();
97
97
  onMessageWrapperMap = /* @__PURE__ */ new Map();
@@ -172,10 +172,10 @@
172
172
  }
173
173
  });
174
174
 
175
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/async-queue/async-queue.js
175
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js
176
176
  var AsyncQueue;
177
177
  var init_async_queue = __esm({
178
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/async-queue/async-queue.js"() {
178
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js"() {
179
179
  AsyncQueue = class {
180
180
  constructor() {
181
181
  this._values = [];
@@ -244,10 +244,10 @@
244
244
  }
245
245
  });
246
246
 
247
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/shared-state.js
247
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js
248
248
  var SharedWorkerState;
249
249
  var init_shared_state = __esm({
250
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/shared-state.js"() {
250
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js"() {
251
251
  SharedWorkerState = class {
252
252
  constructor(buffer) {
253
253
  if (typeof SharedArrayBuffer === "undefined" || !(buffer instanceof SharedArrayBuffer) || buffer.byteLength !== 16)
@@ -288,18 +288,18 @@
288
288
  }
289
289
  });
290
290
 
291
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/validate-output-ownership.js
291
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js
292
292
  function validateOutputOwnership(ownership) {
293
293
  if (ownership !== void 0 && ownership !== "copy" && ownership !== "transfer") {
294
294
  throw new Error("Invalid worker output ownership");
295
295
  }
296
296
  }
297
297
  var init_validate_output_ownership = __esm({
298
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/validate-output-ownership.js"() {
298
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js"() {
299
299
  }
300
300
  });
301
301
 
302
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/create-worker.js
302
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/create-worker.js
303
303
  async function createWorker(process2, processInBatches, preload) {
304
304
  if (!await WorkerBody.inWorkerThread()) {
305
305
  return;
@@ -504,7 +504,7 @@
504
504
  }
505
505
  var requestId, activeController, activeInputBatches, activeOutputAcknowledgements;
506
506
  var init_create_worker = __esm({
507
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/create-worker.js"() {
507
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/create-worker.js"() {
508
508
  init_shared_state();
509
509
  init_async_queue();
510
510
  init_worker_body();
@@ -516,19 +516,20 @@
516
516
  }
517
517
  });
518
518
 
519
- // ../../node_modules/@math.gl/core/dist/worker-utils/index.js
519
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/index.js
520
520
  var import_meta, path, moduleUrl;
521
521
  var init_worker_utils = __esm({
522
- "../../node_modules/@math.gl/core/dist/worker-utils/index.js"() {
522
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/index.js"() {
523
523
  init_worker_body();
524
524
  init_create_worker();
525
+ init_get_transfer_list();
525
526
  import_meta = {};
526
527
  path = typeof __filename === "string" ? __filename.replace(/\\/g, "/") : "";
527
528
  moduleUrl = path ? `file://${path.startsWith("/") ? "" : "/"}${encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F")}` : import_meta.url;
528
529
  }
529
530
  });
530
531
 
531
- // ../../node_modules/@math.gl/core/dist/tasks/task-preload.js
532
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js
532
533
  function preloadTaskCode(task, signal) {
533
534
  if (!task.preload)
534
535
  return Promise.resolve();
@@ -564,23 +565,193 @@
564
565
  }
565
566
  var pending, loaded;
566
567
  var init_task_preload = __esm({
567
- "../../node_modules/@math.gl/core/dist/tasks/task-preload.js"() {
568
+ "../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js"() {
568
569
  pending = /* @__PURE__ */ new WeakMap();
569
570
  loaded = /* @__PURE__ */ new WeakSet();
570
571
  }
571
572
  });
572
573
 
573
- // ../../node_modules/@math.gl/core/dist/tasks/task-runtime.js
574
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js
575
+ var TaskRequestError, TaskChannel;
576
+ var init_task_channel = __esm({
577
+ "../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js"() {
578
+ TaskRequestError = class extends Error {
579
+ };
580
+ TaskChannel = class {
581
+ constructor(options) {
582
+ this.options = options;
583
+ this.nextId = 1;
584
+ this.pending = /* @__PURE__ */ new Map();
585
+ this.incoming = /* @__PURE__ */ new Map();
586
+ }
587
+ /** Send a request without serializing other in-flight requests. */
588
+ request(operation, value, signal, transfer = []) {
589
+ if (this.failure)
590
+ return Promise.reject(this.failure.reason);
591
+ if (signal?.aborted)
592
+ return Promise.reject(signal.reason);
593
+ const id = this.nextId++;
594
+ return new Promise((resolve, reject) => {
595
+ const abort = () => {
596
+ const pending2 = this.pending.get(id);
597
+ if (!pending2)
598
+ return;
599
+ this.pending.delete(id);
600
+ pending2.cleanup();
601
+ reject(signal?.reason);
602
+ this.send({ source: "math.gl/tasks", kind: "cancel", id });
603
+ };
604
+ this.pending.set(id, {
605
+ resolve,
606
+ reject,
607
+ cleanup: () => signal?.removeEventListener("abort", abort)
608
+ });
609
+ signal?.addEventListener("abort", abort, { once: true });
610
+ this.send({ source: "math.gl/tasks", kind: "request", id, operation, value }, transfer);
611
+ });
612
+ }
613
+ /** Send a one-way notification. */
614
+ emit(operation, value, transfer = []) {
615
+ if (this.failure)
616
+ throw this.failure.reason;
617
+ this.send({ source: "math.gl/tasks", kind: "event", id: 0, operation, value }, transfer);
618
+ }
619
+ /** Dispatch a transport message; unrelated protocols are ignored. */
620
+ receive(message) {
621
+ if (this.failure || message?.source !== "math.gl/tasks")
622
+ return;
623
+ if (message.kind === "failure") {
624
+ const reason = new Error(message.error?.message ?? "Task channel failed");
625
+ this.close(reason);
626
+ this.options.onFailure?.(reason);
627
+ } else if (message.kind === "result" || message.kind === "error") {
628
+ const pending2 = this.pending.get(message.id);
629
+ if (!pending2)
630
+ return;
631
+ this.pending.delete(message.id);
632
+ pending2.cleanup();
633
+ if (message.kind === "result")
634
+ pending2.resolve(message.value);
635
+ else {
636
+ const error = new TaskRequestError(message.error?.message ?? "Task request failed");
637
+ error.name = message.error?.name ?? "Error";
638
+ pending2.reject(error);
639
+ }
640
+ } else if (message.kind === "cancel") {
641
+ this.incoming.get(message.id)?.abort(new DOMException("Task request cancelled", "AbortError"));
642
+ } else if (message.kind === "event") {
643
+ try {
644
+ this.options.handleEvent?.(message.operation, message.value);
645
+ } catch (error) {
646
+ this.fail(error);
647
+ }
648
+ } else if (message.kind === "request") {
649
+ if (this.incoming.has(message.id)) {
650
+ this.fail(new Error("Duplicate task request identifier"));
651
+ return;
652
+ }
653
+ const controller = new AbortController();
654
+ this.incoming.set(message.id, controller);
655
+ void Promise.resolve().then(() => {
656
+ controller.signal.throwIfAborted();
657
+ return this.options.handleRequest(message.operation, message.value, controller.signal);
658
+ }).then((value) => {
659
+ if (!controller.signal.aborted && !this.failure) {
660
+ this.send({ source: "math.gl/tasks", kind: "result", id: message.id, value }, this.options.getResultTransferList?.(value, message.value));
661
+ }
662
+ }).catch((reason) => {
663
+ if (!controller.signal.aborted && !this.failure) {
664
+ this.send({
665
+ source: "math.gl/tasks",
666
+ kind: "error",
667
+ id: message.id,
668
+ error: {
669
+ name: reason instanceof Error ? reason.name : "Error",
670
+ message: reason instanceof Error ? reason.message : String(reason)
671
+ }
672
+ });
673
+ }
674
+ }).finally(() => this.incoming.delete(message.id));
675
+ }
676
+ }
677
+ /** Reject all outstanding calls with a common cause and abort incoming callbacks. */
678
+ close(reason = new Error("Task channel closed")) {
679
+ if (this.failure)
680
+ return;
681
+ this.failure = { reason };
682
+ for (const pending2 of this.pending.values()) {
683
+ pending2.cleanup();
684
+ pending2.reject(reason);
685
+ }
686
+ this.pending.clear();
687
+ for (const controller of this.incoming.values())
688
+ controller.abort(reason);
689
+ this.incoming.clear();
690
+ }
691
+ send(message, transfer = []) {
692
+ if (this.failure)
693
+ return;
694
+ try {
695
+ this.options.send(message, transfer);
696
+ } catch (error) {
697
+ this.fail(error);
698
+ }
699
+ }
700
+ /** Invalidate the channel and notify the peer when the transport still works. */
701
+ fail(reason) {
702
+ if (this.failure)
703
+ return;
704
+ this.close(reason);
705
+ try {
706
+ this.options.send({
707
+ source: "math.gl/tasks",
708
+ kind: "failure",
709
+ id: 0,
710
+ error: {
711
+ name: reason instanceof Error ? reason.name : "Error",
712
+ message: reason instanceof Error ? reason.message : String(reason)
713
+ }
714
+ }, []);
715
+ } catch {
716
+ }
717
+ this.options.onFailure?.(reason);
718
+ }
719
+ };
720
+ }
721
+ });
722
+
723
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js
574
724
  function assertPayload(value) {
575
725
  if (!value || typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype) {
576
726
  throw new TypeError("Task payloads must be plain objects with named fields");
577
727
  }
578
728
  }
729
+ function clonePayload(value, ownership = "copy") {
730
+ assertPayload(value);
731
+ if (!["copy", "transfer", "share"].includes(ownership))
732
+ throw new TypeError("Invalid input ownership");
733
+ const transfer = getTransferList(value);
734
+ if (ownership === "share" && transfer.length)
735
+ throw new TypeError("Share requires shared storage");
736
+ return structuredClone(value, {
737
+ transfer: ownership === "transfer" ? transfer : []
738
+ });
739
+ }
579
740
  function taskContext(state, context = {}) {
580
741
  const signal = context.signal ?? new AbortController().signal;
581
742
  return {
582
743
  state,
583
744
  signal,
745
+ requestHost: async (operation, payload, controls) => {
746
+ signal.throwIfAborted();
747
+ if (!context.requestHost)
748
+ throw new Error("No host request handler configured");
749
+ return context.requestHost(operation, payload, controls);
750
+ },
751
+ emitHost: (operation, payload) => {
752
+ signal.throwIfAborted();
753
+ context.emitHost?.(operation, payload);
754
+ },
584
755
  throwIfAborted: () => {
585
756
  signal.throwIfAborted();
586
757
  context.throwIfAborted?.();
@@ -599,6 +770,69 @@
599
770
  throw new Error("A task is already installed in this worker");
600
771
  installed = true;
601
772
  const runtime = new TaskRuntime(task);
773
+ let channelStream;
774
+ const channel = new TaskChannel({
775
+ getResultTransferList: (value, request) => request.outputOwnership === "transfer" ? getTransferList(value) : [],
776
+ send: (message, transfer) => {
777
+ const snapshot = structuredClone(message, { transfer });
778
+ void WorkerBody.postMessage("task-channel", snapshot).catch((reason) => channel.fail(reason));
779
+ },
780
+ handleRequest: async (operation, value, signal) => {
781
+ const request = value;
782
+ const context = {
783
+ signal,
784
+ reportProgress: (progress) => channel.emit("task:progress", { id: request.progressId, progress }),
785
+ requestHost: (operation2, payload, controls = {}) => {
786
+ const request2 = {
787
+ operation: operation2,
788
+ payload: clonePayload(payload, controls.inputOwnership),
789
+ outputOwnership: controls.outputOwnership ?? "copy"
790
+ };
791
+ return channel.request("task:host-request", request2, signal, getTransferList(request2));
792
+ },
793
+ emitHost: (operation2, payload) => channel.emit("task:host-event", { operation: operation2, payload, id: request.progressId })
794
+ };
795
+ switch (operation) {
796
+ case "initialize":
797
+ return runtime.initialize(request.input, context);
798
+ case "process":
799
+ return runtime.process(request.input, request.options, context);
800
+ case "stream-open": {
801
+ if (channelStream)
802
+ throw new Error("A task stream is already open");
803
+ async function* inputs() {
804
+ while (true) {
805
+ const result = await channel.request("task:next-input", { outputOwnership: "transfer" }, signal);
806
+ if (result.done)
807
+ return;
808
+ yield result.value;
809
+ }
810
+ }
811
+ channelStream = runtime.stream(inputs(), request.options, context)[Symbol.asyncIterator]();
812
+ return {};
813
+ }
814
+ case "stream-next":
815
+ if (!channelStream)
816
+ throw new Error("No active task stream");
817
+ return channelStream.next();
818
+ case "stream-close":
819
+ try {
820
+ await channelStream?.return?.();
821
+ } finally {
822
+ channelStream = void 0;
823
+ }
824
+ return {};
825
+ case "destroy":
826
+ return runtime.destroy();
827
+ default:
828
+ throw new Error("Unknown task channel operation");
829
+ }
830
+ }
831
+ });
832
+ await WorkerBody.addEventListener((type, payload) => {
833
+ if (type === "task-channel")
834
+ channel.receive(payload);
835
+ });
602
836
  let streamOptions = {};
603
837
  return createWorker(async (request, _options, context) => {
604
838
  switch (request.operation) {
@@ -630,9 +864,10 @@
630
864
  }
631
865
  var TaskRuntime, installed;
632
866
  var init_task_runtime = __esm({
633
- "../../node_modules/@math.gl/core/dist/tasks/task-runtime.js"() {
867
+ "../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js"() {
634
868
  init_worker_utils();
635
869
  init_task_preload();
870
+ init_task_channel();
636
871
  TaskRuntime = class {
637
872
  constructor(task) {
638
873
  this.task = task;
@@ -683,13 +918,20 @@
683
918
  }
684
919
  });
685
920
 
686
- // ../../node_modules/@math.gl/core/dist/tasks/index.js
921
+ // ../../node_modules/@math.gl/tasks/dist/tasks/index.js
687
922
  var init_tasks = __esm({
688
- "../../node_modules/@math.gl/core/dist/tasks/index.js"() {
923
+ "../../node_modules/@math.gl/tasks/dist/tasks/index.js"() {
689
924
  init_task_runtime();
690
925
  }
691
926
  });
692
927
 
928
+ // ../../node_modules/@math.gl/tasks/dist/index.js
929
+ var init_dist = __esm({
930
+ "../../node_modules/@math.gl/tasks/dist/index.js"() {
931
+ init_tasks();
932
+ }
933
+ });
934
+
693
935
  // ../core/src/worker-utils/lib/node/worker_threads-browser.ts
694
936
  var worker_threads_browser_exports = {};
695
937
  __export(worker_threads_browser_exports, {
@@ -734,7 +976,7 @@
734
976
  var init_task_runtime2 = __esm({
735
977
  "../core/src/worker-utils/lib/worker-api/task-runtime.ts"() {
736
978
  "use strict";
737
- init_tasks();
979
+ init_dist();
738
980
  initializeTaskWorker2 = initializeTaskWorker;
739
981
  }
740
982
  });
@@ -1151,7 +1393,7 @@
1151
1393
  });
1152
1394
 
1153
1395
  // ../../node_modules/@math.gl/core/dist/index.js
1154
- var init_dist = __esm({
1396
+ var init_dist2 = __esm({
1155
1397
  "../../node_modules/@math.gl/core/dist/index.js"() {
1156
1398
  init_math_utils();
1157
1399
  init_types2();
@@ -16073,6 +16315,305 @@ return true;`);
16073
16315
  }
16074
16316
  });
16075
16317
 
16318
+ // ../../node_modules/@math.gl/arrow/dist/arrow/arrow-data.js
16319
+ function getArrowVariadicBuffers(data) {
16320
+ return data.variadicBuffers ?? [];
16321
+ }
16322
+ function createArrowData(type, offset, length, nullCount, buffers, children, dictionary, variadicBuffers) {
16323
+ return Reflect.construct(Data, [
16324
+ type,
16325
+ offset,
16326
+ length,
16327
+ nullCount,
16328
+ buffers,
16329
+ children,
16330
+ dictionary,
16331
+ variadicBuffers
16332
+ ]);
16333
+ }
16334
+ var init_arrow_data = __esm({
16335
+ "../../node_modules/@math.gl/arrow/dist/arrow/arrow-data.js"() {
16336
+ init_Arrow_dom();
16337
+ }
16338
+ });
16339
+
16340
+ // ../../node_modules/@math.gl/arrow/dist/arrow/split-arrow-buffers.js
16341
+ function splitArrowBuffers(input, options = {}) {
16342
+ const context = { ...options, copies: /* @__PURE__ */ new WeakMap() };
16343
+ if (isArrowTable2(input)) {
16344
+ return splitArrowTableBuffersInternal(input, context);
16345
+ }
16346
+ if (isArrowRecordBatch2(input)) {
16347
+ return splitArrowRecordBatchBuffers(input, context);
16348
+ }
16349
+ if (isArrowVector2(input)) {
16350
+ return splitArrowVectorBuffers(input, context);
16351
+ }
16352
+ return splitArrowDataBuffers(input, context);
16353
+ }
16354
+ function isArrowTable2(input) {
16355
+ return "batches" in input;
16356
+ }
16357
+ function isArrowRecordBatch2(input) {
16358
+ return "schema" in input && "data" in input && !Array.isArray(input.data);
16359
+ }
16360
+ function isArrowVector2(input) {
16361
+ return "data" in input && Array.isArray(input.data);
16362
+ }
16363
+ function splitArrowTableBuffersInternal(arrowTable, options) {
16364
+ const recordBatches = arrowTable.batches.map((recordBatch) => splitArrowRecordBatchBuffers(recordBatch, options));
16365
+ return new Table(arrowTable.schema, recordBatches);
16366
+ }
16367
+ function splitArrowRecordBatchBuffers(recordBatch, options) {
16368
+ return new RecordBatch3(recordBatch.schema, splitArrowDataBuffers(recordBatch.data, options));
16369
+ }
16370
+ function splitArrowDataBuffers(data, options) {
16371
+ const children = data.children.map((childData) => splitArrowDataBuffers(childData, options));
16372
+ const dictionary = data.dictionary ? splitArrowVectorBuffers(data.dictionary, options) : void 0;
16373
+ const buffers = {
16374
+ [BufferType.OFFSET]: splitArrowBuffer(data.buffers[BufferType.OFFSET], options),
16375
+ [BufferType.DATA]: splitArrowBuffer(data.buffers[BufferType.DATA], options),
16376
+ [BufferType.VALIDITY]: splitArrowBuffer(data.buffers[BufferType.VALIDITY], options),
16377
+ [BufferType.TYPE]: splitArrowBuffer(data.buffers[BufferType.TYPE], options)
16378
+ };
16379
+ return createArrowData(
16380
+ data.type,
16381
+ data.offset,
16382
+ data.length,
16383
+ // @ts-expect-error _nullCount is protected. Reuse it to preserve lazy null-count state.
16384
+ data._nullCount,
16385
+ buffers,
16386
+ children,
16387
+ dictionary,
16388
+ getArrowVariadicBuffers(data).map((buffer) => splitArrowBuffer(buffer, options))
16389
+ );
16390
+ }
16391
+ function splitArrowVectorBuffers(vector, options) {
16392
+ return new Vector(vector.data.map((data) => splitArrowDataBuffers(data, options)));
16393
+ }
16394
+ function splitArrowBuffer(array, options) {
16395
+ if (!isArrowTypedArray(array)) {
16396
+ return array;
16397
+ }
16398
+ if (options.copy === "none") {
16399
+ return array;
16400
+ }
16401
+ if (options.copy !== "all" && array.byteOffset === 0 && array.byteLength === array.buffer.byteLength) {
16402
+ return array;
16403
+ }
16404
+ let copy = options.copies.get(array);
16405
+ if (!copy) {
16406
+ copy = array instanceof Uint8Array ? new Uint8Array(array) : array.slice();
16407
+ options.copies.set(array, copy);
16408
+ }
16409
+ return copy;
16410
+ }
16411
+ function isArrowTypedArray(value) {
16412
+ return ArrayBuffer.isView(value) && !(value instanceof DataView);
16413
+ }
16414
+ var init_split_arrow_buffers = __esm({
16415
+ "../../node_modules/@math.gl/arrow/dist/arrow/split-arrow-buffers.js"() {
16416
+ init_Arrow_dom();
16417
+ init_arrow_data();
16418
+ }
16419
+ });
16420
+
16421
+ // ../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-vector.js
16422
+ var init_indexed_arrow_vector = __esm({
16423
+ "../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-vector.js"() {
16424
+ }
16425
+ });
16426
+
16427
+ // ../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-table.js
16428
+ var init_indexed_arrow_table = __esm({
16429
+ "../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-table.js"() {
16430
+ }
16431
+ });
16432
+
16433
+ // ../../node_modules/@math.gl/arrow/dist/arrow/mapped-arrow-table.js
16434
+ var init_mapped_arrow_table = __esm({
16435
+ "../../node_modules/@math.gl/arrow/dist/arrow/mapped-arrow-table.js"() {
16436
+ }
16437
+ });
16438
+
16439
+ // ../../node_modules/@math.gl/arrow/dist/arrow/rename-arrow-columns.js
16440
+ var init_rename_arrow_columns = __esm({
16441
+ "../../node_modules/@math.gl/arrow/dist/arrow/rename-arrow-columns.js"() {
16442
+ }
16443
+ });
16444
+
16445
+ // ../../node_modules/@math.gl/arrow/dist/arrow/arrow-table-transport.js
16446
+ function dehydrateArrowTable(arrowTable, options) {
16447
+ const splitTable = splitArrowBuffers(arrowTable, options);
16448
+ return {
16449
+ transport: "arrow-js",
16450
+ version: 1,
16451
+ schema: tableToIPC(new Table(splitTable.schema, [])),
16452
+ metadataVersion: splitTable.schema.metadataVersion,
16453
+ batches: splitTable.batches.map((batch) => dehydrateArrowData(batch.data))
16454
+ };
16455
+ }
16456
+ function hydrateArrowTable(table) {
16457
+ if (table.transport !== "arrow-js" || table.version !== 1) {
16458
+ throw new Error("Unsupported Arrow column-buffer transport protocol.");
16459
+ }
16460
+ const decodedSchema = tableFromIPC(table.schema).schema;
16461
+ const schema = new Schema2(decodedSchema.fields, decodedSchema.metadata, decodedSchema.dictionaries, table.metadataVersion);
16462
+ const type = new Struct(schema.fields);
16463
+ const batches = table.batches.map((data) => new RecordBatch3(schema, hydrateArrowData(data, type)));
16464
+ return new Table(schema, batches);
16465
+ }
16466
+ function dehydrateArrowData(data) {
16467
+ return {
16468
+ offset: data.offset,
16469
+ length: data.length,
16470
+ nullCount: data.nullCount,
16471
+ buffers: {
16472
+ [BufferType.OFFSET]: data.buffers[BufferType.OFFSET],
16473
+ [BufferType.DATA]: data.buffers[BufferType.DATA],
16474
+ [BufferType.VALIDITY]: data.buffers[BufferType.VALIDITY],
16475
+ [BufferType.TYPE]: data.buffers[BufferType.TYPE]
16476
+ },
16477
+ children: data.children.map((child) => dehydrateArrowData(child)),
16478
+ variadicBuffers: getArrowVariadicBuffers(data),
16479
+ dictionary: data.dictionary?.data.map((chunk) => dehydrateArrowData(chunk))
16480
+ };
16481
+ }
16482
+ function hydrateArrowData(data, type) {
16483
+ const children = data.children.map((child, index) => hydrateArrowData(child, type.children[index].type));
16484
+ const dictionary = data.dictionary && DataType.isDictionary(type) ? new Vector(data.dictionary.map((chunk) => hydrateArrowData(chunk, type.dictionary))) : void 0;
16485
+ return createArrowData(type, data.offset, data.length, data.nullCount, data.buffers, children, dictionary, data.variadicBuffers);
16486
+ }
16487
+ var init_arrow_table_transport = __esm({
16488
+ "../../node_modules/@math.gl/arrow/dist/arrow/arrow-table-transport.js"() {
16489
+ init_Arrow_dom();
16490
+ init_arrow_data();
16491
+ init_split_arrow_buffers();
16492
+ }
16493
+ });
16494
+
16495
+ // ../../node_modules/@math.gl/arrow/dist/arrow/index.js
16496
+ var init_arrow = __esm({
16497
+ "../../node_modules/@math.gl/arrow/dist/arrow/index.js"() {
16498
+ init_indexed_arrow_table();
16499
+ init_indexed_arrow_vector();
16500
+ init_mapped_arrow_table();
16501
+ init_rename_arrow_columns();
16502
+ init_split_arrow_buffers();
16503
+ init_arrow_table_transport();
16504
+ }
16505
+ });
16506
+
16507
+ // ../../node_modules/@math.gl/arrow/dist/index.js
16508
+ var init_dist3 = __esm({
16509
+ "../../node_modules/@math.gl/arrow/dist/index.js"() {
16510
+ init_arrow();
16511
+ }
16512
+ });
16513
+
16514
+ // ../core/src/arrow-worker-transport.ts
16515
+ function serializeArrowWorkerResult(result, options) {
16516
+ if (!isArrowTableWrapper(result)) {
16517
+ return result;
16518
+ }
16519
+ const workerOptions = options;
16520
+ const bufferCopyMode = workerOptions?.core?.workerTransferBufferCopy ?? workerOptions?.workerTransferBufferCopy;
16521
+ return {
16522
+ ...result,
16523
+ data: dehydrateArrowTable(result.data, bufferCopyMode ? { copy: bufferCopyMode } : void 0)
16524
+ };
16525
+ }
16526
+ function deserializeArrowWorkerResult(result) {
16527
+ if (!isDehydratedArrowTableWrapper(result)) {
16528
+ return result;
16529
+ }
16530
+ return { ...result, data: hydrateArrowTable(result.data) };
16531
+ }
16532
+ function isArrowTableWrapper(value) {
16533
+ const table = value;
16534
+ return Boolean(
16535
+ table && table.shape === "arrow-table" && table.data && typeof table.data === "object" && "batches" in table.data
16536
+ );
16537
+ }
16538
+ function isDehydratedArrowTableWrapper(value) {
16539
+ const table = value;
16540
+ return Boolean(
16541
+ table && table.shape === "arrow-table" && table.data && table.data.transport === "arrow-js" && Array.isArray(table.data.batches)
16542
+ );
16543
+ }
16544
+ var init_arrow_worker_transport = __esm({
16545
+ "../core/src/arrow-worker-transport.ts"() {
16546
+ "use strict";
16547
+ init_dist3();
16548
+ }
16549
+ });
16550
+
16551
+ // ../core/src/schema-utils/lib/schema/data-type.ts
16552
+ function getDataTypeFromValue(value, defaultNumberType = "float32") {
16553
+ if (value instanceof Date) {
16554
+ return "date-millisecond";
16555
+ }
16556
+ if (typeof value === "number") {
16557
+ return defaultNumberType;
16558
+ }
16559
+ if (typeof value === "boolean") {
16560
+ return "bool";
16561
+ }
16562
+ if (typeof value === "string") {
16563
+ return "utf8";
16564
+ }
16565
+ if (value === null || value === "undefined") {
16566
+ return "null";
16567
+ }
16568
+ return "null";
16569
+ }
16570
+ function getDataTypeFromArray(array) {
16571
+ let type = getDataTypeFromTypedArray(array);
16572
+ if (type !== "null") {
16573
+ return { type, nullable: false };
16574
+ }
16575
+ if (array.length > 0) {
16576
+ type = getDataTypeFromValue(array[0]);
16577
+ return { type, nullable: true };
16578
+ }
16579
+ return { type: "null", nullable: true };
16580
+ }
16581
+ function getDataTypeFromTypedArray(array) {
16582
+ if (typeof Float16Array !== "undefined" && array instanceof Float16Array) {
16583
+ return "float16";
16584
+ }
16585
+ switch (array.constructor) {
16586
+ case Int8Array:
16587
+ return "int8";
16588
+ case Uint8Array:
16589
+ case Uint8ClampedArray:
16590
+ return "uint8";
16591
+ case Int16Array:
16592
+ return "int16";
16593
+ case Uint16Array:
16594
+ return "uint16";
16595
+ case Int32Array:
16596
+ return "int32";
16597
+ case Uint32Array:
16598
+ return "uint32";
16599
+ case BigInt64Array:
16600
+ return "int64";
16601
+ case BigUint64Array:
16602
+ return "uint64";
16603
+ case Float32Array:
16604
+ return "float32";
16605
+ case Float64Array:
16606
+ return "float64";
16607
+ default:
16608
+ return "null";
16609
+ }
16610
+ }
16611
+ var init_data_type = __esm({
16612
+ "../core/src/schema-utils/lib/schema/data-type.ts"() {
16613
+ "use strict";
16614
+ }
16615
+ });
16616
+
16076
16617
  // ../core/src/schema-utils/lib/schema/convert-arrow-schema.ts
16077
16618
  function serializeArrowSchema(arrowSchema) {
16078
16619
  return {
@@ -16080,12 +16621,6 @@ return true;`);
16080
16621
  metadata: serializeArrowMetadata(arrowSchema.metadata)
16081
16622
  };
16082
16623
  }
16083
- function deserializeArrowSchema(schema, options) {
16084
- return new Schema2(
16085
- schema.fields.map((field) => deserializeArrowField(field, options)),
16086
- deserializeArrowMetadata(schema.metadata)
16087
- );
16088
- }
16089
16624
  function serializeArrowMetadata(arrowMetadata) {
16090
16625
  return Object.fromEntries(arrowMetadata);
16091
16626
  }
@@ -16508,260 +17043,6 @@ return true;`);
16508
17043
  }
16509
17044
  });
16510
17045
 
16511
- // ../core/src/schema-utils/lib/arrow/split-arrow-buffers.ts
16512
- function splitArrowBuffers(input, options = {}) {
16513
- const context = { ...options, copies: /* @__PURE__ */ new WeakMap() };
16514
- if (isArrowTable2(input)) {
16515
- return splitArrowTableBuffersInternal(input, context);
16516
- }
16517
- if (isArrowRecordBatch2(input)) {
16518
- return splitArrowRecordBatchBuffers(input, context);
16519
- }
16520
- if (isArrowVector2(input)) {
16521
- return splitArrowVectorBuffers(input, context);
16522
- }
16523
- return splitArrowDataBuffers(input, context);
16524
- }
16525
- function isArrowTable2(input) {
16526
- return "batches" in input;
16527
- }
16528
- function isArrowRecordBatch2(input) {
16529
- return "schema" in input && "data" in input && !Array.isArray(input.data);
16530
- }
16531
- function isArrowVector2(input) {
16532
- return "data" in input && Array.isArray(input.data);
16533
- }
16534
- function splitArrowTableBuffersInternal(table, options) {
16535
- const recordBatches = table.batches.map(
16536
- (recordBatch) => splitArrowRecordBatchBuffers(recordBatch, options)
16537
- );
16538
- return new Table(table.schema, recordBatches);
16539
- }
16540
- function splitArrowRecordBatchBuffers(recordBatch, options) {
16541
- return new RecordBatch3(
16542
- recordBatch.schema,
16543
- splitArrowDataBuffers(recordBatch.data, options)
16544
- );
16545
- }
16546
- function splitArrowDataBuffers(data, options) {
16547
- const children = data.children.map((childData) => splitArrowDataBuffers(childData, options));
16548
- const dictionary = data.dictionary ? splitArrowVectorBuffers(data.dictionary, options) : void 0;
16549
- const buffers = {
16550
- [BufferType.OFFSET]: splitArrowBuffer(data.buffers[BufferType.OFFSET], options),
16551
- [BufferType.DATA]: splitArrowBuffer(data.buffers[BufferType.DATA], options),
16552
- [BufferType.VALIDITY]: splitArrowBuffer(data.buffers[BufferType.VALIDITY], options),
16553
- [BufferType.TYPE]: splitArrowBuffer(data.buffers[BufferType.TYPE], options)
16554
- };
16555
- return new Data(
16556
- data.type,
16557
- data.offset,
16558
- data.length,
16559
- // @ts-expect-error _nullCount is protected. Reuse it to preserve lazy null-count state.
16560
- data._nullCount,
16561
- buffers,
16562
- children,
16563
- dictionary
16564
- );
16565
- }
16566
- function splitArrowVectorBuffers(vector, options) {
16567
- return new Vector(vector.data.map((data) => splitArrowDataBuffers(data, options)));
16568
- }
16569
- function splitArrowBuffer(array, options) {
16570
- if (!isArrowTypedArray(array)) {
16571
- return array;
16572
- }
16573
- if (options.copy === "none") {
16574
- return array;
16575
- }
16576
- if (options.copy !== "all" && array.byteOffset === 0 && array.byteLength === array.buffer.byteLength) {
16577
- return array;
16578
- }
16579
- let copy = options.copies.get(array);
16580
- if (!copy) {
16581
- copy = array.slice();
16582
- options.copies.set(array, copy);
16583
- }
16584
- return copy;
16585
- }
16586
- function isArrowTypedArray(value) {
16587
- return ArrayBuffer.isView(value) && !(value instanceof DataView);
16588
- }
16589
- var init_split_arrow_buffers = __esm({
16590
- "../core/src/schema-utils/lib/arrow/split-arrow-buffers.ts"() {
16591
- "use strict";
16592
- init_Arrow_dom();
16593
- }
16594
- });
16595
-
16596
- // ../core/src/schema-utils/lib/arrow/arrow-table-transport.ts
16597
- function dehydrateArrowTable(table, options) {
16598
- const splitTable = splitArrowBuffers(table, options);
16599
- return {
16600
- shape: "arrow-table",
16601
- transport: "arrow-js",
16602
- schema: serializeArrowSchema(splitTable.schema),
16603
- batches: splitTable.batches.map((recordBatch) => dehydrateArrowRecordBatch(recordBatch))
16604
- };
16605
- }
16606
- function hydrateArrowTable(table) {
16607
- const schema = deserializeArrowSchema(table.schema);
16608
- const recordBatches = table.batches.map(
16609
- (recordBatch) => new RecordBatch3(schema, hydrateArrowData(recordBatch.data))
16610
- );
16611
- return new Table(schema, recordBatches);
16612
- }
16613
- function serializeArrowWorkerResult(result, options) {
16614
- if (!isArrowTableWrapper(result)) {
16615
- return result;
16616
- }
16617
- const workerOptions = options;
16618
- const bufferCopyMode = workerOptions?.core?.workerTransferBufferCopy ?? workerOptions?.workerTransferBufferCopy;
16619
- return {
16620
- ...result,
16621
- data: dehydrateArrowTable(result.data, bufferCopyMode ? { copy: bufferCopyMode } : void 0)
16622
- };
16623
- }
16624
- function deserializeArrowWorkerResult(result) {
16625
- if (!isDehydratedArrowTableWrapper(result)) {
16626
- return result;
16627
- }
16628
- return { ...result, data: hydrateArrowTable(result.data) };
16629
- }
16630
- function isArrowTableWrapper(value) {
16631
- const table = value;
16632
- return Boolean(
16633
- table && table.shape === "arrow-table" && table.data && typeof table.data === "object" && "batches" in table.data
16634
- );
16635
- }
16636
- function isDehydratedArrowTableWrapper(value) {
16637
- const table = value;
16638
- return Boolean(
16639
- table && table.shape === "arrow-table" && table.data && table.data.transport === "arrow-js" && Array.isArray(table.data.batches)
16640
- );
16641
- }
16642
- function dehydrateArrowRecordBatch(recordBatch) {
16643
- return { data: dehydrateArrowData(recordBatch.data) };
16644
- }
16645
- function dehydrateArrowData(data) {
16646
- return {
16647
- type: serializeArrowType(data.type),
16648
- offset: data.offset,
16649
- length: data.length,
16650
- // @ts-expect-error _nullCount is protected. Preserve the Arrow lazy null-count state.
16651
- nullCount: data._nullCount,
16652
- buffers: {
16653
- [BufferType.OFFSET]: data.buffers[BufferType.OFFSET],
16654
- [BufferType.DATA]: data.buffers[BufferType.DATA],
16655
- [BufferType.VALIDITY]: data.buffers[BufferType.VALIDITY],
16656
- [BufferType.TYPE]: data.buffers[BufferType.TYPE]
16657
- },
16658
- children: data.children.map((childData) => dehydrateArrowData(childData)),
16659
- dictionary: data.dictionary ? dehydrateArrowVector(data.dictionary) : void 0
16660
- };
16661
- }
16662
- function dehydrateArrowVector(vector) {
16663
- return { data: vector.data.map((data) => dehydrateArrowData(data)) };
16664
- }
16665
- function hydrateArrowData(data) {
16666
- const children = data.children.map((childData) => hydrateArrowData(childData));
16667
- const dictionary = data.dictionary ? hydrateArrowVector(data.dictionary) : void 0;
16668
- return new Data(
16669
- deserializeArrowType(data.type),
16670
- data.offset,
16671
- data.length,
16672
- data.nullCount,
16673
- data.buffers,
16674
- children,
16675
- dictionary
16676
- );
16677
- }
16678
- function hydrateArrowVector(vector) {
16679
- return new Vector(vector.data.map((data) => hydrateArrowData(data)));
16680
- }
16681
- var init_arrow_table_transport = __esm({
16682
- "../core/src/schema-utils/lib/arrow/arrow-table-transport.ts"() {
16683
- "use strict";
16684
- init_Arrow_dom();
16685
- init_convert_arrow_schema();
16686
- init_split_arrow_buffers();
16687
- }
16688
- });
16689
-
16690
- // ../core/src/schema-utils/arrow-transport.ts
16691
- var init_arrow_transport = __esm({
16692
- "../core/src/schema-utils/arrow-transport.ts"() {
16693
- "use strict";
16694
- init_arrow_table_transport();
16695
- init_split_arrow_buffers();
16696
- }
16697
- });
16698
-
16699
- // ../core/src/schema-utils/lib/schema/data-type.ts
16700
- function getDataTypeFromValue(value, defaultNumberType = "float32") {
16701
- if (value instanceof Date) {
16702
- return "date-millisecond";
16703
- }
16704
- if (typeof value === "number") {
16705
- return defaultNumberType;
16706
- }
16707
- if (typeof value === "boolean") {
16708
- return "bool";
16709
- }
16710
- if (typeof value === "string") {
16711
- return "utf8";
16712
- }
16713
- if (value === null || value === "undefined") {
16714
- return "null";
16715
- }
16716
- return "null";
16717
- }
16718
- function getDataTypeFromArray(array) {
16719
- let type = getDataTypeFromTypedArray(array);
16720
- if (type !== "null") {
16721
- return { type, nullable: false };
16722
- }
16723
- if (array.length > 0) {
16724
- type = getDataTypeFromValue(array[0]);
16725
- return { type, nullable: true };
16726
- }
16727
- return { type: "null", nullable: true };
16728
- }
16729
- function getDataTypeFromTypedArray(array) {
16730
- if (typeof Float16Array !== "undefined" && array instanceof Float16Array) {
16731
- return "float16";
16732
- }
16733
- switch (array.constructor) {
16734
- case Int8Array:
16735
- return "int8";
16736
- case Uint8Array:
16737
- case Uint8ClampedArray:
16738
- return "uint8";
16739
- case Int16Array:
16740
- return "int16";
16741
- case Uint16Array:
16742
- return "uint16";
16743
- case Int32Array:
16744
- return "int32";
16745
- case Uint32Array:
16746
- return "uint32";
16747
- case BigInt64Array:
16748
- return "int64";
16749
- case BigUint64Array:
16750
- return "uint64";
16751
- case Float32Array:
16752
- return "float32";
16753
- case Float64Array:
16754
- return "float64";
16755
- default:
16756
- return "null";
16757
- }
16758
- }
16759
- var init_data_type = __esm({
16760
- "../core/src/schema-utils/lib/schema/data-type.ts"() {
16761
- "use strict";
16762
- }
16763
- });
16764
-
16765
17046
  // ../core/src/schema-utils/lib/mesh/mesh-utils.ts
16766
17047
  function getMeshBoundingBox(attributes) {
16767
17048
  const positionAttribute = attributes?.POSITION;
@@ -16863,7 +17144,7 @@ return true;`);
16863
17144
  var init_float162 = __esm({
16864
17145
  "../core/src/schema/float16.ts"() {
16865
17146
  "use strict";
16866
- init_dist();
17147
+ init_dist2();
16867
17148
  }
16868
17149
  });
16869
17150
 
@@ -17802,7 +18083,7 @@ return true;`);
17802
18083
  var init_version = __esm({
17803
18084
  "src/terrain/lib/utils/version.ts"() {
17804
18085
  "use strict";
17805
- VERSION = true ? "5.0.0-beta.4" : "latest";
18086
+ VERSION = true ? "5.0.0-beta.5" : "latest";
17806
18087
  }
17807
18088
  });
17808
18089
 
@@ -17879,7 +18160,7 @@ return true;`);
17879
18160
  var init_quantized_mesh_loader2 = __esm({
17880
18161
  "src/terrain/quantized-mesh-loader.ts"() {
17881
18162
  "use strict";
17882
- init_arrow_transport();
18163
+ init_arrow_worker_transport();
17883
18164
  init_schema_utils();
17884
18165
  init_parse_quantized_mesh();
17885
18166
  init_quantized_mesh_loader_types();