@loaders.gl/pointclouds 5.0.0-beta.1 → 5.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/dist.dev.js +45 -16
- package/dist/dist.min.js +19 -19
- 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.js +1 -1
- package/dist/las/las-copc-loader-types.js.map +1 -1
- package/dist/las/las-loader-shared.cjs +1 -1
- package/dist/las/las-loader-shared.js +1 -1
- package/dist/las/las-loader-types.cjs +1 -1
- package/dist/las/las-loader-types.cjs.map +2 -2
- package/dist/las/las-loader-types.js +1 -1
- package/dist/las/las-loader-types.js.map +1 -1
- package/dist/las/las-writer.cjs +1 -1
- package/dist/las/las-writer.js +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.js +1 -1
- package/dist/las/laz-rs-loader-types.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.js +1 -1
- package/dist/las/lazperf-loader-types.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-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 +59 -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 +56 -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 +82 -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 +565 -133
- 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 +274 -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 +62 -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/pcd-loader-types.cjs +2 -2
- package/dist/pcd/pcd-loader-types.cjs.map +2 -2
- package/dist/pcd/pcd-loader-types.js +2 -2
- package/dist/pcd/pcd-loader-types.js.map +1 -1
- package/dist/pcd/pcd-writer.cjs +1 -1
- package/dist/pcd/pcd-writer.js +1 -1
- package/dist/pcd-loader-types.cjs +66 -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 +146 -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 +586 -117
- 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/ply-loader-types.cjs +2 -2
- package/dist/ply/ply-loader-types.cjs.map +2 -2
- package/dist/ply/ply-loader-types.js +2 -2
- package/dist/ply/ply-loader-types.js.map +1 -1
- package/dist/ply/ply-writer.cjs +1 -1
- package/dist/ply/ply-writer.js +1 -1
- package/dist/ply-loader-types.cjs +67 -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 +136 -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 +586 -117
- 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/las/las-copc-loader-types.ts +1 -1
- package/src/las/las-loader-types.ts +1 -1
- package/src/las/laz-rs-loader-types.ts +1 -1
- package/src/las/lazperf-loader-types.ts +1 -1
- package/src/las/lib/las-extra-bytes.ts +6 -4
- 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-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/pcd-loader-types.ts +1 -1
- 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/ply-loader-types.ts +1 -1
- 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/core/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/core/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/core/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/core/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/core/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/core/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/core/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,356 @@
|
|
|
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/core/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/core/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/core/dist/tasks/task-runtime.js
|
|
550
|
+
function assertPayload(value) {
|
|
551
|
+
if (!value || typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype) {
|
|
552
|
+
throw new TypeError("Task payloads must be plain objects with named fields");
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
function taskContext(state, context = {}) {
|
|
556
|
+
const signal = context.signal ?? new AbortController().signal;
|
|
557
|
+
return {
|
|
558
|
+
state,
|
|
559
|
+
signal,
|
|
560
|
+
throwIfAborted: () => {
|
|
561
|
+
signal.throwIfAborted();
|
|
562
|
+
context.throwIfAborted?.();
|
|
563
|
+
},
|
|
564
|
+
reportProgress: (progress) => context.reportProgress?.({
|
|
565
|
+
...progress,
|
|
566
|
+
phase: progress.phase ?? "process",
|
|
567
|
+
unit: progress.unit ?? "items"
|
|
568
|
+
})
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
var TaskRuntime = class {
|
|
572
|
+
constructor(task) {
|
|
573
|
+
this.task = task;
|
|
574
|
+
this.initialized = false;
|
|
575
|
+
}
|
|
576
|
+
async initialize(input, context = {}) {
|
|
577
|
+
if (this.initialized)
|
|
578
|
+
throw new Error("Task is already initialized");
|
|
579
|
+
assertPayload(input);
|
|
580
|
+
await preloadTaskCode(this.task, context.signal);
|
|
581
|
+
context.signal?.throwIfAborted();
|
|
582
|
+
this.state = await this.task.initialize?.(input, taskContext(void 0, context));
|
|
583
|
+
this.initialized = true;
|
|
584
|
+
return {};
|
|
585
|
+
}
|
|
586
|
+
async destroy() {
|
|
587
|
+
if (this.initialized) {
|
|
588
|
+
this.initialized = false;
|
|
589
|
+
const state = this.state;
|
|
590
|
+
this.state = void 0;
|
|
591
|
+
if (this.task.initialize)
|
|
592
|
+
await this.task.destroy?.(state);
|
|
593
|
+
}
|
|
594
|
+
return {};
|
|
595
|
+
}
|
|
596
|
+
async process(input, options, context = {}) {
|
|
597
|
+
if (!this.initialized)
|
|
598
|
+
throw new Error("Task is not initialized");
|
|
599
|
+
if (!this.task.process)
|
|
600
|
+
throw new Error("Task has no atomic processor");
|
|
601
|
+
assertPayload(input);
|
|
602
|
+
const result = await this.task.process(input, options, taskContext(this.state, context));
|
|
603
|
+
assertPayload(result);
|
|
604
|
+
return result;
|
|
605
|
+
}
|
|
606
|
+
async *stream(inputs, options, context = {}) {
|
|
607
|
+
if (!this.initialized)
|
|
608
|
+
throw new Error("Task is not initialized");
|
|
609
|
+
if (!this.task.processInBatches)
|
|
610
|
+
throw new Error("Task has no streaming processor");
|
|
611
|
+
for await (const output of this.task.processInBatches(inputs, options, taskContext(this.state, context))) {
|
|
612
|
+
assertPayload(output);
|
|
613
|
+
yield output;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
async function initializeTaskWorker(task) {
|
|
618
|
+
if (!await WorkerBody.inWorkerThread())
|
|
619
|
+
throw new Error("initializeTaskWorker must run inside a worker");
|
|
620
|
+
if (installed)
|
|
621
|
+
throw new Error("A task is already installed in this worker");
|
|
622
|
+
installed = true;
|
|
623
|
+
const runtime = new TaskRuntime(task);
|
|
624
|
+
let streamOptions = {};
|
|
625
|
+
return createWorker(async (request, _options, context) => {
|
|
626
|
+
switch (request.operation) {
|
|
627
|
+
case "initialize":
|
|
628
|
+
return runtime.initialize(request.input, context);
|
|
629
|
+
case "destroy":
|
|
630
|
+
return runtime.destroy();
|
|
631
|
+
case "stream-options":
|
|
632
|
+
streamOptions = request.options;
|
|
633
|
+
return {};
|
|
634
|
+
case "process":
|
|
635
|
+
return runtime.process(request.input, request.options, context);
|
|
636
|
+
default:
|
|
637
|
+
throw new Error("Unknown task operation");
|
|
638
|
+
}
|
|
639
|
+
}, async function* (inputs, _options, context) {
|
|
640
|
+
async function* batches() {
|
|
641
|
+
for await (const input of inputs) {
|
|
642
|
+
assertPayload(input);
|
|
643
|
+
yield input;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
try {
|
|
647
|
+
yield* runtime.stream(batches(), streamOptions, context);
|
|
648
|
+
} finally {
|
|
649
|
+
streamOptions = {};
|
|
650
|
+
}
|
|
651
|
+
}, () => preloadTaskCode(task));
|
|
652
|
+
}
|
|
653
|
+
var installed = false;
|
|
654
|
+
|
|
655
|
+
// ../core/src/worker-utils/lib/worker-api/task-runtime.ts
|
|
656
|
+
function normalizeTaskProgress(progress) {
|
|
657
|
+
return { ...progress, phase: progress.phase ?? "process", unit: progress.unit ?? "items" };
|
|
658
|
+
}
|
|
659
|
+
async function isWorkerThread() {
|
|
660
|
+
if (typeof self !== "undefined" && typeof document === "undefined" && typeof self.postMessage === "function")
|
|
661
|
+
return true;
|
|
662
|
+
if (typeof process !== "undefined" && process.versions?.node) {
|
|
663
|
+
const { isMainThread } = await Promise.resolve().then(() => (init_worker_threads_browser(), worker_threads_browser_exports));
|
|
664
|
+
return !isMainThread;
|
|
665
|
+
}
|
|
666
|
+
return false;
|
|
667
|
+
}
|
|
668
|
+
var initializeTaskWorker2 = initializeTaskWorker;
|
|
669
|
+
|
|
670
|
+
// ../core/src/worker-utils/lib/worker-utils/get-transfer-list.ts
|
|
671
|
+
function getTransferList2(object, recursive = true, transfers) {
|
|
672
|
+
const transfersSet = transfers || /* @__PURE__ */ new Set();
|
|
673
|
+
if (!object) {
|
|
674
|
+
} else if (isTransferable2(object)) {
|
|
675
|
+
transfersSet.add(object);
|
|
676
|
+
} else if (isTransferable2(object.buffer)) {
|
|
677
|
+
transfersSet.add(object.buffer);
|
|
678
|
+
} else if (ArrayBuffer.isView(object)) {
|
|
679
|
+
} else if (recursive && typeof object === "object") {
|
|
680
|
+
for (const key in object) {
|
|
681
|
+
getTransferList2(object[key], recursive, transfersSet);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
return transfers === void 0 ? Array.from(transfersSet) : [];
|
|
685
|
+
}
|
|
686
|
+
function isTransferable2(object) {
|
|
687
|
+
if (!object) {
|
|
688
|
+
return false;
|
|
689
|
+
}
|
|
690
|
+
if (object instanceof ArrayBuffer) {
|
|
691
|
+
return true;
|
|
692
|
+
}
|
|
693
|
+
if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
|
|
694
|
+
return true;
|
|
695
|
+
}
|
|
696
|
+
if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
|
|
697
|
+
return true;
|
|
698
|
+
}
|
|
699
|
+
if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
|
|
700
|
+
return true;
|
|
701
|
+
}
|
|
702
|
+
return false;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
// ../core/src/worker-utils/lib/worker-api/create-worker.ts
|
|
706
|
+
async function createWorker2(process2, processInBatches) {
|
|
707
|
+
if (!await isWorkerThread()) return;
|
|
708
|
+
await initializeTaskWorker2(createWorkerTask(process2, processInBatches));
|
|
709
|
+
}
|
|
710
|
+
function createWorkerTask(process2, processInBatches) {
|
|
711
|
+
return {
|
|
712
|
+
id: "loaders.gl",
|
|
713
|
+
initialize: (state) => state,
|
|
714
|
+
destroy: (state) => state.port?.close(),
|
|
715
|
+
process: async ({ value }, options, context) => {
|
|
716
|
+
if (!process2) throw new Error("Worker does not support atomic processing");
|
|
717
|
+
return { value: await process2(value, options, createContext(context), context.state.context) };
|
|
718
|
+
},
|
|
719
|
+
...processInBatches ? {
|
|
720
|
+
processInBatches: async function* (inputs, options, context) {
|
|
721
|
+
async function* values() {
|
|
722
|
+
for await (const input of inputs) yield input.value;
|
|
723
|
+
}
|
|
724
|
+
for await (const value of processInBatches(
|
|
725
|
+
values(),
|
|
726
|
+
options,
|
|
727
|
+
createContext(context),
|
|
728
|
+
context.state.context
|
|
729
|
+
)) {
|
|
730
|
+
yield { value };
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
} : {}
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
function createContext(context) {
|
|
737
|
+
let requestIdentifier = 0;
|
|
738
|
+
const port = context.state.port;
|
|
739
|
+
return {
|
|
740
|
+
signal: context.signal,
|
|
741
|
+
throwIfAborted: () => context.throwIfAborted(),
|
|
742
|
+
reportProgress: (progress) => context.reportProgress(normalizeTaskProgress(progress)),
|
|
743
|
+
process: port ? (input, options = {}, jobContext = {}) => {
|
|
744
|
+
context.throwIfAborted();
|
|
745
|
+
const identifier = ++requestIdentifier;
|
|
746
|
+
return new Promise((resolve, reject) => {
|
|
747
|
+
const onMessage = (event) => {
|
|
748
|
+
if (event.data.identifier !== identifier) return;
|
|
749
|
+
cleanup();
|
|
750
|
+
if (event.data.error) {
|
|
751
|
+
const error = new Error(event.data.error.message);
|
|
752
|
+
error.name = event.data.error.name;
|
|
753
|
+
reject(error);
|
|
754
|
+
} else resolve(event.data.value);
|
|
755
|
+
};
|
|
756
|
+
const onAbort = () => {
|
|
757
|
+
cleanup();
|
|
758
|
+
reject(context.signal.reason);
|
|
759
|
+
};
|
|
760
|
+
const cleanup = () => {
|
|
761
|
+
port.removeEventListener("message", onMessage);
|
|
762
|
+
context.signal.removeEventListener("abort", onAbort);
|
|
763
|
+
};
|
|
764
|
+
port.addEventListener("message", onMessage);
|
|
765
|
+
context.signal.addEventListener("abort", onAbort, { once: true });
|
|
766
|
+
port.start();
|
|
767
|
+
try {
|
|
768
|
+
const request = { identifier, input, options, context: jobContext };
|
|
769
|
+
port.postMessage(request, getTransferList2(request));
|
|
770
|
+
} catch (error) {
|
|
771
|
+
cleanup();
|
|
772
|
+
reject(error);
|
|
773
|
+
}
|
|
774
|
+
});
|
|
775
|
+
} : void 0
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
|
|
352
779
|
// ../core/src/loader-utils/lib/worker-loader-utils/create-loader-worker.ts
|
|
353
780
|
async function createLoaderWorker(loader, selectLoader = () => loader) {
|
|
354
|
-
await
|
|
781
|
+
await createWorker2(
|
|
355
782
|
(input, options, workerContext, loaderContext) => processLoaderWorkerData(
|
|
356
783
|
selectLoader(options || {}),
|
|
357
784
|
input,
|
|
@@ -12456,11 +12883,11 @@ return true;`);
|
|
|
12456
12883
|
this._offsets = new OffsetsBufferBuilder(opts.type);
|
|
12457
12884
|
}
|
|
12458
12885
|
setValue(index, value) {
|
|
12459
|
-
const
|
|
12460
|
-
const current =
|
|
12886
|
+
const pending2 = this._pending || (this._pending = /* @__PURE__ */ new Map());
|
|
12887
|
+
const current = pending2.get(index);
|
|
12461
12888
|
current && (this._pendingLength -= current.length);
|
|
12462
12889
|
this._pendingLength += value instanceof MapRow ? value[kKeys].length : value.length;
|
|
12463
|
-
|
|
12890
|
+
pending2.set(index, value);
|
|
12464
12891
|
}
|
|
12465
12892
|
setValid(index, isValid) {
|
|
12466
12893
|
if (!super.setValid(index, isValid)) {
|
|
@@ -12483,12 +12910,12 @@ return true;`);
|
|
|
12483
12910
|
return super.finish();
|
|
12484
12911
|
}
|
|
12485
12912
|
_flush() {
|
|
12486
|
-
const
|
|
12913
|
+
const pending2 = this._pending;
|
|
12487
12914
|
const pendingLength = this._pendingLength;
|
|
12488
12915
|
this._pendingLength = 0;
|
|
12489
12916
|
this._pending = void 0;
|
|
12490
|
-
if (
|
|
12491
|
-
this._flushPending(
|
|
12917
|
+
if (pending2 && pending2.size > 0) {
|
|
12918
|
+
this._flushPending(pending2, pendingLength);
|
|
12492
12919
|
}
|
|
12493
12920
|
return this;
|
|
12494
12921
|
}
|
|
@@ -14898,11 +15325,11 @@ return true;`);
|
|
|
14898
15325
|
setValue(index, value) {
|
|
14899
15326
|
return super.setValue(index, toUint8Array2(value));
|
|
14900
15327
|
}
|
|
14901
|
-
_flushPending(
|
|
15328
|
+
_flushPending(pending2, pendingLength) {
|
|
14902
15329
|
const offsets = this._offsets;
|
|
14903
15330
|
const data = this._values.reserve(pendingLength).buffer;
|
|
14904
15331
|
let offset = 0;
|
|
14905
|
-
for (const [index, value] of
|
|
15332
|
+
for (const [index, value] of pending2) {
|
|
14906
15333
|
if (value === void 0) {
|
|
14907
15334
|
offsets.set(index, 0);
|
|
14908
15335
|
} else {
|
|
@@ -14931,11 +15358,11 @@ return true;`);
|
|
|
14931
15358
|
setValue(index, value) {
|
|
14932
15359
|
return super.setValue(index, toUint8Array2(value));
|
|
14933
15360
|
}
|
|
14934
|
-
_flushPending(
|
|
15361
|
+
_flushPending(pending2, pendingLength) {
|
|
14935
15362
|
const offsets = this._offsets;
|
|
14936
15363
|
const data = this._values.reserve(pendingLength).buffer;
|
|
14937
15364
|
let offset = 0;
|
|
14938
|
-
for (const [index, value] of
|
|
15365
|
+
for (const [index, value] of pending2) {
|
|
14939
15366
|
if (value === void 0) {
|
|
14940
15367
|
offsets.set(index, BigInt(0));
|
|
14941
15368
|
} else {
|
|
@@ -15166,10 +15593,10 @@ return true;`);
|
|
|
15166
15593
|
this.type = new List2(new Field2(name, child.type, true));
|
|
15167
15594
|
return this.numChildren - 1;
|
|
15168
15595
|
}
|
|
15169
|
-
_flushPending(
|
|
15596
|
+
_flushPending(pending2) {
|
|
15170
15597
|
const offsets = this._offsets;
|
|
15171
15598
|
const [child] = this.children;
|
|
15172
|
-
for (const [index, value] of
|
|
15599
|
+
for (const [index, value] of pending2) {
|
|
15173
15600
|
if (typeof value === "undefined") {
|
|
15174
15601
|
offsets.set(index, 0);
|
|
15175
15602
|
} else {
|
|
@@ -15198,10 +15625,10 @@ return true;`);
|
|
|
15198
15625
|
this.type = new LargeList2(new Field2(name, child.type, true));
|
|
15199
15626
|
return this.numChildren - 1;
|
|
15200
15627
|
}
|
|
15201
|
-
_flushPending(
|
|
15628
|
+
_flushPending(pending2) {
|
|
15202
15629
|
const offsets = this._offsets;
|
|
15203
15630
|
const [child] = this.children;
|
|
15204
|
-
for (const [index, value] of
|
|
15631
|
+
for (const [index, value] of pending2) {
|
|
15205
15632
|
if (typeof value === "undefined") {
|
|
15206
15633
|
offsets.set(index, BigInt(0));
|
|
15207
15634
|
} else {
|
|
@@ -15223,11 +15650,11 @@ return true;`);
|
|
|
15223
15650
|
}
|
|
15224
15651
|
setValue(index, value) {
|
|
15225
15652
|
const row = value instanceof Map ? value : new Map(Object.entries(value));
|
|
15226
|
-
const
|
|
15227
|
-
const current =
|
|
15653
|
+
const pending2 = this._pending || (this._pending = /* @__PURE__ */ new Map());
|
|
15654
|
+
const current = pending2.get(index);
|
|
15228
15655
|
current && (this._pendingLength -= current.size);
|
|
15229
15656
|
this._pendingLength += row.size;
|
|
15230
|
-
|
|
15657
|
+
pending2.set(index, row);
|
|
15231
15658
|
}
|
|
15232
15659
|
addChild(child, name = `${this.numChildren}`) {
|
|
15233
15660
|
if (this.numChildren > 0) {
|
|
@@ -15237,10 +15664,10 @@ return true;`);
|
|
|
15237
15664
|
this.type = new Map_(new Field2(name, child.type, true), this.type.keysSorted);
|
|
15238
15665
|
return this.numChildren - 1;
|
|
15239
15666
|
}
|
|
15240
|
-
_flushPending(
|
|
15667
|
+
_flushPending(pending2) {
|
|
15241
15668
|
const offsets = this._offsets;
|
|
15242
15669
|
const [child] = this.children;
|
|
15243
|
-
for (const [index, value] of
|
|
15670
|
+
for (const [index, value] of pending2) {
|
|
15244
15671
|
if (value === void 0) {
|
|
15245
15672
|
offsets.set(index, 0);
|
|
15246
15673
|
} else {
|
|
@@ -15403,7 +15830,7 @@ return true;`);
|
|
|
15403
15830
|
return super.setValue(index, encodeUtf8(value));
|
|
15404
15831
|
}
|
|
15405
15832
|
// @ts-ignore
|
|
15406
|
-
_flushPending(
|
|
15833
|
+
_flushPending(pending2, pendingLength) {
|
|
15407
15834
|
}
|
|
15408
15835
|
};
|
|
15409
15836
|
Utf8Builder.prototype._flushPending = BinaryBuilder.prototype._flushPending;
|
|
@@ -15425,7 +15852,7 @@ return true;`);
|
|
|
15425
15852
|
return super.setValue(index, encodeUtf8(value));
|
|
15426
15853
|
}
|
|
15427
15854
|
// @ts-ignore
|
|
15428
|
-
_flushPending(
|
|
15855
|
+
_flushPending(pending2, pendingLength) {
|
|
15429
15856
|
}
|
|
15430
15857
|
};
|
|
15431
15858
|
LargeUtf8Builder.prototype._flushPending = LargeBinaryBuilder.prototype._flushPending;
|
|
@@ -19838,7 +20265,7 @@ return true;`);
|
|
|
19838
20265
|
};
|
|
19839
20266
|
|
|
19840
20267
|
// src/las/las-loader-shared.ts
|
|
19841
|
-
var VERSION = true ? "5.0.0-beta.
|
|
20268
|
+
var VERSION = true ? "5.0.0-beta.4" : "latest";
|
|
19842
20269
|
var DEFAULT_LAS_SHAPE = "arrow-table";
|
|
19843
20270
|
function getLASShape(options) {
|
|
19844
20271
|
return options?.las?.shape || DEFAULT_LAS_SHAPE;
|
|
@@ -20238,7 +20665,12 @@ return true;`);
|
|
|
20238
20665
|
return attributes;
|
|
20239
20666
|
}
|
|
20240
20667
|
function readLASString(bytes, offset, length) {
|
|
20241
|
-
|
|
20668
|
+
const decoded = new TextDecoder().decode(bytes.subarray(offset, offset + length));
|
|
20669
|
+
let end = decoded.length;
|
|
20670
|
+
while (end > 0 && decoded[end - 1] === "\0") {
|
|
20671
|
+
end--;
|
|
20672
|
+
}
|
|
20673
|
+
return decoded.slice(0, end).trim();
|
|
20242
20674
|
}
|
|
20243
20675
|
function sanitizeExtraBytesName(name) {
|
|
20244
20676
|
return name.trim().replace(/[^A-Za-z0-9_]+/g, "_");
|
|
@@ -20484,7 +20916,7 @@ return true;`);
|
|
|
20484
20916
|
async function* parseLASInBatches(arrayBufferIterator, options = {}) {
|
|
20485
20917
|
const batchSize = getBatchSize(options);
|
|
20486
20918
|
const inputIterator = toAsyncIterator(arrayBufferIterator);
|
|
20487
|
-
let
|
|
20919
|
+
let pending2 = new Uint8Array(0);
|
|
20488
20920
|
let absoluteOffset = 0;
|
|
20489
20921
|
let header = null;
|
|
20490
20922
|
let sourcePointIndex = 0;
|
|
@@ -20495,9 +20927,9 @@ return true;`);
|
|
|
20495
20927
|
break;
|
|
20496
20928
|
}
|
|
20497
20929
|
const chunk = next.value;
|
|
20498
|
-
|
|
20930
|
+
pending2 = concatenateUint8Arrays2(pending2, toUint8Array3(chunk));
|
|
20499
20931
|
if (!header) {
|
|
20500
|
-
header = tryParseHeader(
|
|
20932
|
+
header = tryParseHeader(pending2, absoluteOffset);
|
|
20501
20933
|
if (header) {
|
|
20502
20934
|
header.totalToRead = header.pointsCount;
|
|
20503
20935
|
}
|
|
@@ -20506,11 +20938,11 @@ return true;`);
|
|
|
20506
20938
|
continue;
|
|
20507
20939
|
}
|
|
20508
20940
|
if (header.isCompressed) {
|
|
20509
|
-
yield* parseLAZInBatches(
|
|
20941
|
+
yield* parseLAZInBatches(pending2, inputIterator, header, options);
|
|
20510
20942
|
return;
|
|
20511
20943
|
}
|
|
20512
20944
|
for (const batch of readAvailablePointBatches(
|
|
20513
|
-
|
|
20945
|
+
pending2,
|
|
20514
20946
|
absoluteOffset,
|
|
20515
20947
|
header,
|
|
20516
20948
|
sourcePointIndex,
|
|
@@ -20519,7 +20951,7 @@ return true;`);
|
|
|
20519
20951
|
)) {
|
|
20520
20952
|
sourcePointIndex = batch.sourcePointIndex;
|
|
20521
20953
|
totalRead = batch.totalRead;
|
|
20522
|
-
|
|
20954
|
+
pending2 = batch.pending;
|
|
20523
20955
|
absoluteOffset = batch.absoluteOffset;
|
|
20524
20956
|
yield parseLASArrowTableBatch(batch.arrayBuffer, batch.header, options);
|
|
20525
20957
|
}
|
|
@@ -20703,11 +21135,11 @@ return true;`);
|
|
|
20703
21135
|
);
|
|
20704
21136
|
}
|
|
20705
21137
|
async function* parseLAZInBatches(initialPending, inputIterator, header, options) {
|
|
20706
|
-
const { pending, laszip } = await readLASZipVLRFromInput(initialPending, inputIterator, header);
|
|
21138
|
+
const { pending: pending2, laszip } = await readLASZipVLRFromInput(initialPending, inputIterator, header);
|
|
20707
21139
|
validateTypeScriptLAZSupport(header, laszip);
|
|
20708
21140
|
if (!laszip.variableChunks && header.pointsFormatId <= 5) {
|
|
20709
21141
|
yield* parsePendingFixedLegacyLAZFileInArrowBatches(
|
|
20710
|
-
|
|
21142
|
+
pending2,
|
|
20711
21143
|
inputIterator,
|
|
20712
21144
|
header,
|
|
20713
21145
|
laszip,
|
|
@@ -20716,11 +21148,11 @@ return true;`);
|
|
|
20716
21148
|
return;
|
|
20717
21149
|
}
|
|
20718
21150
|
if (!laszip.variableChunks && header.pointsFormatId >= 6 && header.pointsFormatId <= 10) {
|
|
20719
|
-
yield* parsePendingLAZFileInArrowBatches(
|
|
21151
|
+
yield* parsePendingLAZFileInArrowBatches(pending2, inputIterator, header, laszip, options);
|
|
20720
21152
|
return;
|
|
20721
21153
|
}
|
|
20722
21154
|
for await (const batch of decodeLAZFileWithParsedVLRInBatches(
|
|
20723
|
-
|
|
21155
|
+
pending2,
|
|
20724
21156
|
inputIterator,
|
|
20725
21157
|
header,
|
|
20726
21158
|
laszip,
|
|
@@ -21921,10 +22353,10 @@ return true;`);
|
|
|
21921
22353
|
}
|
|
21922
22354
|
}
|
|
21923
22355
|
async function readLASZipVLRFromInput(initialPending, inputIterator, header) {
|
|
21924
|
-
let
|
|
22356
|
+
let pending2 = initialPending;
|
|
21925
22357
|
while (true) {
|
|
21926
22358
|
try {
|
|
21927
|
-
return { pending, laszip: parseLASZipVLR(
|
|
22359
|
+
return { pending: pending2, laszip: parseLASZipVLR(pending2, header) };
|
|
21928
22360
|
} catch (error) {
|
|
21929
22361
|
if (!(error instanceof NeedsMoreData)) {
|
|
21930
22362
|
throw error;
|
|
@@ -21934,7 +22366,7 @@ return true;`);
|
|
|
21934
22366
|
if (next.done) {
|
|
21935
22367
|
throw new NeedsMoreData("LASLoader: incomplete LASzip VLR");
|
|
21936
22368
|
}
|
|
21937
|
-
|
|
22369
|
+
pending2 = concatenateUint8Arrays2(pending2, toUint8Array3(next.value));
|
|
21938
22370
|
}
|
|
21939
22371
|
}
|
|
21940
22372
|
async function collectRemainingInputBytes(initialPending, inputIterator) {
|
|
@@ -22858,10 +23290,10 @@ return true;`);
|
|
|
22858
23290
|
[maximum[0], maximum[1], maximum[2]]
|
|
22859
23291
|
];
|
|
22860
23292
|
}
|
|
22861
|
-
function* readAvailablePointBatches(
|
|
23293
|
+
function* readAvailablePointBatches(pending2, absoluteOffset, header, sourcePointIndex, totalRead, batchSize) {
|
|
22862
23294
|
while (sourcePointIndex < header.pointsCount && totalRead < header.totalToRead) {
|
|
22863
23295
|
const batch = readAvailableContiguousPointBatch(
|
|
22864
|
-
|
|
23296
|
+
pending2,
|
|
22865
23297
|
absoluteOffset,
|
|
22866
23298
|
header,
|
|
22867
23299
|
sourcePointIndex,
|
|
@@ -22871,25 +23303,25 @@ return true;`);
|
|
|
22871
23303
|
if (!batch) {
|
|
22872
23304
|
return;
|
|
22873
23305
|
}
|
|
22874
|
-
|
|
23306
|
+
pending2 = batch.pending;
|
|
22875
23307
|
absoluteOffset = batch.absoluteOffset;
|
|
22876
23308
|
sourcePointIndex = batch.sourcePointIndex;
|
|
22877
23309
|
totalRead = batch.totalRead;
|
|
22878
23310
|
yield batch;
|
|
22879
23311
|
}
|
|
22880
23312
|
}
|
|
22881
|
-
function readAvailableContiguousPointBatch(
|
|
23313
|
+
function readAvailableContiguousPointBatch(pending2, absoluteOffset, header, sourcePointIndex, totalRead, batchSize) {
|
|
22882
23314
|
const pointRecordLength = header.pointsStructSize;
|
|
22883
23315
|
const pointAbsoluteOffset = header.pointsOffset + sourcePointIndex * pointRecordLength;
|
|
22884
23316
|
const pointPendingOffset = pointAbsoluteOffset - absoluteOffset;
|
|
22885
23317
|
if (pointPendingOffset < 0) {
|
|
22886
23318
|
throw new Error("LASLoader: invalid streaming point offset");
|
|
22887
23319
|
}
|
|
22888
|
-
if (pointPendingOffset + pointRecordLength >
|
|
23320
|
+
if (pointPendingOffset + pointRecordLength > pending2.byteLength) {
|
|
22889
23321
|
return null;
|
|
22890
23322
|
}
|
|
22891
23323
|
const availablePointCount = Math.floor(
|
|
22892
|
-
(
|
|
23324
|
+
(pending2.byteLength - pointPendingOffset) / pointRecordLength
|
|
22893
23325
|
);
|
|
22894
23326
|
const batchPointCount = Math.min(
|
|
22895
23327
|
batchSize,
|
|
@@ -22904,38 +23336,38 @@ return true;`);
|
|
|
22904
23336
|
totalRead += batchPointCount;
|
|
22905
23337
|
const batchHeader = {
|
|
22906
23338
|
...header,
|
|
22907
|
-
pointsOffset:
|
|
23339
|
+
pointsOffset: pending2.byteOffset + pointPendingOffset,
|
|
22908
23340
|
pointsCount: batchPointCount,
|
|
22909
23341
|
totalRead
|
|
22910
23342
|
};
|
|
22911
23343
|
const nextPointOffset = header.pointsOffset + sourcePointIndex * pointRecordLength;
|
|
22912
23344
|
const discardByteCount = Math.max(
|
|
22913
23345
|
0,
|
|
22914
|
-
Math.min(
|
|
23346
|
+
Math.min(pending2.byteLength, nextPointOffset - absoluteOffset)
|
|
22915
23347
|
);
|
|
22916
23348
|
return {
|
|
22917
|
-
arrayBuffer:
|
|
23349
|
+
arrayBuffer: pending2.buffer,
|
|
22918
23350
|
header: batchHeader,
|
|
22919
|
-
pending:
|
|
23351
|
+
pending: pending2.subarray(discardByteCount),
|
|
22920
23352
|
absoluteOffset: absoluteOffset + discardByteCount,
|
|
22921
23353
|
sourcePointIndex,
|
|
22922
23354
|
totalRead
|
|
22923
23355
|
};
|
|
22924
23356
|
}
|
|
22925
|
-
function tryParseHeader(
|
|
22926
|
-
if (absoluteOffset !== 0 ||
|
|
23357
|
+
function tryParseHeader(pending2, absoluteOffset) {
|
|
23358
|
+
if (absoluteOffset !== 0 || pending2.byteLength < 227) {
|
|
22927
23359
|
return null;
|
|
22928
23360
|
}
|
|
22929
|
-
const dataView = new DataView(
|
|
23361
|
+
const dataView = new DataView(pending2.buffer, pending2.byteOffset, pending2.byteLength);
|
|
22930
23362
|
if (dataView.getUint32(0, true) !== LASF_SIGNATURE) {
|
|
22931
23363
|
throw new Error("LASLoader: invalid LAS header");
|
|
22932
23364
|
}
|
|
22933
23365
|
const headerLength = dataView.getUint32(96, true);
|
|
22934
|
-
if (
|
|
23366
|
+
if (pending2.byteLength < Math.max(headerLength, 255)) {
|
|
22935
23367
|
return null;
|
|
22936
23368
|
}
|
|
22937
23369
|
const header = parseLASHeader(
|
|
22938
|
-
|
|
23370
|
+
pending2.buffer.slice(pending2.byteOffset, pending2.byteOffset + pending2.byteLength)
|
|
22939
23371
|
);
|
|
22940
23372
|
return header;
|
|
22941
23373
|
}
|