@loaders.gl/raster 5.0.0-alpha.14 → 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/LICENSE +2 -30
- package/README.md +13 -4
- package/THIRD-PARTY-NOTICES.md +21 -0
- package/dist/geotiff/advanced.cjs +153 -105
- package/dist/geotiff/advanced.cjs.map +4 -4
- package/dist/geotiff/advanced.d.ts +4 -3
- package/dist/geotiff/advanced.d.ts.map +1 -1
- package/dist/geotiff/advanced.js +3 -2
- package/dist/geotiff/advanced.js.map +1 -1
- package/dist/geotiff/geotiff-loader-types.d.ts +14 -3
- package/dist/geotiff/geotiff-loader-types.d.ts.map +1 -1
- package/dist/geotiff/geotiff-loader-types.js +12 -2
- package/dist/geotiff/geotiff-loader-types.js.map +1 -1
- package/dist/geotiff/geotiff-loader.d.ts +9 -8
- package/dist/geotiff/geotiff-loader.d.ts.map +1 -1
- package/dist/geotiff/geotiff-loader.js +2 -0
- package/dist/geotiff/geotiff-loader.js.map +1 -1
- package/dist/geotiff/geotiff-raster-loader-types.d.ts.map +1 -1
- package/dist/geotiff/geotiff-raster-loader-types.js +2 -2
- package/dist/geotiff/geotiff-raster-loader-types.js.map +1 -1
- package/dist/geotiff/geotiff-source-loader.d.ts +2 -34
- package/dist/geotiff/geotiff-source-loader.d.ts.map +1 -1
- package/dist/geotiff/geotiff-source-loader.js +14 -36
- package/dist/geotiff/geotiff-source-loader.js.map +1 -1
- package/dist/geotiff/lib/ome/load-ome-tiff.d.ts +1 -0
- package/dist/geotiff/lib/ome/load-ome-tiff.d.ts.map +1 -1
- package/dist/geotiff/lib/ome/load-ome-tiff.js +7 -1
- package/dist/geotiff/lib/ome/load-ome-tiff.js.map +1 -1
- package/dist/geotiff/lib/ome/omexml.d.ts.map +1 -1
- package/dist/geotiff/lib/ome/omexml.js +5 -4
- package/dist/geotiff/lib/ome/omexml.js.map +1 -1
- package/dist/geotiff/lib/tiff/tiff-gdal-metadata.d.ts.map +1 -1
- package/dist/geotiff/lib/tiff/tiff-gdal-metadata.js +6 -5
- package/dist/geotiff/lib/tiff/tiff-gdal-metadata.js.map +1 -1
- package/dist/geotiff/lib/tiff-pixel-source.d.ts.map +1 -1
- package/dist/geotiff/lib/tiff-pixel-source.js +2 -1
- package/dist/geotiff/lib/tiff-pixel-source.js.map +1 -1
- package/dist/geotiff/loaders.js +1 -1
- package/dist/geotiff/loaders.js.map +1 -1
- package/dist/geotiff/{ometiff-source-loader-types.d.ts → ometiff-loader-types.d.ts} +7 -7
- package/dist/geotiff/ometiff-loader-types.d.ts.map +1 -0
- package/dist/geotiff/{ometiff-source-loader-types.js → ometiff-loader-types.js} +6 -6
- package/dist/geotiff/ometiff-loader-types.js.map +1 -0
- package/dist/geotiff/{ometiff-source-loader.d.ts → ometiff-loader.d.ts} +6 -6
- package/dist/geotiff/ometiff-loader.d.ts.map +1 -0
- package/dist/geotiff/{ometiff-source-loader.js → ometiff-loader.js} +5 -5
- package/dist/geotiff/ometiff-loader.js.map +1 -0
- package/dist/geotiff-loader-types.d.ts +2 -0
- package/dist/geotiff-loader-types.d.ts.map +1 -0
- package/dist/geotiff-loader-types.js +2 -0
- package/dist/geotiff-loader-types.js.map +1 -0
- package/dist/geotiff-loader.d.ts +2 -0
- package/dist/geotiff-loader.d.ts.map +1 -0
- package/dist/geotiff-loader.js +2 -0
- package/dist/geotiff-loader.js.map +1 -0
- package/dist/geotiff-raster-loader-types.d.ts +2 -0
- package/dist/geotiff-raster-loader-types.d.ts.map +1 -0
- package/dist/geotiff-raster-loader-types.js +2 -0
- package/dist/geotiff-raster-loader-types.js.map +1 -0
- package/dist/geotiff-raster-loader.d.ts +2 -0
- package/dist/geotiff-raster-loader.d.ts.map +1 -0
- package/dist/geotiff-raster-loader.js +2 -0
- package/dist/geotiff-raster-loader.js.map +1 -0
- package/dist/geotiff-source-loader.d.ts +2 -0
- package/dist/geotiff-source-loader.d.ts.map +1 -0
- package/dist/geotiff-source-loader.js +2 -0
- package/dist/geotiff-source-loader.js.map +1 -0
- package/dist/index.cjs +37 -67
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +4 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -6
- package/dist/index.js.map +1 -1
- package/dist/lerc/lerc-loader-types.d.ts +1 -1
- package/dist/lerc/lerc-loader-types.js +2 -2
- package/dist/lerc/lerc-loader-types.js.map +1 -1
- package/dist/lerc-loader-types.d.ts +2 -0
- package/dist/lerc-loader-types.d.ts.map +1 -0
- package/dist/lerc-loader-types.js +2 -0
- package/dist/lerc-loader-types.js.map +1 -0
- package/dist/lerc-loader.d.ts +2 -0
- package/dist/lerc-loader.d.ts.map +1 -0
- package/dist/lerc-loader.js +2 -0
- package/dist/lerc-loader.js.map +1 -0
- package/dist/ometiff-loader-types.d.ts +2 -0
- package/dist/ometiff-loader-types.d.ts.map +1 -0
- package/dist/ometiff-loader-types.js +2 -0
- package/dist/ometiff-loader-types.js.map +1 -0
- package/dist/ometiff-loader.d.ts +2 -0
- package/dist/ometiff-loader.d.ts.map +1 -0
- package/dist/ometiff-loader.js +2 -0
- package/dist/ometiff-loader.js.map +1 -0
- package/dist/quantized-mesh-loader-types.d.ts +2 -0
- package/dist/quantized-mesh-loader-types.d.ts.map +1 -0
- package/dist/quantized-mesh-loader-types.js +2 -0
- package/dist/quantized-mesh-loader-types.js.map +1 -0
- package/dist/quantized-mesh-loader.d.ts +2 -0
- package/dist/quantized-mesh-loader.d.ts.map +1 -0
- package/dist/quantized-mesh-loader.js +2 -0
- package/dist/quantized-mesh-loader.js.map +1 -0
- package/dist/quantized-mesh-worker.js +1955 -1010
- package/dist/quantized-mesh-writer.d.ts +2 -0
- package/dist/quantized-mesh-writer.d.ts.map +1 -0
- package/dist/quantized-mesh-writer.js +2 -0
- package/dist/quantized-mesh-writer.js.map +1 -0
- package/dist/terrain/heightmap.cjs +2 -333
- package/dist/terrain/heightmap.cjs.map +4 -4
- package/dist/terrain/heightmap.d.ts +1 -5
- package/dist/terrain/heightmap.d.ts.map +1 -1
- package/dist/terrain/heightmap.js +0 -3
- package/dist/terrain/heightmap.js.map +1 -1
- package/dist/terrain/index.cjs +74 -612
- package/dist/terrain/index.cjs.map +4 -4
- package/dist/terrain/index.d.ts +3 -6
- package/dist/terrain/index.d.ts.map +1 -1
- package/dist/terrain/index.js +2 -5
- package/dist/terrain/index.js.map +1 -1
- package/dist/terrain/lib/helpers/skirt.d.ts +2 -9
- package/dist/terrain/lib/helpers/skirt.d.ts.map +1 -1
- package/dist/terrain/lib/helpers/skirt.js +30 -114
- package/dist/terrain/lib/helpers/skirt.js.map +1 -1
- package/dist/terrain/lib/parse-terrain.d.ts +2 -0
- package/dist/terrain/lib/parse-terrain.d.ts.map +1 -1
- package/dist/terrain/lib/parse-terrain.js +23 -38
- package/dist/terrain/lib/parse-terrain.js.map +1 -1
- package/dist/terrain/lib/terrain-contracts.d.ts +0 -15
- package/dist/terrain/lib/terrain-contracts.d.ts.map +1 -1
- package/dist/terrain/lib/utils/version.js +1 -1
- package/dist/terrain/lib/utils/version.js.map +1 -1
- package/dist/terrain/quantized-mesh-loader-types.d.ts +1 -1
- package/dist/terrain/quantized-mesh-loader-types.d.ts.map +1 -1
- package/dist/terrain/quantized-mesh-loader-types.js +4 -3
- package/dist/terrain/quantized-mesh-loader-types.js.map +1 -1
- package/dist/terrain/quantized-mesh-loader.d.ts.map +1 -1
- package/dist/terrain/quantized-mesh-loader.js +5 -5
- package/dist/terrain/quantized-mesh-loader.js.map +1 -1
- package/dist/terrain/quantized-mesh-writer.d.ts +4 -3
- package/dist/terrain/quantized-mesh-writer.d.ts.map +1 -1
- package/dist/terrain/quantized-mesh-writer.js +3 -3
- package/dist/terrain/quantized-mesh-writer.js.map +1 -1
- package/dist/terrain/terrain-loader-types.d.ts +3 -3
- package/dist/terrain/terrain-loader-types.d.ts.map +1 -1
- package/dist/terrain/terrain-loader-types.js +4 -2
- package/dist/terrain/terrain-loader-types.js.map +1 -1
- package/dist/terrain/terrain-loader.d.ts +3 -2
- package/dist/terrain/terrain-loader.d.ts.map +1 -1
- package/dist/terrain/terrain-loader.js +8 -8
- package/dist/terrain/terrain-loader.js.map +1 -1
- package/dist/terrain-loader-types.d.ts +2 -0
- package/dist/terrain-loader-types.d.ts.map +1 -0
- package/dist/terrain-loader-types.js +2 -0
- package/dist/terrain-loader-types.js.map +1 -0
- package/dist/terrain-loader.d.ts +2 -0
- package/dist/terrain-loader.d.ts.map +1 -0
- package/dist/terrain-loader.js +2 -0
- package/dist/terrain-loader.js.map +1 -0
- package/dist/terrain-worker.js +5724 -3314
- package/package.json +82 -68
- package/src/geotiff/advanced.ts +9 -4
- package/src/geotiff/geotiff-loader-types.ts +13 -4
- package/src/geotiff/geotiff-loader.ts +5 -8
- package/src/geotiff/geotiff-raster-loader-types.ts +1 -3
- package/src/geotiff/geotiff-source-loader.ts +19 -45
- package/src/geotiff/lib/ome/load-ome-tiff.ts +7 -1
- package/src/geotiff/lib/ome/omexml.ts +5 -4
- package/src/geotiff/lib/tiff/tiff-gdal-metadata.ts +6 -5
- package/src/geotiff/lib/tiff-pixel-source.ts +2 -1
- package/src/geotiff/{ometiff-source-loader-types.ts → ometiff-loader-types.ts} +6 -7
- package/src/geotiff/{ometiff-source-loader.ts → ometiff-loader.ts} +6 -8
- package/src/geotiff-loader-types.ts +1 -0
- package/src/geotiff-loader.ts +1 -0
- package/src/geotiff-raster-loader-types.ts +1 -0
- package/src/geotiff-raster-loader.ts +1 -0
- package/src/geotiff-source-loader.ts +1 -0
- package/src/index.ts +4 -15
- package/src/lerc/lerc-loader-types.ts +1 -1
- package/src/lerc-loader-types.ts +1 -0
- package/src/lerc-loader.ts +1 -0
- package/src/ometiff-loader-types.ts +1 -0
- package/src/ometiff-loader.ts +1 -0
- package/src/quantized-mesh-loader-types.ts +1 -0
- package/src/quantized-mesh-loader.ts +1 -0
- package/src/quantized-mesh-writer.ts +1 -0
- package/src/terrain/heightmap.ts +0 -10
- package/src/terrain/index.ts +2 -13
- package/src/terrain/lib/helpers/skirt.ts +41 -151
- package/src/terrain/lib/parse-terrain.ts +36 -40
- package/src/terrain/lib/terrain-contracts.ts +0 -19
- package/src/terrain/quantized-mesh-loader-types.ts +9 -7
- package/src/terrain/quantized-mesh-loader.ts +9 -8
- package/src/terrain/quantized-mesh-writer.ts +12 -7
- package/src/terrain/terrain-loader-types.ts +11 -9
- package/src/terrain/terrain-loader.ts +12 -11
- package/src/terrain-loader-types.ts +1 -0
- package/src/terrain-loader.ts +1 -0
- package/{dist/terrain/libs/martini-LICENSE → third-party-licenses/delatin-LICENSE} +1 -1
- package/dist/geotiff/geotiff-source-loader-types.d.ts +0 -67
- package/dist/geotiff/geotiff-source-loader-types.d.ts.map +0 -1
- package/dist/geotiff/geotiff-source-loader-types.js +0 -43
- package/dist/geotiff/geotiff-source-loader-types.js.map +0 -1
- package/dist/geotiff/ometiff-source-loader-types.d.ts.map +0 -1
- package/dist/geotiff/ometiff-source-loader-types.js.map +0 -1
- package/dist/geotiff/ometiff-source-loader.d.ts.map +0 -1
- package/dist/geotiff/ometiff-source-loader.js.map +0 -1
- package/dist/terrain/lib/terrain-height-field.d.ts +0 -51
- package/dist/terrain/lib/terrain-height-field.d.ts.map +0 -1
- package/dist/terrain/lib/terrain-height-field.js +0 -260
- package/dist/terrain/lib/terrain-height-field.js.map +0 -1
- package/dist/terrain/lib/terrain-height-grid.d.ts +0 -14
- package/dist/terrain/lib/terrain-height-grid.d.ts.map +0 -1
- package/dist/terrain/lib/terrain-height-grid.js +0 -104
- package/dist/terrain/lib/terrain-height-grid.js.map +0 -1
- package/dist/terrain/lib/terrain-neighborhood.d.ts +0 -15
- package/dist/terrain/lib/terrain-neighborhood.d.ts.map +0 -1
- package/dist/terrain/lib/terrain-neighborhood.js +0 -58
- package/dist/terrain/lib/terrain-neighborhood.js.map +0 -1
- package/dist/terrain/libs/README.md +0 -10
- package/dist/terrain/libs/martini.d.mts +0 -19
- package/dist/terrain/libs/martini.mjs +0 -164
- package/src/geotiff/geotiff-source-loader-types.ts +0 -55
- package/src/terrain/lib/terrain-height-field.ts +0 -355
- package/src/terrain/lib/terrain-height-grid.ts +0 -157
- package/src/terrain/lib/terrain-neighborhood.ts +0 -69
- package/src/terrain/libs/README.md +0 -10
- package/src/terrain/libs/martini-LICENSE +0 -15
- package/src/terrain/libs/martini.d.mts +0 -19
- package/src/terrain/libs/martini.mjs +0 -164
|
@@ -16,563 +16,255 @@
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
// ../core/src/worker-utils/lib/node/worker_threads-browser.ts
|
|
19
|
-
var
|
|
19
|
+
var worker_threads_browser_exports = {};
|
|
20
|
+
__export(worker_threads_browser_exports, {
|
|
21
|
+
NodeWorker: () => NodeWorker,
|
|
22
|
+
parentPort: () => parentPort2
|
|
23
|
+
});
|
|
24
|
+
var NodeWorker, parentPort2;
|
|
20
25
|
var init_worker_threads_browser = __esm({
|
|
21
26
|
"../core/src/worker-utils/lib/node/worker_threads-browser.ts"() {
|
|
22
27
|
"use strict";
|
|
23
|
-
|
|
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;
|
|
24
42
|
}
|
|
25
43
|
});
|
|
26
44
|
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} else if (ArrayBuffer.isView(object)) {
|
|
36
|
-
} else if (recursive && typeof object === "object") {
|
|
37
|
-
for (const key in object) {
|
|
38
|
-
getTransferList(object[key], recursive, transfersSet);
|
|
39
|
-
}
|
|
45
|
+
// ../../node_modules/@math.gl/core/dist/lib/math-utils.js
|
|
46
|
+
var PI_OVER_TWO, PI_OVER_FOUR, PI_OVER_SIX, TWO_PI;
|
|
47
|
+
var init_math_utils = __esm({
|
|
48
|
+
"../../node_modules/@math.gl/core/dist/lib/math-utils.js"() {
|
|
49
|
+
PI_OVER_TWO = Math.PI / 2;
|
|
50
|
+
PI_OVER_FOUR = Math.PI / 4;
|
|
51
|
+
PI_OVER_SIX = Math.PI / 6;
|
|
52
|
+
TWO_PI = Math.PI * 2;
|
|
40
53
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// ../../node_modules/@math.gl/core/dist/gl-matrix/vec2.js
|
|
57
|
+
var init_vec2 = __esm({
|
|
58
|
+
"../../node_modules/@math.gl/core/dist/gl-matrix/vec2.js"() {
|
|
46
59
|
}
|
|
47
|
-
|
|
48
|
-
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// ../../node_modules/@math.gl/core/dist/gl-matrix/vec3.js
|
|
63
|
+
var init_vec3 = __esm({
|
|
64
|
+
"../../node_modules/@math.gl/core/dist/gl-matrix/vec3.js"() {
|
|
49
65
|
}
|
|
50
|
-
|
|
51
|
-
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// ../../node_modules/@math.gl/core/dist/gl-matrix/mat3.js
|
|
69
|
+
var init_mat3 = __esm({
|
|
70
|
+
"../../node_modules/@math.gl/core/dist/gl-matrix/mat3.js"() {
|
|
52
71
|
}
|
|
53
|
-
|
|
54
|
-
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// ../../node_modules/@math.gl/core/dist/gl-matrix/mat4.js
|
|
75
|
+
var init_mat4 = __esm({
|
|
76
|
+
"../../node_modules/@math.gl/core/dist/gl-matrix/mat4.js"() {
|
|
55
77
|
}
|
|
56
|
-
|
|
57
|
-
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// ../../node_modules/@math.gl/core/dist/gl-matrix/vec4.js
|
|
81
|
+
var init_vec4 = __esm({
|
|
82
|
+
"../../node_modules/@math.gl/core/dist/gl-matrix/vec4.js"() {
|
|
58
83
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// ../../node_modules/@math.gl/core/dist/gl-matrix/quat.js
|
|
87
|
+
var init_quat = __esm({
|
|
88
|
+
"../../node_modules/@math.gl/core/dist/gl-matrix/quat.js"() {
|
|
64
89
|
}
|
|
65
90
|
});
|
|
66
91
|
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
return
|
|
92
|
+
// ../../node_modules/@math.gl/core/dist/types/float16.js
|
|
93
|
+
function getFloat16ArrayConstructor() {
|
|
94
|
+
return NativeFloat16ArrayConstructor ?? Uint16Array;
|
|
70
95
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
96
|
+
var NativeFloat16ArrayConstructor;
|
|
97
|
+
var init_float16 = __esm({
|
|
98
|
+
"../../node_modules/@math.gl/core/dist/types/float16.js"() {
|
|
99
|
+
NativeFloat16ArrayConstructor = globalThis.Float16Array;
|
|
74
100
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
var
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"use strict";
|
|
82
|
-
init_get_transfer_list();
|
|
83
|
-
init_worker_threads_browser();
|
|
84
|
-
onMessageWrapperMap = /* @__PURE__ */ new Map();
|
|
85
|
-
WorkerBody = class {
|
|
86
|
-
/** Check that we are actually in a worker thread */
|
|
87
|
-
static async inWorkerThread() {
|
|
88
|
-
return typeof self !== "undefined" || Boolean(await getParentPort());
|
|
89
|
-
}
|
|
90
|
-
/*
|
|
91
|
-
* (type: WorkerMessageType, payload: WorkerMessagePayload) => any
|
|
92
|
-
*/
|
|
93
|
-
static set onmessage(onMessage) {
|
|
94
|
-
async function handleMessage(message) {
|
|
95
|
-
const parentPort2 = await getParentPort();
|
|
96
|
-
const { type, payload } = parentPort2 ? message : message.data;
|
|
97
|
-
onMessage(type, payload);
|
|
98
|
-
}
|
|
99
|
-
getParentPort().then((parentPort2) => {
|
|
100
|
-
if (parentPort2) {
|
|
101
|
-
parentPort2.on("message", (message) => {
|
|
102
|
-
handleMessage(message);
|
|
103
|
-
});
|
|
104
|
-
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
105
|
-
} else {
|
|
106
|
-
globalThis.onmessage = handleMessage;
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
static async addEventListener(onMessage) {
|
|
111
|
-
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
112
|
-
if (!onMessageWrapper) {
|
|
113
|
-
onMessageWrapper = (message) => {
|
|
114
|
-
const messageData = getWorkerMessageData(message);
|
|
115
|
-
if (!messageData) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
onMessage(messageData.type, messageData.payload);
|
|
119
|
-
};
|
|
120
|
-
onMessageWrapperMap.set(onMessage, onMessageWrapper);
|
|
121
|
-
}
|
|
122
|
-
const parentPort2 = await getParentPort();
|
|
123
|
-
if (parentPort2) {
|
|
124
|
-
parentPort2.on("message", onMessageWrapper);
|
|
125
|
-
} else {
|
|
126
|
-
globalThis.addEventListener("message", onMessageWrapper);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
static async removeEventListener(onMessage) {
|
|
130
|
-
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
131
|
-
onMessageWrapperMap.delete(onMessage);
|
|
132
|
-
if (!onMessageWrapper) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
const parentPort2 = await getParentPort();
|
|
136
|
-
if (parentPort2) {
|
|
137
|
-
parentPort2.off("message", onMessageWrapper);
|
|
138
|
-
} else {
|
|
139
|
-
globalThis.removeEventListener("message", onMessageWrapper);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Send a message from a worker to creating thread (main thread)
|
|
144
|
-
* @param type
|
|
145
|
-
* @param payload
|
|
146
|
-
*/
|
|
147
|
-
static async postMessage(type, payload) {
|
|
148
|
-
const data = { source: "loaders.gl", type, payload };
|
|
149
|
-
const transferList = getTransferList(payload);
|
|
150
|
-
const parentPort2 = await getParentPort();
|
|
151
|
-
if (parentPort2) {
|
|
152
|
-
parentPort2.postMessage(data, transferList);
|
|
153
|
-
} else {
|
|
154
|
-
globalThis.postMessage(data, transferList);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
};
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// ../../node_modules/@math.gl/core/dist/types/index.js
|
|
104
|
+
var init_types = __esm({
|
|
105
|
+
"../../node_modules/@math.gl/core/dist/types/index.js"() {
|
|
106
|
+
init_float16();
|
|
158
107
|
}
|
|
159
108
|
});
|
|
160
109
|
|
|
161
|
-
//
|
|
162
|
-
var
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
"use strict";
|
|
166
|
-
AsyncQueue = class {
|
|
167
|
-
_values;
|
|
168
|
-
_settlers;
|
|
169
|
-
_closed;
|
|
170
|
-
constructor() {
|
|
171
|
-
this._values = [];
|
|
172
|
-
this._settlers = [];
|
|
173
|
-
this._closed = false;
|
|
174
|
-
}
|
|
175
|
-
/** Return an async iterator for this queue */
|
|
176
|
-
[Symbol.asyncIterator]() {
|
|
177
|
-
return this;
|
|
178
|
-
}
|
|
179
|
-
/** Push a new value - the async iterator will yield a promise resolved to this value */
|
|
180
|
-
push(value) {
|
|
181
|
-
return this.enqueue(value);
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Push a new value - the async iterator will yield a promise resolved to this value
|
|
185
|
-
* Add an error - the async iterator will yield a promise rejected with this value
|
|
186
|
-
*/
|
|
187
|
-
enqueue(value) {
|
|
188
|
-
if (this._closed) {
|
|
189
|
-
throw new Error("Closed");
|
|
190
|
-
}
|
|
191
|
-
if (this._settlers.length > 0) {
|
|
192
|
-
if (this._values.length > 0) {
|
|
193
|
-
throw new Error("Illegal internal state");
|
|
194
|
-
}
|
|
195
|
-
const settler = this._settlers.shift();
|
|
196
|
-
if (value instanceof Error) {
|
|
197
|
-
settler.reject(value);
|
|
198
|
-
} else {
|
|
199
|
-
settler.resolve({ value });
|
|
200
|
-
}
|
|
201
|
-
} else {
|
|
202
|
-
this._values.push(value);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
/** Indicate that we not waiting for more values - The async iterator will be done */
|
|
206
|
-
close() {
|
|
207
|
-
while (this._settlers.length > 0) {
|
|
208
|
-
const settler = this._settlers.shift();
|
|
209
|
-
settler.resolve({ done: true });
|
|
210
|
-
}
|
|
211
|
-
this._closed = true;
|
|
212
|
-
}
|
|
213
|
-
// ITERATOR IMPLEMENTATION
|
|
214
|
-
/** @returns a Promise for an IteratorResult */
|
|
215
|
-
next() {
|
|
216
|
-
if (this._values.length > 0) {
|
|
217
|
-
const value = this._values.shift();
|
|
218
|
-
if (value instanceof Error) {
|
|
219
|
-
return Promise.reject(value);
|
|
220
|
-
}
|
|
221
|
-
return Promise.resolve({ done: false, value });
|
|
222
|
-
}
|
|
223
|
-
if (this._closed) {
|
|
224
|
-
if (this._settlers.length > 0) {
|
|
225
|
-
throw new Error("Illegal internal state");
|
|
226
|
-
}
|
|
227
|
-
return Promise.resolve({ done: true, value: void 0 });
|
|
228
|
-
}
|
|
229
|
-
return new Promise((resolve, reject) => {
|
|
230
|
-
this._settlers.push({ resolve, reject });
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
};
|
|
110
|
+
// ../../node_modules/@math.gl/core/dist/types.js
|
|
111
|
+
var init_types2 = __esm({
|
|
112
|
+
"../../node_modules/@math.gl/core/dist/types.js"() {
|
|
113
|
+
init_types();
|
|
234
114
|
}
|
|
235
115
|
});
|
|
236
116
|
|
|
237
|
-
//
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
117
|
+
// ../../node_modules/@math.gl/core/dist/mat3.js
|
|
118
|
+
var init_mat32 = __esm({
|
|
119
|
+
"../../node_modules/@math.gl/core/dist/mat3.js"() {
|
|
120
|
+
init_mat3();
|
|
241
121
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// ../../node_modules/@math.gl/core/dist/mat4.js
|
|
125
|
+
var init_mat42 = __esm({
|
|
126
|
+
"../../node_modules/@math.gl/core/dist/mat4.js"() {
|
|
127
|
+
init_mat4();
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// ../../node_modules/@math.gl/core/dist/quat.js
|
|
132
|
+
var init_quat2 = __esm({
|
|
133
|
+
"../../node_modules/@math.gl/core/dist/quat.js"() {
|
|
134
|
+
init_quat();
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// ../../node_modules/@math.gl/core/dist/vec2.js
|
|
139
|
+
var init_vec22 = __esm({
|
|
140
|
+
"../../node_modules/@math.gl/core/dist/vec2.js"() {
|
|
141
|
+
init_vec2();
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// ../../node_modules/@math.gl/core/dist/vec3.js
|
|
146
|
+
var init_vec32 = __esm({
|
|
147
|
+
"../../node_modules/@math.gl/core/dist/vec3.js"() {
|
|
148
|
+
init_vec3();
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// ../../node_modules/@math.gl/core/dist/vec4.js
|
|
153
|
+
var init_vec42 = __esm({
|
|
154
|
+
"../../node_modules/@math.gl/core/dist/vec4.js"() {
|
|
155
|
+
init_vec4();
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// ../../node_modules/@math.gl/core/dist/index.js
|
|
160
|
+
var init_dist = __esm({
|
|
161
|
+
"../../node_modules/@math.gl/core/dist/index.js"() {
|
|
162
|
+
init_math_utils();
|
|
163
|
+
init_types2();
|
|
164
|
+
init_mat32();
|
|
165
|
+
init_mat42();
|
|
166
|
+
init_quat2();
|
|
167
|
+
init_vec22();
|
|
168
|
+
init_vec32();
|
|
169
|
+
init_vec42();
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// ../../node_modules/@math.gl/geospatial/dist/terrain/mesh-skirts.js
|
|
174
|
+
function createTerrainSkirt(mesh, options) {
|
|
175
|
+
const { positions, indices } = mesh, { height, edges } = options;
|
|
176
|
+
const maxVertices = options.maxVertices ?? 2e6, maxTriangles = options.maxTriangles ?? 4e6;
|
|
177
|
+
if (!Number.isFinite(height) || height <= 0 || !Number.isSafeInteger(maxVertices) || maxVertices < 0 || maxVertices > 4294967295 || !Number.isSafeInteger(maxTriangles) || maxTriangles < 0 || maxTriangles > 4294967295)
|
|
178
|
+
throw new Error("Invalid terrain skirt height or capacity");
|
|
179
|
+
if (!(positions instanceof Float32Array || positions instanceof Float64Array) || positions.length < 3 || positions.length % 3 || !positions.every(Number.isFinite) || !(indices instanceof Uint16Array || indices instanceof Uint32Array) || indices.length % 3 || positions.length / 3 > maxVertices || indices.length / 3 > maxTriangles)
|
|
180
|
+
throw new Error("Invalid terrain skirt mesh or capacity");
|
|
181
|
+
if (edges !== void 0 && (!(edges instanceof Uint16Array || edges instanceof Uint32Array) || edges.length % 2))
|
|
182
|
+
throw new Error("Invalid terrain skirt edge pairs");
|
|
183
|
+
const vertexCount = positions.length / 3, triangleCount = indices.length / 3;
|
|
184
|
+
const boundary = /* @__PURE__ */ new Map();
|
|
185
|
+
for (let i = 0; i < indices.length; i += 3) {
|
|
186
|
+
const ids = [indices[i], indices[i + 1], indices[i + 2]];
|
|
187
|
+
if (ids.some((id) => id >= vertexCount))
|
|
188
|
+
throw new Error("Terrain skirt index out of range");
|
|
189
|
+
const [a, b, c] = ids.map((id) => id * 3);
|
|
190
|
+
const area = (positions[b] - positions[a]) * (positions[c + 1] - positions[a + 1]) - (positions[b + 1] - positions[a + 1]) * (positions[c] - positions[a]);
|
|
191
|
+
if (!Number.isFinite(area) || area <= 0)
|
|
192
|
+
throw new Error("Terrain skirt requires upward nondegenerate XY triangles");
|
|
193
|
+
for (let j = 0; j < 3; j++) {
|
|
194
|
+
const u = ids[j], v = ids[(j + 1) % 3], key = edgeKey(u, v), prior = boundary.get(key);
|
|
195
|
+
if (!prior)
|
|
196
|
+
boundary.set(key, { a: u, b: v, count: 1 });
|
|
197
|
+
else {
|
|
198
|
+
if (prior.count !== 1 || prior.a !== v || prior.b !== u)
|
|
199
|
+
throw new Error("Terrain skirt mesh has nonmanifold or inconsistent edges");
|
|
200
|
+
prior.count++;
|
|
311
201
|
}
|
|
312
|
-
} catch (error) {
|
|
313
|
-
reporter?.finish();
|
|
314
|
-
const message = error instanceof Error ? error.message : "";
|
|
315
|
-
WorkerBody.postMessage("error", { error: message });
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
async function* createDemandDrivenIterator(inputBatches) {
|
|
320
|
-
while (true) {
|
|
321
|
-
await WorkerBody.postMessage("input-request", {});
|
|
322
|
-
const nextBatch = await inputBatches.next();
|
|
323
|
-
if (nextBatch.done) {
|
|
324
|
-
return;
|
|
325
202
|
}
|
|
326
|
-
yield nextBatch.value;
|
|
327
203
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
WorkerBody.removeEventListener(onMessage);
|
|
339
|
-
resolve(payload2.result);
|
|
340
|
-
break;
|
|
341
|
-
case "error":
|
|
342
|
-
WorkerBody.removeEventListener(onMessage);
|
|
343
|
-
reject(payload2.error);
|
|
344
|
-
break;
|
|
345
|
-
default:
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
WorkerBody.addEventListener(onMessage);
|
|
349
|
-
const payload = { id, input: arrayBuffer, options, context: jobContext };
|
|
350
|
-
WorkerBody.postMessage("process", payload);
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
function createProgressReporter() {
|
|
354
|
-
let pending;
|
|
355
|
-
let finished = false;
|
|
356
|
-
let scheduled = false;
|
|
357
|
-
const flush = () => {
|
|
358
|
-
scheduled = false;
|
|
359
|
-
if (pending) {
|
|
360
|
-
WorkerBody.postMessage("progress", { progress: pending });
|
|
361
|
-
pending = void 0;
|
|
204
|
+
let selected;
|
|
205
|
+
if (edges) {
|
|
206
|
+
selected = [];
|
|
207
|
+
const used = /* @__PURE__ */ new Set();
|
|
208
|
+
for (let i = 0; i < edges.length; i += 2) {
|
|
209
|
+
const key = edgeKey(edges[i], edges[i + 1]), edge = boundary.get(key);
|
|
210
|
+
if (!edge || edge.count !== 1 || used.has(key))
|
|
211
|
+
throw new Error("Terrain skirt selection must contain unique boundary edges");
|
|
212
|
+
used.add(key);
|
|
213
|
+
selected.push(edge);
|
|
362
214
|
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
215
|
+
} else
|
|
216
|
+
selected = [...boundary.values()].filter((edge) => edge.count === 1);
|
|
217
|
+
const outputVertices = vertexCount + selected.length * 2, outputTriangles = triangleCount + selected.length * 2;
|
|
218
|
+
if (!Number.isSafeInteger(outputVertices) || outputVertices > maxVertices || outputVertices > 4294967295 || !Number.isSafeInteger(outputTriangles) || outputTriangles > maxTriangles)
|
|
219
|
+
throw new Error("Terrain skirt output capacity exceeded");
|
|
220
|
+
const resultPositions = positions instanceof Float32Array ? new Float32Array(outputVertices * 3) : new Float64Array(outputVertices * 3);
|
|
221
|
+
resultPositions.set(positions);
|
|
222
|
+
const resultIndices = indices instanceof Uint16Array && outputVertices <= 65536 ? new Uint16Array(outputTriangles * 3) : new Uint32Array(outputTriangles * 3);
|
|
223
|
+
resultIndices.set(indices);
|
|
224
|
+
const sourceVertexIndices = new Uint32Array(selected.length * 2), triangleValidity = new Uint8Array(outputTriangles);
|
|
225
|
+
triangleValidity.fill(1, 0, triangleCount);
|
|
226
|
+
for (let i = 0; i < selected.length; i++) {
|
|
227
|
+
const { a, b } = selected[i], lowerA = vertexCount + 2 * i, lowerB = lowerA + 1;
|
|
228
|
+
for (const [source, target] of [
|
|
229
|
+
[a, lowerA],
|
|
230
|
+
[b, lowerB]
|
|
231
|
+
]) {
|
|
232
|
+
resultPositions.set(positions.subarray(3 * source, 3 * source + 3), 3 * target);
|
|
233
|
+
resultPositions[3 * target + 2] = positions[3 * source + 2] - height;
|
|
234
|
+
if (!Number.isFinite(resultPositions[3 * target + 2]) || resultPositions[3 * target + 2] >= positions[3 * source + 2])
|
|
235
|
+
throw new Error("Terrain skirt height cannot be represented in position precision");
|
|
236
|
+
sourceVertexIndices[target - vertexCount] = source;
|
|
379
237
|
}
|
|
238
|
+
resultIndices.set([a, lowerB, b, lowerB, a, lowerA], indices.length + i * 6);
|
|
239
|
+
}
|
|
240
|
+
const min = [Infinity, Infinity, Infinity], max = [-Infinity, -Infinity, -Infinity];
|
|
241
|
+
for (let i = 0; i < resultPositions.length; i++) {
|
|
242
|
+
const axis = i % 3;
|
|
243
|
+
min[axis] = Math.min(min[axis], resultPositions[i]);
|
|
244
|
+
max[axis] = Math.max(max[axis], resultPositions[i]);
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
positions: resultPositions,
|
|
248
|
+
indices: resultIndices,
|
|
249
|
+
sourceVertexIndices,
|
|
250
|
+
skirtVertexOffset: vertexCount,
|
|
251
|
+
skirtTriangleOffset: triangleCount,
|
|
252
|
+
triangleValidity,
|
|
253
|
+
bounds: [min, max]
|
|
380
254
|
};
|
|
381
255
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
init_worker_body();
|
|
388
|
-
requestId = 0;
|
|
389
|
-
activeInputBatches = null;
|
|
390
|
-
activeOutputAcknowledgements = null;
|
|
256
|
+
function edgeKey(a, b) {
|
|
257
|
+
return a < b ? `${a},${b}` : `${b},${a}`;
|
|
258
|
+
}
|
|
259
|
+
var init_mesh_skirts = __esm({
|
|
260
|
+
"../../node_modules/@math.gl/geospatial/dist/terrain/mesh-skirts.js"() {
|
|
391
261
|
}
|
|
392
262
|
});
|
|
393
263
|
|
|
394
|
-
//
|
|
395
|
-
var
|
|
396
|
-
"
|
|
397
|
-
|
|
398
|
-
init_create_worker();
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
// ../core/src/loader-utils/lib/worker-loader-utils/create-loader-worker.ts
|
|
403
|
-
async function createLoaderWorker(loader, selectLoader = () => loader) {
|
|
404
|
-
await createWorker(
|
|
405
|
-
(input, options, workerContext, loaderContext) => processLoaderWorkerData(
|
|
406
|
-
selectLoader(options || {}),
|
|
407
|
-
input,
|
|
408
|
-
options,
|
|
409
|
-
workerContext,
|
|
410
|
-
loaderContext
|
|
411
|
-
),
|
|
412
|
-
(inputIterator, options, workerContext, loaderContext) => processLoaderWorkerBatches(
|
|
413
|
-
selectLoader(options || {}),
|
|
414
|
-
inputIterator,
|
|
415
|
-
options,
|
|
416
|
-
workerContext,
|
|
417
|
-
loaderContext
|
|
418
|
-
)
|
|
419
|
-
);
|
|
420
|
-
}
|
|
421
|
-
async function processLoaderWorkerData(loader, input, options = {}, workerContext, loaderContext = {}) {
|
|
422
|
-
const result = await parseData({
|
|
423
|
-
loader,
|
|
424
|
-
arrayBuffer: input,
|
|
425
|
-
options,
|
|
426
|
-
context: {
|
|
427
|
-
...loaderContext,
|
|
428
|
-
reportProgress: workerContext?.reportProgress,
|
|
429
|
-
coreApi: createWorkerCoreApi(),
|
|
430
|
-
_parse: createParseOnMainThread(workerContext?.process)
|
|
431
|
-
}
|
|
432
|
-
});
|
|
433
|
-
return loader.serializeWorkerResult ? loader.serializeWorkerResult(result, options, loaderContext) : result;
|
|
434
|
-
}
|
|
435
|
-
async function* processLoaderWorkerBatches(loader, inputIterator, options = {}, workerContext, loaderContext = {}) {
|
|
436
|
-
if (!loader.parseInBatches) {
|
|
437
|
-
throw new Error(`${loader.id} loader does not support batched parsing`);
|
|
438
|
-
}
|
|
439
|
-
const parserOptions = getWorkerLoaderOptions(loader, options);
|
|
440
|
-
const resultIterator = loader.parseInBatches(inputIterator, parserOptions, {
|
|
441
|
-
...loaderContext,
|
|
442
|
-
reportProgress: workerContext?.reportProgress,
|
|
443
|
-
coreApi: createWorkerCoreApi(),
|
|
444
|
-
_parse: createParseOnMainThread(workerContext?.process)
|
|
445
|
-
});
|
|
446
|
-
for await (const batch of resultIterator) {
|
|
447
|
-
yield loader.serializeWorkerBatch ? loader.serializeWorkerBatch(batch, options, loaderContext) : batch;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
function createWorkerCoreApi() {
|
|
451
|
-
const unavailable = (methodName) => () => {
|
|
452
|
-
throw new Error(`context.coreApi.${methodName} is unavailable inside worker loaders.`);
|
|
453
|
-
};
|
|
454
|
-
return {
|
|
455
|
-
fetchFile: async (urlOrData, fetchOptions) => await fetch(urlOrData, fetchOptions),
|
|
456
|
-
parseSync: unavailable("parseSync"),
|
|
457
|
-
parse: unavailable("parse"),
|
|
458
|
-
parseFile: unavailable("parseFile"),
|
|
459
|
-
parseInBatches: unavailable("parseInBatches"),
|
|
460
|
-
load: unavailable("load"),
|
|
461
|
-
loadInBatches: unavailable("loadInBatches")
|
|
462
|
-
};
|
|
463
|
-
}
|
|
464
|
-
function createParseOnMainThread(processOnMainThread2) {
|
|
465
|
-
return (arrayBuffer, loaders, options, context) => {
|
|
466
|
-
if (!processOnMainThread2) {
|
|
467
|
-
throw new Error("Worker not set up to parse on main thread");
|
|
468
|
-
}
|
|
469
|
-
const parseArguments = getMainThreadParseArguments(loaders, options, context);
|
|
470
|
-
return processOnMainThread2(arrayBuffer, parseArguments.options, {
|
|
471
|
-
...parseArguments.context,
|
|
472
|
-
...Array.isArray(loaders) || loaders && isLoaderObject(loaders) ? {
|
|
473
|
-
_loaderIsArray: Array.isArray(loaders),
|
|
474
|
-
_loaderIds: (Array.isArray(loaders) ? loaders : [loaders]).map((loader) => loader.id)
|
|
475
|
-
} : {}
|
|
476
|
-
});
|
|
477
|
-
};
|
|
478
|
-
}
|
|
479
|
-
function getMainThreadParseArguments(loaders, options, context) {
|
|
480
|
-
if (options) {
|
|
481
|
-
return { options, context: getSerializableLoaderContext(context) };
|
|
482
|
-
}
|
|
483
|
-
if (Array.isArray(loaders) || loaders && isLoaderObject(loaders)) {
|
|
484
|
-
return { options: void 0, context: getSerializableLoaderContext(context) };
|
|
485
|
-
}
|
|
486
|
-
if (loaders && !Array.isArray(loaders)) {
|
|
487
|
-
return { options: loaders };
|
|
488
|
-
}
|
|
489
|
-
return { options: void 0, context: getSerializableLoaderContext(context) };
|
|
490
|
-
}
|
|
491
|
-
function isLoaderObject(value) {
|
|
492
|
-
return "id" in value && "extensions" in value;
|
|
493
|
-
}
|
|
494
|
-
function getSerializableLoaderContext(context) {
|
|
495
|
-
if (!context) {
|
|
496
|
-
return void 0;
|
|
497
|
-
}
|
|
498
|
-
const {
|
|
499
|
-
fetch: fetch2,
|
|
500
|
-
loaders,
|
|
501
|
-
coreApi,
|
|
502
|
-
signal,
|
|
503
|
-
reportProgress,
|
|
504
|
-
_parse,
|
|
505
|
-
_parseSync,
|
|
506
|
-
_parseInBatches,
|
|
507
|
-
...serializableContext
|
|
508
|
-
} = context;
|
|
509
|
-
return JSON.parse(JSON.stringify(serializableContext));
|
|
510
|
-
}
|
|
511
|
-
async function parseData({
|
|
512
|
-
loader,
|
|
513
|
-
arrayBuffer,
|
|
514
|
-
options,
|
|
515
|
-
context
|
|
516
|
-
}) {
|
|
517
|
-
let data;
|
|
518
|
-
let parser;
|
|
519
|
-
if (loader.parse || loader.parseSync) {
|
|
520
|
-
data = arrayBuffer;
|
|
521
|
-
parser = loader.parse || loader.parseSync;
|
|
522
|
-
} else if (loader.parseTextSync) {
|
|
523
|
-
const textDecoder = new TextDecoder();
|
|
524
|
-
data = textDecoder.decode(arrayBuffer);
|
|
525
|
-
parser = loader.parseTextSync;
|
|
526
|
-
} else {
|
|
527
|
-
throw new Error(`Could not load data with ${loader.name} loader`);
|
|
528
|
-
}
|
|
529
|
-
options = getWorkerLoaderOptions(loader, options);
|
|
530
|
-
return await parser(data, { ...options }, context, loader);
|
|
531
|
-
}
|
|
532
|
-
function getWorkerLoaderOptions(loader, options) {
|
|
533
|
-
return {
|
|
534
|
-
...options,
|
|
535
|
-
modules: { ...loader.options?.modules, ...options.modules },
|
|
536
|
-
core: { ...options.core, worker: false }
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
var init_create_loader_worker = __esm({
|
|
540
|
-
"../core/src/loader-utils/lib/worker-loader-utils/create-loader-worker.ts"() {
|
|
541
|
-
"use strict";
|
|
542
|
-
init_worker_utils();
|
|
543
|
-
}
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
// ../core/src/loader-utils/lib/binary-utils/array-buffer-utils.ts
|
|
547
|
-
function concatenateTypedArrays(...typedArrays) {
|
|
548
|
-
const arrays = typedArrays;
|
|
549
|
-
const TypedArrayConstructor = arrays && arrays.length > 1 && arrays[0].constructor || null;
|
|
550
|
-
if (!TypedArrayConstructor) {
|
|
551
|
-
throw new Error(
|
|
552
|
-
'"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types'
|
|
553
|
-
);
|
|
554
|
-
}
|
|
555
|
-
const sumLength = arrays.reduce((acc, value) => acc + value.length, 0);
|
|
556
|
-
const result = new TypedArrayConstructor(sumLength);
|
|
557
|
-
let offset = 0;
|
|
558
|
-
for (const array of arrays) {
|
|
559
|
-
result.set(array, offset);
|
|
560
|
-
offset += array.length;
|
|
561
|
-
}
|
|
562
|
-
return result;
|
|
563
|
-
}
|
|
564
|
-
var init_array_buffer_utils = __esm({
|
|
565
|
-
"../core/src/loader-utils/lib/binary-utils/array-buffer-utils.ts"() {
|
|
566
|
-
"use strict";
|
|
567
|
-
}
|
|
568
|
-
});
|
|
569
|
-
|
|
570
|
-
// ../core/src/loader-utils/index.ts
|
|
571
|
-
var init_loader_utils = __esm({
|
|
572
|
-
"../core/src/loader-utils/index.ts"() {
|
|
573
|
-
"use strict";
|
|
574
|
-
init_create_loader_worker();
|
|
575
|
-
init_array_buffer_utils();
|
|
264
|
+
// ../../node_modules/@math.gl/geospatial/dist/terrain/index.js
|
|
265
|
+
var init_terrain = __esm({
|
|
266
|
+
"../../node_modules/@math.gl/geospatial/dist/terrain/index.js"() {
|
|
267
|
+
init_mesh_skirts();
|
|
576
268
|
}
|
|
577
269
|
});
|
|
578
270
|
|
|
@@ -8226,11 +7918,11 @@ return true;`);
|
|
|
8226
7918
|
this._offsets = new OffsetsBufferBuilder(opts.type);
|
|
8227
7919
|
}
|
|
8228
7920
|
setValue(index, value) {
|
|
8229
|
-
const
|
|
8230
|
-
const current =
|
|
7921
|
+
const pending2 = this._pending || (this._pending = /* @__PURE__ */ new Map());
|
|
7922
|
+
const current = pending2.get(index);
|
|
8231
7923
|
current && (this._pendingLength -= current.length);
|
|
8232
7924
|
this._pendingLength += value instanceof MapRow ? value[kKeys].length : value.length;
|
|
8233
|
-
|
|
7925
|
+
pending2.set(index, value);
|
|
8234
7926
|
}
|
|
8235
7927
|
setValid(index, isValid) {
|
|
8236
7928
|
if (!super.setValid(index, isValid)) {
|
|
@@ -8253,12 +7945,12 @@ return true;`);
|
|
|
8253
7945
|
return super.finish();
|
|
8254
7946
|
}
|
|
8255
7947
|
_flush() {
|
|
8256
|
-
const
|
|
7948
|
+
const pending2 = this._pending;
|
|
8257
7949
|
const pendingLength = this._pendingLength;
|
|
8258
7950
|
this._pendingLength = 0;
|
|
8259
7951
|
this._pending = void 0;
|
|
8260
|
-
if (
|
|
8261
|
-
this._flushPending(
|
|
7952
|
+
if (pending2 && pending2.size > 0) {
|
|
7953
|
+
this._flushPending(pending2, pendingLength);
|
|
8262
7954
|
}
|
|
8263
7955
|
return this;
|
|
8264
7956
|
}
|
|
@@ -10844,11 +10536,11 @@ return true;`);
|
|
|
10844
10536
|
setValue(index, value) {
|
|
10845
10537
|
return super.setValue(index, toUint8Array(value));
|
|
10846
10538
|
}
|
|
10847
|
-
_flushPending(
|
|
10539
|
+
_flushPending(pending2, pendingLength) {
|
|
10848
10540
|
const offsets = this._offsets;
|
|
10849
10541
|
const data = this._values.reserve(pendingLength).buffer;
|
|
10850
10542
|
let offset = 0;
|
|
10851
|
-
for (const [index, value] of
|
|
10543
|
+
for (const [index, value] of pending2) {
|
|
10852
10544
|
if (value === void 0) {
|
|
10853
10545
|
offsets.set(index, 0);
|
|
10854
10546
|
} else {
|
|
@@ -10885,11 +10577,11 @@ return true;`);
|
|
|
10885
10577
|
setValue(index, value) {
|
|
10886
10578
|
return super.setValue(index, toUint8Array(value));
|
|
10887
10579
|
}
|
|
10888
|
-
_flushPending(
|
|
10580
|
+
_flushPending(pending2, pendingLength) {
|
|
10889
10581
|
const offsets = this._offsets;
|
|
10890
10582
|
const data = this._values.reserve(pendingLength).buffer;
|
|
10891
10583
|
let offset = 0;
|
|
10892
|
-
for (const [index, value] of
|
|
10584
|
+
for (const [index, value] of pending2) {
|
|
10893
10585
|
if (value === void 0) {
|
|
10894
10586
|
offsets.set(index, BigInt(0));
|
|
10895
10587
|
} else {
|
|
@@ -11200,10 +10892,10 @@ return true;`);
|
|
|
11200
10892
|
this.type = new List2(new Field2(name, child.type, true));
|
|
11201
10893
|
return this.numChildren - 1;
|
|
11202
10894
|
}
|
|
11203
|
-
_flushPending(
|
|
10895
|
+
_flushPending(pending2) {
|
|
11204
10896
|
const offsets = this._offsets;
|
|
11205
10897
|
const [child] = this.children;
|
|
11206
|
-
for (const [index, value] of
|
|
10898
|
+
for (const [index, value] of pending2) {
|
|
11207
10899
|
if (typeof value === "undefined") {
|
|
11208
10900
|
offsets.set(index, 0);
|
|
11209
10901
|
} else {
|
|
@@ -11242,10 +10934,10 @@ return true;`);
|
|
|
11242
10934
|
this.type = new LargeList2(new Field2(name, child.type, true));
|
|
11243
10935
|
return this.numChildren - 1;
|
|
11244
10936
|
}
|
|
11245
|
-
_flushPending(
|
|
10937
|
+
_flushPending(pending2) {
|
|
11246
10938
|
const offsets = this._offsets;
|
|
11247
10939
|
const [child] = this.children;
|
|
11248
|
-
for (const [index, value] of
|
|
10940
|
+
for (const [index, value] of pending2) {
|
|
11249
10941
|
if (typeof value === "undefined") {
|
|
11250
10942
|
offsets.set(index, BigInt(0));
|
|
11251
10943
|
} else {
|
|
@@ -11275,11 +10967,11 @@ return true;`);
|
|
|
11275
10967
|
}
|
|
11276
10968
|
setValue(index, value) {
|
|
11277
10969
|
const row = value instanceof Map ? value : new Map(Object.entries(value));
|
|
11278
|
-
const
|
|
11279
|
-
const current =
|
|
10970
|
+
const pending2 = this._pending || (this._pending = /* @__PURE__ */ new Map());
|
|
10971
|
+
const current = pending2.get(index);
|
|
11280
10972
|
current && (this._pendingLength -= current.size);
|
|
11281
10973
|
this._pendingLength += row.size;
|
|
11282
|
-
|
|
10974
|
+
pending2.set(index, row);
|
|
11283
10975
|
}
|
|
11284
10976
|
addChild(child, name = `${this.numChildren}`) {
|
|
11285
10977
|
if (this.numChildren > 0) {
|
|
@@ -11289,10 +10981,10 @@ return true;`);
|
|
|
11289
10981
|
this.type = new Map_(new Field2(name, child.type, true), this.type.keysSorted);
|
|
11290
10982
|
return this.numChildren - 1;
|
|
11291
10983
|
}
|
|
11292
|
-
_flushPending(
|
|
10984
|
+
_flushPending(pending2) {
|
|
11293
10985
|
const offsets = this._offsets;
|
|
11294
10986
|
const [child] = this.children;
|
|
11295
|
-
for (const [index, value] of
|
|
10987
|
+
for (const [index, value] of pending2) {
|
|
11296
10988
|
if (value === void 0) {
|
|
11297
10989
|
offsets.set(index, 0);
|
|
11298
10990
|
} else {
|
|
@@ -11501,7 +11193,7 @@ return true;`);
|
|
|
11501
11193
|
return super.setValue(index, encodeUtf8(value));
|
|
11502
11194
|
}
|
|
11503
11195
|
// @ts-ignore
|
|
11504
|
-
_flushPending(
|
|
11196
|
+
_flushPending(pending2, pendingLength) {
|
|
11505
11197
|
}
|
|
11506
11198
|
};
|
|
11507
11199
|
Utf8Builder.prototype._flushPending = BinaryBuilder.prototype._flushPending;
|
|
@@ -11532,7 +11224,7 @@ return true;`);
|
|
|
11532
11224
|
return super.setValue(index, encodeUtf8(value));
|
|
11533
11225
|
}
|
|
11534
11226
|
// @ts-ignore
|
|
11535
|
-
_flushPending(
|
|
11227
|
+
_flushPending(pending2, pendingLength) {
|
|
11536
11228
|
}
|
|
11537
11229
|
};
|
|
11538
11230
|
LargeUtf8Builder.prototype._flushPending = LargeBinaryBuilder.prototype._flushPending;
|
|
@@ -15476,70 +15168,541 @@ return true;`);
|
|
|
15476
15168
|
}
|
|
15477
15169
|
});
|
|
15478
15170
|
|
|
15479
|
-
//
|
|
15480
|
-
|
|
15481
|
-
|
|
15482
|
-
|
|
15483
|
-
|
|
15484
|
-
|
|
15171
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-helpers.js
|
|
15172
|
+
var init_indexed_arrow_helpers = __esm({
|
|
15173
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-helpers.js"() {
|
|
15174
|
+
}
|
|
15175
|
+
});
|
|
15176
|
+
|
|
15177
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/arrow-schema-utils.js
|
|
15178
|
+
var init_arrow_schema_utils = __esm({
|
|
15179
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/arrow-schema-utils.js"() {
|
|
15180
|
+
}
|
|
15181
|
+
});
|
|
15182
|
+
|
|
15183
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/arrow-data.js
|
|
15184
|
+
function getArrowVariadicBuffers(data) {
|
|
15185
|
+
return data.variadicBuffers ?? [];
|
|
15186
|
+
}
|
|
15187
|
+
function createArrowData(type, offset, length, nullCount, buffers, children, dictionary, variadicBuffers) {
|
|
15188
|
+
return Reflect.construct(Data, [
|
|
15189
|
+
type,
|
|
15190
|
+
offset,
|
|
15191
|
+
length,
|
|
15192
|
+
nullCount,
|
|
15193
|
+
buffers,
|
|
15194
|
+
children,
|
|
15195
|
+
dictionary,
|
|
15196
|
+
variadicBuffers
|
|
15197
|
+
]);
|
|
15485
15198
|
}
|
|
15486
|
-
|
|
15487
|
-
|
|
15488
|
-
|
|
15489
|
-
|
|
15490
|
-
|
|
15199
|
+
var init_arrow_data = __esm({
|
|
15200
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/arrow-data.js"() {
|
|
15201
|
+
init_Arrow_dom();
|
|
15202
|
+
}
|
|
15203
|
+
});
|
|
15204
|
+
|
|
15205
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/arrow-record-batch.js
|
|
15206
|
+
function getRecordBatchMetadata(batch) {
|
|
15207
|
+
return batch.metadata;
|
|
15491
15208
|
}
|
|
15492
|
-
function
|
|
15493
|
-
|
|
15209
|
+
function createRecordBatchWithMetadata(schema, data, metadata) {
|
|
15210
|
+
if ("metadata" in RecordBatch3.prototype) {
|
|
15211
|
+
const MetadataRecordBatch = RecordBatch3;
|
|
15212
|
+
return Object.assign(new MetadataRecordBatch(schema, data, metadata), { data });
|
|
15213
|
+
}
|
|
15214
|
+
const batch = Object.assign(new RecordBatch3(schema, data), { data });
|
|
15215
|
+
return metadata === void 0 ? batch : Object.assign(batch, { metadata });
|
|
15494
15216
|
}
|
|
15495
|
-
|
|
15496
|
-
|
|
15217
|
+
var init_arrow_record_batch = __esm({
|
|
15218
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/arrow-record-batch.js"() {
|
|
15219
|
+
init_Arrow_dom();
|
|
15220
|
+
}
|
|
15221
|
+
});
|
|
15222
|
+
|
|
15223
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/split-arrow-buffers.js
|
|
15224
|
+
function splitArrowBuffers(input, options = {}) {
|
|
15225
|
+
const retainedBuffers = /* @__PURE__ */ new Set();
|
|
15226
|
+
const visited = /* @__PURE__ */ new Set();
|
|
15227
|
+
for (const retained of options.retain ?? []) {
|
|
15228
|
+
const chunks = isArrowTable2(retained) ? retained.batches.map((batch) => batch.data) : isArrowVector2(retained) ? retained.data : [isArrowRecordBatch2(retained) ? retained.data : retained];
|
|
15229
|
+
for (const data of chunks)
|
|
15230
|
+
collectArrowBuffers(data, retainedBuffers, visited);
|
|
15231
|
+
}
|
|
15232
|
+
const context = { ...options, copies: /* @__PURE__ */ new WeakMap(), retainedBuffers };
|
|
15233
|
+
if (isArrowTable2(input)) {
|
|
15234
|
+
return splitArrowTableBuffersInternal(input, context);
|
|
15235
|
+
}
|
|
15236
|
+
if (isArrowRecordBatch2(input)) {
|
|
15237
|
+
return splitArrowRecordBatchBuffers(input, context);
|
|
15238
|
+
}
|
|
15239
|
+
if (isArrowVector2(input)) {
|
|
15240
|
+
return splitArrowVectorBuffers(input, context);
|
|
15241
|
+
}
|
|
15242
|
+
return splitArrowDataBuffers(input, context);
|
|
15497
15243
|
}
|
|
15498
|
-
function
|
|
15499
|
-
return
|
|
15500
|
-
name: field.name,
|
|
15501
|
-
type: serializeArrowType(field.type),
|
|
15502
|
-
nullable: field.nullable,
|
|
15503
|
-
metadata: serializeArrowMetadata(field.metadata)
|
|
15504
|
-
};
|
|
15244
|
+
function isArrowTable2(input) {
|
|
15245
|
+
return "batches" in input;
|
|
15505
15246
|
}
|
|
15506
|
-
function
|
|
15507
|
-
return
|
|
15508
|
-
|
|
15509
|
-
|
|
15510
|
-
|
|
15511
|
-
|
|
15247
|
+
function isArrowRecordBatch2(input) {
|
|
15248
|
+
return "schema" in input && "data" in input && !Array.isArray(input.data);
|
|
15249
|
+
}
|
|
15250
|
+
function isArrowVector2(input) {
|
|
15251
|
+
return "data" in input && Array.isArray(input.data);
|
|
15252
|
+
}
|
|
15253
|
+
function splitArrowTableBuffersInternal(arrowTable, options) {
|
|
15254
|
+
const recordBatches = arrowTable.batches.map((recordBatch) => splitArrowRecordBatchBuffers(recordBatch, options));
|
|
15255
|
+
return new Table(arrowTable.schema, recordBatches);
|
|
15256
|
+
}
|
|
15257
|
+
function splitArrowRecordBatchBuffers(recordBatch, options) {
|
|
15258
|
+
const data = splitArrowDataBuffers(recordBatch.data, options);
|
|
15259
|
+
return createRecordBatchWithMetadata(recordBatch.schema, data, getRecordBatchMetadata(recordBatch));
|
|
15260
|
+
}
|
|
15261
|
+
function splitArrowDataBuffers(data, options) {
|
|
15262
|
+
const children = data.children.map((childData) => splitArrowDataBuffers(childData, options));
|
|
15263
|
+
const dictionary = data.dictionary ? splitArrowVectorBuffers(data.dictionary, options) : void 0;
|
|
15264
|
+
const buffers = {
|
|
15265
|
+
[BufferType.OFFSET]: splitArrowBuffer(data.buffers[BufferType.OFFSET], options),
|
|
15266
|
+
[BufferType.DATA]: splitArrowBuffer(data.buffers[BufferType.DATA], options),
|
|
15267
|
+
[BufferType.VALIDITY]: splitArrowBuffer(data.buffers[BufferType.VALIDITY], options),
|
|
15268
|
+
[BufferType.TYPE]: splitArrowBuffer(data.buffers[BufferType.TYPE], options)
|
|
15269
|
+
};
|
|
15270
|
+
return createArrowData(
|
|
15271
|
+
data.type,
|
|
15272
|
+
data.offset,
|
|
15273
|
+
data.length,
|
|
15274
|
+
// @ts-expect-error _nullCount is protected. Reuse it to preserve lazy null-count state.
|
|
15275
|
+
data._nullCount,
|
|
15276
|
+
buffers,
|
|
15277
|
+
children,
|
|
15278
|
+
dictionary,
|
|
15279
|
+
getArrowVariadicBuffers(data).map((buffer) => splitArrowBuffer(buffer, options))
|
|
15512
15280
|
);
|
|
15513
15281
|
}
|
|
15514
|
-
function
|
|
15515
|
-
|
|
15516
|
-
|
|
15282
|
+
function splitArrowVectorBuffers(vector, options) {
|
|
15283
|
+
return new Vector(vector.data.map((data) => splitArrowDataBuffers(data, options)));
|
|
15284
|
+
}
|
|
15285
|
+
function collectArrowBuffers(data, buffers, visited) {
|
|
15286
|
+
if (visited.has(data))
|
|
15287
|
+
return;
|
|
15288
|
+
visited.add(data);
|
|
15289
|
+
for (const view of [...Object.values(data.buffers), ...getArrowVariadicBuffers(data)]) {
|
|
15290
|
+
if (isArrowTypedArray(view))
|
|
15291
|
+
buffers.add(view.buffer);
|
|
15517
15292
|
}
|
|
15518
|
-
|
|
15519
|
-
|
|
15293
|
+
for (const child of data.children)
|
|
15294
|
+
collectArrowBuffers(child, buffers, visited);
|
|
15295
|
+
for (const chunk of data.dictionary?.data ?? [])
|
|
15296
|
+
collectArrowBuffers(chunk, buffers, visited);
|
|
15297
|
+
}
|
|
15298
|
+
function splitArrowBuffer(array, options) {
|
|
15299
|
+
if (!isArrowTypedArray(array)) {
|
|
15300
|
+
return array;
|
|
15520
15301
|
}
|
|
15521
|
-
|
|
15522
|
-
|
|
15523
|
-
return
|
|
15524
|
-
type: "large-list",
|
|
15525
|
-
children: [serializeArrowField(largeListType.valueField)]
|
|
15526
|
-
};
|
|
15302
|
+
const sliced = array.byteOffset !== 0 || array.byteLength !== array.buffer.byteLength;
|
|
15303
|
+
if (!options.retainedBuffers.has(array.buffer) && options.copy !== "all" && (options.copy === "none" || !sliced)) {
|
|
15304
|
+
return array;
|
|
15527
15305
|
}
|
|
15528
|
-
|
|
15529
|
-
|
|
15530
|
-
|
|
15531
|
-
|
|
15532
|
-
|
|
15533
|
-
|
|
15534
|
-
|
|
15535
|
-
|
|
15536
|
-
|
|
15537
|
-
|
|
15538
|
-
|
|
15539
|
-
|
|
15540
|
-
|
|
15541
|
-
|
|
15542
|
-
|
|
15306
|
+
let copy = options.copies.get(array);
|
|
15307
|
+
if (!copy) {
|
|
15308
|
+
copy = array instanceof Uint8Array ? new Uint8Array(array) : array.slice();
|
|
15309
|
+
options.copies.set(array, copy);
|
|
15310
|
+
}
|
|
15311
|
+
return copy;
|
|
15312
|
+
}
|
|
15313
|
+
function isArrowTypedArray(value) {
|
|
15314
|
+
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
15315
|
+
}
|
|
15316
|
+
var init_split_arrow_buffers = __esm({
|
|
15317
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/split-arrow-buffers.js"() {
|
|
15318
|
+
init_Arrow_dom();
|
|
15319
|
+
init_arrow_record_batch();
|
|
15320
|
+
init_arrow_data();
|
|
15321
|
+
}
|
|
15322
|
+
});
|
|
15323
|
+
|
|
15324
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/take-arrow-rows.js
|
|
15325
|
+
var init_take_arrow_rows = __esm({
|
|
15326
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/take-arrow-rows.js"() {
|
|
15327
|
+
init_arrow_data();
|
|
15328
|
+
init_split_arrow_buffers();
|
|
15329
|
+
}
|
|
15330
|
+
});
|
|
15331
|
+
|
|
15332
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-vector.js
|
|
15333
|
+
var init_indexed_arrow_vector = __esm({
|
|
15334
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-vector.js"() {
|
|
15335
|
+
init_indexed_arrow_helpers();
|
|
15336
|
+
}
|
|
15337
|
+
});
|
|
15338
|
+
|
|
15339
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-table.js
|
|
15340
|
+
var init_indexed_arrow_table = __esm({
|
|
15341
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-table.js"() {
|
|
15342
|
+
init_indexed_arrow_helpers();
|
|
15343
|
+
init_arrow_schema_utils();
|
|
15344
|
+
init_take_arrow_rows();
|
|
15345
|
+
init_indexed_arrow_vector();
|
|
15346
|
+
}
|
|
15347
|
+
});
|
|
15348
|
+
|
|
15349
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/mapped-arrow-table.js
|
|
15350
|
+
var init_mapped_arrow_table = __esm({
|
|
15351
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/mapped-arrow-table.js"() {
|
|
15352
|
+
init_indexed_arrow_helpers();
|
|
15353
|
+
init_indexed_arrow_table();
|
|
15354
|
+
}
|
|
15355
|
+
});
|
|
15356
|
+
|
|
15357
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/rename-arrow-columns.js
|
|
15358
|
+
var init_rename_arrow_columns = __esm({
|
|
15359
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/rename-arrow-columns.js"() {
|
|
15360
|
+
init_arrow_schema_utils();
|
|
15361
|
+
}
|
|
15362
|
+
});
|
|
15363
|
+
|
|
15364
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/arrow-table-transport.js
|
|
15365
|
+
function dehydrateArrowTable(arrowTable, options) {
|
|
15366
|
+
const splitTable = splitArrowBuffers(arrowTable, options);
|
|
15367
|
+
return {
|
|
15368
|
+
transport: "arrow-js",
|
|
15369
|
+
version: 1,
|
|
15370
|
+
schema: tableToIPC(new Table(splitTable.schema, [])),
|
|
15371
|
+
metadataVersion: splitTable.schema.metadataVersion,
|
|
15372
|
+
batches: splitTable.batches.map((batch) => {
|
|
15373
|
+
const metadata = getRecordBatchMetadata(batch);
|
|
15374
|
+
return {
|
|
15375
|
+
...dehydrateArrowData(batch.data),
|
|
15376
|
+
...metadata !== void 0 ? { metadata: [...metadata] } : {}
|
|
15377
|
+
};
|
|
15378
|
+
})
|
|
15379
|
+
};
|
|
15380
|
+
}
|
|
15381
|
+
function hydrateArrowTable(table) {
|
|
15382
|
+
if (table.transport !== "arrow-js" || table.version !== 1) {
|
|
15383
|
+
throw new Error("Unsupported Arrow column-buffer transport protocol.");
|
|
15384
|
+
}
|
|
15385
|
+
const decodedSchema = tableFromIPC(table.schema).schema;
|
|
15386
|
+
const schema = new Schema2(decodedSchema.fields, decodedSchema.metadata, decodedSchema.dictionaries, table.metadataVersion);
|
|
15387
|
+
const type = new Struct(schema.fields);
|
|
15388
|
+
const batches = table.batches.map((payload) => {
|
|
15389
|
+
const data = hydrateArrowData(payload, type);
|
|
15390
|
+
return createRecordBatchWithMetadata(schema, data, payload.metadata && new Map(payload.metadata));
|
|
15391
|
+
});
|
|
15392
|
+
return new Table(schema, batches);
|
|
15393
|
+
}
|
|
15394
|
+
function dehydrateArrowData(data) {
|
|
15395
|
+
return {
|
|
15396
|
+
offset: data.offset,
|
|
15397
|
+
length: data.length,
|
|
15398
|
+
nullCount: data.nullCount,
|
|
15399
|
+
buffers: {
|
|
15400
|
+
[BufferType.OFFSET]: data.buffers[BufferType.OFFSET],
|
|
15401
|
+
[BufferType.DATA]: data.buffers[BufferType.DATA],
|
|
15402
|
+
[BufferType.VALIDITY]: data.buffers[BufferType.VALIDITY],
|
|
15403
|
+
[BufferType.TYPE]: data.buffers[BufferType.TYPE]
|
|
15404
|
+
},
|
|
15405
|
+
children: data.children.map((child) => dehydrateArrowData(child)),
|
|
15406
|
+
variadicBuffers: getArrowVariadicBuffers(data),
|
|
15407
|
+
dictionary: data.dictionary?.data.map((chunk) => dehydrateArrowData(chunk))
|
|
15408
|
+
};
|
|
15409
|
+
}
|
|
15410
|
+
function hydrateArrowData(data, type) {
|
|
15411
|
+
const children = data.children.map((child, index) => hydrateArrowData(child, type.children[index].type));
|
|
15412
|
+
const dictionary = data.dictionary && DataType.isDictionary(type) ? new Vector(data.dictionary.map((chunk) => hydrateArrowData(chunk, type.dictionary))) : void 0;
|
|
15413
|
+
return createArrowData(type, data.offset, data.length, data.nullCount, data.buffers, children, dictionary, data.variadicBuffers);
|
|
15414
|
+
}
|
|
15415
|
+
function dehydrateArrowRecordBatch(batch, options) {
|
|
15416
|
+
return dehydrateArrowTable(new Table(batch.schema, [batch]), options);
|
|
15417
|
+
}
|
|
15418
|
+
function hydrateArrowRecordBatch(payload) {
|
|
15419
|
+
if (payload.batches.length !== 1) {
|
|
15420
|
+
throw new Error("Arrow record batch transport requires exactly one batch.");
|
|
15421
|
+
}
|
|
15422
|
+
return hydrateArrowTable(payload).batches[0];
|
|
15423
|
+
}
|
|
15424
|
+
var init_arrow_table_transport = __esm({
|
|
15425
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/arrow-table-transport.js"() {
|
|
15426
|
+
init_Arrow_dom();
|
|
15427
|
+
init_arrow_record_batch();
|
|
15428
|
+
init_arrow_data();
|
|
15429
|
+
init_split_arrow_buffers();
|
|
15430
|
+
}
|
|
15431
|
+
});
|
|
15432
|
+
|
|
15433
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/arrow-column-utils.js
|
|
15434
|
+
var init_arrow_column_utils = __esm({
|
|
15435
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/arrow-column-utils.js"() {
|
|
15436
|
+
}
|
|
15437
|
+
});
|
|
15438
|
+
|
|
15439
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/index.js
|
|
15440
|
+
var init_arrow = __esm({
|
|
15441
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/index.js"() {
|
|
15442
|
+
init_indexed_arrow_table();
|
|
15443
|
+
init_indexed_arrow_vector();
|
|
15444
|
+
init_mapped_arrow_table();
|
|
15445
|
+
init_arrow_schema_utils();
|
|
15446
|
+
init_rename_arrow_columns();
|
|
15447
|
+
init_split_arrow_buffers();
|
|
15448
|
+
init_arrow_table_transport();
|
|
15449
|
+
init_arrow_column_utils();
|
|
15450
|
+
init_take_arrow_rows();
|
|
15451
|
+
init_arrow_record_batch();
|
|
15452
|
+
}
|
|
15453
|
+
});
|
|
15454
|
+
|
|
15455
|
+
// ../../node_modules/@math.gl/arrow/dist/index.js
|
|
15456
|
+
var init_dist2 = __esm({
|
|
15457
|
+
"../../node_modules/@math.gl/arrow/dist/index.js"() {
|
|
15458
|
+
init_arrow();
|
|
15459
|
+
}
|
|
15460
|
+
});
|
|
15461
|
+
|
|
15462
|
+
// ../core/src/arrow-worker-transport.ts
|
|
15463
|
+
function deserializeArrowWorkerTable(result) {
|
|
15464
|
+
if (isArrowWorkerEnvelope(result)) {
|
|
15465
|
+
return { ...result.metadata, shape: "arrow-table", data: hydrateWorkerTable(result) };
|
|
15466
|
+
}
|
|
15467
|
+
if (isLegacyArrowWorkerEnvelope(result)) {
|
|
15468
|
+
const { arrowBatchMetadata: _snapshots, data: _columns, ...metadata } = result;
|
|
15469
|
+
return { ...metadata, data: hydrateWorkerTable(result) };
|
|
15470
|
+
}
|
|
15471
|
+
throw new Error("Workers require Arrow column transport");
|
|
15472
|
+
}
|
|
15473
|
+
function serializeNativeArrowWorkerResult(result, options = { copy: "all" }) {
|
|
15474
|
+
const batch = result instanceof RecordBatch3;
|
|
15475
|
+
if (!batch && !(result instanceof Table)) {
|
|
15476
|
+
throw new Error("Workers require Arrow table output");
|
|
15477
|
+
}
|
|
15478
|
+
return {
|
|
15479
|
+
transport: batch ? "arrow-record-batch" : "arrow-table-columns",
|
|
15480
|
+
columns: batch ? { data: dehydrateArrowRecordBatch(result, options) } : serializeWorkerColumns(result, options)
|
|
15481
|
+
};
|
|
15482
|
+
}
|
|
15483
|
+
function deserializeNativeArrowWorkerResult(result) {
|
|
15484
|
+
const payload = result;
|
|
15485
|
+
if (payload?.transport !== "arrow-table-columns" && payload?.transport !== "arrow-record-batch" || !hasArrowWorkerColumns(payload.columns)) {
|
|
15486
|
+
throw new Error("Workers require Arrow column transport");
|
|
15487
|
+
}
|
|
15488
|
+
if (payload.transport === "arrow-record-batch" && !payload.columns.arrowBatchMetadata) {
|
|
15489
|
+
return hydrateArrowRecordBatch(payload.columns.data);
|
|
15490
|
+
}
|
|
15491
|
+
const data = hydrateWorkerTable(payload.columns);
|
|
15492
|
+
return payload.transport === "arrow-record-batch" ? data.batches[0] : data;
|
|
15493
|
+
}
|
|
15494
|
+
function serializeArrowWorkerResult(result, options) {
|
|
15495
|
+
const workerOptions = options;
|
|
15496
|
+
const bufferCopyMode = workerOptions?.core?.workerTransferBufferCopy ?? workerOptions?.workerTransferBufferCopy;
|
|
15497
|
+
if (result instanceof Table || result instanceof RecordBatch3) {
|
|
15498
|
+
return serializeNativeArrowWorkerResult(result, { copy: bufferCopyMode ?? "all" });
|
|
15499
|
+
}
|
|
15500
|
+
if (!isArrowTableWrapper(result)) {
|
|
15501
|
+
return result;
|
|
15502
|
+
}
|
|
15503
|
+
const { data, shape: _shape, ...metadata } = result;
|
|
15504
|
+
return {
|
|
15505
|
+
transport: "arrow-column-envelope",
|
|
15506
|
+
metadata: structuredClone(metadata),
|
|
15507
|
+
...serializeWorkerColumns(data, bufferCopyMode ? { copy: bufferCopyMode } : void 0)
|
|
15508
|
+
};
|
|
15509
|
+
}
|
|
15510
|
+
function deserializeArrowWorkerResult(result) {
|
|
15511
|
+
const transport = result?.transport;
|
|
15512
|
+
if (transport === "arrow-table-columns" || transport === "arrow-record-batch") {
|
|
15513
|
+
return deserializeNativeArrowWorkerResult(result);
|
|
15514
|
+
}
|
|
15515
|
+
return isArrowWorkerEnvelope(result) || isLegacyArrowWorkerEnvelope(result) ? deserializeArrowWorkerTable(result) : result;
|
|
15516
|
+
}
|
|
15517
|
+
function isArrowTableWrapper(value) {
|
|
15518
|
+
const table = value;
|
|
15519
|
+
return Boolean(
|
|
15520
|
+
table && table.shape === "arrow-table" && table.data && typeof table.data === "object" && "batches" in table.data
|
|
15521
|
+
);
|
|
15522
|
+
}
|
|
15523
|
+
function hasArrowWorkerColumns(value) {
|
|
15524
|
+
const columns = value;
|
|
15525
|
+
return columns?.data?.transport === "arrow-js" && Array.isArray(columns.data.batches);
|
|
15526
|
+
}
|
|
15527
|
+
function isArrowWorkerEnvelope(value) {
|
|
15528
|
+
return value?.transport === "arrow-column-envelope" && hasArrowWorkerColumns(value);
|
|
15529
|
+
}
|
|
15530
|
+
function isLegacyArrowWorkerEnvelope(value) {
|
|
15531
|
+
return value?.shape === "arrow-table" && hasArrowWorkerColumns(value);
|
|
15532
|
+
}
|
|
15533
|
+
function serializeWorkerColumns(table, options) {
|
|
15534
|
+
return {
|
|
15535
|
+
arrowBatchMetadata: snapshotBatchMetadata(table),
|
|
15536
|
+
data: dehydrateWorkerTable(table, options)
|
|
15537
|
+
};
|
|
15538
|
+
}
|
|
15539
|
+
function dehydrateWorkerTable(table, options) {
|
|
15540
|
+
const payload = dehydrateArrowTable(table, options);
|
|
15541
|
+
if (table.numCols === 0) {
|
|
15542
|
+
for (const [index, batch] of table.batches.entries()) {
|
|
15543
|
+
payload.batches[index].length = batch.numRows;
|
|
15544
|
+
}
|
|
15545
|
+
}
|
|
15546
|
+
return payload;
|
|
15547
|
+
}
|
|
15548
|
+
function snapshotBatchMetadata(table) {
|
|
15549
|
+
return table.batches.map((batch) => ({
|
|
15550
|
+
schema: tableToIPC(new Table(batch.schema, [])),
|
|
15551
|
+
metadata: Array.from(batch.metadata)
|
|
15552
|
+
}));
|
|
15553
|
+
}
|
|
15554
|
+
function hydrateWorkerTable(result) {
|
|
15555
|
+
const { arrowBatchMetadata, data } = result;
|
|
15556
|
+
const table = hydrateArrowTable(data);
|
|
15557
|
+
const batches = table.batches.map((batch, index) => {
|
|
15558
|
+
const snapshot = arrowBatchMetadata?.[index];
|
|
15559
|
+
const restored = snapshot ? new RecordBatch3(
|
|
15560
|
+
tableFromIPC(snapshot.schema).schema,
|
|
15561
|
+
batch.data,
|
|
15562
|
+
new Map(snapshot.metadata)
|
|
15563
|
+
) : batch;
|
|
15564
|
+
const rowCount = data.batches[index].length;
|
|
15565
|
+
if (restored.numCols === 0 && restored.numRows !== rowCount) {
|
|
15566
|
+
Object.defineProperty(restored, "data", {
|
|
15567
|
+
value: new Data(new Struct([]), 0, rowCount, 0, void 0, [])
|
|
15568
|
+
});
|
|
15569
|
+
}
|
|
15570
|
+
return restored;
|
|
15571
|
+
});
|
|
15572
|
+
return new Table(table.schema, batches);
|
|
15573
|
+
}
|
|
15574
|
+
var init_arrow_worker_transport = __esm({
|
|
15575
|
+
"../core/src/arrow-worker-transport.ts"() {
|
|
15576
|
+
"use strict";
|
|
15577
|
+
init_Arrow_dom();
|
|
15578
|
+
init_dist2();
|
|
15579
|
+
}
|
|
15580
|
+
});
|
|
15581
|
+
|
|
15582
|
+
// ../core/src/schema-utils/lib/schema/data-type.ts
|
|
15583
|
+
function getDataTypeFromValue(value, defaultNumberType = "float32") {
|
|
15584
|
+
if (value instanceof Date) {
|
|
15585
|
+
return "date-millisecond";
|
|
15586
|
+
}
|
|
15587
|
+
if (typeof value === "number") {
|
|
15588
|
+
return defaultNumberType;
|
|
15589
|
+
}
|
|
15590
|
+
if (typeof value === "boolean") {
|
|
15591
|
+
return "bool";
|
|
15592
|
+
}
|
|
15593
|
+
if (typeof value === "string") {
|
|
15594
|
+
return "utf8";
|
|
15595
|
+
}
|
|
15596
|
+
if (value === null || value === "undefined") {
|
|
15597
|
+
return "null";
|
|
15598
|
+
}
|
|
15599
|
+
return "null";
|
|
15600
|
+
}
|
|
15601
|
+
function getDataTypeFromArray(array) {
|
|
15602
|
+
let type = getDataTypeFromTypedArray(array);
|
|
15603
|
+
if (type !== "null") {
|
|
15604
|
+
return { type, nullable: false };
|
|
15605
|
+
}
|
|
15606
|
+
if (array.length > 0) {
|
|
15607
|
+
type = getDataTypeFromValue(array[0]);
|
|
15608
|
+
return { type, nullable: true };
|
|
15609
|
+
}
|
|
15610
|
+
return { type: "null", nullable: true };
|
|
15611
|
+
}
|
|
15612
|
+
function getDataTypeFromTypedArray(array) {
|
|
15613
|
+
if (typeof Float16Array !== "undefined" && array instanceof Float16Array) {
|
|
15614
|
+
return "float16";
|
|
15615
|
+
}
|
|
15616
|
+
switch (array.constructor) {
|
|
15617
|
+
case Int8Array:
|
|
15618
|
+
return "int8";
|
|
15619
|
+
case Uint8Array:
|
|
15620
|
+
case Uint8ClampedArray:
|
|
15621
|
+
return "uint8";
|
|
15622
|
+
case Int16Array:
|
|
15623
|
+
return "int16";
|
|
15624
|
+
case Uint16Array:
|
|
15625
|
+
return "uint16";
|
|
15626
|
+
case Int32Array:
|
|
15627
|
+
return "int32";
|
|
15628
|
+
case Uint32Array:
|
|
15629
|
+
return "uint32";
|
|
15630
|
+
case BigInt64Array:
|
|
15631
|
+
return "int64";
|
|
15632
|
+
case BigUint64Array:
|
|
15633
|
+
return "uint64";
|
|
15634
|
+
case Float32Array:
|
|
15635
|
+
return "float32";
|
|
15636
|
+
case Float64Array:
|
|
15637
|
+
return "float64";
|
|
15638
|
+
default:
|
|
15639
|
+
return "null";
|
|
15640
|
+
}
|
|
15641
|
+
}
|
|
15642
|
+
var init_data_type = __esm({
|
|
15643
|
+
"../core/src/schema-utils/lib/schema/data-type.ts"() {
|
|
15644
|
+
"use strict";
|
|
15645
|
+
}
|
|
15646
|
+
});
|
|
15647
|
+
|
|
15648
|
+
// ../core/src/schema-utils/lib/schema/convert-arrow-schema.ts
|
|
15649
|
+
function serializeArrowSchema(arrowSchema) {
|
|
15650
|
+
return {
|
|
15651
|
+
fields: arrowSchema.fields.map((arrowField) => serializeArrowField(arrowField)),
|
|
15652
|
+
metadata: serializeArrowMetadata(arrowSchema.metadata)
|
|
15653
|
+
};
|
|
15654
|
+
}
|
|
15655
|
+
function serializeArrowMetadata(arrowMetadata) {
|
|
15656
|
+
return Object.fromEntries(arrowMetadata);
|
|
15657
|
+
}
|
|
15658
|
+
function deserializeArrowMetadata(metadata) {
|
|
15659
|
+
return metadata ? new Map(Object.entries(metadata)) : /* @__PURE__ */ new Map();
|
|
15660
|
+
}
|
|
15661
|
+
function serializeArrowField(field) {
|
|
15662
|
+
return {
|
|
15663
|
+
name: field.name,
|
|
15664
|
+
type: serializeArrowType(field.type),
|
|
15665
|
+
nullable: field.nullable,
|
|
15666
|
+
metadata: serializeArrowMetadata(field.metadata)
|
|
15667
|
+
};
|
|
15668
|
+
}
|
|
15669
|
+
function deserializeArrowField(field, options) {
|
|
15670
|
+
return new Field2(
|
|
15671
|
+
field.name,
|
|
15672
|
+
deserializeArrowType(field.type, options),
|
|
15673
|
+
field.nullable,
|
|
15674
|
+
deserializeArrowMetadata(field.metadata)
|
|
15675
|
+
);
|
|
15676
|
+
}
|
|
15677
|
+
function serializeArrowType(arrowType) {
|
|
15678
|
+
if (isArrowViewType(arrowType, "BinaryView")) {
|
|
15679
|
+
return "binary-view";
|
|
15680
|
+
}
|
|
15681
|
+
if (isArrowViewType(arrowType, "Utf8View")) {
|
|
15682
|
+
return "utf8-view";
|
|
15683
|
+
}
|
|
15684
|
+
if (isOptionalArrowType(arrowType, "LargeList")) {
|
|
15685
|
+
const largeListType = arrowType;
|
|
15686
|
+
return {
|
|
15687
|
+
type: "large-list",
|
|
15688
|
+
children: [serializeArrowField(largeListType.valueField)]
|
|
15689
|
+
};
|
|
15690
|
+
}
|
|
15691
|
+
switch (arrowType.constructor) {
|
|
15692
|
+
case Null2:
|
|
15693
|
+
return "null";
|
|
15694
|
+
case Binary2:
|
|
15695
|
+
return "binary";
|
|
15696
|
+
case FixedSizeBinary2:
|
|
15697
|
+
return {
|
|
15698
|
+
type: "fixed-size-binary",
|
|
15699
|
+
byteWidth: arrowType.byteWidth
|
|
15700
|
+
};
|
|
15701
|
+
case Bool2:
|
|
15702
|
+
return "bool";
|
|
15703
|
+
case Int_:
|
|
15704
|
+
const intType = arrowType;
|
|
15705
|
+
return `${intType.isSigned ? "" : "u"}int${intType.bitWidth}`;
|
|
15543
15706
|
case Int8:
|
|
15544
15707
|
return "int8";
|
|
15545
15708
|
case Int16:
|
|
@@ -15911,284 +16074,23 @@ return true;`);
|
|
|
15911
16074
|
}
|
|
15912
16075
|
});
|
|
15913
16076
|
|
|
15914
|
-
// ../core/src/
|
|
15915
|
-
function
|
|
15916
|
-
|
|
15917
|
-
|
|
15918
|
-
|
|
15919
|
-
|
|
15920
|
-
|
|
16077
|
+
// ../core/src/lib/loader-utils/native-arrow.ts
|
|
16078
|
+
function isNativeArrowTable(value) {
|
|
16079
|
+
return Boolean(
|
|
16080
|
+
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"
|
|
16081
|
+
);
|
|
16082
|
+
}
|
|
16083
|
+
var init_native_arrow = __esm({
|
|
16084
|
+
"../core/src/lib/loader-utils/native-arrow.ts"() {
|
|
16085
|
+
"use strict";
|
|
15921
16086
|
}
|
|
15922
|
-
|
|
15923
|
-
|
|
15924
|
-
|
|
15925
|
-
|
|
15926
|
-
|
|
15927
|
-
|
|
15928
|
-
|
|
15929
|
-
}
|
|
15930
|
-
function isArrowRecordBatch2(input) {
|
|
15931
|
-
return "schema" in input && "data" in input && !Array.isArray(input.data);
|
|
15932
|
-
}
|
|
15933
|
-
function isArrowVector2(input) {
|
|
15934
|
-
return "data" in input && Array.isArray(input.data);
|
|
15935
|
-
}
|
|
15936
|
-
function splitArrowTableBuffersInternal(table, options) {
|
|
15937
|
-
const recordBatches = table.batches.map(
|
|
15938
|
-
(recordBatch) => splitArrowRecordBatchBuffers(recordBatch, options)
|
|
15939
|
-
);
|
|
15940
|
-
return new Table(table.schema, recordBatches);
|
|
15941
|
-
}
|
|
15942
|
-
function splitArrowRecordBatchBuffers(recordBatch, options) {
|
|
15943
|
-
return new RecordBatch3(
|
|
15944
|
-
recordBatch.schema,
|
|
15945
|
-
splitArrowDataBuffers(recordBatch.data, options)
|
|
15946
|
-
);
|
|
15947
|
-
}
|
|
15948
|
-
function splitArrowDataBuffers(data, options) {
|
|
15949
|
-
const children = data.children.map((childData) => splitArrowDataBuffers(childData, options));
|
|
15950
|
-
const dictionary = data.dictionary ? splitArrowVectorBuffers(data.dictionary, options) : void 0;
|
|
15951
|
-
const buffers = {
|
|
15952
|
-
[BufferType.OFFSET]: splitArrowBuffer(data.buffers[BufferType.OFFSET], options),
|
|
15953
|
-
[BufferType.DATA]: splitArrowBuffer(data.buffers[BufferType.DATA], options),
|
|
15954
|
-
[BufferType.VALIDITY]: splitArrowBuffer(data.buffers[BufferType.VALIDITY], options),
|
|
15955
|
-
[BufferType.TYPE]: splitArrowBuffer(data.buffers[BufferType.TYPE], options)
|
|
15956
|
-
};
|
|
15957
|
-
return new Data(
|
|
15958
|
-
data.type,
|
|
15959
|
-
data.offset,
|
|
15960
|
-
data.length,
|
|
15961
|
-
// @ts-expect-error _nullCount is protected. Reuse it to preserve lazy null-count state.
|
|
15962
|
-
data._nullCount,
|
|
15963
|
-
buffers,
|
|
15964
|
-
children,
|
|
15965
|
-
dictionary
|
|
15966
|
-
);
|
|
15967
|
-
}
|
|
15968
|
-
function splitArrowVectorBuffers(vector, options) {
|
|
15969
|
-
return new Vector(vector.data.map((data) => splitArrowDataBuffers(data, options)));
|
|
15970
|
-
}
|
|
15971
|
-
function splitArrowBuffer(array, options) {
|
|
15972
|
-
if (!isArrowTypedArray(array)) {
|
|
15973
|
-
return array;
|
|
15974
|
-
}
|
|
15975
|
-
if (options.copy === "none") {
|
|
15976
|
-
return array;
|
|
15977
|
-
}
|
|
15978
|
-
if (options.copy !== "all" && array.byteOffset === 0 && array.byteLength === array.buffer.byteLength) {
|
|
15979
|
-
return array;
|
|
15980
|
-
}
|
|
15981
|
-
return array.slice();
|
|
15982
|
-
}
|
|
15983
|
-
function isArrowTypedArray(value) {
|
|
15984
|
-
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
15985
|
-
}
|
|
15986
|
-
var init_split_arrow_buffers = __esm({
|
|
15987
|
-
"../core/src/schema-utils/lib/arrow/split-arrow-buffers.ts"() {
|
|
15988
|
-
"use strict";
|
|
15989
|
-
init_Arrow_dom();
|
|
15990
|
-
}
|
|
15991
|
-
});
|
|
15992
|
-
|
|
15993
|
-
// ../core/src/schema-utils/lib/arrow/arrow-table-transport.ts
|
|
15994
|
-
function dehydrateArrowTable(table, options) {
|
|
15995
|
-
const splitTable = splitArrowBuffers(table, options);
|
|
15996
|
-
return {
|
|
15997
|
-
shape: "arrow-table",
|
|
15998
|
-
transport: "arrow-js",
|
|
15999
|
-
schema: serializeArrowSchema(splitTable.schema),
|
|
16000
|
-
batches: splitTable.batches.map((recordBatch) => dehydrateArrowRecordBatch(recordBatch))
|
|
16001
|
-
};
|
|
16002
|
-
}
|
|
16003
|
-
function hydrateArrowTable(table) {
|
|
16004
|
-
const schema = deserializeArrowSchema(table.schema);
|
|
16005
|
-
const recordBatches = table.batches.map(
|
|
16006
|
-
(recordBatch) => new RecordBatch3(schema, hydrateArrowData(recordBatch.data))
|
|
16007
|
-
);
|
|
16008
|
-
return new Table(schema, recordBatches);
|
|
16009
|
-
}
|
|
16010
|
-
function serializeArrowWorkerResult(result, options) {
|
|
16011
|
-
if (!isArrowTableWrapper(result)) {
|
|
16012
|
-
return result;
|
|
16013
|
-
}
|
|
16014
|
-
const workerOptions = options;
|
|
16015
|
-
const bufferCopyMode = workerOptions?.core?.workerTransferBufferCopy ?? workerOptions?.workerTransferBufferCopy;
|
|
16016
|
-
return {
|
|
16017
|
-
...result,
|
|
16018
|
-
data: dehydrateArrowTable(result.data, bufferCopyMode ? { copy: bufferCopyMode } : void 0)
|
|
16019
|
-
};
|
|
16020
|
-
}
|
|
16021
|
-
function deserializeArrowWorkerResult(result) {
|
|
16022
|
-
if (!isDehydratedArrowTableWrapper(result)) {
|
|
16023
|
-
return result;
|
|
16024
|
-
}
|
|
16025
|
-
return { ...result, data: hydrateArrowTable(result.data) };
|
|
16026
|
-
}
|
|
16027
|
-
function isArrowTableWrapper(value) {
|
|
16028
|
-
const table = value;
|
|
16029
|
-
return Boolean(
|
|
16030
|
-
table && table.shape === "arrow-table" && table.data && typeof table.data === "object" && "batches" in table.data
|
|
16031
|
-
);
|
|
16032
|
-
}
|
|
16033
|
-
function isDehydratedArrowTableWrapper(value) {
|
|
16034
|
-
const table = value;
|
|
16035
|
-
return Boolean(
|
|
16036
|
-
table && table.shape === "arrow-table" && table.data && table.data.transport === "arrow-js" && Array.isArray(table.data.batches)
|
|
16037
|
-
);
|
|
16038
|
-
}
|
|
16039
|
-
function dehydrateArrowRecordBatch(recordBatch) {
|
|
16040
|
-
return { data: dehydrateArrowData(recordBatch.data) };
|
|
16041
|
-
}
|
|
16042
|
-
function dehydrateArrowData(data) {
|
|
16043
|
-
return {
|
|
16044
|
-
type: serializeArrowType(data.type),
|
|
16045
|
-
offset: data.offset,
|
|
16046
|
-
length: data.length,
|
|
16047
|
-
// @ts-expect-error _nullCount is protected. Preserve the Arrow lazy null-count state.
|
|
16048
|
-
nullCount: data._nullCount,
|
|
16049
|
-
buffers: {
|
|
16050
|
-
[BufferType.OFFSET]: data.buffers[BufferType.OFFSET],
|
|
16051
|
-
[BufferType.DATA]: data.buffers[BufferType.DATA],
|
|
16052
|
-
[BufferType.VALIDITY]: data.buffers[BufferType.VALIDITY],
|
|
16053
|
-
[BufferType.TYPE]: data.buffers[BufferType.TYPE]
|
|
16054
|
-
},
|
|
16055
|
-
children: data.children.map((childData) => dehydrateArrowData(childData)),
|
|
16056
|
-
dictionary: data.dictionary ? dehydrateArrowVector(data.dictionary) : void 0
|
|
16057
|
-
};
|
|
16058
|
-
}
|
|
16059
|
-
function dehydrateArrowVector(vector) {
|
|
16060
|
-
return { data: vector.data.map((data) => dehydrateArrowData(data)) };
|
|
16061
|
-
}
|
|
16062
|
-
function hydrateArrowData(data) {
|
|
16063
|
-
const children = data.children.map((childData) => hydrateArrowData(childData));
|
|
16064
|
-
const dictionary = data.dictionary ? hydrateArrowVector(data.dictionary) : void 0;
|
|
16065
|
-
return new Data(
|
|
16066
|
-
deserializeArrowType(data.type),
|
|
16067
|
-
data.offset,
|
|
16068
|
-
data.length,
|
|
16069
|
-
data.nullCount,
|
|
16070
|
-
data.buffers,
|
|
16071
|
-
children,
|
|
16072
|
-
dictionary
|
|
16073
|
-
);
|
|
16074
|
-
}
|
|
16075
|
-
function hydrateArrowVector(vector) {
|
|
16076
|
-
return new Vector(vector.data.map((data) => hydrateArrowData(data)));
|
|
16077
|
-
}
|
|
16078
|
-
var init_arrow_table_transport = __esm({
|
|
16079
|
-
"../core/src/schema-utils/lib/arrow/arrow-table-transport.ts"() {
|
|
16080
|
-
"use strict";
|
|
16081
|
-
init_Arrow_dom();
|
|
16082
|
-
init_convert_arrow_schema();
|
|
16083
|
-
init_split_arrow_buffers();
|
|
16084
|
-
}
|
|
16085
|
-
});
|
|
16086
|
-
|
|
16087
|
-
// ../core/src/schema-utils/arrow-transport.ts
|
|
16088
|
-
var init_arrow_transport = __esm({
|
|
16089
|
-
"../core/src/schema-utils/arrow-transport.ts"() {
|
|
16090
|
-
"use strict";
|
|
16091
|
-
init_arrow_table_transport();
|
|
16092
|
-
init_split_arrow_buffers();
|
|
16093
|
-
}
|
|
16094
|
-
});
|
|
16095
|
-
|
|
16096
|
-
// ../../node_modules/@math.gl/core/dist/types/float16.js
|
|
16097
|
-
function getFloat16ArrayConstructor() {
|
|
16098
|
-
return NativeFloat16ArrayConstructor ?? Uint16Array;
|
|
16099
|
-
}
|
|
16100
|
-
var NativeFloat16ArrayConstructor;
|
|
16101
|
-
var init_float16 = __esm({
|
|
16102
|
-
"../../node_modules/@math.gl/core/dist/types/float16.js"() {
|
|
16103
|
-
NativeFloat16ArrayConstructor = globalThis.Float16Array;
|
|
16104
|
-
}
|
|
16105
|
-
});
|
|
16106
|
-
|
|
16107
|
-
// ../../node_modules/@math.gl/core/dist/types/index.js
|
|
16108
|
-
var init_types = __esm({
|
|
16109
|
-
"../../node_modules/@math.gl/core/dist/types/index.js"() {
|
|
16110
|
-
init_float16();
|
|
16111
|
-
}
|
|
16112
|
-
});
|
|
16113
|
-
|
|
16114
|
-
// ../../node_modules/@math.gl/core/dist/types.js
|
|
16115
|
-
var init_types2 = __esm({
|
|
16116
|
-
"../../node_modules/@math.gl/core/dist/types.js"() {
|
|
16117
|
-
init_types();
|
|
16118
|
-
}
|
|
16119
|
-
});
|
|
16120
|
-
|
|
16121
|
-
// ../core/src/schema-utils/lib/schema/data-type.ts
|
|
16122
|
-
function getDataTypeFromValue(value, defaultNumberType = "float32") {
|
|
16123
|
-
if (value instanceof Date) {
|
|
16124
|
-
return "date-millisecond";
|
|
16125
|
-
}
|
|
16126
|
-
if (typeof value === "number") {
|
|
16127
|
-
return defaultNumberType;
|
|
16128
|
-
}
|
|
16129
|
-
if (typeof value === "boolean") {
|
|
16130
|
-
return "bool";
|
|
16131
|
-
}
|
|
16132
|
-
if (typeof value === "string") {
|
|
16133
|
-
return "utf8";
|
|
16134
|
-
}
|
|
16135
|
-
if (value === null || value === "undefined") {
|
|
16136
|
-
return "null";
|
|
16137
|
-
}
|
|
16138
|
-
return "null";
|
|
16139
|
-
}
|
|
16140
|
-
function getDataTypeFromArray(array) {
|
|
16141
|
-
let type = getDataTypeFromTypedArray(array);
|
|
16142
|
-
if (type !== "null") {
|
|
16143
|
-
return { type, nullable: false };
|
|
16144
|
-
}
|
|
16145
|
-
if (array.length > 0) {
|
|
16146
|
-
type = getDataTypeFromValue(array[0]);
|
|
16147
|
-
return { type, nullable: true };
|
|
16148
|
-
}
|
|
16149
|
-
return { type: "null", nullable: true };
|
|
16150
|
-
}
|
|
16151
|
-
function getDataTypeFromTypedArray(array) {
|
|
16152
|
-
if (typeof Float16Array !== "undefined" && array instanceof Float16Array) {
|
|
16153
|
-
return "float16";
|
|
16154
|
-
}
|
|
16155
|
-
switch (array.constructor) {
|
|
16156
|
-
case Int8Array:
|
|
16157
|
-
return "int8";
|
|
16158
|
-
case Uint8Array:
|
|
16159
|
-
case Uint8ClampedArray:
|
|
16160
|
-
return "uint8";
|
|
16161
|
-
case Int16Array:
|
|
16162
|
-
return "int16";
|
|
16163
|
-
case Uint16Array:
|
|
16164
|
-
return "uint16";
|
|
16165
|
-
case Int32Array:
|
|
16166
|
-
return "int32";
|
|
16167
|
-
case Uint32Array:
|
|
16168
|
-
return "uint32";
|
|
16169
|
-
case BigInt64Array:
|
|
16170
|
-
return "int64";
|
|
16171
|
-
case BigUint64Array:
|
|
16172
|
-
return "uint64";
|
|
16173
|
-
case Float32Array:
|
|
16174
|
-
return "float32";
|
|
16175
|
-
case Float64Array:
|
|
16176
|
-
return "float64";
|
|
16177
|
-
default:
|
|
16178
|
-
return "null";
|
|
16179
|
-
}
|
|
16180
|
-
}
|
|
16181
|
-
var init_data_type = __esm({
|
|
16182
|
-
"../core/src/schema-utils/lib/schema/data-type.ts"() {
|
|
16183
|
-
"use strict";
|
|
16184
|
-
}
|
|
16185
|
-
});
|
|
16186
|
-
|
|
16187
|
-
// ../core/src/schema-utils/lib/mesh/mesh-utils.ts
|
|
16188
|
-
function getMeshBoundingBox(attributes) {
|
|
16189
|
-
const positionAttribute = attributes?.POSITION;
|
|
16190
|
-
if (!positionAttribute || !("value" in positionAttribute) || !positionAttribute.value.length) {
|
|
16191
|
-
return null;
|
|
16087
|
+
});
|
|
16088
|
+
|
|
16089
|
+
// ../core/src/schema-utils/lib/mesh/get-mesh-bounding-box.ts
|
|
16090
|
+
function getMeshBoundingBox(attributes) {
|
|
16091
|
+
const positionAttribute = attributes?.POSITION;
|
|
16092
|
+
if (!positionAttribute || !("value" in positionAttribute) || !positionAttribute.value.length) {
|
|
16093
|
+
return null;
|
|
16192
16094
|
}
|
|
16193
16095
|
let minX = Infinity;
|
|
16194
16096
|
let minY = Infinity;
|
|
@@ -16214,9 +16116,17 @@ return true;`);
|
|
|
16214
16116
|
[maxX, maxY, maxZ]
|
|
16215
16117
|
];
|
|
16216
16118
|
}
|
|
16119
|
+
var init_get_mesh_bounding_box = __esm({
|
|
16120
|
+
"../core/src/schema-utils/lib/mesh/get-mesh-bounding-box.ts"() {
|
|
16121
|
+
"use strict";
|
|
16122
|
+
}
|
|
16123
|
+
});
|
|
16124
|
+
|
|
16125
|
+
// ../core/src/schema-utils/lib/mesh/mesh-utils.ts
|
|
16217
16126
|
var init_mesh_utils = __esm({
|
|
16218
16127
|
"../core/src/schema-utils/lib/mesh/mesh-utils.ts"() {
|
|
16219
16128
|
"use strict";
|
|
16129
|
+
init_get_mesh_bounding_box();
|
|
16220
16130
|
}
|
|
16221
16131
|
});
|
|
16222
16132
|
|
|
@@ -16285,7 +16195,7 @@ return true;`);
|
|
|
16285
16195
|
var init_float162 = __esm({
|
|
16286
16196
|
"../core/src/schema/float16.ts"() {
|
|
16287
16197
|
"use strict";
|
|
16288
|
-
|
|
16198
|
+
init_dist();
|
|
16289
16199
|
}
|
|
16290
16200
|
});
|
|
16291
16201
|
|
|
@@ -16369,31 +16279,7 @@ return true;`);
|
|
|
16369
16279
|
});
|
|
16370
16280
|
|
|
16371
16281
|
// ../core/src/schema-utils/lib/mesh/convert-mesh-to-table.ts
|
|
16372
|
-
function
|
|
16373
|
-
switch (shape) {
|
|
16374
|
-
case "columnar-table":
|
|
16375
|
-
return convertMeshToColumnarTable(mesh);
|
|
16376
|
-
case "arrow-table":
|
|
16377
|
-
return convertMeshToArrowTable(mesh);
|
|
16378
|
-
default:
|
|
16379
|
-
throw new Error(shape);
|
|
16380
|
-
}
|
|
16381
|
-
}
|
|
16382
|
-
function convertMeshToColumnarTable(mesh) {
|
|
16383
|
-
const columns = {};
|
|
16384
|
-
const hasIndices = hasMeshIndices(mesh);
|
|
16385
|
-
for (const [columnName, attribute] of Object.entries(mesh.attributes)) {
|
|
16386
|
-
columns[columnName] = attribute.value;
|
|
16387
|
-
}
|
|
16388
|
-
return {
|
|
16389
|
-
shape: "columnar-table",
|
|
16390
|
-
schema: mesh.schema,
|
|
16391
|
-
data: columns,
|
|
16392
|
-
topology: mesh.topology,
|
|
16393
|
-
indices: hasIndices ? mesh.indices : void 0
|
|
16394
|
-
};
|
|
16395
|
-
}
|
|
16396
|
-
function convertMeshToArrowTable(mesh, batchSize) {
|
|
16282
|
+
function convertMeshToArrowTableWrapper(mesh, batchSize) {
|
|
16397
16283
|
return makeMeshArrowTable(mesh.attributes, {
|
|
16398
16284
|
schema: mesh.schema,
|
|
16399
16285
|
topology: mesh.topology,
|
|
@@ -16554,6 +16440,7 @@ return true;`);
|
|
|
16554
16440
|
|
|
16555
16441
|
// ../core/src/schema-utils/lib/mesh/convert-table-to-mesh.ts
|
|
16556
16442
|
function convertTableToMesh(table) {
|
|
16443
|
+
if (isNativeArrowTable(table)) return convertArrowTableToMesh(table);
|
|
16557
16444
|
switch (table.shape) {
|
|
16558
16445
|
// case 'columnar-table':
|
|
16559
16446
|
// return convertColumnarTableToMesh(table);
|
|
@@ -16564,8 +16451,10 @@ return true;`);
|
|
|
16564
16451
|
}
|
|
16565
16452
|
}
|
|
16566
16453
|
function convertArrowTableToMesh(table) {
|
|
16567
|
-
const arrowTable = table.data;
|
|
16454
|
+
const arrowTable = isNativeArrowTable(table) ? table : table.data;
|
|
16568
16455
|
const schema = serializeArrowSchema(arrowTable.schema);
|
|
16456
|
+
const localBounds = arrowTable.batches.length === 1 ? arrowTable.batches[0].metadata.get("boundingBox") : void 0;
|
|
16457
|
+
if (localBounds) schema.metadata = { ...schema.metadata, boundingBox: localBounds };
|
|
16569
16458
|
const fields = schema.fields;
|
|
16570
16459
|
const attributes = {};
|
|
16571
16460
|
const columns = [];
|
|
@@ -16720,6 +16609,7 @@ return true;`);
|
|
|
16720
16609
|
init_Arrow_dom();
|
|
16721
16610
|
init_arrow_fixed_size_list_utils();
|
|
16722
16611
|
init_convert_arrow_schema();
|
|
16612
|
+
init_native_arrow();
|
|
16723
16613
|
init_mesh_utils();
|
|
16724
16614
|
}
|
|
16725
16615
|
});
|
|
@@ -17027,106 +16917,52 @@ return true;`);
|
|
|
17027
16917
|
|
|
17028
16918
|
// src/terrain/lib/helpers/skirt.ts
|
|
17029
16919
|
function addSkirt(attributes, triangles, skirtHeight, outsideIndices) {
|
|
17030
|
-
const
|
|
17031
|
-
const
|
|
17032
|
-
const
|
|
17033
|
-
const
|
|
17034
|
-
|
|
17035
|
-
|
|
17036
|
-
|
|
17037
|
-
|
|
17038
|
-
|
|
17039
|
-
|
|
17040
|
-
|
|
17041
|
-
|
|
17042
|
-
|
|
17043
|
-
|
|
17044
|
-
|
|
16920
|
+
const positions = attributes.POSITION.value;
|
|
16921
|
+
const sourceIndices = Array.isArray(triangles) ? Uint32Array.from(triangles) : triangles;
|
|
16922
|
+
const edges = outsideIndices ? getBoundaryEdges(outsideIndices, positions) : void 0;
|
|
16923
|
+
const skirt = createTerrainSkirt(
|
|
16924
|
+
{ positions, indices: sourceIndices },
|
|
16925
|
+
{ height: skirtHeight, edges }
|
|
16926
|
+
);
|
|
16927
|
+
const textureCoordinates = attributes.TEXCOORD_0.value;
|
|
16928
|
+
const outputTextureCoordinates = new textureCoordinates.constructor(
|
|
16929
|
+
skirt.positions.length / 3 * 2
|
|
16930
|
+
);
|
|
16931
|
+
outputTextureCoordinates.set(textureCoordinates);
|
|
16932
|
+
for (let i = 0; i < skirt.sourceVertexIndices.length; i++) {
|
|
16933
|
+
const source = skirt.sourceVertexIndices[i];
|
|
16934
|
+
outputTextureCoordinates.set(
|
|
16935
|
+
textureCoordinates.subarray(source * 2, source * 2 + 2),
|
|
16936
|
+
(skirt.skirtVertexOffset + i) * 2
|
|
16937
|
+
);
|
|
17045
16938
|
}
|
|
17046
|
-
attributes.POSITION.value =
|
|
17047
|
-
attributes.TEXCOORD_0.value =
|
|
17048
|
-
const resultTriangles = triangles instanceof Array ? triangles.concat(newTriangles) : concatenateTypedArrays(triangles, newTriangles);
|
|
16939
|
+
attributes.POSITION.value = skirt.positions;
|
|
16940
|
+
attributes.TEXCOORD_0.value = outputTextureCoordinates;
|
|
17049
16941
|
return {
|
|
17050
16942
|
attributes,
|
|
17051
|
-
triangles:
|
|
16943
|
+
triangles: Array.isArray(triangles) ? Array.from(skirt.indices) : skirt.indices
|
|
17052
16944
|
};
|
|
17053
16945
|
}
|
|
17054
|
-
function
|
|
17055
|
-
|
|
17056
|
-
|
|
17057
|
-
|
|
17058
|
-
|
|
17059
|
-
edges.push([triangles[i + 2], triangles[i]]);
|
|
17060
|
-
}
|
|
17061
|
-
edges.sort((a, b) => Math.min(...a) - Math.min(...b) || Math.max(...a) - Math.max(...b));
|
|
17062
|
-
const outsideEdges = [];
|
|
17063
|
-
let index = 0;
|
|
17064
|
-
while (index < edges.length) {
|
|
17065
|
-
if (edges[index][0] === edges[index + 1]?.[1] && edges[index][1] === edges[index + 1]?.[0]) {
|
|
17066
|
-
index += 2;
|
|
17067
|
-
} else {
|
|
17068
|
-
outsideEdges.push(edges[index]);
|
|
17069
|
-
index++;
|
|
17070
|
-
}
|
|
17071
|
-
}
|
|
17072
|
-
return outsideEdges;
|
|
17073
|
-
}
|
|
17074
|
-
function getOutsideEdgesFromIndices(indices, position) {
|
|
17075
|
-
indices.westIndices.sort((a, b) => position[3 * a + 1] - position[3 * b + 1]);
|
|
17076
|
-
indices.eastIndices.sort((a, b) => position[3 * b + 1] - position[3 * a + 1]);
|
|
17077
|
-
indices.southIndices.sort((a, b) => position[3 * b] - position[3 * a]);
|
|
17078
|
-
indices.northIndices.sort((a, b) => position[3 * a] - position[3 * b]);
|
|
16946
|
+
function getBoundaryEdges(indices, positions) {
|
|
16947
|
+
indices.westIndices.sort((a, b) => positions[3 * a + 1] - positions[3 * b + 1]);
|
|
16948
|
+
indices.eastIndices.sort((a, b) => positions[3 * b + 1] - positions[3 * a + 1]);
|
|
16949
|
+
indices.southIndices.sort((a, b) => positions[3 * b] - positions[3 * a]);
|
|
16950
|
+
indices.northIndices.sort((a, b) => positions[3 * a] - positions[3 * b]);
|
|
17079
16951
|
const edges = [];
|
|
17080
|
-
for (const
|
|
17081
|
-
|
|
17082
|
-
|
|
17083
|
-
|
|
17084
|
-
|
|
16952
|
+
for (const side of [
|
|
16953
|
+
indices.westIndices,
|
|
16954
|
+
indices.northIndices,
|
|
16955
|
+
indices.eastIndices,
|
|
16956
|
+
indices.southIndices
|
|
16957
|
+
]) {
|
|
16958
|
+
for (let i = 1; i < side.length; i++) edges.push(side[i - 1], side[i]);
|
|
17085
16959
|
}
|
|
17086
|
-
return edges;
|
|
17087
|
-
}
|
|
17088
|
-
function updateAttributesForNewEdge({
|
|
17089
|
-
edge,
|
|
17090
|
-
edgeIndex,
|
|
17091
|
-
attributes,
|
|
17092
|
-
skirtHeight,
|
|
17093
|
-
newPosition,
|
|
17094
|
-
newTexcoord0,
|
|
17095
|
-
newTriangles
|
|
17096
|
-
}) {
|
|
17097
|
-
const positionsLength = attributes.POSITION.value.length;
|
|
17098
|
-
const vertex1Offset = edgeIndex * 2;
|
|
17099
|
-
const vertex2Offset = edgeIndex * 2 + 1;
|
|
17100
|
-
newPosition.set(
|
|
17101
|
-
attributes.POSITION.value.subarray(edge[0] * 3, edge[0] * 3 + 3),
|
|
17102
|
-
vertex1Offset * 3
|
|
17103
|
-
);
|
|
17104
|
-
newPosition[vertex1Offset * 3 + 2] = newPosition[vertex1Offset * 3 + 2] - skirtHeight;
|
|
17105
|
-
newPosition.set(
|
|
17106
|
-
attributes.POSITION.value.subarray(edge[1] * 3, edge[1] * 3 + 3),
|
|
17107
|
-
vertex2Offset * 3
|
|
17108
|
-
);
|
|
17109
|
-
newPosition[vertex2Offset * 3 + 2] = newPosition[vertex2Offset * 3 + 2] - skirtHeight;
|
|
17110
|
-
newTexcoord0.set(
|
|
17111
|
-
attributes.TEXCOORD_0.value.subarray(edge[0] * 2, edge[0] * 2 + 2),
|
|
17112
|
-
vertex1Offset * 2
|
|
17113
|
-
);
|
|
17114
|
-
newTexcoord0.set(
|
|
17115
|
-
attributes.TEXCOORD_0.value.subarray(edge[1] * 2, edge[1] * 2 + 2),
|
|
17116
|
-
vertex2Offset * 2
|
|
17117
|
-
);
|
|
17118
|
-
const triangle1Offset = edgeIndex * 2 * 3;
|
|
17119
|
-
newTriangles[triangle1Offset] = edge[0];
|
|
17120
|
-
newTriangles[triangle1Offset + 1] = positionsLength / 3 + vertex2Offset;
|
|
17121
|
-
newTriangles[triangle1Offset + 2] = edge[1];
|
|
17122
|
-
newTriangles[triangle1Offset + 3] = positionsLength / 3 + vertex2Offset;
|
|
17123
|
-
newTriangles[triangle1Offset + 4] = edge[0];
|
|
17124
|
-
newTriangles[triangle1Offset + 5] = positionsLength / 3 + vertex1Offset;
|
|
16960
|
+
return Uint32Array.from(edges);
|
|
17125
16961
|
}
|
|
17126
16962
|
var init_skirt = __esm({
|
|
17127
16963
|
"src/terrain/lib/helpers/skirt.ts"() {
|
|
17128
16964
|
"use strict";
|
|
17129
|
-
|
|
16965
|
+
init_terrain();
|
|
17130
16966
|
}
|
|
17131
16967
|
});
|
|
17132
16968
|
|
|
@@ -17224,7 +17060,7 @@ return true;`);
|
|
|
17224
17060
|
var init_version = __esm({
|
|
17225
17061
|
"src/terrain/lib/utils/version.ts"() {
|
|
17226
17062
|
"use strict";
|
|
17227
|
-
VERSION = true ? "5.0.0-
|
|
17063
|
+
VERSION = true ? "5.0.0-beta.10" : "latest";
|
|
17228
17064
|
}
|
|
17229
17065
|
});
|
|
17230
17066
|
|
|
@@ -17246,14 +17082,28 @@ return true;`);
|
|
|
17246
17082
|
}
|
|
17247
17083
|
});
|
|
17248
17084
|
|
|
17249
|
-
// src/
|
|
17250
|
-
var
|
|
17251
|
-
|
|
17252
|
-
|
|
17253
|
-
|
|
17254
|
-
|
|
17085
|
+
// src/quantized-mesh-loader.ts
|
|
17086
|
+
var quantized_mesh_loader_exports = {};
|
|
17087
|
+
__export(quantized_mesh_loader_exports, {
|
|
17088
|
+
QuantizedMeshLoaderWithParser: () => QuantizedMeshLoaderWithParser
|
|
17089
|
+
});
|
|
17090
|
+
var init_quantized_mesh_loader = __esm({
|
|
17091
|
+
"src/quantized-mesh-loader.ts"() {
|
|
17092
|
+
"use strict";
|
|
17093
|
+
init_quantized_mesh_loader2();
|
|
17094
|
+
}
|
|
17095
|
+
});
|
|
17096
|
+
|
|
17097
|
+
// src/terrain/quantized-mesh-loader-types.ts
|
|
17098
|
+
var QuantizedMeshLoader;
|
|
17099
|
+
var init_quantized_mesh_loader_types = __esm({
|
|
17100
|
+
"src/terrain/quantized-mesh-loader-types.ts"() {
|
|
17101
|
+
"use strict";
|
|
17102
|
+
init_version();
|
|
17255
17103
|
init_terrain_format();
|
|
17256
17104
|
QuantizedMeshLoader = {
|
|
17105
|
+
defaultShape: "arrow",
|
|
17106
|
+
supportsNativeArrow: true,
|
|
17257
17107
|
dataType: null,
|
|
17258
17108
|
batchType: null,
|
|
17259
17109
|
...QuantizedMeshFormat,
|
|
@@ -17263,7 +17113,7 @@ return true;`);
|
|
|
17263
17113
|
preload: async () => (await Promise.resolve().then(() => (init_quantized_mesh_loader(), quantized_mesh_loader_exports))).QuantizedMeshLoaderWithParser,
|
|
17264
17114
|
options: {
|
|
17265
17115
|
"quantized-mesh": {
|
|
17266
|
-
shape: "arrow
|
|
17116
|
+
shape: "arrow",
|
|
17267
17117
|
bounds: [0, 0, 1, 1],
|
|
17268
17118
|
skirtHeight: null
|
|
17269
17119
|
}
|
|
@@ -17273,15 +17123,11 @@ return true;`);
|
|
|
17273
17123
|
});
|
|
17274
17124
|
|
|
17275
17125
|
// src/terrain/quantized-mesh-loader.ts
|
|
17276
|
-
var quantized_mesh_loader_exports = {};
|
|
17277
|
-
__export(quantized_mesh_loader_exports, {
|
|
17278
|
-
QuantizedMeshLoaderWithParser: () => QuantizedMeshLoaderWithParser
|
|
17279
|
-
});
|
|
17280
17126
|
function parseQuantizedMeshInRequestedShape(arrayBuffer, options) {
|
|
17281
17127
|
const mesh = parseQuantizedMesh(arrayBuffer, options?.["quantized-mesh"]);
|
|
17282
|
-
const table =
|
|
17283
|
-
if (options?.["quantized-mesh"]?.shape === "arrow
|
|
17284
|
-
return table;
|
|
17128
|
+
const table = convertMeshToArrowTableWrapper(mesh);
|
|
17129
|
+
if (options?.["quantized-mesh"]?.shape === "arrow") {
|
|
17130
|
+
return table.data;
|
|
17285
17131
|
}
|
|
17286
17132
|
return {
|
|
17287
17133
|
...convertTableToMesh(table),
|
|
@@ -17290,10 +17136,10 @@ return true;`);
|
|
|
17290
17136
|
};
|
|
17291
17137
|
}
|
|
17292
17138
|
var _QuantizedMeshLoaderPreload, QuantizedMeshLoaderMetadataWithoutPreload, QuantizedMeshLoaderWithParser;
|
|
17293
|
-
var
|
|
17139
|
+
var init_quantized_mesh_loader2 = __esm({
|
|
17294
17140
|
"src/terrain/quantized-mesh-loader.ts"() {
|
|
17295
17141
|
"use strict";
|
|
17296
|
-
|
|
17142
|
+
init_arrow_worker_transport();
|
|
17297
17143
|
init_schema_utils();
|
|
17298
17144
|
init_parse_quantized_mesh();
|
|
17299
17145
|
init_quantized_mesh_loader_types();
|
|
@@ -17308,8 +17154,1107 @@ return true;`);
|
|
|
17308
17154
|
}
|
|
17309
17155
|
});
|
|
17310
17156
|
|
|
17157
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js
|
|
17158
|
+
var parentPort = globalThis.process?.getBuiltinModule?.("node:worker_threads")?.parentPort ?? null;
|
|
17159
|
+
|
|
17160
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js
|
|
17161
|
+
function getTransferList(object, recursive = true, transfers) {
|
|
17162
|
+
const transfersSet = transfers || /* @__PURE__ */ new Set();
|
|
17163
|
+
const seen = /* @__PURE__ */ new Set();
|
|
17164
|
+
function visit(value) {
|
|
17165
|
+
if (!value || typeof value !== "object" || seen.has(value))
|
|
17166
|
+
return;
|
|
17167
|
+
seen.add(value);
|
|
17168
|
+
if (isTransferable(value))
|
|
17169
|
+
transfersSet.add(value);
|
|
17170
|
+
else if (ArrayBuffer.isView(value)) {
|
|
17171
|
+
if (isTransferable(value.buffer))
|
|
17172
|
+
transfersSet.add(value.buffer);
|
|
17173
|
+
} else if (recursive && typeof MessageChannel !== "undefined" && value instanceof MessageChannel) {
|
|
17174
|
+
visit(value.port1);
|
|
17175
|
+
visit(value.port2);
|
|
17176
|
+
} else if (recursive && value instanceof Map) {
|
|
17177
|
+
for (const [key, item] of value) {
|
|
17178
|
+
visit(key);
|
|
17179
|
+
visit(item);
|
|
17180
|
+
}
|
|
17181
|
+
} else if (recursive && value instanceof Set) {
|
|
17182
|
+
for (const item of value)
|
|
17183
|
+
visit(item);
|
|
17184
|
+
} else if (recursive) {
|
|
17185
|
+
for (const key of Object.keys(value))
|
|
17186
|
+
visit(value[key]);
|
|
17187
|
+
}
|
|
17188
|
+
}
|
|
17189
|
+
visit(object);
|
|
17190
|
+
return transfers === void 0 ? Array.from(transfersSet) : [];
|
|
17191
|
+
}
|
|
17192
|
+
function isTransferable(object) {
|
|
17193
|
+
if (!object) {
|
|
17194
|
+
return false;
|
|
17195
|
+
}
|
|
17196
|
+
if (object instanceof ArrayBuffer) {
|
|
17197
|
+
return true;
|
|
17198
|
+
}
|
|
17199
|
+
if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
|
|
17200
|
+
return true;
|
|
17201
|
+
}
|
|
17202
|
+
if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
|
|
17203
|
+
return true;
|
|
17204
|
+
}
|
|
17205
|
+
if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
|
|
17206
|
+
return true;
|
|
17207
|
+
}
|
|
17208
|
+
return false;
|
|
17209
|
+
}
|
|
17210
|
+
|
|
17211
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-body.js
|
|
17212
|
+
async function getParentPort() {
|
|
17213
|
+
return parentPort;
|
|
17214
|
+
}
|
|
17215
|
+
var onMessageWrapperMap = /* @__PURE__ */ new Map();
|
|
17216
|
+
var WorkerBody = class {
|
|
17217
|
+
/** Check that we are actually in a worker thread */
|
|
17218
|
+
static async inWorkerThread() {
|
|
17219
|
+
const workerGlobalScope = globalThis.WorkerGlobalScope;
|
|
17220
|
+
return typeof workerGlobalScope === "function" && globalThis instanceof workerGlobalScope || Boolean(await getParentPort());
|
|
17221
|
+
}
|
|
17222
|
+
/*
|
|
17223
|
+
* (type: WorkerMessageType, payload: WorkerMessagePayload) => any
|
|
17224
|
+
*/
|
|
17225
|
+
static set onmessage(onMessage) {
|
|
17226
|
+
async function handleMessage(message) {
|
|
17227
|
+
const parentPort3 = await getParentPort();
|
|
17228
|
+
const { type, payload } = parentPort3 ? message : message.data;
|
|
17229
|
+
onMessage(type, payload);
|
|
17230
|
+
}
|
|
17231
|
+
getParentPort().then((parentPort3) => {
|
|
17232
|
+
if (parentPort3) {
|
|
17233
|
+
parentPort3.on("message", (message) => {
|
|
17234
|
+
handleMessage(message);
|
|
17235
|
+
});
|
|
17236
|
+
parentPort3.on("exit", () => console.debug("Node worker closing"));
|
|
17237
|
+
} else {
|
|
17238
|
+
globalThis.onmessage = handleMessage;
|
|
17239
|
+
}
|
|
17240
|
+
});
|
|
17241
|
+
}
|
|
17242
|
+
static async addEventListener(onMessage) {
|
|
17243
|
+
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
17244
|
+
if (!onMessageWrapper) {
|
|
17245
|
+
onMessageWrapper = (message) => {
|
|
17246
|
+
const messageData = getWorkerMessageData(message);
|
|
17247
|
+
if (!messageData) {
|
|
17248
|
+
return;
|
|
17249
|
+
}
|
|
17250
|
+
onMessage(messageData.type, messageData.payload);
|
|
17251
|
+
};
|
|
17252
|
+
onMessageWrapperMap.set(onMessage, onMessageWrapper);
|
|
17253
|
+
}
|
|
17254
|
+
const parentPort3 = await getParentPort();
|
|
17255
|
+
if (parentPort3) {
|
|
17256
|
+
parentPort3.on("message", onMessageWrapper);
|
|
17257
|
+
} else {
|
|
17258
|
+
globalThis.addEventListener("message", onMessageWrapper);
|
|
17259
|
+
}
|
|
17260
|
+
}
|
|
17261
|
+
static async removeEventListener(onMessage) {
|
|
17262
|
+
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
17263
|
+
onMessageWrapperMap.delete(onMessage);
|
|
17264
|
+
if (!onMessageWrapper) {
|
|
17265
|
+
return;
|
|
17266
|
+
}
|
|
17267
|
+
const parentPort3 = await getParentPort();
|
|
17268
|
+
if (parentPort3) {
|
|
17269
|
+
parentPort3.off("message", onMessageWrapper);
|
|
17270
|
+
} else {
|
|
17271
|
+
globalThis.removeEventListener("message", onMessageWrapper);
|
|
17272
|
+
}
|
|
17273
|
+
}
|
|
17274
|
+
/**
|
|
17275
|
+
* Send a message from a worker to creating thread (main thread)
|
|
17276
|
+
* @param type
|
|
17277
|
+
* @param payload
|
|
17278
|
+
*/
|
|
17279
|
+
static async postMessage(type, payload, copy = false) {
|
|
17280
|
+
const data = { source: "loaders.gl", type, payload };
|
|
17281
|
+
const transferList = copy ? [] : getTransferList(payload);
|
|
17282
|
+
const parentPort3 = await getParentPort();
|
|
17283
|
+
if (parentPort3) {
|
|
17284
|
+
parentPort3.postMessage(data, transferList);
|
|
17285
|
+
} else {
|
|
17286
|
+
globalThis.postMessage(data, transferList);
|
|
17287
|
+
}
|
|
17288
|
+
}
|
|
17289
|
+
};
|
|
17290
|
+
function getWorkerMessageData(message) {
|
|
17291
|
+
if (!message || typeof message !== "object") {
|
|
17292
|
+
return null;
|
|
17293
|
+
}
|
|
17294
|
+
const messageData = "data" in message && message.type === "message" ? message.data : message;
|
|
17295
|
+
return messageData && typeof messageData.source === "string" && messageData.source.startsWith("loaders.gl") ? messageData : null;
|
|
17296
|
+
}
|
|
17297
|
+
|
|
17298
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js
|
|
17299
|
+
var AsyncQueue = class {
|
|
17300
|
+
constructor() {
|
|
17301
|
+
this._values = [];
|
|
17302
|
+
this._settlers = [];
|
|
17303
|
+
this._closed = false;
|
|
17304
|
+
}
|
|
17305
|
+
/** Return an async iterator for this queue */
|
|
17306
|
+
[Symbol.asyncIterator]() {
|
|
17307
|
+
return this;
|
|
17308
|
+
}
|
|
17309
|
+
/** Push a new value - the async iterator will yield a promise resolved to this value */
|
|
17310
|
+
push(value) {
|
|
17311
|
+
return this.enqueue(value);
|
|
17312
|
+
}
|
|
17313
|
+
/**
|
|
17314
|
+
* Push a new value - the async iterator will yield a promise resolved to this value
|
|
17315
|
+
* Add an error - the async iterator will yield a promise rejected with this value
|
|
17316
|
+
*/
|
|
17317
|
+
enqueue(value) {
|
|
17318
|
+
if (this._closed) {
|
|
17319
|
+
throw new Error("Closed");
|
|
17320
|
+
}
|
|
17321
|
+
if (this._settlers.length > 0) {
|
|
17322
|
+
if (this._values.length > 0) {
|
|
17323
|
+
throw new Error("Illegal internal state");
|
|
17324
|
+
}
|
|
17325
|
+
const settler = this._settlers.shift();
|
|
17326
|
+
if (value instanceof Error) {
|
|
17327
|
+
settler.reject(value);
|
|
17328
|
+
} else {
|
|
17329
|
+
settler.resolve({ value });
|
|
17330
|
+
}
|
|
17331
|
+
} else {
|
|
17332
|
+
this._values.push(value);
|
|
17333
|
+
}
|
|
17334
|
+
}
|
|
17335
|
+
/** Indicate that we not waiting for more values - The async iterator will be done */
|
|
17336
|
+
close() {
|
|
17337
|
+
while (this._settlers.length > 0) {
|
|
17338
|
+
const settler = this._settlers.shift();
|
|
17339
|
+
settler.resolve({ done: true });
|
|
17340
|
+
}
|
|
17341
|
+
this._closed = true;
|
|
17342
|
+
}
|
|
17343
|
+
// ITERATOR IMPLEMENTATION
|
|
17344
|
+
/** @returns a Promise for an IteratorResult */
|
|
17345
|
+
next() {
|
|
17346
|
+
if (this._values.length > 0) {
|
|
17347
|
+
const value = this._values.shift();
|
|
17348
|
+
if (value instanceof Error) {
|
|
17349
|
+
return Promise.reject(value);
|
|
17350
|
+
}
|
|
17351
|
+
return Promise.resolve({ done: false, value });
|
|
17352
|
+
}
|
|
17353
|
+
if (this._closed) {
|
|
17354
|
+
if (this._settlers.length > 0) {
|
|
17355
|
+
throw new Error("Illegal internal state");
|
|
17356
|
+
}
|
|
17357
|
+
return Promise.resolve({ done: true, value: void 0 });
|
|
17358
|
+
}
|
|
17359
|
+
return new Promise((resolve, reject) => {
|
|
17360
|
+
this._settlers.push({ resolve, reject });
|
|
17361
|
+
});
|
|
17362
|
+
}
|
|
17363
|
+
};
|
|
17364
|
+
|
|
17365
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js
|
|
17366
|
+
var SharedWorkerState = class {
|
|
17367
|
+
constructor(buffer) {
|
|
17368
|
+
if (typeof SharedArrayBuffer === "undefined" || !(buffer instanceof SharedArrayBuffer) || buffer.byteLength !== 16)
|
|
17369
|
+
throw new Error("Expected a 16-byte shared worker control buffer");
|
|
17370
|
+
this.buffer = buffer;
|
|
17371
|
+
this.values = new Int32Array(buffer);
|
|
17372
|
+
}
|
|
17373
|
+
get snapshot() {
|
|
17374
|
+
return {
|
|
17375
|
+
cancelled: Atomics.load(this.values, 0) !== 0,
|
|
17376
|
+
completed: Atomics.load(this.values, 1),
|
|
17377
|
+
total: Atomics.load(this.values, 2),
|
|
17378
|
+
revision: Atomics.load(this.values, 3)
|
|
17379
|
+
};
|
|
17380
|
+
}
|
|
17381
|
+
cancel() {
|
|
17382
|
+
Atomics.store(this.values, 0, 1);
|
|
17383
|
+
Atomics.add(this.values, 3, 1);
|
|
17384
|
+
Atomics.notify(this.values, 0);
|
|
17385
|
+
}
|
|
17386
|
+
throwIfCancelled() {
|
|
17387
|
+
if (Atomics.load(this.values, 0) !== 0) {
|
|
17388
|
+
const error = new Error("Shared worker task was cancelled");
|
|
17389
|
+
error.name = "AbortError";
|
|
17390
|
+
throw error;
|
|
17391
|
+
}
|
|
17392
|
+
}
|
|
17393
|
+
/** Integer counters for application-defined work; messages still carry phase names and units. */
|
|
17394
|
+
setProgress(completed, total = -1) {
|
|
17395
|
+
if (!Number.isInteger(completed) || completed < 0 || completed > 2147483647 || !Number.isInteger(total) || total < -1 || total > 2147483647) {
|
|
17396
|
+
throw new RangeError("Shared progress requires nonnegative int32 counts (or total -1)");
|
|
17397
|
+
}
|
|
17398
|
+
Atomics.store(this.values, 1, completed);
|
|
17399
|
+
Atomics.store(this.values, 2, total);
|
|
17400
|
+
Atomics.add(this.values, 3, 1);
|
|
17401
|
+
}
|
|
17402
|
+
};
|
|
17403
|
+
|
|
17404
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js
|
|
17405
|
+
function validateOutputOwnership(ownership) {
|
|
17406
|
+
if (ownership !== void 0 && ownership !== "copy" && ownership !== "transfer") {
|
|
17407
|
+
throw new Error("Invalid worker output ownership");
|
|
17408
|
+
}
|
|
17409
|
+
}
|
|
17410
|
+
|
|
17411
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/create-worker.js
|
|
17412
|
+
var requestId = 0;
|
|
17413
|
+
var activeController = null;
|
|
17414
|
+
var activeInputBatches = null;
|
|
17415
|
+
var activeOutputAcknowledgements = null;
|
|
17416
|
+
async function createWorker(process2, processInBatches, preload) {
|
|
17417
|
+
if (!await WorkerBody.inWorkerThread()) {
|
|
17418
|
+
return;
|
|
17419
|
+
}
|
|
17420
|
+
const context = {
|
|
17421
|
+
process: processOnMainThread
|
|
17422
|
+
};
|
|
17423
|
+
WorkerBody.onmessage = async (type, payload) => {
|
|
17424
|
+
if (type === "cancel") {
|
|
17425
|
+
activeController?.abort();
|
|
17426
|
+
activeInputBatches?.close();
|
|
17427
|
+
activeOutputAcknowledgements?.close();
|
|
17428
|
+
return;
|
|
17429
|
+
}
|
|
17430
|
+
const controller = type === "process" || type === "process-in-batches" ? new AbortController() : void 0;
|
|
17431
|
+
if (controller)
|
|
17432
|
+
activeController = controller;
|
|
17433
|
+
const startedAt = performance.now();
|
|
17434
|
+
const reporter = type === "process" || type === "process-in-batches" ? createProgressReporter() : void 0;
|
|
17435
|
+
let sharedState;
|
|
17436
|
+
const throwIfAborted = () => {
|
|
17437
|
+
controller?.signal.throwIfAborted();
|
|
17438
|
+
sharedState?.throwIfCancelled();
|
|
17439
|
+
};
|
|
17440
|
+
const jobContext = {
|
|
17441
|
+
...context,
|
|
17442
|
+
signal: controller?.signal,
|
|
17443
|
+
sharedState,
|
|
17444
|
+
throwIfAborted,
|
|
17445
|
+
reportProgress: (progress) => {
|
|
17446
|
+
if (!controller?.signal.aborted && !sharedState?.snapshot.cancelled)
|
|
17447
|
+
reporter?.report(progress);
|
|
17448
|
+
}
|
|
17449
|
+
};
|
|
17450
|
+
try {
|
|
17451
|
+
if (controller && payload.options?.["sharedState"]) {
|
|
17452
|
+
sharedState = new SharedWorkerState(payload.options["sharedState"]);
|
|
17453
|
+
jobContext.sharedState = sharedState;
|
|
17454
|
+
}
|
|
17455
|
+
switch (type) {
|
|
17456
|
+
case "preload":
|
|
17457
|
+
await preload?.();
|
|
17458
|
+
WorkerBody.postMessage("done", {});
|
|
17459
|
+
break;
|
|
17460
|
+
case "process":
|
|
17461
|
+
throwIfAborted();
|
|
17462
|
+
validateOutputOwnership(payload.options?.["outputOwnership"]);
|
|
17463
|
+
if (!process2) {
|
|
17464
|
+
throw new Error("Worker does not support atomic processing");
|
|
17465
|
+
}
|
|
17466
|
+
const result = await process2(payload.input, payload.options || {}, jobContext, payload.context || {});
|
|
17467
|
+
throwIfAborted();
|
|
17468
|
+
reporter?.finish();
|
|
17469
|
+
await WorkerBody.postMessage("done", {
|
|
17470
|
+
result,
|
|
17471
|
+
executionMs: performance.now() - startedAt
|
|
17472
|
+
}, payload.options?.["outputOwnership"] === "copy");
|
|
17473
|
+
break;
|
|
17474
|
+
case "process-in-batches":
|
|
17475
|
+
throwIfAborted();
|
|
17476
|
+
validateOutputOwnership(payload.options?.["outputOwnership"]);
|
|
17477
|
+
if (!processInBatches) {
|
|
17478
|
+
throw new Error("Worker does not support batched processing");
|
|
17479
|
+
}
|
|
17480
|
+
const inputBatches = new AsyncQueue();
|
|
17481
|
+
const outputAcknowledgements = new AsyncQueue();
|
|
17482
|
+
activeInputBatches = inputBatches;
|
|
17483
|
+
activeOutputAcknowledgements = outputAcknowledgements;
|
|
17484
|
+
try {
|
|
17485
|
+
const resultIterator = processInBatches(createDemandDrivenIterator(inputBatches), payload.options || {}, jobContext, payload.context || {});
|
|
17486
|
+
for await (const batch of resultIterator) {
|
|
17487
|
+
throwIfAborted();
|
|
17488
|
+
await WorkerBody.postMessage("output-batch", { result: batch }, payload.options?.["outputOwnership"] === "copy");
|
|
17489
|
+
await outputAcknowledgements.next();
|
|
17490
|
+
}
|
|
17491
|
+
throwIfAborted();
|
|
17492
|
+
reporter?.finish();
|
|
17493
|
+
await WorkerBody.postMessage("done", { executionMs: performance.now() - startedAt });
|
|
17494
|
+
} finally {
|
|
17495
|
+
activeInputBatches = null;
|
|
17496
|
+
activeOutputAcknowledgements = null;
|
|
17497
|
+
}
|
|
17498
|
+
break;
|
|
17499
|
+
case "input-batch":
|
|
17500
|
+
if (!activeInputBatches) {
|
|
17501
|
+
throw new Error("Worker has no active batched processing session");
|
|
17502
|
+
}
|
|
17503
|
+
activeInputBatches.push(payload.input);
|
|
17504
|
+
break;
|
|
17505
|
+
case "input-done":
|
|
17506
|
+
if (!activeInputBatches) {
|
|
17507
|
+
throw new Error("Worker has no active batched processing session");
|
|
17508
|
+
}
|
|
17509
|
+
activeInputBatches.close();
|
|
17510
|
+
break;
|
|
17511
|
+
case "output-ack":
|
|
17512
|
+
if (!activeOutputAcknowledgements) {
|
|
17513
|
+
throw new Error("Worker has no active batched processing session");
|
|
17514
|
+
}
|
|
17515
|
+
activeOutputAcknowledgements.push(void 0);
|
|
17516
|
+
break;
|
|
17517
|
+
default:
|
|
17518
|
+
}
|
|
17519
|
+
} catch (error) {
|
|
17520
|
+
reporter?.finish(controller?.signal.aborted || sharedState?.snapshot.cancelled);
|
|
17521
|
+
const message = error instanceof Error ? error.message : "";
|
|
17522
|
+
await WorkerBody.postMessage("error", {
|
|
17523
|
+
error: message,
|
|
17524
|
+
errorName: error instanceof Error ? error.name : "Error"
|
|
17525
|
+
});
|
|
17526
|
+
} finally {
|
|
17527
|
+
if (controller && activeController === controller)
|
|
17528
|
+
activeController = null;
|
|
17529
|
+
}
|
|
17530
|
+
};
|
|
17531
|
+
await WorkerBody.postMessage("ready", {});
|
|
17532
|
+
}
|
|
17533
|
+
async function* createDemandDrivenIterator(inputBatches) {
|
|
17534
|
+
while (true) {
|
|
17535
|
+
await WorkerBody.postMessage("input-request", {});
|
|
17536
|
+
const nextBatch = await inputBatches.next();
|
|
17537
|
+
if (nextBatch.done) {
|
|
17538
|
+
return;
|
|
17539
|
+
}
|
|
17540
|
+
yield nextBatch.value;
|
|
17541
|
+
}
|
|
17542
|
+
}
|
|
17543
|
+
function processOnMainThread(arrayBuffer, options = {}, jobContext = {}) {
|
|
17544
|
+
const signal = activeController?.signal;
|
|
17545
|
+
signal?.throwIfAborted();
|
|
17546
|
+
return new Promise((resolve, reject) => {
|
|
17547
|
+
const id = requestId++;
|
|
17548
|
+
const cleanup = () => {
|
|
17549
|
+
signal?.removeEventListener("abort", abort);
|
|
17550
|
+
void WorkerBody.removeEventListener(onMessage);
|
|
17551
|
+
};
|
|
17552
|
+
const abort = () => {
|
|
17553
|
+
cleanup();
|
|
17554
|
+
reject(signal?.reason);
|
|
17555
|
+
};
|
|
17556
|
+
const onMessage = (type, payload) => {
|
|
17557
|
+
if (payload.id !== id)
|
|
17558
|
+
return;
|
|
17559
|
+
if (type === "done") {
|
|
17560
|
+
cleanup();
|
|
17561
|
+
resolve(payload.result);
|
|
17562
|
+
} else if (type === "error") {
|
|
17563
|
+
cleanup();
|
|
17564
|
+
reject(payload.error);
|
|
17565
|
+
}
|
|
17566
|
+
};
|
|
17567
|
+
void WorkerBody.addEventListener(onMessage).then(async () => {
|
|
17568
|
+
if (signal?.aborted) {
|
|
17569
|
+
abort();
|
|
17570
|
+
return;
|
|
17571
|
+
}
|
|
17572
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
17573
|
+
await WorkerBody.postMessage("process", {
|
|
17574
|
+
id,
|
|
17575
|
+
input: arrayBuffer,
|
|
17576
|
+
options,
|
|
17577
|
+
context: jobContext
|
|
17578
|
+
});
|
|
17579
|
+
}).catch((error) => {
|
|
17580
|
+
cleanup();
|
|
17581
|
+
reject(error);
|
|
17582
|
+
});
|
|
17583
|
+
});
|
|
17584
|
+
}
|
|
17585
|
+
function createProgressReporter() {
|
|
17586
|
+
let pending2;
|
|
17587
|
+
let finished = false;
|
|
17588
|
+
let scheduled = false;
|
|
17589
|
+
const flush = () => {
|
|
17590
|
+
scheduled = false;
|
|
17591
|
+
if (pending2) {
|
|
17592
|
+
WorkerBody.postMessage("progress", { progress: pending2 });
|
|
17593
|
+
pending2 = void 0;
|
|
17594
|
+
}
|
|
17595
|
+
};
|
|
17596
|
+
return {
|
|
17597
|
+
/** Records progress while retaining phase transitions. */
|
|
17598
|
+
report(progress) {
|
|
17599
|
+
if (finished)
|
|
17600
|
+
return;
|
|
17601
|
+
if (pending2 && pending2.phase !== progress.phase)
|
|
17602
|
+
flush();
|
|
17603
|
+
pending2 = { ...progress };
|
|
17604
|
+
if (!scheduled) {
|
|
17605
|
+
scheduled = true;
|
|
17606
|
+
setTimeout(flush, 0);
|
|
17607
|
+
}
|
|
17608
|
+
},
|
|
17609
|
+
/** Flushes final progress and suppresses reports from stale callbacks. */
|
|
17610
|
+
finish(discard = false) {
|
|
17611
|
+
if (discard)
|
|
17612
|
+
pending2 = void 0;
|
|
17613
|
+
flush();
|
|
17614
|
+
finished = true;
|
|
17615
|
+
}
|
|
17616
|
+
};
|
|
17617
|
+
}
|
|
17618
|
+
|
|
17619
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/index.js
|
|
17620
|
+
var import_meta = {};
|
|
17621
|
+
var path = typeof __filename === "string" ? __filename.replace(/\\/g, "/") : "";
|
|
17622
|
+
var moduleUrl = path ? `file://${path.startsWith("/") ? "" : "/"}${encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F")}` : import_meta.url;
|
|
17623
|
+
|
|
17624
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js
|
|
17625
|
+
var pending = /* @__PURE__ */ new WeakMap();
|
|
17626
|
+
var loaded = /* @__PURE__ */ new WeakSet();
|
|
17627
|
+
function preloadTaskCode(task, signal) {
|
|
17628
|
+
if (!task.preload)
|
|
17629
|
+
return Promise.resolve();
|
|
17630
|
+
let promise = pending.get(task);
|
|
17631
|
+
if (!promise) {
|
|
17632
|
+
promise = Promise.resolve().then(() => task.preload()).then(() => {
|
|
17633
|
+
loaded.add(task);
|
|
17634
|
+
});
|
|
17635
|
+
pending.set(task, promise);
|
|
17636
|
+
void promise.catch(() => pending.delete(task));
|
|
17637
|
+
}
|
|
17638
|
+
return withSignal(promise, signal);
|
|
17639
|
+
}
|
|
17640
|
+
function withSignal(operation, signal) {
|
|
17641
|
+
if (!signal)
|
|
17642
|
+
return operation;
|
|
17643
|
+
return new Promise((resolve, reject) => {
|
|
17644
|
+
const abort = () => {
|
|
17645
|
+
signal.removeEventListener("abort", abort);
|
|
17646
|
+
reject(signal.reason);
|
|
17647
|
+
};
|
|
17648
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
17649
|
+
if (signal.aborted)
|
|
17650
|
+
abort();
|
|
17651
|
+
operation.then((value) => {
|
|
17652
|
+
signal.removeEventListener("abort", abort);
|
|
17653
|
+
resolve(value);
|
|
17654
|
+
}, (error) => {
|
|
17655
|
+
signal.removeEventListener("abort", abort);
|
|
17656
|
+
reject(error);
|
|
17657
|
+
});
|
|
17658
|
+
});
|
|
17659
|
+
}
|
|
17660
|
+
|
|
17661
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js
|
|
17662
|
+
var TaskRequestError = class extends Error {
|
|
17663
|
+
};
|
|
17664
|
+
var TaskChannel = class {
|
|
17665
|
+
constructor(options) {
|
|
17666
|
+
this.options = options;
|
|
17667
|
+
this.nextId = 1;
|
|
17668
|
+
this.pending = /* @__PURE__ */ new Map();
|
|
17669
|
+
this.incoming = /* @__PURE__ */ new Map();
|
|
17670
|
+
}
|
|
17671
|
+
/** Send a request without serializing other in-flight requests. */
|
|
17672
|
+
request(operation, value, signal, transfer = []) {
|
|
17673
|
+
if (this.failure)
|
|
17674
|
+
return Promise.reject(this.failure.reason);
|
|
17675
|
+
if (signal?.aborted)
|
|
17676
|
+
return Promise.reject(signal.reason);
|
|
17677
|
+
const id = this.nextId++;
|
|
17678
|
+
return new Promise((resolve, reject) => {
|
|
17679
|
+
const abort = () => {
|
|
17680
|
+
const pending2 = this.pending.get(id);
|
|
17681
|
+
if (!pending2)
|
|
17682
|
+
return;
|
|
17683
|
+
this.pending.delete(id);
|
|
17684
|
+
pending2.cleanup();
|
|
17685
|
+
reject(signal?.reason);
|
|
17686
|
+
this.send({ source: "math.gl/tasks", kind: "cancel", id });
|
|
17687
|
+
};
|
|
17688
|
+
this.pending.set(id, {
|
|
17689
|
+
resolve,
|
|
17690
|
+
reject,
|
|
17691
|
+
cleanup: () => signal?.removeEventListener("abort", abort)
|
|
17692
|
+
});
|
|
17693
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
17694
|
+
this.send({ source: "math.gl/tasks", kind: "request", id, operation, value }, transfer);
|
|
17695
|
+
});
|
|
17696
|
+
}
|
|
17697
|
+
/** Send a one-way notification. */
|
|
17698
|
+
emit(operation, value, transfer = []) {
|
|
17699
|
+
if (this.failure)
|
|
17700
|
+
throw this.failure.reason;
|
|
17701
|
+
this.send({ source: "math.gl/tasks", kind: "event", id: 0, operation, value }, transfer);
|
|
17702
|
+
}
|
|
17703
|
+
/** Dispatch a transport message; unrelated protocols are ignored. */
|
|
17704
|
+
receive(message) {
|
|
17705
|
+
if (this.failure || message?.source !== "math.gl/tasks")
|
|
17706
|
+
return;
|
|
17707
|
+
if (message.kind === "failure") {
|
|
17708
|
+
const reason = new Error(message.error?.message ?? "Task channel failed");
|
|
17709
|
+
this.close(reason);
|
|
17710
|
+
this.options.onFailure?.(reason);
|
|
17711
|
+
} else if (message.kind === "result" || message.kind === "error") {
|
|
17712
|
+
const pending2 = this.pending.get(message.id);
|
|
17713
|
+
if (!pending2)
|
|
17714
|
+
return;
|
|
17715
|
+
this.pending.delete(message.id);
|
|
17716
|
+
pending2.cleanup();
|
|
17717
|
+
if (message.kind === "result")
|
|
17718
|
+
pending2.resolve(message.value);
|
|
17719
|
+
else {
|
|
17720
|
+
const error = new TaskRequestError(message.error?.message ?? "Task request failed");
|
|
17721
|
+
error.name = message.error?.name ?? "Error";
|
|
17722
|
+
pending2.reject(error);
|
|
17723
|
+
}
|
|
17724
|
+
} else if (message.kind === "cancel") {
|
|
17725
|
+
this.incoming.get(message.id)?.abort(new DOMException("Task request cancelled", "AbortError"));
|
|
17726
|
+
} else if (message.kind === "event") {
|
|
17727
|
+
try {
|
|
17728
|
+
this.options.handleEvent?.(message.operation, message.value);
|
|
17729
|
+
} catch (error) {
|
|
17730
|
+
this.fail(error);
|
|
17731
|
+
}
|
|
17732
|
+
} else if (message.kind === "request") {
|
|
17733
|
+
if (this.incoming.has(message.id)) {
|
|
17734
|
+
this.fail(new Error("Duplicate task request identifier"));
|
|
17735
|
+
return;
|
|
17736
|
+
}
|
|
17737
|
+
const controller = new AbortController();
|
|
17738
|
+
this.incoming.set(message.id, controller);
|
|
17739
|
+
void Promise.resolve().then(() => {
|
|
17740
|
+
controller.signal.throwIfAborted();
|
|
17741
|
+
return this.options.handleRequest(message.operation, message.value, controller.signal);
|
|
17742
|
+
}).then((value) => {
|
|
17743
|
+
if (!controller.signal.aborted && !this.failure) {
|
|
17744
|
+
this.send({ source: "math.gl/tasks", kind: "result", id: message.id, value }, this.options.getResultTransferList?.(value, message.value));
|
|
17745
|
+
}
|
|
17746
|
+
}).catch((reason) => {
|
|
17747
|
+
if (!controller.signal.aborted && !this.failure) {
|
|
17748
|
+
this.send({
|
|
17749
|
+
source: "math.gl/tasks",
|
|
17750
|
+
kind: "error",
|
|
17751
|
+
id: message.id,
|
|
17752
|
+
error: {
|
|
17753
|
+
name: reason instanceof Error ? reason.name : "Error",
|
|
17754
|
+
message: reason instanceof Error ? reason.message : String(reason)
|
|
17755
|
+
}
|
|
17756
|
+
});
|
|
17757
|
+
}
|
|
17758
|
+
}).finally(() => this.incoming.delete(message.id));
|
|
17759
|
+
}
|
|
17760
|
+
}
|
|
17761
|
+
/** Reject all outstanding calls with a common cause and abort incoming callbacks. */
|
|
17762
|
+
close(reason = new Error("Task channel closed")) {
|
|
17763
|
+
if (this.failure)
|
|
17764
|
+
return;
|
|
17765
|
+
this.failure = { reason };
|
|
17766
|
+
for (const pending2 of this.pending.values()) {
|
|
17767
|
+
pending2.cleanup();
|
|
17768
|
+
pending2.reject(reason);
|
|
17769
|
+
}
|
|
17770
|
+
this.pending.clear();
|
|
17771
|
+
for (const controller of this.incoming.values())
|
|
17772
|
+
controller.abort(reason);
|
|
17773
|
+
this.incoming.clear();
|
|
17774
|
+
}
|
|
17775
|
+
send(message, transfer = []) {
|
|
17776
|
+
if (this.failure)
|
|
17777
|
+
return;
|
|
17778
|
+
try {
|
|
17779
|
+
this.options.send(message, transfer);
|
|
17780
|
+
} catch (error) {
|
|
17781
|
+
this.fail(error);
|
|
17782
|
+
}
|
|
17783
|
+
}
|
|
17784
|
+
/** Invalidate the channel and notify the peer when the transport still works. */
|
|
17785
|
+
fail(reason) {
|
|
17786
|
+
if (this.failure)
|
|
17787
|
+
return;
|
|
17788
|
+
this.close(reason);
|
|
17789
|
+
try {
|
|
17790
|
+
this.options.send({
|
|
17791
|
+
source: "math.gl/tasks",
|
|
17792
|
+
kind: "failure",
|
|
17793
|
+
id: 0,
|
|
17794
|
+
error: {
|
|
17795
|
+
name: reason instanceof Error ? reason.name : "Error",
|
|
17796
|
+
message: reason instanceof Error ? reason.message : String(reason)
|
|
17797
|
+
}
|
|
17798
|
+
}, []);
|
|
17799
|
+
} catch {
|
|
17800
|
+
}
|
|
17801
|
+
this.options.onFailure?.(reason);
|
|
17802
|
+
}
|
|
17803
|
+
};
|
|
17804
|
+
|
|
17805
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js
|
|
17806
|
+
function assertPayload(value) {
|
|
17807
|
+
if (!value || typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype) {
|
|
17808
|
+
throw new TypeError("Task payloads must be plain objects with named fields");
|
|
17809
|
+
}
|
|
17810
|
+
}
|
|
17811
|
+
function clonePayload(value, ownership = "copy") {
|
|
17812
|
+
assertPayload(value);
|
|
17813
|
+
if (!["copy", "transfer", "share"].includes(ownership))
|
|
17814
|
+
throw new TypeError("Invalid input ownership");
|
|
17815
|
+
const transfer = getTransferList(value);
|
|
17816
|
+
if (ownership === "share" && transfer.length)
|
|
17817
|
+
throw new TypeError("Share requires shared storage");
|
|
17818
|
+
return structuredClone(value, {
|
|
17819
|
+
transfer: ownership === "transfer" ? transfer : []
|
|
17820
|
+
});
|
|
17821
|
+
}
|
|
17822
|
+
function taskContext(state, context = {}) {
|
|
17823
|
+
const signal = context.signal ?? new AbortController().signal;
|
|
17824
|
+
return {
|
|
17825
|
+
state,
|
|
17826
|
+
signal,
|
|
17827
|
+
requestHost: async (operation, payload, controls) => {
|
|
17828
|
+
signal.throwIfAborted();
|
|
17829
|
+
if (!context.requestHost)
|
|
17830
|
+
throw new Error("No host request handler configured");
|
|
17831
|
+
return context.requestHost(operation, payload, controls);
|
|
17832
|
+
},
|
|
17833
|
+
emitHost: (operation, payload) => {
|
|
17834
|
+
signal.throwIfAborted();
|
|
17835
|
+
context.emitHost?.(operation, payload);
|
|
17836
|
+
},
|
|
17837
|
+
throwIfAborted: () => {
|
|
17838
|
+
signal.throwIfAborted();
|
|
17839
|
+
context.throwIfAborted?.();
|
|
17840
|
+
},
|
|
17841
|
+
reportProgress: (progress) => context.reportProgress?.({
|
|
17842
|
+
...progress,
|
|
17843
|
+
phase: progress.phase ?? "process",
|
|
17844
|
+
unit: progress.unit ?? "items"
|
|
17845
|
+
})
|
|
17846
|
+
};
|
|
17847
|
+
}
|
|
17848
|
+
var TaskRuntime = class {
|
|
17849
|
+
constructor(task) {
|
|
17850
|
+
this.task = task;
|
|
17851
|
+
this.initialized = false;
|
|
17852
|
+
}
|
|
17853
|
+
async initialize(input, context = {}) {
|
|
17854
|
+
if (this.initialized)
|
|
17855
|
+
throw new Error("Task is already initialized");
|
|
17856
|
+
assertPayload(input);
|
|
17857
|
+
await preloadTaskCode(this.task, context.signal);
|
|
17858
|
+
context.signal?.throwIfAborted();
|
|
17859
|
+
this.state = await this.task.initialize?.(input, taskContext(void 0, context));
|
|
17860
|
+
this.initialized = true;
|
|
17861
|
+
return {};
|
|
17862
|
+
}
|
|
17863
|
+
async destroy() {
|
|
17864
|
+
if (this.initialized) {
|
|
17865
|
+
this.initialized = false;
|
|
17866
|
+
const state = this.state;
|
|
17867
|
+
this.state = void 0;
|
|
17868
|
+
if (this.task.initialize)
|
|
17869
|
+
await this.task.destroy?.(state);
|
|
17870
|
+
}
|
|
17871
|
+
return {};
|
|
17872
|
+
}
|
|
17873
|
+
async process(input, options, context = {}) {
|
|
17874
|
+
if (!this.initialized)
|
|
17875
|
+
throw new Error("Task is not initialized");
|
|
17876
|
+
if (!this.task.process)
|
|
17877
|
+
throw new Error("Task has no atomic processor");
|
|
17878
|
+
assertPayload(input);
|
|
17879
|
+
const result = await this.task.process(input, options, taskContext(this.state, context));
|
|
17880
|
+
assertPayload(result);
|
|
17881
|
+
return result;
|
|
17882
|
+
}
|
|
17883
|
+
async *stream(inputs, options, context = {}) {
|
|
17884
|
+
if (!this.initialized)
|
|
17885
|
+
throw new Error("Task is not initialized");
|
|
17886
|
+
if (!this.task.processInBatches)
|
|
17887
|
+
throw new Error("Task has no streaming processor");
|
|
17888
|
+
for await (const output of this.task.processInBatches(inputs, options, taskContext(this.state, context))) {
|
|
17889
|
+
assertPayload(output);
|
|
17890
|
+
yield output;
|
|
17891
|
+
}
|
|
17892
|
+
}
|
|
17893
|
+
};
|
|
17894
|
+
async function initializeTaskWorker(task) {
|
|
17895
|
+
if (!await WorkerBody.inWorkerThread())
|
|
17896
|
+
throw new Error("initializeTaskWorker must run inside a worker");
|
|
17897
|
+
if (installed)
|
|
17898
|
+
throw new Error("A task is already installed in this worker");
|
|
17899
|
+
installed = true;
|
|
17900
|
+
const runtime = new TaskRuntime(task);
|
|
17901
|
+
let channelStream;
|
|
17902
|
+
const channel = new TaskChannel({
|
|
17903
|
+
getResultTransferList: (value, request) => request.outputOwnership === "transfer" ? getTransferList(value) : [],
|
|
17904
|
+
send: (message, transfer) => {
|
|
17905
|
+
const snapshot = structuredClone(message, { transfer });
|
|
17906
|
+
void WorkerBody.postMessage("task-channel", snapshot).catch((reason) => channel.fail(reason));
|
|
17907
|
+
},
|
|
17908
|
+
handleRequest: async (operation, value, signal) => {
|
|
17909
|
+
const request = value;
|
|
17910
|
+
const context = {
|
|
17911
|
+
signal,
|
|
17912
|
+
reportProgress: (progress) => channel.emit("task:progress", { id: request.progressId, progress }),
|
|
17913
|
+
requestHost: (operation2, payload, controls = {}) => {
|
|
17914
|
+
const request2 = {
|
|
17915
|
+
operation: operation2,
|
|
17916
|
+
payload: clonePayload(payload, controls.inputOwnership),
|
|
17917
|
+
outputOwnership: controls.outputOwnership ?? "copy"
|
|
17918
|
+
};
|
|
17919
|
+
return channel.request("task:host-request", request2, signal, getTransferList(request2));
|
|
17920
|
+
},
|
|
17921
|
+
emitHost: (operation2, payload) => channel.emit("task:host-event", { operation: operation2, payload, id: request.progressId })
|
|
17922
|
+
};
|
|
17923
|
+
switch (operation) {
|
|
17924
|
+
case "initialize":
|
|
17925
|
+
return runtime.initialize(request.input, context);
|
|
17926
|
+
case "process":
|
|
17927
|
+
return runtime.process(request.input, request.options, context);
|
|
17928
|
+
case "stream-open": {
|
|
17929
|
+
if (channelStream)
|
|
17930
|
+
throw new Error("A task stream is already open");
|
|
17931
|
+
async function* inputs() {
|
|
17932
|
+
while (true) {
|
|
17933
|
+
const result = await channel.request("task:next-input", { outputOwnership: "transfer" }, signal);
|
|
17934
|
+
if (result.done)
|
|
17935
|
+
return;
|
|
17936
|
+
yield result.value;
|
|
17937
|
+
}
|
|
17938
|
+
}
|
|
17939
|
+
channelStream = runtime.stream(inputs(), request.options, context)[Symbol.asyncIterator]();
|
|
17940
|
+
return {};
|
|
17941
|
+
}
|
|
17942
|
+
case "stream-next":
|
|
17943
|
+
if (!channelStream)
|
|
17944
|
+
throw new Error("No active task stream");
|
|
17945
|
+
return channelStream.next();
|
|
17946
|
+
case "stream-close":
|
|
17947
|
+
try {
|
|
17948
|
+
await channelStream?.return?.();
|
|
17949
|
+
} finally {
|
|
17950
|
+
channelStream = void 0;
|
|
17951
|
+
}
|
|
17952
|
+
return {};
|
|
17953
|
+
case "destroy":
|
|
17954
|
+
return runtime.destroy();
|
|
17955
|
+
default:
|
|
17956
|
+
throw new Error("Unknown task channel operation");
|
|
17957
|
+
}
|
|
17958
|
+
}
|
|
17959
|
+
});
|
|
17960
|
+
await WorkerBody.addEventListener((type, payload) => {
|
|
17961
|
+
if (type === "task-channel")
|
|
17962
|
+
channel.receive(payload);
|
|
17963
|
+
});
|
|
17964
|
+
let streamOptions = {};
|
|
17965
|
+
return createWorker(async (request, _options, context) => {
|
|
17966
|
+
switch (request.operation) {
|
|
17967
|
+
case "initialize":
|
|
17968
|
+
return runtime.initialize(request.input, context);
|
|
17969
|
+
case "destroy":
|
|
17970
|
+
return runtime.destroy();
|
|
17971
|
+
case "stream-options":
|
|
17972
|
+
streamOptions = request.options;
|
|
17973
|
+
return {};
|
|
17974
|
+
case "process":
|
|
17975
|
+
return runtime.process(request.input, request.options, context);
|
|
17976
|
+
default:
|
|
17977
|
+
throw new Error("Unknown task operation");
|
|
17978
|
+
}
|
|
17979
|
+
}, async function* (inputs, _options, context) {
|
|
17980
|
+
async function* batches() {
|
|
17981
|
+
for await (const input of inputs) {
|
|
17982
|
+
assertPayload(input);
|
|
17983
|
+
yield input;
|
|
17984
|
+
}
|
|
17985
|
+
}
|
|
17986
|
+
try {
|
|
17987
|
+
yield* runtime.stream(batches(), streamOptions, context);
|
|
17988
|
+
} finally {
|
|
17989
|
+
streamOptions = {};
|
|
17990
|
+
}
|
|
17991
|
+
}, () => preloadTaskCode(task));
|
|
17992
|
+
}
|
|
17993
|
+
var installed = false;
|
|
17994
|
+
|
|
17995
|
+
// ../core/src/worker-utils/lib/worker-api/task-runtime.ts
|
|
17996
|
+
function normalizeTaskProgress(progress) {
|
|
17997
|
+
return { ...progress, phase: progress.phase ?? "process", unit: progress.unit ?? "items" };
|
|
17998
|
+
}
|
|
17999
|
+
async function isWorkerThread() {
|
|
18000
|
+
if (typeof self !== "undefined" && typeof document === "undefined" && typeof self.postMessage === "function")
|
|
18001
|
+
return true;
|
|
18002
|
+
if (typeof process !== "undefined" && process.versions?.node) {
|
|
18003
|
+
const { isMainThread } = await Promise.resolve().then(() => (init_worker_threads_browser(), worker_threads_browser_exports));
|
|
18004
|
+
return !isMainThread;
|
|
18005
|
+
}
|
|
18006
|
+
return false;
|
|
18007
|
+
}
|
|
18008
|
+
var initializeTaskWorker2 = initializeTaskWorker;
|
|
18009
|
+
|
|
18010
|
+
// ../core/src/worker-utils/lib/worker-utils/get-transfer-list.ts
|
|
18011
|
+
function getTransferList2(object, recursive = true, transfers) {
|
|
18012
|
+
const transfersSet = transfers || /* @__PURE__ */ new Set();
|
|
18013
|
+
if (!object) {
|
|
18014
|
+
} else if (isTransferable2(object)) {
|
|
18015
|
+
transfersSet.add(object);
|
|
18016
|
+
} else if (isTransferable2(object.buffer)) {
|
|
18017
|
+
transfersSet.add(object.buffer);
|
|
18018
|
+
} else if (ArrayBuffer.isView(object)) {
|
|
18019
|
+
} else if (recursive && typeof object === "object") {
|
|
18020
|
+
for (const key in object) {
|
|
18021
|
+
getTransferList2(object[key], recursive, transfersSet);
|
|
18022
|
+
}
|
|
18023
|
+
}
|
|
18024
|
+
return transfers === void 0 ? Array.from(transfersSet) : [];
|
|
18025
|
+
}
|
|
18026
|
+
function isTransferable2(object) {
|
|
18027
|
+
if (!object) {
|
|
18028
|
+
return false;
|
|
18029
|
+
}
|
|
18030
|
+
if (object instanceof ArrayBuffer) {
|
|
18031
|
+
return true;
|
|
18032
|
+
}
|
|
18033
|
+
if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
|
|
18034
|
+
return true;
|
|
18035
|
+
}
|
|
18036
|
+
if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
|
|
18037
|
+
return true;
|
|
18038
|
+
}
|
|
18039
|
+
if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
|
|
18040
|
+
return true;
|
|
18041
|
+
}
|
|
18042
|
+
return false;
|
|
18043
|
+
}
|
|
18044
|
+
|
|
18045
|
+
// ../core/src/worker-utils/lib/worker-api/create-worker.ts
|
|
18046
|
+
async function createWorker2(process2, processInBatches) {
|
|
18047
|
+
if (!await isWorkerThread()) return;
|
|
18048
|
+
await initializeTaskWorker2(createWorkerTask(process2, processInBatches));
|
|
18049
|
+
}
|
|
18050
|
+
function createWorkerTask(process2, processInBatches) {
|
|
18051
|
+
return {
|
|
18052
|
+
id: "loaders.gl",
|
|
18053
|
+
initialize: (state) => state,
|
|
18054
|
+
destroy: (state) => state.port?.close(),
|
|
18055
|
+
process: async ({ value }, options, context) => {
|
|
18056
|
+
if (!process2) throw new Error("Worker does not support atomic processing");
|
|
18057
|
+
return { value: await process2(value, options, createContext(context), context.state.context) };
|
|
18058
|
+
},
|
|
18059
|
+
...processInBatches ? {
|
|
18060
|
+
processInBatches: async function* (inputs, options, context) {
|
|
18061
|
+
async function* values() {
|
|
18062
|
+
for await (const input of inputs) yield input.value;
|
|
18063
|
+
}
|
|
18064
|
+
for await (const value of processInBatches(
|
|
18065
|
+
values(),
|
|
18066
|
+
options,
|
|
18067
|
+
createContext(context),
|
|
18068
|
+
context.state.context
|
|
18069
|
+
)) {
|
|
18070
|
+
yield { value };
|
|
18071
|
+
}
|
|
18072
|
+
}
|
|
18073
|
+
} : {}
|
|
18074
|
+
};
|
|
18075
|
+
}
|
|
18076
|
+
function createContext(context) {
|
|
18077
|
+
let requestIdentifier = 0;
|
|
18078
|
+
const port = context.state.port;
|
|
18079
|
+
return {
|
|
18080
|
+
signal: context.signal,
|
|
18081
|
+
throwIfAborted: () => context.throwIfAborted(),
|
|
18082
|
+
reportProgress: (progress) => context.reportProgress(normalizeTaskProgress(progress)),
|
|
18083
|
+
process: port ? (input, options = {}, jobContext = {}) => {
|
|
18084
|
+
context.throwIfAborted();
|
|
18085
|
+
const identifier = ++requestIdentifier;
|
|
18086
|
+
return new Promise((resolve, reject) => {
|
|
18087
|
+
const onMessage = (event) => {
|
|
18088
|
+
if (event.data.identifier !== identifier) return;
|
|
18089
|
+
cleanup();
|
|
18090
|
+
if (event.data.error) {
|
|
18091
|
+
const error = new Error(event.data.error.message);
|
|
18092
|
+
error.name = event.data.error.name;
|
|
18093
|
+
reject(error);
|
|
18094
|
+
} else resolve(event.data.value);
|
|
18095
|
+
};
|
|
18096
|
+
const onAbort = () => {
|
|
18097
|
+
cleanup();
|
|
18098
|
+
reject(context.signal.reason);
|
|
18099
|
+
};
|
|
18100
|
+
const cleanup = () => {
|
|
18101
|
+
port.removeEventListener("message", onMessage);
|
|
18102
|
+
context.signal.removeEventListener("abort", onAbort);
|
|
18103
|
+
};
|
|
18104
|
+
port.addEventListener("message", onMessage);
|
|
18105
|
+
context.signal.addEventListener("abort", onAbort, { once: true });
|
|
18106
|
+
port.start();
|
|
18107
|
+
try {
|
|
18108
|
+
const request = { identifier, input, options, context: jobContext };
|
|
18109
|
+
port.postMessage(request, getTransferList2(request));
|
|
18110
|
+
} catch (error) {
|
|
18111
|
+
cleanup();
|
|
18112
|
+
reject(error);
|
|
18113
|
+
}
|
|
18114
|
+
});
|
|
18115
|
+
} : void 0
|
|
18116
|
+
};
|
|
18117
|
+
}
|
|
18118
|
+
|
|
18119
|
+
// ../core/src/loader-utils/lib/worker-loader-utils/create-loader-worker.ts
|
|
18120
|
+
async function createLoaderWorker(loader, selectLoader = () => loader) {
|
|
18121
|
+
await createWorker2(
|
|
18122
|
+
(input, options, workerContext, loaderContext) => processLoaderWorkerData(
|
|
18123
|
+
selectLoader(options || {}),
|
|
18124
|
+
input,
|
|
18125
|
+
options,
|
|
18126
|
+
workerContext,
|
|
18127
|
+
loaderContext
|
|
18128
|
+
),
|
|
18129
|
+
(inputIterator, options, workerContext, loaderContext) => processLoaderWorkerBatches(
|
|
18130
|
+
selectLoader(options || {}),
|
|
18131
|
+
inputIterator,
|
|
18132
|
+
options,
|
|
18133
|
+
workerContext,
|
|
18134
|
+
loaderContext
|
|
18135
|
+
)
|
|
18136
|
+
);
|
|
18137
|
+
}
|
|
18138
|
+
async function processLoaderWorkerData(loader, input, options = {}, workerContext, loaderContext = {}) {
|
|
18139
|
+
const result = await parseData({
|
|
18140
|
+
loader,
|
|
18141
|
+
arrayBuffer: input,
|
|
18142
|
+
options,
|
|
18143
|
+
context: {
|
|
18144
|
+
...loaderContext,
|
|
18145
|
+
reportProgress: workerContext?.reportProgress,
|
|
18146
|
+
coreApi: createWorkerCoreApi(),
|
|
18147
|
+
_parse: createParseOnMainThread(workerContext?.process)
|
|
18148
|
+
}
|
|
18149
|
+
});
|
|
18150
|
+
return loader.serializeWorkerResult ? loader.serializeWorkerResult(result, options, loaderContext) : result;
|
|
18151
|
+
}
|
|
18152
|
+
async function* processLoaderWorkerBatches(loader, inputIterator, options = {}, workerContext, loaderContext = {}) {
|
|
18153
|
+
if (!loader.parseInBatches) {
|
|
18154
|
+
throw new Error(`${loader.id} loader does not support batched parsing`);
|
|
18155
|
+
}
|
|
18156
|
+
const parserOptions = getWorkerLoaderOptions(loader, options);
|
|
18157
|
+
const resultIterator = loader.parseInBatches(inputIterator, parserOptions, {
|
|
18158
|
+
...loaderContext,
|
|
18159
|
+
reportProgress: workerContext?.reportProgress,
|
|
18160
|
+
coreApi: createWorkerCoreApi(),
|
|
18161
|
+
_parse: createParseOnMainThread(workerContext?.process)
|
|
18162
|
+
});
|
|
18163
|
+
for await (const batch of resultIterator) {
|
|
18164
|
+
yield loader.serializeWorkerBatch ? loader.serializeWorkerBatch(batch, options, loaderContext) : batch;
|
|
18165
|
+
}
|
|
18166
|
+
}
|
|
18167
|
+
function createWorkerCoreApi() {
|
|
18168
|
+
const unavailable = (methodName) => () => {
|
|
18169
|
+
throw new Error(`context.coreApi.${methodName} is unavailable inside worker loaders.`);
|
|
18170
|
+
};
|
|
18171
|
+
return {
|
|
18172
|
+
fetchFile: async (urlOrData, fetchOptions) => await fetch(urlOrData, fetchOptions),
|
|
18173
|
+
parseSync: unavailable("parseSync"),
|
|
18174
|
+
parse: unavailable("parse"),
|
|
18175
|
+
parseFile: unavailable("parseFile"),
|
|
18176
|
+
parseInBatches: unavailable("parseInBatches"),
|
|
18177
|
+
load: unavailable("load"),
|
|
18178
|
+
loadInBatches: unavailable("loadInBatches")
|
|
18179
|
+
};
|
|
18180
|
+
}
|
|
18181
|
+
function createParseOnMainThread(processOnMainThread2) {
|
|
18182
|
+
return (arrayBuffer, loaders, options, context) => {
|
|
18183
|
+
if (!processOnMainThread2) {
|
|
18184
|
+
throw new Error("Worker not set up to parse on main thread");
|
|
18185
|
+
}
|
|
18186
|
+
const parseArguments = getMainThreadParseArguments(loaders, options, context);
|
|
18187
|
+
return processOnMainThread2(arrayBuffer, parseArguments.options, {
|
|
18188
|
+
...parseArguments.context,
|
|
18189
|
+
...Array.isArray(loaders) || loaders && isLoaderObject(loaders) ? {
|
|
18190
|
+
_loaderIsArray: Array.isArray(loaders),
|
|
18191
|
+
_loaderIds: (Array.isArray(loaders) ? loaders : [loaders]).map((loader) => loader.id)
|
|
18192
|
+
} : {}
|
|
18193
|
+
});
|
|
18194
|
+
};
|
|
18195
|
+
}
|
|
18196
|
+
function getMainThreadParseArguments(loaders, options, context) {
|
|
18197
|
+
if (options) {
|
|
18198
|
+
return { options, context: getSerializableLoaderContext(context) };
|
|
18199
|
+
}
|
|
18200
|
+
if (Array.isArray(loaders) || loaders && isLoaderObject(loaders)) {
|
|
18201
|
+
return { options: void 0, context: getSerializableLoaderContext(context) };
|
|
18202
|
+
}
|
|
18203
|
+
if (loaders && !Array.isArray(loaders)) {
|
|
18204
|
+
return { options: loaders };
|
|
18205
|
+
}
|
|
18206
|
+
return { options: void 0, context: getSerializableLoaderContext(context) };
|
|
18207
|
+
}
|
|
18208
|
+
function isLoaderObject(value) {
|
|
18209
|
+
return "id" in value && "extensions" in value;
|
|
18210
|
+
}
|
|
18211
|
+
function getSerializableLoaderContext(context) {
|
|
18212
|
+
if (!context) {
|
|
18213
|
+
return void 0;
|
|
18214
|
+
}
|
|
18215
|
+
const {
|
|
18216
|
+
fetch: fetch2,
|
|
18217
|
+
loaders,
|
|
18218
|
+
coreApi,
|
|
18219
|
+
signal,
|
|
18220
|
+
reportProgress,
|
|
18221
|
+
_parse,
|
|
18222
|
+
_parseSync,
|
|
18223
|
+
_parseInBatches,
|
|
18224
|
+
...serializableContext
|
|
18225
|
+
} = context;
|
|
18226
|
+
return JSON.parse(JSON.stringify(serializableContext));
|
|
18227
|
+
}
|
|
18228
|
+
async function parseData({
|
|
18229
|
+
loader,
|
|
18230
|
+
arrayBuffer,
|
|
18231
|
+
options,
|
|
18232
|
+
context
|
|
18233
|
+
}) {
|
|
18234
|
+
let data;
|
|
18235
|
+
let parser;
|
|
18236
|
+
if (loader.parse || loader.parseSync) {
|
|
18237
|
+
data = arrayBuffer;
|
|
18238
|
+
parser = loader.parse || loader.parseSync;
|
|
18239
|
+
} else if (loader.parseTextSync) {
|
|
18240
|
+
const textDecoder = new TextDecoder();
|
|
18241
|
+
data = textDecoder.decode(arrayBuffer);
|
|
18242
|
+
parser = loader.parseTextSync;
|
|
18243
|
+
} else {
|
|
18244
|
+
throw new Error(`Could not load data with ${loader.name} loader`);
|
|
18245
|
+
}
|
|
18246
|
+
options = getWorkerLoaderOptions(loader, options);
|
|
18247
|
+
return await parser(data, { ...options }, context, loader);
|
|
18248
|
+
}
|
|
18249
|
+
function getWorkerLoaderOptions(loader, options) {
|
|
18250
|
+
return {
|
|
18251
|
+
...options,
|
|
18252
|
+
modules: { ...loader.options?.modules, ...options.modules },
|
|
18253
|
+
core: { ...options.core, worker: false }
|
|
18254
|
+
};
|
|
18255
|
+
}
|
|
18256
|
+
|
|
17311
18257
|
// src/terrain/workers/quantized-mesh-worker.ts
|
|
17312
|
-
|
|
17313
|
-
init_quantized_mesh_loader();
|
|
18258
|
+
init_quantized_mesh_loader2();
|
|
17314
18259
|
createLoaderWorker(QuantizedMeshLoaderWithParser);
|
|
17315
18260
|
})();
|