@loaders.gl/scene 5.0.0-beta.4 → 5.0.0-beta.5
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/DRACO-README.md +1 -1
- package/GLTF-README.md +1 -1
- package/OBJ-README.md +1 -1
- package/README.md +6 -1
- package/THIRD-PARTY-NOTICES.md +6 -0
- package/dist/dist.dev.js +2958 -750
- package/dist/dist.min.js +18 -18
- package/dist/draco/draco-javascript-loader-with-parser.d.ts +2 -2
- package/dist/draco/draco-loader-types.cjs +3 -3
- package/dist/draco/draco-loader-types.cjs.map +2 -2
- package/dist/draco/draco-loader-types.d.ts +1 -1
- package/dist/draco/draco-loader-types.d.ts.map +1 -1
- package/dist/draco/draco-loader-types.js +1 -1
- package/dist/draco/draco-loader-types.js.map +1 -1
- package/dist/draco/draco-loader.d.ts +2 -2
- package/dist/draco/draco-wasm-loader-with-parser.d.ts +2 -2
- package/dist/draco/draco3d-loader-with-parser.d.ts +2 -2
- package/dist/draco/lib/utils/version.cjs +1 -1
- package/dist/draco/lib/utils/version.js +1 -1
- package/dist/draco-worker-node.js +400 -113
- package/dist/draco-worker-node.js.map +4 -4
- package/dist/draco-worker.js +394 -113
- package/dist/draco-worker.js.map +4 -4
- package/dist/draco-writer-worker-node.cjs +654 -85
- package/dist/draco-writer-worker-node.cjs.map +4 -4
- package/dist/draco-writer-worker.js +624 -69
- package/dist/draco-writer-worker.js.map +4 -4
- package/dist/gltf/lib/extensions/KHR_gaussian_splatting.cjs +11 -4
- package/dist/gltf/lib/extensions/KHR_gaussian_splatting.cjs.map +2 -2
- package/dist/gltf/lib/extensions/KHR_gaussian_splatting.d.ts.map +1 -1
- package/dist/gltf/lib/extensions/KHR_gaussian_splatting.js +12 -2
- package/dist/gltf/lib/extensions/KHR_gaussian_splatting.js.map +1 -1
- package/dist/gltf/lib/parsers/parse-gltf.cjs.map +2 -2
- package/dist/gltf/lib/parsers/parse-gltf.d.ts +2 -0
- package/dist/gltf/lib/parsers/parse-gltf.d.ts.map +1 -1
- package/dist/gltf/lib/parsers/parse-gltf.js.map +1 -1
- package/dist/gltf/lib/types/gltf-additional-extension-schemas.cjs +22 -0
- package/dist/gltf/lib/types/gltf-additional-extension-schemas.cjs.map +2 -2
- package/dist/gltf/lib/types/gltf-additional-extension-schemas.d.ts +23 -0
- package/dist/gltf/lib/types/gltf-additional-extension-schemas.d.ts.map +1 -1
- package/dist/gltf/lib/types/gltf-additional-extension-schemas.js +22 -0
- package/dist/gltf/lib/types/gltf-additional-extension-schemas.js.map +1 -1
- package/dist/gltf/lib/types/gltf-extension-schemas.cjs +8 -0
- package/dist/gltf/lib/types/gltf-extension-schemas.cjs.map +2 -2
- package/dist/gltf/lib/types/gltf-extension-schemas.d.ts +27 -0
- package/dist/gltf/lib/types/gltf-extension-schemas.d.ts.map +1 -1
- package/dist/gltf/lib/types/gltf-extension-schemas.js +8 -1
- package/dist/gltf/lib/types/gltf-extension-schemas.js.map +1 -1
- package/dist/gltf/lib/types/gltf-json-schema.cjs.map +1 -1
- package/dist/gltf/lib/types/gltf-json-schema.d.ts +2 -2
- package/dist/gltf/lib/types/gltf-json-schema.d.ts.map +1 -1
- package/dist/gltf/lib/types/gltf-version-zod-schemas.d.ts +34 -0
- package/dist/gltf/lib/types/gltf-version-zod-schemas.d.ts.map +1 -1
- package/dist/gltf/lib/types/gltf-zod-schema.cjs +1 -1
- package/dist/gltf/lib/types/gltf-zod-schema.cjs.map +2 -2
- package/dist/gltf/lib/types/gltf-zod-schema.d.ts +51 -0
- package/dist/gltf/lib/types/gltf-zod-schema.d.ts.map +1 -1
- package/dist/gltf/lib/types/gltf-zod-schema.js +2 -2
- package/dist/gltf/lib/types/gltf-zod-schema.js.map +1 -1
- package/dist/gltf/lib/utils/version.cjs +1 -1
- package/dist/gltf/lib/utils/version.js +1 -1
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/mtl-loader-types.cjs +1 -1
- package/dist/obj/mtl-loader-types.cjs +1 -1
- package/dist/obj/mtl-loader-types.js +1 -1
- package/dist/obj/obj-loader-types.cjs +3 -3
- package/dist/obj/obj-loader-types.cjs.map +2 -2
- package/dist/obj/obj-loader-types.d.ts +1 -1
- package/dist/obj/obj-loader-types.d.ts.map +1 -1
- package/dist/obj/obj-loader-types.js +2 -2
- package/dist/obj/obj-loader-types.js.map +1 -1
- package/dist/obj/obj-loader.cjs +5 -5
- package/dist/obj/obj-loader.cjs.map +2 -2
- package/dist/obj/obj-loader.d.ts +1 -1
- package/dist/obj/obj-loader.d.ts.map +1 -1
- package/dist/obj/obj-loader.js +1 -1
- package/dist/obj/obj-loader.js.map +1 -1
- package/dist/obj/obj-writer.cjs +1 -1
- package/dist/obj/obj-writer.js +1 -1
- package/dist/obj-loader-types.cjs +3 -3
- package/dist/obj-loader-types.cjs.map +2 -2
- package/dist/obj-loader.cjs +5 -5
- package/dist/obj-loader.cjs.map +2 -2
- package/dist/obj-worker.js +568 -287
- package/dist/obj-writer.cjs +1 -1
- package/dist/stl/parse-stl.cjs +100 -0
- package/dist/stl/parse-stl.cjs.map +7 -0
- package/dist/stl/parse-stl.d.ts +4 -0
- package/dist/stl/parse-stl.d.ts.map +1 -0
- package/dist/stl/parse-stl.js +84 -0
- package/dist/stl/parse-stl.js.map +1 -0
- package/dist/stl-loader-types.cjs +58 -0
- package/dist/stl-loader-types.cjs.map +7 -0
- package/dist/stl-loader-types.d.ts +32 -0
- package/dist/stl-loader-types.d.ts.map +1 -0
- package/dist/stl-loader-types.js +25 -0
- package/dist/stl-loader-types.js.map +1 -0
- package/dist/stl-loader.cjs +38 -0
- package/dist/stl-loader.cjs.map +7 -0
- package/dist/stl-loader.d.ts +17 -0
- package/dist/stl-loader.d.ts.map +1 -0
- package/dist/stl-loader.js +13 -0
- package/dist/stl-loader.js.map +1 -0
- package/dist/usd/index.cjs.map +1 -1
- package/dist/usd/index.d.ts +1 -1
- package/dist/usd/index.d.ts.map +1 -1
- package/dist/usd/lib/parse-usd.cjs +42 -5
- package/dist/usd/lib/parse-usd.cjs.map +2 -2
- package/dist/usd/lib/parse-usd.d.ts.map +1 -1
- package/dist/usd/lib/parse-usd.js +53 -6
- package/dist/usd/lib/parse-usd.js.map +1 -1
- package/dist/usd/lib/parse-usdc.cjs +187 -0
- package/dist/usd/lib/parse-usdc.cjs.map +7 -0
- package/dist/usd/lib/parse-usdc.d.ts +4 -0
- package/dist/usd/lib/parse-usdc.d.ts.map +1 -0
- package/dist/usd/lib/parse-usdc.js +176 -0
- package/dist/usd/lib/parse-usdc.js.map +1 -0
- package/dist/usd/lib/parse-usdz.cjs +22 -0
- package/dist/usd/lib/parse-usdz.cjs.map +2 -2
- package/dist/usd/lib/parse-usdz.d.ts.map +1 -1
- package/dist/usd/lib/parse-usdz.js +26 -0
- package/dist/usd/lib/parse-usdz.js.map +1 -1
- package/dist/usd/lib/usd-types.cjs.map +1 -1
- package/dist/usd/lib/usd-types.d.ts +14 -1
- package/dist/usd/lib/usd-types.d.ts.map +1 -1
- package/dist/usd/lib/usd-types.js +1 -1
- package/dist/usd/lib/usd-types.js.map +1 -1
- package/dist/usd/libs/README.md +27 -0
- package/dist/usd/libs/THREE-LICENSE +21 -0
- package/dist/usd/libs/usdc-parser.d.ts +78 -0
- package/dist/usd/libs/usdc-parser.d.ts.map +1 -0
- package/dist/usd/libs/usdc-parser.js +1669 -0
- package/dist/usd/libs/usdc-parser.js.map +1 -0
- package/dist/usd/usd-loader-types.cjs +4 -4
- package/dist/usd/usd-loader-types.cjs.map +2 -2
- package/dist/usd/usd-loader-types.d.ts +7 -7
- package/dist/usd/usd-loader-types.d.ts.map +1 -1
- package/dist/usd/usd-loader-types.js +6 -6
- package/dist/usd/usd-loader-types.js.map +1 -1
- package/dist/usd/usd-loader.cjs.map +1 -1
- package/dist/usd/usd-loader.d.ts +4 -4
- package/dist/usd/usd-loader.d.ts.map +1 -1
- package/dist/usd/usd-loader.js +2 -2
- package/dist/usd/usd-loader.js.map +1 -1
- package/dist/usd-loader-types.cjs +4 -4
- package/dist/usd-loader-types.cjs.map +2 -2
- package/dist/usd-loader.cjs.map +1 -1
- package/package.json +14 -8
- package/src/draco/draco-loader-types.ts +1 -1
- package/src/gltf/lib/extensions/KHR_gaussian_splatting.ts +14 -4
- package/src/gltf/lib/parsers/parse-gltf.ts +2 -0
- package/src/gltf/lib/types/gltf-additional-extension-schemas.ts +32 -0
- package/src/gltf/lib/types/gltf-extension-schemas.ts +12 -0
- package/src/gltf/lib/types/gltf-json-schema.ts +2 -1
- package/src/gltf/lib/types/gltf-zod-schema.ts +2 -1
- package/src/index.ts +3 -1
- package/src/obj/obj-loader-types.ts +1 -1
- package/src/obj/obj-loader.ts +1 -1
- package/src/stl/parse-stl.ts +90 -0
- package/src/stl-loader-types.ts +28 -0
- package/src/stl-loader.ts +12 -0
- package/src/usd/index.ts +1 -0
- package/src/usd/lib/parse-usd.ts +68 -7
- package/src/usd/lib/parse-usdc.ts +188 -0
- package/src/usd/lib/parse-usdz.ts +28 -0
- package/src/usd/lib/usd-types.ts +16 -2
- package/src/usd/libs/README.md +27 -0
- package/src/usd/libs/THREE-LICENSE +21 -0
- package/src/usd/libs/usdc-parser.d.ts +18 -0
- package/src/usd/libs/usdc-parser.js +1669 -0
- package/src/usd/usd-loader-types.ts +5 -5
- package/src/usd/usd-loader.ts +2 -2
package/dist/dist.dev.js
CHANGED
|
@@ -56,6 +56,1417 @@ var __exports__ = (() => {
|
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
+
// src/usd/libs/usdc-parser.js
|
|
60
|
+
function checkedLength(length4, bytesPerElement = 8) {
|
|
61
|
+
const byteLength = length4 * bytesPerElement;
|
|
62
|
+
if (!Number.isSafeInteger(length4) || length4 < 0 || !Number.isSafeInteger(byteLength) || byteLength > 256 * 1024 * 1024 - allocationBytes)
|
|
63
|
+
throw new Error("USDC: decoded allocation limit exceeded");
|
|
64
|
+
allocationBytes += byteLength;
|
|
65
|
+
return length4;
|
|
66
|
+
}
|
|
67
|
+
function checkedCount(count) {
|
|
68
|
+
if (!Number.isSafeInteger(count) || count < 0 || count > 4e6)
|
|
69
|
+
throw new Error("USDC: decoded allocation limit exceeded");
|
|
70
|
+
return checkedLength(count);
|
|
71
|
+
}
|
|
72
|
+
function lz4DecompressBlock(input, inputOffset, inputEnd, output, outputOffset, outputEnd) {
|
|
73
|
+
while (inputOffset < inputEnd) {
|
|
74
|
+
const token = input[inputOffset++];
|
|
75
|
+
if (inputOffset > inputEnd) throw new Error("USDC: truncated LZ4 token");
|
|
76
|
+
let literalLength = token >> 4;
|
|
77
|
+
if (literalLength === 15) {
|
|
78
|
+
let b;
|
|
79
|
+
do {
|
|
80
|
+
if (inputOffset >= inputEnd) throw new Error("USDC: truncated LZ4 length");
|
|
81
|
+
b = input[inputOffset++];
|
|
82
|
+
literalLength += b;
|
|
83
|
+
} while (b === 255);
|
|
84
|
+
}
|
|
85
|
+
if (literalLength > 0) {
|
|
86
|
+
if (inputOffset + literalLength > inputEnd) {
|
|
87
|
+
throw new Error("USDC: truncated LZ4 literal");
|
|
88
|
+
}
|
|
89
|
+
for (let i = 0; i < literalLength; i++) {
|
|
90
|
+
if (outputOffset >= outputEnd) throw new Error("USDC: LZ4 output overflow");
|
|
91
|
+
output[outputOffset++] = input[inputOffset++];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (inputOffset >= inputEnd) break;
|
|
95
|
+
if (inputOffset + 2 > inputEnd) throw new Error("USDC: truncated LZ4 offset");
|
|
96
|
+
const matchOffset = input[inputOffset++] | input[inputOffset++] << 8;
|
|
97
|
+
if (matchOffset === 0) {
|
|
98
|
+
throw new Error("USDC: invalid LZ4 match offset");
|
|
99
|
+
}
|
|
100
|
+
let matchLength = (token & 15) + 4;
|
|
101
|
+
if (matchLength === 19) {
|
|
102
|
+
let b;
|
|
103
|
+
do {
|
|
104
|
+
if (inputOffset >= inputEnd) throw new Error("USDC: truncated LZ4 length");
|
|
105
|
+
b = input[inputOffset++];
|
|
106
|
+
matchLength += b;
|
|
107
|
+
} while (b === 255);
|
|
108
|
+
}
|
|
109
|
+
const matchPos = outputOffset - matchOffset;
|
|
110
|
+
if (matchPos < 0) {
|
|
111
|
+
throw new Error("USDC: invalid LZ4 match position");
|
|
112
|
+
}
|
|
113
|
+
for (let i = 0; i < matchLength; i++) {
|
|
114
|
+
if (outputOffset >= outputEnd) throw new Error("USDC: LZ4 output overflow");
|
|
115
|
+
output[outputOffset++] = output[matchPos + i];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return outputOffset;
|
|
119
|
+
}
|
|
120
|
+
function decompressLZ4(input, uncompressedSize, allowShortOutput = false) {
|
|
121
|
+
const output = new Uint8Array(checkedLength(uncompressedSize, 1));
|
|
122
|
+
if (!input.length) throw new Error("USDC: missing LZ4 chunk header");
|
|
123
|
+
const numChunks = input[0];
|
|
124
|
+
if (numChunks === 0) {
|
|
125
|
+
const written = lz4DecompressBlock(input, 1, input.length, output, 0, uncompressedSize);
|
|
126
|
+
if (!allowShortOutput && written !== uncompressedSize)
|
|
127
|
+
throw new Error("USDC: incomplete LZ4 output");
|
|
128
|
+
return output.subarray(0, written);
|
|
129
|
+
} else {
|
|
130
|
+
const CHUNK_SIZE = 65536;
|
|
131
|
+
if (1 + numChunks * 4 > input.length) throw new Error("USDC: truncated LZ4 chunk sizes");
|
|
132
|
+
let headerOffset = 1;
|
|
133
|
+
const compressedSizes = [];
|
|
134
|
+
for (let i = 0; i < numChunks; i++) {
|
|
135
|
+
const size = (input[headerOffset] | input[headerOffset + 1] << 8 | input[headerOffset + 2] << 16 | input[headerOffset + 3] << 24) >>> 0;
|
|
136
|
+
compressedSizes.push(size);
|
|
137
|
+
headerOffset += 4;
|
|
138
|
+
}
|
|
139
|
+
let inputOffset = headerOffset;
|
|
140
|
+
let outputOffset = 0;
|
|
141
|
+
for (let i = 0; i < numChunks; i++) {
|
|
142
|
+
const chunkCompressedSize = compressedSizes[i];
|
|
143
|
+
const chunkOutputSize = Math.min(CHUNK_SIZE, uncompressedSize - outputOffset);
|
|
144
|
+
if (chunkCompressedSize > input.length - inputOffset)
|
|
145
|
+
throw new Error("USDC: truncated LZ4 chunk");
|
|
146
|
+
const written = lz4DecompressBlock(
|
|
147
|
+
input,
|
|
148
|
+
inputOffset,
|
|
149
|
+
inputOffset + chunkCompressedSize,
|
|
150
|
+
output,
|
|
151
|
+
outputOffset,
|
|
152
|
+
outputOffset + chunkOutputSize
|
|
153
|
+
);
|
|
154
|
+
inputOffset += chunkCompressedSize;
|
|
155
|
+
if (i < numChunks - 1 && written !== outputOffset + chunkOutputSize)
|
|
156
|
+
throw new Error("USDC: incomplete LZ4 chunk");
|
|
157
|
+
outputOffset = written;
|
|
158
|
+
}
|
|
159
|
+
if (inputOffset !== input.length || !allowShortOutput && outputOffset !== uncompressedSize)
|
|
160
|
+
throw new Error("USDC: incomplete LZ4 output");
|
|
161
|
+
return output.subarray(0, outputOffset);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function decompressIntegers32(compressedData, numInts) {
|
|
165
|
+
const encodedSize = numInts * 4 + (numInts * 2 + 7 >> 3) + 4;
|
|
166
|
+
const encoded = decompressLZ4(new Uint8Array(compressedData), encodedSize, true);
|
|
167
|
+
return decodeIntegers32(encoded, numInts);
|
|
168
|
+
}
|
|
169
|
+
function decodeIntegers32(data, numInts) {
|
|
170
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
171
|
+
let offset = 0;
|
|
172
|
+
const commonValue = view.getInt32(offset, true);
|
|
173
|
+
offset += 4;
|
|
174
|
+
const numCodesBytes = numInts * 2 + 7 >> 3;
|
|
175
|
+
if (data.length < offset + numCodesBytes) throw new Error("USDC: truncated integer codes");
|
|
176
|
+
const codesStart = offset;
|
|
177
|
+
const vintsStart = offset + numCodesBytes;
|
|
178
|
+
const result = new Int32Array(checkedLength(numInts));
|
|
179
|
+
let prevVal = 0;
|
|
180
|
+
let codesOffset = codesStart;
|
|
181
|
+
let vintsOffset = vintsStart;
|
|
182
|
+
for (let i = 0; i < numInts; ) {
|
|
183
|
+
const codeByte = data[codesOffset++];
|
|
184
|
+
for (let j = 0; j < 4 && i < numInts; j++, i++) {
|
|
185
|
+
const code = codeByte >> j * 2 & 3;
|
|
186
|
+
let delta = 0;
|
|
187
|
+
switch (code) {
|
|
188
|
+
case 0:
|
|
189
|
+
delta = commonValue;
|
|
190
|
+
break;
|
|
191
|
+
case 1:
|
|
192
|
+
delta = view.getInt8(vintsOffset);
|
|
193
|
+
vintsOffset += 1;
|
|
194
|
+
break;
|
|
195
|
+
case 2:
|
|
196
|
+
delta = view.getInt16(vintsOffset, true);
|
|
197
|
+
vintsOffset += 2;
|
|
198
|
+
break;
|
|
199
|
+
case 3:
|
|
200
|
+
delta = view.getInt32(vintsOffset, true);
|
|
201
|
+
vintsOffset += 4;
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
prevVal += delta;
|
|
205
|
+
result[i] = prevVal;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
210
|
+
var allocationBytes, textDecoder, HALF_EXPONENT_TABLE, HALF_DENORM_SCALE, TypeEnum, DICTIONARY_ARRAY_TYPES, FIELD_SET_TERMINATOR, FLOAT_COMPRESSION_INT, FLOAT_COMPRESSION_LUT, BinaryReader, ValueRep, USDCParser;
|
|
211
|
+
var init_usdc_parser = __esm({
|
|
212
|
+
"src/usd/libs/usdc-parser.js"() {
|
|
213
|
+
"use strict";
|
|
214
|
+
allocationBytes = 0;
|
|
215
|
+
textDecoder = new TextDecoder();
|
|
216
|
+
HALF_EXPONENT_TABLE = new Float32Array(32);
|
|
217
|
+
for (let i = 0; i < 32; i++) {
|
|
218
|
+
HALF_EXPONENT_TABLE[i] = Math.pow(2, i - 15);
|
|
219
|
+
}
|
|
220
|
+
HALF_DENORM_SCALE = Math.pow(2, -14);
|
|
221
|
+
TypeEnum = {
|
|
222
|
+
Invalid: 0,
|
|
223
|
+
Bool: 1,
|
|
224
|
+
UChar: 2,
|
|
225
|
+
Int: 3,
|
|
226
|
+
UInt: 4,
|
|
227
|
+
Int64: 5,
|
|
228
|
+
UInt64: 6,
|
|
229
|
+
Half: 7,
|
|
230
|
+
Float: 8,
|
|
231
|
+
Double: 9,
|
|
232
|
+
String: 10,
|
|
233
|
+
Token: 11,
|
|
234
|
+
AssetPath: 12,
|
|
235
|
+
Matrix2d: 13,
|
|
236
|
+
Matrix3d: 14,
|
|
237
|
+
Matrix4d: 15,
|
|
238
|
+
Quatd: 16,
|
|
239
|
+
Quatf: 17,
|
|
240
|
+
Quath: 18,
|
|
241
|
+
Vec2d: 19,
|
|
242
|
+
Vec2f: 20,
|
|
243
|
+
Vec2h: 21,
|
|
244
|
+
Vec2i: 22,
|
|
245
|
+
Vec3d: 23,
|
|
246
|
+
Vec3f: 24,
|
|
247
|
+
Vec3h: 25,
|
|
248
|
+
Vec3i: 26,
|
|
249
|
+
Vec4d: 27,
|
|
250
|
+
Vec4f: 28,
|
|
251
|
+
Vec4h: 29,
|
|
252
|
+
Vec4i: 30,
|
|
253
|
+
Dictionary: 31,
|
|
254
|
+
TokenListOp: 32,
|
|
255
|
+
StringListOp: 33,
|
|
256
|
+
PathListOp: 34,
|
|
257
|
+
ReferenceListOp: 35,
|
|
258
|
+
IntListOp: 36,
|
|
259
|
+
Int64ListOp: 37,
|
|
260
|
+
UIntListOp: 38,
|
|
261
|
+
UInt64ListOp: 39,
|
|
262
|
+
PathVector: 40,
|
|
263
|
+
TokenVector: 41,
|
|
264
|
+
Specifier: 42,
|
|
265
|
+
Permission: 43,
|
|
266
|
+
Variability: 44,
|
|
267
|
+
VariantSelectionMap: 45,
|
|
268
|
+
TimeSamples: 46,
|
|
269
|
+
Payload: 47,
|
|
270
|
+
DoubleVector: 48,
|
|
271
|
+
LayerOffsetVector: 49,
|
|
272
|
+
StringVector: 50,
|
|
273
|
+
ValueBlock: 51,
|
|
274
|
+
Value: 52,
|
|
275
|
+
UnregisteredValue: 53,
|
|
276
|
+
UnregisteredValueListOp: 54,
|
|
277
|
+
PayloadListOp: 55,
|
|
278
|
+
TimeCode: 56,
|
|
279
|
+
PathExpression: 57,
|
|
280
|
+
Relocates: 58,
|
|
281
|
+
Spline: 59,
|
|
282
|
+
AnimationBlock: 60
|
|
283
|
+
};
|
|
284
|
+
DICTIONARY_ARRAY_TYPES = /* @__PURE__ */ new Set([
|
|
285
|
+
TypeEnum.Int,
|
|
286
|
+
TypeEnum.UInt,
|
|
287
|
+
TypeEnum.Float,
|
|
288
|
+
TypeEnum.Double,
|
|
289
|
+
TypeEnum.Half,
|
|
290
|
+
TypeEnum.String,
|
|
291
|
+
TypeEnum.Token
|
|
292
|
+
]);
|
|
293
|
+
FIELD_SET_TERMINATOR = 4294967295;
|
|
294
|
+
FLOAT_COMPRESSION_INT = 105;
|
|
295
|
+
FLOAT_COMPRESSION_LUT = 116;
|
|
296
|
+
BinaryReader = class {
|
|
297
|
+
constructor(buffer) {
|
|
298
|
+
this.buffer = buffer;
|
|
299
|
+
this.view = new DataView(buffer);
|
|
300
|
+
this.offset = 0;
|
|
301
|
+
}
|
|
302
|
+
seek(offset) {
|
|
303
|
+
if (!Number.isSafeInteger(offset) || offset < 0 || offset > this.buffer.byteLength)
|
|
304
|
+
throw new Error("USDC: invalid seek");
|
|
305
|
+
this.offset = offset;
|
|
306
|
+
}
|
|
307
|
+
tell() {
|
|
308
|
+
return this.offset;
|
|
309
|
+
}
|
|
310
|
+
readUint8() {
|
|
311
|
+
const value = this.view.getUint8(this.offset);
|
|
312
|
+
this.offset += 1;
|
|
313
|
+
return value;
|
|
314
|
+
}
|
|
315
|
+
readInt8() {
|
|
316
|
+
const value = this.view.getInt8(this.offset);
|
|
317
|
+
this.offset += 1;
|
|
318
|
+
return value;
|
|
319
|
+
}
|
|
320
|
+
readUint16() {
|
|
321
|
+
const value = this.view.getUint16(this.offset, true);
|
|
322
|
+
this.offset += 2;
|
|
323
|
+
return value;
|
|
324
|
+
}
|
|
325
|
+
readInt16() {
|
|
326
|
+
const value = this.view.getInt16(this.offset, true);
|
|
327
|
+
this.offset += 2;
|
|
328
|
+
return value;
|
|
329
|
+
}
|
|
330
|
+
readUint32() {
|
|
331
|
+
const value = this.view.getUint32(this.offset, true);
|
|
332
|
+
this.offset += 4;
|
|
333
|
+
return value;
|
|
334
|
+
}
|
|
335
|
+
readInt32() {
|
|
336
|
+
const value = this.view.getInt32(this.offset, true);
|
|
337
|
+
this.offset += 4;
|
|
338
|
+
return value;
|
|
339
|
+
}
|
|
340
|
+
readUint64() {
|
|
341
|
+
const lo = this.view.getUint32(this.offset, true);
|
|
342
|
+
const hi = this.view.getUint32(this.offset + 4, true);
|
|
343
|
+
this.offset += 8;
|
|
344
|
+
const result = hi * 4294967296 + lo;
|
|
345
|
+
if (!Number.isSafeInteger(result)) throw new Error("USDC: integer exceeds safe precision");
|
|
346
|
+
return result;
|
|
347
|
+
}
|
|
348
|
+
readInt64() {
|
|
349
|
+
const lo = this.view.getUint32(this.offset, true);
|
|
350
|
+
const hi = this.view.getInt32(this.offset + 4, true);
|
|
351
|
+
this.offset += 8;
|
|
352
|
+
const result = hi * 4294967296 + lo;
|
|
353
|
+
if (!Number.isSafeInteger(result)) throw new Error("USDC: integer exceeds safe precision");
|
|
354
|
+
return result;
|
|
355
|
+
}
|
|
356
|
+
readFloat32() {
|
|
357
|
+
const value = this.view.getFloat32(this.offset, true);
|
|
358
|
+
this.offset += 4;
|
|
359
|
+
return value;
|
|
360
|
+
}
|
|
361
|
+
readFloat64() {
|
|
362
|
+
const value = this.view.getFloat64(this.offset, true);
|
|
363
|
+
this.offset += 8;
|
|
364
|
+
return value;
|
|
365
|
+
}
|
|
366
|
+
readBytes(length4) {
|
|
367
|
+
const bytes = new Uint8Array(this.buffer, this.offset, length4);
|
|
368
|
+
this.offset += length4;
|
|
369
|
+
return bytes;
|
|
370
|
+
}
|
|
371
|
+
readString(length4) {
|
|
372
|
+
const bytes = this.readBytes(length4);
|
|
373
|
+
let end = 0;
|
|
374
|
+
while (end < length4 && bytes[end] !== 0) end++;
|
|
375
|
+
return textDecoder.decode(bytes.subarray(0, end));
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
ValueRep = class {
|
|
379
|
+
constructor(lo, hi) {
|
|
380
|
+
this.lo = lo;
|
|
381
|
+
this.hi = hi;
|
|
382
|
+
}
|
|
383
|
+
get isArray() {
|
|
384
|
+
return (this.hi & 2147483648) !== 0;
|
|
385
|
+
}
|
|
386
|
+
get isInlined() {
|
|
387
|
+
return (this.hi & 1073741824) !== 0;
|
|
388
|
+
}
|
|
389
|
+
get isCompressed() {
|
|
390
|
+
return (this.hi & 536870912) !== 0;
|
|
391
|
+
}
|
|
392
|
+
get typeEnum() {
|
|
393
|
+
return this.hi >> 16 & 255;
|
|
394
|
+
}
|
|
395
|
+
get payload() {
|
|
396
|
+
return this.lo + (this.hi & 65535) * 4294967296;
|
|
397
|
+
}
|
|
398
|
+
getInlinedValue() {
|
|
399
|
+
return this.lo;
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
USDCParser = class {
|
|
403
|
+
/**
|
|
404
|
+
* Parse USDC file and return raw spec data without building Three.js scene.
|
|
405
|
+
* Used by USDComposer for unified scene composition.
|
|
406
|
+
*/
|
|
407
|
+
parseData(buffer) {
|
|
408
|
+
allocationBytes = 0;
|
|
409
|
+
this._valueReadCount = 0;
|
|
410
|
+
this._activeDictionaries = /* @__PURE__ */ new Set();
|
|
411
|
+
this.buffer = buffer instanceof ArrayBuffer ? buffer : buffer.buffer;
|
|
412
|
+
this.reader = new BinaryReader(this.buffer);
|
|
413
|
+
this.version = { major: 0, minor: 0, patch: 0 };
|
|
414
|
+
this._conversionBuffer = new ArrayBuffer(4);
|
|
415
|
+
this._conversionView = new DataView(this._conversionBuffer);
|
|
416
|
+
this._readBootstrap();
|
|
417
|
+
this._readTOC();
|
|
418
|
+
this._readTokens();
|
|
419
|
+
this._readStrings();
|
|
420
|
+
this._readFields();
|
|
421
|
+
this._readFieldSets();
|
|
422
|
+
this._readPaths();
|
|
423
|
+
this._readSpecs();
|
|
424
|
+
this.specsByPath = /* @__PURE__ */ Object.create(null);
|
|
425
|
+
for (const spec of this.specs) {
|
|
426
|
+
const path2 = this.paths[spec.pathIndex];
|
|
427
|
+
if (!path2) continue;
|
|
428
|
+
const fields = this._getFieldsForSpec(spec);
|
|
429
|
+
this.specsByPath[path2] = { specType: spec.specType, fields };
|
|
430
|
+
}
|
|
431
|
+
return { specsByPath: this.specsByPath };
|
|
432
|
+
}
|
|
433
|
+
_readBootstrap() {
|
|
434
|
+
const reader = this.reader;
|
|
435
|
+
reader.seek(0);
|
|
436
|
+
const magic = reader.readString(8);
|
|
437
|
+
if (magic !== "PXR-USDC") {
|
|
438
|
+
throw new Error("THREE.USDCParser: Not a valid USDC file.");
|
|
439
|
+
}
|
|
440
|
+
this.version.major = reader.readUint8();
|
|
441
|
+
this.version.minor = reader.readUint8();
|
|
442
|
+
this.version.patch = reader.readUint8();
|
|
443
|
+
reader.readBytes(5);
|
|
444
|
+
this.tocOffset = reader.readUint64();
|
|
445
|
+
}
|
|
446
|
+
_readTOC() {
|
|
447
|
+
const reader = this.reader;
|
|
448
|
+
reader.seek(this.tocOffset);
|
|
449
|
+
const numSections = reader.readUint64();
|
|
450
|
+
if (numSections > 16) throw new Error("USDC: invalid section count");
|
|
451
|
+
this.sections = /* @__PURE__ */ Object.create(null);
|
|
452
|
+
for (let i = 0; i < numSections; i++) {
|
|
453
|
+
const name22 = reader.readString(16);
|
|
454
|
+
const start = reader.readUint64();
|
|
455
|
+
const size = reader.readUint64();
|
|
456
|
+
this.sections[name22] = { start, size };
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
_readTokens() {
|
|
460
|
+
const section = this.sections["TOKENS"];
|
|
461
|
+
if (!section) return;
|
|
462
|
+
const reader = this.reader;
|
|
463
|
+
reader.seek(section.start);
|
|
464
|
+
const numTokens = checkedCount(reader.readUint64());
|
|
465
|
+
this.tokens = [];
|
|
466
|
+
if (this.version.major === 0 && this.version.minor < 4) {
|
|
467
|
+
const tokensNumBytes = reader.readUint64();
|
|
468
|
+
const tokensData = reader.readBytes(tokensNumBytes);
|
|
469
|
+
let strStart = 0;
|
|
470
|
+
for (let i = 0; i < numTokens; i++) {
|
|
471
|
+
let strEnd = strStart;
|
|
472
|
+
while (strEnd < tokensData.length && tokensData[strEnd] !== 0) strEnd++;
|
|
473
|
+
if (strEnd >= tokensData.length) throw new Error("USDC: unterminated token data");
|
|
474
|
+
this.tokens.push(textDecoder.decode(tokensData.subarray(strStart, strEnd)));
|
|
475
|
+
strStart = strEnd + 1;
|
|
476
|
+
}
|
|
477
|
+
} else {
|
|
478
|
+
const uncompressedSize = reader.readUint64();
|
|
479
|
+
const compressedSize = reader.readUint64();
|
|
480
|
+
const compressedData = reader.readBytes(compressedSize);
|
|
481
|
+
const tokensData = decompressLZ4(compressedData, uncompressedSize);
|
|
482
|
+
checkedLength(tokensData.length, 2);
|
|
483
|
+
let strStart = 0;
|
|
484
|
+
for (let i = 0; i < numTokens; i++) {
|
|
485
|
+
let strEnd = strStart;
|
|
486
|
+
while (strEnd < tokensData.length && tokensData[strEnd] !== 0) strEnd++;
|
|
487
|
+
if (strEnd >= tokensData.length) throw new Error("USDC: unterminated token data");
|
|
488
|
+
this.tokens.push(textDecoder.decode(tokensData.subarray(strStart, strEnd)));
|
|
489
|
+
strStart = strEnd + 1;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
_readStrings() {
|
|
494
|
+
const section = this.sections["STRINGS"];
|
|
495
|
+
if (!section) {
|
|
496
|
+
this.strings = [];
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
const reader = this.reader;
|
|
500
|
+
reader.seek(section.start);
|
|
501
|
+
const numStrings = checkedCount(reader.readUint64());
|
|
502
|
+
this.strings = [];
|
|
503
|
+
for (let i = 0; i < numStrings; i++) {
|
|
504
|
+
this.strings.push(reader.readUint32());
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
_readFields() {
|
|
508
|
+
const section = this.sections["FIELDS"];
|
|
509
|
+
if (!section) return;
|
|
510
|
+
const reader = this.reader;
|
|
511
|
+
reader.seek(section.start);
|
|
512
|
+
this.fields = [];
|
|
513
|
+
if (this.version.major === 0 && this.version.minor < 4) {
|
|
514
|
+
const numFields = Math.floor(section.size / 12);
|
|
515
|
+
for (let i = 0; i < numFields; i++) {
|
|
516
|
+
const tokenIndex = reader.readUint32();
|
|
517
|
+
const repLo = reader.readUint32();
|
|
518
|
+
const repHi = reader.readUint32();
|
|
519
|
+
this.fields.push({
|
|
520
|
+
tokenIndex,
|
|
521
|
+
valueRep: new ValueRep(repLo, repHi)
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
} else {
|
|
525
|
+
const numFields = checkedCount(reader.readUint64());
|
|
526
|
+
const tokenIndicesCompressedSize = reader.readUint64();
|
|
527
|
+
const tokenIndicesCompressed = reader.readBytes(tokenIndicesCompressedSize);
|
|
528
|
+
const tokenIndices = decompressIntegers32(
|
|
529
|
+
tokenIndicesCompressed.buffer.slice(
|
|
530
|
+
tokenIndicesCompressed.byteOffset,
|
|
531
|
+
tokenIndicesCompressed.byteOffset + tokenIndicesCompressedSize
|
|
532
|
+
),
|
|
533
|
+
numFields
|
|
534
|
+
);
|
|
535
|
+
const repsCompressedSize = reader.readUint64();
|
|
536
|
+
const repsCompressed = reader.readBytes(repsCompressedSize);
|
|
537
|
+
const repsData = decompressLZ4(repsCompressed, numFields * 8);
|
|
538
|
+
const repsView = new DataView(repsData.buffer, repsData.byteOffset, repsData.byteLength);
|
|
539
|
+
for (let i = 0; i < numFields; i++) {
|
|
540
|
+
const repLo = repsView.getUint32(i * 8, true);
|
|
541
|
+
const repHi = repsView.getUint32(i * 8 + 4, true);
|
|
542
|
+
this.fields.push({
|
|
543
|
+
tokenIndex: tokenIndices[i],
|
|
544
|
+
valueRep: new ValueRep(repLo, repHi)
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
_readFieldSets() {
|
|
550
|
+
const section = this.sections["FIELDSETS"];
|
|
551
|
+
if (!section) return;
|
|
552
|
+
const reader = this.reader;
|
|
553
|
+
reader.seek(section.start);
|
|
554
|
+
this.fieldSets = [];
|
|
555
|
+
if (this.version.major === 0 && this.version.minor < 4) {
|
|
556
|
+
const numFieldSets = Math.floor(section.size / 4);
|
|
557
|
+
for (let i = 0; i < numFieldSets; i++) {
|
|
558
|
+
this.fieldSets.push(reader.readUint32());
|
|
559
|
+
}
|
|
560
|
+
} else {
|
|
561
|
+
const numFieldSets = checkedCount(reader.readUint64());
|
|
562
|
+
const compressedSize = reader.readUint64();
|
|
563
|
+
const compressed = reader.readBytes(compressedSize);
|
|
564
|
+
const indices = decompressIntegers32(
|
|
565
|
+
compressed.buffer.slice(compressed.byteOffset, compressed.byteOffset + compressedSize),
|
|
566
|
+
numFieldSets
|
|
567
|
+
);
|
|
568
|
+
for (let i = 0; i < numFieldSets; i++) {
|
|
569
|
+
this.fieldSets.push(indices[i]);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
_readPaths() {
|
|
574
|
+
const section = this.sections["PATHS"];
|
|
575
|
+
if (!section) return;
|
|
576
|
+
const reader = this.reader;
|
|
577
|
+
reader.seek(section.start);
|
|
578
|
+
const numPaths = checkedCount(reader.readUint64());
|
|
579
|
+
this.paths = new Array(checkedLength(numPaths)).fill("");
|
|
580
|
+
if (this.version.major === 0 && this.version.minor < 4) {
|
|
581
|
+
this._readPathsRecursive("");
|
|
582
|
+
} else {
|
|
583
|
+
reader.readUint64();
|
|
584
|
+
const compressedSize1 = reader.readUint64();
|
|
585
|
+
const pathIndicesCompressed = reader.readBytes(compressedSize1);
|
|
586
|
+
const pathIndices = decompressIntegers32(
|
|
587
|
+
pathIndicesCompressed.buffer.slice(
|
|
588
|
+
pathIndicesCompressed.byteOffset,
|
|
589
|
+
pathIndicesCompressed.byteOffset + compressedSize1
|
|
590
|
+
),
|
|
591
|
+
numPaths
|
|
592
|
+
);
|
|
593
|
+
const compressedSize2 = reader.readUint64();
|
|
594
|
+
const elementTokenIndicesCompressed = reader.readBytes(compressedSize2);
|
|
595
|
+
const elementTokenIndices = decompressIntegers32(
|
|
596
|
+
elementTokenIndicesCompressed.buffer.slice(
|
|
597
|
+
elementTokenIndicesCompressed.byteOffset,
|
|
598
|
+
elementTokenIndicesCompressed.byteOffset + compressedSize2
|
|
599
|
+
),
|
|
600
|
+
numPaths
|
|
601
|
+
);
|
|
602
|
+
const compressedSize3 = reader.readUint64();
|
|
603
|
+
const jumpsCompressed = reader.readBytes(compressedSize3);
|
|
604
|
+
const jumps = decompressIntegers32(
|
|
605
|
+
jumpsCompressed.buffer.slice(
|
|
606
|
+
jumpsCompressed.byteOffset,
|
|
607
|
+
jumpsCompressed.byteOffset + compressedSize3
|
|
608
|
+
),
|
|
609
|
+
numPaths
|
|
610
|
+
);
|
|
611
|
+
this._buildPathsFromCompressed(pathIndices, elementTokenIndices, jumps);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
_readPathsRecursive(parentPath, depth = 0) {
|
|
615
|
+
const reader = this.reader;
|
|
616
|
+
if (depth > 1e3) return;
|
|
617
|
+
const index = reader.readUint32();
|
|
618
|
+
const elementTokenIndex = reader.readUint32();
|
|
619
|
+
const bits = reader.readUint8();
|
|
620
|
+
const hasChild = (bits & 1) !== 0;
|
|
621
|
+
const hasSibling = (bits & 2) !== 0;
|
|
622
|
+
const isPrimProperty = (bits & 4) !== 0;
|
|
623
|
+
let path2;
|
|
624
|
+
if (parentPath === "") {
|
|
625
|
+
path2 = "/";
|
|
626
|
+
} else {
|
|
627
|
+
const elemToken = this.tokens[elementTokenIndex] || "";
|
|
628
|
+
if (isPrimProperty) {
|
|
629
|
+
path2 = parentPath + "." + elemToken;
|
|
630
|
+
} else {
|
|
631
|
+
path2 = parentPath === "/" ? "/" + elemToken : parentPath + "/" + elemToken;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
checkedLength(path2.length, 2);
|
|
635
|
+
this.paths[index] = path2;
|
|
636
|
+
if (hasChild && hasSibling) {
|
|
637
|
+
const siblingOffset = reader.readUint64();
|
|
638
|
+
this._readPathsRecursive(path2, depth + 1);
|
|
639
|
+
reader.seek(siblingOffset);
|
|
640
|
+
this._readPathsRecursive(parentPath, depth + 1);
|
|
641
|
+
} else if (hasChild) {
|
|
642
|
+
this._readPathsRecursive(path2, depth + 1);
|
|
643
|
+
} else if (hasSibling) {
|
|
644
|
+
this._readPathsRecursive(parentPath, depth + 1);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
/** Rebuilds compressed paths with an explicit stack instead of sibling recursion. */
|
|
648
|
+
_buildPathsFromCompressed(pathIndices, elementTokenIndices, jumps) {
|
|
649
|
+
let traversalCount = 0;
|
|
650
|
+
const pendingPaths = [{ startIndex: 0, parentPath: "" }];
|
|
651
|
+
while (pendingPaths.length) {
|
|
652
|
+
const pendingPath = pendingPaths.pop();
|
|
653
|
+
let currentIndex = pendingPath.startIndex;
|
|
654
|
+
let parentPath = pendingPath.parentPath;
|
|
655
|
+
while (currentIndex < pathIndices.length) {
|
|
656
|
+
if (++traversalCount > pathIndices.length * 2)
|
|
657
|
+
throw new Error("USDC: path traversal limit exceeded");
|
|
658
|
+
const nodeIndex = currentIndex++;
|
|
659
|
+
const pathIndex = pathIndices[nodeIndex];
|
|
660
|
+
const elementTokenIndex = elementTokenIndices[nodeIndex];
|
|
661
|
+
const jump = jumps[nodeIndex];
|
|
662
|
+
if (pathIndex < 0 || pathIndex >= this.paths.length || Math.abs(elementTokenIndex) >= this.tokens.length || jump < -2)
|
|
663
|
+
throw new Error("USDC: invalid compressed path index");
|
|
664
|
+
let path2;
|
|
665
|
+
if (parentPath === "") {
|
|
666
|
+
path2 = "/";
|
|
667
|
+
parentPath = path2;
|
|
668
|
+
} else {
|
|
669
|
+
const elementToken = this.tokens[Math.abs(elementTokenIndex)];
|
|
670
|
+
path2 = elementTokenIndex < 0 ? parentPath + "." + elementToken : parentPath === "/" ? "/" + elementToken : parentPath + "/" + elementToken;
|
|
671
|
+
}
|
|
672
|
+
checkedLength(path2.length, 2);
|
|
673
|
+
this.paths[pathIndex] = path2;
|
|
674
|
+
const hasChild = jump > 0 || jump === -1;
|
|
675
|
+
const hasSibling = jump >= 0;
|
|
676
|
+
if ((hasChild || hasSibling) && currentIndex >= pathIndices.length)
|
|
677
|
+
throw new Error("USDC: missing compressed path entry");
|
|
678
|
+
if (hasChild && hasSibling) {
|
|
679
|
+
const siblingIndex = nodeIndex + jump;
|
|
680
|
+
if (siblingIndex <= currentIndex || siblingIndex >= pathIndices.length)
|
|
681
|
+
throw new Error("USDC: invalid compressed path jump");
|
|
682
|
+
pendingPaths.push({ startIndex: siblingIndex, parentPath });
|
|
683
|
+
}
|
|
684
|
+
if (hasChild) parentPath = path2;
|
|
685
|
+
else if (!hasSibling) break;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
_readSpecs() {
|
|
690
|
+
const section = this.sections["SPECS"];
|
|
691
|
+
if (!section) return;
|
|
692
|
+
const reader = this.reader;
|
|
693
|
+
reader.seek(section.start);
|
|
694
|
+
this.specs = [];
|
|
695
|
+
if (this.version.major === 0 && this.version.minor < 4) {
|
|
696
|
+
const specSize = this.version.minor === 0 && this.version.patch === 1 ? 16 : 12;
|
|
697
|
+
const numSpecs = Math.floor(section.size / specSize);
|
|
698
|
+
for (let i = 0; i < numSpecs; i++) {
|
|
699
|
+
const pathIndex = reader.readUint32();
|
|
700
|
+
const fieldSetIndex = reader.readUint32();
|
|
701
|
+
const specType = reader.readUint32();
|
|
702
|
+
if (specSize === 16) reader.readUint32();
|
|
703
|
+
this.specs.push({ pathIndex, fieldSetIndex, specType });
|
|
704
|
+
}
|
|
705
|
+
} else {
|
|
706
|
+
const numSpecs = checkedCount(reader.readUint64());
|
|
707
|
+
const compressedSize1 = reader.readUint64();
|
|
708
|
+
const pathIndicesCompressed = reader.readBytes(compressedSize1);
|
|
709
|
+
const pathIndices = decompressIntegers32(
|
|
710
|
+
pathIndicesCompressed.buffer.slice(
|
|
711
|
+
pathIndicesCompressed.byteOffset,
|
|
712
|
+
pathIndicesCompressed.byteOffset + compressedSize1
|
|
713
|
+
),
|
|
714
|
+
numSpecs
|
|
715
|
+
);
|
|
716
|
+
const compressedSize2 = reader.readUint64();
|
|
717
|
+
const fieldSetIndicesCompressed = reader.readBytes(compressedSize2);
|
|
718
|
+
const fieldSetIndices = decompressIntegers32(
|
|
719
|
+
fieldSetIndicesCompressed.buffer.slice(
|
|
720
|
+
fieldSetIndicesCompressed.byteOffset,
|
|
721
|
+
fieldSetIndicesCompressed.byteOffset + compressedSize2
|
|
722
|
+
),
|
|
723
|
+
numSpecs
|
|
724
|
+
);
|
|
725
|
+
const compressedSize3 = reader.readUint64();
|
|
726
|
+
const specTypesCompressed = reader.readBytes(compressedSize3);
|
|
727
|
+
const specTypes = decompressIntegers32(
|
|
728
|
+
specTypesCompressed.buffer.slice(
|
|
729
|
+
specTypesCompressed.byteOffset,
|
|
730
|
+
specTypesCompressed.byteOffset + compressedSize3
|
|
731
|
+
),
|
|
732
|
+
numSpecs
|
|
733
|
+
);
|
|
734
|
+
for (let i = 0; i < numSpecs; i++) {
|
|
735
|
+
this.specs.push({
|
|
736
|
+
pathIndex: pathIndices[i],
|
|
737
|
+
fieldSetIndex: fieldSetIndices[i],
|
|
738
|
+
specType: specTypes[i]
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
// ========================================================================
|
|
744
|
+
// Value Reading
|
|
745
|
+
// ========================================================================
|
|
746
|
+
_readValue(valueRep) {
|
|
747
|
+
this._valueReadCount = (this._valueReadCount || 0) + 1;
|
|
748
|
+
if (this._valueReadCount > 1e6) throw new Error("USDC: value traversal limit exceeded");
|
|
749
|
+
const type = valueRep.typeEnum;
|
|
750
|
+
const isArray2 = valueRep.isArray;
|
|
751
|
+
const isInlined = valueRep.isInlined;
|
|
752
|
+
if (type === TypeEnum.TimeSamples) {
|
|
753
|
+
return this._readTimeSamples(valueRep);
|
|
754
|
+
}
|
|
755
|
+
if (isInlined) {
|
|
756
|
+
return this._readInlinedValue(valueRep);
|
|
757
|
+
}
|
|
758
|
+
const offset = valueRep.payload;
|
|
759
|
+
if (offset === 0 && isArray2) {
|
|
760
|
+
return [];
|
|
761
|
+
}
|
|
762
|
+
if (offset < 0 || offset >= this.buffer.byteLength) {
|
|
763
|
+
throw new RangeError(
|
|
764
|
+
"USDCParser: Invalid payload offset " + offset + " for type " + type + "."
|
|
765
|
+
);
|
|
766
|
+
}
|
|
767
|
+
const savedOffset = this.reader.tell();
|
|
768
|
+
this.reader.seek(offset);
|
|
769
|
+
let value;
|
|
770
|
+
if (isArray2) {
|
|
771
|
+
value = this._readArrayValue(valueRep);
|
|
772
|
+
} else {
|
|
773
|
+
value = this._readScalarValue(type);
|
|
774
|
+
}
|
|
775
|
+
this.reader.seek(savedOffset);
|
|
776
|
+
return value;
|
|
777
|
+
}
|
|
778
|
+
_readInlinedValue(valueRep) {
|
|
779
|
+
const type = valueRep.typeEnum;
|
|
780
|
+
const payload = valueRep.getInlinedValue();
|
|
781
|
+
const view = this._conversionView;
|
|
782
|
+
switch (type) {
|
|
783
|
+
case TypeEnum.Dictionary:
|
|
784
|
+
if (payload !== 0) throw new Error("USDC: invalid inline dictionary");
|
|
785
|
+
return /* @__PURE__ */ Object.create(null);
|
|
786
|
+
case TypeEnum.Bool:
|
|
787
|
+
return payload !== 0;
|
|
788
|
+
case TypeEnum.UChar:
|
|
789
|
+
return payload & 255;
|
|
790
|
+
case TypeEnum.Int:
|
|
791
|
+
case TypeEnum.Int64:
|
|
792
|
+
return payload | 0;
|
|
793
|
+
case TypeEnum.UInt:
|
|
794
|
+
case TypeEnum.UInt64:
|
|
795
|
+
return payload >>> 0;
|
|
796
|
+
case TypeEnum.Half:
|
|
797
|
+
return this._halfToFloat(payload & 65535);
|
|
798
|
+
case TypeEnum.Float: {
|
|
799
|
+
view.setUint32(0, payload, true);
|
|
800
|
+
return view.getFloat32(0, true);
|
|
801
|
+
}
|
|
802
|
+
case TypeEnum.Double: {
|
|
803
|
+
view.setUint32(0, payload, true);
|
|
804
|
+
return view.getFloat32(0, true);
|
|
805
|
+
}
|
|
806
|
+
case TypeEnum.Token:
|
|
807
|
+
return this.tokens[payload] || "";
|
|
808
|
+
case TypeEnum.String:
|
|
809
|
+
return this.tokens[this.strings[payload]] || "";
|
|
810
|
+
case TypeEnum.AssetPath:
|
|
811
|
+
return this.tokens[payload] || "";
|
|
812
|
+
case TypeEnum.Specifier:
|
|
813
|
+
return payload;
|
|
814
|
+
// 0=def, 1=over, 2=class
|
|
815
|
+
case TypeEnum.Permission:
|
|
816
|
+
case TypeEnum.Variability:
|
|
817
|
+
return payload;
|
|
818
|
+
// Vec2h: Two half-floats fit in 4 bytes, stored directly
|
|
819
|
+
case TypeEnum.Vec2h: {
|
|
820
|
+
view.setUint32(0, payload, true);
|
|
821
|
+
return [
|
|
822
|
+
this._halfToFloat(view.getUint16(0, true)),
|
|
823
|
+
this._halfToFloat(view.getUint16(2, true))
|
|
824
|
+
];
|
|
825
|
+
}
|
|
826
|
+
// Inlined vectors that don't fit in 4 bytes are encoded as signed 8-bit integers
|
|
827
|
+
// Vec2f = 8 bytes (2x float32), Vec3f = 12 bytes, Vec4f = 16 bytes, etc.
|
|
828
|
+
case TypeEnum.Vec2f:
|
|
829
|
+
case TypeEnum.Vec2i: {
|
|
830
|
+
view.setUint32(0, payload, true);
|
|
831
|
+
return [view.getInt8(0), view.getInt8(1)];
|
|
832
|
+
}
|
|
833
|
+
case TypeEnum.Vec3f:
|
|
834
|
+
case TypeEnum.Vec3i: {
|
|
835
|
+
view.setUint32(0, payload, true);
|
|
836
|
+
return [view.getInt8(0), view.getInt8(1), view.getInt8(2)];
|
|
837
|
+
}
|
|
838
|
+
case TypeEnum.Vec4f:
|
|
839
|
+
case TypeEnum.Vec4i: {
|
|
840
|
+
view.setUint32(0, payload, true);
|
|
841
|
+
return [view.getInt8(0), view.getInt8(1), view.getInt8(2), view.getInt8(3)];
|
|
842
|
+
}
|
|
843
|
+
case TypeEnum.Matrix2d: {
|
|
844
|
+
view.setUint32(0, payload, true);
|
|
845
|
+
const d0 = view.getInt8(0), d1 = view.getInt8(1);
|
|
846
|
+
return [d0, 0, 0, d1];
|
|
847
|
+
}
|
|
848
|
+
case TypeEnum.Matrix3d: {
|
|
849
|
+
view.setUint32(0, payload, true);
|
|
850
|
+
const d0 = view.getInt8(0), d1 = view.getInt8(1), d2 = view.getInt8(2);
|
|
851
|
+
return [d0, 0, 0, 0, d1, 0, 0, 0, d2];
|
|
852
|
+
}
|
|
853
|
+
case TypeEnum.Matrix4d: {
|
|
854
|
+
view.setUint32(0, payload, true);
|
|
855
|
+
const d0 = view.getInt8(0), d1 = view.getInt8(1), d2 = view.getInt8(2), d3 = view.getInt8(3);
|
|
856
|
+
return [d0, 0, 0, 0, 0, d1, 0, 0, 0, 0, d2, 0, 0, 0, 0, d3];
|
|
857
|
+
}
|
|
858
|
+
default:
|
|
859
|
+
throw new Error("USDC: unsupported inline value type " + type);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
_readTimeSamples(valueRep) {
|
|
863
|
+
const reader = this.reader;
|
|
864
|
+
const offset = valueRep.payload;
|
|
865
|
+
const savedOffset = reader.tell();
|
|
866
|
+
reader.seek(offset);
|
|
867
|
+
const timesStart = reader.tell();
|
|
868
|
+
const timesRelOffset = reader.readInt64();
|
|
869
|
+
reader.seek(timesStart + timesRelOffset);
|
|
870
|
+
const timesRepLo = reader.readUint32();
|
|
871
|
+
const timesRepHi = reader.readUint32();
|
|
872
|
+
const timesRep = new ValueRep(timesRepLo, timesRepHi);
|
|
873
|
+
const times = this._readValue(timesRep);
|
|
874
|
+
const afterTimesRep = timesStart + timesRelOffset + 8;
|
|
875
|
+
reader.seek(afterTimesRep);
|
|
876
|
+
const valuesStart = reader.tell();
|
|
877
|
+
const valuesRelOffset = reader.readInt64();
|
|
878
|
+
reader.seek(valuesStart + valuesRelOffset);
|
|
879
|
+
const numValues = checkedCount(reader.readUint64());
|
|
880
|
+
const valueReps = [];
|
|
881
|
+
for (let i = 0; i < numValues; i++) {
|
|
882
|
+
const repLo = reader.readUint32();
|
|
883
|
+
const repHi = reader.readUint32();
|
|
884
|
+
valueReps.push(new ValueRep(repLo, repHi));
|
|
885
|
+
}
|
|
886
|
+
const values = [];
|
|
887
|
+
for (let i = 0; i < numValues; i++) {
|
|
888
|
+
values.push(this._readValue(valueReps[i]));
|
|
889
|
+
}
|
|
890
|
+
reader.seek(savedOffset);
|
|
891
|
+
const timesArray = times instanceof Float64Array ? Array.from(times) : Array.isArray(times) ? times : [times];
|
|
892
|
+
return { times: timesArray, values };
|
|
893
|
+
}
|
|
894
|
+
_readScalarValue(type) {
|
|
895
|
+
const reader = this.reader;
|
|
896
|
+
switch (type) {
|
|
897
|
+
case TypeEnum.Invalid:
|
|
898
|
+
return null;
|
|
899
|
+
case TypeEnum.Bool:
|
|
900
|
+
return reader.readUint8() !== 0;
|
|
901
|
+
case TypeEnum.UChar:
|
|
902
|
+
return reader.readUint8();
|
|
903
|
+
case TypeEnum.Int:
|
|
904
|
+
return reader.readInt32();
|
|
905
|
+
case TypeEnum.UInt:
|
|
906
|
+
return reader.readUint32();
|
|
907
|
+
case TypeEnum.Int64:
|
|
908
|
+
return reader.readInt64();
|
|
909
|
+
case TypeEnum.UInt64:
|
|
910
|
+
return reader.readUint64();
|
|
911
|
+
case TypeEnum.Half:
|
|
912
|
+
return this._readHalf();
|
|
913
|
+
case TypeEnum.Float:
|
|
914
|
+
return reader.readFloat32();
|
|
915
|
+
case TypeEnum.Double:
|
|
916
|
+
return reader.readFloat64();
|
|
917
|
+
case TypeEnum.String:
|
|
918
|
+
case TypeEnum.Token: {
|
|
919
|
+
const index = reader.readUint32();
|
|
920
|
+
return this.tokens[index] || "";
|
|
921
|
+
}
|
|
922
|
+
case TypeEnum.AssetPath: {
|
|
923
|
+
const index = reader.readUint32();
|
|
924
|
+
return this.tokens[index] || "";
|
|
925
|
+
}
|
|
926
|
+
case TypeEnum.Vec2f:
|
|
927
|
+
return [reader.readFloat32(), reader.readFloat32()];
|
|
928
|
+
case TypeEnum.Vec2d:
|
|
929
|
+
return [reader.readFloat64(), reader.readFloat64()];
|
|
930
|
+
case TypeEnum.Vec2i:
|
|
931
|
+
return [reader.readInt32(), reader.readInt32()];
|
|
932
|
+
case TypeEnum.Vec3f:
|
|
933
|
+
return [reader.readFloat32(), reader.readFloat32(), reader.readFloat32()];
|
|
934
|
+
case TypeEnum.Vec3d:
|
|
935
|
+
return [reader.readFloat64(), reader.readFloat64(), reader.readFloat64()];
|
|
936
|
+
case TypeEnum.Vec3i:
|
|
937
|
+
return [reader.readInt32(), reader.readInt32(), reader.readInt32()];
|
|
938
|
+
case TypeEnum.Vec4f:
|
|
939
|
+
return [
|
|
940
|
+
reader.readFloat32(),
|
|
941
|
+
reader.readFloat32(),
|
|
942
|
+
reader.readFloat32(),
|
|
943
|
+
reader.readFloat32()
|
|
944
|
+
];
|
|
945
|
+
case TypeEnum.Vec4d:
|
|
946
|
+
return [
|
|
947
|
+
reader.readFloat64(),
|
|
948
|
+
reader.readFloat64(),
|
|
949
|
+
reader.readFloat64(),
|
|
950
|
+
reader.readFloat64()
|
|
951
|
+
];
|
|
952
|
+
case TypeEnum.Quatf:
|
|
953
|
+
return [
|
|
954
|
+
reader.readFloat32(),
|
|
955
|
+
reader.readFloat32(),
|
|
956
|
+
reader.readFloat32(),
|
|
957
|
+
reader.readFloat32()
|
|
958
|
+
];
|
|
959
|
+
case TypeEnum.Quatd:
|
|
960
|
+
return [
|
|
961
|
+
reader.readFloat64(),
|
|
962
|
+
reader.readFloat64(),
|
|
963
|
+
reader.readFloat64(),
|
|
964
|
+
reader.readFloat64()
|
|
965
|
+
];
|
|
966
|
+
case TypeEnum.Matrix4d: {
|
|
967
|
+
const m = [];
|
|
968
|
+
for (let i = 0; i < 16; i++) m.push(reader.readFloat64());
|
|
969
|
+
return m;
|
|
970
|
+
}
|
|
971
|
+
case TypeEnum.TokenVector: {
|
|
972
|
+
const count = checkedCount(reader.readUint64());
|
|
973
|
+
const tokens = [];
|
|
974
|
+
for (let i = 0; i < count; i++) {
|
|
975
|
+
const index = reader.readUint32();
|
|
976
|
+
tokens.push(this.tokens[index] || "");
|
|
977
|
+
}
|
|
978
|
+
return tokens;
|
|
979
|
+
}
|
|
980
|
+
case TypeEnum.PathVector: {
|
|
981
|
+
const count = checkedCount(reader.readUint64());
|
|
982
|
+
const paths = [];
|
|
983
|
+
for (let i = 0; i < count; i++) {
|
|
984
|
+
const index = reader.readUint32();
|
|
985
|
+
paths.push(this.paths[index] || "");
|
|
986
|
+
}
|
|
987
|
+
return paths;
|
|
988
|
+
}
|
|
989
|
+
case TypeEnum.DoubleVector: {
|
|
990
|
+
const count = checkedCount(reader.readUint64());
|
|
991
|
+
const arr = new Float64Array(checkedLength(count));
|
|
992
|
+
for (let i = 0; i < count; i++) arr[i] = reader.readFloat64();
|
|
993
|
+
return arr;
|
|
994
|
+
}
|
|
995
|
+
case TypeEnum.Dictionary:
|
|
996
|
+
return this._readDictionary();
|
|
997
|
+
case TypeEnum.TokenListOp:
|
|
998
|
+
case TypeEnum.StringListOp:
|
|
999
|
+
case TypeEnum.IntListOp:
|
|
1000
|
+
case TypeEnum.Int64ListOp:
|
|
1001
|
+
case TypeEnum.UIntListOp:
|
|
1002
|
+
case TypeEnum.UInt64ListOp:
|
|
1003
|
+
throw new Error("USDC: value list operations are unsupported");
|
|
1004
|
+
case TypeEnum.PathListOp: {
|
|
1005
|
+
const flags = reader.readUint8();
|
|
1006
|
+
if (flags & 24 || (flags & 102).toString(2).replaceAll("0", "").length > 1)
|
|
1007
|
+
throw new Error("USDC: compound path list operations are unsupported");
|
|
1008
|
+
const hasExplicitItems = (flags & 2) !== 0;
|
|
1009
|
+
const hasAddItems = (flags & 4) !== 0;
|
|
1010
|
+
const hasDeleteItems = (flags & 8) !== 0;
|
|
1011
|
+
const hasReorderItems = (flags & 16) !== 0;
|
|
1012
|
+
const hasPrependItems = (flags & 32) !== 0;
|
|
1013
|
+
const hasAppendItems = (flags & 64) !== 0;
|
|
1014
|
+
const readPathList = () => {
|
|
1015
|
+
const itemCount = checkedCount(reader.readUint64());
|
|
1016
|
+
const paths = [];
|
|
1017
|
+
for (let i = 0; i < itemCount; i++) {
|
|
1018
|
+
const pathIdx = reader.readUint32();
|
|
1019
|
+
paths.push(this.paths[pathIdx]);
|
|
1020
|
+
}
|
|
1021
|
+
return paths;
|
|
1022
|
+
};
|
|
1023
|
+
let explicitPaths = null;
|
|
1024
|
+
let addPaths = null;
|
|
1025
|
+
let prependPaths = null;
|
|
1026
|
+
let appendPaths = null;
|
|
1027
|
+
if (hasExplicitItems) explicitPaths = readPathList();
|
|
1028
|
+
if (hasAddItems) addPaths = readPathList();
|
|
1029
|
+
if (hasPrependItems) prependPaths = readPathList();
|
|
1030
|
+
if (hasAppendItems) appendPaths = readPathList();
|
|
1031
|
+
if (hasDeleteItems) readPathList();
|
|
1032
|
+
if (hasReorderItems) readPathList();
|
|
1033
|
+
if (prependPaths && prependPaths.length > 0) return prependPaths;
|
|
1034
|
+
if (explicitPaths && explicitPaths.length > 0) return explicitPaths;
|
|
1035
|
+
if (appendPaths && appendPaths.length > 0) return appendPaths;
|
|
1036
|
+
if (addPaths && addPaths.length > 0) return addPaths;
|
|
1037
|
+
return null;
|
|
1038
|
+
}
|
|
1039
|
+
case TypeEnum.VariantSelectionMap: {
|
|
1040
|
+
const elementCount = checkedCount(reader.readUint64());
|
|
1041
|
+
const map = /* @__PURE__ */ Object.create(null);
|
|
1042
|
+
for (let i = 0; i < elementCount; i++) {
|
|
1043
|
+
const keyIdx = reader.readUint32();
|
|
1044
|
+
const valueIdx = reader.readUint32();
|
|
1045
|
+
const key = this.tokens[this.strings[keyIdx]];
|
|
1046
|
+
const value = this.tokens[this.strings[valueIdx]];
|
|
1047
|
+
if (key && value) map[key] = value;
|
|
1048
|
+
}
|
|
1049
|
+
return map;
|
|
1050
|
+
}
|
|
1051
|
+
default:
|
|
1052
|
+
throw new Error(
|
|
1053
|
+
"USDC: unsupported encoding: " + ["USDCParser: Unsupported scalar type", type].join(" ")
|
|
1054
|
+
);
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
/** Reads bounded string-keyed dictionary entries and their recursive value representations. */
|
|
1058
|
+
_readDictionary() {
|
|
1059
|
+
const reader = this.reader;
|
|
1060
|
+
const dictionaryOffset = reader.tell();
|
|
1061
|
+
this._activeDictionaries ||= /* @__PURE__ */ new Set();
|
|
1062
|
+
if (this._activeDictionaries.has(dictionaryOffset))
|
|
1063
|
+
throw new Error("USDC: cyclic dictionary value");
|
|
1064
|
+
if (this._activeDictionaries.size >= 64)
|
|
1065
|
+
throw new Error("USDC: dictionary depth limit exceeded");
|
|
1066
|
+
this._activeDictionaries.add(dictionaryOffset);
|
|
1067
|
+
try {
|
|
1068
|
+
const count = checkedCount(reader.readUint64());
|
|
1069
|
+
if (count > Math.floor((this.buffer.byteLength - reader.tell()) / 20))
|
|
1070
|
+
throw new Error("USDC: truncated dictionary entries");
|
|
1071
|
+
const dictionary = /* @__PURE__ */ Object.create(null);
|
|
1072
|
+
for (let index = 0; index < count; index++) {
|
|
1073
|
+
const stringIndex = reader.readUint32();
|
|
1074
|
+
const key = this.tokens[this.strings[stringIndex]];
|
|
1075
|
+
if (typeof key !== "string" || Object.hasOwn(dictionary, key))
|
|
1076
|
+
throw new Error("USDC: invalid dictionary key");
|
|
1077
|
+
const offsetLocation = reader.tell();
|
|
1078
|
+
const relativeOffset = reader.readInt64();
|
|
1079
|
+
if (relativeOffset < 8) throw new Error("USDC: invalid dictionary value offset");
|
|
1080
|
+
reader.seek(offsetLocation + relativeOffset);
|
|
1081
|
+
const representation = new ValueRep(reader.readUint32(), reader.readUint32());
|
|
1082
|
+
if (representation.typeEnum < TypeEnum.Bool || representation.typeEnum > TypeEnum.AssetPath && representation.typeEnum !== TypeEnum.Dictionary || representation.isArray && !DICTIONARY_ARRAY_TYPES.has(representation.typeEnum))
|
|
1083
|
+
throw new Error("USDC: unsupported dictionary value type");
|
|
1084
|
+
const nextEntry = reader.tell();
|
|
1085
|
+
const value = this._readValue(representation);
|
|
1086
|
+
dictionary[key] = representation.typeEnum === TypeEnum.AssetPath ? { assetPath: value } : value;
|
|
1087
|
+
reader.seek(nextEntry);
|
|
1088
|
+
}
|
|
1089
|
+
return dictionary;
|
|
1090
|
+
} finally {
|
|
1091
|
+
this._activeDictionaries.delete(dictionaryOffset);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
_readArrayValue(valueRep) {
|
|
1095
|
+
const reader = this.reader;
|
|
1096
|
+
const type = valueRep.typeEnum;
|
|
1097
|
+
const isCompressed = valueRep.isCompressed;
|
|
1098
|
+
let size;
|
|
1099
|
+
if (this.version.major === 0 && this.version.minor < 7) {
|
|
1100
|
+
size = reader.readUint32();
|
|
1101
|
+
} else {
|
|
1102
|
+
size = reader.readUint64();
|
|
1103
|
+
}
|
|
1104
|
+
if (!Number.isSafeInteger(size) || size < 0) {
|
|
1105
|
+
throw new RangeError("USDCParser: Invalid array size " + size + " for type " + type + ".");
|
|
1106
|
+
}
|
|
1107
|
+
if (size > 2147483647) {
|
|
1108
|
+
throw new RangeError("USDCParser: Array size " + size + " exceeds implementation limits.");
|
|
1109
|
+
}
|
|
1110
|
+
size = checkedCount(size);
|
|
1111
|
+
if (size === 0) return [];
|
|
1112
|
+
if (isCompressed) {
|
|
1113
|
+
return this._readCompressedArray(type, size);
|
|
1114
|
+
}
|
|
1115
|
+
switch (type) {
|
|
1116
|
+
case TypeEnum.Int: {
|
|
1117
|
+
const arr = new Int32Array(checkedLength(size));
|
|
1118
|
+
for (let i = 0; i < size; i++) arr[i] = reader.readInt32();
|
|
1119
|
+
return arr;
|
|
1120
|
+
}
|
|
1121
|
+
case TypeEnum.UInt: {
|
|
1122
|
+
const arr = new Uint32Array(checkedLength(size));
|
|
1123
|
+
for (let i = 0; i < size; i++) arr[i] = reader.readUint32();
|
|
1124
|
+
return arr;
|
|
1125
|
+
}
|
|
1126
|
+
case TypeEnum.Float: {
|
|
1127
|
+
const arr = new Float32Array(checkedLength(size));
|
|
1128
|
+
for (let i = 0; i < size; i++) arr[i] = reader.readFloat32();
|
|
1129
|
+
return arr;
|
|
1130
|
+
}
|
|
1131
|
+
case TypeEnum.Double: {
|
|
1132
|
+
const arr = new Float64Array(checkedLength(size));
|
|
1133
|
+
for (let i = 0; i < size; i++) arr[i] = reader.readFloat64();
|
|
1134
|
+
return arr;
|
|
1135
|
+
}
|
|
1136
|
+
case TypeEnum.Vec2f: {
|
|
1137
|
+
const arr = new Float32Array(checkedLength(size * 2));
|
|
1138
|
+
for (let i = 0; i < size * 2; i++) arr[i] = reader.readFloat32();
|
|
1139
|
+
return arr;
|
|
1140
|
+
}
|
|
1141
|
+
case TypeEnum.Vec3f: {
|
|
1142
|
+
const arr = new Float32Array(checkedLength(size * 3));
|
|
1143
|
+
for (let i = 0; i < size * 3; i++) arr[i] = reader.readFloat32();
|
|
1144
|
+
return arr;
|
|
1145
|
+
}
|
|
1146
|
+
case TypeEnum.Vec4f: {
|
|
1147
|
+
const arr = new Float32Array(checkedLength(size * 4));
|
|
1148
|
+
for (let i = 0; i < size * 4; i++) arr[i] = reader.readFloat32();
|
|
1149
|
+
return arr;
|
|
1150
|
+
}
|
|
1151
|
+
case TypeEnum.Vec3h: {
|
|
1152
|
+
const arr = new Float32Array(checkedLength(size * 3));
|
|
1153
|
+
for (let i = 0; i < size * 3; i++) arr[i] = this._readHalf();
|
|
1154
|
+
return arr;
|
|
1155
|
+
}
|
|
1156
|
+
case TypeEnum.Quatf: {
|
|
1157
|
+
const arr = new Float32Array(checkedLength(size * 4));
|
|
1158
|
+
for (let i = 0; i < size * 4; i++) arr[i] = reader.readFloat32();
|
|
1159
|
+
return arr;
|
|
1160
|
+
}
|
|
1161
|
+
case TypeEnum.Quath: {
|
|
1162
|
+
const arr = new Float32Array(checkedLength(size * 4));
|
|
1163
|
+
for (let i = 0; i < size * 4; i++) arr[i] = this._readHalf();
|
|
1164
|
+
return arr;
|
|
1165
|
+
}
|
|
1166
|
+
case TypeEnum.Matrix4d: {
|
|
1167
|
+
const arr = new Float64Array(checkedLength(size * 16));
|
|
1168
|
+
for (let i = 0; i < size * 16; i++) arr[i] = reader.readFloat64();
|
|
1169
|
+
return arr;
|
|
1170
|
+
}
|
|
1171
|
+
case TypeEnum.String:
|
|
1172
|
+
case TypeEnum.Token: {
|
|
1173
|
+
const arr = [];
|
|
1174
|
+
for (let i = 0; i < size; i++) {
|
|
1175
|
+
const index = reader.readUint32();
|
|
1176
|
+
const tokenIndex = type === TypeEnum.String ? this.strings[index] : index;
|
|
1177
|
+
const value = this.tokens[tokenIndex];
|
|
1178
|
+
if (typeof value !== "string") throw new Error("USDC: invalid string array index");
|
|
1179
|
+
arr.push(value);
|
|
1180
|
+
}
|
|
1181
|
+
return arr;
|
|
1182
|
+
}
|
|
1183
|
+
case TypeEnum.Half: {
|
|
1184
|
+
const arr = new Float32Array(checkedLength(size));
|
|
1185
|
+
for (let i = 0; i < size; i++) arr[i] = this._readHalf();
|
|
1186
|
+
return arr;
|
|
1187
|
+
}
|
|
1188
|
+
default:
|
|
1189
|
+
throw new Error(
|
|
1190
|
+
"USDC: unsupported encoding: " + ["USDCParser: Unsupported array type", type].join(" ")
|
|
1191
|
+
);
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
_readCompressedArray(type, size) {
|
|
1195
|
+
const reader = this.reader;
|
|
1196
|
+
switch (type) {
|
|
1197
|
+
case TypeEnum.Int:
|
|
1198
|
+
case TypeEnum.UInt: {
|
|
1199
|
+
const compressedSize = reader.readUint64();
|
|
1200
|
+
const compressed = reader.readBytes(compressedSize);
|
|
1201
|
+
const values = decompressIntegers32(
|
|
1202
|
+
compressed.buffer.slice(compressed.byteOffset, compressed.byteOffset + compressedSize),
|
|
1203
|
+
size
|
|
1204
|
+
);
|
|
1205
|
+
return type === TypeEnum.UInt ? new Uint32Array(values.buffer, values.byteOffset, values.length) : values;
|
|
1206
|
+
}
|
|
1207
|
+
case TypeEnum.Half:
|
|
1208
|
+
case TypeEnum.Double:
|
|
1209
|
+
case TypeEnum.Float: {
|
|
1210
|
+
const code = reader.readInt8();
|
|
1211
|
+
if (code === FLOAT_COMPRESSION_INT) {
|
|
1212
|
+
const compressedSize = reader.readUint64();
|
|
1213
|
+
const compressed = reader.readBytes(compressedSize);
|
|
1214
|
+
const ints = decompressIntegers32(
|
|
1215
|
+
compressed.buffer.slice(compressed.byteOffset, compressed.byteOffset + compressedSize),
|
|
1216
|
+
size
|
|
1217
|
+
);
|
|
1218
|
+
const floats = type === TypeEnum.Double ? new Float64Array(checkedLength(size)) : new Float32Array(checkedLength(size));
|
|
1219
|
+
for (let i = 0; i < size; i++)
|
|
1220
|
+
floats[i] = type === TypeEnum.Half ? this._convertHalfInteger(ints[i]) : ints[i];
|
|
1221
|
+
return floats;
|
|
1222
|
+
} else if (code === FLOAT_COMPRESSION_LUT) {
|
|
1223
|
+
const lutSize = checkedCount(reader.readUint32());
|
|
1224
|
+
if (lutSize === 0) throw new Error("USDC: invalid float lookup table");
|
|
1225
|
+
const lut = type === TypeEnum.Double ? new Float64Array(checkedLength(lutSize)) : new Float32Array(checkedLength(lutSize));
|
|
1226
|
+
for (let i = 0; i < lutSize; i++)
|
|
1227
|
+
lut[i] = type === TypeEnum.Half ? this._readHalf() : type === TypeEnum.Double ? reader.readFloat64() : reader.readFloat32();
|
|
1228
|
+
const compressedSize = reader.readUint64();
|
|
1229
|
+
const compressed = reader.readBytes(compressedSize);
|
|
1230
|
+
const indices = decompressIntegers32(
|
|
1231
|
+
compressed.buffer.slice(compressed.byteOffset, compressed.byteOffset + compressedSize),
|
|
1232
|
+
size
|
|
1233
|
+
);
|
|
1234
|
+
const floats = type === TypeEnum.Double ? new Float64Array(checkedLength(size)) : new Float32Array(checkedLength(size));
|
|
1235
|
+
for (let i = 0; i < size; i++) {
|
|
1236
|
+
if (indices[i] < 0 || indices[i] >= lutSize)
|
|
1237
|
+
throw new Error("USDC: invalid float lookup index");
|
|
1238
|
+
floats[i] = lut[indices[i]];
|
|
1239
|
+
}
|
|
1240
|
+
return floats;
|
|
1241
|
+
}
|
|
1242
|
+
throw new Error(
|
|
1243
|
+
"USDC: unsupported encoding: " + ["USDCParser: Unknown float compression code", code].join(" ")
|
|
1244
|
+
);
|
|
1245
|
+
}
|
|
1246
|
+
default:
|
|
1247
|
+
throw new Error(
|
|
1248
|
+
"USDC: unsupported encoding: " + ["USDCParser: Unsupported compressed array type", type].join(" ")
|
|
1249
|
+
);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
/** Rounds integer-compressed half samples using IEEE ties-to-even semantics. */
|
|
1253
|
+
_convertHalfInteger(value) {
|
|
1254
|
+
const absoluteValue = Math.abs(value);
|
|
1255
|
+
if (absoluteValue <= 2048) return value;
|
|
1256
|
+
if (absoluteValue >= 65520) return Math.sign(value) * Infinity;
|
|
1257
|
+
const spacing = 2 ** (Math.floor(Math.log2(absoluteValue)) - 10);
|
|
1258
|
+
const scaledValue = absoluteValue / spacing;
|
|
1259
|
+
const lowerValue = Math.floor(scaledValue);
|
|
1260
|
+
const fractionValue = scaledValue - lowerValue;
|
|
1261
|
+
const roundedValue = fractionValue > 0.5 || fractionValue === 0.5 && lowerValue % 2 !== 0 ? lowerValue + 1 : lowerValue;
|
|
1262
|
+
return Math.sign(value) * roundedValue * spacing;
|
|
1263
|
+
}
|
|
1264
|
+
_readHalf() {
|
|
1265
|
+
return this._halfToFloat(this.reader.readUint16());
|
|
1266
|
+
}
|
|
1267
|
+
_halfToFloat(h) {
|
|
1268
|
+
const sign = (h & 32768) >> 15;
|
|
1269
|
+
const exp = (h & 31744) >> 10;
|
|
1270
|
+
const frac = h & 1023;
|
|
1271
|
+
if (exp === 0) {
|
|
1272
|
+
if (frac === 0) {
|
|
1273
|
+
return sign ? -0 : 0;
|
|
1274
|
+
}
|
|
1275
|
+
return (sign ? -1 : 1) * HALF_DENORM_SCALE * (frac / 1024);
|
|
1276
|
+
} else if (exp === 31) {
|
|
1277
|
+
return frac ? NaN : sign ? -Infinity : Infinity;
|
|
1278
|
+
}
|
|
1279
|
+
return (sign ? -1 : 1) * HALF_EXPONENT_TABLE[exp] * (1 + frac / 1024);
|
|
1280
|
+
}
|
|
1281
|
+
_getFieldsForSpec(spec) {
|
|
1282
|
+
const fields = /* @__PURE__ */ Object.create(null);
|
|
1283
|
+
let fieldSetIndex = spec.fieldSetIndex;
|
|
1284
|
+
const maxIterations = 1e4;
|
|
1285
|
+
let iterations = 0;
|
|
1286
|
+
while (fieldSetIndex < this.fieldSets.length && iterations < maxIterations) {
|
|
1287
|
+
const fieldIndex = this.fieldSets[fieldSetIndex];
|
|
1288
|
+
if (fieldIndex === FIELD_SET_TERMINATOR || fieldIndex === -1) break;
|
|
1289
|
+
const field = this.fields[fieldIndex];
|
|
1290
|
+
if (!field) throw new Error("USDC: invalid field index");
|
|
1291
|
+
if (field) {
|
|
1292
|
+
const name22 = this.tokens[field.tokenIndex];
|
|
1293
|
+
const value = this._readValue(field.valueRep);
|
|
1294
|
+
fields[name22] = value;
|
|
1295
|
+
}
|
|
1296
|
+
fieldSetIndex++;
|
|
1297
|
+
iterations++;
|
|
1298
|
+
}
|
|
1299
|
+
if (iterations >= maxIterations) throw new Error("USDC: field traversal limit exceeded");
|
|
1300
|
+
return fields;
|
|
1301
|
+
}
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
});
|
|
1305
|
+
|
|
1306
|
+
// src/usd/lib/parse-usdc.ts
|
|
1307
|
+
function parseUSDC(data, url) {
|
|
1308
|
+
if (data.byteLength < 88 || data.byteLength > 64 * 1024 * 1024)
|
|
1309
|
+
throw new Error("USDC: invalid input size");
|
|
1310
|
+
const bytes = new Uint8Array(data);
|
|
1311
|
+
if (bytes[8] !== 0 || bytes[9] !== 8 || bytes[10] !== 0)
|
|
1312
|
+
throw new Error("USDC: initial decoder requires crate version 0.8.0");
|
|
1313
|
+
const reader = new DataView(data);
|
|
1314
|
+
const table = reader.getBigUint64(16, true);
|
|
1315
|
+
if (table > BigInt(data.byteLength - 8)) throw new Error("USDC: invalid section table");
|
|
1316
|
+
const offset = Number(table), count = reader.getBigUint64(offset, true);
|
|
1317
|
+
if (count > 16n || offset + 8 + Number(count) * 32 > data.byteLength)
|
|
1318
|
+
throw new Error("USDC: invalid section table length");
|
|
1319
|
+
const sectionNames = /* @__PURE__ */ new Set();
|
|
1320
|
+
for (let index = 0; index < Number(count); index++) {
|
|
1321
|
+
const entry = offset + 8 + index * 32;
|
|
1322
|
+
const nameBytes = bytes.subarray(entry, entry + 16);
|
|
1323
|
+
const terminator = nameBytes.indexOf(0);
|
|
1324
|
+
const name22 = new TextDecoder().decode(
|
|
1325
|
+
nameBytes.subarray(0, terminator < 0 ? nameBytes.length : terminator)
|
|
1326
|
+
);
|
|
1327
|
+
if (sectionNames.has(name22)) throw new Error("USDC: duplicate section");
|
|
1328
|
+
sectionNames.add(name22);
|
|
1329
|
+
const start = reader.getBigUint64(entry + 16, true), size = reader.getBigUint64(entry + 24, true);
|
|
1330
|
+
if (start < 88n || start + size > BigInt(data.byteLength))
|
|
1331
|
+
throw new Error("USDC: section out of bounds");
|
|
1332
|
+
}
|
|
1333
|
+
for (const name22 of ["TOKENS", "STRINGS", "FIELDS", "FIELDSETS", "PATHS", "SPECS"])
|
|
1334
|
+
if (!sectionNames.has(name22)) throw new Error("USDC: missing required section");
|
|
1335
|
+
const { specsByPath } = new USDCParser().parseData(data);
|
|
1336
|
+
const prims = /* @__PURE__ */ new Map();
|
|
1337
|
+
for (const [path2, specification] of Object.entries(specsByPath)) {
|
|
1338
|
+
if (specification.specType === 7 && path2 === "/") continue;
|
|
1339
|
+
if (specification.specType === 1 || specification.specType === 8) continue;
|
|
1340
|
+
if (specification.specType !== 6 || !/^\/(?:[A-Za-z_][\w:]*\/)*[A-Za-z_][\w:]*$/.test(path2))
|
|
1341
|
+
throw new Error("USDC: unsupported prim specification");
|
|
1342
|
+
const fields = specification.fields;
|
|
1343
|
+
const specifier = fields.specifier ?? 0;
|
|
1344
|
+
if (specifier !== 0 && specifier !== 1 && specifier !== 2)
|
|
1345
|
+
throw new Error("USDC: invalid prim specifier");
|
|
1346
|
+
const metadata3 = convertFields(
|
|
1347
|
+
fields,
|
|
1348
|
+
/* @__PURE__ */ new Set(["specifier", "typeName", "primChildren", "properties"])
|
|
1349
|
+
);
|
|
1350
|
+
prims.set(path2, {
|
|
1351
|
+
name: path2.slice(path2.lastIndexOf("/") + 1),
|
|
1352
|
+
path: path2,
|
|
1353
|
+
sourceUrl: url,
|
|
1354
|
+
type: String(fields.typeName || ""),
|
|
1355
|
+
specifier: ["def", "over", "class"][specifier],
|
|
1356
|
+
attributes: /* @__PURE__ */ Object.create(null),
|
|
1357
|
+
metadata: metadata3,
|
|
1358
|
+
variants: /* @__PURE__ */ Object.create(null),
|
|
1359
|
+
children: []
|
|
1360
|
+
});
|
|
1361
|
+
}
|
|
1362
|
+
const roots = [];
|
|
1363
|
+
for (const prim of prims.values()) {
|
|
1364
|
+
const parentPath = prim.path.slice(0, prim.path.lastIndexOf("/"));
|
|
1365
|
+
if (!parentPath) roots.push(prim);
|
|
1366
|
+
else {
|
|
1367
|
+
const parent = prims.get(parentPath);
|
|
1368
|
+
if (!parent) throw new Error("USDC: missing parent prim");
|
|
1369
|
+
parent.children.push(prim);
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
orderPrims(roots, specsByPath["/"]?.fields.primChildren);
|
|
1373
|
+
for (const prim of prims.values())
|
|
1374
|
+
orderPrims(prim.children, specsByPath[prim.path]?.fields.primChildren);
|
|
1375
|
+
for (const [path2, specification] of Object.entries(specsByPath)) {
|
|
1376
|
+
if (specification.specType !== 1 && specification.specType !== 8) continue;
|
|
1377
|
+
const separator = path2.indexOf(".");
|
|
1378
|
+
const prim = prims.get(path2.slice(0, separator));
|
|
1379
|
+
if (separator < 0 || !prim) throw new Error("USDC: property has no owning prim");
|
|
1380
|
+
const name22 = path2.slice(separator + 1), fields = specification.fields;
|
|
1381
|
+
const type = specification.specType === 8 ? "rel" : String(fields.typeName || "");
|
|
1382
|
+
const value = convertAttributeValue(
|
|
1383
|
+
specification.specType === 8 ? fields.targetPaths : fields.default,
|
|
1384
|
+
type
|
|
1385
|
+
);
|
|
1386
|
+
const metadata3 = convertFields(
|
|
1387
|
+
fields,
|
|
1388
|
+
/* @__PURE__ */ new Set(["typeName", "default", "targetPaths", "timeSamples"])
|
|
1389
|
+
);
|
|
1390
|
+
if (fields.timeSamples !== void 0)
|
|
1391
|
+
metadata3.timeSamples = convertTimeSamples(fields.timeSamples, type);
|
|
1392
|
+
prim.attributes[name22] = {
|
|
1393
|
+
name: name22,
|
|
1394
|
+
type,
|
|
1395
|
+
value,
|
|
1396
|
+
metadata: metadata3
|
|
1397
|
+
};
|
|
1398
|
+
}
|
|
1399
|
+
return {
|
|
1400
|
+
format: "usdc",
|
|
1401
|
+
url,
|
|
1402
|
+
metadata: convertFields(specsByPath["/"]?.fields || {}, /* @__PURE__ */ new Set(["primChildren"])),
|
|
1403
|
+
rootPrims: roots,
|
|
1404
|
+
layers: []
|
|
1405
|
+
};
|
|
1406
|
+
}
|
|
1407
|
+
function convertFields(fields, excluded) {
|
|
1408
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
1409
|
+
for (const [name22, value] of Object.entries(fields))
|
|
1410
|
+
if (!excluded.has(name22)) result[name22] = convertValue(value);
|
|
1411
|
+
return result;
|
|
1412
|
+
}
|
|
1413
|
+
function convertValue(value) {
|
|
1414
|
+
if (value === void 0 || value === null) return null;
|
|
1415
|
+
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean")
|
|
1416
|
+
return value;
|
|
1417
|
+
if (Array.isArray(value)) return value.map(convertValue);
|
|
1418
|
+
if (ArrayBuffer.isView(value) && !(value instanceof DataView))
|
|
1419
|
+
return Array.from(value);
|
|
1420
|
+
if (typeof value === "object") return convertFields(value, /* @__PURE__ */ new Set());
|
|
1421
|
+
throw new Error("USDC: unsupported decoded value");
|
|
1422
|
+
}
|
|
1423
|
+
function convertAttributeValue(raw, type) {
|
|
1424
|
+
const value = convertValue(raw);
|
|
1425
|
+
if (type === "asset" && typeof value === "string") return { assetPath: value };
|
|
1426
|
+
if (type === "rel" && Array.isArray(value))
|
|
1427
|
+
return value.map((path2) => typeof path2 === "string" ? { path: path2 } : path2);
|
|
1428
|
+
const tuple = /^(?:(?:point|normal|vector|color|texCoord)([234])[fdh]|(?:float|double|half|int)([234]))\[\]$/.exec(
|
|
1429
|
+
type
|
|
1430
|
+
);
|
|
1431
|
+
if (tuple && Array.isArray(value)) {
|
|
1432
|
+
const components = Number(tuple[1] || tuple[2]);
|
|
1433
|
+
if (value.length % components) throw new Error("USDC: incomplete vector tuple");
|
|
1434
|
+
const tuples = [];
|
|
1435
|
+
for (let offset = 0; offset < value.length; offset += components)
|
|
1436
|
+
tuples.push(value.slice(offset, offset + components));
|
|
1437
|
+
return tuples;
|
|
1438
|
+
}
|
|
1439
|
+
return value;
|
|
1440
|
+
}
|
|
1441
|
+
function orderPrims(prims, names) {
|
|
1442
|
+
if (names === void 0) return;
|
|
1443
|
+
if (!Array.isArray(names)) throw new Error("USDC: invalid primChildren order");
|
|
1444
|
+
const remaining = new Map(prims.map((prim) => [prim.name, prim]));
|
|
1445
|
+
const ordered = [];
|
|
1446
|
+
for (const name22 of names) {
|
|
1447
|
+
const prim = typeof name22 === "string" ? remaining.get(name22) : void 0;
|
|
1448
|
+
if (!prim) throw new Error("USDC: invalid primChildren reference");
|
|
1449
|
+
ordered.push(prim);
|
|
1450
|
+
remaining.delete(name22);
|
|
1451
|
+
}
|
|
1452
|
+
for (const prim of remaining.values()) ordered.push(prim);
|
|
1453
|
+
for (let index = 0; index < ordered.length; index++) prims[index] = ordered[index];
|
|
1454
|
+
}
|
|
1455
|
+
function convertTimeSamples(raw, type) {
|
|
1456
|
+
if (!raw || typeof raw !== "object") throw new Error("USDC: invalid time samples");
|
|
1457
|
+
const samples = raw;
|
|
1458
|
+
const times = convertValue(samples.times);
|
|
1459
|
+
if (!Array.isArray(times) || !Array.isArray(samples.values) || times.length !== samples.values.length)
|
|
1460
|
+
throw new Error("USDC: invalid time samples");
|
|
1461
|
+
return { times, values: samples.values.map((value) => convertAttributeValue(value, type)) };
|
|
1462
|
+
}
|
|
1463
|
+
var init_parse_usdc = __esm({
|
|
1464
|
+
"src/usd/lib/parse-usdc.ts"() {
|
|
1465
|
+
"use strict";
|
|
1466
|
+
init_usdc_parser();
|
|
1467
|
+
}
|
|
1468
|
+
});
|
|
1469
|
+
|
|
59
1470
|
// src/usd/lib/parse-usda.ts
|
|
60
1471
|
function parseUSDA(source, url) {
|
|
61
1472
|
if (!source.trimStart().startsWith("#usda")) {
|
|
@@ -90,7 +1501,7 @@ var __exports__ = (() => {
|
|
|
90
1501
|
}
|
|
91
1502
|
/** Parses the complete USDA layer. */
|
|
92
1503
|
parse() {
|
|
93
|
-
const
|
|
1504
|
+
const metadata3 = this.tokenizer.match("(") ? this.parseMetadata(")") : {};
|
|
94
1505
|
const rootPrims = [];
|
|
95
1506
|
while (!this.tokenizer.isAtEnd()) {
|
|
96
1507
|
if (this.isPrimDeclaration()) {
|
|
@@ -102,7 +1513,7 @@ var __exports__ = (() => {
|
|
|
102
1513
|
return {
|
|
103
1514
|
format: "usda",
|
|
104
1515
|
url: this.url,
|
|
105
|
-
metadata:
|
|
1516
|
+
metadata: metadata3,
|
|
106
1517
|
rootPrims,
|
|
107
1518
|
layers: this.url ? [this.url] : []
|
|
108
1519
|
};
|
|
@@ -116,7 +1527,7 @@ var __exports__ = (() => {
|
|
|
116
1527
|
const type = hasExplicitType ? firstToken.value : "";
|
|
117
1528
|
const name22 = hasExplicitType ? this.tokenizer.read().value : firstToken.value;
|
|
118
1529
|
const path2 = `${parentPath}/${name22}`;
|
|
119
|
-
const
|
|
1530
|
+
const metadata3 = this.tokenizer.match("(") ? this.parseMetadata(")") : {};
|
|
120
1531
|
this.tokenizer.expect("{");
|
|
121
1532
|
const contents = this.parsePrimContents(path2);
|
|
122
1533
|
return {
|
|
@@ -126,7 +1537,7 @@ var __exports__ = (() => {
|
|
|
126
1537
|
type,
|
|
127
1538
|
specifier,
|
|
128
1539
|
attributes: contents.attributes,
|
|
129
|
-
metadata: { ...
|
|
1540
|
+
metadata: { ...metadata3, ...contents.metadata },
|
|
130
1541
|
variants: contents.variants,
|
|
131
1542
|
children: contents.children
|
|
132
1543
|
};
|
|
@@ -134,7 +1545,7 @@ var __exports__ = (() => {
|
|
|
134
1545
|
/** Parses the attributes, variants, and child prims inside a prim body. */
|
|
135
1546
|
parsePrimContents(parentPath) {
|
|
136
1547
|
const attributes = {};
|
|
137
|
-
const
|
|
1548
|
+
const metadata3 = {};
|
|
138
1549
|
const children = [];
|
|
139
1550
|
const variants = {};
|
|
140
1551
|
while (!this.tokenizer.isAtEnd() && !this.tokenizer.match("}")) {
|
|
@@ -149,7 +1560,7 @@ var __exports__ = (() => {
|
|
|
149
1560
|
}
|
|
150
1561
|
}
|
|
151
1562
|
}
|
|
152
|
-
return { attributes, metadata:
|
|
1563
|
+
return { attributes, metadata: metadata3, children, variants };
|
|
153
1564
|
}
|
|
154
1565
|
/** Parses one named variant set. */
|
|
155
1566
|
parseVariantSet(parentPath, variants) {
|
|
@@ -199,12 +1610,12 @@ var __exports__ = (() => {
|
|
|
199
1610
|
const name22 = significantTokens[significantTokens.length - 1].value;
|
|
200
1611
|
const type = significantTokens.slice(0, -1).map((token) => token.value).join("");
|
|
201
1612
|
const value = this.parseValue();
|
|
202
|
-
const
|
|
203
|
-
return { name: name22, type, value, metadata:
|
|
1613
|
+
const metadata3 = this.tokenizer.match("(") ? this.parseMetadata(")") : {};
|
|
1614
|
+
return { name: name22, type, value, metadata: metadata3 };
|
|
204
1615
|
}
|
|
205
1616
|
/** Parses a metadata dictionary through the requested terminator. */
|
|
206
1617
|
parseMetadata(terminator) {
|
|
207
|
-
const
|
|
1618
|
+
const metadata3 = {};
|
|
208
1619
|
while (!this.tokenizer.isAtEnd() && !this.tokenizer.match(terminator)) {
|
|
209
1620
|
this.tokenizer.match(",");
|
|
210
1621
|
if (this.tokenizer.peek().value === terminator) {
|
|
@@ -227,10 +1638,10 @@ var __exports__ = (() => {
|
|
|
227
1638
|
continue;
|
|
228
1639
|
}
|
|
229
1640
|
const name22 = declarationTokens[declarationTokens.length - 1].value;
|
|
230
|
-
|
|
1641
|
+
metadata3[name22] = this.parseValue();
|
|
231
1642
|
this.tokenizer.match(",");
|
|
232
1643
|
}
|
|
233
|
-
return
|
|
1644
|
+
return metadata3;
|
|
234
1645
|
}
|
|
235
1646
|
/** Parses one scalar, list, tuple, dictionary, asset path, or scene path value. */
|
|
236
1647
|
parseValue() {
|
|
@@ -446,30 +1857,52 @@ var __exports__ = (() => {
|
|
|
446
1857
|
const directoryOffset = findCentralDirectory(view);
|
|
447
1858
|
const entryCount = view.getUint16(directoryOffset + 10, true);
|
|
448
1859
|
let entryOffset = view.getUint32(directoryOffset + 16, true);
|
|
1860
|
+
const dataLimit = entryOffset;
|
|
449
1861
|
const files = /* @__PURE__ */ new Map();
|
|
450
|
-
const
|
|
1862
|
+
const textDecoder2 = new TextDecoder();
|
|
1863
|
+
let extractedByteLength = 0;
|
|
451
1864
|
for (let entryIndex = 0; entryIndex < entryCount; entryIndex++) {
|
|
1865
|
+
if (entryOffset + 46 > directoryOffset) {
|
|
1866
|
+
throw new Error("USDZ archive contains a truncated ZIP central-directory entry.");
|
|
1867
|
+
}
|
|
452
1868
|
if (view.getUint32(entryOffset, true) !== CENTRAL_DIRECTORY_ENTRY) {
|
|
453
1869
|
throw new Error("USDZ archive contains an invalid ZIP central-directory entry.");
|
|
454
1870
|
}
|
|
455
1871
|
const compression = view.getUint16(entryOffset + 10, true);
|
|
456
1872
|
const compressedLength = view.getUint32(entryOffset + 20, true);
|
|
1873
|
+
const uncompressedLength = view.getUint32(entryOffset + 24, true);
|
|
457
1874
|
const filenameLength = view.getUint16(entryOffset + 28, true);
|
|
458
1875
|
const extraLength = view.getUint16(entryOffset + 30, true);
|
|
459
1876
|
const commentLength = view.getUint16(entryOffset + 32, true);
|
|
460
1877
|
const localOffset = view.getUint32(entryOffset + 42, true);
|
|
461
|
-
|
|
1878
|
+
if (entryOffset + 46 + filenameLength + extraLength + commentLength > directoryOffset) {
|
|
1879
|
+
throw new Error("USDZ archive contains a truncated ZIP filename or extra field.");
|
|
1880
|
+
}
|
|
1881
|
+
const filename = textDecoder2.decode(
|
|
462
1882
|
new Uint8Array(arrayBuffer, entryOffset + 46, filenameLength)
|
|
463
1883
|
);
|
|
464
1884
|
if (compression !== 0) {
|
|
465
1885
|
throw new Error(`USDZ entry "${filename}" is compressed; USDZ requires stored ZIP entries.`);
|
|
466
1886
|
}
|
|
1887
|
+
if (localOffset + 30 > dataLimit || compressedLength !== uncompressedLength) {
|
|
1888
|
+
throw new Error(`USDZ entry "${filename}" has invalid stored ZIP bounds.`);
|
|
1889
|
+
}
|
|
467
1890
|
if (view.getUint32(localOffset, true) !== LOCAL_FILE_HEADER) {
|
|
468
1891
|
throw new Error(`USDZ entry "${filename}" has an invalid local ZIP header.`);
|
|
469
1892
|
}
|
|
470
1893
|
const localNameLength = view.getUint16(localOffset + 26, true);
|
|
471
1894
|
const localExtraLength = view.getUint16(localOffset + 28, true);
|
|
472
1895
|
const contentOffset = localOffset + 30 + localNameLength + localExtraLength;
|
|
1896
|
+
if ((view.getUint16(entryOffset + 8, true) | view.getUint16(localOffset + 6, true)) & 1) {
|
|
1897
|
+
throw new Error(`USDZ entry "${filename}" is encrypted.`);
|
|
1898
|
+
}
|
|
1899
|
+
if (contentOffset + compressedLength > dataLimit || view.getUint16(localOffset + 8, true) !== 0 || textDecoder2.decode(new Uint8Array(arrayBuffer, localOffset + 30, localNameLength)) !== filename || files.has(filename)) {
|
|
1900
|
+
throw new Error(`USDZ entry "${filename}" has invalid or duplicate stored ZIP data.`);
|
|
1901
|
+
}
|
|
1902
|
+
extractedByteLength += compressedLength;
|
|
1903
|
+
if (extractedByteLength > arrayBuffer.byteLength) {
|
|
1904
|
+
throw new Error("USDZ archive exceeds its stored data budget.");
|
|
1905
|
+
}
|
|
473
1906
|
files.set(filename, arrayBuffer.slice(contentOffset, contentOffset + compressedLength));
|
|
474
1907
|
entryOffset += 46 + filenameLength + extraLength + commentLength;
|
|
475
1908
|
}
|
|
@@ -519,21 +1952,32 @@ var __exports__ = (() => {
|
|
|
519
1952
|
let stage;
|
|
520
1953
|
if (isZIPArchive(data)) {
|
|
521
1954
|
const archive = parseUSDZArchive(data);
|
|
522
|
-
const rootFilename =
|
|
523
|
-
if (!rootFilename) {
|
|
524
|
-
throw new Error("USDZ
|
|
1955
|
+
const rootFilename = archive.keys().next().value;
|
|
1956
|
+
if (!rootFilename || !/\.(?:usd[ac]?)$/i.test(rootFilename)) {
|
|
1957
|
+
throw new Error("USDZ archive has no supported USD root layer.");
|
|
525
1958
|
}
|
|
526
1959
|
const archiveBase = "https://usd.archive/";
|
|
1960
|
+
const assets = /* @__PURE__ */ Object.create(null);
|
|
527
1961
|
for (const [filename, content] of archive) {
|
|
528
|
-
|
|
1962
|
+
const assetUrl = new URL(filename, archiveBase);
|
|
1963
|
+
if (filename.startsWith("/") || /^[a-z][a-z\d+.-]*:/i.test(filename) || filename.includes("\\") || /[\u0000-\u001f\u007f]/.test(filename) || filename.trim() !== filename || filename.split("/").some((segment) => {
|
|
1964
|
+
const normalizedSegment = segment.replace(/%2e/gi, ".");
|
|
1965
|
+
return normalizedSegment === "." || normalizedSegment === "..";
|
|
1966
|
+
}) || assetUrl.origin !== new URL(archiveBase).origin || assetUrl.search || assetUrl.hash || assets[assetUrl.href]) {
|
|
1967
|
+
throw new Error(`USDZ entry "${filename}" has an ambiguous package URL.`);
|
|
1968
|
+
}
|
|
1969
|
+
environment.archiveFiles.set(assetUrl.href, content);
|
|
1970
|
+
assets[assetUrl.href] = createEmbeddedAsset(filename, content);
|
|
529
1971
|
}
|
|
530
1972
|
const rootUrl = new URL(rootFilename, archiveBase).href;
|
|
531
1973
|
stage = parseUSDLayer(archive.get(rootFilename), rootUrl);
|
|
532
1974
|
stage.format = "usdz";
|
|
1975
|
+
stage.assets = assets;
|
|
533
1976
|
} else {
|
|
534
1977
|
stage = parseUSDLayer(data, url);
|
|
535
1978
|
}
|
|
536
1979
|
if (stage.url) {
|
|
1980
|
+
setAttributeSourceUrls(stage, stage.url);
|
|
537
1981
|
environment.layers.add(stage.url);
|
|
538
1982
|
}
|
|
539
1983
|
if (environment.options.usd?.compose !== false) {
|
|
@@ -545,6 +1989,11 @@ var __exports__ = (() => {
|
|
|
545
1989
|
}
|
|
546
1990
|
return stage;
|
|
547
1991
|
}
|
|
1992
|
+
function createEmbeddedAsset(path2, data) {
|
|
1993
|
+
const extension = path2.slice(path2.lastIndexOf(".") + 1).toLowerCase();
|
|
1994
|
+
const mimeType = extension === "png" ? "image/png" : /^(?:jpe?g)$/.test(extension) ? "image/jpeg" : void 0;
|
|
1995
|
+
return mimeType ? { path: path2, data, mimeType } : { path: path2, data };
|
|
1996
|
+
}
|
|
548
1997
|
function getSourceLocation(configuredLocation, contextLocation) {
|
|
549
1998
|
const configuredUrl = getAbsoluteUrl(configuredLocation);
|
|
550
1999
|
if (configuredUrl) {
|
|
@@ -571,10 +2020,29 @@ var __exports__ = (() => {
|
|
|
571
2020
|
function parseUSDLayer(data, url) {
|
|
572
2021
|
const signature = TEXT_DECODER.decode(data.slice(0, 8));
|
|
573
2022
|
if (signature === CRATE_SIGNATURE) {
|
|
574
|
-
|
|
2023
|
+
return parseUSDC(data, url);
|
|
575
2024
|
}
|
|
576
2025
|
return parseUSDA(TEXT_DECODER.decode(data), url);
|
|
577
2026
|
}
|
|
2027
|
+
function setAttributeSourceUrls(stage, sourceUrl) {
|
|
2028
|
+
const pendingContents = [...stage.rootPrims];
|
|
2029
|
+
while (pendingContents.length) {
|
|
2030
|
+
const contents = pendingContents.pop();
|
|
2031
|
+
for (const attribute of Object.values(contents.attributes)) {
|
|
2032
|
+
attribute.sourceUrl = sourceUrl;
|
|
2033
|
+
}
|
|
2034
|
+
for (const child of contents.children) {
|
|
2035
|
+
pendingContents.push(child);
|
|
2036
|
+
}
|
|
2037
|
+
if ("variants" in contents) {
|
|
2038
|
+
for (const variants of Object.values(contents.variants)) {
|
|
2039
|
+
for (const variant of Object.values(variants)) {
|
|
2040
|
+
pendingContents.push(variant);
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
578
2046
|
async function composePrims(prims, sourceUrl, inheritedVariants, environment, depth) {
|
|
579
2047
|
if (depth > (environment.options.usd?.maxReferenceDepth ?? 12)) {
|
|
580
2048
|
throw new Error("OpenUSD reference composition exceeded the configured depth limit.");
|
|
@@ -653,6 +2121,7 @@ var __exports__ = (() => {
|
|
|
653
2121
|
content = response.arrayBuffer();
|
|
654
2122
|
}
|
|
655
2123
|
const stage = parseUSDLayer(await content, url);
|
|
2124
|
+
setAttributeSourceUrls(stage, url);
|
|
656
2125
|
environment.layers.add(url);
|
|
657
2126
|
return stage;
|
|
658
2127
|
})();
|
|
@@ -752,6 +2221,7 @@ var __exports__ = (() => {
|
|
|
752
2221
|
var init_parse_usd = __esm({
|
|
753
2222
|
"src/usd/lib/parse-usd.ts"() {
|
|
754
2223
|
"use strict";
|
|
2224
|
+
init_parse_usdc();
|
|
755
2225
|
init_parse_usda();
|
|
756
2226
|
init_parse_usdz();
|
|
757
2227
|
TEXT_DECODER = new TextDecoder();
|
|
@@ -814,11 +2284,11 @@ var __exports__ = (() => {
|
|
|
814
2284
|
id: "usd",
|
|
815
2285
|
module: "scene",
|
|
816
2286
|
version: VERSION,
|
|
817
|
-
extensions: ["usd", "usda", "usdz"],
|
|
818
|
-
mimeTypes: ["model/vnd.usd", "model/vnd.usda", "model/vnd.usdz+zip"],
|
|
2287
|
+
extensions: ["usd", "usda", "usdc", "usdz"],
|
|
2288
|
+
mimeTypes: ["model/vnd.usd", "model/vnd.usda", "model/vnd.usdc", "model/vnd.usdz+zip"],
|
|
819
2289
|
text: true,
|
|
820
2290
|
binary: true,
|
|
821
|
-
tests: ["#usda", "PK"],
|
|
2291
|
+
tests: ["#usda", "PXR-USDC", "PK"],
|
|
822
2292
|
options: {
|
|
823
2293
|
usd: {
|
|
824
2294
|
compose: true,
|
|
@@ -8733,9 +10203,9 @@ return true;`);
|
|
|
8733
10203
|
static isSchema(x) {
|
|
8734
10204
|
return (x === null || x === void 0 ? void 0 : x[kSchemaSymbol]) === true;
|
|
8735
10205
|
}
|
|
8736
|
-
constructor(fields = [],
|
|
10206
|
+
constructor(fields = [], metadata3, dictionaries, metadataVersion = MetadataVersion.V5) {
|
|
8737
10207
|
this.fields = fields || [];
|
|
8738
|
-
this.metadata =
|
|
10208
|
+
this.metadata = metadata3 || /* @__PURE__ */ new Map();
|
|
8739
10209
|
if (!dictionaries) {
|
|
8740
10210
|
dictionaries = generateDictionaryMap(this.fields);
|
|
8741
10211
|
}
|
|
@@ -8775,7 +10245,7 @@ return true;`);
|
|
|
8775
10245
|
assign(...args) {
|
|
8776
10246
|
const other = args[0] instanceof _Schema ? args[0] : Array.isArray(args[0]) ? new _Schema(args[0]) : new _Schema(args);
|
|
8777
10247
|
const curFields = [...this.fields];
|
|
8778
|
-
const
|
|
10248
|
+
const metadata3 = mergeMaps(mergeMaps(/* @__PURE__ */ new Map(), this.metadata), other.metadata);
|
|
8779
10249
|
const newFields = other.fields.filter((f2) => {
|
|
8780
10250
|
const i = curFields.findIndex((f) => f.name === f2.name);
|
|
8781
10251
|
return ~i ? (curFields[i] = f2.clone({
|
|
@@ -8783,7 +10253,7 @@ return true;`);
|
|
|
8783
10253
|
})) && false : true;
|
|
8784
10254
|
});
|
|
8785
10255
|
const newDictionaries = generateDictionaryMap(newFields, /* @__PURE__ */ new Map());
|
|
8786
|
-
return new _Schema([...curFields, ...newFields],
|
|
10256
|
+
return new _Schema([...curFields, ...newFields], metadata3, new Map([...this.dictionaries, ...newDictionaries]));
|
|
8787
10257
|
}
|
|
8788
10258
|
};
|
|
8789
10259
|
Schema2.prototype.fields = null;
|
|
@@ -8806,20 +10276,20 @@ return true;`);
|
|
|
8806
10276
|
}
|
|
8807
10277
|
/** @nocollapse */
|
|
8808
10278
|
static new(...args) {
|
|
8809
|
-
let [name22, type, nullable,
|
|
10279
|
+
let [name22, type, nullable, metadata3] = args;
|
|
8810
10280
|
if (args[0] && typeof args[0] === "object") {
|
|
8811
10281
|
({ name: name22 } = args[0]);
|
|
8812
10282
|
type === void 0 && (type = args[0].type);
|
|
8813
10283
|
nullable === void 0 && (nullable = args[0].nullable);
|
|
8814
|
-
|
|
10284
|
+
metadata3 === void 0 && (metadata3 = args[0].metadata);
|
|
8815
10285
|
}
|
|
8816
|
-
return new _Field(`${name22}`, type, nullable,
|
|
10286
|
+
return new _Field(`${name22}`, type, nullable, metadata3);
|
|
8817
10287
|
}
|
|
8818
|
-
constructor(name22, type, nullable = false,
|
|
10288
|
+
constructor(name22, type, nullable = false, metadata3) {
|
|
8819
10289
|
this.name = name22;
|
|
8820
10290
|
this.type = type;
|
|
8821
10291
|
this.nullable = nullable;
|
|
8822
|
-
this.metadata =
|
|
10292
|
+
this.metadata = metadata3 || /* @__PURE__ */ new Map();
|
|
8823
10293
|
}
|
|
8824
10294
|
get typeId() {
|
|
8825
10295
|
return this.type.typeId;
|
|
@@ -8831,9 +10301,9 @@ return true;`);
|
|
|
8831
10301
|
return `${this.name}: ${this.type}`;
|
|
8832
10302
|
}
|
|
8833
10303
|
clone(...args) {
|
|
8834
|
-
let [name22, type, nullable,
|
|
8835
|
-
!args[0] || typeof args[0] !== "object" ? [name22 = this.name, type = this.type, nullable = this.nullable,
|
|
8836
|
-
return _Field.new(name22, type, nullable,
|
|
10304
|
+
let [name22, type, nullable, metadata3] = args;
|
|
10305
|
+
!args[0] || typeof args[0] !== "object" ? [name22 = this.name, type = this.type, nullable = this.nullable, metadata3 = this.metadata] = args : { name: name22 = this.name, type = this.type, nullable = this.nullable, metadata: metadata3 = this.metadata } = args[0];
|
|
10306
|
+
return _Field.new(name22, type, nullable, metadata3);
|
|
8837
10307
|
}
|
|
8838
10308
|
};
|
|
8839
10309
|
Field2.prototype.type = null;
|
|
@@ -9311,8 +10781,8 @@ return true;`);
|
|
|
9311
10781
|
}
|
|
9312
10782
|
return field || null;
|
|
9313
10783
|
}
|
|
9314
|
-
function customMetadataFromJSON(
|
|
9315
|
-
return new Map(
|
|
10784
|
+
function customMetadataFromJSON(metadata3 = []) {
|
|
10785
|
+
return new Map(metadata3.map(({ key, value }) => [key, value]));
|
|
9316
10786
|
}
|
|
9317
10787
|
function indexTypeFromJSON(_type) {
|
|
9318
10788
|
return new Int_(_type["isSigned"], _type["bitWidth"]);
|
|
@@ -9794,8 +11264,8 @@ return true;`);
|
|
|
9794
11264
|
const bodyLength = _message.bodyLength();
|
|
9795
11265
|
const version = _message.version();
|
|
9796
11266
|
const headerType = _message.headerType();
|
|
9797
|
-
const
|
|
9798
|
-
const message = new _Message(bodyLength, version, headerType, void 0,
|
|
11267
|
+
const metadata3 = decodeMessageCustomMetadata(_message);
|
|
11268
|
+
const message = new _Message(bodyLength, version, headerType, void 0, metadata3);
|
|
9799
11269
|
message._createHeader = decodeMessageHeader(_message, headerType);
|
|
9800
11270
|
return message;
|
|
9801
11271
|
}
|
|
@@ -9872,14 +11342,14 @@ return true;`);
|
|
|
9872
11342
|
isDictionaryBatch() {
|
|
9873
11343
|
return this.headerType === MessageHeader.DictionaryBatch;
|
|
9874
11344
|
}
|
|
9875
|
-
constructor(bodyLength, version, headerType, header,
|
|
11345
|
+
constructor(bodyLength, version, headerType, header, metadata3) {
|
|
9876
11346
|
this._version = version;
|
|
9877
11347
|
this._headerType = headerType;
|
|
9878
11348
|
this.body = new Uint8Array(0);
|
|
9879
11349
|
this._compression = header === null || header === void 0 ? void 0 : header.compression;
|
|
9880
11350
|
header && (this._createHeader = () => header);
|
|
9881
11351
|
this._bodyLength = bigIntToNumber(bodyLength);
|
|
9882
|
-
this._metadata =
|
|
11352
|
+
this._metadata = metadata3 || /* @__PURE__ */ new Map();
|
|
9883
11353
|
}
|
|
9884
11354
|
};
|
|
9885
11355
|
RecordBatch2 = class {
|
|
@@ -9901,13 +11371,13 @@ return true;`);
|
|
|
9901
11371
|
get metadata() {
|
|
9902
11372
|
return this._metadata;
|
|
9903
11373
|
}
|
|
9904
|
-
constructor(length4, nodes, buffers, compression, variadicBufferCounts = [],
|
|
11374
|
+
constructor(length4, nodes, buffers, compression, variadicBufferCounts = [], metadata3) {
|
|
9905
11375
|
this._nodes = nodes;
|
|
9906
11376
|
this._buffers = buffers;
|
|
9907
11377
|
this._length = bigIntToNumber(length4);
|
|
9908
11378
|
this._compression = compression;
|
|
9909
11379
|
this._variadicBufferCounts = variadicBufferCounts;
|
|
9910
|
-
this._metadata =
|
|
11380
|
+
this._metadata = metadata3 || /* @__PURE__ */ new Map();
|
|
9911
11381
|
}
|
|
9912
11382
|
};
|
|
9913
11383
|
DictionaryBatch2 = class {
|
|
@@ -13145,10 +14615,10 @@ return true;`);
|
|
|
13145
14615
|
}
|
|
13146
14616
|
});
|
|
13147
14617
|
_InternalEmptyPlaceholderRecordBatch = class extends RecordBatch3 {
|
|
13148
|
-
constructor(schema,
|
|
14618
|
+
constructor(schema, metadata3) {
|
|
13149
14619
|
const children = schema.fields.map((f) => makeData({ type: f.type }));
|
|
13150
14620
|
const data = makeData({ type: new Struct(schema.fields), length: 0, nullCount: 0, children });
|
|
13151
|
-
super(schema, data,
|
|
14621
|
+
super(schema, data, metadata3 || /* @__PURE__ */ new Map());
|
|
13152
14622
|
}
|
|
13153
14623
|
};
|
|
13154
14624
|
}
|
|
@@ -15749,442 +17219,29 @@ return true;`);
|
|
|
15749
17219
|
}
|
|
15750
17220
|
});
|
|
15751
17221
|
|
|
15752
|
-
//
|
|
15753
|
-
function
|
|
15754
|
-
return
|
|
15755
|
-
fields: arrowSchema.fields.map((arrowField) => serializeArrowField(arrowField)),
|
|
15756
|
-
metadata: serializeArrowMetadata(arrowSchema.metadata)
|
|
15757
|
-
};
|
|
17222
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/arrow-data.js
|
|
17223
|
+
function getArrowVariadicBuffers(data) {
|
|
17224
|
+
return data.variadicBuffers ?? [];
|
|
15758
17225
|
}
|
|
15759
|
-
function
|
|
15760
|
-
return
|
|
15761
|
-
|
|
15762
|
-
|
|
15763
|
-
|
|
15764
|
-
|
|
15765
|
-
|
|
15766
|
-
|
|
15767
|
-
|
|
15768
|
-
|
|
15769
|
-
|
|
15770
|
-
}
|
|
15771
|
-
function serializeArrowField(field) {
|
|
15772
|
-
return {
|
|
15773
|
-
name: field.name,
|
|
15774
|
-
type: serializeArrowType(field.type),
|
|
15775
|
-
nullable: field.nullable,
|
|
15776
|
-
metadata: serializeArrowMetadata(field.metadata)
|
|
15777
|
-
};
|
|
15778
|
-
}
|
|
15779
|
-
function deserializeArrowField(field, options) {
|
|
15780
|
-
return new Field2(
|
|
15781
|
-
field.name,
|
|
15782
|
-
deserializeArrowType(field.type, options),
|
|
15783
|
-
field.nullable,
|
|
15784
|
-
deserializeArrowMetadata(field.metadata)
|
|
15785
|
-
);
|
|
15786
|
-
}
|
|
15787
|
-
function serializeArrowType(arrowType) {
|
|
15788
|
-
if (isArrowViewType(arrowType, "BinaryView")) {
|
|
15789
|
-
return "binary-view";
|
|
15790
|
-
}
|
|
15791
|
-
if (isArrowViewType(arrowType, "Utf8View")) {
|
|
15792
|
-
return "utf8-view";
|
|
15793
|
-
}
|
|
15794
|
-
if (isOptionalArrowType(arrowType, "LargeList")) {
|
|
15795
|
-
const largeListType = arrowType;
|
|
15796
|
-
return {
|
|
15797
|
-
type: "large-list",
|
|
15798
|
-
children: [serializeArrowField(largeListType.valueField)]
|
|
15799
|
-
};
|
|
15800
|
-
}
|
|
15801
|
-
switch (arrowType.constructor) {
|
|
15802
|
-
case Null2:
|
|
15803
|
-
return "null";
|
|
15804
|
-
case Binary2:
|
|
15805
|
-
return "binary";
|
|
15806
|
-
case FixedSizeBinary2:
|
|
15807
|
-
return {
|
|
15808
|
-
type: "fixed-size-binary",
|
|
15809
|
-
byteWidth: arrowType.byteWidth
|
|
15810
|
-
};
|
|
15811
|
-
case Bool2:
|
|
15812
|
-
return "bool";
|
|
15813
|
-
case Int_:
|
|
15814
|
-
const intType = arrowType;
|
|
15815
|
-
return `${intType.isSigned ? "" : "u"}int${intType.bitWidth}`;
|
|
15816
|
-
case Int8:
|
|
15817
|
-
return "int8";
|
|
15818
|
-
case Int16:
|
|
15819
|
-
return "int16";
|
|
15820
|
-
case Int32:
|
|
15821
|
-
return "int32";
|
|
15822
|
-
case Int64:
|
|
15823
|
-
return "int64";
|
|
15824
|
-
case Uint8:
|
|
15825
|
-
return "uint8";
|
|
15826
|
-
case Uint16:
|
|
15827
|
-
return "uint16";
|
|
15828
|
-
case Uint32:
|
|
15829
|
-
return "uint32";
|
|
15830
|
-
case Uint64:
|
|
15831
|
-
return "uint64";
|
|
15832
|
-
case Float:
|
|
15833
|
-
const precision = arrowType.precision;
|
|
15834
|
-
switch (precision) {
|
|
15835
|
-
case Precision.HALF:
|
|
15836
|
-
return "float16";
|
|
15837
|
-
case Precision.SINGLE:
|
|
15838
|
-
return "float32";
|
|
15839
|
-
case Precision.DOUBLE:
|
|
15840
|
-
return "float64";
|
|
15841
|
-
default:
|
|
15842
|
-
return "float16";
|
|
15843
|
-
}
|
|
15844
|
-
case Float16:
|
|
15845
|
-
return "float16";
|
|
15846
|
-
case Float32:
|
|
15847
|
-
return "float32";
|
|
15848
|
-
case Float64:
|
|
15849
|
-
return "float64";
|
|
15850
|
-
case Utf82:
|
|
15851
|
-
return "utf8";
|
|
15852
|
-
case Decimal2:
|
|
15853
|
-
const decimal = arrowType;
|
|
15854
|
-
return {
|
|
15855
|
-
type: "decimal",
|
|
15856
|
-
bitWidth: decimal.bitWidth,
|
|
15857
|
-
precision: decimal.precision,
|
|
15858
|
-
scale: decimal.scale
|
|
15859
|
-
};
|
|
15860
|
-
case Date_:
|
|
15861
|
-
const dateUnit = arrowType.unit;
|
|
15862
|
-
return dateUnit === DateUnit.DAY ? "date-day" : "date-millisecond";
|
|
15863
|
-
case DateDay:
|
|
15864
|
-
return "date-day";
|
|
15865
|
-
case DateMillisecond:
|
|
15866
|
-
return "date-millisecond";
|
|
15867
|
-
case Time_:
|
|
15868
|
-
const timeUnit = arrowType.unit;
|
|
15869
|
-
switch (timeUnit) {
|
|
15870
|
-
case TimeUnit.SECOND:
|
|
15871
|
-
return "time-second";
|
|
15872
|
-
case TimeUnit.MILLISECOND:
|
|
15873
|
-
return "time-millisecond";
|
|
15874
|
-
case TimeUnit.MICROSECOND:
|
|
15875
|
-
return "time-microsecond";
|
|
15876
|
-
case TimeUnit.NANOSECOND:
|
|
15877
|
-
return "time-nanosecond";
|
|
15878
|
-
default:
|
|
15879
|
-
return "time-second";
|
|
15880
|
-
}
|
|
15881
|
-
case TimeMillisecond:
|
|
15882
|
-
return "time-millisecond";
|
|
15883
|
-
case TimeSecond:
|
|
15884
|
-
return "time-second";
|
|
15885
|
-
case TimeMicrosecond:
|
|
15886
|
-
return "time-microsecond";
|
|
15887
|
-
case TimeNanosecond:
|
|
15888
|
-
return "time-nanosecond";
|
|
15889
|
-
case Timestamp_:
|
|
15890
|
-
const timeStampUnit = arrowType.unit;
|
|
15891
|
-
switch (timeStampUnit) {
|
|
15892
|
-
case TimeUnit.SECOND:
|
|
15893
|
-
return "timestamp-second";
|
|
15894
|
-
case TimeUnit.MILLISECOND:
|
|
15895
|
-
return "timestamp-millisecond";
|
|
15896
|
-
case TimeUnit.MICROSECOND:
|
|
15897
|
-
return "timestamp-microsecond";
|
|
15898
|
-
case TimeUnit.NANOSECOND:
|
|
15899
|
-
return "timestamp-nanosecond";
|
|
15900
|
-
default:
|
|
15901
|
-
return "timestamp-second";
|
|
15902
|
-
}
|
|
15903
|
-
case TimestampSecond:
|
|
15904
|
-
return "timestamp-second";
|
|
15905
|
-
case TimestampMillisecond:
|
|
15906
|
-
return "timestamp-millisecond";
|
|
15907
|
-
case TimestampMicrosecond:
|
|
15908
|
-
return "timestamp-microsecond";
|
|
15909
|
-
case TimestampNanosecond:
|
|
15910
|
-
return "timestamp-nanosecond";
|
|
15911
|
-
case Interval_:
|
|
15912
|
-
const intervalUnit = arrowType.unit;
|
|
15913
|
-
switch (intervalUnit) {
|
|
15914
|
-
case IntervalUnit.DAY_TIME:
|
|
15915
|
-
return "interval-daytime";
|
|
15916
|
-
case IntervalUnit.YEAR_MONTH:
|
|
15917
|
-
return "interval-yearmonth";
|
|
15918
|
-
default:
|
|
15919
|
-
return "interval-daytime";
|
|
15920
|
-
}
|
|
15921
|
-
case IntervalDayTime:
|
|
15922
|
-
return "interval-daytime";
|
|
15923
|
-
case IntervalYearMonth:
|
|
15924
|
-
return "interval-yearmonth";
|
|
15925
|
-
case Map_:
|
|
15926
|
-
const mapType = arrowType;
|
|
15927
|
-
return {
|
|
15928
|
-
type: "map",
|
|
15929
|
-
keysSorted: mapType.keysSorted,
|
|
15930
|
-
children: mapType.children.map((arrowField) => serializeArrowField(arrowField))
|
|
15931
|
-
};
|
|
15932
|
-
case List2:
|
|
15933
|
-
const listType = arrowType;
|
|
15934
|
-
const listField = listType.valueField;
|
|
15935
|
-
return {
|
|
15936
|
-
type: "list",
|
|
15937
|
-
children: [serializeArrowField(listField)]
|
|
15938
|
-
};
|
|
15939
|
-
case FixedSizeList2:
|
|
15940
|
-
const fixedSizeList = arrowType;
|
|
15941
|
-
return {
|
|
15942
|
-
type: "fixed-size-list",
|
|
15943
|
-
listSize: fixedSizeList.listSize,
|
|
15944
|
-
children: [serializeArrowField(fixedSizeList.children[0])]
|
|
15945
|
-
};
|
|
15946
|
-
case Struct:
|
|
15947
|
-
const structType = arrowType;
|
|
15948
|
-
return {
|
|
15949
|
-
type: "struct",
|
|
15950
|
-
children: structType.children.map((arrowField) => serializeArrowField(arrowField))
|
|
15951
|
-
};
|
|
15952
|
-
case SparseUnion:
|
|
15953
|
-
case DenseUnion:
|
|
15954
|
-
const unionType = arrowType;
|
|
15955
|
-
return {
|
|
15956
|
-
type: unionType instanceof DenseUnion ? "dense-union" : "sparse-union",
|
|
15957
|
-
typeIds: unionType.typeIds,
|
|
15958
|
-
children: unionType.children.map((arrowField) => serializeArrowField(arrowField)),
|
|
15959
|
-
typeIdToChildIndex: { ...unionType.typeIdToChildIndex }
|
|
15960
|
-
};
|
|
15961
|
-
case Dictionary:
|
|
15962
|
-
const dictionaryType = arrowType;
|
|
15963
|
-
return {
|
|
15964
|
-
type: "dictionary",
|
|
15965
|
-
id: dictionaryType.id,
|
|
15966
|
-
indices: serializeArrowDictionaryKeyType(dictionaryType.indices),
|
|
15967
|
-
dictionary: serializeArrowType(dictionaryType.dictionary),
|
|
15968
|
-
isOrdered: dictionaryType.isOrdered
|
|
15969
|
-
};
|
|
15970
|
-
default:
|
|
15971
|
-
throw new Error(`arrow type not supported: ${arrowType.constructor.name}`);
|
|
15972
|
-
}
|
|
15973
|
-
}
|
|
15974
|
-
function deserializeArrowType(dataType, options) {
|
|
15975
|
-
if (typeof dataType === "object") {
|
|
15976
|
-
switch (dataType.type) {
|
|
15977
|
-
case "decimal":
|
|
15978
|
-
return new Decimal2(dataType.scale, dataType.precision, dataType.bitWidth);
|
|
15979
|
-
case "map": {
|
|
15980
|
-
const children = dataType.children.map(
|
|
15981
|
-
(arrowField) => deserializeArrowField(arrowField, options)
|
|
15982
|
-
);
|
|
15983
|
-
return new Map_(children[0], dataType.keysSorted);
|
|
15984
|
-
}
|
|
15985
|
-
case "list": {
|
|
15986
|
-
const field = deserializeArrowField(dataType.children[0], options);
|
|
15987
|
-
return new List2(field);
|
|
15988
|
-
}
|
|
15989
|
-
case "large-list": {
|
|
15990
|
-
const field = deserializeArrowField(dataType.children[0], options);
|
|
15991
|
-
const LargeList3 = getOptionalArrowConstructor("LargeList");
|
|
15992
|
-
if (!LargeList3) {
|
|
15993
|
-
throw new Error(
|
|
15994
|
-
"LargeList requires an Apache Arrow runtime that exports the LargeList constructor"
|
|
15995
|
-
);
|
|
15996
|
-
}
|
|
15997
|
-
return new LargeList3(field);
|
|
15998
|
-
}
|
|
15999
|
-
case "fixed-size-list": {
|
|
16000
|
-
const child = deserializeArrowField(dataType.children[0], options);
|
|
16001
|
-
return new FixedSizeList2(dataType.listSize, child);
|
|
16002
|
-
}
|
|
16003
|
-
case "fixed-size-binary":
|
|
16004
|
-
return new FixedSizeBinary2(dataType.byteWidth);
|
|
16005
|
-
case "struct": {
|
|
16006
|
-
const children = dataType.children.map(
|
|
16007
|
-
(arrowField) => deserializeArrowField(arrowField, options)
|
|
16008
|
-
);
|
|
16009
|
-
return new Struct(children);
|
|
16010
|
-
}
|
|
16011
|
-
case "sparse-union":
|
|
16012
|
-
case "dense-union": {
|
|
16013
|
-
const children = dataType.children.map(
|
|
16014
|
-
(arrowField) => deserializeArrowField(arrowField, options)
|
|
16015
|
-
);
|
|
16016
|
-
return dataType.type === "dense-union" ? new DenseUnion(dataType.typeIds, children) : new SparseUnion(dataType.typeIds, children);
|
|
16017
|
-
}
|
|
16018
|
-
case "dictionary": {
|
|
16019
|
-
return new Dictionary(
|
|
16020
|
-
deserializeArrowType(dataType.dictionary, options),
|
|
16021
|
-
deserializeArrowDictionaryKeyType(dataType.indices),
|
|
16022
|
-
dataType.id,
|
|
16023
|
-
dataType.isOrdered
|
|
16024
|
-
);
|
|
16025
|
-
}
|
|
16026
|
-
default:
|
|
16027
|
-
throw new Error("array type not supported");
|
|
16028
|
-
}
|
|
16029
|
-
}
|
|
16030
|
-
switch (dataType) {
|
|
16031
|
-
case "null":
|
|
16032
|
-
return new Null2();
|
|
16033
|
-
case "binary":
|
|
16034
|
-
return makeVariableWidthArrowType("BinaryView", new Binary2(), options);
|
|
16035
|
-
case "binary-view":
|
|
16036
|
-
return makeRequiredArrowViewType("BinaryView");
|
|
16037
|
-
case "bool":
|
|
16038
|
-
return new Bool2();
|
|
16039
|
-
case "int8":
|
|
16040
|
-
return new Int8();
|
|
16041
|
-
case "int16":
|
|
16042
|
-
return new Int16();
|
|
16043
|
-
case "int32":
|
|
16044
|
-
return new Int32();
|
|
16045
|
-
case "int64":
|
|
16046
|
-
return new Int64();
|
|
16047
|
-
case "uint8":
|
|
16048
|
-
return new Uint8();
|
|
16049
|
-
case "uint16":
|
|
16050
|
-
return new Uint16();
|
|
16051
|
-
case "uint32":
|
|
16052
|
-
return new Uint32();
|
|
16053
|
-
case "uint64":
|
|
16054
|
-
return new Uint64();
|
|
16055
|
-
case "float16":
|
|
16056
|
-
return new Float16();
|
|
16057
|
-
case "float32":
|
|
16058
|
-
return new Float32();
|
|
16059
|
-
case "float64":
|
|
16060
|
-
return new Float64();
|
|
16061
|
-
case "utf8":
|
|
16062
|
-
return makeVariableWidthArrowType("Utf8View", new Utf82(), options);
|
|
16063
|
-
case "utf8-view":
|
|
16064
|
-
return makeRequiredArrowViewType("Utf8View");
|
|
16065
|
-
case "date-day":
|
|
16066
|
-
return new DateDay();
|
|
16067
|
-
case "date-millisecond":
|
|
16068
|
-
return new DateMillisecond();
|
|
16069
|
-
case "time-second":
|
|
16070
|
-
return new TimeSecond();
|
|
16071
|
-
case "time-millisecond":
|
|
16072
|
-
return new TimeMillisecond();
|
|
16073
|
-
case "time-microsecond":
|
|
16074
|
-
return new TimeMicrosecond();
|
|
16075
|
-
case "time-nanosecond":
|
|
16076
|
-
return new TimeNanosecond();
|
|
16077
|
-
case "timestamp-second":
|
|
16078
|
-
return new TimestampSecond();
|
|
16079
|
-
case "timestamp-millisecond":
|
|
16080
|
-
return new TimestampMillisecond();
|
|
16081
|
-
case "timestamp-microsecond":
|
|
16082
|
-
return new TimestampMicrosecond();
|
|
16083
|
-
case "timestamp-nanosecond":
|
|
16084
|
-
return new TimestampNanosecond();
|
|
16085
|
-
case "interval-daytime":
|
|
16086
|
-
return new IntervalDayTime();
|
|
16087
|
-
case "interval-yearmonth":
|
|
16088
|
-
return new IntervalYearMonth();
|
|
16089
|
-
default:
|
|
16090
|
-
throw new Error("array type not supported");
|
|
16091
|
-
}
|
|
16092
|
-
}
|
|
16093
|
-
function getOptionalArrowConstructor(typeName) {
|
|
16094
|
-
return Arrow_dom_exports[typeName];
|
|
16095
|
-
}
|
|
16096
|
-
function isArrowViewType(arrowType, viewTypeName) {
|
|
16097
|
-
const constructor = getOptionalArrowConstructor(viewTypeName);
|
|
16098
|
-
if (constructor && arrowType instanceof constructor) {
|
|
16099
|
-
return true;
|
|
16100
|
-
}
|
|
16101
|
-
const guards = DataType;
|
|
16102
|
-
const guard = viewTypeName === "BinaryView" ? guards.isBinaryView : guards.isUtf8View;
|
|
16103
|
-
return Boolean(guard?.(arrowType));
|
|
16104
|
-
}
|
|
16105
|
-
function isOptionalArrowType(arrowType, typeName) {
|
|
16106
|
-
const constructor = getOptionalArrowConstructor(typeName);
|
|
16107
|
-
return Boolean(constructor && arrowType instanceof constructor);
|
|
16108
|
-
}
|
|
16109
|
-
function makeVariableWidthArrowType(viewTypeName, fallbackType, options) {
|
|
16110
|
-
const viewTypeMode = options?.viewTypes || "never";
|
|
16111
|
-
if (viewTypeMode === "never") {
|
|
16112
|
-
return fallbackType;
|
|
16113
|
-
}
|
|
16114
|
-
const constructor = getOptionalArrowConstructor(viewTypeName);
|
|
16115
|
-
if (constructor) {
|
|
16116
|
-
return new constructor();
|
|
16117
|
-
}
|
|
16118
|
-
if (viewTypeMode === "require") {
|
|
16119
|
-
throw new Error(
|
|
16120
|
-
`${viewTypeName} requires apache-arrow 21.2.0 or later; the installed runtime does not support it`
|
|
16121
|
-
);
|
|
16122
|
-
}
|
|
16123
|
-
return fallbackType;
|
|
16124
|
-
}
|
|
16125
|
-
function makeRequiredArrowViewType(viewTypeName) {
|
|
16126
|
-
const constructor = getOptionalArrowConstructor(viewTypeName);
|
|
16127
|
-
if (!constructor) {
|
|
16128
|
-
throw new Error(
|
|
16129
|
-
`${viewTypeName} requires apache-arrow 21.2.0 or later; the installed runtime does not support it`
|
|
16130
|
-
);
|
|
16131
|
-
}
|
|
16132
|
-
return new constructor();
|
|
16133
|
-
}
|
|
16134
|
-
function serializeArrowDictionaryKeyType(arrowType) {
|
|
16135
|
-
if (arrowType instanceof Int_) {
|
|
16136
|
-
const prefix = arrowType.isSigned ? "int" : "uint";
|
|
16137
|
-
const keyType = `${prefix}${arrowType.bitWidth}`;
|
|
16138
|
-
if (isSchemaDictionaryKeyType(keyType)) {
|
|
16139
|
-
return keyType;
|
|
16140
|
-
}
|
|
16141
|
-
}
|
|
16142
|
-
switch (arrowType.constructor) {
|
|
16143
|
-
case Int8:
|
|
16144
|
-
return "int8";
|
|
16145
|
-
case Int16:
|
|
16146
|
-
return "int16";
|
|
16147
|
-
case Int32:
|
|
16148
|
-
return "int32";
|
|
16149
|
-
case Uint8:
|
|
16150
|
-
return "uint8";
|
|
16151
|
-
case Uint16:
|
|
16152
|
-
return "uint16";
|
|
16153
|
-
case Uint32:
|
|
16154
|
-
return "uint32";
|
|
16155
|
-
default:
|
|
16156
|
-
throw new Error(`arrow dictionary index type not supported: ${arrowType.constructor.name}`);
|
|
16157
|
-
}
|
|
16158
|
-
}
|
|
16159
|
-
function isSchemaDictionaryKeyType(keyType) {
|
|
16160
|
-
return ["int8", "int16", "int32", "uint8", "uint16", "uint32"].includes(keyType);
|
|
16161
|
-
}
|
|
16162
|
-
function deserializeArrowDictionaryKeyType(keyType) {
|
|
16163
|
-
switch (keyType) {
|
|
16164
|
-
case "int8":
|
|
16165
|
-
return new Int8();
|
|
16166
|
-
case "int16":
|
|
16167
|
-
return new Int16();
|
|
16168
|
-
case "int32":
|
|
16169
|
-
return new Int32();
|
|
16170
|
-
case "uint8":
|
|
16171
|
-
return new Uint8();
|
|
16172
|
-
case "uint16":
|
|
16173
|
-
return new Uint16();
|
|
16174
|
-
case "uint32":
|
|
16175
|
-
return new Uint32();
|
|
16176
|
-
default:
|
|
16177
|
-
throw new Error(`schema dictionary index type not supported: ${keyType}`);
|
|
16178
|
-
}
|
|
17226
|
+
function createArrowData(type, offset, length4, nullCount, buffers, children, dictionary, variadicBuffers) {
|
|
17227
|
+
return Reflect.construct(Data, [
|
|
17228
|
+
type,
|
|
17229
|
+
offset,
|
|
17230
|
+
length4,
|
|
17231
|
+
nullCount,
|
|
17232
|
+
buffers,
|
|
17233
|
+
children,
|
|
17234
|
+
dictionary,
|
|
17235
|
+
variadicBuffers
|
|
17236
|
+
]);
|
|
16179
17237
|
}
|
|
16180
|
-
var
|
|
16181
|
-
"
|
|
16182
|
-
"use strict";
|
|
17238
|
+
var init_arrow_data = __esm({
|
|
17239
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/arrow-data.js"() {
|
|
16183
17240
|
init_Arrow_dom();
|
|
16184
17241
|
}
|
|
16185
17242
|
});
|
|
16186
17243
|
|
|
16187
|
-
//
|
|
17244
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/split-arrow-buffers.js
|
|
16188
17245
|
function splitArrowBuffers(input, options = {}) {
|
|
16189
17246
|
const context = { ...options, copies: /* @__PURE__ */ new WeakMap() };
|
|
16190
17247
|
if (isArrowTable2(input)) {
|
|
@@ -16207,17 +17264,12 @@ return true;`);
|
|
|
16207
17264
|
function isArrowVector2(input) {
|
|
16208
17265
|
return "data" in input && Array.isArray(input.data);
|
|
16209
17266
|
}
|
|
16210
|
-
function splitArrowTableBuffersInternal(
|
|
16211
|
-
const recordBatches =
|
|
16212
|
-
|
|
16213
|
-
);
|
|
16214
|
-
return new Table(table.schema, recordBatches);
|
|
17267
|
+
function splitArrowTableBuffersInternal(arrowTable, options) {
|
|
17268
|
+
const recordBatches = arrowTable.batches.map((recordBatch) => splitArrowRecordBatchBuffers(recordBatch, options));
|
|
17269
|
+
return new Table(arrowTable.schema, recordBatches);
|
|
16215
17270
|
}
|
|
16216
17271
|
function splitArrowRecordBatchBuffers(recordBatch, options) {
|
|
16217
|
-
return new RecordBatch3(
|
|
16218
|
-
recordBatch.schema,
|
|
16219
|
-
splitArrowDataBuffers(recordBatch.data, options)
|
|
16220
|
-
);
|
|
17272
|
+
return new RecordBatch3(recordBatch.schema, splitArrowDataBuffers(recordBatch.data, options));
|
|
16221
17273
|
}
|
|
16222
17274
|
function splitArrowDataBuffers(data, options) {
|
|
16223
17275
|
const children = data.children.map((childData) => splitArrowDataBuffers(childData, options));
|
|
@@ -16228,7 +17280,7 @@ return true;`);
|
|
|
16228
17280
|
[BufferType.VALIDITY]: splitArrowBuffer(data.buffers[BufferType.VALIDITY], options),
|
|
16229
17281
|
[BufferType.TYPE]: splitArrowBuffer(data.buffers[BufferType.TYPE], options)
|
|
16230
17282
|
};
|
|
16231
|
-
return
|
|
17283
|
+
return createArrowData(
|
|
16232
17284
|
data.type,
|
|
16233
17285
|
data.offset,
|
|
16234
17286
|
data.length,
|
|
@@ -16236,7 +17288,8 @@ return true;`);
|
|
|
16236
17288
|
data._nullCount,
|
|
16237
17289
|
buffers,
|
|
16238
17290
|
children,
|
|
16239
|
-
dictionary
|
|
17291
|
+
dictionary,
|
|
17292
|
+
getArrowVariadicBuffers(data).map((buffer) => splitArrowBuffer(buffer, options))
|
|
16240
17293
|
);
|
|
16241
17294
|
}
|
|
16242
17295
|
function splitArrowVectorBuffers(vector, options) {
|
|
@@ -16254,7 +17307,7 @@ return true;`);
|
|
|
16254
17307
|
}
|
|
16255
17308
|
let copy2 = options.copies.get(array);
|
|
16256
17309
|
if (!copy2) {
|
|
16257
|
-
copy2 = array.slice();
|
|
17310
|
+
copy2 = array instanceof Uint8Array ? new Uint8Array(array) : array.slice();
|
|
16258
17311
|
options.copies.set(array, copy2);
|
|
16259
17312
|
}
|
|
16260
17313
|
return copy2;
|
|
@@ -16263,36 +17316,113 @@ return true;`);
|
|
|
16263
17316
|
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
16264
17317
|
}
|
|
16265
17318
|
var init_split_arrow_buffers = __esm({
|
|
16266
|
-
"
|
|
16267
|
-
"use strict";
|
|
17319
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/split-arrow-buffers.js"() {
|
|
16268
17320
|
init_Arrow_dom();
|
|
17321
|
+
init_arrow_data();
|
|
16269
17322
|
}
|
|
16270
17323
|
});
|
|
16271
17324
|
|
|
16272
|
-
//
|
|
16273
|
-
|
|
16274
|
-
|
|
17325
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-vector.js
|
|
17326
|
+
var init_indexed_arrow_vector = __esm({
|
|
17327
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-vector.js"() {
|
|
17328
|
+
}
|
|
17329
|
+
});
|
|
17330
|
+
|
|
17331
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-table.js
|
|
17332
|
+
var init_indexed_arrow_table = __esm({
|
|
17333
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/indexed-arrow-table.js"() {
|
|
17334
|
+
}
|
|
17335
|
+
});
|
|
17336
|
+
|
|
17337
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/mapped-arrow-table.js
|
|
17338
|
+
var init_mapped_arrow_table = __esm({
|
|
17339
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/mapped-arrow-table.js"() {
|
|
17340
|
+
}
|
|
17341
|
+
});
|
|
17342
|
+
|
|
17343
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/rename-arrow-columns.js
|
|
17344
|
+
var init_rename_arrow_columns = __esm({
|
|
17345
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/rename-arrow-columns.js"() {
|
|
17346
|
+
}
|
|
17347
|
+
});
|
|
17348
|
+
|
|
17349
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/arrow-table-transport.js
|
|
17350
|
+
function dehydrateArrowTable(arrowTable, options) {
|
|
17351
|
+
const splitTable = splitArrowBuffers(arrowTable, options);
|
|
16275
17352
|
return {
|
|
16276
|
-
shape: "arrow-table",
|
|
16277
17353
|
transport: "arrow-js",
|
|
16278
|
-
|
|
16279
|
-
|
|
17354
|
+
version: 1,
|
|
17355
|
+
schema: tableToIPC(new Table(splitTable.schema, [])),
|
|
17356
|
+
metadataVersion: splitTable.schema.metadataVersion,
|
|
17357
|
+
batches: splitTable.batches.map((batch) => dehydrateArrowData(batch.data))
|
|
16280
17358
|
};
|
|
16281
17359
|
}
|
|
16282
17360
|
function hydrateArrowTable(table) {
|
|
16283
|
-
|
|
16284
|
-
|
|
16285
|
-
|
|
16286
|
-
);
|
|
16287
|
-
|
|
17361
|
+
if (table.transport !== "arrow-js" || table.version !== 1) {
|
|
17362
|
+
throw new Error("Unsupported Arrow column-buffer transport protocol.");
|
|
17363
|
+
}
|
|
17364
|
+
const decodedSchema = tableFromIPC(table.schema).schema;
|
|
17365
|
+
const schema = new Schema2(decodedSchema.fields, decodedSchema.metadata, decodedSchema.dictionaries, table.metadataVersion);
|
|
17366
|
+
const type = new Struct(schema.fields);
|
|
17367
|
+
const batches = table.batches.map((data) => new RecordBatch3(schema, hydrateArrowData(data, type)));
|
|
17368
|
+
return new Table(schema, batches);
|
|
17369
|
+
}
|
|
17370
|
+
function dehydrateArrowData(data) {
|
|
17371
|
+
return {
|
|
17372
|
+
offset: data.offset,
|
|
17373
|
+
length: data.length,
|
|
17374
|
+
nullCount: data.nullCount,
|
|
17375
|
+
buffers: {
|
|
17376
|
+
[BufferType.OFFSET]: data.buffers[BufferType.OFFSET],
|
|
17377
|
+
[BufferType.DATA]: data.buffers[BufferType.DATA],
|
|
17378
|
+
[BufferType.VALIDITY]: data.buffers[BufferType.VALIDITY],
|
|
17379
|
+
[BufferType.TYPE]: data.buffers[BufferType.TYPE]
|
|
17380
|
+
},
|
|
17381
|
+
children: data.children.map((child) => dehydrateArrowData(child)),
|
|
17382
|
+
variadicBuffers: getArrowVariadicBuffers(data),
|
|
17383
|
+
dictionary: data.dictionary?.data.map((chunk) => dehydrateArrowData(chunk))
|
|
17384
|
+
};
|
|
16288
17385
|
}
|
|
17386
|
+
function hydrateArrowData(data, type) {
|
|
17387
|
+
const children = data.children.map((child, index) => hydrateArrowData(child, type.children[index].type));
|
|
17388
|
+
const dictionary = data.dictionary && DataType.isDictionary(type) ? new Vector(data.dictionary.map((chunk) => hydrateArrowData(chunk, type.dictionary))) : void 0;
|
|
17389
|
+
return createArrowData(type, data.offset, data.length, data.nullCount, data.buffers, children, dictionary, data.variadicBuffers);
|
|
17390
|
+
}
|
|
17391
|
+
var init_arrow_table_transport = __esm({
|
|
17392
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/arrow-table-transport.js"() {
|
|
17393
|
+
init_Arrow_dom();
|
|
17394
|
+
init_arrow_data();
|
|
17395
|
+
init_split_arrow_buffers();
|
|
17396
|
+
}
|
|
17397
|
+
});
|
|
17398
|
+
|
|
17399
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/index.js
|
|
17400
|
+
var init_arrow = __esm({
|
|
17401
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/index.js"() {
|
|
17402
|
+
init_indexed_arrow_table();
|
|
17403
|
+
init_indexed_arrow_vector();
|
|
17404
|
+
init_mapped_arrow_table();
|
|
17405
|
+
init_rename_arrow_columns();
|
|
17406
|
+
init_split_arrow_buffers();
|
|
17407
|
+
init_arrow_table_transport();
|
|
17408
|
+
}
|
|
17409
|
+
});
|
|
17410
|
+
|
|
17411
|
+
// ../../node_modules/@math.gl/arrow/dist/index.js
|
|
17412
|
+
var init_dist = __esm({
|
|
17413
|
+
"../../node_modules/@math.gl/arrow/dist/index.js"() {
|
|
17414
|
+
init_arrow();
|
|
17415
|
+
}
|
|
17416
|
+
});
|
|
17417
|
+
|
|
17418
|
+
// ../core/src/arrow-worker-transport.ts
|
|
16289
17419
|
function serializeArrowWorkerTable(result) {
|
|
16290
17420
|
if (!isArrowTableWrapper(result)) {
|
|
16291
17421
|
throw new Error("Workers require Arrow table output");
|
|
16292
17422
|
}
|
|
16293
|
-
const { data, ...
|
|
17423
|
+
const { data, ...metadata3 } = result;
|
|
16294
17424
|
return {
|
|
16295
|
-
...structuredClone(
|
|
17425
|
+
...structuredClone(metadata3),
|
|
16296
17426
|
data: dehydrateArrowTable(data, { copy: "all" })
|
|
16297
17427
|
};
|
|
16298
17428
|
}
|
|
@@ -16331,60 +17461,10 @@ return true;`);
|
|
|
16331
17461
|
table && table.shape === "arrow-table" && table.data && table.data.transport === "arrow-js" && Array.isArray(table.data.batches)
|
|
16332
17462
|
);
|
|
16333
17463
|
}
|
|
16334
|
-
|
|
16335
|
-
|
|
16336
|
-
}
|
|
16337
|
-
function dehydrateArrowData(data) {
|
|
16338
|
-
return {
|
|
16339
|
-
type: serializeArrowType(data.type),
|
|
16340
|
-
offset: data.offset,
|
|
16341
|
-
length: data.length,
|
|
16342
|
-
// @ts-expect-error _nullCount is protected. Preserve the Arrow lazy null-count state.
|
|
16343
|
-
nullCount: data._nullCount,
|
|
16344
|
-
buffers: {
|
|
16345
|
-
[BufferType.OFFSET]: data.buffers[BufferType.OFFSET],
|
|
16346
|
-
[BufferType.DATA]: data.buffers[BufferType.DATA],
|
|
16347
|
-
[BufferType.VALIDITY]: data.buffers[BufferType.VALIDITY],
|
|
16348
|
-
[BufferType.TYPE]: data.buffers[BufferType.TYPE]
|
|
16349
|
-
},
|
|
16350
|
-
children: data.children.map((childData) => dehydrateArrowData(childData)),
|
|
16351
|
-
dictionary: data.dictionary ? dehydrateArrowVector(data.dictionary) : void 0
|
|
16352
|
-
};
|
|
16353
|
-
}
|
|
16354
|
-
function dehydrateArrowVector(vector) {
|
|
16355
|
-
return { data: vector.data.map((data) => dehydrateArrowData(data)) };
|
|
16356
|
-
}
|
|
16357
|
-
function hydrateArrowData(data) {
|
|
16358
|
-
const children = data.children.map((childData) => hydrateArrowData(childData));
|
|
16359
|
-
const dictionary = data.dictionary ? hydrateArrowVector(data.dictionary) : void 0;
|
|
16360
|
-
return new Data(
|
|
16361
|
-
deserializeArrowType(data.type),
|
|
16362
|
-
data.offset,
|
|
16363
|
-
data.length,
|
|
16364
|
-
data.nullCount,
|
|
16365
|
-
data.buffers,
|
|
16366
|
-
children,
|
|
16367
|
-
dictionary
|
|
16368
|
-
);
|
|
16369
|
-
}
|
|
16370
|
-
function hydrateArrowVector(vector) {
|
|
16371
|
-
return new Vector(vector.data.map((data) => hydrateArrowData(data)));
|
|
16372
|
-
}
|
|
16373
|
-
var init_arrow_table_transport = __esm({
|
|
16374
|
-
"../core/src/schema-utils/lib/arrow/arrow-table-transport.ts"() {
|
|
17464
|
+
var init_arrow_worker_transport = __esm({
|
|
17465
|
+
"../core/src/arrow-worker-transport.ts"() {
|
|
16375
17466
|
"use strict";
|
|
16376
|
-
|
|
16377
|
-
init_convert_arrow_schema();
|
|
16378
|
-
init_split_arrow_buffers();
|
|
16379
|
-
}
|
|
16380
|
-
});
|
|
16381
|
-
|
|
16382
|
-
// ../core/src/schema-utils/arrow-transport.ts
|
|
16383
|
-
var init_arrow_transport = __esm({
|
|
16384
|
-
"../core/src/schema-utils/arrow-transport.ts"() {
|
|
16385
|
-
"use strict";
|
|
16386
|
-
init_arrow_table_transport();
|
|
16387
|
-
init_split_arrow_buffers();
|
|
17467
|
+
init_dist();
|
|
16388
17468
|
}
|
|
16389
17469
|
});
|
|
16390
17470
|
|
|
@@ -16564,41 +17644,41 @@ return true;`);
|
|
|
16564
17644
|
}
|
|
16565
17645
|
});
|
|
16566
17646
|
|
|
16567
|
-
// ../../node_modules/@math.gl/
|
|
17647
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/npm-tag.js
|
|
16568
17648
|
var NPM_TAG2;
|
|
16569
17649
|
var init_npm_tag2 = __esm({
|
|
16570
|
-
"../../node_modules/@math.gl/
|
|
17650
|
+
"../../node_modules/@math.gl/tasks/dist/worker-utils/lib/npm-tag.js"() {
|
|
16571
17651
|
NPM_TAG2 = "latest";
|
|
16572
17652
|
}
|
|
16573
17653
|
});
|
|
16574
17654
|
|
|
16575
|
-
// ../../node_modules/@math.gl/
|
|
17655
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/env-utils/version.js
|
|
16576
17656
|
function getVersion2() {
|
|
16577
17657
|
return typeof __VERSION__ === "undefined" ? NPM_TAG2 : __VERSION__;
|
|
16578
17658
|
}
|
|
16579
17659
|
var VERSION3;
|
|
16580
17660
|
var init_version2 = __esm({
|
|
16581
|
-
"../../node_modules/@math.gl/
|
|
17661
|
+
"../../node_modules/@math.gl/tasks/dist/worker-utils/lib/env-utils/version.js"() {
|
|
16582
17662
|
init_npm_tag2();
|
|
16583
17663
|
VERSION3 = getVersion2();
|
|
16584
17664
|
}
|
|
16585
17665
|
});
|
|
16586
17666
|
|
|
16587
|
-
// ../../node_modules/@math.gl/
|
|
17667
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/env-utils/assert.js
|
|
16588
17668
|
function assert3(condition, message) {
|
|
16589
17669
|
if (!condition) {
|
|
16590
17670
|
throw new Error(message || "loaders.gl assertion failed.");
|
|
16591
17671
|
}
|
|
16592
17672
|
}
|
|
16593
17673
|
var init_assert3 = __esm({
|
|
16594
|
-
"../../node_modules/@math.gl/
|
|
17674
|
+
"../../node_modules/@math.gl/tasks/dist/worker-utils/lib/env-utils/assert.js"() {
|
|
16595
17675
|
}
|
|
16596
17676
|
});
|
|
16597
17677
|
|
|
16598
|
-
// ../../node_modules/@math.gl/
|
|
17678
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/env-utils/globals.js
|
|
16599
17679
|
var globals3, self_3, window_3, global_3, document_3, isBrowser3, isMobile2, matches3, nodeVersion3;
|
|
16600
17680
|
var init_globals3 = __esm({
|
|
16601
|
-
"../../node_modules/@math.gl/
|
|
17681
|
+
"../../node_modules/@math.gl/tasks/dist/worker-utils/lib/env-utils/globals.js"() {
|
|
16602
17682
|
globals3 = {
|
|
16603
17683
|
self: typeof self !== "undefined" && self,
|
|
16604
17684
|
window: typeof window !== "undefined" && window,
|
|
@@ -16617,7 +17697,7 @@ return true;`);
|
|
|
16617
17697
|
}
|
|
16618
17698
|
});
|
|
16619
17699
|
|
|
16620
|
-
// ../../node_modules/@math.gl/
|
|
17700
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-job.js
|
|
16621
17701
|
function createAbortError(message) {
|
|
16622
17702
|
const error = new Error(message);
|
|
16623
17703
|
error.name = "AbortError";
|
|
@@ -16625,7 +17705,7 @@ return true;`);
|
|
|
16625
17705
|
}
|
|
16626
17706
|
var WorkerJob;
|
|
16627
17707
|
var init_worker_job = __esm({
|
|
16628
|
-
"../../node_modules/@math.gl/
|
|
17708
|
+
"../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-job.js"() {
|
|
16629
17709
|
WorkerJob = class {
|
|
16630
17710
|
constructor(jobName, workerThread) {
|
|
16631
17711
|
this.isRunning = true;
|
|
@@ -16739,10 +17819,10 @@ return true;`);
|
|
|
16739
17819
|
}
|
|
16740
17820
|
});
|
|
16741
17821
|
|
|
16742
|
-
// ../../node_modules/@math.gl/
|
|
17822
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js
|
|
16743
17823
|
var NodeWorker, parentPort;
|
|
16744
17824
|
var init_worker_threads_browser = __esm({
|
|
16745
|
-
"../../node_modules/@math.gl/
|
|
17825
|
+
"../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js"() {
|
|
16746
17826
|
NodeWorker = class {
|
|
16747
17827
|
/** Restores the native worker constructor when this browser shim is embedded in a Node bundle. */
|
|
16748
17828
|
constructor(...arguments_) {
|
|
@@ -16760,7 +17840,7 @@ return true;`);
|
|
|
16760
17840
|
}
|
|
16761
17841
|
});
|
|
16762
17842
|
|
|
16763
|
-
// ../../node_modules/@math.gl/
|
|
17843
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js
|
|
16764
17844
|
function getLoadableWorkerURL(props) {
|
|
16765
17845
|
assert3(props.source && !props.url || !props.source && props.url);
|
|
16766
17846
|
if (props.url && props.workerType === "module") {
|
|
@@ -16809,13 +17889,13 @@ return true;`);
|
|
|
16809
17889
|
}
|
|
16810
17890
|
var workerURLCache;
|
|
16811
17891
|
var init_get_loadable_worker_url = __esm({
|
|
16812
|
-
"../../node_modules/@math.gl/
|
|
17892
|
+
"../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js"() {
|
|
16813
17893
|
init_assert3();
|
|
16814
17894
|
workerURLCache = /* @__PURE__ */ new Map();
|
|
16815
17895
|
}
|
|
16816
17896
|
});
|
|
16817
17897
|
|
|
16818
|
-
// ../../node_modules/@math.gl/
|
|
17898
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js
|
|
16819
17899
|
function getTransferList(object, recursive = true, transfers) {
|
|
16820
17900
|
const transfersSet = transfers || /* @__PURE__ */ new Set();
|
|
16821
17901
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -16899,14 +17979,14 @@ return true;`);
|
|
|
16899
17979
|
return object === null ? {} : clone2(object);
|
|
16900
17980
|
}
|
|
16901
17981
|
var init_get_transfer_list = __esm({
|
|
16902
|
-
"../../node_modules/@math.gl/
|
|
17982
|
+
"../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js"() {
|
|
16903
17983
|
}
|
|
16904
17984
|
});
|
|
16905
17985
|
|
|
16906
|
-
// ../../node_modules/@math.gl/
|
|
17986
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-thread.js
|
|
16907
17987
|
var NOOP, WorkerThread;
|
|
16908
17988
|
var init_worker_thread = __esm({
|
|
16909
|
-
"../../node_modules/@math.gl/
|
|
17989
|
+
"../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-thread.js"() {
|
|
16910
17990
|
init_worker_threads_browser();
|
|
16911
17991
|
init_globals3();
|
|
16912
17992
|
init_assert3();
|
|
@@ -17094,10 +18174,10 @@ return true;`);
|
|
|
17094
18174
|
}
|
|
17095
18175
|
});
|
|
17096
18176
|
|
|
17097
|
-
// ../../node_modules/@math.gl/
|
|
18177
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-pool.js
|
|
17098
18178
|
var WorkerPool;
|
|
17099
18179
|
var init_worker_pool = __esm({
|
|
17100
|
-
"../../node_modules/@math.gl/
|
|
18180
|
+
"../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-pool.js"() {
|
|
17101
18181
|
init_globals3();
|
|
17102
18182
|
init_worker_thread();
|
|
17103
18183
|
init_worker_job();
|
|
@@ -17628,7 +18708,7 @@ return true;`);
|
|
|
17628
18708
|
}
|
|
17629
18709
|
});
|
|
17630
18710
|
|
|
17631
|
-
// ../../node_modules/@math.gl/
|
|
18711
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-farm.js
|
|
17632
18712
|
function getWorkerPoolKey(options) {
|
|
17633
18713
|
const { name: name22, source, url, urlKey, loadWorker, workerType } = options;
|
|
17634
18714
|
const sourceKey = source ? `source:${source}` : "";
|
|
@@ -17646,7 +18726,7 @@ return true;`);
|
|
|
17646
18726
|
}
|
|
17647
18727
|
var DEFAULT_PROPS, loadWorkerIds, nextLoadWorkerId, WorkerFarm;
|
|
17648
18728
|
var init_worker_farm = __esm({
|
|
17649
|
-
"../../node_modules/@math.gl/
|
|
18729
|
+
"../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-farm.js"() {
|
|
17650
18730
|
init_worker_pool();
|
|
17651
18731
|
init_worker_thread();
|
|
17652
18732
|
DEFAULT_PROPS = {
|
|
@@ -17756,10 +18836,10 @@ return true;`);
|
|
|
17756
18836
|
}
|
|
17757
18837
|
});
|
|
17758
18838
|
|
|
17759
|
-
// ../../node_modules/@math.gl/
|
|
18839
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js
|
|
17760
18840
|
var AsyncQueue2;
|
|
17761
18841
|
var init_async_queue = __esm({
|
|
17762
|
-
"../../node_modules/@math.gl/
|
|
18842
|
+
"../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js"() {
|
|
17763
18843
|
AsyncQueue2 = class {
|
|
17764
18844
|
constructor() {
|
|
17765
18845
|
this._values = [];
|
|
@@ -17828,7 +18908,7 @@ return true;`);
|
|
|
17828
18908
|
}
|
|
17829
18909
|
});
|
|
17830
18910
|
|
|
17831
|
-
// ../../node_modules/@math.gl/
|
|
18911
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/get-worker-url.js
|
|
17832
18912
|
function getWorkerName(worker) {
|
|
17833
18913
|
const warning = worker.version !== VERSION3 ? ` (worker-utils@${VERSION3})` : "";
|
|
17834
18914
|
return `${worker.name}@${worker.version}${warning}`;
|
|
@@ -17841,7 +18921,7 @@ return true;`);
|
|
|
17841
18921
|
if (isBrowser3) {
|
|
17842
18922
|
url = `modules/${worker.module}/dist/${workerFile}`;
|
|
17843
18923
|
} else {
|
|
17844
|
-
const workerSourceDirectory = worker.module === "
|
|
18924
|
+
const workerSourceDirectory = worker.module === "tasks" && worker.workerNode?.startsWith("worker-utils/") ? "worker-utils/workers" : "workers";
|
|
17845
18925
|
const workerSourceNode = worker.workerSourceNode || `${workerSourceDirectory}/${worker.id}-worker-node.ts`;
|
|
17846
18926
|
url = `modules/${worker.module}/src/${workerSourceNode}`;
|
|
17847
18927
|
}
|
|
@@ -17886,7 +18966,7 @@ return true;`);
|
|
|
17886
18966
|
}
|
|
17887
18967
|
var warnedWorkerVersionFallbacks;
|
|
17888
18968
|
var init_get_worker_url = __esm({
|
|
17889
|
-
"../../node_modules/@math.gl/
|
|
18969
|
+
"../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/get-worker-url.js"() {
|
|
17890
18970
|
init_assert3();
|
|
17891
18971
|
init_globals3();
|
|
17892
18972
|
init_version2();
|
|
@@ -17895,7 +18975,7 @@ return true;`);
|
|
|
17895
18975
|
}
|
|
17896
18976
|
});
|
|
17897
18977
|
|
|
17898
|
-
// ../../node_modules/@math.gl/
|
|
18978
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js
|
|
17899
18979
|
function getWorkerCapabilities() {
|
|
17900
18980
|
const isolated = typeof globalThis.crossOriginIsolated === "boolean" ? globalThis.crossOriginIsolated : void 0;
|
|
17901
18981
|
const capabilities = {
|
|
@@ -17942,7 +19022,7 @@ return true;`);
|
|
|
17942
19022
|
}
|
|
17943
19023
|
var SharedWorkerState;
|
|
17944
19024
|
var init_shared_state = __esm({
|
|
17945
|
-
"../../node_modules/@math.gl/
|
|
19025
|
+
"../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js"() {
|
|
17946
19026
|
init_worker_thread();
|
|
17947
19027
|
init_globals3();
|
|
17948
19028
|
SharedWorkerState = class {
|
|
@@ -17985,7 +19065,7 @@ return true;`);
|
|
|
17985
19065
|
}
|
|
17986
19066
|
});
|
|
17987
19067
|
|
|
17988
|
-
// ../../node_modules/@math.gl/
|
|
19068
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-input-byte-length.js
|
|
17989
19069
|
function getInputByteLength(input) {
|
|
17990
19070
|
const seen = /* @__PURE__ */ new Set();
|
|
17991
19071
|
let bytes = 0;
|
|
@@ -18014,22 +19094,22 @@ return true;`);
|
|
|
18014
19094
|
return bytes;
|
|
18015
19095
|
}
|
|
18016
19096
|
var init_get_input_byte_length = __esm({
|
|
18017
|
-
"../../node_modules/@math.gl/
|
|
19097
|
+
"../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-input-byte-length.js"() {
|
|
18018
19098
|
}
|
|
18019
19099
|
});
|
|
18020
19100
|
|
|
18021
|
-
// ../../node_modules/@math.gl/
|
|
19101
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js
|
|
18022
19102
|
function validateOutputOwnership(ownership) {
|
|
18023
19103
|
if (ownership !== void 0 && ownership !== "copy" && ownership !== "transfer") {
|
|
18024
19104
|
throw new Error("Invalid worker output ownership");
|
|
18025
19105
|
}
|
|
18026
19106
|
}
|
|
18027
19107
|
var init_validate_output_ownership = __esm({
|
|
18028
|
-
"../../node_modules/@math.gl/
|
|
19108
|
+
"../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js"() {
|
|
18029
19109
|
}
|
|
18030
19110
|
});
|
|
18031
19111
|
|
|
18032
|
-
// ../../node_modules/@math.gl/
|
|
19112
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/process-on-worker.js
|
|
18033
19113
|
async function processOnWorker(worker, data, options = {}, context = {}, jobContext = {}) {
|
|
18034
19114
|
validateOutputOwnership(options.outputOwnership);
|
|
18035
19115
|
if (options.inputOwnership !== void 0 && !["copy", "transfer", "share"].includes(options.inputOwnership))
|
|
@@ -18323,7 +19403,7 @@ return true;`);
|
|
|
18323
19403
|
return inputOptions;
|
|
18324
19404
|
}
|
|
18325
19405
|
var init_process_on_worker = __esm({
|
|
18326
|
-
"../../node_modules/@math.gl/
|
|
19406
|
+
"../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/process-on-worker.js"() {
|
|
18327
19407
|
init_async_queue();
|
|
18328
19408
|
init_worker_farm();
|
|
18329
19409
|
init_get_worker_url();
|
|
@@ -18335,10 +19415,10 @@ return true;`);
|
|
|
18335
19415
|
}
|
|
18336
19416
|
});
|
|
18337
19417
|
|
|
18338
|
-
// ../../node_modules/@math.gl/
|
|
19418
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/index.js
|
|
18339
19419
|
var import_meta, path, moduleUrl;
|
|
18340
19420
|
var init_worker_utils = __esm({
|
|
18341
|
-
"../../node_modules/@math.gl/
|
|
19421
|
+
"../../node_modules/@math.gl/tasks/dist/worker-utils/index.js"() {
|
|
18342
19422
|
init_worker_pool();
|
|
18343
19423
|
init_process_on_worker();
|
|
18344
19424
|
init_get_transfer_list();
|
|
@@ -18348,7 +19428,7 @@ return true;`);
|
|
|
18348
19428
|
}
|
|
18349
19429
|
});
|
|
18350
19430
|
|
|
18351
|
-
// ../../node_modules/@math.gl/
|
|
19431
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js
|
|
18352
19432
|
function preloadTaskCode(task, signal) {
|
|
18353
19433
|
if (!task.preload)
|
|
18354
19434
|
return Promise.resolve();
|
|
@@ -18387,13 +19467,162 @@ return true;`);
|
|
|
18387
19467
|
}
|
|
18388
19468
|
var pending, loaded;
|
|
18389
19469
|
var init_task_preload = __esm({
|
|
18390
|
-
"../../node_modules/@math.gl/
|
|
19470
|
+
"../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js"() {
|
|
18391
19471
|
pending = /* @__PURE__ */ new WeakMap();
|
|
18392
19472
|
loaded = /* @__PURE__ */ new WeakSet();
|
|
18393
19473
|
}
|
|
18394
19474
|
});
|
|
18395
19475
|
|
|
18396
|
-
// ../../node_modules/@math.gl/
|
|
19476
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js
|
|
19477
|
+
var TaskRequestError, TaskChannel;
|
|
19478
|
+
var init_task_channel = __esm({
|
|
19479
|
+
"../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js"() {
|
|
19480
|
+
TaskRequestError = class extends Error {
|
|
19481
|
+
};
|
|
19482
|
+
TaskChannel = class {
|
|
19483
|
+
constructor(options) {
|
|
19484
|
+
this.options = options;
|
|
19485
|
+
this.nextId = 1;
|
|
19486
|
+
this.pending = /* @__PURE__ */ new Map();
|
|
19487
|
+
this.incoming = /* @__PURE__ */ new Map();
|
|
19488
|
+
}
|
|
19489
|
+
/** Send a request without serializing other in-flight requests. */
|
|
19490
|
+
request(operation, value, signal, transfer = []) {
|
|
19491
|
+
if (this.failure)
|
|
19492
|
+
return Promise.reject(this.failure.reason);
|
|
19493
|
+
if (signal?.aborted)
|
|
19494
|
+
return Promise.reject(signal.reason);
|
|
19495
|
+
const id = this.nextId++;
|
|
19496
|
+
return new Promise((resolve, reject) => {
|
|
19497
|
+
const abort = () => {
|
|
19498
|
+
const pending2 = this.pending.get(id);
|
|
19499
|
+
if (!pending2)
|
|
19500
|
+
return;
|
|
19501
|
+
this.pending.delete(id);
|
|
19502
|
+
pending2.cleanup();
|
|
19503
|
+
reject(signal?.reason);
|
|
19504
|
+
this.send({ source: "math.gl/tasks", kind: "cancel", id });
|
|
19505
|
+
};
|
|
19506
|
+
this.pending.set(id, {
|
|
19507
|
+
resolve,
|
|
19508
|
+
reject,
|
|
19509
|
+
cleanup: () => signal?.removeEventListener("abort", abort)
|
|
19510
|
+
});
|
|
19511
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
19512
|
+
this.send({ source: "math.gl/tasks", kind: "request", id, operation, value }, transfer);
|
|
19513
|
+
});
|
|
19514
|
+
}
|
|
19515
|
+
/** Send a one-way notification. */
|
|
19516
|
+
emit(operation, value, transfer = []) {
|
|
19517
|
+
if (this.failure)
|
|
19518
|
+
throw this.failure.reason;
|
|
19519
|
+
this.send({ source: "math.gl/tasks", kind: "event", id: 0, operation, value }, transfer);
|
|
19520
|
+
}
|
|
19521
|
+
/** Dispatch a transport message; unrelated protocols are ignored. */
|
|
19522
|
+
receive(message) {
|
|
19523
|
+
if (this.failure || message?.source !== "math.gl/tasks")
|
|
19524
|
+
return;
|
|
19525
|
+
if (message.kind === "failure") {
|
|
19526
|
+
const reason = new Error(message.error?.message ?? "Task channel failed");
|
|
19527
|
+
this.close(reason);
|
|
19528
|
+
this.options.onFailure?.(reason);
|
|
19529
|
+
} else if (message.kind === "result" || message.kind === "error") {
|
|
19530
|
+
const pending2 = this.pending.get(message.id);
|
|
19531
|
+
if (!pending2)
|
|
19532
|
+
return;
|
|
19533
|
+
this.pending.delete(message.id);
|
|
19534
|
+
pending2.cleanup();
|
|
19535
|
+
if (message.kind === "result")
|
|
19536
|
+
pending2.resolve(message.value);
|
|
19537
|
+
else {
|
|
19538
|
+
const error = new TaskRequestError(message.error?.message ?? "Task request failed");
|
|
19539
|
+
error.name = message.error?.name ?? "Error";
|
|
19540
|
+
pending2.reject(error);
|
|
19541
|
+
}
|
|
19542
|
+
} else if (message.kind === "cancel") {
|
|
19543
|
+
this.incoming.get(message.id)?.abort(new DOMException("Task request cancelled", "AbortError"));
|
|
19544
|
+
} else if (message.kind === "event") {
|
|
19545
|
+
try {
|
|
19546
|
+
this.options.handleEvent?.(message.operation, message.value);
|
|
19547
|
+
} catch (error) {
|
|
19548
|
+
this.fail(error);
|
|
19549
|
+
}
|
|
19550
|
+
} else if (message.kind === "request") {
|
|
19551
|
+
if (this.incoming.has(message.id)) {
|
|
19552
|
+
this.fail(new Error("Duplicate task request identifier"));
|
|
19553
|
+
return;
|
|
19554
|
+
}
|
|
19555
|
+
const controller = new AbortController();
|
|
19556
|
+
this.incoming.set(message.id, controller);
|
|
19557
|
+
void Promise.resolve().then(() => {
|
|
19558
|
+
controller.signal.throwIfAborted();
|
|
19559
|
+
return this.options.handleRequest(message.operation, message.value, controller.signal);
|
|
19560
|
+
}).then((value) => {
|
|
19561
|
+
if (!controller.signal.aborted && !this.failure) {
|
|
19562
|
+
this.send({ source: "math.gl/tasks", kind: "result", id: message.id, value }, this.options.getResultTransferList?.(value, message.value));
|
|
19563
|
+
}
|
|
19564
|
+
}).catch((reason) => {
|
|
19565
|
+
if (!controller.signal.aborted && !this.failure) {
|
|
19566
|
+
this.send({
|
|
19567
|
+
source: "math.gl/tasks",
|
|
19568
|
+
kind: "error",
|
|
19569
|
+
id: message.id,
|
|
19570
|
+
error: {
|
|
19571
|
+
name: reason instanceof Error ? reason.name : "Error",
|
|
19572
|
+
message: reason instanceof Error ? reason.message : String(reason)
|
|
19573
|
+
}
|
|
19574
|
+
});
|
|
19575
|
+
}
|
|
19576
|
+
}).finally(() => this.incoming.delete(message.id));
|
|
19577
|
+
}
|
|
19578
|
+
}
|
|
19579
|
+
/** Reject all outstanding calls with a common cause and abort incoming callbacks. */
|
|
19580
|
+
close(reason = new Error("Task channel closed")) {
|
|
19581
|
+
if (this.failure)
|
|
19582
|
+
return;
|
|
19583
|
+
this.failure = { reason };
|
|
19584
|
+
for (const pending2 of this.pending.values()) {
|
|
19585
|
+
pending2.cleanup();
|
|
19586
|
+
pending2.reject(reason);
|
|
19587
|
+
}
|
|
19588
|
+
this.pending.clear();
|
|
19589
|
+
for (const controller of this.incoming.values())
|
|
19590
|
+
controller.abort(reason);
|
|
19591
|
+
this.incoming.clear();
|
|
19592
|
+
}
|
|
19593
|
+
send(message, transfer = []) {
|
|
19594
|
+
if (this.failure)
|
|
19595
|
+
return;
|
|
19596
|
+
try {
|
|
19597
|
+
this.options.send(message, transfer);
|
|
19598
|
+
} catch (error) {
|
|
19599
|
+
this.fail(error);
|
|
19600
|
+
}
|
|
19601
|
+
}
|
|
19602
|
+
/** Invalidate the channel and notify the peer when the transport still works. */
|
|
19603
|
+
fail(reason) {
|
|
19604
|
+
if (this.failure)
|
|
19605
|
+
return;
|
|
19606
|
+
this.close(reason);
|
|
19607
|
+
try {
|
|
19608
|
+
this.options.send({
|
|
19609
|
+
source: "math.gl/tasks",
|
|
19610
|
+
kind: "failure",
|
|
19611
|
+
id: 0,
|
|
19612
|
+
error: {
|
|
19613
|
+
name: reason instanceof Error ? reason.name : "Error",
|
|
19614
|
+
message: reason instanceof Error ? reason.message : String(reason)
|
|
19615
|
+
}
|
|
19616
|
+
}, []);
|
|
19617
|
+
} catch {
|
|
19618
|
+
}
|
|
19619
|
+
this.options.onFailure?.(reason);
|
|
19620
|
+
}
|
|
19621
|
+
};
|
|
19622
|
+
}
|
|
19623
|
+
});
|
|
19624
|
+
|
|
19625
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js
|
|
18397
19626
|
function assertPayload(value) {
|
|
18398
19627
|
if (!value || typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype) {
|
|
18399
19628
|
throw new TypeError("Task payloads must be plain objects with named fields");
|
|
@@ -18415,6 +19644,16 @@ return true;`);
|
|
|
18415
19644
|
return {
|
|
18416
19645
|
state,
|
|
18417
19646
|
signal,
|
|
19647
|
+
requestHost: async (operation, payload, controls) => {
|
|
19648
|
+
signal.throwIfAborted();
|
|
19649
|
+
if (!context.requestHost)
|
|
19650
|
+
throw new Error("No host request handler configured");
|
|
19651
|
+
return context.requestHost(operation, payload, controls);
|
|
19652
|
+
},
|
|
19653
|
+
emitHost: (operation, payload) => {
|
|
19654
|
+
signal.throwIfAborted();
|
|
19655
|
+
context.emitHost?.(operation, payload);
|
|
19656
|
+
},
|
|
18418
19657
|
throwIfAborted: () => {
|
|
18419
19658
|
signal.throwIfAborted();
|
|
18420
19659
|
context.throwIfAborted?.();
|
|
@@ -18434,7 +19673,7 @@ return true;`);
|
|
|
18434
19673
|
}
|
|
18435
19674
|
var TaskRuntime;
|
|
18436
19675
|
var init_task_runtime = __esm({
|
|
18437
|
-
"../../node_modules/@math.gl/
|
|
19676
|
+
"../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js"() {
|
|
18438
19677
|
init_worker_utils();
|
|
18439
19678
|
init_task_preload();
|
|
18440
19679
|
TaskRuntime = class {
|
|
@@ -18486,7 +19725,7 @@ return true;`);
|
|
|
18486
19725
|
}
|
|
18487
19726
|
});
|
|
18488
19727
|
|
|
18489
|
-
// ../../node_modules/@math.gl/
|
|
19728
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-sync.js
|
|
18490
19729
|
function runTaskSync(task, input, request = {}) {
|
|
18491
19730
|
if (!isTaskCodeLoaded(task))
|
|
18492
19731
|
throw new Error("Preload task on the main thread before runTaskSync");
|
|
@@ -18504,8 +19743,8 @@ return true;`);
|
|
|
18504
19743
|
context.throwIfAborted();
|
|
18505
19744
|
const options = request.options ?? {};
|
|
18506
19745
|
if (request.inputOwnership === "transfer") {
|
|
18507
|
-
const
|
|
18508
|
-
if (getTransferList(input).some((buffer) =>
|
|
19746
|
+
const metadata3 = new Set(getTransferList(options));
|
|
19747
|
+
if (getTransferList(input).some((buffer) => metadata3.has(buffer)))
|
|
18509
19748
|
throw new Error("Transferred input aliases reusable options; use inputOwnership: copy");
|
|
18510
19749
|
}
|
|
18511
19750
|
const copiedOptions = clonePayload(options);
|
|
@@ -18566,14 +19805,151 @@ return true;`);
|
|
|
18566
19805
|
return Boolean(value && (typeof value === "object" || typeof value === "function") && typeof value.then === "function");
|
|
18567
19806
|
}
|
|
18568
19807
|
var init_task_sync = __esm({
|
|
18569
|
-
"../../node_modules/@math.gl/
|
|
19808
|
+
"../../node_modules/@math.gl/tasks/dist/tasks/task-sync.js"() {
|
|
18570
19809
|
init_task_preload();
|
|
18571
19810
|
init_worker_utils();
|
|
18572
19811
|
init_task_runtime();
|
|
18573
19812
|
}
|
|
18574
19813
|
});
|
|
18575
19814
|
|
|
18576
|
-
// ../../node_modules/@math.gl/
|
|
19815
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-operation-queue.js
|
|
19816
|
+
var TaskOperationQueue;
|
|
19817
|
+
var init_task_operation_queue = __esm({
|
|
19818
|
+
"../../node_modules/@math.gl/tasks/dist/tasks/task-operation-queue.js"() {
|
|
19819
|
+
TaskOperationQueue = class {
|
|
19820
|
+
constructor(maxConcurrency) {
|
|
19821
|
+
this.maxConcurrency = maxConcurrency;
|
|
19822
|
+
this.pending = [];
|
|
19823
|
+
this.active = 0;
|
|
19824
|
+
this.exclusive = false;
|
|
19825
|
+
this.closed = false;
|
|
19826
|
+
this.idleWaiters = /* @__PURE__ */ new Set();
|
|
19827
|
+
if (!Number.isSafeInteger(maxConcurrency) || maxConcurrency < 1) {
|
|
19828
|
+
throw new RangeError("maxConcurrency must be a positive safe integer");
|
|
19829
|
+
}
|
|
19830
|
+
}
|
|
19831
|
+
/** Queue an operation; aborting before it starts removes it without running it. */
|
|
19832
|
+
run(mode, operation, signal) {
|
|
19833
|
+
if (this.closed)
|
|
19834
|
+
return Promise.reject(new Error("Task operation queue is closed"));
|
|
19835
|
+
if (mode !== "parallel" && mode !== "exclusive")
|
|
19836
|
+
return Promise.reject(new TypeError("Invalid operation mode"));
|
|
19837
|
+
if (signal?.aborted)
|
|
19838
|
+
return Promise.reject(signal.reason);
|
|
19839
|
+
return new Promise((resolve, reject) => {
|
|
19840
|
+
const onAbort = () => {
|
|
19841
|
+
const index = this.pending.indexOf(entry);
|
|
19842
|
+
if (index >= 0) {
|
|
19843
|
+
this.pending.splice(index, 1);
|
|
19844
|
+
entry.cancel(signal?.reason);
|
|
19845
|
+
this.pump();
|
|
19846
|
+
}
|
|
19847
|
+
};
|
|
19848
|
+
const entry = {
|
|
19849
|
+
mode,
|
|
19850
|
+
cancel: (reason) => {
|
|
19851
|
+
signal?.removeEventListener("abort", onAbort);
|
|
19852
|
+
reject(reason);
|
|
19853
|
+
},
|
|
19854
|
+
start: () => {
|
|
19855
|
+
signal?.removeEventListener("abort", onAbort);
|
|
19856
|
+
this.active++;
|
|
19857
|
+
if (mode === "exclusive")
|
|
19858
|
+
this.exclusive = true;
|
|
19859
|
+
void Promise.resolve().then(() => {
|
|
19860
|
+
signal?.throwIfAborted();
|
|
19861
|
+
return operation();
|
|
19862
|
+
}).then(resolve, reject).finally(() => {
|
|
19863
|
+
this.active--;
|
|
19864
|
+
if (mode === "exclusive")
|
|
19865
|
+
this.exclusive = false;
|
|
19866
|
+
this.pump();
|
|
19867
|
+
});
|
|
19868
|
+
}
|
|
19869
|
+
};
|
|
19870
|
+
this.pending.push(entry);
|
|
19871
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
19872
|
+
if (signal?.aborted)
|
|
19873
|
+
onAbort();
|
|
19874
|
+
else
|
|
19875
|
+
this.pump();
|
|
19876
|
+
});
|
|
19877
|
+
}
|
|
19878
|
+
/** Reject queued calls with one cause while allowing active operations to settle. */
|
|
19879
|
+
cancelPending(reason) {
|
|
19880
|
+
this.closed = true;
|
|
19881
|
+
for (const entry of this.pending.splice(0))
|
|
19882
|
+
entry.cancel(reason);
|
|
19883
|
+
this.pump();
|
|
19884
|
+
}
|
|
19885
|
+
/** Stop accepting new work; accepted operations continue to completion. */
|
|
19886
|
+
close() {
|
|
19887
|
+
this.closed = true;
|
|
19888
|
+
return this.whenIdle();
|
|
19889
|
+
}
|
|
19890
|
+
/** Wait until the queue has no running or waiting operations. */
|
|
19891
|
+
whenIdle() {
|
|
19892
|
+
if (!this.active && !this.pending.length)
|
|
19893
|
+
return Promise.resolve();
|
|
19894
|
+
return new Promise((resolve) => this.idleWaiters.add(resolve));
|
|
19895
|
+
}
|
|
19896
|
+
pump() {
|
|
19897
|
+
while (!this.exclusive && this.pending.length && this.active < this.maxConcurrency) {
|
|
19898
|
+
const entry = this.pending[0];
|
|
19899
|
+
if (entry.mode === "exclusive" && this.active)
|
|
19900
|
+
break;
|
|
19901
|
+
this.pending.shift();
|
|
19902
|
+
entry.start();
|
|
19903
|
+
if (entry.mode === "exclusive")
|
|
19904
|
+
break;
|
|
19905
|
+
}
|
|
19906
|
+
if (!this.active && !this.pending.length) {
|
|
19907
|
+
for (const resolve of this.idleWaiters)
|
|
19908
|
+
resolve();
|
|
19909
|
+
this.idleWaiters.clear();
|
|
19910
|
+
}
|
|
19911
|
+
}
|
|
19912
|
+
};
|
|
19913
|
+
}
|
|
19914
|
+
});
|
|
19915
|
+
|
|
19916
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-worker-channel.js
|
|
19917
|
+
var TaskWorkerChannel;
|
|
19918
|
+
var init_task_worker_channel = __esm({
|
|
19919
|
+
"../../node_modules/@math.gl/tasks/dist/tasks/task-worker-channel.js"() {
|
|
19920
|
+
init_worker_thread();
|
|
19921
|
+
init_task_channel();
|
|
19922
|
+
TaskWorkerChannel = class {
|
|
19923
|
+
constructor(name22, target, options) {
|
|
19924
|
+
this.thread = new WorkerThread({
|
|
19925
|
+
name: name22,
|
|
19926
|
+
url: target.url?.toString(),
|
|
19927
|
+
loadWorker: target.create,
|
|
19928
|
+
workerType: "module"
|
|
19929
|
+
});
|
|
19930
|
+
this.channel = new TaskChannel({
|
|
19931
|
+
...options,
|
|
19932
|
+
send: (message, transfer) => this.thread.postMessage({ source: "loaders.gl/tasks", type: "task-channel", payload: message }, transfer)
|
|
19933
|
+
});
|
|
19934
|
+
this.thread.onMessage = (message) => {
|
|
19935
|
+
if (message?.type === "task-channel")
|
|
19936
|
+
this.channel.receive(message.payload);
|
|
19937
|
+
};
|
|
19938
|
+
this.thread.onError = (reason) => {
|
|
19939
|
+
this.channel.close(reason);
|
|
19940
|
+
options.onFailure?.(reason);
|
|
19941
|
+
};
|
|
19942
|
+
}
|
|
19943
|
+
/** Settle pending calls and terminate the worker without replacing its state. */
|
|
19944
|
+
async destroy(reason) {
|
|
19945
|
+
this.channel.close(reason);
|
|
19946
|
+
await this.thread.destroy();
|
|
19947
|
+
}
|
|
19948
|
+
};
|
|
19949
|
+
}
|
|
19950
|
+
});
|
|
19951
|
+
|
|
19952
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-runner.js
|
|
18577
19953
|
async function finish(handle, operation) {
|
|
18578
19954
|
let result;
|
|
18579
19955
|
try {
|
|
@@ -18645,29 +20021,44 @@ return true;`);
|
|
|
18645
20021
|
}
|
|
18646
20022
|
function assertNoTransferAlias(input, options, ownership) {
|
|
18647
20023
|
if (ownership === "transfer") {
|
|
18648
|
-
const
|
|
18649
|
-
if (getTransferList(input).some((buffer) =>
|
|
20024
|
+
const metadata3 = new Set(getTransferList(options));
|
|
20025
|
+
if (getTransferList(input).some((buffer) => metadata3.has(buffer))) {
|
|
18650
20026
|
throw new Error("Transferred input aliases reusable options; use inputOwnership: copy");
|
|
18651
20027
|
}
|
|
18652
20028
|
}
|
|
18653
20029
|
}
|
|
18654
20030
|
var InitializedTask, TaskRunner;
|
|
18655
20031
|
var init_task_runner = __esm({
|
|
18656
|
-
"../../node_modules/@math.gl/
|
|
20032
|
+
"../../node_modules/@math.gl/tasks/dist/tasks/task-runner.js"() {
|
|
18657
20033
|
init_worker_utils();
|
|
18658
20034
|
init_task_runtime();
|
|
18659
20035
|
init_task_sync();
|
|
20036
|
+
init_task_operation_queue();
|
|
20037
|
+
init_task_worker_channel();
|
|
20038
|
+
init_task_channel();
|
|
18660
20039
|
InitializedTask = class {
|
|
18661
20040
|
/** @internal Use TaskRunner.initializeTask. */
|
|
18662
|
-
constructor(task, release,
|
|
20041
|
+
constructor(task, release, initializationControls) {
|
|
18663
20042
|
this.task = task;
|
|
18664
20043
|
this.release = release;
|
|
18665
|
-
this.
|
|
20044
|
+
this.initializationControls = initializationControls;
|
|
20045
|
+
this.nextProgressId = 1;
|
|
20046
|
+
this.progressCallbacks = /* @__PURE__ */ new Map();
|
|
20047
|
+
this.callbackFailures = /* @__PURE__ */ new Map();
|
|
18666
20048
|
this.closed = false;
|
|
20049
|
+
this.finalized = false;
|
|
18667
20050
|
this.streams = /* @__PURE__ */ new Set();
|
|
18668
20051
|
this.invalid = false;
|
|
18669
20052
|
this.controller = new AbortController();
|
|
20053
|
+
const controls = initializationControls;
|
|
18670
20054
|
this.runtime = new TaskRuntime(task);
|
|
20055
|
+
const concurrency = controls.operationConcurrency ?? 1;
|
|
20056
|
+
const maximum = task.concurrency?.maxConcurrency ?? 1;
|
|
20057
|
+
if (!Number.isSafeInteger(maximum) || maximum < 1 || !Number.isSafeInteger(concurrency) || concurrency < 1 || concurrency > maximum) {
|
|
20058
|
+
throw new RangeError("Task concurrency must be between 1 and the task maximum");
|
|
20059
|
+
}
|
|
20060
|
+
this.operationQueue = new TaskOperationQueue(concurrency);
|
|
20061
|
+
this.concurrent = concurrency > 1;
|
|
18671
20062
|
const execution = controls.execution ?? "auto";
|
|
18672
20063
|
if (!["auto", "main-thread", "worker"].includes(execution))
|
|
18673
20064
|
throw new TypeError("Invalid execution mode");
|
|
@@ -18677,6 +20068,47 @@ return true;`);
|
|
|
18677
20068
|
const target = task.worker;
|
|
18678
20069
|
if (Boolean(target.url) === Boolean(target.create))
|
|
18679
20070
|
throw new Error("Supply exactly one worker URL or factory");
|
|
20071
|
+
if (this.concurrent || controls.onRequest || controls.onEvent) {
|
|
20072
|
+
this.workerChannel = new TaskWorkerChannel(task.id, target, {
|
|
20073
|
+
handleRequest: async (operation, payload, signal) => {
|
|
20074
|
+
if (operation === "task:next-input") {
|
|
20075
|
+
if (!this.channelInputs)
|
|
20076
|
+
throw new Error("No active task stream");
|
|
20077
|
+
return this.channelInputs.next();
|
|
20078
|
+
}
|
|
20079
|
+
if (!controls.onRequest)
|
|
20080
|
+
throw new Error("No host request handler configured");
|
|
20081
|
+
const request = payload;
|
|
20082
|
+
if (operation !== "task:host-request")
|
|
20083
|
+
throw new Error("Unknown host request");
|
|
20084
|
+
return controls.onRequest(request.operation, request.payload, signal);
|
|
20085
|
+
},
|
|
20086
|
+
getResultTransferList: (value, request) => request.outputOwnership === "transfer" ? getTransferList(value) : [],
|
|
20087
|
+
handleEvent: (operation, payload) => {
|
|
20088
|
+
const { id } = payload;
|
|
20089
|
+
try {
|
|
20090
|
+
if (operation === "task:progress") {
|
|
20091
|
+
const event = payload;
|
|
20092
|
+
(this.progressCallbacks.get(event.id) ?? this.streamProgress)?.(event.progress);
|
|
20093
|
+
} else if (operation === "task:host-event") {
|
|
20094
|
+
const event = payload;
|
|
20095
|
+
controls.onEvent?.(event.operation, event.payload);
|
|
20096
|
+
}
|
|
20097
|
+
} catch (reason) {
|
|
20098
|
+
if (this.progressCallbacks.has(id) || this.streamProgressId === id) {
|
|
20099
|
+
if (!this.callbackFailures.has(id))
|
|
20100
|
+
this.callbackFailures.set(id, { reason });
|
|
20101
|
+
}
|
|
20102
|
+
}
|
|
20103
|
+
},
|
|
20104
|
+
onFailure: (reason) => {
|
|
20105
|
+
this.invalid = true;
|
|
20106
|
+
this.operationQueue.cancelPending(reason);
|
|
20107
|
+
this.controller.abort(reason);
|
|
20108
|
+
}
|
|
20109
|
+
});
|
|
20110
|
+
return;
|
|
20111
|
+
}
|
|
18680
20112
|
this.pool = new WorkerPool({
|
|
18681
20113
|
name: task.id,
|
|
18682
20114
|
url: target.url?.toString(),
|
|
@@ -18688,7 +20120,7 @@ return true;`);
|
|
|
18688
20120
|
this.descriptor = {
|
|
18689
20121
|
id: task.id,
|
|
18690
20122
|
name: task.id,
|
|
18691
|
-
module: "
|
|
20123
|
+
module: "tasks",
|
|
18692
20124
|
version: "prototype",
|
|
18693
20125
|
options: {},
|
|
18694
20126
|
worker: target.url?.toString() ?? true,
|
|
@@ -18708,23 +20140,48 @@ return true;`);
|
|
|
18708
20140
|
}
|
|
18709
20141
|
}
|
|
18710
20142
|
runTask(input, ...args) {
|
|
18711
|
-
|
|
20143
|
+
if (this.invalid)
|
|
20144
|
+
return Promise.reject(new Error("Initialized task is invalid; initialize a new instance"));
|
|
20145
|
+
if (this.closed)
|
|
20146
|
+
return Promise.reject(new Error("Initialized task is closed"));
|
|
20147
|
+
const timeout = args[0]?.timeout;
|
|
20148
|
+
if (timeout !== void 0 && (!Number.isSafeInteger(timeout) || timeout < 0 || timeout > 4294967295)) {
|
|
20149
|
+
return Promise.reject(new RangeError("Invalid task timeout"));
|
|
20150
|
+
}
|
|
20151
|
+
const deadline = timeout === void 0 ? void 0 : AbortSignal.timeout(timeout);
|
|
20152
|
+
const signal = deadline && args[0]?.signal ? AbortSignal.any([deadline, args[0].signal]) : deadline ?? args[0]?.signal;
|
|
20153
|
+
const controls = { ...args[0], signal };
|
|
20154
|
+
const mode = this.task.concurrency?.getSchedulingMode?.(input) ?? "exclusive";
|
|
20155
|
+
return this.operationQueue.run(mode, async () => {
|
|
20156
|
+
signal?.throwIfAborted();
|
|
18712
20157
|
this.checkCapability("atomic");
|
|
18713
|
-
|
|
18714
|
-
|
|
20158
|
+
const invalidate = () => {
|
|
20159
|
+
if (this.concurrent) {
|
|
20160
|
+
this.invalid = true;
|
|
20161
|
+
this.operationQueue.cancelPending(signal?.reason);
|
|
20162
|
+
this.controller.abort(signal?.reason);
|
|
20163
|
+
}
|
|
20164
|
+
};
|
|
20165
|
+
signal?.addEventListener("abort", invalidate, { once: true });
|
|
20166
|
+
try {
|
|
20167
|
+
return await this.invoke("process", input, args[0]?.options ?? {}, controls);
|
|
20168
|
+
} finally {
|
|
20169
|
+
signal?.removeEventListener("abort", invalidate);
|
|
20170
|
+
}
|
|
20171
|
+
}, signal);
|
|
18715
20172
|
}
|
|
18716
20173
|
/** Independent calls sharing this instance, always serial and in input order. */
|
|
18717
|
-
|
|
18718
|
-
|
|
20174
|
+
runTasks(inputs, ...args) {
|
|
20175
|
+
return this.serialStream(async function* (self3) {
|
|
18719
20176
|
self3.checkCapability("atomic");
|
|
18720
20177
|
for await (const input of asAsync(inputs, self3.controls(args[0]).signal)) {
|
|
18721
20178
|
yield await self3.invoke("process", input, args[0]?.options ?? {}, args[0]);
|
|
18722
20179
|
}
|
|
18723
|
-
});
|
|
20180
|
+
}, args[0]?.signal);
|
|
18724
20181
|
}
|
|
18725
20182
|
/** One processor invocation for the entire input iterable. */
|
|
18726
|
-
|
|
18727
|
-
|
|
20183
|
+
runTaskInBatches(inputs, ...args) {
|
|
20184
|
+
return this.serialStream(async function* (self3) {
|
|
18728
20185
|
self3.checkCapability("streaming");
|
|
18729
20186
|
const controls = self3.controls(args[0]);
|
|
18730
20187
|
const options = clonePayload(args[0]?.options ?? {});
|
|
@@ -18737,7 +20194,31 @@ return true;`);
|
|
|
18737
20194
|
}
|
|
18738
20195
|
let completed = false;
|
|
18739
20196
|
try {
|
|
18740
|
-
if (self3.
|
|
20197
|
+
if (self3.workerChannel) {
|
|
20198
|
+
self3.channelInputs = prepared()[Symbol.asyncIterator]();
|
|
20199
|
+
self3.streamProgress = controls.onProgress;
|
|
20200
|
+
try {
|
|
20201
|
+
await self3.invoke("stream-open", {}, options, controls);
|
|
20202
|
+
while (true) {
|
|
20203
|
+
const result = await self3.invoke("stream-next", {}, {}, controls);
|
|
20204
|
+
if (result.done)
|
|
20205
|
+
break;
|
|
20206
|
+
yield result.value;
|
|
20207
|
+
}
|
|
20208
|
+
} finally {
|
|
20209
|
+
try {
|
|
20210
|
+
if (!self3.invalid)
|
|
20211
|
+
await self3.invoke("stream-close", {}, {}, controls);
|
|
20212
|
+
} finally {
|
|
20213
|
+
await self3.channelInputs.return?.();
|
|
20214
|
+
self3.channelInputs = void 0;
|
|
20215
|
+
self3.streamProgress = void 0;
|
|
20216
|
+
if (self3.streamProgressId !== void 0)
|
|
20217
|
+
self3.callbackFailures.delete(self3.streamProgressId);
|
|
20218
|
+
self3.streamProgressId = void 0;
|
|
20219
|
+
}
|
|
20220
|
+
}
|
|
20221
|
+
} else if (self3.pool) {
|
|
18741
20222
|
await self3.invoke("stream-options", {}, options, controls);
|
|
18742
20223
|
yield* processOnWorkerInBatches(self3.descriptor, prepared(), {
|
|
18743
20224
|
...self3.workerOptions(controls),
|
|
@@ -18745,13 +20226,19 @@ return true;`);
|
|
|
18745
20226
|
workerInBatches: true
|
|
18746
20227
|
});
|
|
18747
20228
|
} else {
|
|
18748
|
-
for await (const output of self3.runtime.stream(prepared(), options,
|
|
20229
|
+
for await (const output of self3.runtime.stream(prepared(), options, self3.runtimeContext(controls))) {
|
|
18749
20230
|
controls.signal?.throwIfAborted();
|
|
18750
20231
|
yield clonePayload(output, controls.outputOwnership ?? "transfer");
|
|
18751
20232
|
}
|
|
18752
20233
|
}
|
|
18753
20234
|
completed = true;
|
|
18754
20235
|
} catch (error) {
|
|
20236
|
+
if (self3.workerChannel) {
|
|
20237
|
+
self3.invalid = true;
|
|
20238
|
+
self3.operationQueue.cancelPending(error);
|
|
20239
|
+
self3.controller.abort(error);
|
|
20240
|
+
await self3.workerChannel.destroy(error);
|
|
20241
|
+
}
|
|
18755
20242
|
if (self3.pool) {
|
|
18756
20243
|
self3.invalid = true;
|
|
18757
20244
|
await self3.pool.destroy(error);
|
|
@@ -18760,8 +20247,23 @@ return true;`);
|
|
|
18760
20247
|
} finally {
|
|
18761
20248
|
if (self3.pool && !completed)
|
|
18762
20249
|
self3.invalid = true;
|
|
20250
|
+
if (self3.workerChannel && !completed && !self3.invalid) {
|
|
20251
|
+
const reason = new Error("Worker stream ended before completion");
|
|
20252
|
+
self3.invalid = true;
|
|
20253
|
+
self3.operationQueue.cancelPending(reason);
|
|
20254
|
+
self3.controller.abort(reason);
|
|
20255
|
+
await self3.workerChannel.destroy(reason);
|
|
20256
|
+
}
|
|
18763
20257
|
}
|
|
18764
|
-
});
|
|
20258
|
+
}, args[0]?.signal);
|
|
20259
|
+
}
|
|
20260
|
+
/** Lifecycle status of this initialized task. */
|
|
20261
|
+
get state() {
|
|
20262
|
+
if (this.invalid)
|
|
20263
|
+
return "invalid";
|
|
20264
|
+
if (this.finalized)
|
|
20265
|
+
return "closed";
|
|
20266
|
+
return this.closed ? "closing" : "ready";
|
|
18765
20267
|
}
|
|
18766
20268
|
/** Drain accepted work, invoke destroy, and release execution capacity. */
|
|
18767
20269
|
close() {
|
|
@@ -18769,13 +20271,17 @@ return true;`);
|
|
|
18769
20271
|
this.closed = true;
|
|
18770
20272
|
this.closing = (async () => {
|
|
18771
20273
|
try {
|
|
18772
|
-
await this.
|
|
20274
|
+
await this.operationQueue.close();
|
|
18773
20275
|
if (!this.invalid)
|
|
18774
20276
|
await this.invoke("destroy", {}, {});
|
|
20277
|
+
else if (!this.pool && !this.workerChannel)
|
|
20278
|
+
await this.runtime.destroy();
|
|
18775
20279
|
} finally {
|
|
18776
20280
|
try {
|
|
18777
20281
|
await this.pool?.destroy();
|
|
20282
|
+
await this.workerChannel?.destroy();
|
|
18778
20283
|
} finally {
|
|
20284
|
+
this.finalized = true;
|
|
18779
20285
|
this.release();
|
|
18780
20286
|
}
|
|
18781
20287
|
}
|
|
@@ -18785,7 +20291,12 @@ return true;`);
|
|
|
18785
20291
|
}
|
|
18786
20292
|
/** Abort work. Local JavaScript must settle before its state can be destroyed. */
|
|
18787
20293
|
async terminate(reason = new Error("Task terminated")) {
|
|
20294
|
+
this.operationQueue.cancelPending(reason);
|
|
18788
20295
|
this.controller.abort(reason);
|
|
20296
|
+
if (this.workerChannel) {
|
|
20297
|
+
this.invalid = true;
|
|
20298
|
+
await this.workerChannel.destroy(reason);
|
|
20299
|
+
}
|
|
18789
20300
|
if (this.pool) {
|
|
18790
20301
|
this.invalid = true;
|
|
18791
20302
|
await this.pool.destroy(reason);
|
|
@@ -18794,7 +20305,7 @@ return true;`);
|
|
|
18794
20305
|
await this.close();
|
|
18795
20306
|
}
|
|
18796
20307
|
checkCapability(kind) {
|
|
18797
|
-
if (this.pool ? !this.task.worker?.capabilities[kind] : !(kind === "atomic" ? this.task.process : this.task.processInBatches)) {
|
|
20308
|
+
if (this.pool || this.workerChannel ? !this.task.worker?.capabilities[kind] : !(kind === "atomic" ? this.task.process : this.task.processInBatches)) {
|
|
18798
20309
|
throw new Error(`Task has no ${kind} processor for this execution route`);
|
|
18799
20310
|
}
|
|
18800
20311
|
}
|
|
@@ -18825,6 +20336,38 @@ return true;`);
|
|
|
18825
20336
|
assertPayload(input);
|
|
18826
20337
|
assertNoTransferAlias(input, options, prepared.inputOwnership);
|
|
18827
20338
|
const copiedOptions = clonePayload(options);
|
|
20339
|
+
if (this.workerChannel) {
|
|
20340
|
+
const progressId = this.nextProgressId++;
|
|
20341
|
+
const request = {
|
|
20342
|
+
input: clonePayload(input, prepared.inputOwnership),
|
|
20343
|
+
options: copiedOptions,
|
|
20344
|
+
outputOwnership: prepared.outputOwnership ?? "transfer",
|
|
20345
|
+
progressId
|
|
20346
|
+
};
|
|
20347
|
+
if (operation === "stream-open")
|
|
20348
|
+
this.streamProgressId = progressId;
|
|
20349
|
+
this.progressCallbacks.set(progressId, prepared.onProgress);
|
|
20350
|
+
let callbackFailure;
|
|
20351
|
+
try {
|
|
20352
|
+
const result2 = await this.workerChannel.channel.request(operation, request, prepared.signal, getTransferList(request));
|
|
20353
|
+
callbackFailure = this.callbackFailures.get(progressId) ?? (operation.startsWith("stream-") && this.streamProgressId !== void 0 ? this.callbackFailures.get(this.streamProgressId) : void 0);
|
|
20354
|
+
if (callbackFailure)
|
|
20355
|
+
throw callbackFailure.reason;
|
|
20356
|
+
return result2;
|
|
20357
|
+
} catch (reason) {
|
|
20358
|
+
if (operation === "process" && !prepared.signal?.aborted && (reason instanceof TaskRequestError || callbackFailure))
|
|
20359
|
+
throw reason;
|
|
20360
|
+
this.invalid = true;
|
|
20361
|
+
this.operationQueue.cancelPending(reason);
|
|
20362
|
+
this.controller.abort(reason);
|
|
20363
|
+
await this.workerChannel.destroy(reason);
|
|
20364
|
+
throw reason;
|
|
20365
|
+
} finally {
|
|
20366
|
+
this.progressCallbacks.delete(progressId);
|
|
20367
|
+
if (this.streamProgressId !== progressId)
|
|
20368
|
+
this.callbackFailures.delete(progressId);
|
|
20369
|
+
}
|
|
20370
|
+
}
|
|
18828
20371
|
if (this.pool) {
|
|
18829
20372
|
try {
|
|
18830
20373
|
return await processOnWorker(this.descriptor, { operation, input: clonePayload(input, prepared.inputOwnership), options: copiedOptions }, this.workerOptions({ ...prepared, inputOwnership: "transfer" }));
|
|
@@ -18837,7 +20380,7 @@ return true;`);
|
|
|
18837
20380
|
if (operation === "destroy")
|
|
18838
20381
|
return this.runtime.destroy();
|
|
18839
20382
|
const copied = clonePayload(input, prepared.inputOwnership);
|
|
18840
|
-
const context =
|
|
20383
|
+
const context = this.runtimeContext(prepared);
|
|
18841
20384
|
if (operation === "initialize") {
|
|
18842
20385
|
const result2 = await this.runtime.initialize(copied, context);
|
|
18843
20386
|
prepared.signal?.throwIfAborted();
|
|
@@ -18847,27 +20390,76 @@ return true;`);
|
|
|
18847
20390
|
prepared.signal?.throwIfAborted();
|
|
18848
20391
|
return clonePayload(result, prepared.outputOwnership ?? "transfer");
|
|
18849
20392
|
}
|
|
20393
|
+
runtimeContext(prepared) {
|
|
20394
|
+
return {
|
|
20395
|
+
...localContext(prepared),
|
|
20396
|
+
requestHost: async (operation, payload, controls = {}) => {
|
|
20397
|
+
const signal = prepared.signal ?? this.controller.signal;
|
|
20398
|
+
signal.throwIfAborted();
|
|
20399
|
+
const handler = this.initializationControls.onRequest;
|
|
20400
|
+
if (!handler)
|
|
20401
|
+
throw new Error("No host request handler configured");
|
|
20402
|
+
const result = await handler(operation, clonePayload(payload, controls.inputOwnership), signal);
|
|
20403
|
+
signal.throwIfAborted();
|
|
20404
|
+
return structuredClone(result, {
|
|
20405
|
+
transfer: controls.outputOwnership === "transfer" ? getTransferList(result) : []
|
|
20406
|
+
});
|
|
20407
|
+
},
|
|
20408
|
+
emitHost: (operation, payload) => this.initializationControls.onEvent?.(operation, structuredClone(payload))
|
|
20409
|
+
};
|
|
20410
|
+
}
|
|
18850
20411
|
enqueue(operation) {
|
|
18851
20412
|
if (this.closed)
|
|
18852
20413
|
return Promise.reject(new Error("Initialized task is closed"));
|
|
18853
|
-
|
|
18854
|
-
|
|
20414
|
+
return this.operationQueue.run("exclusive", operation);
|
|
20415
|
+
}
|
|
20416
|
+
serialStream(operation, signal) {
|
|
20417
|
+
const waiting = new AbortController();
|
|
20418
|
+
const queueSignal = AbortSignal.any([waiting.signal, this.controller.signal, signal].filter((value) => Boolean(value)));
|
|
20419
|
+
let started = false;
|
|
20420
|
+
const iterator = this.acquireStream(operation, queueSignal, () => {
|
|
20421
|
+
started = true;
|
|
18855
20422
|
});
|
|
18856
|
-
|
|
20423
|
+
const cancelWaiting = () => {
|
|
20424
|
+
if (!started)
|
|
20425
|
+
waiting.abort(new Error("Stream returned before execution"));
|
|
20426
|
+
};
|
|
20427
|
+
return {
|
|
20428
|
+
[Symbol.asyncIterator]() {
|
|
20429
|
+
return this;
|
|
20430
|
+
},
|
|
20431
|
+
next: () => iterator.next(),
|
|
20432
|
+
return: async () => {
|
|
20433
|
+
cancelWaiting();
|
|
20434
|
+
return iterator.return(void 0);
|
|
20435
|
+
},
|
|
20436
|
+
throw: async (reason) => {
|
|
20437
|
+
cancelWaiting();
|
|
20438
|
+
return iterator.throw(reason);
|
|
20439
|
+
}
|
|
20440
|
+
};
|
|
18857
20441
|
}
|
|
18858
|
-
async *
|
|
20442
|
+
async *acquireStream(operation, signal, onStart) {
|
|
18859
20443
|
if (this.closed)
|
|
18860
20444
|
throw new Error("Initialized task is closed");
|
|
18861
|
-
|
|
20445
|
+
let acquire;
|
|
20446
|
+
const acquired = new Promise((resolve) => {
|
|
20447
|
+
acquire = resolve;
|
|
20448
|
+
});
|
|
18862
20449
|
let release;
|
|
18863
|
-
|
|
20450
|
+
const held = new Promise((resolve) => {
|
|
18864
20451
|
release = resolve;
|
|
18865
20452
|
});
|
|
18866
|
-
|
|
18867
|
-
|
|
20453
|
+
const lease = this.operationQueue.run("exclusive", async () => {
|
|
20454
|
+
acquire();
|
|
20455
|
+
await held;
|
|
20456
|
+
}, signal);
|
|
20457
|
+
await Promise.race([acquired, lease]);
|
|
20458
|
+
if (signal.aborted) {
|
|
18868
20459
|
release();
|
|
18869
|
-
throw
|
|
20460
|
+
throw signal.reason;
|
|
18870
20461
|
}
|
|
20462
|
+
onStart();
|
|
18871
20463
|
const iterator = operation(this)[Symbol.asyncIterator]();
|
|
18872
20464
|
let stopping;
|
|
18873
20465
|
const stop = () => {
|
|
@@ -19108,20 +20700,17 @@ return true;`);
|
|
|
19108
20700
|
}
|
|
19109
20701
|
});
|
|
19110
20702
|
|
|
19111
|
-
// ../../node_modules/@math.gl/
|
|
20703
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/index.js
|
|
19112
20704
|
var init_tasks = __esm({
|
|
19113
|
-
"../../node_modules/@math.gl/
|
|
20705
|
+
"../../node_modules/@math.gl/tasks/dist/tasks/index.js"() {
|
|
19114
20706
|
init_task_runner();
|
|
19115
20707
|
}
|
|
19116
20708
|
});
|
|
19117
20709
|
|
|
19118
|
-
//
|
|
19119
|
-
|
|
19120
|
-
|
|
19121
|
-
|
|
19122
|
-
var init_task_runtime2 = __esm({
|
|
19123
|
-
"../core/src/worker-utils/lib/worker-api/task-runtime.ts"() {
|
|
19124
|
-
"use strict";
|
|
20710
|
+
// ../../node_modules/@math.gl/tasks/dist/index.js
|
|
20711
|
+
var init_dist2 = __esm({
|
|
20712
|
+
"../../node_modules/@math.gl/tasks/dist/index.js"() {
|
|
20713
|
+
init_tasks();
|
|
19125
20714
|
}
|
|
19126
20715
|
});
|
|
19127
20716
|
|
|
@@ -19189,6 +20778,16 @@ return true;`);
|
|
|
19189
20778
|
}
|
|
19190
20779
|
});
|
|
19191
20780
|
|
|
20781
|
+
// ../core/src/worker-utils/lib/worker-api/task-runtime.ts
|
|
20782
|
+
function normalizeTaskProgress(progress) {
|
|
20783
|
+
return { ...progress, phase: progress.phase ?? "process", unit: progress.unit ?? "items" };
|
|
20784
|
+
}
|
|
20785
|
+
var init_task_runtime2 = __esm({
|
|
20786
|
+
"../core/src/worker-utils/lib/worker-api/task-runtime.ts"() {
|
|
20787
|
+
"use strict";
|
|
20788
|
+
}
|
|
20789
|
+
});
|
|
20790
|
+
|
|
19192
20791
|
// ../core/src/worker-utils/lib/worker-utils/get-transfer-list.ts
|
|
19193
20792
|
function getTransferList2(object, recursive = true, transfers) {
|
|
19194
20793
|
const transfersSet = transfers || /* @__PURE__ */ new Set();
|
|
@@ -19433,7 +21032,7 @@ return true;`);
|
|
|
19433
21032
|
var init_process_on_worker2 = __esm({
|
|
19434
21033
|
"../core/src/worker-utils/lib/worker-api/process-on-worker.ts"() {
|
|
19435
21034
|
"use strict";
|
|
19436
|
-
|
|
21035
|
+
init_dist2();
|
|
19437
21036
|
init_get_worker_url2();
|
|
19438
21037
|
init_task_runtime2();
|
|
19439
21038
|
init_get_transfer_list2();
|
|
@@ -19784,9 +21383,9 @@ return true;`);
|
|
|
19784
21383
|
|
|
19785
21384
|
// ../core/src/loader-utils/lib/iterators/text-iterators.ts
|
|
19786
21385
|
async function* makeTextDecoderIterator(arrayBufferIterator, options = {}) {
|
|
19787
|
-
const
|
|
21386
|
+
const textDecoder2 = new TextDecoder(void 0, options);
|
|
19788
21387
|
for await (const arrayBuffer of arrayBufferIterator) {
|
|
19789
|
-
yield typeof arrayBuffer === "string" ? arrayBuffer :
|
|
21388
|
+
yield typeof arrayBuffer === "string" ? arrayBuffer : textDecoder2.decode(arrayBuffer, { stream: true });
|
|
19790
21389
|
}
|
|
19791
21390
|
}
|
|
19792
21391
|
async function* makeLineIterator(textIterator) {
|
|
@@ -21731,6 +23330,35 @@ return true;`);
|
|
|
21731
23330
|
out[15] = 1;
|
|
21732
23331
|
return out;
|
|
21733
23332
|
}
|
|
23333
|
+
function affineComponents(matrix) {
|
|
23334
|
+
if (matrix.length !== 16 || Array.from(matrix).some((x) => !Number.isFinite(x)) || matrix[3] !== 0 || matrix[7] !== 0 || matrix[11] !== 0 || matrix[15] !== 1) {
|
|
23335
|
+
throw new RangeError("Expected a finite affine matrix");
|
|
23336
|
+
}
|
|
23337
|
+
const scale5 = [
|
|
23338
|
+
Math.hypot(matrix[0], matrix[1], matrix[2]),
|
|
23339
|
+
Math.hypot(matrix[4], matrix[5], matrix[6]),
|
|
23340
|
+
Math.hypot(matrix[8], matrix[9], matrix[10])
|
|
23341
|
+
];
|
|
23342
|
+
if (scale5.some((x) => x === 0 || !Number.isFinite(x)))
|
|
23343
|
+
throw new RangeError("Singular transform");
|
|
23344
|
+
const rotation = Array.from({ length: 9 }, (_, i) => matrix[Math.floor(i / 3) * 4 + i % 3] / scale5[Math.floor(i / 3)]);
|
|
23345
|
+
for (const [a, b] of [
|
|
23346
|
+
[0, 3],
|
|
23347
|
+
[0, 6],
|
|
23348
|
+
[3, 6]
|
|
23349
|
+
]) {
|
|
23350
|
+
if (Math.abs(rotation[a] * rotation[b] + rotation[a + 1] * rotation[b + 1] + rotation[a + 2] * rotation[b + 2]) > 1e-7) {
|
|
23351
|
+
throw new RangeError("Sheared transforms do not have a TRS decomposition");
|
|
23352
|
+
}
|
|
23353
|
+
}
|
|
23354
|
+
const determinant3 = rotation[0] * (rotation[4] * rotation[8] - rotation[5] * rotation[7]) - rotation[3] * (rotation[1] * rotation[8] - rotation[2] * rotation[7]) + rotation[6] * (rotation[1] * rotation[5] - rotation[2] * rotation[4]);
|
|
23355
|
+
if (determinant3 < 0) {
|
|
23356
|
+
scale5[0] = -scale5[0];
|
|
23357
|
+
for (let i = 0; i < 3; i++)
|
|
23358
|
+
rotation[i] = -rotation[i];
|
|
23359
|
+
}
|
|
23360
|
+
return { rotation, scale: scale5, translation: [matrix[12], matrix[13], matrix[14]] };
|
|
23361
|
+
}
|
|
21734
23362
|
var perspective, ortho;
|
|
21735
23363
|
var init_mat4 = __esm({
|
|
21736
23364
|
"../../node_modules/@math.gl/core/dist/gl-matrix/mat4.js"() {
|
|
@@ -21864,6 +23492,7 @@ return true;`);
|
|
|
21864
23492
|
var init_matrix4 = __esm({
|
|
21865
23493
|
"../../node_modules/@math.gl/core/dist/classes/matrix4.js"() {
|
|
21866
23494
|
init_matrix();
|
|
23495
|
+
init_mat4();
|
|
21867
23496
|
init_validators2();
|
|
21868
23497
|
init_gl_matrix_extras();
|
|
21869
23498
|
init_mat4();
|
|
@@ -22148,27 +23777,15 @@ return true;`);
|
|
|
22148
23777
|
* @returns self
|
|
22149
23778
|
*/
|
|
22150
23779
|
getRotation(result, scaleResult) {
|
|
22151
|
-
|
|
22152
|
-
|
|
22153
|
-
|
|
22154
|
-
|
|
22155
|
-
|
|
22156
|
-
|
|
22157
|
-
|
|
22158
|
-
|
|
22159
|
-
|
|
22160
|
-
result[3] = 0;
|
|
22161
|
-
result[4] = this[4] * inverseScale0;
|
|
22162
|
-
result[5] = this[5] * inverseScale1;
|
|
22163
|
-
result[6] = this[6] * inverseScale2;
|
|
22164
|
-
result[7] = 0;
|
|
22165
|
-
result[8] = this[8] * inverseScale0;
|
|
22166
|
-
result[9] = this[9] * inverseScale1;
|
|
22167
|
-
result[10] = this[10] * inverseScale2;
|
|
22168
|
-
result[11] = 0;
|
|
22169
|
-
result[12] = 0;
|
|
22170
|
-
result[13] = 0;
|
|
22171
|
-
result[14] = 0;
|
|
23780
|
+
const { rotation, scale: scale5 } = affineComponents(this);
|
|
23781
|
+
result = result || new Array(16);
|
|
23782
|
+
if (scaleResult)
|
|
23783
|
+
for (let i = 0; i < 3; i++)
|
|
23784
|
+
scaleResult[i] = scale5[i];
|
|
23785
|
+
for (let i = 0; i < 16; i++)
|
|
23786
|
+
result[i] = 0;
|
|
23787
|
+
for (let i = 0; i < 9; i++)
|
|
23788
|
+
result[Math.floor(i / 3) * 4 + i % 3] = rotation[i];
|
|
22172
23789
|
result[15] = 1;
|
|
22173
23790
|
return result;
|
|
22174
23791
|
}
|
|
@@ -22179,21 +23796,13 @@ return true;`);
|
|
|
22179
23796
|
* @returns self
|
|
22180
23797
|
*/
|
|
22181
23798
|
getRotationMatrix3(result, scaleResult) {
|
|
22182
|
-
|
|
22183
|
-
|
|
22184
|
-
|
|
22185
|
-
|
|
22186
|
-
|
|
22187
|
-
|
|
22188
|
-
|
|
22189
|
-
result[1] = this[1] * inverseScale1;
|
|
22190
|
-
result[2] = this[2] * inverseScale2;
|
|
22191
|
-
result[3] = this[4] * inverseScale0;
|
|
22192
|
-
result[4] = this[5] * inverseScale1;
|
|
22193
|
-
result[5] = this[6] * inverseScale2;
|
|
22194
|
-
result[6] = this[8] * inverseScale0;
|
|
22195
|
-
result[7] = this[9] * inverseScale1;
|
|
22196
|
-
result[8] = this[10] * inverseScale2;
|
|
23799
|
+
const { rotation, scale: scale5 } = affineComponents(this);
|
|
23800
|
+
result = result || new Array(9);
|
|
23801
|
+
if (scaleResult)
|
|
23802
|
+
for (let i = 0; i < 3; i++)
|
|
23803
|
+
scaleResult[i] = scale5[i];
|
|
23804
|
+
for (let i = 0; i < 9; i++)
|
|
23805
|
+
result[i] = rotation[i];
|
|
22197
23806
|
return result;
|
|
22198
23807
|
}
|
|
22199
23808
|
// Modifiers
|
|
@@ -22506,6 +24115,28 @@ return true;`);
|
|
|
22506
24115
|
}
|
|
22507
24116
|
return out;
|
|
22508
24117
|
}
|
|
24118
|
+
function rotateTowards(out, a, b, step) {
|
|
24119
|
+
if (a.length !== 4 || b.length !== 4 || [...Array.from(a), ...Array.from(b), step].some((x) => !Number.isFinite(x))) {
|
|
24120
|
+
throw new RangeError("Expected finite quaternions and step");
|
|
24121
|
+
}
|
|
24122
|
+
if (a.length !== 4 || step < 0)
|
|
24123
|
+
throw new RangeError("Expected quaternions and a nonnegative step");
|
|
24124
|
+
const aScale = Math.max(...Array.from(a, Math.abs)), bScale = Math.max(...Array.from(b, Math.abs));
|
|
24125
|
+
if (!aScale || !bScale)
|
|
24126
|
+
throw new RangeError("Zero quaternion");
|
|
24127
|
+
const an = Array.from(a, (x) => x / aScale), bn = Array.from(b, (x) => x / bScale);
|
|
24128
|
+
const al = Math.hypot(...an), bl = Math.hypot(...bn);
|
|
24129
|
+
for (let i = 0; i < 4; i++) {
|
|
24130
|
+
an[i] /= al;
|
|
24131
|
+
bn[i] /= bl;
|
|
24132
|
+
}
|
|
24133
|
+
const dot4 = an.reduce((sum, x, i) => sum + x * bn[i], 0);
|
|
24134
|
+
const angle2 = 2 * Math.acos(Math.min(1, Math.abs(dot4)));
|
|
24135
|
+
if (out.length < 4)
|
|
24136
|
+
throw new RangeError("Result buffer is too short");
|
|
24137
|
+
slerp(out, an, bn, angle2 === 0 ? 0 : Math.min(1, step / angle2));
|
|
24138
|
+
return out;
|
|
24139
|
+
}
|
|
22509
24140
|
var add2, scale4, dot3, lerp2, length3, squaredLength2, normalize3, rotationTo;
|
|
22510
24141
|
var init_quat = __esm({
|
|
22511
24142
|
"../../node_modules/@math.gl/core/dist/gl-matrix/quat.js"() {
|
|
@@ -22554,6 +24185,7 @@ return true;`);
|
|
|
22554
24185
|
var Quaternion;
|
|
22555
24186
|
var init_quaternion = __esm({
|
|
22556
24187
|
"../../node_modules/@math.gl/core/dist/classes/quaternion.js"() {
|
|
24188
|
+
init_quat();
|
|
22557
24189
|
init_math_array();
|
|
22558
24190
|
init_validators2();
|
|
22559
24191
|
init_quat();
|
|
@@ -22627,6 +24259,9 @@ return true;`);
|
|
|
22627
24259
|
return this.check();
|
|
22628
24260
|
}
|
|
22629
24261
|
/** Set a quat to the identity quaternion */
|
|
24262
|
+
rotateTowards(target, step) {
|
|
24263
|
+
return rotateTowards(this, this, target, step);
|
|
24264
|
+
}
|
|
22630
24265
|
identity() {
|
|
22631
24266
|
identity2(this);
|
|
22632
24267
|
return this.check();
|
|
@@ -22887,7 +24522,7 @@ return true;`);
|
|
|
22887
24522
|
});
|
|
22888
24523
|
|
|
22889
24524
|
// ../../node_modules/@math.gl/core/dist/index.js
|
|
22890
|
-
var
|
|
24525
|
+
var init_dist3 = __esm({
|
|
22891
24526
|
"../../node_modules/@math.gl/core/dist/index.js"() {
|
|
22892
24527
|
init_vector32();
|
|
22893
24528
|
init_matrix3();
|
|
@@ -22993,6 +24628,435 @@ return true;`);
|
|
|
22993
24628
|
}
|
|
22994
24629
|
});
|
|
22995
24630
|
|
|
24631
|
+
// ../core/src/schema-utils/lib/schema/convert-arrow-schema.ts
|
|
24632
|
+
function serializeArrowSchema(arrowSchema) {
|
|
24633
|
+
return {
|
|
24634
|
+
fields: arrowSchema.fields.map((arrowField) => serializeArrowField(arrowField)),
|
|
24635
|
+
metadata: serializeArrowMetadata(arrowSchema.metadata)
|
|
24636
|
+
};
|
|
24637
|
+
}
|
|
24638
|
+
function serializeArrowMetadata(arrowMetadata) {
|
|
24639
|
+
return Object.fromEntries(arrowMetadata);
|
|
24640
|
+
}
|
|
24641
|
+
function deserializeArrowMetadata(metadata3) {
|
|
24642
|
+
return metadata3 ? new Map(Object.entries(metadata3)) : /* @__PURE__ */ new Map();
|
|
24643
|
+
}
|
|
24644
|
+
function serializeArrowField(field) {
|
|
24645
|
+
return {
|
|
24646
|
+
name: field.name,
|
|
24647
|
+
type: serializeArrowType(field.type),
|
|
24648
|
+
nullable: field.nullable,
|
|
24649
|
+
metadata: serializeArrowMetadata(field.metadata)
|
|
24650
|
+
};
|
|
24651
|
+
}
|
|
24652
|
+
function deserializeArrowField(field, options) {
|
|
24653
|
+
return new Field2(
|
|
24654
|
+
field.name,
|
|
24655
|
+
deserializeArrowType(field.type, options),
|
|
24656
|
+
field.nullable,
|
|
24657
|
+
deserializeArrowMetadata(field.metadata)
|
|
24658
|
+
);
|
|
24659
|
+
}
|
|
24660
|
+
function serializeArrowType(arrowType) {
|
|
24661
|
+
if (isArrowViewType(arrowType, "BinaryView")) {
|
|
24662
|
+
return "binary-view";
|
|
24663
|
+
}
|
|
24664
|
+
if (isArrowViewType(arrowType, "Utf8View")) {
|
|
24665
|
+
return "utf8-view";
|
|
24666
|
+
}
|
|
24667
|
+
if (isOptionalArrowType(arrowType, "LargeList")) {
|
|
24668
|
+
const largeListType = arrowType;
|
|
24669
|
+
return {
|
|
24670
|
+
type: "large-list",
|
|
24671
|
+
children: [serializeArrowField(largeListType.valueField)]
|
|
24672
|
+
};
|
|
24673
|
+
}
|
|
24674
|
+
switch (arrowType.constructor) {
|
|
24675
|
+
case Null2:
|
|
24676
|
+
return "null";
|
|
24677
|
+
case Binary2:
|
|
24678
|
+
return "binary";
|
|
24679
|
+
case FixedSizeBinary2:
|
|
24680
|
+
return {
|
|
24681
|
+
type: "fixed-size-binary",
|
|
24682
|
+
byteWidth: arrowType.byteWidth
|
|
24683
|
+
};
|
|
24684
|
+
case Bool2:
|
|
24685
|
+
return "bool";
|
|
24686
|
+
case Int_:
|
|
24687
|
+
const intType = arrowType;
|
|
24688
|
+
return `${intType.isSigned ? "" : "u"}int${intType.bitWidth}`;
|
|
24689
|
+
case Int8:
|
|
24690
|
+
return "int8";
|
|
24691
|
+
case Int16:
|
|
24692
|
+
return "int16";
|
|
24693
|
+
case Int32:
|
|
24694
|
+
return "int32";
|
|
24695
|
+
case Int64:
|
|
24696
|
+
return "int64";
|
|
24697
|
+
case Uint8:
|
|
24698
|
+
return "uint8";
|
|
24699
|
+
case Uint16:
|
|
24700
|
+
return "uint16";
|
|
24701
|
+
case Uint32:
|
|
24702
|
+
return "uint32";
|
|
24703
|
+
case Uint64:
|
|
24704
|
+
return "uint64";
|
|
24705
|
+
case Float:
|
|
24706
|
+
const precision = arrowType.precision;
|
|
24707
|
+
switch (precision) {
|
|
24708
|
+
case Precision.HALF:
|
|
24709
|
+
return "float16";
|
|
24710
|
+
case Precision.SINGLE:
|
|
24711
|
+
return "float32";
|
|
24712
|
+
case Precision.DOUBLE:
|
|
24713
|
+
return "float64";
|
|
24714
|
+
default:
|
|
24715
|
+
return "float16";
|
|
24716
|
+
}
|
|
24717
|
+
case Float16:
|
|
24718
|
+
return "float16";
|
|
24719
|
+
case Float32:
|
|
24720
|
+
return "float32";
|
|
24721
|
+
case Float64:
|
|
24722
|
+
return "float64";
|
|
24723
|
+
case Utf82:
|
|
24724
|
+
return "utf8";
|
|
24725
|
+
case Decimal2:
|
|
24726
|
+
const decimal = arrowType;
|
|
24727
|
+
return {
|
|
24728
|
+
type: "decimal",
|
|
24729
|
+
bitWidth: decimal.bitWidth,
|
|
24730
|
+
precision: decimal.precision,
|
|
24731
|
+
scale: decimal.scale
|
|
24732
|
+
};
|
|
24733
|
+
case Date_:
|
|
24734
|
+
const dateUnit = arrowType.unit;
|
|
24735
|
+
return dateUnit === DateUnit.DAY ? "date-day" : "date-millisecond";
|
|
24736
|
+
case DateDay:
|
|
24737
|
+
return "date-day";
|
|
24738
|
+
case DateMillisecond:
|
|
24739
|
+
return "date-millisecond";
|
|
24740
|
+
case Time_:
|
|
24741
|
+
const timeUnit = arrowType.unit;
|
|
24742
|
+
switch (timeUnit) {
|
|
24743
|
+
case TimeUnit.SECOND:
|
|
24744
|
+
return "time-second";
|
|
24745
|
+
case TimeUnit.MILLISECOND:
|
|
24746
|
+
return "time-millisecond";
|
|
24747
|
+
case TimeUnit.MICROSECOND:
|
|
24748
|
+
return "time-microsecond";
|
|
24749
|
+
case TimeUnit.NANOSECOND:
|
|
24750
|
+
return "time-nanosecond";
|
|
24751
|
+
default:
|
|
24752
|
+
return "time-second";
|
|
24753
|
+
}
|
|
24754
|
+
case TimeMillisecond:
|
|
24755
|
+
return "time-millisecond";
|
|
24756
|
+
case TimeSecond:
|
|
24757
|
+
return "time-second";
|
|
24758
|
+
case TimeMicrosecond:
|
|
24759
|
+
return "time-microsecond";
|
|
24760
|
+
case TimeNanosecond:
|
|
24761
|
+
return "time-nanosecond";
|
|
24762
|
+
case Timestamp_:
|
|
24763
|
+
const timeStampUnit = arrowType.unit;
|
|
24764
|
+
switch (timeStampUnit) {
|
|
24765
|
+
case TimeUnit.SECOND:
|
|
24766
|
+
return "timestamp-second";
|
|
24767
|
+
case TimeUnit.MILLISECOND:
|
|
24768
|
+
return "timestamp-millisecond";
|
|
24769
|
+
case TimeUnit.MICROSECOND:
|
|
24770
|
+
return "timestamp-microsecond";
|
|
24771
|
+
case TimeUnit.NANOSECOND:
|
|
24772
|
+
return "timestamp-nanosecond";
|
|
24773
|
+
default:
|
|
24774
|
+
return "timestamp-second";
|
|
24775
|
+
}
|
|
24776
|
+
case TimestampSecond:
|
|
24777
|
+
return "timestamp-second";
|
|
24778
|
+
case TimestampMillisecond:
|
|
24779
|
+
return "timestamp-millisecond";
|
|
24780
|
+
case TimestampMicrosecond:
|
|
24781
|
+
return "timestamp-microsecond";
|
|
24782
|
+
case TimestampNanosecond:
|
|
24783
|
+
return "timestamp-nanosecond";
|
|
24784
|
+
case Interval_:
|
|
24785
|
+
const intervalUnit = arrowType.unit;
|
|
24786
|
+
switch (intervalUnit) {
|
|
24787
|
+
case IntervalUnit.DAY_TIME:
|
|
24788
|
+
return "interval-daytime";
|
|
24789
|
+
case IntervalUnit.YEAR_MONTH:
|
|
24790
|
+
return "interval-yearmonth";
|
|
24791
|
+
default:
|
|
24792
|
+
return "interval-daytime";
|
|
24793
|
+
}
|
|
24794
|
+
case IntervalDayTime:
|
|
24795
|
+
return "interval-daytime";
|
|
24796
|
+
case IntervalYearMonth:
|
|
24797
|
+
return "interval-yearmonth";
|
|
24798
|
+
case Map_:
|
|
24799
|
+
const mapType = arrowType;
|
|
24800
|
+
return {
|
|
24801
|
+
type: "map",
|
|
24802
|
+
keysSorted: mapType.keysSorted,
|
|
24803
|
+
children: mapType.children.map((arrowField) => serializeArrowField(arrowField))
|
|
24804
|
+
};
|
|
24805
|
+
case List2:
|
|
24806
|
+
const listType = arrowType;
|
|
24807
|
+
const listField = listType.valueField;
|
|
24808
|
+
return {
|
|
24809
|
+
type: "list",
|
|
24810
|
+
children: [serializeArrowField(listField)]
|
|
24811
|
+
};
|
|
24812
|
+
case FixedSizeList2:
|
|
24813
|
+
const fixedSizeList = arrowType;
|
|
24814
|
+
return {
|
|
24815
|
+
type: "fixed-size-list",
|
|
24816
|
+
listSize: fixedSizeList.listSize,
|
|
24817
|
+
children: [serializeArrowField(fixedSizeList.children[0])]
|
|
24818
|
+
};
|
|
24819
|
+
case Struct:
|
|
24820
|
+
const structType = arrowType;
|
|
24821
|
+
return {
|
|
24822
|
+
type: "struct",
|
|
24823
|
+
children: structType.children.map((arrowField) => serializeArrowField(arrowField))
|
|
24824
|
+
};
|
|
24825
|
+
case SparseUnion:
|
|
24826
|
+
case DenseUnion:
|
|
24827
|
+
const unionType = arrowType;
|
|
24828
|
+
return {
|
|
24829
|
+
type: unionType instanceof DenseUnion ? "dense-union" : "sparse-union",
|
|
24830
|
+
typeIds: unionType.typeIds,
|
|
24831
|
+
children: unionType.children.map((arrowField) => serializeArrowField(arrowField)),
|
|
24832
|
+
typeIdToChildIndex: { ...unionType.typeIdToChildIndex }
|
|
24833
|
+
};
|
|
24834
|
+
case Dictionary:
|
|
24835
|
+
const dictionaryType = arrowType;
|
|
24836
|
+
return {
|
|
24837
|
+
type: "dictionary",
|
|
24838
|
+
id: dictionaryType.id,
|
|
24839
|
+
indices: serializeArrowDictionaryKeyType(dictionaryType.indices),
|
|
24840
|
+
dictionary: serializeArrowType(dictionaryType.dictionary),
|
|
24841
|
+
isOrdered: dictionaryType.isOrdered
|
|
24842
|
+
};
|
|
24843
|
+
default:
|
|
24844
|
+
throw new Error(`arrow type not supported: ${arrowType.constructor.name}`);
|
|
24845
|
+
}
|
|
24846
|
+
}
|
|
24847
|
+
function deserializeArrowType(dataType, options) {
|
|
24848
|
+
if (typeof dataType === "object") {
|
|
24849
|
+
switch (dataType.type) {
|
|
24850
|
+
case "decimal":
|
|
24851
|
+
return new Decimal2(dataType.scale, dataType.precision, dataType.bitWidth);
|
|
24852
|
+
case "map": {
|
|
24853
|
+
const children = dataType.children.map(
|
|
24854
|
+
(arrowField) => deserializeArrowField(arrowField, options)
|
|
24855
|
+
);
|
|
24856
|
+
return new Map_(children[0], dataType.keysSorted);
|
|
24857
|
+
}
|
|
24858
|
+
case "list": {
|
|
24859
|
+
const field = deserializeArrowField(dataType.children[0], options);
|
|
24860
|
+
return new List2(field);
|
|
24861
|
+
}
|
|
24862
|
+
case "large-list": {
|
|
24863
|
+
const field = deserializeArrowField(dataType.children[0], options);
|
|
24864
|
+
const LargeList3 = getOptionalArrowConstructor("LargeList");
|
|
24865
|
+
if (!LargeList3) {
|
|
24866
|
+
throw new Error(
|
|
24867
|
+
"LargeList requires an Apache Arrow runtime that exports the LargeList constructor"
|
|
24868
|
+
);
|
|
24869
|
+
}
|
|
24870
|
+
return new LargeList3(field);
|
|
24871
|
+
}
|
|
24872
|
+
case "fixed-size-list": {
|
|
24873
|
+
const child = deserializeArrowField(dataType.children[0], options);
|
|
24874
|
+
return new FixedSizeList2(dataType.listSize, child);
|
|
24875
|
+
}
|
|
24876
|
+
case "fixed-size-binary":
|
|
24877
|
+
return new FixedSizeBinary2(dataType.byteWidth);
|
|
24878
|
+
case "struct": {
|
|
24879
|
+
const children = dataType.children.map(
|
|
24880
|
+
(arrowField) => deserializeArrowField(arrowField, options)
|
|
24881
|
+
);
|
|
24882
|
+
return new Struct(children);
|
|
24883
|
+
}
|
|
24884
|
+
case "sparse-union":
|
|
24885
|
+
case "dense-union": {
|
|
24886
|
+
const children = dataType.children.map(
|
|
24887
|
+
(arrowField) => deserializeArrowField(arrowField, options)
|
|
24888
|
+
);
|
|
24889
|
+
return dataType.type === "dense-union" ? new DenseUnion(dataType.typeIds, children) : new SparseUnion(dataType.typeIds, children);
|
|
24890
|
+
}
|
|
24891
|
+
case "dictionary": {
|
|
24892
|
+
return new Dictionary(
|
|
24893
|
+
deserializeArrowType(dataType.dictionary, options),
|
|
24894
|
+
deserializeArrowDictionaryKeyType(dataType.indices),
|
|
24895
|
+
dataType.id,
|
|
24896
|
+
dataType.isOrdered
|
|
24897
|
+
);
|
|
24898
|
+
}
|
|
24899
|
+
default:
|
|
24900
|
+
throw new Error("array type not supported");
|
|
24901
|
+
}
|
|
24902
|
+
}
|
|
24903
|
+
switch (dataType) {
|
|
24904
|
+
case "null":
|
|
24905
|
+
return new Null2();
|
|
24906
|
+
case "binary":
|
|
24907
|
+
return makeVariableWidthArrowType("BinaryView", new Binary2(), options);
|
|
24908
|
+
case "binary-view":
|
|
24909
|
+
return makeRequiredArrowViewType("BinaryView");
|
|
24910
|
+
case "bool":
|
|
24911
|
+
return new Bool2();
|
|
24912
|
+
case "int8":
|
|
24913
|
+
return new Int8();
|
|
24914
|
+
case "int16":
|
|
24915
|
+
return new Int16();
|
|
24916
|
+
case "int32":
|
|
24917
|
+
return new Int32();
|
|
24918
|
+
case "int64":
|
|
24919
|
+
return new Int64();
|
|
24920
|
+
case "uint8":
|
|
24921
|
+
return new Uint8();
|
|
24922
|
+
case "uint16":
|
|
24923
|
+
return new Uint16();
|
|
24924
|
+
case "uint32":
|
|
24925
|
+
return new Uint32();
|
|
24926
|
+
case "uint64":
|
|
24927
|
+
return new Uint64();
|
|
24928
|
+
case "float16":
|
|
24929
|
+
return new Float16();
|
|
24930
|
+
case "float32":
|
|
24931
|
+
return new Float32();
|
|
24932
|
+
case "float64":
|
|
24933
|
+
return new Float64();
|
|
24934
|
+
case "utf8":
|
|
24935
|
+
return makeVariableWidthArrowType("Utf8View", new Utf82(), options);
|
|
24936
|
+
case "utf8-view":
|
|
24937
|
+
return makeRequiredArrowViewType("Utf8View");
|
|
24938
|
+
case "date-day":
|
|
24939
|
+
return new DateDay();
|
|
24940
|
+
case "date-millisecond":
|
|
24941
|
+
return new DateMillisecond();
|
|
24942
|
+
case "time-second":
|
|
24943
|
+
return new TimeSecond();
|
|
24944
|
+
case "time-millisecond":
|
|
24945
|
+
return new TimeMillisecond();
|
|
24946
|
+
case "time-microsecond":
|
|
24947
|
+
return new TimeMicrosecond();
|
|
24948
|
+
case "time-nanosecond":
|
|
24949
|
+
return new TimeNanosecond();
|
|
24950
|
+
case "timestamp-second":
|
|
24951
|
+
return new TimestampSecond();
|
|
24952
|
+
case "timestamp-millisecond":
|
|
24953
|
+
return new TimestampMillisecond();
|
|
24954
|
+
case "timestamp-microsecond":
|
|
24955
|
+
return new TimestampMicrosecond();
|
|
24956
|
+
case "timestamp-nanosecond":
|
|
24957
|
+
return new TimestampNanosecond();
|
|
24958
|
+
case "interval-daytime":
|
|
24959
|
+
return new IntervalDayTime();
|
|
24960
|
+
case "interval-yearmonth":
|
|
24961
|
+
return new IntervalYearMonth();
|
|
24962
|
+
default:
|
|
24963
|
+
throw new Error("array type not supported");
|
|
24964
|
+
}
|
|
24965
|
+
}
|
|
24966
|
+
function getOptionalArrowConstructor(typeName) {
|
|
24967
|
+
return Arrow_dom_exports[typeName];
|
|
24968
|
+
}
|
|
24969
|
+
function isArrowViewType(arrowType, viewTypeName) {
|
|
24970
|
+
const constructor = getOptionalArrowConstructor(viewTypeName);
|
|
24971
|
+
if (constructor && arrowType instanceof constructor) {
|
|
24972
|
+
return true;
|
|
24973
|
+
}
|
|
24974
|
+
const guards = DataType;
|
|
24975
|
+
const guard = viewTypeName === "BinaryView" ? guards.isBinaryView : guards.isUtf8View;
|
|
24976
|
+
return Boolean(guard?.(arrowType));
|
|
24977
|
+
}
|
|
24978
|
+
function isOptionalArrowType(arrowType, typeName) {
|
|
24979
|
+
const constructor = getOptionalArrowConstructor(typeName);
|
|
24980
|
+
return Boolean(constructor && arrowType instanceof constructor);
|
|
24981
|
+
}
|
|
24982
|
+
function makeVariableWidthArrowType(viewTypeName, fallbackType, options) {
|
|
24983
|
+
const viewTypeMode = options?.viewTypes || "never";
|
|
24984
|
+
if (viewTypeMode === "never") {
|
|
24985
|
+
return fallbackType;
|
|
24986
|
+
}
|
|
24987
|
+
const constructor = getOptionalArrowConstructor(viewTypeName);
|
|
24988
|
+
if (constructor) {
|
|
24989
|
+
return new constructor();
|
|
24990
|
+
}
|
|
24991
|
+
if (viewTypeMode === "require") {
|
|
24992
|
+
throw new Error(
|
|
24993
|
+
`${viewTypeName} requires apache-arrow 21.2.0 or later; the installed runtime does not support it`
|
|
24994
|
+
);
|
|
24995
|
+
}
|
|
24996
|
+
return fallbackType;
|
|
24997
|
+
}
|
|
24998
|
+
function makeRequiredArrowViewType(viewTypeName) {
|
|
24999
|
+
const constructor = getOptionalArrowConstructor(viewTypeName);
|
|
25000
|
+
if (!constructor) {
|
|
25001
|
+
throw new Error(
|
|
25002
|
+
`${viewTypeName} requires apache-arrow 21.2.0 or later; the installed runtime does not support it`
|
|
25003
|
+
);
|
|
25004
|
+
}
|
|
25005
|
+
return new constructor();
|
|
25006
|
+
}
|
|
25007
|
+
function serializeArrowDictionaryKeyType(arrowType) {
|
|
25008
|
+
if (arrowType instanceof Int_) {
|
|
25009
|
+
const prefix = arrowType.isSigned ? "int" : "uint";
|
|
25010
|
+
const keyType = `${prefix}${arrowType.bitWidth}`;
|
|
25011
|
+
if (isSchemaDictionaryKeyType(keyType)) {
|
|
25012
|
+
return keyType;
|
|
25013
|
+
}
|
|
25014
|
+
}
|
|
25015
|
+
switch (arrowType.constructor) {
|
|
25016
|
+
case Int8:
|
|
25017
|
+
return "int8";
|
|
25018
|
+
case Int16:
|
|
25019
|
+
return "int16";
|
|
25020
|
+
case Int32:
|
|
25021
|
+
return "int32";
|
|
25022
|
+
case Uint8:
|
|
25023
|
+
return "uint8";
|
|
25024
|
+
case Uint16:
|
|
25025
|
+
return "uint16";
|
|
25026
|
+
case Uint32:
|
|
25027
|
+
return "uint32";
|
|
25028
|
+
default:
|
|
25029
|
+
throw new Error(`arrow dictionary index type not supported: ${arrowType.constructor.name}`);
|
|
25030
|
+
}
|
|
25031
|
+
}
|
|
25032
|
+
function isSchemaDictionaryKeyType(keyType) {
|
|
25033
|
+
return ["int8", "int16", "int32", "uint8", "uint16", "uint32"].includes(keyType);
|
|
25034
|
+
}
|
|
25035
|
+
function deserializeArrowDictionaryKeyType(keyType) {
|
|
25036
|
+
switch (keyType) {
|
|
25037
|
+
case "int8":
|
|
25038
|
+
return new Int8();
|
|
25039
|
+
case "int16":
|
|
25040
|
+
return new Int16();
|
|
25041
|
+
case "int32":
|
|
25042
|
+
return new Int32();
|
|
25043
|
+
case "uint8":
|
|
25044
|
+
return new Uint8();
|
|
25045
|
+
case "uint16":
|
|
25046
|
+
return new Uint16();
|
|
25047
|
+
case "uint32":
|
|
25048
|
+
return new Uint32();
|
|
25049
|
+
default:
|
|
25050
|
+
throw new Error(`schema dictionary index type not supported: ${keyType}`);
|
|
25051
|
+
}
|
|
25052
|
+
}
|
|
25053
|
+
var init_convert_arrow_schema = __esm({
|
|
25054
|
+
"../core/src/schema-utils/lib/schema/convert-arrow-schema.ts"() {
|
|
25055
|
+
"use strict";
|
|
25056
|
+
init_Arrow_dom();
|
|
25057
|
+
}
|
|
25058
|
+
});
|
|
25059
|
+
|
|
22996
25060
|
// ../core/src/schema-utils/lib/mesh/mesh-utils.ts
|
|
22997
25061
|
function getMeshBoundingBox(attributes) {
|
|
22998
25062
|
const positionAttribute = attributes?.POSITION;
|
|
@@ -23094,7 +25158,7 @@ return true;`);
|
|
|
23094
25158
|
var init_float162 = __esm({
|
|
23095
25159
|
"../core/src/schema/float16.ts"() {
|
|
23096
25160
|
"use strict";
|
|
23097
|
-
|
|
25161
|
+
init_dist3();
|
|
23098
25162
|
}
|
|
23099
25163
|
});
|
|
23100
25164
|
|
|
@@ -23273,22 +25337,22 @@ return true;`);
|
|
|
23273
25337
|
if (!suppliedField?.metadata) {
|
|
23274
25338
|
return canonicalField;
|
|
23275
25339
|
}
|
|
23276
|
-
const
|
|
25340
|
+
const metadata3 = new Map(canonicalField.metadata);
|
|
23277
25341
|
for (const [key, value] of Object.entries(suppliedField.metadata)) {
|
|
23278
|
-
|
|
25342
|
+
metadata3.set(key, value);
|
|
23279
25343
|
}
|
|
23280
25344
|
return new Field2(
|
|
23281
25345
|
canonicalField.name,
|
|
23282
25346
|
canonicalField.type,
|
|
23283
25347
|
canonicalField.nullable,
|
|
23284
|
-
|
|
25348
|
+
metadata3
|
|
23285
25349
|
);
|
|
23286
25350
|
}
|
|
23287
25351
|
const field = schema?.fields.find((schemaField) => schemaField.name === attributeName);
|
|
23288
25352
|
if (componentType === "float16") {
|
|
23289
|
-
const
|
|
23290
|
-
|
|
23291
|
-
return new Field2(attributeName, column.type, false,
|
|
25353
|
+
const metadata3 = new Map(Object.entries(field?.metadata || {}));
|
|
25354
|
+
metadata3.set("componentType", "float16");
|
|
25355
|
+
return new Field2(attributeName, column.type, false, metadata3);
|
|
23292
25356
|
}
|
|
23293
25357
|
if (field && field.type.toString() !== column.type.toString()) {
|
|
23294
25358
|
const deserializedField = deserializeArrowField(field);
|
|
@@ -23336,17 +25400,17 @@ return true;`);
|
|
|
23336
25400
|
return new Vector([indicesData]);
|
|
23337
25401
|
}
|
|
23338
25402
|
function getMeshArrowMetadata(options) {
|
|
23339
|
-
const
|
|
25403
|
+
const metadata3 = { ...options.schema?.metadata };
|
|
23340
25404
|
if (options.topology) {
|
|
23341
|
-
|
|
25405
|
+
metadata3.topology ||= options.topology;
|
|
23342
25406
|
}
|
|
23343
25407
|
if (Number.isFinite(options.mode)) {
|
|
23344
|
-
|
|
25408
|
+
metadata3.mode ||= String(options.mode);
|
|
23345
25409
|
}
|
|
23346
25410
|
if (options.boundingBox) {
|
|
23347
|
-
|
|
25411
|
+
metadata3.boundingBox ||= JSON.stringify(options.boundingBox);
|
|
23348
25412
|
}
|
|
23349
|
-
return deserializeArrowMetadata(
|
|
25413
|
+
return deserializeArrowMetadata(metadata3);
|
|
23350
25414
|
}
|
|
23351
25415
|
var MESH_ARROW_ATTRIBUTE_ORDER;
|
|
23352
25416
|
var init_convert_mesh_to_table = __esm({
|
|
@@ -23386,15 +25450,15 @@ return true;`);
|
|
|
23386
25450
|
const attributeData = arrowTable.getChild(name22);
|
|
23387
25451
|
const size = getFixedSizeListSize(attributeData);
|
|
23388
25452
|
const typedArray = getAttributeTypedArray(attributeData, size);
|
|
23389
|
-
const
|
|
23390
|
-
const value =
|
|
25453
|
+
const metadata3 = getMeshAttributeMetadata(field.metadata);
|
|
25454
|
+
const value = metadata3.componentType === "float16" ? restoreFloat16Array(typedArray) : typedArray;
|
|
23391
25455
|
const shared = columns.find(
|
|
23392
25456
|
(column) => column.data.length === attributeData.data.length && attributes[column.name].value.constructor === value.constructor && column.data.every((chunk, index) => shareArrowStorage(chunk, attributeData.data[index]))
|
|
23393
25457
|
);
|
|
23394
25458
|
attributes[name22] = {
|
|
23395
25459
|
value: shared ? attributes[shared.name].value : value,
|
|
23396
25460
|
size,
|
|
23397
|
-
...
|
|
25461
|
+
...metadata3
|
|
23398
25462
|
};
|
|
23399
25463
|
if (!shared) columns.push({ name: name22, data: attributeData.data });
|
|
23400
25464
|
}
|
|
@@ -23431,23 +25495,23 @@ return true;`);
|
|
|
23431
25495
|
}
|
|
23432
25496
|
return null;
|
|
23433
25497
|
}
|
|
23434
|
-
function getMeshAttributeMetadata(
|
|
25498
|
+
function getMeshAttributeMetadata(metadata3 = {}) {
|
|
23435
25499
|
const result = {};
|
|
23436
|
-
if (
|
|
23437
|
-
result.byteOffset = Number(
|
|
25500
|
+
if (metadata3.byteOffset !== void 0) {
|
|
25501
|
+
result.byteOffset = Number(metadata3.byteOffset);
|
|
23438
25502
|
}
|
|
23439
|
-
if (
|
|
23440
|
-
result.byteStride = Number(
|
|
25503
|
+
if (metadata3.byteStride !== void 0) {
|
|
25504
|
+
result.byteStride = Number(metadata3.byteStride);
|
|
23441
25505
|
}
|
|
23442
|
-
if (
|
|
23443
|
-
result.normalized =
|
|
25506
|
+
if (metadata3.normalized !== void 0) {
|
|
25507
|
+
result.normalized = metadata3.normalized === "true";
|
|
23444
25508
|
}
|
|
23445
|
-
if (
|
|
25509
|
+
if (metadata3.componentType === "float16") {
|
|
23446
25510
|
result.componentType = "float16";
|
|
23447
25511
|
}
|
|
23448
|
-
if (
|
|
25512
|
+
if (metadata3["loaders.gl.transform"]) {
|
|
23449
25513
|
try {
|
|
23450
|
-
const transform = JSON.parse(
|
|
25514
|
+
const transform = JSON.parse(metadata3["loaders.gl.transform"]);
|
|
23451
25515
|
if (isMeshAttributeTransform(transform)) {
|
|
23452
25516
|
result.transform = transform;
|
|
23453
25517
|
}
|
|
@@ -23534,17 +25598,29 @@ return true;`);
|
|
|
23534
25598
|
});
|
|
23535
25599
|
|
|
23536
25600
|
// ../core/src/schema-utils/lib/mesh/deduce-mesh-schema.ts
|
|
25601
|
+
function deduceMeshSchema(attributes, metadata3 = {}) {
|
|
25602
|
+
const fields = deduceMeshFields(attributes);
|
|
25603
|
+
return { fields, metadata: metadata3 };
|
|
25604
|
+
}
|
|
23537
25605
|
function deduceMeshField(name22, attribute, optionalMetadata) {
|
|
23538
25606
|
const type = attribute.componentType || getDataTypeFromTypedArray(attribute.value);
|
|
23539
|
-
const
|
|
25607
|
+
const metadata3 = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
|
|
23540
25608
|
const dataType = attribute.size === 1 ? type : { type: "fixed-size-list", listSize: attribute.size, children: [{ name: "value", type }] };
|
|
23541
25609
|
return {
|
|
23542
25610
|
name: name22,
|
|
23543
25611
|
type: dataType,
|
|
23544
25612
|
nullable: false,
|
|
23545
|
-
metadata:
|
|
25613
|
+
metadata: metadata3
|
|
23546
25614
|
};
|
|
23547
25615
|
}
|
|
25616
|
+
function deduceMeshFields(attributes) {
|
|
25617
|
+
const fields = [];
|
|
25618
|
+
for (const attributeName in attributes) {
|
|
25619
|
+
const attribute = attributes[attributeName];
|
|
25620
|
+
fields.push(deduceMeshField(attributeName, attribute));
|
|
25621
|
+
}
|
|
25622
|
+
return fields;
|
|
25623
|
+
}
|
|
23548
25624
|
function makeMeshAttributeMetadata(attribute) {
|
|
23549
25625
|
const result = {};
|
|
23550
25626
|
if ("byteOffset" in attribute) {
|
|
@@ -23584,11 +25660,11 @@ return true;`);
|
|
|
23584
25660
|
});
|
|
23585
25661
|
|
|
23586
25662
|
// src/obj/lib/get-obj-schema.ts
|
|
23587
|
-
function getOBJSchema(attributes,
|
|
25663
|
+
function getOBJSchema(attributes, metadata3 = {}) {
|
|
23588
25664
|
const stringMetadata = {};
|
|
23589
|
-
for (const key in
|
|
25665
|
+
for (const key in metadata3) {
|
|
23590
25666
|
if (key !== "value") {
|
|
23591
|
-
stringMetadata[key] = JSON.stringify(
|
|
25667
|
+
stringMetadata[key] = JSON.stringify(metadata3[key]);
|
|
23592
25668
|
}
|
|
23593
25669
|
}
|
|
23594
25670
|
const fields = [];
|
|
@@ -23600,10 +25676,10 @@ return true;`);
|
|
|
23600
25676
|
return { fields, metadata: stringMetadata };
|
|
23601
25677
|
}
|
|
23602
25678
|
function getFieldFromAttribute(name22, attribute) {
|
|
23603
|
-
const
|
|
25679
|
+
const metadata3 = {};
|
|
23604
25680
|
for (const key in attribute) {
|
|
23605
25681
|
if (key !== "value") {
|
|
23606
|
-
|
|
25682
|
+
metadata3[key] = JSON.stringify(attribute[key]);
|
|
23607
25683
|
}
|
|
23608
25684
|
}
|
|
23609
25685
|
let { type } = getDataTypeFromArray(attribute.value);
|
|
@@ -23611,7 +25687,7 @@ return true;`);
|
|
|
23611
25687
|
if (!isSingleValue) {
|
|
23612
25688
|
type = { type: "fixed-size-list", listSize: attribute.size, children: [{ name: "values", type }] };
|
|
23613
25689
|
}
|
|
23614
|
-
return { name: name22, type, nullable: false, metadata:
|
|
25690
|
+
return { name: name22, type, nullable: false, metadata: metadata3 };
|
|
23615
25691
|
}
|
|
23616
25692
|
var init_get_obj_schema = __esm({
|
|
23617
25693
|
"src/obj/lib/get-obj-schema.ts"() {
|
|
@@ -24165,7 +26241,7 @@ return true;`);
|
|
|
24165
26241
|
"src/obj/obj-loader.ts"() {
|
|
24166
26242
|
"use strict";
|
|
24167
26243
|
init_loader_utils();
|
|
24168
|
-
|
|
26244
|
+
init_arrow_worker_transport();
|
|
24169
26245
|
init_schema_utils();
|
|
24170
26246
|
init_get_obj_schema();
|
|
24171
26247
|
init_parse_obj();
|
|
@@ -24224,7 +26300,7 @@ return true;`);
|
|
|
24224
26300
|
"src/obj/obj-loader-types.ts"() {
|
|
24225
26301
|
"use strict";
|
|
24226
26302
|
init_obj_format();
|
|
24227
|
-
|
|
26303
|
+
init_arrow_worker_transport();
|
|
24228
26304
|
VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
24229
26305
|
OBJLoader = {
|
|
24230
26306
|
...OBJFormat,
|
|
@@ -24666,8 +26742,8 @@ return true;`);
|
|
|
24666
26742
|
}
|
|
24667
26743
|
function getBlobOrSVGDataUrl(arrayBuffer, url) {
|
|
24668
26744
|
if (isSVG(url)) {
|
|
24669
|
-
const
|
|
24670
|
-
let xmlText =
|
|
26745
|
+
const textDecoder2 = new TextDecoder();
|
|
26746
|
+
let xmlText = textDecoder2.decode(arrayBuffer);
|
|
24671
26747
|
try {
|
|
24672
26748
|
if (typeof unescape === "function" && typeof encodeURIComponent === "function") {
|
|
24673
26749
|
xmlText = unescape(encodeURIComponent(xmlText));
|
|
@@ -26127,8 +28203,8 @@ return true;`);
|
|
|
26127
28203
|
}
|
|
26128
28204
|
function parseJSONChunk(glb, dataView, byteOffset, chunkLength2, chunkIndex) {
|
|
26129
28205
|
const jsonChunk = new Uint8Array(dataView.buffer, byteOffset, chunkLength2);
|
|
26130
|
-
const
|
|
26131
|
-
const jsonText =
|
|
28206
|
+
const textDecoder2 = new TextDecoder("utf8");
|
|
28207
|
+
const jsonText = textDecoder2.decode(jsonChunk);
|
|
26132
28208
|
glb.json = JSON.parse(jsonText);
|
|
26133
28209
|
glb.jsonChunkIndex = chunkIndex;
|
|
26134
28210
|
return padToFourBytes(chunkLength2);
|
|
@@ -26913,8 +28989,8 @@ return true;`);
|
|
|
26913
28989
|
* @param mimeType
|
|
26914
28990
|
*/
|
|
26915
28991
|
addImage(imageData, mimeTypeOpt) {
|
|
26916
|
-
const
|
|
26917
|
-
const mimeType = mimeTypeOpt ||
|
|
28992
|
+
const metadata3 = getBinaryImageMetadata(imageData);
|
|
28993
|
+
const mimeType = mimeTypeOpt || metadata3?.mimeType;
|
|
26918
28994
|
const bufferViewIndex = this.addBufferView(imageData);
|
|
26919
28995
|
const glTFImage = {
|
|
26920
28996
|
bufferView: bufferViewIndex,
|
|
@@ -27773,8 +29849,8 @@ return true;`);
|
|
|
27773
29849
|
}
|
|
27774
29850
|
/** Return the loaded buffer companion for a raw buffer definition. */
|
|
27775
29851
|
getLoadedBuffer(buffer) {
|
|
27776
|
-
const
|
|
27777
|
-
return this.gltf.buffers[
|
|
29852
|
+
const metadata3 = this.getMetadata(buffer);
|
|
29853
|
+
return this.gltf.buffers[metadata3.index];
|
|
27778
29854
|
}
|
|
27779
29855
|
/** Return the loaded byte range for a raw buffer-view definition. */
|
|
27780
29856
|
getLoadedBufferView(bufferView) {
|
|
@@ -28321,7 +30397,7 @@ return true;`);
|
|
|
28321
30397
|
return attributeValueArray;
|
|
28322
30398
|
}
|
|
28323
30399
|
function getPropertyDataString(numberOfElements, valuesDataBytes, arrayOffsets, stringOffsets, fixedArrayCount) {
|
|
28324
|
-
const
|
|
30400
|
+
const textDecoder2 = new TextDecoder("utf8");
|
|
28325
30401
|
if (arrayOffsets) {
|
|
28326
30402
|
if (!stringOffsets) {
|
|
28327
30403
|
throw new Error("stringOffsets is required for variable-length string arrays");
|
|
@@ -28335,7 +30411,7 @@ return true;`);
|
|
|
28335
30411
|
const startByte = stringOffsets[stringIndex];
|
|
28336
30412
|
const endByte = stringOffsets[stringIndex + 1];
|
|
28337
30413
|
const stringData = valuesDataBytes.subarray(startByte, endByte);
|
|
28338
|
-
strings.push(
|
|
30414
|
+
strings.push(textDecoder2.decode(stringData));
|
|
28339
30415
|
}
|
|
28340
30416
|
result.push(strings);
|
|
28341
30417
|
}
|
|
@@ -28348,7 +30424,7 @@ return true;`);
|
|
|
28348
30424
|
const startByte = Number(stringOffsets[index]);
|
|
28349
30425
|
const endByte = Number(stringOffsets[index + 1]);
|
|
28350
30426
|
if (startByte >= 0 && endByte >= startByte && endByte <= valuesDataBytes.length) {
|
|
28351
|
-
stringsArray.push(
|
|
30427
|
+
stringsArray.push(textDecoder2.decode(valuesDataBytes.subarray(startByte, endByte)));
|
|
28352
30428
|
}
|
|
28353
30429
|
}
|
|
28354
30430
|
return fixedArrayCount ? Array.from(
|
|
@@ -29238,19 +31314,26 @@ return true;`);
|
|
|
29238
31314
|
for (const [primitiveIndex, primitive] of mesh.primitives.entries()) {
|
|
29239
31315
|
const extension = primitive.extensions?.[name4];
|
|
29240
31316
|
if (!extension) continue;
|
|
31317
|
+
const descriptor = descriptors.find(
|
|
31318
|
+
(item) => item.meshIndex === meshIndex && item.primitiveIndex === primitiveIndex
|
|
31319
|
+
);
|
|
31320
|
+
const legacyColorSpace = options?.gltf?.legacyGaussianSplatColorSpace;
|
|
31321
|
+
const normalizedExtension = legacyColorSpace && extension.extensions?.[SPZ_COMPRESSION_EXTENSION_NAME] ? {
|
|
31322
|
+
...extension,
|
|
31323
|
+
kernel: extension.kernel ?? "ellipse",
|
|
31324
|
+
colorSpace: extension.colorSpace ?? legacyColorSpace
|
|
31325
|
+
} : extension;
|
|
31326
|
+
if (descriptor) descriptor.extension = normalizedExtension;
|
|
29241
31327
|
validateGaussianSplatPrimitive(
|
|
29242
31328
|
gltfData.json,
|
|
29243
31329
|
primitive,
|
|
29244
|
-
|
|
31330
|
+
normalizedExtension,
|
|
29245
31331
|
meshIndex,
|
|
29246
31332
|
primitiveIndex,
|
|
29247
31333
|
iterator
|
|
29248
31334
|
);
|
|
29249
31335
|
const compression = extension.extensions?.[SPZ_COMPRESSION_EXTENSION_NAME];
|
|
29250
31336
|
if (compression) {
|
|
29251
|
-
const descriptor = descriptors.find(
|
|
29252
|
-
(item) => item.meshIndex === meshIndex && item.primitiveIndex === primitiveIndex
|
|
29253
|
-
);
|
|
29254
31337
|
if (descriptor) {
|
|
29255
31338
|
const decoder2 = options?.gltf?.splatDecoder;
|
|
29256
31339
|
const bufferView = gltfData.json.bufferViews?.[compression.bufferView];
|
|
@@ -30807,7 +32890,7 @@ return true;`);
|
|
|
30807
32890
|
|
|
30808
32891
|
// src/draco/lib/utils/get-draco-schema.ts
|
|
30809
32892
|
function getDracoSchema(attributes, loaderData, indices) {
|
|
30810
|
-
const
|
|
32893
|
+
const metadata3 = makeMetadata(loaderData.metadata);
|
|
30811
32894
|
const fields = [];
|
|
30812
32895
|
const namedLoaderDataAttributes = transformAttributesLoaderData(loaderData.attributes);
|
|
30813
32896
|
for (const attributeName in attributes) {
|
|
@@ -30823,7 +32906,7 @@ return true;`);
|
|
|
30823
32906
|
const indicesField = getArrowFieldFromAttribute("indices", indices);
|
|
30824
32907
|
fields.push(indicesField);
|
|
30825
32908
|
}
|
|
30826
|
-
return { fields, metadata:
|
|
32909
|
+
return { fields, metadata: metadata3 };
|
|
30827
32910
|
}
|
|
30828
32911
|
function transformAttributesLoaderData(loaderData) {
|
|
30829
32912
|
const result = {};
|
|
@@ -30841,11 +32924,11 @@ return true;`);
|
|
|
30841
32924
|
const field = deduceMeshField(attributeName, attribute, metadataMap);
|
|
30842
32925
|
return field;
|
|
30843
32926
|
}
|
|
30844
|
-
function makeMetadata(
|
|
30845
|
-
Object.entries(
|
|
32927
|
+
function makeMetadata(metadata3) {
|
|
32928
|
+
Object.entries(metadata3);
|
|
30846
32929
|
const serializedMetadata = {};
|
|
30847
|
-
for (const key in
|
|
30848
|
-
serializedMetadata[`${key}.string`] = JSON.stringify(
|
|
32930
|
+
for (const key in metadata3) {
|
|
32931
|
+
serializedMetadata[`${key}.string`] = JSON.stringify(metadata3[key]);
|
|
30849
32932
|
}
|
|
30850
32933
|
return serializedMetadata;
|
|
30851
32934
|
}
|
|
@@ -31062,14 +33145,14 @@ return true;`);
|
|
|
31062
33145
|
* @returns
|
|
31063
33146
|
*/
|
|
31064
33147
|
_getDracoLoaderData(dracoGeometry, geometry_type, options) {
|
|
31065
|
-
const
|
|
33148
|
+
const metadata3 = this._getTopLevelMetadata(dracoGeometry);
|
|
31066
33149
|
const attributes = this._getDracoAttributes(dracoGeometry, options);
|
|
31067
33150
|
return {
|
|
31068
33151
|
geometry_type,
|
|
31069
33152
|
num_attributes: dracoGeometry.num_attributes(),
|
|
31070
33153
|
num_points: dracoGeometry.num_points(),
|
|
31071
33154
|
num_faces: dracoGeometry instanceof this.draco.Mesh ? dracoGeometry.num_faces() : 0,
|
|
31072
|
-
metadata:
|
|
33155
|
+
metadata: metadata3,
|
|
31073
33156
|
attributes
|
|
31074
33157
|
};
|
|
31075
33158
|
}
|
|
@@ -31083,7 +33166,7 @@ return true;`);
|
|
|
31083
33166
|
const dracoAttributes = {};
|
|
31084
33167
|
for (let attributeId = 0; attributeId < dracoGeometry.num_attributes(); attributeId++) {
|
|
31085
33168
|
const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attributeId);
|
|
31086
|
-
const
|
|
33169
|
+
const metadata3 = this._getAttributeMetadata(dracoGeometry, attributeId);
|
|
31087
33170
|
dracoAttributes[dracoAttribute.unique_id()] = {
|
|
31088
33171
|
unique_id: dracoAttribute.unique_id(),
|
|
31089
33172
|
attribute_type: dracoAttribute.attribute_type(),
|
|
@@ -31093,7 +33176,7 @@ return true;`);
|
|
|
31093
33176
|
byte_stride: dracoAttribute.byte_stride(),
|
|
31094
33177
|
normalized: dracoAttribute.normalized(),
|
|
31095
33178
|
attribute_index: attributeId,
|
|
31096
|
-
metadata:
|
|
33179
|
+
metadata: metadata3
|
|
31097
33180
|
};
|
|
31098
33181
|
const quantization = this._getQuantizationTransform(dracoAttribute, options);
|
|
31099
33182
|
if (quantization) {
|
|
@@ -31604,7 +33687,7 @@ return true;`);
|
|
|
31604
33687
|
var init_draco_loader_types = __esm({
|
|
31605
33688
|
"src/draco/draco-loader-types.ts"() {
|
|
31606
33689
|
"use strict";
|
|
31607
|
-
|
|
33690
|
+
init_arrow_worker_transport();
|
|
31608
33691
|
init_version5();
|
|
31609
33692
|
init_draco_format();
|
|
31610
33693
|
init_draco_loader_options();
|
|
@@ -32038,7 +34121,7 @@ return true;`);
|
|
|
32038
34121
|
var init_KHR_texture_transform = __esm({
|
|
32039
34122
|
"src/gltf/lib/extensions/KHR_texture_transform.ts"() {
|
|
32040
34123
|
"use strict";
|
|
32041
|
-
|
|
34124
|
+
init_dist3();
|
|
32042
34125
|
init_gltf_utils();
|
|
32043
34126
|
init_gltf_constants();
|
|
32044
34127
|
init_gltf_iterator();
|
|
@@ -32176,10 +34259,10 @@ return true;`);
|
|
|
32176
34259
|
}
|
|
32177
34260
|
function resolveTechniques(techniquesExtension, iterator) {
|
|
32178
34261
|
const { programs = [], shaders = [], techniques = [] } = techniquesExtension;
|
|
32179
|
-
const
|
|
34262
|
+
const textDecoder2 = new TextDecoder();
|
|
32180
34263
|
shaders.forEach((shader) => {
|
|
32181
34264
|
if (Number.isFinite(shader.bufferView)) {
|
|
32182
|
-
shader.code =
|
|
34265
|
+
shader.code = textDecoder2.decode(
|
|
32183
34266
|
getTypedArrayForBufferView(iterator.data, iterator.gltf.buffers, shader.bufferView)
|
|
32184
34267
|
);
|
|
32185
34268
|
} else {
|
|
@@ -34090,7 +36173,7 @@ return true;`);
|
|
|
34090
36173
|
var init_convert_gltf_v1_matrix_nodes = __esm({
|
|
34091
36174
|
"src/gltf/lib/api/convert-gltf-v1-matrix-nodes.ts"() {
|
|
34092
36175
|
"use strict";
|
|
34093
|
-
|
|
36176
|
+
init_dist3();
|
|
34094
36177
|
}
|
|
34095
36178
|
});
|
|
34096
36179
|
|
|
@@ -34805,8 +36888,8 @@ return true;`);
|
|
|
34805
36888
|
gltf.baseUri = options.core?.baseUrl;
|
|
34806
36889
|
}
|
|
34807
36890
|
if (data instanceof ArrayBuffer && !isGLB(data, byteOffset, options.glb)) {
|
|
34808
|
-
const
|
|
34809
|
-
data =
|
|
36891
|
+
const textDecoder2 = new TextDecoder();
|
|
36892
|
+
data = textDecoder2.decode(data);
|
|
34810
36893
|
}
|
|
34811
36894
|
if (typeof data === "string") {
|
|
34812
36895
|
gltf.json = parseJSON(data);
|
|
@@ -35791,9 +37874,9 @@ return true;`);
|
|
|
35791
37874
|
* @param dracoGeometry - WASM Draco Object
|
|
35792
37875
|
* @param metadata
|
|
35793
37876
|
*/
|
|
35794
|
-
_addGeometryMetadata(dracoGeometry,
|
|
37877
|
+
_addGeometryMetadata(dracoGeometry, metadata3) {
|
|
35795
37878
|
const dracoMetadata = new this.draco.Metadata();
|
|
35796
|
-
this._populateDracoMetadata(dracoMetadata,
|
|
37879
|
+
this._populateDracoMetadata(dracoMetadata, metadata3);
|
|
35797
37880
|
this.dracoMeshBuilder.AddMetadata(dracoGeometry, dracoMetadata);
|
|
35798
37881
|
}
|
|
35799
37882
|
/**
|
|
@@ -35802,9 +37885,9 @@ return true;`);
|
|
|
35802
37885
|
* @param uniqueAttributeId
|
|
35803
37886
|
* @param metadata
|
|
35804
37887
|
*/
|
|
35805
|
-
_addAttributeMetadata(dracoGeometry, uniqueAttributeId,
|
|
37888
|
+
_addAttributeMetadata(dracoGeometry, uniqueAttributeId, metadata3) {
|
|
35806
37889
|
const dracoAttributeMetadata = new this.draco.Metadata();
|
|
35807
|
-
this._populateDracoMetadata(dracoAttributeMetadata,
|
|
37890
|
+
this._populateDracoMetadata(dracoAttributeMetadata, metadata3);
|
|
35808
37891
|
this.dracoMeshBuilder.SetMetadataForAttribute(
|
|
35809
37892
|
dracoGeometry,
|
|
35810
37893
|
uniqueAttributeId,
|
|
@@ -35816,8 +37899,8 @@ return true;`);
|
|
|
35816
37899
|
* @param dracoMetadata - WASM Draco Object
|
|
35817
37900
|
* @param metadata
|
|
35818
37901
|
*/
|
|
35819
|
-
_populateDracoMetadata(dracoMetadata,
|
|
35820
|
-
for (const [key, value] of getEntries(
|
|
37902
|
+
_populateDracoMetadata(dracoMetadata, metadata3) {
|
|
37903
|
+
for (const [key, value] of getEntries(metadata3)) {
|
|
35821
37904
|
switch (typeof value) {
|
|
35822
37905
|
case "number":
|
|
35823
37906
|
if (Math.trunc(value) === value) {
|
|
@@ -37778,6 +39861,129 @@ Actual: ${this.attribValue}`
|
|
|
37778
39861
|
}
|
|
37779
39862
|
});
|
|
37780
39863
|
|
|
39864
|
+
// src/stl/parse-stl.ts
|
|
39865
|
+
function parseSTL(data) {
|
|
39866
|
+
const view = new DataView(data);
|
|
39867
|
+
const binary = data.byteLength >= 84 && 84 + view.getUint32(80, true) * 50 === data.byteLength;
|
|
39868
|
+
let positions;
|
|
39869
|
+
let normals;
|
|
39870
|
+
let header;
|
|
39871
|
+
if (binary) {
|
|
39872
|
+
const triangleCount = view.getUint32(80, true);
|
|
39873
|
+
positions = new Float32Array(triangleCount * 9);
|
|
39874
|
+
normals = new Float32Array(triangleCount * 9);
|
|
39875
|
+
header = new TextDecoder().decode(data.slice(0, 80));
|
|
39876
|
+
for (let triangle = 0; triangle < triangleCount; triangle++) {
|
|
39877
|
+
const offset = 84 + triangle * 50;
|
|
39878
|
+
for (let component = 0; component < 9; component++) {
|
|
39879
|
+
positions[triangle * 9 + component] = view.getFloat32(offset + 12 + component * 4, true);
|
|
39880
|
+
normals[triangle * 9 + component] = view.getFloat32(offset + component % 3 * 4, true);
|
|
39881
|
+
}
|
|
39882
|
+
}
|
|
39883
|
+
} else {
|
|
39884
|
+
const lines = new TextDecoder().decode(data).trim().split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
39885
|
+
const vertices = [];
|
|
39886
|
+
const normalValues = [];
|
|
39887
|
+
header = lines[0] || "";
|
|
39888
|
+
let lineIndex = 0;
|
|
39889
|
+
while (lineIndex < lines.length) {
|
|
39890
|
+
if (!/^solid(?:\s|$)/i.test(lines[lineIndex++]))
|
|
39891
|
+
throw new Error("STL: expected solid header or exact binary length");
|
|
39892
|
+
while (lineIndex < lines.length && !/^endsolid(?:\s|$)/i.test(lines[lineIndex])) {
|
|
39893
|
+
const normal = parseVector(lines[lineIndex++], "facet normal");
|
|
39894
|
+
if (!/^outer\s+loop$/i.test(lines[lineIndex++] || ""))
|
|
39895
|
+
throw new Error("STL: expected outer loop");
|
|
39896
|
+
for (let vertex = 0; vertex < 3; vertex++) {
|
|
39897
|
+
vertices.push(...parseVector(lines[lineIndex++], "vertex"));
|
|
39898
|
+
normalValues.push(...normal);
|
|
39899
|
+
}
|
|
39900
|
+
if (!/^endloop$/i.test(lines[lineIndex++] || "") || !/^endfacet$/i.test(lines[lineIndex++] || ""))
|
|
39901
|
+
throw new Error("STL: incomplete facet");
|
|
39902
|
+
}
|
|
39903
|
+
if (lineIndex >= lines.length) throw new Error("STL: missing endsolid");
|
|
39904
|
+
lineIndex++;
|
|
39905
|
+
}
|
|
39906
|
+
if (!lines.length) throw new Error("STL: empty input");
|
|
39907
|
+
positions = new Float32Array(vertices);
|
|
39908
|
+
normals = new Float32Array(normalValues);
|
|
39909
|
+
}
|
|
39910
|
+
if (!positions.every(Number.isFinite) || !normals.every(Number.isFinite))
|
|
39911
|
+
throw new Error("STL: non-finite coordinates");
|
|
39912
|
+
const attributes = { POSITION: { value: positions, size: 3 }, NORMAL: { value: normals, size: 3 } };
|
|
39913
|
+
return {
|
|
39914
|
+
topology: "triangle-list",
|
|
39915
|
+
mode: 4,
|
|
39916
|
+
attributes,
|
|
39917
|
+
schema: deduceMeshSchema(attributes),
|
|
39918
|
+
header: {
|
|
39919
|
+
vertexCount: positions.length / 3,
|
|
39920
|
+
boundingBox: getMeshBoundingBox(attributes) ?? void 0
|
|
39921
|
+
},
|
|
39922
|
+
loaderData: { header, format: binary ? "binary" : "ascii" }
|
|
39923
|
+
};
|
|
39924
|
+
}
|
|
39925
|
+
function parseVector(line, prefix) {
|
|
39926
|
+
const tokens = line?.split(/\s+/) || [];
|
|
39927
|
+
const prefixTokens = prefix.split(" ");
|
|
39928
|
+
const components = tokens.slice(prefixTokens.length);
|
|
39929
|
+
if (prefixTokens.some((token, index) => tokens[index]?.toLowerCase() !== token) || components.length !== 3 || components.some((value) => !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(value))) {
|
|
39930
|
+
throw new Error(`STL: invalid ${prefix} record`);
|
|
39931
|
+
}
|
|
39932
|
+
return components.map(Number);
|
|
39933
|
+
}
|
|
39934
|
+
var init_parse_stl = __esm({
|
|
39935
|
+
"src/stl/parse-stl.ts"() {
|
|
39936
|
+
"use strict";
|
|
39937
|
+
init_schema_utils();
|
|
39938
|
+
}
|
|
39939
|
+
});
|
|
39940
|
+
|
|
39941
|
+
// src/stl-loader.ts
|
|
39942
|
+
var stl_loader_exports = {};
|
|
39943
|
+
__export(stl_loader_exports, {
|
|
39944
|
+
STLLoaderWithParser: () => STLLoaderWithParser
|
|
39945
|
+
});
|
|
39946
|
+
var _preload2, metadata2, STLLoaderWithParser;
|
|
39947
|
+
var init_stl_loader = __esm({
|
|
39948
|
+
"src/stl-loader.ts"() {
|
|
39949
|
+
"use strict";
|
|
39950
|
+
init_stl_loader_types();
|
|
39951
|
+
init_parse_stl();
|
|
39952
|
+
({ preload: _preload2, ...metadata2 } = STLLoader);
|
|
39953
|
+
STLLoaderWithParser = {
|
|
39954
|
+
...metadata2,
|
|
39955
|
+
parse: async (data) => parseSTL(data),
|
|
39956
|
+
parseSync: parseSTL
|
|
39957
|
+
};
|
|
39958
|
+
}
|
|
39959
|
+
});
|
|
39960
|
+
|
|
39961
|
+
// src/stl-loader-types.ts
|
|
39962
|
+
async function preload10() {
|
|
39963
|
+
const { STLLoaderWithParser: STLLoaderWithParser2 } = await Promise.resolve().then(() => (init_stl_loader(), stl_loader_exports));
|
|
39964
|
+
return STLLoaderWithParser2;
|
|
39965
|
+
}
|
|
39966
|
+
var VERSION10, STLLoader;
|
|
39967
|
+
var init_stl_loader_types = __esm({
|
|
39968
|
+
"src/stl-loader-types.ts"() {
|
|
39969
|
+
"use strict";
|
|
39970
|
+
VERSION10 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
39971
|
+
STLLoader = {
|
|
39972
|
+
name: "STL",
|
|
39973
|
+
id: "stl",
|
|
39974
|
+
module: "scene",
|
|
39975
|
+
version: VERSION10,
|
|
39976
|
+
extensions: ["stl"],
|
|
39977
|
+
mimeTypes: ["model/stl"],
|
|
39978
|
+
binary: true,
|
|
39979
|
+
dataType: null,
|
|
39980
|
+
batchType: null,
|
|
39981
|
+
options: {},
|
|
39982
|
+
preload: preload10
|
|
39983
|
+
};
|
|
39984
|
+
}
|
|
39985
|
+
});
|
|
39986
|
+
|
|
37781
39987
|
// bundle.ts
|
|
37782
39988
|
var bundle_exports = {};
|
|
37783
39989
|
__export(bundle_exports, {
|
|
@@ -37805,6 +40011,7 @@ Actual: ${this.attribValue}`
|
|
|
37805
40011
|
OBJWorkerLoader: () => OBJWorkerLoader,
|
|
37806
40012
|
OBJWriter: () => OBJWriter,
|
|
37807
40013
|
RequestScheduler: () => import_core4.RequestScheduler,
|
|
40014
|
+
STLLoader: () => STLLoader,
|
|
37808
40015
|
USDLoader: () => USDLoader,
|
|
37809
40016
|
_BrowserFileSystem: () => import_core4._BrowserFileSystem,
|
|
37810
40017
|
_fetchProgress: () => import_core4._fetchProgress,
|
|
@@ -38388,6 +40595,7 @@ Actual: ${this.attribValue}`
|
|
|
38388
40595
|
init_draco_format();
|
|
38389
40596
|
init_draco_libraries();
|
|
38390
40597
|
init_materialx_loader_types();
|
|
40598
|
+
init_stl_loader_types();
|
|
38391
40599
|
return __toCommonJS(bundle_exports);
|
|
38392
40600
|
})();
|
|
38393
40601
|
return __exports__;
|