@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/dist.dev.js
CHANGED
|
@@ -1408,6 +1408,308 @@ var __exports__ = (() => {
|
|
|
1408
1408
|
}
|
|
1409
1409
|
});
|
|
1410
1410
|
|
|
1411
|
+
// ../compression/src/lib/compression-stream.ts
|
|
1412
|
+
async function compressWithNativeCompressionStream(input2, format) {
|
|
1413
|
+
const outputBatches = compressBatchesWithNativeCompressionStream([input2], format);
|
|
1414
|
+
return outputBatches ? await concatenateBatches(outputBatches) : null;
|
|
1415
|
+
}
|
|
1416
|
+
function compressBatchesWithNativeCompressionStream(inputBatches, format) {
|
|
1417
|
+
const compressionStream = createNativeCompressionStream(format);
|
|
1418
|
+
return compressionStream ? transformBatches(inputBatches, compressionStream) : null;
|
|
1419
|
+
}
|
|
1420
|
+
function createNativeCompressionStream(format) {
|
|
1421
|
+
if (typeof globalThis.CompressionStream === "undefined") {
|
|
1422
|
+
return null;
|
|
1423
|
+
}
|
|
1424
|
+
try {
|
|
1425
|
+
const CompressionStreamConstructor = globalThis.CompressionStream;
|
|
1426
|
+
return new CompressionStreamConstructor(format);
|
|
1427
|
+
} catch (error62) {
|
|
1428
|
+
if (error62 instanceof TypeError || error62?.name === "TypeError") {
|
|
1429
|
+
return null;
|
|
1430
|
+
}
|
|
1431
|
+
throw error62;
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
async function* transformBatches(inputBatches, compressionStream) {
|
|
1435
|
+
const writer = compressionStream.writable.getWriter();
|
|
1436
|
+
const reader = compressionStream.readable.getReader();
|
|
1437
|
+
const writePromise = writeBatches(inputBatches, writer);
|
|
1438
|
+
writePromise.catch(() => {
|
|
1439
|
+
});
|
|
1440
|
+
let outputCompleted = false;
|
|
1441
|
+
try {
|
|
1442
|
+
while (true) {
|
|
1443
|
+
const { done, value } = await reader.read();
|
|
1444
|
+
if (done) {
|
|
1445
|
+
outputCompleted = true;
|
|
1446
|
+
break;
|
|
1447
|
+
}
|
|
1448
|
+
yield new Uint8Array(value).buffer;
|
|
1449
|
+
}
|
|
1450
|
+
await writePromise;
|
|
1451
|
+
} finally {
|
|
1452
|
+
if (!outputCompleted) {
|
|
1453
|
+
await reader.cancel().catch(() => {
|
|
1454
|
+
});
|
|
1455
|
+
await writer.abort().catch(() => {
|
|
1456
|
+
});
|
|
1457
|
+
await writePromise.catch(() => {
|
|
1458
|
+
});
|
|
1459
|
+
}
|
|
1460
|
+
reader.releaseLock();
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
async function writeBatches(inputBatches, writer) {
|
|
1464
|
+
try {
|
|
1465
|
+
for await (const inputBatch of inputBatches) {
|
|
1466
|
+
await writer.write(new Uint8Array(inputBatch));
|
|
1467
|
+
}
|
|
1468
|
+
await writer.close();
|
|
1469
|
+
} catch (error62) {
|
|
1470
|
+
await writer.abort(error62).catch(() => {
|
|
1471
|
+
});
|
|
1472
|
+
throw error62;
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
async function concatenateBatches(batches) {
|
|
1476
|
+
const output2 = [];
|
|
1477
|
+
let byteLength = 0;
|
|
1478
|
+
for await (const batch of batches) {
|
|
1479
|
+
const bytes = new Uint8Array(batch);
|
|
1480
|
+
output2.push(bytes);
|
|
1481
|
+
byteLength += bytes.byteLength;
|
|
1482
|
+
}
|
|
1483
|
+
const result = new Uint8Array(byteLength);
|
|
1484
|
+
let offset = 0;
|
|
1485
|
+
for (const batch of output2) {
|
|
1486
|
+
result.set(batch, offset);
|
|
1487
|
+
offset += batch.byteLength;
|
|
1488
|
+
}
|
|
1489
|
+
return result.buffer;
|
|
1490
|
+
}
|
|
1491
|
+
var init_compression_stream = __esm({
|
|
1492
|
+
"../compression/src/lib/compression-stream.ts"() {
|
|
1493
|
+
"use strict";
|
|
1494
|
+
}
|
|
1495
|
+
});
|
|
1496
|
+
|
|
1497
|
+
// ../compression/src/lib/decompression-stream.ts
|
|
1498
|
+
async function decompressWithNativeDecompressionStream(input2, format) {
|
|
1499
|
+
const outputBatches = decompressBatchesWithNativeDecompressionStream([input2], format);
|
|
1500
|
+
return outputBatches ? await concatenateNativeDecompressionBatches(outputBatches) : null;
|
|
1501
|
+
}
|
|
1502
|
+
function decompressBatchesWithNativeDecompressionStream(inputBatches, format) {
|
|
1503
|
+
const decompressionStream = createNativeDecompressionStream(format);
|
|
1504
|
+
return decompressionStream ? transformBatchesWithNativeDecompressionStream(inputBatches, decompressionStream) : null;
|
|
1505
|
+
}
|
|
1506
|
+
function isNativeDecompressionSupported(format) {
|
|
1507
|
+
return Boolean(createNativeDecompressionStream(format));
|
|
1508
|
+
}
|
|
1509
|
+
function createNativeDecompressionStream(format) {
|
|
1510
|
+
if (typeof globalThis.DecompressionStream === "undefined") {
|
|
1511
|
+
return null;
|
|
1512
|
+
}
|
|
1513
|
+
if (globalThis.process?.release?.name === "node" && typeof globalThis.Buffer === "undefined") {
|
|
1514
|
+
return null;
|
|
1515
|
+
}
|
|
1516
|
+
try {
|
|
1517
|
+
const DecompressionStreamConstructor = globalThis.DecompressionStream;
|
|
1518
|
+
return new DecompressionStreamConstructor(format);
|
|
1519
|
+
} catch (error62) {
|
|
1520
|
+
if (error62 instanceof TypeError || error62?.name === "TypeError") {
|
|
1521
|
+
return null;
|
|
1522
|
+
}
|
|
1523
|
+
throw error62;
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
async function* transformBatchesWithNativeDecompressionStream(inputBatches, decompressionStream) {
|
|
1527
|
+
const writer = decompressionStream.writable.getWriter();
|
|
1528
|
+
const reader = decompressionStream.readable.getReader();
|
|
1529
|
+
const writePromise = writeBatchesToNativeDecompressionStream(inputBatches, writer);
|
|
1530
|
+
writePromise.catch(() => {
|
|
1531
|
+
});
|
|
1532
|
+
let outputCompleted = false;
|
|
1533
|
+
try {
|
|
1534
|
+
while (true) {
|
|
1535
|
+
const { done, value } = await reader.read();
|
|
1536
|
+
if (done) {
|
|
1537
|
+
outputCompleted = true;
|
|
1538
|
+
break;
|
|
1539
|
+
}
|
|
1540
|
+
yield copyExactArrayBuffer(value);
|
|
1541
|
+
}
|
|
1542
|
+
await writePromise;
|
|
1543
|
+
} finally {
|
|
1544
|
+
if (!outputCompleted) {
|
|
1545
|
+
await reader.cancel().catch(() => {
|
|
1546
|
+
});
|
|
1547
|
+
await writer.abort().catch(() => {
|
|
1548
|
+
});
|
|
1549
|
+
await writePromise.catch(() => {
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1552
|
+
reader.releaseLock();
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
async function concatenateNativeDecompressionBatches(outputBatches) {
|
|
1556
|
+
const batches = [];
|
|
1557
|
+
let byteLength = 0;
|
|
1558
|
+
for await (const outputBatch of outputBatches) {
|
|
1559
|
+
const bytes = new Uint8Array(outputBatch);
|
|
1560
|
+
batches.push(bytes);
|
|
1561
|
+
byteLength += bytes.byteLength;
|
|
1562
|
+
}
|
|
1563
|
+
const output2 = new Uint8Array(byteLength);
|
|
1564
|
+
let byteOffset = 0;
|
|
1565
|
+
for (const batch of batches) {
|
|
1566
|
+
output2.set(batch, byteOffset);
|
|
1567
|
+
byteOffset += batch.byteLength;
|
|
1568
|
+
}
|
|
1569
|
+
return output2.buffer;
|
|
1570
|
+
}
|
|
1571
|
+
function copyExactArrayBuffer(value) {
|
|
1572
|
+
return new Uint8Array(value).buffer;
|
|
1573
|
+
}
|
|
1574
|
+
async function writeBatchesToNativeDecompressionStream(inputBatches, writer) {
|
|
1575
|
+
try {
|
|
1576
|
+
for await (const inputBatch of inputBatches) {
|
|
1577
|
+
await writer.write(new Uint8Array(inputBatch));
|
|
1578
|
+
}
|
|
1579
|
+
await writer.close();
|
|
1580
|
+
} catch (error62) {
|
|
1581
|
+
await writer.abort(error62).catch(() => {
|
|
1582
|
+
});
|
|
1583
|
+
throw error62;
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
var init_decompression_stream = __esm({
|
|
1587
|
+
"../compression/src/lib/decompression-stream.ts"() {
|
|
1588
|
+
"use strict";
|
|
1589
|
+
}
|
|
1590
|
+
});
|
|
1591
|
+
|
|
1592
|
+
// ../compression/src/lib/native-decompressor.ts
|
|
1593
|
+
var native_decompressor_exports = {};
|
|
1594
|
+
__export(native_decompressor_exports, {
|
|
1595
|
+
NativeDecompressor: () => NativeDecompressor
|
|
1596
|
+
});
|
|
1597
|
+
var NativeDecompressor;
|
|
1598
|
+
var init_native_decompressor = __esm({
|
|
1599
|
+
"../compression/src/lib/native-decompressor.ts"() {
|
|
1600
|
+
"use strict";
|
|
1601
|
+
init_compression();
|
|
1602
|
+
init_decompression_stream();
|
|
1603
|
+
NativeDecompressor = class extends Decompressor {
|
|
1604
|
+
name;
|
|
1605
|
+
extensions;
|
|
1606
|
+
contentEncodings;
|
|
1607
|
+
isSupported = true;
|
|
1608
|
+
/** Runtime stream format used for every operation. */
|
|
1609
|
+
format;
|
|
1610
|
+
constructor(metadata, format, options = {}) {
|
|
1611
|
+
super(options);
|
|
1612
|
+
this.name = metadata.name;
|
|
1613
|
+
this.extensions = [...metadata.extensions];
|
|
1614
|
+
this.contentEncodings = [...metadata.contentEncodings];
|
|
1615
|
+
this.format = format;
|
|
1616
|
+
}
|
|
1617
|
+
/** Decompresses one buffer with the runtime-provided stream. */
|
|
1618
|
+
async decompress(input2) {
|
|
1619
|
+
const output2 = await decompressWithNativeDecompressionStream(input2, this.format);
|
|
1620
|
+
if (!output2) throw new Error(`${this.name}: built-in decompression is no longer available`);
|
|
1621
|
+
return output2;
|
|
1622
|
+
}
|
|
1623
|
+
/** Decompresses batches incrementally with the runtime-provided stream. */
|
|
1624
|
+
async *decompressBatches(inputBatches) {
|
|
1625
|
+
const output2 = decompressBatchesWithNativeDecompressionStream(inputBatches, this.format);
|
|
1626
|
+
if (!output2) throw new Error(`${this.name}: built-in decompression is no longer available`);
|
|
1627
|
+
yield* output2;
|
|
1628
|
+
}
|
|
1629
|
+
};
|
|
1630
|
+
}
|
|
1631
|
+
});
|
|
1632
|
+
|
|
1633
|
+
// ../compression/src/lib/lazy-compression.ts
|
|
1634
|
+
function mergeModules(options, modules) {
|
|
1635
|
+
return { ...options, modules: { ...options.modules, ...modules } };
|
|
1636
|
+
}
|
|
1637
|
+
var LazyDecompressor;
|
|
1638
|
+
var init_lazy_compression = __esm({
|
|
1639
|
+
"../compression/src/lib/lazy-compression.ts"() {
|
|
1640
|
+
"use strict";
|
|
1641
|
+
init_compression();
|
|
1642
|
+
init_decompression_stream();
|
|
1643
|
+
LazyDecompressor = class extends Decompressor {
|
|
1644
|
+
name;
|
|
1645
|
+
extensions;
|
|
1646
|
+
contentEncodings;
|
|
1647
|
+
isSupported = true;
|
|
1648
|
+
/** Constructor options retained until a concrete implementation is selected. */
|
|
1649
|
+
options;
|
|
1650
|
+
/** Built-in stream format to probe, or null when the format has no built-in path. */
|
|
1651
|
+
nativeFormat;
|
|
1652
|
+
/** Returns whether built-in selection remains eligible for the merged preload options. */
|
|
1653
|
+
shouldUseNative;
|
|
1654
|
+
/** Dynamically imports the balanced fallback constructor. */
|
|
1655
|
+
loadFallback;
|
|
1656
|
+
/** Selected concrete implementation after preload completes. */
|
|
1657
|
+
implementation = null;
|
|
1658
|
+
/** Shared in-flight selection used by concurrent asynchronous calls. */
|
|
1659
|
+
implementationPromise = null;
|
|
1660
|
+
constructor(metadata, loadFallback, options = {}, nativeFormat = null, shouldUseNative = () => true) {
|
|
1661
|
+
super(options);
|
|
1662
|
+
this.name = metadata.name;
|
|
1663
|
+
this.extensions = [...metadata.extensions];
|
|
1664
|
+
this.contentEncodings = [...metadata.contentEncodings];
|
|
1665
|
+
this.options = options;
|
|
1666
|
+
this.nativeFormat = nativeFormat;
|
|
1667
|
+
this.shouldUseNative = shouldUseNative;
|
|
1668
|
+
this.loadFallback = loadFallback;
|
|
1669
|
+
}
|
|
1670
|
+
/** Selects and returns the built-in or dynamically imported fallback decompressor. */
|
|
1671
|
+
async preload(modules = {}) {
|
|
1672
|
+
if (this.implementation) return this.implementation;
|
|
1673
|
+
const options = mergeModules(this.options, modules);
|
|
1674
|
+
this.implementationPromise ||= this.loadImplementation(options);
|
|
1675
|
+
try {
|
|
1676
|
+
this.implementation = await this.implementationPromise;
|
|
1677
|
+
return this.implementation;
|
|
1678
|
+
} catch (error62) {
|
|
1679
|
+
this.implementationPromise = null;
|
|
1680
|
+
throw error62;
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
/** Loads the selected concrete decompressor. */
|
|
1684
|
+
async loadImplementation(options) {
|
|
1685
|
+
if (options.useNative !== false && this.nativeFormat && this.shouldUseNative(options) && isNativeDecompressionSupported(this.nativeFormat)) {
|
|
1686
|
+
const { NativeDecompressor: NativeDecompressor2 } = await Promise.resolve().then(() => (init_native_decompressor(), native_decompressor_exports));
|
|
1687
|
+
return new NativeDecompressor2(this, this.nativeFormat, options);
|
|
1688
|
+
}
|
|
1689
|
+
const Decompressor2 = await this.loadFallback();
|
|
1690
|
+
const implementation = new Decompressor2({ ...options, useNative: false });
|
|
1691
|
+
await implementation.preload(options.modules);
|
|
1692
|
+
return implementation;
|
|
1693
|
+
}
|
|
1694
|
+
/** Decompresses after lazily selecting the default implementation. */
|
|
1695
|
+
async decompress(input2, size) {
|
|
1696
|
+
return (await this.preload()).decompress(input2, size);
|
|
1697
|
+
}
|
|
1698
|
+
/** Decompresses synchronously after an implementation has been preloaded. */
|
|
1699
|
+
decompressSync(input2, size) {
|
|
1700
|
+
if (!this.implementation) {
|
|
1701
|
+
throw new Error(`${this.name}: call preload() before decompressSync()`);
|
|
1702
|
+
}
|
|
1703
|
+
return this.implementation.decompressSync(input2, size);
|
|
1704
|
+
}
|
|
1705
|
+
/** Decompresses batches after lazily selecting the default implementation. */
|
|
1706
|
+
async *decompressBatches(inputBatches) {
|
|
1707
|
+
yield* (await this.preload()).decompressBatches(inputBatches);
|
|
1708
|
+
}
|
|
1709
|
+
};
|
|
1710
|
+
}
|
|
1711
|
+
});
|
|
1712
|
+
|
|
1411
1713
|
// ../compression/src/lib/fflate/index.ts
|
|
1412
1714
|
function inflateSync(data, out) {
|
|
1413
1715
|
return inflt(data, out);
|
|
@@ -1740,417 +2042,115 @@ var __exports__ = (() => {
|
|
|
1740
2042
|
for (let zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++]) ;
|
|
1741
2043
|
return st + (flg & 2);
|
|
1742
2044
|
};
|
|
1743
|
-
gzl = (d) => {
|
|
1744
|
-
const l = d.length;
|
|
1745
|
-
return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16 | d[l - 1] << 24) >>> 0;
|
|
1746
|
-
};
|
|
1747
|
-
zlv = (d) => {
|
|
1748
|
-
if ((d[0] & 15) != 8 || d[0] >>> 4 > 7 || (d[0] << 8 | d[1]) % 31) err(6, "invalid zlib data");
|
|
1749
|
-
if (d[1] & 32) err(6, "invalid zlib data: preset dictionaries not supported");
|
|
1750
|
-
};
|
|
1751
|
-
Inflate = class {
|
|
1752
|
-
/**
|
|
1753
|
-
* Creates an inflation stream
|
|
1754
|
-
* @param cb The callback to call whenever data is inflated
|
|
1755
|
-
*/
|
|
1756
|
-
constructor(cb) {
|
|
1757
|
-
this.ondata = cb;
|
|
1758
|
-
}
|
|
1759
|
-
/** Persistent bit-reader and Huffman decoding state. */
|
|
1760
|
-
s = {};
|
|
1761
|
-
/** Compression options or retained output window for this stream. */
|
|
1762
|
-
o;
|
|
1763
|
-
/** Compressed bytes pending decoding. */
|
|
1764
|
-
p = new u8(0);
|
|
1765
|
-
/** Whether the stream has received its final chunk. */
|
|
1766
|
-
d;
|
|
1767
|
-
/**
|
|
1768
|
-
* The handler to call whenever data is available
|
|
1769
|
-
*/
|
|
1770
|
-
ondata;
|
|
1771
|
-
/** Appends pending input after checking stream lifecycle. */
|
|
1772
|
-
e(c) {
|
|
1773
|
-
if (!this.ondata) err(5);
|
|
1774
|
-
if (this.d) err(4);
|
|
1775
|
-
const l = this.p.length;
|
|
1776
|
-
const n = new u8(l + c.length);
|
|
1777
|
-
n.set(this.p), n.set(c, l), this.p = n;
|
|
1778
|
-
}
|
|
1779
|
-
/** Decodes pending input and retains the sliding window. */
|
|
1780
|
-
c(final) {
|
|
1781
|
-
this.d = this.s.i = final || false;
|
|
1782
|
-
const bts = this.s.b;
|
|
1783
|
-
const dt = inflt(this.p, this.o, this.s);
|
|
1784
|
-
this.ondata(slc(dt, bts, this.s.b), this.d);
|
|
1785
|
-
this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;
|
|
1786
|
-
this.p = slc(this.p, this.s.p / 8 | 0), this.s.p &= 7;
|
|
1787
|
-
}
|
|
1788
|
-
/**
|
|
1789
|
-
* Pushes a chunk to be inflated
|
|
1790
|
-
* @param chunk The chunk to push
|
|
1791
|
-
* @param final Whether this is the final chunk
|
|
1792
|
-
*/
|
|
1793
|
-
push(chunk, final) {
|
|
1794
|
-
this.e(chunk), this.c(final);
|
|
1795
|
-
}
|
|
1796
|
-
};
|
|
1797
|
-
Gunzip = class extends Inflate {
|
|
1798
|
-
/** Whether the stream header still needs to be emitted or consumed. */
|
|
1799
|
-
v = 1;
|
|
1800
|
-
/**
|
|
1801
|
-
* Creates a GUNZIP stream
|
|
1802
|
-
* @param cb The callback to call whenever data is inflated
|
|
1803
|
-
*/
|
|
1804
|
-
constructor(cb) {
|
|
1805
|
-
super(cb);
|
|
1806
|
-
}
|
|
1807
|
-
/**
|
|
1808
|
-
* Pushes a chunk to be GUNZIPped
|
|
1809
|
-
* @param chunk The chunk to push
|
|
1810
|
-
* @param final Whether this is the last chunk
|
|
1811
|
-
*/
|
|
1812
|
-
push(chunk, final) {
|
|
1813
|
-
Inflate.prototype.e.call(this, chunk);
|
|
1814
|
-
if (this.v) {
|
|
1815
|
-
const s = this.p.length > 3 ? gzs(this.p) : 4;
|
|
1816
|
-
if (s >= this.p.length && !final) return;
|
|
1817
|
-
this.p = this.p.subarray(s), this.v = 0;
|
|
1818
|
-
}
|
|
1819
|
-
if (final) {
|
|
1820
|
-
if (this.p.length < 8) err(6, "invalid gzip data");
|
|
1821
|
-
this.p = this.p.subarray(0, -8);
|
|
1822
|
-
}
|
|
1823
|
-
Inflate.prototype.c.call(this, final);
|
|
1824
|
-
}
|
|
1825
|
-
};
|
|
1826
|
-
Unzlib = class extends Inflate {
|
|
1827
|
-
/** Whether the stream header still needs to be emitted or consumed. */
|
|
1828
|
-
v = 1;
|
|
1829
|
-
/**
|
|
1830
|
-
* Creates a Zlib decompression stream
|
|
1831
|
-
* @param cb The callback to call whenever data is inflated
|
|
1832
|
-
*/
|
|
1833
|
-
constructor(cb) {
|
|
1834
|
-
super(cb);
|
|
1835
|
-
}
|
|
1836
|
-
/**
|
|
1837
|
-
* Pushes a chunk to be unzlibbed
|
|
1838
|
-
* @param chunk The chunk to push
|
|
1839
|
-
* @param final Whether this is the last chunk
|
|
1840
|
-
*/
|
|
1841
|
-
push(chunk, final) {
|
|
1842
|
-
Inflate.prototype.e.call(this, chunk);
|
|
1843
|
-
if (this.v) {
|
|
1844
|
-
if (this.p.length < 2 && !final) return;
|
|
1845
|
-
this.p = this.p.subarray(2), this.v = 0;
|
|
1846
|
-
}
|
|
1847
|
-
if (final) {
|
|
1848
|
-
if (this.p.length < 4) err(6, "invalid zlib data");
|
|
1849
|
-
this.p = this.p.subarray(0, -4);
|
|
1850
|
-
}
|
|
1851
|
-
Inflate.prototype.c.call(this, final);
|
|
1852
|
-
}
|
|
1853
|
-
};
|
|
1854
|
-
}
|
|
1855
|
-
});
|
|
1856
|
-
|
|
1857
|
-
// ../compression/src/lib/compression-stream.ts
|
|
1858
|
-
async function compressWithNativeCompressionStream(input2, format) {
|
|
1859
|
-
const outputBatches = compressBatchesWithNativeCompressionStream([input2], format);
|
|
1860
|
-
return outputBatches ? await concatenateBatches(outputBatches) : null;
|
|
1861
|
-
}
|
|
1862
|
-
function compressBatchesWithNativeCompressionStream(inputBatches, format) {
|
|
1863
|
-
const compressionStream = createNativeCompressionStream(format);
|
|
1864
|
-
return compressionStream ? transformBatches(inputBatches, compressionStream) : null;
|
|
1865
|
-
}
|
|
1866
|
-
function createNativeCompressionStream(format) {
|
|
1867
|
-
if (typeof globalThis.CompressionStream === "undefined") {
|
|
1868
|
-
return null;
|
|
1869
|
-
}
|
|
1870
|
-
try {
|
|
1871
|
-
const CompressionStreamConstructor = globalThis.CompressionStream;
|
|
1872
|
-
return new CompressionStreamConstructor(format);
|
|
1873
|
-
} catch (error62) {
|
|
1874
|
-
if (error62 instanceof TypeError || error62?.name === "TypeError") {
|
|
1875
|
-
return null;
|
|
1876
|
-
}
|
|
1877
|
-
throw error62;
|
|
1878
|
-
}
|
|
1879
|
-
}
|
|
1880
|
-
async function* transformBatches(inputBatches, compressionStream) {
|
|
1881
|
-
const writer = compressionStream.writable.getWriter();
|
|
1882
|
-
const reader = compressionStream.readable.getReader();
|
|
1883
|
-
const writePromise = writeBatches(inputBatches, writer);
|
|
1884
|
-
writePromise.catch(() => {
|
|
1885
|
-
});
|
|
1886
|
-
let outputCompleted = false;
|
|
1887
|
-
try {
|
|
1888
|
-
while (true) {
|
|
1889
|
-
const { done, value } = await reader.read();
|
|
1890
|
-
if (done) {
|
|
1891
|
-
outputCompleted = true;
|
|
1892
|
-
break;
|
|
1893
|
-
}
|
|
1894
|
-
yield new Uint8Array(value).buffer;
|
|
1895
|
-
}
|
|
1896
|
-
await writePromise;
|
|
1897
|
-
} finally {
|
|
1898
|
-
if (!outputCompleted) {
|
|
1899
|
-
await reader.cancel().catch(() => {
|
|
1900
|
-
});
|
|
1901
|
-
await writer.abort().catch(() => {
|
|
1902
|
-
});
|
|
1903
|
-
await writePromise.catch(() => {
|
|
1904
|
-
});
|
|
1905
|
-
}
|
|
1906
|
-
reader.releaseLock();
|
|
1907
|
-
}
|
|
1908
|
-
}
|
|
1909
|
-
async function writeBatches(inputBatches, writer) {
|
|
1910
|
-
try {
|
|
1911
|
-
for await (const inputBatch of inputBatches) {
|
|
1912
|
-
await writer.write(new Uint8Array(inputBatch));
|
|
1913
|
-
}
|
|
1914
|
-
await writer.close();
|
|
1915
|
-
} catch (error62) {
|
|
1916
|
-
await writer.abort(error62).catch(() => {
|
|
1917
|
-
});
|
|
1918
|
-
throw error62;
|
|
1919
|
-
}
|
|
1920
|
-
}
|
|
1921
|
-
async function concatenateBatches(batches) {
|
|
1922
|
-
const output2 = [];
|
|
1923
|
-
let byteLength = 0;
|
|
1924
|
-
for await (const batch of batches) {
|
|
1925
|
-
const bytes = new Uint8Array(batch);
|
|
1926
|
-
output2.push(bytes);
|
|
1927
|
-
byteLength += bytes.byteLength;
|
|
1928
|
-
}
|
|
1929
|
-
const result = new Uint8Array(byteLength);
|
|
1930
|
-
let offset = 0;
|
|
1931
|
-
for (const batch of output2) {
|
|
1932
|
-
result.set(batch, offset);
|
|
1933
|
-
offset += batch.byteLength;
|
|
1934
|
-
}
|
|
1935
|
-
return result.buffer;
|
|
1936
|
-
}
|
|
1937
|
-
var init_compression_stream = __esm({
|
|
1938
|
-
"../compression/src/lib/compression-stream.ts"() {
|
|
1939
|
-
"use strict";
|
|
1940
|
-
}
|
|
1941
|
-
});
|
|
1942
|
-
|
|
1943
|
-
// ../compression/src/lib/decompression-stream.ts
|
|
1944
|
-
async function decompressWithNativeDecompressionStream(input2, format) {
|
|
1945
|
-
const outputBatches = decompressBatchesWithNativeDecompressionStream([input2], format);
|
|
1946
|
-
return outputBatches ? await concatenateNativeDecompressionBatches(outputBatches) : null;
|
|
1947
|
-
}
|
|
1948
|
-
function decompressBatchesWithNativeDecompressionStream(inputBatches, format) {
|
|
1949
|
-
const decompressionStream = createNativeDecompressionStream(format);
|
|
1950
|
-
return decompressionStream ? transformBatchesWithNativeDecompressionStream(inputBatches, decompressionStream) : null;
|
|
1951
|
-
}
|
|
1952
|
-
function isNativeDecompressionSupported(format) {
|
|
1953
|
-
return Boolean(createNativeDecompressionStream(format));
|
|
1954
|
-
}
|
|
1955
|
-
function createNativeDecompressionStream(format) {
|
|
1956
|
-
if (typeof globalThis.DecompressionStream === "undefined") {
|
|
1957
|
-
return null;
|
|
1958
|
-
}
|
|
1959
|
-
if (globalThis.process?.release?.name === "node" && typeof globalThis.Buffer === "undefined") {
|
|
1960
|
-
return null;
|
|
1961
|
-
}
|
|
1962
|
-
try {
|
|
1963
|
-
const DecompressionStreamConstructor = globalThis.DecompressionStream;
|
|
1964
|
-
return new DecompressionStreamConstructor(format);
|
|
1965
|
-
} catch (error62) {
|
|
1966
|
-
if (error62 instanceof TypeError || error62?.name === "TypeError") {
|
|
1967
|
-
return null;
|
|
1968
|
-
}
|
|
1969
|
-
throw error62;
|
|
1970
|
-
}
|
|
1971
|
-
}
|
|
1972
|
-
async function* transformBatchesWithNativeDecompressionStream(inputBatches, decompressionStream) {
|
|
1973
|
-
const writer = decompressionStream.writable.getWriter();
|
|
1974
|
-
const reader = decompressionStream.readable.getReader();
|
|
1975
|
-
const writePromise = writeBatchesToNativeDecompressionStream(inputBatches, writer);
|
|
1976
|
-
writePromise.catch(() => {
|
|
1977
|
-
});
|
|
1978
|
-
let outputCompleted = false;
|
|
1979
|
-
try {
|
|
1980
|
-
while (true) {
|
|
1981
|
-
const { done, value } = await reader.read();
|
|
1982
|
-
if (done) {
|
|
1983
|
-
outputCompleted = true;
|
|
1984
|
-
break;
|
|
2045
|
+
gzl = (d) => {
|
|
2046
|
+
const l = d.length;
|
|
2047
|
+
return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16 | d[l - 1] << 24) >>> 0;
|
|
2048
|
+
};
|
|
2049
|
+
zlv = (d) => {
|
|
2050
|
+
if ((d[0] & 15) != 8 || d[0] >>> 4 > 7 || (d[0] << 8 | d[1]) % 31) err(6, "invalid zlib data");
|
|
2051
|
+
if (d[1] & 32) err(6, "invalid zlib data: preset dictionaries not supported");
|
|
2052
|
+
};
|
|
2053
|
+
Inflate = class {
|
|
2054
|
+
/**
|
|
2055
|
+
* Creates an inflation stream
|
|
2056
|
+
* @param cb The callback to call whenever data is inflated
|
|
2057
|
+
*/
|
|
2058
|
+
constructor(cb) {
|
|
2059
|
+
this.ondata = cb;
|
|
1985
2060
|
}
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
const bytes = new Uint8Array(outputBatch);
|
|
2006
|
-
batches.push(bytes);
|
|
2007
|
-
byteLength += bytes.byteLength;
|
|
2008
|
-
}
|
|
2009
|
-
const output2 = new Uint8Array(byteLength);
|
|
2010
|
-
let byteOffset = 0;
|
|
2011
|
-
for (const batch of batches) {
|
|
2012
|
-
output2.set(batch, byteOffset);
|
|
2013
|
-
byteOffset += batch.byteLength;
|
|
2014
|
-
}
|
|
2015
|
-
return output2.buffer;
|
|
2016
|
-
}
|
|
2017
|
-
function copyExactArrayBuffer(value) {
|
|
2018
|
-
return new Uint8Array(value).buffer;
|
|
2019
|
-
}
|
|
2020
|
-
async function writeBatchesToNativeDecompressionStream(inputBatches, writer) {
|
|
2021
|
-
try {
|
|
2022
|
-
for await (const inputBatch of inputBatches) {
|
|
2023
|
-
await writer.write(new Uint8Array(inputBatch));
|
|
2024
|
-
}
|
|
2025
|
-
await writer.close();
|
|
2026
|
-
} catch (error62) {
|
|
2027
|
-
await writer.abort(error62).catch(() => {
|
|
2028
|
-
});
|
|
2029
|
-
throw error62;
|
|
2030
|
-
}
|
|
2031
|
-
}
|
|
2032
|
-
var init_decompression_stream = __esm({
|
|
2033
|
-
"../compression/src/lib/decompression-stream.ts"() {
|
|
2034
|
-
"use strict";
|
|
2035
|
-
}
|
|
2036
|
-
});
|
|
2037
|
-
|
|
2038
|
-
// ../compression/src/lib/native-decompressor.ts
|
|
2039
|
-
var native_decompressor_exports = {};
|
|
2040
|
-
__export(native_decompressor_exports, {
|
|
2041
|
-
NativeDecompressor: () => NativeDecompressor
|
|
2042
|
-
});
|
|
2043
|
-
var NativeDecompressor;
|
|
2044
|
-
var init_native_decompressor = __esm({
|
|
2045
|
-
"../compression/src/lib/native-decompressor.ts"() {
|
|
2046
|
-
"use strict";
|
|
2047
|
-
init_compression();
|
|
2048
|
-
init_decompression_stream();
|
|
2049
|
-
NativeDecompressor = class extends Decompressor {
|
|
2050
|
-
name;
|
|
2051
|
-
extensions;
|
|
2052
|
-
contentEncodings;
|
|
2053
|
-
isSupported = true;
|
|
2054
|
-
/** Runtime stream format used for every operation. */
|
|
2055
|
-
format;
|
|
2056
|
-
constructor(metadata, format, options = {}) {
|
|
2057
|
-
super(options);
|
|
2058
|
-
this.name = metadata.name;
|
|
2059
|
-
this.extensions = [...metadata.extensions];
|
|
2060
|
-
this.contentEncodings = [...metadata.contentEncodings];
|
|
2061
|
-
this.format = format;
|
|
2061
|
+
/** Persistent bit-reader and Huffman decoding state. */
|
|
2062
|
+
s = {};
|
|
2063
|
+
/** Compression options or retained output window for this stream. */
|
|
2064
|
+
o;
|
|
2065
|
+
/** Compressed bytes pending decoding. */
|
|
2066
|
+
p = new u8(0);
|
|
2067
|
+
/** Whether the stream has received its final chunk. */
|
|
2068
|
+
d;
|
|
2069
|
+
/**
|
|
2070
|
+
* The handler to call whenever data is available
|
|
2071
|
+
*/
|
|
2072
|
+
ondata;
|
|
2073
|
+
/** Appends pending input after checking stream lifecycle. */
|
|
2074
|
+
e(c) {
|
|
2075
|
+
if (!this.ondata) err(5);
|
|
2076
|
+
if (this.d) err(4);
|
|
2077
|
+
const l = this.p.length;
|
|
2078
|
+
const n = new u8(l + c.length);
|
|
2079
|
+
n.set(this.p), n.set(c, l), this.p = n;
|
|
2062
2080
|
}
|
|
2063
|
-
/**
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2081
|
+
/** Decodes pending input and retains the sliding window. */
|
|
2082
|
+
c(final) {
|
|
2083
|
+
this.d = this.s.i = final || false;
|
|
2084
|
+
const bts = this.s.b;
|
|
2085
|
+
const dt = inflt(this.p, this.o, this.s);
|
|
2086
|
+
this.ondata(slc(dt, bts, this.s.b), this.d);
|
|
2087
|
+
this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;
|
|
2088
|
+
this.p = slc(this.p, this.s.p / 8 | 0), this.s.p &= 7;
|
|
2068
2089
|
}
|
|
2069
|
-
/**
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2090
|
+
/**
|
|
2091
|
+
* Pushes a chunk to be inflated
|
|
2092
|
+
* @param chunk The chunk to push
|
|
2093
|
+
* @param final Whether this is the final chunk
|
|
2094
|
+
*/
|
|
2095
|
+
push(chunk, final) {
|
|
2096
|
+
this.e(chunk), this.c(final);
|
|
2074
2097
|
}
|
|
2075
2098
|
};
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
"../compression/src/lib/lazy-compression.ts"() {
|
|
2086
|
-
"use strict";
|
|
2087
|
-
init_compression();
|
|
2088
|
-
init_decompression_stream();
|
|
2089
|
-
LazyDecompressor = class extends Decompressor {
|
|
2090
|
-
name;
|
|
2091
|
-
extensions;
|
|
2092
|
-
contentEncodings;
|
|
2093
|
-
isSupported = true;
|
|
2094
|
-
/** Constructor options retained until a concrete implementation is selected. */
|
|
2095
|
-
options;
|
|
2096
|
-
/** Built-in stream format to probe, or null when the format has no built-in path. */
|
|
2097
|
-
nativeFormat;
|
|
2098
|
-
/** Returns whether built-in selection remains eligible for the merged preload options. */
|
|
2099
|
-
shouldUseNative;
|
|
2100
|
-
/** Dynamically imports the balanced fallback constructor. */
|
|
2101
|
-
loadFallback;
|
|
2102
|
-
/** Selected concrete implementation after preload completes. */
|
|
2103
|
-
implementation = null;
|
|
2104
|
-
/** Shared in-flight selection used by concurrent asynchronous calls. */
|
|
2105
|
-
implementationPromise = null;
|
|
2106
|
-
constructor(metadata, loadFallback, options = {}, nativeFormat = null, shouldUseNative = () => true) {
|
|
2107
|
-
super(options);
|
|
2108
|
-
this.name = metadata.name;
|
|
2109
|
-
this.extensions = [...metadata.extensions];
|
|
2110
|
-
this.contentEncodings = [...metadata.contentEncodings];
|
|
2111
|
-
this.options = options;
|
|
2112
|
-
this.nativeFormat = nativeFormat;
|
|
2113
|
-
this.shouldUseNative = shouldUseNative;
|
|
2114
|
-
this.loadFallback = loadFallback;
|
|
2099
|
+
Gunzip = class extends Inflate {
|
|
2100
|
+
/** Whether the stream header still needs to be emitted or consumed. */
|
|
2101
|
+
v = 1;
|
|
2102
|
+
/**
|
|
2103
|
+
* Creates a GUNZIP stream
|
|
2104
|
+
* @param cb The callback to call whenever data is inflated
|
|
2105
|
+
*/
|
|
2106
|
+
constructor(cb) {
|
|
2107
|
+
super(cb);
|
|
2115
2108
|
}
|
|
2116
|
-
/**
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
this.
|
|
2126
|
-
|
|
2109
|
+
/**
|
|
2110
|
+
* Pushes a chunk to be GUNZIPped
|
|
2111
|
+
* @param chunk The chunk to push
|
|
2112
|
+
* @param final Whether this is the last chunk
|
|
2113
|
+
*/
|
|
2114
|
+
push(chunk, final) {
|
|
2115
|
+
Inflate.prototype.e.call(this, chunk);
|
|
2116
|
+
if (this.v) {
|
|
2117
|
+
const s = this.p.length > 3 ? gzs(this.p) : 4;
|
|
2118
|
+
if (s >= this.p.length && !final) return;
|
|
2119
|
+
this.p = this.p.subarray(s), this.v = 0;
|
|
2127
2120
|
}
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
if (options.useNative !== false && this.nativeFormat && this.shouldUseNative(options) && isNativeDecompressionSupported(this.nativeFormat)) {
|
|
2132
|
-
const { NativeDecompressor: NativeDecompressor2 } = await Promise.resolve().then(() => (init_native_decompressor(), native_decompressor_exports));
|
|
2133
|
-
return new NativeDecompressor2(this, this.nativeFormat, options);
|
|
2121
|
+
if (final) {
|
|
2122
|
+
if (this.p.length < 8) err(6, "invalid gzip data");
|
|
2123
|
+
this.p = this.p.subarray(0, -8);
|
|
2134
2124
|
}
|
|
2135
|
-
|
|
2136
|
-
const implementation = new Decompressor2({ ...options, useNative: false });
|
|
2137
|
-
await implementation.preload(options.modules);
|
|
2138
|
-
return implementation;
|
|
2125
|
+
Inflate.prototype.c.call(this, final);
|
|
2139
2126
|
}
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2127
|
+
};
|
|
2128
|
+
Unzlib = class extends Inflate {
|
|
2129
|
+
/** Whether the stream header still needs to be emitted or consumed. */
|
|
2130
|
+
v = 1;
|
|
2131
|
+
/**
|
|
2132
|
+
* Creates a Zlib decompression stream
|
|
2133
|
+
* @param cb The callback to call whenever data is inflated
|
|
2134
|
+
*/
|
|
2135
|
+
constructor(cb) {
|
|
2136
|
+
super(cb);
|
|
2143
2137
|
}
|
|
2144
|
-
/**
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2138
|
+
/**
|
|
2139
|
+
* Pushes a chunk to be unzlibbed
|
|
2140
|
+
* @param chunk The chunk to push
|
|
2141
|
+
* @param final Whether this is the last chunk
|
|
2142
|
+
*/
|
|
2143
|
+
push(chunk, final) {
|
|
2144
|
+
Inflate.prototype.e.call(this, chunk);
|
|
2145
|
+
if (this.v) {
|
|
2146
|
+
if (this.p.length < 2 && !final) return;
|
|
2147
|
+
this.p = this.p.subarray(2), this.v = 0;
|
|
2148
2148
|
}
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2149
|
+
if (final) {
|
|
2150
|
+
if (this.p.length < 4) err(6, "invalid zlib data");
|
|
2151
|
+
this.p = this.p.subarray(0, -4);
|
|
2152
|
+
}
|
|
2153
|
+
Inflate.prototype.c.call(this, final);
|
|
2154
2154
|
}
|
|
2155
2155
|
};
|
|
2156
2156
|
}
|