@loaders.gl/geospatial 5.0.0-beta.2 → 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 (58) 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 +776 -153
  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 +1238 -584
  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/dbf-loader.d.ts +1 -1
  35. package/dist/shapefile/lib/shapefile-worker-transport.cjs +3 -3
  36. package/dist/shapefile/lib/shapefile-worker-transport.cjs.map +2 -2
  37. package/dist/shapefile/lib/shapefile-worker-transport.js +1 -1
  38. package/dist/shapefile/lib/shapefile-worker-transport.js.map +1 -1
  39. package/dist/shapefile/shapefile-loader-types.cjs +1 -1
  40. package/dist/shapefile/shapefile-loader-types.js +1 -1
  41. package/dist/shapefile/shp-loader-types.cjs +1 -1
  42. package/dist/shapefile/shp-loader-types.js +1 -1
  43. package/dist/shapefile/shp-loader.d.ts +1 -1
  44. package/dist/shapefile-loader-types.cjs +1 -1
  45. package/dist/shapefile-worker.js +3099 -2400
  46. package/dist/shp-loader-types.cjs +1 -1
  47. package/dist/shp-worker.js +2811 -2216
  48. package/dist/tcx-loader-types.cjs +1 -1
  49. package/dist/wkt/lib/version.cjs +1 -1
  50. package/dist/wkt/lib/version.js +1 -1
  51. package/dist/wkt/wkt-format.cjs +2 -2
  52. package/dist/wkt/wkt-format.cjs.map +2 -2
  53. package/dist/wkt/wkt-format.js +1 -1
  54. package/dist/wkt/wkt-format.js.map +1 -1
  55. package/dist/wkt-worker.js +582 -75
  56. package/package.json +6 -5
  57. package/src/shapefile/lib/shapefile-worker-transport.ts +1 -1
  58. 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"() {
22
- parentPort = null;
21
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js"() {
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();
@@ -36,6 +36,9 @@
36
36
  else if (ArrayBuffer.isView(value)) {
37
37
  if (isTransferable(value.buffer))
38
38
  transfersSet.add(value.buffer);
39
+ } else if (recursive && typeof MessageChannel !== "undefined" && value instanceof MessageChannel) {
40
+ visit(value.port1);
41
+ visit(value.port2);
39
42
  } else if (recursive && value instanceof Map) {
40
43
  for (const [key, item] of value) {
41
44
  visit(key);
@@ -71,11 +74,11 @@
71
74
  return false;
72
75
  }
73
76
  var init_get_transfer_list = __esm({
74
- "../../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"() {
75
78
  }
76
79
  });
77
80
 
78
- // ../../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
79
82
  async function getParentPort() {
80
83
  return parentPort;
81
84
  }
@@ -88,7 +91,7 @@
88
91
  }
89
92
  var onMessageWrapperMap, WorkerBody;
90
93
  var init_worker_body = __esm({
91
- "../../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"() {
92
95
  init_get_transfer_list();
93
96
  init_worker_threads_browser();
94
97
  onMessageWrapperMap = /* @__PURE__ */ new Map();
@@ -103,16 +106,16 @@
103
106
  */
104
107
  static set onmessage(onMessage) {
105
108
  async function handleMessage(message) {
106
- const parentPort2 = await getParentPort();
107
- const { type, payload } = parentPort2 ? message : message.data;
109
+ const parentPort3 = await getParentPort();
110
+ const { type, payload } = parentPort3 ? message : message.data;
108
111
  onMessage(type, payload);
109
112
  }
110
- getParentPort().then((parentPort2) => {
111
- if (parentPort2) {
112
- parentPort2.on("message", (message) => {
113
+ getParentPort().then((parentPort3) => {
114
+ if (parentPort3) {
115
+ parentPort3.on("message", (message) => {
113
116
  handleMessage(message);
114
117
  });
115
- parentPort2.on("exit", () => console.debug("Node worker closing"));
118
+ parentPort3.on("exit", () => console.debug("Node worker closing"));
116
119
  } else {
117
120
  globalThis.onmessage = handleMessage;
118
121
  }
@@ -130,9 +133,9 @@
130
133
  };
131
134
  onMessageWrapperMap.set(onMessage, onMessageWrapper);
132
135
  }
133
- const parentPort2 = await getParentPort();
134
- if (parentPort2) {
135
- parentPort2.on("message", onMessageWrapper);
136
+ const parentPort3 = await getParentPort();
137
+ if (parentPort3) {
138
+ parentPort3.on("message", onMessageWrapper);
136
139
  } else {
137
140
  globalThis.addEventListener("message", onMessageWrapper);
138
141
  }
@@ -143,9 +146,9 @@
143
146
  if (!onMessageWrapper) {
144
147
  return;
145
148
  }
146
- const parentPort2 = await getParentPort();
147
- if (parentPort2) {
148
- parentPort2.off("message", onMessageWrapper);
149
+ const parentPort3 = await getParentPort();
150
+ if (parentPort3) {
151
+ parentPort3.off("message", onMessageWrapper);
149
152
  } else {
150
153
  globalThis.removeEventListener("message", onMessageWrapper);
151
154
  }
@@ -155,12 +158,12 @@
155
158
  * @param type
156
159
  * @param payload
157
160
  */
158
- static async postMessage(type, payload) {
161
+ static async postMessage(type, payload, copy = false) {
159
162
  const data = { source: "loaders.gl", type, payload };
160
- const transferList = getTransferList(payload);
161
- const parentPort2 = await getParentPort();
162
- if (parentPort2) {
163
- parentPort2.postMessage(data, transferList);
163
+ const transferList = copy ? [] : getTransferList(payload);
164
+ const parentPort3 = await getParentPort();
165
+ if (parentPort3) {
166
+ parentPort3.postMessage(data, transferList);
164
167
  } else {
165
168
  globalThis.postMessage(data, transferList);
166
169
  }
@@ -169,10 +172,10 @@
169
172
  }
170
173
  });
171
174
 
172
- // ../../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
173
176
  var AsyncQueue;
174
177
  var init_async_queue = __esm({
175
- "../../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"() {
176
179
  AsyncQueue = class {
177
180
  constructor() {
178
181
  this._values = [];
@@ -241,10 +244,10 @@
241
244
  }
242
245
  });
243
246
 
244
- // ../../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
245
248
  var SharedWorkerState;
246
249
  var init_shared_state = __esm({
247
- "../../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"() {
248
251
  SharedWorkerState = class {
249
252
  constructor(buffer) {
250
253
  if (typeof SharedArrayBuffer === "undefined" || !(buffer instanceof SharedArrayBuffer) || buffer.byteLength !== 16)
@@ -285,8 +288,19 @@
285
288
  }
286
289
  });
287
290
 
288
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/create-worker.js
289
- async function createWorker(process, processInBatches) {
291
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js
292
+ function validateOutputOwnership(ownership) {
293
+ if (ownership !== void 0 && ownership !== "copy" && ownership !== "transfer") {
294
+ throw new Error("Invalid worker output ownership");
295
+ }
296
+ }
297
+ var init_validate_output_ownership = __esm({
298
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js"() {
299
+ }
300
+ });
301
+
302
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/create-worker.js
303
+ async function createWorker(process2, processInBatches, preload) {
290
304
  if (!await WorkerBody.inWorkerThread()) {
291
305
  return;
292
306
  }
@@ -327,23 +341,26 @@
327
341
  }
328
342
  switch (type) {
329
343
  case "preload":
344
+ await preload?.();
330
345
  WorkerBody.postMessage("done", {});
331
346
  break;
332
347
  case "process":
333
348
  throwIfAborted();
334
- if (!process) {
349
+ validateOutputOwnership(payload.options?.["outputOwnership"]);
350
+ if (!process2) {
335
351
  throw new Error("Worker does not support atomic processing");
336
352
  }
337
- const result = await process(payload.input, payload.options || {}, jobContext, payload.context || {});
353
+ const result = await process2(payload.input, payload.options || {}, jobContext, payload.context || {});
338
354
  throwIfAborted();
339
355
  reporter?.finish();
340
356
  await WorkerBody.postMessage("done", {
341
357
  result,
342
358
  executionMs: performance.now() - startedAt
343
- });
359
+ }, payload.options?.["outputOwnership"] === "copy");
344
360
  break;
345
361
  case "process-in-batches":
346
362
  throwIfAborted();
363
+ validateOutputOwnership(payload.options?.["outputOwnership"]);
347
364
  if (!processInBatches) {
348
365
  throw new Error("Worker does not support batched processing");
349
366
  }
@@ -355,7 +372,7 @@
355
372
  const resultIterator = processInBatches(createDemandDrivenIterator(inputBatches), payload.options || {}, jobContext, payload.context || {});
356
373
  for await (const batch of resultIterator) {
357
374
  throwIfAborted();
358
- await WorkerBody.postMessage("output-batch", { result: batch });
375
+ await WorkerBody.postMessage("output-batch", { result: batch }, payload.options?.["outputOwnership"] === "copy");
359
376
  await outputAcknowledgements.next();
360
377
  }
361
378
  throwIfAborted();
@@ -453,14 +470,14 @@
453
470
  });
454
471
  }
455
472
  function createProgressReporter() {
456
- let pending;
473
+ let pending2;
457
474
  let finished = false;
458
475
  let scheduled = false;
459
476
  const flush = () => {
460
477
  scheduled = false;
461
- if (pending) {
462
- WorkerBody.postMessage("progress", { progress: pending });
463
- pending = void 0;
478
+ if (pending2) {
479
+ WorkerBody.postMessage("progress", { progress: pending2 });
480
+ pending2 = void 0;
464
481
  }
465
482
  };
466
483
  return {
@@ -468,9 +485,9 @@
468
485
  report(progress) {
469
486
  if (finished)
470
487
  return;
471
- if (pending && pending.phase !== progress.phase)
488
+ if (pending2 && pending2.phase !== progress.phase)
472
489
  flush();
473
- pending = { ...progress };
490
+ pending2 = { ...progress };
474
491
  if (!scheduled) {
475
492
  scheduled = true;
476
493
  setTimeout(flush, 0);
@@ -479,7 +496,7 @@
479
496
  /** Flushes final progress and suppresses reports from stale callbacks. */
480
497
  finish(discard = false) {
481
498
  if (discard)
482
- pending = void 0;
499
+ pending2 = void 0;
483
500
  flush();
484
501
  finished = true;
485
502
  }
@@ -487,10 +504,11 @@
487
504
  }
488
505
  var requestId, activeController, activeInputBatches, activeOutputAcknowledgements;
489
506
  var init_create_worker = __esm({
490
- "../../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"() {
491
508
  init_shared_state();
492
509
  init_async_queue();
493
510
  init_worker_body();
511
+ init_validate_output_ownership();
494
512
  requestId = 0;
495
513
  activeController = null;
496
514
  activeInputBatches = null;
@@ -498,29 +516,589 @@
498
516
  }
499
517
  });
500
518
 
501
- // ../../node_modules/@math.gl/core/dist/worker-utils/index.js
519
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/index.js
502
520
  var import_meta, path, moduleUrl;
503
521
  var init_worker_utils = __esm({
504
- "../../node_modules/@math.gl/core/dist/worker-utils/index.js"() {
522
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/index.js"() {
523
+ init_worker_body();
505
524
  init_create_worker();
525
+ init_get_transfer_list();
506
526
  import_meta = {};
507
527
  path = typeof __filename === "string" ? __filename.replace(/\\/g, "/") : "";
508
528
  moduleUrl = path ? `file://${path.startsWith("/") ? "" : "/"}${encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F")}` : import_meta.url;
509
529
  }
510
530
  });
511
531
 
512
- // ../../node_modules/@math.gl/core/dist/tasks/index.js
513
- var init_tasks = __esm({
514
- "../../node_modules/@math.gl/core/dist/tasks/index.js"() {
532
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js
533
+ function preloadTaskCode(task, signal) {
534
+ if (!task.preload)
535
+ return Promise.resolve();
536
+ let promise = pending.get(task);
537
+ if (!promise) {
538
+ promise = Promise.resolve().then(() => task.preload()).then(() => {
539
+ loaded.add(task);
540
+ });
541
+ pending.set(task, promise);
542
+ void promise.catch(() => pending.delete(task));
543
+ }
544
+ return withSignal(promise, signal);
545
+ }
546
+ function withSignal(operation, signal) {
547
+ if (!signal)
548
+ return operation;
549
+ return new Promise((resolve, reject) => {
550
+ const abort = () => {
551
+ signal.removeEventListener("abort", abort);
552
+ reject(signal.reason);
553
+ };
554
+ signal.addEventListener("abort", abort, { once: true });
555
+ if (signal.aborted)
556
+ abort();
557
+ operation.then((value) => {
558
+ signal.removeEventListener("abort", abort);
559
+ resolve(value);
560
+ }, (error) => {
561
+ signal.removeEventListener("abort", abort);
562
+ reject(error);
563
+ });
564
+ });
565
+ }
566
+ var pending, loaded;
567
+ var init_task_preload = __esm({
568
+ "../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js"() {
569
+ pending = /* @__PURE__ */ new WeakMap();
570
+ loaded = /* @__PURE__ */ new WeakSet();
571
+ }
572
+ });
573
+
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
724
+ function assertPayload(value) {
725
+ if (!value || typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype) {
726
+ throw new TypeError("Task payloads must be plain objects with named fields");
727
+ }
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
+ }
740
+ function taskContext(state, context = {}) {
741
+ const signal = context.signal ?? new AbortController().signal;
742
+ return {
743
+ state,
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
+ },
755
+ throwIfAborted: () => {
756
+ signal.throwIfAborted();
757
+ context.throwIfAborted?.();
758
+ },
759
+ reportProgress: (progress) => context.reportProgress?.({
760
+ ...progress,
761
+ phase: progress.phase ?? "process",
762
+ unit: progress.unit ?? "items"
763
+ })
764
+ };
765
+ }
766
+ async function initializeTaskWorker(task) {
767
+ if (!await WorkerBody.inWorkerThread())
768
+ throw new Error("initializeTaskWorker must run inside a worker");
769
+ if (installed)
770
+ throw new Error("A task is already installed in this worker");
771
+ installed = true;
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
+ });
836
+ let streamOptions = {};
837
+ return createWorker(async (request, _options, context) => {
838
+ switch (request.operation) {
839
+ case "initialize":
840
+ return runtime.initialize(request.input, context);
841
+ case "destroy":
842
+ return runtime.destroy();
843
+ case "stream-options":
844
+ streamOptions = request.options;
845
+ return {};
846
+ case "process":
847
+ return runtime.process(request.input, request.options, context);
848
+ default:
849
+ throw new Error("Unknown task operation");
850
+ }
851
+ }, async function* (inputs, _options, context) {
852
+ async function* batches() {
853
+ for await (const input of inputs) {
854
+ assertPayload(input);
855
+ yield input;
856
+ }
857
+ }
858
+ try {
859
+ yield* runtime.stream(batches(), streamOptions, context);
860
+ } finally {
861
+ streamOptions = {};
862
+ }
863
+ }, () => preloadTaskCode(task));
864
+ }
865
+ var TaskRuntime, installed;
866
+ var init_task_runtime = __esm({
867
+ "../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js"() {
515
868
  init_worker_utils();
869
+ init_task_preload();
870
+ init_task_channel();
871
+ TaskRuntime = class {
872
+ constructor(task) {
873
+ this.task = task;
874
+ this.initialized = false;
875
+ }
876
+ async initialize(input, context = {}) {
877
+ if (this.initialized)
878
+ throw new Error("Task is already initialized");
879
+ assertPayload(input);
880
+ await preloadTaskCode(this.task, context.signal);
881
+ context.signal?.throwIfAborted();
882
+ this.state = await this.task.initialize?.(input, taskContext(void 0, context));
883
+ this.initialized = true;
884
+ return {};
885
+ }
886
+ async destroy() {
887
+ if (this.initialized) {
888
+ this.initialized = false;
889
+ const state = this.state;
890
+ this.state = void 0;
891
+ if (this.task.initialize)
892
+ await this.task.destroy?.(state);
893
+ }
894
+ return {};
895
+ }
896
+ async process(input, options, context = {}) {
897
+ if (!this.initialized)
898
+ throw new Error("Task is not initialized");
899
+ if (!this.task.process)
900
+ throw new Error("Task has no atomic processor");
901
+ assertPayload(input);
902
+ const result = await this.task.process(input, options, taskContext(this.state, context));
903
+ assertPayload(result);
904
+ return result;
905
+ }
906
+ async *stream(inputs, options, context = {}) {
907
+ if (!this.initialized)
908
+ throw new Error("Task is not initialized");
909
+ if (!this.task.processInBatches)
910
+ throw new Error("Task has no streaming processor");
911
+ for await (const output of this.task.processInBatches(inputs, options, taskContext(this.state, context))) {
912
+ assertPayload(output);
913
+ yield output;
914
+ }
915
+ }
916
+ };
917
+ installed = false;
918
+ }
919
+ });
920
+
921
+ // ../../node_modules/@math.gl/tasks/dist/tasks/index.js
922
+ var init_tasks = __esm({
923
+ "../../node_modules/@math.gl/tasks/dist/tasks/index.js"() {
924
+ init_task_runtime();
925
+ }
926
+ });
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
+
935
+ // ../core/src/worker-utils/lib/node/worker_threads-browser.ts
936
+ var worker_threads_browser_exports = {};
937
+ __export(worker_threads_browser_exports, {
938
+ NodeWorker: () => NodeWorker,
939
+ parentPort: () => parentPort2
940
+ });
941
+ var NodeWorker, parentPort2;
942
+ var init_worker_threads_browser2 = __esm({
943
+ "../core/src/worker-utils/lib/node/worker_threads-browser.ts"() {
944
+ "use strict";
945
+ NodeWorker = class {
946
+ /** Restores the native worker constructor when this browser shim is embedded in a Node bundle. */
947
+ constructor(...arguments_) {
948
+ const runtimeProcess = globalThis.process;
949
+ const WorkerConstructor = runtimeProcess?.getBuiltinModule?.("node:worker_threads").Worker;
950
+ if (WorkerConstructor) {
951
+ return new WorkerConstructor(...arguments_);
952
+ }
953
+ }
954
+ /** No-op browser fallback matching the native Worker API. */
955
+ terminate() {
956
+ }
957
+ };
958
+ parentPort2 = null;
959
+ }
960
+ });
961
+
962
+ // ../core/src/worker-utils/lib/worker-api/task-runtime.ts
963
+ function normalizeTaskProgress(progress) {
964
+ return { ...progress, phase: progress.phase ?? "process", unit: progress.unit ?? "items" };
965
+ }
966
+ async function isWorkerThread() {
967
+ if (typeof self !== "undefined" && typeof document === "undefined" && typeof self.postMessage === "function")
968
+ return true;
969
+ if (typeof process !== "undefined" && process.versions?.node) {
970
+ const { isMainThread } = await Promise.resolve().then(() => (init_worker_threads_browser2(), worker_threads_browser_exports));
971
+ return !isMainThread;
972
+ }
973
+ return false;
974
+ }
975
+ var initializeTaskWorker2;
976
+ var init_task_runtime2 = __esm({
977
+ "../core/src/worker-utils/lib/worker-api/task-runtime.ts"() {
978
+ "use strict";
979
+ init_dist();
980
+ initializeTaskWorker2 = initializeTaskWorker;
981
+ }
982
+ });
983
+
984
+ // ../core/src/worker-utils/lib/worker-utils/get-transfer-list.ts
985
+ function getTransferList2(object, recursive = true, transfers) {
986
+ const transfersSet = transfers || /* @__PURE__ */ new Set();
987
+ if (!object) {
988
+ } else if (isTransferable2(object)) {
989
+ transfersSet.add(object);
990
+ } else if (isTransferable2(object.buffer)) {
991
+ transfersSet.add(object.buffer);
992
+ } else if (ArrayBuffer.isView(object)) {
993
+ } else if (recursive && typeof object === "object") {
994
+ for (const key in object) {
995
+ getTransferList2(object[key], recursive, transfersSet);
996
+ }
997
+ }
998
+ return transfers === void 0 ? Array.from(transfersSet) : [];
999
+ }
1000
+ function isTransferable2(object) {
1001
+ if (!object) {
1002
+ return false;
1003
+ }
1004
+ if (object instanceof ArrayBuffer) {
1005
+ return true;
1006
+ }
1007
+ if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
1008
+ return true;
1009
+ }
1010
+ if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
1011
+ return true;
1012
+ }
1013
+ if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
1014
+ return true;
1015
+ }
1016
+ return false;
1017
+ }
1018
+ var init_get_transfer_list2 = __esm({
1019
+ "../core/src/worker-utils/lib/worker-utils/get-transfer-list.ts"() {
1020
+ "use strict";
516
1021
  }
517
1022
  });
518
1023
 
519
1024
  // ../core/src/worker-utils/lib/worker-api/create-worker.ts
1025
+ async function createWorker2(process2, processInBatches) {
1026
+ if (!await isWorkerThread()) return;
1027
+ await initializeTaskWorker2(createWorkerTask(process2, processInBatches));
1028
+ }
1029
+ function createWorkerTask(process2, processInBatches) {
1030
+ return {
1031
+ id: "loaders.gl",
1032
+ initialize: (state) => state,
1033
+ destroy: (state) => state.port?.close(),
1034
+ process: async ({ value }, options, context) => {
1035
+ if (!process2) throw new Error("Worker does not support atomic processing");
1036
+ return { value: await process2(value, options, createContext(context), context.state.context) };
1037
+ },
1038
+ ...processInBatches ? {
1039
+ processInBatches: async function* (inputs, options, context) {
1040
+ async function* values() {
1041
+ for await (const input of inputs) yield input.value;
1042
+ }
1043
+ for await (const value of processInBatches(
1044
+ values(),
1045
+ options,
1046
+ createContext(context),
1047
+ context.state.context
1048
+ )) {
1049
+ yield { value };
1050
+ }
1051
+ }
1052
+ } : {}
1053
+ };
1054
+ }
1055
+ function createContext(context) {
1056
+ let requestIdentifier = 0;
1057
+ const port = context.state.port;
1058
+ return {
1059
+ signal: context.signal,
1060
+ throwIfAborted: () => context.throwIfAborted(),
1061
+ reportProgress: (progress) => context.reportProgress(normalizeTaskProgress(progress)),
1062
+ process: port ? (input, options = {}, jobContext = {}) => {
1063
+ context.throwIfAborted();
1064
+ const identifier = ++requestIdentifier;
1065
+ return new Promise((resolve, reject) => {
1066
+ const onMessage = (event) => {
1067
+ if (event.data.identifier !== identifier) return;
1068
+ cleanup();
1069
+ if (event.data.error) {
1070
+ const error = new Error(event.data.error.message);
1071
+ error.name = event.data.error.name;
1072
+ reject(error);
1073
+ } else resolve(event.data.value);
1074
+ };
1075
+ const onAbort = () => {
1076
+ cleanup();
1077
+ reject(context.signal.reason);
1078
+ };
1079
+ const cleanup = () => {
1080
+ port.removeEventListener("message", onMessage);
1081
+ context.signal.removeEventListener("abort", onAbort);
1082
+ };
1083
+ port.addEventListener("message", onMessage);
1084
+ context.signal.addEventListener("abort", onAbort, { once: true });
1085
+ port.start();
1086
+ try {
1087
+ const request = { identifier, input, options, context: jobContext };
1088
+ port.postMessage(request, getTransferList2(request));
1089
+ } catch (error) {
1090
+ cleanup();
1091
+ reject(error);
1092
+ }
1093
+ });
1094
+ } : void 0
1095
+ };
1096
+ }
520
1097
  var init_create_worker2 = __esm({
521
1098
  "../core/src/worker-utils/lib/worker-api/create-worker.ts"() {
522
1099
  "use strict";
523
- init_tasks();
1100
+ init_task_runtime2();
1101
+ init_get_transfer_list2();
524
1102
  }
525
1103
  });
526
1104
 
@@ -534,7 +1112,7 @@
534
1112
 
535
1113
  // ../core/src/loader-utils/lib/worker-loader-utils/create-loader-worker.ts
536
1114
  async function createLoaderWorker(loader, selectLoader = () => loader) {
537
- await createWorker(
1115
+ await createWorker2(
538
1116
  (input, options, workerContext, loaderContext) => processLoaderWorkerData(
539
1117
  selectLoader(options || {}),
540
1118
  input,
@@ -8876,11 +9454,11 @@ return true;`);
8876
9454
  this._offsets = new OffsetsBufferBuilder(opts.type);
8877
9455
  }
8878
9456
  setValue(index, value) {
8879
- const pending = this._pending || (this._pending = /* @__PURE__ */ new Map());
8880
- const current = pending.get(index);
9457
+ const pending2 = this._pending || (this._pending = /* @__PURE__ */ new Map());
9458
+ const current = pending2.get(index);
8881
9459
  current && (this._pendingLength -= current.length);
8882
9460
  this._pendingLength += value instanceof MapRow ? value[kKeys].length : value.length;
8883
- pending.set(index, value);
9461
+ pending2.set(index, value);
8884
9462
  }
8885
9463
  setValid(index, isValid) {
8886
9464
  if (!super.setValid(index, isValid)) {
@@ -8903,12 +9481,12 @@ return true;`);
8903
9481
  return super.finish();
8904
9482
  }
8905
9483
  _flush() {
8906
- const pending = this._pending;
9484
+ const pending2 = this._pending;
8907
9485
  const pendingLength = this._pendingLength;
8908
9486
  this._pendingLength = 0;
8909
9487
  this._pending = void 0;
8910
- if (pending && pending.size > 0) {
8911
- this._flushPending(pending, pendingLength);
9488
+ if (pending2 && pending2.size > 0) {
9489
+ this._flushPending(pending2, pendingLength);
8912
9490
  }
8913
9491
  return this;
8914
9492
  }
@@ -11494,11 +12072,11 @@ return true;`);
11494
12072
  setValue(index, value) {
11495
12073
  return super.setValue(index, toUint8Array(value));
11496
12074
  }
11497
- _flushPending(pending, pendingLength) {
12075
+ _flushPending(pending2, pendingLength) {
11498
12076
  const offsets = this._offsets;
11499
12077
  const data = this._values.reserve(pendingLength).buffer;
11500
12078
  let offset = 0;
11501
- for (const [index, value] of pending) {
12079
+ for (const [index, value] of pending2) {
11502
12080
  if (value === void 0) {
11503
12081
  offsets.set(index, 0);
11504
12082
  } else {
@@ -11535,11 +12113,11 @@ return true;`);
11535
12113
  setValue(index, value) {
11536
12114
  return super.setValue(index, toUint8Array(value));
11537
12115
  }
11538
- _flushPending(pending, pendingLength) {
12116
+ _flushPending(pending2, pendingLength) {
11539
12117
  const offsets = this._offsets;
11540
12118
  const data = this._values.reserve(pendingLength).buffer;
11541
12119
  let offset = 0;
11542
- for (const [index, value] of pending) {
12120
+ for (const [index, value] of pending2) {
11543
12121
  if (value === void 0) {
11544
12122
  offsets.set(index, BigInt(0));
11545
12123
  } else {
@@ -11850,10 +12428,10 @@ return true;`);
11850
12428
  this.type = new List2(new Field2(name, child.type, true));
11851
12429
  return this.numChildren - 1;
11852
12430
  }
11853
- _flushPending(pending) {
12431
+ _flushPending(pending2) {
11854
12432
  const offsets = this._offsets;
11855
12433
  const [child] = this.children;
11856
- for (const [index, value] of pending) {
12434
+ for (const [index, value] of pending2) {
11857
12435
  if (typeof value === "undefined") {
11858
12436
  offsets.set(index, 0);
11859
12437
  } else {
@@ -11892,10 +12470,10 @@ return true;`);
11892
12470
  this.type = new LargeList2(new Field2(name, child.type, true));
11893
12471
  return this.numChildren - 1;
11894
12472
  }
11895
- _flushPending(pending) {
12473
+ _flushPending(pending2) {
11896
12474
  const offsets = this._offsets;
11897
12475
  const [child] = this.children;
11898
- for (const [index, value] of pending) {
12476
+ for (const [index, value] of pending2) {
11899
12477
  if (typeof value === "undefined") {
11900
12478
  offsets.set(index, BigInt(0));
11901
12479
  } else {
@@ -11925,11 +12503,11 @@ return true;`);
11925
12503
  }
11926
12504
  setValue(index, value) {
11927
12505
  const row = value instanceof Map ? value : new Map(Object.entries(value));
11928
- const pending = this._pending || (this._pending = /* @__PURE__ */ new Map());
11929
- const current = pending.get(index);
12506
+ const pending2 = this._pending || (this._pending = /* @__PURE__ */ new Map());
12507
+ const current = pending2.get(index);
11930
12508
  current && (this._pendingLength -= current.size);
11931
12509
  this._pendingLength += row.size;
11932
- pending.set(index, row);
12510
+ pending2.set(index, row);
11933
12511
  }
11934
12512
  addChild(child, name = `${this.numChildren}`) {
11935
12513
  if (this.numChildren > 0) {
@@ -11939,10 +12517,10 @@ return true;`);
11939
12517
  this.type = new Map_(new Field2(name, child.type, true), this.type.keysSorted);
11940
12518
  return this.numChildren - 1;
11941
12519
  }
11942
- _flushPending(pending) {
12520
+ _flushPending(pending2) {
11943
12521
  const offsets = this._offsets;
11944
12522
  const [child] = this.children;
11945
- for (const [index, value] of pending) {
12523
+ for (const [index, value] of pending2) {
11946
12524
  if (value === void 0) {
11947
12525
  offsets.set(index, 0);
11948
12526
  } else {
@@ -12151,7 +12729,7 @@ return true;`);
12151
12729
  return super.setValue(index, encodeUtf8(value));
12152
12730
  }
12153
12731
  // @ts-ignore
12154
- _flushPending(pending, pendingLength) {
12732
+ _flushPending(pending2, pendingLength) {
12155
12733
  }
12156
12734
  };
12157
12735
  Utf8Builder.prototype._flushPending = BinaryBuilder.prototype._flushPending;
@@ -12182,7 +12760,7 @@ return true;`);
12182
12760
  return super.setValue(index, encodeUtf8(value));
12183
12761
  }
12184
12762
  // @ts-ignore
12185
- _flushPending(pending, pendingLength) {
12763
+ _flushPending(pending2, pendingLength) {
12186
12764
  }
12187
12765
  };
12188
12766
  LargeUtf8Builder.prototype._flushPending = LargeBinaryBuilder.prototype._flushPending;
@@ -13894,8 +14472,8 @@ return true;`);
13894
14472
  });
13895
14473
 
13896
14474
  // ../../node_modules/apache-arrow/ipc/reader.mjs
13897
- function shouldAutoDestroy(self, options) {
13898
- return options && typeof options["autoDestroy"] === "boolean" ? options["autoDestroy"] : self["autoDestroy"];
14475
+ function shouldAutoDestroy(self2, options) {
14476
+ return options && typeof options["autoDestroy"] === "boolean" ? options["autoDestroy"] : self2["autoDestroy"];
13899
14477
  }
13900
14478
  function* readAllSync(source) {
13901
14479
  const reader = RecordBatchReader.from(source);
@@ -16978,7 +17556,7 @@ return true;`);
16978
17556
  var init_dbf_loader_types = __esm({
16979
17557
  "src/shapefile/dbf-loader-types.ts"() {
16980
17558
  "use strict";
16981
- VERSION = true ? "5.0.0-beta.2" : "latest";
17559
+ VERSION = true ? "5.0.0-beta.5" : "latest";
16982
17560
  DBFLoader = {
16983
17561
  name: "DBF",
16984
17562
  dataType: null,
@@ -17002,7 +17580,29 @@ return true;`);
17002
17580
  }
17003
17581
  });
17004
17582
 
17005
- // ../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
17006
17606
  function splitArrowBuffers(input, options = {}) {
17007
17607
  const context = { ...options, copies: /* @__PURE__ */ new WeakMap() };
17008
17608
  if (isArrowTable2(input)) {
@@ -17025,17 +17625,12 @@ return true;`);
17025
17625
  function isArrowVector2(input) {
17026
17626
  return "data" in input && Array.isArray(input.data);
17027
17627
  }
17028
- function splitArrowTableBuffersInternal(table, options) {
17029
- const recordBatches = table.batches.map(
17030
- (recordBatch) => splitArrowRecordBatchBuffers(recordBatch, options)
17031
- );
17032
- 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);
17033
17631
  }
17034
17632
  function splitArrowRecordBatchBuffers(recordBatch, options) {
17035
- return new RecordBatch3(
17036
- recordBatch.schema,
17037
- splitArrowDataBuffers(recordBatch.data, options)
17038
- );
17633
+ return new RecordBatch3(recordBatch.schema, splitArrowDataBuffers(recordBatch.data, options));
17039
17634
  }
17040
17635
  function splitArrowDataBuffers(data, options) {
17041
17636
  const children = data.children.map((childData) => splitArrowDataBuffers(childData, options));
@@ -17046,7 +17641,7 @@ return true;`);
17046
17641
  [BufferType.VALIDITY]: splitArrowBuffer(data.buffers[BufferType.VALIDITY], options),
17047
17642
  [BufferType.TYPE]: splitArrowBuffer(data.buffers[BufferType.TYPE], options)
17048
17643
  };
17049
- return new Data(
17644
+ return createArrowData(
17050
17645
  data.type,
17051
17646
  data.offset,
17052
17647
  data.length,
@@ -17054,7 +17649,8 @@ return true;`);
17054
17649
  data._nullCount,
17055
17650
  buffers,
17056
17651
  children,
17057
- dictionary
17652
+ dictionary,
17653
+ getArrowVariadicBuffers(data).map((buffer) => splitArrowBuffer(buffer, options))
17058
17654
  );
17059
17655
  }
17060
17656
  function splitArrowVectorBuffers(vector, options) {
@@ -17072,7 +17668,7 @@ return true;`);
17072
17668
  }
17073
17669
  let copy = options.copies.get(array);
17074
17670
  if (!copy) {
17075
- copy = array.slice();
17671
+ copy = array instanceof Uint8Array ? new Uint8Array(array) : array.slice();
17076
17672
  options.copies.set(array, copy);
17077
17673
  }
17078
17674
  return copy;
@@ -17081,29 +17677,106 @@ return true;`);
17081
17677
  return ArrayBuffer.isView(value) && !(value instanceof DataView);
17082
17678
  }
17083
17679
  var init_split_arrow_buffers = __esm({
17084
- "../core/src/schema-utils/lib/arrow/split-arrow-buffers.ts"() {
17085
- "use strict";
17680
+ "../../node_modules/@math.gl/arrow/dist/arrow/split-arrow-buffers.js"() {
17086
17681
  init_Arrow_dom();
17682
+ init_arrow_data();
17683
+ }
17684
+ });
17685
+
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"() {
17087
17701
  }
17088
17702
  });
17089
17703
 
17090
- // ../core/src/schema-utils/lib/arrow/arrow-table-transport.ts
17091
- function dehydrateArrowTable(table, options) {
17092
- const splitTable = splitArrowBuffers(table, options);
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);
17093
17713
  return {
17094
- shape: "arrow-table",
17095
17714
  transport: "arrow-js",
17096
- schema: serializeArrowSchema(splitTable.schema),
17097
- 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))
17098
17719
  };
17099
17720
  }
17100
17721
  function hydrateArrowTable(table) {
17101
- const schema = deserializeArrowSchema(table.schema);
17102
- const recordBatches = table.batches.map(
17103
- (recordBatch) => new RecordBatch3(schema, hydrateArrowData(recordBatch.data))
17104
- );
17105
- 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);
17106
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
17107
17780
  function serializeArrowWorkerTable(result) {
17108
17781
  if (!isArrowTableWrapper(result)) {
17109
17782
  throw new Error("Workers require Arrow table output");
@@ -17132,60 +17805,10 @@ return true;`);
17132
17805
  table && table.shape === "arrow-table" && table.data && table.data.transport === "arrow-js" && Array.isArray(table.data.batches)
17133
17806
  );
17134
17807
  }
17135
- function dehydrateArrowRecordBatch(recordBatch) {
17136
- return { data: dehydrateArrowData(recordBatch.data) };
17137
- }
17138
- function dehydrateArrowData(data) {
17139
- return {
17140
- type: serializeArrowType(data.type),
17141
- offset: data.offset,
17142
- length: data.length,
17143
- // @ts-expect-error _nullCount is protected. Preserve the Arrow lazy null-count state.
17144
- nullCount: data._nullCount,
17145
- buffers: {
17146
- [BufferType.OFFSET]: data.buffers[BufferType.OFFSET],
17147
- [BufferType.DATA]: data.buffers[BufferType.DATA],
17148
- [BufferType.VALIDITY]: data.buffers[BufferType.VALIDITY],
17149
- [BufferType.TYPE]: data.buffers[BufferType.TYPE]
17150
- },
17151
- children: data.children.map((childData) => dehydrateArrowData(childData)),
17152
- dictionary: data.dictionary ? dehydrateArrowVector(data.dictionary) : void 0
17153
- };
17154
- }
17155
- function dehydrateArrowVector(vector) {
17156
- return { data: vector.data.map((data) => dehydrateArrowData(data)) };
17157
- }
17158
- function hydrateArrowData(data) {
17159
- const children = data.children.map((childData) => hydrateArrowData(childData));
17160
- const dictionary = data.dictionary ? hydrateArrowVector(data.dictionary) : void 0;
17161
- return new Data(
17162
- deserializeArrowType(data.type),
17163
- data.offset,
17164
- data.length,
17165
- data.nullCount,
17166
- data.buffers,
17167
- children,
17168
- dictionary
17169
- );
17170
- }
17171
- function hydrateArrowVector(vector) {
17172
- return new Vector(vector.data.map((data) => hydrateArrowData(data)));
17173
- }
17174
- var init_arrow_table_transport = __esm({
17175
- "../core/src/schema-utils/lib/arrow/arrow-table-transport.ts"() {
17808
+ var init_arrow_worker_transport = __esm({
17809
+ "../core/src/arrow-worker-transport.ts"() {
17176
17810
  "use strict";
17177
- init_Arrow_dom();
17178
- init_convert_arrow_schema();
17179
- init_split_arrow_buffers();
17180
- }
17181
- });
17182
-
17183
- // ../core/src/schema-utils/arrow-transport.ts
17184
- var init_arrow_transport = __esm({
17185
- "../core/src/schema-utils/arrow-transport.ts"() {
17186
- "use strict";
17187
- init_arrow_table_transport();
17188
- init_split_arrow_buffers();
17811
+ init_dist2();
17189
17812
  }
17190
17813
  });
17191
17814
 
@@ -17226,7 +17849,7 @@ return true;`);
17226
17849
  var init_shapefile_worker_transport = __esm({
17227
17850
  "src/shapefile/lib/shapefile-worker-transport.ts"() {
17228
17851
  "use strict";
17229
- init_arrow_transport();
17852
+ init_arrow_worker_transport();
17230
17853
  serializeShapefileWorkerBatch = serializeShapefileWorkerResult;
17231
17854
  }
17232
17855
  });