@loaders.gl/pointclouds 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 (73) hide show
  1. package/LAS-README.md +1 -1
  2. package/PCD-README.md +1 -1
  3. package/PLY-README.md +1 -1
  4. package/README.md +1 -1
  5. package/dist/dist.dev.js +135 -91
  6. package/dist/dist.min.js +20 -20
  7. package/dist/las/las-loader-shared.cjs +1 -1
  8. package/dist/las/las-loader-shared.js +1 -1
  9. package/dist/las/las-loader-types.d.ts +2 -2
  10. package/dist/las/las-loader.cjs +4 -4
  11. package/dist/las/las-loader.cjs.map +2 -2
  12. package/dist/las/las-loader.d.ts +1 -1
  13. package/dist/las/las-loader.d.ts.map +1 -1
  14. package/dist/las/las-loader.js +1 -1
  15. package/dist/las/las-loader.js.map +1 -1
  16. package/dist/las/las-writer.cjs +1 -1
  17. package/dist/las/las-writer.js +1 -1
  18. package/dist/las/lib/las-extra-bytes.cjs +6 -1
  19. package/dist/las/lib/las-extra-bytes.cjs.map +2 -2
  20. package/dist/las/lib/las-extra-bytes.d.ts.map +1 -1
  21. package/dist/las/lib/las-extra-bytes.js +6 -4
  22. package/dist/las/lib/las-extra-bytes.js.map +1 -1
  23. package/dist/las-loader.cjs +4 -4
  24. package/dist/las-loader.cjs.map +2 -2
  25. package/dist/las-worker.js +704 -160
  26. package/dist/las-writer.cjs +1 -1
  27. package/dist/pcd/pcd-loader-types.cjs +3 -3
  28. package/dist/pcd/pcd-loader-types.cjs.map +2 -2
  29. package/dist/pcd/pcd-loader-types.d.ts +1 -1
  30. package/dist/pcd/pcd-loader-types.d.ts.map +1 -1
  31. package/dist/pcd/pcd-loader-types.js +2 -2
  32. package/dist/pcd/pcd-loader-types.js.map +1 -1
  33. package/dist/pcd/pcd-loader.cjs +4 -4
  34. package/dist/pcd/pcd-loader.cjs.map +2 -2
  35. package/dist/pcd/pcd-loader.d.ts +1 -1
  36. package/dist/pcd/pcd-loader.d.ts.map +1 -1
  37. package/dist/pcd/pcd-loader.js +1 -1
  38. package/dist/pcd/pcd-loader.js.map +1 -1
  39. package/dist/pcd/pcd-writer.cjs +1 -1
  40. package/dist/pcd/pcd-writer.js +1 -1
  41. package/dist/pcd-loader-types.cjs +3 -3
  42. package/dist/pcd-loader-types.cjs.map +2 -2
  43. package/dist/pcd-loader.cjs +4 -4
  44. package/dist/pcd-loader.cjs.map +2 -2
  45. package/dist/pcd-worker.js +984 -367
  46. package/dist/pcd-writer.cjs +1 -1
  47. package/dist/ply/ply-loader-types.cjs +3 -3
  48. package/dist/ply/ply-loader-types.cjs.map +2 -2
  49. package/dist/ply/ply-loader-types.d.ts +1 -1
  50. package/dist/ply/ply-loader-types.d.ts.map +1 -1
  51. package/dist/ply/ply-loader-types.js +2 -2
  52. package/dist/ply/ply-loader-types.js.map +1 -1
  53. package/dist/ply/ply-loader.cjs +4 -4
  54. package/dist/ply/ply-loader.cjs.map +2 -2
  55. package/dist/ply/ply-loader.d.ts +1 -1
  56. package/dist/ply/ply-loader.d.ts.map +1 -1
  57. package/dist/ply/ply-loader.js +1 -1
  58. package/dist/ply/ply-loader.js.map +1 -1
  59. package/dist/ply/ply-writer.cjs +1 -1
  60. package/dist/ply/ply-writer.js +1 -1
  61. package/dist/ply-loader-types.cjs +3 -3
  62. package/dist/ply-loader-types.cjs.map +2 -2
  63. package/dist/ply-loader.cjs +4 -4
  64. package/dist/ply-loader.cjs.map +2 -2
  65. package/dist/ply-worker.js +779 -162
  66. package/dist/ply-writer.cjs +1 -1
  67. package/package.json +4 -3
  68. package/src/las/las-loader.ts +1 -1
  69. package/src/las/lib/las-extra-bytes.ts +6 -4
  70. package/src/pcd/pcd-loader-types.ts +1 -1
  71. package/src/pcd/pcd-loader.ts +1 -1
  72. package/src/ply/ply-loader-types.ts +1 -1
  73. package/src/ply/ply-loader.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, preload2) {
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 preload2?.();
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,
@@ -904,7 +1482,7 @@
904
1482
  });
905
1483
 
906
1484
  // ../../node_modules/@math.gl/core/dist/index.js
907
- var init_dist = __esm({
1485
+ var init_dist2 = __esm({
908
1486
  "../../node_modules/@math.gl/core/dist/index.js"() {
909
1487
  init_math_utils();
910
1488
  init_types2();
@@ -8644,11 +9222,11 @@ return true;`);
8644
9222
  this._offsets = new OffsetsBufferBuilder(opts.type);
8645
9223
  }
8646
9224
  setValue(index, value) {
8647
- const pending = this._pending || (this._pending = /* @__PURE__ */ new Map());
8648
- const current = pending.get(index);
9225
+ const pending2 = this._pending || (this._pending = /* @__PURE__ */ new Map());
9226
+ const current = pending2.get(index);
8649
9227
  current && (this._pendingLength -= current.length);
8650
9228
  this._pendingLength += value instanceof MapRow ? value[kKeys].length : value.length;
8651
- pending.set(index, value);
9229
+ pending2.set(index, value);
8652
9230
  }
8653
9231
  setValid(index, isValid) {
8654
9232
  if (!super.setValid(index, isValid)) {
@@ -8671,12 +9249,12 @@ return true;`);
8671
9249
  return super.finish();
8672
9250
  }
8673
9251
  _flush() {
8674
- const pending = this._pending;
9252
+ const pending2 = this._pending;
8675
9253
  const pendingLength = this._pendingLength;
8676
9254
  this._pendingLength = 0;
8677
9255
  this._pending = void 0;
8678
- if (pending && pending.size > 0) {
8679
- this._flushPending(pending, pendingLength);
9256
+ if (pending2 && pending2.size > 0) {
9257
+ this._flushPending(pending2, pendingLength);
8680
9258
  }
8681
9259
  return this;
8682
9260
  }
@@ -11262,11 +11840,11 @@ return true;`);
11262
11840
  setValue(index, value) {
11263
11841
  return super.setValue(index, toUint8Array(value));
11264
11842
  }
11265
- _flushPending(pending, pendingLength) {
11843
+ _flushPending(pending2, pendingLength) {
11266
11844
  const offsets = this._offsets;
11267
11845
  const data = this._values.reserve(pendingLength).buffer;
11268
11846
  let offset = 0;
11269
- for (const [index, value] of pending) {
11847
+ for (const [index, value] of pending2) {
11270
11848
  if (value === void 0) {
11271
11849
  offsets.set(index, 0);
11272
11850
  } else {
@@ -11303,11 +11881,11 @@ return true;`);
11303
11881
  setValue(index, value) {
11304
11882
  return super.setValue(index, toUint8Array(value));
11305
11883
  }
11306
- _flushPending(pending, pendingLength) {
11884
+ _flushPending(pending2, pendingLength) {
11307
11885
  const offsets = this._offsets;
11308
11886
  const data = this._values.reserve(pendingLength).buffer;
11309
11887
  let offset = 0;
11310
- for (const [index, value] of pending) {
11888
+ for (const [index, value] of pending2) {
11311
11889
  if (value === void 0) {
11312
11890
  offsets.set(index, BigInt(0));
11313
11891
  } else {
@@ -11618,10 +12196,10 @@ return true;`);
11618
12196
  this.type = new List2(new Field2(name, child.type, true));
11619
12197
  return this.numChildren - 1;
11620
12198
  }
11621
- _flushPending(pending) {
12199
+ _flushPending(pending2) {
11622
12200
  const offsets = this._offsets;
11623
12201
  const [child] = this.children;
11624
- for (const [index, value] of pending) {
12202
+ for (const [index, value] of pending2) {
11625
12203
  if (typeof value === "undefined") {
11626
12204
  offsets.set(index, 0);
11627
12205
  } else {
@@ -11660,10 +12238,10 @@ return true;`);
11660
12238
  this.type = new LargeList2(new Field2(name, child.type, true));
11661
12239
  return this.numChildren - 1;
11662
12240
  }
11663
- _flushPending(pending) {
12241
+ _flushPending(pending2) {
11664
12242
  const offsets = this._offsets;
11665
12243
  const [child] = this.children;
11666
- for (const [index, value] of pending) {
12244
+ for (const [index, value] of pending2) {
11667
12245
  if (typeof value === "undefined") {
11668
12246
  offsets.set(index, BigInt(0));
11669
12247
  } else {
@@ -11693,11 +12271,11 @@ return true;`);
11693
12271
  }
11694
12272
  setValue(index, value) {
11695
12273
  const row = value instanceof Map ? value : new Map(Object.entries(value));
11696
- const pending = this._pending || (this._pending = /* @__PURE__ */ new Map());
11697
- const current = pending.get(index);
12274
+ const pending2 = this._pending || (this._pending = /* @__PURE__ */ new Map());
12275
+ const current = pending2.get(index);
11698
12276
  current && (this._pendingLength -= current.size);
11699
12277
  this._pendingLength += row.size;
11700
- pending.set(index, row);
12278
+ pending2.set(index, row);
11701
12279
  }
11702
12280
  addChild(child, name = `${this.numChildren}`) {
11703
12281
  if (this.numChildren > 0) {
@@ -11707,10 +12285,10 @@ return true;`);
11707
12285
  this.type = new Map_(new Field2(name, child.type, true), this.type.keysSorted);
11708
12286
  return this.numChildren - 1;
11709
12287
  }
11710
- _flushPending(pending) {
12288
+ _flushPending(pending2) {
11711
12289
  const offsets = this._offsets;
11712
12290
  const [child] = this.children;
11713
- for (const [index, value] of pending) {
12291
+ for (const [index, value] of pending2) {
11714
12292
  if (value === void 0) {
11715
12293
  offsets.set(index, 0);
11716
12294
  } else {
@@ -11919,7 +12497,7 @@ return true;`);
11919
12497
  return super.setValue(index, encodeUtf8(value));
11920
12498
  }
11921
12499
  // @ts-ignore
11922
- _flushPending(pending, pendingLength) {
12500
+ _flushPending(pending2, pendingLength) {
11923
12501
  }
11924
12502
  };
11925
12503
  Utf8Builder.prototype._flushPending = BinaryBuilder.prototype._flushPending;
@@ -11950,7 +12528,7 @@ return true;`);
11950
12528
  return super.setValue(index, encodeUtf8(value));
11951
12529
  }
11952
12530
  // @ts-ignore
11953
- _flushPending(pending, pendingLength) {
12531
+ _flushPending(pending2, pendingLength) {
11954
12532
  }
11955
12533
  };
11956
12534
  LargeUtf8Builder.prototype._flushPending = LargeBinaryBuilder.prototype._flushPending;
@@ -13662,8 +14240,8 @@ return true;`);
13662
14240
  });
13663
14241
 
13664
14242
  // ../../node_modules/apache-arrow/ipc/reader.mjs
13665
- function shouldAutoDestroy(self, options) {
13666
- return options && typeof options["autoDestroy"] === "boolean" ? options["autoDestroy"] : self["autoDestroy"];
14243
+ function shouldAutoDestroy(self2, options) {
14244
+ return options && typeof options["autoDestroy"] === "boolean" ? options["autoDestroy"] : self2["autoDestroy"];
13667
14245
  }
13668
14246
  function* readAllSync(source) {
13669
14247
  const reader = RecordBatchReader.from(source);
@@ -15901,12 +16479,6 @@ return true;`);
15901
16479
  metadata: serializeArrowMetadata(arrowSchema.metadata)
15902
16480
  };
15903
16481
  }
15904
- function deserializeArrowSchema(schema, options) {
15905
- return new Schema2(
15906
- schema.fields.map((field) => deserializeArrowField(field, options)),
15907
- deserializeArrowMetadata(schema.metadata)
15908
- );
15909
- }
15910
16482
  function serializeArrowMetadata(arrowMetadata) {
15911
16483
  return Object.fromEntries(arrowMetadata);
15912
16484
  }
@@ -16440,7 +17012,7 @@ return true;`);
16440
17012
  var init_float162 = __esm({
16441
17013
  "../core/src/schema/float16.ts"() {
16442
17014
  "use strict";
16443
- init_dist();
17015
+ init_dist2();
16444
17016
  }
16445
17017
  });
16446
17018
 
@@ -16940,7 +17512,29 @@ return true;`);
16940
17512
  }
16941
17513
  });
16942
17514
 
16943
- // ../core/src/schema-utils/lib/arrow/split-arrow-buffers.ts
17515
+ // ../../node_modules/@math.gl/arrow/dist/arrow/arrow-data.js
17516
+ function getArrowVariadicBuffers(data) {
17517
+ return data.variadicBuffers ?? [];
17518
+ }
17519
+ function createArrowData(type, offset, length, nullCount, buffers, children, dictionary, variadicBuffers) {
17520
+ return Reflect.construct(Data, [
17521
+ type,
17522
+ offset,
17523
+ length,
17524
+ nullCount,
17525
+ buffers,
17526
+ children,
17527
+ dictionary,
17528
+ variadicBuffers
17529
+ ]);
17530
+ }
17531
+ var init_arrow_data = __esm({
17532
+ "../../node_modules/@math.gl/arrow/dist/arrow/arrow-data.js"() {
17533
+ init_Arrow_dom();
17534
+ }
17535
+ });
17536
+
17537
+ // ../../node_modules/@math.gl/arrow/dist/arrow/split-arrow-buffers.js
16944
17538
  function splitArrowBuffers(input, options = {}) {
16945
17539
  const context = { ...options, copies: /* @__PURE__ */ new WeakMap() };
16946
17540
  if (isArrowTable2(input)) {
@@ -16963,17 +17557,12 @@ return true;`);
16963
17557
  function isArrowVector2(input) {
16964
17558
  return "data" in input && Array.isArray(input.data);
16965
17559
  }
16966
- function splitArrowTableBuffersInternal(table, options) {
16967
- const recordBatches = table.batches.map(
16968
- (recordBatch) => splitArrowRecordBatchBuffers(recordBatch, options)
16969
- );
16970
- return new Table(table.schema, recordBatches);
17560
+ function splitArrowTableBuffersInternal(arrowTable, options) {
17561
+ const recordBatches = arrowTable.batches.map((recordBatch) => splitArrowRecordBatchBuffers(recordBatch, options));
17562
+ return new Table(arrowTable.schema, recordBatches);
16971
17563
  }
16972
17564
  function splitArrowRecordBatchBuffers(recordBatch, options) {
16973
- return new RecordBatch3(
16974
- recordBatch.schema,
16975
- splitArrowDataBuffers(recordBatch.data, options)
16976
- );
17565
+ return new RecordBatch3(recordBatch.schema, splitArrowDataBuffers(recordBatch.data, options));
16977
17566
  }
16978
17567
  function splitArrowDataBuffers(data, options) {
16979
17568
  const children = data.children.map((childData) => splitArrowDataBuffers(childData, options));
@@ -16984,7 +17573,7 @@ return true;`);
16984
17573
  [BufferType.VALIDITY]: splitArrowBuffer(data.buffers[BufferType.VALIDITY], options),
16985
17574
  [BufferType.TYPE]: splitArrowBuffer(data.buffers[BufferType.TYPE], options)
16986
17575
  };
16987
- return new Data(
17576
+ return createArrowData(
16988
17577
  data.type,
16989
17578
  data.offset,
16990
17579
  data.length,
@@ -16992,7 +17581,8 @@ return true;`);
16992
17581
  data._nullCount,
16993
17582
  buffers,
16994
17583
  children,
16995
- dictionary
17584
+ dictionary,
17585
+ getArrowVariadicBuffers(data).map((buffer) => splitArrowBuffer(buffer, options))
16996
17586
  );
16997
17587
  }
16998
17588
  function splitArrowVectorBuffers(vector, options) {
@@ -17010,7 +17600,7 @@ return true;`);
17010
17600
  }
17011
17601
  let copy = options.copies.get(array);
17012
17602
  if (!copy) {
17013
- copy = array.slice();
17603
+ copy = array instanceof Uint8Array ? new Uint8Array(array) : array.slice();
17014
17604
  options.copies.set(array, copy);
17015
17605
  }
17016
17606
  return copy;
@@ -17019,29 +17609,106 @@ return true;`);
17019
17609
  return ArrayBuffer.isView(value) && !(value instanceof DataView);
17020
17610
  }
17021
17611
  var init_split_arrow_buffers = __esm({
17022
- "../core/src/schema-utils/lib/arrow/split-arrow-buffers.ts"() {
17023
- "use strict";
17612
+ "../../node_modules/@math.gl/arrow/dist/arrow/split-arrow-buffers.js"() {
17024
17613
  init_Arrow_dom();
17614
+ init_arrow_data();
17025
17615
  }
17026
17616
  });
17027
17617
 
17028
- // ../core/src/schema-utils/lib/arrow/arrow-table-transport.ts
17029
- function dehydrateArrowTable(table, options) {
17030
- const splitTable = splitArrowBuffers(table, options);
17618
+ // ../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-vector.js
17619
+ var init_indexed_arrow_vector = __esm({
17620
+ "../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-vector.js"() {
17621
+ }
17622
+ });
17623
+
17624
+ // ../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-table.js
17625
+ var init_indexed_arrow_table = __esm({
17626
+ "../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-table.js"() {
17627
+ }
17628
+ });
17629
+
17630
+ // ../../node_modules/@math.gl/arrow/dist/arrow/mapped-arrow-table.js
17631
+ var init_mapped_arrow_table = __esm({
17632
+ "../../node_modules/@math.gl/arrow/dist/arrow/mapped-arrow-table.js"() {
17633
+ }
17634
+ });
17635
+
17636
+ // ../../node_modules/@math.gl/arrow/dist/arrow/rename-arrow-columns.js
17637
+ var init_rename_arrow_columns = __esm({
17638
+ "../../node_modules/@math.gl/arrow/dist/arrow/rename-arrow-columns.js"() {
17639
+ }
17640
+ });
17641
+
17642
+ // ../../node_modules/@math.gl/arrow/dist/arrow/arrow-table-transport.js
17643
+ function dehydrateArrowTable(arrowTable, options) {
17644
+ const splitTable = splitArrowBuffers(arrowTable, options);
17031
17645
  return {
17032
- shape: "arrow-table",
17033
17646
  transport: "arrow-js",
17034
- schema: serializeArrowSchema(splitTable.schema),
17035
- batches: splitTable.batches.map((recordBatch) => dehydrateArrowRecordBatch(recordBatch))
17647
+ version: 1,
17648
+ schema: tableToIPC(new Table(splitTable.schema, [])),
17649
+ metadataVersion: splitTable.schema.metadataVersion,
17650
+ batches: splitTable.batches.map((batch) => dehydrateArrowData(batch.data))
17036
17651
  };
17037
17652
  }
17038
17653
  function hydrateArrowTable(table) {
17039
- const schema = deserializeArrowSchema(table.schema);
17040
- const recordBatches = table.batches.map(
17041
- (recordBatch) => new RecordBatch3(schema, hydrateArrowData(recordBatch.data))
17042
- );
17043
- return new Table(schema, recordBatches);
17654
+ if (table.transport !== "arrow-js" || table.version !== 1) {
17655
+ throw new Error("Unsupported Arrow column-buffer transport protocol.");
17656
+ }
17657
+ const decodedSchema = tableFromIPC(table.schema).schema;
17658
+ const schema = new Schema2(decodedSchema.fields, decodedSchema.metadata, decodedSchema.dictionaries, table.metadataVersion);
17659
+ const type = new Struct(schema.fields);
17660
+ const batches = table.batches.map((data) => new RecordBatch3(schema, hydrateArrowData(data, type)));
17661
+ return new Table(schema, batches);
17662
+ }
17663
+ function dehydrateArrowData(data) {
17664
+ return {
17665
+ offset: data.offset,
17666
+ length: data.length,
17667
+ nullCount: data.nullCount,
17668
+ buffers: {
17669
+ [BufferType.OFFSET]: data.buffers[BufferType.OFFSET],
17670
+ [BufferType.DATA]: data.buffers[BufferType.DATA],
17671
+ [BufferType.VALIDITY]: data.buffers[BufferType.VALIDITY],
17672
+ [BufferType.TYPE]: data.buffers[BufferType.TYPE]
17673
+ },
17674
+ children: data.children.map((child) => dehydrateArrowData(child)),
17675
+ variadicBuffers: getArrowVariadicBuffers(data),
17676
+ dictionary: data.dictionary?.data.map((chunk) => dehydrateArrowData(chunk))
17677
+ };
17678
+ }
17679
+ function hydrateArrowData(data, type) {
17680
+ const children = data.children.map((child, index) => hydrateArrowData(child, type.children[index].type));
17681
+ const dictionary = data.dictionary && DataType.isDictionary(type) ? new Vector(data.dictionary.map((chunk) => hydrateArrowData(chunk, type.dictionary))) : void 0;
17682
+ return createArrowData(type, data.offset, data.length, data.nullCount, data.buffers, children, dictionary, data.variadicBuffers);
17044
17683
  }
17684
+ var init_arrow_table_transport = __esm({
17685
+ "../../node_modules/@math.gl/arrow/dist/arrow/arrow-table-transport.js"() {
17686
+ init_Arrow_dom();
17687
+ init_arrow_data();
17688
+ init_split_arrow_buffers();
17689
+ }
17690
+ });
17691
+
17692
+ // ../../node_modules/@math.gl/arrow/dist/arrow/index.js
17693
+ var init_arrow = __esm({
17694
+ "../../node_modules/@math.gl/arrow/dist/arrow/index.js"() {
17695
+ init_indexed_arrow_table();
17696
+ init_indexed_arrow_vector();
17697
+ init_mapped_arrow_table();
17698
+ init_rename_arrow_columns();
17699
+ init_split_arrow_buffers();
17700
+ init_arrow_table_transport();
17701
+ }
17702
+ });
17703
+
17704
+ // ../../node_modules/@math.gl/arrow/dist/index.js
17705
+ var init_dist3 = __esm({
17706
+ "../../node_modules/@math.gl/arrow/dist/index.js"() {
17707
+ init_arrow();
17708
+ }
17709
+ });
17710
+
17711
+ // ../core/src/arrow-worker-transport.ts
17045
17712
  function serializeArrowWorkerTable(result) {
17046
17713
  if (!isArrowTableWrapper(result)) {
17047
17714
  throw new Error("Workers require Arrow table output");
@@ -17070,60 +17737,10 @@ return true;`);
17070
17737
  table && table.shape === "arrow-table" && table.data && table.data.transport === "arrow-js" && Array.isArray(table.data.batches)
17071
17738
  );
17072
17739
  }
17073
- function dehydrateArrowRecordBatch(recordBatch) {
17074
- return { data: dehydrateArrowData(recordBatch.data) };
17075
- }
17076
- function dehydrateArrowData(data) {
17077
- return {
17078
- type: serializeArrowType(data.type),
17079
- offset: data.offset,
17080
- length: data.length,
17081
- // @ts-expect-error _nullCount is protected. Preserve the Arrow lazy null-count state.
17082
- nullCount: data._nullCount,
17083
- buffers: {
17084
- [BufferType.OFFSET]: data.buffers[BufferType.OFFSET],
17085
- [BufferType.DATA]: data.buffers[BufferType.DATA],
17086
- [BufferType.VALIDITY]: data.buffers[BufferType.VALIDITY],
17087
- [BufferType.TYPE]: data.buffers[BufferType.TYPE]
17088
- },
17089
- children: data.children.map((childData) => dehydrateArrowData(childData)),
17090
- dictionary: data.dictionary ? dehydrateArrowVector(data.dictionary) : void 0
17091
- };
17092
- }
17093
- function dehydrateArrowVector(vector) {
17094
- return { data: vector.data.map((data) => dehydrateArrowData(data)) };
17095
- }
17096
- function hydrateArrowData(data) {
17097
- const children = data.children.map((childData) => hydrateArrowData(childData));
17098
- const dictionary = data.dictionary ? hydrateArrowVector(data.dictionary) : void 0;
17099
- return new Data(
17100
- deserializeArrowType(data.type),
17101
- data.offset,
17102
- data.length,
17103
- data.nullCount,
17104
- data.buffers,
17105
- children,
17106
- dictionary
17107
- );
17108
- }
17109
- function hydrateArrowVector(vector) {
17110
- return new Vector(vector.data.map((data) => hydrateArrowData(data)));
17111
- }
17112
- var init_arrow_table_transport = __esm({
17113
- "../core/src/schema-utils/lib/arrow/arrow-table-transport.ts"() {
17114
- "use strict";
17115
- init_Arrow_dom();
17116
- init_convert_arrow_schema();
17117
- init_split_arrow_buffers();
17118
- }
17119
- });
17120
-
17121
- // ../core/src/schema-utils/arrow-transport.ts
17122
- var init_arrow_transport = __esm({
17123
- "../core/src/schema-utils/arrow-transport.ts"() {
17740
+ var init_arrow_worker_transport = __esm({
17741
+ "../core/src/arrow-worker-transport.ts"() {
17124
17742
  "use strict";
17125
- init_arrow_table_transport();
17126
- init_split_arrow_buffers();
17743
+ init_dist3();
17127
17744
  }
17128
17745
  });
17129
17746
 
@@ -19138,8 +19755,8 @@ return true;`);
19138
19755
  "src/ply/ply-loader-types.ts"() {
19139
19756
  "use strict";
19140
19757
  init_ply_format();
19141
- init_arrow_transport();
19142
- VERSION = true ? "5.0.0-beta.2" : "latest";
19758
+ init_arrow_worker_transport();
19759
+ VERSION = true ? "5.0.0-beta.5" : "latest";
19143
19760
  PLYLoader = {
19144
19761
  dataType: null,
19145
19762
  batchType: null,
@@ -19244,7 +19861,7 @@ return true;`);
19244
19861
  "use strict";
19245
19862
  init_loader_utils();
19246
19863
  init_schema3();
19247
- init_arrow_transport();
19864
+ init_arrow_worker_transport();
19248
19865
  init_schema_utils();
19249
19866
  init_parse_ply();
19250
19867
  init_parse_ply_arrow();