@solana/web3.js 1.91.7 → 1.91.8
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/lib/index.browser.cjs.js +7 -9
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +7 -9
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +7 -9
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +7 -9
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +817 -1955
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +7 -8
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +7 -9
- package/lib/index.native.js.map +1 -1
- package/package.json +5 -5
package/lib/index.iife.js
CHANGED
|
@@ -2381,17 +2381,17 @@ var solanaWeb3 = (function (exports) {
|
|
|
2381
2381
|
}
|
|
2382
2382
|
} (buffer));
|
|
2383
2383
|
|
|
2384
|
-
function number$
|
|
2384
|
+
function number$1(n) {
|
|
2385
2385
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
2386
2386
|
throw new Error(`positive integer expected, not ${n}`);
|
|
2387
2387
|
}
|
|
2388
2388
|
// copied from utils
|
|
2389
|
-
function isBytes$
|
|
2389
|
+
function isBytes$1(a) {
|
|
2390
2390
|
return (a instanceof Uint8Array ||
|
|
2391
2391
|
(a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
|
|
2392
2392
|
}
|
|
2393
|
-
function bytes
|
|
2394
|
-
if (!isBytes$
|
|
2393
|
+
function bytes(b, ...lengths) {
|
|
2394
|
+
if (!isBytes$1(b))
|
|
2395
2395
|
throw new Error('Uint8Array expected');
|
|
2396
2396
|
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
2397
2397
|
throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);
|
|
@@ -2399,17 +2399,17 @@ var solanaWeb3 = (function (exports) {
|
|
|
2399
2399
|
function hash(h) {
|
|
2400
2400
|
if (typeof h !== 'function' || typeof h.create !== 'function')
|
|
2401
2401
|
throw new Error('Hash should be wrapped by utils.wrapConstructor');
|
|
2402
|
-
number$
|
|
2403
|
-
number$
|
|
2402
|
+
number$1(h.outputLen);
|
|
2403
|
+
number$1(h.blockLen);
|
|
2404
2404
|
}
|
|
2405
|
-
function exists
|
|
2405
|
+
function exists(instance, checkFinished = true) {
|
|
2406
2406
|
if (instance.destroyed)
|
|
2407
2407
|
throw new Error('Hash instance has been destroyed');
|
|
2408
2408
|
if (checkFinished && instance.finished)
|
|
2409
2409
|
throw new Error('Hash#digest() has already been called');
|
|
2410
2410
|
}
|
|
2411
|
-
function output
|
|
2412
|
-
bytes
|
|
2411
|
+
function output(out, instance) {
|
|
2412
|
+
bytes(out);
|
|
2413
2413
|
const min = instance.outputLen;
|
|
2414
2414
|
if (out.length < min) {
|
|
2415
2415
|
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
@@ -2425,15 +2425,27 @@ var solanaWeb3 = (function (exports) {
|
|
|
2425
2425
|
// from `crypto` to `cryptoNode`, which imports native module.
|
|
2426
2426
|
// Makes the utils un-importable in browsers without a bundler.
|
|
2427
2427
|
// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
|
|
2428
|
+
const u32$1 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
2428
2429
|
// Cast array to view
|
|
2429
|
-
const createView
|
|
2430
|
+
const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
2430
2431
|
// The rotate right (circular right shift) operation for uint32
|
|
2431
|
-
const rotr
|
|
2432
|
-
new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
|
|
2432
|
+
const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
|
|
2433
|
+
const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
|
|
2434
|
+
// The byte swap operation for uint32
|
|
2435
|
+
const byteSwap = (word) => ((word << 24) & 0xff000000) |
|
|
2436
|
+
((word << 8) & 0xff0000) |
|
|
2437
|
+
((word >>> 8) & 0xff00) |
|
|
2438
|
+
((word >>> 24) & 0xff);
|
|
2439
|
+
// In place byte swap for Uint32Array
|
|
2440
|
+
function byteSwap32(arr) {
|
|
2441
|
+
for (let i = 0; i < arr.length; i++) {
|
|
2442
|
+
arr[i] = byteSwap(arr[i]);
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2433
2445
|
/**
|
|
2434
2446
|
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
|
|
2435
2447
|
*/
|
|
2436
|
-
function utf8ToBytes$
|
|
2448
|
+
function utf8ToBytes$1(str) {
|
|
2437
2449
|
if (typeof str !== 'string')
|
|
2438
2450
|
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
2439
2451
|
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
@@ -2443,10 +2455,10 @@ var solanaWeb3 = (function (exports) {
|
|
|
2443
2455
|
* Warning: when Uint8Array is passed, it would NOT get copied.
|
|
2444
2456
|
* Keep in mind for future mutable operations.
|
|
2445
2457
|
*/
|
|
2446
|
-
function toBytes
|
|
2458
|
+
function toBytes(data) {
|
|
2447
2459
|
if (typeof data === 'string')
|
|
2448
|
-
data = utf8ToBytes$
|
|
2449
|
-
bytes
|
|
2460
|
+
data = utf8ToBytes$1(data);
|
|
2461
|
+
bytes(data);
|
|
2450
2462
|
return data;
|
|
2451
2463
|
}
|
|
2452
2464
|
/**
|
|
@@ -2456,7 +2468,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
2456
2468
|
let sum = 0;
|
|
2457
2469
|
for (let i = 0; i < arrays.length; i++) {
|
|
2458
2470
|
const a = arrays[i];
|
|
2459
|
-
bytes
|
|
2471
|
+
bytes(a);
|
|
2460
2472
|
sum += a.length;
|
|
2461
2473
|
}
|
|
2462
2474
|
const res = new Uint8Array(sum);
|
|
@@ -2468,14 +2480,14 @@ var solanaWeb3 = (function (exports) {
|
|
|
2468
2480
|
return res;
|
|
2469
2481
|
}
|
|
2470
2482
|
// For runtime check if class implements interface
|
|
2471
|
-
|
|
2483
|
+
class Hash {
|
|
2472
2484
|
// Safe version that clones internal state
|
|
2473
2485
|
clone() {
|
|
2474
2486
|
return this._cloneInto();
|
|
2475
2487
|
}
|
|
2476
|
-
}
|
|
2477
|
-
function wrapConstructor
|
|
2478
|
-
const hashC = (msg) => hashCons().update(toBytes
|
|
2488
|
+
}
|
|
2489
|
+
function wrapConstructor(hashCons) {
|
|
2490
|
+
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
2479
2491
|
const tmp = hashCons();
|
|
2480
2492
|
hashC.outputLen = tmp.outputLen;
|
|
2481
2493
|
hashC.blockLen = tmp.blockLen;
|
|
@@ -2493,7 +2505,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
2493
2505
|
}
|
|
2494
2506
|
|
|
2495
2507
|
// Polyfill for Safari 14
|
|
2496
|
-
function setBigUint64
|
|
2508
|
+
function setBigUint64(view, byteOffset, value, isLE) {
|
|
2497
2509
|
if (typeof view.setBigUint64 === 'function')
|
|
2498
2510
|
return view.setBigUint64(byteOffset, value, isLE);
|
|
2499
2511
|
const _32n = BigInt(32);
|
|
@@ -2506,14 +2518,14 @@ var solanaWeb3 = (function (exports) {
|
|
|
2506
2518
|
view.setUint32(byteOffset + l, wl, isLE);
|
|
2507
2519
|
}
|
|
2508
2520
|
// Choice: a ? b : c
|
|
2509
|
-
const Chi
|
|
2521
|
+
const Chi = (a, b, c) => (a & b) ^ (~a & c);
|
|
2510
2522
|
// Majority function, true if any two inpust is true
|
|
2511
|
-
const Maj
|
|
2523
|
+
const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
|
|
2512
2524
|
/**
|
|
2513
2525
|
* Merkle-Damgard hash construction base class.
|
|
2514
2526
|
* Could be used to create MD5, RIPEMD, SHA1, SHA2.
|
|
2515
2527
|
*/
|
|
2516
|
-
class HashMD extends Hash
|
|
2528
|
+
class HashMD extends Hash {
|
|
2517
2529
|
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
2518
2530
|
super();
|
|
2519
2531
|
this.blockLen = blockLen;
|
|
@@ -2525,18 +2537,18 @@ var solanaWeb3 = (function (exports) {
|
|
|
2525
2537
|
this.pos = 0;
|
|
2526
2538
|
this.destroyed = false;
|
|
2527
2539
|
this.buffer = new Uint8Array(blockLen);
|
|
2528
|
-
this.view = createView
|
|
2540
|
+
this.view = createView(this.buffer);
|
|
2529
2541
|
}
|
|
2530
2542
|
update(data) {
|
|
2531
|
-
exists
|
|
2543
|
+
exists(this);
|
|
2532
2544
|
const { view, buffer, blockLen } = this;
|
|
2533
|
-
data = toBytes
|
|
2545
|
+
data = toBytes(data);
|
|
2534
2546
|
const len = data.length;
|
|
2535
2547
|
for (let pos = 0; pos < len;) {
|
|
2536
2548
|
const take = Math.min(blockLen - this.pos, len - pos);
|
|
2537
2549
|
// Fast path: we have at least one block in input, cast it to view and process
|
|
2538
2550
|
if (take === blockLen) {
|
|
2539
|
-
const dataView = createView
|
|
2551
|
+
const dataView = createView(data);
|
|
2540
2552
|
for (; blockLen <= len - pos; pos += blockLen)
|
|
2541
2553
|
this.process(dataView, pos);
|
|
2542
2554
|
continue;
|
|
@@ -2554,8 +2566,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
2554
2566
|
return this;
|
|
2555
2567
|
}
|
|
2556
2568
|
digestInto(out) {
|
|
2557
|
-
exists
|
|
2558
|
-
output
|
|
2569
|
+
exists(this);
|
|
2570
|
+
output(out, this);
|
|
2559
2571
|
this.finished = true;
|
|
2560
2572
|
// Padding
|
|
2561
2573
|
// We can avoid allocation of buffer for padding completely if it
|
|
@@ -2577,9 +2589,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
2577
2589
|
// Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
|
|
2578
2590
|
// You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
|
|
2579
2591
|
// So we just write lowest 64 bits of that value.
|
|
2580
|
-
setBigUint64
|
|
2592
|
+
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
2581
2593
|
this.process(view, 0);
|
|
2582
|
-
const oview = createView
|
|
2594
|
+
const oview = createView(out);
|
|
2583
2595
|
const len = this.outputLen;
|
|
2584
2596
|
// NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
|
|
2585
2597
|
if (len % 4)
|
|
@@ -2612,24 +2624,24 @@ var solanaWeb3 = (function (exports) {
|
|
|
2612
2624
|
}
|
|
2613
2625
|
}
|
|
2614
2626
|
|
|
2615
|
-
const U32_MASK64
|
|
2616
|
-
const _32n
|
|
2627
|
+
const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
2628
|
+
const _32n = /* @__PURE__ */ BigInt(32);
|
|
2617
2629
|
// We are not using BigUint64Array, because they are extremely slow as per 2022
|
|
2618
|
-
function fromBig
|
|
2630
|
+
function fromBig(n, le = false) {
|
|
2619
2631
|
if (le)
|
|
2620
|
-
return { h: Number(n & U32_MASK64
|
|
2621
|
-
return { h: Number((n >> _32n
|
|
2632
|
+
return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
|
|
2633
|
+
return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
2622
2634
|
}
|
|
2623
|
-
function split
|
|
2635
|
+
function split(lst, le = false) {
|
|
2624
2636
|
let Ah = new Uint32Array(lst.length);
|
|
2625
2637
|
let Al = new Uint32Array(lst.length);
|
|
2626
2638
|
for (let i = 0; i < lst.length; i++) {
|
|
2627
|
-
const { h, l } = fromBig
|
|
2639
|
+
const { h, l } = fromBig(lst[i], le);
|
|
2628
2640
|
[Ah[i], Al[i]] = [h, l];
|
|
2629
2641
|
}
|
|
2630
2642
|
return [Ah, Al];
|
|
2631
2643
|
}
|
|
2632
|
-
const toBig = (h, l) => (BigInt(h >>> 0) << _32n
|
|
2644
|
+
const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);
|
|
2633
2645
|
// for Shift in [0, 32)
|
|
2634
2646
|
const shrSH = (h, _l, s) => h >>> s;
|
|
2635
2647
|
const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
@@ -2643,11 +2655,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
2643
2655
|
const rotr32H = (_h, l) => l;
|
|
2644
2656
|
const rotr32L = (h, _l) => h;
|
|
2645
2657
|
// Left rotate for Shift in [1, 32)
|
|
2646
|
-
const rotlSH
|
|
2647
|
-
const rotlSL
|
|
2658
|
+
const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
|
|
2659
|
+
const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
|
|
2648
2660
|
// Left rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
2649
|
-
const rotlBH
|
|
2650
|
-
const rotlBL
|
|
2661
|
+
const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
|
|
2662
|
+
const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
|
|
2651
2663
|
// JS uses 32-bit signed integers for bitwise operations which means we cannot
|
|
2652
2664
|
// simple take carry out of low bit sum by shift, we need to use division.
|
|
2653
2665
|
function add(Ah, Al, Bh, Bl) {
|
|
@@ -2663,11 +2675,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
2663
2675
|
const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
|
|
2664
2676
|
// prettier-ignore
|
|
2665
2677
|
const u64$1 = {
|
|
2666
|
-
fromBig
|
|
2678
|
+
fromBig, split, toBig,
|
|
2667
2679
|
shrSH, shrSL,
|
|
2668
2680
|
rotrSH, rotrSL, rotrBH, rotrBL,
|
|
2669
2681
|
rotr32H, rotr32L,
|
|
2670
|
-
rotlSH
|
|
2682
|
+
rotlSH, rotlSL, rotlBH, rotlBL,
|
|
2671
2683
|
add, add3L, add3H, add4L, add4H, add5H, add5L,
|
|
2672
2684
|
};
|
|
2673
2685
|
|
|
@@ -2825,7 +2837,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
2825
2837
|
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
2826
2838
|
}
|
|
2827
2839
|
}
|
|
2828
|
-
const sha512 = /* @__PURE__ */ wrapConstructor
|
|
2840
|
+
const sha512 = /* @__PURE__ */ wrapConstructor(() => new SHA512());
|
|
2829
2841
|
|
|
2830
2842
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2831
2843
|
// 100 lines of code in the file are duplicated from noble-hashes (utils).
|
|
@@ -2835,12 +2847,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
2835
2847
|
const _0n$5 = BigInt(0);
|
|
2836
2848
|
const _1n$7 = BigInt(1);
|
|
2837
2849
|
const _2n$5 = BigInt(2);
|
|
2838
|
-
function isBytes
|
|
2850
|
+
function isBytes(a) {
|
|
2839
2851
|
return (a instanceof Uint8Array ||
|
|
2840
2852
|
(a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
|
|
2841
2853
|
}
|
|
2842
2854
|
function abytes(item) {
|
|
2843
|
-
if (!isBytes
|
|
2855
|
+
if (!isBytes(item))
|
|
2844
2856
|
throw new Error('Uint8Array expected');
|
|
2845
2857
|
}
|
|
2846
2858
|
// Array where index 0xf0 (240) is mapped to string 'f0'
|
|
@@ -2937,7 +2949,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
2937
2949
|
throw new Error(`${title} must be valid hex string, got "${hex}". Cause: ${e}`);
|
|
2938
2950
|
}
|
|
2939
2951
|
}
|
|
2940
|
-
else if (isBytes
|
|
2952
|
+
else if (isBytes(hex)) {
|
|
2941
2953
|
// Uint8Array.from() instead of hash.slice() because node.js Buffer
|
|
2942
2954
|
// is instance of Uint8Array, and its slice() creates **mutable** copy
|
|
2943
2955
|
res = Uint8Array.from(hex);
|
|
@@ -2980,7 +2992,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
2980
2992
|
/**
|
|
2981
2993
|
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
|
|
2982
2994
|
*/
|
|
2983
|
-
function utf8ToBytes
|
|
2995
|
+
function utf8ToBytes(str) {
|
|
2984
2996
|
if (typeof str !== 'string')
|
|
2985
2997
|
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
2986
2998
|
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
@@ -3082,7 +3094,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
3082
3094
|
function: (val) => typeof val === 'function',
|
|
3083
3095
|
boolean: (val) => typeof val === 'boolean',
|
|
3084
3096
|
string: (val) => typeof val === 'string',
|
|
3085
|
-
stringOrUint8Array: (val) => typeof val === 'string' || isBytes
|
|
3097
|
+
stringOrUint8Array: (val) => typeof val === 'string' || isBytes(val),
|
|
3086
3098
|
isSafeInteger: (val) => Number.isSafeInteger(val),
|
|
3087
3099
|
array: (val) => Array.isArray(val),
|
|
3088
3100
|
field: (val, object) => object.Fp.isValid(val),
|
|
@@ -3132,12 +3144,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
3132
3144
|
equalBytes: equalBytes,
|
|
3133
3145
|
hexToBytes: hexToBytes,
|
|
3134
3146
|
hexToNumber: hexToNumber,
|
|
3135
|
-
isBytes: isBytes
|
|
3147
|
+
isBytes: isBytes,
|
|
3136
3148
|
numberToBytesBE: numberToBytesBE,
|
|
3137
3149
|
numberToBytesLE: numberToBytesLE,
|
|
3138
3150
|
numberToHexUnpadded: numberToHexUnpadded,
|
|
3139
3151
|
numberToVarBytesBE: numberToVarBytesBE,
|
|
3140
|
-
utf8ToBytes: utf8ToBytes
|
|
3152
|
+
utf8ToBytes: utf8ToBytes,
|
|
3141
3153
|
validateObject: validateObject
|
|
3142
3154
|
});
|
|
3143
3155
|
|
|
@@ -4166,7 +4178,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
4166
4178
|
function ed25519_domain(data, ctx, phflag) {
|
|
4167
4179
|
if (ctx.length > 255)
|
|
4168
4180
|
throw new Error('Context is too big');
|
|
4169
|
-
return concatBytes$1(utf8ToBytes$
|
|
4181
|
+
return concatBytes$1(utf8ToBytes$1('SigEd25519 no Ed25519 collisions'), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data);
|
|
4170
4182
|
}
|
|
4171
4183
|
/* @__PURE__ */ twistedEdwards({
|
|
4172
4184
|
...ed25519Defaults,
|
|
@@ -7806,216 +7818,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
7806
7818
|
|
|
7807
7819
|
var bs58$1 = /*@__PURE__*/getDefaultExportFromCjs(bs58);
|
|
7808
7820
|
|
|
7809
|
-
function number$1(n) {
|
|
7810
|
-
if (!Number.isSafeInteger(n) || n < 0)
|
|
7811
|
-
throw new Error(`Wrong positive integer: ${n}`);
|
|
7812
|
-
}
|
|
7813
|
-
// copied from utils
|
|
7814
|
-
function isBytes$1(a) {
|
|
7815
|
-
return (a instanceof Uint8Array ||
|
|
7816
|
-
(a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
|
|
7817
|
-
}
|
|
7818
|
-
function bytes(b, ...lengths) {
|
|
7819
|
-
if (!isBytes$1(b))
|
|
7820
|
-
throw new Error('Expected Uint8Array');
|
|
7821
|
-
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
7822
|
-
throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
|
|
7823
|
-
}
|
|
7824
|
-
function exists(instance, checkFinished = true) {
|
|
7825
|
-
if (instance.destroyed)
|
|
7826
|
-
throw new Error('Hash instance has been destroyed');
|
|
7827
|
-
if (checkFinished && instance.finished)
|
|
7828
|
-
throw new Error('Hash#digest() has already been called');
|
|
7829
|
-
}
|
|
7830
|
-
function output(out, instance) {
|
|
7831
|
-
bytes(out);
|
|
7832
|
-
const min = instance.outputLen;
|
|
7833
|
-
if (out.length < min) {
|
|
7834
|
-
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
7835
|
-
}
|
|
7836
|
-
}
|
|
7837
|
-
|
|
7838
|
-
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
7839
|
-
// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
|
|
7840
|
-
// node.js versions earlier than v19 don't declare it in global scope.
|
|
7841
|
-
// For node.js, package.json#exports field mapping rewrites import
|
|
7842
|
-
// from `crypto` to `cryptoNode`, which imports native module.
|
|
7843
|
-
// Makes the utils un-importable in browsers without a bundler.
|
|
7844
|
-
// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
|
|
7845
|
-
const u32$1 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
7846
|
-
function isBytes(a) {
|
|
7847
|
-
return (a instanceof Uint8Array ||
|
|
7848
|
-
(a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
|
|
7849
|
-
}
|
|
7850
|
-
// Cast array to view
|
|
7851
|
-
const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
7852
|
-
// The rotate right (circular right shift) operation for uint32
|
|
7853
|
-
const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
|
|
7854
|
-
// big-endian hardware is rare. Just in case someone still decides to run hashes:
|
|
7855
|
-
// early-throw an error because we don't support BE yet.
|
|
7856
|
-
// Other libraries would silently corrupt the data instead of throwing an error,
|
|
7857
|
-
// when they don't support it.
|
|
7858
|
-
const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
|
|
7859
|
-
if (!isLE)
|
|
7860
|
-
throw new Error('Non little-endian hardware is not supported');
|
|
7861
|
-
/**
|
|
7862
|
-
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
|
|
7863
|
-
*/
|
|
7864
|
-
function utf8ToBytes(str) {
|
|
7865
|
-
if (typeof str !== 'string')
|
|
7866
|
-
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
7867
|
-
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
7868
|
-
}
|
|
7869
|
-
/**
|
|
7870
|
-
* Normalizes (non-hex) string or Uint8Array to Uint8Array.
|
|
7871
|
-
* Warning: when Uint8Array is passed, it would NOT get copied.
|
|
7872
|
-
* Keep in mind for future mutable operations.
|
|
7873
|
-
*/
|
|
7874
|
-
function toBytes(data) {
|
|
7875
|
-
if (typeof data === 'string')
|
|
7876
|
-
data = utf8ToBytes(data);
|
|
7877
|
-
if (!isBytes(data))
|
|
7878
|
-
throw new Error(`expected Uint8Array, got ${typeof data}`);
|
|
7879
|
-
return data;
|
|
7880
|
-
}
|
|
7881
|
-
// For runtime check if class implements interface
|
|
7882
|
-
class Hash {
|
|
7883
|
-
// Safe version that clones internal state
|
|
7884
|
-
clone() {
|
|
7885
|
-
return this._cloneInto();
|
|
7886
|
-
}
|
|
7887
|
-
}
|
|
7888
|
-
function wrapConstructor(hashCons) {
|
|
7889
|
-
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
7890
|
-
const tmp = hashCons();
|
|
7891
|
-
hashC.outputLen = tmp.outputLen;
|
|
7892
|
-
hashC.blockLen = tmp.blockLen;
|
|
7893
|
-
hashC.create = () => hashCons();
|
|
7894
|
-
return hashC;
|
|
7895
|
-
}
|
|
7896
|
-
|
|
7897
|
-
// Polyfill for Safari 14
|
|
7898
|
-
function setBigUint64(view, byteOffset, value, isLE) {
|
|
7899
|
-
if (typeof view.setBigUint64 === 'function')
|
|
7900
|
-
return view.setBigUint64(byteOffset, value, isLE);
|
|
7901
|
-
const _32n = BigInt(32);
|
|
7902
|
-
const _u32_max = BigInt(0xffffffff);
|
|
7903
|
-
const wh = Number((value >> _32n) & _u32_max);
|
|
7904
|
-
const wl = Number(value & _u32_max);
|
|
7905
|
-
const h = isLE ? 4 : 0;
|
|
7906
|
-
const l = isLE ? 0 : 4;
|
|
7907
|
-
view.setUint32(byteOffset + h, wh, isLE);
|
|
7908
|
-
view.setUint32(byteOffset + l, wl, isLE);
|
|
7909
|
-
}
|
|
7910
|
-
// Base SHA2 class (RFC 6234)
|
|
7911
|
-
class SHA2 extends Hash {
|
|
7912
|
-
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
7913
|
-
super();
|
|
7914
|
-
this.blockLen = blockLen;
|
|
7915
|
-
this.outputLen = outputLen;
|
|
7916
|
-
this.padOffset = padOffset;
|
|
7917
|
-
this.isLE = isLE;
|
|
7918
|
-
this.finished = false;
|
|
7919
|
-
this.length = 0;
|
|
7920
|
-
this.pos = 0;
|
|
7921
|
-
this.destroyed = false;
|
|
7922
|
-
this.buffer = new Uint8Array(blockLen);
|
|
7923
|
-
this.view = createView(this.buffer);
|
|
7924
|
-
}
|
|
7925
|
-
update(data) {
|
|
7926
|
-
exists(this);
|
|
7927
|
-
const { view, buffer, blockLen } = this;
|
|
7928
|
-
data = toBytes(data);
|
|
7929
|
-
const len = data.length;
|
|
7930
|
-
for (let pos = 0; pos < len;) {
|
|
7931
|
-
const take = Math.min(blockLen - this.pos, len - pos);
|
|
7932
|
-
// Fast path: we have at least one block in input, cast it to view and process
|
|
7933
|
-
if (take === blockLen) {
|
|
7934
|
-
const dataView = createView(data);
|
|
7935
|
-
for (; blockLen <= len - pos; pos += blockLen)
|
|
7936
|
-
this.process(dataView, pos);
|
|
7937
|
-
continue;
|
|
7938
|
-
}
|
|
7939
|
-
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
7940
|
-
this.pos += take;
|
|
7941
|
-
pos += take;
|
|
7942
|
-
if (this.pos === blockLen) {
|
|
7943
|
-
this.process(view, 0);
|
|
7944
|
-
this.pos = 0;
|
|
7945
|
-
}
|
|
7946
|
-
}
|
|
7947
|
-
this.length += data.length;
|
|
7948
|
-
this.roundClean();
|
|
7949
|
-
return this;
|
|
7950
|
-
}
|
|
7951
|
-
digestInto(out) {
|
|
7952
|
-
exists(this);
|
|
7953
|
-
output(out, this);
|
|
7954
|
-
this.finished = true;
|
|
7955
|
-
// Padding
|
|
7956
|
-
// We can avoid allocation of buffer for padding completely if it
|
|
7957
|
-
// was previously not allocated here. But it won't change performance.
|
|
7958
|
-
const { buffer, view, blockLen, isLE } = this;
|
|
7959
|
-
let { pos } = this;
|
|
7960
|
-
// append the bit '1' to the message
|
|
7961
|
-
buffer[pos++] = 0b10000000;
|
|
7962
|
-
this.buffer.subarray(pos).fill(0);
|
|
7963
|
-
// we have less than padOffset left in buffer, so we cannot put length in current block, need process it and pad again
|
|
7964
|
-
if (this.padOffset > blockLen - pos) {
|
|
7965
|
-
this.process(view, 0);
|
|
7966
|
-
pos = 0;
|
|
7967
|
-
}
|
|
7968
|
-
// Pad until full block byte with zeros
|
|
7969
|
-
for (let i = pos; i < blockLen; i++)
|
|
7970
|
-
buffer[i] = 0;
|
|
7971
|
-
// Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
|
|
7972
|
-
// You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
|
|
7973
|
-
// So we just write lowest 64 bits of that value.
|
|
7974
|
-
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
7975
|
-
this.process(view, 0);
|
|
7976
|
-
const oview = createView(out);
|
|
7977
|
-
const len = this.outputLen;
|
|
7978
|
-
// NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
|
|
7979
|
-
if (len % 4)
|
|
7980
|
-
throw new Error('_sha2: outputLen should be aligned to 32bit');
|
|
7981
|
-
const outLen = len / 4;
|
|
7982
|
-
const state = this.get();
|
|
7983
|
-
if (outLen > state.length)
|
|
7984
|
-
throw new Error('_sha2: outputLen bigger than state');
|
|
7985
|
-
for (let i = 0; i < outLen; i++)
|
|
7986
|
-
oview.setUint32(4 * i, state[i], isLE);
|
|
7987
|
-
}
|
|
7988
|
-
digest() {
|
|
7989
|
-
const { buffer, outputLen } = this;
|
|
7990
|
-
this.digestInto(buffer);
|
|
7991
|
-
const res = buffer.slice(0, outputLen);
|
|
7992
|
-
this.destroy();
|
|
7993
|
-
return res;
|
|
7994
|
-
}
|
|
7995
|
-
_cloneInto(to) {
|
|
7996
|
-
to || (to = new this.constructor());
|
|
7997
|
-
to.set(...this.get());
|
|
7998
|
-
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
7999
|
-
to.length = length;
|
|
8000
|
-
to.pos = pos;
|
|
8001
|
-
to.finished = finished;
|
|
8002
|
-
to.destroyed = destroyed;
|
|
8003
|
-
if (length % blockLen)
|
|
8004
|
-
to.buffer.set(buffer);
|
|
8005
|
-
return to;
|
|
8006
|
-
}
|
|
8007
|
-
}
|
|
8008
|
-
|
|
8009
7821
|
// SHA2-256 need to try 2^128 hashes to execute birthday attack.
|
|
8010
7822
|
// BTC network is doing 2^67 hashes/sec as per early 2023.
|
|
8011
|
-
// Choice: a ? b : c
|
|
8012
|
-
const Chi = (a, b, c) => (a & b) ^ (~a & c);
|
|
8013
|
-
// Majority function, true if any two inpust is true
|
|
8014
|
-
const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
|
|
8015
7823
|
// Round constants:
|
|
8016
7824
|
// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
|
|
8017
7825
|
// prettier-ignore
|
|
8018
|
-
const SHA256_K
|
|
7826
|
+
const SHA256_K = /* @__PURE__ */ new Uint32Array([
|
|
8019
7827
|
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
8020
7828
|
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
8021
7829
|
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
@@ -8025,27 +7833,28 @@ var solanaWeb3 = (function (exports) {
|
|
|
8025
7833
|
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
8026
7834
|
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
8027
7835
|
]);
|
|
8028
|
-
// Initial state
|
|
7836
|
+
// Initial state:
|
|
7837
|
+
// first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19
|
|
8029
7838
|
// prettier-ignore
|
|
8030
|
-
const
|
|
7839
|
+
const SHA256_IV = /* @__PURE__ */ new Uint32Array([
|
|
8031
7840
|
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
|
8032
7841
|
]);
|
|
8033
7842
|
// Temporary buffer, not used to store anything between runs
|
|
8034
7843
|
// Named this way because it matches specification.
|
|
8035
|
-
const SHA256_W
|
|
8036
|
-
|
|
7844
|
+
const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
7845
|
+
class SHA256 extends HashMD {
|
|
8037
7846
|
constructor() {
|
|
8038
7847
|
super(64, 32, 8, false);
|
|
8039
7848
|
// We cannot use array here since array allows indexing by variable
|
|
8040
7849
|
// which means optimizer/compiler cannot use registers.
|
|
8041
|
-
this.A =
|
|
8042
|
-
this.B =
|
|
8043
|
-
this.C =
|
|
8044
|
-
this.D =
|
|
8045
|
-
this.E =
|
|
8046
|
-
this.F =
|
|
8047
|
-
this.G =
|
|
8048
|
-
this.H =
|
|
7850
|
+
this.A = SHA256_IV[0] | 0;
|
|
7851
|
+
this.B = SHA256_IV[1] | 0;
|
|
7852
|
+
this.C = SHA256_IV[2] | 0;
|
|
7853
|
+
this.D = SHA256_IV[3] | 0;
|
|
7854
|
+
this.E = SHA256_IV[4] | 0;
|
|
7855
|
+
this.F = SHA256_IV[5] | 0;
|
|
7856
|
+
this.G = SHA256_IV[6] | 0;
|
|
7857
|
+
this.H = SHA256_IV[7] | 0;
|
|
8049
7858
|
}
|
|
8050
7859
|
get() {
|
|
8051
7860
|
const { A, B, C, D, E, F, G, H } = this;
|
|
@@ -8065,19 +7874,19 @@ var solanaWeb3 = (function (exports) {
|
|
|
8065
7874
|
process(view, offset) {
|
|
8066
7875
|
// Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
|
|
8067
7876
|
for (let i = 0; i < 16; i++, offset += 4)
|
|
8068
|
-
SHA256_W
|
|
7877
|
+
SHA256_W[i] = view.getUint32(offset, false);
|
|
8069
7878
|
for (let i = 16; i < 64; i++) {
|
|
8070
|
-
const W15 = SHA256_W
|
|
8071
|
-
const W2 = SHA256_W
|
|
7879
|
+
const W15 = SHA256_W[i - 15];
|
|
7880
|
+
const W2 = SHA256_W[i - 2];
|
|
8072
7881
|
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);
|
|
8073
7882
|
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);
|
|
8074
|
-
SHA256_W
|
|
7883
|
+
SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;
|
|
8075
7884
|
}
|
|
8076
7885
|
// Compression function main loop, 64 rounds
|
|
8077
7886
|
let { A, B, C, D, E, F, G, H } = this;
|
|
8078
7887
|
for (let i = 0; i < 64; i++) {
|
|
8079
7888
|
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
8080
|
-
const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K
|
|
7889
|
+
const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
|
8081
7890
|
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
8082
7891
|
const T2 = (sigma0 + Maj(A, B, C)) | 0;
|
|
8083
7892
|
H = G;
|
|
@@ -8101,18 +7910,18 @@ var solanaWeb3 = (function (exports) {
|
|
|
8101
7910
|
this.set(A, B, C, D, E, F, G, H);
|
|
8102
7911
|
}
|
|
8103
7912
|
roundClean() {
|
|
8104
|
-
SHA256_W
|
|
7913
|
+
SHA256_W.fill(0);
|
|
8105
7914
|
}
|
|
8106
7915
|
destroy() {
|
|
8107
7916
|
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
8108
7917
|
this.buffer.fill(0);
|
|
8109
7918
|
}
|
|
8110
|
-
}
|
|
7919
|
+
}
|
|
8111
7920
|
/**
|
|
8112
7921
|
* SHA2-256 hash function
|
|
8113
7922
|
* @param message - data that would be hashed
|
|
8114
7923
|
*/
|
|
8115
|
-
const sha256
|
|
7924
|
+
const sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
|
|
8116
7925
|
|
|
8117
7926
|
var lib = {};
|
|
8118
7927
|
|
|
@@ -9231,8 +9040,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
9231
9040
|
}
|
|
9232
9041
|
const SOLANA_SCHEMA = new Map();
|
|
9233
9042
|
|
|
9234
|
-
var
|
|
9235
|
-
let _Symbol$toStringTag;
|
|
9043
|
+
var _PublicKey;
|
|
9236
9044
|
|
|
9237
9045
|
/**
|
|
9238
9046
|
* Maximum length of derived pubkey seed
|
|
@@ -9262,7 +9070,6 @@ var solanaWeb3 = (function (exports) {
|
|
|
9262
9070
|
/**
|
|
9263
9071
|
* A public key
|
|
9264
9072
|
*/
|
|
9265
|
-
_Symbol$toStringTag = Symbol.toStringTag;
|
|
9266
9073
|
class PublicKey extends Struct$1 {
|
|
9267
9074
|
/**
|
|
9268
9075
|
* Create a new PublicKey object
|
|
@@ -9342,7 +9149,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
9342
9149
|
b.copy(zeroPad, 32 - b.length);
|
|
9343
9150
|
return zeroPad;
|
|
9344
9151
|
}
|
|
9345
|
-
get [
|
|
9152
|
+
get [Symbol.toStringTag]() {
|
|
9346
9153
|
return `PublicKey(${this.toString()})`;
|
|
9347
9154
|
}
|
|
9348
9155
|
|
|
@@ -9361,7 +9168,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
9361
9168
|
/* eslint-disable require-await */
|
|
9362
9169
|
static async createWithSeed(fromPublicKey, seed, programId) {
|
|
9363
9170
|
const buffer$1 = buffer.Buffer.concat([fromPublicKey.toBuffer(), buffer.Buffer.from(seed), programId.toBuffer()]);
|
|
9364
|
-
const publicKeyBytes = sha256
|
|
9171
|
+
const publicKeyBytes = sha256(buffer$1);
|
|
9365
9172
|
return new PublicKey(publicKeyBytes);
|
|
9366
9173
|
}
|
|
9367
9174
|
|
|
@@ -9378,7 +9185,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
9378
9185
|
buffer$1 = buffer.Buffer.concat([buffer$1, toBuffer(seed)]);
|
|
9379
9186
|
});
|
|
9380
9187
|
buffer$1 = buffer.Buffer.concat([buffer$1, programId.toBuffer(), buffer.Buffer.from('ProgramDerivedAddress')]);
|
|
9381
|
-
const publicKeyBytes = sha256
|
|
9188
|
+
const publicKeyBytes = sha256(buffer$1);
|
|
9382
9189
|
if (isOnCurve(publicKeyBytes)) {
|
|
9383
9190
|
throw new Error(`Invalid seeds, address must fall off the curve`);
|
|
9384
9191
|
}
|
|
@@ -9440,8 +9247,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
9440
9247
|
return isOnCurve(pubkey.toBytes());
|
|
9441
9248
|
}
|
|
9442
9249
|
}
|
|
9443
|
-
|
|
9444
|
-
PublicKey.default = new
|
|
9250
|
+
_PublicKey = PublicKey;
|
|
9251
|
+
PublicKey.default = new _PublicKey('11111111111111111111111111111111');
|
|
9445
9252
|
SOLANA_SCHEMA.set(PublicKey, {
|
|
9446
9253
|
kind: 'struct',
|
|
9447
9254
|
fields: [['_bn', 'u256']]
|
|
@@ -16393,1459 +16200,694 @@ var solanaWeb3 = (function (exports) {
|
|
|
16393
16200
|
|
|
16394
16201
|
var client = {};
|
|
16395
16202
|
|
|
16396
|
-
var
|
|
16203
|
+
var eventemitter3 = {exports: {}};
|
|
16397
16204
|
|
|
16398
16205
|
(function (module) {
|
|
16399
|
-
function _interopRequireDefault(obj) {
|
|
16400
|
-
return obj && obj.__esModule ? obj : {
|
|
16401
|
-
"default": obj
|
|
16402
|
-
};
|
|
16403
|
-
}
|
|
16404
|
-
module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16405
|
-
} (interopRequireDefault));
|
|
16406
|
-
|
|
16407
|
-
var interopRequireDefaultExports = interopRequireDefault.exports;
|
|
16408
|
-
|
|
16409
|
-
var regeneratorRuntime$1 = {exports: {}};
|
|
16410
16206
|
|
|
16411
|
-
|
|
16207
|
+
var has = Object.prototype.hasOwnProperty
|
|
16208
|
+
, prefix = '~';
|
|
16412
16209
|
|
|
16413
|
-
|
|
16414
|
-
|
|
16415
|
-
|
|
16416
|
-
|
|
16417
|
-
|
|
16418
|
-
|
|
16419
|
-
|
|
16420
|
-
|
|
16421
|
-
|
|
16422
|
-
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
16423
|
-
return typeof o;
|
|
16424
|
-
} : function (o) {
|
|
16425
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
16426
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o);
|
|
16427
|
-
}
|
|
16428
|
-
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16429
|
-
} (_typeof));
|
|
16430
|
-
return _typeof.exports;
|
|
16431
|
-
}
|
|
16432
|
-
|
|
16433
|
-
var hasRequiredRegeneratorRuntime;
|
|
16434
|
-
|
|
16435
|
-
function requireRegeneratorRuntime () {
|
|
16436
|
-
if (hasRequiredRegeneratorRuntime) return regeneratorRuntime$1.exports;
|
|
16437
|
-
hasRequiredRegeneratorRuntime = 1;
|
|
16438
|
-
(function (module) {
|
|
16439
|
-
var _typeof = require_typeof()["default"];
|
|
16440
|
-
function _regeneratorRuntime() {
|
|
16441
|
-
module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
16442
|
-
return e;
|
|
16443
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16444
|
-
var t,
|
|
16445
|
-
e = {},
|
|
16446
|
-
r = Object.prototype,
|
|
16447
|
-
n = r.hasOwnProperty,
|
|
16448
|
-
o = Object.defineProperty || function (t, e, r) {
|
|
16449
|
-
t[e] = r.value;
|
|
16450
|
-
},
|
|
16451
|
-
i = "function" == typeof Symbol ? Symbol : {},
|
|
16452
|
-
a = i.iterator || "@@iterator",
|
|
16453
|
-
c = i.asyncIterator || "@@asyncIterator",
|
|
16454
|
-
u = i.toStringTag || "@@toStringTag";
|
|
16455
|
-
function define(t, e, r) {
|
|
16456
|
-
return Object.defineProperty(t, e, {
|
|
16457
|
-
value: r,
|
|
16458
|
-
enumerable: !0,
|
|
16459
|
-
configurable: !0,
|
|
16460
|
-
writable: !0
|
|
16461
|
-
}), t[e];
|
|
16462
|
-
}
|
|
16463
|
-
try {
|
|
16464
|
-
define({}, "");
|
|
16465
|
-
} catch (t) {
|
|
16466
|
-
define = function define(t, e, r) {
|
|
16467
|
-
return t[e] = r;
|
|
16468
|
-
};
|
|
16469
|
-
}
|
|
16470
|
-
function wrap(t, e, r, n) {
|
|
16471
|
-
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
16472
|
-
a = Object.create(i.prototype),
|
|
16473
|
-
c = new Context(n || []);
|
|
16474
|
-
return o(a, "_invoke", {
|
|
16475
|
-
value: makeInvokeMethod(t, r, c)
|
|
16476
|
-
}), a;
|
|
16477
|
-
}
|
|
16478
|
-
function tryCatch(t, e, r) {
|
|
16479
|
-
try {
|
|
16480
|
-
return {
|
|
16481
|
-
type: "normal",
|
|
16482
|
-
arg: t.call(e, r)
|
|
16483
|
-
};
|
|
16484
|
-
} catch (t) {
|
|
16485
|
-
return {
|
|
16486
|
-
type: "throw",
|
|
16487
|
-
arg: t
|
|
16488
|
-
};
|
|
16489
|
-
}
|
|
16490
|
-
}
|
|
16491
|
-
e.wrap = wrap;
|
|
16492
|
-
var h = "suspendedStart",
|
|
16493
|
-
l = "suspendedYield",
|
|
16494
|
-
f = "executing",
|
|
16495
|
-
s = "completed",
|
|
16496
|
-
y = {};
|
|
16497
|
-
function Generator() {}
|
|
16498
|
-
function GeneratorFunction() {}
|
|
16499
|
-
function GeneratorFunctionPrototype() {}
|
|
16500
|
-
var p = {};
|
|
16501
|
-
define(p, a, function () {
|
|
16502
|
-
return this;
|
|
16503
|
-
});
|
|
16504
|
-
var d = Object.getPrototypeOf,
|
|
16505
|
-
v = d && d(d(values([])));
|
|
16506
|
-
v && v !== r && n.call(v, a) && (p = v);
|
|
16507
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
16508
|
-
function defineIteratorMethods(t) {
|
|
16509
|
-
["next", "throw", "return"].forEach(function (e) {
|
|
16510
|
-
define(t, e, function (t) {
|
|
16511
|
-
return this._invoke(e, t);
|
|
16512
|
-
});
|
|
16513
|
-
});
|
|
16514
|
-
}
|
|
16515
|
-
function AsyncIterator(t, e) {
|
|
16516
|
-
function invoke(r, o, i, a) {
|
|
16517
|
-
var c = tryCatch(t[r], t, o);
|
|
16518
|
-
if ("throw" !== c.type) {
|
|
16519
|
-
var u = c.arg,
|
|
16520
|
-
h = u.value;
|
|
16521
|
-
return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
16522
|
-
invoke("next", t, i, a);
|
|
16523
|
-
}, function (t) {
|
|
16524
|
-
invoke("throw", t, i, a);
|
|
16525
|
-
}) : e.resolve(h).then(function (t) {
|
|
16526
|
-
u.value = t, i(u);
|
|
16527
|
-
}, function (t) {
|
|
16528
|
-
return invoke("throw", t, i, a);
|
|
16529
|
-
});
|
|
16530
|
-
}
|
|
16531
|
-
a(c.arg);
|
|
16532
|
-
}
|
|
16533
|
-
var r;
|
|
16534
|
-
o(this, "_invoke", {
|
|
16535
|
-
value: function value(t, n) {
|
|
16536
|
-
function callInvokeWithMethodAndArg() {
|
|
16537
|
-
return new e(function (e, r) {
|
|
16538
|
-
invoke(t, n, e, r);
|
|
16539
|
-
});
|
|
16540
|
-
}
|
|
16541
|
-
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
16542
|
-
}
|
|
16543
|
-
});
|
|
16544
|
-
}
|
|
16545
|
-
function makeInvokeMethod(e, r, n) {
|
|
16546
|
-
var o = h;
|
|
16547
|
-
return function (i, a) {
|
|
16548
|
-
if (o === f) throw new Error("Generator is already running");
|
|
16549
|
-
if (o === s) {
|
|
16550
|
-
if ("throw" === i) throw a;
|
|
16551
|
-
return {
|
|
16552
|
-
value: t,
|
|
16553
|
-
done: !0
|
|
16554
|
-
};
|
|
16555
|
-
}
|
|
16556
|
-
for (n.method = i, n.arg = a;;) {
|
|
16557
|
-
var c = n.delegate;
|
|
16558
|
-
if (c) {
|
|
16559
|
-
var u = maybeInvokeDelegate(c, n);
|
|
16560
|
-
if (u) {
|
|
16561
|
-
if (u === y) continue;
|
|
16562
|
-
return u;
|
|
16563
|
-
}
|
|
16564
|
-
}
|
|
16565
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
16566
|
-
if (o === h) throw o = s, n.arg;
|
|
16567
|
-
n.dispatchException(n.arg);
|
|
16568
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
16569
|
-
o = f;
|
|
16570
|
-
var p = tryCatch(e, r, n);
|
|
16571
|
-
if ("normal" === p.type) {
|
|
16572
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
|
16573
|
-
return {
|
|
16574
|
-
value: p.arg,
|
|
16575
|
-
done: n.done
|
|
16576
|
-
};
|
|
16577
|
-
}
|
|
16578
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
16579
|
-
}
|
|
16580
|
-
};
|
|
16581
|
-
}
|
|
16582
|
-
function maybeInvokeDelegate(e, r) {
|
|
16583
|
-
var n = r.method,
|
|
16584
|
-
o = e.iterator[n];
|
|
16585
|
-
if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
16586
|
-
var i = tryCatch(o, e.iterator, r.arg);
|
|
16587
|
-
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
16588
|
-
var a = i.arg;
|
|
16589
|
-
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
16590
|
-
}
|
|
16591
|
-
function pushTryEntry(t) {
|
|
16592
|
-
var e = {
|
|
16593
|
-
tryLoc: t[0]
|
|
16594
|
-
};
|
|
16595
|
-
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
16596
|
-
}
|
|
16597
|
-
function resetTryEntry(t) {
|
|
16598
|
-
var e = t.completion || {};
|
|
16599
|
-
e.type = "normal", delete e.arg, t.completion = e;
|
|
16600
|
-
}
|
|
16601
|
-
function Context(t) {
|
|
16602
|
-
this.tryEntries = [{
|
|
16603
|
-
tryLoc: "root"
|
|
16604
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
16605
|
-
}
|
|
16606
|
-
function values(e) {
|
|
16607
|
-
if (e || "" === e) {
|
|
16608
|
-
var r = e[a];
|
|
16609
|
-
if (r) return r.call(e);
|
|
16610
|
-
if ("function" == typeof e.next) return e;
|
|
16611
|
-
if (!isNaN(e.length)) {
|
|
16612
|
-
var o = -1,
|
|
16613
|
-
i = function next() {
|
|
16614
|
-
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
16615
|
-
return next.value = t, next.done = !0, next;
|
|
16616
|
-
};
|
|
16617
|
-
return i.next = i;
|
|
16618
|
-
}
|
|
16619
|
-
}
|
|
16620
|
-
throw new TypeError(_typeof(e) + " is not iterable");
|
|
16621
|
-
}
|
|
16622
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
16623
|
-
value: GeneratorFunctionPrototype,
|
|
16624
|
-
configurable: !0
|
|
16625
|
-
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
16626
|
-
value: GeneratorFunction,
|
|
16627
|
-
configurable: !0
|
|
16628
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
16629
|
-
var e = "function" == typeof t && t.constructor;
|
|
16630
|
-
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
16631
|
-
}, e.mark = function (t) {
|
|
16632
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
16633
|
-
}, e.awrap = function (t) {
|
|
16634
|
-
return {
|
|
16635
|
-
__await: t
|
|
16636
|
-
};
|
|
16637
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
16638
|
-
return this;
|
|
16639
|
-
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
16640
|
-
void 0 === i && (i = Promise);
|
|
16641
|
-
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
16642
|
-
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
16643
|
-
return t.done ? t.value : a.next();
|
|
16644
|
-
});
|
|
16645
|
-
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
16646
|
-
return this;
|
|
16647
|
-
}), define(g, "toString", function () {
|
|
16648
|
-
return "[object Generator]";
|
|
16649
|
-
}), e.keys = function (t) {
|
|
16650
|
-
var e = Object(t),
|
|
16651
|
-
r = [];
|
|
16652
|
-
for (var n in e) r.push(n);
|
|
16653
|
-
return r.reverse(), function next() {
|
|
16654
|
-
for (; r.length;) {
|
|
16655
|
-
var t = r.pop();
|
|
16656
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
|
16657
|
-
}
|
|
16658
|
-
return next.done = !0, next;
|
|
16659
|
-
};
|
|
16660
|
-
}, e.values = values, Context.prototype = {
|
|
16661
|
-
constructor: Context,
|
|
16662
|
-
reset: function reset(e) {
|
|
16663
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
16664
|
-
},
|
|
16665
|
-
stop: function stop() {
|
|
16666
|
-
this.done = !0;
|
|
16667
|
-
var t = this.tryEntries[0].completion;
|
|
16668
|
-
if ("throw" === t.type) throw t.arg;
|
|
16669
|
-
return this.rval;
|
|
16670
|
-
},
|
|
16671
|
-
dispatchException: function dispatchException(e) {
|
|
16672
|
-
if (this.done) throw e;
|
|
16673
|
-
var r = this;
|
|
16674
|
-
function handle(n, o) {
|
|
16675
|
-
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
16676
|
-
}
|
|
16677
|
-
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
16678
|
-
var i = this.tryEntries[o],
|
|
16679
|
-
a = i.completion;
|
|
16680
|
-
if ("root" === i.tryLoc) return handle("end");
|
|
16681
|
-
if (i.tryLoc <= this.prev) {
|
|
16682
|
-
var c = n.call(i, "catchLoc"),
|
|
16683
|
-
u = n.call(i, "finallyLoc");
|
|
16684
|
-
if (c && u) {
|
|
16685
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
16686
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
16687
|
-
} else if (c) {
|
|
16688
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
16689
|
-
} else {
|
|
16690
|
-
if (!u) throw new Error("try statement without catch or finally");
|
|
16691
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
16692
|
-
}
|
|
16693
|
-
}
|
|
16694
|
-
}
|
|
16695
|
-
},
|
|
16696
|
-
abrupt: function abrupt(t, e) {
|
|
16697
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
16698
|
-
var o = this.tryEntries[r];
|
|
16699
|
-
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
16700
|
-
var i = o;
|
|
16701
|
-
break;
|
|
16702
|
-
}
|
|
16703
|
-
}
|
|
16704
|
-
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
16705
|
-
var a = i ? i.completion : {};
|
|
16706
|
-
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
16707
|
-
},
|
|
16708
|
-
complete: function complete(t, e) {
|
|
16709
|
-
if ("throw" === t.type) throw t.arg;
|
|
16710
|
-
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
16711
|
-
},
|
|
16712
|
-
finish: function finish(t) {
|
|
16713
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
16714
|
-
var r = this.tryEntries[e];
|
|
16715
|
-
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
16716
|
-
}
|
|
16717
|
-
},
|
|
16718
|
-
"catch": function _catch(t) {
|
|
16719
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
16720
|
-
var r = this.tryEntries[e];
|
|
16721
|
-
if (r.tryLoc === t) {
|
|
16722
|
-
var n = r.completion;
|
|
16723
|
-
if ("throw" === n.type) {
|
|
16724
|
-
var o = n.arg;
|
|
16725
|
-
resetTryEntry(r);
|
|
16726
|
-
}
|
|
16727
|
-
return o;
|
|
16728
|
-
}
|
|
16729
|
-
}
|
|
16730
|
-
throw new Error("illegal catch attempt");
|
|
16731
|
-
},
|
|
16732
|
-
delegateYield: function delegateYield(e, r, n) {
|
|
16733
|
-
return this.delegate = {
|
|
16734
|
-
iterator: values(e),
|
|
16735
|
-
resultName: r,
|
|
16736
|
-
nextLoc: n
|
|
16737
|
-
}, "next" === this.method && (this.arg = t), y;
|
|
16738
|
-
}
|
|
16739
|
-
}, e;
|
|
16740
|
-
}
|
|
16741
|
-
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16742
|
-
} (regeneratorRuntime$1));
|
|
16743
|
-
return regeneratorRuntime$1.exports;
|
|
16744
|
-
}
|
|
16745
|
-
|
|
16746
|
-
var regenerator;
|
|
16747
|
-
var hasRequiredRegenerator;
|
|
16210
|
+
/**
|
|
16211
|
+
* Constructor to create a storage for our `EE` objects.
|
|
16212
|
+
* An `Events` instance is a plain object whose properties are event names.
|
|
16213
|
+
*
|
|
16214
|
+
* @constructor
|
|
16215
|
+
* @private
|
|
16216
|
+
*/
|
|
16217
|
+
function Events() {}
|
|
16748
16218
|
|
|
16749
|
-
|
|
16750
|
-
|
|
16751
|
-
|
|
16752
|
-
//
|
|
16219
|
+
//
|
|
16220
|
+
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
16221
|
+
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
16222
|
+
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
16223
|
+
// character to make sure that the built-in object properties are not
|
|
16224
|
+
// overridden or used as an attack vector.
|
|
16225
|
+
//
|
|
16226
|
+
if (Object.create) {
|
|
16227
|
+
Events.prototype = Object.create(null);
|
|
16753
16228
|
|
|
16754
|
-
|
|
16755
|
-
|
|
16229
|
+
//
|
|
16230
|
+
// This hack is needed because the `__proto__` property is still inherited in
|
|
16231
|
+
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
16232
|
+
//
|
|
16233
|
+
if (!new Events().__proto__) prefix = false;
|
|
16234
|
+
}
|
|
16756
16235
|
|
|
16757
|
-
|
|
16758
|
-
|
|
16759
|
-
|
|
16760
|
-
|
|
16761
|
-
|
|
16762
|
-
|
|
16763
|
-
|
|
16764
|
-
|
|
16765
|
-
|
|
16236
|
+
/**
|
|
16237
|
+
* Representation of a single event listener.
|
|
16238
|
+
*
|
|
16239
|
+
* @param {Function} fn The listener function.
|
|
16240
|
+
* @param {*} context The context to invoke the listener with.
|
|
16241
|
+
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
16242
|
+
* @constructor
|
|
16243
|
+
* @private
|
|
16244
|
+
*/
|
|
16245
|
+
function EE(fn, context, once) {
|
|
16246
|
+
this.fn = fn;
|
|
16247
|
+
this.context = context;
|
|
16248
|
+
this.once = once || false;
|
|
16766
16249
|
}
|
|
16767
|
-
return regenerator;
|
|
16768
|
-
}
|
|
16769
|
-
|
|
16770
|
-
var asyncToGenerator = {exports: {}};
|
|
16771
|
-
|
|
16772
|
-
var hasRequiredAsyncToGenerator;
|
|
16773
|
-
|
|
16774
|
-
function requireAsyncToGenerator () {
|
|
16775
|
-
if (hasRequiredAsyncToGenerator) return asyncToGenerator.exports;
|
|
16776
|
-
hasRequiredAsyncToGenerator = 1;
|
|
16777
|
-
(function (module) {
|
|
16778
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
16779
|
-
try {
|
|
16780
|
-
var info = gen[key](arg);
|
|
16781
|
-
var value = info.value;
|
|
16782
|
-
} catch (error) {
|
|
16783
|
-
reject(error);
|
|
16784
|
-
return;
|
|
16785
|
-
}
|
|
16786
|
-
if (info.done) {
|
|
16787
|
-
resolve(value);
|
|
16788
|
-
} else {
|
|
16789
|
-
Promise.resolve(value).then(_next, _throw);
|
|
16790
|
-
}
|
|
16791
|
-
}
|
|
16792
|
-
function _asyncToGenerator(fn) {
|
|
16793
|
-
return function () {
|
|
16794
|
-
var self = this,
|
|
16795
|
-
args = arguments;
|
|
16796
|
-
return new Promise(function (resolve, reject) {
|
|
16797
|
-
var gen = fn.apply(self, args);
|
|
16798
|
-
function _next(value) {
|
|
16799
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
16800
|
-
}
|
|
16801
|
-
function _throw(err) {
|
|
16802
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
16803
|
-
}
|
|
16804
|
-
_next(undefined);
|
|
16805
|
-
});
|
|
16806
|
-
};
|
|
16807
|
-
}
|
|
16808
|
-
module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16809
|
-
} (asyncToGenerator));
|
|
16810
|
-
return asyncToGenerator.exports;
|
|
16811
|
-
}
|
|
16812
16250
|
|
|
16813
|
-
|
|
16251
|
+
/**
|
|
16252
|
+
* Add a listener for a given event.
|
|
16253
|
+
*
|
|
16254
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
16255
|
+
* @param {(String|Symbol)} event The event name.
|
|
16256
|
+
* @param {Function} fn The listener function.
|
|
16257
|
+
* @param {*} context The context to invoke the listener with.
|
|
16258
|
+
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
16259
|
+
* @returns {EventEmitter}
|
|
16260
|
+
* @private
|
|
16261
|
+
*/
|
|
16262
|
+
function addListener(emitter, event, fn, context, once) {
|
|
16263
|
+
if (typeof fn !== 'function') {
|
|
16264
|
+
throw new TypeError('The listener must be a function');
|
|
16265
|
+
}
|
|
16814
16266
|
|
|
16815
|
-
|
|
16267
|
+
var listener = new EE(fn, context || emitter, once)
|
|
16268
|
+
, evt = prefix ? prefix + event : event;
|
|
16816
16269
|
|
|
16817
|
-
|
|
16818
|
-
|
|
16819
|
-
|
|
16820
|
-
(function (module) {
|
|
16821
|
-
function _classCallCheck(instance, Constructor) {
|
|
16822
|
-
if (!(instance instanceof Constructor)) {
|
|
16823
|
-
throw new TypeError("Cannot call a class as a function");
|
|
16824
|
-
}
|
|
16825
|
-
}
|
|
16826
|
-
module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16827
|
-
} (classCallCheck));
|
|
16828
|
-
return classCallCheck.exports;
|
|
16829
|
-
}
|
|
16270
|
+
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
16271
|
+
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
16272
|
+
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
16830
16273
|
|
|
16831
|
-
|
|
16274
|
+
return emitter;
|
|
16275
|
+
}
|
|
16832
16276
|
|
|
16833
|
-
|
|
16277
|
+
/**
|
|
16278
|
+
* Clear event by name.
|
|
16279
|
+
*
|
|
16280
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
16281
|
+
* @param {(String|Symbol)} evt The Event name.
|
|
16282
|
+
* @private
|
|
16283
|
+
*/
|
|
16284
|
+
function clearEvent(emitter, evt) {
|
|
16285
|
+
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
16286
|
+
else delete emitter._events[evt];
|
|
16287
|
+
}
|
|
16834
16288
|
|
|
16835
|
-
|
|
16289
|
+
/**
|
|
16290
|
+
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
16291
|
+
* `EventEmitter` interface.
|
|
16292
|
+
*
|
|
16293
|
+
* @constructor
|
|
16294
|
+
* @public
|
|
16295
|
+
*/
|
|
16296
|
+
function EventEmitter() {
|
|
16297
|
+
this._events = new Events();
|
|
16298
|
+
this._eventsCount = 0;
|
|
16299
|
+
}
|
|
16836
16300
|
|
|
16837
|
-
|
|
16301
|
+
/**
|
|
16302
|
+
* Return an array listing the events for which the emitter has registered
|
|
16303
|
+
* listeners.
|
|
16304
|
+
*
|
|
16305
|
+
* @returns {Array}
|
|
16306
|
+
* @public
|
|
16307
|
+
*/
|
|
16308
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
16309
|
+
var names = []
|
|
16310
|
+
, events
|
|
16311
|
+
, name;
|
|
16838
16312
|
|
|
16839
|
-
|
|
16840
|
-
if (hasRequiredToPrimitive) return toPrimitive.exports;
|
|
16841
|
-
hasRequiredToPrimitive = 1;
|
|
16842
|
-
(function (module) {
|
|
16843
|
-
var _typeof = require_typeof()["default"];
|
|
16844
|
-
function _toPrimitive(input, hint) {
|
|
16845
|
-
if (_typeof(input) !== "object" || input === null) return input;
|
|
16846
|
-
var prim = input[Symbol.toPrimitive];
|
|
16847
|
-
if (prim !== undefined) {
|
|
16848
|
-
var res = prim.call(input, hint || "default");
|
|
16849
|
-
if (_typeof(res) !== "object") return res;
|
|
16850
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
16851
|
-
}
|
|
16852
|
-
return (hint === "string" ? String : Number)(input);
|
|
16853
|
-
}
|
|
16854
|
-
module.exports = _toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16855
|
-
} (toPrimitive));
|
|
16856
|
-
return toPrimitive.exports;
|
|
16857
|
-
}
|
|
16858
|
-
|
|
16859
|
-
var hasRequiredToPropertyKey;
|
|
16860
|
-
|
|
16861
|
-
function requireToPropertyKey () {
|
|
16862
|
-
if (hasRequiredToPropertyKey) return toPropertyKey.exports;
|
|
16863
|
-
hasRequiredToPropertyKey = 1;
|
|
16864
|
-
(function (module) {
|
|
16865
|
-
var _typeof = require_typeof()["default"];
|
|
16866
|
-
var toPrimitive = requireToPrimitive();
|
|
16867
|
-
function _toPropertyKey(arg) {
|
|
16868
|
-
var key = toPrimitive(arg, "string");
|
|
16869
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
16870
|
-
}
|
|
16871
|
-
module.exports = _toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16872
|
-
} (toPropertyKey));
|
|
16873
|
-
return toPropertyKey.exports;
|
|
16874
|
-
}
|
|
16875
|
-
|
|
16876
|
-
var hasRequiredCreateClass;
|
|
16877
|
-
|
|
16878
|
-
function requireCreateClass () {
|
|
16879
|
-
if (hasRequiredCreateClass) return createClass.exports;
|
|
16880
|
-
hasRequiredCreateClass = 1;
|
|
16881
|
-
(function (module) {
|
|
16882
|
-
var toPropertyKey = requireToPropertyKey();
|
|
16883
|
-
function _defineProperties(target, props) {
|
|
16884
|
-
for (var i = 0; i < props.length; i++) {
|
|
16885
|
-
var descriptor = props[i];
|
|
16886
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
16887
|
-
descriptor.configurable = true;
|
|
16888
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
16889
|
-
Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor);
|
|
16890
|
-
}
|
|
16891
|
-
}
|
|
16892
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
16893
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
16894
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
16895
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
16896
|
-
writable: false
|
|
16897
|
-
});
|
|
16898
|
-
return Constructor;
|
|
16899
|
-
}
|
|
16900
|
-
module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16901
|
-
} (createClass));
|
|
16902
|
-
return createClass.exports;
|
|
16903
|
-
}
|
|
16313
|
+
if (this._eventsCount === 0) return names;
|
|
16904
16314
|
|
|
16905
|
-
|
|
16315
|
+
for (name in (events = this._events)) {
|
|
16316
|
+
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
16317
|
+
}
|
|
16906
16318
|
|
|
16907
|
-
|
|
16319
|
+
if (Object.getOwnPropertySymbols) {
|
|
16320
|
+
return names.concat(Object.getOwnPropertySymbols(events));
|
|
16321
|
+
}
|
|
16908
16322
|
|
|
16909
|
-
|
|
16323
|
+
return names;
|
|
16324
|
+
};
|
|
16910
16325
|
|
|
16911
|
-
|
|
16912
|
-
|
|
16913
|
-
|
|
16914
|
-
|
|
16915
|
-
|
|
16916
|
-
|
|
16917
|
-
|
|
16918
|
-
|
|
16919
|
-
|
|
16920
|
-
|
|
16921
|
-
}
|
|
16922
|
-
module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16923
|
-
} (setPrototypeOf));
|
|
16924
|
-
return setPrototypeOf.exports;
|
|
16925
|
-
}
|
|
16926
|
-
|
|
16927
|
-
var hasRequiredInherits;
|
|
16928
|
-
|
|
16929
|
-
function requireInherits () {
|
|
16930
|
-
if (hasRequiredInherits) return inherits.exports;
|
|
16931
|
-
hasRequiredInherits = 1;
|
|
16932
|
-
(function (module) {
|
|
16933
|
-
var setPrototypeOf = requireSetPrototypeOf();
|
|
16934
|
-
function _inherits(subClass, superClass) {
|
|
16935
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
16936
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
16937
|
-
}
|
|
16938
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
16939
|
-
constructor: {
|
|
16940
|
-
value: subClass,
|
|
16941
|
-
writable: true,
|
|
16942
|
-
configurable: true
|
|
16943
|
-
}
|
|
16944
|
-
});
|
|
16945
|
-
Object.defineProperty(subClass, "prototype", {
|
|
16946
|
-
writable: false
|
|
16947
|
-
});
|
|
16948
|
-
if (superClass) setPrototypeOf(subClass, superClass);
|
|
16949
|
-
}
|
|
16950
|
-
module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16951
|
-
} (inherits));
|
|
16952
|
-
return inherits.exports;
|
|
16953
|
-
}
|
|
16326
|
+
/**
|
|
16327
|
+
* Return the listeners registered for a given event.
|
|
16328
|
+
*
|
|
16329
|
+
* @param {(String|Symbol)} event The event name.
|
|
16330
|
+
* @returns {Array} The registered listeners.
|
|
16331
|
+
* @public
|
|
16332
|
+
*/
|
|
16333
|
+
EventEmitter.prototype.listeners = function listeners(event) {
|
|
16334
|
+
var evt = prefix ? prefix + event : event
|
|
16335
|
+
, handlers = this._events[evt];
|
|
16954
16336
|
|
|
16955
|
-
|
|
16337
|
+
if (!handlers) return [];
|
|
16338
|
+
if (handlers.fn) return [handlers.fn];
|
|
16956
16339
|
|
|
16957
|
-
|
|
16340
|
+
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
16341
|
+
ee[i] = handlers[i].fn;
|
|
16342
|
+
}
|
|
16958
16343
|
|
|
16959
|
-
|
|
16344
|
+
return ee;
|
|
16345
|
+
};
|
|
16960
16346
|
|
|
16961
|
-
|
|
16962
|
-
|
|
16963
|
-
|
|
16964
|
-
|
|
16965
|
-
|
|
16966
|
-
|
|
16967
|
-
|
|
16968
|
-
|
|
16969
|
-
|
|
16970
|
-
|
|
16971
|
-
module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16972
|
-
} (assertThisInitialized));
|
|
16973
|
-
return assertThisInitialized.exports;
|
|
16974
|
-
}
|
|
16975
|
-
|
|
16976
|
-
var hasRequiredPossibleConstructorReturn;
|
|
16977
|
-
|
|
16978
|
-
function requirePossibleConstructorReturn () {
|
|
16979
|
-
if (hasRequiredPossibleConstructorReturn) return possibleConstructorReturn.exports;
|
|
16980
|
-
hasRequiredPossibleConstructorReturn = 1;
|
|
16981
|
-
(function (module) {
|
|
16982
|
-
var _typeof = require_typeof()["default"];
|
|
16983
|
-
var assertThisInitialized = requireAssertThisInitialized();
|
|
16984
|
-
function _possibleConstructorReturn(self, call) {
|
|
16985
|
-
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
16986
|
-
return call;
|
|
16987
|
-
} else if (call !== void 0) {
|
|
16988
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
16989
|
-
}
|
|
16990
|
-
return assertThisInitialized(self);
|
|
16991
|
-
}
|
|
16992
|
-
module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16993
|
-
} (possibleConstructorReturn));
|
|
16994
|
-
return possibleConstructorReturn.exports;
|
|
16995
|
-
}
|
|
16347
|
+
/**
|
|
16348
|
+
* Return the number of listeners listening to a given event.
|
|
16349
|
+
*
|
|
16350
|
+
* @param {(String|Symbol)} event The event name.
|
|
16351
|
+
* @returns {Number} The number of listeners.
|
|
16352
|
+
* @public
|
|
16353
|
+
*/
|
|
16354
|
+
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
16355
|
+
var evt = prefix ? prefix + event : event
|
|
16356
|
+
, listeners = this._events[evt];
|
|
16996
16357
|
|
|
16997
|
-
|
|
16358
|
+
if (!listeners) return 0;
|
|
16359
|
+
if (listeners.fn) return 1;
|
|
16360
|
+
return listeners.length;
|
|
16361
|
+
};
|
|
16998
16362
|
|
|
16999
|
-
|
|
16363
|
+
/**
|
|
16364
|
+
* Calls each of the listeners registered for a given event.
|
|
16365
|
+
*
|
|
16366
|
+
* @param {(String|Symbol)} event The event name.
|
|
16367
|
+
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
16368
|
+
* @public
|
|
16369
|
+
*/
|
|
16370
|
+
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
16371
|
+
var evt = prefix ? prefix + event : event;
|
|
16372
|
+
|
|
16373
|
+
if (!this._events[evt]) return false;
|
|
16374
|
+
|
|
16375
|
+
var listeners = this._events[evt]
|
|
16376
|
+
, len = arguments.length
|
|
16377
|
+
, args
|
|
16378
|
+
, i;
|
|
16379
|
+
|
|
16380
|
+
if (listeners.fn) {
|
|
16381
|
+
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
16382
|
+
|
|
16383
|
+
switch (len) {
|
|
16384
|
+
case 1: return listeners.fn.call(listeners.context), true;
|
|
16385
|
+
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
16386
|
+
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
16387
|
+
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
16388
|
+
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
16389
|
+
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
16390
|
+
}
|
|
17000
16391
|
|
|
17001
|
-
|
|
17002
|
-
|
|
17003
|
-
|
|
17004
|
-
(function (module) {
|
|
17005
|
-
function _getPrototypeOf(o) {
|
|
17006
|
-
module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
17007
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
17008
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
17009
|
-
return _getPrototypeOf(o);
|
|
17010
|
-
}
|
|
17011
|
-
module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
17012
|
-
} (getPrototypeOf));
|
|
17013
|
-
return getPrototypeOf.exports;
|
|
17014
|
-
}
|
|
16392
|
+
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
16393
|
+
args[i - 1] = arguments[i];
|
|
16394
|
+
}
|
|
17015
16395
|
|
|
17016
|
-
|
|
16396
|
+
listeners.fn.apply(listeners.context, args);
|
|
16397
|
+
} else {
|
|
16398
|
+
var length = listeners.length
|
|
16399
|
+
, j;
|
|
16400
|
+
|
|
16401
|
+
for (i = 0; i < length; i++) {
|
|
16402
|
+
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
16403
|
+
|
|
16404
|
+
switch (len) {
|
|
16405
|
+
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
16406
|
+
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
16407
|
+
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
16408
|
+
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
16409
|
+
default:
|
|
16410
|
+
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
16411
|
+
args[j - 1] = arguments[j];
|
|
16412
|
+
}
|
|
17017
16413
|
|
|
17018
|
-
|
|
17019
|
-
|
|
17020
|
-
|
|
17021
|
-
|
|
17022
|
-
hasRequiredEventemitter3 = 1;
|
|
17023
|
-
(function (module) {
|
|
17024
|
-
|
|
17025
|
-
var has = Object.prototype.hasOwnProperty
|
|
17026
|
-
, prefix = '~';
|
|
17027
|
-
|
|
17028
|
-
/**
|
|
17029
|
-
* Constructor to create a storage for our `EE` objects.
|
|
17030
|
-
* An `Events` instance is a plain object whose properties are event names.
|
|
17031
|
-
*
|
|
17032
|
-
* @constructor
|
|
17033
|
-
* @private
|
|
17034
|
-
*/
|
|
17035
|
-
function Events() {}
|
|
17036
|
-
|
|
17037
|
-
//
|
|
17038
|
-
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
17039
|
-
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
17040
|
-
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
17041
|
-
// character to make sure that the built-in object properties are not
|
|
17042
|
-
// overridden or used as an attack vector.
|
|
17043
|
-
//
|
|
17044
|
-
if (Object.create) {
|
|
17045
|
-
Events.prototype = Object.create(null);
|
|
17046
|
-
|
|
17047
|
-
//
|
|
17048
|
-
// This hack is needed because the `__proto__` property is still inherited in
|
|
17049
|
-
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
17050
|
-
//
|
|
17051
|
-
if (!new Events().__proto__) prefix = false;
|
|
17052
|
-
}
|
|
16414
|
+
listeners[i].fn.apply(listeners[i].context, args);
|
|
16415
|
+
}
|
|
16416
|
+
}
|
|
16417
|
+
}
|
|
17053
16418
|
|
|
17054
|
-
|
|
17055
|
-
|
|
17056
|
-
*
|
|
17057
|
-
* @param {Function} fn The listener function.
|
|
17058
|
-
* @param {*} context The context to invoke the listener with.
|
|
17059
|
-
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
17060
|
-
* @constructor
|
|
17061
|
-
* @private
|
|
17062
|
-
*/
|
|
17063
|
-
function EE(fn, context, once) {
|
|
17064
|
-
this.fn = fn;
|
|
17065
|
-
this.context = context;
|
|
17066
|
-
this.once = once || false;
|
|
17067
|
-
}
|
|
16419
|
+
return true;
|
|
16420
|
+
};
|
|
17068
16421
|
|
|
17069
|
-
|
|
17070
|
-
|
|
17071
|
-
|
|
17072
|
-
|
|
17073
|
-
|
|
17074
|
-
|
|
17075
|
-
|
|
17076
|
-
|
|
17077
|
-
|
|
17078
|
-
|
|
17079
|
-
|
|
17080
|
-
|
|
17081
|
-
if (typeof fn !== 'function') {
|
|
17082
|
-
throw new TypeError('The listener must be a function');
|
|
17083
|
-
}
|
|
17084
|
-
|
|
17085
|
-
var listener = new EE(fn, context || emitter, once)
|
|
17086
|
-
, evt = prefix ? prefix + event : event;
|
|
17087
|
-
|
|
17088
|
-
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
17089
|
-
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
17090
|
-
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
17091
|
-
|
|
17092
|
-
return emitter;
|
|
17093
|
-
}
|
|
16422
|
+
/**
|
|
16423
|
+
* Add a listener for a given event.
|
|
16424
|
+
*
|
|
16425
|
+
* @param {(String|Symbol)} event The event name.
|
|
16426
|
+
* @param {Function} fn The listener function.
|
|
16427
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
16428
|
+
* @returns {EventEmitter} `this`.
|
|
16429
|
+
* @public
|
|
16430
|
+
*/
|
|
16431
|
+
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
16432
|
+
return addListener(this, event, fn, context, false);
|
|
16433
|
+
};
|
|
17094
16434
|
|
|
17095
|
-
|
|
17096
|
-
|
|
17097
|
-
|
|
17098
|
-
|
|
17099
|
-
|
|
17100
|
-
|
|
17101
|
-
|
|
17102
|
-
|
|
17103
|
-
|
|
17104
|
-
|
|
17105
|
-
|
|
16435
|
+
/**
|
|
16436
|
+
* Add a one-time listener for a given event.
|
|
16437
|
+
*
|
|
16438
|
+
* @param {(String|Symbol)} event The event name.
|
|
16439
|
+
* @param {Function} fn The listener function.
|
|
16440
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
16441
|
+
* @returns {EventEmitter} `this`.
|
|
16442
|
+
* @public
|
|
16443
|
+
*/
|
|
16444
|
+
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
16445
|
+
return addListener(this, event, fn, context, true);
|
|
16446
|
+
};
|
|
17106
16447
|
|
|
17107
|
-
|
|
17108
|
-
|
|
17109
|
-
|
|
17110
|
-
|
|
17111
|
-
|
|
17112
|
-
|
|
17113
|
-
|
|
17114
|
-
|
|
17115
|
-
|
|
17116
|
-
|
|
17117
|
-
|
|
16448
|
+
/**
|
|
16449
|
+
* Remove the listeners of a given event.
|
|
16450
|
+
*
|
|
16451
|
+
* @param {(String|Symbol)} event The event name.
|
|
16452
|
+
* @param {Function} fn Only remove the listeners that match this function.
|
|
16453
|
+
* @param {*} context Only remove the listeners that have this context.
|
|
16454
|
+
* @param {Boolean} once Only remove one-time listeners.
|
|
16455
|
+
* @returns {EventEmitter} `this`.
|
|
16456
|
+
* @public
|
|
16457
|
+
*/
|
|
16458
|
+
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
16459
|
+
var evt = prefix ? prefix + event : event;
|
|
17118
16460
|
|
|
17119
|
-
|
|
17120
|
-
|
|
17121
|
-
|
|
17122
|
-
|
|
17123
|
-
|
|
17124
|
-
* @public
|
|
17125
|
-
*/
|
|
17126
|
-
EventEmitter.prototype.eventNames = function eventNames() {
|
|
17127
|
-
var names = []
|
|
17128
|
-
, events
|
|
17129
|
-
, name;
|
|
17130
|
-
|
|
17131
|
-
if (this._eventsCount === 0) return names;
|
|
17132
|
-
|
|
17133
|
-
for (name in (events = this._events)) {
|
|
17134
|
-
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
17135
|
-
}
|
|
17136
|
-
|
|
17137
|
-
if (Object.getOwnPropertySymbols) {
|
|
17138
|
-
return names.concat(Object.getOwnPropertySymbols(events));
|
|
17139
|
-
}
|
|
17140
|
-
|
|
17141
|
-
return names;
|
|
17142
|
-
};
|
|
16461
|
+
if (!this._events[evt]) return this;
|
|
16462
|
+
if (!fn) {
|
|
16463
|
+
clearEvent(this, evt);
|
|
16464
|
+
return this;
|
|
16465
|
+
}
|
|
17143
16466
|
|
|
17144
|
-
|
|
17145
|
-
* Return the listeners registered for a given event.
|
|
17146
|
-
*
|
|
17147
|
-
* @param {(String|Symbol)} event The event name.
|
|
17148
|
-
* @returns {Array} The registered listeners.
|
|
17149
|
-
* @public
|
|
17150
|
-
*/
|
|
17151
|
-
EventEmitter.prototype.listeners = function listeners(event) {
|
|
17152
|
-
var evt = prefix ? prefix + event : event
|
|
17153
|
-
, handlers = this._events[evt];
|
|
17154
|
-
|
|
17155
|
-
if (!handlers) return [];
|
|
17156
|
-
if (handlers.fn) return [handlers.fn];
|
|
17157
|
-
|
|
17158
|
-
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
17159
|
-
ee[i] = handlers[i].fn;
|
|
17160
|
-
}
|
|
17161
|
-
|
|
17162
|
-
return ee;
|
|
17163
|
-
};
|
|
16467
|
+
var listeners = this._events[evt];
|
|
17164
16468
|
|
|
17165
|
-
|
|
17166
|
-
|
|
17167
|
-
|
|
17168
|
-
|
|
17169
|
-
|
|
17170
|
-
|
|
17171
|
-
|
|
17172
|
-
|
|
17173
|
-
|
|
17174
|
-
|
|
17175
|
-
|
|
17176
|
-
|
|
17177
|
-
|
|
17178
|
-
|
|
17179
|
-
|
|
16469
|
+
if (listeners.fn) {
|
|
16470
|
+
if (
|
|
16471
|
+
listeners.fn === fn &&
|
|
16472
|
+
(!once || listeners.once) &&
|
|
16473
|
+
(!context || listeners.context === context)
|
|
16474
|
+
) {
|
|
16475
|
+
clearEvent(this, evt);
|
|
16476
|
+
}
|
|
16477
|
+
} else {
|
|
16478
|
+
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
16479
|
+
if (
|
|
16480
|
+
listeners[i].fn !== fn ||
|
|
16481
|
+
(once && !listeners[i].once) ||
|
|
16482
|
+
(context && listeners[i].context !== context)
|
|
16483
|
+
) {
|
|
16484
|
+
events.push(listeners[i]);
|
|
16485
|
+
}
|
|
16486
|
+
}
|
|
17180
16487
|
|
|
17181
|
-
|
|
17182
|
-
|
|
17183
|
-
|
|
17184
|
-
|
|
17185
|
-
|
|
17186
|
-
|
|
17187
|
-
*/
|
|
17188
|
-
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
17189
|
-
var evt = prefix ? prefix + event : event;
|
|
17190
|
-
|
|
17191
|
-
if (!this._events[evt]) return false;
|
|
17192
|
-
|
|
17193
|
-
var listeners = this._events[evt]
|
|
17194
|
-
, len = arguments.length
|
|
17195
|
-
, args
|
|
17196
|
-
, i;
|
|
17197
|
-
|
|
17198
|
-
if (listeners.fn) {
|
|
17199
|
-
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
17200
|
-
|
|
17201
|
-
switch (len) {
|
|
17202
|
-
case 1: return listeners.fn.call(listeners.context), true;
|
|
17203
|
-
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
17204
|
-
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
17205
|
-
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
17206
|
-
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
17207
|
-
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
17208
|
-
}
|
|
17209
|
-
|
|
17210
|
-
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
17211
|
-
args[i - 1] = arguments[i];
|
|
17212
|
-
}
|
|
17213
|
-
|
|
17214
|
-
listeners.fn.apply(listeners.context, args);
|
|
17215
|
-
} else {
|
|
17216
|
-
var length = listeners.length
|
|
17217
|
-
, j;
|
|
17218
|
-
|
|
17219
|
-
for (i = 0; i < length; i++) {
|
|
17220
|
-
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
17221
|
-
|
|
17222
|
-
switch (len) {
|
|
17223
|
-
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
17224
|
-
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
17225
|
-
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
17226
|
-
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
17227
|
-
default:
|
|
17228
|
-
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
17229
|
-
args[j - 1] = arguments[j];
|
|
17230
|
-
}
|
|
17231
|
-
|
|
17232
|
-
listeners[i].fn.apply(listeners[i].context, args);
|
|
17233
|
-
}
|
|
17234
|
-
}
|
|
17235
|
-
}
|
|
17236
|
-
|
|
17237
|
-
return true;
|
|
17238
|
-
};
|
|
16488
|
+
//
|
|
16489
|
+
// Reset the array, or remove it completely if we have no more listeners.
|
|
16490
|
+
//
|
|
16491
|
+
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
16492
|
+
else clearEvent(this, evt);
|
|
16493
|
+
}
|
|
17239
16494
|
|
|
17240
|
-
|
|
17241
|
-
|
|
17242
|
-
*
|
|
17243
|
-
* @param {(String|Symbol)} event The event name.
|
|
17244
|
-
* @param {Function} fn The listener function.
|
|
17245
|
-
* @param {*} [context=this] The context to invoke the listener with.
|
|
17246
|
-
* @returns {EventEmitter} `this`.
|
|
17247
|
-
* @public
|
|
17248
|
-
*/
|
|
17249
|
-
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
17250
|
-
return addListener(this, event, fn, context, false);
|
|
17251
|
-
};
|
|
16495
|
+
return this;
|
|
16496
|
+
};
|
|
17252
16497
|
|
|
17253
|
-
|
|
17254
|
-
|
|
17255
|
-
|
|
17256
|
-
|
|
17257
|
-
|
|
17258
|
-
|
|
17259
|
-
|
|
17260
|
-
|
|
17261
|
-
|
|
17262
|
-
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
17263
|
-
return addListener(this, event, fn, context, true);
|
|
17264
|
-
};
|
|
16498
|
+
/**
|
|
16499
|
+
* Remove all listeners, or those of the specified event.
|
|
16500
|
+
*
|
|
16501
|
+
* @param {(String|Symbol)} [event] The event name.
|
|
16502
|
+
* @returns {EventEmitter} `this`.
|
|
16503
|
+
* @public
|
|
16504
|
+
*/
|
|
16505
|
+
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
16506
|
+
var evt;
|
|
17265
16507
|
|
|
17266
|
-
|
|
17267
|
-
|
|
17268
|
-
|
|
17269
|
-
|
|
17270
|
-
|
|
17271
|
-
|
|
17272
|
-
|
|
17273
|
-
* @returns {EventEmitter} `this`.
|
|
17274
|
-
* @public
|
|
17275
|
-
*/
|
|
17276
|
-
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
17277
|
-
var evt = prefix ? prefix + event : event;
|
|
17278
|
-
|
|
17279
|
-
if (!this._events[evt]) return this;
|
|
17280
|
-
if (!fn) {
|
|
17281
|
-
clearEvent(this, evt);
|
|
17282
|
-
return this;
|
|
17283
|
-
}
|
|
17284
|
-
|
|
17285
|
-
var listeners = this._events[evt];
|
|
17286
|
-
|
|
17287
|
-
if (listeners.fn) {
|
|
17288
|
-
if (
|
|
17289
|
-
listeners.fn === fn &&
|
|
17290
|
-
(!once || listeners.once) &&
|
|
17291
|
-
(!context || listeners.context === context)
|
|
17292
|
-
) {
|
|
17293
|
-
clearEvent(this, evt);
|
|
17294
|
-
}
|
|
17295
|
-
} else {
|
|
17296
|
-
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
17297
|
-
if (
|
|
17298
|
-
listeners[i].fn !== fn ||
|
|
17299
|
-
(once && !listeners[i].once) ||
|
|
17300
|
-
(context && listeners[i].context !== context)
|
|
17301
|
-
) {
|
|
17302
|
-
events.push(listeners[i]);
|
|
17303
|
-
}
|
|
17304
|
-
}
|
|
17305
|
-
|
|
17306
|
-
//
|
|
17307
|
-
// Reset the array, or remove it completely if we have no more listeners.
|
|
17308
|
-
//
|
|
17309
|
-
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
17310
|
-
else clearEvent(this, evt);
|
|
17311
|
-
}
|
|
17312
|
-
|
|
17313
|
-
return this;
|
|
17314
|
-
};
|
|
16508
|
+
if (event) {
|
|
16509
|
+
evt = prefix ? prefix + event : event;
|
|
16510
|
+
if (this._events[evt]) clearEvent(this, evt);
|
|
16511
|
+
} else {
|
|
16512
|
+
this._events = new Events();
|
|
16513
|
+
this._eventsCount = 0;
|
|
16514
|
+
}
|
|
17315
16515
|
|
|
17316
|
-
|
|
17317
|
-
|
|
17318
|
-
*
|
|
17319
|
-
* @param {(String|Symbol)} [event] The event name.
|
|
17320
|
-
* @returns {EventEmitter} `this`.
|
|
17321
|
-
* @public
|
|
17322
|
-
*/
|
|
17323
|
-
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
17324
|
-
var evt;
|
|
17325
|
-
|
|
17326
|
-
if (event) {
|
|
17327
|
-
evt = prefix ? prefix + event : event;
|
|
17328
|
-
if (this._events[evt]) clearEvent(this, evt);
|
|
17329
|
-
} else {
|
|
17330
|
-
this._events = new Events();
|
|
17331
|
-
this._eventsCount = 0;
|
|
17332
|
-
}
|
|
17333
|
-
|
|
17334
|
-
return this;
|
|
17335
|
-
};
|
|
16516
|
+
return this;
|
|
16517
|
+
};
|
|
17336
16518
|
|
|
17337
|
-
|
|
17338
|
-
|
|
17339
|
-
|
|
17340
|
-
|
|
17341
|
-
|
|
16519
|
+
//
|
|
16520
|
+
// Alias methods names because people roll like that.
|
|
16521
|
+
//
|
|
16522
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
16523
|
+
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
17342
16524
|
|
|
17343
|
-
|
|
17344
|
-
|
|
17345
|
-
|
|
17346
|
-
|
|
16525
|
+
//
|
|
16526
|
+
// Expose the prefix.
|
|
16527
|
+
//
|
|
16528
|
+
EventEmitter.prefixed = prefix;
|
|
17347
16529
|
|
|
17348
|
-
|
|
17349
|
-
|
|
17350
|
-
|
|
17351
|
-
|
|
16530
|
+
//
|
|
16531
|
+
// Allow `EventEmitter` to be imported as module namespace.
|
|
16532
|
+
//
|
|
16533
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
17352
16534
|
|
|
17353
|
-
|
|
17354
|
-
|
|
17355
|
-
|
|
17356
|
-
|
|
17357
|
-
|
|
17358
|
-
|
|
17359
|
-
|
|
17360
|
-
|
|
16535
|
+
//
|
|
16536
|
+
// Expose the module.
|
|
16537
|
+
//
|
|
16538
|
+
{
|
|
16539
|
+
module.exports = EventEmitter;
|
|
16540
|
+
}
|
|
16541
|
+
} (eventemitter3));
|
|
16542
|
+
|
|
16543
|
+
var eventemitter3Exports = eventemitter3.exports;
|
|
16544
|
+
|
|
16545
|
+
var utils = {};
|
|
16546
|
+
|
|
16547
|
+
Object.defineProperty(utils, "__esModule", { value: true });
|
|
16548
|
+
utils.createError = utils.DefaultDataPack = void 0;
|
|
16549
|
+
const errors = new Map([
|
|
16550
|
+
[-32000, "Event not provided"],
|
|
16551
|
+
[-32600, "Invalid Request"],
|
|
16552
|
+
[-32601, "Method not found"],
|
|
16553
|
+
[-32602, "Invalid params"],
|
|
16554
|
+
[-32603, "Internal error"],
|
|
16555
|
+
[-32604, "Params not found"],
|
|
16556
|
+
[-32605, "Method forbidden"],
|
|
16557
|
+
[-32606, "Event forbidden"],
|
|
16558
|
+
[-32700, "Parse error"]
|
|
16559
|
+
]);
|
|
16560
|
+
class DefaultDataPack {
|
|
16561
|
+
encode(value) {
|
|
16562
|
+
return JSON.stringify(value);
|
|
16563
|
+
}
|
|
16564
|
+
decode(value) {
|
|
16565
|
+
return JSON.parse(value);
|
|
16566
|
+
}
|
|
16567
|
+
}
|
|
16568
|
+
utils.DefaultDataPack = DefaultDataPack;
|
|
16569
|
+
/**
|
|
16570
|
+
* Creates a JSON-RPC 2.0-compliant error.
|
|
16571
|
+
* @param {Number} code - error code
|
|
16572
|
+
* @param {String} details - error details
|
|
16573
|
+
* @return {Object}
|
|
16574
|
+
*/
|
|
16575
|
+
function createError(code, details) {
|
|
16576
|
+
const error = {
|
|
16577
|
+
code: code,
|
|
16578
|
+
message: errors.get(code) || "Internal Server Error"
|
|
16579
|
+
};
|
|
16580
|
+
if (details)
|
|
16581
|
+
error["data"] = details;
|
|
16582
|
+
return error;
|
|
17361
16583
|
}
|
|
16584
|
+
utils.createError = createError;
|
|
17362
16585
|
|
|
17363
16586
|
/**
|
|
17364
16587
|
* "Client" wraps "ws" or a browser-implemented "WebSocket" library
|
|
17365
16588
|
* according to the environment providing JSON RPC 2.0 support on top.
|
|
17366
16589
|
* @module Client
|
|
17367
16590
|
*/
|
|
17368
|
-
|
|
17369
|
-
|
|
17370
|
-
|
|
17371
|
-
|
|
17372
|
-
|
|
17373
|
-
|
|
17374
|
-
|
|
17375
|
-
|
|
17376
|
-
|
|
17377
|
-
|
|
17378
|
-
|
|
17379
|
-
|
|
17380
|
-
|
|
17381
|
-
|
|
17382
|
-
|
|
17383
|
-
|
|
17384
|
-
|
|
17385
|
-
|
|
17386
|
-
|
|
17387
|
-
|
|
17388
|
-
|
|
17389
|
-
|
|
17390
|
-
|
|
17391
|
-
|
|
17392
|
-
|
|
17393
|
-
|
|
17394
|
-
|
|
17395
|
-
|
|
17396
|
-
|
|
17397
|
-
|
|
17398
|
-
|
|
17399
|
-
|
|
17400
|
-
|
|
17401
|
-
|
|
17402
|
-
|
|
17403
|
-
|
|
17404
|
-
|
|
17405
|
-
|
|
17406
|
-
|
|
17407
|
-
|
|
17408
|
-
|
|
17409
|
-
|
|
17410
|
-
|
|
17411
|
-
|
|
17412
|
-
|
|
17413
|
-
|
|
17414
|
-
|
|
17415
|
-
|
|
17416
|
-
|
|
17417
|
-
|
|
17418
|
-
|
|
17419
|
-
|
|
17420
|
-
|
|
17421
|
-
|
|
17422
|
-
|
|
17423
|
-
|
|
17424
|
-
|
|
17425
|
-
|
|
17426
|
-
|
|
17427
|
-
|
|
17428
|
-
|
|
17429
|
-
|
|
17430
|
-
|
|
17431
|
-
|
|
17432
|
-
|
|
17433
|
-
|
|
17434
|
-
|
|
17435
|
-
|
|
17436
|
-
|
|
17437
|
-
|
|
17438
|
-
|
|
17439
|
-
|
|
17440
|
-
|
|
17441
|
-
|
|
17442
|
-
|
|
17443
|
-
|
|
17444
|
-
|
|
17445
|
-
|
|
17446
|
-
|
|
17447
|
-
|
|
17448
|
-
|
|
17449
|
-
|
|
17450
|
-
|
|
17451
|
-
|
|
17452
|
-
|
|
17453
|
-
|
|
17454
|
-
|
|
17455
|
-
|
|
17456
|
-
|
|
17457
|
-
|
|
17458
|
-
|
|
17459
|
-
|
|
17460
|
-
|
|
17461
|
-
|
|
17462
|
-
|
|
17463
|
-
|
|
17464
|
-
|
|
17465
|
-
|
|
17466
|
-
|
|
17467
|
-
|
|
17468
|
-
|
|
17469
|
-
|
|
17470
|
-
|
|
17471
|
-
|
|
17472
|
-
|
|
17473
|
-
|
|
17474
|
-
|
|
17475
|
-
|
|
17476
|
-
|
|
17477
|
-
|
|
17478
|
-
|
|
17479
|
-
|
|
17480
|
-
|
|
17481
|
-
|
|
17482
|
-
|
|
17483
|
-
|
|
17484
|
-
|
|
17485
|
-
|
|
17486
|
-
|
|
17487
|
-
|
|
17488
|
-
|
|
17489
|
-
|
|
17490
|
-
|
|
17491
|
-
|
|
17492
|
-
|
|
17493
|
-
|
|
17494
|
-
|
|
17495
|
-
|
|
17496
|
-
|
|
17497
|
-
|
|
17498
|
-
|
|
17499
|
-
|
|
17500
|
-
|
|
17501
|
-
|
|
17502
|
-
|
|
17503
|
-
|
|
17504
|
-
|
|
17505
|
-
|
|
17506
|
-
|
|
17507
|
-
|
|
17508
|
-
|
|
17509
|
-
|
|
17510
|
-
|
|
17511
|
-
|
|
17512
|
-
|
|
17513
|
-
|
|
17514
|
-
|
|
17515
|
-
|
|
17516
|
-
|
|
17517
|
-
|
|
17518
|
-
|
|
17519
|
-
|
|
17520
|
-
|
|
17521
|
-
|
|
17522
|
-
|
|
17523
|
-
|
|
17524
|
-
|
|
17525
|
-
|
|
17526
|
-
|
|
17527
|
-
|
|
17528
|
-
|
|
17529
|
-
|
|
17530
|
-
|
|
17531
|
-
|
|
17532
|
-
|
|
17533
|
-
|
|
17534
|
-
|
|
17535
|
-
|
|
17536
|
-
|
|
17537
|
-
|
|
17538
|
-
|
|
17539
|
-
|
|
17540
|
-
|
|
17541
|
-
|
|
17542
|
-
|
|
17543
|
-
|
|
17544
|
-
|
|
17545
|
-
|
|
17546
|
-
|
|
17547
|
-
|
|
17548
|
-
|
|
17549
|
-
|
|
17550
|
-
|
|
17551
|
-
|
|
17552
|
-
|
|
17553
|
-
|
|
17554
|
-
|
|
17555
|
-
|
|
17556
|
-
|
|
17557
|
-
|
|
17558
|
-
|
|
17559
|
-
|
|
17560
|
-
|
|
17561
|
-
|
|
17562
|
-
|
|
17563
|
-
|
|
17564
|
-
|
|
17565
|
-
|
|
17566
|
-
|
|
17567
|
-
|
|
17568
|
-
|
|
17569
|
-
|
|
17570
|
-
|
|
17571
|
-
|
|
17572
|
-
|
|
17573
|
-
|
|
17574
|
-
|
|
17575
|
-
|
|
17576
|
-
|
|
17577
|
-
|
|
17578
|
-
|
|
17579
|
-
|
|
17580
|
-
|
|
17581
|
-
|
|
17582
|
-
|
|
17583
|
-
|
|
17584
|
-
|
|
17585
|
-
|
|
17586
|
-
|
|
17587
|
-
|
|
17588
|
-
|
|
17589
|
-
|
|
17590
|
-
|
|
17591
|
-
|
|
17592
|
-
|
|
17593
|
-
|
|
17594
|
-
|
|
17595
|
-
|
|
17596
|
-
|
|
17597
|
-
|
|
17598
|
-
|
|
17599
|
-
|
|
17600
|
-
|
|
17601
|
-
|
|
17602
|
-
|
|
17603
|
-
|
|
17604
|
-
|
|
17605
|
-
|
|
17606
|
-
|
|
17607
|
-
|
|
17608
|
-
|
|
17609
|
-
|
|
17610
|
-
|
|
17611
|
-
|
|
17612
|
-
|
|
17613
|
-
|
|
17614
|
-
|
|
17615
|
-
|
|
17616
|
-
|
|
17617
|
-
|
|
17618
|
-
|
|
17619
|
-
|
|
17620
|
-
|
|
17621
|
-
|
|
17622
|
-
|
|
17623
|
-
|
|
17624
|
-
|
|
17625
|
-
|
|
17626
|
-
|
|
17627
|
-
|
|
17628
|
-
|
|
17629
|
-
|
|
17630
|
-
|
|
17631
|
-
|
|
17632
|
-
|
|
17633
|
-
|
|
17634
|
-
|
|
17635
|
-
|
|
17636
|
-
|
|
17637
|
-
|
|
17638
|
-
|
|
17639
|
-
|
|
17640
|
-
|
|
17641
|
-
|
|
17642
|
-
|
|
17643
|
-
|
|
17644
|
-
|
|
17645
|
-
|
|
17646
|
-
|
|
17647
|
-
|
|
17648
|
-
|
|
17649
|
-
|
|
17650
|
-
|
|
17651
|
-
|
|
17652
|
-
|
|
17653
|
-
|
|
17654
|
-
|
|
17655
|
-
|
|
17656
|
-
|
|
17657
|
-
|
|
17658
|
-
|
|
17659
|
-
|
|
17660
|
-
|
|
17661
|
-
|
|
17662
|
-
|
|
17663
|
-
|
|
17664
|
-
|
|
17665
|
-
|
|
17666
|
-
|
|
17667
|
-
|
|
17668
|
-
case 3:
|
|
17669
|
-
result = _context3.sent;
|
|
17670
|
-
|
|
17671
|
-
if (!(typeof event === "string" && result[event] !== "ok")) {
|
|
17672
|
-
_context3.next = 6;
|
|
17673
|
-
break;
|
|
17674
|
-
}
|
|
17675
|
-
|
|
17676
|
-
throw new Error("Failed subscribing to an event '" + event + "' with: " + result[event]);
|
|
17677
|
-
|
|
17678
|
-
case 6:
|
|
17679
|
-
return _context3.abrupt("return", result);
|
|
17680
|
-
|
|
17681
|
-
case 7:
|
|
17682
|
-
case "end":
|
|
17683
|
-
return _context3.stop();
|
|
17684
|
-
}
|
|
17685
|
-
}
|
|
17686
|
-
}, _callee3, this);
|
|
17687
|
-
}));
|
|
17688
|
-
|
|
17689
|
-
function subscribe(_x2) {
|
|
17690
|
-
return _subscribe.apply(this, arguments);
|
|
17691
|
-
}
|
|
17692
|
-
|
|
17693
|
-
return subscribe;
|
|
17694
|
-
}()
|
|
17695
|
-
/**
|
|
17696
|
-
* Unsubscribes from a defined event.
|
|
17697
|
-
* @method
|
|
17698
|
-
* @param {String|Array} event - event name
|
|
17699
|
-
* @return {Undefined}
|
|
17700
|
-
* @throws {Error}
|
|
17701
|
-
*/
|
|
17702
|
-
|
|
17703
|
-
}, {
|
|
17704
|
-
key: "unsubscribe",
|
|
17705
|
-
value: function () {
|
|
17706
|
-
var _unsubscribe = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(event) {
|
|
17707
|
-
var result;
|
|
17708
|
-
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
17709
|
-
while (1) {
|
|
17710
|
-
switch (_context4.prev = _context4.next) {
|
|
17711
|
-
case 0:
|
|
17712
|
-
if (typeof event === "string") event = [event];
|
|
17713
|
-
_context4.next = 3;
|
|
17714
|
-
return this.call("rpc.off", event);
|
|
17715
|
-
|
|
17716
|
-
case 3:
|
|
17717
|
-
result = _context4.sent;
|
|
17718
|
-
|
|
17719
|
-
if (!(typeof event === "string" && result[event] !== "ok")) {
|
|
17720
|
-
_context4.next = 6;
|
|
17721
|
-
break;
|
|
17722
|
-
}
|
|
17723
|
-
|
|
17724
|
-
throw new Error("Failed unsubscribing from an event with: " + result);
|
|
17725
|
-
|
|
17726
|
-
case 6:
|
|
17727
|
-
return _context4.abrupt("return", result);
|
|
17728
|
-
|
|
17729
|
-
case 7:
|
|
17730
|
-
case "end":
|
|
17731
|
-
return _context4.stop();
|
|
17732
|
-
}
|
|
17733
|
-
}
|
|
17734
|
-
}, _callee4, this);
|
|
17735
|
-
}));
|
|
17736
|
-
|
|
17737
|
-
function unsubscribe(_x3) {
|
|
17738
|
-
return _unsubscribe.apply(this, arguments);
|
|
17739
|
-
}
|
|
17740
|
-
|
|
17741
|
-
return unsubscribe;
|
|
17742
|
-
}()
|
|
17743
|
-
/**
|
|
17744
|
-
* Closes a WebSocket connection gracefully.
|
|
17745
|
-
* @method
|
|
17746
|
-
* @param {Number} code - socket close code
|
|
17747
|
-
* @param {String} data - optional data to be sent before closing
|
|
17748
|
-
* @return {Undefined}
|
|
17749
|
-
*/
|
|
17750
|
-
|
|
17751
|
-
}, {
|
|
17752
|
-
key: "close",
|
|
17753
|
-
value: function close(code, data) {
|
|
17754
|
-
this.socket.close(code || 1000, data);
|
|
17755
|
-
}
|
|
17756
|
-
/**
|
|
17757
|
-
* Connection/Message handler.
|
|
17758
|
-
* @method
|
|
17759
|
-
* @private
|
|
17760
|
-
* @param {String} address - WebSocket API address
|
|
17761
|
-
* @param {Object} options - ws options object
|
|
17762
|
-
* @return {Undefined}
|
|
17763
|
-
*/
|
|
17764
|
-
|
|
17765
|
-
}, {
|
|
17766
|
-
key: "_connect",
|
|
17767
|
-
value: function _connect(address, options) {
|
|
17768
|
-
var _this4 = this;
|
|
17769
|
-
|
|
17770
|
-
clearTimeout(this.reconnect_timer_id);
|
|
17771
|
-
this.socket = this.webSocketFactory(address, options);
|
|
17772
|
-
this.socket.addEventListener("open", function () {
|
|
17773
|
-
_this4.ready = true;
|
|
17774
|
-
|
|
17775
|
-
_this4.emit("open");
|
|
17776
|
-
|
|
17777
|
-
_this4.current_reconnects = 0;
|
|
17778
|
-
});
|
|
17779
|
-
this.socket.addEventListener("message", function (_ref) {
|
|
17780
|
-
var message = _ref.data;
|
|
17781
|
-
if (message instanceof ArrayBuffer) message = Buffer.from(message).toString();
|
|
17782
|
-
|
|
17783
|
-
try {
|
|
17784
|
-
message = JSON.parse(message);
|
|
17785
|
-
} catch (error) {
|
|
17786
|
-
return;
|
|
17787
|
-
} // check if any listeners are attached and forward event
|
|
17788
|
-
|
|
17789
|
-
|
|
17790
|
-
if (message.notification && _this4.listeners(message.notification).length) {
|
|
17791
|
-
if (!Object.keys(message.params).length) return _this4.emit(message.notification);
|
|
17792
|
-
var args = [message.notification];
|
|
17793
|
-
if (message.params.constructor === Object) args.push(message.params);else // using for-loop instead of unshift/spread because performance is better
|
|
17794
|
-
for (var i = 0; i < message.params.length; i++) {
|
|
17795
|
-
args.push(message.params[i]);
|
|
17796
|
-
} // run as microtask so that pending queue messages are resolved first
|
|
17797
|
-
// eslint-disable-next-line prefer-spread
|
|
17798
|
-
|
|
17799
|
-
return Promise.resolve().then(function () {
|
|
17800
|
-
_this4.emit.apply(_this4, args);
|
|
17801
|
-
});
|
|
17802
|
-
}
|
|
17803
|
-
|
|
17804
|
-
if (!_this4.queue[message.id]) {
|
|
17805
|
-
// general JSON RPC 2.0 events
|
|
17806
|
-
if (message.method && message.params) {
|
|
17807
|
-
// run as microtask so that pending queue messages are resolved first
|
|
17808
|
-
return Promise.resolve().then(function () {
|
|
17809
|
-
_this4.emit(message.method, message.params);
|
|
17810
|
-
});
|
|
17811
|
-
}
|
|
17812
|
-
|
|
17813
|
-
return;
|
|
17814
|
-
} // reject early since server's response is invalid
|
|
17815
|
-
|
|
17816
|
-
|
|
17817
|
-
if ("error" in message === "result" in message) _this4.queue[message.id].promise[1](new Error("Server response malformed. Response must include either \"result\"" + " or \"error\", but not both."));
|
|
17818
|
-
if (_this4.queue[message.id].timeout) clearTimeout(_this4.queue[message.id].timeout);
|
|
17819
|
-
if (message.error) _this4.queue[message.id].promise[1](message.error);else _this4.queue[message.id].promise[0](message.result);
|
|
17820
|
-
delete _this4.queue[message.id];
|
|
17821
|
-
});
|
|
17822
|
-
this.socket.addEventListener("error", function (error) {
|
|
17823
|
-
return _this4.emit("error", error);
|
|
17824
|
-
});
|
|
17825
|
-
this.socket.addEventListener("close", function (_ref2) {
|
|
17826
|
-
var code = _ref2.code,
|
|
17827
|
-
reason = _ref2.reason;
|
|
17828
|
-
if (_this4.ready) // Delay close event until internal state is updated
|
|
17829
|
-
setTimeout(function () {
|
|
17830
|
-
return _this4.emit("close", code, reason);
|
|
17831
|
-
}, 0);
|
|
17832
|
-
_this4.ready = false;
|
|
17833
|
-
_this4.socket = undefined;
|
|
17834
|
-
if (code === 1000) return;
|
|
17835
|
-
_this4.current_reconnects++;
|
|
17836
|
-
if (_this4.reconnect && (_this4.max_reconnects > _this4.current_reconnects || _this4.max_reconnects === 0)) _this4.reconnect_timer_id = setTimeout(function () {
|
|
17837
|
-
return _this4._connect(address, options);
|
|
17838
|
-
}, _this4.reconnect_interval);
|
|
17839
|
-
});
|
|
17840
|
-
}
|
|
17841
|
-
}]);
|
|
17842
|
-
return CommonClient;
|
|
17843
|
-
}(_eventemitter.EventEmitter);
|
|
17844
|
-
|
|
17845
|
-
exports["default"] = CommonClient;
|
|
17846
|
-
} (client));
|
|
17847
|
-
|
|
17848
|
-
var RpcWebSocketCommonClient = /*@__PURE__*/getDefaultExportFromCjs(client);
|
|
16591
|
+
Object.defineProperty(client, "__esModule", { value: true });
|
|
16592
|
+
// @ts-ignore
|
|
16593
|
+
const eventemitter3_1$1 = eventemitter3Exports;
|
|
16594
|
+
const utils_1 = utils;
|
|
16595
|
+
class CommonClient extends eventemitter3_1$1.EventEmitter {
|
|
16596
|
+
address;
|
|
16597
|
+
rpc_id;
|
|
16598
|
+
queue;
|
|
16599
|
+
options;
|
|
16600
|
+
autoconnect;
|
|
16601
|
+
ready;
|
|
16602
|
+
reconnect;
|
|
16603
|
+
reconnect_timer_id;
|
|
16604
|
+
reconnect_interval;
|
|
16605
|
+
max_reconnects;
|
|
16606
|
+
rest_options;
|
|
16607
|
+
current_reconnects;
|
|
16608
|
+
generate_request_id;
|
|
16609
|
+
socket;
|
|
16610
|
+
webSocketFactory;
|
|
16611
|
+
dataPack;
|
|
16612
|
+
/**
|
|
16613
|
+
* Instantiate a Client class.
|
|
16614
|
+
* @constructor
|
|
16615
|
+
* @param {webSocketFactory} webSocketFactory - factory method for WebSocket
|
|
16616
|
+
* @param {String} address - url to a websocket server
|
|
16617
|
+
* @param {Object} options - ws options object with reconnect parameters
|
|
16618
|
+
* @param {Function} generate_request_id - custom generation request Id
|
|
16619
|
+
* @param {DataPack} dataPack - data pack contains encoder and decoder
|
|
16620
|
+
* @return {CommonClient}
|
|
16621
|
+
*/
|
|
16622
|
+
constructor(webSocketFactory, address = "ws://localhost:8080", { autoconnect = true, reconnect = true, reconnect_interval = 1000, max_reconnects = 5, ...rest_options } = {}, generate_request_id, dataPack) {
|
|
16623
|
+
super();
|
|
16624
|
+
this.webSocketFactory = webSocketFactory;
|
|
16625
|
+
this.queue = {};
|
|
16626
|
+
this.rpc_id = 0;
|
|
16627
|
+
this.address = address;
|
|
16628
|
+
this.autoconnect = autoconnect;
|
|
16629
|
+
this.ready = false;
|
|
16630
|
+
this.reconnect = reconnect;
|
|
16631
|
+
this.reconnect_timer_id = undefined;
|
|
16632
|
+
this.reconnect_interval = reconnect_interval;
|
|
16633
|
+
this.max_reconnects = max_reconnects;
|
|
16634
|
+
this.rest_options = rest_options;
|
|
16635
|
+
this.current_reconnects = 0;
|
|
16636
|
+
this.generate_request_id = generate_request_id || (() => ++this.rpc_id);
|
|
16637
|
+
if (!dataPack)
|
|
16638
|
+
this.dataPack = new utils_1.DefaultDataPack();
|
|
16639
|
+
else
|
|
16640
|
+
this.dataPack = dataPack;
|
|
16641
|
+
if (this.autoconnect)
|
|
16642
|
+
this._connect(this.address, {
|
|
16643
|
+
autoconnect: this.autoconnect,
|
|
16644
|
+
reconnect: this.reconnect,
|
|
16645
|
+
reconnect_interval: this.reconnect_interval,
|
|
16646
|
+
max_reconnects: this.max_reconnects,
|
|
16647
|
+
...this.rest_options
|
|
16648
|
+
});
|
|
16649
|
+
}
|
|
16650
|
+
/**
|
|
16651
|
+
* Connects to a defined server if not connected already.
|
|
16652
|
+
* @method
|
|
16653
|
+
* @return {Undefined}
|
|
16654
|
+
*/
|
|
16655
|
+
connect() {
|
|
16656
|
+
if (this.socket)
|
|
16657
|
+
return;
|
|
16658
|
+
this._connect(this.address, {
|
|
16659
|
+
autoconnect: this.autoconnect,
|
|
16660
|
+
reconnect: this.reconnect,
|
|
16661
|
+
reconnect_interval: this.reconnect_interval,
|
|
16662
|
+
max_reconnects: this.max_reconnects,
|
|
16663
|
+
...this.rest_options
|
|
16664
|
+
});
|
|
16665
|
+
}
|
|
16666
|
+
/**
|
|
16667
|
+
* Calls a registered RPC method on server.
|
|
16668
|
+
* @method
|
|
16669
|
+
* @param {String} method - RPC method name
|
|
16670
|
+
* @param {Object|Array} params - optional method parameters
|
|
16671
|
+
* @param {Number} timeout - RPC reply timeout value
|
|
16672
|
+
* @param {Object} ws_opts - options passed to ws
|
|
16673
|
+
* @return {Promise}
|
|
16674
|
+
*/
|
|
16675
|
+
call(method, params, timeout, ws_opts) {
|
|
16676
|
+
if (!ws_opts && "object" === typeof timeout) {
|
|
16677
|
+
ws_opts = timeout;
|
|
16678
|
+
timeout = null;
|
|
16679
|
+
}
|
|
16680
|
+
return new Promise((resolve, reject) => {
|
|
16681
|
+
if (!this.ready)
|
|
16682
|
+
return reject(new Error("socket not ready"));
|
|
16683
|
+
const rpc_id = this.generate_request_id(method, params);
|
|
16684
|
+
const message = {
|
|
16685
|
+
jsonrpc: "2.0",
|
|
16686
|
+
method: method,
|
|
16687
|
+
params: params || undefined,
|
|
16688
|
+
id: rpc_id
|
|
16689
|
+
};
|
|
16690
|
+
this.socket.send(this.dataPack.encode(message), ws_opts, (error) => {
|
|
16691
|
+
if (error)
|
|
16692
|
+
return reject(error);
|
|
16693
|
+
this.queue[rpc_id] = { promise: [resolve, reject] };
|
|
16694
|
+
if (timeout) {
|
|
16695
|
+
this.queue[rpc_id].timeout = setTimeout(() => {
|
|
16696
|
+
delete this.queue[rpc_id];
|
|
16697
|
+
reject(new Error("reply timeout"));
|
|
16698
|
+
}, timeout);
|
|
16699
|
+
}
|
|
16700
|
+
});
|
|
16701
|
+
});
|
|
16702
|
+
}
|
|
16703
|
+
/**
|
|
16704
|
+
* Logins with the other side of the connection.
|
|
16705
|
+
* @method
|
|
16706
|
+
* @param {Object} params - Login credentials object
|
|
16707
|
+
* @return {Promise}
|
|
16708
|
+
*/
|
|
16709
|
+
async login(params) {
|
|
16710
|
+
const resp = await this.call("rpc.login", params);
|
|
16711
|
+
if (!resp)
|
|
16712
|
+
throw new Error("authentication failed");
|
|
16713
|
+
return resp;
|
|
16714
|
+
}
|
|
16715
|
+
/**
|
|
16716
|
+
* Fetches a list of client's methods registered on server.
|
|
16717
|
+
* @method
|
|
16718
|
+
* @return {Array}
|
|
16719
|
+
*/
|
|
16720
|
+
async listMethods() {
|
|
16721
|
+
return await this.call("__listMethods");
|
|
16722
|
+
}
|
|
16723
|
+
/**
|
|
16724
|
+
* Sends a JSON-RPC 2.0 notification to server.
|
|
16725
|
+
* @method
|
|
16726
|
+
* @param {String} method - RPC method name
|
|
16727
|
+
* @param {Object} params - optional method parameters
|
|
16728
|
+
* @return {Promise}
|
|
16729
|
+
*/
|
|
16730
|
+
notify(method, params) {
|
|
16731
|
+
return new Promise((resolve, reject) => {
|
|
16732
|
+
if (!this.ready)
|
|
16733
|
+
return reject(new Error("socket not ready"));
|
|
16734
|
+
const message = {
|
|
16735
|
+
jsonrpc: "2.0",
|
|
16736
|
+
method: method,
|
|
16737
|
+
params
|
|
16738
|
+
};
|
|
16739
|
+
this.socket.send(this.dataPack.encode(message), (error) => {
|
|
16740
|
+
if (error)
|
|
16741
|
+
return reject(error);
|
|
16742
|
+
resolve();
|
|
16743
|
+
});
|
|
16744
|
+
});
|
|
16745
|
+
}
|
|
16746
|
+
/**
|
|
16747
|
+
* Subscribes for a defined event.
|
|
16748
|
+
* @method
|
|
16749
|
+
* @param {String|Array} event - event name
|
|
16750
|
+
* @return {Undefined}
|
|
16751
|
+
* @throws {Error}
|
|
16752
|
+
*/
|
|
16753
|
+
async subscribe(event) {
|
|
16754
|
+
if (typeof event === "string")
|
|
16755
|
+
event = [event];
|
|
16756
|
+
const result = await this.call("rpc.on", event);
|
|
16757
|
+
if (typeof event === "string" && result[event] !== "ok")
|
|
16758
|
+
throw new Error("Failed subscribing to an event '" + event + "' with: " + result[event]);
|
|
16759
|
+
return result;
|
|
16760
|
+
}
|
|
16761
|
+
/**
|
|
16762
|
+
* Unsubscribes from a defined event.
|
|
16763
|
+
* @method
|
|
16764
|
+
* @param {String|Array} event - event name
|
|
16765
|
+
* @return {Undefined}
|
|
16766
|
+
* @throws {Error}
|
|
16767
|
+
*/
|
|
16768
|
+
async unsubscribe(event) {
|
|
16769
|
+
if (typeof event === "string")
|
|
16770
|
+
event = [event];
|
|
16771
|
+
const result = await this.call("rpc.off", event);
|
|
16772
|
+
if (typeof event === "string" && result[event] !== "ok")
|
|
16773
|
+
throw new Error("Failed unsubscribing from an event with: " + result);
|
|
16774
|
+
return result;
|
|
16775
|
+
}
|
|
16776
|
+
/**
|
|
16777
|
+
* Closes a WebSocket connection gracefully.
|
|
16778
|
+
* @method
|
|
16779
|
+
* @param {Number} code - socket close code
|
|
16780
|
+
* @param {String} data - optional data to be sent before closing
|
|
16781
|
+
* @return {Undefined}
|
|
16782
|
+
*/
|
|
16783
|
+
close(code, data) {
|
|
16784
|
+
this.socket.close(code || 1000, data);
|
|
16785
|
+
}
|
|
16786
|
+
/**
|
|
16787
|
+
* Enable / disable automatic reconnection.
|
|
16788
|
+
* @method
|
|
16789
|
+
* @param {Boolean} reconnect - enable / disable reconnection
|
|
16790
|
+
* @return {Undefined}
|
|
16791
|
+
*/
|
|
16792
|
+
setAutoReconnect(reconnect) {
|
|
16793
|
+
this.reconnect = reconnect;
|
|
16794
|
+
}
|
|
16795
|
+
/**
|
|
16796
|
+
* Set the interval between reconnection attempts.
|
|
16797
|
+
* @method
|
|
16798
|
+
* @param {Number} interval - reconnection interval in milliseconds
|
|
16799
|
+
* @return {Undefined}
|
|
16800
|
+
*/
|
|
16801
|
+
setReconnectInterval(interval) {
|
|
16802
|
+
this.reconnect_interval = interval;
|
|
16803
|
+
}
|
|
16804
|
+
/**
|
|
16805
|
+
* Set the maximum number of reconnection attempts.
|
|
16806
|
+
* @method
|
|
16807
|
+
* @param {Number} max_reconnects - maximum reconnection attempts
|
|
16808
|
+
* @return {Undefined}
|
|
16809
|
+
*/
|
|
16810
|
+
setMaxReconnects(max_reconnects) {
|
|
16811
|
+
this.max_reconnects = max_reconnects;
|
|
16812
|
+
}
|
|
16813
|
+
/**
|
|
16814
|
+
* Connection/Message handler.
|
|
16815
|
+
* @method
|
|
16816
|
+
* @private
|
|
16817
|
+
* @param {String} address - WebSocket API address
|
|
16818
|
+
* @param {Object} options - ws options object
|
|
16819
|
+
* @return {Undefined}
|
|
16820
|
+
*/
|
|
16821
|
+
_connect(address, options) {
|
|
16822
|
+
clearTimeout(this.reconnect_timer_id);
|
|
16823
|
+
this.socket = this.webSocketFactory(address, options);
|
|
16824
|
+
this.socket.addEventListener("open", () => {
|
|
16825
|
+
this.ready = true;
|
|
16826
|
+
this.emit("open");
|
|
16827
|
+
this.current_reconnects = 0;
|
|
16828
|
+
});
|
|
16829
|
+
this.socket.addEventListener("message", ({ data: message }) => {
|
|
16830
|
+
if (message instanceof ArrayBuffer)
|
|
16831
|
+
message = Buffer.from(message).toString();
|
|
16832
|
+
try {
|
|
16833
|
+
message = this.dataPack.decode(message);
|
|
16834
|
+
}
|
|
16835
|
+
catch (error) {
|
|
16836
|
+
return;
|
|
16837
|
+
}
|
|
16838
|
+
// check if any listeners are attached and forward event
|
|
16839
|
+
if (message.notification && this.listeners(message.notification).length) {
|
|
16840
|
+
if (!Object.keys(message.params).length)
|
|
16841
|
+
return this.emit(message.notification);
|
|
16842
|
+
const args = [message.notification];
|
|
16843
|
+
if (message.params.constructor === Object)
|
|
16844
|
+
args.push(message.params);
|
|
16845
|
+
else
|
|
16846
|
+
// using for-loop instead of unshift/spread because performance is better
|
|
16847
|
+
for (let i = 0; i < message.params.length; i++)
|
|
16848
|
+
args.push(message.params[i]);
|
|
16849
|
+
// run as microtask so that pending queue messages are resolved first
|
|
16850
|
+
// eslint-disable-next-line prefer-spread
|
|
16851
|
+
return Promise.resolve().then(() => { this.emit.apply(this, args); });
|
|
16852
|
+
}
|
|
16853
|
+
if (!this.queue[message.id]) {
|
|
16854
|
+
// general JSON RPC 2.0 events
|
|
16855
|
+
if (message.method) {
|
|
16856
|
+
// run as microtask so that pending queue messages are resolved first
|
|
16857
|
+
return Promise.resolve().then(() => {
|
|
16858
|
+
this.emit(message.method, message?.params);
|
|
16859
|
+
});
|
|
16860
|
+
}
|
|
16861
|
+
return;
|
|
16862
|
+
}
|
|
16863
|
+
// reject early since server's response is invalid
|
|
16864
|
+
if ("error" in message === "result" in message)
|
|
16865
|
+
this.queue[message.id].promise[1](new Error("Server response malformed. Response must include either \"result\"" +
|
|
16866
|
+
" or \"error\", but not both."));
|
|
16867
|
+
if (this.queue[message.id].timeout)
|
|
16868
|
+
clearTimeout(this.queue[message.id].timeout);
|
|
16869
|
+
if (message.error)
|
|
16870
|
+
this.queue[message.id].promise[1](message.error);
|
|
16871
|
+
else
|
|
16872
|
+
this.queue[message.id].promise[0](message.result);
|
|
16873
|
+
delete this.queue[message.id];
|
|
16874
|
+
});
|
|
16875
|
+
this.socket.addEventListener("error", (error) => this.emit("error", error));
|
|
16876
|
+
this.socket.addEventListener("close", ({ code, reason }) => {
|
|
16877
|
+
if (this.ready) // Delay close event until internal state is updated
|
|
16878
|
+
setTimeout(() => this.emit("close", code, reason), 0);
|
|
16879
|
+
this.ready = false;
|
|
16880
|
+
this.socket = undefined;
|
|
16881
|
+
if (code === 1000)
|
|
16882
|
+
return;
|
|
16883
|
+
this.current_reconnects++;
|
|
16884
|
+
if (this.reconnect && ((this.max_reconnects > this.current_reconnects) ||
|
|
16885
|
+
this.max_reconnects === 0))
|
|
16886
|
+
this.reconnect_timer_id = setTimeout(() => this._connect(address, options), this.reconnect_interval);
|
|
16887
|
+
});
|
|
16888
|
+
}
|
|
16889
|
+
}
|
|
16890
|
+
var _default$1 = client.default = CommonClient;
|
|
17849
16891
|
|
|
17850
16892
|
var websocket_browser = {};
|
|
17851
16893
|
|
|
@@ -17853,133 +16895,76 @@ var solanaWeb3 = (function (exports) {
|
|
|
17853
16895
|
* WebSocket implements a browser-side WebSocket specification.
|
|
17854
16896
|
* @module Client
|
|
17855
16897
|
*/
|
|
16898
|
+
Object.defineProperty(websocket_browser, "__esModule", { value: true });
|
|
16899
|
+
const eventemitter3_1 = eventemitter3Exports;
|
|
16900
|
+
class WebSocketBrowserImpl extends eventemitter3_1.EventEmitter {
|
|
16901
|
+
socket;
|
|
16902
|
+
/** Instantiate a WebSocket class
|
|
16903
|
+
* @constructor
|
|
16904
|
+
* @param {String} address - url to a websocket server
|
|
16905
|
+
* @param {(Object)} options - websocket options
|
|
16906
|
+
* @param {(String|Array)} protocols - a list of protocols
|
|
16907
|
+
* @return {WebSocketBrowserImpl} - returns a WebSocket instance
|
|
16908
|
+
*/
|
|
16909
|
+
constructor(address, options, protocols) {
|
|
16910
|
+
super();
|
|
16911
|
+
this.socket = new window.WebSocket(address, protocols);
|
|
16912
|
+
this.socket.onopen = () => this.emit("open");
|
|
16913
|
+
this.socket.onmessage = (event) => this.emit("message", event.data);
|
|
16914
|
+
this.socket.onerror = (error) => this.emit("error", error);
|
|
16915
|
+
this.socket.onclose = (event) => {
|
|
16916
|
+
this.emit("close", event.code, event.reason);
|
|
16917
|
+
};
|
|
16918
|
+
}
|
|
16919
|
+
/**
|
|
16920
|
+
* Sends data through a websocket connection
|
|
16921
|
+
* @method
|
|
16922
|
+
* @param {(String|Object)} data - data to be sent via websocket
|
|
16923
|
+
* @param {Object} optionsOrCallback - ws options
|
|
16924
|
+
* @param {Function} callback - a callback called once the data is sent
|
|
16925
|
+
* @return {Undefined}
|
|
16926
|
+
*/
|
|
16927
|
+
send(data, optionsOrCallback, callback) {
|
|
16928
|
+
const cb = callback || optionsOrCallback;
|
|
16929
|
+
try {
|
|
16930
|
+
this.socket.send(data);
|
|
16931
|
+
cb();
|
|
16932
|
+
}
|
|
16933
|
+
catch (error) {
|
|
16934
|
+
cb(error);
|
|
16935
|
+
}
|
|
16936
|
+
}
|
|
16937
|
+
/**
|
|
16938
|
+
* Closes an underlying socket
|
|
16939
|
+
* @method
|
|
16940
|
+
* @param {Number} code - status code explaining why the connection is being closed
|
|
16941
|
+
* @param {String} reason - a description why the connection is closing
|
|
16942
|
+
* @return {Undefined}
|
|
16943
|
+
* @throws {Error}
|
|
16944
|
+
*/
|
|
16945
|
+
close(code, reason) {
|
|
16946
|
+
this.socket.close(code, reason);
|
|
16947
|
+
}
|
|
16948
|
+
addEventListener(type, listener, options) {
|
|
16949
|
+
this.socket.addEventListener(type, listener, options);
|
|
16950
|
+
}
|
|
16951
|
+
}
|
|
16952
|
+
/**
|
|
16953
|
+
* factory method for common WebSocket instance
|
|
16954
|
+
* @method
|
|
16955
|
+
* @param {String} address - url to a websocket server
|
|
16956
|
+
* @param {(Object)} options - websocket options
|
|
16957
|
+
* @return {Undefined}
|
|
16958
|
+
*/
|
|
16959
|
+
function default_1(address, options) {
|
|
16960
|
+
return new WebSocketBrowserImpl(address, options);
|
|
16961
|
+
}
|
|
16962
|
+
var _default = websocket_browser.default = default_1;
|
|
17856
16963
|
|
|
17857
|
-
|
|
17858
|
-
|
|
17859
|
-
var _interopRequireDefault = interopRequireDefaultExports;
|
|
17860
|
-
|
|
17861
|
-
Object.defineProperty(exports, "__esModule", {
|
|
17862
|
-
value: true
|
|
17863
|
-
});
|
|
17864
|
-
exports["default"] = _default;
|
|
17865
|
-
|
|
17866
|
-
var _classCallCheck2 = _interopRequireDefault(requireClassCallCheck());
|
|
17867
|
-
|
|
17868
|
-
var _createClass2 = _interopRequireDefault(requireCreateClass());
|
|
17869
|
-
|
|
17870
|
-
var _inherits2 = _interopRequireDefault(requireInherits());
|
|
17871
|
-
|
|
17872
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(requirePossibleConstructorReturn());
|
|
17873
|
-
|
|
17874
|
-
var _getPrototypeOf2 = _interopRequireDefault(requireGetPrototypeOf());
|
|
17875
|
-
|
|
17876
|
-
var _eventemitter = requireEventemitter3();
|
|
17877
|
-
|
|
17878
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
17879
|
-
|
|
17880
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
17881
|
-
|
|
17882
|
-
var WebSocketBrowserImpl = /*#__PURE__*/function (_EventEmitter) {
|
|
17883
|
-
(0, _inherits2["default"])(WebSocketBrowserImpl, _EventEmitter);
|
|
17884
|
-
|
|
17885
|
-
var _super = _createSuper(WebSocketBrowserImpl);
|
|
17886
|
-
|
|
17887
|
-
/** Instantiate a WebSocket class
|
|
17888
|
-
* @constructor
|
|
17889
|
-
* @param {String} address - url to a websocket server
|
|
17890
|
-
* @param {(Object)} options - websocket options
|
|
17891
|
-
* @param {(String|Array)} protocols - a list of protocols
|
|
17892
|
-
* @return {WebSocketBrowserImpl} - returns a WebSocket instance
|
|
17893
|
-
*/
|
|
17894
|
-
function WebSocketBrowserImpl(address, options, protocols) {
|
|
17895
|
-
var _this;
|
|
17896
|
-
|
|
17897
|
-
(0, _classCallCheck2["default"])(this, WebSocketBrowserImpl);
|
|
17898
|
-
_this = _super.call(this);
|
|
17899
|
-
_this.socket = new window.WebSocket(address, protocols);
|
|
17900
|
-
|
|
17901
|
-
_this.socket.onopen = function () {
|
|
17902
|
-
return _this.emit("open");
|
|
17903
|
-
};
|
|
17904
|
-
|
|
17905
|
-
_this.socket.onmessage = function (event) {
|
|
17906
|
-
return _this.emit("message", event.data);
|
|
17907
|
-
};
|
|
17908
|
-
|
|
17909
|
-
_this.socket.onerror = function (error) {
|
|
17910
|
-
return _this.emit("error", error);
|
|
17911
|
-
};
|
|
17912
|
-
|
|
17913
|
-
_this.socket.onclose = function (event) {
|
|
17914
|
-
_this.emit("close", event.code, event.reason);
|
|
17915
|
-
};
|
|
17916
|
-
|
|
17917
|
-
return _this;
|
|
17918
|
-
}
|
|
17919
|
-
/**
|
|
17920
|
-
* Sends data through a websocket connection
|
|
17921
|
-
* @method
|
|
17922
|
-
* @param {(String|Object)} data - data to be sent via websocket
|
|
17923
|
-
* @param {Object} optionsOrCallback - ws options
|
|
17924
|
-
* @param {Function} callback - a callback called once the data is sent
|
|
17925
|
-
* @return {Undefined}
|
|
17926
|
-
*/
|
|
17927
|
-
|
|
17928
|
-
|
|
17929
|
-
(0, _createClass2["default"])(WebSocketBrowserImpl, [{
|
|
17930
|
-
key: "send",
|
|
17931
|
-
value: function send(data, optionsOrCallback, callback) {
|
|
17932
|
-
var cb = callback || optionsOrCallback;
|
|
17933
|
-
|
|
17934
|
-
try {
|
|
17935
|
-
this.socket.send(data);
|
|
17936
|
-
cb();
|
|
17937
|
-
} catch (error) {
|
|
17938
|
-
cb(error);
|
|
17939
|
-
}
|
|
17940
|
-
}
|
|
17941
|
-
/**
|
|
17942
|
-
* Closes an underlying socket
|
|
17943
|
-
* @method
|
|
17944
|
-
* @param {Number} code - status code explaining why the connection is being closed
|
|
17945
|
-
* @param {String} reason - a description why the connection is closing
|
|
17946
|
-
* @return {Undefined}
|
|
17947
|
-
* @throws {Error}
|
|
17948
|
-
*/
|
|
17949
|
-
|
|
17950
|
-
}, {
|
|
17951
|
-
key: "close",
|
|
17952
|
-
value: function close(code, reason) {
|
|
17953
|
-
this.socket.close(code, reason);
|
|
17954
|
-
}
|
|
17955
|
-
}, {
|
|
17956
|
-
key: "addEventListener",
|
|
17957
|
-
value: function addEventListener(type, listener, options) {
|
|
17958
|
-
this.socket.addEventListener(type, listener, options);
|
|
17959
|
-
}
|
|
17960
|
-
}]);
|
|
17961
|
-
return WebSocketBrowserImpl;
|
|
17962
|
-
}(_eventemitter.EventEmitter);
|
|
17963
|
-
/**
|
|
17964
|
-
* factory method for common WebSocket instance
|
|
17965
|
-
* @method
|
|
17966
|
-
* @param {String} address - url to a websocket server
|
|
17967
|
-
* @param {(Object)} options - websocket options
|
|
17968
|
-
* @return {Undefined}
|
|
17969
|
-
*/
|
|
17970
|
-
|
|
17971
|
-
|
|
17972
|
-
function _default(address, options) {
|
|
17973
|
-
return new WebSocketBrowserImpl(address, options);
|
|
17974
|
-
}
|
|
17975
|
-
} (websocket_browser));
|
|
17976
|
-
|
|
17977
|
-
var createRpc = /*@__PURE__*/getDefaultExportFromCjs(websocket_browser);
|
|
17978
|
-
|
|
17979
|
-
class RpcWebSocketClient extends RpcWebSocketCommonClient {
|
|
16964
|
+
class RpcWebSocketClient extends _default$1 {
|
|
17980
16965
|
constructor(address, options, generate_request_id) {
|
|
17981
16966
|
const webSocketFactory = url => {
|
|
17982
|
-
const rpc =
|
|
16967
|
+
const rpc = _default(url, {
|
|
17983
16968
|
autoconnect: true,
|
|
17984
16969
|
max_reconnects: 5,
|
|
17985
16970
|
reconnect: true,
|
|
@@ -23172,34 +22157,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
23172
22157
|
}
|
|
23173
22158
|
Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
|
|
23174
22159
|
|
|
23175
|
-
const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
23176
|
-
const _32n = /* @__PURE__ */ BigInt(32);
|
|
23177
|
-
// We are not using BigUint64Array, because they are extremely slow as per 2022
|
|
23178
|
-
function fromBig(n, le = false) {
|
|
23179
|
-
if (le)
|
|
23180
|
-
return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
|
|
23181
|
-
return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
23182
|
-
}
|
|
23183
|
-
function split(lst, le = false) {
|
|
23184
|
-
let Ah = new Uint32Array(lst.length);
|
|
23185
|
-
let Al = new Uint32Array(lst.length);
|
|
23186
|
-
for (let i = 0; i < lst.length; i++) {
|
|
23187
|
-
const { h, l } = fromBig(lst[i], le);
|
|
23188
|
-
[Ah[i], Al[i]] = [h, l];
|
|
23189
|
-
}
|
|
23190
|
-
return [Ah, Al];
|
|
23191
|
-
}
|
|
23192
|
-
// Left rotate for Shift in [1, 32)
|
|
23193
|
-
const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
|
|
23194
|
-
const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
|
|
23195
|
-
// Left rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
23196
|
-
const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
|
|
23197
|
-
const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
|
|
23198
|
-
|
|
23199
22160
|
// SHA3 (keccak) is based on a new design: basically, the internal state is bigger than output size.
|
|
23200
22161
|
// It's called a sponge function.
|
|
23201
22162
|
// Various per round constants calculations
|
|
23202
|
-
const
|
|
22163
|
+
const SHA3_PI = [];
|
|
22164
|
+
const SHA3_ROTL = [];
|
|
22165
|
+
const _SHA3_IOTA = [];
|
|
23203
22166
|
const _0n$1 = /* @__PURE__ */ BigInt(0);
|
|
23204
22167
|
const _1n$2 = /* @__PURE__ */ BigInt(1);
|
|
23205
22168
|
const _2n$1 = /* @__PURE__ */ BigInt(2);
|
|
@@ -23293,7 +22256,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
23293
22256
|
this.state32 = u32$1(this.state);
|
|
23294
22257
|
}
|
|
23295
22258
|
keccak() {
|
|
22259
|
+
if (!isLE)
|
|
22260
|
+
byteSwap32(this.state32);
|
|
23296
22261
|
keccakP(this.state32, this.rounds);
|
|
22262
|
+
if (!isLE)
|
|
22263
|
+
byteSwap32(this.state32);
|
|
23297
22264
|
this.posOut = 0;
|
|
23298
22265
|
this.pos = 0;
|
|
23299
22266
|
}
|
|
@@ -23387,111 +22354,6 @@ var solanaWeb3 = (function (exports) {
|
|
|
23387
22354
|
*/
|
|
23388
22355
|
const keccak_256 = /* @__PURE__ */ gen(0x01, 136, 256 / 8);
|
|
23389
22356
|
|
|
23390
|
-
// SHA2-256 need to try 2^128 hashes to execute birthday attack.
|
|
23391
|
-
// BTC network is doing 2^67 hashes/sec as per early 2023.
|
|
23392
|
-
// Round constants:
|
|
23393
|
-
// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
|
|
23394
|
-
// prettier-ignore
|
|
23395
|
-
const SHA256_K = /* @__PURE__ */ new Uint32Array([
|
|
23396
|
-
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
23397
|
-
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
23398
|
-
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
23399
|
-
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
23400
|
-
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
23401
|
-
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
23402
|
-
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
23403
|
-
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
23404
|
-
]);
|
|
23405
|
-
// Initial state:
|
|
23406
|
-
// first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19
|
|
23407
|
-
// prettier-ignore
|
|
23408
|
-
const SHA256_IV = /* @__PURE__ */ new Uint32Array([
|
|
23409
|
-
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
|
23410
|
-
]);
|
|
23411
|
-
// Temporary buffer, not used to store anything between runs
|
|
23412
|
-
// Named this way because it matches specification.
|
|
23413
|
-
const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
23414
|
-
class SHA256 extends HashMD {
|
|
23415
|
-
constructor() {
|
|
23416
|
-
super(64, 32, 8, false);
|
|
23417
|
-
// We cannot use array here since array allows indexing by variable
|
|
23418
|
-
// which means optimizer/compiler cannot use registers.
|
|
23419
|
-
this.A = SHA256_IV[0] | 0;
|
|
23420
|
-
this.B = SHA256_IV[1] | 0;
|
|
23421
|
-
this.C = SHA256_IV[2] | 0;
|
|
23422
|
-
this.D = SHA256_IV[3] | 0;
|
|
23423
|
-
this.E = SHA256_IV[4] | 0;
|
|
23424
|
-
this.F = SHA256_IV[5] | 0;
|
|
23425
|
-
this.G = SHA256_IV[6] | 0;
|
|
23426
|
-
this.H = SHA256_IV[7] | 0;
|
|
23427
|
-
}
|
|
23428
|
-
get() {
|
|
23429
|
-
const { A, B, C, D, E, F, G, H } = this;
|
|
23430
|
-
return [A, B, C, D, E, F, G, H];
|
|
23431
|
-
}
|
|
23432
|
-
// prettier-ignore
|
|
23433
|
-
set(A, B, C, D, E, F, G, H) {
|
|
23434
|
-
this.A = A | 0;
|
|
23435
|
-
this.B = B | 0;
|
|
23436
|
-
this.C = C | 0;
|
|
23437
|
-
this.D = D | 0;
|
|
23438
|
-
this.E = E | 0;
|
|
23439
|
-
this.F = F | 0;
|
|
23440
|
-
this.G = G | 0;
|
|
23441
|
-
this.H = H | 0;
|
|
23442
|
-
}
|
|
23443
|
-
process(view, offset) {
|
|
23444
|
-
// Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
|
|
23445
|
-
for (let i = 0; i < 16; i++, offset += 4)
|
|
23446
|
-
SHA256_W[i] = view.getUint32(offset, false);
|
|
23447
|
-
for (let i = 16; i < 64; i++) {
|
|
23448
|
-
const W15 = SHA256_W[i - 15];
|
|
23449
|
-
const W2 = SHA256_W[i - 2];
|
|
23450
|
-
const s0 = rotr$1(W15, 7) ^ rotr$1(W15, 18) ^ (W15 >>> 3);
|
|
23451
|
-
const s1 = rotr$1(W2, 17) ^ rotr$1(W2, 19) ^ (W2 >>> 10);
|
|
23452
|
-
SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;
|
|
23453
|
-
}
|
|
23454
|
-
// Compression function main loop, 64 rounds
|
|
23455
|
-
let { A, B, C, D, E, F, G, H } = this;
|
|
23456
|
-
for (let i = 0; i < 64; i++) {
|
|
23457
|
-
const sigma1 = rotr$1(E, 6) ^ rotr$1(E, 11) ^ rotr$1(E, 25);
|
|
23458
|
-
const T1 = (H + sigma1 + Chi$1(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
|
23459
|
-
const sigma0 = rotr$1(A, 2) ^ rotr$1(A, 13) ^ rotr$1(A, 22);
|
|
23460
|
-
const T2 = (sigma0 + Maj$1(A, B, C)) | 0;
|
|
23461
|
-
H = G;
|
|
23462
|
-
G = F;
|
|
23463
|
-
F = E;
|
|
23464
|
-
E = (D + T1) | 0;
|
|
23465
|
-
D = C;
|
|
23466
|
-
C = B;
|
|
23467
|
-
B = A;
|
|
23468
|
-
A = (T1 + T2) | 0;
|
|
23469
|
-
}
|
|
23470
|
-
// Add the compressed chunk to the current hash value
|
|
23471
|
-
A = (A + this.A) | 0;
|
|
23472
|
-
B = (B + this.B) | 0;
|
|
23473
|
-
C = (C + this.C) | 0;
|
|
23474
|
-
D = (D + this.D) | 0;
|
|
23475
|
-
E = (E + this.E) | 0;
|
|
23476
|
-
F = (F + this.F) | 0;
|
|
23477
|
-
G = (G + this.G) | 0;
|
|
23478
|
-
H = (H + this.H) | 0;
|
|
23479
|
-
this.set(A, B, C, D, E, F, G, H);
|
|
23480
|
-
}
|
|
23481
|
-
roundClean() {
|
|
23482
|
-
SHA256_W.fill(0);
|
|
23483
|
-
}
|
|
23484
|
-
destroy() {
|
|
23485
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
23486
|
-
this.buffer.fill(0);
|
|
23487
|
-
}
|
|
23488
|
-
}
|
|
23489
|
-
/**
|
|
23490
|
-
* SHA2-256 hash function
|
|
23491
|
-
* @param message - data that would be hashed
|
|
23492
|
-
*/
|
|
23493
|
-
const sha256 = /* @__PURE__ */ wrapConstructor$1(() => new SHA256());
|
|
23494
|
-
|
|
23495
22357
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
23496
22358
|
// Short Weierstrass curve. The formula is: y² = x³ + ax + b
|
|
23497
22359
|
function validatePointOpts(curve) {
|
|
@@ -23629,7 +22491,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
23629
22491
|
function normPrivateKeyToScalar(key) {
|
|
23630
22492
|
const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n } = CURVE;
|
|
23631
22493
|
if (lengths && typeof key !== 'bigint') {
|
|
23632
|
-
if (isBytes
|
|
22494
|
+
if (isBytes(key))
|
|
23633
22495
|
key = bytesToHex(key);
|
|
23634
22496
|
// Normalize to hex string, pad. E.g. P521 would norm 130-132 char hex to 132-char bytes
|
|
23635
22497
|
if (typeof key !== 'string' || !lengths.includes(key.length))
|
|
@@ -24214,7 +23076,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
24214
23076
|
* Quick and dirty check for item being public key. Does not validate hex, or being on-curve.
|
|
24215
23077
|
*/
|
|
24216
23078
|
function isProbPub(item) {
|
|
24217
|
-
const arr = isBytes
|
|
23079
|
+
const arr = isBytes(item);
|
|
24218
23080
|
const str = typeof item === 'string';
|
|
24219
23081
|
const len = (arr || str) && item.length;
|
|
24220
23082
|
if (arr)
|
|
@@ -24375,7 +23237,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
24375
23237
|
let _sig = undefined;
|
|
24376
23238
|
let P;
|
|
24377
23239
|
try {
|
|
24378
|
-
if (typeof sg === 'string' || isBytes
|
|
23240
|
+
if (typeof sg === 'string' || isBytes(sg)) {
|
|
24379
23241
|
// Signature can be represented in 2 ways: compact (2*nByteLength) & DER (variable-length).
|
|
24380
23242
|
// Since DER can also be 2*nByteLength bytes, we check for it first.
|
|
24381
23243
|
try {
|
|
@@ -24429,13 +23291,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
24429
23291
|
}
|
|
24430
23292
|
|
|
24431
23293
|
// HMAC (RFC 2104)
|
|
24432
|
-
class HMAC extends Hash
|
|
23294
|
+
class HMAC extends Hash {
|
|
24433
23295
|
constructor(hash$1, _key) {
|
|
24434
23296
|
super();
|
|
24435
23297
|
this.finished = false;
|
|
24436
23298
|
this.destroyed = false;
|
|
24437
23299
|
hash(hash$1);
|
|
24438
|
-
const key = toBytes
|
|
23300
|
+
const key = toBytes(_key);
|
|
24439
23301
|
this.iHash = hash$1.create();
|
|
24440
23302
|
if (typeof this.iHash.update !== 'function')
|
|
24441
23303
|
throw new Error('Expected instance of class which extends utils.Hash');
|
|
@@ -24457,13 +23319,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
24457
23319
|
pad.fill(0);
|
|
24458
23320
|
}
|
|
24459
23321
|
update(buf) {
|
|
24460
|
-
exists
|
|
23322
|
+
exists(this);
|
|
24461
23323
|
this.iHash.update(buf);
|
|
24462
23324
|
return this;
|
|
24463
23325
|
}
|
|
24464
23326
|
digestInto(out) {
|
|
24465
|
-
exists
|
|
24466
|
-
bytes
|
|
23327
|
+
exists(this);
|
|
23328
|
+
bytes(out, this.outputLen);
|
|
24467
23329
|
this.finished = true;
|
|
24468
23330
|
this.iHash.digestInto(out);
|
|
24469
23331
|
this.oHash.update(out);
|
|
@@ -24748,7 +23610,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
24748
23610
|
}
|
|
24749
23611
|
Secp256k1Program.programId = new PublicKey('KeccakSecp256k11111111111111111111111111111');
|
|
24750
23612
|
|
|
24751
|
-
var
|
|
23613
|
+
var _Lockup;
|
|
24752
23614
|
|
|
24753
23615
|
/**
|
|
24754
23616
|
* Address of the stake config account which configures the rate
|
|
@@ -24797,8 +23659,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
24797
23659
|
* Default, inactive Lockup value
|
|
24798
23660
|
*/
|
|
24799
23661
|
}
|
|
24800
|
-
|
|
24801
|
-
Lockup.default = new
|
|
23662
|
+
_Lockup = Lockup;
|
|
23663
|
+
Lockup.default = new _Lockup(0, 0, PublicKey.default);
|
|
24802
23664
|
/**
|
|
24803
23665
|
* Create stake account transaction params
|
|
24804
23666
|
*/
|