@loaders.gl/splats 5.0.0-alpha.10 → 5.0.0-alpha.11
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/dist/dist.dev.js +400 -400
- package/dist/dist.min.js +8 -8
- package/dist/index.cjs +406 -406
- package/dist/index.cjs.map +3 -3
- package/dist/ksplat-loader-types.js +1 -1
- package/dist/rad-loader-types.js +1 -1
- package/dist/rad-source-loader.js +1 -1
- package/dist/splat-loader-types.js +1 -1
- package/dist/spz-loader-types.js +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -791,6 +791,309 @@ var init_compression = __esm({
|
|
|
791
791
|
}
|
|
792
792
|
});
|
|
793
793
|
|
|
794
|
+
// ../compression/src/lib/compression-stream.ts
|
|
795
|
+
async function compressWithNativeCompressionStream(input, format) {
|
|
796
|
+
const outputBatches = compressBatchesWithNativeCompressionStream([input], format);
|
|
797
|
+
return outputBatches ? await concatenateBatches(outputBatches) : null;
|
|
798
|
+
}
|
|
799
|
+
function compressBatchesWithNativeCompressionStream(inputBatches, format) {
|
|
800
|
+
const compressionStream = createNativeCompressionStream(format);
|
|
801
|
+
return compressionStream ? transformBatches(inputBatches, compressionStream) : null;
|
|
802
|
+
}
|
|
803
|
+
function createNativeCompressionStream(format) {
|
|
804
|
+
if (typeof globalThis.CompressionStream === "undefined") {
|
|
805
|
+
return null;
|
|
806
|
+
}
|
|
807
|
+
try {
|
|
808
|
+
const CompressionStreamConstructor = globalThis.CompressionStream;
|
|
809
|
+
return new CompressionStreamConstructor(format);
|
|
810
|
+
} catch (error) {
|
|
811
|
+
if (error instanceof TypeError || (error == null ? void 0 : error.name) === "TypeError") {
|
|
812
|
+
return null;
|
|
813
|
+
}
|
|
814
|
+
throw error;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
async function* transformBatches(inputBatches, compressionStream) {
|
|
818
|
+
const writer = compressionStream.writable.getWriter();
|
|
819
|
+
const reader = compressionStream.readable.getReader();
|
|
820
|
+
const writePromise = writeBatches(inputBatches, writer);
|
|
821
|
+
writePromise.catch(() => {
|
|
822
|
+
});
|
|
823
|
+
let outputCompleted = false;
|
|
824
|
+
try {
|
|
825
|
+
while (true) {
|
|
826
|
+
const { done, value } = await reader.read();
|
|
827
|
+
if (done) {
|
|
828
|
+
outputCompleted = true;
|
|
829
|
+
break;
|
|
830
|
+
}
|
|
831
|
+
yield new Uint8Array(value).buffer;
|
|
832
|
+
}
|
|
833
|
+
await writePromise;
|
|
834
|
+
} finally {
|
|
835
|
+
if (!outputCompleted) {
|
|
836
|
+
await reader.cancel().catch(() => {
|
|
837
|
+
});
|
|
838
|
+
await writer.abort().catch(() => {
|
|
839
|
+
});
|
|
840
|
+
await writePromise.catch(() => {
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
reader.releaseLock();
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
async function writeBatches(inputBatches, writer) {
|
|
847
|
+
try {
|
|
848
|
+
for await (const inputBatch of inputBatches) {
|
|
849
|
+
await writer.write(new Uint8Array(inputBatch));
|
|
850
|
+
}
|
|
851
|
+
await writer.close();
|
|
852
|
+
} catch (error) {
|
|
853
|
+
await writer.abort(error).catch(() => {
|
|
854
|
+
});
|
|
855
|
+
throw error;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
async function concatenateBatches(batches) {
|
|
859
|
+
const output = [];
|
|
860
|
+
let byteLength = 0;
|
|
861
|
+
for await (const batch of batches) {
|
|
862
|
+
const bytes = new Uint8Array(batch);
|
|
863
|
+
output.push(bytes);
|
|
864
|
+
byteLength += bytes.byteLength;
|
|
865
|
+
}
|
|
866
|
+
const result = new Uint8Array(byteLength);
|
|
867
|
+
let offset = 0;
|
|
868
|
+
for (const batch of output) {
|
|
869
|
+
result.set(batch, offset);
|
|
870
|
+
offset += batch.byteLength;
|
|
871
|
+
}
|
|
872
|
+
return result.buffer;
|
|
873
|
+
}
|
|
874
|
+
var init_compression_stream = __esm({
|
|
875
|
+
"../compression/src/lib/compression-stream.ts"() {
|
|
876
|
+
"use strict";
|
|
877
|
+
}
|
|
878
|
+
});
|
|
879
|
+
|
|
880
|
+
// ../compression/src/lib/decompression-stream.ts
|
|
881
|
+
async function decompressWithNativeDecompressionStream(input, format) {
|
|
882
|
+
const outputBatches = decompressBatchesWithNativeDecompressionStream([input], format);
|
|
883
|
+
return outputBatches ? await concatenateNativeDecompressionBatches(outputBatches) : null;
|
|
884
|
+
}
|
|
885
|
+
function decompressBatchesWithNativeDecompressionStream(inputBatches, format) {
|
|
886
|
+
const decompressionStream = createNativeDecompressionStream(format);
|
|
887
|
+
return decompressionStream ? transformBatchesWithNativeDecompressionStream(inputBatches, decompressionStream) : null;
|
|
888
|
+
}
|
|
889
|
+
function isNativeDecompressionSupported(format) {
|
|
890
|
+
return Boolean(createNativeDecompressionStream(format));
|
|
891
|
+
}
|
|
892
|
+
function createNativeDecompressionStream(format) {
|
|
893
|
+
var _a, _b;
|
|
894
|
+
if (typeof globalThis.DecompressionStream === "undefined") {
|
|
895
|
+
return null;
|
|
896
|
+
}
|
|
897
|
+
if (((_b = (_a = globalThis.process) == null ? void 0 : _a.release) == null ? void 0 : _b.name) === "node" && typeof globalThis.Buffer === "undefined") {
|
|
898
|
+
return null;
|
|
899
|
+
}
|
|
900
|
+
try {
|
|
901
|
+
const DecompressionStreamConstructor = globalThis.DecompressionStream;
|
|
902
|
+
return new DecompressionStreamConstructor(format);
|
|
903
|
+
} catch (error) {
|
|
904
|
+
if (error instanceof TypeError || (error == null ? void 0 : error.name) === "TypeError") {
|
|
905
|
+
return null;
|
|
906
|
+
}
|
|
907
|
+
throw error;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
async function* transformBatchesWithNativeDecompressionStream(inputBatches, decompressionStream) {
|
|
911
|
+
const writer = decompressionStream.writable.getWriter();
|
|
912
|
+
const reader = decompressionStream.readable.getReader();
|
|
913
|
+
const writePromise = writeBatchesToNativeDecompressionStream(inputBatches, writer);
|
|
914
|
+
writePromise.catch(() => {
|
|
915
|
+
});
|
|
916
|
+
let outputCompleted = false;
|
|
917
|
+
try {
|
|
918
|
+
while (true) {
|
|
919
|
+
const { done, value } = await reader.read();
|
|
920
|
+
if (done) {
|
|
921
|
+
outputCompleted = true;
|
|
922
|
+
break;
|
|
923
|
+
}
|
|
924
|
+
yield copyExactArrayBuffer(value);
|
|
925
|
+
}
|
|
926
|
+
await writePromise;
|
|
927
|
+
} finally {
|
|
928
|
+
if (!outputCompleted) {
|
|
929
|
+
await reader.cancel().catch(() => {
|
|
930
|
+
});
|
|
931
|
+
await writer.abort().catch(() => {
|
|
932
|
+
});
|
|
933
|
+
await writePromise.catch(() => {
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
reader.releaseLock();
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
async function concatenateNativeDecompressionBatches(outputBatches) {
|
|
940
|
+
const batches = [];
|
|
941
|
+
let byteLength = 0;
|
|
942
|
+
for await (const outputBatch of outputBatches) {
|
|
943
|
+
const bytes = new Uint8Array(outputBatch);
|
|
944
|
+
batches.push(bytes);
|
|
945
|
+
byteLength += bytes.byteLength;
|
|
946
|
+
}
|
|
947
|
+
const output = new Uint8Array(byteLength);
|
|
948
|
+
let byteOffset = 0;
|
|
949
|
+
for (const batch of batches) {
|
|
950
|
+
output.set(batch, byteOffset);
|
|
951
|
+
byteOffset += batch.byteLength;
|
|
952
|
+
}
|
|
953
|
+
return output.buffer;
|
|
954
|
+
}
|
|
955
|
+
function copyExactArrayBuffer(value) {
|
|
956
|
+
return new Uint8Array(value).buffer;
|
|
957
|
+
}
|
|
958
|
+
async function writeBatchesToNativeDecompressionStream(inputBatches, writer) {
|
|
959
|
+
try {
|
|
960
|
+
for await (const inputBatch of inputBatches) {
|
|
961
|
+
await writer.write(new Uint8Array(inputBatch));
|
|
962
|
+
}
|
|
963
|
+
await writer.close();
|
|
964
|
+
} catch (error) {
|
|
965
|
+
await writer.abort(error).catch(() => {
|
|
966
|
+
});
|
|
967
|
+
throw error;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
var init_decompression_stream = __esm({
|
|
971
|
+
"../compression/src/lib/decompression-stream.ts"() {
|
|
972
|
+
"use strict";
|
|
973
|
+
}
|
|
974
|
+
});
|
|
975
|
+
|
|
976
|
+
// ../compression/src/lib/native-decompressor.ts
|
|
977
|
+
var native_decompressor_exports = {};
|
|
978
|
+
__export(native_decompressor_exports, {
|
|
979
|
+
NativeDecompressor: () => NativeDecompressor
|
|
980
|
+
});
|
|
981
|
+
var NativeDecompressor;
|
|
982
|
+
var init_native_decompressor = __esm({
|
|
983
|
+
"../compression/src/lib/native-decompressor.ts"() {
|
|
984
|
+
"use strict";
|
|
985
|
+
init_compression();
|
|
986
|
+
init_decompression_stream();
|
|
987
|
+
NativeDecompressor = class extends Decompressor {
|
|
988
|
+
name;
|
|
989
|
+
extensions;
|
|
990
|
+
contentEncodings;
|
|
991
|
+
isSupported = true;
|
|
992
|
+
/** Runtime stream format used for every operation. */
|
|
993
|
+
format;
|
|
994
|
+
constructor(metadata, format, options = {}) {
|
|
995
|
+
super(options);
|
|
996
|
+
this.name = metadata.name;
|
|
997
|
+
this.extensions = [...metadata.extensions];
|
|
998
|
+
this.contentEncodings = [...metadata.contentEncodings];
|
|
999
|
+
this.format = format;
|
|
1000
|
+
}
|
|
1001
|
+
/** Decompresses one buffer with the runtime-provided stream. */
|
|
1002
|
+
async decompress(input) {
|
|
1003
|
+
const output = await decompressWithNativeDecompressionStream(input, this.format);
|
|
1004
|
+
if (!output) throw new Error(`${this.name}: built-in decompression is no longer available`);
|
|
1005
|
+
return output;
|
|
1006
|
+
}
|
|
1007
|
+
/** Decompresses batches incrementally with the runtime-provided stream. */
|
|
1008
|
+
async *decompressBatches(inputBatches) {
|
|
1009
|
+
const output = decompressBatchesWithNativeDecompressionStream(inputBatches, this.format);
|
|
1010
|
+
if (!output) throw new Error(`${this.name}: built-in decompression is no longer available`);
|
|
1011
|
+
yield* output;
|
|
1012
|
+
}
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
});
|
|
1016
|
+
|
|
1017
|
+
// ../compression/src/lib/lazy-compression.ts
|
|
1018
|
+
function mergeModules(options, modules) {
|
|
1019
|
+
return { ...options, modules: { ...options.modules, ...modules } };
|
|
1020
|
+
}
|
|
1021
|
+
var LazyDecompressor;
|
|
1022
|
+
var init_lazy_compression = __esm({
|
|
1023
|
+
"../compression/src/lib/lazy-compression.ts"() {
|
|
1024
|
+
"use strict";
|
|
1025
|
+
init_compression();
|
|
1026
|
+
init_decompression_stream();
|
|
1027
|
+
LazyDecompressor = class extends Decompressor {
|
|
1028
|
+
name;
|
|
1029
|
+
extensions;
|
|
1030
|
+
contentEncodings;
|
|
1031
|
+
isSupported = true;
|
|
1032
|
+
/** Constructor options retained until a concrete implementation is selected. */
|
|
1033
|
+
options;
|
|
1034
|
+
/** Built-in stream format to probe, or null when the format has no built-in path. */
|
|
1035
|
+
nativeFormat;
|
|
1036
|
+
/** Returns whether built-in selection remains eligible for the merged preload options. */
|
|
1037
|
+
shouldUseNative;
|
|
1038
|
+
/** Dynamically imports the balanced fallback constructor. */
|
|
1039
|
+
loadFallback;
|
|
1040
|
+
/** Selected concrete implementation after preload completes. */
|
|
1041
|
+
implementation = null;
|
|
1042
|
+
/** Shared in-flight selection used by concurrent asynchronous calls. */
|
|
1043
|
+
implementationPromise = null;
|
|
1044
|
+
constructor(metadata, loadFallback, options = {}, nativeFormat = null, shouldUseNative = () => true) {
|
|
1045
|
+
super(options);
|
|
1046
|
+
this.name = metadata.name;
|
|
1047
|
+
this.extensions = [...metadata.extensions];
|
|
1048
|
+
this.contentEncodings = [...metadata.contentEncodings];
|
|
1049
|
+
this.options = options;
|
|
1050
|
+
this.nativeFormat = nativeFormat;
|
|
1051
|
+
this.shouldUseNative = shouldUseNative;
|
|
1052
|
+
this.loadFallback = loadFallback;
|
|
1053
|
+
}
|
|
1054
|
+
/** Selects and returns the built-in or dynamically imported fallback decompressor. */
|
|
1055
|
+
async preload(modules = {}) {
|
|
1056
|
+
if (this.implementation) return this.implementation;
|
|
1057
|
+
const options = mergeModules(this.options, modules);
|
|
1058
|
+
this.implementationPromise ||= this.loadImplementation(options);
|
|
1059
|
+
try {
|
|
1060
|
+
this.implementation = await this.implementationPromise;
|
|
1061
|
+
return this.implementation;
|
|
1062
|
+
} catch (error) {
|
|
1063
|
+
this.implementationPromise = null;
|
|
1064
|
+
throw error;
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
/** Loads the selected concrete decompressor. */
|
|
1068
|
+
async loadImplementation(options) {
|
|
1069
|
+
if (options.useNative !== false && this.nativeFormat && this.shouldUseNative(options) && isNativeDecompressionSupported(this.nativeFormat)) {
|
|
1070
|
+
const { NativeDecompressor: NativeDecompressor2 } = await Promise.resolve().then(() => (init_native_decompressor(), native_decompressor_exports));
|
|
1071
|
+
return new NativeDecompressor2(this, this.nativeFormat, options);
|
|
1072
|
+
}
|
|
1073
|
+
const Decompressor2 = await this.loadFallback();
|
|
1074
|
+
const implementation = new Decompressor2({ ...options, useNative: false });
|
|
1075
|
+
await implementation.preload(options.modules);
|
|
1076
|
+
return implementation;
|
|
1077
|
+
}
|
|
1078
|
+
/** Decompresses after lazily selecting the default implementation. */
|
|
1079
|
+
async decompress(input, size) {
|
|
1080
|
+
return (await this.preload()).decompress(input, size);
|
|
1081
|
+
}
|
|
1082
|
+
/** Decompresses synchronously after an implementation has been preloaded. */
|
|
1083
|
+
decompressSync(input, size) {
|
|
1084
|
+
if (!this.implementation) {
|
|
1085
|
+
throw new Error(`${this.name}: call preload() before decompressSync()`);
|
|
1086
|
+
}
|
|
1087
|
+
return this.implementation.decompressSync(input, size);
|
|
1088
|
+
}
|
|
1089
|
+
/** Decompresses batches after lazily selecting the default implementation. */
|
|
1090
|
+
async *decompressBatches(inputBatches) {
|
|
1091
|
+
yield* (await this.preload()).decompressBatches(inputBatches);
|
|
1092
|
+
}
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
});
|
|
1096
|
+
|
|
794
1097
|
// ../compression/src/lib/fflate/index.ts
|
|
795
1098
|
function inflateSync(data, out) {
|
|
796
1099
|
return inflt(data, out);
|
|
@@ -1123,418 +1426,115 @@ var init_fflate = __esm({
|
|
|
1123
1426
|
for (let zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++]) ;
|
|
1124
1427
|
return st + (flg & 2);
|
|
1125
1428
|
};
|
|
1126
|
-
gzl = (d) => {
|
|
1127
|
-
const l = d.length;
|
|
1128
|
-
return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16 | d[l - 1] << 24) >>> 0;
|
|
1129
|
-
};
|
|
1130
|
-
zlv = (d) => {
|
|
1131
|
-
if ((d[0] & 15) != 8 || d[0] >>> 4 > 7 || (d[0] << 8 | d[1]) % 31) err(6, "invalid zlib data");
|
|
1132
|
-
if (d[1] & 32) err(6, "invalid zlib data: preset dictionaries not supported");
|
|
1133
|
-
};
|
|
1134
|
-
Inflate = class {
|
|
1135
|
-
/**
|
|
1136
|
-
* Creates an inflation stream
|
|
1137
|
-
* @param cb The callback to call whenever data is inflated
|
|
1138
|
-
*/
|
|
1139
|
-
constructor(cb) {
|
|
1140
|
-
this.ondata = cb;
|
|
1141
|
-
}
|
|
1142
|
-
/** Persistent bit-reader and Huffman decoding state. */
|
|
1143
|
-
s = {};
|
|
1144
|
-
/** Compression options or retained output window for this stream. */
|
|
1145
|
-
o;
|
|
1146
|
-
/** Compressed bytes pending decoding. */
|
|
1147
|
-
p = new u8(0);
|
|
1148
|
-
/** Whether the stream has received its final chunk. */
|
|
1149
|
-
d;
|
|
1150
|
-
/**
|
|
1151
|
-
* The handler to call whenever data is available
|
|
1152
|
-
*/
|
|
1153
|
-
ondata;
|
|
1154
|
-
/** Appends pending input after checking stream lifecycle. */
|
|
1155
|
-
e(c) {
|
|
1156
|
-
if (!this.ondata) err(5);
|
|
1157
|
-
if (this.d) err(4);
|
|
1158
|
-
const l = this.p.length;
|
|
1159
|
-
const n = new u8(l + c.length);
|
|
1160
|
-
n.set(this.p), n.set(c, l), this.p = n;
|
|
1161
|
-
}
|
|
1162
|
-
/** Decodes pending input and retains the sliding window. */
|
|
1163
|
-
c(final) {
|
|
1164
|
-
this.d = this.s.i = final || false;
|
|
1165
|
-
const bts = this.s.b;
|
|
1166
|
-
const dt = inflt(this.p, this.o, this.s);
|
|
1167
|
-
this.ondata(slc(dt, bts, this.s.b), this.d);
|
|
1168
|
-
this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;
|
|
1169
|
-
this.p = slc(this.p, this.s.p / 8 | 0), this.s.p &= 7;
|
|
1170
|
-
}
|
|
1171
|
-
/**
|
|
1172
|
-
* Pushes a chunk to be inflated
|
|
1173
|
-
* @param chunk The chunk to push
|
|
1174
|
-
* @param final Whether this is the final chunk
|
|
1175
|
-
*/
|
|
1176
|
-
push(chunk, final) {
|
|
1177
|
-
this.e(chunk), this.c(final);
|
|
1178
|
-
}
|
|
1179
|
-
};
|
|
1180
|
-
Gunzip = class extends Inflate {
|
|
1181
|
-
/** Whether the stream header still needs to be emitted or consumed. */
|
|
1182
|
-
v = 1;
|
|
1183
|
-
/**
|
|
1184
|
-
* Creates a GUNZIP stream
|
|
1185
|
-
* @param cb The callback to call whenever data is inflated
|
|
1186
|
-
*/
|
|
1187
|
-
constructor(cb) {
|
|
1188
|
-
super(cb);
|
|
1189
|
-
}
|
|
1190
|
-
/**
|
|
1191
|
-
* Pushes a chunk to be GUNZIPped
|
|
1192
|
-
* @param chunk The chunk to push
|
|
1193
|
-
* @param final Whether this is the last chunk
|
|
1194
|
-
*/
|
|
1195
|
-
push(chunk, final) {
|
|
1196
|
-
Inflate.prototype.e.call(this, chunk);
|
|
1197
|
-
if (this.v) {
|
|
1198
|
-
const s = this.p.length > 3 ? gzs(this.p) : 4;
|
|
1199
|
-
if (s >= this.p.length && !final) return;
|
|
1200
|
-
this.p = this.p.subarray(s), this.v = 0;
|
|
1201
|
-
}
|
|
1202
|
-
if (final) {
|
|
1203
|
-
if (this.p.length < 8) err(6, "invalid gzip data");
|
|
1204
|
-
this.p = this.p.subarray(0, -8);
|
|
1205
|
-
}
|
|
1206
|
-
Inflate.prototype.c.call(this, final);
|
|
1207
|
-
}
|
|
1208
|
-
};
|
|
1209
|
-
Unzlib = class extends Inflate {
|
|
1210
|
-
/** Whether the stream header still needs to be emitted or consumed. */
|
|
1211
|
-
v = 1;
|
|
1212
|
-
/**
|
|
1213
|
-
* Creates a Zlib decompression stream
|
|
1214
|
-
* @param cb The callback to call whenever data is inflated
|
|
1215
|
-
*/
|
|
1216
|
-
constructor(cb) {
|
|
1217
|
-
super(cb);
|
|
1218
|
-
}
|
|
1219
|
-
/**
|
|
1220
|
-
* Pushes a chunk to be unzlibbed
|
|
1221
|
-
* @param chunk The chunk to push
|
|
1222
|
-
* @param final Whether this is the last chunk
|
|
1223
|
-
*/
|
|
1224
|
-
push(chunk, final) {
|
|
1225
|
-
Inflate.prototype.e.call(this, chunk);
|
|
1226
|
-
if (this.v) {
|
|
1227
|
-
if (this.p.length < 2 && !final) return;
|
|
1228
|
-
this.p = this.p.subarray(2), this.v = 0;
|
|
1229
|
-
}
|
|
1230
|
-
if (final) {
|
|
1231
|
-
if (this.p.length < 4) err(6, "invalid zlib data");
|
|
1232
|
-
this.p = this.p.subarray(0, -4);
|
|
1233
|
-
}
|
|
1234
|
-
Inflate.prototype.c.call(this, final);
|
|
1235
|
-
}
|
|
1236
|
-
};
|
|
1237
|
-
}
|
|
1238
|
-
});
|
|
1239
|
-
|
|
1240
|
-
// ../compression/src/lib/compression-stream.ts
|
|
1241
|
-
async function compressWithNativeCompressionStream(input, format) {
|
|
1242
|
-
const outputBatches = compressBatchesWithNativeCompressionStream([input], format);
|
|
1243
|
-
return outputBatches ? await concatenateBatches(outputBatches) : null;
|
|
1244
|
-
}
|
|
1245
|
-
function compressBatchesWithNativeCompressionStream(inputBatches, format) {
|
|
1246
|
-
const compressionStream = createNativeCompressionStream(format);
|
|
1247
|
-
return compressionStream ? transformBatches(inputBatches, compressionStream) : null;
|
|
1248
|
-
}
|
|
1249
|
-
function createNativeCompressionStream(format) {
|
|
1250
|
-
if (typeof globalThis.CompressionStream === "undefined") {
|
|
1251
|
-
return null;
|
|
1252
|
-
}
|
|
1253
|
-
try {
|
|
1254
|
-
const CompressionStreamConstructor = globalThis.CompressionStream;
|
|
1255
|
-
return new CompressionStreamConstructor(format);
|
|
1256
|
-
} catch (error) {
|
|
1257
|
-
if (error instanceof TypeError || (error == null ? void 0 : error.name) === "TypeError") {
|
|
1258
|
-
return null;
|
|
1259
|
-
}
|
|
1260
|
-
throw error;
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
async function* transformBatches(inputBatches, compressionStream) {
|
|
1264
|
-
const writer = compressionStream.writable.getWriter();
|
|
1265
|
-
const reader = compressionStream.readable.getReader();
|
|
1266
|
-
const writePromise = writeBatches(inputBatches, writer);
|
|
1267
|
-
writePromise.catch(() => {
|
|
1268
|
-
});
|
|
1269
|
-
let outputCompleted = false;
|
|
1270
|
-
try {
|
|
1271
|
-
while (true) {
|
|
1272
|
-
const { done, value } = await reader.read();
|
|
1273
|
-
if (done) {
|
|
1274
|
-
outputCompleted = true;
|
|
1275
|
-
break;
|
|
1276
|
-
}
|
|
1277
|
-
yield new Uint8Array(value).buffer;
|
|
1278
|
-
}
|
|
1279
|
-
await writePromise;
|
|
1280
|
-
} finally {
|
|
1281
|
-
if (!outputCompleted) {
|
|
1282
|
-
await reader.cancel().catch(() => {
|
|
1283
|
-
});
|
|
1284
|
-
await writer.abort().catch(() => {
|
|
1285
|
-
});
|
|
1286
|
-
await writePromise.catch(() => {
|
|
1287
|
-
});
|
|
1288
|
-
}
|
|
1289
|
-
reader.releaseLock();
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
async function writeBatches(inputBatches, writer) {
|
|
1293
|
-
try {
|
|
1294
|
-
for await (const inputBatch of inputBatches) {
|
|
1295
|
-
await writer.write(new Uint8Array(inputBatch));
|
|
1296
|
-
}
|
|
1297
|
-
await writer.close();
|
|
1298
|
-
} catch (error) {
|
|
1299
|
-
await writer.abort(error).catch(() => {
|
|
1300
|
-
});
|
|
1301
|
-
throw error;
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
async function concatenateBatches(batches) {
|
|
1305
|
-
const output = [];
|
|
1306
|
-
let byteLength = 0;
|
|
1307
|
-
for await (const batch of batches) {
|
|
1308
|
-
const bytes = new Uint8Array(batch);
|
|
1309
|
-
output.push(bytes);
|
|
1310
|
-
byteLength += bytes.byteLength;
|
|
1311
|
-
}
|
|
1312
|
-
const result = new Uint8Array(byteLength);
|
|
1313
|
-
let offset = 0;
|
|
1314
|
-
for (const batch of output) {
|
|
1315
|
-
result.set(batch, offset);
|
|
1316
|
-
offset += batch.byteLength;
|
|
1317
|
-
}
|
|
1318
|
-
return result.buffer;
|
|
1319
|
-
}
|
|
1320
|
-
var init_compression_stream = __esm({
|
|
1321
|
-
"../compression/src/lib/compression-stream.ts"() {
|
|
1322
|
-
"use strict";
|
|
1323
|
-
}
|
|
1324
|
-
});
|
|
1325
|
-
|
|
1326
|
-
// ../compression/src/lib/decompression-stream.ts
|
|
1327
|
-
async function decompressWithNativeDecompressionStream(input, format) {
|
|
1328
|
-
const outputBatches = decompressBatchesWithNativeDecompressionStream([input], format);
|
|
1329
|
-
return outputBatches ? await concatenateNativeDecompressionBatches(outputBatches) : null;
|
|
1330
|
-
}
|
|
1331
|
-
function decompressBatchesWithNativeDecompressionStream(inputBatches, format) {
|
|
1332
|
-
const decompressionStream = createNativeDecompressionStream(format);
|
|
1333
|
-
return decompressionStream ? transformBatchesWithNativeDecompressionStream(inputBatches, decompressionStream) : null;
|
|
1334
|
-
}
|
|
1335
|
-
function isNativeDecompressionSupported(format) {
|
|
1336
|
-
return Boolean(createNativeDecompressionStream(format));
|
|
1337
|
-
}
|
|
1338
|
-
function createNativeDecompressionStream(format) {
|
|
1339
|
-
var _a, _b;
|
|
1340
|
-
if (typeof globalThis.DecompressionStream === "undefined") {
|
|
1341
|
-
return null;
|
|
1342
|
-
}
|
|
1343
|
-
if (((_b = (_a = globalThis.process) == null ? void 0 : _a.release) == null ? void 0 : _b.name) === "node" && typeof globalThis.Buffer === "undefined") {
|
|
1344
|
-
return null;
|
|
1345
|
-
}
|
|
1346
|
-
try {
|
|
1347
|
-
const DecompressionStreamConstructor = globalThis.DecompressionStream;
|
|
1348
|
-
return new DecompressionStreamConstructor(format);
|
|
1349
|
-
} catch (error) {
|
|
1350
|
-
if (error instanceof TypeError || (error == null ? void 0 : error.name) === "TypeError") {
|
|
1351
|
-
return null;
|
|
1352
|
-
}
|
|
1353
|
-
throw error;
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
|
-
async function* transformBatchesWithNativeDecompressionStream(inputBatches, decompressionStream) {
|
|
1357
|
-
const writer = decompressionStream.writable.getWriter();
|
|
1358
|
-
const reader = decompressionStream.readable.getReader();
|
|
1359
|
-
const writePromise = writeBatchesToNativeDecompressionStream(inputBatches, writer);
|
|
1360
|
-
writePromise.catch(() => {
|
|
1361
|
-
});
|
|
1362
|
-
let outputCompleted = false;
|
|
1363
|
-
try {
|
|
1364
|
-
while (true) {
|
|
1365
|
-
const { done, value } = await reader.read();
|
|
1366
|
-
if (done) {
|
|
1367
|
-
outputCompleted = true;
|
|
1368
|
-
break;
|
|
1429
|
+
gzl = (d) => {
|
|
1430
|
+
const l = d.length;
|
|
1431
|
+
return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16 | d[l - 1] << 24) >>> 0;
|
|
1432
|
+
};
|
|
1433
|
+
zlv = (d) => {
|
|
1434
|
+
if ((d[0] & 15) != 8 || d[0] >>> 4 > 7 || (d[0] << 8 | d[1]) % 31) err(6, "invalid zlib data");
|
|
1435
|
+
if (d[1] & 32) err(6, "invalid zlib data: preset dictionaries not supported");
|
|
1436
|
+
};
|
|
1437
|
+
Inflate = class {
|
|
1438
|
+
/**
|
|
1439
|
+
* Creates an inflation stream
|
|
1440
|
+
* @param cb The callback to call whenever data is inflated
|
|
1441
|
+
*/
|
|
1442
|
+
constructor(cb) {
|
|
1443
|
+
this.ondata = cb;
|
|
1369
1444
|
}
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
const bytes = new Uint8Array(outputBatch);
|
|
1390
|
-
batches.push(bytes);
|
|
1391
|
-
byteLength += bytes.byteLength;
|
|
1392
|
-
}
|
|
1393
|
-
const output = new Uint8Array(byteLength);
|
|
1394
|
-
let byteOffset = 0;
|
|
1395
|
-
for (const batch of batches) {
|
|
1396
|
-
output.set(batch, byteOffset);
|
|
1397
|
-
byteOffset += batch.byteLength;
|
|
1398
|
-
}
|
|
1399
|
-
return output.buffer;
|
|
1400
|
-
}
|
|
1401
|
-
function copyExactArrayBuffer(value) {
|
|
1402
|
-
return new Uint8Array(value).buffer;
|
|
1403
|
-
}
|
|
1404
|
-
async function writeBatchesToNativeDecompressionStream(inputBatches, writer) {
|
|
1405
|
-
try {
|
|
1406
|
-
for await (const inputBatch of inputBatches) {
|
|
1407
|
-
await writer.write(new Uint8Array(inputBatch));
|
|
1408
|
-
}
|
|
1409
|
-
await writer.close();
|
|
1410
|
-
} catch (error) {
|
|
1411
|
-
await writer.abort(error).catch(() => {
|
|
1412
|
-
});
|
|
1413
|
-
throw error;
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1416
|
-
var init_decompression_stream = __esm({
|
|
1417
|
-
"../compression/src/lib/decompression-stream.ts"() {
|
|
1418
|
-
"use strict";
|
|
1419
|
-
}
|
|
1420
|
-
});
|
|
1421
|
-
|
|
1422
|
-
// ../compression/src/lib/native-decompressor.ts
|
|
1423
|
-
var native_decompressor_exports = {};
|
|
1424
|
-
__export(native_decompressor_exports, {
|
|
1425
|
-
NativeDecompressor: () => NativeDecompressor
|
|
1426
|
-
});
|
|
1427
|
-
var NativeDecompressor;
|
|
1428
|
-
var init_native_decompressor = __esm({
|
|
1429
|
-
"../compression/src/lib/native-decompressor.ts"() {
|
|
1430
|
-
"use strict";
|
|
1431
|
-
init_compression();
|
|
1432
|
-
init_decompression_stream();
|
|
1433
|
-
NativeDecompressor = class extends Decompressor {
|
|
1434
|
-
name;
|
|
1435
|
-
extensions;
|
|
1436
|
-
contentEncodings;
|
|
1437
|
-
isSupported = true;
|
|
1438
|
-
/** Runtime stream format used for every operation. */
|
|
1439
|
-
format;
|
|
1440
|
-
constructor(metadata, format, options = {}) {
|
|
1441
|
-
super(options);
|
|
1442
|
-
this.name = metadata.name;
|
|
1443
|
-
this.extensions = [...metadata.extensions];
|
|
1444
|
-
this.contentEncodings = [...metadata.contentEncodings];
|
|
1445
|
-
this.format = format;
|
|
1445
|
+
/** Persistent bit-reader and Huffman decoding state. */
|
|
1446
|
+
s = {};
|
|
1447
|
+
/** Compression options or retained output window for this stream. */
|
|
1448
|
+
o;
|
|
1449
|
+
/** Compressed bytes pending decoding. */
|
|
1450
|
+
p = new u8(0);
|
|
1451
|
+
/** Whether the stream has received its final chunk. */
|
|
1452
|
+
d;
|
|
1453
|
+
/**
|
|
1454
|
+
* The handler to call whenever data is available
|
|
1455
|
+
*/
|
|
1456
|
+
ondata;
|
|
1457
|
+
/** Appends pending input after checking stream lifecycle. */
|
|
1458
|
+
e(c) {
|
|
1459
|
+
if (!this.ondata) err(5);
|
|
1460
|
+
if (this.d) err(4);
|
|
1461
|
+
const l = this.p.length;
|
|
1462
|
+
const n = new u8(l + c.length);
|
|
1463
|
+
n.set(this.p), n.set(c, l), this.p = n;
|
|
1446
1464
|
}
|
|
1447
|
-
/**
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1465
|
+
/** Decodes pending input and retains the sliding window. */
|
|
1466
|
+
c(final) {
|
|
1467
|
+
this.d = this.s.i = final || false;
|
|
1468
|
+
const bts = this.s.b;
|
|
1469
|
+
const dt = inflt(this.p, this.o, this.s);
|
|
1470
|
+
this.ondata(slc(dt, bts, this.s.b), this.d);
|
|
1471
|
+
this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;
|
|
1472
|
+
this.p = slc(this.p, this.s.p / 8 | 0), this.s.p &= 7;
|
|
1452
1473
|
}
|
|
1453
|
-
/**
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1474
|
+
/**
|
|
1475
|
+
* Pushes a chunk to be inflated
|
|
1476
|
+
* @param chunk The chunk to push
|
|
1477
|
+
* @param final Whether this is the final chunk
|
|
1478
|
+
*/
|
|
1479
|
+
push(chunk, final) {
|
|
1480
|
+
this.e(chunk), this.c(final);
|
|
1458
1481
|
}
|
|
1459
1482
|
};
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
"../compression/src/lib/lazy-compression.ts"() {
|
|
1470
|
-
"use strict";
|
|
1471
|
-
init_compression();
|
|
1472
|
-
init_decompression_stream();
|
|
1473
|
-
LazyDecompressor = class extends Decompressor {
|
|
1474
|
-
name;
|
|
1475
|
-
extensions;
|
|
1476
|
-
contentEncodings;
|
|
1477
|
-
isSupported = true;
|
|
1478
|
-
/** Constructor options retained until a concrete implementation is selected. */
|
|
1479
|
-
options;
|
|
1480
|
-
/** Built-in stream format to probe, or null when the format has no built-in path. */
|
|
1481
|
-
nativeFormat;
|
|
1482
|
-
/** Returns whether built-in selection remains eligible for the merged preload options. */
|
|
1483
|
-
shouldUseNative;
|
|
1484
|
-
/** Dynamically imports the balanced fallback constructor. */
|
|
1485
|
-
loadFallback;
|
|
1486
|
-
/** Selected concrete implementation after preload completes. */
|
|
1487
|
-
implementation = null;
|
|
1488
|
-
/** Shared in-flight selection used by concurrent asynchronous calls. */
|
|
1489
|
-
implementationPromise = null;
|
|
1490
|
-
constructor(metadata, loadFallback, options = {}, nativeFormat = null, shouldUseNative = () => true) {
|
|
1491
|
-
super(options);
|
|
1492
|
-
this.name = metadata.name;
|
|
1493
|
-
this.extensions = [...metadata.extensions];
|
|
1494
|
-
this.contentEncodings = [...metadata.contentEncodings];
|
|
1495
|
-
this.options = options;
|
|
1496
|
-
this.nativeFormat = nativeFormat;
|
|
1497
|
-
this.shouldUseNative = shouldUseNative;
|
|
1498
|
-
this.loadFallback = loadFallback;
|
|
1483
|
+
Gunzip = class extends Inflate {
|
|
1484
|
+
/** Whether the stream header still needs to be emitted or consumed. */
|
|
1485
|
+
v = 1;
|
|
1486
|
+
/**
|
|
1487
|
+
* Creates a GUNZIP stream
|
|
1488
|
+
* @param cb The callback to call whenever data is inflated
|
|
1489
|
+
*/
|
|
1490
|
+
constructor(cb) {
|
|
1491
|
+
super(cb);
|
|
1499
1492
|
}
|
|
1500
|
-
/**
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
this.
|
|
1510
|
-
|
|
1493
|
+
/**
|
|
1494
|
+
* Pushes a chunk to be GUNZIPped
|
|
1495
|
+
* @param chunk The chunk to push
|
|
1496
|
+
* @param final Whether this is the last chunk
|
|
1497
|
+
*/
|
|
1498
|
+
push(chunk, final) {
|
|
1499
|
+
Inflate.prototype.e.call(this, chunk);
|
|
1500
|
+
if (this.v) {
|
|
1501
|
+
const s = this.p.length > 3 ? gzs(this.p) : 4;
|
|
1502
|
+
if (s >= this.p.length && !final) return;
|
|
1503
|
+
this.p = this.p.subarray(s), this.v = 0;
|
|
1511
1504
|
}
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
if (options.useNative !== false && this.nativeFormat && this.shouldUseNative(options) && isNativeDecompressionSupported(this.nativeFormat)) {
|
|
1516
|
-
const { NativeDecompressor: NativeDecompressor2 } = await Promise.resolve().then(() => (init_native_decompressor(), native_decompressor_exports));
|
|
1517
|
-
return new NativeDecompressor2(this, this.nativeFormat, options);
|
|
1505
|
+
if (final) {
|
|
1506
|
+
if (this.p.length < 8) err(6, "invalid gzip data");
|
|
1507
|
+
this.p = this.p.subarray(0, -8);
|
|
1518
1508
|
}
|
|
1519
|
-
|
|
1520
|
-
const implementation = new Decompressor2({ ...options, useNative: false });
|
|
1521
|
-
await implementation.preload(options.modules);
|
|
1522
|
-
return implementation;
|
|
1509
|
+
Inflate.prototype.c.call(this, final);
|
|
1523
1510
|
}
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1511
|
+
};
|
|
1512
|
+
Unzlib = class extends Inflate {
|
|
1513
|
+
/** Whether the stream header still needs to be emitted or consumed. */
|
|
1514
|
+
v = 1;
|
|
1515
|
+
/**
|
|
1516
|
+
* Creates a Zlib decompression stream
|
|
1517
|
+
* @param cb The callback to call whenever data is inflated
|
|
1518
|
+
*/
|
|
1519
|
+
constructor(cb) {
|
|
1520
|
+
super(cb);
|
|
1527
1521
|
}
|
|
1528
|
-
/**
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1522
|
+
/**
|
|
1523
|
+
* Pushes a chunk to be unzlibbed
|
|
1524
|
+
* @param chunk The chunk to push
|
|
1525
|
+
* @param final Whether this is the last chunk
|
|
1526
|
+
*/
|
|
1527
|
+
push(chunk, final) {
|
|
1528
|
+
Inflate.prototype.e.call(this, chunk);
|
|
1529
|
+
if (this.v) {
|
|
1530
|
+
if (this.p.length < 2 && !final) return;
|
|
1531
|
+
this.p = this.p.subarray(2), this.v = 0;
|
|
1532
1532
|
}
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1533
|
+
if (final) {
|
|
1534
|
+
if (this.p.length < 4) err(6, "invalid zlib data");
|
|
1535
|
+
this.p = this.p.subarray(0, -4);
|
|
1536
|
+
}
|
|
1537
|
+
Inflate.prototype.c.call(this, final);
|
|
1538
1538
|
}
|
|
1539
1539
|
};
|
|
1540
1540
|
}
|
|
@@ -2499,7 +2499,7 @@ var init_splat_loader_types = __esm({
|
|
|
2499
2499
|
"dist/splat-loader-types.js"() {
|
|
2500
2500
|
"use strict";
|
|
2501
2501
|
init_splats_format();
|
|
2502
|
-
VERSION2 = true ? "5.0.0-alpha.
|
|
2502
|
+
VERSION2 = true ? "5.0.0-alpha.11" : "latest";
|
|
2503
2503
|
SPLATLoader = {
|
|
2504
2504
|
dataType: null,
|
|
2505
2505
|
batchType: null,
|
|
@@ -2824,7 +2824,7 @@ var init_ksplat_loader_types = __esm({
|
|
|
2824
2824
|
"dist/ksplat-loader-types.js"() {
|
|
2825
2825
|
"use strict";
|
|
2826
2826
|
init_splats_format();
|
|
2827
|
-
VERSION3 = true ? "5.0.0-alpha.
|
|
2827
|
+
VERSION3 = true ? "5.0.0-alpha.11" : "latest";
|
|
2828
2828
|
KSPLATLoader = {
|
|
2829
2829
|
dataType: null,
|
|
2830
2830
|
batchType: null,
|
|
@@ -2869,7 +2869,7 @@ var init_spz_loader_types = __esm({
|
|
|
2869
2869
|
"dist/spz-loader-types.js"() {
|
|
2870
2870
|
"use strict";
|
|
2871
2871
|
init_splats_format();
|
|
2872
|
-
VERSION4 = true ? "5.0.0-alpha.
|
|
2872
|
+
VERSION4 = true ? "5.0.0-alpha.11" : "latest";
|
|
2873
2873
|
SPZLoader = {
|
|
2874
2874
|
dataType: null,
|
|
2875
2875
|
batchType: null,
|
|
@@ -3620,7 +3620,7 @@ var init_rad_loader_types = __esm({
|
|
|
3620
3620
|
"dist/rad-loader-types.js"() {
|
|
3621
3621
|
"use strict";
|
|
3622
3622
|
init_splats_format();
|
|
3623
|
-
VERSION5 = true ? "5.0.0-alpha.
|
|
3623
|
+
VERSION5 = true ? "5.0.0-alpha.11" : "latest";
|
|
3624
3624
|
RADLoader = {
|
|
3625
3625
|
dataType: null,
|
|
3626
3626
|
batchType: null,
|
|
@@ -3665,7 +3665,7 @@ init_parse_rad_chunk();
|
|
|
3665
3665
|
init_splats_arrow_table();
|
|
3666
3666
|
var DEFAULT_RAD_HEADER_BYTE_LENGTHS = [64 * 1024, 256 * 1024, 1024 * 1024];
|
|
3667
3667
|
var DEFAULT_RAD_MAX_CONCURRENT_CHUNK_REQUESTS = 4;
|
|
3668
|
-
var VERSION6 = true ? "5.0.0-alpha.
|
|
3668
|
+
var VERSION6 = true ? "5.0.0-alpha.11" : "latest";
|
|
3669
3669
|
var RADSourceLoader = {
|
|
3670
3670
|
dataType: null,
|
|
3671
3671
|
batchType: null,
|