@loaders.gl/pointclouds 5.0.0-beta.1 → 5.0.0-beta.10

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 (372) hide show
  1. package/LAS-README.md +1 -1
  2. package/PCD-README.md +1 -1
  3. package/PLY-README.md +1 -1
  4. package/README.md +5 -1
  5. package/dist/dist.dev.js +3584 -2211
  6. package/dist/dist.min.js +20 -20
  7. package/dist/index.cjs +0 -6
  8. package/dist/index.cjs.map +2 -2
  9. package/dist/index.d.ts +3 -3
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +3 -3
  12. package/dist/index.js.map +1 -1
  13. package/dist/las/bundled.cjs +0 -3
  14. package/dist/las/bundled.cjs.map +2 -2
  15. package/dist/las/bundled.d.ts +0 -1
  16. package/dist/las/bundled.d.ts.map +1 -1
  17. package/dist/las/bundled.js +0 -1
  18. package/dist/las/bundled.js.map +1 -1
  19. package/dist/las/index.cjs +0 -3
  20. package/dist/las/index.cjs.map +3 -3
  21. package/dist/las/index.d.ts +0 -2
  22. package/dist/las/index.d.ts.map +1 -1
  23. package/dist/las/index.js +0 -3
  24. package/dist/las/index.js.map +1 -1
  25. package/dist/las/las-copc-loader-types.cjs +1 -1
  26. package/dist/las/las-copc-loader-types.cjs.map +2 -2
  27. package/dist/las/las-copc-loader-types.d.ts +13 -9
  28. package/dist/las/las-copc-loader-types.d.ts.map +1 -1
  29. package/dist/las/las-copc-loader-types.js +1 -1
  30. package/dist/las/las-copc-loader-types.js.map +1 -1
  31. package/dist/las/las-copc-loader.cjs +8 -5
  32. package/dist/las/las-copc-loader.cjs.map +2 -2
  33. package/dist/las/las-copc-loader.d.ts +8 -6
  34. package/dist/las/las-copc-loader.d.ts.map +1 -1
  35. package/dist/las/las-copc-loader.js +11 -6
  36. package/dist/las/las-copc-loader.js.map +1 -1
  37. package/dist/las/las-loader-shared.cjs +4 -2
  38. package/dist/las/las-loader-shared.cjs.map +2 -2
  39. package/dist/las/las-loader-shared.d.ts +9 -7
  40. package/dist/las/las-loader-shared.d.ts.map +1 -1
  41. package/dist/las/las-loader-shared.js +4 -2
  42. package/dist/las/las-loader-shared.js.map +1 -1
  43. package/dist/las/las-loader-types.cjs +3 -6
  44. package/dist/las/las-loader-types.cjs.map +2 -2
  45. package/dist/las/las-loader-types.d.ts +18 -45
  46. package/dist/las/las-loader-types.d.ts.map +1 -1
  47. package/dist/las/las-loader-types.js +1 -3
  48. package/dist/las/las-loader-types.js.map +1 -1
  49. package/dist/las/las-loader.cjs +61 -13
  50. package/dist/las/las-loader.cjs.map +3 -3
  51. package/dist/las/las-loader.d.ts +51 -5
  52. package/dist/las/las-loader.d.ts.map +1 -1
  53. package/dist/las/las-loader.js +56 -6
  54. package/dist/las/las-loader.js.map +1 -1
  55. package/dist/las/las-writer.cjs +3 -3
  56. package/dist/las/las-writer.cjs.map +2 -2
  57. package/dist/las/las-writer.d.ts +4 -3
  58. package/dist/las/las-writer.d.ts.map +1 -1
  59. package/dist/las/las-writer.js +4 -6
  60. package/dist/las/las-writer.js.map +1 -1
  61. package/dist/las/laz-rs-loader-types.cjs +1 -1
  62. package/dist/las/laz-rs-loader-types.cjs.map +2 -2
  63. package/dist/las/laz-rs-loader-types.d.ts +13 -9
  64. package/dist/las/laz-rs-loader-types.d.ts.map +1 -1
  65. package/dist/las/laz-rs-loader-types.js +1 -1
  66. package/dist/las/laz-rs-loader-types.js.map +1 -1
  67. package/dist/las/laz-rs-loader.cjs +8 -5
  68. package/dist/las/laz-rs-loader.cjs.map +2 -2
  69. package/dist/las/laz-rs-loader.d.ts +8 -6
  70. package/dist/las/laz-rs-loader.d.ts.map +1 -1
  71. package/dist/las/laz-rs-loader.js +11 -6
  72. package/dist/las/laz-rs-loader.js.map +1 -1
  73. package/dist/las/lazperf-loader-types.cjs +1 -1
  74. package/dist/las/lazperf-loader-types.cjs.map +2 -2
  75. package/dist/las/lazperf-loader-types.d.ts +14 -10
  76. package/dist/las/lazperf-loader-types.d.ts.map +1 -1
  77. package/dist/las/lazperf-loader-types.js +1 -1
  78. package/dist/las/lazperf-loader-types.js.map +1 -1
  79. package/dist/las/lazperf-loader.cjs +9 -6
  80. package/dist/las/lazperf-loader.cjs.map +2 -2
  81. package/dist/las/lazperf-loader.d.ts +9 -7
  82. package/dist/las/lazperf-loader.d.ts.map +1 -1
  83. package/dist/las/lazperf-loader.js +12 -7
  84. package/dist/las/lazperf-loader.js.map +1 -1
  85. package/dist/las/lib/copc/parse-las.cjs +1 -1
  86. package/dist/las/lib/copc/parse-las.cjs.map +2 -2
  87. package/dist/las/lib/copc/parse-las.js +1 -1
  88. package/dist/las/lib/copc/parse-las.js.map +1 -1
  89. package/dist/las/lib/get-las-schema.cjs +5 -0
  90. package/dist/las/lib/get-las-schema.cjs.map +2 -2
  91. package/dist/las/lib/get-las-schema.d.ts.map +1 -1
  92. package/dist/las/lib/get-las-schema.js +6 -0
  93. package/dist/las/lib/get-las-schema.js.map +1 -1
  94. package/dist/las/lib/las-extra-bytes.cjs +6 -1
  95. package/dist/las/lib/las-extra-bytes.cjs.map +2 -2
  96. package/dist/las/lib/las-extra-bytes.d.ts.map +1 -1
  97. package/dist/las/lib/las-extra-bytes.js +6 -4
  98. package/dist/las/lib/las-extra-bytes.js.map +1 -1
  99. package/dist/las/lib/laz-perf/parse-las.cjs +9 -8
  100. package/dist/las/lib/laz-perf/parse-las.cjs.map +3 -3
  101. package/dist/las/lib/laz-perf/parse-las.js +9 -8
  102. package/dist/las/lib/laz-perf/parse-las.js.map +1 -1
  103. package/dist/las/lib/laz-rs-wasm/parse-las.cjs +9 -8
  104. package/dist/las/lib/laz-rs-wasm/parse-las.cjs.map +3 -3
  105. package/dist/las/lib/laz-rs-wasm/parse-las.js +9 -8
  106. package/dist/las/lib/laz-rs-wasm/parse-las.js.map +1 -1
  107. package/dist/las/lib/typescript/parse-las.cjs +135 -13
  108. package/dist/las/lib/typescript/parse-las.cjs.map +3 -3
  109. package/dist/las/lib/typescript/parse-las.d.ts.map +1 -1
  110. package/dist/las/lib/typescript/parse-las.js +106 -10
  111. package/dist/las/lib/typescript/parse-las.js.map +1 -1
  112. package/dist/las/unbundled.cjs +0 -2
  113. package/dist/las/unbundled.cjs.map +2 -2
  114. package/dist/las/unbundled.d.ts +1 -1
  115. package/dist/las/unbundled.d.ts.map +1 -1
  116. package/dist/las/unbundled.js +1 -1
  117. package/dist/las/unbundled.js.map +1 -1
  118. package/dist/las/workers/las-worker.cjs +5 -5
  119. package/dist/las/workers/las-worker.cjs.map +2 -2
  120. package/dist/las/workers/las-worker.js +6 -6
  121. package/dist/las/workers/las-worker.js.map +1 -1
  122. package/dist/las-copc-loader-types.cjs +51 -0
  123. package/dist/las-copc-loader-types.cjs.map +7 -0
  124. package/dist/las-copc-loader-types.d.ts +2 -0
  125. package/dist/las-copc-loader-types.d.ts.map +1 -0
  126. package/dist/las-copc-loader-types.js +2 -0
  127. package/dist/las-copc-loader-types.js.map +1 -0
  128. package/dist/las-copc-loader.cjs +62 -0
  129. package/dist/las-copc-loader.cjs.map +7 -0
  130. package/dist/las-copc-loader.d.ts +2 -0
  131. package/dist/las-copc-loader.d.ts.map +1 -0
  132. package/dist/las-copc-loader.js +2 -0
  133. package/dist/las-copc-loader.js.map +1 -0
  134. package/dist/las-loader-types.cjs +53 -0
  135. package/dist/las-loader-types.cjs.map +7 -0
  136. package/dist/las-loader-types.d.ts +2 -0
  137. package/dist/las-loader-types.d.ts.map +1 -0
  138. package/dist/las-loader-types.js +2 -0
  139. package/dist/las-loader-types.js.map +1 -0
  140. package/dist/las-loader.cjs +130 -0
  141. package/dist/las-loader.cjs.map +7 -0
  142. package/dist/las-loader.d.ts +2 -0
  143. package/dist/las-loader.d.ts.map +1 -0
  144. package/dist/las-loader.js +2 -0
  145. package/dist/las-loader.js.map +1 -0
  146. package/dist/las-worker.js +1219 -253
  147. package/dist/las-writer.cjs +1056 -0
  148. package/dist/las-writer.cjs.map +7 -0
  149. package/dist/las-writer.d.ts +2 -0
  150. package/dist/las-writer.d.ts.map +1 -0
  151. package/dist/las-writer.js +2 -0
  152. package/dist/las-writer.js.map +1 -0
  153. package/dist/laz-rs-loader-types.cjs +51 -0
  154. package/dist/laz-rs-loader-types.cjs.map +7 -0
  155. package/dist/laz-rs-loader-types.d.ts +2 -0
  156. package/dist/laz-rs-loader-types.d.ts.map +1 -0
  157. package/dist/laz-rs-loader-types.js +2 -0
  158. package/dist/laz-rs-loader-types.js.map +1 -0
  159. package/dist/laz-rs-loader.cjs +277 -0
  160. package/dist/laz-rs-loader.cjs.map +7 -0
  161. package/dist/laz-rs-loader.d.ts +2 -0
  162. package/dist/laz-rs-loader.d.ts.map +1 -0
  163. package/dist/laz-rs-loader.js +2 -0
  164. package/dist/laz-rs-loader.js.map +1 -0
  165. package/dist/lazperf-loader-types.cjs +51 -0
  166. package/dist/lazperf-loader-types.cjs.map +7 -0
  167. package/dist/lazperf-loader-types.d.ts +2 -0
  168. package/dist/lazperf-loader-types.d.ts.map +1 -0
  169. package/dist/lazperf-loader-types.js +2 -0
  170. package/dist/lazperf-loader-types.js.map +1 -0
  171. package/dist/lazperf-loader.cjs +65 -0
  172. package/dist/lazperf-loader.cjs.map +7 -0
  173. package/dist/lazperf-loader.d.ts +2 -0
  174. package/dist/lazperf-loader.d.ts.map +1 -0
  175. package/dist/lazperf-loader.js +2 -0
  176. package/dist/lazperf-loader.js.map +1 -0
  177. package/dist/pcd/bundled.cjs +2 -4
  178. package/dist/pcd/bundled.cjs.map +2 -2
  179. package/dist/pcd/bundled.d.ts +1 -1
  180. package/dist/pcd/bundled.d.ts.map +1 -1
  181. package/dist/pcd/bundled.js +1 -1
  182. package/dist/pcd/bundled.js.map +1 -1
  183. package/dist/pcd/index.cjs +0 -3
  184. package/dist/pcd/index.cjs.map +3 -3
  185. package/dist/pcd/index.d.ts +0 -2
  186. package/dist/pcd/index.d.ts.map +1 -1
  187. package/dist/pcd/index.js +0 -3
  188. package/dist/pcd/index.js.map +1 -1
  189. package/dist/pcd/pcd-loader-types.cjs +9 -10
  190. package/dist/pcd/pcd-loader-types.cjs.map +2 -2
  191. package/dist/pcd/pcd-loader-types.d.ts +18 -41
  192. package/dist/pcd/pcd-loader-types.d.ts.map +1 -1
  193. package/dist/pcd/pcd-loader-types.js +6 -6
  194. package/dist/pcd/pcd-loader-types.js.map +1 -1
  195. package/dist/pcd/pcd-loader.cjs +82 -25
  196. package/dist/pcd/pcd-loader.cjs.map +3 -3
  197. package/dist/pcd/pcd-loader.d.ts +42 -6
  198. package/dist/pcd/pcd-loader.d.ts.map +1 -1
  199. package/dist/pcd/pcd-loader.js +72 -21
  200. package/dist/pcd/pcd-loader.js.map +1 -1
  201. package/dist/pcd/pcd-writer.cjs +3 -3
  202. package/dist/pcd/pcd-writer.cjs.map +2 -2
  203. package/dist/pcd/pcd-writer.d.ts +5 -4
  204. package/dist/pcd/pcd-writer.d.ts.map +1 -1
  205. package/dist/pcd/pcd-writer.js +4 -4
  206. package/dist/pcd/pcd-writer.js.map +1 -1
  207. package/dist/pcd/unbundled.cjs +2 -4
  208. package/dist/pcd/unbundled.cjs.map +2 -2
  209. package/dist/pcd/unbundled.d.ts +1 -1
  210. package/dist/pcd/unbundled.d.ts.map +1 -1
  211. package/dist/pcd/unbundled.js +1 -1
  212. package/dist/pcd/unbundled.js.map +1 -1
  213. package/dist/pcd/workers/pcd-worker.cjs +5 -5
  214. package/dist/pcd/workers/pcd-worker.cjs.map +2 -2
  215. package/dist/pcd/workers/pcd-worker.js +6 -6
  216. package/dist/pcd/workers/pcd-worker.js.map +1 -1
  217. package/dist/pcd-loader-types.cjs +65 -0
  218. package/dist/pcd-loader-types.cjs.map +7 -0
  219. package/dist/pcd-loader-types.d.ts +2 -0
  220. package/dist/pcd-loader-types.d.ts.map +1 -0
  221. package/dist/pcd-loader-types.js +2 -0
  222. package/dist/pcd-loader-types.js.map +1 -0
  223. package/dist/pcd-loader.cjs +203 -0
  224. package/dist/pcd-loader.cjs.map +7 -0
  225. package/dist/pcd-loader.d.ts +2 -0
  226. package/dist/pcd-loader.d.ts.map +1 -0
  227. package/dist/pcd-loader.js +2 -0
  228. package/dist/pcd-loader.js.map +1 -0
  229. package/dist/pcd-worker.js +1457 -418
  230. package/dist/pcd-writer.cjs +136 -0
  231. package/dist/pcd-writer.cjs.map +7 -0
  232. package/dist/pcd-writer.d.ts +2 -0
  233. package/dist/pcd-writer.d.ts.map +1 -0
  234. package/dist/pcd-writer.js +2 -0
  235. package/dist/pcd-writer.js.map +1 -0
  236. package/dist/ply/bundled.cjs +2 -4
  237. package/dist/ply/bundled.cjs.map +2 -2
  238. package/dist/ply/bundled.d.ts +1 -1
  239. package/dist/ply/bundled.d.ts.map +1 -1
  240. package/dist/ply/bundled.js +1 -1
  241. package/dist/ply/bundled.js.map +1 -1
  242. package/dist/ply/index.cjs +0 -3
  243. package/dist/ply/index.cjs.map +3 -3
  244. package/dist/ply/index.d.ts +0 -2
  245. package/dist/ply/index.d.ts.map +1 -1
  246. package/dist/ply/index.js +0 -3
  247. package/dist/ply/index.js.map +1 -1
  248. package/dist/ply/lib/get-ply-schema.cjs +4 -2
  249. package/dist/ply/lib/get-ply-schema.cjs.map +2 -2
  250. package/dist/ply/lib/get-ply-schema.d.ts +6 -0
  251. package/dist/ply/lib/get-ply-schema.d.ts.map +1 -1
  252. package/dist/ply/lib/get-ply-schema.js +1 -1
  253. package/dist/ply/lib/get-ply-schema.js.map +1 -1
  254. package/dist/ply/lib/parse-ply-arrow.cjs +1 -1
  255. package/dist/ply/lib/parse-ply-arrow.cjs.map +2 -2
  256. package/dist/ply/lib/parse-ply-arrow.js +2 -2
  257. package/dist/ply/lib/parse-ply-arrow.js.map +1 -1
  258. package/dist/ply/lib/parse-ply-in-batches.cjs +14 -8
  259. package/dist/ply/lib/parse-ply-in-batches.cjs.map +3 -3
  260. package/dist/ply/lib/parse-ply-in-batches.d.ts.map +1 -1
  261. package/dist/ply/lib/parse-ply-in-batches.js +9 -4
  262. package/dist/ply/lib/parse-ply-in-batches.js.map +1 -1
  263. package/dist/ply/lib/parse-ply.cjs +3 -0
  264. package/dist/ply/lib/parse-ply.cjs.map +2 -2
  265. package/dist/ply/lib/parse-ply.d.ts +1 -1
  266. package/dist/ply/lib/parse-ply.d.ts.map +1 -1
  267. package/dist/ply/lib/parse-ply.js +4 -0
  268. package/dist/ply/lib/parse-ply.js.map +1 -1
  269. package/dist/ply/ply-loader-types.cjs +9 -10
  270. package/dist/ply/ply-loader-types.cjs.map +2 -2
  271. package/dist/ply/ply-loader-types.d.ts +19 -42
  272. package/dist/ply/ply-loader-types.d.ts.map +1 -1
  273. package/dist/ply/ply-loader-types.js +6 -6
  274. package/dist/ply/ply-loader-types.js.map +1 -1
  275. package/dist/ply/ply-loader.cjs +82 -24
  276. package/dist/ply/ply-loader.cjs.map +3 -3
  277. package/dist/ply/ply-loader.d.ts +43 -6
  278. package/dist/ply/ply-loader.d.ts.map +1 -1
  279. package/dist/ply/ply-loader.js +71 -19
  280. package/dist/ply/ply-loader.js.map +1 -1
  281. package/dist/ply/ply-writer.cjs +3 -3
  282. package/dist/ply/ply-writer.cjs.map +2 -2
  283. package/dist/ply/ply-writer.d.ts +5 -4
  284. package/dist/ply/ply-writer.d.ts.map +1 -1
  285. package/dist/ply/ply-writer.js +4 -4
  286. package/dist/ply/ply-writer.js.map +1 -1
  287. package/dist/ply/unbundled.cjs +2 -4
  288. package/dist/ply/unbundled.cjs.map +2 -2
  289. package/dist/ply/unbundled.d.ts +1 -1
  290. package/dist/ply/unbundled.d.ts.map +1 -1
  291. package/dist/ply/unbundled.js +1 -1
  292. package/dist/ply/unbundled.js.map +1 -1
  293. package/dist/ply/workers/ply-worker.cjs +6 -6
  294. package/dist/ply/workers/ply-worker.cjs.map +2 -2
  295. package/dist/ply/workers/ply-worker.js +8 -8
  296. package/dist/ply/workers/ply-worker.js.map +1 -1
  297. package/dist/ply-loader-types.cjs +66 -0
  298. package/dist/ply-loader-types.cjs.map +7 -0
  299. package/dist/ply-loader-types.d.ts +2 -0
  300. package/dist/ply-loader-types.d.ts.map +1 -0
  301. package/dist/ply-loader-types.js +2 -0
  302. package/dist/ply-loader-types.js.map +1 -0
  303. package/dist/ply-loader.cjs +194 -0
  304. package/dist/ply-loader.cjs.map +7 -0
  305. package/dist/ply-loader.d.ts +2 -0
  306. package/dist/ply-loader.d.ts.map +1 -0
  307. package/dist/ply-loader.js +2 -0
  308. package/dist/ply-loader.js.map +1 -0
  309. package/dist/ply-worker.js +2099 -312
  310. package/dist/ply-writer.cjs +177 -0
  311. package/dist/ply-writer.cjs.map +7 -0
  312. package/dist/ply-writer.d.ts +2 -0
  313. package/dist/ply-writer.d.ts.map +1 -0
  314. package/dist/ply-writer.js +2 -0
  315. package/dist/ply-writer.js.map +1 -0
  316. package/package.json +75 -71
  317. package/src/index.ts +3 -3
  318. package/src/las/bundled.ts +0 -1
  319. package/src/las/index.ts +0 -4
  320. package/src/las/las-copc-loader-types.ts +3 -3
  321. package/src/las/las-copc-loader.ts +12 -12
  322. package/src/las/las-loader-shared.ts +9 -7
  323. package/src/las/las-loader-types.ts +3 -6
  324. package/src/las/las-loader.ts +63 -9
  325. package/src/las/las-writer.ts +17 -13
  326. package/src/las/laz-rs-loader-types.ts +3 -3
  327. package/src/las/laz-rs-loader.ts +11 -11
  328. package/src/las/lazperf-loader-types.ts +3 -3
  329. package/src/las/lazperf-loader.ts +13 -13
  330. package/src/las/lib/copc/parse-las.ts +1 -1
  331. package/src/las/lib/get-las-schema.ts +5 -0
  332. package/src/las/lib/las-extra-bytes.ts +6 -4
  333. package/src/las/lib/laz-perf/parse-las.ts +8 -9
  334. package/src/las/lib/laz-rs-wasm/parse-las.ts +8 -9
  335. package/src/las/lib/typescript/parse-las.ts +143 -11
  336. package/src/las/libs/laz-rs-wasm/README.md +5 -0
  337. package/src/las/libs/laz-rs-wasm/package.json +6 -0
  338. package/src/las/unbundled.ts +1 -1
  339. package/src/las/workers/las-worker.ts +6 -6
  340. package/src/las-copc-loader-types.ts +1 -0
  341. package/src/las-copc-loader.ts +1 -0
  342. package/src/las-loader-types.ts +1 -0
  343. package/src/las-loader.ts +1 -0
  344. package/src/las-writer.ts +1 -0
  345. package/src/laz-rs-loader-types.ts +1 -0
  346. package/src/laz-rs-loader.ts +1 -0
  347. package/src/lazperf-loader-types.ts +1 -0
  348. package/src/lazperf-loader.ts +1 -0
  349. package/src/pcd/bundled.ts +1 -4
  350. package/src/pcd/index.ts +0 -4
  351. package/src/pcd/pcd-loader-types.ts +10 -11
  352. package/src/pcd/pcd-loader.ts +97 -29
  353. package/src/pcd/pcd-writer.ts +12 -8
  354. package/src/pcd/unbundled.ts +1 -1
  355. package/src/pcd/workers/pcd-worker.ts +6 -6
  356. package/src/pcd-loader-types.ts +1 -0
  357. package/src/pcd-loader.ts +1 -0
  358. package/src/pcd-writer.ts +1 -0
  359. package/src/ply/bundled.ts +1 -4
  360. package/src/ply/index.ts +0 -4
  361. package/src/ply/lib/get-ply-schema.ts +1 -1
  362. package/src/ply/lib/parse-ply-arrow.ts +2 -2
  363. package/src/ply/lib/parse-ply-in-batches.ts +9 -4
  364. package/src/ply/lib/parse-ply.ts +4 -1
  365. package/src/ply/ply-loader-types.ts +10 -11
  366. package/src/ply/ply-loader.ts +94 -24
  367. package/src/ply/ply-writer.ts +12 -8
  368. package/src/ply/unbundled.ts +1 -1
  369. package/src/ply/workers/ply-worker.ts +8 -8
  370. package/src/ply-loader-types.ts +1 -0
  371. package/src/ply-loader.ts +1 -0
  372. package/src/ply-writer.ts +1 -0
@@ -15,29 +15,772 @@
15
15
  __defProp(target, name, { get: all[name], enumerable: true });
16
16
  };
17
17
 
18
- // ../core/src/worker-utils/lib/node/worker_threads-browser.ts
18
+ // ../../node_modules/probe.gl/dist/env/lib/globals.js
19
+ var window_, document_, process_, console_, navigator_;
20
+ var init_globals = __esm({
21
+ "../../node_modules/probe.gl/dist/env/lib/globals.js"() {
22
+ window_ = globalThis;
23
+ document_ = globalThis.document || {};
24
+ process_ = globalThis.process || {};
25
+ console_ = globalThis.console;
26
+ navigator_ = globalThis.navigator || {};
27
+ }
28
+ });
29
+
30
+ // ../../node_modules/probe.gl/dist/env/lib/is-electron.js
31
+ function isElectron(mockUserAgent) {
32
+ if (typeof window !== "undefined" && window.process?.type === "renderer") {
33
+ return true;
34
+ }
35
+ if (typeof process !== "undefined" && Boolean(process.versions?.["electron"])) {
36
+ return true;
37
+ }
38
+ const realUserAgent = typeof navigator !== "undefined" && navigator.userAgent;
39
+ const userAgent = mockUserAgent || realUserAgent;
40
+ return Boolean(userAgent && userAgent.indexOf("Electron") >= 0);
41
+ }
42
+ var init_is_electron = __esm({
43
+ "../../node_modules/probe.gl/dist/env/lib/is-electron.js"() {
44
+ }
45
+ });
46
+
47
+ // ../../node_modules/probe.gl/dist/env/lib/is-browser.js
48
+ function isBrowser() {
49
+ const isNode = (
50
+ // @ts-expect-error
51
+ typeof process === "object" && String(process) === "[object process]" && !process?.browser
52
+ );
53
+ return !isNode || isElectron();
54
+ }
55
+ var init_is_browser = __esm({
56
+ "../../node_modules/probe.gl/dist/env/lib/is-browser.js"() {
57
+ init_is_electron();
58
+ }
59
+ });
60
+
61
+ // ../../node_modules/probe.gl/dist/env/lib/get-browser.js
62
+ var init_get_browser = __esm({
63
+ "../../node_modules/probe.gl/dist/env/lib/get-browser.js"() {
64
+ init_is_browser();
65
+ init_is_electron();
66
+ init_globals();
67
+ }
68
+ });
69
+
70
+ // ../../node_modules/probe.gl/dist/env/utils/assert.js
71
+ var init_assert = __esm({
72
+ "../../node_modules/probe.gl/dist/env/utils/assert.js"() {
73
+ }
74
+ });
75
+
76
+ // ../../node_modules/probe.gl/dist/env/index.js
77
+ var VERSION;
78
+ var init_env = __esm({
79
+ "../../node_modules/probe.gl/dist/env/index.js"() {
80
+ init_globals();
81
+ init_is_browser();
82
+ init_get_browser();
83
+ init_is_electron();
84
+ init_assert();
85
+ VERSION = true ? "5.0.0" : "untranspiled source";
86
+ }
87
+ });
88
+
89
+ // ../../node_modules/probe.gl/dist/log/utils/assert.js
90
+ function assert2(condition, message) {
91
+ if (!condition) {
92
+ throw new Error(message || "Assertion failed");
93
+ }
94
+ }
95
+ var init_assert2 = __esm({
96
+ "../../node_modules/probe.gl/dist/log/utils/assert.js"() {
97
+ }
98
+ });
99
+
100
+ // ../../node_modules/probe.gl/dist/log/loggers/log-utils.js
101
+ function normalizeLogLevel(logLevel) {
102
+ if (!logLevel) {
103
+ return 0;
104
+ }
105
+ let resolvedLevel;
106
+ switch (typeof logLevel) {
107
+ case "number":
108
+ resolvedLevel = logLevel;
109
+ break;
110
+ case "object":
111
+ resolvedLevel = logLevel.logLevel || logLevel.priority || 0;
112
+ break;
113
+ default:
114
+ return 0;
115
+ }
116
+ assert2(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
117
+ return resolvedLevel;
118
+ }
119
+ function normalizeArguments(opts) {
120
+ const { logLevel, message } = opts;
121
+ opts.logLevel = normalizeLogLevel(logLevel);
122
+ const args = opts.args ? Array.from(opts.args) : [];
123
+ while (args.length && args.shift() !== message) {
124
+ }
125
+ switch (typeof logLevel) {
126
+ case "string":
127
+ case "function":
128
+ if (message !== void 0) {
129
+ args.unshift(message);
130
+ }
131
+ opts.message = logLevel;
132
+ break;
133
+ case "object":
134
+ Object.assign(opts, logLevel);
135
+ break;
136
+ default:
137
+ }
138
+ if (typeof opts.message === "function") {
139
+ opts.message = opts.message();
140
+ }
141
+ const messageType = typeof opts.message;
142
+ assert2(messageType === "string" || messageType === "object");
143
+ return Object.assign(opts, { args }, opts.opts);
144
+ }
145
+ var init_log_utils = __esm({
146
+ "../../node_modules/probe.gl/dist/log/loggers/log-utils.js"() {
147
+ init_assert2();
148
+ }
149
+ });
150
+
151
+ // ../../node_modules/probe.gl/dist/log/loggers/base-log.js
152
+ var noop, BaseLog;
153
+ var init_base_log = __esm({
154
+ "../../node_modules/probe.gl/dist/log/loggers/base-log.js"() {
155
+ init_log_utils();
156
+ noop = () => {
157
+ };
158
+ BaseLog = class {
159
+ constructor({ level = 0 } = {}) {
160
+ this.userData = {};
161
+ this._onceCache = /* @__PURE__ */ new Set();
162
+ this._level = level;
163
+ }
164
+ set level(newLevel) {
165
+ this.setLevel(newLevel);
166
+ }
167
+ get level() {
168
+ return this.getLevel();
169
+ }
170
+ setLevel(level) {
171
+ this._level = level;
172
+ return this;
173
+ }
174
+ getLevel() {
175
+ return this._level;
176
+ }
177
+ // Unconditional logging
178
+ warn(message, ...args) {
179
+ return this._log("warn", 0, message, args, { once: true });
180
+ }
181
+ error(message, ...args) {
182
+ return this._log("error", 0, message, args);
183
+ }
184
+ // Conditional logging
185
+ log(logLevel, message, ...args) {
186
+ return this._log("log", logLevel, message, args);
187
+ }
188
+ info(logLevel, message, ...args) {
189
+ return this._log("info", logLevel, message, args);
190
+ }
191
+ once(logLevel, message, ...args) {
192
+ return this._log("once", logLevel, message, args, { once: true });
193
+ }
194
+ _log(type, logLevel, message, args, options = {}) {
195
+ const normalized = normalizeArguments({
196
+ logLevel,
197
+ message,
198
+ args: this._buildArgs(logLevel, message, args),
199
+ opts: options
200
+ });
201
+ return this._createLogFunction(type, normalized, options);
202
+ }
203
+ _buildArgs(logLevel, message, args) {
204
+ return [logLevel, message, ...args];
205
+ }
206
+ _createLogFunction(type, normalized, options) {
207
+ if (!this._shouldLog(normalized.logLevel)) {
208
+ return noop;
209
+ }
210
+ const tag = this._getOnceTag(options.tag ?? normalized.tag ?? normalized.message);
211
+ if ((options.once || normalized.once) && tag !== void 0) {
212
+ if (this._onceCache.has(tag)) {
213
+ return noop;
214
+ }
215
+ this._onceCache.add(tag);
216
+ }
217
+ return this._emit(type, normalized);
218
+ }
219
+ _shouldLog(logLevel) {
220
+ return this.getLevel() >= normalizeLogLevel(logLevel);
221
+ }
222
+ _getOnceTag(tag) {
223
+ if (tag === void 0) {
224
+ return void 0;
225
+ }
226
+ try {
227
+ return typeof tag === "string" ? tag : String(tag);
228
+ } catch {
229
+ return void 0;
230
+ }
231
+ }
232
+ };
233
+ }
234
+ });
235
+
236
+ // ../../node_modules/probe.gl/dist/log/utils/local-storage.js
237
+ function getStorage(type) {
238
+ try {
239
+ const storage = window[type];
240
+ const x = "__storage_test__";
241
+ storage.setItem(x, x);
242
+ storage.removeItem(x);
243
+ return storage;
244
+ } catch (e) {
245
+ return null;
246
+ }
247
+ }
248
+ var LocalStorage;
249
+ var init_local_storage = __esm({
250
+ "../../node_modules/probe.gl/dist/log/utils/local-storage.js"() {
251
+ LocalStorage = class {
252
+ constructor(id, defaultConfig, type = "sessionStorage") {
253
+ this.storage = getStorage(type);
254
+ this.id = id;
255
+ this.config = defaultConfig;
256
+ this._loadConfiguration();
257
+ }
258
+ getConfiguration() {
259
+ return this.config;
260
+ }
261
+ setConfiguration(configuration) {
262
+ Object.assign(this.config, configuration);
263
+ if (this.storage) {
264
+ const serialized = JSON.stringify(this.config);
265
+ this.storage.setItem(this.id, serialized);
266
+ }
267
+ }
268
+ // Get config from persistent store, if available
269
+ _loadConfiguration() {
270
+ let configuration = {};
271
+ if (this.storage) {
272
+ const serializedConfiguration = this.storage.getItem(this.id);
273
+ configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
274
+ }
275
+ Object.assign(this.config, configuration);
276
+ return this;
277
+ }
278
+ };
279
+ }
280
+ });
281
+
282
+ // ../../node_modules/probe.gl/dist/log/utils/formatters.js
283
+ function formatTime(ms) {
284
+ let formatted;
285
+ if (ms < 10) {
286
+ formatted = `${ms.toFixed(2)}ms`;
287
+ } else if (ms < 100) {
288
+ formatted = `${ms.toFixed(1)}ms`;
289
+ } else if (ms < 1e3) {
290
+ formatted = `${ms.toFixed(0)}ms`;
291
+ } else {
292
+ formatted = `${(ms / 1e3).toFixed(2)}s`;
293
+ }
294
+ return formatted;
295
+ }
296
+ function leftPad(string, length = 8) {
297
+ const padLength = Math.max(length - string.length, 0);
298
+ return `${" ".repeat(padLength)}${string}`;
299
+ }
300
+ var init_formatters = __esm({
301
+ "../../node_modules/probe.gl/dist/log/utils/formatters.js"() {
302
+ }
303
+ });
304
+
305
+ // ../../node_modules/probe.gl/dist/log/utils/color.js
306
+ function getColor(color) {
307
+ if (typeof color !== "string") {
308
+ return color;
309
+ }
310
+ color = color.toUpperCase();
311
+ return COLOR[color] || COLOR.WHITE;
312
+ }
313
+ function addColor(string, color, background) {
314
+ if (!isBrowser && typeof string === "string") {
315
+ if (color) {
316
+ const colorCode = getColor(color);
317
+ string = `\x1B[${colorCode}m${string}\x1B[39m`;
318
+ }
319
+ if (background) {
320
+ const colorCode = getColor(background);
321
+ string = `\x1B[${colorCode + BACKGROUND_INCREMENT}m${string}\x1B[49m`;
322
+ }
323
+ }
324
+ return string;
325
+ }
326
+ var COLOR, BACKGROUND_INCREMENT;
327
+ var init_color = __esm({
328
+ "../../node_modules/probe.gl/dist/log/utils/color.js"() {
329
+ init_env();
330
+ (function(COLOR2) {
331
+ COLOR2[COLOR2["BLACK"] = 30] = "BLACK";
332
+ COLOR2[COLOR2["RED"] = 31] = "RED";
333
+ COLOR2[COLOR2["GREEN"] = 32] = "GREEN";
334
+ COLOR2[COLOR2["YELLOW"] = 33] = "YELLOW";
335
+ COLOR2[COLOR2["BLUE"] = 34] = "BLUE";
336
+ COLOR2[COLOR2["MAGENTA"] = 35] = "MAGENTA";
337
+ COLOR2[COLOR2["CYAN"] = 36] = "CYAN";
338
+ COLOR2[COLOR2["WHITE"] = 37] = "WHITE";
339
+ COLOR2[COLOR2["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK";
340
+ COLOR2[COLOR2["BRIGHT_RED"] = 91] = "BRIGHT_RED";
341
+ COLOR2[COLOR2["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN";
342
+ COLOR2[COLOR2["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW";
343
+ COLOR2[COLOR2["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE";
344
+ COLOR2[COLOR2["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA";
345
+ COLOR2[COLOR2["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN";
346
+ COLOR2[COLOR2["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE";
347
+ })(COLOR || (COLOR = {}));
348
+ BACKGROUND_INCREMENT = 10;
349
+ }
350
+ });
351
+
352
+ // ../../node_modules/probe.gl/dist/log/utils/autobind.js
353
+ function autobind(obj, predefined = ["constructor"]) {
354
+ const proto = Object.getPrototypeOf(obj);
355
+ const propNames = Object.getOwnPropertyNames(proto);
356
+ const object = obj;
357
+ for (const key of propNames) {
358
+ const value = object[key];
359
+ if (typeof value === "function") {
360
+ if (!predefined.find((name) => key === name)) {
361
+ object[key] = value.bind(obj);
362
+ }
363
+ }
364
+ }
365
+ }
366
+ var init_autobind = __esm({
367
+ "../../node_modules/probe.gl/dist/log/utils/autobind.js"() {
368
+ }
369
+ });
370
+
371
+ // ../../node_modules/probe.gl/dist/log/probe.js
372
+ var Probe, probe;
373
+ var init_probe = __esm({
374
+ "../../node_modules/probe.gl/dist/log/probe.js"() {
375
+ init_env();
376
+ Probe = class {
377
+ getHighResolutionTimer() {
378
+ let timestamp;
379
+ if (isBrowser() && window_.performance) {
380
+ timestamp = window_?.performance?.now?.();
381
+ } else if ("hrtime" in process_) {
382
+ const timeParts = process_?.hrtime?.();
383
+ timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
384
+ } else {
385
+ timestamp = Date.now();
386
+ }
387
+ return timestamp;
388
+ }
389
+ getMemoryUsageMB() {
390
+ const performance2 = window_?.performance;
391
+ const usedJSHeapSize = performance2?.memory?.usedJSHeapSize;
392
+ if (usedJSHeapSize === void 0 || usedJSHeapSize === null) {
393
+ return null;
394
+ }
395
+ return Math.trunc(usedJSHeapSize / 1024 / 1024);
396
+ }
397
+ };
398
+ probe = new Probe();
399
+ globalThis.Probe = Probe;
400
+ globalThis.probe = probe;
401
+ }
402
+ });
403
+
404
+ // ../../node_modules/probe.gl/dist/log/loggers/probe-log.js
405
+ function decorateMessage(id, message, opts) {
406
+ if (typeof message === "string") {
407
+ const time = opts.time ? leftPad(formatTime(opts.total)) : "";
408
+ message = opts.time ? `${id}: ${time} ${message}` : `${id}: ${message}`;
409
+ message = addColor(message, opts.color, opts.background);
410
+ }
411
+ return message;
412
+ }
413
+ function getTableHeader(table) {
414
+ for (const key in table) {
415
+ for (const title in table[key]) {
416
+ return title || "untitled";
417
+ }
418
+ }
419
+ return "empty";
420
+ }
421
+ var originalConsole, DEFAULT_LOG_CONFIGURATION, ProbeLog;
422
+ var init_probe_log = __esm({
423
+ "../../node_modules/probe.gl/dist/log/loggers/probe-log.js"() {
424
+ init_env();
425
+ init_base_log();
426
+ init_local_storage();
427
+ init_formatters();
428
+ init_color();
429
+ init_autobind();
430
+ init_assert2();
431
+ init_probe();
432
+ init_log_utils();
433
+ init_log_utils();
434
+ originalConsole = {
435
+ debug: isBrowser() ? console.debug || console.log : console.log,
436
+ log: console.log,
437
+ info: console.info,
438
+ warn: console.warn,
439
+ error: console.error
440
+ };
441
+ DEFAULT_LOG_CONFIGURATION = {
442
+ enabled: true,
443
+ level: 0
444
+ };
445
+ ProbeLog = class extends BaseLog {
446
+ constructor({ id } = { id: "" }) {
447
+ super({ level: 0 });
448
+ this.VERSION = VERSION;
449
+ this._startTs = probe.getHighResolutionTimer();
450
+ this._deltaTs = probe.getHighResolutionTimer();
451
+ this.userData = {};
452
+ this.LOG_THROTTLE_TIMEOUT = 0;
453
+ this.id = id;
454
+ this.userData = {};
455
+ this._storage = new LocalStorage(`__probe-${this.id}__`, { [this.id]: DEFAULT_LOG_CONFIGURATION });
456
+ this.timeStamp(`${this.id} started`);
457
+ autobind(this);
458
+ Object.seal(this);
459
+ }
460
+ isEnabled() {
461
+ return this._getConfiguration().enabled;
462
+ }
463
+ getLevel() {
464
+ return this._getConfiguration().level;
465
+ }
466
+ /** @return milliseconds, with fractions */
467
+ getTotal() {
468
+ return Number((probe.getHighResolutionTimer() - this._startTs).toPrecision(10));
469
+ }
470
+ /** @return milliseconds, with fractions */
471
+ getDelta() {
472
+ return Number((probe.getHighResolutionTimer() - this._deltaTs).toPrecision(10));
473
+ }
474
+ /** @deprecated use logLevel */
475
+ set priority(newPriority) {
476
+ this.level = newPriority;
477
+ }
478
+ /** @deprecated use logLevel */
479
+ get priority() {
480
+ return this.level;
481
+ }
482
+ /** @deprecated use logLevel */
483
+ getPriority() {
484
+ return this.level;
485
+ }
486
+ // Configure
487
+ enable(enabled = true) {
488
+ this._updateConfiguration({ enabled });
489
+ return this;
490
+ }
491
+ setLevel(level) {
492
+ this._updateConfiguration({ level });
493
+ return this;
494
+ }
495
+ /** return the current status of the setting */
496
+ get(setting) {
497
+ return this._getConfiguration()[setting];
498
+ }
499
+ // update the status of the setting
500
+ set(setting, value) {
501
+ this._updateConfiguration({ [setting]: value });
502
+ }
503
+ /** Logs the current settings as a table */
504
+ settings() {
505
+ if (console.table) {
506
+ console.table(this._storage.config);
507
+ } else {
508
+ console.log(this._storage.config);
509
+ }
510
+ }
511
+ // Unconditional logging
512
+ assert(condition, message) {
513
+ if (!condition) {
514
+ throw new Error(message || "Assertion failed");
515
+ }
516
+ }
517
+ warn(message, ...args) {
518
+ return this._log("warn", 0, message, args, {
519
+ method: originalConsole.warn,
520
+ once: true
521
+ });
522
+ }
523
+ error(message, ...args) {
524
+ return this._log("error", 0, message, args, {
525
+ method: originalConsole.error
526
+ });
527
+ }
528
+ /** Print a deprecation warning */
529
+ deprecated(oldUsage, newUsage) {
530
+ return this.warn(`\`${oldUsage}\` is deprecated and will be removed in a later version. Use \`${newUsage}\` instead`);
531
+ }
532
+ /** Print a removal warning */
533
+ removed(oldUsage, newUsage) {
534
+ return this.error(`\`${oldUsage}\` has been removed. Use \`${newUsage}\` instead`);
535
+ }
536
+ probe(logLevel, message, ...args) {
537
+ const memoryUsageMB = probe.getMemoryUsageMB();
538
+ if (memoryUsageMB !== null) {
539
+ const memoryUsagePrefix = `${memoryUsageMB}MB `;
540
+ if (typeof message === "function") {
541
+ message = () => `${memoryUsagePrefix}${message()}`;
542
+ } else if (typeof message === "string") {
543
+ message = `${memoryUsagePrefix}${message}`;
544
+ }
545
+ }
546
+ return this._log("log", logLevel, message, args, {
547
+ method: originalConsole.log,
548
+ time: true,
549
+ once: true
550
+ });
551
+ }
552
+ log(logLevel, message, ...args) {
553
+ return this._log("log", logLevel, message, args, {
554
+ method: originalConsole.debug
555
+ });
556
+ }
557
+ info(logLevel, message, ...args) {
558
+ return this._log("info", logLevel, message, args, { method: console.info });
559
+ }
560
+ once(logLevel, message, ...args) {
561
+ return this._log("once", logLevel, message, args, {
562
+ method: originalConsole.debug || originalConsole.info,
563
+ once: true
564
+ });
565
+ }
566
+ /** Logs an object as a table */
567
+ table(logLevel, table, columns) {
568
+ if (table) {
569
+ return this._log("table", logLevel, table, columns && [columns] || [], {
570
+ method: console.table || noop,
571
+ tag: getTableHeader(table)
572
+ });
573
+ }
574
+ return noop;
575
+ }
576
+ time(logLevel, message) {
577
+ return this._log("time", logLevel, message, [], {
578
+ method: console.time ? console.time : console.info
579
+ });
580
+ }
581
+ timeEnd(logLevel, message) {
582
+ return this._log("time", logLevel, message, [], {
583
+ method: console.timeEnd ? console.timeEnd : console.info
584
+ });
585
+ }
586
+ timeStamp(logLevel, message) {
587
+ return this._log("time", logLevel, message, [], {
588
+ method: console.timeStamp || noop
589
+ });
590
+ }
591
+ group(logLevel, message, opts = { collapsed: false }) {
592
+ const method = (opts.collapsed ? console.groupCollapsed : console.group) || console.info;
593
+ return this._log("group", logLevel, message, [], { method });
594
+ }
595
+ groupCollapsed(logLevel, message, opts = {}) {
596
+ return this.group(logLevel, message, Object.assign({}, opts, { collapsed: true }));
597
+ }
598
+ groupEnd(logLevel) {
599
+ return this._log("groupEnd", logLevel, "", [], {
600
+ method: console.groupEnd || noop
601
+ });
602
+ }
603
+ // EXPERIMENTAL
604
+ withGroup(logLevel, message, func) {
605
+ this.group(logLevel, message)();
606
+ try {
607
+ func();
608
+ } finally {
609
+ this.groupEnd(logLevel)();
610
+ }
611
+ }
612
+ trace() {
613
+ if (console.trace) {
614
+ console.trace();
615
+ }
616
+ }
617
+ _shouldLog(logLevel) {
618
+ return this.isEnabled() && super._shouldLog(logLevel);
619
+ }
620
+ _emit(_type, normalized) {
621
+ const method = normalized.method;
622
+ assert2(method);
623
+ normalized.total = this.getTotal();
624
+ normalized.delta = this.getDelta();
625
+ this._deltaTs = probe.getHighResolutionTimer();
626
+ const message = decorateMessage(this.id, normalized.message, normalized);
627
+ return method.bind(console, message, ...normalized.args);
628
+ }
629
+ _getConfiguration() {
630
+ if (!this._storage.config[this.id]) {
631
+ this._updateConfiguration(DEFAULT_LOG_CONFIGURATION);
632
+ }
633
+ return this._storage.config[this.id];
634
+ }
635
+ _updateConfiguration(configuration) {
636
+ const currentConfiguration = this._storage.config[this.id] || {
637
+ ...DEFAULT_LOG_CONFIGURATION
638
+ };
639
+ this._storage.setConfiguration({
640
+ [this.id]: { ...currentConfiguration, ...configuration }
641
+ });
642
+ }
643
+ };
644
+ ProbeLog.VERSION = VERSION;
645
+ }
646
+ });
647
+
648
+ // ../../node_modules/probe.gl/dist/log/loggers/console-log.js
649
+ var init_console_log = __esm({
650
+ "../../node_modules/probe.gl/dist/log/loggers/console-log.js"() {
651
+ init_base_log();
652
+ }
653
+ });
654
+
655
+ // ../../node_modules/probe.gl/dist/log/loggers/memory-log.js
656
+ var init_memory_log = __esm({
657
+ "../../node_modules/probe.gl/dist/log/loggers/memory-log.js"() {
658
+ init_base_log();
659
+ }
660
+ });
661
+
662
+ // ../../node_modules/probe.gl/dist/log/deprecated/hi-res-timestamp.js
663
+ var init_hi_res_timestamp = __esm({
664
+ "../../node_modules/probe.gl/dist/log/deprecated/hi-res-timestamp.js"() {
665
+ init_probe();
666
+ }
667
+ });
668
+
669
+ // ../../node_modules/probe.gl/dist/log/init.js
670
+ var init_init = __esm({
671
+ "../../node_modules/probe.gl/dist/log/init.js"() {
672
+ init_probe();
673
+ if (!globalThis.probe) {
674
+ globalThis.probe = probe;
675
+ }
676
+ }
677
+ });
678
+
679
+ // ../../node_modules/probe.gl/dist/log/index.js
680
+ var log;
681
+ var init_log = __esm({
682
+ "../../node_modules/probe.gl/dist/log/index.js"() {
683
+ init_probe_log();
684
+ init_probe();
685
+ init_probe_log();
686
+ init_console_log();
687
+ init_base_log();
688
+ init_memory_log();
689
+ init_color();
690
+ init_color();
691
+ init_formatters();
692
+ init_autobind();
693
+ init_local_storage();
694
+ init_hi_res_timestamp();
695
+ init_init();
696
+ log = new ProbeLog({ id: "@probe.gl/log" });
697
+ }
698
+ });
699
+
700
+ // ../core/src/loader-utils/lib/log-utils/log.ts
701
+ function createLog() {
702
+ const log3 = new ProbeLog({ id: "loaders.gl" });
703
+ globalThis.loaders ||= {};
704
+ globalThis.loaders.log = log3;
705
+ globalThis.loaders.version = version;
706
+ globalThis.probe ||= {};
707
+ globalThis.probe.loaders = log3;
708
+ return log3;
709
+ }
710
+ function ignoreMessage() {
711
+ }
712
+ var VERSION2, version, log2, NullLog, nullLog;
713
+ var init_log2 = __esm({
714
+ "../core/src/loader-utils/lib/log-utils/log.ts"() {
715
+ "use strict";
716
+ init_log();
717
+ VERSION2 = true ? "5.0.0-beta.10" : "latest";
718
+ version = VERSION2[0] >= "0" && VERSION2[0] <= "9" ? `v${VERSION2}` : "";
719
+ log2 = createLog();
720
+ NullLog = class {
721
+ /** Discards debug messages. */
722
+ log() {
723
+ return ignoreMessage;
724
+ }
725
+ /** Discards informational messages. */
726
+ info() {
727
+ return ignoreMessage;
728
+ }
729
+ /** Discards messages marked to be emitted once. */
730
+ once() {
731
+ return ignoreMessage;
732
+ }
733
+ /** Discards warnings. */
734
+ warn() {
735
+ return ignoreMessage;
736
+ }
737
+ /** Discards errors. */
738
+ error() {
739
+ return ignoreMessage;
740
+ }
741
+ };
742
+ nullLog = new NullLog();
743
+ }
744
+ });
745
+
746
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js
19
747
  var parentPort;
20
748
  var init_worker_threads_browser = __esm({
21
- "../core/src/worker-utils/lib/node/worker_threads-browser.ts"() {
22
- "use strict";
23
- parentPort = null;
749
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js"() {
750
+ parentPort = globalThis.process?.getBuiltinModule?.("node:worker_threads")?.parentPort ?? null;
24
751
  }
25
752
  });
26
753
 
27
- // ../core/src/worker-utils/lib/worker-utils/get-transfer-list.ts
754
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js
28
755
  function getTransferList(object, recursive = true, transfers) {
29
756
  const transfersSet = transfers || /* @__PURE__ */ new Set();
30
- if (!object) {
31
- } else if (isTransferable(object)) {
32
- transfersSet.add(object);
33
- } else if (isTransferable(object.buffer)) {
34
- transfersSet.add(object.buffer);
35
- } else if (ArrayBuffer.isView(object)) {
36
- } else if (recursive && typeof object === "object") {
37
- for (const key in object) {
38
- getTransferList(object[key], recursive, transfersSet);
757
+ const seen = /* @__PURE__ */ new Set();
758
+ function visit(value) {
759
+ if (!value || typeof value !== "object" || seen.has(value))
760
+ return;
761
+ seen.add(value);
762
+ if (isTransferable(value))
763
+ transfersSet.add(value);
764
+ else if (ArrayBuffer.isView(value)) {
765
+ if (isTransferable(value.buffer))
766
+ transfersSet.add(value.buffer);
767
+ } else if (recursive && typeof MessageChannel !== "undefined" && value instanceof MessageChannel) {
768
+ visit(value.port1);
769
+ visit(value.port2);
770
+ } else if (recursive && value instanceof Map) {
771
+ for (const [key, item] of value) {
772
+ visit(key);
773
+ visit(item);
774
+ }
775
+ } else if (recursive && value instanceof Set) {
776
+ for (const item of value)
777
+ visit(item);
778
+ } else if (recursive) {
779
+ for (const key of Object.keys(value))
780
+ visit(value[key]);
39
781
  }
40
782
  }
783
+ visit(object);
41
784
  return transfers === void 0 ? Array.from(transfersSet) : [];
42
785
  }
43
786
  function isTransferable(object) {
@@ -59,12 +802,11 @@
59
802
  return false;
60
803
  }
61
804
  var init_get_transfer_list = __esm({
62
- "../core/src/worker-utils/lib/worker-utils/get-transfer-list.ts"() {
63
- "use strict";
805
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js"() {
64
806
  }
65
807
  });
66
808
 
67
- // ../core/src/worker-utils/lib/worker-farm/worker-body.ts
809
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-body.js
68
810
  async function getParentPort() {
69
811
  return parentPort;
70
812
  }
@@ -77,31 +819,31 @@
77
819
  }
78
820
  var onMessageWrapperMap, WorkerBody;
79
821
  var init_worker_body = __esm({
80
- "../core/src/worker-utils/lib/worker-farm/worker-body.ts"() {
81
- "use strict";
822
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-body.js"() {
82
823
  init_get_transfer_list();
83
824
  init_worker_threads_browser();
84
825
  onMessageWrapperMap = /* @__PURE__ */ new Map();
85
826
  WorkerBody = class {
86
827
  /** Check that we are actually in a worker thread */
87
828
  static async inWorkerThread() {
88
- return typeof self !== "undefined" || Boolean(await getParentPort());
829
+ const workerGlobalScope = globalThis.WorkerGlobalScope;
830
+ return typeof workerGlobalScope === "function" && globalThis instanceof workerGlobalScope || Boolean(await getParentPort());
89
831
  }
90
832
  /*
91
833
  * (type: WorkerMessageType, payload: WorkerMessagePayload) => any
92
834
  */
93
835
  static set onmessage(onMessage) {
94
836
  async function handleMessage(message) {
95
- const parentPort2 = await getParentPort();
96
- const { type, payload } = parentPort2 ? message : message.data;
837
+ const parentPort3 = await getParentPort();
838
+ const { type, payload } = parentPort3 ? message : message.data;
97
839
  onMessage(type, payload);
98
840
  }
99
- getParentPort().then((parentPort2) => {
100
- if (parentPort2) {
101
- parentPort2.on("message", (message) => {
841
+ getParentPort().then((parentPort3) => {
842
+ if (parentPort3) {
843
+ parentPort3.on("message", (message) => {
102
844
  handleMessage(message);
103
845
  });
104
- parentPort2.on("exit", () => console.debug("Node worker closing"));
846
+ parentPort3.on("exit", () => console.debug("Node worker closing"));
105
847
  } else {
106
848
  globalThis.onmessage = handleMessage;
107
849
  }
@@ -119,9 +861,9 @@
119
861
  };
120
862
  onMessageWrapperMap.set(onMessage, onMessageWrapper);
121
863
  }
122
- const parentPort2 = await getParentPort();
123
- if (parentPort2) {
124
- parentPort2.on("message", onMessageWrapper);
864
+ const parentPort3 = await getParentPort();
865
+ if (parentPort3) {
866
+ parentPort3.on("message", onMessageWrapper);
125
867
  } else {
126
868
  globalThis.addEventListener("message", onMessageWrapper);
127
869
  }
@@ -132,9 +874,9 @@
132
874
  if (!onMessageWrapper) {
133
875
  return;
134
876
  }
135
- const parentPort2 = await getParentPort();
136
- if (parentPort2) {
137
- parentPort2.off("message", onMessageWrapper);
877
+ const parentPort3 = await getParentPort();
878
+ if (parentPort3) {
879
+ parentPort3.off("message", onMessageWrapper);
138
880
  } else {
139
881
  globalThis.removeEventListener("message", onMessageWrapper);
140
882
  }
@@ -144,12 +886,12 @@
144
886
  * @param type
145
887
  * @param payload
146
888
  */
147
- static async postMessage(type, payload) {
889
+ static async postMessage(type, payload, copy = false) {
148
890
  const data = { source: "loaders.gl", type, payload };
149
- const transferList = getTransferList(payload);
150
- const parentPort2 = await getParentPort();
151
- if (parentPort2) {
152
- parentPort2.postMessage(data, transferList);
891
+ const transferList = copy ? [] : getTransferList(payload);
892
+ const parentPort3 = await getParentPort();
893
+ if (parentPort3) {
894
+ parentPort3.postMessage(data, transferList);
153
895
  } else {
154
896
  globalThis.postMessage(data, transferList);
155
897
  }
@@ -158,15 +900,11 @@
158
900
  }
159
901
  });
160
902
 
161
- // ../core/src/worker-utils/lib/async-queue/async-queue.ts
903
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js
162
904
  var AsyncQueue;
163
905
  var init_async_queue = __esm({
164
- "../core/src/worker-utils/lib/async-queue/async-queue.ts"() {
165
- "use strict";
906
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js"() {
166
907
  AsyncQueue = class {
167
- _values;
168
- _settlers;
169
- _closed;
170
908
  constructor() {
171
909
  this._values = [];
172
910
  this._settlers = [];
@@ -234,8 +972,63 @@
234
972
  }
235
973
  });
236
974
 
237
- // ../core/src/worker-utils/lib/worker-api/create-worker.ts
238
- async function createWorker(process, processInBatches) {
975
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js
976
+ var SharedWorkerState;
977
+ var init_shared_state = __esm({
978
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js"() {
979
+ SharedWorkerState = class {
980
+ constructor(buffer) {
981
+ if (typeof SharedArrayBuffer === "undefined" || !(buffer instanceof SharedArrayBuffer) || buffer.byteLength !== 16)
982
+ throw new Error("Expected a 16-byte shared worker control buffer");
983
+ this.buffer = buffer;
984
+ this.values = new Int32Array(buffer);
985
+ }
986
+ get snapshot() {
987
+ return {
988
+ cancelled: Atomics.load(this.values, 0) !== 0,
989
+ completed: Atomics.load(this.values, 1),
990
+ total: Atomics.load(this.values, 2),
991
+ revision: Atomics.load(this.values, 3)
992
+ };
993
+ }
994
+ cancel() {
995
+ Atomics.store(this.values, 0, 1);
996
+ Atomics.add(this.values, 3, 1);
997
+ Atomics.notify(this.values, 0);
998
+ }
999
+ throwIfCancelled() {
1000
+ if (Atomics.load(this.values, 0) !== 0) {
1001
+ const error = new Error("Shared worker task was cancelled");
1002
+ error.name = "AbortError";
1003
+ throw error;
1004
+ }
1005
+ }
1006
+ /** Integer counters for application-defined work; messages still carry phase names and units. */
1007
+ setProgress(completed, total = -1) {
1008
+ if (!Number.isInteger(completed) || completed < 0 || completed > 2147483647 || !Number.isInteger(total) || total < -1 || total > 2147483647) {
1009
+ throw new RangeError("Shared progress requires nonnegative int32 counts (or total -1)");
1010
+ }
1011
+ Atomics.store(this.values, 1, completed);
1012
+ Atomics.store(this.values, 2, total);
1013
+ Atomics.add(this.values, 3, 1);
1014
+ }
1015
+ };
1016
+ }
1017
+ });
1018
+
1019
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js
1020
+ function validateOutputOwnership(ownership) {
1021
+ if (ownership !== void 0 && ownership !== "copy" && ownership !== "transfer") {
1022
+ throw new Error("Invalid worker output ownership");
1023
+ }
1024
+ }
1025
+ var init_validate_output_ownership = __esm({
1026
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js"() {
1027
+ }
1028
+ });
1029
+
1030
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/create-worker.js
1031
+ async function createWorker(process2, processInBatches, preload2) {
239
1032
  if (!await WorkerBody.inWorkerThread()) {
240
1033
  return;
241
1034
  }
@@ -243,27 +1036,59 @@
243
1036
  process: processOnMainThread
244
1037
  };
245
1038
  WorkerBody.onmessage = async (type, payload) => {
1039
+ if (type === "cancel") {
1040
+ activeController?.abort();
1041
+ activeInputBatches?.close();
1042
+ activeOutputAcknowledgements?.close();
1043
+ return;
1044
+ }
1045
+ const controller = type === "process" || type === "process-in-batches" ? new AbortController() : void 0;
1046
+ if (controller)
1047
+ activeController = controller;
1048
+ const startedAt = performance.now();
246
1049
  const reporter = type === "process" || type === "process-in-batches" ? createProgressReporter() : void 0;
247
- const jobContext = { ...context, reportProgress: reporter?.report };
1050
+ let sharedState;
1051
+ const throwIfAborted = () => {
1052
+ controller?.signal.throwIfAborted();
1053
+ sharedState?.throwIfCancelled();
1054
+ };
1055
+ const jobContext = {
1056
+ ...context,
1057
+ signal: controller?.signal,
1058
+ sharedState,
1059
+ throwIfAborted,
1060
+ reportProgress: (progress) => {
1061
+ if (!controller?.signal.aborted && !sharedState?.snapshot.cancelled)
1062
+ reporter?.report(progress);
1063
+ }
1064
+ };
248
1065
  try {
1066
+ if (controller && payload.options?.["sharedState"]) {
1067
+ sharedState = new SharedWorkerState(payload.options["sharedState"]);
1068
+ jobContext.sharedState = sharedState;
1069
+ }
249
1070
  switch (type) {
250
1071
  case "preload":
1072
+ await preload2?.();
251
1073
  WorkerBody.postMessage("done", {});
252
1074
  break;
253
1075
  case "process":
254
- if (!process) {
1076
+ throwIfAborted();
1077
+ validateOutputOwnership(payload.options?.["outputOwnership"]);
1078
+ if (!process2) {
255
1079
  throw new Error("Worker does not support atomic processing");
256
1080
  }
257
- const result = await process(
258
- payload.input,
259
- payload.options || {},
260
- jobContext,
261
- payload.context || {}
262
- );
1081
+ const result = await process2(payload.input, payload.options || {}, jobContext, payload.context || {});
1082
+ throwIfAborted();
263
1083
  reporter?.finish();
264
- WorkerBody.postMessage("done", { result });
1084
+ await WorkerBody.postMessage("done", {
1085
+ result,
1086
+ executionMs: performance.now() - startedAt
1087
+ }, payload.options?.["outputOwnership"] === "copy");
265
1088
  break;
266
1089
  case "process-in-batches":
1090
+ throwIfAborted();
1091
+ validateOutputOwnership(payload.options?.["outputOwnership"]);
267
1092
  if (!processInBatches) {
268
1093
  throw new Error("Worker does not support batched processing");
269
1094
  }
@@ -272,18 +1097,15 @@
272
1097
  activeInputBatches = inputBatches;
273
1098
  activeOutputAcknowledgements = outputAcknowledgements;
274
1099
  try {
275
- const resultIterator = processInBatches(
276
- createDemandDrivenIterator(inputBatches),
277
- payload.options || {},
278
- jobContext,
279
- payload.context || {}
280
- );
1100
+ const resultIterator = processInBatches(createDemandDrivenIterator(inputBatches), payload.options || {}, jobContext, payload.context || {});
281
1101
  for await (const batch of resultIterator) {
282
- await WorkerBody.postMessage("output-batch", { result: batch });
1102
+ throwIfAborted();
1103
+ await WorkerBody.postMessage("output-batch", { result: batch }, payload.options?.["outputOwnership"] === "copy");
283
1104
  await outputAcknowledgements.next();
284
1105
  }
1106
+ throwIfAborted();
285
1107
  reporter?.finish();
286
- await WorkerBody.postMessage("done", {});
1108
+ await WorkerBody.postMessage("done", { executionMs: performance.now() - startedAt });
287
1109
  } finally {
288
1110
  activeInputBatches = null;
289
1111
  activeOutputAcknowledgements = null;
@@ -310,11 +1132,18 @@
310
1132
  default:
311
1133
  }
312
1134
  } catch (error) {
313
- reporter?.finish();
1135
+ reporter?.finish(controller?.signal.aborted || sharedState?.snapshot.cancelled);
314
1136
  const message = error instanceof Error ? error.message : "";
315
- WorkerBody.postMessage("error", { error: message });
1137
+ await WorkerBody.postMessage("error", {
1138
+ error: message,
1139
+ errorName: error instanceof Error ? error.name : "Error"
1140
+ });
1141
+ } finally {
1142
+ if (controller && activeController === controller)
1143
+ activeController = null;
316
1144
  }
317
1145
  };
1146
+ await WorkerBody.postMessage("ready", {});
318
1147
  }
319
1148
  async function* createDemandDrivenIterator(inputBatches) {
320
1149
  while (true) {
@@ -326,82 +1155,692 @@
326
1155
  yield nextBatch.value;
327
1156
  }
328
1157
  }
329
- function processOnMainThread(arrayBuffer, options = {}, jobContext = {}) {
330
- return new Promise((resolve, reject) => {
331
- const id = requestId++;
332
- const onMessage = (type, payload2) => {
333
- if (payload2.id !== id) {
334
- return;
335
- }
336
- switch (type) {
337
- case "done":
338
- WorkerBody.removeEventListener(onMessage);
339
- resolve(payload2.result);
340
- break;
341
- case "error":
342
- WorkerBody.removeEventListener(onMessage);
343
- reject(payload2.error);
344
- break;
345
- default:
1158
+ function processOnMainThread(arrayBuffer, options = {}, jobContext = {}) {
1159
+ const signal = activeController?.signal;
1160
+ signal?.throwIfAborted();
1161
+ return new Promise((resolve, reject) => {
1162
+ const id = requestId++;
1163
+ const cleanup = () => {
1164
+ signal?.removeEventListener("abort", abort);
1165
+ void WorkerBody.removeEventListener(onMessage);
1166
+ };
1167
+ const abort = () => {
1168
+ cleanup();
1169
+ reject(signal?.reason);
1170
+ };
1171
+ const onMessage = (type, payload) => {
1172
+ if (payload.id !== id)
1173
+ return;
1174
+ if (type === "done") {
1175
+ cleanup();
1176
+ resolve(payload.result);
1177
+ } else if (type === "error") {
1178
+ cleanup();
1179
+ reject(payload.error);
1180
+ }
1181
+ };
1182
+ void WorkerBody.addEventListener(onMessage).then(async () => {
1183
+ if (signal?.aborted) {
1184
+ abort();
1185
+ return;
1186
+ }
1187
+ signal?.addEventListener("abort", abort, { once: true });
1188
+ await WorkerBody.postMessage("process", {
1189
+ id,
1190
+ input: arrayBuffer,
1191
+ options,
1192
+ context: jobContext
1193
+ });
1194
+ }).catch((error) => {
1195
+ cleanup();
1196
+ reject(error);
1197
+ });
1198
+ });
1199
+ }
1200
+ function createProgressReporter() {
1201
+ let pending2;
1202
+ let finished = false;
1203
+ let scheduled = false;
1204
+ const flush = () => {
1205
+ scheduled = false;
1206
+ if (pending2) {
1207
+ WorkerBody.postMessage("progress", { progress: pending2 });
1208
+ pending2 = void 0;
1209
+ }
1210
+ };
1211
+ return {
1212
+ /** Records progress while retaining phase transitions. */
1213
+ report(progress) {
1214
+ if (finished)
1215
+ return;
1216
+ if (pending2 && pending2.phase !== progress.phase)
1217
+ flush();
1218
+ pending2 = { ...progress };
1219
+ if (!scheduled) {
1220
+ scheduled = true;
1221
+ setTimeout(flush, 0);
1222
+ }
1223
+ },
1224
+ /** Flushes final progress and suppresses reports from stale callbacks. */
1225
+ finish(discard = false) {
1226
+ if (discard)
1227
+ pending2 = void 0;
1228
+ flush();
1229
+ finished = true;
1230
+ }
1231
+ };
1232
+ }
1233
+ var requestId, activeController, activeInputBatches, activeOutputAcknowledgements;
1234
+ var init_create_worker = __esm({
1235
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/create-worker.js"() {
1236
+ init_shared_state();
1237
+ init_async_queue();
1238
+ init_worker_body();
1239
+ init_validate_output_ownership();
1240
+ requestId = 0;
1241
+ activeController = null;
1242
+ activeInputBatches = null;
1243
+ activeOutputAcknowledgements = null;
1244
+ }
1245
+ });
1246
+
1247
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/index.js
1248
+ var import_meta, path, moduleUrl;
1249
+ var init_worker_utils = __esm({
1250
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/index.js"() {
1251
+ init_worker_body();
1252
+ init_create_worker();
1253
+ init_get_transfer_list();
1254
+ import_meta = {};
1255
+ path = typeof __filename === "string" ? __filename.replace(/\\/g, "/") : "";
1256
+ moduleUrl = path ? `file://${path.startsWith("/") ? "" : "/"}${encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F")}` : import_meta.url;
1257
+ }
1258
+ });
1259
+
1260
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js
1261
+ function preloadTaskCode(task, signal) {
1262
+ if (!task.preload)
1263
+ return Promise.resolve();
1264
+ let promise = pending.get(task);
1265
+ if (!promise) {
1266
+ promise = Promise.resolve().then(() => task.preload()).then(() => {
1267
+ loaded.add(task);
1268
+ });
1269
+ pending.set(task, promise);
1270
+ void promise.catch(() => pending.delete(task));
1271
+ }
1272
+ return withSignal(promise, signal);
1273
+ }
1274
+ function withSignal(operation, signal) {
1275
+ if (!signal)
1276
+ return operation;
1277
+ return new Promise((resolve, reject) => {
1278
+ const abort = () => {
1279
+ signal.removeEventListener("abort", abort);
1280
+ reject(signal.reason);
1281
+ };
1282
+ signal.addEventListener("abort", abort, { once: true });
1283
+ if (signal.aborted)
1284
+ abort();
1285
+ operation.then((value) => {
1286
+ signal.removeEventListener("abort", abort);
1287
+ resolve(value);
1288
+ }, (error) => {
1289
+ signal.removeEventListener("abort", abort);
1290
+ reject(error);
1291
+ });
1292
+ });
1293
+ }
1294
+ var pending, loaded;
1295
+ var init_task_preload = __esm({
1296
+ "../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js"() {
1297
+ pending = /* @__PURE__ */ new WeakMap();
1298
+ loaded = /* @__PURE__ */ new WeakSet();
1299
+ }
1300
+ });
1301
+
1302
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js
1303
+ var TaskRequestError, TaskChannel;
1304
+ var init_task_channel = __esm({
1305
+ "../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js"() {
1306
+ TaskRequestError = class extends Error {
1307
+ };
1308
+ TaskChannel = class {
1309
+ constructor(options) {
1310
+ this.options = options;
1311
+ this.nextId = 1;
1312
+ this.pending = /* @__PURE__ */ new Map();
1313
+ this.incoming = /* @__PURE__ */ new Map();
1314
+ }
1315
+ /** Send a request without serializing other in-flight requests. */
1316
+ request(operation, value, signal, transfer = []) {
1317
+ if (this.failure)
1318
+ return Promise.reject(this.failure.reason);
1319
+ if (signal?.aborted)
1320
+ return Promise.reject(signal.reason);
1321
+ const id = this.nextId++;
1322
+ return new Promise((resolve, reject) => {
1323
+ const abort = () => {
1324
+ const pending2 = this.pending.get(id);
1325
+ if (!pending2)
1326
+ return;
1327
+ this.pending.delete(id);
1328
+ pending2.cleanup();
1329
+ reject(signal?.reason);
1330
+ this.send({ source: "math.gl/tasks", kind: "cancel", id });
1331
+ };
1332
+ this.pending.set(id, {
1333
+ resolve,
1334
+ reject,
1335
+ cleanup: () => signal?.removeEventListener("abort", abort)
1336
+ });
1337
+ signal?.addEventListener("abort", abort, { once: true });
1338
+ this.send({ source: "math.gl/tasks", kind: "request", id, operation, value }, transfer);
1339
+ });
1340
+ }
1341
+ /** Send a one-way notification. */
1342
+ emit(operation, value, transfer = []) {
1343
+ if (this.failure)
1344
+ throw this.failure.reason;
1345
+ this.send({ source: "math.gl/tasks", kind: "event", id: 0, operation, value }, transfer);
1346
+ }
1347
+ /** Dispatch a transport message; unrelated protocols are ignored. */
1348
+ receive(message) {
1349
+ if (this.failure || message?.source !== "math.gl/tasks")
1350
+ return;
1351
+ if (message.kind === "failure") {
1352
+ const reason = new Error(message.error?.message ?? "Task channel failed");
1353
+ this.close(reason);
1354
+ this.options.onFailure?.(reason);
1355
+ } else if (message.kind === "result" || message.kind === "error") {
1356
+ const pending2 = this.pending.get(message.id);
1357
+ if (!pending2)
1358
+ return;
1359
+ this.pending.delete(message.id);
1360
+ pending2.cleanup();
1361
+ if (message.kind === "result")
1362
+ pending2.resolve(message.value);
1363
+ else {
1364
+ const error = new TaskRequestError(message.error?.message ?? "Task request failed");
1365
+ error.name = message.error?.name ?? "Error";
1366
+ pending2.reject(error);
1367
+ }
1368
+ } else if (message.kind === "cancel") {
1369
+ this.incoming.get(message.id)?.abort(new DOMException("Task request cancelled", "AbortError"));
1370
+ } else if (message.kind === "event") {
1371
+ try {
1372
+ this.options.handleEvent?.(message.operation, message.value);
1373
+ } catch (error) {
1374
+ this.fail(error);
1375
+ }
1376
+ } else if (message.kind === "request") {
1377
+ if (this.incoming.has(message.id)) {
1378
+ this.fail(new Error("Duplicate task request identifier"));
1379
+ return;
1380
+ }
1381
+ const controller = new AbortController();
1382
+ this.incoming.set(message.id, controller);
1383
+ void Promise.resolve().then(() => {
1384
+ controller.signal.throwIfAborted();
1385
+ return this.options.handleRequest(message.operation, message.value, controller.signal);
1386
+ }).then((value) => {
1387
+ if (!controller.signal.aborted && !this.failure) {
1388
+ this.send({ source: "math.gl/tasks", kind: "result", id: message.id, value }, this.options.getResultTransferList?.(value, message.value));
1389
+ }
1390
+ }).catch((reason) => {
1391
+ if (!controller.signal.aborted && !this.failure) {
1392
+ this.send({
1393
+ source: "math.gl/tasks",
1394
+ kind: "error",
1395
+ id: message.id,
1396
+ error: {
1397
+ name: reason instanceof Error ? reason.name : "Error",
1398
+ message: reason instanceof Error ? reason.message : String(reason)
1399
+ }
1400
+ });
1401
+ }
1402
+ }).finally(() => this.incoming.delete(message.id));
1403
+ }
1404
+ }
1405
+ /** Reject all outstanding calls with a common cause and abort incoming callbacks. */
1406
+ close(reason = new Error("Task channel closed")) {
1407
+ if (this.failure)
1408
+ return;
1409
+ this.failure = { reason };
1410
+ for (const pending2 of this.pending.values()) {
1411
+ pending2.cleanup();
1412
+ pending2.reject(reason);
1413
+ }
1414
+ this.pending.clear();
1415
+ for (const controller of this.incoming.values())
1416
+ controller.abort(reason);
1417
+ this.incoming.clear();
1418
+ }
1419
+ send(message, transfer = []) {
1420
+ if (this.failure)
1421
+ return;
1422
+ try {
1423
+ this.options.send(message, transfer);
1424
+ } catch (error) {
1425
+ this.fail(error);
1426
+ }
1427
+ }
1428
+ /** Invalidate the channel and notify the peer when the transport still works. */
1429
+ fail(reason) {
1430
+ if (this.failure)
1431
+ return;
1432
+ this.close(reason);
1433
+ try {
1434
+ this.options.send({
1435
+ source: "math.gl/tasks",
1436
+ kind: "failure",
1437
+ id: 0,
1438
+ error: {
1439
+ name: reason instanceof Error ? reason.name : "Error",
1440
+ message: reason instanceof Error ? reason.message : String(reason)
1441
+ }
1442
+ }, []);
1443
+ } catch {
1444
+ }
1445
+ this.options.onFailure?.(reason);
1446
+ }
1447
+ };
1448
+ }
1449
+ });
1450
+
1451
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js
1452
+ function assertPayload(value) {
1453
+ if (!value || typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype) {
1454
+ throw new TypeError("Task payloads must be plain objects with named fields");
1455
+ }
1456
+ }
1457
+ function clonePayload(value, ownership = "copy") {
1458
+ assertPayload(value);
1459
+ if (!["copy", "transfer", "share"].includes(ownership))
1460
+ throw new TypeError("Invalid input ownership");
1461
+ const transfer = getTransferList(value);
1462
+ if (ownership === "share" && transfer.length)
1463
+ throw new TypeError("Share requires shared storage");
1464
+ return structuredClone(value, {
1465
+ transfer: ownership === "transfer" ? transfer : []
1466
+ });
1467
+ }
1468
+ function taskContext(state, context = {}) {
1469
+ const signal = context.signal ?? new AbortController().signal;
1470
+ return {
1471
+ state,
1472
+ signal,
1473
+ requestHost: async (operation, payload, controls) => {
1474
+ signal.throwIfAborted();
1475
+ if (!context.requestHost)
1476
+ throw new Error("No host request handler configured");
1477
+ return context.requestHost(operation, payload, controls);
1478
+ },
1479
+ emitHost: (operation, payload) => {
1480
+ signal.throwIfAborted();
1481
+ context.emitHost?.(operation, payload);
1482
+ },
1483
+ throwIfAborted: () => {
1484
+ signal.throwIfAborted();
1485
+ context.throwIfAborted?.();
1486
+ },
1487
+ reportProgress: (progress) => context.reportProgress?.({
1488
+ ...progress,
1489
+ phase: progress.phase ?? "process",
1490
+ unit: progress.unit ?? "items"
1491
+ })
1492
+ };
1493
+ }
1494
+ async function initializeTaskWorker(task) {
1495
+ if (!await WorkerBody.inWorkerThread())
1496
+ throw new Error("initializeTaskWorker must run inside a worker");
1497
+ if (installed)
1498
+ throw new Error("A task is already installed in this worker");
1499
+ installed = true;
1500
+ const runtime = new TaskRuntime(task);
1501
+ let channelStream;
1502
+ const channel = new TaskChannel({
1503
+ getResultTransferList: (value, request) => request.outputOwnership === "transfer" ? getTransferList(value) : [],
1504
+ send: (message, transfer) => {
1505
+ const snapshot = structuredClone(message, { transfer });
1506
+ void WorkerBody.postMessage("task-channel", snapshot).catch((reason) => channel.fail(reason));
1507
+ },
1508
+ handleRequest: async (operation, value, signal) => {
1509
+ const request = value;
1510
+ const context = {
1511
+ signal,
1512
+ reportProgress: (progress) => channel.emit("task:progress", { id: request.progressId, progress }),
1513
+ requestHost: (operation2, payload, controls = {}) => {
1514
+ const request2 = {
1515
+ operation: operation2,
1516
+ payload: clonePayload(payload, controls.inputOwnership),
1517
+ outputOwnership: controls.outputOwnership ?? "copy"
1518
+ };
1519
+ return channel.request("task:host-request", request2, signal, getTransferList(request2));
1520
+ },
1521
+ emitHost: (operation2, payload) => channel.emit("task:host-event", { operation: operation2, payload, id: request.progressId })
1522
+ };
1523
+ switch (operation) {
1524
+ case "initialize":
1525
+ return runtime.initialize(request.input, context);
1526
+ case "process":
1527
+ return runtime.process(request.input, request.options, context);
1528
+ case "stream-open": {
1529
+ if (channelStream)
1530
+ throw new Error("A task stream is already open");
1531
+ async function* inputs() {
1532
+ while (true) {
1533
+ const result = await channel.request("task:next-input", { outputOwnership: "transfer" }, signal);
1534
+ if (result.done)
1535
+ return;
1536
+ yield result.value;
1537
+ }
1538
+ }
1539
+ channelStream = runtime.stream(inputs(), request.options, context)[Symbol.asyncIterator]();
1540
+ return {};
1541
+ }
1542
+ case "stream-next":
1543
+ if (!channelStream)
1544
+ throw new Error("No active task stream");
1545
+ return channelStream.next();
1546
+ case "stream-close":
1547
+ try {
1548
+ await channelStream?.return?.();
1549
+ } finally {
1550
+ channelStream = void 0;
1551
+ }
1552
+ return {};
1553
+ case "destroy":
1554
+ return runtime.destroy();
1555
+ default:
1556
+ throw new Error("Unknown task channel operation");
1557
+ }
1558
+ }
1559
+ });
1560
+ await WorkerBody.addEventListener((type, payload) => {
1561
+ if (type === "task-channel")
1562
+ channel.receive(payload);
1563
+ });
1564
+ let streamOptions = {};
1565
+ return createWorker(async (request, _options, context) => {
1566
+ switch (request.operation) {
1567
+ case "initialize":
1568
+ return runtime.initialize(request.input, context);
1569
+ case "destroy":
1570
+ return runtime.destroy();
1571
+ case "stream-options":
1572
+ streamOptions = request.options;
1573
+ return {};
1574
+ case "process":
1575
+ return runtime.process(request.input, request.options, context);
1576
+ default:
1577
+ throw new Error("Unknown task operation");
1578
+ }
1579
+ }, async function* (inputs, _options, context) {
1580
+ async function* batches() {
1581
+ for await (const input of inputs) {
1582
+ assertPayload(input);
1583
+ yield input;
1584
+ }
1585
+ }
1586
+ try {
1587
+ yield* runtime.stream(batches(), streamOptions, context);
1588
+ } finally {
1589
+ streamOptions = {};
1590
+ }
1591
+ }, () => preloadTaskCode(task));
1592
+ }
1593
+ var TaskRuntime, installed;
1594
+ var init_task_runtime = __esm({
1595
+ "../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js"() {
1596
+ init_worker_utils();
1597
+ init_task_preload();
1598
+ init_task_channel();
1599
+ TaskRuntime = class {
1600
+ constructor(task) {
1601
+ this.task = task;
1602
+ this.initialized = false;
1603
+ }
1604
+ async initialize(input, context = {}) {
1605
+ if (this.initialized)
1606
+ throw new Error("Task is already initialized");
1607
+ assertPayload(input);
1608
+ await preloadTaskCode(this.task, context.signal);
1609
+ context.signal?.throwIfAborted();
1610
+ this.state = await this.task.initialize?.(input, taskContext(void 0, context));
1611
+ this.initialized = true;
1612
+ return {};
1613
+ }
1614
+ async destroy() {
1615
+ if (this.initialized) {
1616
+ this.initialized = false;
1617
+ const state = this.state;
1618
+ this.state = void 0;
1619
+ if (this.task.initialize)
1620
+ await this.task.destroy?.(state);
1621
+ }
1622
+ return {};
1623
+ }
1624
+ async process(input, options, context = {}) {
1625
+ if (!this.initialized)
1626
+ throw new Error("Task is not initialized");
1627
+ if (!this.task.process)
1628
+ throw new Error("Task has no atomic processor");
1629
+ assertPayload(input);
1630
+ const result = await this.task.process(input, options, taskContext(this.state, context));
1631
+ assertPayload(result);
1632
+ return result;
1633
+ }
1634
+ async *stream(inputs, options, context = {}) {
1635
+ if (!this.initialized)
1636
+ throw new Error("Task is not initialized");
1637
+ if (!this.task.processInBatches)
1638
+ throw new Error("Task has no streaming processor");
1639
+ for await (const output of this.task.processInBatches(inputs, options, taskContext(this.state, context))) {
1640
+ assertPayload(output);
1641
+ yield output;
1642
+ }
1643
+ }
1644
+ };
1645
+ installed = false;
1646
+ }
1647
+ });
1648
+
1649
+ // ../../node_modules/@math.gl/tasks/dist/tasks/index.js
1650
+ var init_tasks = __esm({
1651
+ "../../node_modules/@math.gl/tasks/dist/tasks/index.js"() {
1652
+ init_task_runtime();
1653
+ }
1654
+ });
1655
+
1656
+ // ../../node_modules/@math.gl/tasks/dist/index.js
1657
+ var init_dist = __esm({
1658
+ "../../node_modules/@math.gl/tasks/dist/index.js"() {
1659
+ init_tasks();
1660
+ }
1661
+ });
1662
+
1663
+ // ../core/src/worker-utils/lib/node/worker_threads-browser.ts
1664
+ var worker_threads_browser_exports = {};
1665
+ __export(worker_threads_browser_exports, {
1666
+ NodeWorker: () => NodeWorker,
1667
+ parentPort: () => parentPort2
1668
+ });
1669
+ var NodeWorker, parentPort2;
1670
+ var init_worker_threads_browser2 = __esm({
1671
+ "../core/src/worker-utils/lib/node/worker_threads-browser.ts"() {
1672
+ "use strict";
1673
+ NodeWorker = class {
1674
+ /** Restores the native worker constructor when this browser shim is embedded in a Node bundle. */
1675
+ constructor(...arguments_) {
1676
+ const runtimeProcess = globalThis.process;
1677
+ const WorkerConstructor = runtimeProcess?.getBuiltinModule?.("node:worker_threads").Worker;
1678
+ if (WorkerConstructor) {
1679
+ return new WorkerConstructor(...arguments_);
1680
+ }
1681
+ }
1682
+ /** No-op browser fallback matching the native Worker API. */
1683
+ terminate() {
1684
+ }
1685
+ };
1686
+ parentPort2 = null;
1687
+ }
1688
+ });
1689
+
1690
+ // ../core/src/worker-utils/lib/worker-api/task-runtime.ts
1691
+ function normalizeTaskProgress(progress) {
1692
+ return { ...progress, phase: progress.phase ?? "process", unit: progress.unit ?? "items" };
1693
+ }
1694
+ async function isWorkerThread() {
1695
+ if (typeof self !== "undefined" && typeof document === "undefined" && typeof self.postMessage === "function")
1696
+ return true;
1697
+ if (typeof process !== "undefined" && process.versions?.node) {
1698
+ const { isMainThread } = await Promise.resolve().then(() => (init_worker_threads_browser2(), worker_threads_browser_exports));
1699
+ return !isMainThread;
1700
+ }
1701
+ return false;
1702
+ }
1703
+ var initializeTaskWorker2;
1704
+ var init_task_runtime2 = __esm({
1705
+ "../core/src/worker-utils/lib/worker-api/task-runtime.ts"() {
1706
+ "use strict";
1707
+ init_dist();
1708
+ initializeTaskWorker2 = initializeTaskWorker;
1709
+ }
1710
+ });
1711
+
1712
+ // ../core/src/worker-utils/lib/worker-utils/get-transfer-list.ts
1713
+ function getTransferList2(object, recursive = true, transfers) {
1714
+ const transfersSet = transfers || /* @__PURE__ */ new Set();
1715
+ if (!object) {
1716
+ } else if (isTransferable2(object)) {
1717
+ transfersSet.add(object);
1718
+ } else if (isTransferable2(object.buffer)) {
1719
+ transfersSet.add(object.buffer);
1720
+ } else if (ArrayBuffer.isView(object)) {
1721
+ } else if (recursive && typeof object === "object") {
1722
+ for (const key in object) {
1723
+ getTransferList2(object[key], recursive, transfersSet);
1724
+ }
1725
+ }
1726
+ return transfers === void 0 ? Array.from(transfersSet) : [];
1727
+ }
1728
+ function isTransferable2(object) {
1729
+ if (!object) {
1730
+ return false;
1731
+ }
1732
+ if (object instanceof ArrayBuffer) {
1733
+ return true;
1734
+ }
1735
+ if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
1736
+ return true;
1737
+ }
1738
+ if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
1739
+ return true;
1740
+ }
1741
+ if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
1742
+ return true;
1743
+ }
1744
+ return false;
1745
+ }
1746
+ var init_get_transfer_list2 = __esm({
1747
+ "../core/src/worker-utils/lib/worker-utils/get-transfer-list.ts"() {
1748
+ "use strict";
1749
+ }
1750
+ });
1751
+
1752
+ // ../core/src/worker-utils/lib/worker-api/create-worker.ts
1753
+ async function createWorker2(process2, processInBatches) {
1754
+ if (!await isWorkerThread()) return;
1755
+ await initializeTaskWorker2(createWorkerTask(process2, processInBatches));
1756
+ }
1757
+ function createWorkerTask(process2, processInBatches) {
1758
+ return {
1759
+ id: "loaders.gl",
1760
+ initialize: (state) => state,
1761
+ destroy: (state) => state.port?.close(),
1762
+ process: async ({ value }, options, context) => {
1763
+ if (!process2) throw new Error("Worker does not support atomic processing");
1764
+ return { value: await process2(value, options, createContext(context), context.state.context) };
1765
+ },
1766
+ ...processInBatches ? {
1767
+ processInBatches: async function* (inputs, options, context) {
1768
+ async function* values() {
1769
+ for await (const input of inputs) yield input.value;
1770
+ }
1771
+ for await (const value of processInBatches(
1772
+ values(),
1773
+ options,
1774
+ createContext(context),
1775
+ context.state.context
1776
+ )) {
1777
+ yield { value };
1778
+ }
346
1779
  }
347
- };
348
- WorkerBody.addEventListener(onMessage);
349
- const payload = { id, input: arrayBuffer, options, context: jobContext };
350
- WorkerBody.postMessage("process", payload);
351
- });
352
- }
353
- function createProgressReporter() {
354
- let pending;
355
- let finished = false;
356
- let scheduled = false;
357
- const flush = () => {
358
- scheduled = false;
359
- if (pending) {
360
- WorkerBody.postMessage("progress", { progress: pending });
361
- pending = void 0;
362
- }
1780
+ } : {}
363
1781
  };
1782
+ }
1783
+ function createContext(context) {
1784
+ let requestIdentifier = 0;
1785
+ const port = context.state.port;
364
1786
  return {
365
- /** Records progress while retaining phase transitions. */
366
- report(progress) {
367
- if (finished) return;
368
- if (pending && pending.phase !== progress.phase) flush();
369
- pending = { ...progress };
370
- if (!scheduled) {
371
- scheduled = true;
372
- setTimeout(flush, 0);
373
- }
374
- },
375
- /** Flushes final progress and suppresses reports from stale callbacks. */
376
- finish() {
377
- flush();
378
- finished = true;
379
- }
1787
+ signal: context.signal,
1788
+ throwIfAborted: () => context.throwIfAborted(),
1789
+ reportProgress: (progress) => context.reportProgress(normalizeTaskProgress(progress)),
1790
+ process: port ? (input, options = {}, jobContext = {}) => {
1791
+ context.throwIfAborted();
1792
+ const identifier = ++requestIdentifier;
1793
+ return new Promise((resolve, reject) => {
1794
+ const onMessage = (event) => {
1795
+ if (event.data.identifier !== identifier) return;
1796
+ cleanup();
1797
+ if (event.data.error) {
1798
+ const error = new Error(event.data.error.message);
1799
+ error.name = event.data.error.name;
1800
+ reject(error);
1801
+ } else resolve(event.data.value);
1802
+ };
1803
+ const onAbort = () => {
1804
+ cleanup();
1805
+ reject(context.signal.reason);
1806
+ };
1807
+ const cleanup = () => {
1808
+ port.removeEventListener("message", onMessage);
1809
+ context.signal.removeEventListener("abort", onAbort);
1810
+ };
1811
+ port.addEventListener("message", onMessage);
1812
+ context.signal.addEventListener("abort", onAbort, { once: true });
1813
+ port.start();
1814
+ try {
1815
+ const request = { identifier, input, options, context: jobContext };
1816
+ port.postMessage(request, getTransferList2(request));
1817
+ } catch (error) {
1818
+ cleanup();
1819
+ reject(error);
1820
+ }
1821
+ });
1822
+ } : void 0
380
1823
  };
381
1824
  }
382
- var requestId, activeInputBatches, activeOutputAcknowledgements;
383
- var init_create_worker = __esm({
1825
+ var init_create_worker2 = __esm({
384
1826
  "../core/src/worker-utils/lib/worker-api/create-worker.ts"() {
385
1827
  "use strict";
386
- init_async_queue();
387
- init_worker_body();
388
- requestId = 0;
389
- activeInputBatches = null;
390
- activeOutputAcknowledgements = null;
1828
+ init_task_runtime2();
1829
+ init_get_transfer_list2();
391
1830
  }
392
1831
  });
393
1832
 
394
1833
  // ../core/src/worker-utils/index.ts
395
- var init_worker_utils = __esm({
1834
+ var init_worker_utils2 = __esm({
396
1835
  "../core/src/worker-utils/index.ts"() {
397
1836
  "use strict";
398
- init_create_worker();
1837
+ init_create_worker2();
399
1838
  }
400
1839
  });
401
1840
 
402
1841
  // ../core/src/loader-utils/lib/worker-loader-utils/create-loader-worker.ts
403
1842
  async function createLoaderWorker(loader, selectLoader = () => loader) {
404
- await createWorker(
1843
+ await createWorker2(
405
1844
  (input, options, workerContext, loaderContext) => processLoaderWorkerData(
406
1845
  selectLoader(options || {}),
407
1846
  input,
@@ -539,7 +1978,7 @@
539
1978
  var init_create_loader_worker = __esm({
540
1979
  "../core/src/loader-utils/lib/worker-loader-utils/create-loader-worker.ts"() {
541
1980
  "use strict";
542
- init_worker_utils();
1981
+ init_worker_utils2();
543
1982
  }
544
1983
  });
545
1984
 
@@ -771,7 +2210,7 @@
771
2210
  });
772
2211
 
773
2212
  // ../../node_modules/@math.gl/core/dist/index.js
774
- var init_dist = __esm({
2213
+ var init_dist2 = __esm({
775
2214
  "../../node_modules/@math.gl/core/dist/index.js"() {
776
2215
  init_math_utils();
777
2216
  init_types2();
@@ -788,6 +2227,7 @@
788
2227
  var init_loader_utils = __esm({
789
2228
  "../core/src/loader-utils/index.ts"() {
790
2229
  "use strict";
2230
+ init_log2();
791
2231
  init_create_loader_worker();
792
2232
  init_text_iterators();
793
2233
  init_async_iteration();
@@ -8511,11 +9951,11 @@ return true;`);
8511
9951
  this._offsets = new OffsetsBufferBuilder(opts.type);
8512
9952
  }
8513
9953
  setValue(index, value) {
8514
- const pending = this._pending || (this._pending = /* @__PURE__ */ new Map());
8515
- const current = pending.get(index);
9954
+ const pending2 = this._pending || (this._pending = /* @__PURE__ */ new Map());
9955
+ const current = pending2.get(index);
8516
9956
  current && (this._pendingLength -= current.length);
8517
9957
  this._pendingLength += value instanceof MapRow ? value[kKeys].length : value.length;
8518
- pending.set(index, value);
9958
+ pending2.set(index, value);
8519
9959
  }
8520
9960
  setValid(index, isValid) {
8521
9961
  if (!super.setValid(index, isValid)) {
@@ -8538,12 +9978,12 @@ return true;`);
8538
9978
  return super.finish();
8539
9979
  }
8540
9980
  _flush() {
8541
- const pending = this._pending;
9981
+ const pending2 = this._pending;
8542
9982
  const pendingLength = this._pendingLength;
8543
9983
  this._pendingLength = 0;
8544
9984
  this._pending = void 0;
8545
- if (pending && pending.size > 0) {
8546
- this._flushPending(pending, pendingLength);
9985
+ if (pending2 && pending2.size > 0) {
9986
+ this._flushPending(pending2, pendingLength);
8547
9987
  }
8548
9988
  return this;
8549
9989
  }
@@ -8663,8 +10103,8 @@ return true;`);
8663
10103
  static startFooter(builder) {
8664
10104
  builder.startObject(5);
8665
10105
  }
8666
- static addVersion(builder, version) {
8667
- builder.addFieldInt16(0, version, MetadataVersion.V1);
10106
+ static addVersion(builder, version2) {
10107
+ builder.addFieldInt16(0, version2, MetadataVersion.V1);
8668
10108
  }
8669
10109
  static addSchema(builder, schemaOffset) {
8670
10110
  builder.addFieldOffset(1, schemaOffset, 0);
@@ -8910,9 +10350,9 @@ return true;`);
8910
10350
  get numDictionaries() {
8911
10351
  return this._dictionaryBatches.length;
8912
10352
  }
8913
- constructor(schema, version = MetadataVersion.V5, recordBatches, dictionaryBatches) {
10353
+ constructor(schema, version2 = MetadataVersion.V5, recordBatches, dictionaryBatches) {
8914
10354
  this.schema = schema;
8915
- this.version = version;
10355
+ this.version = version2;
8916
10356
  recordBatches && (this._recordBatches = recordBatches);
8917
10357
  dictionaryBatches && (this._dictionaryBatches = dictionaryBatches);
8918
10358
  }
@@ -9040,8 +10480,8 @@ return true;`);
9040
10480
  static startMessage(builder) {
9041
10481
  builder.startObject(5);
9042
10482
  }
9043
- static addVersion(builder, version) {
9044
- builder.addFieldInt16(0, version, MetadataVersion.V1);
10483
+ static addVersion(builder, version2) {
10484
+ builder.addFieldInt16(0, version2, MetadataVersion.V1);
9045
10485
  }
9046
10486
  static addHeaderType(builder, headerType) {
9047
10487
  builder.addFieldInt8(1, headerType, MessageHeader.NONE);
@@ -9075,9 +10515,9 @@ return true;`);
9075
10515
  static finishSizePrefixedMessageBuffer(builder, offset) {
9076
10516
  builder.finish(offset, void 0, true);
9077
10517
  }
9078
- static createMessage(builder, version, headerType, headerOffset, bodyLength, customMetadataOffset) {
10518
+ static createMessage(builder, version2, headerType, headerOffset, bodyLength, customMetadataOffset) {
9079
10519
  _Message.startMessage(builder);
9080
- _Message.addVersion(builder, version);
10520
+ _Message.addVersion(builder, version2);
9081
10521
  _Message.addHeaderType(builder, headerType);
9082
10522
  _Message.addHeader(builder, headerOffset);
9083
10523
  _Message.addBodyLength(builder, bodyLength);
@@ -9449,16 +10889,16 @@ return true;`);
9449
10889
  throw new Error(`Unrecognized Message type: { name: ${MessageHeader[type]}, type: ${type} }`);
9450
10890
  });
9451
10891
  }
9452
- function decodeSchema(_schema, dictionaries = /* @__PURE__ */ new Map(), version = MetadataVersion.V5) {
10892
+ function decodeSchema(_schema, dictionaries = /* @__PURE__ */ new Map(), version2 = MetadataVersion.V5) {
9453
10893
  const fields = decodeSchemaFields(_schema, dictionaries);
9454
- return new Schema2(fields, decodeCustomMetadata(_schema), dictionaries, version);
10894
+ return new Schema2(fields, decodeCustomMetadata(_schema), dictionaries, version2);
9455
10895
  }
9456
- function decodeRecordBatch(batch, version = MetadataVersion.V5) {
9457
- const recordBatch = new RecordBatch2(batch.length(), decodeFieldNodes(batch), decodeBuffers(batch, version), decodeBodyCompression(batch.compression()), decodeVariadicBufferCounts(batch));
10896
+ function decodeRecordBatch(batch, version2 = MetadataVersion.V5) {
10897
+ const recordBatch = new RecordBatch2(batch.length(), decodeFieldNodes(batch), decodeBuffers(batch, version2), decodeBodyCompression(batch.compression()), decodeVariadicBufferCounts(batch));
9458
10898
  return recordBatch;
9459
10899
  }
9460
- function decodeDictionaryBatch(batch, version = MetadataVersion.V5) {
9461
- return new DictionaryBatch2(RecordBatch2.decode(batch.data(), version), batch.id(), batch.isDelta());
10900
+ function decodeDictionaryBatch(batch, version2 = MetadataVersion.V5) {
10901
+ return new DictionaryBatch2(RecordBatch2.decode(batch.data(), version2), batch.id(), batch.isDelta());
9462
10902
  }
9463
10903
  function decodeBufferRegion(b) {
9464
10904
  return new BufferRegion(b.offset(), b.length());
@@ -9475,11 +10915,11 @@ return true;`);
9475
10915
  }
9476
10916
  return nodes;
9477
10917
  }
9478
- function decodeBuffers(batch, version) {
10918
+ function decodeBuffers(batch, version2) {
9479
10919
  const bufferRegions = [];
9480
10920
  for (let b, i = -1, j = -1, n = batch.buffersLength(); ++i < n; ) {
9481
10921
  if (b = batch.buffers(i)) {
9482
- if (version < MetadataVersion.V4) {
10922
+ if (version2 < MetadataVersion.V4) {
9483
10923
  b.bb_pos += 8 * (i + 1);
9484
10924
  }
9485
10925
  bufferRegions[++j] = BufferRegion.decode(b);
@@ -9804,10 +11244,10 @@ return true;`);
9804
11244
  buf = new ByteBuffer3(toUint8Array(buf));
9805
11245
  const _message = Message.getRootAsMessage(buf);
9806
11246
  const bodyLength = _message.bodyLength();
9807
- const version = _message.version();
11247
+ const version2 = _message.version();
9808
11248
  const headerType = _message.headerType();
9809
11249
  const metadata = decodeMessageCustomMetadata(_message);
9810
- const message = new _Message(bodyLength, version, headerType, void 0, metadata);
11250
+ const message = new _Message(bodyLength, version2, headerType, void 0, metadata);
9811
11251
  message._createHeader = decodeMessageHeader(_message, headerType);
9812
11252
  return message;
9813
11253
  }
@@ -9884,8 +11324,8 @@ return true;`);
9884
11324
  isDictionaryBatch() {
9885
11325
  return this.headerType === MessageHeader.DictionaryBatch;
9886
11326
  }
9887
- constructor(bodyLength, version, headerType, header, metadata) {
9888
- this._version = version;
11327
+ constructor(bodyLength, version2, headerType, header, metadata) {
11328
+ this._version = version2;
9889
11329
  this._headerType = headerType;
9890
11330
  this.body = new Uint8Array(0);
9891
11331
  this._compression = header === null || header === void 0 ? void 0 : header.compression;
@@ -11129,11 +12569,11 @@ return true;`);
11129
12569
  setValue(index, value) {
11130
12570
  return super.setValue(index, toUint8Array(value));
11131
12571
  }
11132
- _flushPending(pending, pendingLength) {
12572
+ _flushPending(pending2, pendingLength) {
11133
12573
  const offsets = this._offsets;
11134
12574
  const data = this._values.reserve(pendingLength).buffer;
11135
12575
  let offset = 0;
11136
- for (const [index, value] of pending) {
12576
+ for (const [index, value] of pending2) {
11137
12577
  if (value === void 0) {
11138
12578
  offsets.set(index, 0);
11139
12579
  } else {
@@ -11170,11 +12610,11 @@ return true;`);
11170
12610
  setValue(index, value) {
11171
12611
  return super.setValue(index, toUint8Array(value));
11172
12612
  }
11173
- _flushPending(pending, pendingLength) {
12613
+ _flushPending(pending2, pendingLength) {
11174
12614
  const offsets = this._offsets;
11175
12615
  const data = this._values.reserve(pendingLength).buffer;
11176
12616
  let offset = 0;
11177
- for (const [index, value] of pending) {
12617
+ for (const [index, value] of pending2) {
11178
12618
  if (value === void 0) {
11179
12619
  offsets.set(index, BigInt(0));
11180
12620
  } else {
@@ -11485,10 +12925,10 @@ return true;`);
11485
12925
  this.type = new List2(new Field2(name, child.type, true));
11486
12926
  return this.numChildren - 1;
11487
12927
  }
11488
- _flushPending(pending) {
12928
+ _flushPending(pending2) {
11489
12929
  const offsets = this._offsets;
11490
12930
  const [child] = this.children;
11491
- for (const [index, value] of pending) {
12931
+ for (const [index, value] of pending2) {
11492
12932
  if (typeof value === "undefined") {
11493
12933
  offsets.set(index, 0);
11494
12934
  } else {
@@ -11527,10 +12967,10 @@ return true;`);
11527
12967
  this.type = new LargeList2(new Field2(name, child.type, true));
11528
12968
  return this.numChildren - 1;
11529
12969
  }
11530
- _flushPending(pending) {
12970
+ _flushPending(pending2) {
11531
12971
  const offsets = this._offsets;
11532
12972
  const [child] = this.children;
11533
- for (const [index, value] of pending) {
12973
+ for (const [index, value] of pending2) {
11534
12974
  if (typeof value === "undefined") {
11535
12975
  offsets.set(index, BigInt(0));
11536
12976
  } else {
@@ -11560,11 +13000,11 @@ return true;`);
11560
13000
  }
11561
13001
  setValue(index, value) {
11562
13002
  const row = value instanceof Map ? value : new Map(Object.entries(value));
11563
- const pending = this._pending || (this._pending = /* @__PURE__ */ new Map());
11564
- const current = pending.get(index);
13003
+ const pending2 = this._pending || (this._pending = /* @__PURE__ */ new Map());
13004
+ const current = pending2.get(index);
11565
13005
  current && (this._pendingLength -= current.size);
11566
13006
  this._pendingLength += row.size;
11567
- pending.set(index, row);
13007
+ pending2.set(index, row);
11568
13008
  }
11569
13009
  addChild(child, name = `${this.numChildren}`) {
11570
13010
  if (this.numChildren > 0) {
@@ -11574,10 +13014,10 @@ return true;`);
11574
13014
  this.type = new Map_(new Field2(name, child.type, true), this.type.keysSorted);
11575
13015
  return this.numChildren - 1;
11576
13016
  }
11577
- _flushPending(pending) {
13017
+ _flushPending(pending2) {
11578
13018
  const offsets = this._offsets;
11579
13019
  const [child] = this.children;
11580
- for (const [index, value] of pending) {
13020
+ for (const [index, value] of pending2) {
11581
13021
  if (value === void 0) {
11582
13022
  offsets.set(index, 0);
11583
13023
  } else {
@@ -11786,7 +13226,7 @@ return true;`);
11786
13226
  return super.setValue(index, encodeUtf8(value));
11787
13227
  }
11788
13228
  // @ts-ignore
11789
- _flushPending(pending, pendingLength) {
13229
+ _flushPending(pending2, pendingLength) {
11790
13230
  }
11791
13231
  };
11792
13232
  Utf8Builder.prototype._flushPending = BinaryBuilder.prototype._flushPending;
@@ -11817,7 +13257,7 @@ return true;`);
11817
13257
  return super.setValue(index, encodeUtf8(value));
11818
13258
  }
11819
13259
  // @ts-ignore
11820
- _flushPending(pending, pendingLength) {
13260
+ _flushPending(pending2, pendingLength) {
11821
13261
  }
11822
13262
  };
11823
13263
  LargeUtf8Builder.prototype._flushPending = LargeBinaryBuilder.prototype._flushPending;
@@ -16196,7 +17636,113 @@ return true;`);
16196
17636
  }
16197
17637
  });
16198
17638
 
16199
- // ../core/src/schema-utils/lib/mesh/mesh-utils.ts
17639
+ // ../core/src/lib/loader-utils/native-arrow.ts
17640
+ function isNativeArrowTable(value) {
17641
+ return Boolean(
17642
+ value && typeof value === "object" && "schema" in value && "batches" in value && Array.isArray(value.batches) && "numRows" in value && typeof value.numRows === "number" && "getChildAt" in value && typeof value.getChildAt === "function"
17643
+ );
17644
+ }
17645
+ var init_native_arrow = __esm({
17646
+ "../core/src/lib/loader-utils/native-arrow.ts"() {
17647
+ "use strict";
17648
+ }
17649
+ });
17650
+
17651
+ // ../core/src/schema-utils/lib/arrow/arrow-metadata.ts
17652
+ function snapshotArrowSchema(schema) {
17653
+ return deserializeArrowSchema(serializeArrowSchema(schema));
17654
+ }
17655
+ function mergeArrowSchemas(previous, next) {
17656
+ if (!previous) return snapshotArrowSchema(next);
17657
+ new Table(previous, [new RecordBatch3(next, void 0)]);
17658
+ const earlier = serializeArrowSchema(previous);
17659
+ const later = serializeArrowSchema(next);
17660
+ return deserializeArrowSchema({
17661
+ ...later,
17662
+ fields: later.fields.map((field, index) => mergeFieldMetadata(earlier.fields[index], field)),
17663
+ metadata: { ...earlier.metadata, ...later.metadata }
17664
+ });
17665
+ }
17666
+ function mergeFieldMetadata(previous, next) {
17667
+ return {
17668
+ ...next,
17669
+ type: mergeTypeMetadata(previous.type, next.type),
17670
+ metadata: { ...previous.metadata, ...next.metadata }
17671
+ };
17672
+ }
17673
+ function mergeTypeMetadata(previous, next) {
17674
+ if (typeof previous !== "object" || typeof next !== "object") return next;
17675
+ if ("children" in previous && "children" in next) {
17676
+ const previousChildren = previous.children;
17677
+ return {
17678
+ ...next,
17679
+ children: next.children.map(
17680
+ (field, index) => mergeFieldMetadata(previousChildren[index], field)
17681
+ )
17682
+ };
17683
+ }
17684
+ if (previous.type === "dictionary" && next.type === "dictionary") {
17685
+ return { ...next, dictionary: mergeTypeMetadata(previous.dictionary, next.dictionary) };
17686
+ }
17687
+ return next;
17688
+ }
17689
+ function updateArrowTableSchema(table, schema) {
17690
+ const snapshot = snapshotArrowSchema(schema);
17691
+ const batches = table.batches.map(
17692
+ (batch) => new RecordBatch3(snapshotArrowSchema(snapshot), batch.data, new Map(batch.metadata))
17693
+ );
17694
+ return new Table(
17695
+ snapshot,
17696
+ batches.length ? batches : [new RecordBatch3(snapshotArrowSchema(snapshot), void 0)]
17697
+ );
17698
+ }
17699
+ function updateArrowTableMetadata(table, metadata) {
17700
+ const schema = new Schema2(
17701
+ table.data.schema.fields,
17702
+ new Map([...table.data.schema.metadata, ...Object.entries(metadata)])
17703
+ );
17704
+ const data = updateArrowTableSchema(table.data, schema);
17705
+ return { ...table, data, schema: serializeArrowSchema(data.schema) };
17706
+ }
17707
+ function makeArrowMetadataBatch(schema) {
17708
+ return new RecordBatch3(snapshotArrowSchema(schema), void 0);
17709
+ }
17710
+ async function* refineArrowTableBatches(batches) {
17711
+ let schema;
17712
+ let bounds;
17713
+ for await (const batch of batches) {
17714
+ const table = batch;
17715
+ if (table?.shape !== "arrow-table") {
17716
+ yield batch;
17717
+ continue;
17718
+ }
17719
+ const localBounds = table.data.schema.metadata.get("boundingBox");
17720
+ const nextSchema = snapshotArrowSchema(table.data.schema);
17721
+ if (localBounds) {
17722
+ const nextBounds = JSON.parse(localBounds);
17723
+ bounds = bounds ? [
17724
+ nextBounds[0].map((value, index) => Math.min(bounds[0][index], value)),
17725
+ nextBounds[1].map((value, index) => Math.max(bounds[1][index], value))
17726
+ ] : nextBounds;
17727
+ nextSchema.metadata.set("boundingBox", JSON.stringify(bounds));
17728
+ }
17729
+ schema = mergeArrowSchemas(schema, nextSchema);
17730
+ const data = updateArrowTableSchema(table.data, schema);
17731
+ if (localBounds) {
17732
+ for (const recordBatch of data.batches) recordBatch.metadata.set("boundingBox", localBounds);
17733
+ }
17734
+ yield { ...table, data, schema: serializeArrowSchema(data.schema) };
17735
+ }
17736
+ }
17737
+ var init_arrow_metadata = __esm({
17738
+ "../core/src/schema-utils/lib/arrow/arrow-metadata.ts"() {
17739
+ "use strict";
17740
+ init_Arrow_dom();
17741
+ init_convert_arrow_schema();
17742
+ }
17743
+ });
17744
+
17745
+ // ../core/src/schema-utils/lib/mesh/get-mesh-bounding-box.ts
16200
17746
  function getMeshBoundingBox(attributes) {
16201
17747
  const positionAttribute = attributes?.POSITION;
16202
17748
  if (!positionAttribute || !("value" in positionAttribute) || !positionAttribute.value.length) {
@@ -16226,9 +17772,17 @@ return true;`);
16226
17772
  [maxX, maxY, maxZ]
16227
17773
  ];
16228
17774
  }
17775
+ var init_get_mesh_bounding_box = __esm({
17776
+ "../core/src/schema-utils/lib/mesh/get-mesh-bounding-box.ts"() {
17777
+ "use strict";
17778
+ }
17779
+ });
17780
+
17781
+ // ../core/src/schema-utils/lib/mesh/mesh-utils.ts
16229
17782
  var init_mesh_utils = __esm({
16230
17783
  "../core/src/schema-utils/lib/mesh/mesh-utils.ts"() {
16231
17784
  "use strict";
17785
+ init_get_mesh_bounding_box();
16232
17786
  }
16233
17787
  });
16234
17788
 
@@ -16307,7 +17861,7 @@ return true;`);
16307
17861
  var init_float162 = __esm({
16308
17862
  "../core/src/schema/float16.ts"() {
16309
17863
  "use strict";
16310
- init_dist();
17864
+ init_dist2();
16311
17865
  }
16312
17866
  });
16313
17867
 
@@ -16391,31 +17945,7 @@ return true;`);
16391
17945
  });
16392
17946
 
16393
17947
  // ../core/src/schema-utils/lib/mesh/convert-mesh-to-table.ts
16394
- function convertMeshToTable(mesh, shape) {
16395
- switch (shape) {
16396
- case "columnar-table":
16397
- return convertMeshToColumnarTable(mesh);
16398
- case "arrow-table":
16399
- return convertMeshToArrowTable(mesh);
16400
- default:
16401
- throw new Error(shape);
16402
- }
16403
- }
16404
- function convertMeshToColumnarTable(mesh) {
16405
- const columns = {};
16406
- const hasIndices = hasMeshIndices(mesh);
16407
- for (const [columnName, attribute] of Object.entries(mesh.attributes)) {
16408
- columns[columnName] = attribute.value;
16409
- }
16410
- return {
16411
- shape: "columnar-table",
16412
- schema: mesh.schema,
16413
- data: columns,
16414
- topology: mesh.topology,
16415
- indices: hasIndices ? mesh.indices : void 0
16416
- };
16417
- }
16418
- function convertMeshToArrowTable(mesh, batchSize) {
17948
+ function convertMeshToArrowTableWrapper(mesh, batchSize) {
16419
17949
  return makeMeshArrowTable(mesh.attributes, {
16420
17950
  schema: mesh.schema,
16421
17951
  topology: mesh.topology,
@@ -16576,6 +18106,7 @@ return true;`);
16576
18106
 
16577
18107
  // ../core/src/schema-utils/lib/mesh/convert-table-to-mesh.ts
16578
18108
  function convertTableToMesh(table) {
18109
+ if (isNativeArrowTable(table)) return convertArrowTableToMesh(table);
16579
18110
  switch (table.shape) {
16580
18111
  // case 'columnar-table':
16581
18112
  // return convertColumnarTableToMesh(table);
@@ -16586,8 +18117,10 @@ return true;`);
16586
18117
  }
16587
18118
  }
16588
18119
  function convertArrowTableToMesh(table) {
16589
- const arrowTable = table.data;
18120
+ const arrowTable = isNativeArrowTable(table) ? table : table.data;
16590
18121
  const schema = serializeArrowSchema(arrowTable.schema);
18122
+ const localBounds = arrowTable.batches.length === 1 ? arrowTable.batches[0].metadata.get("boundingBox") : void 0;
18123
+ if (localBounds) schema.metadata = { ...schema.metadata, boundingBox: localBounds };
16591
18124
  const fields = schema.fields;
16592
18125
  const attributes = {};
16593
18126
  const columns = [];
@@ -16742,6 +18275,7 @@ return true;`);
16742
18275
  init_Arrow_dom();
16743
18276
  init_arrow_fixed_size_list_utils();
16744
18277
  init_convert_arrow_schema();
18278
+ init_native_arrow();
16745
18279
  init_mesh_utils();
16746
18280
  }
16747
18281
  });
@@ -16800,16 +18334,78 @@ return true;`);
16800
18334
  var init_schema_utils = __esm({
16801
18335
  "../core/src/schema-utils/index.ts"() {
16802
18336
  "use strict";
18337
+ init_convert_arrow_schema();
16803
18338
  init_mesh_utils();
16804
18339
  init_convert_mesh_to_table();
16805
18340
  init_convert_table_to_mesh();
16806
18341
  init_deduce_mesh_schema();
18342
+ init_arrow_metadata();
18343
+ init_arrow_metadata();
18344
+ }
18345
+ });
18346
+
18347
+ // ../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-helpers.js
18348
+ var init_indexed_arrow_helpers = __esm({
18349
+ "../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-helpers.js"() {
18350
+ }
18351
+ });
18352
+
18353
+ // ../../node_modules/@math.gl/arrow/dist/arrow/arrow-schema-utils.js
18354
+ var init_arrow_schema_utils = __esm({
18355
+ "../../node_modules/@math.gl/arrow/dist/arrow/arrow-schema-utils.js"() {
18356
+ }
18357
+ });
18358
+
18359
+ // ../../node_modules/@math.gl/arrow/dist/arrow/arrow-data.js
18360
+ function getArrowVariadicBuffers(data) {
18361
+ return data.variadicBuffers ?? [];
18362
+ }
18363
+ function createArrowData(type, offset, length, nullCount, buffers, children, dictionary, variadicBuffers) {
18364
+ return Reflect.construct(Data, [
18365
+ type,
18366
+ offset,
18367
+ length,
18368
+ nullCount,
18369
+ buffers,
18370
+ children,
18371
+ dictionary,
18372
+ variadicBuffers
18373
+ ]);
18374
+ }
18375
+ var init_arrow_data = __esm({
18376
+ "../../node_modules/@math.gl/arrow/dist/arrow/arrow-data.js"() {
18377
+ init_Arrow_dom();
18378
+ }
18379
+ });
18380
+
18381
+ // ../../node_modules/@math.gl/arrow/dist/arrow/arrow-record-batch.js
18382
+ function getRecordBatchMetadata(batch) {
18383
+ return batch.metadata;
18384
+ }
18385
+ function createRecordBatchWithMetadata(schema, data, metadata) {
18386
+ if ("metadata" in RecordBatch3.prototype) {
18387
+ const MetadataRecordBatch = RecordBatch3;
18388
+ return Object.assign(new MetadataRecordBatch(schema, data, metadata), { data });
18389
+ }
18390
+ const batch = Object.assign(new RecordBatch3(schema, data), { data });
18391
+ return metadata === void 0 ? batch : Object.assign(batch, { metadata });
18392
+ }
18393
+ var init_arrow_record_batch = __esm({
18394
+ "../../node_modules/@math.gl/arrow/dist/arrow/arrow-record-batch.js"() {
18395
+ init_Arrow_dom();
16807
18396
  }
16808
18397
  });
16809
18398
 
16810
- // ../core/src/schema-utils/lib/arrow/split-arrow-buffers.ts
18399
+ // ../../node_modules/@math.gl/arrow/dist/arrow/split-arrow-buffers.js
16811
18400
  function splitArrowBuffers(input, options = {}) {
16812
- const context = { ...options, copies: /* @__PURE__ */ new WeakMap() };
18401
+ const retainedBuffers = /* @__PURE__ */ new Set();
18402
+ const visited = /* @__PURE__ */ new Set();
18403
+ for (const retained of options.retain ?? []) {
18404
+ const chunks = isArrowTable2(retained) ? retained.batches.map((batch) => batch.data) : isArrowVector2(retained) ? retained.data : [isArrowRecordBatch2(retained) ? retained.data : retained];
18405
+ for (const data of chunks)
18406
+ collectArrowBuffers(data, retainedBuffers, visited);
18407
+ }
18408
+ const context = { ...options, copies: /* @__PURE__ */ new WeakMap(), retainedBuffers };
16813
18409
  if (isArrowTable2(input)) {
16814
18410
  return splitArrowTableBuffersInternal(input, context);
16815
18411
  }
@@ -16830,17 +18426,13 @@ return true;`);
16830
18426
  function isArrowVector2(input) {
16831
18427
  return "data" in input && Array.isArray(input.data);
16832
18428
  }
16833
- function splitArrowTableBuffersInternal(table, options) {
16834
- const recordBatches = table.batches.map(
16835
- (recordBatch) => splitArrowRecordBatchBuffers(recordBatch, options)
16836
- );
16837
- return new Table(table.schema, recordBatches);
18429
+ function splitArrowTableBuffersInternal(arrowTable, options) {
18430
+ const recordBatches = arrowTable.batches.map((recordBatch) => splitArrowRecordBatchBuffers(recordBatch, options));
18431
+ return new Table(arrowTable.schema, recordBatches);
16838
18432
  }
16839
18433
  function splitArrowRecordBatchBuffers(recordBatch, options) {
16840
- return new RecordBatch3(
16841
- recordBatch.schema,
16842
- splitArrowDataBuffers(recordBatch.data, options)
16843
- );
18434
+ const data = splitArrowDataBuffers(recordBatch.data, options);
18435
+ return createRecordBatchWithMetadata(recordBatch.schema, data, getRecordBatchMetadata(recordBatch));
16844
18436
  }
16845
18437
  function splitArrowDataBuffers(data, options) {
16846
18438
  const children = data.children.map((childData) => splitArrowDataBuffers(childData, options));
@@ -16851,7 +18443,7 @@ return true;`);
16851
18443
  [BufferType.VALIDITY]: splitArrowBuffer(data.buffers[BufferType.VALIDITY], options),
16852
18444
  [BufferType.TYPE]: splitArrowBuffer(data.buffers[BufferType.TYPE], options)
16853
18445
  };
16854
- return new Data(
18446
+ return createArrowData(
16855
18447
  data.type,
16856
18448
  data.offset,
16857
18449
  data.length,
@@ -16859,25 +18451,37 @@ return true;`);
16859
18451
  data._nullCount,
16860
18452
  buffers,
16861
18453
  children,
16862
- dictionary
18454
+ dictionary,
18455
+ getArrowVariadicBuffers(data).map((buffer) => splitArrowBuffer(buffer, options))
16863
18456
  );
16864
18457
  }
16865
18458
  function splitArrowVectorBuffers(vector, options) {
16866
18459
  return new Vector(vector.data.map((data) => splitArrowDataBuffers(data, options)));
16867
18460
  }
18461
+ function collectArrowBuffers(data, buffers, visited) {
18462
+ if (visited.has(data))
18463
+ return;
18464
+ visited.add(data);
18465
+ for (const view of [...Object.values(data.buffers), ...getArrowVariadicBuffers(data)]) {
18466
+ if (isArrowTypedArray(view))
18467
+ buffers.add(view.buffer);
18468
+ }
18469
+ for (const child of data.children)
18470
+ collectArrowBuffers(child, buffers, visited);
18471
+ for (const chunk of data.dictionary?.data ?? [])
18472
+ collectArrowBuffers(chunk, buffers, visited);
18473
+ }
16868
18474
  function splitArrowBuffer(array, options) {
16869
18475
  if (!isArrowTypedArray(array)) {
16870
18476
  return array;
16871
18477
  }
16872
- if (options.copy === "none") {
16873
- return array;
16874
- }
16875
- if (options.copy !== "all" && array.byteOffset === 0 && array.byteLength === array.buffer.byteLength) {
18478
+ const sliced = array.byteOffset !== 0 || array.byteLength !== array.buffer.byteLength;
18479
+ if (!options.retainedBuffers.has(array.buffer) && options.copy !== "all" && (options.copy === "none" || !sliced)) {
16876
18480
  return array;
16877
18481
  }
16878
18482
  let copy = options.copies.get(array);
16879
18483
  if (!copy) {
16880
- copy = array.slice();
18484
+ copy = array instanceof Uint8Array ? new Uint8Array(array) : array.slice();
16881
18485
  options.copies.set(array, copy);
16882
18486
  }
16883
18487
  return copy;
@@ -16886,44 +18490,163 @@ return true;`);
16886
18490
  return ArrayBuffer.isView(value) && !(value instanceof DataView);
16887
18491
  }
16888
18492
  var init_split_arrow_buffers = __esm({
16889
- "../core/src/schema-utils/lib/arrow/split-arrow-buffers.ts"() {
16890
- "use strict";
18493
+ "../../node_modules/@math.gl/arrow/dist/arrow/split-arrow-buffers.js"() {
16891
18494
  init_Arrow_dom();
18495
+ init_arrow_record_batch();
18496
+ init_arrow_data();
18497
+ }
18498
+ });
18499
+
18500
+ // ../../node_modules/@math.gl/arrow/dist/arrow/take-arrow-rows.js
18501
+ var init_take_arrow_rows = __esm({
18502
+ "../../node_modules/@math.gl/arrow/dist/arrow/take-arrow-rows.js"() {
18503
+ init_arrow_data();
18504
+ init_split_arrow_buffers();
18505
+ }
18506
+ });
18507
+
18508
+ // ../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-vector.js
18509
+ var init_indexed_arrow_vector = __esm({
18510
+ "../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-vector.js"() {
18511
+ init_indexed_arrow_helpers();
18512
+ }
18513
+ });
18514
+
18515
+ // ../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-table.js
18516
+ var init_indexed_arrow_table = __esm({
18517
+ "../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-table.js"() {
18518
+ init_indexed_arrow_helpers();
18519
+ init_arrow_schema_utils();
18520
+ init_take_arrow_rows();
18521
+ init_indexed_arrow_vector();
16892
18522
  }
16893
18523
  });
16894
18524
 
16895
- // ../core/src/schema-utils/lib/arrow/arrow-table-transport.ts
16896
- function dehydrateArrowTable(table, options) {
16897
- const splitTable = splitArrowBuffers(table, options);
18525
+ // ../../node_modules/@math.gl/arrow/dist/arrow/mapped-arrow-table.js
18526
+ var init_mapped_arrow_table = __esm({
18527
+ "../../node_modules/@math.gl/arrow/dist/arrow/mapped-arrow-table.js"() {
18528
+ init_indexed_arrow_helpers();
18529
+ init_indexed_arrow_table();
18530
+ }
18531
+ });
18532
+
18533
+ // ../../node_modules/@math.gl/arrow/dist/arrow/rename-arrow-columns.js
18534
+ var init_rename_arrow_columns = __esm({
18535
+ "../../node_modules/@math.gl/arrow/dist/arrow/rename-arrow-columns.js"() {
18536
+ init_arrow_schema_utils();
18537
+ }
18538
+ });
18539
+
18540
+ // ../../node_modules/@math.gl/arrow/dist/arrow/arrow-table-transport.js
18541
+ function dehydrateArrowTable(arrowTable, options) {
18542
+ const splitTable = splitArrowBuffers(arrowTable, options);
16898
18543
  return {
16899
- shape: "arrow-table",
16900
18544
  transport: "arrow-js",
16901
- schema: serializeArrowSchema(splitTable.schema),
16902
- batches: splitTable.batches.map((recordBatch) => dehydrateArrowRecordBatch(recordBatch))
18545
+ version: 1,
18546
+ schema: tableToIPC(new Table(splitTable.schema, [])),
18547
+ metadataVersion: splitTable.schema.metadataVersion,
18548
+ batches: splitTable.batches.map((batch) => {
18549
+ const metadata = getRecordBatchMetadata(batch);
18550
+ return {
18551
+ ...dehydrateArrowData(batch.data),
18552
+ ...metadata !== void 0 ? { metadata: [...metadata] } : {}
18553
+ };
18554
+ })
16903
18555
  };
16904
18556
  }
16905
18557
  function hydrateArrowTable(table) {
16906
- const schema = deserializeArrowSchema(table.schema);
16907
- const recordBatches = table.batches.map(
16908
- (recordBatch) => new RecordBatch3(schema, hydrateArrowData(recordBatch.data))
16909
- );
16910
- return new Table(schema, recordBatches);
18558
+ if (table.transport !== "arrow-js" || table.version !== 1) {
18559
+ throw new Error("Unsupported Arrow column-buffer transport protocol.");
18560
+ }
18561
+ const decodedSchema = tableFromIPC(table.schema).schema;
18562
+ const schema = new Schema2(decodedSchema.fields, decodedSchema.metadata, decodedSchema.dictionaries, table.metadataVersion);
18563
+ const type = new Struct(schema.fields);
18564
+ const batches = table.batches.map((payload) => {
18565
+ const data = hydrateArrowData(payload, type);
18566
+ return createRecordBatchWithMetadata(schema, data, payload.metadata && new Map(payload.metadata));
18567
+ });
18568
+ return new Table(schema, batches);
18569
+ }
18570
+ function dehydrateArrowData(data) {
18571
+ return {
18572
+ offset: data.offset,
18573
+ length: data.length,
18574
+ nullCount: data.nullCount,
18575
+ buffers: {
18576
+ [BufferType.OFFSET]: data.buffers[BufferType.OFFSET],
18577
+ [BufferType.DATA]: data.buffers[BufferType.DATA],
18578
+ [BufferType.VALIDITY]: data.buffers[BufferType.VALIDITY],
18579
+ [BufferType.TYPE]: data.buffers[BufferType.TYPE]
18580
+ },
18581
+ children: data.children.map((child) => dehydrateArrowData(child)),
18582
+ variadicBuffers: getArrowVariadicBuffers(data),
18583
+ dictionary: data.dictionary?.data.map((chunk) => dehydrateArrowData(chunk))
18584
+ };
18585
+ }
18586
+ function hydrateArrowData(data, type) {
18587
+ const children = data.children.map((child, index) => hydrateArrowData(child, type.children[index].type));
18588
+ const dictionary = data.dictionary && DataType.isDictionary(type) ? new Vector(data.dictionary.map((chunk) => hydrateArrowData(chunk, type.dictionary))) : void 0;
18589
+ return createArrowData(type, data.offset, data.length, data.nullCount, data.buffers, children, dictionary, data.variadicBuffers);
16911
18590
  }
18591
+ var init_arrow_table_transport = __esm({
18592
+ "../../node_modules/@math.gl/arrow/dist/arrow/arrow-table-transport.js"() {
18593
+ init_Arrow_dom();
18594
+ init_arrow_record_batch();
18595
+ init_arrow_data();
18596
+ init_split_arrow_buffers();
18597
+ }
18598
+ });
18599
+
18600
+ // ../../node_modules/@math.gl/arrow/dist/arrow/arrow-column-utils.js
18601
+ var init_arrow_column_utils = __esm({
18602
+ "../../node_modules/@math.gl/arrow/dist/arrow/arrow-column-utils.js"() {
18603
+ }
18604
+ });
18605
+
18606
+ // ../../node_modules/@math.gl/arrow/dist/arrow/index.js
18607
+ var init_arrow = __esm({
18608
+ "../../node_modules/@math.gl/arrow/dist/arrow/index.js"() {
18609
+ init_indexed_arrow_table();
18610
+ init_indexed_arrow_vector();
18611
+ init_mapped_arrow_table();
18612
+ init_arrow_schema_utils();
18613
+ init_rename_arrow_columns();
18614
+ init_split_arrow_buffers();
18615
+ init_arrow_table_transport();
18616
+ init_arrow_column_utils();
18617
+ init_take_arrow_rows();
18618
+ init_arrow_record_batch();
18619
+ }
18620
+ });
18621
+
18622
+ // ../../node_modules/@math.gl/arrow/dist/index.js
18623
+ var init_dist3 = __esm({
18624
+ "../../node_modules/@math.gl/arrow/dist/index.js"() {
18625
+ init_arrow();
18626
+ }
18627
+ });
18628
+
18629
+ // ../core/src/arrow-worker-transport.ts
16912
18630
  function serializeArrowWorkerTable(result) {
16913
18631
  if (!isArrowTableWrapper(result)) {
16914
18632
  throw new Error("Workers require Arrow table output");
16915
18633
  }
16916
- const { data, ...metadata } = result;
18634
+ const { data, shape: _shape, ...metadata } = result;
16917
18635
  return {
16918
- ...structuredClone(metadata),
16919
- data: dehydrateArrowTable(data, { copy: "all" })
18636
+ transport: "arrow-column-envelope",
18637
+ metadata: structuredClone(metadata),
18638
+ ...serializeWorkerColumns(data, { copy: "all" })
16920
18639
  };
16921
18640
  }
16922
18641
  function deserializeArrowWorkerTable(result) {
16923
- if (!isDehydratedArrowTableWrapper(result)) {
16924
- throw new Error("Workers require Arrow column transport");
18642
+ if (isArrowWorkerEnvelope(result)) {
18643
+ return { ...result.metadata, shape: "arrow-table", data: hydrateWorkerTable(result) };
18644
+ }
18645
+ if (isLegacyArrowWorkerEnvelope(result)) {
18646
+ const { arrowBatchMetadata: _snapshots, data: _columns, ...metadata } = result;
18647
+ return { ...metadata, data: hydrateWorkerTable(result) };
16925
18648
  }
16926
- return { ...result, data: hydrateArrowTable(result.data) };
18649
+ throw new Error("Workers require Arrow column transport");
16927
18650
  }
16928
18651
  function isArrowTableWrapper(value) {
16929
18652
  const table = value;
@@ -16931,66 +18654,62 @@ return true;`);
16931
18654
  table && table.shape === "arrow-table" && table.data && typeof table.data === "object" && "batches" in table.data
16932
18655
  );
16933
18656
  }
16934
- function isDehydratedArrowTableWrapper(value) {
16935
- const table = value;
16936
- return Boolean(
16937
- table && table.shape === "arrow-table" && table.data && table.data.transport === "arrow-js" && Array.isArray(table.data.batches)
16938
- );
18657
+ function hasArrowWorkerColumns(value) {
18658
+ const columns = value;
18659
+ return columns?.data?.transport === "arrow-js" && Array.isArray(columns.data.batches);
16939
18660
  }
16940
- function dehydrateArrowRecordBatch(recordBatch) {
16941
- return { data: dehydrateArrowData(recordBatch.data) };
18661
+ function isArrowWorkerEnvelope(value) {
18662
+ return value?.transport === "arrow-column-envelope" && hasArrowWorkerColumns(value);
16942
18663
  }
16943
- function dehydrateArrowData(data) {
18664
+ function isLegacyArrowWorkerEnvelope(value) {
18665
+ return value?.shape === "arrow-table" && hasArrowWorkerColumns(value);
18666
+ }
18667
+ function serializeWorkerColumns(table, options) {
16944
18668
  return {
16945
- type: serializeArrowType(data.type),
16946
- offset: data.offset,
16947
- length: data.length,
16948
- // @ts-expect-error _nullCount is protected. Preserve the Arrow lazy null-count state.
16949
- nullCount: data._nullCount,
16950
- buffers: {
16951
- [BufferType.OFFSET]: data.buffers[BufferType.OFFSET],
16952
- [BufferType.DATA]: data.buffers[BufferType.DATA],
16953
- [BufferType.VALIDITY]: data.buffers[BufferType.VALIDITY],
16954
- [BufferType.TYPE]: data.buffers[BufferType.TYPE]
16955
- },
16956
- children: data.children.map((childData) => dehydrateArrowData(childData)),
16957
- dictionary: data.dictionary ? dehydrateArrowVector(data.dictionary) : void 0
18669
+ arrowBatchMetadata: snapshotBatchMetadata(table),
18670
+ data: dehydrateWorkerTable(table, options)
16958
18671
  };
16959
18672
  }
16960
- function dehydrateArrowVector(vector) {
16961
- return { data: vector.data.map((data) => dehydrateArrowData(data)) };
18673
+ function dehydrateWorkerTable(table, options) {
18674
+ const payload = dehydrateArrowTable(table, options);
18675
+ if (table.numCols === 0) {
18676
+ for (const [index, batch] of table.batches.entries()) {
18677
+ payload.batches[index].length = batch.numRows;
18678
+ }
18679
+ }
18680
+ return payload;
16962
18681
  }
16963
- function hydrateArrowData(data) {
16964
- const children = data.children.map((childData) => hydrateArrowData(childData));
16965
- const dictionary = data.dictionary ? hydrateArrowVector(data.dictionary) : void 0;
16966
- return new Data(
16967
- deserializeArrowType(data.type),
16968
- data.offset,
16969
- data.length,
16970
- data.nullCount,
16971
- data.buffers,
16972
- children,
16973
- dictionary
16974
- );
18682
+ function snapshotBatchMetadata(table) {
18683
+ return table.batches.map((batch) => ({
18684
+ schema: tableToIPC(new Table(batch.schema, [])),
18685
+ metadata: Array.from(batch.metadata)
18686
+ }));
16975
18687
  }
16976
- function hydrateArrowVector(vector) {
16977
- return new Vector(vector.data.map((data) => hydrateArrowData(data)));
18688
+ function hydrateWorkerTable(result) {
18689
+ const { arrowBatchMetadata, data } = result;
18690
+ const table = hydrateArrowTable(data);
18691
+ const batches = table.batches.map((batch, index) => {
18692
+ const snapshot = arrowBatchMetadata?.[index];
18693
+ const restored = snapshot ? new RecordBatch3(
18694
+ tableFromIPC(snapshot.schema).schema,
18695
+ batch.data,
18696
+ new Map(snapshot.metadata)
18697
+ ) : batch;
18698
+ const rowCount = data.batches[index].length;
18699
+ if (restored.numCols === 0 && restored.numRows !== rowCount) {
18700
+ Object.defineProperty(restored, "data", {
18701
+ value: new Data(new Struct([]), 0, rowCount, 0, void 0, [])
18702
+ });
18703
+ }
18704
+ return restored;
18705
+ });
18706
+ return new Table(table.schema, batches);
16978
18707
  }
16979
- var init_arrow_table_transport = __esm({
16980
- "../core/src/schema-utils/lib/arrow/arrow-table-transport.ts"() {
18708
+ var init_arrow_worker_transport = __esm({
18709
+ "../core/src/arrow-worker-transport.ts"() {
16981
18710
  "use strict";
16982
18711
  init_Arrow_dom();
16983
- init_convert_arrow_schema();
16984
- init_split_arrow_buffers();
16985
- }
16986
- });
16987
-
16988
- // ../core/src/schema-utils/arrow-transport.ts
16989
- var init_arrow_transport = __esm({
16990
- "../core/src/schema-utils/arrow-transport.ts"() {
16991
- "use strict";
16992
- init_arrow_table_transport();
16993
- init_split_arrow_buffers();
18712
+ init_dist3();
16994
18713
  }
16995
18714
  });
16996
18715
 
@@ -17541,6 +19260,8 @@ return true;`);
17541
19260
  const schema = getPLYSchema(header, meshAttributes);
17542
19261
  schema.metadata.topology = "point-list";
17543
19262
  schema.metadata.mode = "0";
19263
+ const boundingBox = getMeshBoundingBox(meshAttributes);
19264
+ if (boundingBox) schema.metadata.boundingBox = JSON.stringify(boundingBox);
17544
19265
  const columns = {};
17545
19266
  const fields = [];
17546
19267
  for (const field of schema.fields) {
@@ -17877,6 +19598,7 @@ return true;`);
17877
19598
  "src/ply/lib/parse-ply.ts"() {
17878
19599
  "use strict";
17879
19600
  init_Arrow_dom();
19601
+ init_schema_utils();
17880
19602
  init_normalize_ply();
17881
19603
  init_get_ply_schema();
17882
19604
  PLY_END_HEADER = "end_header";
@@ -18169,7 +19891,7 @@ return true;`);
18169
19891
  const arrowSchema = new Schema2(fields, metadata);
18170
19892
  return {
18171
19893
  shape: "arrow-table",
18172
- schema: mesh.schema,
19894
+ schema: serializeArrowSchema(arrowSchema),
18173
19895
  data: new Table(arrowSchema, columns),
18174
19896
  topology: mesh.topology,
18175
19897
  indices: mesh.indices?.value.length ? mesh.indices : void 0
@@ -18401,7 +20123,7 @@ return true;`);
18401
20123
 
18402
20124
  // src/ply/lib/parse-ply-in-batches.ts
18403
20125
  async function* parsePLYInBatches(iterator, options) {
18404
- if (options?.shape === "arrow-table") {
20126
+ if (options?.shape === "arrow") {
18405
20127
  yield* parseBinaryPLYToArrowInBatches(iterator, options);
18406
20128
  return;
18407
20129
  }
@@ -18438,7 +20160,10 @@ return true;`);
18438
20160
  );
18439
20161
  }
18440
20162
  for await (const table of tables) {
18441
- yield { ...table, loaderData: header };
20163
+ yield {
20164
+ ...updateArrowTableMetadata(table, makeMetadataFromPlyHeader(header)),
20165
+ loaderData: header
20166
+ };
18442
20167
  }
18443
20168
  }
18444
20169
  async function* parseBinaryFixedWidthVertexPLYToArrowInBatches(byteIterator, header, initialBodyBytes, options) {
@@ -18843,7 +20568,7 @@ return true;`);
18843
20568
  currentElement?.properties.push(property);
18844
20569
  break;
18845
20570
  default:
18846
- console.log("unhandled", lineType, lineValues);
20571
+ log2.log(0, "unhandled", lineType, lineValues)();
18847
20572
  }
18848
20573
  return false;
18849
20574
  });
@@ -18966,6 +20691,9 @@ return true;`);
18966
20691
  "src/ply/lib/parse-ply-in-batches.ts"() {
18967
20692
  "use strict";
18968
20693
  init_loader_utils();
20694
+ init_loader_utils();
20695
+ init_schema_utils();
20696
+ init_get_ply_schema();
18969
20697
  init_normalize_ply();
18970
20698
  init_parse_ply();
18971
20699
  init_parse_ply_arrow();
@@ -19000,25 +20728,27 @@ return true;`);
19000
20728
  const { PLYLoaderWithParser: PLYLoaderWithParser2 } = await Promise.resolve().then(() => (init_ply_loader(), ply_loader_exports));
19001
20729
  return PLYLoaderWithParser2;
19002
20730
  }
19003
- var VERSION, PLYLoader;
20731
+ var VERSION3, PLYLoader;
19004
20732
  var init_ply_loader_types = __esm({
19005
20733
  "src/ply/ply-loader-types.ts"() {
19006
20734
  "use strict";
19007
20735
  init_ply_format();
19008
- init_arrow_transport();
19009
- VERSION = true ? "5.0.0-beta.1" : "latest";
20736
+ init_arrow_worker_transport();
20737
+ VERSION3 = true ? "5.0.0-beta.10" : "latest";
19010
20738
  PLYLoader = {
20739
+ defaultShape: "arrow",
20740
+ supportsNativeArrow: true,
19011
20741
  dataType: null,
19012
20742
  batchType: null,
19013
20743
  ...PLYFormat,
19014
20744
  // shapes: ['mesh', 'gltf', 'columnar-table'],
19015
- version: VERSION,
20745
+ version: VERSION3,
19016
20746
  worker: true,
19017
20747
  /** Enables the stateful input/output batch protocol on the built-in worker. */
19018
20748
  workerInBatches: true,
19019
20749
  serializeWorkerResult: serializeArrowWorkerTable,
19020
20750
  options: {
19021
- ply: { shape: "arrow-table", colorFormat: "uint8norm" }
20751
+ ply: { shape: "arrow", colorFormat: "uint8norm" }
19022
20752
  },
19023
20753
  preload
19024
20754
  };
@@ -19028,10 +20758,11 @@ return true;`);
19028
20758
  // src/ply/ply-loader.ts
19029
20759
  var ply_loader_exports = {};
19030
20760
  __export(ply_loader_exports, {
20761
+ PLYColumnLoader: () => PLYColumnLoader,
19031
20762
  PLYLoaderWithParser: () => PLYLoaderWithParser
19032
20763
  });
19033
20764
  function convertPLYMesh(mesh, options) {
19034
- const table = convertMeshToTable(mesh, "arrow-table");
20765
+ const table = convertMeshToArrowTableWrapper(mesh);
19035
20766
  return convertPLYTable(table, options, mesh.loaderData);
19036
20767
  }
19037
20768
  function parsePLYData(data, options) {
@@ -19051,7 +20782,7 @@ return true;`);
19051
20782
  }
19052
20783
  function convertPLYTable(table, options, header) {
19053
20784
  const loaderData = header || table.loaderData || { comments: [], elements: [] };
19054
- const result = options?.ply?.shape === "arrow-table" ? { ...table, loader: "ply", loaderData } : {
20785
+ const result = options?.ply?.shape === "arrow" ? { ...table, loader: "ply", loaderData } : {
19055
20786
  ...convertTableToMesh(table),
19056
20787
  loader: "ply",
19057
20788
  loaderData
@@ -19065,8 +20796,8 @@ return true;`);
19065
20796
  isMeshArrowTable(resultData) ? convertTableToMesh(resultData) : resultData,
19066
20797
  colorFormat
19067
20798
  );
19068
- return options?.ply?.shape === "arrow-table" ? {
19069
- ...convertMeshToTable(formattedMesh, "arrow-table"),
20799
+ return options?.ply?.shape === "arrow" ? {
20800
+ ...convertMeshToArrowTableWrapper(formattedMesh),
19070
20801
  loader: "ply",
19071
20802
  loaderData
19072
20803
  } : formattedMesh;
@@ -19105,39 +20836,95 @@ return true;`);
19105
20836
  function deserializePLYWorkerBatch(result, options) {
19106
20837
  return deserializePLYWorkerResult(result, options);
19107
20838
  }
19108
- var _PLYLoaderPreload, PLYLoaderMetadataWithoutPreload, PLYLoaderWithParser;
20839
+ async function* parsePLYWithMetadataInBatches(arrayBuffer, options) {
20840
+ const plyOptions = {
20841
+ ...options?.ply,
20842
+ batchSize: options?.core?.batchSize
20843
+ };
20844
+ for await (const meshOrTable of parsePLYInBatches(arrayBuffer, plyOptions)) {
20845
+ const convertedData = isMeshArrowTable(meshOrTable) ? convertPLYTable(meshOrTable, options) : convertPLYMesh(meshOrTable, options);
20846
+ yield isMeshArrowTable(convertedData) ? makeTableScanBatch(convertedData) : convertedData;
20847
+ }
20848
+ }
20849
+ function unwrapPLYTable(result) {
20850
+ if ("shape" in result && result.shape === "arrow-table") {
20851
+ result.data.schema.metadata.set(
20852
+ "loaders.gl.ply.header",
20853
+ JSON.stringify(result.loaderData)
20854
+ );
20855
+ return result.data;
20856
+ }
20857
+ return result;
20858
+ }
20859
+ function isColumnBatch(batch) {
20860
+ return "shape" in batch && batch.shape === "arrow-table";
20861
+ }
20862
+ var _PLYLoaderPreload, PLYLoaderMetadataWithoutPreload, PLYColumnLoader, PLYLoaderWithParser;
19109
20863
  var init_ply_loader = __esm({
19110
20864
  "src/ply/ply-loader.ts"() {
19111
20865
  "use strict";
20866
+ init_schema_utils();
19112
20867
  init_loader_utils();
19113
20868
  init_schema3();
19114
- init_arrow_transport();
20869
+ init_arrow_worker_transport();
19115
20870
  init_schema_utils();
19116
20871
  init_parse_ply();
19117
20872
  init_parse_ply_arrow();
19118
20873
  init_parse_ply_in_batches();
19119
20874
  init_ply_loader_types();
19120
20875
  ({ preload: _PLYLoaderPreload, ...PLYLoaderMetadataWithoutPreload } = PLYLoader);
19121
- PLYLoaderWithParser = {
20876
+ PLYColumnLoader = {
19122
20877
  ...PLYLoaderMetadataWithoutPreload,
20878
+ dataType: null,
20879
+ batchType: null,
19123
20880
  parse: async (arrayBuffer, options) => parsePLYData(arrayBuffer, options),
19124
20881
  parseTextSync: (arrayBuffer, options) => parsePLYData(arrayBuffer, options),
19125
20882
  parseSync: (arrayBuffer, options) => parsePLYData(arrayBuffer, options),
19126
- parseInBatches: async function* (arrayBuffer, options) {
19127
- const plyOptions = {
19128
- ...options?.ply,
19129
- batchSize: options?.batchSize ?? options?.core?.batchSize
19130
- };
19131
- for await (const meshOrTable of parsePLYInBatches(arrayBuffer, plyOptions)) {
19132
- const convertedData = isMeshArrowTable(meshOrTable) ? convertPLYTable(meshOrTable, options) : convertPLYMesh(meshOrTable, options);
19133
- yield isMeshArrowTable(convertedData) ? makeTableScanBatch(convertedData) : convertedData;
19134
- }
19135
- },
20883
+ parseInBatches: (input, options) => refineArrowTableBatches(parsePLYWithMetadataInBatches(input, options)),
19136
20884
  serializeWorkerResult: serializeArrowWorkerTable,
19137
20885
  deserializeWorkerResult: deserializePLYWorkerResult,
19138
20886
  serializeWorkerBatch: serializeArrowWorkerTable,
19139
20887
  deserializeWorkerBatch: deserializePLYWorkerBatch
19140
20888
  };
20889
+ PLYLoaderWithParser = {
20890
+ ...PLYColumnLoader,
20891
+ dataType: PLYLoader.dataType,
20892
+ batchType: PLYLoader.batchType,
20893
+ parse: async (input, options) => unwrapPLYTable(await PLYColumnLoader.parse(input, options)),
20894
+ parseTextSync: (input, options) => unwrapPLYTable(PLYColumnLoader.parseTextSync(input, options)),
20895
+ parseSync: (input, options) => unwrapPLYTable(PLYColumnLoader.parseSync(input, options)),
20896
+ async *parseInBatches(input, options) {
20897
+ for await (const batch of PLYColumnLoader.parseInBatches(input, options)) {
20898
+ if (isColumnBatch(batch)) {
20899
+ batch.data.schema.metadata.set(
20900
+ "loaders.gl.ply.header",
20901
+ JSON.stringify(batch.loaderData)
20902
+ );
20903
+ for (const recordBatch of batch.data.batches) {
20904
+ recordBatch.schema.metadata.set(
20905
+ "loaders.gl.ply.header",
20906
+ batch.data.schema.metadata.get("loaders.gl.ply.header")
20907
+ );
20908
+ }
20909
+ if (batch.data.batches.length) yield* batch.data.batches;
20910
+ else yield makeArrowMetadataBatch(batch.data.schema);
20911
+ } else yield batch;
20912
+ }
20913
+ },
20914
+ deserializeWorkerResult: (result, options) => unwrapPLYTable(PLYColumnLoader.deserializeWorkerResult(result, options)),
20915
+ deserializeWorkerBatch(result, options) {
20916
+ const batch = PLYColumnLoader.deserializeWorkerBatch(result, options);
20917
+ if (isColumnBatch(batch)) {
20918
+ const recordBatch = batch.data.batches[0] ?? makeArrowMetadataBatch(batch.data.schema);
20919
+ recordBatch.schema.metadata.set(
20920
+ "loaders.gl.ply.header",
20921
+ JSON.stringify(batch.loaderData)
20922
+ );
20923
+ return recordBatch;
20924
+ }
20925
+ return batch;
20926
+ }
20927
+ };
19141
20928
  }
19142
20929
  });
19143
20930
 
@@ -19146,25 +20933,25 @@ return true;`);
19146
20933
  init_schema_utils();
19147
20934
  init_ply_loader();
19148
20935
  createLoaderWorker({
19149
- ...PLYLoaderWithParser,
20936
+ ...PLYColumnLoader,
19150
20937
  /** Always returns columnar data; legacy mesh conversion runs on the caller. */
19151
20938
  parse(input, options) {
19152
- return PLYLoaderWithParser.parse(input, {
20939
+ return PLYColumnLoader.parse(input, {
19153
20940
  ...options,
19154
- ply: { ...options?.ply, shape: "arrow-table" }
20941
+ ply: { ...options?.ply, shape: "arrow" }
19155
20942
  });
19156
20943
  },
19157
20944
  /** Preserves full-mesh parsing while streaming point-cloud vertices as Arrow batches. */
19158
20945
  async *parseInBatches(input, options) {
19159
20946
  const parseMesh = options?.ply?.shape === "mesh" && !options?.ply?.pointCloud;
19160
- const parserOptions = parseMesh ? options : { ...options, ply: { ...options?.ply, shape: "arrow-table" } };
19161
- for await (const batch of PLYLoaderWithParser.parseInBatches(input, parserOptions)) {
20947
+ const parserOptions = parseMesh ? options : { ...options, ply: { ...options?.ply, shape: "arrow" } };
20948
+ for await (const batch of PLYColumnLoader.parseInBatches(input, parserOptions)) {
19162
20949
  if ("shape" in batch && batch.shape === "arrow-table") {
19163
20950
  yield batch;
19164
20951
  } else {
19165
20952
  const mesh = batch;
19166
20953
  yield makeTableScanBatch({
19167
- ...convertMeshToTable(mesh, "arrow-table"),
20954
+ ...convertMeshToArrowTableWrapper(mesh),
19168
20955
  loader: mesh.loader,
19169
20956
  loaderData: mesh.loaderData
19170
20957
  });