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

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 (151) hide show
  1. package/dist/dist.dev.js +3393 -407
  2. package/dist/dist.min.js +24 -16
  3. package/dist/draco/lib/utils/version.cjs +1 -1
  4. package/dist/draco/lib/utils/version.js +1 -1
  5. package/dist/draco-worker-node.js +415 -54
  6. package/dist/draco-worker-node.js.map +4 -4
  7. package/dist/draco-worker.js +390 -54
  8. package/dist/draco-worker.js.map +4 -4
  9. package/dist/draco-writer-worker-node.cjs +1401 -67
  10. package/dist/draco-writer-worker-node.cjs.map +4 -4
  11. package/dist/draco-writer-worker.js +1345 -67
  12. package/dist/draco-writer-worker.js.map +4 -4
  13. package/dist/gltf/gltf-loader-types.cjs.map +2 -2
  14. package/dist/gltf/gltf-loader-types.d.ts +6 -0
  15. package/dist/gltf/gltf-loader-types.d.ts.map +1 -1
  16. package/dist/gltf/gltf-loader-types.js.map +1 -1
  17. package/dist/gltf/index.cjs +2 -0
  18. package/dist/gltf/index.cjs.map +2 -2
  19. package/dist/gltf/index.d.ts +2 -2
  20. package/dist/gltf/index.d.ts.map +1 -1
  21. package/dist/gltf/index.js +1 -1
  22. package/dist/gltf/index.js.map +1 -1
  23. package/dist/gltf/lib/api/gltf-extensions.cjs +7 -2
  24. package/dist/gltf/lib/api/gltf-extensions.cjs.map +2 -2
  25. package/dist/gltf/lib/api/gltf-extensions.d.ts.map +1 -1
  26. package/dist/gltf/lib/api/gltf-extensions.js +7 -5
  27. package/dist/gltf/lib/api/gltf-extensions.js.map +1 -1
  28. package/dist/gltf/lib/extensions/EXT_texture_webp.cjs +1 -0
  29. package/dist/gltf/lib/extensions/EXT_texture_webp.cjs.map +2 -2
  30. package/dist/gltf/lib/extensions/EXT_texture_webp.d.ts.map +1 -1
  31. package/dist/gltf/lib/extensions/EXT_texture_webp.js +3 -0
  32. package/dist/gltf/lib/extensions/EXT_texture_webp.js.map +1 -1
  33. package/dist/gltf/lib/extensions/KHR_accessor_float64.cjs +45 -0
  34. package/dist/gltf/lib/extensions/KHR_accessor_float64.cjs.map +7 -0
  35. package/dist/gltf/lib/extensions/KHR_accessor_float64.d.ts +6 -0
  36. package/dist/gltf/lib/extensions/KHR_accessor_float64.d.ts.map +1 -0
  37. package/dist/gltf/lib/extensions/KHR_accessor_float64.js +20 -0
  38. package/dist/gltf/lib/extensions/KHR_accessor_float64.js.map +1 -0
  39. package/dist/gltf/lib/extensions/KHR_gaussian_splatting.cjs +12 -3
  40. package/dist/gltf/lib/extensions/KHR_gaussian_splatting.cjs.map +2 -2
  41. package/dist/gltf/lib/extensions/KHR_gaussian_splatting.d.ts +2 -1
  42. package/dist/gltf/lib/extensions/KHR_gaussian_splatting.d.ts.map +1 -1
  43. package/dist/gltf/lib/extensions/KHR_gaussian_splatting.js +9 -3
  44. package/dist/gltf/lib/extensions/KHR_gaussian_splatting.js.map +1 -1
  45. package/dist/gltf/lib/extensions/MSFT_texture_dds.cjs +64 -0
  46. package/dist/gltf/lib/extensions/MSFT_texture_dds.cjs.map +7 -0
  47. package/dist/gltf/lib/extensions/MSFT_texture_dds.d.ts +12 -0
  48. package/dist/gltf/lib/extensions/MSFT_texture_dds.d.ts.map +1 -0
  49. package/dist/gltf/lib/extensions/MSFT_texture_dds.js +39 -0
  50. package/dist/gltf/lib/extensions/MSFT_texture_dds.js.map +1 -0
  51. package/dist/gltf/lib/extensions/utils/3d-tiles-utils.cjs +1 -1
  52. package/dist/gltf/lib/extensions/utils/3d-tiles-utils.cjs.map +2 -2
  53. package/dist/gltf/lib/extensions/utils/3d-tiles-utils.d.ts.map +1 -1
  54. package/dist/gltf/lib/extensions/utils/3d-tiles-utils.js +3 -1
  55. package/dist/gltf/lib/extensions/utils/3d-tiles-utils.js.map +1 -1
  56. package/dist/gltf/lib/parsers/parse-gltf.cjs +25 -0
  57. package/dist/gltf/lib/parsers/parse-gltf.cjs.map +2 -2
  58. package/dist/gltf/lib/parsers/parse-gltf.d.ts.map +1 -1
  59. package/dist/gltf/lib/parsers/parse-gltf.js +18 -0
  60. package/dist/gltf/lib/parsers/parse-gltf.js.map +1 -1
  61. package/dist/gltf/lib/types/gltf-ext-gaussian-splatting-schema.cjs.map +1 -1
  62. package/dist/gltf/lib/types/gltf-ext-gaussian-splatting-schema.d.ts +1 -1
  63. package/dist/gltf/lib/types/gltf-ext-gaussian-splatting-schema.d.ts.map +1 -1
  64. package/dist/gltf/lib/types/gltf-texture-procedurals.cjs +19 -0
  65. package/dist/gltf/lib/types/gltf-texture-procedurals.cjs.map +7 -0
  66. package/dist/gltf/lib/types/gltf-texture-procedurals.d.ts +45 -0
  67. package/dist/gltf/lib/types/gltf-texture-procedurals.d.ts.map +1 -0
  68. package/dist/gltf/lib/types/gltf-texture-procedurals.js +5 -0
  69. package/dist/gltf/lib/types/gltf-texture-procedurals.js.map +1 -0
  70. package/dist/gltf/lib/types/gltf-types.cjs.map +1 -1
  71. package/dist/gltf/lib/types/gltf-types.d.ts +7 -0
  72. package/dist/gltf/lib/types/gltf-types.d.ts.map +1 -1
  73. package/dist/gltf/lib/types/gltf-zod-schema.cjs +3 -0
  74. package/dist/gltf/lib/types/gltf-zod-schema.cjs.map +2 -2
  75. package/dist/gltf/lib/types/gltf-zod-schema.d.ts +5 -0
  76. package/dist/gltf/lib/types/gltf-zod-schema.d.ts.map +1 -1
  77. package/dist/gltf/lib/types/gltf-zod-schema.js +4 -0
  78. package/dist/gltf/lib/types/gltf-zod-schema.js.map +1 -1
  79. package/dist/gltf/lib/utils/version.cjs +1 -1
  80. package/dist/gltf/lib/utils/version.js +1 -1
  81. package/dist/gltf/schema.cjs +3 -0
  82. package/dist/gltf/schema.cjs.map +2 -2
  83. package/dist/gltf/schema.d.ts +1 -0
  84. package/dist/gltf/schema.d.ts.map +1 -1
  85. package/dist/gltf/schema.js +1 -0
  86. package/dist/gltf/schema.js.map +1 -1
  87. package/dist/gltf-loader-types.cjs.map +2 -2
  88. package/dist/index.cjs +3 -0
  89. package/dist/index.cjs.map +2 -2
  90. package/dist/index.d.ts +2 -0
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +1 -0
  93. package/dist/index.js.map +1 -1
  94. package/dist/materialx/parse-materialx.cjs +61 -0
  95. package/dist/materialx/parse-materialx.cjs.map +7 -0
  96. package/dist/materialx/parse-materialx.d.ts +23 -0
  97. package/dist/materialx/parse-materialx.d.ts.map +1 -0
  98. package/dist/materialx/parse-materialx.js +39 -0
  99. package/dist/materialx/parse-materialx.js.map +1 -0
  100. package/dist/materialx/procedural-graph.cjs +77 -0
  101. package/dist/materialx/procedural-graph.cjs.map +7 -0
  102. package/dist/materialx/procedural-graph.d.ts +40 -0
  103. package/dist/materialx/procedural-graph.d.ts.map +1 -0
  104. package/dist/materialx/procedural-graph.js +59 -0
  105. package/dist/materialx/procedural-graph.js.map +1 -0
  106. package/dist/materialx-loader-types.cjs +57 -0
  107. package/dist/materialx-loader-types.cjs.map +7 -0
  108. package/dist/materialx-loader-types.d.ts +34 -0
  109. package/dist/materialx-loader-types.d.ts.map +1 -0
  110. package/dist/materialx-loader-types.js +20 -0
  111. package/dist/materialx-loader-types.js.map +1 -0
  112. package/dist/materialx-loader.cjs +40 -0
  113. package/dist/materialx-loader.cjs.map +7 -0
  114. package/dist/materialx-loader.d.ts +19 -0
  115. package/dist/materialx-loader.d.ts.map +1 -0
  116. package/dist/materialx-loader.js +14 -0
  117. package/dist/materialx-loader.js.map +1 -0
  118. package/dist/mtl-loader-types.cjs +1 -1
  119. package/dist/obj/mtl-loader-types.cjs +1 -1
  120. package/dist/obj/mtl-loader-types.js +1 -1
  121. package/dist/obj/obj-loader-types.cjs +1 -1
  122. package/dist/obj/obj-loader-types.js +1 -1
  123. package/dist/obj/obj-writer.cjs +1 -1
  124. package/dist/obj/obj-writer.js +1 -1
  125. package/dist/obj-loader-types.cjs +1 -1
  126. package/dist/obj-worker.js +393 -57
  127. package/dist/obj-writer.cjs +1 -1
  128. package/dist/usd/usd-loader-types.cjs +1 -1
  129. package/dist/usd/usd-loader-types.js +1 -1
  130. package/dist/usd-loader-types.cjs +1 -1
  131. package/package.json +11 -5
  132. package/src/gltf/gltf-loader-types.ts +6 -0
  133. package/src/gltf/index.ts +4 -1
  134. package/src/gltf/lib/api/gltf-extensions.ts +7 -2
  135. package/src/gltf/lib/extensions/EXT_texture_webp.ts +3 -0
  136. package/src/gltf/lib/extensions/KHR_accessor_float64.ts +22 -0
  137. package/src/gltf/lib/extensions/KHR_gaussian_splatting.ts +17 -3
  138. package/src/gltf/lib/extensions/MSFT_texture_dds.ts +52 -0
  139. package/src/gltf/lib/extensions/utils/3d-tiles-utils.ts +5 -1
  140. package/src/gltf/lib/parsers/parse-gltf.ts +29 -0
  141. package/src/gltf/lib/types/gltf-ext-gaussian-splatting-schema.ts +1 -1
  142. package/src/gltf/lib/types/gltf-texture-procedurals.ts +67 -0
  143. package/src/gltf/lib/types/gltf-types.ts +8 -0
  144. package/src/gltf/lib/types/gltf-zod-schema.ts +5 -0
  145. package/src/gltf/schema.ts +1 -0
  146. package/src/index.ts +3 -0
  147. package/src/materialx/README.md +5 -0
  148. package/src/materialx/parse-materialx.ts +70 -0
  149. package/src/materialx/procedural-graph.ts +94 -0
  150. package/src/materialx-loader-types.ts +24 -0
  151. package/src/materialx-loader.ts +15 -0
@@ -7617,7 +7617,7 @@ var init_initialize_wasm_module = __esm({
7617
7617
 
7618
7618
  // ../core/src/worker-utils/lib/env-utils/version.ts
7619
7619
  function getVersion() {
7620
- const version2 = false ? NPM_TAG : "5.0.0-beta.2";
7620
+ const version2 = false ? NPM_TAG : "5.0.0-beta.4";
7621
7621
  globalThis._loadersgl_ = globalThis._loadersgl_ || {};
7622
7622
  globalThis._loadersgl_.version ||= version2;
7623
7623
  return version2;
@@ -7688,6 +7688,9 @@ function getTransferList(object2, recursive = true, transfers) {
7688
7688
  else if (ArrayBuffer.isView(value)) {
7689
7689
  if (isTransferable(value.buffer))
7690
7690
  transfersSet.add(value.buffer);
7691
+ } else if (recursive && typeof MessageChannel !== "undefined" && value instanceof MessageChannel) {
7692
+ visit(value.port1);
7693
+ visit(value.port2);
7691
7694
  } else if (recursive && value instanceof Map) {
7692
7695
  for (const [key, item] of value) {
7693
7696
  visit(key);
@@ -7755,16 +7758,16 @@ var init_worker_body = __esm({
7755
7758
  */
7756
7759
  static set onmessage(onMessage) {
7757
7760
  async function handleMessage(message) {
7758
- const parentPort2 = await getParentPort();
7759
- const { type, payload } = parentPort2 ? message : message.data;
7761
+ const parentPort3 = await getParentPort();
7762
+ const { type, payload } = parentPort3 ? message : message.data;
7760
7763
  onMessage(type, payload);
7761
7764
  }
7762
- getParentPort().then((parentPort2) => {
7763
- if (parentPort2) {
7764
- parentPort2.on("message", (message) => {
7765
+ getParentPort().then((parentPort3) => {
7766
+ if (parentPort3) {
7767
+ parentPort3.on("message", (message) => {
7765
7768
  handleMessage(message);
7766
7769
  });
7767
- parentPort2.on("exit", () => console.debug("Node worker closing"));
7770
+ parentPort3.on("exit", () => console.debug("Node worker closing"));
7768
7771
  } else {
7769
7772
  globalThis.onmessage = handleMessage;
7770
7773
  }
@@ -7782,9 +7785,9 @@ var init_worker_body = __esm({
7782
7785
  };
7783
7786
  onMessageWrapperMap.set(onMessage, onMessageWrapper);
7784
7787
  }
7785
- const parentPort2 = await getParentPort();
7786
- if (parentPort2) {
7787
- parentPort2.on("message", onMessageWrapper);
7788
+ const parentPort3 = await getParentPort();
7789
+ if (parentPort3) {
7790
+ parentPort3.on("message", onMessageWrapper);
7788
7791
  } else {
7789
7792
  globalThis.addEventListener("message", onMessageWrapper);
7790
7793
  }
@@ -7795,9 +7798,9 @@ var init_worker_body = __esm({
7795
7798
  if (!onMessageWrapper) {
7796
7799
  return;
7797
7800
  }
7798
- const parentPort2 = await getParentPort();
7799
- if (parentPort2) {
7800
- parentPort2.off("message", onMessageWrapper);
7801
+ const parentPort3 = await getParentPort();
7802
+ if (parentPort3) {
7803
+ parentPort3.off("message", onMessageWrapper);
7801
7804
  } else {
7802
7805
  globalThis.removeEventListener("message", onMessageWrapper);
7803
7806
  }
@@ -7807,12 +7810,12 @@ var init_worker_body = __esm({
7807
7810
  * @param type
7808
7811
  * @param payload
7809
7812
  */
7810
- static async postMessage(type, payload) {
7813
+ static async postMessage(type, payload, copy = false) {
7811
7814
  const data = { source: "loaders.gl", type, payload };
7812
- const transferList = getTransferList(payload);
7813
- const parentPort2 = await getParentPort();
7814
- if (parentPort2) {
7815
- parentPort2.postMessage(data, transferList);
7815
+ const transferList = copy ? [] : getTransferList(payload);
7816
+ const parentPort3 = await getParentPort();
7817
+ if (parentPort3) {
7818
+ parentPort3.postMessage(data, transferList);
7816
7819
  } else {
7817
7820
  globalThis.postMessage(data, transferList);
7818
7821
  }
@@ -7937,8 +7940,19 @@ var init_shared_state = __esm({
7937
7940
  }
7938
7941
  });
7939
7942
 
7943
+ // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/validate-output-ownership.js
7944
+ function validateOutputOwnership(ownership) {
7945
+ if (ownership !== void 0 && ownership !== "copy" && ownership !== "transfer") {
7946
+ throw new Error("Invalid worker output ownership");
7947
+ }
7948
+ }
7949
+ var init_validate_output_ownership = __esm({
7950
+ "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/validate-output-ownership.js"() {
7951
+ }
7952
+ });
7953
+
7940
7954
  // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/create-worker.js
7941
- async function createWorker(process2, processInBatches) {
7955
+ async function createWorker(process2, processInBatches, preload2) {
7942
7956
  if (!await WorkerBody.inWorkerThread()) {
7943
7957
  return;
7944
7958
  }
@@ -7946,7 +7960,7 @@ async function createWorker(process2, processInBatches) {
7946
7960
  process: processOnMainThread
7947
7961
  };
7948
7962
  WorkerBody.onmessage = async (type, payload) => {
7949
- var _a5;
7963
+ var _a5, _b2, _c2, _d2, _e2;
7950
7964
  if (type === "cancel") {
7951
7965
  activeController == null ? void 0 : activeController.abort();
7952
7966
  activeInputBatches == null ? void 0 : activeInputBatches.close();
@@ -7980,10 +7994,12 @@ async function createWorker(process2, processInBatches) {
7980
7994
  }
7981
7995
  switch (type) {
7982
7996
  case "preload":
7997
+ await (preload2 == null ? void 0 : preload2());
7983
7998
  WorkerBody.postMessage("done", {});
7984
7999
  break;
7985
8000
  case "process":
7986
8001
  throwIfAborted();
8002
+ validateOutputOwnership((_b2 = payload.options) == null ? void 0 : _b2["outputOwnership"]);
7987
8003
  if (!process2) {
7988
8004
  throw new Error("Worker does not support atomic processing");
7989
8005
  }
@@ -7993,10 +8009,11 @@ async function createWorker(process2, processInBatches) {
7993
8009
  await WorkerBody.postMessage("done", {
7994
8010
  result,
7995
8011
  executionMs: performance.now() - startedAt
7996
- });
8012
+ }, ((_c2 = payload.options) == null ? void 0 : _c2["outputOwnership"]) === "copy");
7997
8013
  break;
7998
8014
  case "process-in-batches":
7999
8015
  throwIfAborted();
8016
+ validateOutputOwnership((_d2 = payload.options) == null ? void 0 : _d2["outputOwnership"]);
8000
8017
  if (!processInBatches) {
8001
8018
  throw new Error("Worker does not support batched processing");
8002
8019
  }
@@ -8008,7 +8025,7 @@ async function createWorker(process2, processInBatches) {
8008
8025
  const resultIterator = processInBatches(createDemandDrivenIterator(inputBatches), payload.options || {}, jobContext, payload.context || {});
8009
8026
  for await (const batch of resultIterator) {
8010
8027
  throwIfAborted();
8011
- await WorkerBody.postMessage("output-batch", { result: batch });
8028
+ await WorkerBody.postMessage("output-batch", { result: batch }, ((_e2 = payload.options) == null ? void 0 : _e2["outputOwnership"]) === "copy");
8012
8029
  await outputAcknowledgements.next();
8013
8030
  }
8014
8031
  throwIfAborted();
@@ -8106,14 +8123,14 @@ function processOnMainThread(arrayBuffer2, options = {}, jobContext = {}) {
8106
8123
  });
8107
8124
  }
8108
8125
  function createProgressReporter() {
8109
- let pending;
8126
+ let pending2;
8110
8127
  let finished2 = false;
8111
8128
  let scheduled = false;
8112
8129
  const flush = () => {
8113
8130
  scheduled = false;
8114
- if (pending) {
8115
- WorkerBody.postMessage("progress", { progress: pending });
8116
- pending = void 0;
8131
+ if (pending2) {
8132
+ WorkerBody.postMessage("progress", { progress: pending2 });
8133
+ pending2 = void 0;
8117
8134
  }
8118
8135
  };
8119
8136
  return {
@@ -8121,9 +8138,9 @@ function createProgressReporter() {
8121
8138
  report(progress) {
8122
8139
  if (finished2)
8123
8140
  return;
8124
- if (pending && pending.phase !== progress.phase)
8141
+ if (pending2 && pending2.phase !== progress.phase)
8125
8142
  flush();
8126
- pending = { ...progress };
8143
+ pending2 = { ...progress };
8127
8144
  if (!scheduled) {
8128
8145
  scheduled = true;
8129
8146
  setTimeout(flush, 0);
@@ -8132,7 +8149,7 @@ function createProgressReporter() {
8132
8149
  /** Flushes final progress and suppresses reports from stale callbacks. */
8133
8150
  finish(discard = false) {
8134
8151
  if (discard)
8135
- pending = void 0;
8152
+ pending2 = void 0;
8136
8153
  flush();
8137
8154
  finished2 = true;
8138
8155
  }
@@ -8144,6 +8161,7 @@ var init_create_worker = __esm({
8144
8161
  init_shared_state();
8145
8162
  init_async_queue();
8146
8163
  init_worker_body();
8164
+ init_validate_output_ownership();
8147
8165
  requestId = 0;
8148
8166
  activeController = null;
8149
8167
  activeInputBatches = null;
@@ -8155,6 +8173,7 @@ var init_create_worker = __esm({
8155
8173
  var import_meta3, path3, moduleUrl;
8156
8174
  var init_worker_utils = __esm({
8157
8175
  "../../node_modules/@math.gl/core/dist/worker-utils/index.js"() {
8176
+ init_worker_body();
8158
8177
  init_create_worker();
8159
8178
  import_meta3 = {};
8160
8179
  path3 = typeof __filename === "string" ? __filename.replace(/\\/g, "/") : "";
@@ -8162,18 +8181,360 @@ var init_worker_utils = __esm({
8162
8181
  }
8163
8182
  });
8164
8183
 
8184
+ // ../../node_modules/@math.gl/core/dist/tasks/task-preload.js
8185
+ function preloadTaskCode(task, signal) {
8186
+ if (!task.preload)
8187
+ return Promise.resolve();
8188
+ let promise = pending.get(task);
8189
+ if (!promise) {
8190
+ promise = Promise.resolve().then(() => task.preload()).then(() => {
8191
+ loaded.add(task);
8192
+ });
8193
+ pending.set(task, promise);
8194
+ void promise.catch(() => pending.delete(task));
8195
+ }
8196
+ return withSignal(promise, signal);
8197
+ }
8198
+ function withSignal(operation, signal) {
8199
+ if (!signal)
8200
+ return operation;
8201
+ return new Promise((resolve, reject) => {
8202
+ const abort = () => {
8203
+ signal.removeEventListener("abort", abort);
8204
+ reject(signal.reason);
8205
+ };
8206
+ signal.addEventListener("abort", abort, { once: true });
8207
+ if (signal.aborted)
8208
+ abort();
8209
+ operation.then((value) => {
8210
+ signal.removeEventListener("abort", abort);
8211
+ resolve(value);
8212
+ }, (error) => {
8213
+ signal.removeEventListener("abort", abort);
8214
+ reject(error);
8215
+ });
8216
+ });
8217
+ }
8218
+ var pending, loaded;
8219
+ var init_task_preload = __esm({
8220
+ "../../node_modules/@math.gl/core/dist/tasks/task-preload.js"() {
8221
+ pending = /* @__PURE__ */ new WeakMap();
8222
+ loaded = /* @__PURE__ */ new WeakSet();
8223
+ }
8224
+ });
8225
+
8226
+ // ../../node_modules/@math.gl/core/dist/tasks/task-runtime.js
8227
+ function assertPayload(value) {
8228
+ if (!value || typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype) {
8229
+ throw new TypeError("Task payloads must be plain objects with named fields");
8230
+ }
8231
+ }
8232
+ function taskContext(state, context = {}) {
8233
+ const signal = context.signal ?? new AbortController().signal;
8234
+ return {
8235
+ state,
8236
+ signal,
8237
+ throwIfAborted: () => {
8238
+ var _a5;
8239
+ signal.throwIfAborted();
8240
+ (_a5 = context.throwIfAborted) == null ? void 0 : _a5.call(context);
8241
+ },
8242
+ reportProgress: (progress) => {
8243
+ var _a5;
8244
+ return (_a5 = context.reportProgress) == null ? void 0 : _a5.call(context, {
8245
+ ...progress,
8246
+ phase: progress.phase ?? "process",
8247
+ unit: progress.unit ?? "items"
8248
+ });
8249
+ }
8250
+ };
8251
+ }
8252
+ async function initializeTaskWorker(task) {
8253
+ if (!await WorkerBody.inWorkerThread())
8254
+ throw new Error("initializeTaskWorker must run inside a worker");
8255
+ if (installed)
8256
+ throw new Error("A task is already installed in this worker");
8257
+ installed = true;
8258
+ const runtime = new TaskRuntime(task);
8259
+ let streamOptions = {};
8260
+ return createWorker(async (request, _options, context) => {
8261
+ switch (request.operation) {
8262
+ case "initialize":
8263
+ return runtime.initialize(request.input, context);
8264
+ case "destroy":
8265
+ return runtime.destroy();
8266
+ case "stream-options":
8267
+ streamOptions = request.options;
8268
+ return {};
8269
+ case "process":
8270
+ return runtime.process(request.input, request.options, context);
8271
+ default:
8272
+ throw new Error("Unknown task operation");
8273
+ }
8274
+ }, async function* (inputs, _options, context) {
8275
+ async function* batches() {
8276
+ for await (const input of inputs) {
8277
+ assertPayload(input);
8278
+ yield input;
8279
+ }
8280
+ }
8281
+ try {
8282
+ yield* runtime.stream(batches(), streamOptions, context);
8283
+ } finally {
8284
+ streamOptions = {};
8285
+ }
8286
+ }, () => preloadTaskCode(task));
8287
+ }
8288
+ var TaskRuntime, installed;
8289
+ var init_task_runtime = __esm({
8290
+ "../../node_modules/@math.gl/core/dist/tasks/task-runtime.js"() {
8291
+ init_worker_utils();
8292
+ init_task_preload();
8293
+ TaskRuntime = class {
8294
+ constructor(task) {
8295
+ this.task = task;
8296
+ this.initialized = false;
8297
+ }
8298
+ async initialize(input, context = {}) {
8299
+ var _a5, _b2, _c2;
8300
+ if (this.initialized)
8301
+ throw new Error("Task is already initialized");
8302
+ assertPayload(input);
8303
+ await preloadTaskCode(this.task, context.signal);
8304
+ (_a5 = context.signal) == null ? void 0 : _a5.throwIfAborted();
8305
+ this.state = await ((_c2 = (_b2 = this.task).initialize) == null ? void 0 : _c2.call(_b2, input, taskContext(void 0, context)));
8306
+ this.initialized = true;
8307
+ return {};
8308
+ }
8309
+ async destroy() {
8310
+ var _a5, _b2;
8311
+ if (this.initialized) {
8312
+ this.initialized = false;
8313
+ const state = this.state;
8314
+ this.state = void 0;
8315
+ if (this.task.initialize)
8316
+ await ((_b2 = (_a5 = this.task).destroy) == null ? void 0 : _b2.call(_a5, state));
8317
+ }
8318
+ return {};
8319
+ }
8320
+ async process(input, options, context = {}) {
8321
+ if (!this.initialized)
8322
+ throw new Error("Task is not initialized");
8323
+ if (!this.task.process)
8324
+ throw new Error("Task has no atomic processor");
8325
+ assertPayload(input);
8326
+ const result = await this.task.process(input, options, taskContext(this.state, context));
8327
+ assertPayload(result);
8328
+ return result;
8329
+ }
8330
+ async *stream(inputs, options, context = {}) {
8331
+ if (!this.initialized)
8332
+ throw new Error("Task is not initialized");
8333
+ if (!this.task.processInBatches)
8334
+ throw new Error("Task has no streaming processor");
8335
+ for await (const output of this.task.processInBatches(inputs, options, taskContext(this.state, context))) {
8336
+ assertPayload(output);
8337
+ yield output;
8338
+ }
8339
+ }
8340
+ };
8341
+ installed = false;
8342
+ }
8343
+ });
8344
+
8165
8345
  // ../../node_modules/@math.gl/core/dist/tasks/index.js
8166
8346
  var init_tasks = __esm({
8167
8347
  "../../node_modules/@math.gl/core/dist/tasks/index.js"() {
8168
- init_worker_utils();
8348
+ init_task_runtime();
8349
+ }
8350
+ });
8351
+
8352
+ // ../core/src/worker-utils/lib/node/worker_threads.ts
8353
+ var worker_threads_exports = {};
8354
+ __export(worker_threads_exports, {
8355
+ BroadcastChannel: () => import_worker_threads3.BroadcastChannel,
8356
+ MessageChannel: () => import_worker_threads3.MessageChannel,
8357
+ MessagePort: () => import_worker_threads3.MessagePort,
8358
+ NodeWorker: () => NodeWorker,
8359
+ SHARE_ENV: () => import_worker_threads3.SHARE_ENV,
8360
+ Worker: () => import_worker_threads3.Worker,
8361
+ getEnvironmentData: () => import_worker_threads3.getEnvironmentData,
8362
+ isInternalThread: () => isInternalThread2,
8363
+ isMainThread: () => import_worker_threads3.isMainThread,
8364
+ isMarkedAsUntransferable: () => import_worker_threads3.isMarkedAsUntransferable,
8365
+ locks: () => locks2,
8366
+ markAsUncloneable: () => import_worker_threads3.markAsUncloneable,
8367
+ markAsUntransferable: () => import_worker_threads3.markAsUntransferable,
8368
+ moveMessagePortToContext: () => import_worker_threads3.moveMessagePortToContext,
8369
+ parentPort: () => parentPort2,
8370
+ postMessageToThread: () => import_worker_threads3.postMessageToThread,
8371
+ receiveMessageOnPort: () => import_worker_threads3.receiveMessageOnPort,
8372
+ resourceLimits: () => import_worker_threads3.resourceLimits,
8373
+ setEnvironmentData: () => import_worker_threads3.setEnvironmentData,
8374
+ structuredClone: () => structuredClone3,
8375
+ threadId: () => import_worker_threads3.threadId,
8376
+ threadName: () => threadName2,
8377
+ workerData: () => import_worker_threads3.workerData
8378
+ });
8379
+ var WorkerThreads, import_worker_threads3, parentPort2, NodeWorker, isInternalThread2, threadName2, locks2, structuredClone3;
8380
+ var init_worker_threads2 = __esm({
8381
+ "../core/src/worker-utils/lib/node/worker_threads.ts"() {
8382
+ "use strict";
8383
+ WorkerThreads = __toESM(require("worker_threads"), 1);
8384
+ import_worker_threads3 = require("worker_threads");
8385
+ parentPort2 = WorkerThreads == null ? void 0 : WorkerThreads.parentPort;
8386
+ NodeWorker = WorkerThreads.Worker;
8387
+ isInternalThread2 = WorkerThreads.isInternalThread;
8388
+ threadName2 = WorkerThreads.threadName;
8389
+ locks2 = WorkerThreads.locks;
8390
+ structuredClone3 = WorkerThreads.structuredClone;
8391
+ }
8392
+ });
8393
+
8394
+ // ../core/src/worker-utils/lib/worker-api/task-runtime.ts
8395
+ function normalizeTaskProgress(progress) {
8396
+ return { ...progress, phase: progress.phase ?? "process", unit: progress.unit ?? "items" };
8397
+ }
8398
+ async function isWorkerThread() {
8399
+ var _a5;
8400
+ if (typeof self !== "undefined" && typeof document === "undefined" && typeof self.postMessage === "function")
8401
+ return true;
8402
+ if (typeof process !== "undefined" && ((_a5 = process.versions) == null ? void 0 : _a5.node)) {
8403
+ const { isMainThread: isMainThread2 } = await Promise.resolve().then(() => (init_worker_threads2(), worker_threads_exports));
8404
+ return !isMainThread2;
8405
+ }
8406
+ return false;
8407
+ }
8408
+ var initializeTaskWorker2;
8409
+ var init_task_runtime2 = __esm({
8410
+ "../core/src/worker-utils/lib/worker-api/task-runtime.ts"() {
8411
+ "use strict";
8412
+ init_tasks();
8413
+ initializeTaskWorker2 = initializeTaskWorker;
8414
+ }
8415
+ });
8416
+
8417
+ // ../core/src/worker-utils/lib/worker-utils/get-transfer-list.ts
8418
+ function getTransferList2(object2, recursive = true, transfers) {
8419
+ const transfersSet = transfers || /* @__PURE__ */ new Set();
8420
+ if (!object2) {
8421
+ } else if (isTransferable2(object2)) {
8422
+ transfersSet.add(object2);
8423
+ } else if (isTransferable2(object2.buffer)) {
8424
+ transfersSet.add(object2.buffer);
8425
+ } else if (ArrayBuffer.isView(object2)) {
8426
+ } else if (recursive && typeof object2 === "object") {
8427
+ for (const key in object2) {
8428
+ getTransferList2(object2[key], recursive, transfersSet);
8429
+ }
8430
+ }
8431
+ return transfers === void 0 ? Array.from(transfersSet) : [];
8432
+ }
8433
+ function isTransferable2(object2) {
8434
+ if (!object2) {
8435
+ return false;
8436
+ }
8437
+ if (object2 instanceof ArrayBuffer) {
8438
+ return true;
8439
+ }
8440
+ if (typeof MessagePort !== "undefined" && object2 instanceof MessagePort) {
8441
+ return true;
8442
+ }
8443
+ if (typeof ImageBitmap !== "undefined" && object2 instanceof ImageBitmap) {
8444
+ return true;
8445
+ }
8446
+ if (typeof OffscreenCanvas !== "undefined" && object2 instanceof OffscreenCanvas) {
8447
+ return true;
8448
+ }
8449
+ return false;
8450
+ }
8451
+ var init_get_transfer_list2 = __esm({
8452
+ "../core/src/worker-utils/lib/worker-utils/get-transfer-list.ts"() {
8453
+ "use strict";
8169
8454
  }
8170
8455
  });
8171
8456
 
8172
8457
  // ../core/src/worker-utils/lib/worker-api/create-worker.ts
8458
+ async function createWorker2(process2, processInBatches) {
8459
+ if (!await isWorkerThread()) return;
8460
+ await initializeTaskWorker2(createWorkerTask(process2, processInBatches));
8461
+ }
8462
+ function createWorkerTask(process2, processInBatches) {
8463
+ return {
8464
+ id: "loaders.gl",
8465
+ initialize: (state) => state,
8466
+ destroy: (state) => {
8467
+ var _a5;
8468
+ return (_a5 = state.port) == null ? void 0 : _a5.close();
8469
+ },
8470
+ process: async ({ value }, options, context) => {
8471
+ if (!process2) throw new Error("Worker does not support atomic processing");
8472
+ return { value: await process2(value, options, createContext(context), context.state.context) };
8473
+ },
8474
+ ...processInBatches ? {
8475
+ processInBatches: async function* (inputs, options, context) {
8476
+ async function* values() {
8477
+ for await (const input of inputs) yield input.value;
8478
+ }
8479
+ for await (const value of processInBatches(
8480
+ values(),
8481
+ options,
8482
+ createContext(context),
8483
+ context.state.context
8484
+ )) {
8485
+ yield { value };
8486
+ }
8487
+ }
8488
+ } : {}
8489
+ };
8490
+ }
8491
+ function createContext(context) {
8492
+ let requestIdentifier = 0;
8493
+ const port = context.state.port;
8494
+ return {
8495
+ signal: context.signal,
8496
+ throwIfAborted: () => context.throwIfAborted(),
8497
+ reportProgress: (progress) => context.reportProgress(normalizeTaskProgress(progress)),
8498
+ process: port ? (input, options = {}, jobContext = {}) => {
8499
+ context.throwIfAborted();
8500
+ const identifier = ++requestIdentifier;
8501
+ return new Promise((resolve, reject) => {
8502
+ const onMessage = (event) => {
8503
+ if (event.data.identifier !== identifier) return;
8504
+ cleanup();
8505
+ if (event.data.error) {
8506
+ const error = new Error(event.data.error.message);
8507
+ error.name = event.data.error.name;
8508
+ reject(error);
8509
+ } else resolve(event.data.value);
8510
+ };
8511
+ const onAbort = () => {
8512
+ cleanup();
8513
+ reject(context.signal.reason);
8514
+ };
8515
+ const cleanup = () => {
8516
+ port.removeEventListener("message", onMessage);
8517
+ context.signal.removeEventListener("abort", onAbort);
8518
+ };
8519
+ port.addEventListener("message", onMessage);
8520
+ context.signal.addEventListener("abort", onAbort, { once: true });
8521
+ port.start();
8522
+ try {
8523
+ const request = { identifier, input, options, context: jobContext };
8524
+ port.postMessage(request, getTransferList2(request));
8525
+ } catch (error) {
8526
+ cleanup();
8527
+ reject(error);
8528
+ }
8529
+ });
8530
+ } : void 0
8531
+ };
8532
+ }
8173
8533
  var init_create_worker2 = __esm({
8174
8534
  "../core/src/worker-utils/lib/worker-api/create-worker.ts"() {
8175
8535
  "use strict";
8176
- init_tasks();
8536
+ init_task_runtime2();
8537
+ init_get_transfer_list2();
8177
8538
  }
8178
8539
  });
8179
8540
 
@@ -8352,7 +8713,7 @@ var init_worker_utils2 = __esm({
8352
8713
 
8353
8714
  // ../core/src/loader-utils/lib/worker-loader-utils/create-loader-worker.ts
8354
8715
  async function createLoaderWorker(loader, selectLoader = () => loader) {
8355
- await createWorker(
8716
+ await createWorker2(
8356
8717
  (input, options, workerContext, loaderContext) => processLoaderWorkerData(
8357
8718
  selectLoader(options || {}),
8358
8719
  input,
@@ -16394,11 +16755,11 @@ var init_builder = __esm({
16394
16755
  this._offsets = new OffsetsBufferBuilder(opts.type);
16395
16756
  }
16396
16757
  setValue(index2, value) {
16397
- const pending = this._pending || (this._pending = /* @__PURE__ */ new Map());
16398
- const current = pending.get(index2);
16758
+ const pending2 = this._pending || (this._pending = /* @__PURE__ */ new Map());
16759
+ const current = pending2.get(index2);
16399
16760
  current && (this._pendingLength -= current.length);
16400
16761
  this._pendingLength += value instanceof MapRow ? value[kKeys].length : value.length;
16401
- pending.set(index2, value);
16762
+ pending2.set(index2, value);
16402
16763
  }
16403
16764
  setValid(index2, isValid) {
16404
16765
  if (!super.setValid(index2, isValid)) {
@@ -16421,12 +16782,12 @@ var init_builder = __esm({
16421
16782
  return super.finish();
16422
16783
  }
16423
16784
  _flush() {
16424
- const pending = this._pending;
16785
+ const pending2 = this._pending;
16425
16786
  const pendingLength = this._pendingLength;
16426
16787
  this._pendingLength = 0;
16427
16788
  this._pending = void 0;
16428
- if (pending && pending.size > 0) {
16429
- this._flushPending(pending, pendingLength);
16789
+ if (pending2 && pending2.size > 0) {
16790
+ this._flushPending(pending2, pendingLength);
16430
16791
  }
16431
16792
  return this;
16432
16793
  }
@@ -19012,11 +19373,11 @@ var init_binary2 = __esm({
19012
19373
  setValue(index2, value) {
19013
19374
  return super.setValue(index2, toUint8Array2(value));
19014
19375
  }
19015
- _flushPending(pending, pendingLength) {
19376
+ _flushPending(pending2, pendingLength) {
19016
19377
  const offsets = this._offsets;
19017
19378
  const data = this._values.reserve(pendingLength).buffer;
19018
19379
  let offset = 0;
19019
- for (const [index2, value] of pending) {
19380
+ for (const [index2, value] of pending2) {
19020
19381
  if (value === void 0) {
19021
19382
  offsets.set(index2, 0);
19022
19383
  } else {
@@ -19053,11 +19414,11 @@ var init_largebinary = __esm({
19053
19414
  setValue(index2, value) {
19054
19415
  return super.setValue(index2, toUint8Array2(value));
19055
19416
  }
19056
- _flushPending(pending, pendingLength) {
19417
+ _flushPending(pending2, pendingLength) {
19057
19418
  const offsets = this._offsets;
19058
19419
  const data = this._values.reserve(pendingLength).buffer;
19059
19420
  let offset = 0;
19060
- for (const [index2, value] of pending) {
19421
+ for (const [index2, value] of pending2) {
19061
19422
  if (value === void 0) {
19062
19423
  offsets.set(index2, BigInt(0));
19063
19424
  } else {
@@ -19368,10 +19729,10 @@ var init_list2 = __esm({
19368
19729
  this.type = new List2(new Field2(name, child.type, true));
19369
19730
  return this.numChildren - 1;
19370
19731
  }
19371
- _flushPending(pending) {
19732
+ _flushPending(pending2) {
19372
19733
  const offsets = this._offsets;
19373
19734
  const [child] = this.children;
19374
- for (const [index2, value] of pending) {
19735
+ for (const [index2, value] of pending2) {
19375
19736
  if (typeof value === "undefined") {
19376
19737
  offsets.set(index2, 0);
19377
19738
  } else {
@@ -19410,10 +19771,10 @@ var init_largelist = __esm({
19410
19771
  this.type = new LargeList2(new Field2(name, child.type, true));
19411
19772
  return this.numChildren - 1;
19412
19773
  }
19413
- _flushPending(pending) {
19774
+ _flushPending(pending2) {
19414
19775
  const offsets = this._offsets;
19415
19776
  const [child] = this.children;
19416
- for (const [index2, value] of pending) {
19777
+ for (const [index2, value] of pending2) {
19417
19778
  if (typeof value === "undefined") {
19418
19779
  offsets.set(index2, BigInt(0));
19419
19780
  } else {
@@ -19443,11 +19804,11 @@ var init_map3 = __esm({
19443
19804
  }
19444
19805
  setValue(index2, value) {
19445
19806
  const row = value instanceof Map ? value : new Map(Object.entries(value));
19446
- const pending = this._pending || (this._pending = /* @__PURE__ */ new Map());
19447
- const current = pending.get(index2);
19807
+ const pending2 = this._pending || (this._pending = /* @__PURE__ */ new Map());
19808
+ const current = pending2.get(index2);
19448
19809
  current && (this._pendingLength -= current.size);
19449
19810
  this._pendingLength += row.size;
19450
- pending.set(index2, row);
19811
+ pending2.set(index2, row);
19451
19812
  }
19452
19813
  addChild(child, name = `${this.numChildren}`) {
19453
19814
  if (this.numChildren > 0) {
@@ -19457,10 +19818,10 @@ var init_map3 = __esm({
19457
19818
  this.type = new Map_(new Field2(name, child.type, true), this.type.keysSorted);
19458
19819
  return this.numChildren - 1;
19459
19820
  }
19460
- _flushPending(pending) {
19821
+ _flushPending(pending2) {
19461
19822
  const offsets = this._offsets;
19462
19823
  const [child] = this.children;
19463
- for (const [index2, value] of pending) {
19824
+ for (const [index2, value] of pending2) {
19464
19825
  if (value === void 0) {
19465
19826
  offsets.set(index2, 0);
19466
19827
  } else {
@@ -19669,7 +20030,7 @@ var init_utf83 = __esm({
19669
20030
  return super.setValue(index2, encodeUtf8(value));
19670
20031
  }
19671
20032
  // @ts-ignore
19672
- _flushPending(pending, pendingLength) {
20033
+ _flushPending(pending2, pendingLength) {
19673
20034
  }
19674
20035
  };
19675
20036
  Utf8Builder.prototype._flushPending = BinaryBuilder.prototype._flushPending;
@@ -19700,7 +20061,7 @@ var init_largeutf8 = __esm({
19700
20061
  return super.setValue(index2, encodeUtf8(value));
19701
20062
  }
19702
20063
  // @ts-ignore
19703
- _flushPending(pending, pendingLength) {
20064
+ _flushPending(pending2, pendingLength) {
19704
20065
  }
19705
20066
  };
19706
20067
  LargeUtf8Builder.prototype._flushPending = LargeBinaryBuilder.prototype._flushPending;
@@ -25851,7 +26212,7 @@ var VERSION2;
25851
26212
  var init_version2 = __esm({
25852
26213
  "src/draco/lib/utils/version.ts"() {
25853
26214
  "use strict";
25854
- VERSION2 = true ? "5.0.0-beta.2" : "latest";
26215
+ VERSION2 = true ? "5.0.0-beta.4" : "latest";
25855
26216
  }
25856
26217
  });
25857
26218