@dxos/vendor-hypercore 0.8.4-main.5ad4a44 → 0.8.4-main.69d29f4
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/lib/browser/chunk-WLEV7IVZ.mjs +6336 -0
- package/dist/lib/browser/chunk-WLEV7IVZ.mjs.map +7 -0
- package/dist/lib/browser/hypercore-crypto.mjs +1 -1
- package/dist/lib/browser/hypercore.mjs +1022 -1128
- package/dist/lib/browser/hypercore.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/chunk-H7LBQLKP.mjs +5779 -0
- package/dist/lib/node-esm/chunk-H7LBQLKP.mjs.map +7 -0
- package/dist/lib/node-esm/hypercore-crypto.mjs +1 -1
- package/dist/lib/node-esm/hypercore.mjs +1050 -203
- package/dist/lib/node-esm/hypercore.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/package.json +7 -2
- package/dist/lib/browser/chunk-XAJ5RWMK.mjs +0 -223
- package/dist/lib/browser/chunk-XAJ5RWMK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IEADO42Y.mjs +0 -222
- package/dist/lib/node-esm/chunk-IEADO42Y.mjs.map +0 -7
|
@@ -5,8 +5,17 @@ import {
|
|
|
5
5
|
__reExport,
|
|
6
6
|
__require,
|
|
7
7
|
__toESM,
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
require_b4a,
|
|
9
|
+
require_crypto_aead,
|
|
10
|
+
require_crypto_generichash,
|
|
11
|
+
require_crypto_kx,
|
|
12
|
+
require_crypto_scalarmult,
|
|
13
|
+
require_helpers,
|
|
14
|
+
require_hypercore_crypto,
|
|
15
|
+
require_memory,
|
|
16
|
+
require_nanoassert,
|
|
17
|
+
require_sodium_javascript
|
|
18
|
+
} from "./chunk-H7LBQLKP.mjs";
|
|
10
19
|
|
|
11
20
|
// ../../node_modules/.pnpm/last-one-wins@1.0.4/node_modules/last-one-wins/index.js
|
|
12
21
|
var require_last_one_wins = __commonJS({
|
|
@@ -2105,23 +2114,6 @@ var require_safe_buffer_equals = __commonJS({
|
|
|
2105
2114
|
}
|
|
2106
2115
|
});
|
|
2107
2116
|
|
|
2108
|
-
// ../../node_modules/.pnpm/nanoassert@2.0.0/node_modules/nanoassert/index.js
|
|
2109
|
-
var require_nanoassert = __commonJS({
|
|
2110
|
-
"../../node_modules/.pnpm/nanoassert@2.0.0/node_modules/nanoassert/index.js"(exports, module) {
|
|
2111
|
-
module.exports = assert;
|
|
2112
|
-
var AssertionError = class extends Error {
|
|
2113
|
-
};
|
|
2114
|
-
AssertionError.prototype.name = "AssertionError";
|
|
2115
|
-
function assert(t, m) {
|
|
2116
|
-
if (!t) {
|
|
2117
|
-
var err = new AssertionError(m);
|
|
2118
|
-
if (Error.captureStackTrace) Error.captureStackTrace(err, assert);
|
|
2119
|
-
throw err;
|
|
2120
|
-
}
|
|
2121
|
-
}
|
|
2122
|
-
}
|
|
2123
|
-
});
|
|
2124
|
-
|
|
2125
2117
|
// ../../node_modules/.pnpm/clone@2.1.2/node_modules/clone/clone.js
|
|
2126
2118
|
var require_clone = __commonJS({
|
|
2127
2119
|
"../../node_modules/.pnpm/clone@2.1.2/node_modules/clone/clone.js"(exports, module) {
|
|
@@ -2321,14 +2313,14 @@ var require_clone = __commonJS({
|
|
|
2321
2313
|
// ../../node_modules/.pnpm/noise-protocol@3.0.1/node_modules/noise-protocol/cipher.js
|
|
2322
2314
|
var require_cipher = __commonJS({
|
|
2323
2315
|
"../../node_modules/.pnpm/noise-protocol@3.0.1/node_modules/noise-protocol/cipher.js"(exports, module) {
|
|
2324
|
-
var { sodium_malloc, sodium_memzero } =
|
|
2316
|
+
var { sodium_malloc, sodium_memzero } = require_memory();
|
|
2325
2317
|
var {
|
|
2326
2318
|
crypto_aead_chacha20poly1305_ietf_KEYBYTES,
|
|
2327
2319
|
crypto_aead_chacha20poly1305_ietf_NPUBBYTES,
|
|
2328
2320
|
crypto_aead_chacha20poly1305_ietf_ABYTES,
|
|
2329
2321
|
crypto_aead_chacha20poly1305_ietf_encrypt,
|
|
2330
2322
|
crypto_aead_chacha20poly1305_ietf_decrypt
|
|
2331
|
-
} =
|
|
2323
|
+
} = require_crypto_aead();
|
|
2332
2324
|
var assert = require_nanoassert();
|
|
2333
2325
|
var KEYLEN = 32;
|
|
2334
2326
|
var NONCELEN = 8;
|
|
@@ -2395,8 +2387,8 @@ var require_cipher = __commonJS({
|
|
|
2395
2387
|
// ../../node_modules/.pnpm/noise-protocol@3.0.1/node_modules/noise-protocol/cipher-state.js
|
|
2396
2388
|
var require_cipher_state = __commonJS({
|
|
2397
2389
|
"../../node_modules/.pnpm/noise-protocol@3.0.1/node_modules/noise-protocol/cipher-state.js"(exports, module) {
|
|
2398
|
-
var { sodium_memzero } =
|
|
2399
|
-
var { sodium_increment, sodium_memcmp, sodium_is_zero } =
|
|
2390
|
+
var { sodium_memzero } = require_memory();
|
|
2391
|
+
var { sodium_increment, sodium_memcmp, sodium_is_zero } = require_helpers();
|
|
2400
2392
|
var assert = require_nanoassert();
|
|
2401
2393
|
var cipher = require_cipher();
|
|
2402
2394
|
var STATELEN = cipher.KEYLEN + cipher.NONCELEN;
|
|
@@ -2528,8 +2520,8 @@ var require_nanoassert2 = __commonJS({
|
|
|
2528
2520
|
// ../../node_modules/.pnpm/hmac-blake2b@2.0.0/node_modules/hmac-blake2b/index.js
|
|
2529
2521
|
var require_hmac_blake2b = __commonJS({
|
|
2530
2522
|
"../../node_modules/.pnpm/hmac-blake2b@2.0.0/node_modules/hmac-blake2b/index.js"(exports, module) {
|
|
2531
|
-
var { sodium_malloc, sodium_memzero } =
|
|
2532
|
-
var { crypto_generichash, crypto_generichash_batch } =
|
|
2523
|
+
var { sodium_malloc, sodium_memzero } = require_memory();
|
|
2524
|
+
var { crypto_generichash, crypto_generichash_batch } = require_crypto_generichash();
|
|
2533
2525
|
var assert = require_nanoassert2();
|
|
2534
2526
|
var HASHLEN = 64;
|
|
2535
2527
|
var BLOCKLEN = 128;
|
|
@@ -2566,8 +2558,8 @@ var require_hmac_blake2b = __commonJS({
|
|
|
2566
2558
|
// ../../node_modules/.pnpm/noise-protocol@3.0.1/node_modules/noise-protocol/dh.js
|
|
2567
2559
|
var require_dh = __commonJS({
|
|
2568
2560
|
"../../node_modules/.pnpm/noise-protocol@3.0.1/node_modules/noise-protocol/dh.js"(exports, module) {
|
|
2569
|
-
var { crypto_kx_SEEDBYTES, crypto_kx_keypair, crypto_kx_seed_keypair } =
|
|
2570
|
-
var { crypto_scalarmult_BYTES, crypto_scalarmult_SCALARBYTES, crypto_scalarmult } =
|
|
2561
|
+
var { crypto_kx_SEEDBYTES, crypto_kx_keypair, crypto_kx_seed_keypair } = require_crypto_kx();
|
|
2562
|
+
var { crypto_scalarmult_BYTES, crypto_scalarmult_SCALARBYTES, crypto_scalarmult } = require_crypto_scalarmult();
|
|
2571
2563
|
var assert = require_nanoassert();
|
|
2572
2564
|
var DHLEN = crypto_scalarmult_BYTES;
|
|
2573
2565
|
var PKLEN = crypto_scalarmult_BYTES;
|
|
@@ -2609,8 +2601,8 @@ var require_dh = __commonJS({
|
|
|
2609
2601
|
// ../../node_modules/.pnpm/noise-protocol@3.0.1/node_modules/noise-protocol/hash.js
|
|
2610
2602
|
var require_hash = __commonJS({
|
|
2611
2603
|
"../../node_modules/.pnpm/noise-protocol@3.0.1/node_modules/noise-protocol/hash.js"(exports, module) {
|
|
2612
|
-
var { sodium_malloc, sodium_memzero } =
|
|
2613
|
-
var { crypto_generichash_batch } =
|
|
2604
|
+
var { sodium_malloc, sodium_memzero } = require_memory();
|
|
2605
|
+
var { crypto_generichash_batch } = require_crypto_generichash();
|
|
2614
2606
|
var assert = require_nanoassert();
|
|
2615
2607
|
var hmacBlake2b = require_hmac_blake2b();
|
|
2616
2608
|
var dh = require_dh();
|
|
@@ -2657,7 +2649,7 @@ var require_hash = __commonJS({
|
|
|
2657
2649
|
// ../../node_modules/.pnpm/noise-protocol@3.0.1/node_modules/noise-protocol/symmetric-state.js
|
|
2658
2650
|
var require_symmetric_state = __commonJS({
|
|
2659
2651
|
"../../node_modules/.pnpm/noise-protocol@3.0.1/node_modules/noise-protocol/symmetric-state.js"(exports, module) {
|
|
2660
|
-
var { sodium_malloc, sodium_memzero } =
|
|
2652
|
+
var { sodium_malloc, sodium_memzero } = require_memory();
|
|
2661
2653
|
var assert = require_nanoassert();
|
|
2662
2654
|
var cipherState = require_cipher_state();
|
|
2663
2655
|
var hash = require_hash();
|
|
@@ -2784,7 +2776,7 @@ var require_symmetric_state = __commonJS({
|
|
|
2784
2776
|
// ../../node_modules/.pnpm/noise-protocol@3.0.1/node_modules/noise-protocol/handshake-state.js
|
|
2785
2777
|
var require_handshake_state = __commonJS({
|
|
2786
2778
|
"../../node_modules/.pnpm/noise-protocol@3.0.1/node_modules/noise-protocol/handshake-state.js"(exports, module) {
|
|
2787
|
-
var { sodium_malloc, sodium_memzero, sodium_free } =
|
|
2779
|
+
var { sodium_malloc, sodium_memzero, sodium_free } = require_memory();
|
|
2788
2780
|
var assert = require_nanoassert();
|
|
2789
2781
|
var clone = require_clone();
|
|
2790
2782
|
var symmetricState = require_symmetric_state();
|
|
@@ -3607,131 +3599,6 @@ var require_signed_varint = __commonJS({
|
|
|
3607
3599
|
}
|
|
3608
3600
|
});
|
|
3609
3601
|
|
|
3610
|
-
// ../../node_modules/.pnpm/b4a@1.6.4/node_modules/b4a/index.js
|
|
3611
|
-
var require_b4a = __commonJS({
|
|
3612
|
-
"../../node_modules/.pnpm/b4a@1.6.4/node_modules/b4a/index.js"(exports, module) {
|
|
3613
|
-
function isBuffer(value) {
|
|
3614
|
-
return Buffer.isBuffer(value) || value instanceof Uint8Array;
|
|
3615
|
-
}
|
|
3616
|
-
function isEncoding(encoding) {
|
|
3617
|
-
return Buffer.isEncoding(encoding);
|
|
3618
|
-
}
|
|
3619
|
-
function alloc(size, fill2, encoding) {
|
|
3620
|
-
return Buffer.alloc(size, fill2, encoding);
|
|
3621
|
-
}
|
|
3622
|
-
function allocUnsafe(size) {
|
|
3623
|
-
return Buffer.allocUnsafe(size);
|
|
3624
|
-
}
|
|
3625
|
-
function allocUnsafeSlow(size) {
|
|
3626
|
-
return Buffer.allocUnsafeSlow(size);
|
|
3627
|
-
}
|
|
3628
|
-
function byteLength(string, encoding) {
|
|
3629
|
-
return Buffer.byteLength(string, encoding);
|
|
3630
|
-
}
|
|
3631
|
-
function compare(a, b) {
|
|
3632
|
-
return Buffer.compare(a, b);
|
|
3633
|
-
}
|
|
3634
|
-
function concat(buffers, totalLength) {
|
|
3635
|
-
return Buffer.concat(buffers, totalLength);
|
|
3636
|
-
}
|
|
3637
|
-
function copy(source, target, targetStart, start, end) {
|
|
3638
|
-
return toBuffer(source).copy(target, targetStart, start, end);
|
|
3639
|
-
}
|
|
3640
|
-
function equals(a, b) {
|
|
3641
|
-
return toBuffer(a).equals(b);
|
|
3642
|
-
}
|
|
3643
|
-
function fill(buffer, value, offset, end, encoding) {
|
|
3644
|
-
return toBuffer(buffer).fill(value, offset, end, encoding);
|
|
3645
|
-
}
|
|
3646
|
-
function from(value, encodingOrOffset, length) {
|
|
3647
|
-
return Buffer.from(value, encodingOrOffset, length);
|
|
3648
|
-
}
|
|
3649
|
-
function includes(buffer, value, byteOffset, encoding) {
|
|
3650
|
-
return toBuffer(buffer).includes(value, byteOffset, encoding);
|
|
3651
|
-
}
|
|
3652
|
-
function indexOf(buffer, value, byfeOffset, encoding) {
|
|
3653
|
-
return toBuffer(buffer).indexOf(value, byfeOffset, encoding);
|
|
3654
|
-
}
|
|
3655
|
-
function lastIndexOf(buffer, value, byteOffset, encoding) {
|
|
3656
|
-
return toBuffer(buffer).lastIndexOf(value, byteOffset, encoding);
|
|
3657
|
-
}
|
|
3658
|
-
function swap16(buffer) {
|
|
3659
|
-
return toBuffer(buffer).swap16();
|
|
3660
|
-
}
|
|
3661
|
-
function swap32(buffer) {
|
|
3662
|
-
return toBuffer(buffer).swap32();
|
|
3663
|
-
}
|
|
3664
|
-
function swap64(buffer) {
|
|
3665
|
-
return toBuffer(buffer).swap64();
|
|
3666
|
-
}
|
|
3667
|
-
function toBuffer(buffer) {
|
|
3668
|
-
if (Buffer.isBuffer(buffer)) return buffer;
|
|
3669
|
-
return Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
3670
|
-
}
|
|
3671
|
-
function toString(buffer, encoding, start, end) {
|
|
3672
|
-
return toBuffer(buffer).toString(encoding, start, end);
|
|
3673
|
-
}
|
|
3674
|
-
function write(buffer, string, offset, length, encoding) {
|
|
3675
|
-
return toBuffer(buffer).write(string, offset, length, encoding);
|
|
3676
|
-
}
|
|
3677
|
-
function writeDoubleLE(buffer, value, offset) {
|
|
3678
|
-
return toBuffer(buffer).writeDoubleLE(value, offset);
|
|
3679
|
-
}
|
|
3680
|
-
function writeFloatLE(buffer, value, offset) {
|
|
3681
|
-
return toBuffer(buffer).writeFloatLE(value, offset);
|
|
3682
|
-
}
|
|
3683
|
-
function writeUInt32LE(buffer, value, offset) {
|
|
3684
|
-
return toBuffer(buffer).writeUInt32LE(value, offset);
|
|
3685
|
-
}
|
|
3686
|
-
function writeInt32LE(buffer, value, offset) {
|
|
3687
|
-
return toBuffer(buffer).writeInt32LE(value, offset);
|
|
3688
|
-
}
|
|
3689
|
-
function readDoubleLE(buffer, offset) {
|
|
3690
|
-
return toBuffer(buffer).readDoubleLE(offset);
|
|
3691
|
-
}
|
|
3692
|
-
function readFloatLE(buffer, offset) {
|
|
3693
|
-
return toBuffer(buffer).readFloatLE(offset);
|
|
3694
|
-
}
|
|
3695
|
-
function readUInt32LE(buffer, offset) {
|
|
3696
|
-
return toBuffer(buffer).readUInt32LE(offset);
|
|
3697
|
-
}
|
|
3698
|
-
function readInt32LE(buffer, offset) {
|
|
3699
|
-
return toBuffer(buffer).readInt32LE(offset);
|
|
3700
|
-
}
|
|
3701
|
-
module.exports = {
|
|
3702
|
-
isBuffer,
|
|
3703
|
-
isEncoding,
|
|
3704
|
-
alloc,
|
|
3705
|
-
allocUnsafe,
|
|
3706
|
-
allocUnsafeSlow,
|
|
3707
|
-
byteLength,
|
|
3708
|
-
compare,
|
|
3709
|
-
concat,
|
|
3710
|
-
copy,
|
|
3711
|
-
equals,
|
|
3712
|
-
fill,
|
|
3713
|
-
from,
|
|
3714
|
-
includes,
|
|
3715
|
-
indexOf,
|
|
3716
|
-
lastIndexOf,
|
|
3717
|
-
swap16,
|
|
3718
|
-
swap32,
|
|
3719
|
-
swap64,
|
|
3720
|
-
toBuffer,
|
|
3721
|
-
toString,
|
|
3722
|
-
write,
|
|
3723
|
-
writeDoubleLE,
|
|
3724
|
-
writeFloatLE,
|
|
3725
|
-
writeUInt32LE,
|
|
3726
|
-
writeInt32LE,
|
|
3727
|
-
readDoubleLE,
|
|
3728
|
-
readFloatLE,
|
|
3729
|
-
readUInt32LE,
|
|
3730
|
-
readInt32LE
|
|
3731
|
-
};
|
|
3732
|
-
}
|
|
3733
|
-
});
|
|
3734
|
-
|
|
3735
3602
|
// ../../node_modules/.pnpm/protocol-buffers-encodings@1.2.0/node_modules/protocol-buffers-encodings/index.js
|
|
3736
3603
|
var require_protocol_buffers_encodings = __commonJS({
|
|
3737
3604
|
"../../node_modules/.pnpm/protocol-buffers-encodings@1.2.0/node_modules/protocol-buffers-encodings/index.js"(exports) {
|
|
@@ -5105,7 +4972,7 @@ var require_messages = __commonJS({
|
|
|
5105
4972
|
// ../../node_modules/.pnpm/xsalsa20-universal@1.0.0/node_modules/xsalsa20-universal/index.js
|
|
5106
4973
|
var require_xsalsa20_universal = __commonJS({
|
|
5107
4974
|
"../../node_modules/.pnpm/xsalsa20-universal@1.0.0/node_modules/xsalsa20-universal/index.js"(exports, module) {
|
|
5108
|
-
var sodium =
|
|
4975
|
+
var sodium = require_sodium_javascript();
|
|
5109
4976
|
module.exports = class XORNative {
|
|
5110
4977
|
constructor(nonce, key) {
|
|
5111
4978
|
this.handle = Buffer.alloc(sodium.crypto_stream_xor_STATEBYTES);
|
|
@@ -5788,6 +5655,998 @@ var require_abstract_extension = __commonJS({
|
|
|
5788
5655
|
}
|
|
5789
5656
|
});
|
|
5790
5657
|
|
|
5658
|
+
// ../../node_modules/.pnpm/queue-tick@1.0.1/node_modules/queue-tick/queue-microtask.js
|
|
5659
|
+
var require_queue_microtask = __commonJS({
|
|
5660
|
+
"../../node_modules/.pnpm/queue-tick@1.0.1/node_modules/queue-tick/queue-microtask.js"(exports, module) {
|
|
5661
|
+
module.exports = typeof queueMicrotask === "function" ? queueMicrotask : (fn) => Promise.resolve().then(fn);
|
|
5662
|
+
}
|
|
5663
|
+
});
|
|
5664
|
+
|
|
5665
|
+
// ../../node_modules/.pnpm/queue-tick@1.0.1/node_modules/queue-tick/process-next-tick.js
|
|
5666
|
+
var require_process_next_tick = __commonJS({
|
|
5667
|
+
"../../node_modules/.pnpm/queue-tick@1.0.1/node_modules/queue-tick/process-next-tick.js"(exports, module) {
|
|
5668
|
+
module.exports = typeof process !== "undefined" && typeof process.nextTick === "function" ? process.nextTick.bind(process) : require_queue_microtask();
|
|
5669
|
+
}
|
|
5670
|
+
});
|
|
5671
|
+
|
|
5672
|
+
// ../../node_modules/.pnpm/fast-fifo@1.3.2/node_modules/fast-fifo/fixed-size.js
|
|
5673
|
+
var require_fixed_size = __commonJS({
|
|
5674
|
+
"../../node_modules/.pnpm/fast-fifo@1.3.2/node_modules/fast-fifo/fixed-size.js"(exports, module) {
|
|
5675
|
+
module.exports = class FixedFIFO {
|
|
5676
|
+
constructor(hwm) {
|
|
5677
|
+
if (!(hwm > 0) || (hwm - 1 & hwm) !== 0) throw new Error("Max size for a FixedFIFO should be a power of two");
|
|
5678
|
+
this.buffer = new Array(hwm);
|
|
5679
|
+
this.mask = hwm - 1;
|
|
5680
|
+
this.top = 0;
|
|
5681
|
+
this.btm = 0;
|
|
5682
|
+
this.next = null;
|
|
5683
|
+
}
|
|
5684
|
+
clear() {
|
|
5685
|
+
this.top = this.btm = 0;
|
|
5686
|
+
this.next = null;
|
|
5687
|
+
this.buffer.fill(void 0);
|
|
5688
|
+
}
|
|
5689
|
+
push(data) {
|
|
5690
|
+
if (this.buffer[this.top] !== void 0) return false;
|
|
5691
|
+
this.buffer[this.top] = data;
|
|
5692
|
+
this.top = this.top + 1 & this.mask;
|
|
5693
|
+
return true;
|
|
5694
|
+
}
|
|
5695
|
+
shift() {
|
|
5696
|
+
const last = this.buffer[this.btm];
|
|
5697
|
+
if (last === void 0) return void 0;
|
|
5698
|
+
this.buffer[this.btm] = void 0;
|
|
5699
|
+
this.btm = this.btm + 1 & this.mask;
|
|
5700
|
+
return last;
|
|
5701
|
+
}
|
|
5702
|
+
peek() {
|
|
5703
|
+
return this.buffer[this.btm];
|
|
5704
|
+
}
|
|
5705
|
+
isEmpty() {
|
|
5706
|
+
return this.buffer[this.btm] === void 0;
|
|
5707
|
+
}
|
|
5708
|
+
};
|
|
5709
|
+
}
|
|
5710
|
+
});
|
|
5711
|
+
|
|
5712
|
+
// ../../node_modules/.pnpm/fast-fifo@1.3.2/node_modules/fast-fifo/index.js
|
|
5713
|
+
var require_fast_fifo = __commonJS({
|
|
5714
|
+
"../../node_modules/.pnpm/fast-fifo@1.3.2/node_modules/fast-fifo/index.js"(exports, module) {
|
|
5715
|
+
var FixedFIFO = require_fixed_size();
|
|
5716
|
+
module.exports = class FastFIFO {
|
|
5717
|
+
constructor(hwm) {
|
|
5718
|
+
this.hwm = hwm || 16;
|
|
5719
|
+
this.head = new FixedFIFO(this.hwm);
|
|
5720
|
+
this.tail = this.head;
|
|
5721
|
+
this.length = 0;
|
|
5722
|
+
}
|
|
5723
|
+
clear() {
|
|
5724
|
+
this.head = this.tail;
|
|
5725
|
+
this.head.clear();
|
|
5726
|
+
this.length = 0;
|
|
5727
|
+
}
|
|
5728
|
+
push(val) {
|
|
5729
|
+
this.length++;
|
|
5730
|
+
if (!this.head.push(val)) {
|
|
5731
|
+
const prev = this.head;
|
|
5732
|
+
this.head = prev.next = new FixedFIFO(2 * this.head.buffer.length);
|
|
5733
|
+
this.head.push(val);
|
|
5734
|
+
}
|
|
5735
|
+
}
|
|
5736
|
+
shift() {
|
|
5737
|
+
if (this.length !== 0) this.length--;
|
|
5738
|
+
const val = this.tail.shift();
|
|
5739
|
+
if (val === void 0 && this.tail.next) {
|
|
5740
|
+
const next = this.tail.next;
|
|
5741
|
+
this.tail.next = null;
|
|
5742
|
+
this.tail = next;
|
|
5743
|
+
return this.tail.shift();
|
|
5744
|
+
}
|
|
5745
|
+
return val;
|
|
5746
|
+
}
|
|
5747
|
+
peek() {
|
|
5748
|
+
const val = this.tail.peek();
|
|
5749
|
+
if (val === void 0 && this.tail.next) return this.tail.next.peek();
|
|
5750
|
+
return val;
|
|
5751
|
+
}
|
|
5752
|
+
isEmpty() {
|
|
5753
|
+
return this.length === 0;
|
|
5754
|
+
}
|
|
5755
|
+
};
|
|
5756
|
+
}
|
|
5757
|
+
});
|
|
5758
|
+
|
|
5759
|
+
// ../../node_modules/.pnpm/streamx@2.15.6/node_modules/streamx/index.js
|
|
5760
|
+
var require_streamx = __commonJS({
|
|
5761
|
+
"../../node_modules/.pnpm/streamx@2.15.6/node_modules/streamx/index.js"(exports, module) {
|
|
5762
|
+
var { EventEmitter } = __require("node:events");
|
|
5763
|
+
var STREAM_DESTROYED = new Error("Stream was destroyed");
|
|
5764
|
+
var PREMATURE_CLOSE = new Error("Premature close");
|
|
5765
|
+
var queueTick = require_process_next_tick();
|
|
5766
|
+
var FIFO = require_fast_fifo();
|
|
5767
|
+
var MAX = (1 << 27) - 1;
|
|
5768
|
+
var OPENING = 1;
|
|
5769
|
+
var PREDESTROYING = 2;
|
|
5770
|
+
var DESTROYING = 4;
|
|
5771
|
+
var DESTROYED = 8;
|
|
5772
|
+
var NOT_OPENING = MAX ^ OPENING;
|
|
5773
|
+
var NOT_PREDESTROYING = MAX ^ PREDESTROYING;
|
|
5774
|
+
var READ_ACTIVE = 1 << 4;
|
|
5775
|
+
var READ_UPDATING = 2 << 4;
|
|
5776
|
+
var READ_PRIMARY = 4 << 4;
|
|
5777
|
+
var READ_QUEUED = 8 << 4;
|
|
5778
|
+
var READ_RESUMED = 16 << 4;
|
|
5779
|
+
var READ_PIPE_DRAINED = 32 << 4;
|
|
5780
|
+
var READ_ENDING = 64 << 4;
|
|
5781
|
+
var READ_EMIT_DATA = 128 << 4;
|
|
5782
|
+
var READ_EMIT_READABLE = 256 << 4;
|
|
5783
|
+
var READ_EMITTED_READABLE = 512 << 4;
|
|
5784
|
+
var READ_DONE = 1024 << 4;
|
|
5785
|
+
var READ_NEXT_TICK = 2048 << 4;
|
|
5786
|
+
var READ_NEEDS_PUSH = 4096 << 4;
|
|
5787
|
+
var READ_FLOWING = READ_RESUMED | READ_PIPE_DRAINED;
|
|
5788
|
+
var READ_ACTIVE_AND_NEEDS_PUSH = READ_ACTIVE | READ_NEEDS_PUSH;
|
|
5789
|
+
var READ_PRIMARY_AND_ACTIVE = READ_PRIMARY | READ_ACTIVE;
|
|
5790
|
+
var READ_EMIT_READABLE_AND_QUEUED = READ_EMIT_READABLE | READ_QUEUED;
|
|
5791
|
+
var READ_NOT_ACTIVE = MAX ^ READ_ACTIVE;
|
|
5792
|
+
var READ_NON_PRIMARY = MAX ^ READ_PRIMARY;
|
|
5793
|
+
var READ_NON_PRIMARY_AND_PUSHED = MAX ^ (READ_PRIMARY | READ_NEEDS_PUSH);
|
|
5794
|
+
var READ_PUSHED = MAX ^ READ_NEEDS_PUSH;
|
|
5795
|
+
var READ_PAUSED = MAX ^ READ_RESUMED;
|
|
5796
|
+
var READ_NOT_QUEUED = MAX ^ (READ_QUEUED | READ_EMITTED_READABLE);
|
|
5797
|
+
var READ_NOT_ENDING = MAX ^ READ_ENDING;
|
|
5798
|
+
var READ_PIPE_NOT_DRAINED = MAX ^ READ_FLOWING;
|
|
5799
|
+
var READ_NOT_NEXT_TICK = MAX ^ READ_NEXT_TICK;
|
|
5800
|
+
var READ_NOT_UPDATING = MAX ^ READ_UPDATING;
|
|
5801
|
+
var WRITE_ACTIVE = 1 << 17;
|
|
5802
|
+
var WRITE_UPDATING = 2 << 17;
|
|
5803
|
+
var WRITE_PRIMARY = 4 << 17;
|
|
5804
|
+
var WRITE_QUEUED = 8 << 17;
|
|
5805
|
+
var WRITE_UNDRAINED = 16 << 17;
|
|
5806
|
+
var WRITE_DONE = 32 << 17;
|
|
5807
|
+
var WRITE_EMIT_DRAIN = 64 << 17;
|
|
5808
|
+
var WRITE_NEXT_TICK = 128 << 17;
|
|
5809
|
+
var WRITE_WRITING = 256 << 17;
|
|
5810
|
+
var WRITE_FINISHING = 512 << 17;
|
|
5811
|
+
var WRITE_NOT_ACTIVE = MAX ^ (WRITE_ACTIVE | WRITE_WRITING);
|
|
5812
|
+
var WRITE_NON_PRIMARY = MAX ^ WRITE_PRIMARY;
|
|
5813
|
+
var WRITE_NOT_FINISHING = MAX ^ WRITE_FINISHING;
|
|
5814
|
+
var WRITE_DRAINED = MAX ^ WRITE_UNDRAINED;
|
|
5815
|
+
var WRITE_NOT_QUEUED = MAX ^ WRITE_QUEUED;
|
|
5816
|
+
var WRITE_NOT_NEXT_TICK = MAX ^ WRITE_NEXT_TICK;
|
|
5817
|
+
var WRITE_NOT_UPDATING = MAX ^ WRITE_UPDATING;
|
|
5818
|
+
var ACTIVE = READ_ACTIVE | WRITE_ACTIVE;
|
|
5819
|
+
var NOT_ACTIVE = MAX ^ ACTIVE;
|
|
5820
|
+
var DONE = READ_DONE | WRITE_DONE;
|
|
5821
|
+
var DESTROY_STATUS = DESTROYING | DESTROYED | PREDESTROYING;
|
|
5822
|
+
var OPEN_STATUS = DESTROY_STATUS | OPENING;
|
|
5823
|
+
var AUTO_DESTROY = DESTROY_STATUS | DONE;
|
|
5824
|
+
var NON_PRIMARY = WRITE_NON_PRIMARY & READ_NON_PRIMARY;
|
|
5825
|
+
var ACTIVE_OR_TICKING = WRITE_NEXT_TICK | READ_NEXT_TICK;
|
|
5826
|
+
var TICKING = ACTIVE_OR_TICKING & NOT_ACTIVE;
|
|
5827
|
+
var IS_OPENING = OPEN_STATUS | TICKING;
|
|
5828
|
+
var READ_PRIMARY_STATUS = OPEN_STATUS | READ_ENDING | READ_DONE;
|
|
5829
|
+
var READ_STATUS = OPEN_STATUS | READ_DONE | READ_QUEUED;
|
|
5830
|
+
var READ_ENDING_STATUS = OPEN_STATUS | READ_ENDING | READ_QUEUED;
|
|
5831
|
+
var READ_READABLE_STATUS = OPEN_STATUS | READ_EMIT_READABLE | READ_QUEUED | READ_EMITTED_READABLE;
|
|
5832
|
+
var SHOULD_NOT_READ = OPEN_STATUS | READ_ACTIVE | READ_ENDING | READ_DONE | READ_NEEDS_PUSH;
|
|
5833
|
+
var READ_BACKPRESSURE_STATUS = DESTROY_STATUS | READ_ENDING | READ_DONE;
|
|
5834
|
+
var READ_UPDATE_SYNC_STATUS = READ_UPDATING | OPEN_STATUS | READ_NEXT_TICK | READ_PRIMARY;
|
|
5835
|
+
var WRITE_PRIMARY_STATUS = OPEN_STATUS | WRITE_FINISHING | WRITE_DONE;
|
|
5836
|
+
var WRITE_QUEUED_AND_UNDRAINED = WRITE_QUEUED | WRITE_UNDRAINED;
|
|
5837
|
+
var WRITE_QUEUED_AND_ACTIVE = WRITE_QUEUED | WRITE_ACTIVE;
|
|
5838
|
+
var WRITE_DRAIN_STATUS = WRITE_QUEUED | WRITE_UNDRAINED | OPEN_STATUS | WRITE_ACTIVE;
|
|
5839
|
+
var WRITE_STATUS = OPEN_STATUS | WRITE_ACTIVE | WRITE_QUEUED;
|
|
5840
|
+
var WRITE_PRIMARY_AND_ACTIVE = WRITE_PRIMARY | WRITE_ACTIVE;
|
|
5841
|
+
var WRITE_ACTIVE_AND_WRITING = WRITE_ACTIVE | WRITE_WRITING;
|
|
5842
|
+
var WRITE_FINISHING_STATUS = OPEN_STATUS | WRITE_FINISHING | WRITE_QUEUED_AND_ACTIVE | WRITE_DONE;
|
|
5843
|
+
var WRITE_BACKPRESSURE_STATUS = WRITE_UNDRAINED | DESTROY_STATUS | WRITE_FINISHING | WRITE_DONE;
|
|
5844
|
+
var WRITE_UPDATE_SYNC_STATUS = WRITE_UPDATING | OPEN_STATUS | WRITE_NEXT_TICK | WRITE_PRIMARY;
|
|
5845
|
+
var asyncIterator = Symbol.asyncIterator || Symbol("asyncIterator");
|
|
5846
|
+
var WritableState = class {
|
|
5847
|
+
constructor(stream, { highWaterMark = 16384, map = null, mapWritable, byteLength, byteLengthWritable } = {}) {
|
|
5848
|
+
this.stream = stream;
|
|
5849
|
+
this.queue = new FIFO();
|
|
5850
|
+
this.highWaterMark = highWaterMark;
|
|
5851
|
+
this.buffered = 0;
|
|
5852
|
+
this.error = null;
|
|
5853
|
+
this.pipeline = null;
|
|
5854
|
+
this.drains = null;
|
|
5855
|
+
this.byteLength = byteLengthWritable || byteLength || defaultByteLength;
|
|
5856
|
+
this.map = mapWritable || map;
|
|
5857
|
+
this.afterWrite = afterWrite.bind(this);
|
|
5858
|
+
this.afterUpdateNextTick = updateWriteNT.bind(this);
|
|
5859
|
+
}
|
|
5860
|
+
get ended() {
|
|
5861
|
+
return (this.stream._duplexState & WRITE_DONE) !== 0;
|
|
5862
|
+
}
|
|
5863
|
+
push(data) {
|
|
5864
|
+
if (this.map !== null) data = this.map(data);
|
|
5865
|
+
this.buffered += this.byteLength(data);
|
|
5866
|
+
this.queue.push(data);
|
|
5867
|
+
if (this.buffered < this.highWaterMark) {
|
|
5868
|
+
this.stream._duplexState |= WRITE_QUEUED;
|
|
5869
|
+
return true;
|
|
5870
|
+
}
|
|
5871
|
+
this.stream._duplexState |= WRITE_QUEUED_AND_UNDRAINED;
|
|
5872
|
+
return false;
|
|
5873
|
+
}
|
|
5874
|
+
shift() {
|
|
5875
|
+
const data = this.queue.shift();
|
|
5876
|
+
this.buffered -= this.byteLength(data);
|
|
5877
|
+
if (this.buffered === 0) this.stream._duplexState &= WRITE_NOT_QUEUED;
|
|
5878
|
+
return data;
|
|
5879
|
+
}
|
|
5880
|
+
end(data) {
|
|
5881
|
+
if (typeof data === "function") this.stream.once("finish", data);
|
|
5882
|
+
else if (data !== void 0 && data !== null) this.push(data);
|
|
5883
|
+
this.stream._duplexState = (this.stream._duplexState | WRITE_FINISHING) & WRITE_NON_PRIMARY;
|
|
5884
|
+
}
|
|
5885
|
+
autoBatch(data, cb) {
|
|
5886
|
+
const buffer = [];
|
|
5887
|
+
const stream = this.stream;
|
|
5888
|
+
buffer.push(data);
|
|
5889
|
+
while ((stream._duplexState & WRITE_STATUS) === WRITE_QUEUED_AND_ACTIVE) {
|
|
5890
|
+
buffer.push(stream._writableState.shift());
|
|
5891
|
+
}
|
|
5892
|
+
if ((stream._duplexState & OPEN_STATUS) !== 0) return cb(null);
|
|
5893
|
+
stream._writev(buffer, cb);
|
|
5894
|
+
}
|
|
5895
|
+
update() {
|
|
5896
|
+
const stream = this.stream;
|
|
5897
|
+
stream._duplexState |= WRITE_UPDATING;
|
|
5898
|
+
do {
|
|
5899
|
+
while ((stream._duplexState & WRITE_STATUS) === WRITE_QUEUED) {
|
|
5900
|
+
const data = this.shift();
|
|
5901
|
+
stream._duplexState |= WRITE_ACTIVE_AND_WRITING;
|
|
5902
|
+
stream._write(data, this.afterWrite);
|
|
5903
|
+
}
|
|
5904
|
+
if ((stream._duplexState & WRITE_PRIMARY_AND_ACTIVE) === 0) this.updateNonPrimary();
|
|
5905
|
+
} while (this.continueUpdate() === true);
|
|
5906
|
+
stream._duplexState &= WRITE_NOT_UPDATING;
|
|
5907
|
+
}
|
|
5908
|
+
updateNonPrimary() {
|
|
5909
|
+
const stream = this.stream;
|
|
5910
|
+
if ((stream._duplexState & WRITE_FINISHING_STATUS) === WRITE_FINISHING) {
|
|
5911
|
+
stream._duplexState = (stream._duplexState | WRITE_ACTIVE) & WRITE_NOT_FINISHING;
|
|
5912
|
+
stream._final(afterFinal.bind(this));
|
|
5913
|
+
return;
|
|
5914
|
+
}
|
|
5915
|
+
if ((stream._duplexState & DESTROY_STATUS) === DESTROYING) {
|
|
5916
|
+
if ((stream._duplexState & ACTIVE_OR_TICKING) === 0) {
|
|
5917
|
+
stream._duplexState |= ACTIVE;
|
|
5918
|
+
stream._destroy(afterDestroy.bind(this));
|
|
5919
|
+
}
|
|
5920
|
+
return;
|
|
5921
|
+
}
|
|
5922
|
+
if ((stream._duplexState & IS_OPENING) === OPENING) {
|
|
5923
|
+
stream._duplexState = (stream._duplexState | ACTIVE) & NOT_OPENING;
|
|
5924
|
+
stream._open(afterOpen.bind(this));
|
|
5925
|
+
}
|
|
5926
|
+
}
|
|
5927
|
+
continueUpdate() {
|
|
5928
|
+
if ((this.stream._duplexState & WRITE_NEXT_TICK) === 0) return false;
|
|
5929
|
+
this.stream._duplexState &= WRITE_NOT_NEXT_TICK;
|
|
5930
|
+
return true;
|
|
5931
|
+
}
|
|
5932
|
+
updateCallback() {
|
|
5933
|
+
if ((this.stream._duplexState & WRITE_UPDATE_SYNC_STATUS) === WRITE_PRIMARY) this.update();
|
|
5934
|
+
else this.updateNextTick();
|
|
5935
|
+
}
|
|
5936
|
+
updateNextTick() {
|
|
5937
|
+
if ((this.stream._duplexState & WRITE_NEXT_TICK) !== 0) return;
|
|
5938
|
+
this.stream._duplexState |= WRITE_NEXT_TICK;
|
|
5939
|
+
if ((this.stream._duplexState & WRITE_UPDATING) === 0) queueTick(this.afterUpdateNextTick);
|
|
5940
|
+
}
|
|
5941
|
+
};
|
|
5942
|
+
var ReadableState = class {
|
|
5943
|
+
constructor(stream, { highWaterMark = 16384, map = null, mapReadable, byteLength, byteLengthReadable } = {}) {
|
|
5944
|
+
this.stream = stream;
|
|
5945
|
+
this.queue = new FIFO();
|
|
5946
|
+
this.highWaterMark = highWaterMark;
|
|
5947
|
+
this.buffered = 0;
|
|
5948
|
+
this.error = null;
|
|
5949
|
+
this.pipeline = null;
|
|
5950
|
+
this.byteLength = byteLengthReadable || byteLength || defaultByteLength;
|
|
5951
|
+
this.map = mapReadable || map;
|
|
5952
|
+
this.pipeTo = null;
|
|
5953
|
+
this.afterRead = afterRead.bind(this);
|
|
5954
|
+
this.afterUpdateNextTick = updateReadNT.bind(this);
|
|
5955
|
+
}
|
|
5956
|
+
get ended() {
|
|
5957
|
+
return (this.stream._duplexState & READ_DONE) !== 0;
|
|
5958
|
+
}
|
|
5959
|
+
pipe(pipeTo, cb) {
|
|
5960
|
+
if (this.pipeTo !== null) throw new Error("Can only pipe to one destination");
|
|
5961
|
+
if (typeof cb !== "function") cb = null;
|
|
5962
|
+
this.stream._duplexState |= READ_PIPE_DRAINED;
|
|
5963
|
+
this.pipeTo = pipeTo;
|
|
5964
|
+
this.pipeline = new Pipeline(this.stream, pipeTo, cb);
|
|
5965
|
+
if (cb) this.stream.on("error", noop);
|
|
5966
|
+
if (isStreamx(pipeTo)) {
|
|
5967
|
+
pipeTo._writableState.pipeline = this.pipeline;
|
|
5968
|
+
if (cb) pipeTo.on("error", noop);
|
|
5969
|
+
pipeTo.on("finish", this.pipeline.finished.bind(this.pipeline));
|
|
5970
|
+
} else {
|
|
5971
|
+
const onerror = this.pipeline.done.bind(this.pipeline, pipeTo);
|
|
5972
|
+
const onclose = this.pipeline.done.bind(this.pipeline, pipeTo, null);
|
|
5973
|
+
pipeTo.on("error", onerror);
|
|
5974
|
+
pipeTo.on("close", onclose);
|
|
5975
|
+
pipeTo.on("finish", this.pipeline.finished.bind(this.pipeline));
|
|
5976
|
+
}
|
|
5977
|
+
pipeTo.on("drain", afterDrain.bind(this));
|
|
5978
|
+
this.stream.emit("piping", pipeTo);
|
|
5979
|
+
pipeTo.emit("pipe", this.stream);
|
|
5980
|
+
}
|
|
5981
|
+
push(data) {
|
|
5982
|
+
const stream = this.stream;
|
|
5983
|
+
if (data === null) {
|
|
5984
|
+
this.highWaterMark = 0;
|
|
5985
|
+
stream._duplexState = (stream._duplexState | READ_ENDING) & READ_NON_PRIMARY_AND_PUSHED;
|
|
5986
|
+
return false;
|
|
5987
|
+
}
|
|
5988
|
+
if (this.map !== null) data = this.map(data);
|
|
5989
|
+
this.buffered += this.byteLength(data);
|
|
5990
|
+
this.queue.push(data);
|
|
5991
|
+
stream._duplexState = (stream._duplexState | READ_QUEUED) & READ_PUSHED;
|
|
5992
|
+
return this.buffered < this.highWaterMark;
|
|
5993
|
+
}
|
|
5994
|
+
shift() {
|
|
5995
|
+
const data = this.queue.shift();
|
|
5996
|
+
this.buffered -= this.byteLength(data);
|
|
5997
|
+
if (this.buffered === 0) this.stream._duplexState &= READ_NOT_QUEUED;
|
|
5998
|
+
return data;
|
|
5999
|
+
}
|
|
6000
|
+
unshift(data) {
|
|
6001
|
+
const pending = [this.map !== null ? this.map(data) : data];
|
|
6002
|
+
while (this.buffered > 0) pending.push(this.shift());
|
|
6003
|
+
for (let i = 0; i < pending.length - 1; i++) {
|
|
6004
|
+
const data2 = pending[i];
|
|
6005
|
+
this.buffered += this.byteLength(data2);
|
|
6006
|
+
this.queue.push(data2);
|
|
6007
|
+
}
|
|
6008
|
+
this.push(pending[pending.length - 1]);
|
|
6009
|
+
}
|
|
6010
|
+
read() {
|
|
6011
|
+
const stream = this.stream;
|
|
6012
|
+
if ((stream._duplexState & READ_STATUS) === READ_QUEUED) {
|
|
6013
|
+
const data = this.shift();
|
|
6014
|
+
if (this.pipeTo !== null && this.pipeTo.write(data) === false) stream._duplexState &= READ_PIPE_NOT_DRAINED;
|
|
6015
|
+
if ((stream._duplexState & READ_EMIT_DATA) !== 0) stream.emit("data", data);
|
|
6016
|
+
return data;
|
|
6017
|
+
}
|
|
6018
|
+
return null;
|
|
6019
|
+
}
|
|
6020
|
+
drain() {
|
|
6021
|
+
const stream = this.stream;
|
|
6022
|
+
while ((stream._duplexState & READ_STATUS) === READ_QUEUED && (stream._duplexState & READ_FLOWING) !== 0) {
|
|
6023
|
+
const data = this.shift();
|
|
6024
|
+
if (this.pipeTo !== null && this.pipeTo.write(data) === false) stream._duplexState &= READ_PIPE_NOT_DRAINED;
|
|
6025
|
+
if ((stream._duplexState & READ_EMIT_DATA) !== 0) stream.emit("data", data);
|
|
6026
|
+
}
|
|
6027
|
+
}
|
|
6028
|
+
update() {
|
|
6029
|
+
const stream = this.stream;
|
|
6030
|
+
stream._duplexState |= READ_UPDATING;
|
|
6031
|
+
do {
|
|
6032
|
+
this.drain();
|
|
6033
|
+
while (this.buffered < this.highWaterMark && (stream._duplexState & SHOULD_NOT_READ) === 0) {
|
|
6034
|
+
stream._duplexState |= READ_ACTIVE_AND_NEEDS_PUSH;
|
|
6035
|
+
stream._read(this.afterRead);
|
|
6036
|
+
this.drain();
|
|
6037
|
+
}
|
|
6038
|
+
if ((stream._duplexState & READ_READABLE_STATUS) === READ_EMIT_READABLE_AND_QUEUED) {
|
|
6039
|
+
stream._duplexState |= READ_EMITTED_READABLE;
|
|
6040
|
+
stream.emit("readable");
|
|
6041
|
+
}
|
|
6042
|
+
if ((stream._duplexState & READ_PRIMARY_AND_ACTIVE) === 0) this.updateNonPrimary();
|
|
6043
|
+
} while (this.continueUpdate() === true);
|
|
6044
|
+
stream._duplexState &= READ_NOT_UPDATING;
|
|
6045
|
+
}
|
|
6046
|
+
updateNonPrimary() {
|
|
6047
|
+
const stream = this.stream;
|
|
6048
|
+
if ((stream._duplexState & READ_ENDING_STATUS) === READ_ENDING) {
|
|
6049
|
+
stream._duplexState = (stream._duplexState | READ_DONE) & READ_NOT_ENDING;
|
|
6050
|
+
stream.emit("end");
|
|
6051
|
+
if ((stream._duplexState & AUTO_DESTROY) === DONE) stream._duplexState |= DESTROYING;
|
|
6052
|
+
if (this.pipeTo !== null) this.pipeTo.end();
|
|
6053
|
+
}
|
|
6054
|
+
if ((stream._duplexState & DESTROY_STATUS) === DESTROYING) {
|
|
6055
|
+
if ((stream._duplexState & ACTIVE_OR_TICKING) === 0) {
|
|
6056
|
+
stream._duplexState |= ACTIVE;
|
|
6057
|
+
stream._destroy(afterDestroy.bind(this));
|
|
6058
|
+
}
|
|
6059
|
+
return;
|
|
6060
|
+
}
|
|
6061
|
+
if ((stream._duplexState & IS_OPENING) === OPENING) {
|
|
6062
|
+
stream._duplexState = (stream._duplexState | ACTIVE) & NOT_OPENING;
|
|
6063
|
+
stream._open(afterOpen.bind(this));
|
|
6064
|
+
}
|
|
6065
|
+
}
|
|
6066
|
+
continueUpdate() {
|
|
6067
|
+
if ((this.stream._duplexState & READ_NEXT_TICK) === 0) return false;
|
|
6068
|
+
this.stream._duplexState &= READ_NOT_NEXT_TICK;
|
|
6069
|
+
return true;
|
|
6070
|
+
}
|
|
6071
|
+
updateCallback() {
|
|
6072
|
+
if ((this.stream._duplexState & READ_UPDATE_SYNC_STATUS) === READ_PRIMARY) this.update();
|
|
6073
|
+
else this.updateNextTick();
|
|
6074
|
+
}
|
|
6075
|
+
updateNextTick() {
|
|
6076
|
+
if ((this.stream._duplexState & READ_NEXT_TICK) !== 0) return;
|
|
6077
|
+
this.stream._duplexState |= READ_NEXT_TICK;
|
|
6078
|
+
if ((this.stream._duplexState & READ_UPDATING) === 0) queueTick(this.afterUpdateNextTick);
|
|
6079
|
+
}
|
|
6080
|
+
};
|
|
6081
|
+
var TransformState = class {
|
|
6082
|
+
constructor(stream) {
|
|
6083
|
+
this.data = null;
|
|
6084
|
+
this.afterTransform = afterTransform.bind(stream);
|
|
6085
|
+
this.afterFinal = null;
|
|
6086
|
+
}
|
|
6087
|
+
};
|
|
6088
|
+
var Pipeline = class {
|
|
6089
|
+
constructor(src, dst, cb) {
|
|
6090
|
+
this.from = src;
|
|
6091
|
+
this.to = dst;
|
|
6092
|
+
this.afterPipe = cb;
|
|
6093
|
+
this.error = null;
|
|
6094
|
+
this.pipeToFinished = false;
|
|
6095
|
+
}
|
|
6096
|
+
finished() {
|
|
6097
|
+
this.pipeToFinished = true;
|
|
6098
|
+
}
|
|
6099
|
+
done(stream, err) {
|
|
6100
|
+
if (err) this.error = err;
|
|
6101
|
+
if (stream === this.to) {
|
|
6102
|
+
this.to = null;
|
|
6103
|
+
if (this.from !== null) {
|
|
6104
|
+
if ((this.from._duplexState & READ_DONE) === 0 || !this.pipeToFinished) {
|
|
6105
|
+
this.from.destroy(this.error || new Error("Writable stream closed prematurely"));
|
|
6106
|
+
}
|
|
6107
|
+
return;
|
|
6108
|
+
}
|
|
6109
|
+
}
|
|
6110
|
+
if (stream === this.from) {
|
|
6111
|
+
this.from = null;
|
|
6112
|
+
if (this.to !== null) {
|
|
6113
|
+
if ((stream._duplexState & READ_DONE) === 0) {
|
|
6114
|
+
this.to.destroy(this.error || new Error("Readable stream closed before ending"));
|
|
6115
|
+
}
|
|
6116
|
+
return;
|
|
6117
|
+
}
|
|
6118
|
+
}
|
|
6119
|
+
if (this.afterPipe !== null) this.afterPipe(this.error);
|
|
6120
|
+
this.to = this.from = this.afterPipe = null;
|
|
6121
|
+
}
|
|
6122
|
+
};
|
|
6123
|
+
function afterDrain() {
|
|
6124
|
+
this.stream._duplexState |= READ_PIPE_DRAINED;
|
|
6125
|
+
this.updateCallback();
|
|
6126
|
+
}
|
|
6127
|
+
function afterFinal(err) {
|
|
6128
|
+
const stream = this.stream;
|
|
6129
|
+
if (err) stream.destroy(err);
|
|
6130
|
+
if ((stream._duplexState & DESTROY_STATUS) === 0) {
|
|
6131
|
+
stream._duplexState |= WRITE_DONE;
|
|
6132
|
+
stream.emit("finish");
|
|
6133
|
+
}
|
|
6134
|
+
if ((stream._duplexState & AUTO_DESTROY) === DONE) {
|
|
6135
|
+
stream._duplexState |= DESTROYING;
|
|
6136
|
+
}
|
|
6137
|
+
stream._duplexState &= WRITE_NOT_ACTIVE;
|
|
6138
|
+
if ((stream._duplexState & WRITE_UPDATING) === 0) this.update();
|
|
6139
|
+
else this.updateNextTick();
|
|
6140
|
+
}
|
|
6141
|
+
function afterDestroy(err) {
|
|
6142
|
+
const stream = this.stream;
|
|
6143
|
+
if (!err && this.error !== STREAM_DESTROYED) err = this.error;
|
|
6144
|
+
if (err) stream.emit("error", err);
|
|
6145
|
+
stream._duplexState |= DESTROYED;
|
|
6146
|
+
stream.emit("close");
|
|
6147
|
+
const rs = stream._readableState;
|
|
6148
|
+
const ws = stream._writableState;
|
|
6149
|
+
if (rs !== null && rs.pipeline !== null) rs.pipeline.done(stream, err);
|
|
6150
|
+
if (ws !== null) {
|
|
6151
|
+
while (ws.drains !== null && ws.drains.length > 0) ws.drains.shift().resolve(false);
|
|
6152
|
+
if (ws.pipeline !== null) ws.pipeline.done(stream, err);
|
|
6153
|
+
}
|
|
6154
|
+
}
|
|
6155
|
+
function afterWrite(err) {
|
|
6156
|
+
const stream = this.stream;
|
|
6157
|
+
if (err) stream.destroy(err);
|
|
6158
|
+
stream._duplexState &= WRITE_NOT_ACTIVE;
|
|
6159
|
+
if (this.drains !== null) tickDrains(this.drains);
|
|
6160
|
+
if ((stream._duplexState & WRITE_DRAIN_STATUS) === WRITE_UNDRAINED) {
|
|
6161
|
+
stream._duplexState &= WRITE_DRAINED;
|
|
6162
|
+
if ((stream._duplexState & WRITE_EMIT_DRAIN) === WRITE_EMIT_DRAIN) {
|
|
6163
|
+
stream.emit("drain");
|
|
6164
|
+
}
|
|
6165
|
+
}
|
|
6166
|
+
this.updateCallback();
|
|
6167
|
+
}
|
|
6168
|
+
function afterRead(err) {
|
|
6169
|
+
if (err) this.stream.destroy(err);
|
|
6170
|
+
this.stream._duplexState &= READ_NOT_ACTIVE;
|
|
6171
|
+
this.updateCallback();
|
|
6172
|
+
}
|
|
6173
|
+
function updateReadNT() {
|
|
6174
|
+
if ((this.stream._duplexState & READ_UPDATING) === 0) {
|
|
6175
|
+
this.stream._duplexState &= READ_NOT_NEXT_TICK;
|
|
6176
|
+
this.update();
|
|
6177
|
+
}
|
|
6178
|
+
}
|
|
6179
|
+
function updateWriteNT() {
|
|
6180
|
+
if ((this.stream._duplexState & WRITE_UPDATING) === 0) {
|
|
6181
|
+
this.stream._duplexState &= WRITE_NOT_NEXT_TICK;
|
|
6182
|
+
this.update();
|
|
6183
|
+
}
|
|
6184
|
+
}
|
|
6185
|
+
function tickDrains(drains) {
|
|
6186
|
+
for (let i = 0; i < drains.length; i++) {
|
|
6187
|
+
if (--drains[i].writes === 0) {
|
|
6188
|
+
drains.shift().resolve(true);
|
|
6189
|
+
i--;
|
|
6190
|
+
}
|
|
6191
|
+
}
|
|
6192
|
+
}
|
|
6193
|
+
function afterOpen(err) {
|
|
6194
|
+
const stream = this.stream;
|
|
6195
|
+
if (err) stream.destroy(err);
|
|
6196
|
+
if ((stream._duplexState & DESTROYING) === 0) {
|
|
6197
|
+
if ((stream._duplexState & READ_PRIMARY_STATUS) === 0) stream._duplexState |= READ_PRIMARY;
|
|
6198
|
+
if ((stream._duplexState & WRITE_PRIMARY_STATUS) === 0) stream._duplexState |= WRITE_PRIMARY;
|
|
6199
|
+
stream.emit("open");
|
|
6200
|
+
}
|
|
6201
|
+
stream._duplexState &= NOT_ACTIVE;
|
|
6202
|
+
if (stream._writableState !== null) {
|
|
6203
|
+
stream._writableState.updateCallback();
|
|
6204
|
+
}
|
|
6205
|
+
if (stream._readableState !== null) {
|
|
6206
|
+
stream._readableState.updateCallback();
|
|
6207
|
+
}
|
|
6208
|
+
}
|
|
6209
|
+
function afterTransform(err, data) {
|
|
6210
|
+
if (data !== void 0 && data !== null) this.push(data);
|
|
6211
|
+
this._writableState.afterWrite(err);
|
|
6212
|
+
}
|
|
6213
|
+
function newListener(name) {
|
|
6214
|
+
if (this._readableState !== null) {
|
|
6215
|
+
if (name === "data") {
|
|
6216
|
+
this._duplexState |= READ_EMIT_DATA | READ_RESUMED;
|
|
6217
|
+
this._readableState.updateNextTick();
|
|
6218
|
+
}
|
|
6219
|
+
if (name === "readable") {
|
|
6220
|
+
this._duplexState |= READ_EMIT_READABLE;
|
|
6221
|
+
this._readableState.updateNextTick();
|
|
6222
|
+
}
|
|
6223
|
+
}
|
|
6224
|
+
if (this._writableState !== null) {
|
|
6225
|
+
if (name === "drain") {
|
|
6226
|
+
this._duplexState |= WRITE_EMIT_DRAIN;
|
|
6227
|
+
this._writableState.updateNextTick();
|
|
6228
|
+
}
|
|
6229
|
+
}
|
|
6230
|
+
}
|
|
6231
|
+
var Stream = class extends EventEmitter {
|
|
6232
|
+
constructor(opts) {
|
|
6233
|
+
super();
|
|
6234
|
+
this._duplexState = 0;
|
|
6235
|
+
this._readableState = null;
|
|
6236
|
+
this._writableState = null;
|
|
6237
|
+
if (opts) {
|
|
6238
|
+
if (opts.open) this._open = opts.open;
|
|
6239
|
+
if (opts.destroy) this._destroy = opts.destroy;
|
|
6240
|
+
if (opts.predestroy) this._predestroy = opts.predestroy;
|
|
6241
|
+
if (opts.signal) {
|
|
6242
|
+
opts.signal.addEventListener("abort", abort.bind(this));
|
|
6243
|
+
}
|
|
6244
|
+
}
|
|
6245
|
+
this.on("newListener", newListener);
|
|
6246
|
+
}
|
|
6247
|
+
_open(cb) {
|
|
6248
|
+
cb(null);
|
|
6249
|
+
}
|
|
6250
|
+
_destroy(cb) {
|
|
6251
|
+
cb(null);
|
|
6252
|
+
}
|
|
6253
|
+
_predestroy() {
|
|
6254
|
+
}
|
|
6255
|
+
get readable() {
|
|
6256
|
+
return this._readableState !== null ? true : void 0;
|
|
6257
|
+
}
|
|
6258
|
+
get writable() {
|
|
6259
|
+
return this._writableState !== null ? true : void 0;
|
|
6260
|
+
}
|
|
6261
|
+
get destroyed() {
|
|
6262
|
+
return (this._duplexState & DESTROYED) !== 0;
|
|
6263
|
+
}
|
|
6264
|
+
get destroying() {
|
|
6265
|
+
return (this._duplexState & DESTROY_STATUS) !== 0;
|
|
6266
|
+
}
|
|
6267
|
+
destroy(err) {
|
|
6268
|
+
if ((this._duplexState & DESTROY_STATUS) === 0) {
|
|
6269
|
+
if (!err) err = STREAM_DESTROYED;
|
|
6270
|
+
this._duplexState = (this._duplexState | DESTROYING) & NON_PRIMARY;
|
|
6271
|
+
if (this._readableState !== null) {
|
|
6272
|
+
this._readableState.highWaterMark = 0;
|
|
6273
|
+
this._readableState.error = err;
|
|
6274
|
+
}
|
|
6275
|
+
if (this._writableState !== null) {
|
|
6276
|
+
this._writableState.highWaterMark = 0;
|
|
6277
|
+
this._writableState.error = err;
|
|
6278
|
+
}
|
|
6279
|
+
this._duplexState |= PREDESTROYING;
|
|
6280
|
+
this._predestroy();
|
|
6281
|
+
this._duplexState &= NOT_PREDESTROYING;
|
|
6282
|
+
if (this._readableState !== null) this._readableState.updateNextTick();
|
|
6283
|
+
if (this._writableState !== null) this._writableState.updateNextTick();
|
|
6284
|
+
}
|
|
6285
|
+
}
|
|
6286
|
+
};
|
|
6287
|
+
var Readable = class _Readable extends Stream {
|
|
6288
|
+
constructor(opts) {
|
|
6289
|
+
super(opts);
|
|
6290
|
+
this._duplexState |= OPENING | WRITE_DONE;
|
|
6291
|
+
this._readableState = new ReadableState(this, opts);
|
|
6292
|
+
if (opts) {
|
|
6293
|
+
if (opts.read) this._read = opts.read;
|
|
6294
|
+
if (opts.eagerOpen) this._readableState.updateNextTick();
|
|
6295
|
+
}
|
|
6296
|
+
}
|
|
6297
|
+
_read(cb) {
|
|
6298
|
+
cb(null);
|
|
6299
|
+
}
|
|
6300
|
+
pipe(dest, cb) {
|
|
6301
|
+
this._readableState.updateNextTick();
|
|
6302
|
+
this._readableState.pipe(dest, cb);
|
|
6303
|
+
return dest;
|
|
6304
|
+
}
|
|
6305
|
+
read() {
|
|
6306
|
+
this._readableState.updateNextTick();
|
|
6307
|
+
return this._readableState.read();
|
|
6308
|
+
}
|
|
6309
|
+
push(data) {
|
|
6310
|
+
this._readableState.updateNextTick();
|
|
6311
|
+
return this._readableState.push(data);
|
|
6312
|
+
}
|
|
6313
|
+
unshift(data) {
|
|
6314
|
+
this._readableState.updateNextTick();
|
|
6315
|
+
return this._readableState.unshift(data);
|
|
6316
|
+
}
|
|
6317
|
+
resume() {
|
|
6318
|
+
this._duplexState |= READ_RESUMED;
|
|
6319
|
+
this._readableState.updateNextTick();
|
|
6320
|
+
return this;
|
|
6321
|
+
}
|
|
6322
|
+
pause() {
|
|
6323
|
+
this._duplexState &= READ_PAUSED;
|
|
6324
|
+
return this;
|
|
6325
|
+
}
|
|
6326
|
+
static _fromAsyncIterator(ite, opts) {
|
|
6327
|
+
let destroy;
|
|
6328
|
+
const rs = new _Readable({
|
|
6329
|
+
...opts,
|
|
6330
|
+
read(cb) {
|
|
6331
|
+
ite.next().then(push).then(cb.bind(null, null)).catch(cb);
|
|
6332
|
+
},
|
|
6333
|
+
predestroy() {
|
|
6334
|
+
destroy = ite.return();
|
|
6335
|
+
},
|
|
6336
|
+
destroy(cb) {
|
|
6337
|
+
if (!destroy) return cb(null);
|
|
6338
|
+
destroy.then(cb.bind(null, null)).catch(cb);
|
|
6339
|
+
}
|
|
6340
|
+
});
|
|
6341
|
+
return rs;
|
|
6342
|
+
function push(data) {
|
|
6343
|
+
if (data.done) rs.push(null);
|
|
6344
|
+
else rs.push(data.value);
|
|
6345
|
+
}
|
|
6346
|
+
}
|
|
6347
|
+
static from(data, opts) {
|
|
6348
|
+
if (isReadStreamx(data)) return data;
|
|
6349
|
+
if (data[asyncIterator]) return this._fromAsyncIterator(data[asyncIterator](), opts);
|
|
6350
|
+
if (!Array.isArray(data)) data = data === void 0 ? [] : [data];
|
|
6351
|
+
let i = 0;
|
|
6352
|
+
return new _Readable({
|
|
6353
|
+
...opts,
|
|
6354
|
+
read(cb) {
|
|
6355
|
+
this.push(i === data.length ? null : data[i++]);
|
|
6356
|
+
cb(null);
|
|
6357
|
+
}
|
|
6358
|
+
});
|
|
6359
|
+
}
|
|
6360
|
+
static isBackpressured(rs) {
|
|
6361
|
+
return (rs._duplexState & READ_BACKPRESSURE_STATUS) !== 0 || rs._readableState.buffered >= rs._readableState.highWaterMark;
|
|
6362
|
+
}
|
|
6363
|
+
static isPaused(rs) {
|
|
6364
|
+
return (rs._duplexState & READ_RESUMED) === 0;
|
|
6365
|
+
}
|
|
6366
|
+
[asyncIterator]() {
|
|
6367
|
+
const stream = this;
|
|
6368
|
+
let error = null;
|
|
6369
|
+
let promiseResolve = null;
|
|
6370
|
+
let promiseReject = null;
|
|
6371
|
+
this.on("error", (err) => {
|
|
6372
|
+
error = err;
|
|
6373
|
+
});
|
|
6374
|
+
this.on("readable", onreadable);
|
|
6375
|
+
this.on("close", onclose);
|
|
6376
|
+
return {
|
|
6377
|
+
[asyncIterator]() {
|
|
6378
|
+
return this;
|
|
6379
|
+
},
|
|
6380
|
+
next() {
|
|
6381
|
+
return new Promise(function(resolve, reject) {
|
|
6382
|
+
promiseResolve = resolve;
|
|
6383
|
+
promiseReject = reject;
|
|
6384
|
+
const data = stream.read();
|
|
6385
|
+
if (data !== null) ondata(data);
|
|
6386
|
+
else if ((stream._duplexState & DESTROYED) !== 0) ondata(null);
|
|
6387
|
+
});
|
|
6388
|
+
},
|
|
6389
|
+
return() {
|
|
6390
|
+
return destroy(null);
|
|
6391
|
+
},
|
|
6392
|
+
throw(err) {
|
|
6393
|
+
return destroy(err);
|
|
6394
|
+
}
|
|
6395
|
+
};
|
|
6396
|
+
function onreadable() {
|
|
6397
|
+
if (promiseResolve !== null) ondata(stream.read());
|
|
6398
|
+
}
|
|
6399
|
+
function onclose() {
|
|
6400
|
+
if (promiseResolve !== null) ondata(null);
|
|
6401
|
+
}
|
|
6402
|
+
function ondata(data) {
|
|
6403
|
+
if (promiseReject === null) return;
|
|
6404
|
+
if (error) promiseReject(error);
|
|
6405
|
+
else if (data === null && (stream._duplexState & READ_DONE) === 0) promiseReject(STREAM_DESTROYED);
|
|
6406
|
+
else promiseResolve({ value: data, done: data === null });
|
|
6407
|
+
promiseReject = promiseResolve = null;
|
|
6408
|
+
}
|
|
6409
|
+
function destroy(err) {
|
|
6410
|
+
stream.destroy(err);
|
|
6411
|
+
return new Promise((resolve, reject) => {
|
|
6412
|
+
if (stream._duplexState & DESTROYED) return resolve({ value: void 0, done: true });
|
|
6413
|
+
stream.once("close", function() {
|
|
6414
|
+
if (err) reject(err);
|
|
6415
|
+
else resolve({ value: void 0, done: true });
|
|
6416
|
+
});
|
|
6417
|
+
});
|
|
6418
|
+
}
|
|
6419
|
+
}
|
|
6420
|
+
};
|
|
6421
|
+
var Writable = class extends Stream {
|
|
6422
|
+
constructor(opts) {
|
|
6423
|
+
super(opts);
|
|
6424
|
+
this._duplexState |= OPENING | READ_DONE;
|
|
6425
|
+
this._writableState = new WritableState(this, opts);
|
|
6426
|
+
if (opts) {
|
|
6427
|
+
if (opts.writev) this._writev = opts.writev;
|
|
6428
|
+
if (opts.write) this._write = opts.write;
|
|
6429
|
+
if (opts.final) this._final = opts.final;
|
|
6430
|
+
if (opts.eagerOpen) this._writableState.updateNextTick();
|
|
6431
|
+
}
|
|
6432
|
+
}
|
|
6433
|
+
_writev(batch, cb) {
|
|
6434
|
+
cb(null);
|
|
6435
|
+
}
|
|
6436
|
+
_write(data, cb) {
|
|
6437
|
+
this._writableState.autoBatch(data, cb);
|
|
6438
|
+
}
|
|
6439
|
+
_final(cb) {
|
|
6440
|
+
cb(null);
|
|
6441
|
+
}
|
|
6442
|
+
static isBackpressured(ws) {
|
|
6443
|
+
return (ws._duplexState & WRITE_BACKPRESSURE_STATUS) !== 0;
|
|
6444
|
+
}
|
|
6445
|
+
static drained(ws) {
|
|
6446
|
+
if (ws.destroyed) return Promise.resolve(false);
|
|
6447
|
+
const state = ws._writableState;
|
|
6448
|
+
const pending = isWritev(ws) ? Math.min(1, state.queue.length) : state.queue.length;
|
|
6449
|
+
const writes = pending + (ws._duplexState & WRITE_WRITING ? 1 : 0);
|
|
6450
|
+
if (writes === 0) return Promise.resolve(true);
|
|
6451
|
+
if (state.drains === null) state.drains = [];
|
|
6452
|
+
return new Promise((resolve) => {
|
|
6453
|
+
state.drains.push({ writes, resolve });
|
|
6454
|
+
});
|
|
6455
|
+
}
|
|
6456
|
+
write(data) {
|
|
6457
|
+
this._writableState.updateNextTick();
|
|
6458
|
+
return this._writableState.push(data);
|
|
6459
|
+
}
|
|
6460
|
+
end(data) {
|
|
6461
|
+
this._writableState.updateNextTick();
|
|
6462
|
+
this._writableState.end(data);
|
|
6463
|
+
return this;
|
|
6464
|
+
}
|
|
6465
|
+
};
|
|
6466
|
+
var Duplex = class extends Readable {
|
|
6467
|
+
// and Writable
|
|
6468
|
+
constructor(opts) {
|
|
6469
|
+
super(opts);
|
|
6470
|
+
this._duplexState = OPENING;
|
|
6471
|
+
this._writableState = new WritableState(this, opts);
|
|
6472
|
+
if (opts) {
|
|
6473
|
+
if (opts.writev) this._writev = opts.writev;
|
|
6474
|
+
if (opts.write) this._write = opts.write;
|
|
6475
|
+
if (opts.final) this._final = opts.final;
|
|
6476
|
+
}
|
|
6477
|
+
}
|
|
6478
|
+
_writev(batch, cb) {
|
|
6479
|
+
cb(null);
|
|
6480
|
+
}
|
|
6481
|
+
_write(data, cb) {
|
|
6482
|
+
this._writableState.autoBatch(data, cb);
|
|
6483
|
+
}
|
|
6484
|
+
_final(cb) {
|
|
6485
|
+
cb(null);
|
|
6486
|
+
}
|
|
6487
|
+
write(data) {
|
|
6488
|
+
this._writableState.updateNextTick();
|
|
6489
|
+
return this._writableState.push(data);
|
|
6490
|
+
}
|
|
6491
|
+
end(data) {
|
|
6492
|
+
this._writableState.updateNextTick();
|
|
6493
|
+
this._writableState.end(data);
|
|
6494
|
+
return this;
|
|
6495
|
+
}
|
|
6496
|
+
};
|
|
6497
|
+
var Transform = class extends Duplex {
|
|
6498
|
+
constructor(opts) {
|
|
6499
|
+
super(opts);
|
|
6500
|
+
this._transformState = new TransformState(this);
|
|
6501
|
+
if (opts) {
|
|
6502
|
+
if (opts.transform) this._transform = opts.transform;
|
|
6503
|
+
if (opts.flush) this._flush = opts.flush;
|
|
6504
|
+
}
|
|
6505
|
+
}
|
|
6506
|
+
_write(data, cb) {
|
|
6507
|
+
if (this._readableState.buffered >= this._readableState.highWaterMark) {
|
|
6508
|
+
this._transformState.data = data;
|
|
6509
|
+
} else {
|
|
6510
|
+
this._transform(data, this._transformState.afterTransform);
|
|
6511
|
+
}
|
|
6512
|
+
}
|
|
6513
|
+
_read(cb) {
|
|
6514
|
+
if (this._transformState.data !== null) {
|
|
6515
|
+
const data = this._transformState.data;
|
|
6516
|
+
this._transformState.data = null;
|
|
6517
|
+
cb(null);
|
|
6518
|
+
this._transform(data, this._transformState.afterTransform);
|
|
6519
|
+
} else {
|
|
6520
|
+
cb(null);
|
|
6521
|
+
}
|
|
6522
|
+
}
|
|
6523
|
+
destroy(err) {
|
|
6524
|
+
super.destroy(err);
|
|
6525
|
+
if (this._transformState.data !== null) {
|
|
6526
|
+
this._transformState.data = null;
|
|
6527
|
+
this._transformState.afterTransform();
|
|
6528
|
+
}
|
|
6529
|
+
}
|
|
6530
|
+
_transform(data, cb) {
|
|
6531
|
+
cb(null, data);
|
|
6532
|
+
}
|
|
6533
|
+
_flush(cb) {
|
|
6534
|
+
cb(null);
|
|
6535
|
+
}
|
|
6536
|
+
_final(cb) {
|
|
6537
|
+
this._transformState.afterFinal = cb;
|
|
6538
|
+
this._flush(transformAfterFlush.bind(this));
|
|
6539
|
+
}
|
|
6540
|
+
};
|
|
6541
|
+
var PassThrough = class extends Transform {
|
|
6542
|
+
};
|
|
6543
|
+
function transformAfterFlush(err, data) {
|
|
6544
|
+
const cb = this._transformState.afterFinal;
|
|
6545
|
+
if (err) return cb(err);
|
|
6546
|
+
if (data !== null && data !== void 0) this.push(data);
|
|
6547
|
+
this.push(null);
|
|
6548
|
+
cb(null);
|
|
6549
|
+
}
|
|
6550
|
+
function pipelinePromise(...streams) {
|
|
6551
|
+
return new Promise((resolve, reject) => {
|
|
6552
|
+
return pipeline(...streams, (err) => {
|
|
6553
|
+
if (err) return reject(err);
|
|
6554
|
+
resolve();
|
|
6555
|
+
});
|
|
6556
|
+
});
|
|
6557
|
+
}
|
|
6558
|
+
function pipeline(stream, ...streams) {
|
|
6559
|
+
const all = Array.isArray(stream) ? [...stream, ...streams] : [stream, ...streams];
|
|
6560
|
+
const done = all.length && typeof all[all.length - 1] === "function" ? all.pop() : null;
|
|
6561
|
+
if (all.length < 2) throw new Error("Pipeline requires at least 2 streams");
|
|
6562
|
+
let src = all[0];
|
|
6563
|
+
let dest = null;
|
|
6564
|
+
let error = null;
|
|
6565
|
+
for (let i = 1; i < all.length; i++) {
|
|
6566
|
+
dest = all[i];
|
|
6567
|
+
if (isStreamx(src)) {
|
|
6568
|
+
src.pipe(dest, onerror);
|
|
6569
|
+
} else {
|
|
6570
|
+
errorHandle(src, true, i > 1, onerror);
|
|
6571
|
+
src.pipe(dest);
|
|
6572
|
+
}
|
|
6573
|
+
src = dest;
|
|
6574
|
+
}
|
|
6575
|
+
if (done) {
|
|
6576
|
+
let fin = false;
|
|
6577
|
+
const autoDestroy = isStreamx(dest) || !!(dest._writableState && dest._writableState.autoDestroy);
|
|
6578
|
+
dest.on("error", (err) => {
|
|
6579
|
+
if (error === null) error = err;
|
|
6580
|
+
});
|
|
6581
|
+
dest.on("finish", () => {
|
|
6582
|
+
fin = true;
|
|
6583
|
+
if (!autoDestroy) done(error);
|
|
6584
|
+
});
|
|
6585
|
+
if (autoDestroy) {
|
|
6586
|
+
dest.on("close", () => done(error || (fin ? null : PREMATURE_CLOSE)));
|
|
6587
|
+
}
|
|
6588
|
+
}
|
|
6589
|
+
return dest;
|
|
6590
|
+
function errorHandle(s, rd, wr, onerror2) {
|
|
6591
|
+
s.on("error", onerror2);
|
|
6592
|
+
s.on("close", onclose);
|
|
6593
|
+
function onclose() {
|
|
6594
|
+
if (rd && s._readableState && !s._readableState.ended) return onerror2(PREMATURE_CLOSE);
|
|
6595
|
+
if (wr && s._writableState && !s._writableState.ended) return onerror2(PREMATURE_CLOSE);
|
|
6596
|
+
}
|
|
6597
|
+
}
|
|
6598
|
+
function onerror(err) {
|
|
6599
|
+
if (!err || error) return;
|
|
6600
|
+
error = err;
|
|
6601
|
+
for (const s of all) {
|
|
6602
|
+
s.destroy(err);
|
|
6603
|
+
}
|
|
6604
|
+
}
|
|
6605
|
+
}
|
|
6606
|
+
function isStream(stream) {
|
|
6607
|
+
return !!stream._readableState || !!stream._writableState;
|
|
6608
|
+
}
|
|
6609
|
+
function isStreamx(stream) {
|
|
6610
|
+
return typeof stream._duplexState === "number" && isStream(stream);
|
|
6611
|
+
}
|
|
6612
|
+
function getStreamError(stream) {
|
|
6613
|
+
const err = stream._readableState && stream._readableState.error || stream._writableState && stream._writableState.error;
|
|
6614
|
+
return err === STREAM_DESTROYED ? null : err;
|
|
6615
|
+
}
|
|
6616
|
+
function isReadStreamx(stream) {
|
|
6617
|
+
return isStreamx(stream) && stream.readable;
|
|
6618
|
+
}
|
|
6619
|
+
function isTypedArray(data) {
|
|
6620
|
+
return typeof data === "object" && data !== null && typeof data.byteLength === "number";
|
|
6621
|
+
}
|
|
6622
|
+
function defaultByteLength(data) {
|
|
6623
|
+
return isTypedArray(data) ? data.byteLength : 1024;
|
|
6624
|
+
}
|
|
6625
|
+
function noop() {
|
|
6626
|
+
}
|
|
6627
|
+
function abort() {
|
|
6628
|
+
this.destroy(new Error("Stream aborted."));
|
|
6629
|
+
}
|
|
6630
|
+
function isWritev(s) {
|
|
6631
|
+
return s._writev !== Writable.prototype._writev && s._writev !== Duplex.prototype._writev;
|
|
6632
|
+
}
|
|
6633
|
+
module.exports = {
|
|
6634
|
+
pipeline,
|
|
6635
|
+
pipelinePromise,
|
|
6636
|
+
isStream,
|
|
6637
|
+
isStreamx,
|
|
6638
|
+
getStreamError,
|
|
6639
|
+
Stream,
|
|
6640
|
+
Writable,
|
|
6641
|
+
Readable,
|
|
6642
|
+
Duplex,
|
|
6643
|
+
Transform,
|
|
6644
|
+
// Export PassThrough for compatibility with Node.js core's stream module
|
|
6645
|
+
PassThrough
|
|
6646
|
+
};
|
|
6647
|
+
}
|
|
6648
|
+
});
|
|
6649
|
+
|
|
5791
6650
|
// ../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js
|
|
5792
6651
|
var require_ms = __commonJS({
|
|
5793
6652
|
"../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js"(exports, module) {
|
|
@@ -5904,9 +6763,9 @@ var require_ms = __commonJS({
|
|
|
5904
6763
|
}
|
|
5905
6764
|
});
|
|
5906
6765
|
|
|
5907
|
-
// ../../node_modules/.pnpm/debug@4.4.
|
|
6766
|
+
// ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js
|
|
5908
6767
|
var require_common = __commonJS({
|
|
5909
|
-
"../../node_modules/.pnpm/debug@4.4.
|
|
6768
|
+
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js"(exports, module) {
|
|
5910
6769
|
function setup(env) {
|
|
5911
6770
|
createDebug.debug = createDebug;
|
|
5912
6771
|
createDebug.default = createDebug;
|
|
@@ -6081,9 +6940,9 @@ var require_common = __commonJS({
|
|
|
6081
6940
|
}
|
|
6082
6941
|
});
|
|
6083
6942
|
|
|
6084
|
-
// ../../node_modules/.pnpm/debug@4.4.
|
|
6943
|
+
// ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js
|
|
6085
6944
|
var require_browser2 = __commonJS({
|
|
6086
|
-
"../../node_modules/.pnpm/debug@4.4.
|
|
6945
|
+
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js"(exports, module) {
|
|
6087
6946
|
exports.formatArgs = formatArgs;
|
|
6088
6947
|
exports.save = save;
|
|
6089
6948
|
exports.load = load;
|
|
@@ -6264,29 +7123,27 @@ var require_has_flag = __commonJS({
|
|
|
6264
7123
|
}
|
|
6265
7124
|
});
|
|
6266
7125
|
|
|
6267
|
-
// ../../node_modules/.pnpm/supports-color@
|
|
7126
|
+
// ../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js
|
|
6268
7127
|
var require_supports_color = __commonJS({
|
|
6269
|
-
"../../node_modules/.pnpm/supports-color@
|
|
7128
|
+
"../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js"(exports, module) {
|
|
6270
7129
|
"use strict";
|
|
6271
7130
|
var os = __require("node:os");
|
|
6272
7131
|
var tty = __require("node:tty");
|
|
6273
7132
|
var hasFlag = require_has_flag();
|
|
6274
7133
|
var { env } = process;
|
|
6275
|
-
var
|
|
7134
|
+
var forceColor;
|
|
6276
7135
|
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
6277
|
-
|
|
7136
|
+
forceColor = 0;
|
|
6278
7137
|
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
6279
|
-
|
|
7138
|
+
forceColor = 1;
|
|
6280
7139
|
}
|
|
6281
|
-
|
|
6282
|
-
if (
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
}
|
|
6289
|
-
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
7140
|
+
if ("FORCE_COLOR" in env) {
|
|
7141
|
+
if (env.FORCE_COLOR === "true") {
|
|
7142
|
+
forceColor = 1;
|
|
7143
|
+
} else if (env.FORCE_COLOR === "false") {
|
|
7144
|
+
forceColor = 0;
|
|
7145
|
+
} else {
|
|
7146
|
+
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
6290
7147
|
}
|
|
6291
7148
|
}
|
|
6292
7149
|
function translateLevel(level) {
|
|
@@ -6300,22 +7157,15 @@ var require_supports_color = __commonJS({
|
|
|
6300
7157
|
has16m: level >= 3
|
|
6301
7158
|
};
|
|
6302
7159
|
}
|
|
6303
|
-
function supportsColor(haveStream,
|
|
6304
|
-
const noFlagForceColor = envForceColor();
|
|
6305
|
-
if (noFlagForceColor !== void 0) {
|
|
6306
|
-
flagForceColor = noFlagForceColor;
|
|
6307
|
-
}
|
|
6308
|
-
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
7160
|
+
function supportsColor(haveStream, streamIsTTY) {
|
|
6309
7161
|
if (forceColor === 0) {
|
|
6310
7162
|
return 0;
|
|
6311
7163
|
}
|
|
6312
|
-
if (
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
return 2;
|
|
6318
|
-
}
|
|
7164
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
7165
|
+
return 3;
|
|
7166
|
+
}
|
|
7167
|
+
if (hasFlag("color=256")) {
|
|
7168
|
+
return 2;
|
|
6319
7169
|
}
|
|
6320
7170
|
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
6321
7171
|
return 0;
|
|
@@ -6332,7 +7182,7 @@ var require_supports_color = __commonJS({
|
|
|
6332
7182
|
return 1;
|
|
6333
7183
|
}
|
|
6334
7184
|
if ("CI" in env) {
|
|
6335
|
-
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"
|
|
7185
|
+
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
6336
7186
|
return 1;
|
|
6337
7187
|
}
|
|
6338
7188
|
return min;
|
|
@@ -6344,7 +7194,7 @@ var require_supports_color = __commonJS({
|
|
|
6344
7194
|
return 3;
|
|
6345
7195
|
}
|
|
6346
7196
|
if ("TERM_PROGRAM" in env) {
|
|
6347
|
-
const version =
|
|
7197
|
+
const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
6348
7198
|
switch (env.TERM_PROGRAM) {
|
|
6349
7199
|
case "iTerm.app":
|
|
6350
7200
|
return version >= 3 ? 3 : 2;
|
|
@@ -6363,24 +7213,21 @@ var require_supports_color = __commonJS({
|
|
|
6363
7213
|
}
|
|
6364
7214
|
return min;
|
|
6365
7215
|
}
|
|
6366
|
-
function getSupportLevel(stream
|
|
6367
|
-
const level = supportsColor(stream,
|
|
6368
|
-
streamIsTTY: stream && stream.isTTY,
|
|
6369
|
-
...options
|
|
6370
|
-
});
|
|
7216
|
+
function getSupportLevel(stream) {
|
|
7217
|
+
const level = supportsColor(stream, stream && stream.isTTY);
|
|
6371
7218
|
return translateLevel(level);
|
|
6372
7219
|
}
|
|
6373
7220
|
module.exports = {
|
|
6374
7221
|
supportsColor: getSupportLevel,
|
|
6375
|
-
stdout:
|
|
6376
|
-
stderr:
|
|
7222
|
+
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
|
7223
|
+
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
|
6377
7224
|
};
|
|
6378
7225
|
}
|
|
6379
7226
|
});
|
|
6380
7227
|
|
|
6381
|
-
// ../../node_modules/.pnpm/debug@4.4.
|
|
7228
|
+
// ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js
|
|
6382
7229
|
var require_node = __commonJS({
|
|
6383
|
-
"../../node_modules/.pnpm/debug@4.4.
|
|
7230
|
+
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js"(exports, module) {
|
|
6384
7231
|
var tty = __require("node:tty");
|
|
6385
7232
|
var util = __require("node:util");
|
|
6386
7233
|
exports.init = init;
|
|
@@ -6552,9 +7399,9 @@ var require_node = __commonJS({
|
|
|
6552
7399
|
}
|
|
6553
7400
|
});
|
|
6554
7401
|
|
|
6555
|
-
// ../../node_modules/.pnpm/debug@4.4.
|
|
7402
|
+
// ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js
|
|
6556
7403
|
var require_src = __commonJS({
|
|
6557
|
-
"../../node_modules/.pnpm/debug@4.4.
|
|
7404
|
+
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js"(exports, module) {
|
|
6558
7405
|
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
6559
7406
|
module.exports = require_browser2();
|
|
6560
7407
|
} else {
|
|
@@ -6573,7 +7420,7 @@ var require_hypercore_protocol = __commonJS({
|
|
|
6573
7420
|
var Nanoguard = require_nanoguard();
|
|
6574
7421
|
var pretty = require_pretty_hash();
|
|
6575
7422
|
var Message = require_abstract_extension();
|
|
6576
|
-
var { Duplex } =
|
|
7423
|
+
var { Duplex } = require_streamx();
|
|
6577
7424
|
var debug = require_src()("hypercore-protocol");
|
|
6578
7425
|
var StreamExtension = class extends Message {
|
|
6579
7426
|
send(message) {
|
|
@@ -8163,7 +9010,7 @@ var require_empty = __commonJS({
|
|
|
8163
9010
|
// ../../node_modules/.pnpm/hypercore-streams@1.0.1/node_modules/hypercore-streams/index.js
|
|
8164
9011
|
var require_hypercore_streams = __commonJS({
|
|
8165
9012
|
"../../node_modules/.pnpm/hypercore-streams@1.0.1/node_modules/hypercore-streams/index.js"(exports, module) {
|
|
8166
|
-
var { Writable, Readable } =
|
|
9013
|
+
var { Writable, Readable } = require_streamx();
|
|
8167
9014
|
var WriteStream = class extends Writable {
|
|
8168
9015
|
constructor(feed, opts) {
|
|
8169
9016
|
super();
|