@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.
- package/LAS-README.md +1 -1
- package/PCD-README.md +1 -1
- package/PLY-README.md +1 -1
- package/README.md +5 -1
- package/dist/dist.dev.js +3584 -2211
- package/dist/dist.min.js +20 -20
- package/dist/index.cjs +0 -6
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/las/bundled.cjs +0 -3
- package/dist/las/bundled.cjs.map +2 -2
- package/dist/las/bundled.d.ts +0 -1
- package/dist/las/bundled.d.ts.map +1 -1
- package/dist/las/bundled.js +0 -1
- package/dist/las/bundled.js.map +1 -1
- package/dist/las/index.cjs +0 -3
- package/dist/las/index.cjs.map +3 -3
- package/dist/las/index.d.ts +0 -2
- package/dist/las/index.d.ts.map +1 -1
- package/dist/las/index.js +0 -3
- package/dist/las/index.js.map +1 -1
- package/dist/las/las-copc-loader-types.cjs +1 -1
- package/dist/las/las-copc-loader-types.cjs.map +2 -2
- package/dist/las/las-copc-loader-types.d.ts +13 -9
- package/dist/las/las-copc-loader-types.d.ts.map +1 -1
- package/dist/las/las-copc-loader-types.js +1 -1
- package/dist/las/las-copc-loader-types.js.map +1 -1
- package/dist/las/las-copc-loader.cjs +8 -5
- package/dist/las/las-copc-loader.cjs.map +2 -2
- package/dist/las/las-copc-loader.d.ts +8 -6
- package/dist/las/las-copc-loader.d.ts.map +1 -1
- package/dist/las/las-copc-loader.js +11 -6
- package/dist/las/las-copc-loader.js.map +1 -1
- package/dist/las/las-loader-shared.cjs +4 -2
- package/dist/las/las-loader-shared.cjs.map +2 -2
- package/dist/las/las-loader-shared.d.ts +9 -7
- package/dist/las/las-loader-shared.d.ts.map +1 -1
- package/dist/las/las-loader-shared.js +4 -2
- package/dist/las/las-loader-shared.js.map +1 -1
- package/dist/las/las-loader-types.cjs +3 -6
- package/dist/las/las-loader-types.cjs.map +2 -2
- package/dist/las/las-loader-types.d.ts +18 -45
- package/dist/las/las-loader-types.d.ts.map +1 -1
- package/dist/las/las-loader-types.js +1 -3
- package/dist/las/las-loader-types.js.map +1 -1
- package/dist/las/las-loader.cjs +61 -13
- package/dist/las/las-loader.cjs.map +3 -3
- package/dist/las/las-loader.d.ts +51 -5
- package/dist/las/las-loader.d.ts.map +1 -1
- package/dist/las/las-loader.js +56 -6
- package/dist/las/las-loader.js.map +1 -1
- package/dist/las/las-writer.cjs +3 -3
- package/dist/las/las-writer.cjs.map +2 -2
- package/dist/las/las-writer.d.ts +4 -3
- package/dist/las/las-writer.d.ts.map +1 -1
- package/dist/las/las-writer.js +4 -6
- package/dist/las/las-writer.js.map +1 -1
- package/dist/las/laz-rs-loader-types.cjs +1 -1
- package/dist/las/laz-rs-loader-types.cjs.map +2 -2
- package/dist/las/laz-rs-loader-types.d.ts +13 -9
- package/dist/las/laz-rs-loader-types.d.ts.map +1 -1
- package/dist/las/laz-rs-loader-types.js +1 -1
- package/dist/las/laz-rs-loader-types.js.map +1 -1
- package/dist/las/laz-rs-loader.cjs +8 -5
- package/dist/las/laz-rs-loader.cjs.map +2 -2
- package/dist/las/laz-rs-loader.d.ts +8 -6
- package/dist/las/laz-rs-loader.d.ts.map +1 -1
- package/dist/las/laz-rs-loader.js +11 -6
- package/dist/las/laz-rs-loader.js.map +1 -1
- package/dist/las/lazperf-loader-types.cjs +1 -1
- package/dist/las/lazperf-loader-types.cjs.map +2 -2
- package/dist/las/lazperf-loader-types.d.ts +14 -10
- package/dist/las/lazperf-loader-types.d.ts.map +1 -1
- package/dist/las/lazperf-loader-types.js +1 -1
- package/dist/las/lazperf-loader-types.js.map +1 -1
- package/dist/las/lazperf-loader.cjs +9 -6
- package/dist/las/lazperf-loader.cjs.map +2 -2
- package/dist/las/lazperf-loader.d.ts +9 -7
- package/dist/las/lazperf-loader.d.ts.map +1 -1
- package/dist/las/lazperf-loader.js +12 -7
- package/dist/las/lazperf-loader.js.map +1 -1
- package/dist/las/lib/copc/parse-las.cjs +1 -1
- package/dist/las/lib/copc/parse-las.cjs.map +2 -2
- package/dist/las/lib/copc/parse-las.js +1 -1
- package/dist/las/lib/copc/parse-las.js.map +1 -1
- package/dist/las/lib/get-las-schema.cjs +5 -0
- package/dist/las/lib/get-las-schema.cjs.map +2 -2
- package/dist/las/lib/get-las-schema.d.ts.map +1 -1
- package/dist/las/lib/get-las-schema.js +6 -0
- package/dist/las/lib/get-las-schema.js.map +1 -1
- package/dist/las/lib/las-extra-bytes.cjs +6 -1
- package/dist/las/lib/las-extra-bytes.cjs.map +2 -2
- package/dist/las/lib/las-extra-bytes.d.ts.map +1 -1
- package/dist/las/lib/las-extra-bytes.js +6 -4
- package/dist/las/lib/las-extra-bytes.js.map +1 -1
- package/dist/las/lib/laz-perf/parse-las.cjs +9 -8
- package/dist/las/lib/laz-perf/parse-las.cjs.map +3 -3
- package/dist/las/lib/laz-perf/parse-las.js +9 -8
- package/dist/las/lib/laz-perf/parse-las.js.map +1 -1
- package/dist/las/lib/laz-rs-wasm/parse-las.cjs +9 -8
- package/dist/las/lib/laz-rs-wasm/parse-las.cjs.map +3 -3
- package/dist/las/lib/laz-rs-wasm/parse-las.js +9 -8
- package/dist/las/lib/laz-rs-wasm/parse-las.js.map +1 -1
- package/dist/las/lib/typescript/parse-las.cjs +135 -13
- package/dist/las/lib/typescript/parse-las.cjs.map +3 -3
- package/dist/las/lib/typescript/parse-las.d.ts.map +1 -1
- package/dist/las/lib/typescript/parse-las.js +106 -10
- package/dist/las/lib/typescript/parse-las.js.map +1 -1
- package/dist/las/unbundled.cjs +0 -2
- package/dist/las/unbundled.cjs.map +2 -2
- package/dist/las/unbundled.d.ts +1 -1
- package/dist/las/unbundled.d.ts.map +1 -1
- package/dist/las/unbundled.js +1 -1
- package/dist/las/unbundled.js.map +1 -1
- package/dist/las/workers/las-worker.cjs +5 -5
- package/dist/las/workers/las-worker.cjs.map +2 -2
- package/dist/las/workers/las-worker.js +6 -6
- package/dist/las/workers/las-worker.js.map +1 -1
- package/dist/las-copc-loader-types.cjs +51 -0
- package/dist/las-copc-loader-types.cjs.map +7 -0
- package/dist/las-copc-loader-types.d.ts +2 -0
- package/dist/las-copc-loader-types.d.ts.map +1 -0
- package/dist/las-copc-loader-types.js +2 -0
- package/dist/las-copc-loader-types.js.map +1 -0
- package/dist/las-copc-loader.cjs +62 -0
- package/dist/las-copc-loader.cjs.map +7 -0
- package/dist/las-copc-loader.d.ts +2 -0
- package/dist/las-copc-loader.d.ts.map +1 -0
- package/dist/las-copc-loader.js +2 -0
- package/dist/las-copc-loader.js.map +1 -0
- package/dist/las-loader-types.cjs +53 -0
- package/dist/las-loader-types.cjs.map +7 -0
- package/dist/las-loader-types.d.ts +2 -0
- package/dist/las-loader-types.d.ts.map +1 -0
- package/dist/las-loader-types.js +2 -0
- package/dist/las-loader-types.js.map +1 -0
- package/dist/las-loader.cjs +130 -0
- package/dist/las-loader.cjs.map +7 -0
- package/dist/las-loader.d.ts +2 -0
- package/dist/las-loader.d.ts.map +1 -0
- package/dist/las-loader.js +2 -0
- package/dist/las-loader.js.map +1 -0
- package/dist/las-worker.js +1219 -253
- package/dist/las-writer.cjs +1056 -0
- package/dist/las-writer.cjs.map +7 -0
- package/dist/las-writer.d.ts +2 -0
- package/dist/las-writer.d.ts.map +1 -0
- package/dist/las-writer.js +2 -0
- package/dist/las-writer.js.map +1 -0
- package/dist/laz-rs-loader-types.cjs +51 -0
- package/dist/laz-rs-loader-types.cjs.map +7 -0
- package/dist/laz-rs-loader-types.d.ts +2 -0
- package/dist/laz-rs-loader-types.d.ts.map +1 -0
- package/dist/laz-rs-loader-types.js +2 -0
- package/dist/laz-rs-loader-types.js.map +1 -0
- package/dist/laz-rs-loader.cjs +277 -0
- package/dist/laz-rs-loader.cjs.map +7 -0
- package/dist/laz-rs-loader.d.ts +2 -0
- package/dist/laz-rs-loader.d.ts.map +1 -0
- package/dist/laz-rs-loader.js +2 -0
- package/dist/laz-rs-loader.js.map +1 -0
- package/dist/lazperf-loader-types.cjs +51 -0
- package/dist/lazperf-loader-types.cjs.map +7 -0
- package/dist/lazperf-loader-types.d.ts +2 -0
- package/dist/lazperf-loader-types.d.ts.map +1 -0
- package/dist/lazperf-loader-types.js +2 -0
- package/dist/lazperf-loader-types.js.map +1 -0
- package/dist/lazperf-loader.cjs +65 -0
- package/dist/lazperf-loader.cjs.map +7 -0
- package/dist/lazperf-loader.d.ts +2 -0
- package/dist/lazperf-loader.d.ts.map +1 -0
- package/dist/lazperf-loader.js +2 -0
- package/dist/lazperf-loader.js.map +1 -0
- package/dist/pcd/bundled.cjs +2 -4
- package/dist/pcd/bundled.cjs.map +2 -2
- package/dist/pcd/bundled.d.ts +1 -1
- package/dist/pcd/bundled.d.ts.map +1 -1
- package/dist/pcd/bundled.js +1 -1
- package/dist/pcd/bundled.js.map +1 -1
- package/dist/pcd/index.cjs +0 -3
- package/dist/pcd/index.cjs.map +3 -3
- package/dist/pcd/index.d.ts +0 -2
- package/dist/pcd/index.d.ts.map +1 -1
- package/dist/pcd/index.js +0 -3
- package/dist/pcd/index.js.map +1 -1
- package/dist/pcd/pcd-loader-types.cjs +9 -10
- package/dist/pcd/pcd-loader-types.cjs.map +2 -2
- package/dist/pcd/pcd-loader-types.d.ts +18 -41
- package/dist/pcd/pcd-loader-types.d.ts.map +1 -1
- package/dist/pcd/pcd-loader-types.js +6 -6
- package/dist/pcd/pcd-loader-types.js.map +1 -1
- package/dist/pcd/pcd-loader.cjs +82 -25
- package/dist/pcd/pcd-loader.cjs.map +3 -3
- package/dist/pcd/pcd-loader.d.ts +42 -6
- package/dist/pcd/pcd-loader.d.ts.map +1 -1
- package/dist/pcd/pcd-loader.js +72 -21
- package/dist/pcd/pcd-loader.js.map +1 -1
- package/dist/pcd/pcd-writer.cjs +3 -3
- package/dist/pcd/pcd-writer.cjs.map +2 -2
- package/dist/pcd/pcd-writer.d.ts +5 -4
- package/dist/pcd/pcd-writer.d.ts.map +1 -1
- package/dist/pcd/pcd-writer.js +4 -4
- package/dist/pcd/pcd-writer.js.map +1 -1
- package/dist/pcd/unbundled.cjs +2 -4
- package/dist/pcd/unbundled.cjs.map +2 -2
- package/dist/pcd/unbundled.d.ts +1 -1
- package/dist/pcd/unbundled.d.ts.map +1 -1
- package/dist/pcd/unbundled.js +1 -1
- package/dist/pcd/unbundled.js.map +1 -1
- package/dist/pcd/workers/pcd-worker.cjs +5 -5
- package/dist/pcd/workers/pcd-worker.cjs.map +2 -2
- package/dist/pcd/workers/pcd-worker.js +6 -6
- package/dist/pcd/workers/pcd-worker.js.map +1 -1
- package/dist/pcd-loader-types.cjs +65 -0
- package/dist/pcd-loader-types.cjs.map +7 -0
- package/dist/pcd-loader-types.d.ts +2 -0
- package/dist/pcd-loader-types.d.ts.map +1 -0
- package/dist/pcd-loader-types.js +2 -0
- package/dist/pcd-loader-types.js.map +1 -0
- package/dist/pcd-loader.cjs +203 -0
- package/dist/pcd-loader.cjs.map +7 -0
- package/dist/pcd-loader.d.ts +2 -0
- package/dist/pcd-loader.d.ts.map +1 -0
- package/dist/pcd-loader.js +2 -0
- package/dist/pcd-loader.js.map +1 -0
- package/dist/pcd-worker.js +1457 -418
- package/dist/pcd-writer.cjs +136 -0
- package/dist/pcd-writer.cjs.map +7 -0
- package/dist/pcd-writer.d.ts +2 -0
- package/dist/pcd-writer.d.ts.map +1 -0
- package/dist/pcd-writer.js +2 -0
- package/dist/pcd-writer.js.map +1 -0
- package/dist/ply/bundled.cjs +2 -4
- package/dist/ply/bundled.cjs.map +2 -2
- package/dist/ply/bundled.d.ts +1 -1
- package/dist/ply/bundled.d.ts.map +1 -1
- package/dist/ply/bundled.js +1 -1
- package/dist/ply/bundled.js.map +1 -1
- package/dist/ply/index.cjs +0 -3
- package/dist/ply/index.cjs.map +3 -3
- package/dist/ply/index.d.ts +0 -2
- package/dist/ply/index.d.ts.map +1 -1
- package/dist/ply/index.js +0 -3
- package/dist/ply/index.js.map +1 -1
- package/dist/ply/lib/get-ply-schema.cjs +4 -2
- package/dist/ply/lib/get-ply-schema.cjs.map +2 -2
- package/dist/ply/lib/get-ply-schema.d.ts +6 -0
- package/dist/ply/lib/get-ply-schema.d.ts.map +1 -1
- package/dist/ply/lib/get-ply-schema.js +1 -1
- package/dist/ply/lib/get-ply-schema.js.map +1 -1
- package/dist/ply/lib/parse-ply-arrow.cjs +1 -1
- package/dist/ply/lib/parse-ply-arrow.cjs.map +2 -2
- package/dist/ply/lib/parse-ply-arrow.js +2 -2
- package/dist/ply/lib/parse-ply-arrow.js.map +1 -1
- package/dist/ply/lib/parse-ply-in-batches.cjs +14 -8
- package/dist/ply/lib/parse-ply-in-batches.cjs.map +3 -3
- package/dist/ply/lib/parse-ply-in-batches.d.ts.map +1 -1
- package/dist/ply/lib/parse-ply-in-batches.js +9 -4
- package/dist/ply/lib/parse-ply-in-batches.js.map +1 -1
- package/dist/ply/lib/parse-ply.cjs +3 -0
- package/dist/ply/lib/parse-ply.cjs.map +2 -2
- package/dist/ply/lib/parse-ply.d.ts +1 -1
- package/dist/ply/lib/parse-ply.d.ts.map +1 -1
- package/dist/ply/lib/parse-ply.js +4 -0
- package/dist/ply/lib/parse-ply.js.map +1 -1
- package/dist/ply/ply-loader-types.cjs +9 -10
- package/dist/ply/ply-loader-types.cjs.map +2 -2
- package/dist/ply/ply-loader-types.d.ts +19 -42
- package/dist/ply/ply-loader-types.d.ts.map +1 -1
- package/dist/ply/ply-loader-types.js +6 -6
- package/dist/ply/ply-loader-types.js.map +1 -1
- package/dist/ply/ply-loader.cjs +82 -24
- package/dist/ply/ply-loader.cjs.map +3 -3
- package/dist/ply/ply-loader.d.ts +43 -6
- package/dist/ply/ply-loader.d.ts.map +1 -1
- package/dist/ply/ply-loader.js +71 -19
- package/dist/ply/ply-loader.js.map +1 -1
- package/dist/ply/ply-writer.cjs +3 -3
- package/dist/ply/ply-writer.cjs.map +2 -2
- package/dist/ply/ply-writer.d.ts +5 -4
- package/dist/ply/ply-writer.d.ts.map +1 -1
- package/dist/ply/ply-writer.js +4 -4
- package/dist/ply/ply-writer.js.map +1 -1
- package/dist/ply/unbundled.cjs +2 -4
- package/dist/ply/unbundled.cjs.map +2 -2
- package/dist/ply/unbundled.d.ts +1 -1
- package/dist/ply/unbundled.d.ts.map +1 -1
- package/dist/ply/unbundled.js +1 -1
- package/dist/ply/unbundled.js.map +1 -1
- package/dist/ply/workers/ply-worker.cjs +6 -6
- package/dist/ply/workers/ply-worker.cjs.map +2 -2
- package/dist/ply/workers/ply-worker.js +8 -8
- package/dist/ply/workers/ply-worker.js.map +1 -1
- package/dist/ply-loader-types.cjs +66 -0
- package/dist/ply-loader-types.cjs.map +7 -0
- package/dist/ply-loader-types.d.ts +2 -0
- package/dist/ply-loader-types.d.ts.map +1 -0
- package/dist/ply-loader-types.js +2 -0
- package/dist/ply-loader-types.js.map +1 -0
- package/dist/ply-loader.cjs +194 -0
- package/dist/ply-loader.cjs.map +7 -0
- package/dist/ply-loader.d.ts +2 -0
- package/dist/ply-loader.d.ts.map +1 -0
- package/dist/ply-loader.js +2 -0
- package/dist/ply-loader.js.map +1 -0
- package/dist/ply-worker.js +2099 -312
- package/dist/ply-writer.cjs +177 -0
- package/dist/ply-writer.cjs.map +7 -0
- package/dist/ply-writer.d.ts +2 -0
- package/dist/ply-writer.d.ts.map +1 -0
- package/dist/ply-writer.js +2 -0
- package/dist/ply-writer.js.map +1 -0
- package/package.json +75 -71
- package/src/index.ts +3 -3
- package/src/las/bundled.ts +0 -1
- package/src/las/index.ts +0 -4
- package/src/las/las-copc-loader-types.ts +3 -3
- package/src/las/las-copc-loader.ts +12 -12
- package/src/las/las-loader-shared.ts +9 -7
- package/src/las/las-loader-types.ts +3 -6
- package/src/las/las-loader.ts +63 -9
- package/src/las/las-writer.ts +17 -13
- package/src/las/laz-rs-loader-types.ts +3 -3
- package/src/las/laz-rs-loader.ts +11 -11
- package/src/las/lazperf-loader-types.ts +3 -3
- package/src/las/lazperf-loader.ts +13 -13
- package/src/las/lib/copc/parse-las.ts +1 -1
- package/src/las/lib/get-las-schema.ts +5 -0
- package/src/las/lib/las-extra-bytes.ts +6 -4
- package/src/las/lib/laz-perf/parse-las.ts +8 -9
- package/src/las/lib/laz-rs-wasm/parse-las.ts +8 -9
- package/src/las/lib/typescript/parse-las.ts +143 -11
- package/src/las/libs/laz-rs-wasm/README.md +5 -0
- package/src/las/libs/laz-rs-wasm/package.json +6 -0
- package/src/las/unbundled.ts +1 -1
- package/src/las/workers/las-worker.ts +6 -6
- package/src/las-copc-loader-types.ts +1 -0
- package/src/las-copc-loader.ts +1 -0
- package/src/las-loader-types.ts +1 -0
- package/src/las-loader.ts +1 -0
- package/src/las-writer.ts +1 -0
- package/src/laz-rs-loader-types.ts +1 -0
- package/src/laz-rs-loader.ts +1 -0
- package/src/lazperf-loader-types.ts +1 -0
- package/src/lazperf-loader.ts +1 -0
- package/src/pcd/bundled.ts +1 -4
- package/src/pcd/index.ts +0 -4
- package/src/pcd/pcd-loader-types.ts +10 -11
- package/src/pcd/pcd-loader.ts +97 -29
- package/src/pcd/pcd-writer.ts +12 -8
- package/src/pcd/unbundled.ts +1 -1
- package/src/pcd/workers/pcd-worker.ts +6 -6
- package/src/pcd-loader-types.ts +1 -0
- package/src/pcd-loader.ts +1 -0
- package/src/pcd-writer.ts +1 -0
- package/src/ply/bundled.ts +1 -4
- package/src/ply/index.ts +0 -4
- package/src/ply/lib/get-ply-schema.ts +1 -1
- package/src/ply/lib/parse-ply-arrow.ts +2 -2
- package/src/ply/lib/parse-ply-in-batches.ts +9 -4
- package/src/ply/lib/parse-ply.ts +4 -1
- package/src/ply/ply-loader-types.ts +10 -11
- package/src/ply/ply-loader.ts +94 -24
- package/src/ply/ply-writer.ts +12 -8
- package/src/ply/unbundled.ts +1 -1
- package/src/ply/workers/ply-worker.ts +8 -8
- package/src/ply-loader-types.ts +1 -0
- package/src/ply-loader.ts +1 -0
- package/src/ply-writer.ts +1 -0
package/dist/las-worker.js
CHANGED
|
@@ -1,28 +1,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __esm = (fn, res, err) => function __init() {
|
|
6
|
+
if (err) throw err[0];
|
|
7
|
+
try {
|
|
8
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
9
|
+
} catch (e) {
|
|
10
|
+
throw err = [e], e;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
4
13
|
var __export = (target, all) => {
|
|
5
14
|
for (var name in all)
|
|
6
15
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
7
16
|
};
|
|
8
17
|
|
|
9
18
|
// ../core/src/worker-utils/lib/node/worker_threads-browser.ts
|
|
10
|
-
var
|
|
19
|
+
var worker_threads_browser_exports = {};
|
|
20
|
+
__export(worker_threads_browser_exports, {
|
|
21
|
+
NodeWorker: () => NodeWorker,
|
|
22
|
+
parentPort: () => parentPort2
|
|
23
|
+
});
|
|
24
|
+
var NodeWorker, parentPort2;
|
|
25
|
+
var init_worker_threads_browser = __esm({
|
|
26
|
+
"../core/src/worker-utils/lib/node/worker_threads-browser.ts"() {
|
|
27
|
+
"use strict";
|
|
28
|
+
NodeWorker = class {
|
|
29
|
+
/** Restores the native worker constructor when this browser shim is embedded in a Node bundle. */
|
|
30
|
+
constructor(...arguments_) {
|
|
31
|
+
const runtimeProcess = globalThis.process;
|
|
32
|
+
const WorkerConstructor = runtimeProcess?.getBuiltinModule?.("node:worker_threads").Worker;
|
|
33
|
+
if (WorkerConstructor) {
|
|
34
|
+
return new WorkerConstructor(...arguments_);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** No-op browser fallback matching the native Worker API. */
|
|
38
|
+
terminate() {
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
parentPort2 = null;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
11
44
|
|
|
12
|
-
//
|
|
45
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js
|
|
46
|
+
var parentPort = globalThis.process?.getBuiltinModule?.("node:worker_threads")?.parentPort ?? null;
|
|
47
|
+
|
|
48
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js
|
|
13
49
|
function getTransferList(object, recursive = true, transfers) {
|
|
14
50
|
const transfersSet = transfers || /* @__PURE__ */ new Set();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
51
|
+
const seen = /* @__PURE__ */ new Set();
|
|
52
|
+
function visit(value) {
|
|
53
|
+
if (!value || typeof value !== "object" || seen.has(value))
|
|
54
|
+
return;
|
|
55
|
+
seen.add(value);
|
|
56
|
+
if (isTransferable(value))
|
|
57
|
+
transfersSet.add(value);
|
|
58
|
+
else if (ArrayBuffer.isView(value)) {
|
|
59
|
+
if (isTransferable(value.buffer))
|
|
60
|
+
transfersSet.add(value.buffer);
|
|
61
|
+
} else if (recursive && typeof MessageChannel !== "undefined" && value instanceof MessageChannel) {
|
|
62
|
+
visit(value.port1);
|
|
63
|
+
visit(value.port2);
|
|
64
|
+
} else if (recursive && value instanceof Map) {
|
|
65
|
+
for (const [key, item] of value) {
|
|
66
|
+
visit(key);
|
|
67
|
+
visit(item);
|
|
68
|
+
}
|
|
69
|
+
} else if (recursive && value instanceof Set) {
|
|
70
|
+
for (const item of value)
|
|
71
|
+
visit(item);
|
|
72
|
+
} else if (recursive) {
|
|
73
|
+
for (const key of Object.keys(value))
|
|
74
|
+
visit(value[key]);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
visit(object);
|
|
26
78
|
return transfers === void 0 ? Array.from(transfersSet) : [];
|
|
27
79
|
}
|
|
28
80
|
function isTransferable(object) {
|
|
@@ -44,7 +96,7 @@
|
|
|
44
96
|
return false;
|
|
45
97
|
}
|
|
46
98
|
|
|
47
|
-
//
|
|
99
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-body.js
|
|
48
100
|
async function getParentPort() {
|
|
49
101
|
return parentPort;
|
|
50
102
|
}
|
|
@@ -52,23 +104,24 @@
|
|
|
52
104
|
var WorkerBody = class {
|
|
53
105
|
/** Check that we are actually in a worker thread */
|
|
54
106
|
static async inWorkerThread() {
|
|
55
|
-
|
|
107
|
+
const workerGlobalScope = globalThis.WorkerGlobalScope;
|
|
108
|
+
return typeof workerGlobalScope === "function" && globalThis instanceof workerGlobalScope || Boolean(await getParentPort());
|
|
56
109
|
}
|
|
57
110
|
/*
|
|
58
111
|
* (type: WorkerMessageType, payload: WorkerMessagePayload) => any
|
|
59
112
|
*/
|
|
60
113
|
static set onmessage(onMessage) {
|
|
61
114
|
async function handleMessage(message) {
|
|
62
|
-
const
|
|
63
|
-
const { type, payload } =
|
|
115
|
+
const parentPort3 = await getParentPort();
|
|
116
|
+
const { type, payload } = parentPort3 ? message : message.data;
|
|
64
117
|
onMessage(type, payload);
|
|
65
118
|
}
|
|
66
|
-
getParentPort().then((
|
|
67
|
-
if (
|
|
68
|
-
|
|
119
|
+
getParentPort().then((parentPort3) => {
|
|
120
|
+
if (parentPort3) {
|
|
121
|
+
parentPort3.on("message", (message) => {
|
|
69
122
|
handleMessage(message);
|
|
70
123
|
});
|
|
71
|
-
|
|
124
|
+
parentPort3.on("exit", () => console.debug("Node worker closing"));
|
|
72
125
|
} else {
|
|
73
126
|
globalThis.onmessage = handleMessage;
|
|
74
127
|
}
|
|
@@ -86,9 +139,9 @@
|
|
|
86
139
|
};
|
|
87
140
|
onMessageWrapperMap.set(onMessage, onMessageWrapper);
|
|
88
141
|
}
|
|
89
|
-
const
|
|
90
|
-
if (
|
|
91
|
-
|
|
142
|
+
const parentPort3 = await getParentPort();
|
|
143
|
+
if (parentPort3) {
|
|
144
|
+
parentPort3.on("message", onMessageWrapper);
|
|
92
145
|
} else {
|
|
93
146
|
globalThis.addEventListener("message", onMessageWrapper);
|
|
94
147
|
}
|
|
@@ -99,9 +152,9 @@
|
|
|
99
152
|
if (!onMessageWrapper) {
|
|
100
153
|
return;
|
|
101
154
|
}
|
|
102
|
-
const
|
|
103
|
-
if (
|
|
104
|
-
|
|
155
|
+
const parentPort3 = await getParentPort();
|
|
156
|
+
if (parentPort3) {
|
|
157
|
+
parentPort3.off("message", onMessageWrapper);
|
|
105
158
|
} else {
|
|
106
159
|
globalThis.removeEventListener("message", onMessageWrapper);
|
|
107
160
|
}
|
|
@@ -111,12 +164,12 @@
|
|
|
111
164
|
* @param type
|
|
112
165
|
* @param payload
|
|
113
166
|
*/
|
|
114
|
-
static async postMessage(type, payload) {
|
|
167
|
+
static async postMessage(type, payload, copy = false) {
|
|
115
168
|
const data = { source: "loaders.gl", type, payload };
|
|
116
|
-
const transferList = getTransferList(payload);
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
119
|
-
|
|
169
|
+
const transferList = copy ? [] : getTransferList(payload);
|
|
170
|
+
const parentPort3 = await getParentPort();
|
|
171
|
+
if (parentPort3) {
|
|
172
|
+
parentPort3.postMessage(data, transferList);
|
|
120
173
|
} else {
|
|
121
174
|
globalThis.postMessage(data, transferList);
|
|
122
175
|
}
|
|
@@ -130,11 +183,8 @@
|
|
|
130
183
|
return messageData && typeof messageData.source === "string" && messageData.source.startsWith("loaders.gl") ? messageData : null;
|
|
131
184
|
}
|
|
132
185
|
|
|
133
|
-
//
|
|
186
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js
|
|
134
187
|
var AsyncQueue = class {
|
|
135
|
-
_values;
|
|
136
|
-
_settlers;
|
|
137
|
-
_closed;
|
|
138
188
|
constructor() {
|
|
139
189
|
this._values = [];
|
|
140
190
|
this._settlers = [];
|
|
@@ -200,11 +250,58 @@
|
|
|
200
250
|
}
|
|
201
251
|
};
|
|
202
252
|
|
|
203
|
-
//
|
|
253
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js
|
|
254
|
+
var SharedWorkerState = class {
|
|
255
|
+
constructor(buffer) {
|
|
256
|
+
if (typeof SharedArrayBuffer === "undefined" || !(buffer instanceof SharedArrayBuffer) || buffer.byteLength !== 16)
|
|
257
|
+
throw new Error("Expected a 16-byte shared worker control buffer");
|
|
258
|
+
this.buffer = buffer;
|
|
259
|
+
this.values = new Int32Array(buffer);
|
|
260
|
+
}
|
|
261
|
+
get snapshot() {
|
|
262
|
+
return {
|
|
263
|
+
cancelled: Atomics.load(this.values, 0) !== 0,
|
|
264
|
+
completed: Atomics.load(this.values, 1),
|
|
265
|
+
total: Atomics.load(this.values, 2),
|
|
266
|
+
revision: Atomics.load(this.values, 3)
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
cancel() {
|
|
270
|
+
Atomics.store(this.values, 0, 1);
|
|
271
|
+
Atomics.add(this.values, 3, 1);
|
|
272
|
+
Atomics.notify(this.values, 0);
|
|
273
|
+
}
|
|
274
|
+
throwIfCancelled() {
|
|
275
|
+
if (Atomics.load(this.values, 0) !== 0) {
|
|
276
|
+
const error = new Error("Shared worker task was cancelled");
|
|
277
|
+
error.name = "AbortError";
|
|
278
|
+
throw error;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
/** Integer counters for application-defined work; messages still carry phase names and units. */
|
|
282
|
+
setProgress(completed, total = -1) {
|
|
283
|
+
if (!Number.isInteger(completed) || completed < 0 || completed > 2147483647 || !Number.isInteger(total) || total < -1 || total > 2147483647) {
|
|
284
|
+
throw new RangeError("Shared progress requires nonnegative int32 counts (or total -1)");
|
|
285
|
+
}
|
|
286
|
+
Atomics.store(this.values, 1, completed);
|
|
287
|
+
Atomics.store(this.values, 2, total);
|
|
288
|
+
Atomics.add(this.values, 3, 1);
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js
|
|
293
|
+
function validateOutputOwnership(ownership) {
|
|
294
|
+
if (ownership !== void 0 && ownership !== "copy" && ownership !== "transfer") {
|
|
295
|
+
throw new Error("Invalid worker output ownership");
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/create-worker.js
|
|
204
300
|
var requestId = 0;
|
|
301
|
+
var activeController = null;
|
|
205
302
|
var activeInputBatches = null;
|
|
206
303
|
var activeOutputAcknowledgements = null;
|
|
207
|
-
async function createWorker(
|
|
304
|
+
async function createWorker(process2, processInBatches, preload) {
|
|
208
305
|
if (!await WorkerBody.inWorkerThread()) {
|
|
209
306
|
return;
|
|
210
307
|
}
|
|
@@ -212,27 +309,59 @@
|
|
|
212
309
|
process: processOnMainThread
|
|
213
310
|
};
|
|
214
311
|
WorkerBody.onmessage = async (type, payload) => {
|
|
312
|
+
if (type === "cancel") {
|
|
313
|
+
activeController?.abort();
|
|
314
|
+
activeInputBatches?.close();
|
|
315
|
+
activeOutputAcknowledgements?.close();
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
const controller = type === "process" || type === "process-in-batches" ? new AbortController() : void 0;
|
|
319
|
+
if (controller)
|
|
320
|
+
activeController = controller;
|
|
321
|
+
const startedAt = performance.now();
|
|
215
322
|
const reporter = type === "process" || type === "process-in-batches" ? createProgressReporter() : void 0;
|
|
216
|
-
|
|
323
|
+
let sharedState;
|
|
324
|
+
const throwIfAborted = () => {
|
|
325
|
+
controller?.signal.throwIfAborted();
|
|
326
|
+
sharedState?.throwIfCancelled();
|
|
327
|
+
};
|
|
328
|
+
const jobContext = {
|
|
329
|
+
...context,
|
|
330
|
+
signal: controller?.signal,
|
|
331
|
+
sharedState,
|
|
332
|
+
throwIfAborted,
|
|
333
|
+
reportProgress: (progress) => {
|
|
334
|
+
if (!controller?.signal.aborted && !sharedState?.snapshot.cancelled)
|
|
335
|
+
reporter?.report(progress);
|
|
336
|
+
}
|
|
337
|
+
};
|
|
217
338
|
try {
|
|
339
|
+
if (controller && payload.options?.["sharedState"]) {
|
|
340
|
+
sharedState = new SharedWorkerState(payload.options["sharedState"]);
|
|
341
|
+
jobContext.sharedState = sharedState;
|
|
342
|
+
}
|
|
218
343
|
switch (type) {
|
|
219
344
|
case "preload":
|
|
345
|
+
await preload?.();
|
|
220
346
|
WorkerBody.postMessage("done", {});
|
|
221
347
|
break;
|
|
222
348
|
case "process":
|
|
223
|
-
|
|
349
|
+
throwIfAborted();
|
|
350
|
+
validateOutputOwnership(payload.options?.["outputOwnership"]);
|
|
351
|
+
if (!process2) {
|
|
224
352
|
throw new Error("Worker does not support atomic processing");
|
|
225
353
|
}
|
|
226
|
-
const result = await
|
|
227
|
-
|
|
228
|
-
payload.options || {},
|
|
229
|
-
jobContext,
|
|
230
|
-
payload.context || {}
|
|
231
|
-
);
|
|
354
|
+
const result = await process2(payload.input, payload.options || {}, jobContext, payload.context || {});
|
|
355
|
+
throwIfAborted();
|
|
232
356
|
reporter?.finish();
|
|
233
|
-
WorkerBody.postMessage("done", {
|
|
357
|
+
await WorkerBody.postMessage("done", {
|
|
358
|
+
result,
|
|
359
|
+
executionMs: performance.now() - startedAt
|
|
360
|
+
}, payload.options?.["outputOwnership"] === "copy");
|
|
234
361
|
break;
|
|
235
362
|
case "process-in-batches":
|
|
363
|
+
throwIfAborted();
|
|
364
|
+
validateOutputOwnership(payload.options?.["outputOwnership"]);
|
|
236
365
|
if (!processInBatches) {
|
|
237
366
|
throw new Error("Worker does not support batched processing");
|
|
238
367
|
}
|
|
@@ -241,18 +370,15 @@
|
|
|
241
370
|
activeInputBatches = inputBatches;
|
|
242
371
|
activeOutputAcknowledgements = outputAcknowledgements;
|
|
243
372
|
try {
|
|
244
|
-
const resultIterator = processInBatches(
|
|
245
|
-
createDemandDrivenIterator(inputBatches),
|
|
246
|
-
payload.options || {},
|
|
247
|
-
jobContext,
|
|
248
|
-
payload.context || {}
|
|
249
|
-
);
|
|
373
|
+
const resultIterator = processInBatches(createDemandDrivenIterator(inputBatches), payload.options || {}, jobContext, payload.context || {});
|
|
250
374
|
for await (const batch of resultIterator) {
|
|
251
|
-
|
|
375
|
+
throwIfAborted();
|
|
376
|
+
await WorkerBody.postMessage("output-batch", { result: batch }, payload.options?.["outputOwnership"] === "copy");
|
|
252
377
|
await outputAcknowledgements.next();
|
|
253
378
|
}
|
|
379
|
+
throwIfAborted();
|
|
254
380
|
reporter?.finish();
|
|
255
|
-
await WorkerBody.postMessage("done", {});
|
|
381
|
+
await WorkerBody.postMessage("done", { executionMs: performance.now() - startedAt });
|
|
256
382
|
} finally {
|
|
257
383
|
activeInputBatches = null;
|
|
258
384
|
activeOutputAcknowledgements = null;
|
|
@@ -279,11 +405,18 @@
|
|
|
279
405
|
default:
|
|
280
406
|
}
|
|
281
407
|
} catch (error) {
|
|
282
|
-
reporter?.finish();
|
|
408
|
+
reporter?.finish(controller?.signal.aborted || sharedState?.snapshot.cancelled);
|
|
283
409
|
const message = error instanceof Error ? error.message : "";
|
|
284
|
-
WorkerBody.postMessage("error", {
|
|
410
|
+
await WorkerBody.postMessage("error", {
|
|
411
|
+
error: message,
|
|
412
|
+
errorName: error instanceof Error ? error.name : "Error"
|
|
413
|
+
});
|
|
414
|
+
} finally {
|
|
415
|
+
if (controller && activeController === controller)
|
|
416
|
+
activeController = null;
|
|
285
417
|
}
|
|
286
418
|
};
|
|
419
|
+
await WorkerBody.postMessage("ready", {});
|
|
287
420
|
}
|
|
288
421
|
async function* createDemandDrivenIterator(inputBatches) {
|
|
289
422
|
while (true) {
|
|
@@ -296,62 +429,584 @@
|
|
|
296
429
|
}
|
|
297
430
|
}
|
|
298
431
|
function processOnMainThread(arrayBuffer, options = {}, jobContext = {}) {
|
|
432
|
+
const signal = activeController?.signal;
|
|
433
|
+
signal?.throwIfAborted();
|
|
299
434
|
return new Promise((resolve, reject) => {
|
|
300
435
|
const id = requestId++;
|
|
301
|
-
const
|
|
302
|
-
|
|
436
|
+
const cleanup = () => {
|
|
437
|
+
signal?.removeEventListener("abort", abort);
|
|
438
|
+
void WorkerBody.removeEventListener(onMessage);
|
|
439
|
+
};
|
|
440
|
+
const abort = () => {
|
|
441
|
+
cleanup();
|
|
442
|
+
reject(signal?.reason);
|
|
443
|
+
};
|
|
444
|
+
const onMessage = (type, payload) => {
|
|
445
|
+
if (payload.id !== id)
|
|
303
446
|
return;
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
case "error":
|
|
311
|
-
WorkerBody.removeEventListener(onMessage);
|
|
312
|
-
reject(payload2.error);
|
|
313
|
-
break;
|
|
314
|
-
default:
|
|
447
|
+
if (type === "done") {
|
|
448
|
+
cleanup();
|
|
449
|
+
resolve(payload.result);
|
|
450
|
+
} else if (type === "error") {
|
|
451
|
+
cleanup();
|
|
452
|
+
reject(payload.error);
|
|
315
453
|
}
|
|
316
454
|
};
|
|
317
|
-
WorkerBody.addEventListener(onMessage)
|
|
318
|
-
|
|
319
|
-
|
|
455
|
+
void WorkerBody.addEventListener(onMessage).then(async () => {
|
|
456
|
+
if (signal?.aborted) {
|
|
457
|
+
abort();
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
461
|
+
await WorkerBody.postMessage("process", {
|
|
462
|
+
id,
|
|
463
|
+
input: arrayBuffer,
|
|
464
|
+
options,
|
|
465
|
+
context: jobContext
|
|
466
|
+
});
|
|
467
|
+
}).catch((error) => {
|
|
468
|
+
cleanup();
|
|
469
|
+
reject(error);
|
|
470
|
+
});
|
|
320
471
|
});
|
|
321
472
|
}
|
|
322
473
|
function createProgressReporter() {
|
|
323
|
-
let
|
|
474
|
+
let pending2;
|
|
324
475
|
let finished = false;
|
|
325
476
|
let scheduled = false;
|
|
326
477
|
const flush = () => {
|
|
327
478
|
scheduled = false;
|
|
328
|
-
if (
|
|
329
|
-
WorkerBody.postMessage("progress", { progress:
|
|
330
|
-
|
|
479
|
+
if (pending2) {
|
|
480
|
+
WorkerBody.postMessage("progress", { progress: pending2 });
|
|
481
|
+
pending2 = void 0;
|
|
331
482
|
}
|
|
332
483
|
};
|
|
333
484
|
return {
|
|
334
485
|
/** Records progress while retaining phase transitions. */
|
|
335
486
|
report(progress) {
|
|
336
|
-
if (finished)
|
|
337
|
-
|
|
338
|
-
|
|
487
|
+
if (finished)
|
|
488
|
+
return;
|
|
489
|
+
if (pending2 && pending2.phase !== progress.phase)
|
|
490
|
+
flush();
|
|
491
|
+
pending2 = { ...progress };
|
|
339
492
|
if (!scheduled) {
|
|
340
493
|
scheduled = true;
|
|
341
494
|
setTimeout(flush, 0);
|
|
342
495
|
}
|
|
343
496
|
},
|
|
344
497
|
/** Flushes final progress and suppresses reports from stale callbacks. */
|
|
345
|
-
finish() {
|
|
498
|
+
finish(discard = false) {
|
|
499
|
+
if (discard)
|
|
500
|
+
pending2 = void 0;
|
|
346
501
|
flush();
|
|
347
502
|
finished = true;
|
|
348
503
|
}
|
|
349
504
|
};
|
|
350
505
|
}
|
|
351
506
|
|
|
507
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/index.js
|
|
508
|
+
var import_meta = {};
|
|
509
|
+
var path = typeof __filename === "string" ? __filename.replace(/\\/g, "/") : "";
|
|
510
|
+
var moduleUrl = path ? `file://${path.startsWith("/") ? "" : "/"}${encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F")}` : import_meta.url;
|
|
511
|
+
|
|
512
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js
|
|
513
|
+
var pending = /* @__PURE__ */ new WeakMap();
|
|
514
|
+
var loaded = /* @__PURE__ */ new WeakSet();
|
|
515
|
+
function preloadTaskCode(task, signal) {
|
|
516
|
+
if (!task.preload)
|
|
517
|
+
return Promise.resolve();
|
|
518
|
+
let promise = pending.get(task);
|
|
519
|
+
if (!promise) {
|
|
520
|
+
promise = Promise.resolve().then(() => task.preload()).then(() => {
|
|
521
|
+
loaded.add(task);
|
|
522
|
+
});
|
|
523
|
+
pending.set(task, promise);
|
|
524
|
+
void promise.catch(() => pending.delete(task));
|
|
525
|
+
}
|
|
526
|
+
return withSignal(promise, signal);
|
|
527
|
+
}
|
|
528
|
+
function withSignal(operation, signal) {
|
|
529
|
+
if (!signal)
|
|
530
|
+
return operation;
|
|
531
|
+
return new Promise((resolve, reject) => {
|
|
532
|
+
const abort = () => {
|
|
533
|
+
signal.removeEventListener("abort", abort);
|
|
534
|
+
reject(signal.reason);
|
|
535
|
+
};
|
|
536
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
537
|
+
if (signal.aborted)
|
|
538
|
+
abort();
|
|
539
|
+
operation.then((value) => {
|
|
540
|
+
signal.removeEventListener("abort", abort);
|
|
541
|
+
resolve(value);
|
|
542
|
+
}, (error) => {
|
|
543
|
+
signal.removeEventListener("abort", abort);
|
|
544
|
+
reject(error);
|
|
545
|
+
});
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js
|
|
550
|
+
var TaskRequestError = class extends Error {
|
|
551
|
+
};
|
|
552
|
+
var TaskChannel = class {
|
|
553
|
+
constructor(options) {
|
|
554
|
+
this.options = options;
|
|
555
|
+
this.nextId = 1;
|
|
556
|
+
this.pending = /* @__PURE__ */ new Map();
|
|
557
|
+
this.incoming = /* @__PURE__ */ new Map();
|
|
558
|
+
}
|
|
559
|
+
/** Send a request without serializing other in-flight requests. */
|
|
560
|
+
request(operation, value, signal, transfer = []) {
|
|
561
|
+
if (this.failure)
|
|
562
|
+
return Promise.reject(this.failure.reason);
|
|
563
|
+
if (signal?.aborted)
|
|
564
|
+
return Promise.reject(signal.reason);
|
|
565
|
+
const id = this.nextId++;
|
|
566
|
+
return new Promise((resolve, reject) => {
|
|
567
|
+
const abort = () => {
|
|
568
|
+
const pending2 = this.pending.get(id);
|
|
569
|
+
if (!pending2)
|
|
570
|
+
return;
|
|
571
|
+
this.pending.delete(id);
|
|
572
|
+
pending2.cleanup();
|
|
573
|
+
reject(signal?.reason);
|
|
574
|
+
this.send({ source: "math.gl/tasks", kind: "cancel", id });
|
|
575
|
+
};
|
|
576
|
+
this.pending.set(id, {
|
|
577
|
+
resolve,
|
|
578
|
+
reject,
|
|
579
|
+
cleanup: () => signal?.removeEventListener("abort", abort)
|
|
580
|
+
});
|
|
581
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
582
|
+
this.send({ source: "math.gl/tasks", kind: "request", id, operation, value }, transfer);
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
/** Send a one-way notification. */
|
|
586
|
+
emit(operation, value, transfer = []) {
|
|
587
|
+
if (this.failure)
|
|
588
|
+
throw this.failure.reason;
|
|
589
|
+
this.send({ source: "math.gl/tasks", kind: "event", id: 0, operation, value }, transfer);
|
|
590
|
+
}
|
|
591
|
+
/** Dispatch a transport message; unrelated protocols are ignored. */
|
|
592
|
+
receive(message) {
|
|
593
|
+
if (this.failure || message?.source !== "math.gl/tasks")
|
|
594
|
+
return;
|
|
595
|
+
if (message.kind === "failure") {
|
|
596
|
+
const reason = new Error(message.error?.message ?? "Task channel failed");
|
|
597
|
+
this.close(reason);
|
|
598
|
+
this.options.onFailure?.(reason);
|
|
599
|
+
} else if (message.kind === "result" || message.kind === "error") {
|
|
600
|
+
const pending2 = this.pending.get(message.id);
|
|
601
|
+
if (!pending2)
|
|
602
|
+
return;
|
|
603
|
+
this.pending.delete(message.id);
|
|
604
|
+
pending2.cleanup();
|
|
605
|
+
if (message.kind === "result")
|
|
606
|
+
pending2.resolve(message.value);
|
|
607
|
+
else {
|
|
608
|
+
const error = new TaskRequestError(message.error?.message ?? "Task request failed");
|
|
609
|
+
error.name = message.error?.name ?? "Error";
|
|
610
|
+
pending2.reject(error);
|
|
611
|
+
}
|
|
612
|
+
} else if (message.kind === "cancel") {
|
|
613
|
+
this.incoming.get(message.id)?.abort(new DOMException("Task request cancelled", "AbortError"));
|
|
614
|
+
} else if (message.kind === "event") {
|
|
615
|
+
try {
|
|
616
|
+
this.options.handleEvent?.(message.operation, message.value);
|
|
617
|
+
} catch (error) {
|
|
618
|
+
this.fail(error);
|
|
619
|
+
}
|
|
620
|
+
} else if (message.kind === "request") {
|
|
621
|
+
if (this.incoming.has(message.id)) {
|
|
622
|
+
this.fail(new Error("Duplicate task request identifier"));
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
const controller = new AbortController();
|
|
626
|
+
this.incoming.set(message.id, controller);
|
|
627
|
+
void Promise.resolve().then(() => {
|
|
628
|
+
controller.signal.throwIfAborted();
|
|
629
|
+
return this.options.handleRequest(message.operation, message.value, controller.signal);
|
|
630
|
+
}).then((value) => {
|
|
631
|
+
if (!controller.signal.aborted && !this.failure) {
|
|
632
|
+
this.send({ source: "math.gl/tasks", kind: "result", id: message.id, value }, this.options.getResultTransferList?.(value, message.value));
|
|
633
|
+
}
|
|
634
|
+
}).catch((reason) => {
|
|
635
|
+
if (!controller.signal.aborted && !this.failure) {
|
|
636
|
+
this.send({
|
|
637
|
+
source: "math.gl/tasks",
|
|
638
|
+
kind: "error",
|
|
639
|
+
id: message.id,
|
|
640
|
+
error: {
|
|
641
|
+
name: reason instanceof Error ? reason.name : "Error",
|
|
642
|
+
message: reason instanceof Error ? reason.message : String(reason)
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
}).finally(() => this.incoming.delete(message.id));
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
/** Reject all outstanding calls with a common cause and abort incoming callbacks. */
|
|
650
|
+
close(reason = new Error("Task channel closed")) {
|
|
651
|
+
if (this.failure)
|
|
652
|
+
return;
|
|
653
|
+
this.failure = { reason };
|
|
654
|
+
for (const pending2 of this.pending.values()) {
|
|
655
|
+
pending2.cleanup();
|
|
656
|
+
pending2.reject(reason);
|
|
657
|
+
}
|
|
658
|
+
this.pending.clear();
|
|
659
|
+
for (const controller of this.incoming.values())
|
|
660
|
+
controller.abort(reason);
|
|
661
|
+
this.incoming.clear();
|
|
662
|
+
}
|
|
663
|
+
send(message, transfer = []) {
|
|
664
|
+
if (this.failure)
|
|
665
|
+
return;
|
|
666
|
+
try {
|
|
667
|
+
this.options.send(message, transfer);
|
|
668
|
+
} catch (error) {
|
|
669
|
+
this.fail(error);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
/** Invalidate the channel and notify the peer when the transport still works. */
|
|
673
|
+
fail(reason) {
|
|
674
|
+
if (this.failure)
|
|
675
|
+
return;
|
|
676
|
+
this.close(reason);
|
|
677
|
+
try {
|
|
678
|
+
this.options.send({
|
|
679
|
+
source: "math.gl/tasks",
|
|
680
|
+
kind: "failure",
|
|
681
|
+
id: 0,
|
|
682
|
+
error: {
|
|
683
|
+
name: reason instanceof Error ? reason.name : "Error",
|
|
684
|
+
message: reason instanceof Error ? reason.message : String(reason)
|
|
685
|
+
}
|
|
686
|
+
}, []);
|
|
687
|
+
} catch {
|
|
688
|
+
}
|
|
689
|
+
this.options.onFailure?.(reason);
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
|
|
693
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js
|
|
694
|
+
function assertPayload(value) {
|
|
695
|
+
if (!value || typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype) {
|
|
696
|
+
throw new TypeError("Task payloads must be plain objects with named fields");
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
function clonePayload(value, ownership = "copy") {
|
|
700
|
+
assertPayload(value);
|
|
701
|
+
if (!["copy", "transfer", "share"].includes(ownership))
|
|
702
|
+
throw new TypeError("Invalid input ownership");
|
|
703
|
+
const transfer = getTransferList(value);
|
|
704
|
+
if (ownership === "share" && transfer.length)
|
|
705
|
+
throw new TypeError("Share requires shared storage");
|
|
706
|
+
return structuredClone(value, {
|
|
707
|
+
transfer: ownership === "transfer" ? transfer : []
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
function taskContext(state, context = {}) {
|
|
711
|
+
const signal = context.signal ?? new AbortController().signal;
|
|
712
|
+
return {
|
|
713
|
+
state,
|
|
714
|
+
signal,
|
|
715
|
+
requestHost: async (operation, payload, controls) => {
|
|
716
|
+
signal.throwIfAborted();
|
|
717
|
+
if (!context.requestHost)
|
|
718
|
+
throw new Error("No host request handler configured");
|
|
719
|
+
return context.requestHost(operation, payload, controls);
|
|
720
|
+
},
|
|
721
|
+
emitHost: (operation, payload) => {
|
|
722
|
+
signal.throwIfAborted();
|
|
723
|
+
context.emitHost?.(operation, payload);
|
|
724
|
+
},
|
|
725
|
+
throwIfAborted: () => {
|
|
726
|
+
signal.throwIfAborted();
|
|
727
|
+
context.throwIfAborted?.();
|
|
728
|
+
},
|
|
729
|
+
reportProgress: (progress) => context.reportProgress?.({
|
|
730
|
+
...progress,
|
|
731
|
+
phase: progress.phase ?? "process",
|
|
732
|
+
unit: progress.unit ?? "items"
|
|
733
|
+
})
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
var TaskRuntime = class {
|
|
737
|
+
constructor(task) {
|
|
738
|
+
this.task = task;
|
|
739
|
+
this.initialized = false;
|
|
740
|
+
}
|
|
741
|
+
async initialize(input, context = {}) {
|
|
742
|
+
if (this.initialized)
|
|
743
|
+
throw new Error("Task is already initialized");
|
|
744
|
+
assertPayload(input);
|
|
745
|
+
await preloadTaskCode(this.task, context.signal);
|
|
746
|
+
context.signal?.throwIfAborted();
|
|
747
|
+
this.state = await this.task.initialize?.(input, taskContext(void 0, context));
|
|
748
|
+
this.initialized = true;
|
|
749
|
+
return {};
|
|
750
|
+
}
|
|
751
|
+
async destroy() {
|
|
752
|
+
if (this.initialized) {
|
|
753
|
+
this.initialized = false;
|
|
754
|
+
const state = this.state;
|
|
755
|
+
this.state = void 0;
|
|
756
|
+
if (this.task.initialize)
|
|
757
|
+
await this.task.destroy?.(state);
|
|
758
|
+
}
|
|
759
|
+
return {};
|
|
760
|
+
}
|
|
761
|
+
async process(input, options, context = {}) {
|
|
762
|
+
if (!this.initialized)
|
|
763
|
+
throw new Error("Task is not initialized");
|
|
764
|
+
if (!this.task.process)
|
|
765
|
+
throw new Error("Task has no atomic processor");
|
|
766
|
+
assertPayload(input);
|
|
767
|
+
const result = await this.task.process(input, options, taskContext(this.state, context));
|
|
768
|
+
assertPayload(result);
|
|
769
|
+
return result;
|
|
770
|
+
}
|
|
771
|
+
async *stream(inputs, options, context = {}) {
|
|
772
|
+
if (!this.initialized)
|
|
773
|
+
throw new Error("Task is not initialized");
|
|
774
|
+
if (!this.task.processInBatches)
|
|
775
|
+
throw new Error("Task has no streaming processor");
|
|
776
|
+
for await (const output of this.task.processInBatches(inputs, options, taskContext(this.state, context))) {
|
|
777
|
+
assertPayload(output);
|
|
778
|
+
yield output;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
async function initializeTaskWorker(task) {
|
|
783
|
+
if (!await WorkerBody.inWorkerThread())
|
|
784
|
+
throw new Error("initializeTaskWorker must run inside a worker");
|
|
785
|
+
if (installed)
|
|
786
|
+
throw new Error("A task is already installed in this worker");
|
|
787
|
+
installed = true;
|
|
788
|
+
const runtime = new TaskRuntime(task);
|
|
789
|
+
let channelStream;
|
|
790
|
+
const channel = new TaskChannel({
|
|
791
|
+
getResultTransferList: (value, request) => request.outputOwnership === "transfer" ? getTransferList(value) : [],
|
|
792
|
+
send: (message, transfer) => {
|
|
793
|
+
const snapshot = structuredClone(message, { transfer });
|
|
794
|
+
void WorkerBody.postMessage("task-channel", snapshot).catch((reason) => channel.fail(reason));
|
|
795
|
+
},
|
|
796
|
+
handleRequest: async (operation, value, signal) => {
|
|
797
|
+
const request = value;
|
|
798
|
+
const context = {
|
|
799
|
+
signal,
|
|
800
|
+
reportProgress: (progress) => channel.emit("task:progress", { id: request.progressId, progress }),
|
|
801
|
+
requestHost: (operation2, payload, controls = {}) => {
|
|
802
|
+
const request2 = {
|
|
803
|
+
operation: operation2,
|
|
804
|
+
payload: clonePayload(payload, controls.inputOwnership),
|
|
805
|
+
outputOwnership: controls.outputOwnership ?? "copy"
|
|
806
|
+
};
|
|
807
|
+
return channel.request("task:host-request", request2, signal, getTransferList(request2));
|
|
808
|
+
},
|
|
809
|
+
emitHost: (operation2, payload) => channel.emit("task:host-event", { operation: operation2, payload, id: request.progressId })
|
|
810
|
+
};
|
|
811
|
+
switch (operation) {
|
|
812
|
+
case "initialize":
|
|
813
|
+
return runtime.initialize(request.input, context);
|
|
814
|
+
case "process":
|
|
815
|
+
return runtime.process(request.input, request.options, context);
|
|
816
|
+
case "stream-open": {
|
|
817
|
+
if (channelStream)
|
|
818
|
+
throw new Error("A task stream is already open");
|
|
819
|
+
async function* inputs() {
|
|
820
|
+
while (true) {
|
|
821
|
+
const result = await channel.request("task:next-input", { outputOwnership: "transfer" }, signal);
|
|
822
|
+
if (result.done)
|
|
823
|
+
return;
|
|
824
|
+
yield result.value;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
channelStream = runtime.stream(inputs(), request.options, context)[Symbol.asyncIterator]();
|
|
828
|
+
return {};
|
|
829
|
+
}
|
|
830
|
+
case "stream-next":
|
|
831
|
+
if (!channelStream)
|
|
832
|
+
throw new Error("No active task stream");
|
|
833
|
+
return channelStream.next();
|
|
834
|
+
case "stream-close":
|
|
835
|
+
try {
|
|
836
|
+
await channelStream?.return?.();
|
|
837
|
+
} finally {
|
|
838
|
+
channelStream = void 0;
|
|
839
|
+
}
|
|
840
|
+
return {};
|
|
841
|
+
case "destroy":
|
|
842
|
+
return runtime.destroy();
|
|
843
|
+
default:
|
|
844
|
+
throw new Error("Unknown task channel operation");
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
await WorkerBody.addEventListener((type, payload) => {
|
|
849
|
+
if (type === "task-channel")
|
|
850
|
+
channel.receive(payload);
|
|
851
|
+
});
|
|
852
|
+
let streamOptions = {};
|
|
853
|
+
return createWorker(async (request, _options, context) => {
|
|
854
|
+
switch (request.operation) {
|
|
855
|
+
case "initialize":
|
|
856
|
+
return runtime.initialize(request.input, context);
|
|
857
|
+
case "destroy":
|
|
858
|
+
return runtime.destroy();
|
|
859
|
+
case "stream-options":
|
|
860
|
+
streamOptions = request.options;
|
|
861
|
+
return {};
|
|
862
|
+
case "process":
|
|
863
|
+
return runtime.process(request.input, request.options, context);
|
|
864
|
+
default:
|
|
865
|
+
throw new Error("Unknown task operation");
|
|
866
|
+
}
|
|
867
|
+
}, async function* (inputs, _options, context) {
|
|
868
|
+
async function* batches() {
|
|
869
|
+
for await (const input of inputs) {
|
|
870
|
+
assertPayload(input);
|
|
871
|
+
yield input;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
try {
|
|
875
|
+
yield* runtime.stream(batches(), streamOptions, context);
|
|
876
|
+
} finally {
|
|
877
|
+
streamOptions = {};
|
|
878
|
+
}
|
|
879
|
+
}, () => preloadTaskCode(task));
|
|
880
|
+
}
|
|
881
|
+
var installed = false;
|
|
882
|
+
|
|
883
|
+
// ../core/src/worker-utils/lib/worker-api/task-runtime.ts
|
|
884
|
+
function normalizeTaskProgress(progress) {
|
|
885
|
+
return { ...progress, phase: progress.phase ?? "process", unit: progress.unit ?? "items" };
|
|
886
|
+
}
|
|
887
|
+
async function isWorkerThread() {
|
|
888
|
+
if (typeof self !== "undefined" && typeof document === "undefined" && typeof self.postMessage === "function")
|
|
889
|
+
return true;
|
|
890
|
+
if (typeof process !== "undefined" && process.versions?.node) {
|
|
891
|
+
const { isMainThread } = await Promise.resolve().then(() => (init_worker_threads_browser(), worker_threads_browser_exports));
|
|
892
|
+
return !isMainThread;
|
|
893
|
+
}
|
|
894
|
+
return false;
|
|
895
|
+
}
|
|
896
|
+
var initializeTaskWorker2 = initializeTaskWorker;
|
|
897
|
+
|
|
898
|
+
// ../core/src/worker-utils/lib/worker-utils/get-transfer-list.ts
|
|
899
|
+
function getTransferList2(object, recursive = true, transfers) {
|
|
900
|
+
const transfersSet = transfers || /* @__PURE__ */ new Set();
|
|
901
|
+
if (!object) {
|
|
902
|
+
} else if (isTransferable2(object)) {
|
|
903
|
+
transfersSet.add(object);
|
|
904
|
+
} else if (isTransferable2(object.buffer)) {
|
|
905
|
+
transfersSet.add(object.buffer);
|
|
906
|
+
} else if (ArrayBuffer.isView(object)) {
|
|
907
|
+
} else if (recursive && typeof object === "object") {
|
|
908
|
+
for (const key in object) {
|
|
909
|
+
getTransferList2(object[key], recursive, transfersSet);
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
return transfers === void 0 ? Array.from(transfersSet) : [];
|
|
913
|
+
}
|
|
914
|
+
function isTransferable2(object) {
|
|
915
|
+
if (!object) {
|
|
916
|
+
return false;
|
|
917
|
+
}
|
|
918
|
+
if (object instanceof ArrayBuffer) {
|
|
919
|
+
return true;
|
|
920
|
+
}
|
|
921
|
+
if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
|
|
922
|
+
return true;
|
|
923
|
+
}
|
|
924
|
+
if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
|
|
925
|
+
return true;
|
|
926
|
+
}
|
|
927
|
+
if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
|
|
928
|
+
return true;
|
|
929
|
+
}
|
|
930
|
+
return false;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
// ../core/src/worker-utils/lib/worker-api/create-worker.ts
|
|
934
|
+
async function createWorker2(process2, processInBatches) {
|
|
935
|
+
if (!await isWorkerThread()) return;
|
|
936
|
+
await initializeTaskWorker2(createWorkerTask(process2, processInBatches));
|
|
937
|
+
}
|
|
938
|
+
function createWorkerTask(process2, processInBatches) {
|
|
939
|
+
return {
|
|
940
|
+
id: "loaders.gl",
|
|
941
|
+
initialize: (state) => state,
|
|
942
|
+
destroy: (state) => state.port?.close(),
|
|
943
|
+
process: async ({ value }, options, context) => {
|
|
944
|
+
if (!process2) throw new Error("Worker does not support atomic processing");
|
|
945
|
+
return { value: await process2(value, options, createContext(context), context.state.context) };
|
|
946
|
+
},
|
|
947
|
+
...processInBatches ? {
|
|
948
|
+
processInBatches: async function* (inputs, options, context) {
|
|
949
|
+
async function* values() {
|
|
950
|
+
for await (const input of inputs) yield input.value;
|
|
951
|
+
}
|
|
952
|
+
for await (const value of processInBatches(
|
|
953
|
+
values(),
|
|
954
|
+
options,
|
|
955
|
+
createContext(context),
|
|
956
|
+
context.state.context
|
|
957
|
+
)) {
|
|
958
|
+
yield { value };
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
} : {}
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
function createContext(context) {
|
|
965
|
+
let requestIdentifier = 0;
|
|
966
|
+
const port = context.state.port;
|
|
967
|
+
return {
|
|
968
|
+
signal: context.signal,
|
|
969
|
+
throwIfAborted: () => context.throwIfAborted(),
|
|
970
|
+
reportProgress: (progress) => context.reportProgress(normalizeTaskProgress(progress)),
|
|
971
|
+
process: port ? (input, options = {}, jobContext = {}) => {
|
|
972
|
+
context.throwIfAborted();
|
|
973
|
+
const identifier = ++requestIdentifier;
|
|
974
|
+
return new Promise((resolve, reject) => {
|
|
975
|
+
const onMessage = (event) => {
|
|
976
|
+
if (event.data.identifier !== identifier) return;
|
|
977
|
+
cleanup();
|
|
978
|
+
if (event.data.error) {
|
|
979
|
+
const error = new Error(event.data.error.message);
|
|
980
|
+
error.name = event.data.error.name;
|
|
981
|
+
reject(error);
|
|
982
|
+
} else resolve(event.data.value);
|
|
983
|
+
};
|
|
984
|
+
const onAbort = () => {
|
|
985
|
+
cleanup();
|
|
986
|
+
reject(context.signal.reason);
|
|
987
|
+
};
|
|
988
|
+
const cleanup = () => {
|
|
989
|
+
port.removeEventListener("message", onMessage);
|
|
990
|
+
context.signal.removeEventListener("abort", onAbort);
|
|
991
|
+
};
|
|
992
|
+
port.addEventListener("message", onMessage);
|
|
993
|
+
context.signal.addEventListener("abort", onAbort, { once: true });
|
|
994
|
+
port.start();
|
|
995
|
+
try {
|
|
996
|
+
const request = { identifier, input, options, context: jobContext };
|
|
997
|
+
port.postMessage(request, getTransferList2(request));
|
|
998
|
+
} catch (error) {
|
|
999
|
+
cleanup();
|
|
1000
|
+
reject(error);
|
|
1001
|
+
}
|
|
1002
|
+
});
|
|
1003
|
+
} : void 0
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
|
|
352
1007
|
// ../core/src/loader-utils/lib/worker-loader-utils/create-loader-worker.ts
|
|
353
1008
|
async function createLoaderWorker(loader, selectLoader = () => loader) {
|
|
354
|
-
await
|
|
1009
|
+
await createWorker2(
|
|
355
1010
|
(input, options, workerContext, loaderContext) => processLoaderWorkerData(
|
|
356
1011
|
selectLoader(options || {}),
|
|
357
1012
|
input,
|
|
@@ -5043,6 +5698,52 @@
|
|
|
5043
5698
|
return NativeFloat16ArrayConstructor ?? Uint16Array;
|
|
5044
5699
|
}
|
|
5045
5700
|
|
|
5701
|
+
// ../core/src/loader-utils/lib/pace-batch-iterator.ts
|
|
5702
|
+
function validateBatchDeliveryRate(rate) {
|
|
5703
|
+
if (!Number.isFinite(rate) || rate < 0) {
|
|
5704
|
+
throw new RangeError("core.batchMaxRowsPerSecond must be a finite nonnegative number");
|
|
5705
|
+
}
|
|
5706
|
+
}
|
|
5707
|
+
async function* paceBatchIterator(batches, { batchMaxRowsPerSecond = 0, getRowCount, signal }) {
|
|
5708
|
+
validateBatchDeliveryRate(batchMaxRowsPerSecond);
|
|
5709
|
+
signal?.throwIfAborted();
|
|
5710
|
+
if (batchMaxRowsPerSecond === 0) {
|
|
5711
|
+
yield* batches;
|
|
5712
|
+
return;
|
|
5713
|
+
}
|
|
5714
|
+
let deadline = 0;
|
|
5715
|
+
for await (const batch of batches) {
|
|
5716
|
+
signal?.throwIfAborted();
|
|
5717
|
+
const rowCount = getRowCount(batch);
|
|
5718
|
+
if (rowCount !== void 0 && rowCount > 0) {
|
|
5719
|
+
let remaining = deadline - performance.now();
|
|
5720
|
+
while (remaining > 0) {
|
|
5721
|
+
await waitForBatch(Math.min(Math.ceil(remaining), 2 ** 31 - 1), signal);
|
|
5722
|
+
remaining = deadline - performance.now();
|
|
5723
|
+
}
|
|
5724
|
+
signal?.throwIfAborted();
|
|
5725
|
+
deadline = performance.now() + rowCount / batchMaxRowsPerSecond * 1e3;
|
|
5726
|
+
}
|
|
5727
|
+
yield batch;
|
|
5728
|
+
signal?.throwIfAborted();
|
|
5729
|
+
}
|
|
5730
|
+
}
|
|
5731
|
+
function waitForBatch(delay, signal) {
|
|
5732
|
+
signal?.throwIfAborted();
|
|
5733
|
+
return new Promise((resolve, reject) => {
|
|
5734
|
+
const timer = setTimeout(() => {
|
|
5735
|
+
signal?.removeEventListener("abort", abort);
|
|
5736
|
+
resolve();
|
|
5737
|
+
}, delay);
|
|
5738
|
+
function abort() {
|
|
5739
|
+
clearTimeout(timer);
|
|
5740
|
+
signal?.removeEventListener("abort", abort);
|
|
5741
|
+
reject(signal?.reason);
|
|
5742
|
+
}
|
|
5743
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
5744
|
+
});
|
|
5745
|
+
}
|
|
5746
|
+
|
|
5046
5747
|
// ../core/src/schema-utils/lib/schema/data-type.ts
|
|
5047
5748
|
function getDataTypeFromValue(value, defaultNumberType = "float32") {
|
|
5048
5749
|
if (value instanceof Date) {
|
|
@@ -12456,11 +13157,11 @@ return true;`);
|
|
|
12456
13157
|
this._offsets = new OffsetsBufferBuilder(opts.type);
|
|
12457
13158
|
}
|
|
12458
13159
|
setValue(index, value) {
|
|
12459
|
-
const
|
|
12460
|
-
const current =
|
|
13160
|
+
const pending2 = this._pending || (this._pending = /* @__PURE__ */ new Map());
|
|
13161
|
+
const current = pending2.get(index);
|
|
12461
13162
|
current && (this._pendingLength -= current.length);
|
|
12462
13163
|
this._pendingLength += value instanceof MapRow ? value[kKeys].length : value.length;
|
|
12463
|
-
|
|
13164
|
+
pending2.set(index, value);
|
|
12464
13165
|
}
|
|
12465
13166
|
setValid(index, isValid) {
|
|
12466
13167
|
if (!super.setValid(index, isValid)) {
|
|
@@ -12483,12 +13184,12 @@ return true;`);
|
|
|
12483
13184
|
return super.finish();
|
|
12484
13185
|
}
|
|
12485
13186
|
_flush() {
|
|
12486
|
-
const
|
|
13187
|
+
const pending2 = this._pending;
|
|
12487
13188
|
const pendingLength = this._pendingLength;
|
|
12488
13189
|
this._pendingLength = 0;
|
|
12489
13190
|
this._pending = void 0;
|
|
12490
|
-
if (
|
|
12491
|
-
this._flushPending(
|
|
13191
|
+
if (pending2 && pending2.size > 0) {
|
|
13192
|
+
this._flushPending(pending2, pendingLength);
|
|
12492
13193
|
}
|
|
12493
13194
|
return this;
|
|
12494
13195
|
}
|
|
@@ -14898,11 +15599,11 @@ return true;`);
|
|
|
14898
15599
|
setValue(index, value) {
|
|
14899
15600
|
return super.setValue(index, toUint8Array2(value));
|
|
14900
15601
|
}
|
|
14901
|
-
_flushPending(
|
|
15602
|
+
_flushPending(pending2, pendingLength) {
|
|
14902
15603
|
const offsets = this._offsets;
|
|
14903
15604
|
const data = this._values.reserve(pendingLength).buffer;
|
|
14904
15605
|
let offset = 0;
|
|
14905
|
-
for (const [index, value] of
|
|
15606
|
+
for (const [index, value] of pending2) {
|
|
14906
15607
|
if (value === void 0) {
|
|
14907
15608
|
offsets.set(index, 0);
|
|
14908
15609
|
} else {
|
|
@@ -14931,11 +15632,11 @@ return true;`);
|
|
|
14931
15632
|
setValue(index, value) {
|
|
14932
15633
|
return super.setValue(index, toUint8Array2(value));
|
|
14933
15634
|
}
|
|
14934
|
-
_flushPending(
|
|
15635
|
+
_flushPending(pending2, pendingLength) {
|
|
14935
15636
|
const offsets = this._offsets;
|
|
14936
15637
|
const data = this._values.reserve(pendingLength).buffer;
|
|
14937
15638
|
let offset = 0;
|
|
14938
|
-
for (const [index, value] of
|
|
15639
|
+
for (const [index, value] of pending2) {
|
|
14939
15640
|
if (value === void 0) {
|
|
14940
15641
|
offsets.set(index, BigInt(0));
|
|
14941
15642
|
} else {
|
|
@@ -15166,10 +15867,10 @@ return true;`);
|
|
|
15166
15867
|
this.type = new List2(new Field2(name, child.type, true));
|
|
15167
15868
|
return this.numChildren - 1;
|
|
15168
15869
|
}
|
|
15169
|
-
_flushPending(
|
|
15870
|
+
_flushPending(pending2) {
|
|
15170
15871
|
const offsets = this._offsets;
|
|
15171
15872
|
const [child] = this.children;
|
|
15172
|
-
for (const [index, value] of
|
|
15873
|
+
for (const [index, value] of pending2) {
|
|
15173
15874
|
if (typeof value === "undefined") {
|
|
15174
15875
|
offsets.set(index, 0);
|
|
15175
15876
|
} else {
|
|
@@ -15198,10 +15899,10 @@ return true;`);
|
|
|
15198
15899
|
this.type = new LargeList2(new Field2(name, child.type, true));
|
|
15199
15900
|
return this.numChildren - 1;
|
|
15200
15901
|
}
|
|
15201
|
-
_flushPending(
|
|
15902
|
+
_flushPending(pending2) {
|
|
15202
15903
|
const offsets = this._offsets;
|
|
15203
15904
|
const [child] = this.children;
|
|
15204
|
-
for (const [index, value] of
|
|
15905
|
+
for (const [index, value] of pending2) {
|
|
15205
15906
|
if (typeof value === "undefined") {
|
|
15206
15907
|
offsets.set(index, BigInt(0));
|
|
15207
15908
|
} else {
|
|
@@ -15223,11 +15924,11 @@ return true;`);
|
|
|
15223
15924
|
}
|
|
15224
15925
|
setValue(index, value) {
|
|
15225
15926
|
const row = value instanceof Map ? value : new Map(Object.entries(value));
|
|
15226
|
-
const
|
|
15227
|
-
const current =
|
|
15927
|
+
const pending2 = this._pending || (this._pending = /* @__PURE__ */ new Map());
|
|
15928
|
+
const current = pending2.get(index);
|
|
15228
15929
|
current && (this._pendingLength -= current.size);
|
|
15229
15930
|
this._pendingLength += row.size;
|
|
15230
|
-
|
|
15931
|
+
pending2.set(index, row);
|
|
15231
15932
|
}
|
|
15232
15933
|
addChild(child, name = `${this.numChildren}`) {
|
|
15233
15934
|
if (this.numChildren > 0) {
|
|
@@ -15237,10 +15938,10 @@ return true;`);
|
|
|
15237
15938
|
this.type = new Map_(new Field2(name, child.type, true), this.type.keysSorted);
|
|
15238
15939
|
return this.numChildren - 1;
|
|
15239
15940
|
}
|
|
15240
|
-
_flushPending(
|
|
15941
|
+
_flushPending(pending2) {
|
|
15241
15942
|
const offsets = this._offsets;
|
|
15242
15943
|
const [child] = this.children;
|
|
15243
|
-
for (const [index, value] of
|
|
15944
|
+
for (const [index, value] of pending2) {
|
|
15244
15945
|
if (value === void 0) {
|
|
15245
15946
|
offsets.set(index, 0);
|
|
15246
15947
|
} else {
|
|
@@ -15403,7 +16104,7 @@ return true;`);
|
|
|
15403
16104
|
return super.setValue(index, encodeUtf8(value));
|
|
15404
16105
|
}
|
|
15405
16106
|
// @ts-ignore
|
|
15406
|
-
_flushPending(
|
|
16107
|
+
_flushPending(pending2, pendingLength) {
|
|
15407
16108
|
}
|
|
15408
16109
|
};
|
|
15409
16110
|
Utf8Builder.prototype._flushPending = BinaryBuilder.prototype._flushPending;
|
|
@@ -15425,7 +16126,7 @@ return true;`);
|
|
|
15425
16126
|
return super.setValue(index, encodeUtf8(value));
|
|
15426
16127
|
}
|
|
15427
16128
|
// @ts-ignore
|
|
15428
|
-
_flushPending(
|
|
16129
|
+
_flushPending(pending2, pendingLength) {
|
|
15429
16130
|
}
|
|
15430
16131
|
};
|
|
15431
16132
|
LargeUtf8Builder.prototype._flushPending = LargeBinaryBuilder.prototype._flushPending;
|
|
@@ -19284,7 +19985,40 @@ return true;`);
|
|
|
19284
19985
|
}
|
|
19285
19986
|
}
|
|
19286
19987
|
|
|
19287
|
-
// ../core/src/
|
|
19988
|
+
// ../core/src/lib/loader-utils/native-arrow.ts
|
|
19989
|
+
function isNativeArrowTable(value) {
|
|
19990
|
+
return Boolean(
|
|
19991
|
+
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"
|
|
19992
|
+
);
|
|
19993
|
+
}
|
|
19994
|
+
|
|
19995
|
+
// ../core/src/schema-utils/lib/arrow/arrow-metadata.ts
|
|
19996
|
+
function snapshotArrowSchema(schema) {
|
|
19997
|
+
return deserializeArrowSchema(serializeArrowSchema(schema));
|
|
19998
|
+
}
|
|
19999
|
+
function updateArrowTableSchema(table, schema) {
|
|
20000
|
+
const snapshot = snapshotArrowSchema(schema);
|
|
20001
|
+
const batches = table.batches.map(
|
|
20002
|
+
(batch) => new RecordBatch3(snapshotArrowSchema(snapshot), batch.data, new Map(batch.metadata))
|
|
20003
|
+
);
|
|
20004
|
+
return new Table(
|
|
20005
|
+
snapshot,
|
|
20006
|
+
batches.length ? batches : [new RecordBatch3(snapshotArrowSchema(snapshot), void 0)]
|
|
20007
|
+
);
|
|
20008
|
+
}
|
|
20009
|
+
function updateArrowTableMetadata(table, metadata) {
|
|
20010
|
+
const schema = new Schema2(
|
|
20011
|
+
table.data.schema.fields,
|
|
20012
|
+
new Map([...table.data.schema.metadata, ...Object.entries(metadata)])
|
|
20013
|
+
);
|
|
20014
|
+
const data = updateArrowTableSchema(table.data, schema);
|
|
20015
|
+
return { ...table, data, schema: serializeArrowSchema(data.schema) };
|
|
20016
|
+
}
|
|
20017
|
+
function makeArrowMetadataBatch(schema) {
|
|
20018
|
+
return new RecordBatch3(snapshotArrowSchema(schema), void 0);
|
|
20019
|
+
}
|
|
20020
|
+
|
|
20021
|
+
// ../core/src/schema-utils/lib/mesh/get-mesh-bounding-box.ts
|
|
19288
20022
|
function getMeshBoundingBox(attributes) {
|
|
19289
20023
|
const positionAttribute = attributes?.POSITION;
|
|
19290
20024
|
if (!positionAttribute || !("value" in positionAttribute) || !positionAttribute.value.length) {
|
|
@@ -19444,31 +20178,7 @@ return true;`);
|
|
|
19444
20178
|
|
|
19445
20179
|
// ../core/src/schema-utils/lib/mesh/convert-mesh-to-table.ts
|
|
19446
20180
|
var MESH_ARROW_ATTRIBUTE_ORDER = ["POSITION"];
|
|
19447
|
-
function
|
|
19448
|
-
switch (shape) {
|
|
19449
|
-
case "columnar-table":
|
|
19450
|
-
return convertMeshToColumnarTable(mesh);
|
|
19451
|
-
case "arrow-table":
|
|
19452
|
-
return convertMeshToArrowTable(mesh);
|
|
19453
|
-
default:
|
|
19454
|
-
throw new Error(shape);
|
|
19455
|
-
}
|
|
19456
|
-
}
|
|
19457
|
-
function convertMeshToColumnarTable(mesh) {
|
|
19458
|
-
const columns = {};
|
|
19459
|
-
const hasIndices = hasMeshIndices(mesh);
|
|
19460
|
-
for (const [columnName, attribute] of Object.entries(mesh.attributes)) {
|
|
19461
|
-
columns[columnName] = attribute.value;
|
|
19462
|
-
}
|
|
19463
|
-
return {
|
|
19464
|
-
shape: "columnar-table",
|
|
19465
|
-
schema: mesh.schema,
|
|
19466
|
-
data: columns,
|
|
19467
|
-
topology: mesh.topology,
|
|
19468
|
-
indices: hasIndices ? mesh.indices : void 0
|
|
19469
|
-
};
|
|
19470
|
-
}
|
|
19471
|
-
function convertMeshToArrowTable(mesh, batchSize) {
|
|
20181
|
+
function convertMeshToArrowTableWrapper(mesh, batchSize) {
|
|
19472
20182
|
return makeMeshArrowTable(mesh.attributes, {
|
|
19473
20183
|
schema: mesh.schema,
|
|
19474
20184
|
topology: mesh.topology,
|
|
@@ -19617,6 +20327,7 @@ return true;`);
|
|
|
19617
20327
|
|
|
19618
20328
|
// ../core/src/schema-utils/lib/mesh/convert-table-to-mesh.ts
|
|
19619
20329
|
function convertTableToMesh(table) {
|
|
20330
|
+
if (isNativeArrowTable(table)) return convertArrowTableToMesh(table);
|
|
19620
20331
|
switch (table.shape) {
|
|
19621
20332
|
// case 'columnar-table':
|
|
19622
20333
|
// return convertColumnarTableToMesh(table);
|
|
@@ -19627,8 +20338,10 @@ return true;`);
|
|
|
19627
20338
|
}
|
|
19628
20339
|
}
|
|
19629
20340
|
function convertArrowTableToMesh(table) {
|
|
19630
|
-
const arrowTable = table.data;
|
|
20341
|
+
const arrowTable = isNativeArrowTable(table) ? table : table.data;
|
|
19631
20342
|
const schema = serializeArrowSchema(arrowTable.schema);
|
|
20343
|
+
const localBounds = arrowTable.batches.length === 1 ? arrowTable.batches[0].metadata.get("boundingBox") : void 0;
|
|
20344
|
+
if (localBounds) schema.metadata = { ...schema.metadata, boundingBox: localBounds };
|
|
19632
20345
|
const fields = schema.fields;
|
|
19633
20346
|
const attributes = {};
|
|
19634
20347
|
const columns = [];
|
|
@@ -19838,13 +20551,15 @@ return true;`);
|
|
|
19838
20551
|
};
|
|
19839
20552
|
|
|
19840
20553
|
// src/las/las-loader-shared.ts
|
|
19841
|
-
var VERSION = true ? "5.0.0-beta.
|
|
19842
|
-
var DEFAULT_LAS_SHAPE = "arrow
|
|
20554
|
+
var VERSION = true ? "5.0.0-beta.10" : "latest";
|
|
20555
|
+
var DEFAULT_LAS_SHAPE = "arrow";
|
|
19843
20556
|
function getLASShape(options) {
|
|
19844
20557
|
return options?.las?.shape || DEFAULT_LAS_SHAPE;
|
|
19845
20558
|
}
|
|
19846
20559
|
var LAS_LOADER_METADATA = {
|
|
19847
20560
|
...LASFormat,
|
|
20561
|
+
defaultShape: "arrow",
|
|
20562
|
+
supportsNativeArrow: true,
|
|
19848
20563
|
dataType: null,
|
|
19849
20564
|
batchType: null,
|
|
19850
20565
|
version: VERSION,
|
|
@@ -19883,9 +20598,46 @@ return true;`);
|
|
|
19883
20598
|
return { ...mesh, attributes };
|
|
19884
20599
|
}
|
|
19885
20600
|
|
|
19886
|
-
//
|
|
20601
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/arrow-data.js
|
|
20602
|
+
function getArrowVariadicBuffers(data) {
|
|
20603
|
+
return data.variadicBuffers ?? [];
|
|
20604
|
+
}
|
|
20605
|
+
function createArrowData(type, offset, length, nullCount, buffers, children, dictionary, variadicBuffers) {
|
|
20606
|
+
return Reflect.construct(Data, [
|
|
20607
|
+
type,
|
|
20608
|
+
offset,
|
|
20609
|
+
length,
|
|
20610
|
+
nullCount,
|
|
20611
|
+
buffers,
|
|
20612
|
+
children,
|
|
20613
|
+
dictionary,
|
|
20614
|
+
variadicBuffers
|
|
20615
|
+
]);
|
|
20616
|
+
}
|
|
20617
|
+
|
|
20618
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/arrow-record-batch.js
|
|
20619
|
+
function getRecordBatchMetadata(batch) {
|
|
20620
|
+
return batch.metadata;
|
|
20621
|
+
}
|
|
20622
|
+
function createRecordBatchWithMetadata(schema, data, metadata) {
|
|
20623
|
+
if ("metadata" in RecordBatch3.prototype) {
|
|
20624
|
+
const MetadataRecordBatch = RecordBatch3;
|
|
20625
|
+
return Object.assign(new MetadataRecordBatch(schema, data, metadata), { data });
|
|
20626
|
+
}
|
|
20627
|
+
const batch = Object.assign(new RecordBatch3(schema, data), { data });
|
|
20628
|
+
return metadata === void 0 ? batch : Object.assign(batch, { metadata });
|
|
20629
|
+
}
|
|
20630
|
+
|
|
20631
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/split-arrow-buffers.js
|
|
19887
20632
|
function splitArrowBuffers(input, options = {}) {
|
|
19888
|
-
const
|
|
20633
|
+
const retainedBuffers = /* @__PURE__ */ new Set();
|
|
20634
|
+
const visited = /* @__PURE__ */ new Set();
|
|
20635
|
+
for (const retained of options.retain ?? []) {
|
|
20636
|
+
const chunks = isArrowTable2(retained) ? retained.batches.map((batch) => batch.data) : isArrowVector2(retained) ? retained.data : [isArrowRecordBatch2(retained) ? retained.data : retained];
|
|
20637
|
+
for (const data of chunks)
|
|
20638
|
+
collectArrowBuffers(data, retainedBuffers, visited);
|
|
20639
|
+
}
|
|
20640
|
+
const context = { ...options, copies: /* @__PURE__ */ new WeakMap(), retainedBuffers };
|
|
19889
20641
|
if (isArrowTable2(input)) {
|
|
19890
20642
|
return splitArrowTableBuffersInternal(input, context);
|
|
19891
20643
|
}
|
|
@@ -19906,17 +20658,13 @@ return true;`);
|
|
|
19906
20658
|
function isArrowVector2(input) {
|
|
19907
20659
|
return "data" in input && Array.isArray(input.data);
|
|
19908
20660
|
}
|
|
19909
|
-
function splitArrowTableBuffersInternal(
|
|
19910
|
-
const recordBatches =
|
|
19911
|
-
|
|
19912
|
-
);
|
|
19913
|
-
return new Table(table.schema, recordBatches);
|
|
20661
|
+
function splitArrowTableBuffersInternal(arrowTable, options) {
|
|
20662
|
+
const recordBatches = arrowTable.batches.map((recordBatch) => splitArrowRecordBatchBuffers(recordBatch, options));
|
|
20663
|
+
return new Table(arrowTable.schema, recordBatches);
|
|
19914
20664
|
}
|
|
19915
20665
|
function splitArrowRecordBatchBuffers(recordBatch, options) {
|
|
19916
|
-
|
|
19917
|
-
|
|
19918
|
-
splitArrowDataBuffers(recordBatch.data, options)
|
|
19919
|
-
);
|
|
20666
|
+
const data = splitArrowDataBuffers(recordBatch.data, options);
|
|
20667
|
+
return createRecordBatchWithMetadata(recordBatch.schema, data, getRecordBatchMetadata(recordBatch));
|
|
19920
20668
|
}
|
|
19921
20669
|
function splitArrowDataBuffers(data, options) {
|
|
19922
20670
|
const children = data.children.map((childData) => splitArrowDataBuffers(childData, options));
|
|
@@ -19927,7 +20675,7 @@ return true;`);
|
|
|
19927
20675
|
[BufferType.VALIDITY]: splitArrowBuffer(data.buffers[BufferType.VALIDITY], options),
|
|
19928
20676
|
[BufferType.TYPE]: splitArrowBuffer(data.buffers[BufferType.TYPE], options)
|
|
19929
20677
|
};
|
|
19930
|
-
return
|
|
20678
|
+
return createArrowData(
|
|
19931
20679
|
data.type,
|
|
19932
20680
|
data.offset,
|
|
19933
20681
|
data.length,
|
|
@@ -19935,25 +20683,37 @@ return true;`);
|
|
|
19935
20683
|
data._nullCount,
|
|
19936
20684
|
buffers,
|
|
19937
20685
|
children,
|
|
19938
|
-
dictionary
|
|
20686
|
+
dictionary,
|
|
20687
|
+
getArrowVariadicBuffers(data).map((buffer) => splitArrowBuffer(buffer, options))
|
|
19939
20688
|
);
|
|
19940
20689
|
}
|
|
19941
20690
|
function splitArrowVectorBuffers(vector, options) {
|
|
19942
20691
|
return new Vector(vector.data.map((data) => splitArrowDataBuffers(data, options)));
|
|
19943
20692
|
}
|
|
20693
|
+
function collectArrowBuffers(data, buffers, visited) {
|
|
20694
|
+
if (visited.has(data))
|
|
20695
|
+
return;
|
|
20696
|
+
visited.add(data);
|
|
20697
|
+
for (const view of [...Object.values(data.buffers), ...getArrowVariadicBuffers(data)]) {
|
|
20698
|
+
if (isArrowTypedArray(view))
|
|
20699
|
+
buffers.add(view.buffer);
|
|
20700
|
+
}
|
|
20701
|
+
for (const child of data.children)
|
|
20702
|
+
collectArrowBuffers(child, buffers, visited);
|
|
20703
|
+
for (const chunk of data.dictionary?.data ?? [])
|
|
20704
|
+
collectArrowBuffers(chunk, buffers, visited);
|
|
20705
|
+
}
|
|
19944
20706
|
function splitArrowBuffer(array, options) {
|
|
19945
20707
|
if (!isArrowTypedArray(array)) {
|
|
19946
20708
|
return array;
|
|
19947
20709
|
}
|
|
19948
|
-
|
|
19949
|
-
|
|
19950
|
-
}
|
|
19951
|
-
if (options.copy !== "all" && array.byteOffset === 0 && array.byteLength === array.buffer.byteLength) {
|
|
20710
|
+
const sliced = array.byteOffset !== 0 || array.byteLength !== array.buffer.byteLength;
|
|
20711
|
+
if (!options.retainedBuffers.has(array.buffer) && options.copy !== "all" && (options.copy === "none" || !sliced)) {
|
|
19952
20712
|
return array;
|
|
19953
20713
|
}
|
|
19954
20714
|
let copy = options.copies.get(array);
|
|
19955
20715
|
if (!copy) {
|
|
19956
|
-
copy = array.slice();
|
|
20716
|
+
copy = array instanceof Uint8Array ? new Uint8Array(array) : array.slice();
|
|
19957
20717
|
options.copies.set(array, copy);
|
|
19958
20718
|
}
|
|
19959
20719
|
return copy;
|
|
@@ -19962,38 +20722,79 @@ return true;`);
|
|
|
19962
20722
|
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
19963
20723
|
}
|
|
19964
20724
|
|
|
19965
|
-
//
|
|
19966
|
-
function dehydrateArrowTable(
|
|
19967
|
-
const splitTable = splitArrowBuffers(
|
|
20725
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/arrow-table-transport.js
|
|
20726
|
+
function dehydrateArrowTable(arrowTable, options) {
|
|
20727
|
+
const splitTable = splitArrowBuffers(arrowTable, options);
|
|
19968
20728
|
return {
|
|
19969
|
-
shape: "arrow-table",
|
|
19970
20729
|
transport: "arrow-js",
|
|
19971
|
-
|
|
19972
|
-
|
|
20730
|
+
version: 1,
|
|
20731
|
+
schema: tableToIPC(new Table(splitTable.schema, [])),
|
|
20732
|
+
metadataVersion: splitTable.schema.metadataVersion,
|
|
20733
|
+
batches: splitTable.batches.map((batch) => {
|
|
20734
|
+
const metadata = getRecordBatchMetadata(batch);
|
|
20735
|
+
return {
|
|
20736
|
+
...dehydrateArrowData(batch.data),
|
|
20737
|
+
...metadata !== void 0 ? { metadata: [...metadata] } : {}
|
|
20738
|
+
};
|
|
20739
|
+
})
|
|
19973
20740
|
};
|
|
19974
20741
|
}
|
|
19975
20742
|
function hydrateArrowTable(table) {
|
|
19976
|
-
|
|
19977
|
-
|
|
19978
|
-
|
|
19979
|
-
);
|
|
19980
|
-
|
|
20743
|
+
if (table.transport !== "arrow-js" || table.version !== 1) {
|
|
20744
|
+
throw new Error("Unsupported Arrow column-buffer transport protocol.");
|
|
20745
|
+
}
|
|
20746
|
+
const decodedSchema = tableFromIPC(table.schema).schema;
|
|
20747
|
+
const schema = new Schema2(decodedSchema.fields, decodedSchema.metadata, decodedSchema.dictionaries, table.metadataVersion);
|
|
20748
|
+
const type = new Struct(schema.fields);
|
|
20749
|
+
const batches = table.batches.map((payload) => {
|
|
20750
|
+
const data = hydrateArrowData(payload, type);
|
|
20751
|
+
return createRecordBatchWithMetadata(schema, data, payload.metadata && new Map(payload.metadata));
|
|
20752
|
+
});
|
|
20753
|
+
return new Table(schema, batches);
|
|
19981
20754
|
}
|
|
20755
|
+
function dehydrateArrowData(data) {
|
|
20756
|
+
return {
|
|
20757
|
+
offset: data.offset,
|
|
20758
|
+
length: data.length,
|
|
20759
|
+
nullCount: data.nullCount,
|
|
20760
|
+
buffers: {
|
|
20761
|
+
[BufferType.OFFSET]: data.buffers[BufferType.OFFSET],
|
|
20762
|
+
[BufferType.DATA]: data.buffers[BufferType.DATA],
|
|
20763
|
+
[BufferType.VALIDITY]: data.buffers[BufferType.VALIDITY],
|
|
20764
|
+
[BufferType.TYPE]: data.buffers[BufferType.TYPE]
|
|
20765
|
+
},
|
|
20766
|
+
children: data.children.map((child) => dehydrateArrowData(child)),
|
|
20767
|
+
variadicBuffers: getArrowVariadicBuffers(data),
|
|
20768
|
+
dictionary: data.dictionary?.data.map((chunk) => dehydrateArrowData(chunk))
|
|
20769
|
+
};
|
|
20770
|
+
}
|
|
20771
|
+
function hydrateArrowData(data, type) {
|
|
20772
|
+
const children = data.children.map((child, index) => hydrateArrowData(child, type.children[index].type));
|
|
20773
|
+
const dictionary = data.dictionary && DataType.isDictionary(type) ? new Vector(data.dictionary.map((chunk) => hydrateArrowData(chunk, type.dictionary))) : void 0;
|
|
20774
|
+
return createArrowData(type, data.offset, data.length, data.nullCount, data.buffers, children, dictionary, data.variadicBuffers);
|
|
20775
|
+
}
|
|
20776
|
+
|
|
20777
|
+
// ../core/src/arrow-worker-transport.ts
|
|
19982
20778
|
function serializeArrowWorkerTable(result) {
|
|
19983
20779
|
if (!isArrowTableWrapper(result)) {
|
|
19984
20780
|
throw new Error("Workers require Arrow table output");
|
|
19985
20781
|
}
|
|
19986
|
-
const { data, ...metadata } = result;
|
|
20782
|
+
const { data, shape: _shape, ...metadata } = result;
|
|
19987
20783
|
return {
|
|
19988
|
-
|
|
19989
|
-
|
|
20784
|
+
transport: "arrow-column-envelope",
|
|
20785
|
+
metadata: structuredClone(metadata),
|
|
20786
|
+
...serializeWorkerColumns(data, { copy: "all" })
|
|
19990
20787
|
};
|
|
19991
20788
|
}
|
|
19992
20789
|
function deserializeArrowWorkerTable(result) {
|
|
19993
|
-
if (
|
|
19994
|
-
|
|
20790
|
+
if (isArrowWorkerEnvelope(result)) {
|
|
20791
|
+
return { ...result.metadata, shape: "arrow-table", data: hydrateWorkerTable(result) };
|
|
20792
|
+
}
|
|
20793
|
+
if (isLegacyArrowWorkerEnvelope(result)) {
|
|
20794
|
+
const { arrowBatchMetadata: _snapshots, data: _columns, ...metadata } = result;
|
|
20795
|
+
return { ...metadata, data: hydrateWorkerTable(result) };
|
|
19995
20796
|
}
|
|
19996
|
-
|
|
20797
|
+
throw new Error("Workers require Arrow column transport");
|
|
19997
20798
|
}
|
|
19998
20799
|
function isArrowTableWrapper(value) {
|
|
19999
20800
|
const table = value;
|
|
@@ -20001,50 +20802,56 @@ return true;`);
|
|
|
20001
20802
|
table && table.shape === "arrow-table" && table.data && typeof table.data === "object" && "batches" in table.data
|
|
20002
20803
|
);
|
|
20003
20804
|
}
|
|
20004
|
-
function
|
|
20005
|
-
const
|
|
20006
|
-
return
|
|
20007
|
-
table && table.shape === "arrow-table" && table.data && table.data.transport === "arrow-js" && Array.isArray(table.data.batches)
|
|
20008
|
-
);
|
|
20805
|
+
function hasArrowWorkerColumns(value) {
|
|
20806
|
+
const columns = value;
|
|
20807
|
+
return columns?.data?.transport === "arrow-js" && Array.isArray(columns.data.batches);
|
|
20009
20808
|
}
|
|
20010
|
-
function
|
|
20011
|
-
return
|
|
20809
|
+
function isArrowWorkerEnvelope(value) {
|
|
20810
|
+
return value?.transport === "arrow-column-envelope" && hasArrowWorkerColumns(value);
|
|
20012
20811
|
}
|
|
20013
|
-
function
|
|
20812
|
+
function isLegacyArrowWorkerEnvelope(value) {
|
|
20813
|
+
return value?.shape === "arrow-table" && hasArrowWorkerColumns(value);
|
|
20814
|
+
}
|
|
20815
|
+
function serializeWorkerColumns(table, options) {
|
|
20014
20816
|
return {
|
|
20015
|
-
|
|
20016
|
-
|
|
20017
|
-
length: data.length,
|
|
20018
|
-
// @ts-expect-error _nullCount is protected. Preserve the Arrow lazy null-count state.
|
|
20019
|
-
nullCount: data._nullCount,
|
|
20020
|
-
buffers: {
|
|
20021
|
-
[BufferType.OFFSET]: data.buffers[BufferType.OFFSET],
|
|
20022
|
-
[BufferType.DATA]: data.buffers[BufferType.DATA],
|
|
20023
|
-
[BufferType.VALIDITY]: data.buffers[BufferType.VALIDITY],
|
|
20024
|
-
[BufferType.TYPE]: data.buffers[BufferType.TYPE]
|
|
20025
|
-
},
|
|
20026
|
-
children: data.children.map((childData) => dehydrateArrowData(childData)),
|
|
20027
|
-
dictionary: data.dictionary ? dehydrateArrowVector(data.dictionary) : void 0
|
|
20817
|
+
arrowBatchMetadata: snapshotBatchMetadata(table),
|
|
20818
|
+
data: dehydrateWorkerTable(table, options)
|
|
20028
20819
|
};
|
|
20029
20820
|
}
|
|
20030
|
-
function
|
|
20031
|
-
|
|
20821
|
+
function dehydrateWorkerTable(table, options) {
|
|
20822
|
+
const payload = dehydrateArrowTable(table, options);
|
|
20823
|
+
if (table.numCols === 0) {
|
|
20824
|
+
for (const [index, batch] of table.batches.entries()) {
|
|
20825
|
+
payload.batches[index].length = batch.numRows;
|
|
20826
|
+
}
|
|
20827
|
+
}
|
|
20828
|
+
return payload;
|
|
20032
20829
|
}
|
|
20033
|
-
function
|
|
20034
|
-
|
|
20035
|
-
|
|
20036
|
-
|
|
20037
|
-
|
|
20038
|
-
data.offset,
|
|
20039
|
-
data.length,
|
|
20040
|
-
data.nullCount,
|
|
20041
|
-
data.buffers,
|
|
20042
|
-
children,
|
|
20043
|
-
dictionary
|
|
20044
|
-
);
|
|
20830
|
+
function snapshotBatchMetadata(table) {
|
|
20831
|
+
return table.batches.map((batch) => ({
|
|
20832
|
+
schema: tableToIPC(new Table(batch.schema, [])),
|
|
20833
|
+
metadata: Array.from(batch.metadata)
|
|
20834
|
+
}));
|
|
20045
20835
|
}
|
|
20046
|
-
function
|
|
20047
|
-
|
|
20836
|
+
function hydrateWorkerTable(result) {
|
|
20837
|
+
const { arrowBatchMetadata, data } = result;
|
|
20838
|
+
const table = hydrateArrowTable(data);
|
|
20839
|
+
const batches = table.batches.map((batch, index) => {
|
|
20840
|
+
const snapshot = arrowBatchMetadata?.[index];
|
|
20841
|
+
const restored = snapshot ? new RecordBatch3(
|
|
20842
|
+
tableFromIPC(snapshot.schema).schema,
|
|
20843
|
+
batch.data,
|
|
20844
|
+
new Map(snapshot.metadata)
|
|
20845
|
+
) : batch;
|
|
20846
|
+
const rowCount = data.batches[index].length;
|
|
20847
|
+
if (restored.numCols === 0 && restored.numRows !== rowCount) {
|
|
20848
|
+
Object.defineProperty(restored, "data", {
|
|
20849
|
+
value: new Data(new Struct([]), 0, rowCount, 0, void 0, [])
|
|
20850
|
+
});
|
|
20851
|
+
}
|
|
20852
|
+
return restored;
|
|
20853
|
+
});
|
|
20854
|
+
return new Table(table.schema, batches);
|
|
20048
20855
|
}
|
|
20049
20856
|
|
|
20050
20857
|
// src/las/lib/get-las-schema.ts
|
|
@@ -20075,6 +20882,11 @@ return true;`);
|
|
|
20075
20882
|
if (lasHeader.isCompressed !== void 0) {
|
|
20076
20883
|
metadata.las_isCompressed = lasHeader.isCompressed.toString();
|
|
20077
20884
|
}
|
|
20885
|
+
if (lasHeader.metadata?.wkt) metadata.las_wkt = lasHeader.metadata.wkt;
|
|
20886
|
+
if (lasHeader.metadata?.wktMathTransform)
|
|
20887
|
+
metadata.las_wktMathTransform = lasHeader.metadata.wktMathTransform;
|
|
20888
|
+
if (lasHeader.metadata?.geotiff)
|
|
20889
|
+
metadata.las_geotiff = JSON.stringify(lasHeader.metadata.geotiff);
|
|
20078
20890
|
return metadata;
|
|
20079
20891
|
}
|
|
20080
20892
|
|
|
@@ -20238,7 +21050,12 @@ return true;`);
|
|
|
20238
21050
|
return attributes;
|
|
20239
21051
|
}
|
|
20240
21052
|
function readLASString(bytes, offset, length) {
|
|
20241
|
-
|
|
21053
|
+
const decoded = new TextDecoder().decode(bytes.subarray(offset, offset + length));
|
|
21054
|
+
let end = decoded.length;
|
|
21055
|
+
while (end > 0 && decoded[end - 1] === "\0") {
|
|
21056
|
+
end--;
|
|
21057
|
+
}
|
|
21058
|
+
return decoded.slice(0, end).trim();
|
|
20242
21059
|
}
|
|
20243
21060
|
function sanitizeExtraBytesName(name) {
|
|
20244
21061
|
return name.trim().replace(/[^A-Za-z0-9_]+/g, "_");
|
|
@@ -20484,20 +21301,22 @@ return true;`);
|
|
|
20484
21301
|
async function* parseLASInBatches(arrayBufferIterator, options = {}) {
|
|
20485
21302
|
const batchSize = getBatchSize(options);
|
|
20486
21303
|
const inputIterator = toAsyncIterator(arrayBufferIterator);
|
|
20487
|
-
let
|
|
21304
|
+
let pending2 = new Uint8Array(0);
|
|
20488
21305
|
let absoluteOffset = 0;
|
|
20489
21306
|
let header = null;
|
|
20490
21307
|
let sourcePointIndex = 0;
|
|
20491
21308
|
let totalRead = 0;
|
|
21309
|
+
let lastTable;
|
|
20492
21310
|
while (true) {
|
|
20493
21311
|
const next = await inputIterator.next();
|
|
20494
21312
|
if (next.done) {
|
|
20495
21313
|
break;
|
|
20496
21314
|
}
|
|
20497
21315
|
const chunk = next.value;
|
|
20498
|
-
|
|
21316
|
+
pending2 = concatenateUint8Arrays2(pending2, toUint8Array3(chunk));
|
|
20499
21317
|
if (!header) {
|
|
20500
|
-
header = tryParseHeader(
|
|
21318
|
+
header = tryParseHeader(pending2, absoluteOffset);
|
|
21319
|
+
if (header && pending2.byteLength < header.pointsOffset) header = null;
|
|
20501
21320
|
if (header) {
|
|
20502
21321
|
header.totalToRead = header.pointsCount;
|
|
20503
21322
|
}
|
|
@@ -20506,11 +21325,65 @@ return true;`);
|
|
|
20506
21325
|
continue;
|
|
20507
21326
|
}
|
|
20508
21327
|
if (header.isCompressed) {
|
|
20509
|
-
|
|
21328
|
+
const extendedOffset = header.metadata?.evlrOffset;
|
|
21329
|
+
let inputOffset = pending2.byteLength;
|
|
21330
|
+
const extendedChunks = [];
|
|
21331
|
+
if (extendedOffset && extendedOffset < inputOffset) {
|
|
21332
|
+
extendedChunks.push(pending2.subarray(extendedOffset));
|
|
21333
|
+
}
|
|
21334
|
+
const trackedIterator = {
|
|
21335
|
+
async next() {
|
|
21336
|
+
const next2 = await inputIterator.next();
|
|
21337
|
+
if (!next2.done && extendedOffset) {
|
|
21338
|
+
const bytes = toUint8Array3(next2.value);
|
|
21339
|
+
const start = Math.max(extendedOffset - inputOffset, 0);
|
|
21340
|
+
if (start < bytes.byteLength) extendedChunks.push(bytes.slice(start));
|
|
21341
|
+
inputOffset += bytes.byteLength;
|
|
21342
|
+
}
|
|
21343
|
+
return next2;
|
|
21344
|
+
}
|
|
21345
|
+
};
|
|
21346
|
+
if (header.pointsCount === 0) {
|
|
21347
|
+
const { laszip } = await readLASZipVLRFromInput(pending2, trackedIterator, header);
|
|
21348
|
+
validateTypeScriptLAZSupport(header, laszip);
|
|
21349
|
+
lastTable = makeEmptyLASBatch(header, options);
|
|
21350
|
+
} else {
|
|
21351
|
+
for await (const table of parseLAZInBatches(pending2, trackedIterator, header, options)) {
|
|
21352
|
+
lastTable = updateArrowTableMetadata(
|
|
21353
|
+
table,
|
|
21354
|
+
makeMetadataFromLasHeader({
|
|
21355
|
+
...header,
|
|
21356
|
+
totalRead: table.loaderData.totalRead,
|
|
21357
|
+
metadata: table.loaderData.metadata || header.metadata
|
|
21358
|
+
})
|
|
21359
|
+
);
|
|
21360
|
+
yield lastTable;
|
|
21361
|
+
}
|
|
21362
|
+
}
|
|
21363
|
+
if (extendedOffset && lastTable && header.metadata?.evlrCount && (lastTable.loaderData.metadata?.evlrs.length ?? 0) < header.metadata.evlrCount) {
|
|
21364
|
+
while (!(await trackedIterator.next()).done) {
|
|
21365
|
+
}
|
|
21366
|
+
const suffix = extendedChunks.reduce(
|
|
21367
|
+
concatenateUint8Arrays2,
|
|
21368
|
+
new Uint8Array(0)
|
|
21369
|
+
);
|
|
21370
|
+
const update2 = makeLASMetadataUpdate(
|
|
21371
|
+
lastTable,
|
|
21372
|
+
header,
|
|
21373
|
+
suffix,
|
|
21374
|
+
extendedOffset,
|
|
21375
|
+
lastTable.loaderData.totalRead
|
|
21376
|
+
);
|
|
21377
|
+
if (update2) {
|
|
21378
|
+
yield update2;
|
|
21379
|
+
return;
|
|
21380
|
+
}
|
|
21381
|
+
}
|
|
21382
|
+
if (header.pointsCount === 0 && lastTable) yield lastTable;
|
|
20510
21383
|
return;
|
|
20511
21384
|
}
|
|
20512
21385
|
for (const batch of readAvailablePointBatches(
|
|
20513
|
-
|
|
21386
|
+
pending2,
|
|
20514
21387
|
absoluteOffset,
|
|
20515
21388
|
header,
|
|
20516
21389
|
sourcePointIndex,
|
|
@@ -20519,9 +21392,13 @@ return true;`);
|
|
|
20519
21392
|
)) {
|
|
20520
21393
|
sourcePointIndex = batch.sourcePointIndex;
|
|
20521
21394
|
totalRead = batch.totalRead;
|
|
20522
|
-
|
|
21395
|
+
pending2 = batch.pending;
|
|
20523
21396
|
absoluteOffset = batch.absoluteOffset;
|
|
20524
|
-
|
|
21397
|
+
lastTable = updateArrowTableMetadata(
|
|
21398
|
+
parseLASArrowTableBatch(batch.arrayBuffer, batch.header, options),
|
|
21399
|
+
makeMetadataFromLasHeader({ ...header, totalRead })
|
|
21400
|
+
);
|
|
21401
|
+
yield lastTable;
|
|
20525
21402
|
}
|
|
20526
21403
|
}
|
|
20527
21404
|
if (!header) {
|
|
@@ -20530,6 +21407,50 @@ return true;`);
|
|
|
20530
21407
|
if (totalRead < header.totalToRead) {
|
|
20531
21408
|
throw new Error("LASLoader: truncated LAS point data");
|
|
20532
21409
|
}
|
|
21410
|
+
if (!lastTable) {
|
|
21411
|
+
lastTable = makeEmptyLASBatch(header, options);
|
|
21412
|
+
yield lastTable;
|
|
21413
|
+
}
|
|
21414
|
+
const update = makeLASMetadataUpdate(lastTable, header, pending2, absoluteOffset, totalRead);
|
|
21415
|
+
if (update) yield update;
|
|
21416
|
+
}
|
|
21417
|
+
function makeEmptyLASBatch(header, options) {
|
|
21418
|
+
const table = parseLASArrowTableBatch(new ArrayBuffer(0), { ...header, pointsOffset: 0 }, options);
|
|
21419
|
+
return updateArrowTableMetadata(
|
|
21420
|
+
{ ...table, loaderData: header },
|
|
21421
|
+
makeMetadataFromLasHeader(header)
|
|
21422
|
+
);
|
|
21423
|
+
}
|
|
21424
|
+
function makeLASMetadataUpdate(lastTable, header, pending2, absoluteOffset, totalRead) {
|
|
21425
|
+
const metadata = header.metadata;
|
|
21426
|
+
if (metadata?.evlrOffset && metadata.evlrCount) {
|
|
21427
|
+
const relativeOffset = metadata.evlrOffset - absoluteOffset;
|
|
21428
|
+
const records = parseLASExtendedVariableLengthRecords(
|
|
21429
|
+
new DataView(pending2.buffer, pending2.byteOffset, pending2.byteLength),
|
|
21430
|
+
relativeOffset,
|
|
21431
|
+
metadata.evlrCount
|
|
21432
|
+
).map((record) => ({ ...record, offset: record.offset + absoluteOffset }));
|
|
21433
|
+
const finalMetadata = {
|
|
21434
|
+
...metadata,
|
|
21435
|
+
evlrs: records,
|
|
21436
|
+
extraBytes: [...metadata.extraBytes],
|
|
21437
|
+
waveformPacketDescriptors: [...metadata.waveformPacketDescriptors]
|
|
21438
|
+
};
|
|
21439
|
+
for (const record of records)
|
|
21440
|
+
parseTypedLASMetadataRecord(
|
|
21441
|
+
{ ...record, data: record.data || new Uint8Array() },
|
|
21442
|
+
finalMetadata
|
|
21443
|
+
);
|
|
21444
|
+
resolveLASGeoTIFFKeyDirectory(finalMetadata);
|
|
21445
|
+
const finalHeader = { ...header, totalRead, metadata: finalMetadata };
|
|
21446
|
+
if (records.length > 0) {
|
|
21447
|
+
const data = new Table([makeArrowMetadataBatch(lastTable.data.schema)]);
|
|
21448
|
+
return updateArrowTableMetadata(
|
|
21449
|
+
{ ...lastTable, data, loaderData: finalHeader },
|
|
21450
|
+
makeMetadataFromLasHeader(finalHeader)
|
|
21451
|
+
);
|
|
21452
|
+
}
|
|
21453
|
+
}
|
|
20533
21454
|
}
|
|
20534
21455
|
async function* decodeLAZFileWithParsedVLRInBatches(initialPending, inputIterator, header, laszip, options) {
|
|
20535
21456
|
if (laszip.variableChunks) {
|
|
@@ -20703,11 +21624,11 @@ return true;`);
|
|
|
20703
21624
|
);
|
|
20704
21625
|
}
|
|
20705
21626
|
async function* parseLAZInBatches(initialPending, inputIterator, header, options) {
|
|
20706
|
-
const { pending, laszip } = await readLASZipVLRFromInput(initialPending, inputIterator, header);
|
|
21627
|
+
const { pending: pending2, laszip } = await readLASZipVLRFromInput(initialPending, inputIterator, header);
|
|
20707
21628
|
validateTypeScriptLAZSupport(header, laszip);
|
|
20708
21629
|
if (!laszip.variableChunks && header.pointsFormatId <= 5) {
|
|
20709
21630
|
yield* parsePendingFixedLegacyLAZFileInArrowBatches(
|
|
20710
|
-
|
|
21631
|
+
pending2,
|
|
20711
21632
|
inputIterator,
|
|
20712
21633
|
header,
|
|
20713
21634
|
laszip,
|
|
@@ -20716,11 +21637,11 @@ return true;`);
|
|
|
20716
21637
|
return;
|
|
20717
21638
|
}
|
|
20718
21639
|
if (!laszip.variableChunks && header.pointsFormatId >= 6 && header.pointsFormatId <= 10) {
|
|
20719
|
-
yield* parsePendingLAZFileInArrowBatches(
|
|
21640
|
+
yield* parsePendingLAZFileInArrowBatches(pending2, inputIterator, header, laszip, options);
|
|
20720
21641
|
return;
|
|
20721
21642
|
}
|
|
20722
21643
|
for await (const batch of decodeLAZFileWithParsedVLRInBatches(
|
|
20723
|
-
|
|
21644
|
+
pending2,
|
|
20724
21645
|
inputIterator,
|
|
20725
21646
|
header,
|
|
20726
21647
|
laszip,
|
|
@@ -20931,7 +21852,7 @@ return true;`);
|
|
|
20931
21852
|
if (header.pointsFormatId <= 5 || laszip.variableChunks) {
|
|
20932
21853
|
yield* decodeLAZFileFromCompleteBytes(new Uint8Array(arrayBuffer), header, laszip, {
|
|
20933
21854
|
...options,
|
|
20934
|
-
batchSize
|
|
21855
|
+
core: { ...options.core, batchSize }
|
|
20935
21856
|
});
|
|
20936
21857
|
return;
|
|
20937
21858
|
}
|
|
@@ -20955,7 +21876,11 @@ return true;`);
|
|
|
20955
21876
|
}
|
|
20956
21877
|
function* decodeLAZFileFromCompleteBytes(bytes, header, laszip, options = {}) {
|
|
20957
21878
|
const batchSize = getBatchSize(options);
|
|
20958
|
-
const outputHeader = {
|
|
21879
|
+
const outputHeader = {
|
|
21880
|
+
...header,
|
|
21881
|
+
metadata: parseLASMetadata(bytes, header),
|
|
21882
|
+
totalToRead: header.pointsCount
|
|
21883
|
+
};
|
|
20959
21884
|
const state = createRawPointBatchState(
|
|
20960
21885
|
batchSize,
|
|
20961
21886
|
header.pointsStructSize,
|
|
@@ -21087,7 +22012,8 @@ return true;`);
|
|
|
21087
22012
|
return arrayBuffer.byteLength >= Math.max(vlrEnd, header.pointsOffset);
|
|
21088
22013
|
}
|
|
21089
22014
|
function parseLASMetadata(arrayBuffer, header) {
|
|
21090
|
-
const dataView =
|
|
22015
|
+
const dataView = makeDataView(arrayBuffer);
|
|
22016
|
+
const bytes = new Uint8Array(dataView.buffer, dataView.byteOffset, dataView.byteLength);
|
|
21091
22017
|
const version = header.versionAsString || "1.0";
|
|
21092
22018
|
const versionParts = version.split(".").map(Number);
|
|
21093
22019
|
const isAtLeast14 = versionParts[0] > 1 || versionParts[0] === 1 && versionParts[1] >= 4;
|
|
@@ -21099,9 +22025,9 @@ return true;`);
|
|
|
21099
22025
|
fileSourceId: dataView.getUint16(4, true),
|
|
21100
22026
|
globalEncoding: dataView.getUint16(6, true),
|
|
21101
22027
|
waveformDataOffset: versionParts[0] > 1 || versionParts[0] === 1 && versionParts[1] >= 3 ? dataView.getBigUint64(227, true) : void 0,
|
|
21102
|
-
projectId: formatLASProjectId(
|
|
21103
|
-
systemIdentifier: readLASString2(
|
|
21104
|
-
generatingSoftware: readLASString2(
|
|
22028
|
+
projectId: formatLASProjectId(bytes.subarray(8, 24)),
|
|
22029
|
+
systemIdentifier: readLASString2(bytes, 26, 32),
|
|
22030
|
+
generatingSoftware: readLASString2(bytes, 58, 32),
|
|
21105
22031
|
creationDayOfYear: dataView.getUint16(90, true),
|
|
21106
22032
|
creationYear: dataView.getUint16(92, true),
|
|
21107
22033
|
headerSize: header.headerSize,
|
|
@@ -21153,7 +22079,7 @@ return true;`);
|
|
|
21153
22079
|
return records;
|
|
21154
22080
|
}
|
|
21155
22081
|
function parseLASExtendedVariableLengthRecords(dataView, evlrOffset, evlrCount) {
|
|
21156
|
-
if (
|
|
22082
|
+
if (evlrOffset < 0 || !evlrCount || evlrOffset >= dataView.byteLength) {
|
|
21157
22083
|
return [];
|
|
21158
22084
|
}
|
|
21159
22085
|
const bytes = new Uint8Array(dataView.buffer, dataView.byteOffset, dataView.byteLength);
|
|
@@ -21709,7 +22635,7 @@ return true;`);
|
|
|
21709
22635
|
return false;
|
|
21710
22636
|
}
|
|
21711
22637
|
function getBatchSize(options) {
|
|
21712
|
-
const batchSize = options.
|
|
22638
|
+
const batchSize = options.core?.batchSize;
|
|
21713
22639
|
return typeof batchSize === "number" ? batchSize : DEFAULT_BATCH_SIZE;
|
|
21714
22640
|
}
|
|
21715
22641
|
function parseLASZipVLR(bytes, header) {
|
|
@@ -21921,10 +22847,10 @@ return true;`);
|
|
|
21921
22847
|
}
|
|
21922
22848
|
}
|
|
21923
22849
|
async function readLASZipVLRFromInput(initialPending, inputIterator, header) {
|
|
21924
|
-
let
|
|
22850
|
+
let pending2 = initialPending;
|
|
21925
22851
|
while (true) {
|
|
21926
22852
|
try {
|
|
21927
|
-
return { pending, laszip: parseLASZipVLR(
|
|
22853
|
+
return { pending: pending2, laszip: parseLASZipVLR(pending2, header) };
|
|
21928
22854
|
} catch (error) {
|
|
21929
22855
|
if (!(error instanceof NeedsMoreData)) {
|
|
21930
22856
|
throw error;
|
|
@@ -21934,7 +22860,7 @@ return true;`);
|
|
|
21934
22860
|
if (next.done) {
|
|
21935
22861
|
throw new NeedsMoreData("LASLoader: incomplete LASzip VLR");
|
|
21936
22862
|
}
|
|
21937
|
-
|
|
22863
|
+
pending2 = concatenateUint8Arrays2(pending2, toUint8Array3(next.value));
|
|
21938
22864
|
}
|
|
21939
22865
|
}
|
|
21940
22866
|
async function collectRemainingInputBytes(initialPending, inputIterator) {
|
|
@@ -22858,10 +23784,10 @@ return true;`);
|
|
|
22858
23784
|
[maximum[0], maximum[1], maximum[2]]
|
|
22859
23785
|
];
|
|
22860
23786
|
}
|
|
22861
|
-
function* readAvailablePointBatches(
|
|
23787
|
+
function* readAvailablePointBatches(pending2, absoluteOffset, header, sourcePointIndex, totalRead, batchSize) {
|
|
22862
23788
|
while (sourcePointIndex < header.pointsCount && totalRead < header.totalToRead) {
|
|
22863
23789
|
const batch = readAvailableContiguousPointBatch(
|
|
22864
|
-
|
|
23790
|
+
pending2,
|
|
22865
23791
|
absoluteOffset,
|
|
22866
23792
|
header,
|
|
22867
23793
|
sourcePointIndex,
|
|
@@ -22871,25 +23797,25 @@ return true;`);
|
|
|
22871
23797
|
if (!batch) {
|
|
22872
23798
|
return;
|
|
22873
23799
|
}
|
|
22874
|
-
|
|
23800
|
+
pending2 = batch.pending;
|
|
22875
23801
|
absoluteOffset = batch.absoluteOffset;
|
|
22876
23802
|
sourcePointIndex = batch.sourcePointIndex;
|
|
22877
23803
|
totalRead = batch.totalRead;
|
|
22878
23804
|
yield batch;
|
|
22879
23805
|
}
|
|
22880
23806
|
}
|
|
22881
|
-
function readAvailableContiguousPointBatch(
|
|
23807
|
+
function readAvailableContiguousPointBatch(pending2, absoluteOffset, header, sourcePointIndex, totalRead, batchSize) {
|
|
22882
23808
|
const pointRecordLength = header.pointsStructSize;
|
|
22883
23809
|
const pointAbsoluteOffset = header.pointsOffset + sourcePointIndex * pointRecordLength;
|
|
22884
23810
|
const pointPendingOffset = pointAbsoluteOffset - absoluteOffset;
|
|
22885
23811
|
if (pointPendingOffset < 0) {
|
|
22886
23812
|
throw new Error("LASLoader: invalid streaming point offset");
|
|
22887
23813
|
}
|
|
22888
|
-
if (pointPendingOffset + pointRecordLength >
|
|
23814
|
+
if (pointPendingOffset + pointRecordLength > pending2.byteLength) {
|
|
22889
23815
|
return null;
|
|
22890
23816
|
}
|
|
22891
23817
|
const availablePointCount = Math.floor(
|
|
22892
|
-
(
|
|
23818
|
+
(pending2.byteLength - pointPendingOffset) / pointRecordLength
|
|
22893
23819
|
);
|
|
22894
23820
|
const batchPointCount = Math.min(
|
|
22895
23821
|
batchSize,
|
|
@@ -22904,38 +23830,38 @@ return true;`);
|
|
|
22904
23830
|
totalRead += batchPointCount;
|
|
22905
23831
|
const batchHeader = {
|
|
22906
23832
|
...header,
|
|
22907
|
-
pointsOffset:
|
|
23833
|
+
pointsOffset: pending2.byteOffset + pointPendingOffset,
|
|
22908
23834
|
pointsCount: batchPointCount,
|
|
22909
23835
|
totalRead
|
|
22910
23836
|
};
|
|
22911
23837
|
const nextPointOffset = header.pointsOffset + sourcePointIndex * pointRecordLength;
|
|
22912
23838
|
const discardByteCount = Math.max(
|
|
22913
23839
|
0,
|
|
22914
|
-
Math.min(
|
|
23840
|
+
Math.min(pending2.byteLength, nextPointOffset - absoluteOffset)
|
|
22915
23841
|
);
|
|
22916
23842
|
return {
|
|
22917
|
-
arrayBuffer:
|
|
23843
|
+
arrayBuffer: pending2.buffer,
|
|
22918
23844
|
header: batchHeader,
|
|
22919
|
-
pending:
|
|
23845
|
+
pending: pending2.subarray(discardByteCount),
|
|
22920
23846
|
absoluteOffset: absoluteOffset + discardByteCount,
|
|
22921
23847
|
sourcePointIndex,
|
|
22922
23848
|
totalRead
|
|
22923
23849
|
};
|
|
22924
23850
|
}
|
|
22925
|
-
function tryParseHeader(
|
|
22926
|
-
if (absoluteOffset !== 0 ||
|
|
23851
|
+
function tryParseHeader(pending2, absoluteOffset) {
|
|
23852
|
+
if (absoluteOffset !== 0 || pending2.byteLength < 227) {
|
|
22927
23853
|
return null;
|
|
22928
23854
|
}
|
|
22929
|
-
const dataView = new DataView(
|
|
23855
|
+
const dataView = new DataView(pending2.buffer, pending2.byteOffset, pending2.byteLength);
|
|
22930
23856
|
if (dataView.getUint32(0, true) !== LASF_SIGNATURE) {
|
|
22931
23857
|
throw new Error("LASLoader: invalid LAS header");
|
|
22932
23858
|
}
|
|
22933
23859
|
const headerLength = dataView.getUint32(96, true);
|
|
22934
|
-
if (
|
|
23860
|
+
if (pending2.byteLength < Math.max(headerLength, 255)) {
|
|
22935
23861
|
return null;
|
|
22936
23862
|
}
|
|
22937
23863
|
const header = parseLASHeader(
|
|
22938
|
-
|
|
23864
|
+
pending2.buffer.slice(pending2.byteOffset, pending2.byteOffset + pending2.byteLength)
|
|
22939
23865
|
);
|
|
22940
23866
|
return header;
|
|
22941
23867
|
}
|
|
@@ -22990,8 +23916,10 @@ return true;`);
|
|
|
22990
23916
|
}
|
|
22991
23917
|
|
|
22992
23918
|
// src/las/las-loader.ts
|
|
22993
|
-
var
|
|
23919
|
+
var LASColumnLoader = {
|
|
22994
23920
|
...LAS_LOADER_METADATA,
|
|
23921
|
+
dataType: null,
|
|
23922
|
+
batchType: null,
|
|
22995
23923
|
worker: true,
|
|
22996
23924
|
workerInBatches: true,
|
|
22997
23925
|
serializeWorkerResult: serializeArrowWorkerTable,
|
|
@@ -23010,15 +23938,14 @@ return true;`);
|
|
|
23010
23938
|
}
|
|
23011
23939
|
function convertLASMesh(table, options) {
|
|
23012
23940
|
const formattedTable = options?.las?.colorFormat === void 0 || options.las.colorFormat === "uint8norm" ? table : {
|
|
23013
|
-
...
|
|
23014
|
-
formatLASMeshColors(convertTableToMesh(table), options.las.colorFormat)
|
|
23015
|
-
"arrow-table"
|
|
23941
|
+
...convertMeshToArrowTableWrapper(
|
|
23942
|
+
formatLASMeshColors(convertTableToMesh(table), options.las.colorFormat)
|
|
23016
23943
|
),
|
|
23017
23944
|
loader: table.loader,
|
|
23018
23945
|
loaderData: table.loaderData,
|
|
23019
23946
|
progress: table.progress
|
|
23020
23947
|
};
|
|
23021
|
-
if (getLASShape(options) === "arrow
|
|
23948
|
+
if (getLASShape(options) === "arrow") {
|
|
23022
23949
|
return formattedTable;
|
|
23023
23950
|
}
|
|
23024
23951
|
return {
|
|
@@ -23029,29 +23956,68 @@ return true;`);
|
|
|
23029
23956
|
};
|
|
23030
23957
|
}
|
|
23031
23958
|
async function* convertLASMeshBatches(tableBatches, options) {
|
|
23032
|
-
for await (const table of tableBatches
|
|
23959
|
+
for await (const table of paceBatchIterator(tableBatches, {
|
|
23960
|
+
batchMaxRowsPerSecond: options?.core?.batchMaxRowsPerSecond,
|
|
23961
|
+
getRowCount: (batch) => batch.data.numRows,
|
|
23962
|
+
signal: options?.signal
|
|
23963
|
+
})) {
|
|
23033
23964
|
yield convertLASMesh(table, options);
|
|
23034
23965
|
}
|
|
23035
23966
|
}
|
|
23036
23967
|
function deserializeLASWorkerTable(result, options) {
|
|
23037
23968
|
return convertLASMesh(deserializeArrowWorkerTable(result), options);
|
|
23038
23969
|
}
|
|
23970
|
+
var LASLoaderWithParser = {
|
|
23971
|
+
...LASColumnLoader,
|
|
23972
|
+
dataType: LAS_LOADER_METADATA.dataType,
|
|
23973
|
+
batchType: LAS_LOADER_METADATA.batchType,
|
|
23974
|
+
parse: async (input, options) => toPublicLASResult(await LASColumnLoader.parse(input, options)),
|
|
23975
|
+
parseSync: (input, options) => toPublicLASResult(LASColumnLoader.parseSync(input, options)),
|
|
23976
|
+
async *parseInBatches(input, options) {
|
|
23977
|
+
for await (const result of LASColumnLoader.parseInBatches(input, options)) {
|
|
23978
|
+
if ("shape" in result) yield* getLASRecordBatches(result);
|
|
23979
|
+
else yield result;
|
|
23980
|
+
}
|
|
23981
|
+
},
|
|
23982
|
+
deserializeWorkerResult: (result, options) => toPublicLASResult(deserializeLASWorkerTable(result, options)),
|
|
23983
|
+
deserializeWorkerBatch(result, options) {
|
|
23984
|
+
const decoded = deserializeLASWorkerTable(result, options);
|
|
23985
|
+
return "shape" in decoded ? getLASRecordBatches(decoded)[0] : decoded;
|
|
23986
|
+
}
|
|
23987
|
+
};
|
|
23988
|
+
function toPublicLASResult(result) {
|
|
23989
|
+
if (!("shape" in result)) return result;
|
|
23990
|
+
const header = JSON.stringify(
|
|
23991
|
+
result.loaderData,
|
|
23992
|
+
(_key, value) => typeof value === "bigint" ? value.toString() : ArrayBuffer.isView(value) ? Array.from(value) : value
|
|
23993
|
+
);
|
|
23994
|
+
if (header) {
|
|
23995
|
+
result.data.schema.metadata.set("loaders.gl.las.header", header);
|
|
23996
|
+
for (const batch of result.data.batches)
|
|
23997
|
+
batch.schema.metadata.set("loaders.gl.las.header", header);
|
|
23998
|
+
}
|
|
23999
|
+
return result.data;
|
|
24000
|
+
}
|
|
24001
|
+
function getLASRecordBatches(result) {
|
|
24002
|
+
const table = toPublicLASResult(result);
|
|
24003
|
+
return table.batches.length ? table.batches : [makeArrowMetadataBatch(table.schema)];
|
|
24004
|
+
}
|
|
23039
24005
|
|
|
23040
24006
|
// src/las/workers/las-worker.ts
|
|
23041
24007
|
createLoaderWorker({
|
|
23042
|
-
...
|
|
24008
|
+
...LASColumnLoader,
|
|
23043
24009
|
/** Decodes worker output as transferable columns; caller formatting follows hydration. */
|
|
23044
24010
|
parse(input, options) {
|
|
23045
|
-
return
|
|
24011
|
+
return LASColumnLoader.parse(input, {
|
|
23046
24012
|
...options,
|
|
23047
|
-
las: { ...options?.las, shape: "arrow
|
|
24013
|
+
las: { ...options?.las, shape: "arrow", colorFormat: "uint8norm" }
|
|
23048
24014
|
});
|
|
23049
24015
|
},
|
|
23050
24016
|
/** Keeps the primary TypeScript decoder alive for the full input stream. */
|
|
23051
24017
|
parseInBatches(input, options) {
|
|
23052
|
-
return
|
|
24018
|
+
return LASColumnLoader.parseInBatches(input, {
|
|
23053
24019
|
...options,
|
|
23054
|
-
las: { ...options?.las, shape: "arrow
|
|
24020
|
+
las: { ...options?.las, shape: "arrow", colorFormat: "uint8norm" }
|
|
23055
24021
|
});
|
|
23056
24022
|
}
|
|
23057
24023
|
});
|