@loaders.gl/scene 5.0.0-beta.4 → 5.0.0-beta.6

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 (177) hide show
  1. package/DRACO-README.md +1 -1
  2. package/GLTF-README.md +1 -1
  3. package/OBJ-README.md +1 -1
  4. package/README.md +6 -1
  5. package/THIRD-PARTY-NOTICES.md +6 -0
  6. package/dist/dist.dev.js +2959 -750
  7. package/dist/dist.min.js +18 -18
  8. package/dist/draco/draco-javascript-loader-with-parser.d.ts +2 -2
  9. package/dist/draco/draco-loader-types.cjs +3 -3
  10. package/dist/draco/draco-loader-types.cjs.map +2 -2
  11. package/dist/draco/draco-loader-types.d.ts +1 -1
  12. package/dist/draco/draco-loader-types.d.ts.map +1 -1
  13. package/dist/draco/draco-loader-types.js +1 -1
  14. package/dist/draco/draco-loader-types.js.map +1 -1
  15. package/dist/draco/draco-loader.d.ts +2 -2
  16. package/dist/draco/draco-wasm-loader-with-parser.d.ts +2 -2
  17. package/dist/draco/draco3d-loader-with-parser.d.ts +2 -2
  18. package/dist/draco/lib/utils/version.cjs +1 -1
  19. package/dist/draco/lib/utils/version.js +1 -1
  20. package/dist/draco-worker-node.js +401 -113
  21. package/dist/draco-worker-node.js.map +4 -4
  22. package/dist/draco-worker.js +395 -113
  23. package/dist/draco-worker.js.map +4 -4
  24. package/dist/draco-writer-worker-node.cjs +655 -85
  25. package/dist/draco-writer-worker-node.cjs.map +4 -4
  26. package/dist/draco-writer-worker.js +625 -69
  27. package/dist/draco-writer-worker.js.map +4 -4
  28. package/dist/gltf/lib/extensions/KHR_gaussian_splatting.cjs +11 -4
  29. package/dist/gltf/lib/extensions/KHR_gaussian_splatting.cjs.map +2 -2
  30. package/dist/gltf/lib/extensions/KHR_gaussian_splatting.d.ts.map +1 -1
  31. package/dist/gltf/lib/extensions/KHR_gaussian_splatting.js +12 -2
  32. package/dist/gltf/lib/extensions/KHR_gaussian_splatting.js.map +1 -1
  33. package/dist/gltf/lib/parsers/parse-gltf.cjs.map +2 -2
  34. package/dist/gltf/lib/parsers/parse-gltf.d.ts +2 -0
  35. package/dist/gltf/lib/parsers/parse-gltf.d.ts.map +1 -1
  36. package/dist/gltf/lib/parsers/parse-gltf.js.map +1 -1
  37. package/dist/gltf/lib/types/gltf-additional-extension-schemas.cjs +22 -0
  38. package/dist/gltf/lib/types/gltf-additional-extension-schemas.cjs.map +2 -2
  39. package/dist/gltf/lib/types/gltf-additional-extension-schemas.d.ts +23 -0
  40. package/dist/gltf/lib/types/gltf-additional-extension-schemas.d.ts.map +1 -1
  41. package/dist/gltf/lib/types/gltf-additional-extension-schemas.js +22 -0
  42. package/dist/gltf/lib/types/gltf-additional-extension-schemas.js.map +1 -1
  43. package/dist/gltf/lib/types/gltf-extension-schemas.cjs +8 -0
  44. package/dist/gltf/lib/types/gltf-extension-schemas.cjs.map +2 -2
  45. package/dist/gltf/lib/types/gltf-extension-schemas.d.ts +27 -0
  46. package/dist/gltf/lib/types/gltf-extension-schemas.d.ts.map +1 -1
  47. package/dist/gltf/lib/types/gltf-extension-schemas.js +8 -1
  48. package/dist/gltf/lib/types/gltf-extension-schemas.js.map +1 -1
  49. package/dist/gltf/lib/types/gltf-json-schema.cjs.map +1 -1
  50. package/dist/gltf/lib/types/gltf-json-schema.d.ts +2 -2
  51. package/dist/gltf/lib/types/gltf-json-schema.d.ts.map +1 -1
  52. package/dist/gltf/lib/types/gltf-version-zod-schemas.d.ts +34 -0
  53. package/dist/gltf/lib/types/gltf-version-zod-schemas.d.ts.map +1 -1
  54. package/dist/gltf/lib/types/gltf-zod-schema.cjs +1 -1
  55. package/dist/gltf/lib/types/gltf-zod-schema.cjs.map +2 -2
  56. package/dist/gltf/lib/types/gltf-zod-schema.d.ts +51 -0
  57. package/dist/gltf/lib/types/gltf-zod-schema.d.ts.map +1 -1
  58. package/dist/gltf/lib/types/gltf-zod-schema.js +2 -2
  59. package/dist/gltf/lib/types/gltf-zod-schema.js.map +1 -1
  60. package/dist/gltf/lib/utils/version.cjs +1 -1
  61. package/dist/gltf/lib/utils/version.js +1 -1
  62. package/dist/index.cjs +4 -1
  63. package/dist/index.cjs.map +2 -2
  64. package/dist/index.d.ts +1 -0
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +2 -1
  67. package/dist/index.js.map +1 -1
  68. package/dist/mtl-loader-types.cjs +1 -1
  69. package/dist/obj/mtl-loader-types.cjs +1 -1
  70. package/dist/obj/mtl-loader-types.js +1 -1
  71. package/dist/obj/obj-loader-types.cjs +3 -3
  72. package/dist/obj/obj-loader-types.cjs.map +2 -2
  73. package/dist/obj/obj-loader-types.d.ts +1 -1
  74. package/dist/obj/obj-loader-types.d.ts.map +1 -1
  75. package/dist/obj/obj-loader-types.js +2 -2
  76. package/dist/obj/obj-loader-types.js.map +1 -1
  77. package/dist/obj/obj-loader.cjs +5 -5
  78. package/dist/obj/obj-loader.cjs.map +2 -2
  79. package/dist/obj/obj-loader.d.ts +1 -1
  80. package/dist/obj/obj-loader.d.ts.map +1 -1
  81. package/dist/obj/obj-loader.js +1 -1
  82. package/dist/obj/obj-loader.js.map +1 -1
  83. package/dist/obj/obj-writer.cjs +1 -1
  84. package/dist/obj/obj-writer.js +1 -1
  85. package/dist/obj-loader-types.cjs +3 -3
  86. package/dist/obj-loader-types.cjs.map +2 -2
  87. package/dist/obj-loader.cjs +5 -5
  88. package/dist/obj-loader.cjs.map +2 -2
  89. package/dist/obj-worker.js +568 -287
  90. package/dist/obj-writer.cjs +1 -1
  91. package/dist/stl/parse-stl.cjs +100 -0
  92. package/dist/stl/parse-stl.cjs.map +7 -0
  93. package/dist/stl/parse-stl.d.ts +4 -0
  94. package/dist/stl/parse-stl.d.ts.map +1 -0
  95. package/dist/stl/parse-stl.js +84 -0
  96. package/dist/stl/parse-stl.js.map +1 -0
  97. package/dist/stl-loader-types.cjs +58 -0
  98. package/dist/stl-loader-types.cjs.map +7 -0
  99. package/dist/stl-loader-types.d.ts +32 -0
  100. package/dist/stl-loader-types.d.ts.map +1 -0
  101. package/dist/stl-loader-types.js +25 -0
  102. package/dist/stl-loader-types.js.map +1 -0
  103. package/dist/stl-loader.cjs +38 -0
  104. package/dist/stl-loader.cjs.map +7 -0
  105. package/dist/stl-loader.d.ts +17 -0
  106. package/dist/stl-loader.d.ts.map +1 -0
  107. package/dist/stl-loader.js +13 -0
  108. package/dist/stl-loader.js.map +1 -0
  109. package/dist/usd/index.cjs.map +1 -1
  110. package/dist/usd/index.d.ts +1 -1
  111. package/dist/usd/index.d.ts.map +1 -1
  112. package/dist/usd/lib/parse-usd.cjs +42 -5
  113. package/dist/usd/lib/parse-usd.cjs.map +2 -2
  114. package/dist/usd/lib/parse-usd.d.ts.map +1 -1
  115. package/dist/usd/lib/parse-usd.js +53 -6
  116. package/dist/usd/lib/parse-usd.js.map +1 -1
  117. package/dist/usd/lib/parse-usdc.cjs +187 -0
  118. package/dist/usd/lib/parse-usdc.cjs.map +7 -0
  119. package/dist/usd/lib/parse-usdc.d.ts +4 -0
  120. package/dist/usd/lib/parse-usdc.d.ts.map +1 -0
  121. package/dist/usd/lib/parse-usdc.js +176 -0
  122. package/dist/usd/lib/parse-usdc.js.map +1 -0
  123. package/dist/usd/lib/parse-usdz.cjs +22 -0
  124. package/dist/usd/lib/parse-usdz.cjs.map +2 -2
  125. package/dist/usd/lib/parse-usdz.d.ts.map +1 -1
  126. package/dist/usd/lib/parse-usdz.js +26 -0
  127. package/dist/usd/lib/parse-usdz.js.map +1 -1
  128. package/dist/usd/lib/usd-types.cjs.map +1 -1
  129. package/dist/usd/lib/usd-types.d.ts +14 -1
  130. package/dist/usd/lib/usd-types.d.ts.map +1 -1
  131. package/dist/usd/lib/usd-types.js +1 -1
  132. package/dist/usd/lib/usd-types.js.map +1 -1
  133. package/dist/usd/libs/README.md +27 -0
  134. package/dist/usd/libs/THREE-LICENSE +21 -0
  135. package/dist/usd/libs/usdc-parser.d.ts +78 -0
  136. package/dist/usd/libs/usdc-parser.d.ts.map +1 -0
  137. package/dist/usd/libs/usdc-parser.js +1669 -0
  138. package/dist/usd/libs/usdc-parser.js.map +1 -0
  139. package/dist/usd/usd-loader-types.cjs +4 -4
  140. package/dist/usd/usd-loader-types.cjs.map +2 -2
  141. package/dist/usd/usd-loader-types.d.ts +7 -7
  142. package/dist/usd/usd-loader-types.d.ts.map +1 -1
  143. package/dist/usd/usd-loader-types.js +6 -6
  144. package/dist/usd/usd-loader-types.js.map +1 -1
  145. package/dist/usd/usd-loader.cjs.map +1 -1
  146. package/dist/usd/usd-loader.d.ts +4 -4
  147. package/dist/usd/usd-loader.d.ts.map +1 -1
  148. package/dist/usd/usd-loader.js +2 -2
  149. package/dist/usd/usd-loader.js.map +1 -1
  150. package/dist/usd-loader-types.cjs +4 -4
  151. package/dist/usd-loader-types.cjs.map +2 -2
  152. package/dist/usd-loader.cjs.map +1 -1
  153. package/package.json +14 -8
  154. package/src/draco/draco-loader-types.ts +1 -1
  155. package/src/gltf/lib/extensions/KHR_gaussian_splatting.ts +14 -4
  156. package/src/gltf/lib/parsers/parse-gltf.ts +2 -0
  157. package/src/gltf/lib/types/gltf-additional-extension-schemas.ts +32 -0
  158. package/src/gltf/lib/types/gltf-extension-schemas.ts +12 -0
  159. package/src/gltf/lib/types/gltf-json-schema.ts +2 -1
  160. package/src/gltf/lib/types/gltf-zod-schema.ts +2 -1
  161. package/src/index.ts +3 -1
  162. package/src/obj/obj-loader-types.ts +1 -1
  163. package/src/obj/obj-loader.ts +1 -1
  164. package/src/stl/parse-stl.ts +90 -0
  165. package/src/stl-loader-types.ts +28 -0
  166. package/src/stl-loader.ts +12 -0
  167. package/src/usd/index.ts +1 -0
  168. package/src/usd/lib/parse-usd.ts +68 -7
  169. package/src/usd/lib/parse-usdc.ts +188 -0
  170. package/src/usd/lib/parse-usdz.ts +28 -0
  171. package/src/usd/lib/usd-types.ts +16 -2
  172. package/src/usd/libs/README.md +27 -0
  173. package/src/usd/libs/THREE-LICENSE +21 -0
  174. package/src/usd/libs/usdc-parser.d.ts +18 -0
  175. package/src/usd/libs/usdc-parser.js +1669 -0
  176. package/src/usd/usd-loader-types.ts +5 -5
  177. package/src/usd/usd-loader.ts +2 -2
@@ -15,15 +15,15 @@
15
15
  __defProp(target, name, { get: all[name], enumerable: true });
16
16
  };
17
17
 
18
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/node/worker_threads-browser.js
18
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js
19
19
  var parentPort;
20
20
  var init_worker_threads_browser = __esm({
21
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/node/worker_threads-browser.js"() {
21
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js"() {
22
22
  parentPort = globalThis.process?.getBuiltinModule?.("node:worker_threads")?.parentPort ?? null;
23
23
  }
24
24
  });
25
25
 
26
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-utils/get-transfer-list.js
26
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js
27
27
  function getTransferList(object, recursive = true, transfers) {
28
28
  const transfersSet = transfers || /* @__PURE__ */ new Set();
29
29
  const seen = /* @__PURE__ */ new Set();
@@ -74,11 +74,11 @@
74
74
  return false;
75
75
  }
76
76
  var init_get_transfer_list = __esm({
77
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-utils/get-transfer-list.js"() {
77
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js"() {
78
78
  }
79
79
  });
80
80
 
81
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-farm/worker-body.js
81
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-body.js
82
82
  async function getParentPort() {
83
83
  return parentPort;
84
84
  }
@@ -91,7 +91,7 @@
91
91
  }
92
92
  var onMessageWrapperMap, WorkerBody;
93
93
  var init_worker_body = __esm({
94
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-farm/worker-body.js"() {
94
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-body.js"() {
95
95
  init_get_transfer_list();
96
96
  init_worker_threads_browser();
97
97
  onMessageWrapperMap = /* @__PURE__ */ new Map();
@@ -172,10 +172,10 @@
172
172
  }
173
173
  });
174
174
 
175
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/async-queue/async-queue.js
175
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js
176
176
  var AsyncQueue;
177
177
  var init_async_queue = __esm({
178
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/async-queue/async-queue.js"() {
178
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js"() {
179
179
  AsyncQueue = class {
180
180
  constructor() {
181
181
  this._values = [];
@@ -244,10 +244,10 @@
244
244
  }
245
245
  });
246
246
 
247
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/shared-state.js
247
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js
248
248
  var SharedWorkerState;
249
249
  var init_shared_state = __esm({
250
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/shared-state.js"() {
250
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js"() {
251
251
  SharedWorkerState = class {
252
252
  constructor(buffer) {
253
253
  if (typeof SharedArrayBuffer === "undefined" || !(buffer instanceof SharedArrayBuffer) || buffer.byteLength !== 16)
@@ -288,18 +288,18 @@
288
288
  }
289
289
  });
290
290
 
291
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/validate-output-ownership.js
291
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js
292
292
  function validateOutputOwnership(ownership) {
293
293
  if (ownership !== void 0 && ownership !== "copy" && ownership !== "transfer") {
294
294
  throw new Error("Invalid worker output ownership");
295
295
  }
296
296
  }
297
297
  var init_validate_output_ownership = __esm({
298
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/validate-output-ownership.js"() {
298
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js"() {
299
299
  }
300
300
  });
301
301
 
302
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/create-worker.js
302
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/create-worker.js
303
303
  async function createWorker(process2, processInBatches, preload2) {
304
304
  if (!await WorkerBody.inWorkerThread()) {
305
305
  return;
@@ -504,7 +504,7 @@
504
504
  }
505
505
  var requestId, activeController, activeInputBatches, activeOutputAcknowledgements;
506
506
  var init_create_worker = __esm({
507
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/create-worker.js"() {
507
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/create-worker.js"() {
508
508
  init_shared_state();
509
509
  init_async_queue();
510
510
  init_worker_body();
@@ -516,19 +516,20 @@
516
516
  }
517
517
  });
518
518
 
519
- // ../../node_modules/@math.gl/core/dist/worker-utils/index.js
519
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/index.js
520
520
  var import_meta, path, moduleUrl;
521
521
  var init_worker_utils = __esm({
522
- "../../node_modules/@math.gl/core/dist/worker-utils/index.js"() {
522
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/index.js"() {
523
523
  init_worker_body();
524
524
  init_create_worker();
525
+ init_get_transfer_list();
525
526
  import_meta = {};
526
527
  path = typeof __filename === "string" ? __filename.replace(/\\/g, "/") : "";
527
528
  moduleUrl = path ? `file://${path.startsWith("/") ? "" : "/"}${encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F")}` : import_meta.url;
528
529
  }
529
530
  });
530
531
 
531
- // ../../node_modules/@math.gl/core/dist/tasks/task-preload.js
532
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js
532
533
  function preloadTaskCode(task, signal) {
533
534
  if (!task.preload)
534
535
  return Promise.resolve();
@@ -564,23 +565,193 @@
564
565
  }
565
566
  var pending, loaded;
566
567
  var init_task_preload = __esm({
567
- "../../node_modules/@math.gl/core/dist/tasks/task-preload.js"() {
568
+ "../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js"() {
568
569
  pending = /* @__PURE__ */ new WeakMap();
569
570
  loaded = /* @__PURE__ */ new WeakSet();
570
571
  }
571
572
  });
572
573
 
573
- // ../../node_modules/@math.gl/core/dist/tasks/task-runtime.js
574
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js
575
+ var TaskRequestError, TaskChannel;
576
+ var init_task_channel = __esm({
577
+ "../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js"() {
578
+ TaskRequestError = class extends Error {
579
+ };
580
+ TaskChannel = class {
581
+ constructor(options) {
582
+ this.options = options;
583
+ this.nextId = 1;
584
+ this.pending = /* @__PURE__ */ new Map();
585
+ this.incoming = /* @__PURE__ */ new Map();
586
+ }
587
+ /** Send a request without serializing other in-flight requests. */
588
+ request(operation, value, signal, transfer = []) {
589
+ if (this.failure)
590
+ return Promise.reject(this.failure.reason);
591
+ if (signal?.aborted)
592
+ return Promise.reject(signal.reason);
593
+ const id = this.nextId++;
594
+ return new Promise((resolve, reject) => {
595
+ const abort = () => {
596
+ const pending2 = this.pending.get(id);
597
+ if (!pending2)
598
+ return;
599
+ this.pending.delete(id);
600
+ pending2.cleanup();
601
+ reject(signal?.reason);
602
+ this.send({ source: "math.gl/tasks", kind: "cancel", id });
603
+ };
604
+ this.pending.set(id, {
605
+ resolve,
606
+ reject,
607
+ cleanup: () => signal?.removeEventListener("abort", abort)
608
+ });
609
+ signal?.addEventListener("abort", abort, { once: true });
610
+ this.send({ source: "math.gl/tasks", kind: "request", id, operation, value }, transfer);
611
+ });
612
+ }
613
+ /** Send a one-way notification. */
614
+ emit(operation, value, transfer = []) {
615
+ if (this.failure)
616
+ throw this.failure.reason;
617
+ this.send({ source: "math.gl/tasks", kind: "event", id: 0, operation, value }, transfer);
618
+ }
619
+ /** Dispatch a transport message; unrelated protocols are ignored. */
620
+ receive(message) {
621
+ if (this.failure || message?.source !== "math.gl/tasks")
622
+ return;
623
+ if (message.kind === "failure") {
624
+ const reason = new Error(message.error?.message ?? "Task channel failed");
625
+ this.close(reason);
626
+ this.options.onFailure?.(reason);
627
+ } else if (message.kind === "result" || message.kind === "error") {
628
+ const pending2 = this.pending.get(message.id);
629
+ if (!pending2)
630
+ return;
631
+ this.pending.delete(message.id);
632
+ pending2.cleanup();
633
+ if (message.kind === "result")
634
+ pending2.resolve(message.value);
635
+ else {
636
+ const error = new TaskRequestError(message.error?.message ?? "Task request failed");
637
+ error.name = message.error?.name ?? "Error";
638
+ pending2.reject(error);
639
+ }
640
+ } else if (message.kind === "cancel") {
641
+ this.incoming.get(message.id)?.abort(new DOMException("Task request cancelled", "AbortError"));
642
+ } else if (message.kind === "event") {
643
+ try {
644
+ this.options.handleEvent?.(message.operation, message.value);
645
+ } catch (error) {
646
+ this.fail(error);
647
+ }
648
+ } else if (message.kind === "request") {
649
+ if (this.incoming.has(message.id)) {
650
+ this.fail(new Error("Duplicate task request identifier"));
651
+ return;
652
+ }
653
+ const controller = new AbortController();
654
+ this.incoming.set(message.id, controller);
655
+ void Promise.resolve().then(() => {
656
+ controller.signal.throwIfAborted();
657
+ return this.options.handleRequest(message.operation, message.value, controller.signal);
658
+ }).then((value) => {
659
+ if (!controller.signal.aborted && !this.failure) {
660
+ this.send({ source: "math.gl/tasks", kind: "result", id: message.id, value }, this.options.getResultTransferList?.(value, message.value));
661
+ }
662
+ }).catch((reason) => {
663
+ if (!controller.signal.aborted && !this.failure) {
664
+ this.send({
665
+ source: "math.gl/tasks",
666
+ kind: "error",
667
+ id: message.id,
668
+ error: {
669
+ name: reason instanceof Error ? reason.name : "Error",
670
+ message: reason instanceof Error ? reason.message : String(reason)
671
+ }
672
+ });
673
+ }
674
+ }).finally(() => this.incoming.delete(message.id));
675
+ }
676
+ }
677
+ /** Reject all outstanding calls with a common cause and abort incoming callbacks. */
678
+ close(reason = new Error("Task channel closed")) {
679
+ if (this.failure)
680
+ return;
681
+ this.failure = { reason };
682
+ for (const pending2 of this.pending.values()) {
683
+ pending2.cleanup();
684
+ pending2.reject(reason);
685
+ }
686
+ this.pending.clear();
687
+ for (const controller of this.incoming.values())
688
+ controller.abort(reason);
689
+ this.incoming.clear();
690
+ }
691
+ send(message, transfer = []) {
692
+ if (this.failure)
693
+ return;
694
+ try {
695
+ this.options.send(message, transfer);
696
+ } catch (error) {
697
+ this.fail(error);
698
+ }
699
+ }
700
+ /** Invalidate the channel and notify the peer when the transport still works. */
701
+ fail(reason) {
702
+ if (this.failure)
703
+ return;
704
+ this.close(reason);
705
+ try {
706
+ this.options.send({
707
+ source: "math.gl/tasks",
708
+ kind: "failure",
709
+ id: 0,
710
+ error: {
711
+ name: reason instanceof Error ? reason.name : "Error",
712
+ message: reason instanceof Error ? reason.message : String(reason)
713
+ }
714
+ }, []);
715
+ } catch {
716
+ }
717
+ this.options.onFailure?.(reason);
718
+ }
719
+ };
720
+ }
721
+ });
722
+
723
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js
574
724
  function assertPayload(value) {
575
725
  if (!value || typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype) {
576
726
  throw new TypeError("Task payloads must be plain objects with named fields");
577
727
  }
578
728
  }
729
+ function clonePayload(value, ownership = "copy") {
730
+ assertPayload(value);
731
+ if (!["copy", "transfer", "share"].includes(ownership))
732
+ throw new TypeError("Invalid input ownership");
733
+ const transfer = getTransferList(value);
734
+ if (ownership === "share" && transfer.length)
735
+ throw new TypeError("Share requires shared storage");
736
+ return structuredClone(value, {
737
+ transfer: ownership === "transfer" ? transfer : []
738
+ });
739
+ }
579
740
  function taskContext(state, context = {}) {
580
741
  const signal = context.signal ?? new AbortController().signal;
581
742
  return {
582
743
  state,
583
744
  signal,
745
+ requestHost: async (operation, payload, controls) => {
746
+ signal.throwIfAborted();
747
+ if (!context.requestHost)
748
+ throw new Error("No host request handler configured");
749
+ return context.requestHost(operation, payload, controls);
750
+ },
751
+ emitHost: (operation, payload) => {
752
+ signal.throwIfAborted();
753
+ context.emitHost?.(operation, payload);
754
+ },
584
755
  throwIfAborted: () => {
585
756
  signal.throwIfAborted();
586
757
  context.throwIfAborted?.();
@@ -599,6 +770,69 @@
599
770
  throw new Error("A task is already installed in this worker");
600
771
  installed = true;
601
772
  const runtime = new TaskRuntime(task);
773
+ let channelStream;
774
+ const channel = new TaskChannel({
775
+ getResultTransferList: (value, request) => request.outputOwnership === "transfer" ? getTransferList(value) : [],
776
+ send: (message, transfer) => {
777
+ const snapshot = structuredClone(message, { transfer });
778
+ void WorkerBody.postMessage("task-channel", snapshot).catch((reason) => channel.fail(reason));
779
+ },
780
+ handleRequest: async (operation, value, signal) => {
781
+ const request = value;
782
+ const context = {
783
+ signal,
784
+ reportProgress: (progress) => channel.emit("task:progress", { id: request.progressId, progress }),
785
+ requestHost: (operation2, payload, controls = {}) => {
786
+ const request2 = {
787
+ operation: operation2,
788
+ payload: clonePayload(payload, controls.inputOwnership),
789
+ outputOwnership: controls.outputOwnership ?? "copy"
790
+ };
791
+ return channel.request("task:host-request", request2, signal, getTransferList(request2));
792
+ },
793
+ emitHost: (operation2, payload) => channel.emit("task:host-event", { operation: operation2, payload, id: request.progressId })
794
+ };
795
+ switch (operation) {
796
+ case "initialize":
797
+ return runtime.initialize(request.input, context);
798
+ case "process":
799
+ return runtime.process(request.input, request.options, context);
800
+ case "stream-open": {
801
+ if (channelStream)
802
+ throw new Error("A task stream is already open");
803
+ async function* inputs() {
804
+ while (true) {
805
+ const result = await channel.request("task:next-input", { outputOwnership: "transfer" }, signal);
806
+ if (result.done)
807
+ return;
808
+ yield result.value;
809
+ }
810
+ }
811
+ channelStream = runtime.stream(inputs(), request.options, context)[Symbol.asyncIterator]();
812
+ return {};
813
+ }
814
+ case "stream-next":
815
+ if (!channelStream)
816
+ throw new Error("No active task stream");
817
+ return channelStream.next();
818
+ case "stream-close":
819
+ try {
820
+ await channelStream?.return?.();
821
+ } finally {
822
+ channelStream = void 0;
823
+ }
824
+ return {};
825
+ case "destroy":
826
+ return runtime.destroy();
827
+ default:
828
+ throw new Error("Unknown task channel operation");
829
+ }
830
+ }
831
+ });
832
+ await WorkerBody.addEventListener((type, payload) => {
833
+ if (type === "task-channel")
834
+ channel.receive(payload);
835
+ });
602
836
  let streamOptions = {};
603
837
  return createWorker(async (request, _options, context) => {
604
838
  switch (request.operation) {
@@ -630,9 +864,10 @@
630
864
  }
631
865
  var TaskRuntime, installed;
632
866
  var init_task_runtime = __esm({
633
- "../../node_modules/@math.gl/core/dist/tasks/task-runtime.js"() {
867
+ "../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js"() {
634
868
  init_worker_utils();
635
869
  init_task_preload();
870
+ init_task_channel();
636
871
  TaskRuntime = class {
637
872
  constructor(task) {
638
873
  this.task = task;
@@ -683,13 +918,20 @@
683
918
  }
684
919
  });
685
920
 
686
- // ../../node_modules/@math.gl/core/dist/tasks/index.js
921
+ // ../../node_modules/@math.gl/tasks/dist/tasks/index.js
687
922
  var init_tasks = __esm({
688
- "../../node_modules/@math.gl/core/dist/tasks/index.js"() {
923
+ "../../node_modules/@math.gl/tasks/dist/tasks/index.js"() {
689
924
  init_task_runtime();
690
925
  }
691
926
  });
692
927
 
928
+ // ../../node_modules/@math.gl/tasks/dist/index.js
929
+ var init_dist = __esm({
930
+ "../../node_modules/@math.gl/tasks/dist/index.js"() {
931
+ init_tasks();
932
+ }
933
+ });
934
+
693
935
  // ../core/src/worker-utils/lib/node/worker_threads-browser.ts
694
936
  var worker_threads_browser_exports = {};
695
937
  __export(worker_threads_browser_exports, {
@@ -734,7 +976,7 @@
734
976
  var init_task_runtime2 = __esm({
735
977
  "../core/src/worker-utils/lib/worker-api/task-runtime.ts"() {
736
978
  "use strict";
737
- init_tasks();
979
+ init_dist();
738
980
  initializeTaskWorker2 = initializeTaskWorker;
739
981
  }
740
982
  });
@@ -1221,7 +1463,7 @@
1221
1463
  });
1222
1464
 
1223
1465
  // ../../node_modules/@math.gl/core/dist/index.js
1224
- var init_dist = __esm({
1466
+ var init_dist2 = __esm({
1225
1467
  "../../node_modules/@math.gl/core/dist/index.js"() {
1226
1468
  init_math_utils();
1227
1469
  init_types2();
@@ -16145,6 +16387,304 @@ return true;`);
16145
16387
  }
16146
16388
  });
16147
16389
 
16390
+ // ../../node_modules/@math.gl/arrow/dist/arrow/arrow-data.js
16391
+ function getArrowVariadicBuffers(data) {
16392
+ return data.variadicBuffers ?? [];
16393
+ }
16394
+ function createArrowData(type, offset, length, nullCount, buffers, children, dictionary, variadicBuffers) {
16395
+ return Reflect.construct(Data, [
16396
+ type,
16397
+ offset,
16398
+ length,
16399
+ nullCount,
16400
+ buffers,
16401
+ children,
16402
+ dictionary,
16403
+ variadicBuffers
16404
+ ]);
16405
+ }
16406
+ var init_arrow_data = __esm({
16407
+ "../../node_modules/@math.gl/arrow/dist/arrow/arrow-data.js"() {
16408
+ init_Arrow_dom();
16409
+ }
16410
+ });
16411
+
16412
+ // ../../node_modules/@math.gl/arrow/dist/arrow/split-arrow-buffers.js
16413
+ function splitArrowBuffers(input, options = {}) {
16414
+ const context = { ...options, copies: /* @__PURE__ */ new WeakMap() };
16415
+ if (isArrowTable2(input)) {
16416
+ return splitArrowTableBuffersInternal(input, context);
16417
+ }
16418
+ if (isArrowRecordBatch2(input)) {
16419
+ return splitArrowRecordBatchBuffers(input, context);
16420
+ }
16421
+ if (isArrowVector2(input)) {
16422
+ return splitArrowVectorBuffers(input, context);
16423
+ }
16424
+ return splitArrowDataBuffers(input, context);
16425
+ }
16426
+ function isArrowTable2(input) {
16427
+ return "batches" in input;
16428
+ }
16429
+ function isArrowRecordBatch2(input) {
16430
+ return "schema" in input && "data" in input && !Array.isArray(input.data);
16431
+ }
16432
+ function isArrowVector2(input) {
16433
+ return "data" in input && Array.isArray(input.data);
16434
+ }
16435
+ function splitArrowTableBuffersInternal(arrowTable, options) {
16436
+ const recordBatches = arrowTable.batches.map((recordBatch) => splitArrowRecordBatchBuffers(recordBatch, options));
16437
+ return new Table(arrowTable.schema, recordBatches);
16438
+ }
16439
+ function splitArrowRecordBatchBuffers(recordBatch, options) {
16440
+ return new RecordBatch3(recordBatch.schema, splitArrowDataBuffers(recordBatch.data, options));
16441
+ }
16442
+ function splitArrowDataBuffers(data, options) {
16443
+ const children = data.children.map((childData) => splitArrowDataBuffers(childData, options));
16444
+ const dictionary = data.dictionary ? splitArrowVectorBuffers(data.dictionary, options) : void 0;
16445
+ const buffers = {
16446
+ [BufferType.OFFSET]: splitArrowBuffer(data.buffers[BufferType.OFFSET], options),
16447
+ [BufferType.DATA]: splitArrowBuffer(data.buffers[BufferType.DATA], options),
16448
+ [BufferType.VALIDITY]: splitArrowBuffer(data.buffers[BufferType.VALIDITY], options),
16449
+ [BufferType.TYPE]: splitArrowBuffer(data.buffers[BufferType.TYPE], options)
16450
+ };
16451
+ return createArrowData(
16452
+ data.type,
16453
+ data.offset,
16454
+ data.length,
16455
+ // @ts-expect-error _nullCount is protected. Reuse it to preserve lazy null-count state.
16456
+ data._nullCount,
16457
+ buffers,
16458
+ children,
16459
+ dictionary,
16460
+ getArrowVariadicBuffers(data).map((buffer) => splitArrowBuffer(buffer, options))
16461
+ );
16462
+ }
16463
+ function splitArrowVectorBuffers(vector, options) {
16464
+ return new Vector(vector.data.map((data) => splitArrowDataBuffers(data, options)));
16465
+ }
16466
+ function splitArrowBuffer(array, options) {
16467
+ if (!isArrowTypedArray(array)) {
16468
+ return array;
16469
+ }
16470
+ if (options.copy === "none") {
16471
+ return array;
16472
+ }
16473
+ if (options.copy !== "all" && array.byteOffset === 0 && array.byteLength === array.buffer.byteLength) {
16474
+ return array;
16475
+ }
16476
+ let copy = options.copies.get(array);
16477
+ if (!copy) {
16478
+ copy = array instanceof Uint8Array ? new Uint8Array(array) : array.slice();
16479
+ options.copies.set(array, copy);
16480
+ }
16481
+ return copy;
16482
+ }
16483
+ function isArrowTypedArray(value) {
16484
+ return ArrayBuffer.isView(value) && !(value instanceof DataView);
16485
+ }
16486
+ var init_split_arrow_buffers = __esm({
16487
+ "../../node_modules/@math.gl/arrow/dist/arrow/split-arrow-buffers.js"() {
16488
+ init_Arrow_dom();
16489
+ init_arrow_data();
16490
+ }
16491
+ });
16492
+
16493
+ // ../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-vector.js
16494
+ var init_indexed_arrow_vector = __esm({
16495
+ "../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-vector.js"() {
16496
+ }
16497
+ });
16498
+
16499
+ // ../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-table.js
16500
+ var init_indexed_arrow_table = __esm({
16501
+ "../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-table.js"() {
16502
+ }
16503
+ });
16504
+
16505
+ // ../../node_modules/@math.gl/arrow/dist/arrow/mapped-arrow-table.js
16506
+ var init_mapped_arrow_table = __esm({
16507
+ "../../node_modules/@math.gl/arrow/dist/arrow/mapped-arrow-table.js"() {
16508
+ }
16509
+ });
16510
+
16511
+ // ../../node_modules/@math.gl/arrow/dist/arrow/rename-arrow-columns.js
16512
+ var init_rename_arrow_columns = __esm({
16513
+ "../../node_modules/@math.gl/arrow/dist/arrow/rename-arrow-columns.js"() {
16514
+ }
16515
+ });
16516
+
16517
+ // ../../node_modules/@math.gl/arrow/dist/arrow/arrow-table-transport.js
16518
+ function dehydrateArrowTable(arrowTable, options) {
16519
+ const splitTable = splitArrowBuffers(arrowTable, options);
16520
+ return {
16521
+ transport: "arrow-js",
16522
+ version: 1,
16523
+ schema: tableToIPC(new Table(splitTable.schema, [])),
16524
+ metadataVersion: splitTable.schema.metadataVersion,
16525
+ batches: splitTable.batches.map((batch) => dehydrateArrowData(batch.data))
16526
+ };
16527
+ }
16528
+ function hydrateArrowTable(table) {
16529
+ if (table.transport !== "arrow-js" || table.version !== 1) {
16530
+ throw new Error("Unsupported Arrow column-buffer transport protocol.");
16531
+ }
16532
+ const decodedSchema = tableFromIPC(table.schema).schema;
16533
+ const schema = new Schema2(decodedSchema.fields, decodedSchema.metadata, decodedSchema.dictionaries, table.metadataVersion);
16534
+ const type = new Struct(schema.fields);
16535
+ const batches = table.batches.map((data) => new RecordBatch3(schema, hydrateArrowData(data, type)));
16536
+ return new Table(schema, batches);
16537
+ }
16538
+ function dehydrateArrowData(data) {
16539
+ return {
16540
+ offset: data.offset,
16541
+ length: data.length,
16542
+ nullCount: data.nullCount,
16543
+ buffers: {
16544
+ [BufferType.OFFSET]: data.buffers[BufferType.OFFSET],
16545
+ [BufferType.DATA]: data.buffers[BufferType.DATA],
16546
+ [BufferType.VALIDITY]: data.buffers[BufferType.VALIDITY],
16547
+ [BufferType.TYPE]: data.buffers[BufferType.TYPE]
16548
+ },
16549
+ children: data.children.map((child) => dehydrateArrowData(child)),
16550
+ variadicBuffers: getArrowVariadicBuffers(data),
16551
+ dictionary: data.dictionary?.data.map((chunk) => dehydrateArrowData(chunk))
16552
+ };
16553
+ }
16554
+ function hydrateArrowData(data, type) {
16555
+ const children = data.children.map((child, index) => hydrateArrowData(child, type.children[index].type));
16556
+ const dictionary = data.dictionary && DataType.isDictionary(type) ? new Vector(data.dictionary.map((chunk) => hydrateArrowData(chunk, type.dictionary))) : void 0;
16557
+ return createArrowData(type, data.offset, data.length, data.nullCount, data.buffers, children, dictionary, data.variadicBuffers);
16558
+ }
16559
+ var init_arrow_table_transport = __esm({
16560
+ "../../node_modules/@math.gl/arrow/dist/arrow/arrow-table-transport.js"() {
16561
+ init_Arrow_dom();
16562
+ init_arrow_data();
16563
+ init_split_arrow_buffers();
16564
+ }
16565
+ });
16566
+
16567
+ // ../../node_modules/@math.gl/arrow/dist/arrow/index.js
16568
+ var init_arrow = __esm({
16569
+ "../../node_modules/@math.gl/arrow/dist/arrow/index.js"() {
16570
+ init_indexed_arrow_table();
16571
+ init_indexed_arrow_vector();
16572
+ init_mapped_arrow_table();
16573
+ init_rename_arrow_columns();
16574
+ init_split_arrow_buffers();
16575
+ init_arrow_table_transport();
16576
+ }
16577
+ });
16578
+
16579
+ // ../../node_modules/@math.gl/arrow/dist/index.js
16580
+ var init_dist3 = __esm({
16581
+ "../../node_modules/@math.gl/arrow/dist/index.js"() {
16582
+ init_arrow();
16583
+ }
16584
+ });
16585
+
16586
+ // ../core/src/arrow-worker-transport.ts
16587
+ function serializeArrowWorkerTable(result) {
16588
+ if (!isArrowTableWrapper(result)) {
16589
+ throw new Error("Workers require Arrow table output");
16590
+ }
16591
+ const { data, ...metadata } = result;
16592
+ return {
16593
+ ...structuredClone(metadata),
16594
+ data: dehydrateArrowTable(data, { copy: "all" })
16595
+ };
16596
+ }
16597
+ function deserializeArrowWorkerTable(result) {
16598
+ if (!isDehydratedArrowTableWrapper(result)) {
16599
+ throw new Error("Workers require Arrow column transport");
16600
+ }
16601
+ return { ...result, data: hydrateArrowTable(result.data) };
16602
+ }
16603
+ function isArrowTableWrapper(value) {
16604
+ const table = value;
16605
+ return Boolean(
16606
+ table && table.shape === "arrow-table" && table.data && typeof table.data === "object" && "batches" in table.data
16607
+ );
16608
+ }
16609
+ function isDehydratedArrowTableWrapper(value) {
16610
+ const table = value;
16611
+ return Boolean(
16612
+ table && table.shape === "arrow-table" && table.data && table.data.transport === "arrow-js" && Array.isArray(table.data.batches)
16613
+ );
16614
+ }
16615
+ var init_arrow_worker_transport = __esm({
16616
+ "../core/src/arrow-worker-transport.ts"() {
16617
+ "use strict";
16618
+ init_dist3();
16619
+ }
16620
+ });
16621
+
16622
+ // ../core/src/schema-utils/lib/schema/data-type.ts
16623
+ function getDataTypeFromValue(value, defaultNumberType = "float32") {
16624
+ if (value instanceof Date) {
16625
+ return "date-millisecond";
16626
+ }
16627
+ if (typeof value === "number") {
16628
+ return defaultNumberType;
16629
+ }
16630
+ if (typeof value === "boolean") {
16631
+ return "bool";
16632
+ }
16633
+ if (typeof value === "string") {
16634
+ return "utf8";
16635
+ }
16636
+ if (value === null || value === "undefined") {
16637
+ return "null";
16638
+ }
16639
+ return "null";
16640
+ }
16641
+ function getDataTypeFromArray(array) {
16642
+ let type = getDataTypeFromTypedArray(array);
16643
+ if (type !== "null") {
16644
+ return { type, nullable: false };
16645
+ }
16646
+ if (array.length > 0) {
16647
+ type = getDataTypeFromValue(array[0]);
16648
+ return { type, nullable: true };
16649
+ }
16650
+ return { type: "null", nullable: true };
16651
+ }
16652
+ function getDataTypeFromTypedArray(array) {
16653
+ if (typeof Float16Array !== "undefined" && array instanceof Float16Array) {
16654
+ return "float16";
16655
+ }
16656
+ switch (array.constructor) {
16657
+ case Int8Array:
16658
+ return "int8";
16659
+ case Uint8Array:
16660
+ case Uint8ClampedArray:
16661
+ return "uint8";
16662
+ case Int16Array:
16663
+ return "int16";
16664
+ case Uint16Array:
16665
+ return "uint16";
16666
+ case Int32Array:
16667
+ return "int32";
16668
+ case Uint32Array:
16669
+ return "uint32";
16670
+ case BigInt64Array:
16671
+ return "int64";
16672
+ case BigUint64Array:
16673
+ return "uint64";
16674
+ case Float32Array:
16675
+ return "float32";
16676
+ case Float64Array:
16677
+ return "float64";
16678
+ default:
16679
+ return "null";
16680
+ }
16681
+ }
16682
+ var init_data_type = __esm({
16683
+ "../core/src/schema-utils/lib/schema/data-type.ts"() {
16684
+ "use strict";
16685
+ }
16686
+ });
16687
+
16148
16688
  // ../core/src/schema-utils/lib/schema/convert-arrow-schema.ts
16149
16689
  function serializeArrowSchema(arrowSchema) {
16150
16690
  return {
@@ -16152,12 +16692,6 @@ return true;`);
16152
16692
  metadata: serializeArrowMetadata(arrowSchema.metadata)
16153
16693
  };
16154
16694
  }
16155
- function deserializeArrowSchema(schema, options) {
16156
- return new Schema2(
16157
- schema.fields.map((field) => deserializeArrowField(field, options)),
16158
- deserializeArrowMetadata(schema.metadata)
16159
- );
16160
- }
16161
16695
  function serializeArrowMetadata(arrowMetadata) {
16162
16696
  return Object.fromEntries(arrowMetadata);
16163
16697
  }
@@ -16580,259 +17114,6 @@ return true;`);
16580
17114
  }
16581
17115
  });
16582
17116
 
16583
- // ../core/src/schema-utils/lib/arrow/split-arrow-buffers.ts
16584
- function splitArrowBuffers(input, options = {}) {
16585
- const context = { ...options, copies: /* @__PURE__ */ new WeakMap() };
16586
- if (isArrowTable2(input)) {
16587
- return splitArrowTableBuffersInternal(input, context);
16588
- }
16589
- if (isArrowRecordBatch2(input)) {
16590
- return splitArrowRecordBatchBuffers(input, context);
16591
- }
16592
- if (isArrowVector2(input)) {
16593
- return splitArrowVectorBuffers(input, context);
16594
- }
16595
- return splitArrowDataBuffers(input, context);
16596
- }
16597
- function isArrowTable2(input) {
16598
- return "batches" in input;
16599
- }
16600
- function isArrowRecordBatch2(input) {
16601
- return "schema" in input && "data" in input && !Array.isArray(input.data);
16602
- }
16603
- function isArrowVector2(input) {
16604
- return "data" in input && Array.isArray(input.data);
16605
- }
16606
- function splitArrowTableBuffersInternal(table, options) {
16607
- const recordBatches = table.batches.map(
16608
- (recordBatch) => splitArrowRecordBatchBuffers(recordBatch, options)
16609
- );
16610
- return new Table(table.schema, recordBatches);
16611
- }
16612
- function splitArrowRecordBatchBuffers(recordBatch, options) {
16613
- return new RecordBatch3(
16614
- recordBatch.schema,
16615
- splitArrowDataBuffers(recordBatch.data, options)
16616
- );
16617
- }
16618
- function splitArrowDataBuffers(data, options) {
16619
- const children = data.children.map((childData) => splitArrowDataBuffers(childData, options));
16620
- const dictionary = data.dictionary ? splitArrowVectorBuffers(data.dictionary, options) : void 0;
16621
- const buffers = {
16622
- [BufferType.OFFSET]: splitArrowBuffer(data.buffers[BufferType.OFFSET], options),
16623
- [BufferType.DATA]: splitArrowBuffer(data.buffers[BufferType.DATA], options),
16624
- [BufferType.VALIDITY]: splitArrowBuffer(data.buffers[BufferType.VALIDITY], options),
16625
- [BufferType.TYPE]: splitArrowBuffer(data.buffers[BufferType.TYPE], options)
16626
- };
16627
- return new Data(
16628
- data.type,
16629
- data.offset,
16630
- data.length,
16631
- // @ts-expect-error _nullCount is protected. Reuse it to preserve lazy null-count state.
16632
- data._nullCount,
16633
- buffers,
16634
- children,
16635
- dictionary
16636
- );
16637
- }
16638
- function splitArrowVectorBuffers(vector, options) {
16639
- return new Vector(vector.data.map((data) => splitArrowDataBuffers(data, options)));
16640
- }
16641
- function splitArrowBuffer(array, options) {
16642
- if (!isArrowTypedArray(array)) {
16643
- return array;
16644
- }
16645
- if (options.copy === "none") {
16646
- return array;
16647
- }
16648
- if (options.copy !== "all" && array.byteOffset === 0 && array.byteLength === array.buffer.byteLength) {
16649
- return array;
16650
- }
16651
- let copy = options.copies.get(array);
16652
- if (!copy) {
16653
- copy = array.slice();
16654
- options.copies.set(array, copy);
16655
- }
16656
- return copy;
16657
- }
16658
- function isArrowTypedArray(value) {
16659
- return ArrayBuffer.isView(value) && !(value instanceof DataView);
16660
- }
16661
- var init_split_arrow_buffers = __esm({
16662
- "../core/src/schema-utils/lib/arrow/split-arrow-buffers.ts"() {
16663
- "use strict";
16664
- init_Arrow_dom();
16665
- }
16666
- });
16667
-
16668
- // ../core/src/schema-utils/lib/arrow/arrow-table-transport.ts
16669
- function dehydrateArrowTable(table, options) {
16670
- const splitTable = splitArrowBuffers(table, options);
16671
- return {
16672
- shape: "arrow-table",
16673
- transport: "arrow-js",
16674
- schema: serializeArrowSchema(splitTable.schema),
16675
- batches: splitTable.batches.map((recordBatch) => dehydrateArrowRecordBatch(recordBatch))
16676
- };
16677
- }
16678
- function hydrateArrowTable(table) {
16679
- const schema = deserializeArrowSchema(table.schema);
16680
- const recordBatches = table.batches.map(
16681
- (recordBatch) => new RecordBatch3(schema, hydrateArrowData(recordBatch.data))
16682
- );
16683
- return new Table(schema, recordBatches);
16684
- }
16685
- function serializeArrowWorkerTable(result) {
16686
- if (!isArrowTableWrapper(result)) {
16687
- throw new Error("Workers require Arrow table output");
16688
- }
16689
- const { data, ...metadata } = result;
16690
- return {
16691
- ...structuredClone(metadata),
16692
- data: dehydrateArrowTable(data, { copy: "all" })
16693
- };
16694
- }
16695
- function deserializeArrowWorkerTable(result) {
16696
- if (!isDehydratedArrowTableWrapper(result)) {
16697
- throw new Error("Workers require Arrow column transport");
16698
- }
16699
- return { ...result, data: hydrateArrowTable(result.data) };
16700
- }
16701
- function isArrowTableWrapper(value) {
16702
- const table = value;
16703
- return Boolean(
16704
- table && table.shape === "arrow-table" && table.data && typeof table.data === "object" && "batches" in table.data
16705
- );
16706
- }
16707
- function isDehydratedArrowTableWrapper(value) {
16708
- const table = value;
16709
- return Boolean(
16710
- table && table.shape === "arrow-table" && table.data && table.data.transport === "arrow-js" && Array.isArray(table.data.batches)
16711
- );
16712
- }
16713
- function dehydrateArrowRecordBatch(recordBatch) {
16714
- return { data: dehydrateArrowData(recordBatch.data) };
16715
- }
16716
- function dehydrateArrowData(data) {
16717
- return {
16718
- type: serializeArrowType(data.type),
16719
- offset: data.offset,
16720
- length: data.length,
16721
- // @ts-expect-error _nullCount is protected. Preserve the Arrow lazy null-count state.
16722
- nullCount: data._nullCount,
16723
- buffers: {
16724
- [BufferType.OFFSET]: data.buffers[BufferType.OFFSET],
16725
- [BufferType.DATA]: data.buffers[BufferType.DATA],
16726
- [BufferType.VALIDITY]: data.buffers[BufferType.VALIDITY],
16727
- [BufferType.TYPE]: data.buffers[BufferType.TYPE]
16728
- },
16729
- children: data.children.map((childData) => dehydrateArrowData(childData)),
16730
- dictionary: data.dictionary ? dehydrateArrowVector(data.dictionary) : void 0
16731
- };
16732
- }
16733
- function dehydrateArrowVector(vector) {
16734
- return { data: vector.data.map((data) => dehydrateArrowData(data)) };
16735
- }
16736
- function hydrateArrowData(data) {
16737
- const children = data.children.map((childData) => hydrateArrowData(childData));
16738
- const dictionary = data.dictionary ? hydrateArrowVector(data.dictionary) : void 0;
16739
- return new Data(
16740
- deserializeArrowType(data.type),
16741
- data.offset,
16742
- data.length,
16743
- data.nullCount,
16744
- data.buffers,
16745
- children,
16746
- dictionary
16747
- );
16748
- }
16749
- function hydrateArrowVector(vector) {
16750
- return new Vector(vector.data.map((data) => hydrateArrowData(data)));
16751
- }
16752
- var init_arrow_table_transport = __esm({
16753
- "../core/src/schema-utils/lib/arrow/arrow-table-transport.ts"() {
16754
- "use strict";
16755
- init_Arrow_dom();
16756
- init_convert_arrow_schema();
16757
- init_split_arrow_buffers();
16758
- }
16759
- });
16760
-
16761
- // ../core/src/schema-utils/arrow-transport.ts
16762
- var init_arrow_transport = __esm({
16763
- "../core/src/schema-utils/arrow-transport.ts"() {
16764
- "use strict";
16765
- init_arrow_table_transport();
16766
- init_split_arrow_buffers();
16767
- }
16768
- });
16769
-
16770
- // ../core/src/schema-utils/lib/schema/data-type.ts
16771
- function getDataTypeFromValue(value, defaultNumberType = "float32") {
16772
- if (value instanceof Date) {
16773
- return "date-millisecond";
16774
- }
16775
- if (typeof value === "number") {
16776
- return defaultNumberType;
16777
- }
16778
- if (typeof value === "boolean") {
16779
- return "bool";
16780
- }
16781
- if (typeof value === "string") {
16782
- return "utf8";
16783
- }
16784
- if (value === null || value === "undefined") {
16785
- return "null";
16786
- }
16787
- return "null";
16788
- }
16789
- function getDataTypeFromArray(array) {
16790
- let type = getDataTypeFromTypedArray(array);
16791
- if (type !== "null") {
16792
- return { type, nullable: false };
16793
- }
16794
- if (array.length > 0) {
16795
- type = getDataTypeFromValue(array[0]);
16796
- return { type, nullable: true };
16797
- }
16798
- return { type: "null", nullable: true };
16799
- }
16800
- function getDataTypeFromTypedArray(array) {
16801
- if (typeof Float16Array !== "undefined" && array instanceof Float16Array) {
16802
- return "float16";
16803
- }
16804
- switch (array.constructor) {
16805
- case Int8Array:
16806
- return "int8";
16807
- case Uint8Array:
16808
- case Uint8ClampedArray:
16809
- return "uint8";
16810
- case Int16Array:
16811
- return "int16";
16812
- case Uint16Array:
16813
- return "uint16";
16814
- case Int32Array:
16815
- return "int32";
16816
- case Uint32Array:
16817
- return "uint32";
16818
- case BigInt64Array:
16819
- return "int64";
16820
- case BigUint64Array:
16821
- return "uint64";
16822
- case Float32Array:
16823
- return "float32";
16824
- case Float64Array:
16825
- return "float64";
16826
- default:
16827
- return "null";
16828
- }
16829
- }
16830
- var init_data_type = __esm({
16831
- "../core/src/schema-utils/lib/schema/data-type.ts"() {
16832
- "use strict";
16833
- }
16834
- });
16835
-
16836
17117
  // ../core/src/schema-utils/lib/mesh/mesh-utils.ts
16837
17118
  function getMeshBoundingBox(attributes) {
16838
17119
  const positionAttribute = attributes?.POSITION;
@@ -16934,7 +17215,7 @@ return true;`);
16934
17215
  var init_float162 = __esm({
16935
17216
  "../core/src/schema/float16.ts"() {
16936
17217
  "use strict";
16937
- init_dist();
17218
+ init_dist2();
16938
17219
  }
16939
17220
  });
16940
17221
 
@@ -17891,8 +18172,8 @@ return true;`);
17891
18172
  "src/obj/obj-loader-types.ts"() {
17892
18173
  "use strict";
17893
18174
  init_obj_format();
17894
- init_arrow_transport();
17895
- VERSION = true ? "5.0.0-beta.4" : "latest";
18175
+ init_arrow_worker_transport();
18176
+ VERSION = true ? "5.0.0-beta.6" : "latest";
17896
18177
  OBJLoader = {
17897
18178
  ...OBJFormat,
17898
18179
  dataType: null,
@@ -18021,7 +18302,7 @@ return true;`);
18021
18302
  "src/obj/obj-loader.ts"() {
18022
18303
  "use strict";
18023
18304
  init_loader_utils();
18024
- init_arrow_transport();
18305
+ init_arrow_worker_transport();
18025
18306
  init_schema_utils();
18026
18307
  init_get_obj_schema();
18027
18308
  init_parse_obj();