@waku/core 0.0.36-f911bf8.0 → 0.0.36
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/CHANGELOG.md +39 -0
- package/bundle/index.js +1143 -610
- package/bundle/lib/message/version_0.js +1 -2
- package/bundle/{version_0-CiYGrPc2.js → version_0-9DPFjcJG.js} +1586 -10
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/connection_manager/connection_manager.d.ts +2 -1
- package/dist/lib/connection_manager/connection_manager.js +16 -8
- package/dist/lib/connection_manager/connection_manager.js.map +1 -1
- package/dist/lib/filter/filter.d.ts +8 -5
- package/dist/lib/filter/filter.js +30 -10
- package/dist/lib/filter/filter.js.map +1 -1
- package/dist/lib/light_push/light_push.d.ts +4 -3
- package/dist/lib/light_push/light_push.js +6 -4
- package/dist/lib/light_push/light_push.js.map +1 -1
- package/dist/lib/message/version_0.d.ts +3 -4
- package/dist/lib/message/version_0.js +1 -4
- package/dist/lib/message/version_0.js.map +1 -1
- package/dist/lib/message_hash/index.d.ts +1 -0
- package/dist/lib/message_hash/index.js +2 -0
- package/dist/lib/message_hash/index.js.map +1 -0
- package/dist/lib/message_hash/message_hash.d.ts +52 -0
- package/dist/lib/message_hash/message_hash.js +84 -0
- package/dist/lib/message_hash/message_hash.js.map +1 -0
- package/dist/lib/metadata/metadata.js +6 -4
- package/dist/lib/metadata/metadata.js.map +1 -1
- package/dist/lib/store/rpc.js +16 -10
- package/dist/lib/store/rpc.js.map +1 -1
- package/dist/lib/store/store.d.ts +4 -3
- package/dist/lib/store/store.js +18 -6
- package/dist/lib/store/store.js.map +1 -1
- package/dist/lib/stream_manager/stream_manager.d.ts +3 -4
- package/dist/lib/stream_manager/stream_manager.js +6 -8
- package/dist/lib/stream_manager/stream_manager.js.map +1 -1
- package/package.json +125 -1
- package/src/index.ts +2 -0
- package/src/lib/connection_manager/connection_manager.ts +24 -16
- package/src/lib/filter/filter.ts +46 -14
- package/src/lib/light_push/light_push.ts +8 -5
- package/src/lib/message/version_0.ts +3 -7
- package/src/lib/message_hash/index.ts +1 -0
- package/src/lib/message_hash/message_hash.ts +106 -0
- package/src/lib/metadata/metadata.ts +8 -5
- package/src/lib/store/rpc.ts +23 -19
- package/src/lib/store/store.ts +21 -6
- package/src/lib/stream_manager/stream_manager.ts +8 -6
- package/bundle/base_protocol-DvQrudwy.js +0 -152
- package/bundle/index-CTo1my9M.js +0 -1543
- package/bundle/lib/base_protocol.js +0 -2
- package/dist/lib/base_protocol.d.ts +0 -18
- package/dist/lib/base_protocol.js +0 -25
- package/dist/lib/base_protocol.js.map +0 -1
- package/src/lib/base_protocol.ts +0 -44
package/bundle/index-CTo1my9M.js
DELETED
@@ -1,1543 +0,0 @@
|
|
1
|
-
function equals(aa, bb) {
|
2
|
-
if (aa === bb)
|
3
|
-
return true;
|
4
|
-
if (aa.byteLength !== bb.byteLength) {
|
5
|
-
return false;
|
6
|
-
}
|
7
|
-
for (let ii = 0; ii < aa.byteLength; ii++) {
|
8
|
-
if (aa[ii] !== bb[ii]) {
|
9
|
-
return false;
|
10
|
-
}
|
11
|
-
}
|
12
|
-
return true;
|
13
|
-
}
|
14
|
-
function coerce(o) {
|
15
|
-
if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array')
|
16
|
-
return o;
|
17
|
-
if (o instanceof ArrayBuffer)
|
18
|
-
return new Uint8Array(o);
|
19
|
-
if (ArrayBuffer.isView(o)) {
|
20
|
-
return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
|
21
|
-
}
|
22
|
-
throw new Error('Unknown type, must be binary type');
|
23
|
-
}
|
24
|
-
function fromString(str) {
|
25
|
-
return new TextEncoder().encode(str);
|
26
|
-
}
|
27
|
-
function toString(b) {
|
28
|
-
return new TextDecoder().decode(b);
|
29
|
-
}
|
30
|
-
|
31
|
-
/* eslint-disable */
|
32
|
-
// base-x encoding / decoding
|
33
|
-
// Copyright (c) 2018 base-x contributors
|
34
|
-
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
35
|
-
// Distributed under the MIT software license, see the accompanying
|
36
|
-
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
37
|
-
/**
|
38
|
-
* @param {string} ALPHABET
|
39
|
-
* @param {any} name
|
40
|
-
*/
|
41
|
-
function base(ALPHABET, name) {
|
42
|
-
if (ALPHABET.length >= 255) {
|
43
|
-
throw new TypeError('Alphabet too long');
|
44
|
-
}
|
45
|
-
var BASE_MAP = new Uint8Array(256);
|
46
|
-
for (var j = 0; j < BASE_MAP.length; j++) {
|
47
|
-
BASE_MAP[j] = 255;
|
48
|
-
}
|
49
|
-
for (var i = 0; i < ALPHABET.length; i++) {
|
50
|
-
var x = ALPHABET.charAt(i);
|
51
|
-
var xc = x.charCodeAt(0);
|
52
|
-
if (BASE_MAP[xc] !== 255) {
|
53
|
-
throw new TypeError(x + ' is ambiguous');
|
54
|
-
}
|
55
|
-
BASE_MAP[xc] = i;
|
56
|
-
}
|
57
|
-
var BASE = ALPHABET.length;
|
58
|
-
var LEADER = ALPHABET.charAt(0);
|
59
|
-
var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
60
|
-
var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
61
|
-
/**
|
62
|
-
* @param {any[] | Iterable<number>} source
|
63
|
-
*/
|
64
|
-
function encode(source) {
|
65
|
-
// @ts-ignore
|
66
|
-
if (source instanceof Uint8Array)
|
67
|
-
;
|
68
|
-
else if (ArrayBuffer.isView(source)) {
|
69
|
-
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
70
|
-
}
|
71
|
-
else if (Array.isArray(source)) {
|
72
|
-
source = Uint8Array.from(source);
|
73
|
-
}
|
74
|
-
if (!(source instanceof Uint8Array)) {
|
75
|
-
throw new TypeError('Expected Uint8Array');
|
76
|
-
}
|
77
|
-
if (source.length === 0) {
|
78
|
-
return '';
|
79
|
-
}
|
80
|
-
// Skip & count leading zeroes.
|
81
|
-
var zeroes = 0;
|
82
|
-
var length = 0;
|
83
|
-
var pbegin = 0;
|
84
|
-
var pend = source.length;
|
85
|
-
while (pbegin !== pend && source[pbegin] === 0) {
|
86
|
-
pbegin++;
|
87
|
-
zeroes++;
|
88
|
-
}
|
89
|
-
// Allocate enough space in big-endian base58 representation.
|
90
|
-
var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
91
|
-
var b58 = new Uint8Array(size);
|
92
|
-
// Process the bytes.
|
93
|
-
while (pbegin !== pend) {
|
94
|
-
var carry = source[pbegin];
|
95
|
-
// Apply "b58 = b58 * 256 + ch".
|
96
|
-
var i = 0;
|
97
|
-
for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
98
|
-
carry += (256 * b58[it1]) >>> 0;
|
99
|
-
b58[it1] = (carry % BASE) >>> 0;
|
100
|
-
carry = (carry / BASE) >>> 0;
|
101
|
-
}
|
102
|
-
if (carry !== 0) {
|
103
|
-
throw new Error('Non-zero carry');
|
104
|
-
}
|
105
|
-
length = i;
|
106
|
-
pbegin++;
|
107
|
-
}
|
108
|
-
// Skip leading zeroes in base58 result.
|
109
|
-
var it2 = size - length;
|
110
|
-
while (it2 !== size && b58[it2] === 0) {
|
111
|
-
it2++;
|
112
|
-
}
|
113
|
-
// Translate the result into a string.
|
114
|
-
var str = LEADER.repeat(zeroes);
|
115
|
-
for (; it2 < size; ++it2) {
|
116
|
-
str += ALPHABET.charAt(b58[it2]);
|
117
|
-
}
|
118
|
-
return str;
|
119
|
-
}
|
120
|
-
/**
|
121
|
-
* @param {string | string[]} source
|
122
|
-
*/
|
123
|
-
function decodeUnsafe(source) {
|
124
|
-
if (typeof source !== 'string') {
|
125
|
-
throw new TypeError('Expected String');
|
126
|
-
}
|
127
|
-
if (source.length === 0) {
|
128
|
-
return new Uint8Array();
|
129
|
-
}
|
130
|
-
var psz = 0;
|
131
|
-
// Skip leading spaces.
|
132
|
-
if (source[psz] === ' ') {
|
133
|
-
return;
|
134
|
-
}
|
135
|
-
// Skip and count leading '1's.
|
136
|
-
var zeroes = 0;
|
137
|
-
var length = 0;
|
138
|
-
while (source[psz] === LEADER) {
|
139
|
-
zeroes++;
|
140
|
-
psz++;
|
141
|
-
}
|
142
|
-
// Allocate enough space in big-endian base256 representation.
|
143
|
-
var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
144
|
-
var b256 = new Uint8Array(size);
|
145
|
-
// Process the characters.
|
146
|
-
while (source[psz]) {
|
147
|
-
// Decode character
|
148
|
-
var carry = BASE_MAP[source.charCodeAt(psz)];
|
149
|
-
// Invalid character
|
150
|
-
if (carry === 255) {
|
151
|
-
return;
|
152
|
-
}
|
153
|
-
var i = 0;
|
154
|
-
for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
155
|
-
carry += (BASE * b256[it3]) >>> 0;
|
156
|
-
b256[it3] = (carry % 256) >>> 0;
|
157
|
-
carry = (carry / 256) >>> 0;
|
158
|
-
}
|
159
|
-
if (carry !== 0) {
|
160
|
-
throw new Error('Non-zero carry');
|
161
|
-
}
|
162
|
-
length = i;
|
163
|
-
psz++;
|
164
|
-
}
|
165
|
-
// Skip trailing spaces.
|
166
|
-
if (source[psz] === ' ') {
|
167
|
-
return;
|
168
|
-
}
|
169
|
-
// Skip leading zeroes in b256.
|
170
|
-
var it4 = size - length;
|
171
|
-
while (it4 !== size && b256[it4] === 0) {
|
172
|
-
it4++;
|
173
|
-
}
|
174
|
-
var vch = new Uint8Array(zeroes + (size - it4));
|
175
|
-
var j = zeroes;
|
176
|
-
while (it4 !== size) {
|
177
|
-
vch[j++] = b256[it4++];
|
178
|
-
}
|
179
|
-
return vch;
|
180
|
-
}
|
181
|
-
/**
|
182
|
-
* @param {string | string[]} string
|
183
|
-
*/
|
184
|
-
function decode(string) {
|
185
|
-
var buffer = decodeUnsafe(string);
|
186
|
-
if (buffer) {
|
187
|
-
return buffer;
|
188
|
-
}
|
189
|
-
throw new Error(`Non-${name} character`);
|
190
|
-
}
|
191
|
-
return {
|
192
|
-
encode: encode,
|
193
|
-
decodeUnsafe: decodeUnsafe,
|
194
|
-
decode: decode
|
195
|
-
};
|
196
|
-
}
|
197
|
-
var src = base;
|
198
|
-
var _brrp__multiformats_scope_baseX = src;
|
199
|
-
|
200
|
-
/**
|
201
|
-
* Class represents both BaseEncoder and MultibaseEncoder meaning it
|
202
|
-
* can be used to encode to multibase or base encode without multibase
|
203
|
-
* prefix.
|
204
|
-
*/
|
205
|
-
class Encoder {
|
206
|
-
name;
|
207
|
-
prefix;
|
208
|
-
baseEncode;
|
209
|
-
constructor(name, prefix, baseEncode) {
|
210
|
-
this.name = name;
|
211
|
-
this.prefix = prefix;
|
212
|
-
this.baseEncode = baseEncode;
|
213
|
-
}
|
214
|
-
encode(bytes) {
|
215
|
-
if (bytes instanceof Uint8Array) {
|
216
|
-
return `${this.prefix}${this.baseEncode(bytes)}`;
|
217
|
-
}
|
218
|
-
else {
|
219
|
-
throw Error('Unknown type, must be binary type');
|
220
|
-
}
|
221
|
-
}
|
222
|
-
}
|
223
|
-
/**
|
224
|
-
* Class represents both BaseDecoder and MultibaseDecoder so it could be used
|
225
|
-
* to decode multibases (with matching prefix) or just base decode strings
|
226
|
-
* with corresponding base encoding.
|
227
|
-
*/
|
228
|
-
class Decoder {
|
229
|
-
name;
|
230
|
-
prefix;
|
231
|
-
baseDecode;
|
232
|
-
prefixCodePoint;
|
233
|
-
constructor(name, prefix, baseDecode) {
|
234
|
-
this.name = name;
|
235
|
-
this.prefix = prefix;
|
236
|
-
const prefixCodePoint = prefix.codePointAt(0);
|
237
|
-
/* c8 ignore next 3 */
|
238
|
-
if (prefixCodePoint === undefined) {
|
239
|
-
throw new Error('Invalid prefix character');
|
240
|
-
}
|
241
|
-
this.prefixCodePoint = prefixCodePoint;
|
242
|
-
this.baseDecode = baseDecode;
|
243
|
-
}
|
244
|
-
decode(text) {
|
245
|
-
if (typeof text === 'string') {
|
246
|
-
if (text.codePointAt(0) !== this.prefixCodePoint) {
|
247
|
-
throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
|
248
|
-
}
|
249
|
-
return this.baseDecode(text.slice(this.prefix.length));
|
250
|
-
}
|
251
|
-
else {
|
252
|
-
throw Error('Can only multibase decode strings');
|
253
|
-
}
|
254
|
-
}
|
255
|
-
or(decoder) {
|
256
|
-
return or(this, decoder);
|
257
|
-
}
|
258
|
-
}
|
259
|
-
class ComposedDecoder {
|
260
|
-
decoders;
|
261
|
-
constructor(decoders) {
|
262
|
-
this.decoders = decoders;
|
263
|
-
}
|
264
|
-
or(decoder) {
|
265
|
-
return or(this, decoder);
|
266
|
-
}
|
267
|
-
decode(input) {
|
268
|
-
const prefix = input[0];
|
269
|
-
const decoder = this.decoders[prefix];
|
270
|
-
if (decoder != null) {
|
271
|
-
return decoder.decode(input);
|
272
|
-
}
|
273
|
-
else {
|
274
|
-
throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);
|
275
|
-
}
|
276
|
-
}
|
277
|
-
}
|
278
|
-
function or(left, right) {
|
279
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
280
|
-
return new ComposedDecoder({
|
281
|
-
...(left.decoders ?? { [left.prefix]: left }),
|
282
|
-
...(right.decoders ?? { [right.prefix]: right })
|
283
|
-
});
|
284
|
-
}
|
285
|
-
class Codec {
|
286
|
-
name;
|
287
|
-
prefix;
|
288
|
-
baseEncode;
|
289
|
-
baseDecode;
|
290
|
-
encoder;
|
291
|
-
decoder;
|
292
|
-
constructor(name, prefix, baseEncode, baseDecode) {
|
293
|
-
this.name = name;
|
294
|
-
this.prefix = prefix;
|
295
|
-
this.baseEncode = baseEncode;
|
296
|
-
this.baseDecode = baseDecode;
|
297
|
-
this.encoder = new Encoder(name, prefix, baseEncode);
|
298
|
-
this.decoder = new Decoder(name, prefix, baseDecode);
|
299
|
-
}
|
300
|
-
encode(input) {
|
301
|
-
return this.encoder.encode(input);
|
302
|
-
}
|
303
|
-
decode(input) {
|
304
|
-
return this.decoder.decode(input);
|
305
|
-
}
|
306
|
-
}
|
307
|
-
function from({ name, prefix, encode, decode }) {
|
308
|
-
return new Codec(name, prefix, encode, decode);
|
309
|
-
}
|
310
|
-
function baseX({ name, prefix, alphabet }) {
|
311
|
-
const { encode, decode } = _brrp__multiformats_scope_baseX(alphabet, name);
|
312
|
-
return from({
|
313
|
-
prefix,
|
314
|
-
name,
|
315
|
-
encode,
|
316
|
-
decode: (text) => coerce(decode(text))
|
317
|
-
});
|
318
|
-
}
|
319
|
-
function decode$1(string, alphabet, bitsPerChar, name) {
|
320
|
-
// Build the character lookup table:
|
321
|
-
const codes = {};
|
322
|
-
for (let i = 0; i < alphabet.length; ++i) {
|
323
|
-
codes[alphabet[i]] = i;
|
324
|
-
}
|
325
|
-
// Count the padding bytes:
|
326
|
-
let end = string.length;
|
327
|
-
while (string[end - 1] === '=') {
|
328
|
-
--end;
|
329
|
-
}
|
330
|
-
// Allocate the output:
|
331
|
-
const out = new Uint8Array((end * bitsPerChar / 8) | 0);
|
332
|
-
// Parse the data:
|
333
|
-
let bits = 0; // Number of bits currently in the buffer
|
334
|
-
let buffer = 0; // Bits waiting to be written out, MSB first
|
335
|
-
let written = 0; // Next byte to write
|
336
|
-
for (let i = 0; i < end; ++i) {
|
337
|
-
// Read one character from the string:
|
338
|
-
const value = codes[string[i]];
|
339
|
-
if (value === undefined) {
|
340
|
-
throw new SyntaxError(`Non-${name} character`);
|
341
|
-
}
|
342
|
-
// Append the bits to the buffer:
|
343
|
-
buffer = (buffer << bitsPerChar) | value;
|
344
|
-
bits += bitsPerChar;
|
345
|
-
// Write out some bits if the buffer has a byte's worth:
|
346
|
-
if (bits >= 8) {
|
347
|
-
bits -= 8;
|
348
|
-
out[written++] = 0xff & (buffer >> bits);
|
349
|
-
}
|
350
|
-
}
|
351
|
-
// Verify that we have received just enough bits:
|
352
|
-
if (bits >= bitsPerChar || (0xff & (buffer << (8 - bits))) !== 0) {
|
353
|
-
throw new SyntaxError('Unexpected end of data');
|
354
|
-
}
|
355
|
-
return out;
|
356
|
-
}
|
357
|
-
function encode$1(data, alphabet, bitsPerChar) {
|
358
|
-
const pad = alphabet[alphabet.length - 1] === '=';
|
359
|
-
const mask = (1 << bitsPerChar) - 1;
|
360
|
-
let out = '';
|
361
|
-
let bits = 0; // Number of bits currently in the buffer
|
362
|
-
let buffer = 0; // Bits waiting to be written out, MSB first
|
363
|
-
for (let i = 0; i < data.length; ++i) {
|
364
|
-
// Slurp data into the buffer:
|
365
|
-
buffer = (buffer << 8) | data[i];
|
366
|
-
bits += 8;
|
367
|
-
// Write out as much as we can:
|
368
|
-
while (bits > bitsPerChar) {
|
369
|
-
bits -= bitsPerChar;
|
370
|
-
out += alphabet[mask & (buffer >> bits)];
|
371
|
-
}
|
372
|
-
}
|
373
|
-
// Partial character:
|
374
|
-
if (bits !== 0) {
|
375
|
-
out += alphabet[mask & (buffer << (bitsPerChar - bits))];
|
376
|
-
}
|
377
|
-
// Add padding characters until we hit a byte boundary:
|
378
|
-
if (pad) {
|
379
|
-
while (((out.length * bitsPerChar) & 7) !== 0) {
|
380
|
-
out += '=';
|
381
|
-
}
|
382
|
-
}
|
383
|
-
return out;
|
384
|
-
}
|
385
|
-
/**
|
386
|
-
* RFC4648 Factory
|
387
|
-
*/
|
388
|
-
function rfc4648({ name, prefix, bitsPerChar, alphabet }) {
|
389
|
-
return from({
|
390
|
-
prefix,
|
391
|
-
name,
|
392
|
-
encode(input) {
|
393
|
-
return encode$1(input, alphabet, bitsPerChar);
|
394
|
-
},
|
395
|
-
decode(input) {
|
396
|
-
return decode$1(input, alphabet, bitsPerChar, name);
|
397
|
-
}
|
398
|
-
});
|
399
|
-
}
|
400
|
-
|
401
|
-
const base10 = baseX({
|
402
|
-
prefix: '9',
|
403
|
-
name: 'base10',
|
404
|
-
alphabet: '0123456789'
|
405
|
-
});
|
406
|
-
|
407
|
-
var base10$1 = /*#__PURE__*/Object.freeze({
|
408
|
-
__proto__: null,
|
409
|
-
base10: base10
|
410
|
-
});
|
411
|
-
|
412
|
-
const base16 = rfc4648({
|
413
|
-
prefix: 'f',
|
414
|
-
name: 'base16',
|
415
|
-
alphabet: '0123456789abcdef',
|
416
|
-
bitsPerChar: 4
|
417
|
-
});
|
418
|
-
const base16upper = rfc4648({
|
419
|
-
prefix: 'F',
|
420
|
-
name: 'base16upper',
|
421
|
-
alphabet: '0123456789ABCDEF',
|
422
|
-
bitsPerChar: 4
|
423
|
-
});
|
424
|
-
|
425
|
-
var base16$1 = /*#__PURE__*/Object.freeze({
|
426
|
-
__proto__: null,
|
427
|
-
base16: base16,
|
428
|
-
base16upper: base16upper
|
429
|
-
});
|
430
|
-
|
431
|
-
const base2 = rfc4648({
|
432
|
-
prefix: '0',
|
433
|
-
name: 'base2',
|
434
|
-
alphabet: '01',
|
435
|
-
bitsPerChar: 1
|
436
|
-
});
|
437
|
-
|
438
|
-
var base2$1 = /*#__PURE__*/Object.freeze({
|
439
|
-
__proto__: null,
|
440
|
-
base2: base2
|
441
|
-
});
|
442
|
-
|
443
|
-
const alphabet = Array.from('🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂');
|
444
|
-
const alphabetBytesToChars = (alphabet.reduce((p, c, i) => { p[i] = c; return p; }, ([])));
|
445
|
-
const alphabetCharsToBytes = (alphabet.reduce((p, c, i) => {
|
446
|
-
const codePoint = c.codePointAt(0);
|
447
|
-
if (codePoint == null) {
|
448
|
-
throw new Error(`Invalid character: ${c}`);
|
449
|
-
}
|
450
|
-
p[codePoint] = i;
|
451
|
-
return p;
|
452
|
-
}, ([])));
|
453
|
-
function encode(data) {
|
454
|
-
return data.reduce((p, c) => {
|
455
|
-
p += alphabetBytesToChars[c];
|
456
|
-
return p;
|
457
|
-
}, '');
|
458
|
-
}
|
459
|
-
function decode(str) {
|
460
|
-
const byts = [];
|
461
|
-
for (const char of str) {
|
462
|
-
const codePoint = char.codePointAt(0);
|
463
|
-
if (codePoint == null) {
|
464
|
-
throw new Error(`Invalid character: ${char}`);
|
465
|
-
}
|
466
|
-
const byt = alphabetCharsToBytes[codePoint];
|
467
|
-
if (byt == null) {
|
468
|
-
throw new Error(`Non-base256emoji character: ${char}`);
|
469
|
-
}
|
470
|
-
byts.push(byt);
|
471
|
-
}
|
472
|
-
return new Uint8Array(byts);
|
473
|
-
}
|
474
|
-
const base256emoji = from({
|
475
|
-
prefix: '🚀',
|
476
|
-
name: 'base256emoji',
|
477
|
-
encode,
|
478
|
-
decode
|
479
|
-
});
|
480
|
-
|
481
|
-
var base256emoji$1 = /*#__PURE__*/Object.freeze({
|
482
|
-
__proto__: null,
|
483
|
-
base256emoji: base256emoji
|
484
|
-
});
|
485
|
-
|
486
|
-
const base32 = rfc4648({
|
487
|
-
prefix: 'b',
|
488
|
-
name: 'base32',
|
489
|
-
alphabet: 'abcdefghijklmnopqrstuvwxyz234567',
|
490
|
-
bitsPerChar: 5
|
491
|
-
});
|
492
|
-
const base32upper = rfc4648({
|
493
|
-
prefix: 'B',
|
494
|
-
name: 'base32upper',
|
495
|
-
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567',
|
496
|
-
bitsPerChar: 5
|
497
|
-
});
|
498
|
-
const base32pad = rfc4648({
|
499
|
-
prefix: 'c',
|
500
|
-
name: 'base32pad',
|
501
|
-
alphabet: 'abcdefghijklmnopqrstuvwxyz234567=',
|
502
|
-
bitsPerChar: 5
|
503
|
-
});
|
504
|
-
const base32padupper = rfc4648({
|
505
|
-
prefix: 'C',
|
506
|
-
name: 'base32padupper',
|
507
|
-
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=',
|
508
|
-
bitsPerChar: 5
|
509
|
-
});
|
510
|
-
const base32hex = rfc4648({
|
511
|
-
prefix: 'v',
|
512
|
-
name: 'base32hex',
|
513
|
-
alphabet: '0123456789abcdefghijklmnopqrstuv',
|
514
|
-
bitsPerChar: 5
|
515
|
-
});
|
516
|
-
const base32hexupper = rfc4648({
|
517
|
-
prefix: 'V',
|
518
|
-
name: 'base32hexupper',
|
519
|
-
alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV',
|
520
|
-
bitsPerChar: 5
|
521
|
-
});
|
522
|
-
const base32hexpad = rfc4648({
|
523
|
-
prefix: 't',
|
524
|
-
name: 'base32hexpad',
|
525
|
-
alphabet: '0123456789abcdefghijklmnopqrstuv=',
|
526
|
-
bitsPerChar: 5
|
527
|
-
});
|
528
|
-
const base32hexpadupper = rfc4648({
|
529
|
-
prefix: 'T',
|
530
|
-
name: 'base32hexpadupper',
|
531
|
-
alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV=',
|
532
|
-
bitsPerChar: 5
|
533
|
-
});
|
534
|
-
const base32z = rfc4648({
|
535
|
-
prefix: 'h',
|
536
|
-
name: 'base32z',
|
537
|
-
alphabet: 'ybndrfg8ejkmcpqxot1uwisza345h769',
|
538
|
-
bitsPerChar: 5
|
539
|
-
});
|
540
|
-
|
541
|
-
var base32$1 = /*#__PURE__*/Object.freeze({
|
542
|
-
__proto__: null,
|
543
|
-
base32: base32,
|
544
|
-
base32hex: base32hex,
|
545
|
-
base32hexpad: base32hexpad,
|
546
|
-
base32hexpadupper: base32hexpadupper,
|
547
|
-
base32hexupper: base32hexupper,
|
548
|
-
base32pad: base32pad,
|
549
|
-
base32padupper: base32padupper,
|
550
|
-
base32upper: base32upper,
|
551
|
-
base32z: base32z
|
552
|
-
});
|
553
|
-
|
554
|
-
const base36 = baseX({
|
555
|
-
prefix: 'k',
|
556
|
-
name: 'base36',
|
557
|
-
alphabet: '0123456789abcdefghijklmnopqrstuvwxyz'
|
558
|
-
});
|
559
|
-
const base36upper = baseX({
|
560
|
-
prefix: 'K',
|
561
|
-
name: 'base36upper',
|
562
|
-
alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
563
|
-
});
|
564
|
-
|
565
|
-
var base36$1 = /*#__PURE__*/Object.freeze({
|
566
|
-
__proto__: null,
|
567
|
-
base36: base36,
|
568
|
-
base36upper: base36upper
|
569
|
-
});
|
570
|
-
|
571
|
-
const base58btc = baseX({
|
572
|
-
name: 'base58btc',
|
573
|
-
prefix: 'z',
|
574
|
-
alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
575
|
-
});
|
576
|
-
const base58flickr = baseX({
|
577
|
-
name: 'base58flickr',
|
578
|
-
prefix: 'Z',
|
579
|
-
alphabet: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
|
580
|
-
});
|
581
|
-
|
582
|
-
var base58 = /*#__PURE__*/Object.freeze({
|
583
|
-
__proto__: null,
|
584
|
-
base58btc: base58btc,
|
585
|
-
base58flickr: base58flickr
|
586
|
-
});
|
587
|
-
|
588
|
-
const base64 = rfc4648({
|
589
|
-
prefix: 'm',
|
590
|
-
name: 'base64',
|
591
|
-
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
|
592
|
-
bitsPerChar: 6
|
593
|
-
});
|
594
|
-
const base64pad = rfc4648({
|
595
|
-
prefix: 'M',
|
596
|
-
name: 'base64pad',
|
597
|
-
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
|
598
|
-
bitsPerChar: 6
|
599
|
-
});
|
600
|
-
const base64url = rfc4648({
|
601
|
-
prefix: 'u',
|
602
|
-
name: 'base64url',
|
603
|
-
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',
|
604
|
-
bitsPerChar: 6
|
605
|
-
});
|
606
|
-
const base64urlpad = rfc4648({
|
607
|
-
prefix: 'U',
|
608
|
-
name: 'base64urlpad',
|
609
|
-
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=',
|
610
|
-
bitsPerChar: 6
|
611
|
-
});
|
612
|
-
|
613
|
-
var base64$1 = /*#__PURE__*/Object.freeze({
|
614
|
-
__proto__: null,
|
615
|
-
base64: base64,
|
616
|
-
base64pad: base64pad,
|
617
|
-
base64url: base64url,
|
618
|
-
base64urlpad: base64urlpad
|
619
|
-
});
|
620
|
-
|
621
|
-
const base8 = rfc4648({
|
622
|
-
prefix: '7',
|
623
|
-
name: 'base8',
|
624
|
-
alphabet: '01234567',
|
625
|
-
bitsPerChar: 3
|
626
|
-
});
|
627
|
-
|
628
|
-
var base8$1 = /*#__PURE__*/Object.freeze({
|
629
|
-
__proto__: null,
|
630
|
-
base8: base8
|
631
|
-
});
|
632
|
-
|
633
|
-
const identity = from({
|
634
|
-
prefix: '\x00',
|
635
|
-
name: 'identity',
|
636
|
-
encode: (buf) => toString(buf),
|
637
|
-
decode: (str) => fromString(str)
|
638
|
-
});
|
639
|
-
|
640
|
-
var identityBase = /*#__PURE__*/Object.freeze({
|
641
|
-
__proto__: null,
|
642
|
-
identity: identity
|
643
|
-
});
|
644
|
-
|
645
|
-
new TextEncoder();
|
646
|
-
new TextDecoder();
|
647
|
-
|
648
|
-
var Protocols;
|
649
|
-
(function (Protocols) {
|
650
|
-
Protocols["Relay"] = "relay";
|
651
|
-
Protocols["Store"] = "store";
|
652
|
-
Protocols["LightPush"] = "lightpush";
|
653
|
-
Protocols["Filter"] = "filter";
|
654
|
-
})(Protocols || (Protocols = {}));
|
655
|
-
var ProtocolError;
|
656
|
-
(function (ProtocolError) {
|
657
|
-
//
|
658
|
-
// GENERAL ERRORS SECTION
|
659
|
-
//
|
660
|
-
/**
|
661
|
-
* Could not determine the origin of the fault. Best to check connectivity and try again
|
662
|
-
* */
|
663
|
-
ProtocolError["GENERIC_FAIL"] = "Generic error";
|
664
|
-
/**
|
665
|
-
* The remote peer rejected the message. Information provided by the remote peer
|
666
|
-
* is logged. Review message validity, or mitigation for `NO_PEER_AVAILABLE`
|
667
|
-
* or `DECODE_FAILED` can be used.
|
668
|
-
*/
|
669
|
-
ProtocolError["REMOTE_PEER_REJECTED"] = "Remote peer rejected";
|
670
|
-
/**
|
671
|
-
* Failure to protobuf decode the message. May be due to a remote peer issue,
|
672
|
-
* ensuring that messages are sent via several peer enable mitigation of this error.
|
673
|
-
*/
|
674
|
-
ProtocolError["DECODE_FAILED"] = "Failed to decode";
|
675
|
-
/**
|
676
|
-
* Failure to find a peer with suitable protocols. This may due to a connection issue.
|
677
|
-
* Mitigation can be: retrying after a given time period, display connectivity issue
|
678
|
-
* to user or listening for `peer:connected:bootstrap` or `peer:connected:peer-exchange`
|
679
|
-
* on the connection manager before retrying.
|
680
|
-
*/
|
681
|
-
ProtocolError["NO_PEER_AVAILABLE"] = "No peer available";
|
682
|
-
/**
|
683
|
-
* Failure to find a stream to the peer. This may be because the connection with the peer is not still alive.
|
684
|
-
* Mitigation can be: retrying after a given time period, or mitigation for `NO_PEER_AVAILABLE` can be used.
|
685
|
-
*/
|
686
|
-
ProtocolError["NO_STREAM_AVAILABLE"] = "No stream available";
|
687
|
-
/**
|
688
|
-
* The remote peer did not behave as expected. Mitigation for `NO_PEER_AVAILABLE`
|
689
|
-
* or `DECODE_FAILED` can be used.
|
690
|
-
*/
|
691
|
-
ProtocolError["NO_RESPONSE"] = "No response received";
|
692
|
-
//
|
693
|
-
// SEND ERRORS SECTION
|
694
|
-
//
|
695
|
-
/**
|
696
|
-
* Failure to protobuf encode the message. This is not recoverable and needs
|
697
|
-
* further investigation.
|
698
|
-
*/
|
699
|
-
ProtocolError["ENCODE_FAILED"] = "Failed to encode";
|
700
|
-
/**
|
701
|
-
* The message payload is empty, making the message invalid. Ensure that a non-empty
|
702
|
-
* payload is set on the outgoing message.
|
703
|
-
*/
|
704
|
-
ProtocolError["EMPTY_PAYLOAD"] = "Payload is empty";
|
705
|
-
/**
|
706
|
-
* The message size is above the maximum message size allowed on the Waku Network.
|
707
|
-
* Compressing the message or using an alternative strategy for large messages is recommended.
|
708
|
-
*/
|
709
|
-
ProtocolError["SIZE_TOO_BIG"] = "Size is too big";
|
710
|
-
/**
|
711
|
-
* The PubsubTopic passed to the send function is not configured on the Waku node.
|
712
|
-
* Please ensure that the PubsubTopic is used when initializing the Waku node.
|
713
|
-
*/
|
714
|
-
ProtocolError["TOPIC_NOT_CONFIGURED"] = "Topic not configured";
|
715
|
-
/**
|
716
|
-
* Fails when
|
717
|
-
*/
|
718
|
-
ProtocolError["STREAM_ABORTED"] = "Stream aborted";
|
719
|
-
/**
|
720
|
-
* General proof generation error message.
|
721
|
-
* nwaku: https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/group_manager/group_manager_base.nim#L201C19-L201C42
|
722
|
-
*/
|
723
|
-
ProtocolError["RLN_PROOF_GENERATION"] = "Proof generation failed";
|
724
|
-
//
|
725
|
-
// RECEIVE ERRORS SECTION
|
726
|
-
//
|
727
|
-
/**
|
728
|
-
* The pubsub topic configured on the decoder does not match the pubsub topic setup on the protocol.
|
729
|
-
* Ensure that the pubsub topic used for decoder creation is the same as the one used for protocol.
|
730
|
-
*/
|
731
|
-
ProtocolError["TOPIC_DECODER_MISMATCH"] = "Topic decoder mismatch";
|
732
|
-
/**
|
733
|
-
* The topics passed in the decoders do not match each other, or don't exist at all.
|
734
|
-
* Ensure that all the pubsub topics used in the decoders are valid and match each other.
|
735
|
-
*/
|
736
|
-
ProtocolError["INVALID_DECODER_TOPICS"] = "Invalid decoder topics";
|
737
|
-
})(ProtocolError || (ProtocolError = {}));
|
738
|
-
|
739
|
-
var Tags;
|
740
|
-
(function (Tags) {
|
741
|
-
Tags["BOOTSTRAP"] = "bootstrap";
|
742
|
-
Tags["PEER_EXCHANGE"] = "peer-exchange";
|
743
|
-
Tags["LOCAL"] = "local-peer-cache";
|
744
|
-
})(Tags || (Tags = {}));
|
745
|
-
var EPeersByDiscoveryEvents;
|
746
|
-
(function (EPeersByDiscoveryEvents) {
|
747
|
-
EPeersByDiscoveryEvents["PEER_DISCOVERY_BOOTSTRAP"] = "peer:discovery:bootstrap";
|
748
|
-
EPeersByDiscoveryEvents["PEER_DISCOVERY_PEER_EXCHANGE"] = "peer:discovery:peer-exchange";
|
749
|
-
EPeersByDiscoveryEvents["PEER_CONNECT_BOOTSTRAP"] = "peer:connected:bootstrap";
|
750
|
-
EPeersByDiscoveryEvents["PEER_CONNECT_PEER_EXCHANGE"] = "peer:connected:peer-exchange";
|
751
|
-
})(EPeersByDiscoveryEvents || (EPeersByDiscoveryEvents = {}));
|
752
|
-
var EConnectionStateEvents;
|
753
|
-
(function (EConnectionStateEvents) {
|
754
|
-
EConnectionStateEvents["CONNECTION_STATUS"] = "waku:connection";
|
755
|
-
})(EConnectionStateEvents || (EConnectionStateEvents = {}));
|
756
|
-
|
757
|
-
var HealthStatusChangeEvents;
|
758
|
-
(function (HealthStatusChangeEvents) {
|
759
|
-
HealthStatusChangeEvents["StatusChange"] = "health:change";
|
760
|
-
})(HealthStatusChangeEvents || (HealthStatusChangeEvents = {}));
|
761
|
-
var HealthStatus;
|
762
|
-
(function (HealthStatus) {
|
763
|
-
HealthStatus["Unhealthy"] = "Unhealthy";
|
764
|
-
HealthStatus["MinimallyHealthy"] = "MinimallyHealthy";
|
765
|
-
HealthStatus["SufficientlyHealthy"] = "SufficientlyHealthy";
|
766
|
-
})(HealthStatus || (HealthStatus = {}));
|
767
|
-
|
768
|
-
function getDefaultExportFromCjs (x) {
|
769
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
770
|
-
}
|
771
|
-
|
772
|
-
var browser = {exports: {}};
|
773
|
-
|
774
|
-
/**
|
775
|
-
* Helpers.
|
776
|
-
*/
|
777
|
-
|
778
|
-
var ms;
|
779
|
-
var hasRequiredMs;
|
780
|
-
|
781
|
-
function requireMs () {
|
782
|
-
if (hasRequiredMs) return ms;
|
783
|
-
hasRequiredMs = 1;
|
784
|
-
var s = 1000;
|
785
|
-
var m = s * 60;
|
786
|
-
var h = m * 60;
|
787
|
-
var d = h * 24;
|
788
|
-
var w = d * 7;
|
789
|
-
var y = d * 365.25;
|
790
|
-
|
791
|
-
/**
|
792
|
-
* Parse or format the given `val`.
|
793
|
-
*
|
794
|
-
* Options:
|
795
|
-
*
|
796
|
-
* - `long` verbose formatting [false]
|
797
|
-
*
|
798
|
-
* @param {String|Number} val
|
799
|
-
* @param {Object} [options]
|
800
|
-
* @throws {Error} throw an error if val is not a non-empty string or a number
|
801
|
-
* @return {String|Number}
|
802
|
-
* @api public
|
803
|
-
*/
|
804
|
-
|
805
|
-
ms = function (val, options) {
|
806
|
-
options = options || {};
|
807
|
-
var type = typeof val;
|
808
|
-
if (type === 'string' && val.length > 0) {
|
809
|
-
return parse(val);
|
810
|
-
} else if (type === 'number' && isFinite(val)) {
|
811
|
-
return options.long ? fmtLong(val) : fmtShort(val);
|
812
|
-
}
|
813
|
-
throw new Error(
|
814
|
-
'val is not a non-empty string or a valid number. val=' +
|
815
|
-
JSON.stringify(val)
|
816
|
-
);
|
817
|
-
};
|
818
|
-
|
819
|
-
/**
|
820
|
-
* Parse the given `str` and return milliseconds.
|
821
|
-
*
|
822
|
-
* @param {String} str
|
823
|
-
* @return {Number}
|
824
|
-
* @api private
|
825
|
-
*/
|
826
|
-
|
827
|
-
function parse(str) {
|
828
|
-
str = String(str);
|
829
|
-
if (str.length > 100) {
|
830
|
-
return;
|
831
|
-
}
|
832
|
-
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
833
|
-
str
|
834
|
-
);
|
835
|
-
if (!match) {
|
836
|
-
return;
|
837
|
-
}
|
838
|
-
var n = parseFloat(match[1]);
|
839
|
-
var type = (match[2] || 'ms').toLowerCase();
|
840
|
-
switch (type) {
|
841
|
-
case 'years':
|
842
|
-
case 'year':
|
843
|
-
case 'yrs':
|
844
|
-
case 'yr':
|
845
|
-
case 'y':
|
846
|
-
return n * y;
|
847
|
-
case 'weeks':
|
848
|
-
case 'week':
|
849
|
-
case 'w':
|
850
|
-
return n * w;
|
851
|
-
case 'days':
|
852
|
-
case 'day':
|
853
|
-
case 'd':
|
854
|
-
return n * d;
|
855
|
-
case 'hours':
|
856
|
-
case 'hour':
|
857
|
-
case 'hrs':
|
858
|
-
case 'hr':
|
859
|
-
case 'h':
|
860
|
-
return n * h;
|
861
|
-
case 'minutes':
|
862
|
-
case 'minute':
|
863
|
-
case 'mins':
|
864
|
-
case 'min':
|
865
|
-
case 'm':
|
866
|
-
return n * m;
|
867
|
-
case 'seconds':
|
868
|
-
case 'second':
|
869
|
-
case 'secs':
|
870
|
-
case 'sec':
|
871
|
-
case 's':
|
872
|
-
return n * s;
|
873
|
-
case 'milliseconds':
|
874
|
-
case 'millisecond':
|
875
|
-
case 'msecs':
|
876
|
-
case 'msec':
|
877
|
-
case 'ms':
|
878
|
-
return n;
|
879
|
-
default:
|
880
|
-
return undefined;
|
881
|
-
}
|
882
|
-
}
|
883
|
-
|
884
|
-
/**
|
885
|
-
* Short format for `ms`.
|
886
|
-
*
|
887
|
-
* @param {Number} ms
|
888
|
-
* @return {String}
|
889
|
-
* @api private
|
890
|
-
*/
|
891
|
-
|
892
|
-
function fmtShort(ms) {
|
893
|
-
var msAbs = Math.abs(ms);
|
894
|
-
if (msAbs >= d) {
|
895
|
-
return Math.round(ms / d) + 'd';
|
896
|
-
}
|
897
|
-
if (msAbs >= h) {
|
898
|
-
return Math.round(ms / h) + 'h';
|
899
|
-
}
|
900
|
-
if (msAbs >= m) {
|
901
|
-
return Math.round(ms / m) + 'm';
|
902
|
-
}
|
903
|
-
if (msAbs >= s) {
|
904
|
-
return Math.round(ms / s) + 's';
|
905
|
-
}
|
906
|
-
return ms + 'ms';
|
907
|
-
}
|
908
|
-
|
909
|
-
/**
|
910
|
-
* Long format for `ms`.
|
911
|
-
*
|
912
|
-
* @param {Number} ms
|
913
|
-
* @return {String}
|
914
|
-
* @api private
|
915
|
-
*/
|
916
|
-
|
917
|
-
function fmtLong(ms) {
|
918
|
-
var msAbs = Math.abs(ms);
|
919
|
-
if (msAbs >= d) {
|
920
|
-
return plural(ms, msAbs, d, 'day');
|
921
|
-
}
|
922
|
-
if (msAbs >= h) {
|
923
|
-
return plural(ms, msAbs, h, 'hour');
|
924
|
-
}
|
925
|
-
if (msAbs >= m) {
|
926
|
-
return plural(ms, msAbs, m, 'minute');
|
927
|
-
}
|
928
|
-
if (msAbs >= s) {
|
929
|
-
return plural(ms, msAbs, s, 'second');
|
930
|
-
}
|
931
|
-
return ms + ' ms';
|
932
|
-
}
|
933
|
-
|
934
|
-
/**
|
935
|
-
* Pluralization helper.
|
936
|
-
*/
|
937
|
-
|
938
|
-
function plural(ms, msAbs, n, name) {
|
939
|
-
var isPlural = msAbs >= n * 1.5;
|
940
|
-
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
941
|
-
}
|
942
|
-
return ms;
|
943
|
-
}
|
944
|
-
|
945
|
-
/**
|
946
|
-
* This is the common logic for both the Node.js and web browser
|
947
|
-
* implementations of `debug()`.
|
948
|
-
*/
|
949
|
-
|
950
|
-
function setup(env) {
|
951
|
-
createDebug.debug = createDebug;
|
952
|
-
createDebug.default = createDebug;
|
953
|
-
createDebug.coerce = coerce;
|
954
|
-
createDebug.disable = disable;
|
955
|
-
createDebug.enable = enable;
|
956
|
-
createDebug.enabled = enabled;
|
957
|
-
createDebug.humanize = requireMs();
|
958
|
-
createDebug.destroy = destroy;
|
959
|
-
|
960
|
-
Object.keys(env).forEach(key => {
|
961
|
-
createDebug[key] = env[key];
|
962
|
-
});
|
963
|
-
|
964
|
-
/**
|
965
|
-
* The currently active debug mode names, and names to skip.
|
966
|
-
*/
|
967
|
-
|
968
|
-
createDebug.names = [];
|
969
|
-
createDebug.skips = [];
|
970
|
-
|
971
|
-
/**
|
972
|
-
* Map of special "%n" handling functions, for the debug "format" argument.
|
973
|
-
*
|
974
|
-
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
975
|
-
*/
|
976
|
-
createDebug.formatters = {};
|
977
|
-
|
978
|
-
/**
|
979
|
-
* Selects a color for a debug namespace
|
980
|
-
* @param {String} namespace The namespace string for the debug instance to be colored
|
981
|
-
* @return {Number|String} An ANSI color code for the given namespace
|
982
|
-
* @api private
|
983
|
-
*/
|
984
|
-
function selectColor(namespace) {
|
985
|
-
let hash = 0;
|
986
|
-
|
987
|
-
for (let i = 0; i < namespace.length; i++) {
|
988
|
-
hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
|
989
|
-
hash |= 0; // Convert to 32bit integer
|
990
|
-
}
|
991
|
-
|
992
|
-
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
993
|
-
}
|
994
|
-
createDebug.selectColor = selectColor;
|
995
|
-
|
996
|
-
/**
|
997
|
-
* Create a debugger with the given `namespace`.
|
998
|
-
*
|
999
|
-
* @param {String} namespace
|
1000
|
-
* @return {Function}
|
1001
|
-
* @api public
|
1002
|
-
*/
|
1003
|
-
function createDebug(namespace) {
|
1004
|
-
let prevTime;
|
1005
|
-
let enableOverride = null;
|
1006
|
-
let namespacesCache;
|
1007
|
-
let enabledCache;
|
1008
|
-
|
1009
|
-
function debug(...args) {
|
1010
|
-
// Disabled?
|
1011
|
-
if (!debug.enabled) {
|
1012
|
-
return;
|
1013
|
-
}
|
1014
|
-
|
1015
|
-
const self = debug;
|
1016
|
-
|
1017
|
-
// Set `diff` timestamp
|
1018
|
-
const curr = Number(new Date());
|
1019
|
-
const ms = curr - (prevTime || curr);
|
1020
|
-
self.diff = ms;
|
1021
|
-
self.prev = prevTime;
|
1022
|
-
self.curr = curr;
|
1023
|
-
prevTime = curr;
|
1024
|
-
|
1025
|
-
args[0] = createDebug.coerce(args[0]);
|
1026
|
-
|
1027
|
-
if (typeof args[0] !== 'string') {
|
1028
|
-
// Anything else let's inspect with %O
|
1029
|
-
args.unshift('%O');
|
1030
|
-
}
|
1031
|
-
|
1032
|
-
// Apply any `formatters` transformations
|
1033
|
-
let index = 0;
|
1034
|
-
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
1035
|
-
// If we encounter an escaped % then don't increase the array index
|
1036
|
-
if (match === '%%') {
|
1037
|
-
return '%';
|
1038
|
-
}
|
1039
|
-
index++;
|
1040
|
-
const formatter = createDebug.formatters[format];
|
1041
|
-
if (typeof formatter === 'function') {
|
1042
|
-
const val = args[index];
|
1043
|
-
match = formatter.call(self, val);
|
1044
|
-
|
1045
|
-
// Now we need to remove `args[index]` since it's inlined in the `format`
|
1046
|
-
args.splice(index, 1);
|
1047
|
-
index--;
|
1048
|
-
}
|
1049
|
-
return match;
|
1050
|
-
});
|
1051
|
-
|
1052
|
-
// Apply env-specific formatting (colors, etc.)
|
1053
|
-
createDebug.formatArgs.call(self, args);
|
1054
|
-
|
1055
|
-
const logFn = self.log || createDebug.log;
|
1056
|
-
logFn.apply(self, args);
|
1057
|
-
}
|
1058
|
-
|
1059
|
-
debug.namespace = namespace;
|
1060
|
-
debug.useColors = createDebug.useColors();
|
1061
|
-
debug.color = createDebug.selectColor(namespace);
|
1062
|
-
debug.extend = extend;
|
1063
|
-
debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
|
1064
|
-
|
1065
|
-
Object.defineProperty(debug, 'enabled', {
|
1066
|
-
enumerable: true,
|
1067
|
-
configurable: false,
|
1068
|
-
get: () => {
|
1069
|
-
if (enableOverride !== null) {
|
1070
|
-
return enableOverride;
|
1071
|
-
}
|
1072
|
-
if (namespacesCache !== createDebug.namespaces) {
|
1073
|
-
namespacesCache = createDebug.namespaces;
|
1074
|
-
enabledCache = createDebug.enabled(namespace);
|
1075
|
-
}
|
1076
|
-
|
1077
|
-
return enabledCache;
|
1078
|
-
},
|
1079
|
-
set: v => {
|
1080
|
-
enableOverride = v;
|
1081
|
-
}
|
1082
|
-
});
|
1083
|
-
|
1084
|
-
// Env-specific initialization logic for debug instances
|
1085
|
-
if (typeof createDebug.init === 'function') {
|
1086
|
-
createDebug.init(debug);
|
1087
|
-
}
|
1088
|
-
|
1089
|
-
return debug;
|
1090
|
-
}
|
1091
|
-
|
1092
|
-
function extend(namespace, delimiter) {
|
1093
|
-
const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
|
1094
|
-
newDebug.log = this.log;
|
1095
|
-
return newDebug;
|
1096
|
-
}
|
1097
|
-
|
1098
|
-
/**
|
1099
|
-
* Enables a debug mode by namespaces. This can include modes
|
1100
|
-
* separated by a colon and wildcards.
|
1101
|
-
*
|
1102
|
-
* @param {String} namespaces
|
1103
|
-
* @api public
|
1104
|
-
*/
|
1105
|
-
function enable(namespaces) {
|
1106
|
-
createDebug.save(namespaces);
|
1107
|
-
createDebug.namespaces = namespaces;
|
1108
|
-
|
1109
|
-
createDebug.names = [];
|
1110
|
-
createDebug.skips = [];
|
1111
|
-
|
1112
|
-
const split = (typeof namespaces === 'string' ? namespaces : '')
|
1113
|
-
.trim()
|
1114
|
-
.replace(' ', ',')
|
1115
|
-
.split(',')
|
1116
|
-
.filter(Boolean);
|
1117
|
-
|
1118
|
-
for (const ns of split) {
|
1119
|
-
if (ns[0] === '-') {
|
1120
|
-
createDebug.skips.push(ns.slice(1));
|
1121
|
-
} else {
|
1122
|
-
createDebug.names.push(ns);
|
1123
|
-
}
|
1124
|
-
}
|
1125
|
-
}
|
1126
|
-
|
1127
|
-
/**
|
1128
|
-
* Checks if the given string matches a namespace template, honoring
|
1129
|
-
* asterisks as wildcards.
|
1130
|
-
*
|
1131
|
-
* @param {String} search
|
1132
|
-
* @param {String} template
|
1133
|
-
* @return {Boolean}
|
1134
|
-
*/
|
1135
|
-
function matchesTemplate(search, template) {
|
1136
|
-
let searchIndex = 0;
|
1137
|
-
let templateIndex = 0;
|
1138
|
-
let starIndex = -1;
|
1139
|
-
let matchIndex = 0;
|
1140
|
-
|
1141
|
-
while (searchIndex < search.length) {
|
1142
|
-
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {
|
1143
|
-
// Match character or proceed with wildcard
|
1144
|
-
if (template[templateIndex] === '*') {
|
1145
|
-
starIndex = templateIndex;
|
1146
|
-
matchIndex = searchIndex;
|
1147
|
-
templateIndex++; // Skip the '*'
|
1148
|
-
} else {
|
1149
|
-
searchIndex++;
|
1150
|
-
templateIndex++;
|
1151
|
-
}
|
1152
|
-
} else if (starIndex !== -1) { // eslint-disable-line no-negated-condition
|
1153
|
-
// Backtrack to the last '*' and try to match more characters
|
1154
|
-
templateIndex = starIndex + 1;
|
1155
|
-
matchIndex++;
|
1156
|
-
searchIndex = matchIndex;
|
1157
|
-
} else {
|
1158
|
-
return false; // No match
|
1159
|
-
}
|
1160
|
-
}
|
1161
|
-
|
1162
|
-
// Handle trailing '*' in template
|
1163
|
-
while (templateIndex < template.length && template[templateIndex] === '*') {
|
1164
|
-
templateIndex++;
|
1165
|
-
}
|
1166
|
-
|
1167
|
-
return templateIndex === template.length;
|
1168
|
-
}
|
1169
|
-
|
1170
|
-
/**
|
1171
|
-
* Disable debug output.
|
1172
|
-
*
|
1173
|
-
* @return {String} namespaces
|
1174
|
-
* @api public
|
1175
|
-
*/
|
1176
|
-
function disable() {
|
1177
|
-
const namespaces = [
|
1178
|
-
...createDebug.names,
|
1179
|
-
...createDebug.skips.map(namespace => '-' + namespace)
|
1180
|
-
].join(',');
|
1181
|
-
createDebug.enable('');
|
1182
|
-
return namespaces;
|
1183
|
-
}
|
1184
|
-
|
1185
|
-
/**
|
1186
|
-
* Returns true if the given mode name is enabled, false otherwise.
|
1187
|
-
*
|
1188
|
-
* @param {String} name
|
1189
|
-
* @return {Boolean}
|
1190
|
-
* @api public
|
1191
|
-
*/
|
1192
|
-
function enabled(name) {
|
1193
|
-
for (const skip of createDebug.skips) {
|
1194
|
-
if (matchesTemplate(name, skip)) {
|
1195
|
-
return false;
|
1196
|
-
}
|
1197
|
-
}
|
1198
|
-
|
1199
|
-
for (const ns of createDebug.names) {
|
1200
|
-
if (matchesTemplate(name, ns)) {
|
1201
|
-
return true;
|
1202
|
-
}
|
1203
|
-
}
|
1204
|
-
|
1205
|
-
return false;
|
1206
|
-
}
|
1207
|
-
|
1208
|
-
/**
|
1209
|
-
* Coerce `val`.
|
1210
|
-
*
|
1211
|
-
* @param {Mixed} val
|
1212
|
-
* @return {Mixed}
|
1213
|
-
* @api private
|
1214
|
-
*/
|
1215
|
-
function coerce(val) {
|
1216
|
-
if (val instanceof Error) {
|
1217
|
-
return val.stack || val.message;
|
1218
|
-
}
|
1219
|
-
return val;
|
1220
|
-
}
|
1221
|
-
|
1222
|
-
/**
|
1223
|
-
* XXX DO NOT USE. This is a temporary stub function.
|
1224
|
-
* XXX It WILL be removed in the next major release.
|
1225
|
-
*/
|
1226
|
-
function destroy() {
|
1227
|
-
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
1228
|
-
}
|
1229
|
-
|
1230
|
-
createDebug.enable(createDebug.load());
|
1231
|
-
|
1232
|
-
return createDebug;
|
1233
|
-
}
|
1234
|
-
|
1235
|
-
var common = setup;
|
1236
|
-
|
1237
|
-
/* eslint-env browser */
|
1238
|
-
|
1239
|
-
(function (module, exports) {
|
1240
|
-
/**
|
1241
|
-
* This is the web browser implementation of `debug()`.
|
1242
|
-
*/
|
1243
|
-
|
1244
|
-
exports.formatArgs = formatArgs;
|
1245
|
-
exports.save = save;
|
1246
|
-
exports.load = load;
|
1247
|
-
exports.useColors = useColors;
|
1248
|
-
exports.storage = localstorage();
|
1249
|
-
exports.destroy = (() => {
|
1250
|
-
let warned = false;
|
1251
|
-
|
1252
|
-
return () => {
|
1253
|
-
if (!warned) {
|
1254
|
-
warned = true;
|
1255
|
-
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
1256
|
-
}
|
1257
|
-
};
|
1258
|
-
})();
|
1259
|
-
|
1260
|
-
/**
|
1261
|
-
* Colors.
|
1262
|
-
*/
|
1263
|
-
|
1264
|
-
exports.colors = [
|
1265
|
-
'#0000CC',
|
1266
|
-
'#0000FF',
|
1267
|
-
'#0033CC',
|
1268
|
-
'#0033FF',
|
1269
|
-
'#0066CC',
|
1270
|
-
'#0066FF',
|
1271
|
-
'#0099CC',
|
1272
|
-
'#0099FF',
|
1273
|
-
'#00CC00',
|
1274
|
-
'#00CC33',
|
1275
|
-
'#00CC66',
|
1276
|
-
'#00CC99',
|
1277
|
-
'#00CCCC',
|
1278
|
-
'#00CCFF',
|
1279
|
-
'#3300CC',
|
1280
|
-
'#3300FF',
|
1281
|
-
'#3333CC',
|
1282
|
-
'#3333FF',
|
1283
|
-
'#3366CC',
|
1284
|
-
'#3366FF',
|
1285
|
-
'#3399CC',
|
1286
|
-
'#3399FF',
|
1287
|
-
'#33CC00',
|
1288
|
-
'#33CC33',
|
1289
|
-
'#33CC66',
|
1290
|
-
'#33CC99',
|
1291
|
-
'#33CCCC',
|
1292
|
-
'#33CCFF',
|
1293
|
-
'#6600CC',
|
1294
|
-
'#6600FF',
|
1295
|
-
'#6633CC',
|
1296
|
-
'#6633FF',
|
1297
|
-
'#66CC00',
|
1298
|
-
'#66CC33',
|
1299
|
-
'#9900CC',
|
1300
|
-
'#9900FF',
|
1301
|
-
'#9933CC',
|
1302
|
-
'#9933FF',
|
1303
|
-
'#99CC00',
|
1304
|
-
'#99CC33',
|
1305
|
-
'#CC0000',
|
1306
|
-
'#CC0033',
|
1307
|
-
'#CC0066',
|
1308
|
-
'#CC0099',
|
1309
|
-
'#CC00CC',
|
1310
|
-
'#CC00FF',
|
1311
|
-
'#CC3300',
|
1312
|
-
'#CC3333',
|
1313
|
-
'#CC3366',
|
1314
|
-
'#CC3399',
|
1315
|
-
'#CC33CC',
|
1316
|
-
'#CC33FF',
|
1317
|
-
'#CC6600',
|
1318
|
-
'#CC6633',
|
1319
|
-
'#CC9900',
|
1320
|
-
'#CC9933',
|
1321
|
-
'#CCCC00',
|
1322
|
-
'#CCCC33',
|
1323
|
-
'#FF0000',
|
1324
|
-
'#FF0033',
|
1325
|
-
'#FF0066',
|
1326
|
-
'#FF0099',
|
1327
|
-
'#FF00CC',
|
1328
|
-
'#FF00FF',
|
1329
|
-
'#FF3300',
|
1330
|
-
'#FF3333',
|
1331
|
-
'#FF3366',
|
1332
|
-
'#FF3399',
|
1333
|
-
'#FF33CC',
|
1334
|
-
'#FF33FF',
|
1335
|
-
'#FF6600',
|
1336
|
-
'#FF6633',
|
1337
|
-
'#FF9900',
|
1338
|
-
'#FF9933',
|
1339
|
-
'#FFCC00',
|
1340
|
-
'#FFCC33'
|
1341
|
-
];
|
1342
|
-
|
1343
|
-
/**
|
1344
|
-
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
1345
|
-
* and the Firebug extension (any Firefox version) are known
|
1346
|
-
* to support "%c" CSS customizations.
|
1347
|
-
*
|
1348
|
-
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
1349
|
-
*/
|
1350
|
-
|
1351
|
-
// eslint-disable-next-line complexity
|
1352
|
-
function useColors() {
|
1353
|
-
// NB: In an Electron preload script, document will be defined but not fully
|
1354
|
-
// initialized. Since we know we're in Chrome, we'll just detect this case
|
1355
|
-
// explicitly
|
1356
|
-
if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
|
1357
|
-
return true;
|
1358
|
-
}
|
1359
|
-
|
1360
|
-
// Internet Explorer and Edge do not support colors.
|
1361
|
-
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
1362
|
-
return false;
|
1363
|
-
}
|
1364
|
-
|
1365
|
-
let m;
|
1366
|
-
|
1367
|
-
// Is webkit? http://stackoverflow.com/a/16459606/376773
|
1368
|
-
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
1369
|
-
// eslint-disable-next-line no-return-assign
|
1370
|
-
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
1371
|
-
// Is firebug? http://stackoverflow.com/a/398120/376773
|
1372
|
-
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
1373
|
-
// Is firefox >= v31?
|
1374
|
-
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
1375
|
-
(typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
|
1376
|
-
// Double check webkit in userAgent just in case we are in a worker
|
1377
|
-
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
1378
|
-
}
|
1379
|
-
|
1380
|
-
/**
|
1381
|
-
* Colorize log arguments if enabled.
|
1382
|
-
*
|
1383
|
-
* @api public
|
1384
|
-
*/
|
1385
|
-
|
1386
|
-
function formatArgs(args) {
|
1387
|
-
args[0] = (this.useColors ? '%c' : '') +
|
1388
|
-
this.namespace +
|
1389
|
-
(this.useColors ? ' %c' : ' ') +
|
1390
|
-
args[0] +
|
1391
|
-
(this.useColors ? '%c ' : ' ') +
|
1392
|
-
'+' + module.exports.humanize(this.diff);
|
1393
|
-
|
1394
|
-
if (!this.useColors) {
|
1395
|
-
return;
|
1396
|
-
}
|
1397
|
-
|
1398
|
-
const c = 'color: ' + this.color;
|
1399
|
-
args.splice(1, 0, c, 'color: inherit');
|
1400
|
-
|
1401
|
-
// The final "%c" is somewhat tricky, because there could be other
|
1402
|
-
// arguments passed either before or after the %c, so we need to
|
1403
|
-
// figure out the correct index to insert the CSS into
|
1404
|
-
let index = 0;
|
1405
|
-
let lastC = 0;
|
1406
|
-
args[0].replace(/%[a-zA-Z%]/g, match => {
|
1407
|
-
if (match === '%%') {
|
1408
|
-
return;
|
1409
|
-
}
|
1410
|
-
index++;
|
1411
|
-
if (match === '%c') {
|
1412
|
-
// We only are interested in the *last* %c
|
1413
|
-
// (the user may have provided their own)
|
1414
|
-
lastC = index;
|
1415
|
-
}
|
1416
|
-
});
|
1417
|
-
|
1418
|
-
args.splice(lastC, 0, c);
|
1419
|
-
}
|
1420
|
-
|
1421
|
-
/**
|
1422
|
-
* Invokes `console.debug()` when available.
|
1423
|
-
* No-op when `console.debug` is not a "function".
|
1424
|
-
* If `console.debug` is not available, falls back
|
1425
|
-
* to `console.log`.
|
1426
|
-
*
|
1427
|
-
* @api public
|
1428
|
-
*/
|
1429
|
-
exports.log = console.debug || console.log || (() => {});
|
1430
|
-
|
1431
|
-
/**
|
1432
|
-
* Save `namespaces`.
|
1433
|
-
*
|
1434
|
-
* @param {String} namespaces
|
1435
|
-
* @api private
|
1436
|
-
*/
|
1437
|
-
function save(namespaces) {
|
1438
|
-
try {
|
1439
|
-
if (namespaces) {
|
1440
|
-
exports.storage.setItem('debug', namespaces);
|
1441
|
-
} else {
|
1442
|
-
exports.storage.removeItem('debug');
|
1443
|
-
}
|
1444
|
-
} catch (error) {
|
1445
|
-
// Swallow
|
1446
|
-
// XXX (@Qix-) should we be logging these?
|
1447
|
-
}
|
1448
|
-
}
|
1449
|
-
|
1450
|
-
/**
|
1451
|
-
* Load `namespaces`.
|
1452
|
-
*
|
1453
|
-
* @return {String} returns the previously persisted debug modes
|
1454
|
-
* @api private
|
1455
|
-
*/
|
1456
|
-
function load() {
|
1457
|
-
let r;
|
1458
|
-
try {
|
1459
|
-
r = exports.storage.getItem('debug');
|
1460
|
-
} catch (error) {
|
1461
|
-
// Swallow
|
1462
|
-
// XXX (@Qix-) should we be logging these?
|
1463
|
-
}
|
1464
|
-
|
1465
|
-
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
1466
|
-
if (!r && typeof process !== 'undefined' && 'env' in process) {
|
1467
|
-
r = process.env.DEBUG;
|
1468
|
-
}
|
1469
|
-
|
1470
|
-
return r;
|
1471
|
-
}
|
1472
|
-
|
1473
|
-
/**
|
1474
|
-
* Localstorage attempts to return the localstorage.
|
1475
|
-
*
|
1476
|
-
* This is necessary because safari throws
|
1477
|
-
* when a user disables cookies/localstorage
|
1478
|
-
* and you attempt to access it.
|
1479
|
-
*
|
1480
|
-
* @return {LocalStorage}
|
1481
|
-
* @api private
|
1482
|
-
*/
|
1483
|
-
|
1484
|
-
function localstorage() {
|
1485
|
-
try {
|
1486
|
-
// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
|
1487
|
-
// The Browser also has localStorage in the global context.
|
1488
|
-
return localStorage;
|
1489
|
-
} catch (error) {
|
1490
|
-
// Swallow
|
1491
|
-
// XXX (@Qix-) should we be logging these?
|
1492
|
-
}
|
1493
|
-
}
|
1494
|
-
|
1495
|
-
module.exports = common(exports);
|
1496
|
-
|
1497
|
-
const {formatters} = module.exports;
|
1498
|
-
|
1499
|
-
/**
|
1500
|
-
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
1501
|
-
*/
|
1502
|
-
|
1503
|
-
formatters.j = function (v) {
|
1504
|
-
try {
|
1505
|
-
return JSON.stringify(v);
|
1506
|
-
} catch (error) {
|
1507
|
-
return '[UnexpectedJSONParseError]: ' + error.message;
|
1508
|
-
}
|
1509
|
-
};
|
1510
|
-
} (browser, browser.exports));
|
1511
|
-
|
1512
|
-
var browserExports = browser.exports;
|
1513
|
-
var debug = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
|
1514
|
-
|
1515
|
-
const APP_NAME = "waku";
|
1516
|
-
class Logger {
|
1517
|
-
_info;
|
1518
|
-
_warn;
|
1519
|
-
_error;
|
1520
|
-
static createDebugNamespace(level, prefix) {
|
1521
|
-
return prefix ? `${APP_NAME}:${level}:${prefix}` : `${APP_NAME}:${level}`;
|
1522
|
-
}
|
1523
|
-
constructor(prefix) {
|
1524
|
-
this._info = debug(Logger.createDebugNamespace("info", prefix));
|
1525
|
-
this._warn = debug(Logger.createDebugNamespace("warn", prefix));
|
1526
|
-
this._error = debug(Logger.createDebugNamespace("error", prefix));
|
1527
|
-
}
|
1528
|
-
get info() {
|
1529
|
-
return this._info;
|
1530
|
-
}
|
1531
|
-
get warn() {
|
1532
|
-
return this._warn;
|
1533
|
-
}
|
1534
|
-
get error() {
|
1535
|
-
return this._error;
|
1536
|
-
}
|
1537
|
-
log(level, ...args) {
|
1538
|
-
const logger = this[level];
|
1539
|
-
logger(...args);
|
1540
|
-
}
|
1541
|
-
}
|
1542
|
-
|
1543
|
-
export { EPeersByDiscoveryEvents as E, Logger as L, ProtocolError as P, Tags as T, base58btc as a, base32 as b, coerce as c, base36 as d, equals as e, EConnectionStateEvents as f, base256emoji$1 as g, base64$1 as h, base58 as i, base36$1 as j, base32$1 as k, base16$1 as l, base10$1 as m, base8$1 as n, base2$1 as o, identityBase as p };
|