@loaders.gl/geospatial 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.
Files changed (56) hide show
  1. package/README.md +1 -1
  2. package/WKT-README.md +1 -1
  3. package/dist/dbf-loader-types.cjs +1 -1
  4. package/dist/dbf-worker.js +391 -104
  5. package/dist/flatgeobuf/flatgeobuf-loader-types.cjs +1 -1
  6. package/dist/flatgeobuf/flatgeobuf-loader-types.js +1 -1
  7. package/dist/flatgeobuf/flatgeobuf-source-loader.cjs +1 -1
  8. package/dist/flatgeobuf/flatgeobuf-source-loader.js +1 -1
  9. package/dist/flatgeobuf-loader-types.cjs +1 -1
  10. package/dist/flatgeobuf-source-loader.cjs +1 -1
  11. package/dist/flatgeobuf-worker.js +853 -535
  12. package/dist/geopackage/geopackage-source-loader.cjs +1 -1
  13. package/dist/geopackage/geopackage-source-loader.js +1 -1
  14. package/dist/geopackage-source-loader.cjs +1 -1
  15. package/dist/gpx-loader-types.cjs +1 -1
  16. package/dist/kml/gpx-loader-types.cjs +1 -1
  17. package/dist/kml/gpx-loader-types.js +1 -1
  18. package/dist/kml/kml-loader-types.cjs +1 -1
  19. package/dist/kml/kml-loader-types.js +1 -1
  20. package/dist/kml/kml-writer.cjs +1 -1
  21. package/dist/kml/kml-writer.js +1 -1
  22. package/dist/kml/kmz-loader-types.cjs +1 -1
  23. package/dist/kml/kmz-loader-types.js +1 -1
  24. package/dist/kml/kmz-source.cjs +1 -1
  25. package/dist/kml/kmz-source.js +1 -1
  26. package/dist/kml/tcx-loader-types.cjs +1 -1
  27. package/dist/kml/tcx-loader-types.js +1 -1
  28. package/dist/kml-loader-types.cjs +1 -1
  29. package/dist/kml-writer.cjs +1 -1
  30. package/dist/kmz-loader-types.cjs +1 -1
  31. package/dist/kmz-source.cjs +1 -1
  32. package/dist/shapefile/dbf-loader-types.cjs +1 -1
  33. package/dist/shapefile/dbf-loader-types.js +1 -1
  34. package/dist/shapefile/lib/shapefile-worker-transport.cjs +3 -3
  35. package/dist/shapefile/lib/shapefile-worker-transport.cjs.map +2 -2
  36. package/dist/shapefile/lib/shapefile-worker-transport.js +1 -1
  37. package/dist/shapefile/lib/shapefile-worker-transport.js.map +1 -1
  38. package/dist/shapefile/shapefile-loader-types.cjs +1 -1
  39. package/dist/shapefile/shapefile-loader-types.js +1 -1
  40. package/dist/shapefile/shp-loader-types.cjs +1 -1
  41. package/dist/shapefile/shp-loader-types.js +1 -1
  42. package/dist/shapefile-loader-types.cjs +1 -1
  43. package/dist/shapefile-worker.js +2705 -2342
  44. package/dist/shp-loader-types.cjs +1 -1
  45. package/dist/shp-worker.js +2447 -2188
  46. package/dist/tcx-loader-types.cjs +1 -1
  47. package/dist/wkt/lib/version.cjs +1 -1
  48. package/dist/wkt/lib/version.js +1 -1
  49. package/dist/wkt/wkt-format.cjs +2 -2
  50. package/dist/wkt/wkt-format.cjs.map +2 -2
  51. package/dist/wkt/wkt-format.js +1 -1
  52. package/dist/wkt/wkt-format.js.map +1 -1
  53. package/dist/wkt-worker.js +251 -51
  54. package/package.json +6 -5
  55. package/src/shapefile/lib/shapefile-worker-transport.ts +1 -1
  56. package/src/wkt/wkt-format.ts +1 -1
@@ -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
  });
@@ -17314,7 +17556,7 @@ return true;`);
17314
17556
  var init_dbf_loader_types = __esm({
17315
17557
  "src/shapefile/dbf-loader-types.ts"() {
17316
17558
  "use strict";
17317
- VERSION = true ? "5.0.0-beta.4" : "latest";
17559
+ VERSION = true ? "5.0.0-beta.5" : "latest";
17318
17560
  DBFLoader = {
17319
17561
  name: "DBF",
17320
17562
  dataType: null,
@@ -17338,7 +17580,29 @@ return true;`);
17338
17580
  }
17339
17581
  });
17340
17582
 
17341
- // ../core/src/schema-utils/lib/arrow/split-arrow-buffers.ts
17583
+ // ../../node_modules/@math.gl/arrow/dist/arrow/arrow-data.js
17584
+ function getArrowVariadicBuffers(data) {
17585
+ return data.variadicBuffers ?? [];
17586
+ }
17587
+ function createArrowData(type, offset, length, nullCount, buffers, children, dictionary, variadicBuffers) {
17588
+ return Reflect.construct(Data, [
17589
+ type,
17590
+ offset,
17591
+ length,
17592
+ nullCount,
17593
+ buffers,
17594
+ children,
17595
+ dictionary,
17596
+ variadicBuffers
17597
+ ]);
17598
+ }
17599
+ var init_arrow_data = __esm({
17600
+ "../../node_modules/@math.gl/arrow/dist/arrow/arrow-data.js"() {
17601
+ init_Arrow_dom();
17602
+ }
17603
+ });
17604
+
17605
+ // ../../node_modules/@math.gl/arrow/dist/arrow/split-arrow-buffers.js
17342
17606
  function splitArrowBuffers(input, options = {}) {
17343
17607
  const context = { ...options, copies: /* @__PURE__ */ new WeakMap() };
17344
17608
  if (isArrowTable2(input)) {
@@ -17361,17 +17625,12 @@ return true;`);
17361
17625
  function isArrowVector2(input) {
17362
17626
  return "data" in input && Array.isArray(input.data);
17363
17627
  }
17364
- function splitArrowTableBuffersInternal(table, options) {
17365
- const recordBatches = table.batches.map(
17366
- (recordBatch) => splitArrowRecordBatchBuffers(recordBatch, options)
17367
- );
17368
- return new Table(table.schema, recordBatches);
17628
+ function splitArrowTableBuffersInternal(arrowTable, options) {
17629
+ const recordBatches = arrowTable.batches.map((recordBatch) => splitArrowRecordBatchBuffers(recordBatch, options));
17630
+ return new Table(arrowTable.schema, recordBatches);
17369
17631
  }
17370
17632
  function splitArrowRecordBatchBuffers(recordBatch, options) {
17371
- return new RecordBatch3(
17372
- recordBatch.schema,
17373
- splitArrowDataBuffers(recordBatch.data, options)
17374
- );
17633
+ return new RecordBatch3(recordBatch.schema, splitArrowDataBuffers(recordBatch.data, options));
17375
17634
  }
17376
17635
  function splitArrowDataBuffers(data, options) {
17377
17636
  const children = data.children.map((childData) => splitArrowDataBuffers(childData, options));
@@ -17382,7 +17641,7 @@ return true;`);
17382
17641
  [BufferType.VALIDITY]: splitArrowBuffer(data.buffers[BufferType.VALIDITY], options),
17383
17642
  [BufferType.TYPE]: splitArrowBuffer(data.buffers[BufferType.TYPE], options)
17384
17643
  };
17385
- return new Data(
17644
+ return createArrowData(
17386
17645
  data.type,
17387
17646
  data.offset,
17388
17647
  data.length,
@@ -17390,7 +17649,8 @@ return true;`);
17390
17649
  data._nullCount,
17391
17650
  buffers,
17392
17651
  children,
17393
- dictionary
17652
+ dictionary,
17653
+ getArrowVariadicBuffers(data).map((buffer) => splitArrowBuffer(buffer, options))
17394
17654
  );
17395
17655
  }
17396
17656
  function splitArrowVectorBuffers(vector, options) {
@@ -17408,7 +17668,7 @@ return true;`);
17408
17668
  }
17409
17669
  let copy = options.copies.get(array);
17410
17670
  if (!copy) {
17411
- copy = array.slice();
17671
+ copy = array instanceof Uint8Array ? new Uint8Array(array) : array.slice();
17412
17672
  options.copies.set(array, copy);
17413
17673
  }
17414
17674
  return copy;
@@ -17417,29 +17677,106 @@ return true;`);
17417
17677
  return ArrayBuffer.isView(value) && !(value instanceof DataView);
17418
17678
  }
17419
17679
  var init_split_arrow_buffers = __esm({
17420
- "../core/src/schema-utils/lib/arrow/split-arrow-buffers.ts"() {
17421
- "use strict";
17680
+ "../../node_modules/@math.gl/arrow/dist/arrow/split-arrow-buffers.js"() {
17422
17681
  init_Arrow_dom();
17682
+ init_arrow_data();
17423
17683
  }
17424
17684
  });
17425
17685
 
17426
- // ../core/src/schema-utils/lib/arrow/arrow-table-transport.ts
17427
- function dehydrateArrowTable(table, options) {
17428
- const splitTable = splitArrowBuffers(table, options);
17686
+ // ../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-vector.js
17687
+ var init_indexed_arrow_vector = __esm({
17688
+ "../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-vector.js"() {
17689
+ }
17690
+ });
17691
+
17692
+ // ../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-table.js
17693
+ var init_indexed_arrow_table = __esm({
17694
+ "../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-table.js"() {
17695
+ }
17696
+ });
17697
+
17698
+ // ../../node_modules/@math.gl/arrow/dist/arrow/mapped-arrow-table.js
17699
+ var init_mapped_arrow_table = __esm({
17700
+ "../../node_modules/@math.gl/arrow/dist/arrow/mapped-arrow-table.js"() {
17701
+ }
17702
+ });
17703
+
17704
+ // ../../node_modules/@math.gl/arrow/dist/arrow/rename-arrow-columns.js
17705
+ var init_rename_arrow_columns = __esm({
17706
+ "../../node_modules/@math.gl/arrow/dist/arrow/rename-arrow-columns.js"() {
17707
+ }
17708
+ });
17709
+
17710
+ // ../../node_modules/@math.gl/arrow/dist/arrow/arrow-table-transport.js
17711
+ function dehydrateArrowTable(arrowTable, options) {
17712
+ const splitTable = splitArrowBuffers(arrowTable, options);
17429
17713
  return {
17430
- shape: "arrow-table",
17431
17714
  transport: "arrow-js",
17432
- schema: serializeArrowSchema(splitTable.schema),
17433
- batches: splitTable.batches.map((recordBatch) => dehydrateArrowRecordBatch(recordBatch))
17715
+ version: 1,
17716
+ schema: tableToIPC(new Table(splitTable.schema, [])),
17717
+ metadataVersion: splitTable.schema.metadataVersion,
17718
+ batches: splitTable.batches.map((batch) => dehydrateArrowData(batch.data))
17434
17719
  };
17435
17720
  }
17436
17721
  function hydrateArrowTable(table) {
17437
- const schema = deserializeArrowSchema(table.schema);
17438
- const recordBatches = table.batches.map(
17439
- (recordBatch) => new RecordBatch3(schema, hydrateArrowData(recordBatch.data))
17440
- );
17441
- return new Table(schema, recordBatches);
17722
+ if (table.transport !== "arrow-js" || table.version !== 1) {
17723
+ throw new Error("Unsupported Arrow column-buffer transport protocol.");
17724
+ }
17725
+ const decodedSchema = tableFromIPC(table.schema).schema;
17726
+ const schema = new Schema2(decodedSchema.fields, decodedSchema.metadata, decodedSchema.dictionaries, table.metadataVersion);
17727
+ const type = new Struct(schema.fields);
17728
+ const batches = table.batches.map((data) => new RecordBatch3(schema, hydrateArrowData(data, type)));
17729
+ return new Table(schema, batches);
17442
17730
  }
17731
+ function dehydrateArrowData(data) {
17732
+ return {
17733
+ offset: data.offset,
17734
+ length: data.length,
17735
+ nullCount: data.nullCount,
17736
+ buffers: {
17737
+ [BufferType.OFFSET]: data.buffers[BufferType.OFFSET],
17738
+ [BufferType.DATA]: data.buffers[BufferType.DATA],
17739
+ [BufferType.VALIDITY]: data.buffers[BufferType.VALIDITY],
17740
+ [BufferType.TYPE]: data.buffers[BufferType.TYPE]
17741
+ },
17742
+ children: data.children.map((child) => dehydrateArrowData(child)),
17743
+ variadicBuffers: getArrowVariadicBuffers(data),
17744
+ dictionary: data.dictionary?.data.map((chunk) => dehydrateArrowData(chunk))
17745
+ };
17746
+ }
17747
+ function hydrateArrowData(data, type) {
17748
+ const children = data.children.map((child, index) => hydrateArrowData(child, type.children[index].type));
17749
+ const dictionary = data.dictionary && DataType.isDictionary(type) ? new Vector(data.dictionary.map((chunk) => hydrateArrowData(chunk, type.dictionary))) : void 0;
17750
+ return createArrowData(type, data.offset, data.length, data.nullCount, data.buffers, children, dictionary, data.variadicBuffers);
17751
+ }
17752
+ var init_arrow_table_transport = __esm({
17753
+ "../../node_modules/@math.gl/arrow/dist/arrow/arrow-table-transport.js"() {
17754
+ init_Arrow_dom();
17755
+ init_arrow_data();
17756
+ init_split_arrow_buffers();
17757
+ }
17758
+ });
17759
+
17760
+ // ../../node_modules/@math.gl/arrow/dist/arrow/index.js
17761
+ var init_arrow = __esm({
17762
+ "../../node_modules/@math.gl/arrow/dist/arrow/index.js"() {
17763
+ init_indexed_arrow_table();
17764
+ init_indexed_arrow_vector();
17765
+ init_mapped_arrow_table();
17766
+ init_rename_arrow_columns();
17767
+ init_split_arrow_buffers();
17768
+ init_arrow_table_transport();
17769
+ }
17770
+ });
17771
+
17772
+ // ../../node_modules/@math.gl/arrow/dist/index.js
17773
+ var init_dist2 = __esm({
17774
+ "../../node_modules/@math.gl/arrow/dist/index.js"() {
17775
+ init_arrow();
17776
+ }
17777
+ });
17778
+
17779
+ // ../core/src/arrow-worker-transport.ts
17443
17780
  function serializeArrowWorkerTable(result) {
17444
17781
  if (!isArrowTableWrapper(result)) {
17445
17782
  throw new Error("Workers require Arrow table output");
@@ -17468,60 +17805,10 @@ return true;`);
17468
17805
  table && table.shape === "arrow-table" && table.data && table.data.transport === "arrow-js" && Array.isArray(table.data.batches)
17469
17806
  );
17470
17807
  }
17471
- function dehydrateArrowRecordBatch(recordBatch) {
17472
- return { data: dehydrateArrowData(recordBatch.data) };
17473
- }
17474
- function dehydrateArrowData(data) {
17475
- return {
17476
- type: serializeArrowType(data.type),
17477
- offset: data.offset,
17478
- length: data.length,
17479
- // @ts-expect-error _nullCount is protected. Preserve the Arrow lazy null-count state.
17480
- nullCount: data._nullCount,
17481
- buffers: {
17482
- [BufferType.OFFSET]: data.buffers[BufferType.OFFSET],
17483
- [BufferType.DATA]: data.buffers[BufferType.DATA],
17484
- [BufferType.VALIDITY]: data.buffers[BufferType.VALIDITY],
17485
- [BufferType.TYPE]: data.buffers[BufferType.TYPE]
17486
- },
17487
- children: data.children.map((childData) => dehydrateArrowData(childData)),
17488
- dictionary: data.dictionary ? dehydrateArrowVector(data.dictionary) : void 0
17489
- };
17490
- }
17491
- function dehydrateArrowVector(vector) {
17492
- return { data: vector.data.map((data) => dehydrateArrowData(data)) };
17493
- }
17494
- function hydrateArrowData(data) {
17495
- const children = data.children.map((childData) => hydrateArrowData(childData));
17496
- const dictionary = data.dictionary ? hydrateArrowVector(data.dictionary) : void 0;
17497
- return new Data(
17498
- deserializeArrowType(data.type),
17499
- data.offset,
17500
- data.length,
17501
- data.nullCount,
17502
- data.buffers,
17503
- children,
17504
- dictionary
17505
- );
17506
- }
17507
- function hydrateArrowVector(vector) {
17508
- return new Vector(vector.data.map((data) => hydrateArrowData(data)));
17509
- }
17510
- var init_arrow_table_transport = __esm({
17511
- "../core/src/schema-utils/lib/arrow/arrow-table-transport.ts"() {
17808
+ var init_arrow_worker_transport = __esm({
17809
+ "../core/src/arrow-worker-transport.ts"() {
17512
17810
  "use strict";
17513
- init_Arrow_dom();
17514
- init_convert_arrow_schema();
17515
- init_split_arrow_buffers();
17516
- }
17517
- });
17518
-
17519
- // ../core/src/schema-utils/arrow-transport.ts
17520
- var init_arrow_transport = __esm({
17521
- "../core/src/schema-utils/arrow-transport.ts"() {
17522
- "use strict";
17523
- init_arrow_table_transport();
17524
- init_split_arrow_buffers();
17811
+ init_dist2();
17525
17812
  }
17526
17813
  });
17527
17814
 
@@ -17562,7 +17849,7 @@ return true;`);
17562
17849
  var init_shapefile_worker_transport = __esm({
17563
17850
  "src/shapefile/lib/shapefile-worker-transport.ts"() {
17564
17851
  "use strict";
17565
- init_arrow_transport();
17852
+ init_arrow_worker_transport();
17566
17853
  serializeShapefileWorkerBatch = serializeShapefileWorkerResult;
17567
17854
  }
17568
17855
  });