@loaders.gl/splats 5.0.0-alpha.9 → 5.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -30
- package/README.md +5 -0
- package/THIRD-PARTY-NOTICES.md +17 -0
- package/dist/dist.dev.js +2072 -2498
- package/dist/dist.min.js +35 -35
- package/dist/index.cjs +232 -470
- package/dist/index.cjs.map +3 -3
- package/dist/ksplat-loader-types.d.ts +1 -1
- package/dist/ksplat-loader-types.d.ts.map +1 -1
- package/dist/ksplat-loader-types.js +1 -1
- package/dist/ksplat-loader-types.js.map +1 -1
- package/dist/ksplat-loader.d.ts +1 -1
- package/dist/ksplat-loader.d.ts.map +1 -1
- package/dist/lib/parse-ksplat.d.ts +1 -1
- package/dist/lib/parse-ksplat.d.ts.map +1 -1
- package/dist/lib/parse-rad-chunk.d.ts +3 -1
- package/dist/lib/parse-rad-chunk.d.ts.map +1 -1
- package/dist/lib/parse-rad-chunk.js +4 -0
- package/dist/lib/parse-rad-chunk.js.map +1 -1
- package/dist/lib/parse-splat.d.ts +1 -1
- package/dist/lib/parse-splat.d.ts.map +1 -1
- package/dist/lib/parse-spz.d.ts +1 -1
- package/dist/lib/parse-spz.d.ts.map +1 -1
- package/dist/lib/splats-arrow-table.d.ts +1 -1
- package/dist/lib/splats-arrow-table.d.ts.map +1 -1
- package/dist/rad-loader-types.js +1 -1
- package/dist/rad-loader-types.js.map +1 -1
- package/dist/rad-loader.d.ts +1 -1
- package/dist/rad-loader.d.ts.map +1 -1
- package/dist/rad-loader.js +1 -1
- package/dist/rad-loader.js.map +1 -1
- package/dist/rad-source-loader.d.ts +3 -3
- package/dist/rad-source-loader.d.ts.map +1 -1
- package/dist/rad-source-loader.js +5 -3
- package/dist/rad-source-loader.js.map +1 -1
- package/dist/splat-loader-types.d.ts +1 -1
- package/dist/splat-loader-types.d.ts.map +1 -1
- package/dist/splat-loader-types.js +1 -1
- package/dist/splat-loader-types.js.map +1 -1
- package/dist/splat-loader.d.ts +1 -1
- package/dist/splat-loader.d.ts.map +1 -1
- package/dist/spz-loader-types.d.ts +1 -1
- package/dist/spz-loader-types.d.ts.map +1 -1
- package/dist/spz-loader-types.js +1 -1
- package/dist/spz-loader-types.js.map +1 -1
- package/dist/spz-loader.d.ts +1 -1
- package/dist/spz-loader.d.ts.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/ksplat-loader-types.ts +2 -2
- package/src/ksplat-loader.ts +2 -2
- package/src/lib/parse-ksplat.ts +1 -1
- package/src/lib/parse-rad-chunk.ts +6 -1
- package/src/lib/parse-splat.ts +1 -1
- package/src/lib/parse-spz.ts +1 -1
- package/src/lib/splats-arrow-table.ts +1 -1
- package/src/rad-loader-types.ts +1 -1
- package/src/rad-loader.ts +2 -1
- package/src/rad-source-loader.ts +6 -3
- package/src/splat-loader-types.ts +2 -2
- package/src/splat-loader.ts +2 -2
- package/src/splats-format.ts +1 -1
- package/src/spz-loader-types.ts +2 -2
- package/src/spz-loader.ts +2 -2
- package/src/types.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -81,7 +81,7 @@ var init_splats_format = __esm({
|
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
-
// ../loader-utils/
|
|
84
|
+
// ../core/src/loader-utils/lib/log-utils/log.ts
|
|
85
85
|
function createLog() {
|
|
86
86
|
const log2 = new import_log.Log({ id: "loaders.gl" });
|
|
87
87
|
globalThis.loaders ||= {};
|
|
@@ -93,27 +93,26 @@ function createLog() {
|
|
|
93
93
|
}
|
|
94
94
|
var import_log, VERSION, version, log;
|
|
95
95
|
var init_log = __esm({
|
|
96
|
-
"../loader-utils/
|
|
96
|
+
"../core/src/loader-utils/lib/log-utils/log.ts"() {
|
|
97
97
|
"use strict";
|
|
98
|
-
import_log = require("
|
|
98
|
+
import_log = require("probe.gl/log");
|
|
99
99
|
VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
100
100
|
version = VERSION[0] >= "0" && VERSION[0] <= "9" ? `v${VERSION}` : "";
|
|
101
101
|
log = createLog();
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
-
// ../loader-utils/
|
|
106
|
-
var isObject, isPureObject
|
|
105
|
+
// ../core/src/loader-utils/lib/javascript-utils/is-type.ts
|
|
106
|
+
var isObject, isPureObject;
|
|
107
107
|
var init_is_type = __esm({
|
|
108
|
-
"../loader-utils/
|
|
108
|
+
"../core/src/loader-utils/lib/javascript-utils/is-type.ts"() {
|
|
109
109
|
"use strict";
|
|
110
110
|
isObject = (value) => value !== null && typeof value === "object";
|
|
111
111
|
isPureObject = (value) => isObject(value) && value.constructor === {}.constructor;
|
|
112
|
-
isSharedArrayBuffer = (value) => typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer;
|
|
113
112
|
}
|
|
114
113
|
});
|
|
115
114
|
|
|
116
|
-
// ../loader-utils/
|
|
115
|
+
// ../core/src/loader-utils/lib/option-utils/merge-options.ts
|
|
117
116
|
function mergeOptions(baseOptions, newOptions) {
|
|
118
117
|
return mergeOptionsRecursively(baseOptions || {}, newOptions);
|
|
119
118
|
}
|
|
@@ -136,38 +135,25 @@ function mergeOptionsRecursively(baseOptions, newOptions, level = 0) {
|
|
|
136
135
|
return options;
|
|
137
136
|
}
|
|
138
137
|
var init_merge_options = __esm({
|
|
139
|
-
"../loader-utils/
|
|
138
|
+
"../core/src/loader-utils/lib/option-utils/merge-options.ts"() {
|
|
140
139
|
"use strict";
|
|
141
140
|
init_is_type();
|
|
142
141
|
}
|
|
143
142
|
});
|
|
144
143
|
|
|
145
|
-
// ../loader-utils/
|
|
144
|
+
// ../core/src/loader-utils/lib/module-utils/js-module-utils.ts
|
|
146
145
|
function registerJSModules(modules) {
|
|
147
146
|
globalThis.loaders ||= {};
|
|
148
147
|
globalThis.loaders.modules ||= {};
|
|
149
148
|
Object.assign(globalThis.loaders.modules, modules);
|
|
150
149
|
}
|
|
151
|
-
function getJSModule(name, caller) {
|
|
152
|
-
var _a, _b;
|
|
153
|
-
const module2 = (_b = (_a = globalThis.loaders) == null ? void 0 : _a.modules) == null ? void 0 : _b[name];
|
|
154
|
-
if (!module2) {
|
|
155
|
-
throw new Error(`${caller}: ${name} library not installed`);
|
|
156
|
-
}
|
|
157
|
-
return module2;
|
|
158
|
-
}
|
|
159
|
-
function getJSModuleOrNull(name) {
|
|
160
|
-
var _a, _b;
|
|
161
|
-
const module2 = (_b = (_a = globalThis.loaders) == null ? void 0 : _a.modules) == null ? void 0 : _b[name];
|
|
162
|
-
return module2 || null;
|
|
163
|
-
}
|
|
164
150
|
var init_js_module_utils = __esm({
|
|
165
|
-
"../loader-utils/
|
|
151
|
+
"../core/src/loader-utils/lib/module-utils/js-module-utils.ts"() {
|
|
166
152
|
"use strict";
|
|
167
153
|
}
|
|
168
154
|
});
|
|
169
155
|
|
|
170
|
-
// ../loader-utils/
|
|
156
|
+
// ../core/src/loader-utils/lib/binary-utils/array-buffer-utils.ts
|
|
171
157
|
function concatenateArrayBuffers(...sources) {
|
|
172
158
|
return concatenateArrayBuffersFromArray(sources);
|
|
173
159
|
}
|
|
@@ -185,12 +171,12 @@ function concatenateArrayBuffersFromArray(sources) {
|
|
|
185
171
|
return result.buffer;
|
|
186
172
|
}
|
|
187
173
|
var init_array_buffer_utils = __esm({
|
|
188
|
-
"../loader-utils/
|
|
174
|
+
"../core/src/loader-utils/lib/binary-utils/array-buffer-utils.ts"() {
|
|
189
175
|
"use strict";
|
|
190
176
|
}
|
|
191
177
|
});
|
|
192
178
|
|
|
193
|
-
// ../loader-utils/
|
|
179
|
+
// ../core/src/loader-utils/lib/iterators/async-iteration.ts
|
|
194
180
|
async function concatenateArrayBuffersAsync(asyncIterator) {
|
|
195
181
|
const arrayBuffers = [];
|
|
196
182
|
for await (const chunk of asyncIterator) {
|
|
@@ -215,13 +201,13 @@ function copyFromBuffer(buffer, byteOffset = 0, byteLength = buffer.byteLength -
|
|
|
215
201
|
return copy.buffer;
|
|
216
202
|
}
|
|
217
203
|
var init_async_iteration = __esm({
|
|
218
|
-
"../loader-utils/
|
|
204
|
+
"../core/src/loader-utils/lib/iterators/async-iteration.ts"() {
|
|
219
205
|
"use strict";
|
|
220
206
|
init_array_buffer_utils();
|
|
221
207
|
}
|
|
222
208
|
});
|
|
223
209
|
|
|
224
|
-
// ../loader-utils/
|
|
210
|
+
// ../core/src/loader-utils/lib/request-utils/authentication.ts
|
|
225
211
|
function resolveCredentials(credentials, authentications = []) {
|
|
226
212
|
if (credentials.every(isAuthentication)) return credentials;
|
|
227
213
|
return credentials.map((credential, index) => {
|
|
@@ -258,12 +244,12 @@ function isAuthentication(credential) {
|
|
|
258
244
|
return (credential.type === "header" || credential.type === "query-parameter") && typeof credential.name === "string" && (typeof credential.token === "string" || typeof credential.token === "function") && Array.isArray(credential.refreshStatusCodes);
|
|
259
245
|
}
|
|
260
246
|
var init_authentication = __esm({
|
|
261
|
-
"../loader-utils/
|
|
247
|
+
"../core/src/loader-utils/lib/request-utils/authentication.ts"() {
|
|
262
248
|
"use strict";
|
|
263
249
|
}
|
|
264
250
|
});
|
|
265
251
|
|
|
266
|
-
// ../loader-utils/
|
|
252
|
+
// ../core/src/loader-utils/lib/request-utils/request-credentials.ts
|
|
267
253
|
function createAuthenticatedFetch(options) {
|
|
268
254
|
const suppliedFetch = options.fetch || ((url, requestOptions) => fetch(url, requestOptions));
|
|
269
255
|
const existingMetadata = suppliedFetch[AUTHENTICATED_FETCH];
|
|
@@ -293,26 +279,28 @@ function createAuthenticatedFetch(options) {
|
|
|
293
279
|
);
|
|
294
280
|
for (const credential of requestCredentials) normalizeRequestOrigins(credential.origins);
|
|
295
281
|
const authenticatedFetch = async (url, requestOptions = {}) => {
|
|
296
|
-
var _a, _b, _c, _d;
|
|
282
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
297
283
|
requestOptions = mergeFetchOptions(fetchOptions, requestOptions);
|
|
298
|
-
|
|
284
|
+
(_a = requestOptions.signal) == null ? void 0 : _a.throwIfAborted();
|
|
299
285
|
if (!credentials.length) return baseFetch(url, requestOptions);
|
|
300
286
|
const resolvedURL = parseHTTPURL(url);
|
|
301
287
|
const authorization = resolvedURL ? await authorizeRequest(resolvedURL, requestOptions, tokenCredentials) : { url, options: requestOptions, credentials: [] };
|
|
302
288
|
const signedRequest = await authenticateRequest(authorization, requestCredentials, "request");
|
|
303
289
|
const response = await baseFetch(signedRequest.url, signedRequest.options);
|
|
304
|
-
const refreshableCredentials =
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
290
|
+
const refreshableCredentials = [];
|
|
291
|
+
for (const resolvedCredential of authorization.credentials) {
|
|
292
|
+
const { credential } = resolvedCredential;
|
|
293
|
+
if (typeof credential.token === "function" && (isReplayableRequest(requestOptions) || ((_b = credential.canReplayRequest) == null ? void 0 : _b.call(credential, url, requestOptions))) && (isReplayableRequest(signedRequest.options) || ((_c = credential.canReplayRequest) == null ? void 0 : _c.call(credential, signedRequest.url, signedRequest.options))) && (credential.refreshStatusCodes.includes(response.status) || await ((_d = credential.shouldRefresh) == null ? void 0 : _d.call(credential, response))))
|
|
294
|
+
refreshableCredentials.push(resolvedCredential);
|
|
295
|
+
}
|
|
296
|
+
const shouldRetrySignature = isReplayableRequest(requestOptions) && isReplayableRequest(signedRequest.options) && signedRequest.credentials.some(
|
|
308
297
|
(credential) => {
|
|
309
298
|
var _a2;
|
|
310
299
|
return (_a2 = credential.refreshStatusCodes) == null ? void 0 : _a2.includes(response.status);
|
|
311
300
|
}
|
|
312
301
|
);
|
|
313
|
-
if (!refreshableCredentials.length && !shouldRetrySignature
|
|
314
|
-
|
|
315
|
-
if ((_b = requestOptions.signal) == null ? void 0 : _b.aborted) throw createAbortError();
|
|
302
|
+
if (!refreshableCredentials.length && !shouldRetrySignature) return response;
|
|
303
|
+
(_e = requestOptions.signal) == null ? void 0 : _e.throwIfAborted();
|
|
316
304
|
const refreshedTokens = /* @__PURE__ */ new Map();
|
|
317
305
|
await Promise.all(
|
|
318
306
|
refreshableCredentials.map(async ({ credential }) => {
|
|
@@ -321,9 +309,9 @@ function createAuthenticatedFetch(options) {
|
|
|
321
309
|
})
|
|
322
310
|
);
|
|
323
311
|
if (!refreshedTokens.size && !shouldRetrySignature) return response;
|
|
324
|
-
await ((
|
|
312
|
+
await ((_f = response.body) == null ? void 0 : _f.cancel().catch(() => {
|
|
325
313
|
}));
|
|
326
|
-
|
|
314
|
+
(_g = requestOptions.signal) == null ? void 0 : _g.throwIfAborted();
|
|
327
315
|
const replayAuthorization = resolvedURL ? await authorizeRequest(
|
|
328
316
|
resolvedURL,
|
|
329
317
|
requestOptions,
|
|
@@ -358,9 +346,10 @@ function getAuthenticatedFetch(options = {}) {
|
|
|
358
346
|
} else {
|
|
359
347
|
fetchFunction = (url, requestOptions) => fetch(url, requestOptions);
|
|
360
348
|
}
|
|
349
|
+
const fetchOptions = typeof fetchOption === "object" && fetchOption ? fetchOption : void 0;
|
|
361
350
|
return createAuthenticatedFetch({
|
|
362
351
|
fetch: fetchFunction,
|
|
363
|
-
fetchOptions:
|
|
352
|
+
fetchOptions: options.signal ? { ...fetchOptions, signal: options.signal } : fetchOptions,
|
|
364
353
|
credentials: ((_b = options.core) == null ? void 0 : _b.credentials) || [],
|
|
365
354
|
authentications: (_c = options.core) == null ? void 0 : _c.authentications
|
|
366
355
|
});
|
|
@@ -380,7 +369,7 @@ async function authenticateRequest(request, credentials, reason, response) {
|
|
|
380
369
|
for (const credential of credentials) {
|
|
381
370
|
const origin = getRequestOrigin(request.url);
|
|
382
371
|
if (!origin || !normalizeRequestOrigins(credential.origins).includes(origin)) continue;
|
|
383
|
-
|
|
372
|
+
signal == null ? void 0 : signal.throwIfAborted();
|
|
384
373
|
const authenticatedRequest = await credential.authenticate({
|
|
385
374
|
url: request.url,
|
|
386
375
|
options: { ...request.options, headers: new Headers(request.options.headers) },
|
|
@@ -396,7 +385,7 @@ async function authenticateRequest(request, credentials, reason, response) {
|
|
|
396
385
|
};
|
|
397
386
|
appliedCredentials.push(credential);
|
|
398
387
|
}
|
|
399
|
-
|
|
388
|
+
signal == null ? void 0 : signal.throwIfAborted();
|
|
400
389
|
return { ...request, credentials: appliedCredentials };
|
|
401
390
|
}
|
|
402
391
|
function getRequestOrigin(url) {
|
|
@@ -486,12 +475,9 @@ function isReplayableRequest(options) {
|
|
|
486
475
|
if (!["GET", "HEAD", "OPTIONS", "PUT", "DELETE"].includes(method)) return false;
|
|
487
476
|
return !(options.body && typeof ReadableStream !== "undefined" && options.body instanceof ReadableStream);
|
|
488
477
|
}
|
|
489
|
-
function createAbortError() {
|
|
490
|
-
return new DOMException("The operation was aborted.", "AbortError");
|
|
491
|
-
}
|
|
492
478
|
var AUTHENTICATED_FETCH, refreshPromises;
|
|
493
479
|
var init_request_credentials = __esm({
|
|
494
|
-
"../loader-utils/
|
|
480
|
+
"../core/src/loader-utils/lib/request-utils/request-credentials.ts"() {
|
|
495
481
|
"use strict";
|
|
496
482
|
init_authentication();
|
|
497
483
|
AUTHENTICATED_FETCH = /* @__PURE__ */ Symbol("loaders.gl.authenticated-fetch");
|
|
@@ -499,7 +485,7 @@ var init_request_credentials = __esm({
|
|
|
499
485
|
}
|
|
500
486
|
});
|
|
501
487
|
|
|
502
|
-
// ../loader-utils/
|
|
488
|
+
// ../core/src/loader-utils/lib/path-utils/file-aliases.ts
|
|
503
489
|
function resolvePath(filename) {
|
|
504
490
|
for (const alias in fileAliases) {
|
|
505
491
|
if (filename.startsWith(alias)) {
|
|
@@ -514,41 +500,14 @@ function resolvePath(filename) {
|
|
|
514
500
|
}
|
|
515
501
|
var pathPrefix, fileAliases;
|
|
516
502
|
var init_file_aliases = __esm({
|
|
517
|
-
"../loader-utils/
|
|
503
|
+
"../core/src/loader-utils/lib/path-utils/file-aliases.ts"() {
|
|
518
504
|
"use strict";
|
|
519
505
|
pathPrefix = "";
|
|
520
506
|
fileAliases = {};
|
|
521
507
|
}
|
|
522
508
|
});
|
|
523
509
|
|
|
524
|
-
// ../loader-utils/
|
|
525
|
-
function ensureArrayBuffer(bufferSource) {
|
|
526
|
-
if (bufferSource instanceof ArrayBuffer) {
|
|
527
|
-
return bufferSource;
|
|
528
|
-
}
|
|
529
|
-
if (isSharedArrayBuffer(bufferSource)) {
|
|
530
|
-
return copyToArrayBuffer2(bufferSource);
|
|
531
|
-
}
|
|
532
|
-
const { buffer, byteOffset, byteLength } = bufferSource;
|
|
533
|
-
if (buffer instanceof ArrayBuffer && byteOffset === 0 && byteLength === buffer.byteLength) {
|
|
534
|
-
return buffer;
|
|
535
|
-
}
|
|
536
|
-
return copyToArrayBuffer2(buffer, byteOffset, byteLength);
|
|
537
|
-
}
|
|
538
|
-
function copyToArrayBuffer2(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
|
|
539
|
-
const view = new Uint8Array(buffer, byteOffset, byteLength);
|
|
540
|
-
const copy = new Uint8Array(view.length);
|
|
541
|
-
copy.set(view);
|
|
542
|
-
return copy.buffer;
|
|
543
|
-
}
|
|
544
|
-
var init_memory_conversion_utils = __esm({
|
|
545
|
-
"../loader-utils/src/lib/binary-utils/memory-conversion-utils.ts"() {
|
|
546
|
-
"use strict";
|
|
547
|
-
init_is_type();
|
|
548
|
-
}
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
// ../loader-utils/src/lib/sources/data-source.ts
|
|
510
|
+
// ../core/src/loader-utils/lib/sources/data-source.ts
|
|
552
511
|
function getFetchFunction(options) {
|
|
553
512
|
return getAuthenticatedFetch(options);
|
|
554
513
|
}
|
|
@@ -600,7 +559,7 @@ function unavailableCoreApiMethod(methodName) {
|
|
|
600
559
|
}
|
|
601
560
|
var UNAVAILABLE_CORE_API, DataSource;
|
|
602
561
|
var init_data_source = __esm({
|
|
603
|
-
"../loader-utils/
|
|
562
|
+
"../core/src/loader-utils/lib/sources/data-source.ts"() {
|
|
604
563
|
"use strict";
|
|
605
564
|
init_merge_options();
|
|
606
565
|
init_file_aliases();
|
|
@@ -691,24 +650,22 @@ var init_data_source = __esm({
|
|
|
691
650
|
}
|
|
692
651
|
});
|
|
693
652
|
|
|
694
|
-
// ../loader-utils/
|
|
695
|
-
var
|
|
696
|
-
"../loader-utils/
|
|
653
|
+
// ../core/src/loader-utils/index.ts
|
|
654
|
+
var init_loader_utils = __esm({
|
|
655
|
+
"../core/src/loader-utils/index.ts"() {
|
|
697
656
|
"use strict";
|
|
698
657
|
init_js_module_utils();
|
|
699
|
-
init_js_module_utils();
|
|
700
658
|
init_async_iteration();
|
|
701
|
-
init_memory_conversion_utils();
|
|
702
659
|
init_data_source();
|
|
703
660
|
}
|
|
704
661
|
});
|
|
705
662
|
|
|
706
663
|
// ../compression/src/lib/compression.ts
|
|
707
|
-
var CompressionTransform,
|
|
664
|
+
var CompressionTransform, Decompressor;
|
|
708
665
|
var init_compression = __esm({
|
|
709
666
|
"../compression/src/lib/compression.ts"() {
|
|
710
667
|
"use strict";
|
|
711
|
-
|
|
668
|
+
init_loader_utils();
|
|
712
669
|
CompressionTransform = class {
|
|
713
670
|
/** Preloads any dynamic libraries. May enable sync functions */
|
|
714
671
|
async preload(modules = {}) {
|
|
@@ -726,26 +683,6 @@ var init_compression = __esm({
|
|
|
726
683
|
return error;
|
|
727
684
|
}
|
|
728
685
|
};
|
|
729
|
-
Compressor = class extends CompressionTransform {
|
|
730
|
-
constructor(options) {
|
|
731
|
-
super();
|
|
732
|
-
this.compressBatches = this.compressBatches.bind(this);
|
|
733
|
-
}
|
|
734
|
-
/** Asynchronously compresses data. */
|
|
735
|
-
async compress(input) {
|
|
736
|
-
await this.preload();
|
|
737
|
-
return this.compressSync(input);
|
|
738
|
-
}
|
|
739
|
-
/** Synchronously compresses data. */
|
|
740
|
-
compressSync(input) {
|
|
741
|
-
throw new Error(`${this.name}: sync compression not supported`);
|
|
742
|
-
}
|
|
743
|
-
/** Compresses batches. */
|
|
744
|
-
async *compressBatches(asyncIterator) {
|
|
745
|
-
const input = await this.concatenate(asyncIterator);
|
|
746
|
-
yield this.compress(input);
|
|
747
|
-
}
|
|
748
|
-
};
|
|
749
686
|
Decompressor = class extends CompressionTransform {
|
|
750
687
|
constructor(options) {
|
|
751
688
|
super();
|
|
@@ -766,112 +703,6 @@ var init_compression = __esm({
|
|
|
766
703
|
yield this.decompress(input);
|
|
767
704
|
}
|
|
768
705
|
};
|
|
769
|
-
Compression = class extends Compressor {
|
|
770
|
-
constructor(options) {
|
|
771
|
-
super(options);
|
|
772
|
-
this.decompressBatches = this.decompressBatches.bind(this);
|
|
773
|
-
}
|
|
774
|
-
/** Asynchronously decompresses data. */
|
|
775
|
-
async decompress(input, size) {
|
|
776
|
-
await this.preload();
|
|
777
|
-
return this.decompressSync(input, size);
|
|
778
|
-
}
|
|
779
|
-
/** Synchronously decompresses data. */
|
|
780
|
-
decompressSync(input, size) {
|
|
781
|
-
throw new Error(`${this.name}: sync decompression not supported`);
|
|
782
|
-
}
|
|
783
|
-
/** Decompresses batches. */
|
|
784
|
-
async *decompressBatches(asyncIterator) {
|
|
785
|
-
const input = await this.concatenate(asyncIterator);
|
|
786
|
-
yield this.decompress(input);
|
|
787
|
-
}
|
|
788
|
-
};
|
|
789
|
-
}
|
|
790
|
-
});
|
|
791
|
-
|
|
792
|
-
// ../compression/src/lib/compression-stream.ts
|
|
793
|
-
async function compressWithNativeCompressionStream(input, format) {
|
|
794
|
-
const outputBatches = compressBatchesWithNativeCompressionStream([input], format);
|
|
795
|
-
return outputBatches ? await concatenateBatches(outputBatches) : null;
|
|
796
|
-
}
|
|
797
|
-
function compressBatchesWithNativeCompressionStream(inputBatches, format) {
|
|
798
|
-
const compressionStream = createNativeCompressionStream(format);
|
|
799
|
-
return compressionStream ? transformBatches(inputBatches, compressionStream) : null;
|
|
800
|
-
}
|
|
801
|
-
function createNativeCompressionStream(format) {
|
|
802
|
-
if (typeof globalThis.CompressionStream === "undefined") {
|
|
803
|
-
return null;
|
|
804
|
-
}
|
|
805
|
-
try {
|
|
806
|
-
const CompressionStreamConstructor = globalThis.CompressionStream;
|
|
807
|
-
return new CompressionStreamConstructor(format);
|
|
808
|
-
} catch (error) {
|
|
809
|
-
if (error instanceof TypeError || (error == null ? void 0 : error.name) === "TypeError") {
|
|
810
|
-
return null;
|
|
811
|
-
}
|
|
812
|
-
throw error;
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
async function* transformBatches(inputBatches, compressionStream) {
|
|
816
|
-
const writer = compressionStream.writable.getWriter();
|
|
817
|
-
const reader = compressionStream.readable.getReader();
|
|
818
|
-
const writePromise = writeBatches(inputBatches, writer);
|
|
819
|
-
writePromise.catch(() => {
|
|
820
|
-
});
|
|
821
|
-
let outputCompleted = false;
|
|
822
|
-
try {
|
|
823
|
-
while (true) {
|
|
824
|
-
const { done, value } = await reader.read();
|
|
825
|
-
if (done) {
|
|
826
|
-
outputCompleted = true;
|
|
827
|
-
break;
|
|
828
|
-
}
|
|
829
|
-
yield new Uint8Array(value).buffer;
|
|
830
|
-
}
|
|
831
|
-
await writePromise;
|
|
832
|
-
} finally {
|
|
833
|
-
if (!outputCompleted) {
|
|
834
|
-
await reader.cancel().catch(() => {
|
|
835
|
-
});
|
|
836
|
-
await writer.abort().catch(() => {
|
|
837
|
-
});
|
|
838
|
-
await writePromise.catch(() => {
|
|
839
|
-
});
|
|
840
|
-
}
|
|
841
|
-
reader.releaseLock();
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
async function writeBatches(inputBatches, writer) {
|
|
845
|
-
try {
|
|
846
|
-
for await (const inputBatch of inputBatches) {
|
|
847
|
-
await writer.write(new Uint8Array(inputBatch));
|
|
848
|
-
}
|
|
849
|
-
await writer.close();
|
|
850
|
-
} catch (error) {
|
|
851
|
-
await writer.abort(error).catch(() => {
|
|
852
|
-
});
|
|
853
|
-
throw error;
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
async function concatenateBatches(batches) {
|
|
857
|
-
const output = [];
|
|
858
|
-
let byteLength = 0;
|
|
859
|
-
for await (const batch of batches) {
|
|
860
|
-
const bytes = new Uint8Array(batch);
|
|
861
|
-
output.push(bytes);
|
|
862
|
-
byteLength += bytes.byteLength;
|
|
863
|
-
}
|
|
864
|
-
const result = new Uint8Array(byteLength);
|
|
865
|
-
let offset = 0;
|
|
866
|
-
for (const batch of output) {
|
|
867
|
-
result.set(batch, offset);
|
|
868
|
-
offset += batch.byteLength;
|
|
869
|
-
}
|
|
870
|
-
return result.buffer;
|
|
871
|
-
}
|
|
872
|
-
var init_compression_stream = __esm({
|
|
873
|
-
"../compression/src/lib/compression-stream.ts"() {
|
|
874
|
-
"use strict";
|
|
875
706
|
}
|
|
876
707
|
});
|
|
877
708
|
|
|
@@ -1092,48 +923,138 @@ var init_lazy_compression = __esm({
|
|
|
1092
923
|
}
|
|
1093
924
|
});
|
|
1094
925
|
|
|
1095
|
-
// ../compression/src/lib/
|
|
1096
|
-
async function*
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
926
|
+
// ../compression/src/lib/compress-utils-compression.ts
|
|
927
|
+
async function* transformBatches(stream, inputBatches, maximumOutputByteLength = Number.POSITIVE_INFINITY) {
|
|
928
|
+
let outputByteLength = 0;
|
|
929
|
+
try {
|
|
930
|
+
for await (const input of inputBatches) {
|
|
931
|
+
const output2 = stream.write(new Uint8Array(input));
|
|
932
|
+
if (output2.byteLength > maximumOutputByteLength - outputByteLength)
|
|
933
|
+
throw new RangeError("Decompressed output exceeds maxOutputByteLength");
|
|
934
|
+
outputByteLength += output2.byteLength;
|
|
935
|
+
if (output2.byteLength > 0) yield copyArrayBuffer(output2);
|
|
936
|
+
}
|
|
937
|
+
const output = stream.finish();
|
|
938
|
+
if (output.byteLength > maximumOutputByteLength - outputByteLength)
|
|
939
|
+
throw new RangeError("Decompressed output exceeds maxOutputByteLength");
|
|
940
|
+
if (output.byteLength > 0) yield copyArrayBuffer(output);
|
|
941
|
+
} finally {
|
|
942
|
+
stream.destroy();
|
|
1104
943
|
}
|
|
1105
|
-
processor.push(new Uint8Array(0), true);
|
|
1106
|
-
yield* chunks;
|
|
1107
944
|
}
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
945
|
+
function copyArrayBuffer(bytes) {
|
|
946
|
+
return bytes.slice().buffer;
|
|
947
|
+
}
|
|
948
|
+
function getDecompressOptions(options, size) {
|
|
949
|
+
const decodeOptions = {
|
|
950
|
+
...options.compressUtils,
|
|
951
|
+
...size === void 0 ? {} : { expectedSize: size }
|
|
952
|
+
};
|
|
953
|
+
const capacity = decodeOptions.expectedSize;
|
|
954
|
+
const maximum = getMaximumOutputByteLength(options);
|
|
955
|
+
if (capacity !== void 0 && (!Number.isSafeInteger(capacity) || capacity < 0 || capacity > maximum)) {
|
|
956
|
+
throw new RangeError("expectedSize exceeds the configured output capacity limit");
|
|
957
|
+
}
|
|
958
|
+
return decodeOptions;
|
|
959
|
+
}
|
|
960
|
+
function getMaximumOutputByteLength(options) {
|
|
961
|
+
const maximum = options.maxOutputByteLength ?? 512 * 1024 * 1024;
|
|
962
|
+
if (!Number.isSafeInteger(maximum) || maximum < 0 || maximum > 2147483647)
|
|
963
|
+
throw new RangeError("Invalid maxOutputByteLength");
|
|
964
|
+
return maximum;
|
|
965
|
+
}
|
|
966
|
+
function copyDecompressedOutput(bytes, options) {
|
|
967
|
+
if (bytes.byteLength > getMaximumOutputByteLength(options))
|
|
968
|
+
throw new RangeError("Decompressed output exceeds maxOutputByteLength");
|
|
969
|
+
return copyArrayBuffer(bytes);
|
|
970
|
+
}
|
|
971
|
+
var CompressUtilsDecompressor;
|
|
972
|
+
var init_compress_utils_compression = __esm({
|
|
973
|
+
"../compression/src/lib/compress-utils-compression.ts"() {
|
|
1118
974
|
"use strict";
|
|
1119
|
-
import_fflate = require("fflate");
|
|
1120
975
|
init_compression();
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
contentEncodings = ["gzip", "x-gzip"];
|
|
976
|
+
CompressUtilsDecompressor = class extends Decompressor {
|
|
977
|
+
name;
|
|
978
|
+
extensions;
|
|
979
|
+
contentEncodings;
|
|
1126
980
|
isSupported = true;
|
|
1127
|
-
|
|
981
|
+
options;
|
|
982
|
+
loadModule;
|
|
983
|
+
/** Module initialized for synchronous operations. */
|
|
984
|
+
module = null;
|
|
985
|
+
/** Shared import and WASM initialization for concurrent callers. */
|
|
986
|
+
modulePromise = null;
|
|
987
|
+
/** Creates a format-specific compress-utils decoder. */
|
|
988
|
+
constructor(metadata, loadModule, options = {}) {
|
|
1128
989
|
super(options);
|
|
990
|
+
this.name = metadata.name;
|
|
991
|
+
this.extensions = metadata.extensions || [];
|
|
992
|
+
this.contentEncodings = metadata.contentEncodings || [];
|
|
993
|
+
this.loadModule = loadModule;
|
|
994
|
+
this.options = options;
|
|
995
|
+
}
|
|
996
|
+
/** Imports and initializes the codec without loading the opposite direction. */
|
|
997
|
+
async preload(modules = {}) {
|
|
998
|
+
await super.preload(modules);
|
|
999
|
+
this.modulePromise ||= this.loadModule().then(async (module2) => {
|
|
1000
|
+
var _a;
|
|
1001
|
+
await ((_a = module2.preload) == null ? void 0 : _a.call(module2));
|
|
1002
|
+
this.module = module2;
|
|
1003
|
+
});
|
|
1004
|
+
try {
|
|
1005
|
+
await this.modulePromise;
|
|
1006
|
+
} catch (error) {
|
|
1007
|
+
this.modulePromise = null;
|
|
1008
|
+
throw error;
|
|
1009
|
+
}
|
|
1129
1010
|
}
|
|
1130
|
-
/**
|
|
1131
|
-
decompressSync(input) {
|
|
1132
|
-
|
|
1011
|
+
/** Runs synchronously after preload has initialized the WASM codec. */
|
|
1012
|
+
decompressSync(input, size) {
|
|
1013
|
+
var _a;
|
|
1014
|
+
if (!((_a = this.module) == null ? void 0 : _a.decompressSync))
|
|
1015
|
+
throw new Error(`${this.name}: call preload() before decompressSync()`);
|
|
1016
|
+
return copyDecompressedOutput(
|
|
1017
|
+
this.module.decompressSync(new Uint8Array(input), getDecompressOptions(this.options, size)),
|
|
1018
|
+
this.options
|
|
1019
|
+
);
|
|
1133
1020
|
}
|
|
1134
|
-
/** Decompresses
|
|
1021
|
+
/** Decompresses one buffer with the selected compress-utils decoder. */
|
|
1022
|
+
async decompress(input, size) {
|
|
1023
|
+
const decodeOptions = getDecompressOptions(this.options, size);
|
|
1024
|
+
await this.preload();
|
|
1025
|
+
const module2 = this.module;
|
|
1026
|
+
const output = await module2.decompress(new Uint8Array(input), decodeOptions);
|
|
1027
|
+
return copyDecompressedOutput(output, this.options);
|
|
1028
|
+
}
|
|
1029
|
+
/** Incrementally decompresses input batches with compress-utils. */
|
|
1135
1030
|
async *decompressBatches(inputBatches) {
|
|
1136
|
-
|
|
1031
|
+
await this.preload();
|
|
1032
|
+
const module2 = this.module;
|
|
1033
|
+
if (!module2.createDecompressStream) {
|
|
1034
|
+
yield await this.decompress(await this.concatenate(inputBatches));
|
|
1035
|
+
return;
|
|
1036
|
+
}
|
|
1037
|
+
const maximum = getMaximumOutputByteLength(this.options);
|
|
1038
|
+
const stream = await module2.createDecompressStream();
|
|
1039
|
+
yield* transformBatches(stream, inputBatches, maximum);
|
|
1040
|
+
}
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
});
|
|
1044
|
+
|
|
1045
|
+
// ../compression/src/gzip-decompressor-compress-utils.ts
|
|
1046
|
+
var GZipCompressUtilsDecompressor;
|
|
1047
|
+
var init_gzip_decompressor_compress_utils = __esm({
|
|
1048
|
+
"../compression/src/gzip-decompressor-compress-utils.ts"() {
|
|
1049
|
+
"use strict";
|
|
1050
|
+
init_compress_utils_compression();
|
|
1051
|
+
GZipCompressUtilsDecompressor = class extends CompressUtilsDecompressor {
|
|
1052
|
+
constructor(options = {}) {
|
|
1053
|
+
super(
|
|
1054
|
+
{ name: "gzip", extensions: ["gz", "gzip"], contentEncodings: ["gzip", "x-gzip"] },
|
|
1055
|
+
() => import("compress-utils/gzip/decompress"),
|
|
1056
|
+
options
|
|
1057
|
+
);
|
|
1137
1058
|
}
|
|
1138
1059
|
};
|
|
1139
1060
|
}
|
|
@@ -1148,23 +1069,18 @@ var GZipDecompressor;
|
|
|
1148
1069
|
var init_gzip_decompressor = __esm({
|
|
1149
1070
|
"../compression/src/gzip-decompressor.ts"() {
|
|
1150
1071
|
"use strict";
|
|
1151
|
-
|
|
1072
|
+
init_gzip_decompressor_compress_utils();
|
|
1152
1073
|
init_decompression_stream();
|
|
1153
|
-
GZipDecompressor = class extends
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
super(options);
|
|
1157
|
-
this.options = options;
|
|
1158
|
-
}
|
|
1159
|
-
/** Decompresses with the built-in stream when available, then falls back to fflate. */
|
|
1160
|
-
async decompress(input) {
|
|
1074
|
+
GZipDecompressor = class extends GZipCompressUtilsDecompressor {
|
|
1075
|
+
/** Decompresses with native streams when available, otherwise lazily initializes WASM. */
|
|
1076
|
+
async decompress(input, size) {
|
|
1161
1077
|
if (this.options.useNative !== false) {
|
|
1162
1078
|
const output = await decompressWithNativeDecompressionStream(input, "gzip");
|
|
1163
1079
|
if (output) return output;
|
|
1164
1080
|
}
|
|
1165
|
-
return
|
|
1081
|
+
return super.decompress(input, size);
|
|
1166
1082
|
}
|
|
1167
|
-
/**
|
|
1083
|
+
/** Streams native batches when available, otherwise uses the WASM stream. */
|
|
1168
1084
|
async *decompressBatches(inputBatches) {
|
|
1169
1085
|
if (this.options.useNative !== false) {
|
|
1170
1086
|
const output = decompressBatchesWithNativeDecompressionStream(inputBatches, "gzip");
|
|
@@ -1179,126 +1095,19 @@ var init_gzip_decompressor = __esm({
|
|
|
1179
1095
|
}
|
|
1180
1096
|
});
|
|
1181
1097
|
|
|
1182
|
-
// ../compression/src/zstd-decompressor-
|
|
1183
|
-
var
|
|
1184
|
-
var
|
|
1185
|
-
"../compression/src/zstd-decompressor-
|
|
1098
|
+
// ../compression/src/zstd-decompressor-compress-utils.ts
|
|
1099
|
+
var ZstdCompressUtilsDecompressor;
|
|
1100
|
+
var init_zstd_decompressor_compress_utils = __esm({
|
|
1101
|
+
"../compression/src/zstd-decompressor-compress-utils.ts"() {
|
|
1186
1102
|
"use strict";
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
ZstdFzstdDecompressor = class extends Decompressor {
|
|
1190
|
-
name = "zstd";
|
|
1191
|
-
extensions = ["zst"];
|
|
1192
|
-
contentEncodings = ["zstd"];
|
|
1193
|
-
isSupported = true;
|
|
1194
|
-
constructor(options = {}) {
|
|
1195
|
-
super(options);
|
|
1196
|
-
}
|
|
1197
|
-
/** Decompresses one Zstandard frame synchronously. */
|
|
1198
|
-
decompressSync(input) {
|
|
1199
|
-
return (0, import_fzstd.decompress)(new Uint8Array(input)).slice().buffer;
|
|
1200
|
-
}
|
|
1201
|
-
};
|
|
1202
|
-
}
|
|
1203
|
-
});
|
|
1204
|
-
|
|
1205
|
-
// ../compression/src/zstd-fallback.ts
|
|
1206
|
-
var zstd_fallback_exports = {};
|
|
1207
|
-
__export(zstd_fallback_exports, {
|
|
1208
|
-
decompressZstd: () => decompressZstd
|
|
1209
|
-
});
|
|
1210
|
-
function decompressZstd(input) {
|
|
1211
|
-
return (0, import_fzstd2.decompress)(input);
|
|
1212
|
-
}
|
|
1213
|
-
var import_fzstd2;
|
|
1214
|
-
var init_zstd_fallback = __esm({
|
|
1215
|
-
"../compression/src/zstd-fallback.ts"() {
|
|
1216
|
-
"use strict";
|
|
1217
|
-
import_fzstd2 = require("fzstd");
|
|
1218
|
-
}
|
|
1219
|
-
});
|
|
1220
|
-
|
|
1221
|
-
// ../compression/src/lib/zstd-compression.ts
|
|
1222
|
-
var zstd_compression_exports = {};
|
|
1223
|
-
__export(zstd_compression_exports, {
|
|
1224
|
-
ZstdCompression: () => ZstdCompression
|
|
1225
|
-
});
|
|
1226
|
-
var CHUNK_SIZE, zstdPromise, zstd, ZstdCompression;
|
|
1227
|
-
var init_zstd_compression = __esm({
|
|
1228
|
-
"../compression/src/lib/zstd-compression.ts"() {
|
|
1229
|
-
"use strict";
|
|
1230
|
-
init_compression();
|
|
1231
|
-
init_src();
|
|
1232
|
-
init_compression_stream();
|
|
1233
|
-
init_decompression_stream();
|
|
1234
|
-
CHUNK_SIZE = 1e6;
|
|
1235
|
-
ZstdCompression = class extends Compression {
|
|
1236
|
-
name = "zstd";
|
|
1237
|
-
extensions = [];
|
|
1238
|
-
contentEncodings = [];
|
|
1239
|
-
isSupported = true;
|
|
1240
|
-
options;
|
|
1241
|
-
/**
|
|
1242
|
-
* zstd-codec is an injectable dependency due to big size
|
|
1243
|
-
* @param options
|
|
1244
|
-
*/
|
|
1103
|
+
init_compress_utils_compression();
|
|
1104
|
+
ZstdCompressUtilsDecompressor = class extends CompressUtilsDecompressor {
|
|
1245
1105
|
constructor(options = {}) {
|
|
1246
|
-
super(
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
registerJSModules(modules);
|
|
1252
|
-
const ZstdCodec = getJSModuleOrNull("zstd-codec");
|
|
1253
|
-
if (!zstdPromise && ZstdCodec) {
|
|
1254
|
-
zstdPromise = new Promise((resolve) => ZstdCodec.run((zstd2) => resolve(zstd2)));
|
|
1255
|
-
}
|
|
1256
|
-
if (zstdPromise) {
|
|
1257
|
-
zstd = await zstdPromise;
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
compressSync(input) {
|
|
1261
|
-
getJSModule("zstd-codec", this.name);
|
|
1262
|
-
const simpleZstd = new zstd.Simple();
|
|
1263
|
-
const inputArray = new Uint8Array(input);
|
|
1264
|
-
return simpleZstd.compress(inputArray).buffer;
|
|
1265
|
-
}
|
|
1266
|
-
async compress(input) {
|
|
1267
|
-
var _a;
|
|
1268
|
-
if (this.options.useNative !== false && ((_a = this.options.zstd) == null ? void 0 : _a.useNative) !== false) {
|
|
1269
|
-
const nativeOutput = await compressWithNativeCompressionStream(input, "zstd");
|
|
1270
|
-
if (nativeOutput) return nativeOutput;
|
|
1271
|
-
}
|
|
1272
|
-
await this.preload();
|
|
1273
|
-
return this.compressSync(input);
|
|
1274
|
-
}
|
|
1275
|
-
decompressSync(input) {
|
|
1276
|
-
getJSModule("zstd-codec", this.name);
|
|
1277
|
-
const simpleZstd = new zstd.Simple();
|
|
1278
|
-
const inputArray = new Uint8Array(input);
|
|
1279
|
-
return simpleZstd.decompress(inputArray).buffer;
|
|
1280
|
-
}
|
|
1281
|
-
async decompress(input, size) {
|
|
1282
|
-
var _a;
|
|
1283
|
-
if (!getJSModuleOrNull("zstd-codec") && this.options.useNative !== false && ((_a = this.options.zstd) == null ? void 0 : _a.useNative) !== false) {
|
|
1284
|
-
const nativeOutput = await decompressWithNativeDecompressionStream(input, "zstd");
|
|
1285
|
-
if (nativeOutput) return nativeOutput;
|
|
1286
|
-
}
|
|
1287
|
-
await this.preload();
|
|
1288
|
-
const inputArray = new Uint8Array(input);
|
|
1289
|
-
if (!zstd) {
|
|
1290
|
-
const { decompressZstd: decompressZstd2 } = await Promise.resolve().then(() => (init_zstd_fallback(), zstd_fallback_exports));
|
|
1291
|
-
return ensureArrayBuffer(decompressZstd2(inputArray));
|
|
1292
|
-
}
|
|
1293
|
-
const simpleZstd = new zstd.Streaming();
|
|
1294
|
-
const chunks = [];
|
|
1295
|
-
for (let i = 0; i <= inputArray.length; i += CHUNK_SIZE) {
|
|
1296
|
-
const chunkView = inputArray.subarray(i, i + CHUNK_SIZE);
|
|
1297
|
-
const chunkArrayBuffer = ensureArrayBuffer(chunkView);
|
|
1298
|
-
chunks.push(new Uint8Array(chunkArrayBuffer));
|
|
1299
|
-
}
|
|
1300
|
-
const decompressResult = await simpleZstd.decompressChunks(chunks);
|
|
1301
|
-
return decompressResult.buffer;
|
|
1106
|
+
super(
|
|
1107
|
+
{ name: "zstd", extensions: ["zst"], contentEncodings: ["zstd"] },
|
|
1108
|
+
() => import("compress-utils/zstd/decompress"),
|
|
1109
|
+
options
|
|
1110
|
+
);
|
|
1302
1111
|
}
|
|
1303
1112
|
};
|
|
1304
1113
|
}
|
|
@@ -1313,48 +1122,18 @@ var ZstdDecompressor;
|
|
|
1313
1122
|
var init_zstd_decompressor = __esm({
|
|
1314
1123
|
"../compression/src/zstd-decompressor.ts"() {
|
|
1315
1124
|
"use strict";
|
|
1316
|
-
|
|
1125
|
+
init_zstd_decompressor_compress_utils();
|
|
1317
1126
|
init_decompression_stream();
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
compatibility = null;
|
|
1322
|
-
constructor(options = {}) {
|
|
1323
|
-
super(options);
|
|
1324
|
-
this.options = options;
|
|
1325
|
-
registerJSModules(options.modules);
|
|
1326
|
-
}
|
|
1327
|
-
/** Preloads an injected zstd-codec implementation when supplied. */
|
|
1328
|
-
async preload(modules = {}) {
|
|
1329
|
-
registerJSModules(modules);
|
|
1330
|
-
if (getJSModuleOrNull("zstd-codec")) {
|
|
1331
|
-
const { ZstdCompression: ZstdCompression2 } = await Promise.resolve().then(() => (init_zstd_compression(), zstd_compression_exports));
|
|
1332
|
-
this.compatibility ||= new ZstdCompression2(this.options);
|
|
1333
|
-
await this.compatibility.preload(modules);
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
/** Decompresses with the built-in stream when available, then falls back to fzstd. */
|
|
1337
|
-
async decompress(input) {
|
|
1127
|
+
ZstdDecompressor = class extends ZstdCompressUtilsDecompressor {
|
|
1128
|
+
/** Decompresses with native streams when available, otherwise lazily initializes WASM. */
|
|
1129
|
+
async decompress(input, size) {
|
|
1338
1130
|
if (this.options.useNative !== false) {
|
|
1339
1131
|
const output = await decompressWithNativeDecompressionStream(input, "zstd");
|
|
1340
1132
|
if (output) return output;
|
|
1341
1133
|
}
|
|
1342
|
-
|
|
1343
|
-
await this.preload(this.options.modules);
|
|
1344
|
-
}
|
|
1345
|
-
return this.decompressSync(input);
|
|
1346
|
-
}
|
|
1347
|
-
/** Decompresses with a preloaded zstd-codec implementation or compact fzstd. */
|
|
1348
|
-
decompressSync(input) {
|
|
1349
|
-
if (this.compatibility) {
|
|
1350
|
-
return this.compatibility.decompressSync(input);
|
|
1351
|
-
}
|
|
1352
|
-
if (getJSModuleOrNull("zstd-codec")) {
|
|
1353
|
-
throw new Error("zstd: call preload() before synchronous decompression with zstd-codec");
|
|
1354
|
-
}
|
|
1355
|
-
return super.decompressSync(input);
|
|
1134
|
+
return super.decompress(input, size);
|
|
1356
1135
|
}
|
|
1357
|
-
/**
|
|
1136
|
+
/** Streams native batches when available, otherwise uses the WASM stream. */
|
|
1358
1137
|
async *decompressBatches(inputBatches) {
|
|
1359
1138
|
if (this.options.useNative !== false) {
|
|
1360
1139
|
const output = decompressBatchesWithNativeDecompressionStream(inputBatches, "zstd");
|
|
@@ -1363,10 +1142,6 @@ var init_zstd_decompressor = __esm({
|
|
|
1363
1142
|
return;
|
|
1364
1143
|
}
|
|
1365
1144
|
}
|
|
1366
|
-
if (getJSModuleOrNull("zstd-codec")) {
|
|
1367
|
-
yield this.decompress(await this.concatenate(inputBatches));
|
|
1368
|
-
return;
|
|
1369
|
-
}
|
|
1370
1145
|
yield* super.decompressBatches(inputBatches);
|
|
1371
1146
|
}
|
|
1372
1147
|
};
|
|
@@ -1379,7 +1154,6 @@ var init_default_codecs = __esm({
|
|
|
1379
1154
|
"../compression/src/default-codecs.ts"() {
|
|
1380
1155
|
"use strict";
|
|
1381
1156
|
init_lazy_compression();
|
|
1382
|
-
init_src();
|
|
1383
1157
|
GZIP = { name: "gzip", extensions: ["gz"], contentEncodings: ["gzip"] };
|
|
1384
1158
|
ZSTD = { name: "zstd", extensions: ["zst"], contentEncodings: ["zstd"] };
|
|
1385
1159
|
GZipDecompressor2 = class extends LazyDecompressor {
|
|
@@ -1398,11 +1172,7 @@ var init_default_codecs = __esm({
|
|
|
1398
1172
|
ZSTD,
|
|
1399
1173
|
async () => (await Promise.resolve().then(() => (init_zstd_decompressor(), zstd_decompressor_exports))).ZstdDecompressor,
|
|
1400
1174
|
options,
|
|
1401
|
-
"zstd"
|
|
1402
|
-
(preloadOptions) => {
|
|
1403
|
-
var _a;
|
|
1404
|
-
return !((_a = preloadOptions.modules) == null ? void 0 : _a["zstd-codec"]) && !getJSModuleOrNull("zstd-codec");
|
|
1405
|
-
}
|
|
1175
|
+
"zstd"
|
|
1406
1176
|
);
|
|
1407
1177
|
}
|
|
1408
1178
|
};
|
|
@@ -1410,7 +1180,7 @@ var init_default_codecs = __esm({
|
|
|
1410
1180
|
});
|
|
1411
1181
|
|
|
1412
1182
|
// ../compression/src/index.ts
|
|
1413
|
-
var
|
|
1183
|
+
var init_src = __esm({
|
|
1414
1184
|
"../compression/src/index.ts"() {
|
|
1415
1185
|
"use strict";
|
|
1416
1186
|
init_default_codecs();
|
|
@@ -1948,7 +1718,7 @@ var SPZ_HEADER_BYTE_LENGTH, SPZ_MAGIC, SPZ_VERSION, SPZ_EXTENSION_FLAG, SPZ_COLO
|
|
|
1948
1718
|
var init_parse_spz = __esm({
|
|
1949
1719
|
"dist/lib/parse-spz.js"() {
|
|
1950
1720
|
"use strict";
|
|
1951
|
-
|
|
1721
|
+
init_src();
|
|
1952
1722
|
init_splats_arrow_table();
|
|
1953
1723
|
init_splat_utils();
|
|
1954
1724
|
SPZ_HEADER_BYTE_LENGTH = 32;
|
|
@@ -2051,7 +1821,7 @@ var init_splat_loader_types = __esm({
|
|
|
2051
1821
|
"dist/splat-loader-types.js"() {
|
|
2052
1822
|
"use strict";
|
|
2053
1823
|
init_splats_format();
|
|
2054
|
-
VERSION2 = true ? "5.0.0-
|
|
1824
|
+
VERSION2 = true ? "5.0.0-beta.1" : "latest";
|
|
2055
1825
|
SPLATLoader = {
|
|
2056
1826
|
dataType: null,
|
|
2057
1827
|
batchType: null,
|
|
@@ -2376,7 +2146,7 @@ var init_ksplat_loader_types = __esm({
|
|
|
2376
2146
|
"dist/ksplat-loader-types.js"() {
|
|
2377
2147
|
"use strict";
|
|
2378
2148
|
init_splats_format();
|
|
2379
|
-
VERSION3 = true ? "5.0.0-
|
|
2149
|
+
VERSION3 = true ? "5.0.0-beta.1" : "latest";
|
|
2380
2150
|
KSPLATLoader = {
|
|
2381
2151
|
dataType: null,
|
|
2382
2152
|
batchType: null,
|
|
@@ -2421,7 +2191,7 @@ var init_spz_loader_types = __esm({
|
|
|
2421
2191
|
"dist/spz-loader-types.js"() {
|
|
2422
2192
|
"use strict";
|
|
2423
2193
|
init_splats_format();
|
|
2424
|
-
VERSION4 = true ? "5.0.0-
|
|
2194
|
+
VERSION4 = true ? "5.0.0-beta.1" : "latest";
|
|
2425
2195
|
SPZLoader = {
|
|
2426
2196
|
dataType: null,
|
|
2427
2197
|
batchType: null,
|
|
@@ -2595,34 +2365,19 @@ var init_parse_rad = __esm({
|
|
|
2595
2365
|
}
|
|
2596
2366
|
});
|
|
2597
2367
|
|
|
2598
|
-
// ../compression/src/deflate-decompressor-
|
|
2599
|
-
var
|
|
2600
|
-
var
|
|
2601
|
-
"../compression/src/deflate-decompressor-
|
|
2368
|
+
// ../compression/src/deflate-decompressor-compress-utils.ts
|
|
2369
|
+
var DeflateCompressUtilsDecompressor;
|
|
2370
|
+
var init_deflate_decompressor_compress_utils = __esm({
|
|
2371
|
+
"../compression/src/deflate-decompressor-compress-utils.ts"() {
|
|
2602
2372
|
"use strict";
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
init_fflate_stream();
|
|
2606
|
-
DeflateFflateDecompressor = class extends Decompressor {
|
|
2607
|
-
name = "deflate";
|
|
2608
|
-
extensions = [];
|
|
2609
|
-
contentEncodings = ["deflate"];
|
|
2610
|
-
isSupported = true;
|
|
2611
|
-
options;
|
|
2373
|
+
init_compress_utils_compression();
|
|
2374
|
+
DeflateCompressUtilsDecompressor = class extends CompressUtilsDecompressor {
|
|
2612
2375
|
constructor(options = {}) {
|
|
2613
|
-
super(
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
const bytes = new Uint8Array(input);
|
|
2619
|
-
const output = this.options.raw ? (0, import_fflate2.inflateSync)(bytes) : (0, import_fflate2.unzlibSync)(bytes);
|
|
2620
|
-
return output.slice().buffer;
|
|
2621
|
-
}
|
|
2622
|
-
/** Decompresses DEFLATE batches incrementally. */
|
|
2623
|
-
async *decompressBatches(inputBatches) {
|
|
2624
|
-
const processor = this.options.raw ? new import_fflate2.Inflate() : new import_fflate2.Unzlib();
|
|
2625
|
-
yield* transformFflateBatches(processor, inputBatches);
|
|
2376
|
+
super(
|
|
2377
|
+
{ name: "deflate", contentEncodings: ["deflate"] },
|
|
2378
|
+
() => options.raw ? import("compress-utils/deflate/decompress") : import("compress-utils/zlib/decompress"),
|
|
2379
|
+
options
|
|
2380
|
+
);
|
|
2626
2381
|
}
|
|
2627
2382
|
};
|
|
2628
2383
|
}
|
|
@@ -2633,26 +2388,27 @@ var DeflateDecompressor2;
|
|
|
2633
2388
|
var init_deflate_decompressor = __esm({
|
|
2634
2389
|
"../compression/src/deflate-decompressor.ts"() {
|
|
2635
2390
|
"use strict";
|
|
2636
|
-
|
|
2391
|
+
init_deflate_decompressor_compress_utils();
|
|
2637
2392
|
init_decompression_stream();
|
|
2638
|
-
DeflateDecompressor2 = class extends
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
}
|
|
2642
|
-
/** Decompresses with the built-in stream when available, then falls back to fflate. */
|
|
2643
|
-
async decompress(input) {
|
|
2393
|
+
DeflateDecompressor2 = class extends DeflateCompressUtilsDecompressor {
|
|
2394
|
+
/** Decompresses with native streams when available, otherwise lazily initializes WASM. */
|
|
2395
|
+
async decompress(input, size) {
|
|
2644
2396
|
if (this.options.useNative !== false) {
|
|
2645
|
-
const
|
|
2646
|
-
|
|
2397
|
+
const output = await decompressWithNativeDecompressionStream(
|
|
2398
|
+
input,
|
|
2399
|
+
this.options.raw ? "deflate-raw" : "deflate"
|
|
2400
|
+
);
|
|
2647
2401
|
if (output) return output;
|
|
2648
2402
|
}
|
|
2649
|
-
return
|
|
2403
|
+
return super.decompress(input, size);
|
|
2650
2404
|
}
|
|
2651
|
-
/**
|
|
2405
|
+
/** Streams native batches when available, otherwise uses the WASM stream. */
|
|
2652
2406
|
async *decompressBatches(inputBatches) {
|
|
2653
2407
|
if (this.options.useNative !== false) {
|
|
2654
|
-
const
|
|
2655
|
-
|
|
2408
|
+
const output = decompressBatchesWithNativeDecompressionStream(
|
|
2409
|
+
inputBatches,
|
|
2410
|
+
this.options.raw ? "deflate-raw" : "deflate"
|
|
2411
|
+
);
|
|
2656
2412
|
if (output) {
|
|
2657
2413
|
yield* output;
|
|
2658
2414
|
return;
|
|
@@ -2665,6 +2421,9 @@ var init_deflate_decompressor = __esm({
|
|
|
2665
2421
|
});
|
|
2666
2422
|
|
|
2667
2423
|
// dist/lib/parse-rad-chunk.js
|
|
2424
|
+
async function preloadRADCompression() {
|
|
2425
|
+
await Promise.all([RAD_PROPERTY_DEFLATE.preload(), RAD_PROPERTY_RAW_DEFLATE.preload()]);
|
|
2426
|
+
}
|
|
2668
2427
|
function parseRADChunk(data, options) {
|
|
2669
2428
|
return makeGaussianSplatsArrowTable(parseRADChunkToGaussianSplats(data, options));
|
|
2670
2429
|
}
|
|
@@ -2872,7 +2631,7 @@ function getRADPropertyBytes(bytes, metadata, property) {
|
|
|
2872
2631
|
return decompressRADProperty(propertyBytes, property.property);
|
|
2873
2632
|
}
|
|
2874
2633
|
function decompressRADProperty(bytes, propertyName) {
|
|
2875
|
-
const arrayBuffer =
|
|
2634
|
+
const arrayBuffer = copyToArrayBuffer2(bytes);
|
|
2876
2635
|
try {
|
|
2877
2636
|
return new Uint8Array(RAD_PROPERTY_DEFLATE.decompressSync(arrayBuffer));
|
|
2878
2637
|
} catch {
|
|
@@ -3114,7 +2873,7 @@ function getSplatEncodingMaximum(splatEncoding, propertyName) {
|
|
|
3114
2873
|
function normalizeColorByte2(value) {
|
|
3115
2874
|
return Math.round(Math.min(Math.max(value, 0), 1) * 255);
|
|
3116
2875
|
}
|
|
3117
|
-
function
|
|
2876
|
+
function copyToArrayBuffer2(bytes) {
|
|
3118
2877
|
const copy = new Uint8Array(bytes.byteLength);
|
|
3119
2878
|
copy.set(bytes);
|
|
3120
2879
|
return copy.buffer;
|
|
@@ -3143,6 +2902,7 @@ __export(rad_loader_exports, {
|
|
|
3143
2902
|
parseRADChunkHeader: () => parseRADChunkHeader,
|
|
3144
2903
|
parseRADChunkToGaussianSplats: () => parseRADChunkToGaussianSplats,
|
|
3145
2904
|
parseRADHeader: () => parseRADHeader,
|
|
2905
|
+
preloadRADCompression: () => preloadRADCompression,
|
|
3146
2906
|
tryParseRADHeader: () => tryParseRADHeader
|
|
3147
2907
|
});
|
|
3148
2908
|
var _RADLoaderPreload, RADLoaderMetadataWithoutPreload, RADLoaderWithParser;
|
|
@@ -3172,7 +2932,7 @@ var init_rad_loader_types = __esm({
|
|
|
3172
2932
|
"dist/rad-loader-types.js"() {
|
|
3173
2933
|
"use strict";
|
|
3174
2934
|
init_splats_format();
|
|
3175
|
-
VERSION5 = true ? "5.0.0-
|
|
2935
|
+
VERSION5 = true ? "5.0.0-beta.1" : "latest";
|
|
3176
2936
|
RADLoader = {
|
|
3177
2937
|
dataType: null,
|
|
3178
2938
|
batchType: null,
|
|
@@ -3210,14 +2970,14 @@ init_spz_loader_types();
|
|
|
3210
2970
|
init_rad_loader_types();
|
|
3211
2971
|
|
|
3212
2972
|
// dist/rad-source-loader.js
|
|
3213
|
-
|
|
2973
|
+
init_loader_utils();
|
|
3214
2974
|
init_splats_format();
|
|
3215
2975
|
init_parse_rad();
|
|
3216
2976
|
init_parse_rad_chunk();
|
|
3217
2977
|
init_splats_arrow_table();
|
|
3218
2978
|
var DEFAULT_RAD_HEADER_BYTE_LENGTHS = [64 * 1024, 256 * 1024, 1024 * 1024];
|
|
3219
2979
|
var DEFAULT_RAD_MAX_CONCURRENT_CHUNK_REQUESTS = 4;
|
|
3220
|
-
var VERSION6 = true ? "5.0.0-
|
|
2980
|
+
var VERSION6 = true ? "5.0.0-beta.1" : "latest";
|
|
3221
2981
|
var RADSourceLoader = {
|
|
3222
2982
|
dataType: null,
|
|
3223
2983
|
batchType: null,
|
|
@@ -3313,11 +3073,13 @@ var RADSource = class extends DataSource {
|
|
|
3313
3073
|
/** Fetches and decodes one RADC chunk into raw Gaussian splat arrays. */
|
|
3314
3074
|
async getChunkSplats(chunkIndex, options = {}) {
|
|
3315
3075
|
const metadata = await this.getMetadata();
|
|
3076
|
+
await preloadRADCompression();
|
|
3316
3077
|
return parseRADChunkToGaussianSplats(await this.getChunk(chunkIndex, options), this._getChunkDecodeOptions(metadata, options));
|
|
3317
3078
|
}
|
|
3318
3079
|
/** Fetches and decodes one RADC chunk into a Mesh Arrow table. */
|
|
3319
3080
|
async getChunkTable(chunkIndex, options = {}) {
|
|
3320
3081
|
const metadata = await this.getMetadata();
|
|
3082
|
+
await preloadRADCompression();
|
|
3321
3083
|
return parseRADChunk(await this.getChunk(chunkIndex, options), this._getChunkDecodeOptions(metadata, options));
|
|
3322
3084
|
}
|
|
3323
3085
|
/** Iterates decoded RADC chunks as Mesh Arrow tables. */
|