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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +2958 -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 +400 -113
  21. package/dist/draco-worker-node.js.map +4 -4
  22. package/dist/draco-worker.js +394 -113
  23. package/dist/draco-worker.js.map +4 -4
  24. package/dist/draco-writer-worker-node.cjs +654 -85
  25. package/dist/draco-writer-worker-node.cjs.map +4 -4
  26. package/dist/draco-writer-worker.js +624 -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
@@ -52,7 +52,7 @@
52
52
 
53
53
  // ../core/src/worker-utils/lib/env-utils/version.ts
54
54
  function getVersion() {
55
- const version = false ? NPM_TAG : "5.0.0-beta.4";
55
+ const version = false ? NPM_TAG : "5.0.0-beta.5";
56
56
  globalThis._loadersgl_ = globalThis._loadersgl_ || {};
57
57
  globalThis._loadersgl_.version ||= version;
58
58
  return version;
@@ -101,15 +101,15 @@
101
101
  }
102
102
  });
103
103
 
104
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/node/worker_threads-browser.js
104
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js
105
105
  var parentPort;
106
106
  var init_worker_threads_browser = __esm({
107
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/node/worker_threads-browser.js"() {
107
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js"() {
108
108
  parentPort = globalThis.process?.getBuiltinModule?.("node:worker_threads")?.parentPort ?? null;
109
109
  }
110
110
  });
111
111
 
112
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-utils/get-transfer-list.js
112
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js
113
113
  function getTransferList(object, recursive = true, transfers) {
114
114
  const transfersSet = transfers || /* @__PURE__ */ new Set();
115
115
  const seen = /* @__PURE__ */ new Set();
@@ -160,11 +160,11 @@
160
160
  return false;
161
161
  }
162
162
  var init_get_transfer_list = __esm({
163
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-utils/get-transfer-list.js"() {
163
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js"() {
164
164
  }
165
165
  });
166
166
 
167
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-farm/worker-body.js
167
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-body.js
168
168
  async function getParentPort() {
169
169
  return parentPort;
170
170
  }
@@ -177,7 +177,7 @@
177
177
  }
178
178
  var onMessageWrapperMap, WorkerBody;
179
179
  var init_worker_body = __esm({
180
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-farm/worker-body.js"() {
180
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-body.js"() {
181
181
  init_get_transfer_list();
182
182
  init_worker_threads_browser();
183
183
  onMessageWrapperMap = /* @__PURE__ */ new Map();
@@ -258,10 +258,10 @@
258
258
  }
259
259
  });
260
260
 
261
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/async-queue/async-queue.js
261
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js
262
262
  var AsyncQueue;
263
263
  var init_async_queue = __esm({
264
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/async-queue/async-queue.js"() {
264
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js"() {
265
265
  AsyncQueue = class {
266
266
  constructor() {
267
267
  this._values = [];
@@ -330,10 +330,10 @@
330
330
  }
331
331
  });
332
332
 
333
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/shared-state.js
333
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js
334
334
  var SharedWorkerState;
335
335
  var init_shared_state = __esm({
336
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/shared-state.js"() {
336
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js"() {
337
337
  SharedWorkerState = class {
338
338
  constructor(buffer) {
339
339
  if (typeof SharedArrayBuffer === "undefined" || !(buffer instanceof SharedArrayBuffer) || buffer.byteLength !== 16)
@@ -374,18 +374,18 @@
374
374
  }
375
375
  });
376
376
 
377
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/validate-output-ownership.js
377
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js
378
378
  function validateOutputOwnership(ownership) {
379
379
  if (ownership !== void 0 && ownership !== "copy" && ownership !== "transfer") {
380
380
  throw new Error("Invalid worker output ownership");
381
381
  }
382
382
  }
383
383
  var init_validate_output_ownership = __esm({
384
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/validate-output-ownership.js"() {
384
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js"() {
385
385
  }
386
386
  });
387
387
 
388
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/create-worker.js
388
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/create-worker.js
389
389
  async function createWorker(process2, processInBatches, preload2) {
390
390
  if (!await WorkerBody.inWorkerThread()) {
391
391
  return;
@@ -590,7 +590,7 @@
590
590
  }
591
591
  var requestId, activeController, activeInputBatches, activeOutputAcknowledgements;
592
592
  var init_create_worker = __esm({
593
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/create-worker.js"() {
593
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/create-worker.js"() {
594
594
  init_shared_state();
595
595
  init_async_queue();
596
596
  init_worker_body();
@@ -602,19 +602,20 @@
602
602
  }
603
603
  });
604
604
 
605
- // ../../node_modules/@math.gl/core/dist/worker-utils/index.js
605
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/index.js
606
606
  var import_meta, path, moduleUrl;
607
607
  var init_worker_utils = __esm({
608
- "../../node_modules/@math.gl/core/dist/worker-utils/index.js"() {
608
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/index.js"() {
609
609
  init_worker_body();
610
610
  init_create_worker();
611
+ init_get_transfer_list();
611
612
  import_meta = {};
612
613
  path = typeof __filename === "string" ? __filename.replace(/\\/g, "/") : "";
613
614
  moduleUrl = path ? `file://${path.startsWith("/") ? "" : "/"}${encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F")}` : import_meta.url;
614
615
  }
615
616
  });
616
617
 
617
- // ../../node_modules/@math.gl/core/dist/tasks/task-preload.js
618
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js
618
619
  function preloadTaskCode(task, signal) {
619
620
  if (!task.preload)
620
621
  return Promise.resolve();
@@ -650,23 +651,193 @@
650
651
  }
651
652
  var pending, loaded;
652
653
  var init_task_preload = __esm({
653
- "../../node_modules/@math.gl/core/dist/tasks/task-preload.js"() {
654
+ "../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js"() {
654
655
  pending = /* @__PURE__ */ new WeakMap();
655
656
  loaded = /* @__PURE__ */ new WeakSet();
656
657
  }
657
658
  });
658
659
 
659
- // ../../node_modules/@math.gl/core/dist/tasks/task-runtime.js
660
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js
661
+ var TaskRequestError, TaskChannel;
662
+ var init_task_channel = __esm({
663
+ "../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js"() {
664
+ TaskRequestError = class extends Error {
665
+ };
666
+ TaskChannel = class {
667
+ constructor(options) {
668
+ this.options = options;
669
+ this.nextId = 1;
670
+ this.pending = /* @__PURE__ */ new Map();
671
+ this.incoming = /* @__PURE__ */ new Map();
672
+ }
673
+ /** Send a request without serializing other in-flight requests. */
674
+ request(operation, value, signal, transfer = []) {
675
+ if (this.failure)
676
+ return Promise.reject(this.failure.reason);
677
+ if (signal?.aborted)
678
+ return Promise.reject(signal.reason);
679
+ const id = this.nextId++;
680
+ return new Promise((resolve, reject) => {
681
+ const abort = () => {
682
+ const pending2 = this.pending.get(id);
683
+ if (!pending2)
684
+ return;
685
+ this.pending.delete(id);
686
+ pending2.cleanup();
687
+ reject(signal?.reason);
688
+ this.send({ source: "math.gl/tasks", kind: "cancel", id });
689
+ };
690
+ this.pending.set(id, {
691
+ resolve,
692
+ reject,
693
+ cleanup: () => signal?.removeEventListener("abort", abort)
694
+ });
695
+ signal?.addEventListener("abort", abort, { once: true });
696
+ this.send({ source: "math.gl/tasks", kind: "request", id, operation, value }, transfer);
697
+ });
698
+ }
699
+ /** Send a one-way notification. */
700
+ emit(operation, value, transfer = []) {
701
+ if (this.failure)
702
+ throw this.failure.reason;
703
+ this.send({ source: "math.gl/tasks", kind: "event", id: 0, operation, value }, transfer);
704
+ }
705
+ /** Dispatch a transport message; unrelated protocols are ignored. */
706
+ receive(message) {
707
+ if (this.failure || message?.source !== "math.gl/tasks")
708
+ return;
709
+ if (message.kind === "failure") {
710
+ const reason = new Error(message.error?.message ?? "Task channel failed");
711
+ this.close(reason);
712
+ this.options.onFailure?.(reason);
713
+ } else if (message.kind === "result" || message.kind === "error") {
714
+ const pending2 = this.pending.get(message.id);
715
+ if (!pending2)
716
+ return;
717
+ this.pending.delete(message.id);
718
+ pending2.cleanup();
719
+ if (message.kind === "result")
720
+ pending2.resolve(message.value);
721
+ else {
722
+ const error = new TaskRequestError(message.error?.message ?? "Task request failed");
723
+ error.name = message.error?.name ?? "Error";
724
+ pending2.reject(error);
725
+ }
726
+ } else if (message.kind === "cancel") {
727
+ this.incoming.get(message.id)?.abort(new DOMException("Task request cancelled", "AbortError"));
728
+ } else if (message.kind === "event") {
729
+ try {
730
+ this.options.handleEvent?.(message.operation, message.value);
731
+ } catch (error) {
732
+ this.fail(error);
733
+ }
734
+ } else if (message.kind === "request") {
735
+ if (this.incoming.has(message.id)) {
736
+ this.fail(new Error("Duplicate task request identifier"));
737
+ return;
738
+ }
739
+ const controller = new AbortController();
740
+ this.incoming.set(message.id, controller);
741
+ void Promise.resolve().then(() => {
742
+ controller.signal.throwIfAborted();
743
+ return this.options.handleRequest(message.operation, message.value, controller.signal);
744
+ }).then((value) => {
745
+ if (!controller.signal.aborted && !this.failure) {
746
+ this.send({ source: "math.gl/tasks", kind: "result", id: message.id, value }, this.options.getResultTransferList?.(value, message.value));
747
+ }
748
+ }).catch((reason) => {
749
+ if (!controller.signal.aborted && !this.failure) {
750
+ this.send({
751
+ source: "math.gl/tasks",
752
+ kind: "error",
753
+ id: message.id,
754
+ error: {
755
+ name: reason instanceof Error ? reason.name : "Error",
756
+ message: reason instanceof Error ? reason.message : String(reason)
757
+ }
758
+ });
759
+ }
760
+ }).finally(() => this.incoming.delete(message.id));
761
+ }
762
+ }
763
+ /** Reject all outstanding calls with a common cause and abort incoming callbacks. */
764
+ close(reason = new Error("Task channel closed")) {
765
+ if (this.failure)
766
+ return;
767
+ this.failure = { reason };
768
+ for (const pending2 of this.pending.values()) {
769
+ pending2.cleanup();
770
+ pending2.reject(reason);
771
+ }
772
+ this.pending.clear();
773
+ for (const controller of this.incoming.values())
774
+ controller.abort(reason);
775
+ this.incoming.clear();
776
+ }
777
+ send(message, transfer = []) {
778
+ if (this.failure)
779
+ return;
780
+ try {
781
+ this.options.send(message, transfer);
782
+ } catch (error) {
783
+ this.fail(error);
784
+ }
785
+ }
786
+ /** Invalidate the channel and notify the peer when the transport still works. */
787
+ fail(reason) {
788
+ if (this.failure)
789
+ return;
790
+ this.close(reason);
791
+ try {
792
+ this.options.send({
793
+ source: "math.gl/tasks",
794
+ kind: "failure",
795
+ id: 0,
796
+ error: {
797
+ name: reason instanceof Error ? reason.name : "Error",
798
+ message: reason instanceof Error ? reason.message : String(reason)
799
+ }
800
+ }, []);
801
+ } catch {
802
+ }
803
+ this.options.onFailure?.(reason);
804
+ }
805
+ };
806
+ }
807
+ });
808
+
809
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js
660
810
  function assertPayload(value) {
661
811
  if (!value || typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype) {
662
812
  throw new TypeError("Task payloads must be plain objects with named fields");
663
813
  }
664
814
  }
815
+ function clonePayload(value, ownership = "copy") {
816
+ assertPayload(value);
817
+ if (!["copy", "transfer", "share"].includes(ownership))
818
+ throw new TypeError("Invalid input ownership");
819
+ const transfer = getTransferList(value);
820
+ if (ownership === "share" && transfer.length)
821
+ throw new TypeError("Share requires shared storage");
822
+ return structuredClone(value, {
823
+ transfer: ownership === "transfer" ? transfer : []
824
+ });
825
+ }
665
826
  function taskContext(state, context = {}) {
666
827
  const signal = context.signal ?? new AbortController().signal;
667
828
  return {
668
829
  state,
669
830
  signal,
831
+ requestHost: async (operation, payload, controls) => {
832
+ signal.throwIfAborted();
833
+ if (!context.requestHost)
834
+ throw new Error("No host request handler configured");
835
+ return context.requestHost(operation, payload, controls);
836
+ },
837
+ emitHost: (operation, payload) => {
838
+ signal.throwIfAborted();
839
+ context.emitHost?.(operation, payload);
840
+ },
670
841
  throwIfAborted: () => {
671
842
  signal.throwIfAborted();
672
843
  context.throwIfAborted?.();
@@ -685,6 +856,69 @@
685
856
  throw new Error("A task is already installed in this worker");
686
857
  installed = true;
687
858
  const runtime = new TaskRuntime(task);
859
+ let channelStream;
860
+ const channel = new TaskChannel({
861
+ getResultTransferList: (value, request) => request.outputOwnership === "transfer" ? getTransferList(value) : [],
862
+ send: (message, transfer) => {
863
+ const snapshot = structuredClone(message, { transfer });
864
+ void WorkerBody.postMessage("task-channel", snapshot).catch((reason) => channel.fail(reason));
865
+ },
866
+ handleRequest: async (operation, value, signal) => {
867
+ const request = value;
868
+ const context = {
869
+ signal,
870
+ reportProgress: (progress) => channel.emit("task:progress", { id: request.progressId, progress }),
871
+ requestHost: (operation2, payload, controls = {}) => {
872
+ const request2 = {
873
+ operation: operation2,
874
+ payload: clonePayload(payload, controls.inputOwnership),
875
+ outputOwnership: controls.outputOwnership ?? "copy"
876
+ };
877
+ return channel.request("task:host-request", request2, signal, getTransferList(request2));
878
+ },
879
+ emitHost: (operation2, payload) => channel.emit("task:host-event", { operation: operation2, payload, id: request.progressId })
880
+ };
881
+ switch (operation) {
882
+ case "initialize":
883
+ return runtime.initialize(request.input, context);
884
+ case "process":
885
+ return runtime.process(request.input, request.options, context);
886
+ case "stream-open": {
887
+ if (channelStream)
888
+ throw new Error("A task stream is already open");
889
+ async function* inputs() {
890
+ while (true) {
891
+ const result = await channel.request("task:next-input", { outputOwnership: "transfer" }, signal);
892
+ if (result.done)
893
+ return;
894
+ yield result.value;
895
+ }
896
+ }
897
+ channelStream = runtime.stream(inputs(), request.options, context)[Symbol.asyncIterator]();
898
+ return {};
899
+ }
900
+ case "stream-next":
901
+ if (!channelStream)
902
+ throw new Error("No active task stream");
903
+ return channelStream.next();
904
+ case "stream-close":
905
+ try {
906
+ await channelStream?.return?.();
907
+ } finally {
908
+ channelStream = void 0;
909
+ }
910
+ return {};
911
+ case "destroy":
912
+ return runtime.destroy();
913
+ default:
914
+ throw new Error("Unknown task channel operation");
915
+ }
916
+ }
917
+ });
918
+ await WorkerBody.addEventListener((type, payload) => {
919
+ if (type === "task-channel")
920
+ channel.receive(payload);
921
+ });
688
922
  let streamOptions = {};
689
923
  return createWorker(async (request, _options, context) => {
690
924
  switch (request.operation) {
@@ -716,9 +950,10 @@
716
950
  }
717
951
  var TaskRuntime, installed;
718
952
  var init_task_runtime = __esm({
719
- "../../node_modules/@math.gl/core/dist/tasks/task-runtime.js"() {
953
+ "../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js"() {
720
954
  init_worker_utils();
721
955
  init_task_preload();
956
+ init_task_channel();
722
957
  TaskRuntime = class {
723
958
  constructor(task) {
724
959
  this.task = task;
@@ -769,13 +1004,20 @@
769
1004
  }
770
1005
  });
771
1006
 
772
- // ../../node_modules/@math.gl/core/dist/tasks/index.js
1007
+ // ../../node_modules/@math.gl/tasks/dist/tasks/index.js
773
1008
  var init_tasks = __esm({
774
- "../../node_modules/@math.gl/core/dist/tasks/index.js"() {
1009
+ "../../node_modules/@math.gl/tasks/dist/tasks/index.js"() {
775
1010
  init_task_runtime();
776
1011
  }
777
1012
  });
778
1013
 
1014
+ // ../../node_modules/@math.gl/tasks/dist/index.js
1015
+ var init_dist = __esm({
1016
+ "../../node_modules/@math.gl/tasks/dist/index.js"() {
1017
+ init_tasks();
1018
+ }
1019
+ });
1020
+
779
1021
  // ../core/src/worker-utils/lib/node/worker_threads-browser.ts
780
1022
  var worker_threads_browser_exports = {};
781
1023
  __export(worker_threads_browser_exports, {
@@ -820,7 +1062,7 @@
820
1062
  var init_task_runtime2 = __esm({
821
1063
  "../core/src/worker-utils/lib/worker-api/task-runtime.ts"() {
822
1064
  "use strict";
823
- init_tasks();
1065
+ init_dist();
824
1066
  initializeTaskWorker2 = initializeTaskWorker;
825
1067
  }
826
1068
  });
@@ -1373,7 +1615,7 @@
1373
1615
  });
1374
1616
 
1375
1617
  // ../../node_modules/@math.gl/core/dist/index.js
1376
- var init_dist = __esm({
1618
+ var init_dist2 = __esm({
1377
1619
  "../../node_modules/@math.gl/core/dist/index.js"() {
1378
1620
  init_math_utils();
1379
1621
  init_types2();
@@ -16368,12 +16610,6 @@ return true;`);
16368
16610
  metadata: serializeArrowMetadata(arrowSchema.metadata)
16369
16611
  };
16370
16612
  }
16371
- function deserializeArrowSchema(schema, options) {
16372
- return new Schema2(
16373
- schema.fields.map((field) => deserializeArrowField(field, options)),
16374
- deserializeArrowMetadata(schema.metadata)
16375
- );
16376
- }
16377
16613
  function serializeArrowMetadata(arrowMetadata) {
16378
16614
  return Object.fromEntries(arrowMetadata);
16379
16615
  }
@@ -16842,7 +17078,7 @@ return true;`);
16842
17078
  var init_float162 = __esm({
16843
17079
  "../core/src/schema/float16.ts"() {
16844
17080
  "use strict";
16845
- init_dist();
17081
+ init_dist2();
16846
17082
  }
16847
17083
  });
16848
17084
 
@@ -18053,7 +18289,29 @@ return true;`);
18053
18289
  }
18054
18290
  });
18055
18291
 
18056
- // ../core/src/schema-utils/lib/arrow/split-arrow-buffers.ts
18292
+ // ../../node_modules/@math.gl/arrow/dist/arrow/arrow-data.js
18293
+ function getArrowVariadicBuffers(data) {
18294
+ return data.variadicBuffers ?? [];
18295
+ }
18296
+ function createArrowData(type, offset, length, nullCount, buffers, children, dictionary, variadicBuffers) {
18297
+ return Reflect.construct(Data, [
18298
+ type,
18299
+ offset,
18300
+ length,
18301
+ nullCount,
18302
+ buffers,
18303
+ children,
18304
+ dictionary,
18305
+ variadicBuffers
18306
+ ]);
18307
+ }
18308
+ var init_arrow_data = __esm({
18309
+ "../../node_modules/@math.gl/arrow/dist/arrow/arrow-data.js"() {
18310
+ init_Arrow_dom();
18311
+ }
18312
+ });
18313
+
18314
+ // ../../node_modules/@math.gl/arrow/dist/arrow/split-arrow-buffers.js
18057
18315
  function splitArrowBuffers(input, options = {}) {
18058
18316
  const context = { ...options, copies: /* @__PURE__ */ new WeakMap() };
18059
18317
  if (isArrowTable2(input)) {
@@ -18076,17 +18334,12 @@ return true;`);
18076
18334
  function isArrowVector2(input) {
18077
18335
  return "data" in input && Array.isArray(input.data);
18078
18336
  }
18079
- function splitArrowTableBuffersInternal(table, options) {
18080
- const recordBatches = table.batches.map(
18081
- (recordBatch) => splitArrowRecordBatchBuffers(recordBatch, options)
18082
- );
18083
- return new Table(table.schema, recordBatches);
18337
+ function splitArrowTableBuffersInternal(arrowTable, options) {
18338
+ const recordBatches = arrowTable.batches.map((recordBatch) => splitArrowRecordBatchBuffers(recordBatch, options));
18339
+ return new Table(arrowTable.schema, recordBatches);
18084
18340
  }
18085
18341
  function splitArrowRecordBatchBuffers(recordBatch, options) {
18086
- return new RecordBatch3(
18087
- recordBatch.schema,
18088
- splitArrowDataBuffers(recordBatch.data, options)
18089
- );
18342
+ return new RecordBatch3(recordBatch.schema, splitArrowDataBuffers(recordBatch.data, options));
18090
18343
  }
18091
18344
  function splitArrowDataBuffers(data, options) {
18092
18345
  const children = data.children.map((childData) => splitArrowDataBuffers(childData, options));
@@ -18097,7 +18350,7 @@ return true;`);
18097
18350
  [BufferType.VALIDITY]: splitArrowBuffer(data.buffers[BufferType.VALIDITY], options),
18098
18351
  [BufferType.TYPE]: splitArrowBuffer(data.buffers[BufferType.TYPE], options)
18099
18352
  };
18100
- return new Data(
18353
+ return createArrowData(
18101
18354
  data.type,
18102
18355
  data.offset,
18103
18356
  data.length,
@@ -18105,7 +18358,8 @@ return true;`);
18105
18358
  data._nullCount,
18106
18359
  buffers,
18107
18360
  children,
18108
- dictionary
18361
+ dictionary,
18362
+ getArrowVariadicBuffers(data).map((buffer) => splitArrowBuffer(buffer, options))
18109
18363
  );
18110
18364
  }
18111
18365
  function splitArrowVectorBuffers(vector, options) {
@@ -18123,7 +18377,7 @@ return true;`);
18123
18377
  }
18124
18378
  let copy = options.copies.get(array);
18125
18379
  if (!copy) {
18126
- copy = array.slice();
18380
+ copy = array instanceof Uint8Array ? new Uint8Array(array) : array.slice();
18127
18381
  options.copies.set(array, copy);
18128
18382
  }
18129
18383
  return copy;
@@ -18132,29 +18386,106 @@ return true;`);
18132
18386
  return ArrayBuffer.isView(value) && !(value instanceof DataView);
18133
18387
  }
18134
18388
  var init_split_arrow_buffers = __esm({
18135
- "../core/src/schema-utils/lib/arrow/split-arrow-buffers.ts"() {
18136
- "use strict";
18389
+ "../../node_modules/@math.gl/arrow/dist/arrow/split-arrow-buffers.js"() {
18137
18390
  init_Arrow_dom();
18391
+ init_arrow_data();
18392
+ }
18393
+ });
18394
+
18395
+ // ../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-vector.js
18396
+ var init_indexed_arrow_vector = __esm({
18397
+ "../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-vector.js"() {
18398
+ }
18399
+ });
18400
+
18401
+ // ../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-table.js
18402
+ var init_indexed_arrow_table = __esm({
18403
+ "../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-table.js"() {
18404
+ }
18405
+ });
18406
+
18407
+ // ../../node_modules/@math.gl/arrow/dist/arrow/mapped-arrow-table.js
18408
+ var init_mapped_arrow_table = __esm({
18409
+ "../../node_modules/@math.gl/arrow/dist/arrow/mapped-arrow-table.js"() {
18410
+ }
18411
+ });
18412
+
18413
+ // ../../node_modules/@math.gl/arrow/dist/arrow/rename-arrow-columns.js
18414
+ var init_rename_arrow_columns = __esm({
18415
+ "../../node_modules/@math.gl/arrow/dist/arrow/rename-arrow-columns.js"() {
18138
18416
  }
18139
18417
  });
18140
18418
 
18141
- // ../core/src/schema-utils/lib/arrow/arrow-table-transport.ts
18142
- function dehydrateArrowTable(table, options) {
18143
- const splitTable = splitArrowBuffers(table, options);
18419
+ // ../../node_modules/@math.gl/arrow/dist/arrow/arrow-table-transport.js
18420
+ function dehydrateArrowTable(arrowTable, options) {
18421
+ const splitTable = splitArrowBuffers(arrowTable, options);
18144
18422
  return {
18145
- shape: "arrow-table",
18146
18423
  transport: "arrow-js",
18147
- schema: serializeArrowSchema(splitTable.schema),
18148
- batches: splitTable.batches.map((recordBatch) => dehydrateArrowRecordBatch(recordBatch))
18424
+ version: 1,
18425
+ schema: tableToIPC(new Table(splitTable.schema, [])),
18426
+ metadataVersion: splitTable.schema.metadataVersion,
18427
+ batches: splitTable.batches.map((batch) => dehydrateArrowData(batch.data))
18149
18428
  };
18150
18429
  }
18151
18430
  function hydrateArrowTable(table) {
18152
- const schema = deserializeArrowSchema(table.schema);
18153
- const recordBatches = table.batches.map(
18154
- (recordBatch) => new RecordBatch3(schema, hydrateArrowData(recordBatch.data))
18155
- );
18156
- return new Table(schema, recordBatches);
18431
+ if (table.transport !== "arrow-js" || table.version !== 1) {
18432
+ throw new Error("Unsupported Arrow column-buffer transport protocol.");
18433
+ }
18434
+ const decodedSchema = tableFromIPC(table.schema).schema;
18435
+ const schema = new Schema2(decodedSchema.fields, decodedSchema.metadata, decodedSchema.dictionaries, table.metadataVersion);
18436
+ const type = new Struct(schema.fields);
18437
+ const batches = table.batches.map((data) => new RecordBatch3(schema, hydrateArrowData(data, type)));
18438
+ return new Table(schema, batches);
18157
18439
  }
18440
+ function dehydrateArrowData(data) {
18441
+ return {
18442
+ offset: data.offset,
18443
+ length: data.length,
18444
+ nullCount: data.nullCount,
18445
+ buffers: {
18446
+ [BufferType.OFFSET]: data.buffers[BufferType.OFFSET],
18447
+ [BufferType.DATA]: data.buffers[BufferType.DATA],
18448
+ [BufferType.VALIDITY]: data.buffers[BufferType.VALIDITY],
18449
+ [BufferType.TYPE]: data.buffers[BufferType.TYPE]
18450
+ },
18451
+ children: data.children.map((child) => dehydrateArrowData(child)),
18452
+ variadicBuffers: getArrowVariadicBuffers(data),
18453
+ dictionary: data.dictionary?.data.map((chunk) => dehydrateArrowData(chunk))
18454
+ };
18455
+ }
18456
+ function hydrateArrowData(data, type) {
18457
+ const children = data.children.map((child, index) => hydrateArrowData(child, type.children[index].type));
18458
+ const dictionary = data.dictionary && DataType.isDictionary(type) ? new Vector(data.dictionary.map((chunk) => hydrateArrowData(chunk, type.dictionary))) : void 0;
18459
+ return createArrowData(type, data.offset, data.length, data.nullCount, data.buffers, children, dictionary, data.variadicBuffers);
18460
+ }
18461
+ var init_arrow_table_transport = __esm({
18462
+ "../../node_modules/@math.gl/arrow/dist/arrow/arrow-table-transport.js"() {
18463
+ init_Arrow_dom();
18464
+ init_arrow_data();
18465
+ init_split_arrow_buffers();
18466
+ }
18467
+ });
18468
+
18469
+ // ../../node_modules/@math.gl/arrow/dist/arrow/index.js
18470
+ var init_arrow = __esm({
18471
+ "../../node_modules/@math.gl/arrow/dist/arrow/index.js"() {
18472
+ init_indexed_arrow_table();
18473
+ init_indexed_arrow_vector();
18474
+ init_mapped_arrow_table();
18475
+ init_rename_arrow_columns();
18476
+ init_split_arrow_buffers();
18477
+ init_arrow_table_transport();
18478
+ }
18479
+ });
18480
+
18481
+ // ../../node_modules/@math.gl/arrow/dist/index.js
18482
+ var init_dist3 = __esm({
18483
+ "../../node_modules/@math.gl/arrow/dist/index.js"() {
18484
+ init_arrow();
18485
+ }
18486
+ });
18487
+
18488
+ // ../core/src/arrow-worker-transport.ts
18158
18489
  function serializeArrowWorkerResult(result, options) {
18159
18490
  if (!isArrowTableWrapper(result)) {
18160
18491
  return result;
@@ -18184,60 +18515,10 @@ return true;`);
18184
18515
  table && table.shape === "arrow-table" && table.data && table.data.transport === "arrow-js" && Array.isArray(table.data.batches)
18185
18516
  );
18186
18517
  }
18187
- function dehydrateArrowRecordBatch(recordBatch) {
18188
- return { data: dehydrateArrowData(recordBatch.data) };
18189
- }
18190
- function dehydrateArrowData(data) {
18191
- return {
18192
- type: serializeArrowType(data.type),
18193
- offset: data.offset,
18194
- length: data.length,
18195
- // @ts-expect-error _nullCount is protected. Preserve the Arrow lazy null-count state.
18196
- nullCount: data._nullCount,
18197
- buffers: {
18198
- [BufferType.OFFSET]: data.buffers[BufferType.OFFSET],
18199
- [BufferType.DATA]: data.buffers[BufferType.DATA],
18200
- [BufferType.VALIDITY]: data.buffers[BufferType.VALIDITY],
18201
- [BufferType.TYPE]: data.buffers[BufferType.TYPE]
18202
- },
18203
- children: data.children.map((childData) => dehydrateArrowData(childData)),
18204
- dictionary: data.dictionary ? dehydrateArrowVector(data.dictionary) : void 0
18205
- };
18206
- }
18207
- function dehydrateArrowVector(vector) {
18208
- return { data: vector.data.map((data) => dehydrateArrowData(data)) };
18209
- }
18210
- function hydrateArrowData(data) {
18211
- const children = data.children.map((childData) => hydrateArrowData(childData));
18212
- const dictionary = data.dictionary ? hydrateArrowVector(data.dictionary) : void 0;
18213
- return new Data(
18214
- deserializeArrowType(data.type),
18215
- data.offset,
18216
- data.length,
18217
- data.nullCount,
18218
- data.buffers,
18219
- children,
18220
- dictionary
18221
- );
18222
- }
18223
- function hydrateArrowVector(vector) {
18224
- return new Vector(vector.data.map((data) => hydrateArrowData(data)));
18225
- }
18226
- var init_arrow_table_transport = __esm({
18227
- "../core/src/schema-utils/lib/arrow/arrow-table-transport.ts"() {
18518
+ var init_arrow_worker_transport = __esm({
18519
+ "../core/src/arrow-worker-transport.ts"() {
18228
18520
  "use strict";
18229
- init_Arrow_dom();
18230
- init_convert_arrow_schema();
18231
- init_split_arrow_buffers();
18232
- }
18233
- });
18234
-
18235
- // ../core/src/schema-utils/arrow-transport.ts
18236
- var init_arrow_transport = __esm({
18237
- "../core/src/schema-utils/arrow-transport.ts"() {
18238
- "use strict";
18239
- init_arrow_table_transport();
18240
- init_split_arrow_buffers();
18521
+ init_dist3();
18241
18522
  }
18242
18523
  });
18243
18524
 
@@ -18246,7 +18527,7 @@ return true;`);
18246
18527
  var init_version2 = __esm({
18247
18528
  "src/draco/lib/utils/version.ts"() {
18248
18529
  "use strict";
18249
- VERSION2 = true ? "5.0.0-beta.4" : "latest";
18530
+ VERSION2 = true ? "5.0.0-beta.5" : "latest";
18250
18531
  }
18251
18532
  });
18252
18533
 
@@ -18426,7 +18707,7 @@ return true;`);
18426
18707
  var init_draco_loader_types = __esm({
18427
18708
  "src/draco/draco-loader-types.ts"() {
18428
18709
  "use strict";
18429
- init_arrow_transport();
18710
+ init_arrow_worker_transport();
18430
18711
  init_version2();
18431
18712
  init_draco_format();
18432
18713
  init_draco_loader_options();