@ceeblue/web-utils 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web-utils.d.ts +22 -12
- package/dist/web-utils.js +16 -13
- package/dist/web-utils.js.map +1 -1
- package/dist/web-utils.min.js +1 -1
- package/dist/web-utils.min.js.map +1 -1
- package/package.json +1 -1
package/dist/web-utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2024 Ceeblue B.V.
|
|
3
3
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
4
4
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
5
5
|
*/
|
|
@@ -37,7 +37,7 @@ declare class BinaryReader {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* Copyright
|
|
40
|
+
* Copyright 2024 Ceeblue B.V.
|
|
41
41
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
42
42
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
43
43
|
*/
|
|
@@ -70,10 +70,13 @@ declare class BinaryWriter {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
* Copyright
|
|
73
|
+
* Copyright 2024 Ceeblue B.V.
|
|
74
74
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
75
75
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
76
76
|
*/
|
|
77
|
+
/**
|
|
78
|
+
* BitReader allows to read binary data bit by bit
|
|
79
|
+
*/
|
|
77
80
|
declare class BitReader {
|
|
78
81
|
private _data;
|
|
79
82
|
private _size;
|
|
@@ -148,7 +151,7 @@ declare namespace Connect {
|
|
|
148
151
|
}
|
|
149
152
|
|
|
150
153
|
/**
|
|
151
|
-
* Copyright
|
|
154
|
+
* Copyright 2024 Ceeblue B.V.
|
|
152
155
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
153
156
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
154
157
|
*/
|
|
@@ -223,7 +226,7 @@ declare class EventEmitter {
|
|
|
223
226
|
}
|
|
224
227
|
|
|
225
228
|
/**
|
|
226
|
-
* Copyright
|
|
229
|
+
* Copyright 2024 Ceeblue B.V.
|
|
227
230
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
228
231
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
229
232
|
*/
|
|
@@ -246,7 +249,7 @@ interface ILog {
|
|
|
246
249
|
}
|
|
247
250
|
|
|
248
251
|
/**
|
|
249
|
-
* Copyright
|
|
252
|
+
* Copyright 2024 Ceeblue B.V.
|
|
250
253
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
251
254
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
252
255
|
*/
|
|
@@ -304,7 +307,7 @@ declare class NetAddress {
|
|
|
304
307
|
}
|
|
305
308
|
|
|
306
309
|
/**
|
|
307
|
-
* Copyright
|
|
310
|
+
* Copyright 2024 Ceeblue B.V.
|
|
308
311
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
309
312
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
310
313
|
*/
|
|
@@ -369,7 +372,7 @@ declare class Queue<Type> {
|
|
|
369
372
|
}
|
|
370
373
|
|
|
371
374
|
/**
|
|
372
|
-
* Copyright
|
|
375
|
+
* Copyright 2024 Ceeblue B.V.
|
|
373
376
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
374
377
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
375
378
|
*/
|
|
@@ -421,7 +424,7 @@ declare class Numbers extends Queue<number> {
|
|
|
421
424
|
}
|
|
422
425
|
|
|
423
426
|
/**
|
|
424
|
-
* Copyright
|
|
427
|
+
* Copyright 2024 Ceeblue B.V.
|
|
425
428
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
426
429
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
427
430
|
*/
|
|
@@ -539,7 +542,7 @@ declare const SDP: {
|
|
|
539
542
|
};
|
|
540
543
|
|
|
541
544
|
/**
|
|
542
|
-
* Copyright
|
|
545
|
+
* Copyright 2024 Ceeblue B.V.
|
|
543
546
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
544
547
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
545
548
|
*/
|
|
@@ -581,6 +584,12 @@ declare function objectFrom(value: any, params: {
|
|
|
581
584
|
withType: boolean;
|
|
582
585
|
noEmptyString: boolean;
|
|
583
586
|
}): object;
|
|
587
|
+
/**
|
|
588
|
+
* Returns entries from something iterable, such as a Map, Set, or Array
|
|
589
|
+
* @param value iterable input
|
|
590
|
+
* @returns An javascript object
|
|
591
|
+
*/
|
|
592
|
+
declare function objectEntries(value: any): [string, any][];
|
|
584
593
|
/**
|
|
585
594
|
* Converts various data types, such as objects, strings, exceptions, errors,
|
|
586
595
|
* or numbers, into a string representation. Since it offers a more comprehensive format,
|
|
@@ -600,6 +609,7 @@ declare function toBin(value: string): Uint8Array;
|
|
|
600
609
|
|
|
601
610
|
declare const Util_EMPTY_FUNCTION: typeof EMPTY_FUNCTION;
|
|
602
611
|
declare const Util_VERSION: typeof VERSION;
|
|
612
|
+
declare const Util_objectEntries: typeof objectEntries;
|
|
603
613
|
declare const Util_objectFrom: typeof objectFrom;
|
|
604
614
|
declare const Util_options: typeof options;
|
|
605
615
|
declare const Util_stringify: typeof stringify;
|
|
@@ -607,11 +617,11 @@ declare const Util_time: typeof time;
|
|
|
607
617
|
declare const Util_timeOrigin: typeof timeOrigin;
|
|
608
618
|
declare const Util_toBin: typeof toBin;
|
|
609
619
|
declare namespace Util {
|
|
610
|
-
export { Util_EMPTY_FUNCTION as EMPTY_FUNCTION, Util_VERSION as VERSION, Util_objectFrom as objectFrom, Util_options as options, Util_stringify as stringify, Util_time as time, Util_timeOrigin as timeOrigin, Util_toBin as toBin };
|
|
620
|
+
export { Util_EMPTY_FUNCTION as EMPTY_FUNCTION, Util_VERSION as VERSION, Util_objectEntries as objectEntries, Util_objectFrom as objectFrom, Util_options as options, Util_stringify as stringify, Util_time as time, Util_timeOrigin as timeOrigin, Util_toBin as toBin };
|
|
611
621
|
}
|
|
612
622
|
|
|
613
623
|
/**
|
|
614
|
-
* Copyright
|
|
624
|
+
* Copyright 2024 Ceeblue B.V.
|
|
615
625
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
616
626
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
617
627
|
*/
|
package/dist/web-utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2024 Ceeblue B.V.
|
|
3
3
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
4
4
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
5
5
|
*/
|
|
@@ -110,7 +110,7 @@ class BinaryReader {
|
|
|
110
110
|
return value;
|
|
111
111
|
}
|
|
112
112
|
}/**
|
|
113
|
-
* Copyright
|
|
113
|
+
* Copyright 2024 Ceeblue B.V.
|
|
114
114
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
115
115
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
116
116
|
*/
|
|
@@ -287,10 +287,13 @@ class BinaryWriter {
|
|
|
287
287
|
return this;
|
|
288
288
|
}
|
|
289
289
|
}/**
|
|
290
|
-
* Copyright
|
|
290
|
+
* Copyright 2024 Ceeblue B.V.
|
|
291
291
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
292
292
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
293
293
|
*/
|
|
294
|
+
/**
|
|
295
|
+
* BitReader allows to read binary data bit by bit
|
|
296
|
+
*/
|
|
294
297
|
class BitReader {
|
|
295
298
|
constructor(data) {
|
|
296
299
|
if ('buffer' in data) {
|
|
@@ -350,7 +353,7 @@ class BitReader {
|
|
|
350
353
|
return this.read(32);
|
|
351
354
|
}
|
|
352
355
|
}/**
|
|
353
|
-
* Copyright
|
|
356
|
+
* Copyright 2024 Ceeblue B.V.
|
|
354
357
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
355
358
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
356
359
|
*/
|
|
@@ -474,7 +477,7 @@ class NetAddress {
|
|
|
474
477
|
}
|
|
475
478
|
}
|
|
476
479
|
}/**
|
|
477
|
-
* Copyright
|
|
480
|
+
* Copyright 2024 Ceeblue B.V.
|
|
478
481
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
479
482
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
480
483
|
*/
|
|
@@ -532,7 +535,7 @@ function buildURL(type, params, protocol = 'wss') {
|
|
|
532
535
|
}
|
|
533
536
|
return url;
|
|
534
537
|
}var Connect=/*#__PURE__*/Object.freeze({__proto__:null,get Type(){return Type},buildURL:buildURL});/**
|
|
535
|
-
* Copyright
|
|
538
|
+
* Copyright 2024 Ceeblue B.V.
|
|
536
539
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
537
540
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
538
541
|
*/
|
|
@@ -675,7 +678,7 @@ class EventEmitter {
|
|
|
675
678
|
return events;
|
|
676
679
|
}
|
|
677
680
|
}/**
|
|
678
|
-
* Copyright
|
|
681
|
+
* Copyright 2024 Ceeblue B.V.
|
|
679
682
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
680
683
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
681
684
|
*/
|
|
@@ -764,7 +767,7 @@ class Queue {
|
|
|
764
767
|
return this;
|
|
765
768
|
}
|
|
766
769
|
}/**
|
|
767
|
-
* Copyright
|
|
770
|
+
* Copyright 2024 Ceeblue B.V.
|
|
768
771
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
769
772
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
770
773
|
*/
|
|
@@ -849,7 +852,7 @@ class Numbers extends Queue {
|
|
|
849
852
|
return this;
|
|
850
853
|
}
|
|
851
854
|
}/**
|
|
852
|
-
* Copyright
|
|
855
|
+
* Copyright 2024 Ceeblue B.V.
|
|
853
856
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
854
857
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
855
858
|
*/
|
|
@@ -1092,7 +1095,7 @@ const SDP = {
|
|
|
1092
1095
|
}
|
|
1093
1096
|
};
|
|
1094
1097
|
Object.freeze(SDP);/**
|
|
1095
|
-
* Copyright
|
|
1098
|
+
* Copyright 2024 Ceeblue B.V.
|
|
1096
1099
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
1097
1100
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
1098
1101
|
*/
|
|
@@ -1106,7 +1109,7 @@ const _perf = performance; // to increase x10 now performance!
|
|
|
1106
1109
|
/**
|
|
1107
1110
|
* Version of the library
|
|
1108
1111
|
*/
|
|
1109
|
-
const VERSION = '1.0.
|
|
1112
|
+
const VERSION = '1.0.1';
|
|
1110
1113
|
/**
|
|
1111
1114
|
* An empty lambda function, pratical to disable default behavior of function or events which are not expected to be null
|
|
1112
1115
|
* @example
|
|
@@ -1275,8 +1278,8 @@ function stringify(obj, params = {}) {
|
|
|
1275
1278
|
}
|
|
1276
1279
|
function toBin(value) {
|
|
1277
1280
|
return _encoder.encode(value);
|
|
1278
|
-
}var Util=/*#__PURE__*/Object.freeze({__proto__:null,EMPTY_FUNCTION:EMPTY_FUNCTION,VERSION:VERSION,objectFrom:objectFrom,options:options,stringify:stringify,time:time,timeOrigin:timeOrigin,toBin:toBin});/**
|
|
1279
|
-
* Copyright
|
|
1281
|
+
}var Util=/*#__PURE__*/Object.freeze({__proto__:null,EMPTY_FUNCTION:EMPTY_FUNCTION,VERSION:VERSION,objectEntries:objectEntries,objectFrom:objectFrom,options:options,stringify:stringify,time:time,timeOrigin:timeOrigin,toBin:toBin});/**
|
|
1282
|
+
* Copyright 2024 Ceeblue B.V.
|
|
1280
1283
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
1281
1284
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
1282
1285
|
*/
|
package/dist/web-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-utils.js","sources":["../src/BinaryReader.ts","../src/BinaryWriter.ts","../src/BitReader.ts","../src/NetAddress.ts","../src/Connect.ts","../src/EventEmitter.ts","../src/Queue.ts","../src/Numbers.ts","../src/SDP.ts","../src/Util.ts","../src/WebSocketReliable.ts"],"sourcesContent":["/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/**\n * BinaryReader allows to read binary data\n */\nexport class BinaryReader {\n private _data: Uint8Array;\n private _size: number;\n private _position: number;\n private _view: DataView;\n\n constructor(data: BufferSource) {\n this._data =\n 'buffer' in data ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength) : new Uint8Array(data);\n this._size = this._data.byteLength;\n this._position = 0;\n this._view = new DataView(this._data.buffer, this._data.byteOffset, this._size);\n }\n\n data(): Uint8Array {\n return this._data;\n }\n size(): number {\n return this._size;\n }\n\n available(): number {\n return this._size - this._position;\n }\n value(position: number = this._position): number {\n return this._data[position];\n }\n position(): number {\n return this._position;\n }\n reset(position = 0) {\n this._position = position > this._size ? this._size : position;\n }\n\n shrink(available: number): number {\n const rest = this._size - this._position;\n if (available > rest) {\n return rest;\n }\n this._size = this._position + available;\n return available;\n }\n\n next(count = 1): number {\n const rest = this._size - this._position;\n if (count > rest) {\n count = rest;\n }\n this._position += count;\n return count;\n }\n\n read8(): number {\n return this.next(1) === 1 ? this._view.getUint8(this._position - 1) : 0;\n }\n read16(): number {\n return this.next(2) === 2 ? this._view.getUint16(this._position - 2) : 0;\n }\n read24(): number {\n return this.next(3) === 3\n ? (this._view.getUint16(this._position - 3) << 8) | (this._view.getUint8(this._position - 1) & 0xff)\n : 0;\n }\n read32(): number {\n return this.next(4) === 4 ? this._view.getUint32(this._position - 4) : 0;\n }\n readFloat(): number {\n return this.next(4) === 4 ? this._view.getFloat32(this._position - 4) : 0;\n }\n readDouble(): number {\n return this.next(8) === 8 ? this._view.getFloat64(this._position - 8) : 0;\n }\n read7Bit(bytes = 5): number {\n if (bytes > 5) {\n throw Error(\"BinaryReader in JS can't decode more than 32 usefull bits\");\n }\n if (!(bytes > 0)) {\n // negation to catch NaN value\n throw Error('Have to indicate a positive number of bytes to decode');\n }\n let result = 0;\n let byte;\n do {\n byte = this.read8();\n if (!--bytes) {\n return ((result << 8) | byte) >>> 0; // Use all 8 bits from the 5th byte\n }\n result = (result << 7) | (byte & 0x7f);\n } while (byte & 0x80);\n return result;\n }\n readString(): string {\n return String.fromCharCode(...this.read(this.read7Bit()));\n }\n\n readHex(size: number): string {\n let hex = '';\n while (size--) {\n hex += ('0' + this.read8().toString(16)).slice(-2);\n }\n return hex;\n }\n\n /**\n * Read bytes, to convert bytes to string use String.fromCharCode(...reader.read(size))\n * @param {UInt32} size\n */\n read(size = this.available()): Uint8Array {\n if (this.available() < size) {\n return new Uint8Array(size); // default value = empty bytearray!\n }\n const value = this._data.subarray(this._position, this._position + size);\n this._position += size;\n return value;\n }\n}\n","/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/**\n * BinaryWriter allows to write data in its binary form\n */\nexport class BinaryWriter {\n get view(): DataView {\n if (!this._view) {\n this._view = new DataView(this._data.buffer, this._data.byteOffset, this._data.byteLength);\n }\n return this._view;\n }\n get capacity(): number {\n return this._data.byteLength;\n }\n\n private _data: Uint8Array;\n private _size: number;\n private _view?: DataView;\n private _isConst?: boolean;\n\n constructor(dataOrSize: BufferSource | number = 64, offset: number = 0, length?: number) {\n if (typeof dataOrSize == 'number') {\n // allocate new buffer\n this._data = new Uint8Array(dataOrSize);\n this._size = 0;\n } else if ('buffer' in dataOrSize) {\n // append to existing data!\n this._data = new Uint8Array(dataOrSize.buffer, dataOrSize.byteOffset, dataOrSize.byteLength);\n this._size = dataOrSize.byteLength;\n } else {\n // overrides data\n this._isConst = true; // better than boolean for memory usage\n if (length == null) {\n // /!\\ Safari does not support undefined length, so we need to use byteLength instead\n length = dataOrSize.byteLength;\n }\n this._data = new Uint8Array(dataOrSize, offset, length);\n this._size = 0;\n }\n }\n\n data(): Uint8Array {\n return new Uint8Array(this._data.buffer, this._data.byteOffset, this._size);\n }\n size(): number {\n return this._size || 0;\n }\n\n next(count = 1): BinaryWriter {\n return this.reserve((this._size += count));\n }\n clear(size = 0): BinaryWriter {\n return this.reserve((this._size = size));\n }\n\n write(data: string | ArrayLike<number>): BinaryWriter {\n this.reserve(this._size + data.length);\n if (typeof data === 'string') {\n // beware here support just the 255 first bytes (compatible Latin-1)\n for (let i = 0; i < data.length; ++i) {\n const value = data.charCodeAt(i);\n this._data[this._size++] = value > 255 ? 32 : value;\n }\n return this;\n }\n this._data.set(data, this._size);\n this._size += data.length;\n return this;\n }\n\n write8(value: number): BinaryWriter {\n if (value > 0xff) {\n // cast to 8bits range\n value = 0xff;\n }\n this.reserve(this._size + 1);\n this._data[this._size++] = value;\n return this;\n }\n\n write16(value: number): BinaryWriter {\n if (value > 0xffff) {\n // cast to 16bits range\n value = 0xffff;\n }\n this.reserve(this._size + 2);\n this.view.setUint16(this._size, value);\n this._size += 2;\n return this;\n }\n\n write24(value: number): BinaryWriter {\n if (value > 0xffffff) {\n // cast to 24bits range\n value = 0xffffff;\n }\n this.reserve(this._size + 3);\n this.view.setUint16(this._size, value >> 8);\n this.view.setUint8((this._size += 2), value & 0xff);\n ++this._size;\n return this;\n }\n write32(value: number): BinaryWriter {\n if (value > 0xffffffff) {\n // cast to 32bits range\n value = 0xffffffff;\n }\n this.reserve(this._size + 4);\n this.view.setUint32(this._size, value);\n this._size += 4;\n return this;\n }\n\n writeFloat(value: number): BinaryWriter {\n this.reserve(this._size + 4);\n this.view.setFloat32(this._size, value);\n this._size += 4;\n return this;\n }\n\n writeDouble(value: number): BinaryWriter {\n this.reserve(this._size + 8);\n this.view.setFloat64(this._size, value);\n this._size += 8;\n return this;\n }\n\n write7Bit(value: number, bytes: number = 5): BinaryWriter {\n if (bytes > 5) {\n throw Error(\"BinaryWriter in JS can't encode more than 32 usefull bits\");\n }\n if (!(bytes > 0)) {\n // negation to catch NaN value\n throw Error('Have to indicate a positive number of bytes to encode');\n }\n let bits = --bytes * 7;\n const front = value > 0xffffffff ? 0x100 : value >>> bits;\n if (front) {\n ++bits;\n if (front > 0xff) {\n value = 0xffffffff;\n }\n } else {\n while ((bits -= 7) && !(value >>> bits)) {\n continue;\n }\n }\n\n while (bits > 1) {\n this.write8(0x80 | ((value >>> bits) & 0xff));\n bits -= 7;\n }\n return this.write8(value & (bits ? 0xff : 0x7f));\n }\n\n writeString(value: string): BinaryWriter {\n return this.write7Bit(value.length).write(value);\n }\n\n writeHex(value: string): BinaryWriter {\n for (let i = 0; i < value.length; i += 2) {\n this.write8(parseInt(value.substring(i, i + 2), 16));\n }\n return this;\n }\n\n reserve(size: number): BinaryWriter {\n if (!this._data) {\n throw new Error('buffer not writable');\n }\n if (size <= this._data.byteLength) {\n return this;\n }\n if (this._isConst) {\n throw new Error('writing exceeds maximum ' + this._data.byteLength + ' bytes limit');\n }\n\n --size;\n size |= size >> 1;\n size |= size >> 2;\n size |= size >> 4;\n size |= size >> 8;\n size |= size >> 16;\n ++size;\n\n const data = new Uint8Array(size);\n data.set(this._data); // copy old buffer!\n this._data = data;\n this._view = undefined; // release view\n return this;\n }\n}\n","/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n\nexport class BitReader {\n private _data: Uint8Array;\n private _size: number;\n private _position: number;\n private _bit: number;\n\n constructor(data: BufferSource) {\n if ('buffer' in data) {\n this._data = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n } else {\n this._data = new Uint8Array(data);\n }\n this._size = this._data.byteLength;\n this._position = 0;\n this._bit = 0;\n }\n\n data(): Uint8Array {\n return this._data;\n }\n size(): number {\n return this._size;\n }\n available(): number {\n return (this._size - this._position) * 8 - this._bit;\n }\n\n next(count = 1): number {\n let gotten = 0;\n while (this._position !== this._size && count--) {\n ++gotten;\n if (++this._bit === 8) {\n this._bit = 0;\n ++this._position;\n }\n }\n return gotten;\n }\n read(count = 1): number {\n let result = 0;\n while (this._position !== this._size && count--) {\n result <<= 1;\n if (this._data[this._position] & (0x80 >> this._bit++)) {\n result |= 1;\n }\n if (this._bit === 8) {\n this._bit = 0;\n ++this._position;\n }\n }\n return result;\n }\n read8(): number {\n return this.read(8);\n }\n read16(): number {\n return this.read(16);\n }\n read24(): number {\n return this.read(24);\n }\n read32(): number {\n return this.read(32);\n }\n}\n\nexport function readExpGolomb(reader: BitReader): number {\n let i = 0;\n while (reader.available() && !reader.read()) {\n ++i;\n }\n const result = reader.read(i);\n if (i > 15) {\n console.warn('Exponential-Golomb code exceeding unsigned 16 bits');\n return 0;\n }\n return result + (1 << i) - 1;\n}\n","/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n\n/**\n * Help class to manipulate and parse a net address. The Address can be only the domain field,\n * or a URL format with protocol and path part `(http://)domain(:port/path)`\n * @example\n * const address = new Address('nl-ams-42.live.ceeblue.tv:80');\n * console.log(address.domain) // 'nl-ams-42.live.ceeblue.tv'\n * console.log(address.port) // '80'\n * console.log(address) // 'nl-ams-42.live.ceeblue.tv:80'\n */\nexport class NetAddress {\n /**\n * Static help function to build an end point from an address `(proto://)domain(:port/path)`\n *\n * Mainly it fix the protocol, in addition if:\n * - the address passed is securized (TLS) and protocol is not => it tries to fix protocol to get its securize version\n * - the address passed is non securized and protocol is (TLS) => it tries to fix protocol to get its unsecurized version\n * @param protocol protocol to set in the end point returned\n * @param address string address to fix with protocol as indicated\n * @returns the end point built\n * @example\n * console.log(NetAddress.fixProtocol('ws','http://domain/path')) // 'ws://domain/path'\n * console.log(NetAddress.fixProtocol('ws','https://domain/path')) // 'wss://domain/path'\n * console.log(NetAddress.fixProtocol('wss','http://domain/path')) // 'ws://domain/path'\n */\n static fixProtocol(protocol: string, address: string): string {\n const found = address.indexOf('://');\n // isolate protocol is present in address\n if (found >= 0) {\n // In this case replace by protocol in keeping SSL like given in address\n if (found > 2 && address.charAt(found - 1).toLowerCase() === 's') {\n // SSL!\n if (protocol.length <= 2 || !protocol.endsWith('s')) {\n protocol += 's'; // Add SSL\n }\n } else {\n // Not SSL!\n if (protocol.length > 2 && protocol.endsWith('s')) {\n protocol = protocol.slice(0, -1); // Remove SSL\n }\n }\n // Build host!\n address = address.substring(found + 3);\n }\n return protocol + '://' + address;\n }\n\n /**\n * The domain part from address `(http://)domain(:port/path)`\n */\n get domain(): string {\n return this._domain;\n }\n /**\n * The port part from address `(http://)domain(:port/path)`, or defaultPort if passed in NetAddress constructor\n */\n get port(): number | undefined {\n return this._port;\n }\n /**\n * @returns the string address as passed in the constructor\n */\n toString(): string {\n return this._address;\n }\n /**\n * @returns the string address as passed in the constructor\n * @override\n */\n valueOf(): string {\n return this._address;\n }\n\n private _address: string;\n private _domain: string;\n private _port?: number;\n /**\n * Build a NetAddress object and parse address\n * @param address string address to parse, accept an url format with protocol and path `(http://)domain(:port/path)`\n * @param defaultPort set a default port to use if there is no port in the string address parsed\n */\n constructor(address: string, defaultPort?: number) {\n this._address = address;\n\n // Remove Protocol\n let pos = address.indexOf('/');\n if (pos >= 0) {\n // Remove ://\n if (address.charCodeAt(pos + 1) === 47) {\n // has //\n if (pos > 0) {\n if (address.charCodeAt(pos - 1) === 58) {\n // has ://\n address = address.substring(pos + 2);\n } // something else #//\n } else {\n // otherwise starts by //\n address = address.substring(2);\n }\n } else if (!pos) {\n // starts by /, remove it\n address = address.substring(1);\n } // else something else #/\n }\n\n this._domain = address;\n this._port = defaultPort;\n\n // Parse Port\n pos = address.lastIndexOf(':');\n if (pos >= 0) {\n const port = parseInt(address.substring(pos + 1));\n if (port && port <= 0xffff) {\n this._port = port;\n this._domain = address.substring(0, pos);\n }\n } else {\n // Remove Path!\n pos = address.indexOf('/');\n if (pos >= 0) {\n this._domain = address.substring(0, pos);\n }\n }\n }\n}\n","/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\nimport { NetAddress } from './NetAddress';\n\n/**\n * Parameters of connections\n */\nexport type Params = {\n /**\n * Host to connect. Can include port, and accept also an url format with port and path,\n * it can help to force a path OR try to give a protocol preference\n */\n host: string;\n /**\n * The name of the stream to join\n */\n streamName: string;\n /**\n * Optional access token to use to join a private stream\n */\n accessToken?: string;\n /**\n * iceServer to use while connecting to a WebRTC stream\n */\n iceServer?: RTCIceServer; // Authentication value\n /**\n * Optional query to add into the generated url of connection\n */\n query?: Record<string, string>;\n};\n\n/**\n * Type of connection\n */\nexport enum Type {\n HESP = 'hesp',\n WEBRTS = 'webrts',\n WEBRTC = 'webrtc',\n META = 'meta',\n DATA = 'data'\n}\n\n/**\n * Some connection utility functions\n */\n\n/**\n * Build an URL from {@link Type | type} and {@link Params | params}\n * @param type Type of the connection wanted\n * @param params Connection parameters\n * @param protocol Optional parameter to choose the prefered protocol to connect\n * @returns The URL of connection\n */\nexport function buildURL(type: Type, params: Params, protocol: string = 'wss'): URL {\n const url = new URL(NetAddress.fixProtocol(protocol, params.host));\n\n if (url.pathname.length <= 1) {\n // build ceeblue path!\n switch (type) {\n case Type.HESP:\n url.pathname = '/hesp/' + params.streamName + '/index.json';\n break;\n case Type.WEBRTC:\n url.pathname = '/webrtc/' + params.streamName;\n break;\n case Type.WEBRTS:\n url.pathname = '/webrts/' + params.streamName;\n break;\n case Type.META:\n url.pathname = '/json_' + params.streamName + '.js';\n break;\n case Type.DATA:\n url.pathname = '/' + params.streamName + '.json';\n break;\n default:\n console.warn('Unknown url type ' + type);\n break;\n }\n } // Host has already a path! keep it unchanged, it's user intentionnal (used with some other WHIP/WHEP server?)\n if (params.accessToken) {\n url.searchParams.set('id', params.accessToken);\n }\n\n for (const key in params.query) {\n url.searchParams.set(key, params.query[key]);\n }\n return url;\n}\n","/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n\n/**\n * A advanced EventEmitter which allows to declare event as natural function in the inheriting children class,\n * function must start by `on` prefix to be recognized as an event.\n * The function can define a behavior by default, and user can choose to redefine this behavior,\n * or add an additionnal subscription for this event.\n * In addition you can unsubscribe to multiple events with an `AbortController`\n * @example\n * class Logger extends EventEmitter {\n * onLog(log:string) { console.log(log); } // behavior by default\n *\n * test() {\n * // raise event onLog\n * this.onLog('test');\n * }\n * }\n *\n * const logger = new Logger();\n * logger.test(); // displays a log 'test'\n *\n * // redefine default behavior to display nothing\n * logger.onLog = () => {}\n * logger.test(); // displays nothing\n *\n * // add an additionnal subscription\n * logger.on('log', console.log);\n * logger.test(); // displays a log 'test'\n *\n * // remove the additionnal subscription\n * logger.off('log', console.log);\n * logger.test(); // displays nothing\n *\n * // add two additionnal subscriptions with a AbortController\n * const controller = new AbortController();\n * logger.on('log', log => console.log(log), controller);\n * logger.on('log', log => console.error(log), controller);\n * logger.test(); // displays a log 'test' + an error 'test'\n *\n * // Unsubscribe all the subscription with the AbortController\n * controller.abort();\n * logger.test(); // displays nothing\n */\nexport class EventEmitter {\n private _events: Map<string, Set<Function>>;\n\n /**\n * Build our EventEmitter, usually call from children class\n */\n constructor() {\n this._events = new Map();\n // Fill events with events as defined!\n let proto = Object.getPrototypeOf(this);\n while (proto && proto !== Object.prototype) {\n for (const name of Object.getOwnPropertyNames(proto)) {\n if (name.length < 3 || !name.startsWith('on')) {\n continue;\n }\n if (proto[name] instanceof Function) {\n const events = new Set<Function>();\n this._events.set(name.substring(2).toLowerCase(), events);\n let defaultEvent = proto[name];\n Object.defineProperties(this, {\n [name]: {\n get:\n () =>\n (...args: unknown[]) => {\n // Call default event if not null (can happen in JS usage)\n if (defaultEvent) {\n defaultEvent.call(this, ...args);\n }\n // Call subscribers\n for (const event of events) {\n event(...args);\n }\n },\n set: (value: Function | undefined) => {\n // Assign a default behavior!\n defaultEvent = value;\n }\n }\n });\n }\n }\n proto = Object.getPrototypeOf(proto);\n }\n }\n\n /**\n * Event subscription\n * @param name Name of event without the `on` prefix (ex: `log` to `onLog` event declared)\n * @param event Subscriber Function\n * @param abort Optional `AbortController` to stop this or multiple subscriptions in same time\n */\n on(name: string, event: Function, abort?: AbortController) {\n if (!event) {\n throw Error('event to subscribe cannot be null');\n }\n const events = this._event(name);\n events.add(event);\n if (abort) {\n abort.signal.addEventListener('abort', () => {\n events.delete(event);\n });\n }\n }\n\n /**\n * Event subscription only one time, once time fired it's automatically unsubscribe\n * @param name Name of event without the `on` prefix (ex: `log` to `onLog` event declared)\n * @param event Subscriber Function\n * @param abort Optional `AbortController` to stop this or multiple subscriptions in same time\n */\n once(name: string, event: Function, abort?: AbortController) {\n if (!event) {\n throw Error('event to subscribe cannot be null');\n }\n const events = this._event(name);\n events.add(() => {\n events.delete(event); // delete from events\n event(); // execute event\n });\n if (abort) {\n abort.signal.addEventListener('abort', () => {\n events.delete(event);\n });\n }\n }\n\n /**\n * Event unsubscription\n * @param name Name of event without the 'on' prefix (ex: 'log' to 'onLog' event declared)\n * @param event Unsubscriber Function, must be the one passed to {@link on} or {@link once} subscription methods\n */\n off(name: string, event: Function) {\n if (!event) {\n throw Error('event to unsubscribe cannot be null');\n }\n this._event(name).delete(event);\n }\n\n private _event(name: string): Set<Function> {\n const events = this._events.get(name.toLowerCase());\n if (!events) {\n throw Error('No event on' + name + ' on class ' + this.constructor.name);\n }\n return events;\n }\n}\n","/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n\n/**\n * Queue typed similar to a {@link https://en.cppreference.com/w/cpp/container/queue | std::queue<Type>} with possibility to limit the capacity like a FIFO\n * @example\n * const queue = new Queue<number>(2);\n * queue.push(1); // [1]\n * queue.push(2); // [1,2]\n * queue.push(3); // [2,3] 1 has been removed to respect 2 capacity\n */\nexport class Queue<Type> {\n /**\n * Number of element in the queue\n */\n get size(): number {\n return this._queue.length;\n }\n\n /**\n * Maximum capacity for the queue, if not set queue has unlimited capacity\n */\n get capacity(): number | undefined {\n return this._capacity;\n }\n\n /**\n * Set a maximum capacity for the queue,\n * if you push new value exceding this capacity the firsts are removed (FIFO)\n * if set to undefined the queue is unlimited\n */\n set capacity(value: number | undefined) {\n this._capacity = value;\n if (value != null && this._queue.length > value) {\n this._queue.splice(0, this._queue.length - value);\n }\n }\n\n /**\n * The front element\n */\n get front(): Type {\n return this._queue[0];\n }\n\n /**\n * The back element\n */\n get back(): Type {\n return this._queue[this._queue.length - 1];\n }\n\n /**\n * Iterator though queue's elements\n */\n [Symbol.iterator](): IterableIterator<Type> {\n return this._queue[Symbol.iterator]();\n }\n\n private _capacity?: number;\n private _queue: Array<Type>;\n /**\n * Instanciate a new queue object with the type passed as template\n * @param capacity if set it limits the size of the queue, any exceding element pops the first element pushed (FIFO)\n */\n constructor(capacity?: number) {\n this._capacity = capacity;\n this._queue = new Array<Type>();\n }\n\n /**\n * Push a new element in the queue\n * @param value value of the element\n * @returns this\n */\n push(value: Type): Queue<Type> {\n if (this._capacity != null && this._queue.push(value) > this._capacity) {\n this.pop();\n }\n return this;\n }\n\n /**\n * Pop the first element from the queue\n * @returns The first element removed\n */\n pop(): Type | undefined {\n return this._queue.shift();\n }\n\n /**\n * Clear all the elements, queue becomes empty\n * @returns this\n */\n clear(): Queue<Type> {\n this._queue.length = 0;\n return this;\n }\n}\n","/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n\nimport { Queue } from './Queue';\n\n/**\n * A collection of number Queue<number> with the following efficient mathematic computation:\n * - minimum value in the collection\n * - maximum value in the collection\n * - average value of the collection\n */\nexport class Numbers extends Queue<number> {\n /**\n * minimum value in the collection, or 0 if colleciton is empty\n */\n get minimum(): number {\n return this._min;\n }\n\n /**\n * maximum value in the collection, or 0 if colleciton is empty\n */\n get maximum(): number {\n return this._max;\n }\n\n /**\n * average value of the collection, or 0 if collection if empty\n */\n get average(): number {\n if (this._average == null) {\n this._average = this.size ? this._sum / this.size : 0;\n }\n return this._average;\n }\n\n private _average?: number;\n private _sum: number = 0;\n private _min: number = 0;\n private _max: number = 0;\n /**\n * Instantiate the collection of the number\n * @param capacity if set it limits the number of values stored, any exceding number pops the first number pushed (FIFO)\n */\n constructor(capacity?: number) {\n super(capacity);\n }\n\n /**\n * Push a value to the back to the collection\n * @param value number to add\n * @returns this\n */\n push(value: number): Numbers {\n if (value > this._max) {\n this._max = value;\n } else if (value < this._min) {\n this._min = value;\n }\n this._average = undefined;\n this._sum += value;\n super.push(value);\n return this;\n }\n\n /**\n * Pop the front number from the collection\n * @returns the front number removed\n */\n pop(): number | undefined {\n const front = super.pop();\n if (front === this._max) {\n this._max = Math.max(0, ...this);\n } else if (front === this._min) {\n this._min = Math.min(0, ...this);\n }\n this._average = undefined;\n this._sum -= front || 0;\n return front;\n }\n\n /**\n * Clear all the numbers, collection becomes empty\n * @returns this\n */\n clear() {\n this._min = this._max = this._sum = 0;\n super.clear();\n return this;\n }\n}\n","/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Toolkit to deal with Session Description Protocol (SDP),\n * mainly to tranform a SDP string Offer/Answer to a manipulable JS object representation\n * @example\n * const peerConnection = new RTCPeerConnection();\n * peerConnection.createOffer()\n * .then( offer =>\n * // Change offer.sdp string to a JS manipulable object\n * const sdp = SDP.fromString(offer.sdp || '');\n * // Change a property of SDP\n * sdp.v = 2; // change SDP version\n * // Reserialize to the legal SDP string format\n * offer.sdp = SDP.toString(sdp);\n * // Set SDP offer to peerConnection\n * peerConnection.setLocalDescription(offer);\n * )\n */\nexport const SDP = {\n /**\n * Unserialize SDP string to a manipulable JS object representation\n * It's an object with:\n * - root SDP properties\n * - media description iterable\n * @param lines SDP string reprensentation\n * @returns SDP object representation, iterable through media description\n * @example\n * [\n * group: \"DUNBLE 0 1\",\n * o: \"- 1699450751193623 0 IN IP4 0.0.0.0\",\n * s: \"-\",\n * t: \"0 0\",\n * v: \"0\",\n * ice-lite: \"\",\n * length: 2,\n * {\n * m: \"audio 9 UDP/TLS/RTP/SAVPF 111\",\n * c: \"IN IP4 0.0.0.0\",\n * rtcp: \"9\",\n * sendonly: \"\",\n * setup: \"passive\",\n * fingerprint: \"sha-256 51:36:ED:78:A4:9F:25:8C:39:9A:0E:A0:B4:9B:6E:04:37:FF:AD:96:93:71:43:88:2C:0B:0F:AB:6F:9A:52:B8\",\n * ice-ufrag: \"fa37\",\n * ice-pwd: \"JncCHryDsbzayy4cBWDxS2\",\n * rtcp-mux: \"\",\n * rtcp-rsize: \"\",\n * rtpmap: \"111 opus/48000/2\",\n * rtcp-fb: \"111 nack\",\n * id: \"0\",\n * fmtp: \"111 minptime=10;useinbandfec=1\",\n * candidate: \"1 1 udp 2130706431 89.105.221.108 56643 typ host\",\n * end-of-candidates: \"\"\n * },\n * {\n * m: \"video 9 UDP/TLS/RTP/SAVPF 106\",\n * c: \"IN IP4 0.0.0.0\",\n * rtcp: \"9\",\n * sendonly: \"\",\n * setup: \"passive\",\n * fingerprint: \"sha-256 51:36:ED:78:A4:9F:25:8C:39:9A:0E:A0:B4:9B:6E:04:37:FF:AD:96:93:71:43:88:2C:0B:0F:AB:6F:9A:52:B8\",\n * ice-ufrag: \"fa37\",\n * ice-pwd: \"JncCHryDsbzayy4cBWDxS2\",\n * rtcp-mux: \"\",\n * rtcp-rsize: \"\",\n * rtpmap: \"106 H264/90000\",\n * rtcp-fb: [\n * \"106 nack\",\n * \"106 goog-remb\"\n * ],\n * mid: \"1\",\n * fmtp: \"106 profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1\",\n * candidate: \"1 1 udp 2130706431 89.105.221.108 56643 typ host\",\n * end-of-candidates: \"\"\n * }\n * ]\n */\n fromString(lines: string): any {\n if (Array.isArray(lines)) {\n return lines; // already converted\n }\n const sdp = new Array<any>();\n let media: any = sdp;\n let fingerprint;\n for (let line of lines.toString().split('\\n')) {\n line = line.trim();\n if (!line) {\n continue;\n }\n\n let key = line[0];\n const value = line.substring(line.indexOf('=') + 1).trim();\n switch (key.toLowerCase()) {\n case 'a': {\n if (!value) {\n continue;\n } // empty attribute!\n key = this.addAttribute(media, value);\n // save fingerprint to repeat it in medias\n if (sdp === media && key.toLowerCase() === 'fingerprint') {\n fingerprint = media.fingerprint;\n }\n break;\n }\n case 'm':\n if (sdp.length && fingerprint && !sdp[sdp.length - 1].fingerprint) {\n media.fingerprint = fingerprint;\n }\n sdp.push((media = { m: value }));\n break;\n default:\n media[key] = value;\n }\n }\n if (sdp.length && fingerprint && !sdp[sdp.length - 1].fingerprint) {\n media.fingerprint = fingerprint;\n }\n return sdp;\n },\n\n /**\n * Serialize SDP JS object to a SDP string legal representation\n * @param sdp SDP object reprensetation\n * @returns SDP string reprensentation\n */\n toString(sdp: any): string {\n if (typeof sdp === 'string') {\n return sdp; // already converted\n }\n const medias = [];\n // https://www.cl.cam.ac.uk/~jac22/books/mm/book/node182.html\n let lines = 'v' in sdp ? 'v=' + sdp.v + '\\n' : '';\n if ('o' in sdp) {\n lines += 'o=' + sdp.o + '\\n';\n }\n if ('s' in sdp) {\n lines += 's=' + sdp.s + '\\n';\n }\n const obj: any = sdp;\n for (const key of Object.keys(sdp)) {\n if (key === 'v' || key === 'o' || key === 's') {\n continue;\n }\n const value = obj[key];\n if (value == null) {\n continue;\n } // ignore this key/value\n const index = parseInt(key);\n if (!isNaN(index)) {\n // Is a number! Media object!\n medias[index] = value;\n continue;\n }\n const count = (Array.isArray(value) && value.length) || 1; // value can be numeric!\n for (let i = 0; i < count; ++i) {\n const line = Array.isArray(value) && value.length ? value[i] : value;\n if (key.length > 1) {\n // when key is superior to 1 letter it's a attribute!\n lines += 'a=' + key;\n if (line) {\n lines += ':';\n }\n } else {\n lines += key + '=';\n }\n lines += line + '\\n';\n }\n }\n for (const media of medias) {\n lines += this.toString(media);\n }\n return lines;\n },\n\n /**\n * While set a property to a SDP object representation is possible directly,\n * we could prefer add a new property without overload a possible already existing value.\n * This function allows to add a property to our SDP representation:\n * - if the key's attribute doesn't exists yet it adds it like a simple JS property sdp[key] = value\n * - if the key's attribute exists already it morphs the value to a Array and push it inside\n * @param sdp the SDP object representation on which added the attribute\n * @param attribute the string attribut in a format \"key:value\" or just \"key\" to add an attribute without value\n * @returns the key part of the attribute added (or if value is empty it returns the same attribute as passed in argument)\n */\n addAttribute(sdp: object, attribute: string): string {\n const a = SDP.parseAttribute(attribute);\n const value = a.value ?? ''; // to allow to test if key exists even without value with if(sdp.key != null)\n const obj: any = sdp;\n const oldValue = obj[a.key];\n if (!oldValue) {\n obj[a.key] = value;\n } else if (Array.isArray(oldValue)) {\n oldValue.push(value);\n } else if (value !== oldValue) {\n obj[a.key] = [oldValue, value];\n }\n return a.key;\n },\n\n /**\n * While it's possible to delete a attribute manually on the SDP object representation with a delete sdp.key,\n * we could prefer remove only a value in a sdp.key array containing multiple values.\n * Like opposite to addAttribute this method allows to remove an unique attribute value.\n * @param sdp the SDP object representation on which removed the attribute\n * @param attribute the string attribut in a format \"key:value\" or just \"key\" to remove the whole attribute and all its values\n * @returns the key part of the attribute removed (or if value is empty it returns the same attribute as passed in argument)\n */\n removeAttribute(sdp: object, attribute: string): string {\n const a = SDP.parseAttribute(attribute);\n const obj: any = sdp;\n if (a.value === undefined) {\n delete obj[attribute];\n return attribute;\n }\n const current = obj[attribute];\n if (Array.isArray(a.value)) {\n const i = current.findIndex((current: string) => current === a.value);\n if (i >= 0) {\n current.splice(i, 1);\n }\n } else if (current === a.value) {\n delete obj[attribute];\n }\n return a.key;\n },\n\n /**\n * Parse an attribute in a format \"key:value\"\n * @param attribute string attribute to parse\n * @returns the {key, value} result, with value undefined if attribute was a \"key\" without value\n */\n parseAttribute(attribute: string): { key: string; value: string | undefined } {\n const found = attribute.indexOf(':');\n return {\n key: (found >= 0 ? attribute.substring(0, found) : attribute).trim(),\n value: found >= 0 ? attribute.substring(found + 1).trim() : undefined\n };\n }\n};\nObject.freeze(SDP);\n","/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n\nconst _decoder = new TextDecoder();\nconst _encoder = new TextEncoder();\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nconst _perf = performance; // to increase x10 now performance!\nconst __lib__version__ = '?'; // will be replaced on building by library version\n\n/**\n * Some basic utility functions\n */\n/**\n * Version of the library\n */\nexport const VERSION = __lib__version__;\n\n/**\n * An empty lambda function, pratical to disable default behavior of function or events which are not expected to be null\n * @example\n * console.log = Util.EMPTY_FUNCTION; // disable logs without breaking calls\n */\nexport const EMPTY_FUNCTION = () => {};\n\n/**\n * Efficient and high resolution timestamp in milliseconds elapsed since {@link Util.timeOrigin}\n */\nexport function time(): number {\n return Math.floor(_perf.now());\n}\n\n/**\n * Time origin represents the time when the application has started\n */\nexport function timeOrigin(): number {\n return Math.floor(_perf.now() + _perf.timeOrigin);\n}\n\n/**\n * Parse query and returns it in an easy-to-use Javascript object form\n * @param urlOrQueryOrSearch string, url, or searchParams containing query. If not set it uses `location.search` to determinate query.\n * @returns An javascript object containing each option\n */\nexport function options(\n urlOrQueryOrSearch: URL | URLSearchParams | string | object | undefined = typeof location === 'undefined'\n ? undefined\n : location\n): object {\n if (!urlOrQueryOrSearch) {\n return {};\n }\n try {\n const url: any = urlOrQueryOrSearch;\n urlOrQueryOrSearch = new URL(url).searchParams;\n } catch (e) {\n if (typeof urlOrQueryOrSearch == 'string') {\n if (urlOrQueryOrSearch.startsWith('?')) {\n urlOrQueryOrSearch = urlOrQueryOrSearch.substring(1);\n }\n urlOrQueryOrSearch = new URLSearchParams(urlOrQueryOrSearch);\n }\n }\n // works same if urlOrQueryOrSearch is null, integer, or a already object etc...\n return objectFrom(urlOrQueryOrSearch, { withType: true, noEmptyString: true });\n}\n\n/**\n * Returns an easy-to-use Javascript object something iterable, such as a Map, Set, or Array\n * @param value iterable input\n * @param params.withType `false`, if set it tries to cast string value to a JS number/boolean/undefined/null type.\n * @param params.noEmptyString `false`, if set it converts empty string value to a true boolean, usefull to allow a `if(result.key)` check for example\n * @returns An javascript object\n */\nexport function objectFrom(value: any, params: { withType: boolean; noEmptyString: boolean }): object {\n params = Object.assign({ withType: false, noEmptyString: false }, params);\n const obj: any = {};\n if (!value) {\n return obj;\n }\n for (const [key, val] of objectEntries(value)) {\n value = val;\n if (params.withType && value != null && value.substring) {\n if (value) {\n const number = Number(value);\n if (isNaN(number)) {\n switch (value.toLowerCase()) {\n case 'true':\n value = true;\n break;\n case 'false':\n value = false;\n break;\n case 'null':\n value = null;\n break;\n case 'undefined':\n value = undefined;\n break;\n }\n } else {\n value = number;\n }\n } else if (params.noEmptyString) {\n // if empty string => TRUE to allow a if(options.key) check for example\n value = true;\n }\n }\n if (obj[key]) {\n if (!Array.isArray(obj[key])) {\n obj[key] = new Array(obj[key]);\n }\n obj[key].push(value);\n } else {\n obj[key] = value;\n }\n }\n return obj;\n}\n\n/**\n * Returns entries from something iterable, such as a Map, Set, or Array\n * @param value iterable input\n * @returns An javascript object\n */\nfunction objectEntries(value: any): [string, any][] {\n if (value.entries) {\n return value.entries();\n }\n return Array.from({\n [Symbol.iterator]: function* () {\n for (const key in value) {\n yield [key, value[key]];\n }\n }\n });\n}\n\n/**\n * Converts various data types, such as objects, strings, exceptions, errors,\n * or numbers, into a string representation. Since it offers a more comprehensive format,\n * this function is preferred to `JSON.stringify()`.\n * @param obj Any objects, strings, exceptions, errors, or number\n * @param params.space `''`, allows to configure space in the string representation\n * @param params.decimal `2`, allows to choose the number of decimal to display in the string representation\n * @param params.recursive `false`, allows to serialize recursively every object value, beware if a value refers to a already parsed value an infinite loop will occur.\n * @returns the final string representation\n */\n// Online Javascript Editor for free\n// Write, Edit and Run your Javascript code using JS Online Compiler\nexport function stringify(obj: any, params: { space?: string; decimal?: number; recursive?: number } = {}): string {\n params = Object.assign({ space: ' ', decimal: 2, recursive: 1 }, params);\n if (!obj) {\n return String(obj);\n }\n const error = obj.error || obj.message;\n if (error) {\n // is a error!\n obj = error;\n }\n if (obj.toFixed) {\n return obj.toFixed(Number(params.decimal) || 0);\n }\n if (obj.substring || !params.recursive) {\n // is already a string OR has to be stringified\n return String(obj);\n }\n\n const space = params.space || '';\n\n if (Array.isArray(obj)) {\n // Array!\n let res = '';\n for (const value of obj) {\n res += (res ? ',' : '[') + space;\n res += stringify(value, Object.assign(params, { recursive: params.recursive - 1 }));\n }\n return (res += space + ']');\n }\n if (obj.byteLength != null && obj?.[Symbol.iterator]) {\n // Binary!\n return _decoder.decode(obj);\n }\n let res = '';\n for (const name in obj) {\n res += (res ? ',' : '{') + space + name + ':';\n res += stringify(obj[name], Object.assign(params, { recursive: params.recursive - 1 }));\n }\n return (res += space + '}');\n}\n\nexport function toBin(value: string): Uint8Array {\n return _encoder.encode(value);\n}\n","/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n\nimport { EventEmitter } from './EventEmitter';\n\n/**\n * The WebSocketReliable class extends WebSocket to bring up the following improvements:\n * - Fix all possible unintentional closing ways to get always a related error message, {@link onClose | onClose(error?) event}\n * - Make possible message sending while connecting. Indeed no need to wait {@link onOpen} before to send message,\n * you can open the socket and immediately send messages, it will be queue and flushs on connection etablishment\n * - Make possible a delayed connection, or a reconnection. Indeed you can create an unconnected Websocket instance\n * without passing any url argument and starts the conneciton more later with {@link WebSocketReliable.open(url) | open(url)} method\n * - Make possible to control sending/queueing message: send method take an optional queueing=true argument to\n * queue message rather send it, a futur call to flush will send it. Then queueing getter allows to handle the queue\n * if need to purge it or remove some queued message. Use it all together can help to prioritize messages or control overload.\n * @example\n * const ws = new WebSocketReliable(url);\n * ws.onClose = (error?:string) => {\n * if(error) {\n * console.error(error);\n * }\n * // reconnection attempt every seconds\n * setTimeout(() => ws.open(url), 1000);\n * }\n * ws.onMessage = (message:string) => {\n * console.log(message);\n * }\n * ws.send('hello'); // send immediatly a hello message is possible (no need to wait onOpen)\n */\nexport class WebSocketReliable extends EventEmitter {\n /**\n * @event `open` fired when socket is connected\n */\n onOpen() {}\n\n /**\n * @event `message` fired on message reception\n * @param message can be binary or string.\n * If you subscribe to the event with message as string type (and not union),\n * it means that you know that all your messages are distributed in a string format\n */\n onMessage(message: ArrayBuffer | string) {}\n\n /**\n * @event `close` fired on websocket close\n * @param error error description on an improper closure\n */\n onClose(error?: string) {\n if (error) {\n console.error(error);\n }\n }\n\n /**\n * binaryType, fix binary type to arrayBuffer\n */\n get binaryType(): BinaryType {\n return 'arraybuffer';\n }\n\n /**\n * url of connection\n */\n get url(): string {\n return this._ws?.url ?? '';\n }\n\n /**\n * extensions negociated by the server\n */\n get extensions(): string {\n return this._ws?.extensions ?? '';\n }\n\n /**\n * protocol negociated by the server\n */\n get protocol(): string {\n return this._ws?.protocol ?? '';\n }\n\n /**\n * opened equals true when connection is etablished, in other word when onOpen event is fired\n */\n get opened(): boolean {\n return this._opened;\n }\n\n /**\n * {@link https://developer.mozilla.org/docs/Web/API/WebSocket/readyState | Official websocket readyState}\n */\n get readyState(): number {\n return this._ws ? this._ws.readyState : 3;\n }\n\n /**\n * True when connection is closed, in other words when {@link onClose} event is fired\n * or when WebSocketReliable is build without url (disconnected creation)\n */\n get closed(): boolean {\n return this._closed;\n }\n\n /**\n * The number of bytes of data that were queued during calls to send() but not yet transmitted to the network\n */\n get bufferedAmount(): number {\n return this._queueingBytes + (this._ws?.bufferedAmount || 0);\n }\n\n /**\n * Queued messages from a call to send() waiting to be transmit one time websocket connection opened (or with an explicit call to flush() method)\n */\n get queueing(): Array<string | ArrayBuffer | ArrayBufferView> {\n return this._queueing;\n }\n\n private _opened: boolean;\n private _closed: boolean;\n private _queueing: Array<string | ArrayBuffer | ArrayBufferView>;\n private _queueingBytes: number;\n private _ws?: WebSocket;\n /**\n * Create a WebSocketReliable object, and open it if an url is passed in argument\n * @param url URL of the WebSocket endpoint or null to start the connection later\n */\n constructor(url?: string | URL, protocols?: string | string[]) {\n super();\n this._queueing = [];\n this._queueingBytes = 0;\n this._opened = false;\n this._closed = true;\n if (url) {\n this.open(url, protocols);\n }\n }\n\n /**\n * Open a WebSocket connection\n * @param url url of the websocket endpoint\n * @returns this\n */\n open(url: URL | string, protocols?: string | string[]) {\n this._closed = false;\n const ws = (this._ws = new WebSocket(url, protocols));\n ws.binaryType = this.binaryType;\n ws.onmessage = e => this.onMessage(e.data);\n // Add details and fix close ways\n ws.onclose = (e: CloseEvent) => {\n if (!this._opened) {\n // close during connection\n this.close(url.toString() + ' connection failed (' + String(e.reason || e.code) + ')');\n } else if (e.code === 1000 || e.code === 1005) {\n // normal disconnection from server (no error code)\n this.close(url.toString() + ' shutdown');\n } else {\n // disconnection from server\n this.close(url.toString() + ' disconnection (' + String(e.reason || e.code) + ')');\n }\n };\n // Wrap send method to queue messages until connection is established.\n ws.onopen = _ => {\n this._opened = true;\n this.flush();\n this.onOpen();\n };\n return this;\n }\n\n /**\n * Send a message\n * @param message\n * @param queueing When set it reports the sending to a more later call to flush\n * @returns this\n */\n send(message: string | ArrayBuffer | ArrayBufferView, queueing: boolean = false) {\n if (!this._ws) {\n throw Error('Open socket before to send data');\n }\n if (queueing || !this._opened) {\n this._queueing.push(message);\n this._queueingBytes += typeof message === 'string' ? message.length : message.byteLength;\n } else {\n this._ws.send(message);\n }\n return this;\n }\n\n /**\n * Send queueing messages\n */\n flush() {\n if (this._ws) {\n for (const message of this._queueing) {\n this._ws.send(message);\n }\n }\n this._queueing.length = 0;\n this._queueingBytes = 0;\n }\n\n /**\n * Close websocket\n * @param error the error reason if is not a proper close\n */\n close(error?: string) {\n if (!this._ws || this._closed) {\n return;\n }\n this._closed = true;\n this._ws.onopen = this._ws.onclose = this._ws.onmessage = null; // otherwise can receive message AFTER close!\n this._ws.close(); // Don't set to undefined to keep this._ws properties valid!\n // release resources!\n this._opened = false;\n this._queueing.length = 0;\n this._queueingBytes = 0;\n this.onClose(error);\n }\n}\n"],"names":[],"mappings":"AAAA;;;;AAIG;AACH;;AAEG;MACU,YAAY,CAAA;AAMrB,IAAA,WAAA,CAAY,IAAkB,EAAA;AAC1B,QAAA,IAAI,CAAC,KAAK;AACN,YAAA,QAAQ,IAAI,IAAI,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;QAC5G,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;AACnC,QAAA,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;KACnF;IAED,IAAI,GAAA;QACA,OAAO,IAAI,CAAC,KAAK,CAAC;KACrB;IACD,IAAI,GAAA;QACA,OAAO,IAAI,CAAC,KAAK,CAAC;KACrB;IAED,SAAS,GAAA;AACL,QAAA,OAAO,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC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AAE,CAAC;;AAEjB,QAAA,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;AACrB,QAAA,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;AAC1B,QAAA,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;AACxB,QAAA,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;KACvB;AACJ"}
|
|
1
|
+
{"version":3,"file":"web-utils.js","sources":["../src/BinaryReader.ts","../src/BinaryWriter.ts","../src/BitReader.ts","../src/NetAddress.ts","../src/Connect.ts","../src/EventEmitter.ts","../src/Queue.ts","../src/Numbers.ts","../src/SDP.ts","../src/Util.ts","../src/WebSocketReliable.ts"],"sourcesContent":["/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n\n/**\n * BinaryReader allows to read binary data\n */\nexport class BinaryReader {\n private _data: Uint8Array;\n private _size: number;\n private _position: number;\n private _view: DataView;\n\n constructor(data: BufferSource) {\n this._data =\n 'buffer' in data ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength) : new Uint8Array(data);\n this._size = this._data.byteLength;\n this._position = 0;\n this._view = new DataView(this._data.buffer, this._data.byteOffset, this._size);\n }\n\n data(): Uint8Array {\n return this._data;\n }\n size(): number {\n return this._size;\n }\n\n available(): number {\n return this._size - this._position;\n }\n value(position: number = this._position): number {\n return this._data[position];\n }\n position(): number {\n return this._position;\n }\n reset(position = 0) {\n this._position = position > this._size ? this._size : position;\n }\n\n shrink(available: number): number {\n const rest = this._size - this._position;\n if (available > rest) {\n return rest;\n }\n this._size = this._position + available;\n return available;\n }\n\n next(count = 1): number {\n const rest = this._size - this._position;\n if (count > rest) {\n count = rest;\n }\n this._position += count;\n return count;\n }\n\n read8(): number {\n return this.next(1) === 1 ? this._view.getUint8(this._position - 1) : 0;\n }\n read16(): number {\n return this.next(2) === 2 ? this._view.getUint16(this._position - 2) : 0;\n }\n read24(): number {\n return this.next(3) === 3\n ? (this._view.getUint16(this._position - 3) << 8) | (this._view.getUint8(this._position - 1) & 0xff)\n : 0;\n }\n read32(): number {\n return this.next(4) === 4 ? this._view.getUint32(this._position - 4) : 0;\n }\n readFloat(): number {\n return this.next(4) === 4 ? this._view.getFloat32(this._position - 4) : 0;\n }\n readDouble(): number {\n return this.next(8) === 8 ? this._view.getFloat64(this._position - 8) : 0;\n }\n read7Bit(bytes = 5): number {\n if (bytes > 5) {\n throw Error(\"BinaryReader in JS can't decode more than 32 usefull bits\");\n }\n if (!(bytes > 0)) {\n // negation to catch NaN value\n throw Error('Have to indicate a positive number of bytes to decode');\n }\n let result = 0;\n let byte;\n do {\n byte = this.read8();\n if (!--bytes) {\n return ((result << 8) | byte) >>> 0; // Use all 8 bits from the 5th byte\n }\n result = (result << 7) | (byte & 0x7f);\n } while (byte & 0x80);\n return result;\n }\n readString(): string {\n return String.fromCharCode(...this.read(this.read7Bit()));\n }\n\n readHex(size: number): string {\n let hex = '';\n while (size--) {\n hex += ('0' + this.read8().toString(16)).slice(-2);\n }\n return hex;\n }\n\n /**\n * Read bytes, to convert bytes to string use String.fromCharCode(...reader.read(size))\n * @param {UInt32} size\n */\n read(size = this.available()): Uint8Array {\n if (this.available() < size) {\n return new Uint8Array(size); // default value = empty bytearray!\n }\n const value = this._data.subarray(this._position, this._position + size);\n this._position += size;\n return value;\n }\n}\n","/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n\n/**\n * BinaryWriter allows to write data in its binary form\n */\nexport class BinaryWriter {\n get view(): DataView {\n if (!this._view) {\n this._view = new DataView(this._data.buffer, this._data.byteOffset, this._data.byteLength);\n }\n return this._view;\n }\n get capacity(): number {\n return this._data.byteLength;\n }\n\n private _data: Uint8Array;\n private _size: number;\n private _view?: DataView;\n private _isConst?: boolean;\n\n constructor(dataOrSize: BufferSource | number = 64, offset: number = 0, length?: number) {\n if (typeof dataOrSize == 'number') {\n // allocate new buffer\n this._data = new Uint8Array(dataOrSize);\n this._size = 0;\n } else if ('buffer' in dataOrSize) {\n // append to existing data!\n this._data = new Uint8Array(dataOrSize.buffer, dataOrSize.byteOffset, dataOrSize.byteLength);\n this._size = dataOrSize.byteLength;\n } else {\n // overrides data\n this._isConst = true; // better than boolean for memory usage\n if (length == null) {\n // /!\\ Safari does not support undefined length, so we need to use byteLength instead\n length = dataOrSize.byteLength;\n }\n this._data = new Uint8Array(dataOrSize, offset, length);\n this._size = 0;\n }\n }\n\n data(): Uint8Array {\n return new Uint8Array(this._data.buffer, this._data.byteOffset, this._size);\n }\n size(): number {\n return this._size || 0;\n }\n\n next(count = 1): BinaryWriter {\n return this.reserve((this._size += count));\n }\n clear(size = 0): BinaryWriter {\n return this.reserve((this._size = size));\n }\n\n write(data: string | ArrayLike<number>): BinaryWriter {\n this.reserve(this._size + data.length);\n if (typeof data === 'string') {\n // beware here support just the 255 first bytes (compatible Latin-1)\n for (let i = 0; i < data.length; ++i) {\n const value = data.charCodeAt(i);\n this._data[this._size++] = value > 255 ? 32 : value;\n }\n return this;\n }\n this._data.set(data, this._size);\n this._size += data.length;\n return this;\n }\n\n write8(value: number): BinaryWriter {\n if (value > 0xff) {\n // cast to 8bits range\n value = 0xff;\n }\n this.reserve(this._size + 1);\n this._data[this._size++] = value;\n return this;\n }\n\n write16(value: number): BinaryWriter {\n if (value > 0xffff) {\n // cast to 16bits range\n value = 0xffff;\n }\n this.reserve(this._size + 2);\n this.view.setUint16(this._size, value);\n this._size += 2;\n return this;\n }\n\n write24(value: number): BinaryWriter {\n if (value > 0xffffff) {\n // cast to 24bits range\n value = 0xffffff;\n }\n this.reserve(this._size + 3);\n this.view.setUint16(this._size, value >> 8);\n this.view.setUint8((this._size += 2), value & 0xff);\n ++this._size;\n return this;\n }\n write32(value: number): BinaryWriter {\n if (value > 0xffffffff) {\n // cast to 32bits range\n value = 0xffffffff;\n }\n this.reserve(this._size + 4);\n this.view.setUint32(this._size, value);\n this._size += 4;\n return this;\n }\n\n writeFloat(value: number): BinaryWriter {\n this.reserve(this._size + 4);\n this.view.setFloat32(this._size, value);\n this._size += 4;\n return this;\n }\n\n writeDouble(value: number): BinaryWriter {\n this.reserve(this._size + 8);\n this.view.setFloat64(this._size, value);\n this._size += 8;\n return this;\n }\n\n write7Bit(value: number, bytes: number = 5): BinaryWriter {\n if (bytes > 5) {\n throw Error(\"BinaryWriter in JS can't encode more than 32 usefull bits\");\n }\n if (!(bytes > 0)) {\n // negation to catch NaN value\n throw Error('Have to indicate a positive number of bytes to encode');\n }\n let bits = --bytes * 7;\n const front = value > 0xffffffff ? 0x100 : value >>> bits;\n if (front) {\n ++bits;\n if (front > 0xff) {\n value = 0xffffffff;\n }\n } else {\n while ((bits -= 7) && !(value >>> bits)) {\n continue;\n }\n }\n\n while (bits > 1) {\n this.write8(0x80 | ((value >>> bits) & 0xff));\n bits -= 7;\n }\n return this.write8(value & (bits ? 0xff : 0x7f));\n }\n\n writeString(value: string): BinaryWriter {\n return this.write7Bit(value.length).write(value);\n }\n\n writeHex(value: string): BinaryWriter {\n for (let i = 0; i < value.length; i += 2) {\n this.write8(parseInt(value.substring(i, i + 2), 16));\n }\n return this;\n }\n\n reserve(size: number): BinaryWriter {\n if (!this._data) {\n throw new Error('buffer not writable');\n }\n if (size <= this._data.byteLength) {\n return this;\n }\n if (this._isConst) {\n throw new Error('writing exceeds maximum ' + this._data.byteLength + ' bytes limit');\n }\n\n --size;\n size |= size >> 1;\n size |= size >> 2;\n size |= size >> 4;\n size |= size >> 8;\n size |= size >> 16;\n ++size;\n\n const data = new Uint8Array(size);\n data.set(this._data); // copy old buffer!\n this._data = data;\n this._view = undefined; // release view\n return this;\n }\n}\n","/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n\n/**\n * BitReader allows to read binary data bit by bit\n */\nexport class BitReader {\n private _data: Uint8Array;\n private _size: number;\n private _position: number;\n private _bit: number;\n\n constructor(data: BufferSource) {\n if ('buffer' in data) {\n this._data = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n } else {\n this._data = new Uint8Array(data);\n }\n this._size = this._data.byteLength;\n this._position = 0;\n this._bit = 0;\n }\n\n data(): Uint8Array {\n return this._data;\n }\n size(): number {\n return this._size;\n }\n available(): number {\n return (this._size - this._position) * 8 - this._bit;\n }\n\n next(count = 1): number {\n let gotten = 0;\n while (this._position !== this._size && count--) {\n ++gotten;\n if (++this._bit === 8) {\n this._bit = 0;\n ++this._position;\n }\n }\n return gotten;\n }\n read(count = 1): number {\n let result = 0;\n while (this._position !== this._size && count--) {\n result <<= 1;\n if (this._data[this._position] & (0x80 >> this._bit++)) {\n result |= 1;\n }\n if (this._bit === 8) {\n this._bit = 0;\n ++this._position;\n }\n }\n return result;\n }\n read8(): number {\n return this.read(8);\n }\n read16(): number {\n return this.read(16);\n }\n read24(): number {\n return this.read(24);\n }\n read32(): number {\n return this.read(32);\n }\n}\n\nexport function readExpGolomb(reader: BitReader): number {\n let i = 0;\n while (reader.available() && !reader.read()) {\n ++i;\n }\n const result = reader.read(i);\n if (i > 15) {\n console.warn('Exponential-Golomb code exceeding unsigned 16 bits');\n return 0;\n }\n return result + (1 << i) - 1;\n}\n","/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n\n/**\n * Help class to manipulate and parse a net address. The Address can be only the domain field,\n * or a URL format with protocol and path part `(http://)domain(:port/path)`\n * @example\n * const address = new Address('nl-ams-42.live.ceeblue.tv:80');\n * console.log(address.domain) // 'nl-ams-42.live.ceeblue.tv'\n * console.log(address.port) // '80'\n * console.log(address) // 'nl-ams-42.live.ceeblue.tv:80'\n */\nexport class NetAddress {\n /**\n * Static help function to build an end point from an address `(proto://)domain(:port/path)`\n *\n * Mainly it fix the protocol, in addition if:\n * - the address passed is securized (TLS) and protocol is not => it tries to fix protocol to get its securize version\n * - the address passed is non securized and protocol is (TLS) => it tries to fix protocol to get its unsecurized version\n * @param protocol protocol to set in the end point returned\n * @param address string address to fix with protocol as indicated\n * @returns the end point built\n * @example\n * console.log(NetAddress.fixProtocol('ws','http://domain/path')) // 'ws://domain/path'\n * console.log(NetAddress.fixProtocol('ws','https://domain/path')) // 'wss://domain/path'\n * console.log(NetAddress.fixProtocol('wss','http://domain/path')) // 'ws://domain/path'\n */\n static fixProtocol(protocol: string, address: string): string {\n const found = address.indexOf('://');\n // isolate protocol is present in address\n if (found >= 0) {\n // In this case replace by protocol in keeping SSL like given in address\n if (found > 2 && address.charAt(found - 1).toLowerCase() === 's') {\n // SSL!\n if (protocol.length <= 2 || !protocol.endsWith('s')) {\n protocol += 's'; // Add SSL\n }\n } else {\n // Not SSL!\n if (protocol.length > 2 && protocol.endsWith('s')) {\n protocol = protocol.slice(0, -1); // Remove SSL\n }\n }\n // Build host!\n address = address.substring(found + 3);\n }\n return protocol + '://' + address;\n }\n\n /**\n * The domain part from address `(http://)domain(:port/path)`\n */\n get domain(): string {\n return this._domain;\n }\n /**\n * The port part from address `(http://)domain(:port/path)`, or defaultPort if passed in NetAddress constructor\n */\n get port(): number | undefined {\n return this._port;\n }\n /**\n * @returns the string address as passed in the constructor\n */\n toString(): string {\n return this._address;\n }\n /**\n * @returns the string address as passed in the constructor\n * @override\n */\n valueOf(): string {\n return this._address;\n }\n\n private _address: string;\n private _domain: string;\n private _port?: number;\n /**\n * Build a NetAddress object and parse address\n * @param address string address to parse, accept an url format with protocol and path `(http://)domain(:port/path)`\n * @param defaultPort set a default port to use if there is no port in the string address parsed\n */\n constructor(address: string, defaultPort?: number) {\n this._address = address;\n\n // Remove Protocol\n let pos = address.indexOf('/');\n if (pos >= 0) {\n // Remove ://\n if (address.charCodeAt(pos + 1) === 47) {\n // has //\n if (pos > 0) {\n if (address.charCodeAt(pos - 1) === 58) {\n // has ://\n address = address.substring(pos + 2);\n } // something else #//\n } else {\n // otherwise starts by //\n address = address.substring(2);\n }\n } else if (!pos) {\n // starts by /, remove it\n address = address.substring(1);\n } // else something else #/\n }\n\n this._domain = address;\n this._port = defaultPort;\n\n // Parse Port\n pos = address.lastIndexOf(':');\n if (pos >= 0) {\n const port = parseInt(address.substring(pos + 1));\n if (port && port <= 0xffff) {\n this._port = port;\n this._domain = address.substring(0, pos);\n }\n } else {\n // Remove Path!\n pos = address.indexOf('/');\n if (pos >= 0) {\n this._domain = address.substring(0, pos);\n }\n }\n }\n}\n","/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\nimport { NetAddress } from './NetAddress';\n\n/**\n * Parameters of connections\n */\nexport type Params = {\n /**\n * Host to connect. Can include port, and accept also an url format with port and path,\n * it can help to force a path OR try to give a protocol preference\n */\n host: string;\n /**\n * The name of the stream to join\n */\n streamName: string;\n /**\n * Optional access token to use to join a private stream\n */\n accessToken?: string;\n /**\n * iceServer to use while connecting to a WebRTC stream\n */\n iceServer?: RTCIceServer; // Authentication value\n /**\n * Optional query to add into the generated url of connection\n */\n query?: Record<string, string>;\n};\n\n/**\n * Type of connection\n */\nexport enum Type {\n HESP = 'hesp',\n WEBRTS = 'webrts',\n WEBRTC = 'webrtc',\n META = 'meta',\n DATA = 'data'\n}\n\n/**\n * Some connection utility functions\n */\n\n/**\n * Build an URL from {@link Type | type} and {@link Params | params}\n * @param type Type of the connection wanted\n * @param params Connection parameters\n * @param protocol Optional parameter to choose the prefered protocol to connect\n * @returns The URL of connection\n */\nexport function buildURL(type: Type, params: Params, protocol: string = 'wss'): URL {\n const url = new URL(NetAddress.fixProtocol(protocol, params.host));\n\n if (url.pathname.length <= 1) {\n // build ceeblue path!\n switch (type) {\n case Type.HESP:\n url.pathname = '/hesp/' + params.streamName + '/index.json';\n break;\n case Type.WEBRTC:\n url.pathname = '/webrtc/' + params.streamName;\n break;\n case Type.WEBRTS:\n url.pathname = '/webrts/' + params.streamName;\n break;\n case Type.META:\n url.pathname = '/json_' + params.streamName + '.js';\n break;\n case Type.DATA:\n url.pathname = '/' + params.streamName + '.json';\n break;\n default:\n console.warn('Unknown url type ' + type);\n break;\n }\n } // Host has already a path! keep it unchanged, it's user intentionnal (used with some other WHIP/WHEP server?)\n if (params.accessToken) {\n url.searchParams.set('id', params.accessToken);\n }\n\n for (const key in params.query) {\n url.searchParams.set(key, params.query[key]);\n }\n return url;\n}\n","/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n\n/**\n * A advanced EventEmitter which allows to declare event as natural function in the inheriting children class,\n * function must start by `on` prefix to be recognized as an event.\n * The function can define a behavior by default, and user can choose to redefine this behavior,\n * or add an additionnal subscription for this event.\n * In addition you can unsubscribe to multiple events with an `AbortController`\n * @example\n * class Logger extends EventEmitter {\n * onLog(log:string) { console.log(log); } // behavior by default\n *\n * test() {\n * // raise event onLog\n * this.onLog('test');\n * }\n * }\n *\n * const logger = new Logger();\n * logger.test(); // displays a log 'test'\n *\n * // redefine default behavior to display nothing\n * logger.onLog = () => {}\n * logger.test(); // displays nothing\n *\n * // add an additionnal subscription\n * logger.on('log', console.log);\n * logger.test(); // displays a log 'test'\n *\n * // remove the additionnal subscription\n * logger.off('log', console.log);\n * logger.test(); // displays nothing\n *\n * // add two additionnal subscriptions with a AbortController\n * const controller = new AbortController();\n * logger.on('log', log => console.log(log), controller);\n * logger.on('log', log => console.error(log), controller);\n * logger.test(); // displays a log 'test' + an error 'test'\n *\n * // Unsubscribe all the subscription with the AbortController\n * controller.abort();\n * logger.test(); // displays nothing\n */\nexport class EventEmitter {\n private _events: Map<string, Set<Function>>;\n\n /**\n * Build our EventEmitter, usually call from children class\n */\n constructor() {\n this._events = new Map();\n // Fill events with events as defined!\n let proto = Object.getPrototypeOf(this);\n while (proto && proto !== Object.prototype) {\n for (const name of Object.getOwnPropertyNames(proto)) {\n if (name.length < 3 || !name.startsWith('on')) {\n continue;\n }\n if (proto[name] instanceof Function) {\n const events = new Set<Function>();\n this._events.set(name.substring(2).toLowerCase(), events);\n let defaultEvent = proto[name];\n Object.defineProperties(this, {\n [name]: {\n get:\n () =>\n (...args: unknown[]) => {\n // Call default event if not null (can happen in JS usage)\n if (defaultEvent) {\n defaultEvent.call(this, ...args);\n }\n // Call subscribers\n for (const event of events) {\n event(...args);\n }\n },\n set: (value: Function | undefined) => {\n // Assign a default behavior!\n defaultEvent = value;\n }\n }\n });\n }\n }\n proto = Object.getPrototypeOf(proto);\n }\n }\n\n /**\n * Event subscription\n * @param name Name of event without the `on` prefix (ex: `log` to `onLog` event declared)\n * @param event Subscriber Function\n * @param abort Optional `AbortController` to stop this or multiple subscriptions in same time\n */\n on(name: string, event: Function, abort?: AbortController) {\n if (!event) {\n throw Error('event to subscribe cannot be null');\n }\n const events = this._event(name);\n events.add(event);\n if (abort) {\n abort.signal.addEventListener('abort', () => {\n events.delete(event);\n });\n }\n }\n\n /**\n * Event subscription only one time, once time fired it's automatically unsubscribe\n * @param name Name of event without the `on` prefix (ex: `log` to `onLog` event declared)\n * @param event Subscriber Function\n * @param abort Optional `AbortController` to stop this or multiple subscriptions in same time\n */\n once(name: string, event: Function, abort?: AbortController) {\n if (!event) {\n throw Error('event to subscribe cannot be null');\n }\n const events = this._event(name);\n events.add(() => {\n events.delete(event); // delete from events\n event(); // execute event\n });\n if (abort) {\n abort.signal.addEventListener('abort', () => {\n events.delete(event);\n });\n }\n }\n\n /**\n * Event unsubscription\n * @param name Name of event without the 'on' prefix (ex: 'log' to 'onLog' event declared)\n * @param event Unsubscriber Function, must be the one passed to {@link on} or {@link once} subscription methods\n */\n off(name: string, event: Function) {\n if (!event) {\n throw Error('event to unsubscribe cannot be null');\n }\n this._event(name).delete(event);\n }\n\n private _event(name: string): Set<Function> {\n const events = this._events.get(name.toLowerCase());\n if (!events) {\n throw Error('No event on' + name + ' on class ' + this.constructor.name);\n }\n return events;\n }\n}\n","/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n\n/**\n * Queue typed similar to a {@link https://en.cppreference.com/w/cpp/container/queue | std::queue<Type>} with possibility to limit the capacity like a FIFO\n * @example\n * const queue = new Queue<number>(2);\n * queue.push(1); // [1]\n * queue.push(2); // [1,2]\n * queue.push(3); // [2,3] 1 has been removed to respect 2 capacity\n */\nexport class Queue<Type> {\n /**\n * Number of element in the queue\n */\n get size(): number {\n return this._queue.length;\n }\n\n /**\n * Maximum capacity for the queue, if not set queue has unlimited capacity\n */\n get capacity(): number | undefined {\n return this._capacity;\n }\n\n /**\n * Set a maximum capacity for the queue,\n * if you push new value exceding this capacity the firsts are removed (FIFO)\n * if set to undefined the queue is unlimited\n */\n set capacity(value: number | undefined) {\n this._capacity = value;\n if (value != null && this._queue.length > value) {\n this._queue.splice(0, this._queue.length - value);\n }\n }\n\n /**\n * The front element\n */\n get front(): Type {\n return this._queue[0];\n }\n\n /**\n * The back element\n */\n get back(): Type {\n return this._queue[this._queue.length - 1];\n }\n\n /**\n * Iterator though queue's elements\n */\n [Symbol.iterator](): IterableIterator<Type> {\n return this._queue[Symbol.iterator]();\n }\n\n private _capacity?: number;\n private _queue: Array<Type>;\n /**\n * Instanciate a new queue object with the type passed as template\n * @param capacity if set it limits the size of the queue, any exceding element pops the first element pushed (FIFO)\n */\n constructor(capacity?: number) {\n this._capacity = capacity;\n this._queue = new Array<Type>();\n }\n\n /**\n * Push a new element in the queue\n * @param value value of the element\n * @returns this\n */\n push(value: Type): Queue<Type> {\n if (this._capacity != null && this._queue.push(value) > this._capacity) {\n this.pop();\n }\n return this;\n }\n\n /**\n * Pop the first element from the queue\n * @returns The first element removed\n */\n pop(): Type | undefined {\n return this._queue.shift();\n }\n\n /**\n * Clear all the elements, queue becomes empty\n * @returns this\n */\n clear(): Queue<Type> {\n this._queue.length = 0;\n return this;\n }\n}\n","/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n\nimport { Queue } from './Queue';\n\n/**\n * A collection of number Queue<number> with the following efficient mathematic computation:\n * - minimum value in the collection\n * - maximum value in the collection\n * - average value of the collection\n */\nexport class Numbers extends Queue<number> {\n /**\n * minimum value in the collection, or 0 if colleciton is empty\n */\n get minimum(): number {\n return this._min;\n }\n\n /**\n * maximum value in the collection, or 0 if colleciton is empty\n */\n get maximum(): number {\n return this._max;\n }\n\n /**\n * average value of the collection, or 0 if collection if empty\n */\n get average(): number {\n if (this._average == null) {\n this._average = this.size ? this._sum / this.size : 0;\n }\n return this._average;\n }\n\n private _average?: number;\n private _sum: number = 0;\n private _min: number = 0;\n private _max: number = 0;\n /**\n * Instantiate the collection of the number\n * @param capacity if set it limits the number of values stored, any exceding number pops the first number pushed (FIFO)\n */\n constructor(capacity?: number) {\n super(capacity);\n }\n\n /**\n * Push a value to the back to the collection\n * @param value number to add\n * @returns this\n */\n push(value: number): Numbers {\n if (value > this._max) {\n this._max = value;\n } else if (value < this._min) {\n this._min = value;\n }\n this._average = undefined;\n this._sum += value;\n super.push(value);\n return this;\n }\n\n /**\n * Pop the front number from the collection\n * @returns the front number removed\n */\n pop(): number | undefined {\n const front = super.pop();\n if (front === this._max) {\n this._max = Math.max(0, ...this);\n } else if (front === this._min) {\n this._min = Math.min(0, ...this);\n }\n this._average = undefined;\n this._sum -= front || 0;\n return front;\n }\n\n /**\n * Clear all the numbers, collection becomes empty\n * @returns this\n */\n clear() {\n this._min = this._max = this._sum = 0;\n super.clear();\n return this;\n }\n}\n","/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Toolkit to deal with Session Description Protocol (SDP),\n * mainly to tranform a SDP string Offer/Answer to a manipulable JS object representation\n * @example\n * const peerConnection = new RTCPeerConnection();\n * peerConnection.createOffer()\n * .then( offer =>\n * // Change offer.sdp string to a JS manipulable object\n * const sdp = SDP.fromString(offer.sdp || '');\n * // Change a property of SDP\n * sdp.v = 2; // change SDP version\n * // Reserialize to the legal SDP string format\n * offer.sdp = SDP.toString(sdp);\n * // Set SDP offer to peerConnection\n * peerConnection.setLocalDescription(offer);\n * )\n */\nexport const SDP = {\n /**\n * Unserialize SDP string to a manipulable JS object representation\n * It's an object with:\n * - root SDP properties\n * - media description iterable\n * @param lines SDP string reprensentation\n * @returns SDP object representation, iterable through media description\n * @example\n * [\n * group: \"DUNBLE 0 1\",\n * o: \"- 1699450751193623 0 IN IP4 0.0.0.0\",\n * s: \"-\",\n * t: \"0 0\",\n * v: \"0\",\n * ice-lite: \"\",\n * length: 2,\n * {\n * m: \"audio 9 UDP/TLS/RTP/SAVPF 111\",\n * c: \"IN IP4 0.0.0.0\",\n * rtcp: \"9\",\n * sendonly: \"\",\n * setup: \"passive\",\n * fingerprint: \"sha-256 51:36:ED:78:A4:9F:25:8C:39:9A:0E:A0:B4:9B:6E:04:37:FF:AD:96:93:71:43:88:2C:0B:0F:AB:6F:9A:52:B8\",\n * ice-ufrag: \"fa37\",\n * ice-pwd: \"JncCHryDsbzayy4cBWDxS2\",\n * rtcp-mux: \"\",\n * rtcp-rsize: \"\",\n * rtpmap: \"111 opus/48000/2\",\n * rtcp-fb: \"111 nack\",\n * id: \"0\",\n * fmtp: \"111 minptime=10;useinbandfec=1\",\n * candidate: \"1 1 udp 2130706431 89.105.221.108 56643 typ host\",\n * end-of-candidates: \"\"\n * },\n * {\n * m: \"video 9 UDP/TLS/RTP/SAVPF 106\",\n * c: \"IN IP4 0.0.0.0\",\n * rtcp: \"9\",\n * sendonly: \"\",\n * setup: \"passive\",\n * fingerprint: \"sha-256 51:36:ED:78:A4:9F:25:8C:39:9A:0E:A0:B4:9B:6E:04:37:FF:AD:96:93:71:43:88:2C:0B:0F:AB:6F:9A:52:B8\",\n * ice-ufrag: \"fa37\",\n * ice-pwd: \"JncCHryDsbzayy4cBWDxS2\",\n * rtcp-mux: \"\",\n * rtcp-rsize: \"\",\n * rtpmap: \"106 H264/90000\",\n * rtcp-fb: [\n * \"106 nack\",\n * \"106 goog-remb\"\n * ],\n * mid: \"1\",\n * fmtp: \"106 profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1\",\n * candidate: \"1 1 udp 2130706431 89.105.221.108 56643 typ host\",\n * end-of-candidates: \"\"\n * }\n * ]\n */\n fromString(lines: string): any {\n if (Array.isArray(lines)) {\n return lines; // already converted\n }\n const sdp = new Array<any>();\n let media: any = sdp;\n let fingerprint;\n for (let line of lines.toString().split('\\n')) {\n line = line.trim();\n if (!line) {\n continue;\n }\n\n let key = line[0];\n const value = line.substring(line.indexOf('=') + 1).trim();\n switch (key.toLowerCase()) {\n case 'a': {\n if (!value) {\n continue;\n } // empty attribute!\n key = this.addAttribute(media, value);\n // save fingerprint to repeat it in medias\n if (sdp === media && key.toLowerCase() === 'fingerprint') {\n fingerprint = media.fingerprint;\n }\n break;\n }\n case 'm':\n if (sdp.length && fingerprint && !sdp[sdp.length - 1].fingerprint) {\n media.fingerprint = fingerprint;\n }\n sdp.push((media = { m: value }));\n break;\n default:\n media[key] = value;\n }\n }\n if (sdp.length && fingerprint && !sdp[sdp.length - 1].fingerprint) {\n media.fingerprint = fingerprint;\n }\n return sdp;\n },\n\n /**\n * Serialize SDP JS object to a SDP string legal representation\n * @param sdp SDP object reprensetation\n * @returns SDP string reprensentation\n */\n toString(sdp: any): string {\n if (typeof sdp === 'string') {\n return sdp; // already converted\n }\n const medias = [];\n // https://www.cl.cam.ac.uk/~jac22/books/mm/book/node182.html\n let lines = 'v' in sdp ? 'v=' + sdp.v + '\\n' : '';\n if ('o' in sdp) {\n lines += 'o=' + sdp.o + '\\n';\n }\n if ('s' in sdp) {\n lines += 's=' + sdp.s + '\\n';\n }\n const obj: any = sdp;\n for (const key of Object.keys(sdp)) {\n if (key === 'v' || key === 'o' || key === 's') {\n continue;\n }\n const value = obj[key];\n if (value == null) {\n continue;\n } // ignore this key/value\n const index = parseInt(key);\n if (!isNaN(index)) {\n // Is a number! Media object!\n medias[index] = value;\n continue;\n }\n const count = (Array.isArray(value) && value.length) || 1; // value can be numeric!\n for (let i = 0; i < count; ++i) {\n const line = Array.isArray(value) && value.length ? value[i] : value;\n if (key.length > 1) {\n // when key is superior to 1 letter it's a attribute!\n lines += 'a=' + key;\n if (line) {\n lines += ':';\n }\n } else {\n lines += key + '=';\n }\n lines += line + '\\n';\n }\n }\n for (const media of medias) {\n lines += this.toString(media);\n }\n return lines;\n },\n\n /**\n * While set a property to a SDP object representation is possible directly,\n * we could prefer add a new property without overload a possible already existing value.\n * This function allows to add a property to our SDP representation:\n * - if the key's attribute doesn't exists yet it adds it like a simple JS property sdp[key] = value\n * - if the key's attribute exists already it morphs the value to a Array and push it inside\n * @param sdp the SDP object representation on which added the attribute\n * @param attribute the string attribut in a format \"key:value\" or just \"key\" to add an attribute without value\n * @returns the key part of the attribute added (or if value is empty it returns the same attribute as passed in argument)\n */\n addAttribute(sdp: object, attribute: string): string {\n const a = SDP.parseAttribute(attribute);\n const value = a.value ?? ''; // to allow to test if key exists even without value with if(sdp.key != null)\n const obj: any = sdp;\n const oldValue = obj[a.key];\n if (!oldValue) {\n obj[a.key] = value;\n } else if (Array.isArray(oldValue)) {\n oldValue.push(value);\n } else if (value !== oldValue) {\n obj[a.key] = [oldValue, value];\n }\n return a.key;\n },\n\n /**\n * While it's possible to delete a attribute manually on the SDP object representation with a delete sdp.key,\n * we could prefer remove only a value in a sdp.key array containing multiple values.\n * Like opposite to addAttribute this method allows to remove an unique attribute value.\n * @param sdp the SDP object representation on which removed the attribute\n * @param attribute the string attribut in a format \"key:value\" or just \"key\" to remove the whole attribute and all its values\n * @returns the key part of the attribute removed (or if value is empty it returns the same attribute as passed in argument)\n */\n removeAttribute(sdp: object, attribute: string): string {\n const a = SDP.parseAttribute(attribute);\n const obj: any = sdp;\n if (a.value === undefined) {\n delete obj[attribute];\n return attribute;\n }\n const current = obj[attribute];\n if (Array.isArray(a.value)) {\n const i = current.findIndex((current: string) => current === a.value);\n if (i >= 0) {\n current.splice(i, 1);\n }\n } else if (current === a.value) {\n delete obj[attribute];\n }\n return a.key;\n },\n\n /**\n * Parse an attribute in a format \"key:value\"\n * @param attribute string attribute to parse\n * @returns the {key, value} result, with value undefined if attribute was a \"key\" without value\n */\n parseAttribute(attribute: string): { key: string; value: string | undefined } {\n const found = attribute.indexOf(':');\n return {\n key: (found >= 0 ? attribute.substring(0, found) : attribute).trim(),\n value: found >= 0 ? attribute.substring(found + 1).trim() : undefined\n };\n }\n};\nObject.freeze(SDP);\n","/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n\nconst _decoder = new TextDecoder();\nconst _encoder = new TextEncoder();\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nconst _perf = performance; // to increase x10 now performance!\nconst __lib__version__ = '?'; // will be replaced on building by library version\n\n/**\n * Some basic utility functions\n */\n/**\n * Version of the library\n */\nexport const VERSION = __lib__version__;\n\n/**\n * An empty lambda function, pratical to disable default behavior of function or events which are not expected to be null\n * @example\n * console.log = Util.EMPTY_FUNCTION; // disable logs without breaking calls\n */\nexport const EMPTY_FUNCTION = () => {};\n\n/**\n * Efficient and high resolution timestamp in milliseconds elapsed since {@link Util.timeOrigin}\n */\nexport function time(): number {\n return Math.floor(_perf.now());\n}\n\n/**\n * Time origin represents the time when the application has started\n */\nexport function timeOrigin(): number {\n return Math.floor(_perf.now() + _perf.timeOrigin);\n}\n\n/**\n * Parse query and returns it in an easy-to-use Javascript object form\n * @param urlOrQueryOrSearch string, url, or searchParams containing query. If not set it uses `location.search` to determinate query.\n * @returns An javascript object containing each option\n */\nexport function options(\n urlOrQueryOrSearch: URL | URLSearchParams | string | object | undefined = typeof location === 'undefined'\n ? undefined\n : location\n): object {\n if (!urlOrQueryOrSearch) {\n return {};\n }\n try {\n const url: any = urlOrQueryOrSearch;\n urlOrQueryOrSearch = new URL(url).searchParams;\n } catch (e) {\n if (typeof urlOrQueryOrSearch == 'string') {\n if (urlOrQueryOrSearch.startsWith('?')) {\n urlOrQueryOrSearch = urlOrQueryOrSearch.substring(1);\n }\n urlOrQueryOrSearch = new URLSearchParams(urlOrQueryOrSearch);\n }\n }\n // works same if urlOrQueryOrSearch is null, integer, or a already object etc...\n return objectFrom(urlOrQueryOrSearch, { withType: true, noEmptyString: true });\n}\n\n/**\n * Returns an easy-to-use Javascript object something iterable, such as a Map, Set, or Array\n * @param value iterable input\n * @param params.withType `false`, if set it tries to cast string value to a JS number/boolean/undefined/null type.\n * @param params.noEmptyString `false`, if set it converts empty string value to a true boolean, usefull to allow a `if(result.key)` check for example\n * @returns An javascript object\n */\nexport function objectFrom(value: any, params: { withType: boolean; noEmptyString: boolean }): object {\n params = Object.assign({ withType: false, noEmptyString: false }, params);\n const obj: any = {};\n if (!value) {\n return obj;\n }\n for (const [key, val] of objectEntries(value)) {\n value = val;\n if (params.withType && value != null && value.substring) {\n if (value) {\n const number = Number(value);\n if (isNaN(number)) {\n switch (value.toLowerCase()) {\n case 'true':\n value = true;\n break;\n case 'false':\n value = false;\n break;\n case 'null':\n value = null;\n break;\n case 'undefined':\n value = undefined;\n break;\n }\n } else {\n value = number;\n }\n } else if (params.noEmptyString) {\n // if empty string => TRUE to allow a if(options.key) check for example\n value = true;\n }\n }\n if (obj[key]) {\n if (!Array.isArray(obj[key])) {\n obj[key] = new Array(obj[key]);\n }\n obj[key].push(value);\n } else {\n obj[key] = value;\n }\n }\n return obj;\n}\n\n/**\n * Returns entries from something iterable, such as a Map, Set, or Array\n * @param value iterable input\n * @returns An javascript object\n */\nexport function objectEntries(value: any): [string, any][] {\n if (value.entries) {\n return value.entries();\n }\n return Array.from({\n [Symbol.iterator]: function* () {\n for (const key in value) {\n yield [key, value[key]];\n }\n }\n });\n}\n\n/**\n * Converts various data types, such as objects, strings, exceptions, errors,\n * or numbers, into a string representation. Since it offers a more comprehensive format,\n * this function is preferred to `JSON.stringify()`.\n * @param obj Any objects, strings, exceptions, errors, or number\n * @param params.space `''`, allows to configure space in the string representation\n * @param params.decimal `2`, allows to choose the number of decimal to display in the string representation\n * @param params.recursive `false`, allows to serialize recursively every object value, beware if a value refers to a already parsed value an infinite loop will occur.\n * @returns the final string representation\n */\n// Online Javascript Editor for free\n// Write, Edit and Run your Javascript code using JS Online Compiler\nexport function stringify(obj: any, params: { space?: string; decimal?: number; recursive?: number } = {}): string {\n params = Object.assign({ space: ' ', decimal: 2, recursive: 1 }, params);\n if (!obj) {\n return String(obj);\n }\n const error = obj.error || obj.message;\n if (error) {\n // is a error!\n obj = error;\n }\n if (obj.toFixed) {\n return obj.toFixed(Number(params.decimal) || 0);\n }\n if (obj.substring || !params.recursive) {\n // is already a string OR has to be stringified\n return String(obj);\n }\n\n const space = params.space || '';\n\n if (Array.isArray(obj)) {\n // Array!\n let res = '';\n for (const value of obj) {\n res += (res ? ',' : '[') + space;\n res += stringify(value, Object.assign(params, { recursive: params.recursive - 1 }));\n }\n return (res += space + ']');\n }\n if (obj.byteLength != null && obj?.[Symbol.iterator]) {\n // Binary!\n return _decoder.decode(obj);\n }\n let res = '';\n for (const name in obj) {\n res += (res ? ',' : '{') + space + name + ':';\n res += stringify(obj[name], Object.assign(params, { recursive: params.recursive - 1 }));\n }\n return (res += space + '}');\n}\n\nexport function toBin(value: string): Uint8Array {\n return _encoder.encode(value);\n}\n","/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n\nimport { EventEmitter } from './EventEmitter';\n\n/**\n * The WebSocketReliable class extends WebSocket to bring up the following improvements:\n * - Fix all possible unintentional closing ways to get always a related error message, {@link onClose | onClose(error?) event}\n * - Make possible message sending while connecting. Indeed no need to wait {@link onOpen} before to send message,\n * you can open the socket and immediately send messages, it will be queue and flushs on connection etablishment\n * - Make possible a delayed connection, or a reconnection. Indeed you can create an unconnected Websocket instance\n * without passing any url argument and starts the conneciton more later with {@link WebSocketReliable.open(url) | open(url)} method\n * - Make possible to control sending/queueing message: send method take an optional queueing=true argument to\n * queue message rather send it, a futur call to flush will send it. Then queueing getter allows to handle the queue\n * if need to purge it or remove some queued message. Use it all together can help to prioritize messages or control overload.\n * @example\n * const ws = new WebSocketReliable(url);\n * ws.onClose = (error?:string) => {\n * if(error) {\n * console.error(error);\n * }\n * // reconnection attempt every seconds\n * setTimeout(() => ws.open(url), 1000);\n * }\n * ws.onMessage = (message:string) => {\n * console.log(message);\n * }\n * ws.send('hello'); // send immediatly a hello message is possible (no need to wait onOpen)\n */\nexport class WebSocketReliable extends EventEmitter {\n /**\n * @event `open` fired when socket is connected\n */\n onOpen() {}\n\n /**\n * @event `message` fired on message reception\n * @param message can be binary or string.\n * If you subscribe to the event with message as string type (and not union),\n * it means that you know that all your messages are distributed in a string format\n */\n onMessage(message: ArrayBuffer | string) {}\n\n /**\n * @event `close` fired on websocket close\n * @param error error description on an improper closure\n */\n onClose(error?: string) {\n if (error) {\n console.error(error);\n }\n }\n\n /**\n * binaryType, fix binary type to arrayBuffer\n */\n get binaryType(): BinaryType {\n return 'arraybuffer';\n }\n\n /**\n * url of connection\n */\n get url(): string {\n return this._ws?.url ?? '';\n }\n\n /**\n * extensions negociated by the server\n */\n get extensions(): string {\n return this._ws?.extensions ?? '';\n }\n\n /**\n * protocol negociated by the server\n */\n get protocol(): string {\n return this._ws?.protocol ?? '';\n }\n\n /**\n * opened equals true when connection is etablished, in other word when onOpen event is fired\n */\n get opened(): boolean {\n return this._opened;\n }\n\n /**\n * {@link https://developer.mozilla.org/docs/Web/API/WebSocket/readyState | Official websocket readyState}\n */\n get readyState(): number {\n return this._ws ? this._ws.readyState : 3;\n }\n\n /**\n * True when connection is closed, in other words when {@link onClose} event is fired\n * or when WebSocketReliable is build without url (disconnected creation)\n */\n get closed(): boolean {\n return this._closed;\n }\n\n /**\n * The number of bytes of data that were queued during calls to send() but not yet transmitted to the network\n */\n get bufferedAmount(): number {\n return this._queueingBytes + (this._ws?.bufferedAmount || 0);\n }\n\n /**\n * Queued messages from a call to send() waiting to be transmit one time websocket connection opened (or with an explicit call to flush() method)\n */\n get queueing(): Array<string | ArrayBuffer | ArrayBufferView> {\n return this._queueing;\n }\n\n private _opened: boolean;\n private _closed: boolean;\n private _queueing: Array<string | ArrayBuffer | ArrayBufferView>;\n private _queueingBytes: number;\n private _ws?: WebSocket;\n /**\n * Create a WebSocketReliable object, and open it if an url is passed in argument\n * @param url URL of the WebSocket endpoint or null to start the connection later\n */\n constructor(url?: string | URL, protocols?: string | string[]) {\n super();\n this._queueing = [];\n this._queueingBytes = 0;\n this._opened = false;\n this._closed = true;\n if (url) {\n this.open(url, protocols);\n }\n }\n\n /**\n * Open a WebSocket connection\n * @param url url of the websocket endpoint\n * @returns this\n */\n open(url: URL | string, protocols?: string | string[]) {\n this._closed = false;\n const ws = (this._ws = new WebSocket(url, protocols));\n ws.binaryType = this.binaryType;\n ws.onmessage = e => this.onMessage(e.data);\n // Add details and fix close ways\n ws.onclose = (e: CloseEvent) => {\n if (!this._opened) {\n // close during connection\n this.close(url.toString() + ' connection failed (' + String(e.reason || e.code) + ')');\n } else if (e.code === 1000 || e.code === 1005) {\n // normal disconnection from server (no error code)\n this.close(url.toString() + ' shutdown');\n } else {\n // disconnection from server\n this.close(url.toString() + ' disconnection (' + String(e.reason || e.code) + ')');\n }\n };\n // Wrap send method to queue messages until connection is established.\n ws.onopen = _ => {\n this._opened = true;\n this.flush();\n this.onOpen();\n };\n return this;\n }\n\n /**\n * Send a message\n * @param message\n * @param queueing When set it reports the sending to a more later call to flush\n * @returns this\n */\n send(message: string | ArrayBuffer | ArrayBufferView, queueing: boolean = false) {\n if (!this._ws) {\n throw Error('Open socket before to send data');\n }\n if (queueing || !this._opened) {\n this._queueing.push(message);\n this._queueingBytes += typeof message === 'string' ? message.length : message.byteLength;\n } else {\n this._ws.send(message);\n }\n return this;\n }\n\n /**\n * Send queueing messages\n */\n flush() {\n if (this._ws) {\n for (const message of this._queueing) {\n this._ws.send(message);\n }\n }\n this._queueing.length = 0;\n this._queueingBytes = 0;\n }\n\n /**\n * Close websocket\n * @param error the error reason if is not a proper close\n */\n close(error?: string) {\n if (!this._ws || this._closed) {\n return;\n }\n this._closed = true;\n this._ws.onopen = this._ws.onclose = this._ws.onmessage = null; // otherwise can receive message AFTER close!\n this._ws.close(); // Don't set to undefined to keep this._ws properties valid!\n // release resources!\n this._opened = false;\n this._queueing.length = 0;\n this._queueingBytes = 0;\n this.onClose(error);\n }\n}\n"],"names":[],"mappings":"AAAA;;;;AAIG;AAEH;;AAEG;MACU,YAAY,CAAA;AAMrB,IAAA,WAAA,CAAY,IAAkB,EAAA;AAC1B,QAAA,IAAI,CAAC,KAAK;AACN,YAAA,QAAQ,IAAI,IAAI,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;QAC5G,IAAI,CA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AAA,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;AAC1B,QAAA,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;KAC3B;AAED;;;AAGG;AACH,IAAA,KAAK,CAAC,KAAc,EAAA;QAChB,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE;YAC3B,OAAO;AACV,SAAA;AACD,QAAA,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC;AAC/D,QAAA,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;;AAEjB,QAAA,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;AACrB,QAAA,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;AAC1B,QAAA,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;AACxB,QAAA,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;KACvB;AACJ"}
|
package/dist/web-utils.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class t{constructor(t){this._data="buffer"in t?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t),this._size=this._data.byteLength,this._position=0,this._view=new DataView(this._data.buffer,this._data.byteOffset,this._size)}data(){return this._data}size(){return this._size}available(){return this._size-this._position}value(t=this._position){return this._data[t]}position(){return this._position}reset(t=0){this._position=t>this._size?this._size:t}shrink(t){const e=this._size-this._position;return t>e?e:(this._size=this._position+t,t)}next(t=1){const e=this._size-this._position;return t>e&&(t=e),this._position+=t,t}read8(){return 1===this.next(1)?this._view.getUint8(this._position-1):0}read16(){return 2===this.next(2)?this._view.getUint16(this._position-2):0}read24(){return 3===this.next(3)?this._view.getUint16(this._position-3)<<8|255&this._view.getUint8(this._position-1):0}read32(){return 4===this.next(4)?this._view.getUint32(this._position-4):0}readFloat(){return 4===this.next(4)?this._view.getFloat32(this._position-4):0}readDouble(){return 8===this.next(8)?this._view.getFloat64(this._position-8):0}read7Bit(t=5){if(t>5)throw Error("BinaryReader in JS can't decode more than 32 usefull bits");if(!(t>0))throw Error("Have to indicate a positive number of bytes to decode");let e,i=0;do{if(e=this.read8(),! --t)return(i<<8|e)>>>0;i=i<<7|127&e}while(128&e);return i}readString(){return String.fromCharCode(...this.read(this.read7Bit()))}readHex(t){let e="";for(;t--;)e+=("0"+this.read8().toString(16)).slice(-2);return e}read(t=this.available()){if(this.available()<t)return new Uint8Array(t);const e=this._data.subarray(this._position,this._position+t);return this._position+=t,e}}class e{get view(){return this._view||(this._view=new DataView(this._data.buffer,this._data.byteOffset,this._data.byteLength)),this._view}get capacity(){return this._data.byteLength}constructor(t=64,e=0,i){"number"==typeof t?(this._data=new Uint8Array(t),this._size=0):"buffer"in t?(this._data=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),this._size=t.byteLength):(this._isConst=!0,null==i&&(i=t.byteLength),this._data=new Uint8Array(t,e,i),this._size=0)}data(){return new Uint8Array(this._data.buffer,this._data.byteOffset,this._size)}size(){return this._size||0}next(t=1){return this.reserve(this._size+=t)}clear(t=0){return this.reserve(this._size=t)}write(t){if(this.reserve(this._size+t.length),"string"==typeof t){for(let e=0;e<t.length;++e){const i=t.charCodeAt(e);this._data[this._size++]=i>255?32:i}return this}return this._data.set(t,this._size),this._size+=t.length,this}write8(t){return t>255&&(t=255),this.reserve(this._size+1),this._data[this._size++]=t,this}write16(t){return t>65535&&(t=65535),this.reserve(this._size+2),this.view.setUint16(this._size,t),this._size+=2,this}write24(t){return t>16777215&&(t=16777215),this.reserve(this._size+3),this.view.setUint16(this._size,t>>8),this.view.setUint8(this._size+=2,255&t),++this._size,this}write32(t){return t>4294967295&&(t=4294967295),this.reserve(this._size+4),this.view.setUint32(this._size,t),this._size+=4,this}writeFloat(t){return this.reserve(this._size+4),this.view.setFloat32(this._size,t),this._size+=4,this}writeDouble(t){return this.reserve(this._size+8),this.view.setFloat64(this._size,t),this._size+=8,this}write7Bit(t,e=5){if(e>5)throw Error("BinaryWriter in JS can't encode more than 32 usefull bits");if(!(e>0))throw Error("Have to indicate a positive number of bytes to encode");let i=7*--e;const s=t>4294967295?256:t>>>i;if(s)++i,s>255&&(t=4294967295);else for(;(i-=7)&&!(t>>>i););for(;i>1;)this.write8(128|t>>>i&255),i-=7;return this.write8(t&(i?255:127))}writeString(t){return this.write7Bit(t.length).write(t)}writeHex(t){for(let e=0;e<t.length;e+=2)this.write8(parseInt(t.substring(e,e+2),16));return this}reserve(t){if(!this._data)throw new Error("buffer not writable");if(t<=this._data.byteLength)return this;if(this._isConst)throw new Error("writing exceeds maximum "+this._data.byteLength+" bytes limit");--t,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t;const e=new Uint8Array(t);return e.set(this._data),this._data=e,this._view=void 0,this}}class i{constructor(t){this._data="buffer"in t?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t),this._size=this._data.byteLength,this._position=0,this._bit=0}data(){return this._data}size(){return this._size}available(){return 8*(this._size-this._position)-this._bit}next(t=1){let e=0;for(;this._position!==this._size&&t--;)++e,8==++this._bit&&(this._bit=0,++this._position);return e}read(t=1){let e=0;for(;this._position!==this._size&&t--;)e<<=1,this._data[this._position]&128>>this._bit++&&(e|=1),8===this._bit&&(this._bit=0,++this._position);return e}read8(){return this.read(8)}read16(){return this.read(16)}read24(){return this.read(24)}read32(){return this.read(32)}}class s{static fixProtocol(t,e){const i=e.indexOf("://");return i>=0&&(i>2&&"s"===e.charAt(i-1).toLowerCase()?(t.length<=2||!t.endsWith("s"))&&(t+="s"):t.length>2&&t.endsWith("s")&&(t=t.slice(0,-1)),e=e.substring(i+3)),t+"://"+e}get domain(){return this._domain}get port(){return this._port}toString(){return this._address}valueOf(){return this._address}constructor(t,e){this._address=t;let i=t.indexOf("/");if(i>=0&&(47===t.charCodeAt(i+1)?i>0?58===t.charCodeAt(i-1)&&(t=t.substring(i+2)):t=t.substring(2):i||(t=t.substring(1))),this._domain=t,this._port=e,i=t.lastIndexOf(":"),i>=0){const e=parseInt(t.substring(i+1));e&&e<=65535&&(this._port=e,this._domain=t.substring(0,i))}else i=t.indexOf("/"),i>=0&&(this._domain=t.substring(0,i))}}var r;!function(t){t.HESP="hesp",t.WEBRTS="webrts",t.WEBRTC="webrtc",t.META="meta",t.DATA="data"}(r||(r={}));var n=Object.freeze({__proto__:null,get Type(){return r},buildURL:function(t,e,i="wss"){const n=new URL(s.fixProtocol(i,e.host));if(n.pathname.length<=1)switch(t){case r.HESP:n.pathname="/hesp/"+e.streamName+"/index.json";break;case r.WEBRTC:n.pathname="/webrtc/"+e.streamName;break;case r.WEBRTS:n.pathname="/webrts/"+e.streamName;break;case r.META:n.pathname="/json_"+e.streamName+".js";break;case r.DATA:n.pathname="/"+e.streamName+".json";break;default:console.warn("Unknown url type "+t)}e.accessToken&&n.searchParams.set("id",e.accessToken);for(const t in e.query)n.searchParams.set(t,e.query[t]);return n}});class o{constructor(){this._events=new Map;let t=Object.getPrototypeOf(this);for(;t&&t!==Object.prototype;){for(const e of Object.getOwnPropertyNames(t))if(!(e.length<3)&&e.startsWith("on")&&t[e]instanceof Function){const i=new Set;this._events.set(e.substring(2).toLowerCase(),i);let s=t[e];Object.defineProperties(this,{[e]:{get:()=>(...t)=>{s&&s.call(this,...t);for(const e of i)e(...t)},set:t=>{s=t}}})}t=Object.getPrototypeOf(t)}}on(t,e,i){if(!e)throw Error("event to subscribe cannot be null");const s=this._event(t);s.add(e),i&&i.signal.addEventListener("abort",(()=>{s.delete(e)}))}once(t,e,i){if(!e)throw Error("event to subscribe cannot be null");const s=this._event(t);s.add((()=>{s.delete(e),e()})),i&&i.signal.addEventListener("abort",(()=>{s.delete(e)}))}off(t,e){if(!e)throw Error("event to unsubscribe cannot be null");this._event(t).delete(e)}_event(t){const e=this._events.get(t.toLowerCase());if(!e)throw Error("No event on"+t+" on class "+this.constructor.name);return e}}class h{get size(){return this._queue.length}get capacity(){return this._capacity}set capacity(t){this._capacity=t,null!=t&&this._queue.length>t&&this._queue.splice(0,this._queue.length-t)}get front(){return this._queue[0]}get back(){return this._queue[this._queue.length-1]}[Symbol.iterator](){return this._queue[Symbol.iterator]()}constructor(t){this._capacity=t,this._queue=new Array}push(t){return null!=this._capacity&&this._queue.push(t)>this._capacity&&this.pop(),this}pop(){return this._queue.shift()}clear(){return this._queue.length=0,this}}class a extends h{get minimum(){return this._min}get maximum(){return this._max}get average(){return null==this._average&&(this._average=this.size?this._sum/this.size:0),this._average}constructor(t){super(t),this._sum=0,this._min=0,this._max=0}push(t){return t>this._max?this._max=t:t<this._min&&(this._min=t),this._average=void 0,this._sum+=t,super.push(t),this}pop(){const t=super.pop();return t===this._max?this._max=Math.max(0,...this):t===this._min&&(this._min=Math.min(0,...this)),this._average=void 0,this._sum-=t||0,t}clear(){return this._min=this._max=this._sum=0,super.clear(),this}}const u={fromString(t){if(Array.isArray(t))return t;const e=new Array;let i,s=e;for(let r of t.toString().split("\n")){if(r=r.trim(),!r)continue;let t=r[0];const n=r.substring(r.indexOf("=")+1).trim();switch(t.toLowerCase()){case"a":if(!n)continue;t=this.addAttribute(s,n),e===s&&"fingerprint"===t.toLowerCase()&&(i=s.fingerprint);break;case"m":e.length&&i&&!e[e.length-1].fingerprint&&(s.fingerprint=i),e.push(s={m:n});break;default:s[t]=n}}return e.length&&i&&!e[e.length-1].fingerprint&&(s.fingerprint=i),e},toString(t){if("string"==typeof t)return t;const e=[];let i="v"in t?"v="+t.v+"\n":"";"o"in t&&(i+="o="+t.o+"\n"),"s"in t&&(i+="s="+t.s+"\n");const s=t;for(const r of Object.keys(t)){if("v"===r||"o"===r||"s"===r)continue;const t=s[r];if(null==t)continue;const n=parseInt(r);if(!isNaN(n)){e[n]=t;continue}const o=Array.isArray(t)&&t.length||1;for(let e=0;e<o;++e){const s=Array.isArray(t)&&t.length?t[e]:t;r.length>1?(i+="a="+r,s&&(i+=":")):i+=r+"=",i+=s+"\n"}}for(const t of e)i+=this.toString(t);return i},addAttribute(t,e){var i;const s=u.parseAttribute(e),r=null!==(i=s.value)&&void 0!==i?i:"",n=t,o=n[s.key];return o?Array.isArray(o)?o.push(r):r!==o&&(n[s.key]=[o,r]):n[s.key]=r,s.key},removeAttribute(t,e){const i=u.parseAttribute(e),s=t;if(void 0===i.value)return delete s[e],e;const r=s[e];if(Array.isArray(i.value)){const t=r.findIndex((t=>t===i.value));t>=0&&r.splice(t,1)}else r===i.value&&delete s[e];return i.key},parseAttribute(t){const e=t.indexOf(":");return{key:(e>=0?t.substring(0,e):t).trim(),value:e>=0?t.substring(e+1).trim():void 0}}};Object.freeze(u);const _=new TextDecoder,c=new TextEncoder,l=performance;function d(t,e){e=Object.assign({withType:!1,noEmptyString:!1},e);const i={};if(!t)return i;for(const[s,r]of function(t){if(t.entries)return t.entries();return Array.from({[Symbol.iterator]:function*(){for(const e in t)yield[e,t[e]]}})}(t)){if(t=r,e.withType&&null!=t&&t.substring)if(t){const e=Number(t);if(isNaN(e))switch(t.toLowerCase()){case"true":t=!0;break;case"false":t=!1;break;case"null":t=null;break;case"undefined":t=void 0}else t=e}else e.noEmptyString&&(t=!0);i[s]?(Array.isArray(i[s])||(i[s]=new Array(i[s])),i[s].push(t)):i[s]=t}return i}var f=Object.freeze({__proto__:null,EMPTY_FUNCTION:()=>{},VERSION:"1.0.0",objectFrom:d,options:function(t=("undefined"==typeof location?void 0:location)){if(!t)return{};try{t=new URL(t).searchParams}catch(e){"string"==typeof t&&(t.startsWith("?")&&(t=t.substring(1)),t=new URLSearchParams(t))}return d(t,{withType:!0,noEmptyString:!0})},stringify:function t(e,i={}){if(i=Object.assign({space:" ",decimal:2,recursive:1},i),!e)return String(e);const s=e.error||e.message;if(s&&(e=s),e.toFixed)return e.toFixed(Number(i.decimal)||0);if(e.substring||!i.recursive)return String(e);const r=i.space||"";if(Array.isArray(e)){let s="";for(const n of e)s+=(s?",":"[")+r,s+=t(n,Object.assign(i,{recursive:i.recursive-1}));return s+=r+"]"}if(null!=e.byteLength&&(null==e?void 0:e[Symbol.iterator]))return _.decode(e);let n="";for(const s in e)n+=(n?",":"{")+r+s+":",n+=t(e[s],Object.assign(i,{recursive:i.recursive-1}));return n+(r+"}")},time:function(){return Math.floor(l.now())},timeOrigin:function(){return Math.floor(l.now()+l.timeOrigin)},toBin:function(t){return c.encode(t)}});class g extends o{onOpen(){}onMessage(t){}onClose(t){t&&console.error(t)}get binaryType(){return"arraybuffer"}get url(){var t,e;return null!==(e=null===(t=this._ws)||void 0===t?void 0:t.url)&&void 0!==e?e:""}get extensions(){var t,e;return null!==(e=null===(t=this._ws)||void 0===t?void 0:t.extensions)&&void 0!==e?e:""}get protocol(){var t,e;return null!==(e=null===(t=this._ws)||void 0===t?void 0:t.protocol)&&void 0!==e?e:""}get opened(){return this._opened}get readyState(){return this._ws?this._ws.readyState:3}get closed(){return this._closed}get bufferedAmount(){var t;return this._queueingBytes+((null===(t=this._ws)||void 0===t?void 0:t.bufferedAmount)||0)}get queueing(){return this._queueing}constructor(t,e){super(),this._queueing=[],this._queueingBytes=0,this._opened=!1,this._closed=!0,t&&this.open(t,e)}open(t,e){this._closed=!1;const i=this._ws=new WebSocket(t,e);return i.binaryType=this.binaryType,i.onmessage=t=>this.onMessage(t.data),i.onclose=e=>{this._opened?1e3===e.code||1005===e.code?this.close(t.toString()+" shutdown"):this.close(t.toString()+" disconnection ("+String(e.reason||e.code)+")"):this.close(t.toString()+" connection failed ("+String(e.reason||e.code)+")")},i.onopen=t=>{this._opened=!0,this.flush(),this.onOpen()},this}send(t,e=!1){if(!this._ws)throw Error("Open socket before to send data");return e||!this._opened?(this._queueing.push(t),this._queueingBytes+="string"==typeof t?t.length:t.byteLength):this._ws.send(t),this}flush(){if(this._ws)for(const t of this._queueing)this._ws.send(t);this._queueing.length=0,this._queueingBytes=0}close(t){this._ws&&!this._closed&&(this._closed=!0,this._ws.onopen=this._ws.onclose=this._ws.onmessage=null,this._ws.close(),this._opened=!1,this._queueing.length=0,this._queueingBytes=0,this.onClose(t))}}export{t as BinaryReader,e as BinaryWriter,i as BitReader,n as Connect,o as EventEmitter,s as NetAddress,a as Numbers,h as Queue,u as SDP,f as Util,g as WebSocketReliable};//# sourceMappingURL=web-utils.min.js.map
|
|
1
|
+
class t{constructor(t){this._data="buffer"in t?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t),this._size=this._data.byteLength,this._position=0,this._view=new DataView(this._data.buffer,this._data.byteOffset,this._size)}data(){return this._data}size(){return this._size}available(){return this._size-this._position}value(t=this._position){return this._data[t]}position(){return this._position}reset(t=0){this._position=t>this._size?this._size:t}shrink(t){const e=this._size-this._position;return t>e?e:(this._size=this._position+t,t)}next(t=1){const e=this._size-this._position;return t>e&&(t=e),this._position+=t,t}read8(){return 1===this.next(1)?this._view.getUint8(this._position-1):0}read16(){return 2===this.next(2)?this._view.getUint16(this._position-2):0}read24(){return 3===this.next(3)?this._view.getUint16(this._position-3)<<8|255&this._view.getUint8(this._position-1):0}read32(){return 4===this.next(4)?this._view.getUint32(this._position-4):0}readFloat(){return 4===this.next(4)?this._view.getFloat32(this._position-4):0}readDouble(){return 8===this.next(8)?this._view.getFloat64(this._position-8):0}read7Bit(t=5){if(t>5)throw Error("BinaryReader in JS can't decode more than 32 usefull bits");if(!(t>0))throw Error("Have to indicate a positive number of bytes to decode");let e,i=0;do{if(e=this.read8(),! --t)return(i<<8|e)>>>0;i=i<<7|127&e}while(128&e);return i}readString(){return String.fromCharCode(...this.read(this.read7Bit()))}readHex(t){let e="";for(;t--;)e+=("0"+this.read8().toString(16)).slice(-2);return e}read(t=this.available()){if(this.available()<t)return new Uint8Array(t);const e=this._data.subarray(this._position,this._position+t);return this._position+=t,e}}class e{get view(){return this._view||(this._view=new DataView(this._data.buffer,this._data.byteOffset,this._data.byteLength)),this._view}get capacity(){return this._data.byteLength}constructor(t=64,e=0,i){"number"==typeof t?(this._data=new Uint8Array(t),this._size=0):"buffer"in t?(this._data=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),this._size=t.byteLength):(this._isConst=!0,null==i&&(i=t.byteLength),this._data=new Uint8Array(t,e,i),this._size=0)}data(){return new Uint8Array(this._data.buffer,this._data.byteOffset,this._size)}size(){return this._size||0}next(t=1){return this.reserve(this._size+=t)}clear(t=0){return this.reserve(this._size=t)}write(t){if(this.reserve(this._size+t.length),"string"==typeof t){for(let e=0;e<t.length;++e){const i=t.charCodeAt(e);this._data[this._size++]=i>255?32:i}return this}return this._data.set(t,this._size),this._size+=t.length,this}write8(t){return t>255&&(t=255),this.reserve(this._size+1),this._data[this._size++]=t,this}write16(t){return t>65535&&(t=65535),this.reserve(this._size+2),this.view.setUint16(this._size,t),this._size+=2,this}write24(t){return t>16777215&&(t=16777215),this.reserve(this._size+3),this.view.setUint16(this._size,t>>8),this.view.setUint8(this._size+=2,255&t),++this._size,this}write32(t){return t>4294967295&&(t=4294967295),this.reserve(this._size+4),this.view.setUint32(this._size,t),this._size+=4,this}writeFloat(t){return this.reserve(this._size+4),this.view.setFloat32(this._size,t),this._size+=4,this}writeDouble(t){return this.reserve(this._size+8),this.view.setFloat64(this._size,t),this._size+=8,this}write7Bit(t,e=5){if(e>5)throw Error("BinaryWriter in JS can't encode more than 32 usefull bits");if(!(e>0))throw Error("Have to indicate a positive number of bytes to encode");let i=7*--e;const s=t>4294967295?256:t>>>i;if(s)++i,s>255&&(t=4294967295);else for(;(i-=7)&&!(t>>>i););for(;i>1;)this.write8(128|t>>>i&255),i-=7;return this.write8(t&(i?255:127))}writeString(t){return this.write7Bit(t.length).write(t)}writeHex(t){for(let e=0;e<t.length;e+=2)this.write8(parseInt(t.substring(e,e+2),16));return this}reserve(t){if(!this._data)throw new Error("buffer not writable");if(t<=this._data.byteLength)return this;if(this._isConst)throw new Error("writing exceeds maximum "+this._data.byteLength+" bytes limit");--t,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t;const e=new Uint8Array(t);return e.set(this._data),this._data=e,this._view=void 0,this}}class i{constructor(t){this._data="buffer"in t?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t),this._size=this._data.byteLength,this._position=0,this._bit=0}data(){return this._data}size(){return this._size}available(){return 8*(this._size-this._position)-this._bit}next(t=1){let e=0;for(;this._position!==this._size&&t--;)++e,8==++this._bit&&(this._bit=0,++this._position);return e}read(t=1){let e=0;for(;this._position!==this._size&&t--;)e<<=1,this._data[this._position]&128>>this._bit++&&(e|=1),8===this._bit&&(this._bit=0,++this._position);return e}read8(){return this.read(8)}read16(){return this.read(16)}read24(){return this.read(24)}read32(){return this.read(32)}}class s{static fixProtocol(t,e){const i=e.indexOf("://");return i>=0&&(i>2&&"s"===e.charAt(i-1).toLowerCase()?(t.length<=2||!t.endsWith("s"))&&(t+="s"):t.length>2&&t.endsWith("s")&&(t=t.slice(0,-1)),e=e.substring(i+3)),t+"://"+e}get domain(){return this._domain}get port(){return this._port}toString(){return this._address}valueOf(){return this._address}constructor(t,e){this._address=t;let i=t.indexOf("/");if(i>=0&&(47===t.charCodeAt(i+1)?i>0?58===t.charCodeAt(i-1)&&(t=t.substring(i+2)):t=t.substring(2):i||(t=t.substring(1))),this._domain=t,this._port=e,i=t.lastIndexOf(":"),i>=0){const e=parseInt(t.substring(i+1));e&&e<=65535&&(this._port=e,this._domain=t.substring(0,i))}else i=t.indexOf("/"),i>=0&&(this._domain=t.substring(0,i))}}var r;!function(t){t.HESP="hesp",t.WEBRTS="webrts",t.WEBRTC="webrtc",t.META="meta",t.DATA="data"}(r||(r={}));var n=Object.freeze({__proto__:null,get Type(){return r},buildURL:function(t,e,i="wss"){const n=new URL(s.fixProtocol(i,e.host));if(n.pathname.length<=1)switch(t){case r.HESP:n.pathname="/hesp/"+e.streamName+"/index.json";break;case r.WEBRTC:n.pathname="/webrtc/"+e.streamName;break;case r.WEBRTS:n.pathname="/webrts/"+e.streamName;break;case r.META:n.pathname="/json_"+e.streamName+".js";break;case r.DATA:n.pathname="/"+e.streamName+".json";break;default:console.warn("Unknown url type "+t)}e.accessToken&&n.searchParams.set("id",e.accessToken);for(const t in e.query)n.searchParams.set(t,e.query[t]);return n}});class o{constructor(){this._events=new Map;let t=Object.getPrototypeOf(this);for(;t&&t!==Object.prototype;){for(const e of Object.getOwnPropertyNames(t))if(!(e.length<3)&&e.startsWith("on")&&t[e]instanceof Function){const i=new Set;this._events.set(e.substring(2).toLowerCase(),i);let s=t[e];Object.defineProperties(this,{[e]:{get:()=>(...t)=>{s&&s.call(this,...t);for(const e of i)e(...t)},set:t=>{s=t}}})}t=Object.getPrototypeOf(t)}}on(t,e,i){if(!e)throw Error("event to subscribe cannot be null");const s=this._event(t);s.add(e),i&&i.signal.addEventListener("abort",(()=>{s.delete(e)}))}once(t,e,i){if(!e)throw Error("event to subscribe cannot be null");const s=this._event(t);s.add((()=>{s.delete(e),e()})),i&&i.signal.addEventListener("abort",(()=>{s.delete(e)}))}off(t,e){if(!e)throw Error("event to unsubscribe cannot be null");this._event(t).delete(e)}_event(t){const e=this._events.get(t.toLowerCase());if(!e)throw Error("No event on"+t+" on class "+this.constructor.name);return e}}class h{get size(){return this._queue.length}get capacity(){return this._capacity}set capacity(t){this._capacity=t,null!=t&&this._queue.length>t&&this._queue.splice(0,this._queue.length-t)}get front(){return this._queue[0]}get back(){return this._queue[this._queue.length-1]}[Symbol.iterator](){return this._queue[Symbol.iterator]()}constructor(t){this._capacity=t,this._queue=new Array}push(t){return null!=this._capacity&&this._queue.push(t)>this._capacity&&this.pop(),this}pop(){return this._queue.shift()}clear(){return this._queue.length=0,this}}class a extends h{get minimum(){return this._min}get maximum(){return this._max}get average(){return null==this._average&&(this._average=this.size?this._sum/this.size:0),this._average}constructor(t){super(t),this._sum=0,this._min=0,this._max=0}push(t){return t>this._max?this._max=t:t<this._min&&(this._min=t),this._average=void 0,this._sum+=t,super.push(t),this}pop(){const t=super.pop();return t===this._max?this._max=Math.max(0,...this):t===this._min&&(this._min=Math.min(0,...this)),this._average=void 0,this._sum-=t||0,t}clear(){return this._min=this._max=this._sum=0,super.clear(),this}}const u={fromString(t){if(Array.isArray(t))return t;const e=new Array;let i,s=e;for(let r of t.toString().split("\n")){if(r=r.trim(),!r)continue;let t=r[0];const n=r.substring(r.indexOf("=")+1).trim();switch(t.toLowerCase()){case"a":if(!n)continue;t=this.addAttribute(s,n),e===s&&"fingerprint"===t.toLowerCase()&&(i=s.fingerprint);break;case"m":e.length&&i&&!e[e.length-1].fingerprint&&(s.fingerprint=i),e.push(s={m:n});break;default:s[t]=n}}return e.length&&i&&!e[e.length-1].fingerprint&&(s.fingerprint=i),e},toString(t){if("string"==typeof t)return t;const e=[];let i="v"in t?"v="+t.v+"\n":"";"o"in t&&(i+="o="+t.o+"\n"),"s"in t&&(i+="s="+t.s+"\n");const s=t;for(const r of Object.keys(t)){if("v"===r||"o"===r||"s"===r)continue;const t=s[r];if(null==t)continue;const n=parseInt(r);if(!isNaN(n)){e[n]=t;continue}const o=Array.isArray(t)&&t.length||1;for(let e=0;e<o;++e){const s=Array.isArray(t)&&t.length?t[e]:t;r.length>1?(i+="a="+r,s&&(i+=":")):i+=r+"=",i+=s+"\n"}}for(const t of e)i+=this.toString(t);return i},addAttribute(t,e){var i;const s=u.parseAttribute(e),r=null!==(i=s.value)&&void 0!==i?i:"",n=t,o=n[s.key];return o?Array.isArray(o)?o.push(r):r!==o&&(n[s.key]=[o,r]):n[s.key]=r,s.key},removeAttribute(t,e){const i=u.parseAttribute(e),s=t;if(void 0===i.value)return delete s[e],e;const r=s[e];if(Array.isArray(i.value)){const t=r.findIndex((t=>t===i.value));t>=0&&r.splice(t,1)}else r===i.value&&delete s[e];return i.key},parseAttribute(t){const e=t.indexOf(":");return{key:(e>=0?t.substring(0,e):t).trim(),value:e>=0?t.substring(e+1).trim():void 0}}};Object.freeze(u);const _=new TextDecoder,c=new TextEncoder,l=performance;function d(t,e){e=Object.assign({withType:!1,noEmptyString:!1},e);const i={};if(!t)return i;for(const[s,r]of f(t)){if(t=r,e.withType&&null!=t&&t.substring)if(t){const e=Number(t);if(isNaN(e))switch(t.toLowerCase()){case"true":t=!0;break;case"false":t=!1;break;case"null":t=null;break;case"undefined":t=void 0}else t=e}else e.noEmptyString&&(t=!0);i[s]?(Array.isArray(i[s])||(i[s]=new Array(i[s])),i[s].push(t)):i[s]=t}return i}function f(t){return t.entries?t.entries():Array.from({[Symbol.iterator]:function*(){for(const e in t)yield[e,t[e]]}})}var g=Object.freeze({__proto__:null,EMPTY_FUNCTION:()=>{},VERSION:"1.0.1",objectEntries:f,objectFrom:d,options:function(t=("undefined"==typeof location?void 0:location)){if(!t)return{};try{t=new URL(t).searchParams}catch(e){"string"==typeof t&&(t.startsWith("?")&&(t=t.substring(1)),t=new URLSearchParams(t))}return d(t,{withType:!0,noEmptyString:!0})},stringify:function t(e,i={}){if(i=Object.assign({space:" ",decimal:2,recursive:1},i),!e)return String(e);const s=e.error||e.message;if(s&&(e=s),e.toFixed)return e.toFixed(Number(i.decimal)||0);if(e.substring||!i.recursive)return String(e);const r=i.space||"";if(Array.isArray(e)){let s="";for(const n of e)s+=(s?",":"[")+r,s+=t(n,Object.assign(i,{recursive:i.recursive-1}));return s+=r+"]"}if(null!=e.byteLength&&(null==e?void 0:e[Symbol.iterator]))return _.decode(e);let n="";for(const s in e)n+=(n?",":"{")+r+s+":",n+=t(e[s],Object.assign(i,{recursive:i.recursive-1}));return n+(r+"}")},time:function(){return Math.floor(l.now())},timeOrigin:function(){return Math.floor(l.now()+l.timeOrigin)},toBin:function(t){return c.encode(t)}});class p extends o{onOpen(){}onMessage(t){}onClose(t){t&&console.error(t)}get binaryType(){return"arraybuffer"}get url(){var t,e;return null!==(e=null===(t=this._ws)||void 0===t?void 0:t.url)&&void 0!==e?e:""}get extensions(){var t,e;return null!==(e=null===(t=this._ws)||void 0===t?void 0:t.extensions)&&void 0!==e?e:""}get protocol(){var t,e;return null!==(e=null===(t=this._ws)||void 0===t?void 0:t.protocol)&&void 0!==e?e:""}get opened(){return this._opened}get readyState(){return this._ws?this._ws.readyState:3}get closed(){return this._closed}get bufferedAmount(){var t;return this._queueingBytes+((null===(t=this._ws)||void 0===t?void 0:t.bufferedAmount)||0)}get queueing(){return this._queueing}constructor(t,e){super(),this._queueing=[],this._queueingBytes=0,this._opened=!1,this._closed=!0,t&&this.open(t,e)}open(t,e){this._closed=!1;const i=this._ws=new WebSocket(t,e);return i.binaryType=this.binaryType,i.onmessage=t=>this.onMessage(t.data),i.onclose=e=>{this._opened?1e3===e.code||1005===e.code?this.close(t.toString()+" shutdown"):this.close(t.toString()+" disconnection ("+String(e.reason||e.code)+")"):this.close(t.toString()+" connection failed ("+String(e.reason||e.code)+")")},i.onopen=t=>{this._opened=!0,this.flush(),this.onOpen()},this}send(t,e=!1){if(!this._ws)throw Error("Open socket before to send data");return e||!this._opened?(this._queueing.push(t),this._queueingBytes+="string"==typeof t?t.length:t.byteLength):this._ws.send(t),this}flush(){if(this._ws)for(const t of this._queueing)this._ws.send(t);this._queueing.length=0,this._queueingBytes=0}close(t){this._ws&&!this._closed&&(this._closed=!0,this._ws.onopen=this._ws.onclose=this._ws.onmessage=null,this._ws.close(),this._opened=!1,this._queueing.length=0,this._queueingBytes=0,this.onClose(t))}}export{t as BinaryReader,e as BinaryWriter,i as BitReader,n as Connect,o as EventEmitter,s as NetAddress,a as Numbers,h as Queue,u as SDP,g as Util,p as WebSocketReliable};//# sourceMappingURL=web-utils.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-utils.min.js","sources":["web-utils.js"],"sourcesContent":["/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/**\n * BinaryReader allows to read binary data\n */\nclass BinaryReader {\n constructor(data) {\n this._data =\n 'buffer' in data ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength) : new Uint8Array(data);\n this._size = this._data.byteLength;\n this._position = 0;\n this._view = new DataView(this._data.buffer, this._data.byteOffset, this._size);\n }\n data() {\n return this._data;\n }\n size() {\n return this._size;\n }\n available() {\n return this._size - this._position;\n }\n value(position = this._position) {\n return this._data[position];\n }\n position() {\n return this._position;\n }\n reset(position = 0) {\n this._position = position > this._size ? this._size : position;\n }\n shrink(available) {\n const rest = this._size - this._position;\n if (available > rest) {\n return rest;\n }\n this._size = this._position + available;\n return available;\n }\n next(count = 1) {\n const rest = this._size - this._position;\n if (count > rest) {\n count = rest;\n }\n this._position += count;\n return count;\n }\n read8() {\n return this.next(1) === 1 ? this._view.getUint8(this._position - 1) : 0;\n }\n read16() {\n return this.next(2) === 2 ? this._view.getUint16(this._position - 2) : 0;\n }\n read24() {\n return this.next(3) === 3\n ? (this._view.getUint16(this._position - 3) << 8) | (this._view.getUint8(this._position - 1) & 0xff)\n : 0;\n }\n read32() {\n return this.next(4) === 4 ? this._view.getUint32(this._position - 4) : 0;\n }\n readFloat() {\n return this.next(4) === 4 ? this._view.getFloat32(this._position - 4) : 0;\n }\n readDouble() {\n return this.next(8) === 8 ? this._view.getFloat64(this._position - 8) : 0;\n }\n read7Bit(bytes = 5) {\n if (bytes > 5) {\n throw Error(\"BinaryReader in JS can't decode more than 32 usefull bits\");\n }\n if (!(bytes > 0)) {\n // negation to catch NaN value\n throw Error('Have to indicate a positive number of bytes to decode');\n }\n let result = 0;\n let byte;\n do {\n byte = this.read8();\n if (!--bytes) {\n return ((result << 8) | byte) >>> 0; // Use all 8 bits from the 5th byte\n }\n result = (result << 7) | (byte & 0x7f);\n } while (byte & 0x80);\n return result;\n }\n readString() {\n return String.fromCharCode(...this.read(this.read7Bit()));\n }\n readHex(size) {\n let hex = '';\n while (size--) {\n hex += ('0' + this.read8().toString(16)).slice(-2);\n }\n return hex;\n }\n /**\n * Read bytes, to convert bytes to string use String.fromCharCode(...reader.read(size))\n * @param {UInt32} size\n */\n read(size = this.available()) {\n if (this.available() < size) {\n return new Uint8Array(size); // default value = empty bytearray!\n }\n const value = this._data.subarray(this._position, this._position + size);\n this._position += size;\n return value;\n }\n}/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/**\n * BinaryWriter allows to write data in its binary form\n */\nclass BinaryWriter {\n get view() {\n if (!this._view) {\n this._view = new DataView(this._data.buffer, this._data.byteOffset, this._data.byteLength);\n }\n return this._view;\n }\n get capacity() {\n return this._data.byteLength;\n }\n constructor(dataOrSize = 64, offset = 0, length) {\n if (typeof dataOrSize == 'number') {\n // allocate new buffer\n this._data = new Uint8Array(dataOrSize);\n this._size = 0;\n }\n else if ('buffer' in dataOrSize) {\n // append to existing data!\n this._data = new Uint8Array(dataOrSize.buffer, dataOrSize.byteOffset, dataOrSize.byteLength);\n this._size = dataOrSize.byteLength;\n }\n else {\n // overrides data\n this._isConst = true; // better than boolean for memory usage\n if (length == null) {\n // /!\\ Safari does not support undefined length, so we need to use byteLength instead\n length = dataOrSize.byteLength;\n }\n this._data = new Uint8Array(dataOrSize, offset, length);\n this._size = 0;\n }\n }\n data() {\n return new Uint8Array(this._data.buffer, this._data.byteOffset, this._size);\n }\n size() {\n return this._size || 0;\n }\n next(count = 1) {\n return this.reserve((this._size += count));\n }\n clear(size = 0) {\n return this.reserve((this._size = size));\n }\n write(data) {\n this.reserve(this._size + data.length);\n if (typeof data === 'string') {\n // beware here support just the 255 first bytes (compatible Latin-1)\n for (let i = 0; i < data.length; ++i) {\n const value = data.charCodeAt(i);\n this._data[this._size++] = value > 255 ? 32 : value;\n }\n return this;\n }\n this._data.set(data, this._size);\n this._size += data.length;\n return this;\n }\n write8(value) {\n if (value > 0xff) {\n // cast to 8bits range\n value = 0xff;\n }\n this.reserve(this._size + 1);\n this._data[this._size++] = value;\n return this;\n }\n write16(value) {\n if (value > 0xffff) {\n // cast to 16bits range\n value = 0xffff;\n }\n this.reserve(this._size + 2);\n this.view.setUint16(this._size, value);\n this._size += 2;\n return this;\n }\n write24(value) {\n if (value > 0xffffff) {\n // cast to 24bits range\n value = 0xffffff;\n }\n this.reserve(this._size + 3);\n this.view.setUint16(this._size, value >> 8);\n this.view.setUint8((this._size += 2), value & 0xff);\n ++this._size;\n return this;\n }\n write32(value) {\n if (value > 0xffffffff) {\n // cast to 32bits range\n value = 0xffffffff;\n }\n this.reserve(this._size + 4);\n this.view.setUint32(this._size, value);\n this._size += 4;\n return this;\n }\n writeFloat(value) {\n this.reserve(this._size + 4);\n this.view.setFloat32(this._size, value);\n this._size += 4;\n return this;\n }\n writeDouble(value) {\n this.reserve(this._size + 8);\n this.view.setFloat64(this._size, value);\n this._size += 8;\n return this;\n }\n write7Bit(value, bytes = 5) {\n if (bytes > 5) {\n throw Error(\"BinaryWriter in JS can't encode more than 32 usefull bits\");\n }\n if (!(bytes > 0)) {\n // negation to catch NaN value\n throw Error('Have to indicate a positive number of bytes to encode');\n }\n let bits = --bytes * 7;\n const front = value > 0xffffffff ? 0x100 : value >>> bits;\n if (front) {\n ++bits;\n if (front > 0xff) {\n value = 0xffffffff;\n }\n }\n else {\n while ((bits -= 7) && !(value >>> bits)) {\n continue;\n }\n }\n while (bits > 1) {\n this.write8(0x80 | ((value >>> bits) & 0xff));\n bits -= 7;\n }\n return this.write8(value & (bits ? 0xff : 0x7f));\n }\n writeString(value) {\n return this.write7Bit(value.length).write(value);\n }\n writeHex(value) {\n for (let i = 0; i < value.length; i += 2) {\n this.write8(parseInt(value.substring(i, i + 2), 16));\n }\n return this;\n }\n reserve(size) {\n if (!this._data) {\n throw new Error('buffer not writable');\n }\n if (size <= this._data.byteLength) {\n return this;\n }\n if (this._isConst) {\n throw new Error('writing exceeds maximum ' + this._data.byteLength + ' bytes limit');\n }\n --size;\n size |= size >> 1;\n size |= size >> 2;\n size |= size >> 4;\n size |= size >> 8;\n size |= size >> 16;\n ++size;\n const data = new Uint8Array(size);\n data.set(this._data); // copy old buffer!\n this._data = data;\n this._view = undefined; // release view\n return this;\n }\n}/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\nclass BitReader {\n constructor(data) {\n if ('buffer' in data) {\n this._data = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n }\n else {\n this._data = new Uint8Array(data);\n }\n this._size = this._data.byteLength;\n this._position = 0;\n this._bit = 0;\n }\n data() {\n return this._data;\n }\n size() {\n return this._size;\n }\n available() {\n return (this._size - this._position) * 8 - this._bit;\n }\n next(count = 1) {\n let gotten = 0;\n while (this._position !== this._size && count--) {\n ++gotten;\n if (++this._bit === 8) {\n this._bit = 0;\n ++this._position;\n }\n }\n return gotten;\n }\n read(count = 1) {\n let result = 0;\n while (this._position !== this._size && count--) {\n result <<= 1;\n if (this._data[this._position] & (0x80 >> this._bit++)) {\n result |= 1;\n }\n if (this._bit === 8) {\n this._bit = 0;\n ++this._position;\n }\n }\n return result;\n }\n read8() {\n return this.read(8);\n }\n read16() {\n return this.read(16);\n }\n read24() {\n return this.read(24);\n }\n read32() {\n return this.read(32);\n }\n}/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/**\n * Help class to manipulate and parse a net address. The Address can be only the domain field,\n * or a URL format with protocol and path part `(http://)domain(:port/path)`\n * @example\n * const address = new Address('nl-ams-42.live.ceeblue.tv:80');\n * console.log(address.domain) // 'nl-ams-42.live.ceeblue.tv'\n * console.log(address.port) // '80'\n * console.log(address) // 'nl-ams-42.live.ceeblue.tv:80'\n */\nclass NetAddress {\n /**\n * Static help function to build an end point from an address `(proto://)domain(:port/path)`\n *\n * Mainly it fix the protocol, in addition if:\n * - the address passed is securized (TLS) and protocol is not => it tries to fix protocol to get its securize version\n * - the address passed is non securized and protocol is (TLS) => it tries to fix protocol to get its unsecurized version\n * @param protocol protocol to set in the end point returned\n * @param address string address to fix with protocol as indicated\n * @returns the end point built\n * @example\n * console.log(NetAddress.fixProtocol('ws','http://domain/path')) // 'ws://domain/path'\n * console.log(NetAddress.fixProtocol('ws','https://domain/path')) // 'wss://domain/path'\n * console.log(NetAddress.fixProtocol('wss','http://domain/path')) // 'ws://domain/path'\n */\n static fixProtocol(protocol, address) {\n const found = address.indexOf('://');\n // isolate protocol is present in address\n if (found >= 0) {\n // In this case replace by protocol in keeping SSL like given in address\n if (found > 2 && address.charAt(found - 1).toLowerCase() === 's') {\n // SSL!\n if (protocol.length <= 2 || !protocol.endsWith('s')) {\n protocol += 's'; // Add SSL\n }\n }\n else {\n // Not SSL!\n if (protocol.length > 2 && protocol.endsWith('s')) {\n protocol = protocol.slice(0, -1); // Remove SSL\n }\n }\n // Build host!\n address = address.substring(found + 3);\n }\n return protocol + '://' + address;\n }\n /**\n * The domain part from address `(http://)domain(:port/path)`\n */\n get domain() {\n return this._domain;\n }\n /**\n * The port part from address `(http://)domain(:port/path)`, or defaultPort if passed in NetAddress constructor\n */\n get port() {\n return this._port;\n }\n /**\n * @returns the string address as passed in the constructor\n */\n toString() {\n return this._address;\n }\n /**\n * @returns the string address as passed in the constructor\n * @override\n */\n valueOf() {\n return this._address;\n }\n /**\n * Build a NetAddress object and parse address\n * @param address string address to parse, accept an url format with protocol and path `(http://)domain(:port/path)`\n * @param defaultPort set a default port to use if there is no port in the string address parsed\n */\n constructor(address, defaultPort) {\n this._address = address;\n // Remove Protocol\n let pos = address.indexOf('/');\n if (pos >= 0) {\n // Remove ://\n if (address.charCodeAt(pos + 1) === 47) {\n // has //\n if (pos > 0) {\n if (address.charCodeAt(pos - 1) === 58) {\n // has ://\n address = address.substring(pos + 2);\n } // something else #//\n }\n else {\n // otherwise starts by //\n address = address.substring(2);\n }\n }\n else if (!pos) {\n // starts by /, remove it\n address = address.substring(1);\n } // else something else #/\n }\n this._domain = address;\n this._port = defaultPort;\n // Parse Port\n pos = address.lastIndexOf(':');\n if (pos >= 0) {\n const port = parseInt(address.substring(pos + 1));\n if (port && port <= 0xffff) {\n this._port = port;\n this._domain = address.substring(0, pos);\n }\n }\n else {\n // Remove Path!\n pos = address.indexOf('/');\n if (pos >= 0) {\n this._domain = address.substring(0, pos);\n }\n }\n }\n}/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/**\n * Type of connection\n */\nvar Type;\n(function (Type) {\n Type[\"HESP\"] = \"hesp\";\n Type[\"WEBRTS\"] = \"webrts\";\n Type[\"WEBRTC\"] = \"webrtc\";\n Type[\"META\"] = \"meta\";\n Type[\"DATA\"] = \"data\";\n})(Type || (Type = {}));\n/**\n * Some connection utility functions\n */\n/**\n * Build an URL from {@link Type | type} and {@link Params | params}\n * @param type Type of the connection wanted\n * @param params Connection parameters\n * @param protocol Optional parameter to choose the prefered protocol to connect\n * @returns The URL of connection\n */\nfunction buildURL(type, params, protocol = 'wss') {\n const url = new URL(NetAddress.fixProtocol(protocol, params.host));\n if (url.pathname.length <= 1) {\n // build ceeblue path!\n switch (type) {\n case Type.HESP:\n url.pathname = '/hesp/' + params.streamName + '/index.json';\n break;\n case Type.WEBRTC:\n url.pathname = '/webrtc/' + params.streamName;\n break;\n case Type.WEBRTS:\n url.pathname = '/webrts/' + params.streamName;\n break;\n case Type.META:\n url.pathname = '/json_' + params.streamName + '.js';\n break;\n case Type.DATA:\n url.pathname = '/' + params.streamName + '.json';\n break;\n default:\n console.warn('Unknown url type ' + type);\n break;\n }\n } // Host has already a path! keep it unchanged, it's user intentionnal (used with some other WHIP/WHEP server?)\n if (params.accessToken) {\n url.searchParams.set('id', params.accessToken);\n }\n for (const key in params.query) {\n url.searchParams.set(key, params.query[key]);\n }\n return url;\n}var Connect=/*#__PURE__*/Object.freeze({__proto__:null,get Type(){return Type},buildURL:buildURL});/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/**\n * A advanced EventEmitter which allows to declare event as natural function in the inheriting children class,\n * function must start by `on` prefix to be recognized as an event.\n * The function can define a behavior by default, and user can choose to redefine this behavior,\n * or add an additionnal subscription for this event.\n * In addition you can unsubscribe to multiple events with an `AbortController`\n * @example\n * class Logger extends EventEmitter {\n * onLog(log:string) { console.log(log); } // behavior by default\n *\n * test() {\n * // raise event onLog\n * this.onLog('test');\n * }\n * }\n *\n * const logger = new Logger();\n * logger.test(); // displays a log 'test'\n *\n * // redefine default behavior to display nothing\n * logger.onLog = () => {}\n * logger.test(); // displays nothing\n *\n * // add an additionnal subscription\n * logger.on('log', console.log);\n * logger.test(); // displays a log 'test'\n *\n * // remove the additionnal subscription\n * logger.off('log', console.log);\n * logger.test(); // displays nothing\n *\n * // add two additionnal subscriptions with a AbortController\n * const controller = new AbortController();\n * logger.on('log', log => console.log(log), controller);\n * logger.on('log', log => console.error(log), controller);\n * logger.test(); // displays a log 'test' + an error 'test'\n *\n * // Unsubscribe all the subscription with the AbortController\n * controller.abort();\n * logger.test(); // displays nothing\n */\nclass EventEmitter {\n /**\n * Build our EventEmitter, usually call from children class\n */\n constructor() {\n this._events = new Map();\n // Fill events with events as defined!\n let proto = Object.getPrototypeOf(this);\n while (proto && proto !== Object.prototype) {\n for (const name of Object.getOwnPropertyNames(proto)) {\n if (name.length < 3 || !name.startsWith('on')) {\n continue;\n }\n if (proto[name] instanceof Function) {\n const events = new Set();\n this._events.set(name.substring(2).toLowerCase(), events);\n let defaultEvent = proto[name];\n Object.defineProperties(this, {\n [name]: {\n get: () => (...args) => {\n // Call default event if not null (can happen in JS usage)\n if (defaultEvent) {\n defaultEvent.call(this, ...args);\n }\n // Call subscribers\n for (const event of events) {\n event(...args);\n }\n },\n set: (value) => {\n // Assign a default behavior!\n defaultEvent = value;\n }\n }\n });\n }\n }\n proto = Object.getPrototypeOf(proto);\n }\n }\n /**\n * Event subscription\n * @param name Name of event without the `on` prefix (ex: `log` to `onLog` event declared)\n * @param event Subscriber Function\n * @param abort Optional `AbortController` to stop this or multiple subscriptions in same time\n */\n on(name, event, abort) {\n if (!event) {\n throw Error('event to subscribe cannot be null');\n }\n const events = this._event(name);\n events.add(event);\n if (abort) {\n abort.signal.addEventListener('abort', () => {\n events.delete(event);\n });\n }\n }\n /**\n * Event subscription only one time, once time fired it's automatically unsubscribe\n * @param name Name of event without the `on` prefix (ex: `log` to `onLog` event declared)\n * @param event Subscriber Function\n * @param abort Optional `AbortController` to stop this or multiple subscriptions in same time\n */\n once(name, event, abort) {\n if (!event) {\n throw Error('event to subscribe cannot be null');\n }\n const events = this._event(name);\n events.add(() => {\n events.delete(event); // delete from events\n event(); // execute event\n });\n if (abort) {\n abort.signal.addEventListener('abort', () => {\n events.delete(event);\n });\n }\n }\n /**\n * Event unsubscription\n * @param name Name of event without the 'on' prefix (ex: 'log' to 'onLog' event declared)\n * @param event Unsubscriber Function, must be the one passed to {@link on} or {@link once} subscription methods\n */\n off(name, event) {\n if (!event) {\n throw Error('event to unsubscribe cannot be null');\n }\n this._event(name).delete(event);\n }\n _event(name) {\n const events = this._events.get(name.toLowerCase());\n if (!events) {\n throw Error('No event on' + name + ' on class ' + this.constructor.name);\n }\n return events;\n }\n}/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/**\n * Queue typed similar to a {@link https://en.cppreference.com/w/cpp/container/queue | std::queue<Type>} with possibility to limit the capacity like a FIFO\n * @example\n * const queue = new Queue<number>(2);\n * queue.push(1); // [1]\n * queue.push(2); // [1,2]\n * queue.push(3); // [2,3] 1 has been removed to respect 2 capacity\n */\nclass Queue {\n /**\n * Number of element in the queue\n */\n get size() {\n return this._queue.length;\n }\n /**\n * Maximum capacity for the queue, if not set queue has unlimited capacity\n */\n get capacity() {\n return this._capacity;\n }\n /**\n * Set a maximum capacity for the queue,\n * if you push new value exceding this capacity the firsts are removed (FIFO)\n * if set to undefined the queue is unlimited\n */\n set capacity(value) {\n this._capacity = value;\n if (value != null && this._queue.length > value) {\n this._queue.splice(0, this._queue.length - value);\n }\n }\n /**\n * The front element\n */\n get front() {\n return this._queue[0];\n }\n /**\n * The back element\n */\n get back() {\n return this._queue[this._queue.length - 1];\n }\n /**\n * Iterator though queue's elements\n */\n [Symbol.iterator]() {\n return this._queue[Symbol.iterator]();\n }\n /**\n * Instanciate a new queue object with the type passed as template\n * @param capacity if set it limits the size of the queue, any exceding element pops the first element pushed (FIFO)\n */\n constructor(capacity) {\n this._capacity = capacity;\n this._queue = new Array();\n }\n /**\n * Push a new element in the queue\n * @param value value of the element\n * @returns this\n */\n push(value) {\n if (this._capacity != null && this._queue.push(value) > this._capacity) {\n this.pop();\n }\n return this;\n }\n /**\n * Pop the first element from the queue\n * @returns The first element removed\n */\n pop() {\n return this._queue.shift();\n }\n /**\n * Clear all the elements, queue becomes empty\n * @returns this\n */\n clear() {\n this._queue.length = 0;\n return this;\n }\n}/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/**\n * A collection of number Queue<number> with the following efficient mathematic computation:\n * - minimum value in the collection\n * - maximum value in the collection\n * - average value of the collection\n */\nclass Numbers extends Queue {\n /**\n * minimum value in the collection, or 0 if colleciton is empty\n */\n get minimum() {\n return this._min;\n }\n /**\n * maximum value in the collection, or 0 if colleciton is empty\n */\n get maximum() {\n return this._max;\n }\n /**\n * average value of the collection, or 0 if collection if empty\n */\n get average() {\n if (this._average == null) {\n this._average = this.size ? this._sum / this.size : 0;\n }\n return this._average;\n }\n /**\n * Instantiate the collection of the number\n * @param capacity if set it limits the number of values stored, any exceding number pops the first number pushed (FIFO)\n */\n constructor(capacity) {\n super(capacity);\n this._sum = 0;\n this._min = 0;\n this._max = 0;\n }\n /**\n * Push a value to the back to the collection\n * @param value number to add\n * @returns this\n */\n push(value) {\n if (value > this._max) {\n this._max = value;\n }\n else if (value < this._min) {\n this._min = value;\n }\n this._average = undefined;\n this._sum += value;\n super.push(value);\n return this;\n }\n /**\n * Pop the front number from the collection\n * @returns the front number removed\n */\n pop() {\n const front = super.pop();\n if (front === this._max) {\n this._max = Math.max(0, ...this);\n }\n else if (front === this._min) {\n this._min = Math.min(0, ...this);\n }\n this._average = undefined;\n this._sum -= front || 0;\n return front;\n }\n /**\n * Clear all the numbers, collection becomes empty\n * @returns this\n */\n clear() {\n this._min = this._max = this._sum = 0;\n super.clear();\n return this;\n }\n}/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/**\n * Toolkit to deal with Session Description Protocol (SDP),\n * mainly to tranform a SDP string Offer/Answer to a manipulable JS object representation\n * @example\n * const peerConnection = new RTCPeerConnection();\n * peerConnection.createOffer()\n * .then( offer =>\n * // Change offer.sdp string to a JS manipulable object\n * const sdp = SDP.fromString(offer.sdp || '');\n * // Change a property of SDP\n * sdp.v = 2; // change SDP version\n * // Reserialize to the legal SDP string format\n * offer.sdp = SDP.toString(sdp);\n * // Set SDP offer to peerConnection\n * peerConnection.setLocalDescription(offer);\n * )\n */\nconst SDP = {\n /**\n * Unserialize SDP string to a manipulable JS object representation\n * It's an object with:\n * - root SDP properties\n * - media description iterable\n * @param lines SDP string reprensentation\n * @returns SDP object representation, iterable through media description\n * @example\n * [\n * group: \"DUNBLE 0 1\",\n * o: \"- 1699450751193623 0 IN IP4 0.0.0.0\",\n * s: \"-\",\n * t: \"0 0\",\n * v: \"0\",\n * ice-lite: \"\",\n * length: 2,\n * {\n * m: \"audio 9 UDP/TLS/RTP/SAVPF 111\",\n * c: \"IN IP4 0.0.0.0\",\n * rtcp: \"9\",\n * sendonly: \"\",\n * setup: \"passive\",\n * fingerprint: \"sha-256 51:36:ED:78:A4:9F:25:8C:39:9A:0E:A0:B4:9B:6E:04:37:FF:AD:96:93:71:43:88:2C:0B:0F:AB:6F:9A:52:B8\",\n * ice-ufrag: \"fa37\",\n * ice-pwd: \"JncCHryDsbzayy4cBWDxS2\",\n * rtcp-mux: \"\",\n * rtcp-rsize: \"\",\n * rtpmap: \"111 opus/48000/2\",\n * rtcp-fb: \"111 nack\",\n * id: \"0\",\n * fmtp: \"111 minptime=10;useinbandfec=1\",\n * candidate: \"1 1 udp 2130706431 89.105.221.108 56643 typ host\",\n * end-of-candidates: \"\"\n * },\n * {\n * m: \"video 9 UDP/TLS/RTP/SAVPF 106\",\n * c: \"IN IP4 0.0.0.0\",\n * rtcp: \"9\",\n * sendonly: \"\",\n * setup: \"passive\",\n * fingerprint: \"sha-256 51:36:ED:78:A4:9F:25:8C:39:9A:0E:A0:B4:9B:6E:04:37:FF:AD:96:93:71:43:88:2C:0B:0F:AB:6F:9A:52:B8\",\n * ice-ufrag: \"fa37\",\n * ice-pwd: \"JncCHryDsbzayy4cBWDxS2\",\n * rtcp-mux: \"\",\n * rtcp-rsize: \"\",\n * rtpmap: \"106 H264/90000\",\n * rtcp-fb: [\n * \"106 nack\",\n * \"106 goog-remb\"\n * ],\n * mid: \"1\",\n * fmtp: \"106 profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1\",\n * candidate: \"1 1 udp 2130706431 89.105.221.108 56643 typ host\",\n * end-of-candidates: \"\"\n * }\n * ]\n */\n fromString(lines) {\n if (Array.isArray(lines)) {\n return lines; // already converted\n }\n const sdp = new Array();\n let media = sdp;\n let fingerprint;\n for (let line of lines.toString().split('\\n')) {\n line = line.trim();\n if (!line) {\n continue;\n }\n let key = line[0];\n const value = line.substring(line.indexOf('=') + 1).trim();\n switch (key.toLowerCase()) {\n case 'a': {\n if (!value) {\n continue;\n } // empty attribute!\n key = this.addAttribute(media, value);\n // save fingerprint to repeat it in medias\n if (sdp === media && key.toLowerCase() === 'fingerprint') {\n fingerprint = media.fingerprint;\n }\n break;\n }\n case 'm':\n if (sdp.length && fingerprint && !sdp[sdp.length - 1].fingerprint) {\n media.fingerprint = fingerprint;\n }\n sdp.push((media = { m: value }));\n break;\n default:\n media[key] = value;\n }\n }\n if (sdp.length && fingerprint && !sdp[sdp.length - 1].fingerprint) {\n media.fingerprint = fingerprint;\n }\n return sdp;\n },\n /**\n * Serialize SDP JS object to a SDP string legal representation\n * @param sdp SDP object reprensetation\n * @returns SDP string reprensentation\n */\n toString(sdp) {\n if (typeof sdp === 'string') {\n return sdp; // already converted\n }\n const medias = [];\n // https://www.cl.cam.ac.uk/~jac22/books/mm/book/node182.html\n let lines = 'v' in sdp ? 'v=' + sdp.v + '\\n' : '';\n if ('o' in sdp) {\n lines += 'o=' + sdp.o + '\\n';\n }\n if ('s' in sdp) {\n lines += 's=' + sdp.s + '\\n';\n }\n const obj = sdp;\n for (const key of Object.keys(sdp)) {\n if (key === 'v' || key === 'o' || key === 's') {\n continue;\n }\n const value = obj[key];\n if (value == null) {\n continue;\n } // ignore this key/value\n const index = parseInt(key);\n if (!isNaN(index)) {\n // Is a number! Media object!\n medias[index] = value;\n continue;\n }\n const count = (Array.isArray(value) && value.length) || 1; // value can be numeric!\n for (let i = 0; i < count; ++i) {\n const line = Array.isArray(value) && value.length ? value[i] : value;\n if (key.length > 1) {\n // when key is superior to 1 letter it's a attribute!\n lines += 'a=' + key;\n if (line) {\n lines += ':';\n }\n }\n else {\n lines += key + '=';\n }\n lines += line + '\\n';\n }\n }\n for (const media of medias) {\n lines += this.toString(media);\n }\n return lines;\n },\n /**\n * While set a property to a SDP object representation is possible directly,\n * we could prefer add a new property without overload a possible already existing value.\n * This function allows to add a property to our SDP representation:\n * - if the key's attribute doesn't exists yet it adds it like a simple JS property sdp[key] = value\n * - if the key's attribute exists already it morphs the value to a Array and push it inside\n * @param sdp the SDP object representation on which added the attribute\n * @param attribute the string attribut in a format \"key:value\" or just \"key\" to add an attribute without value\n * @returns the key part of the attribute added (or if value is empty it returns the same attribute as passed in argument)\n */\n addAttribute(sdp, attribute) {\n var _a;\n const a = SDP.parseAttribute(attribute);\n const value = (_a = a.value) !== null && _a !== void 0 ? _a : ''; // to allow to test if key exists even without value with if(sdp.key != null)\n const obj = sdp;\n const oldValue = obj[a.key];\n if (!oldValue) {\n obj[a.key] = value;\n }\n else if (Array.isArray(oldValue)) {\n oldValue.push(value);\n }\n else if (value !== oldValue) {\n obj[a.key] = [oldValue, value];\n }\n return a.key;\n },\n /**\n * While it's possible to delete a attribute manually on the SDP object representation with a delete sdp.key,\n * we could prefer remove only a value in a sdp.key array containing multiple values.\n * Like opposite to addAttribute this method allows to remove an unique attribute value.\n * @param sdp the SDP object representation on which removed the attribute\n * @param attribute the string attribut in a format \"key:value\" or just \"key\" to remove the whole attribute and all its values\n * @returns the key part of the attribute removed (or if value is empty it returns the same attribute as passed in argument)\n */\n removeAttribute(sdp, attribute) {\n const a = SDP.parseAttribute(attribute);\n const obj = sdp;\n if (a.value === undefined) {\n delete obj[attribute];\n return attribute;\n }\n const current = obj[attribute];\n if (Array.isArray(a.value)) {\n const i = current.findIndex((current) => current === a.value);\n if (i >= 0) {\n current.splice(i, 1);\n }\n }\n else if (current === a.value) {\n delete obj[attribute];\n }\n return a.key;\n },\n /**\n * Parse an attribute in a format \"key:value\"\n * @param attribute string attribute to parse\n * @returns the {key, value} result, with value undefined if attribute was a \"key\" without value\n */\n parseAttribute(attribute) {\n const found = attribute.indexOf(':');\n return {\n key: (found >= 0 ? attribute.substring(0, found) : attribute).trim(),\n value: found >= 0 ? attribute.substring(found + 1).trim() : undefined\n };\n }\n};\nObject.freeze(SDP);/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\nconst _decoder = new TextDecoder();\nconst _encoder = new TextEncoder();\n/* eslint-disable @typescript-eslint/no-explicit-any */\nconst _perf = performance; // to increase x10 now performance!\n/**\n * Some basic utility functions\n */\n/**\n * Version of the library\n */\nconst VERSION = '1.0.0';\n/**\n * An empty lambda function, pratical to disable default behavior of function or events which are not expected to be null\n * @example\n * console.log = Util.EMPTY_FUNCTION; // disable logs without breaking calls\n */\nconst EMPTY_FUNCTION = () => { };\n/**\n * Efficient and high resolution timestamp in milliseconds elapsed since {@link Util.timeOrigin}\n */\nfunction time() {\n return Math.floor(_perf.now());\n}\n/**\n * Time origin represents the time when the application has started\n */\nfunction timeOrigin() {\n return Math.floor(_perf.now() + _perf.timeOrigin);\n}\n/**\n * Parse query and returns it in an easy-to-use Javascript object form\n * @param urlOrQueryOrSearch string, url, or searchParams containing query. If not set it uses `location.search` to determinate query.\n * @returns An javascript object containing each option\n */\nfunction options(urlOrQueryOrSearch = typeof location === 'undefined'\n ? undefined\n : location) {\n if (!urlOrQueryOrSearch) {\n return {};\n }\n try {\n const url = urlOrQueryOrSearch;\n urlOrQueryOrSearch = new URL(url).searchParams;\n }\n catch (e) {\n if (typeof urlOrQueryOrSearch == 'string') {\n if (urlOrQueryOrSearch.startsWith('?')) {\n urlOrQueryOrSearch = urlOrQueryOrSearch.substring(1);\n }\n urlOrQueryOrSearch = new URLSearchParams(urlOrQueryOrSearch);\n }\n }\n // works same if urlOrQueryOrSearch is null, integer, or a already object etc...\n return objectFrom(urlOrQueryOrSearch, { withType: true, noEmptyString: true });\n}\n/**\n * Returns an easy-to-use Javascript object something iterable, such as a Map, Set, or Array\n * @param value iterable input\n * @param params.withType `false`, if set it tries to cast string value to a JS number/boolean/undefined/null type.\n * @param params.noEmptyString `false`, if set it converts empty string value to a true boolean, usefull to allow a `if(result.key)` check for example\n * @returns An javascript object\n */\nfunction objectFrom(value, params) {\n params = Object.assign({ withType: false, noEmptyString: false }, params);\n const obj = {};\n if (!value) {\n return obj;\n }\n for (const [key, val] of objectEntries(value)) {\n value = val;\n if (params.withType && value != null && value.substring) {\n if (value) {\n const number = Number(value);\n if (isNaN(number)) {\n switch (value.toLowerCase()) {\n case 'true':\n value = true;\n break;\n case 'false':\n value = false;\n break;\n case 'null':\n value = null;\n break;\n case 'undefined':\n value = undefined;\n break;\n }\n }\n else {\n value = number;\n }\n }\n else if (params.noEmptyString) {\n // if empty string => TRUE to allow a if(options.key) check for example\n value = true;\n }\n }\n if (obj[key]) {\n if (!Array.isArray(obj[key])) {\n obj[key] = new Array(obj[key]);\n }\n obj[key].push(value);\n }\n else {\n obj[key] = value;\n }\n }\n return obj;\n}\n/**\n * Returns entries from something iterable, such as a Map, Set, or Array\n * @param value iterable input\n * @returns An javascript object\n */\nfunction objectEntries(value) {\n if (value.entries) {\n return value.entries();\n }\n return Array.from({\n [Symbol.iterator]: function* () {\n for (const key in value) {\n yield [key, value[key]];\n }\n }\n });\n}\n/**\n * Converts various data types, such as objects, strings, exceptions, errors,\n * or numbers, into a string representation. Since it offers a more comprehensive format,\n * this function is preferred to `JSON.stringify()`.\n * @param obj Any objects, strings, exceptions, errors, or number\n * @param params.space `''`, allows to configure space in the string representation\n * @param params.decimal `2`, allows to choose the number of decimal to display in the string representation\n * @param params.recursive `false`, allows to serialize recursively every object value, beware if a value refers to a already parsed value an infinite loop will occur.\n * @returns the final string representation\n */\n// Online Javascript Editor for free\n// Write, Edit and Run your Javascript code using JS Online Compiler\nfunction stringify(obj, params = {}) {\n params = Object.assign({ space: ' ', decimal: 2, recursive: 1 }, params);\n if (!obj) {\n return String(obj);\n }\n const error = obj.error || obj.message;\n if (error) {\n // is a error!\n obj = error;\n }\n if (obj.toFixed) {\n return obj.toFixed(Number(params.decimal) || 0);\n }\n if (obj.substring || !params.recursive) {\n // is already a string OR has to be stringified\n return String(obj);\n }\n const space = params.space || '';\n if (Array.isArray(obj)) {\n // Array!\n let res = '';\n for (const value of obj) {\n res += (res ? ',' : '[') + space;\n res += stringify(value, Object.assign(params, { recursive: params.recursive - 1 }));\n }\n return (res += space + ']');\n }\n if (obj.byteLength != null && (obj === null || obj === void 0 ? void 0 : obj[Symbol.iterator])) {\n // Binary!\n return _decoder.decode(obj);\n }\n let res = '';\n for (const name in obj) {\n res += (res ? ',' : '{') + space + name + ':';\n res += stringify(obj[name], Object.assign(params, { recursive: params.recursive - 1 }));\n }\n return (res += space + '}');\n}\nfunction toBin(value) {\n return _encoder.encode(value);\n}var Util=/*#__PURE__*/Object.freeze({__proto__:null,EMPTY_FUNCTION:EMPTY_FUNCTION,VERSION:VERSION,objectFrom:objectFrom,options:options,stringify:stringify,time:time,timeOrigin:timeOrigin,toBin:toBin});/**\n * Copyright 2023 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/**\n * The WebSocketReliable class extends WebSocket to bring up the following improvements:\n * - Fix all possible unintentional closing ways to get always a related error message, {@link onClose | onClose(error?) event}\n * - Make possible message sending while connecting. Indeed no need to wait {@link onOpen} before to send message,\n * you can open the socket and immediately send messages, it will be queue and flushs on connection etablishment\n * - Make possible a delayed connection, or a reconnection. Indeed you can create an unconnected Websocket instance\n * without passing any url argument and starts the conneciton more later with {@link WebSocketReliable.open(url) | open(url)} method\n * - Make possible to control sending/queueing message: send method take an optional queueing=true argument to\n * queue message rather send it, a futur call to flush will send it. Then queueing getter allows to handle the queue\n * if need to purge it or remove some queued message. Use it all together can help to prioritize messages or control overload.\n * @example\n * const ws = new WebSocketReliable(url);\n * ws.onClose = (error?:string) => {\n * if(error) {\n * console.error(error);\n * }\n * // reconnection attempt every seconds\n * setTimeout(() => ws.open(url), 1000);\n * }\n * ws.onMessage = (message:string) => {\n * console.log(message);\n * }\n * ws.send('hello'); // send immediatly a hello message is possible (no need to wait onOpen)\n */\nclass WebSocketReliable extends EventEmitter {\n /**\n * @event `open` fired when socket is connected\n */\n onOpen() { }\n /**\n * @event `message` fired on message reception\n * @param message can be binary or string.\n * If you subscribe to the event with message as string type (and not union),\n * it means that you know that all your messages are distributed in a string format\n */\n onMessage(message) { }\n /**\n * @event `close` fired on websocket close\n * @param error error description on an improper closure\n */\n onClose(error) {\n if (error) {\n console.error(error);\n }\n }\n /**\n * binaryType, fix binary type to arrayBuffer\n */\n get binaryType() {\n return 'arraybuffer';\n }\n /**\n * url of connection\n */\n get url() {\n var _a, _b;\n return (_b = (_a = this._ws) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : '';\n }\n /**\n * extensions negociated by the server\n */\n get extensions() {\n var _a, _b;\n return (_b = (_a = this._ws) === null || _a === void 0 ? void 0 : _a.extensions) !== null && _b !== void 0 ? _b : '';\n }\n /**\n * protocol negociated by the server\n */\n get protocol() {\n var _a, _b;\n return (_b = (_a = this._ws) === null || _a === void 0 ? void 0 : _a.protocol) !== null && _b !== void 0 ? _b : '';\n }\n /**\n * opened equals true when connection is etablished, in other word when onOpen event is fired\n */\n get opened() {\n return this._opened;\n }\n /**\n * {@link https://developer.mozilla.org/docs/Web/API/WebSocket/readyState | Official websocket readyState}\n */\n get readyState() {\n return this._ws ? this._ws.readyState : 3;\n }\n /**\n * True when connection is closed, in other words when {@link onClose} event is fired\n * or when WebSocketReliable is build without url (disconnected creation)\n */\n get closed() {\n return this._closed;\n }\n /**\n * The number of bytes of data that were queued during calls to send() but not yet transmitted to the network\n */\n get bufferedAmount() {\n var _a;\n return this._queueingBytes + (((_a = this._ws) === null || _a === void 0 ? void 0 : _a.bufferedAmount) || 0);\n }\n /**\n * Queued messages from a call to send() waiting to be transmit one time websocket connection opened (or with an explicit call to flush() method)\n */\n get queueing() {\n return this._queueing;\n }\n /**\n * Create a WebSocketReliable object, and open it if an url is passed in argument\n * @param url URL of the WebSocket endpoint or null to start the connection later\n */\n constructor(url, protocols) {\n super();\n this._queueing = [];\n this._queueingBytes = 0;\n this._opened = false;\n this._closed = true;\n if (url) {\n this.open(url, protocols);\n }\n }\n /**\n * Open a WebSocket connection\n * @param url url of the websocket endpoint\n * @returns this\n */\n open(url, protocols) {\n this._closed = false;\n const ws = (this._ws = new WebSocket(url, protocols));\n ws.binaryType = this.binaryType;\n ws.onmessage = e => this.onMessage(e.data);\n // Add details and fix close ways\n ws.onclose = (e) => {\n if (!this._opened) {\n // close during connection\n this.close(url.toString() + ' connection failed (' + String(e.reason || e.code) + ')');\n }\n else if (e.code === 1000 || e.code === 1005) {\n // normal disconnection from server (no error code)\n this.close(url.toString() + ' shutdown');\n }\n else {\n // disconnection from server\n this.close(url.toString() + ' disconnection (' + String(e.reason || e.code) + ')');\n }\n };\n // Wrap send method to queue messages until connection is established.\n ws.onopen = _ => {\n this._opened = true;\n this.flush();\n this.onOpen();\n };\n return this;\n }\n /**\n * Send a message\n * @param message\n * @param queueing When set it reports the sending to a more later call to flush\n * @returns this\n */\n send(message, queueing = false) {\n if (!this._ws) {\n throw Error('Open socket before to send data');\n }\n if (queueing || !this._opened) {\n this._queueing.push(message);\n this._queueingBytes += typeof message === 'string' ? message.length : message.byteLength;\n }\n else {\n this._ws.send(message);\n }\n return this;\n }\n /**\n * Send queueing messages\n */\n flush() {\n if (this._ws) {\n for (const message of this._queueing) {\n this._ws.send(message);\n }\n }\n this._queueing.length = 0;\n this._queueingBytes = 0;\n }\n /**\n * Close websocket\n * @param error the error reason if is not a proper close\n */\n close(error) {\n if (!this._ws || this._closed) {\n return;\n }\n this._closed = true;\n this._ws.onopen = this._ws.onclose = this._ws.onmessage = null; // otherwise can receive message AFTER close!\n this._ws.close(); // Don't set to undefined to keep this._ws properties valid!\n // release resources!\n this._opened = false;\n this._queueing.length = 0;\n this._queueingBytes = 0;\n this.onClose(error);\n }\n}export{BinaryReader,BinaryWriter,BitReader,Connect,EventEmitter,NetAddress,Numbers,Queue,SDP,Util,WebSocketReliable};//# sourceMappingURL=web-utils.js.map\n"],"names":["BinaryReader","constructor","data","this","_data","Uint8Array","buffer","byteOffset","byteLength","_size","_position","_view","DataView","size","available","value","position","reset","shrink","rest","next","count","read8","getUint8","read16","getUint16","read24","read32","getUint32","readFloat","getFloat32","readDouble","getFloat64","read7Bit","bytes","Error","byte","result","readString","String","fromCharCode","read","readHex","hex","toString","slice","subarray","BinaryWriter","view","capacity","dataOrSize","offset","length","_isConst","reserve","clear","write","i","charCodeAt","set","write8","write16","setUint16","write24","setUint8","write32","setUint32","writeFloat","setFloat32","writeDouble","setFloat64","write7Bit","bits","front","writeString","writeHex","parseInt","substring","undefined","BitReader","_bit","gotten","NetAddress","fixProtocol","protocol","address","found","indexOf","charAt","toLowerCase","endsWith","domain","_domain","port","_port","_address","valueOf","defaultPort","pos","lastIndexOf","Type","Connect","Object","freeze","__proto__","buildURL","type","params","url","URL","host","pathname","HESP","streamName","WEBRTC","WEBRTS","META","DATA","console","warn","accessToken","searchParams","key","query","EventEmitter","_events","Map","proto","getPrototypeOf","prototype","name","getOwnPropertyNames","startsWith","Function","events","Set","defaultEvent","defineProperties","get","args","call","event","on","abort","_event","add","signal","addEventListener","delete","once","off","Queue","_queue","_capacity","splice","back","Symbol","iterator","Array","push","pop","shift","Numbers","minimum","_min","maximum","_max","average","_average","_sum","super","Math","max","min","SDP","fromString","lines","isArray","sdp","fingerprint","media","line","split","trim","addAttribute","m","medias","v","o","s","obj","keys","index","isNaN","attribute","_a","a","parseAttribute","oldValue","removeAttribute","current","findIndex","_decoder","TextDecoder","_encoder","TextEncoder","_perf","performance","objectFrom","assign","withType","noEmptyString","val","entries","from","objectEntries","number","Number","Util","EMPTY_FUNCTION","VERSION","options","urlOrQueryOrSearch","location","e","URLSearchParams","stringify","space","decimal","recursive","error","message","toFixed","res","decode","time","floor","now","timeOrigin","toBin","encode","WebSocketReliable","onOpen","onMessage","onClose","binaryType","_b","_ws","extensions","opened","_opened","readyState","closed","_closed","bufferedAmount","_queueingBytes","queueing","_queueing","protocols","open","ws","WebSocket","onmessage","onclose","code","close","reason","onopen","_","flush","send"],"mappings":"AAQA,MAAMA,EACF,WAAAC,CAAYC,GACRC,KAAKC,MACD,WAAYF,EAAO,IAAIG,WAAWH,EAAKI,OAAQJ,EAAKK,WAAYL,EAAKM,YAAc,IAAIH,WAAWH,GACtGC,KAAKM,MAAQN,KAAKC,MAAMI,WACxBL,KAAKO,UAAY,EACjBP,KAAKQ,MAAQ,IAAIC,SAAST,KAAKC,MAAME,OAAQH,KAAKC,MAAMG,WAAYJ,KAAKM,MAC5E,CACD,IAAAP,GACI,OAAOC,KAAKC,KACf,CACD,IAAAS,GACI,OAAOV,KAAKM,KACf,CACD,SAAAK,GACI,OAAOX,KAAKM,MAAQN,KAAKO,SAC5B,CACD,KAAAK,CAAMC,EAAWb,KAAKO,WAClB,OAAOP,KAAKC,MAAMY,EACrB,CACD,QAAAA,GACI,OAAOb,KAAKO,SACf,CACD,KAAAO,CAAMD,EAAW,GACbb,KAAKO,UAAYM,EAAWb,KAAKM,MAAQN,KAAKM,MAAQO,CACzD,CACD,MAAAE,CAAOJ,GACH,MAAMK,EAAOhB,KAAKM,MAAQN,KAAKO,UAC/B,OAAII,EAAYK,EACLA,GAEXhB,KAAKM,MAAQN,KAAKO,UAAYI,EACvBA,EACV,CACD,IAAAM,CAAKC,EAAQ,GACT,MAAMF,EAAOhB,KAAKM,MAAQN,KAAKO,UAK/B,OAJIW,EAAQF,IACRE,EAAQF,GAEZhB,KAAKO,WAAaW,EACXA,CACV,CACD,KAAAC,GACI,OAAwB,IAAjBnB,KAAKiB,KAAK,GAAWjB,KAAKQ,MAAMY,SAASpB,KAAKO,UAAY,GAAK,CACzE,CACD,MAAAc,GACI,OAAwB,IAAjBrB,KAAKiB,KAAK,G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KuP,SAAU,EACfvP,KAAK8P,UAAU7M,OAAS,EACxBjD,KAAK4P,eAAiB,EACtB5P,KAAKiP,QAAQd,GAChB,SACLtO,kBAAA+C,kBAAAgC,eAAAsB,aAAAuB,kBAAA1C,gBAAAgF,aAAAX,WAAAuB,SAAA4C,UAAAuB"}
|
|
1
|
+
{"version":3,"file":"web-utils.min.js","sources":["web-utils.js"],"sourcesContent":["/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/**\n * BinaryReader allows to read binary data\n */\nclass BinaryReader {\n constructor(data) {\n this._data =\n 'buffer' in data ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength) : new Uint8Array(data);\n this._size = this._data.byteLength;\n this._position = 0;\n this._view = new DataView(this._data.buffer, this._data.byteOffset, this._size);\n }\n data() {\n return this._data;\n }\n size() {\n return this._size;\n }\n available() {\n return this._size - this._position;\n }\n value(position = this._position) {\n return this._data[position];\n }\n position() {\n return this._position;\n }\n reset(position = 0) {\n this._position = position > this._size ? this._size : position;\n }\n shrink(available) {\n const rest = this._size - this._position;\n if (available > rest) {\n return rest;\n }\n this._size = this._position + available;\n return available;\n }\n next(count = 1) {\n const rest = this._size - this._position;\n if (count > rest) {\n count = rest;\n }\n this._position += count;\n return count;\n }\n read8() {\n return this.next(1) === 1 ? this._view.getUint8(this._position - 1) : 0;\n }\n read16() {\n return this.next(2) === 2 ? this._view.getUint16(this._position - 2) : 0;\n }\n read24() {\n return this.next(3) === 3\n ? (this._view.getUint16(this._position - 3) << 8) | (this._view.getUint8(this._position - 1) & 0xff)\n : 0;\n }\n read32() {\n return this.next(4) === 4 ? this._view.getUint32(this._position - 4) : 0;\n }\n readFloat() {\n return this.next(4) === 4 ? this._view.getFloat32(this._position - 4) : 0;\n }\n readDouble() {\n return this.next(8) === 8 ? this._view.getFloat64(this._position - 8) : 0;\n }\n read7Bit(bytes = 5) {\n if (bytes > 5) {\n throw Error(\"BinaryReader in JS can't decode more than 32 usefull bits\");\n }\n if (!(bytes > 0)) {\n // negation to catch NaN value\n throw Error('Have to indicate a positive number of bytes to decode');\n }\n let result = 0;\n let byte;\n do {\n byte = this.read8();\n if (!--bytes) {\n return ((result << 8) | byte) >>> 0; // Use all 8 bits from the 5th byte\n }\n result = (result << 7) | (byte & 0x7f);\n } while (byte & 0x80);\n return result;\n }\n readString() {\n return String.fromCharCode(...this.read(this.read7Bit()));\n }\n readHex(size) {\n let hex = '';\n while (size--) {\n hex += ('0' + this.read8().toString(16)).slice(-2);\n }\n return hex;\n }\n /**\n * Read bytes, to convert bytes to string use String.fromCharCode(...reader.read(size))\n * @param {UInt32} size\n */\n read(size = this.available()) {\n if (this.available() < size) {\n return new Uint8Array(size); // default value = empty bytearray!\n }\n const value = this._data.subarray(this._position, this._position + size);\n this._position += size;\n return value;\n }\n}/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/**\n * BinaryWriter allows to write data in its binary form\n */\nclass BinaryWriter {\n get view() {\n if (!this._view) {\n this._view = new DataView(this._data.buffer, this._data.byteOffset, this._data.byteLength);\n }\n return this._view;\n }\n get capacity() {\n return this._data.byteLength;\n }\n constructor(dataOrSize = 64, offset = 0, length) {\n if (typeof dataOrSize == 'number') {\n // allocate new buffer\n this._data = new Uint8Array(dataOrSize);\n this._size = 0;\n }\n else if ('buffer' in dataOrSize) {\n // append to existing data!\n this._data = new Uint8Array(dataOrSize.buffer, dataOrSize.byteOffset, dataOrSize.byteLength);\n this._size = dataOrSize.byteLength;\n }\n else {\n // overrides data\n this._isConst = true; // better than boolean for memory usage\n if (length == null) {\n // /!\\ Safari does not support undefined length, so we need to use byteLength instead\n length = dataOrSize.byteLength;\n }\n this._data = new Uint8Array(dataOrSize, offset, length);\n this._size = 0;\n }\n }\n data() {\n return new Uint8Array(this._data.buffer, this._data.byteOffset, this._size);\n }\n size() {\n return this._size || 0;\n }\n next(count = 1) {\n return this.reserve((this._size += count));\n }\n clear(size = 0) {\n return this.reserve((this._size = size));\n }\n write(data) {\n this.reserve(this._size + data.length);\n if (typeof data === 'string') {\n // beware here support just the 255 first bytes (compatible Latin-1)\n for (let i = 0; i < data.length; ++i) {\n const value = data.charCodeAt(i);\n this._data[this._size++] = value > 255 ? 32 : value;\n }\n return this;\n }\n this._data.set(data, this._size);\n this._size += data.length;\n return this;\n }\n write8(value) {\n if (value > 0xff) {\n // cast to 8bits range\n value = 0xff;\n }\n this.reserve(this._size + 1);\n this._data[this._size++] = value;\n return this;\n }\n write16(value) {\n if (value > 0xffff) {\n // cast to 16bits range\n value = 0xffff;\n }\n this.reserve(this._size + 2);\n this.view.setUint16(this._size, value);\n this._size += 2;\n return this;\n }\n write24(value) {\n if (value > 0xffffff) {\n // cast to 24bits range\n value = 0xffffff;\n }\n this.reserve(this._size + 3);\n this.view.setUint16(this._size, value >> 8);\n this.view.setUint8((this._size += 2), value & 0xff);\n ++this._size;\n return this;\n }\n write32(value) {\n if (value > 0xffffffff) {\n // cast to 32bits range\n value = 0xffffffff;\n }\n this.reserve(this._size + 4);\n this.view.setUint32(this._size, value);\n this._size += 4;\n return this;\n }\n writeFloat(value) {\n this.reserve(this._size + 4);\n this.view.setFloat32(this._size, value);\n this._size += 4;\n return this;\n }\n writeDouble(value) {\n this.reserve(this._size + 8);\n this.view.setFloat64(this._size, value);\n this._size += 8;\n return this;\n }\n write7Bit(value, bytes = 5) {\n if (bytes > 5) {\n throw Error(\"BinaryWriter in JS can't encode more than 32 usefull bits\");\n }\n if (!(bytes > 0)) {\n // negation to catch NaN value\n throw Error('Have to indicate a positive number of bytes to encode');\n }\n let bits = --bytes * 7;\n const front = value > 0xffffffff ? 0x100 : value >>> bits;\n if (front) {\n ++bits;\n if (front > 0xff) {\n value = 0xffffffff;\n }\n }\n else {\n while ((bits -= 7) && !(value >>> bits)) {\n continue;\n }\n }\n while (bits > 1) {\n this.write8(0x80 | ((value >>> bits) & 0xff));\n bits -= 7;\n }\n return this.write8(value & (bits ? 0xff : 0x7f));\n }\n writeString(value) {\n return this.write7Bit(value.length).write(value);\n }\n writeHex(value) {\n for (let i = 0; i < value.length; i += 2) {\n this.write8(parseInt(value.substring(i, i + 2), 16));\n }\n return this;\n }\n reserve(size) {\n if (!this._data) {\n throw new Error('buffer not writable');\n }\n if (size <= this._data.byteLength) {\n return this;\n }\n if (this._isConst) {\n throw new Error('writing exceeds maximum ' + this._data.byteLength + ' bytes limit');\n }\n --size;\n size |= size >> 1;\n size |= size >> 2;\n size |= size >> 4;\n size |= size >> 8;\n size |= size >> 16;\n ++size;\n const data = new Uint8Array(size);\n data.set(this._data); // copy old buffer!\n this._data = data;\n this._view = undefined; // release view\n return this;\n }\n}/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/**\n * BitReader allows to read binary data bit by bit\n */\nclass BitReader {\n constructor(data) {\n if ('buffer' in data) {\n this._data = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n }\n else {\n this._data = new Uint8Array(data);\n }\n this._size = this._data.byteLength;\n this._position = 0;\n this._bit = 0;\n }\n data() {\n return this._data;\n }\n size() {\n return this._size;\n }\n available() {\n return (this._size - this._position) * 8 - this._bit;\n }\n next(count = 1) {\n let gotten = 0;\n while (this._position !== this._size && count--) {\n ++gotten;\n if (++this._bit === 8) {\n this._bit = 0;\n ++this._position;\n }\n }\n return gotten;\n }\n read(count = 1) {\n let result = 0;\n while (this._position !== this._size && count--) {\n result <<= 1;\n if (this._data[this._position] & (0x80 >> this._bit++)) {\n result |= 1;\n }\n if (this._bit === 8) {\n this._bit = 0;\n ++this._position;\n }\n }\n return result;\n }\n read8() {\n return this.read(8);\n }\n read16() {\n return this.read(16);\n }\n read24() {\n return this.read(24);\n }\n read32() {\n return this.read(32);\n }\n}/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/**\n * Help class to manipulate and parse a net address. The Address can be only the domain field,\n * or a URL format with protocol and path part `(http://)domain(:port/path)`\n * @example\n * const address = new Address('nl-ams-42.live.ceeblue.tv:80');\n * console.log(address.domain) // 'nl-ams-42.live.ceeblue.tv'\n * console.log(address.port) // '80'\n * console.log(address) // 'nl-ams-42.live.ceeblue.tv:80'\n */\nclass NetAddress {\n /**\n * Static help function to build an end point from an address `(proto://)domain(:port/path)`\n *\n * Mainly it fix the protocol, in addition if:\n * - the address passed is securized (TLS) and protocol is not => it tries to fix protocol to get its securize version\n * - the address passed is non securized and protocol is (TLS) => it tries to fix protocol to get its unsecurized version\n * @param protocol protocol to set in the end point returned\n * @param address string address to fix with protocol as indicated\n * @returns the end point built\n * @example\n * console.log(NetAddress.fixProtocol('ws','http://domain/path')) // 'ws://domain/path'\n * console.log(NetAddress.fixProtocol('ws','https://domain/path')) // 'wss://domain/path'\n * console.log(NetAddress.fixProtocol('wss','http://domain/path')) // 'ws://domain/path'\n */\n static fixProtocol(protocol, address) {\n const found = address.indexOf('://');\n // isolate protocol is present in address\n if (found >= 0) {\n // In this case replace by protocol in keeping SSL like given in address\n if (found > 2 && address.charAt(found - 1).toLowerCase() === 's') {\n // SSL!\n if (protocol.length <= 2 || !protocol.endsWith('s')) {\n protocol += 's'; // Add SSL\n }\n }\n else {\n // Not SSL!\n if (protocol.length > 2 && protocol.endsWith('s')) {\n protocol = protocol.slice(0, -1); // Remove SSL\n }\n }\n // Build host!\n address = address.substring(found + 3);\n }\n return protocol + '://' + address;\n }\n /**\n * The domain part from address `(http://)domain(:port/path)`\n */\n get domain() {\n return this._domain;\n }\n /**\n * The port part from address `(http://)domain(:port/path)`, or defaultPort if passed in NetAddress constructor\n */\n get port() {\n return this._port;\n }\n /**\n * @returns the string address as passed in the constructor\n */\n toString() {\n return this._address;\n }\n /**\n * @returns the string address as passed in the constructor\n * @override\n */\n valueOf() {\n return this._address;\n }\n /**\n * Build a NetAddress object and parse address\n * @param address string address to parse, accept an url format with protocol and path `(http://)domain(:port/path)`\n * @param defaultPort set a default port to use if there is no port in the string address parsed\n */\n constructor(address, defaultPort) {\n this._address = address;\n // Remove Protocol\n let pos = address.indexOf('/');\n if (pos >= 0) {\n // Remove ://\n if (address.charCodeAt(pos + 1) === 47) {\n // has //\n if (pos > 0) {\n if (address.charCodeAt(pos - 1) === 58) {\n // has ://\n address = address.substring(pos + 2);\n } // something else #//\n }\n else {\n // otherwise starts by //\n address = address.substring(2);\n }\n }\n else if (!pos) {\n // starts by /, remove it\n address = address.substring(1);\n } // else something else #/\n }\n this._domain = address;\n this._port = defaultPort;\n // Parse Port\n pos = address.lastIndexOf(':');\n if (pos >= 0) {\n const port = parseInt(address.substring(pos + 1));\n if (port && port <= 0xffff) {\n this._port = port;\n this._domain = address.substring(0, pos);\n }\n }\n else {\n // Remove Path!\n pos = address.indexOf('/');\n if (pos >= 0) {\n this._domain = address.substring(0, pos);\n }\n }\n }\n}/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/**\n * Type of connection\n */\nvar Type;\n(function (Type) {\n Type[\"HESP\"] = \"hesp\";\n Type[\"WEBRTS\"] = \"webrts\";\n Type[\"WEBRTC\"] = \"webrtc\";\n Type[\"META\"] = \"meta\";\n Type[\"DATA\"] = \"data\";\n})(Type || (Type = {}));\n/**\n * Some connection utility functions\n */\n/**\n * Build an URL from {@link Type | type} and {@link Params | params}\n * @param type Type of the connection wanted\n * @param params Connection parameters\n * @param protocol Optional parameter to choose the prefered protocol to connect\n * @returns The URL of connection\n */\nfunction buildURL(type, params, protocol = 'wss') {\n const url = new URL(NetAddress.fixProtocol(protocol, params.host));\n if (url.pathname.length <= 1) {\n // build ceeblue path!\n switch (type) {\n case Type.HESP:\n url.pathname = '/hesp/' + params.streamName + '/index.json';\n break;\n case Type.WEBRTC:\n url.pathname = '/webrtc/' + params.streamName;\n break;\n case Type.WEBRTS:\n url.pathname = '/webrts/' + params.streamName;\n break;\n case Type.META:\n url.pathname = '/json_' + params.streamName + '.js';\n break;\n case Type.DATA:\n url.pathname = '/' + params.streamName + '.json';\n break;\n default:\n console.warn('Unknown url type ' + type);\n break;\n }\n } // Host has already a path! keep it unchanged, it's user intentionnal (used with some other WHIP/WHEP server?)\n if (params.accessToken) {\n url.searchParams.set('id', params.accessToken);\n }\n for (const key in params.query) {\n url.searchParams.set(key, params.query[key]);\n }\n return url;\n}var Connect=/*#__PURE__*/Object.freeze({__proto__:null,get Type(){return Type},buildURL:buildURL});/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/**\n * A advanced EventEmitter which allows to declare event as natural function in the inheriting children class,\n * function must start by `on` prefix to be recognized as an event.\n * The function can define a behavior by default, and user can choose to redefine this behavior,\n * or add an additionnal subscription for this event.\n * In addition you can unsubscribe to multiple events with an `AbortController`\n * @example\n * class Logger extends EventEmitter {\n * onLog(log:string) { console.log(log); } // behavior by default\n *\n * test() {\n * // raise event onLog\n * this.onLog('test');\n * }\n * }\n *\n * const logger = new Logger();\n * logger.test(); // displays a log 'test'\n *\n * // redefine default behavior to display nothing\n * logger.onLog = () => {}\n * logger.test(); // displays nothing\n *\n * // add an additionnal subscription\n * logger.on('log', console.log);\n * logger.test(); // displays a log 'test'\n *\n * // remove the additionnal subscription\n * logger.off('log', console.log);\n * logger.test(); // displays nothing\n *\n * // add two additionnal subscriptions with a AbortController\n * const controller = new AbortController();\n * logger.on('log', log => console.log(log), controller);\n * logger.on('log', log => console.error(log), controller);\n * logger.test(); // displays a log 'test' + an error 'test'\n *\n * // Unsubscribe all the subscription with the AbortController\n * controller.abort();\n * logger.test(); // displays nothing\n */\nclass EventEmitter {\n /**\n * Build our EventEmitter, usually call from children class\n */\n constructor() {\n this._events = new Map();\n // Fill events with events as defined!\n let proto = Object.getPrototypeOf(this);\n while (proto && proto !== Object.prototype) {\n for (const name of Object.getOwnPropertyNames(proto)) {\n if (name.length < 3 || !name.startsWith('on')) {\n continue;\n }\n if (proto[name] instanceof Function) {\n const events = new Set();\n this._events.set(name.substring(2).toLowerCase(), events);\n let defaultEvent = proto[name];\n Object.defineProperties(this, {\n [name]: {\n get: () => (...args) => {\n // Call default event if not null (can happen in JS usage)\n if (defaultEvent) {\n defaultEvent.call(this, ...args);\n }\n // Call subscribers\n for (const event of events) {\n event(...args);\n }\n },\n set: (value) => {\n // Assign a default behavior!\n defaultEvent = value;\n }\n }\n });\n }\n }\n proto = Object.getPrototypeOf(proto);\n }\n }\n /**\n * Event subscription\n * @param name Name of event without the `on` prefix (ex: `log` to `onLog` event declared)\n * @param event Subscriber Function\n * @param abort Optional `AbortController` to stop this or multiple subscriptions in same time\n */\n on(name, event, abort) {\n if (!event) {\n throw Error('event to subscribe cannot be null');\n }\n const events = this._event(name);\n events.add(event);\n if (abort) {\n abort.signal.addEventListener('abort', () => {\n events.delete(event);\n });\n }\n }\n /**\n * Event subscription only one time, once time fired it's automatically unsubscribe\n * @param name Name of event without the `on` prefix (ex: `log` to `onLog` event declared)\n * @param event Subscriber Function\n * @param abort Optional `AbortController` to stop this or multiple subscriptions in same time\n */\n once(name, event, abort) {\n if (!event) {\n throw Error('event to subscribe cannot be null');\n }\n const events = this._event(name);\n events.add(() => {\n events.delete(event); // delete from events\n event(); // execute event\n });\n if (abort) {\n abort.signal.addEventListener('abort', () => {\n events.delete(event);\n });\n }\n }\n /**\n * Event unsubscription\n * @param name Name of event without the 'on' prefix (ex: 'log' to 'onLog' event declared)\n * @param event Unsubscriber Function, must be the one passed to {@link on} or {@link once} subscription methods\n */\n off(name, event) {\n if (!event) {\n throw Error('event to unsubscribe cannot be null');\n }\n this._event(name).delete(event);\n }\n _event(name) {\n const events = this._events.get(name.toLowerCase());\n if (!events) {\n throw Error('No event on' + name + ' on class ' + this.constructor.name);\n }\n return events;\n }\n}/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/**\n * Queue typed similar to a {@link https://en.cppreference.com/w/cpp/container/queue | std::queue<Type>} with possibility to limit the capacity like a FIFO\n * @example\n * const queue = new Queue<number>(2);\n * queue.push(1); // [1]\n * queue.push(2); // [1,2]\n * queue.push(3); // [2,3] 1 has been removed to respect 2 capacity\n */\nclass Queue {\n /**\n * Number of element in the queue\n */\n get size() {\n return this._queue.length;\n }\n /**\n * Maximum capacity for the queue, if not set queue has unlimited capacity\n */\n get capacity() {\n return this._capacity;\n }\n /**\n * Set a maximum capacity for the queue,\n * if you push new value exceding this capacity the firsts are removed (FIFO)\n * if set to undefined the queue is unlimited\n */\n set capacity(value) {\n this._capacity = value;\n if (value != null && this._queue.length > value) {\n this._queue.splice(0, this._queue.length - value);\n }\n }\n /**\n * The front element\n */\n get front() {\n return this._queue[0];\n }\n /**\n * The back element\n */\n get back() {\n return this._queue[this._queue.length - 1];\n }\n /**\n * Iterator though queue's elements\n */\n [Symbol.iterator]() {\n return this._queue[Symbol.iterator]();\n }\n /**\n * Instanciate a new queue object with the type passed as template\n * @param capacity if set it limits the size of the queue, any exceding element pops the first element pushed (FIFO)\n */\n constructor(capacity) {\n this._capacity = capacity;\n this._queue = new Array();\n }\n /**\n * Push a new element in the queue\n * @param value value of the element\n * @returns this\n */\n push(value) {\n if (this._capacity != null && this._queue.push(value) > this._capacity) {\n this.pop();\n }\n return this;\n }\n /**\n * Pop the first element from the queue\n * @returns The first element removed\n */\n pop() {\n return this._queue.shift();\n }\n /**\n * Clear all the elements, queue becomes empty\n * @returns this\n */\n clear() {\n this._queue.length = 0;\n return this;\n }\n}/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/**\n * A collection of number Queue<number> with the following efficient mathematic computation:\n * - minimum value in the collection\n * - maximum value in the collection\n * - average value of the collection\n */\nclass Numbers extends Queue {\n /**\n * minimum value in the collection, or 0 if colleciton is empty\n */\n get minimum() {\n return this._min;\n }\n /**\n * maximum value in the collection, or 0 if colleciton is empty\n */\n get maximum() {\n return this._max;\n }\n /**\n * average value of the collection, or 0 if collection if empty\n */\n get average() {\n if (this._average == null) {\n this._average = this.size ? this._sum / this.size : 0;\n }\n return this._average;\n }\n /**\n * Instantiate the collection of the number\n * @param capacity if set it limits the number of values stored, any exceding number pops the first number pushed (FIFO)\n */\n constructor(capacity) {\n super(capacity);\n this._sum = 0;\n this._min = 0;\n this._max = 0;\n }\n /**\n * Push a value to the back to the collection\n * @param value number to add\n * @returns this\n */\n push(value) {\n if (value > this._max) {\n this._max = value;\n }\n else if (value < this._min) {\n this._min = value;\n }\n this._average = undefined;\n this._sum += value;\n super.push(value);\n return this;\n }\n /**\n * Pop the front number from the collection\n * @returns the front number removed\n */\n pop() {\n const front = super.pop();\n if (front === this._max) {\n this._max = Math.max(0, ...this);\n }\n else if (front === this._min) {\n this._min = Math.min(0, ...this);\n }\n this._average = undefined;\n this._sum -= front || 0;\n return front;\n }\n /**\n * Clear all the numbers, collection becomes empty\n * @returns this\n */\n clear() {\n this._min = this._max = this._sum = 0;\n super.clear();\n return this;\n }\n}/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/**\n * Toolkit to deal with Session Description Protocol (SDP),\n * mainly to tranform a SDP string Offer/Answer to a manipulable JS object representation\n * @example\n * const peerConnection = new RTCPeerConnection();\n * peerConnection.createOffer()\n * .then( offer =>\n * // Change offer.sdp string to a JS manipulable object\n * const sdp = SDP.fromString(offer.sdp || '');\n * // Change a property of SDP\n * sdp.v = 2; // change SDP version\n * // Reserialize to the legal SDP string format\n * offer.sdp = SDP.toString(sdp);\n * // Set SDP offer to peerConnection\n * peerConnection.setLocalDescription(offer);\n * )\n */\nconst SDP = {\n /**\n * Unserialize SDP string to a manipulable JS object representation\n * It's an object with:\n * - root SDP properties\n * - media description iterable\n * @param lines SDP string reprensentation\n * @returns SDP object representation, iterable through media description\n * @example\n * [\n * group: \"DUNBLE 0 1\",\n * o: \"- 1699450751193623 0 IN IP4 0.0.0.0\",\n * s: \"-\",\n * t: \"0 0\",\n * v: \"0\",\n * ice-lite: \"\",\n * length: 2,\n * {\n * m: \"audio 9 UDP/TLS/RTP/SAVPF 111\",\n * c: \"IN IP4 0.0.0.0\",\n * rtcp: \"9\",\n * sendonly: \"\",\n * setup: \"passive\",\n * fingerprint: \"sha-256 51:36:ED:78:A4:9F:25:8C:39:9A:0E:A0:B4:9B:6E:04:37:FF:AD:96:93:71:43:88:2C:0B:0F:AB:6F:9A:52:B8\",\n * ice-ufrag: \"fa37\",\n * ice-pwd: \"JncCHryDsbzayy4cBWDxS2\",\n * rtcp-mux: \"\",\n * rtcp-rsize: \"\",\n * rtpmap: \"111 opus/48000/2\",\n * rtcp-fb: \"111 nack\",\n * id: \"0\",\n * fmtp: \"111 minptime=10;useinbandfec=1\",\n * candidate: \"1 1 udp 2130706431 89.105.221.108 56643 typ host\",\n * end-of-candidates: \"\"\n * },\n * {\n * m: \"video 9 UDP/TLS/RTP/SAVPF 106\",\n * c: \"IN IP4 0.0.0.0\",\n * rtcp: \"9\",\n * sendonly: \"\",\n * setup: \"passive\",\n * fingerprint: \"sha-256 51:36:ED:78:A4:9F:25:8C:39:9A:0E:A0:B4:9B:6E:04:37:FF:AD:96:93:71:43:88:2C:0B:0F:AB:6F:9A:52:B8\",\n * ice-ufrag: \"fa37\",\n * ice-pwd: \"JncCHryDsbzayy4cBWDxS2\",\n * rtcp-mux: \"\",\n * rtcp-rsize: \"\",\n * rtpmap: \"106 H264/90000\",\n * rtcp-fb: [\n * \"106 nack\",\n * \"106 goog-remb\"\n * ],\n * mid: \"1\",\n * fmtp: \"106 profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1\",\n * candidate: \"1 1 udp 2130706431 89.105.221.108 56643 typ host\",\n * end-of-candidates: \"\"\n * }\n * ]\n */\n fromString(lines) {\n if (Array.isArray(lines)) {\n return lines; // already converted\n }\n const sdp = new Array();\n let media = sdp;\n let fingerprint;\n for (let line of lines.toString().split('\\n')) {\n line = line.trim();\n if (!line) {\n continue;\n }\n let key = line[0];\n const value = line.substring(line.indexOf('=') + 1).trim();\n switch (key.toLowerCase()) {\n case 'a': {\n if (!value) {\n continue;\n } // empty attribute!\n key = this.addAttribute(media, value);\n // save fingerprint to repeat it in medias\n if (sdp === media && key.toLowerCase() === 'fingerprint') {\n fingerprint = media.fingerprint;\n }\n break;\n }\n case 'm':\n if (sdp.length && fingerprint && !sdp[sdp.length - 1].fingerprint) {\n media.fingerprint = fingerprint;\n }\n sdp.push((media = { m: value }));\n break;\n default:\n media[key] = value;\n }\n }\n if (sdp.length && fingerprint && !sdp[sdp.length - 1].fingerprint) {\n media.fingerprint = fingerprint;\n }\n return sdp;\n },\n /**\n * Serialize SDP JS object to a SDP string legal representation\n * @param sdp SDP object reprensetation\n * @returns SDP string reprensentation\n */\n toString(sdp) {\n if (typeof sdp === 'string') {\n return sdp; // already converted\n }\n const medias = [];\n // https://www.cl.cam.ac.uk/~jac22/books/mm/book/node182.html\n let lines = 'v' in sdp ? 'v=' + sdp.v + '\\n' : '';\n if ('o' in sdp) {\n lines += 'o=' + sdp.o + '\\n';\n }\n if ('s' in sdp) {\n lines += 's=' + sdp.s + '\\n';\n }\n const obj = sdp;\n for (const key of Object.keys(sdp)) {\n if (key === 'v' || key === 'o' || key === 's') {\n continue;\n }\n const value = obj[key];\n if (value == null) {\n continue;\n } // ignore this key/value\n const index = parseInt(key);\n if (!isNaN(index)) {\n // Is a number! Media object!\n medias[index] = value;\n continue;\n }\n const count = (Array.isArray(value) && value.length) || 1; // value can be numeric!\n for (let i = 0; i < count; ++i) {\n const line = Array.isArray(value) && value.length ? value[i] : value;\n if (key.length > 1) {\n // when key is superior to 1 letter it's a attribute!\n lines += 'a=' + key;\n if (line) {\n lines += ':';\n }\n }\n else {\n lines += key + '=';\n }\n lines += line + '\\n';\n }\n }\n for (const media of medias) {\n lines += this.toString(media);\n }\n return lines;\n },\n /**\n * While set a property to a SDP object representation is possible directly,\n * we could prefer add a new property without overload a possible already existing value.\n * This function allows to add a property to our SDP representation:\n * - if the key's attribute doesn't exists yet it adds it like a simple JS property sdp[key] = value\n * - if the key's attribute exists already it morphs the value to a Array and push it inside\n * @param sdp the SDP object representation on which added the attribute\n * @param attribute the string attribut in a format \"key:value\" or just \"key\" to add an attribute without value\n * @returns the key part of the attribute added (or if value is empty it returns the same attribute as passed in argument)\n */\n addAttribute(sdp, attribute) {\n var _a;\n const a = SDP.parseAttribute(attribute);\n const value = (_a = a.value) !== null && _a !== void 0 ? _a : ''; // to allow to test if key exists even without value with if(sdp.key != null)\n const obj = sdp;\n const oldValue = obj[a.key];\n if (!oldValue) {\n obj[a.key] = value;\n }\n else if (Array.isArray(oldValue)) {\n oldValue.push(value);\n }\n else if (value !== oldValue) {\n obj[a.key] = [oldValue, value];\n }\n return a.key;\n },\n /**\n * While it's possible to delete a attribute manually on the SDP object representation with a delete sdp.key,\n * we could prefer remove only a value in a sdp.key array containing multiple values.\n * Like opposite to addAttribute this method allows to remove an unique attribute value.\n * @param sdp the SDP object representation on which removed the attribute\n * @param attribute the string attribut in a format \"key:value\" or just \"key\" to remove the whole attribute and all its values\n * @returns the key part of the attribute removed (or if value is empty it returns the same attribute as passed in argument)\n */\n removeAttribute(sdp, attribute) {\n const a = SDP.parseAttribute(attribute);\n const obj = sdp;\n if (a.value === undefined) {\n delete obj[attribute];\n return attribute;\n }\n const current = obj[attribute];\n if (Array.isArray(a.value)) {\n const i = current.findIndex((current) => current === a.value);\n if (i >= 0) {\n current.splice(i, 1);\n }\n }\n else if (current === a.value) {\n delete obj[attribute];\n }\n return a.key;\n },\n /**\n * Parse an attribute in a format \"key:value\"\n * @param attribute string attribute to parse\n * @returns the {key, value} result, with value undefined if attribute was a \"key\" without value\n */\n parseAttribute(attribute) {\n const found = attribute.indexOf(':');\n return {\n key: (found >= 0 ? attribute.substring(0, found) : attribute).trim(),\n value: found >= 0 ? attribute.substring(found + 1).trim() : undefined\n };\n }\n};\nObject.freeze(SDP);/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\nconst _decoder = new TextDecoder();\nconst _encoder = new TextEncoder();\n/* eslint-disable @typescript-eslint/no-explicit-any */\nconst _perf = performance; // to increase x10 now performance!\n/**\n * Some basic utility functions\n */\n/**\n * Version of the library\n */\nconst VERSION = '1.0.1';\n/**\n * An empty lambda function, pratical to disable default behavior of function or events which are not expected to be null\n * @example\n * console.log = Util.EMPTY_FUNCTION; // disable logs without breaking calls\n */\nconst EMPTY_FUNCTION = () => { };\n/**\n * Efficient and high resolution timestamp in milliseconds elapsed since {@link Util.timeOrigin}\n */\nfunction time() {\n return Math.floor(_perf.now());\n}\n/**\n * Time origin represents the time when the application has started\n */\nfunction timeOrigin() {\n return Math.floor(_perf.now() + _perf.timeOrigin);\n}\n/**\n * Parse query and returns it in an easy-to-use Javascript object form\n * @param urlOrQueryOrSearch string, url, or searchParams containing query. If not set it uses `location.search` to determinate query.\n * @returns An javascript object containing each option\n */\nfunction options(urlOrQueryOrSearch = typeof location === 'undefined'\n ? undefined\n : location) {\n if (!urlOrQueryOrSearch) {\n return {};\n }\n try {\n const url = urlOrQueryOrSearch;\n urlOrQueryOrSearch = new URL(url).searchParams;\n }\n catch (e) {\n if (typeof urlOrQueryOrSearch == 'string') {\n if (urlOrQueryOrSearch.startsWith('?')) {\n urlOrQueryOrSearch = urlOrQueryOrSearch.substring(1);\n }\n urlOrQueryOrSearch = new URLSearchParams(urlOrQueryOrSearch);\n }\n }\n // works same if urlOrQueryOrSearch is null, integer, or a already object etc...\n return objectFrom(urlOrQueryOrSearch, { withType: true, noEmptyString: true });\n}\n/**\n * Returns an easy-to-use Javascript object something iterable, such as a Map, Set, or Array\n * @param value iterable input\n * @param params.withType `false`, if set it tries to cast string value to a JS number/boolean/undefined/null type.\n * @param params.noEmptyString `false`, if set it converts empty string value to a true boolean, usefull to allow a `if(result.key)` check for example\n * @returns An javascript object\n */\nfunction objectFrom(value, params) {\n params = Object.assign({ withType: false, noEmptyString: false }, params);\n const obj = {};\n if (!value) {\n return obj;\n }\n for (const [key, val] of objectEntries(value)) {\n value = val;\n if (params.withType && value != null && value.substring) {\n if (value) {\n const number = Number(value);\n if (isNaN(number)) {\n switch (value.toLowerCase()) {\n case 'true':\n value = true;\n break;\n case 'false':\n value = false;\n break;\n case 'null':\n value = null;\n break;\n case 'undefined':\n value = undefined;\n break;\n }\n }\n else {\n value = number;\n }\n }\n else if (params.noEmptyString) {\n // if empty string => TRUE to allow a if(options.key) check for example\n value = true;\n }\n }\n if (obj[key]) {\n if (!Array.isArray(obj[key])) {\n obj[key] = new Array(obj[key]);\n }\n obj[key].push(value);\n }\n else {\n obj[key] = value;\n }\n }\n return obj;\n}\n/**\n * Returns entries from something iterable, such as a Map, Set, or Array\n * @param value iterable input\n * @returns An javascript object\n */\nfunction objectEntries(value) {\n if (value.entries) {\n return value.entries();\n }\n return Array.from({\n [Symbol.iterator]: function* () {\n for (const key in value) {\n yield [key, value[key]];\n }\n }\n });\n}\n/**\n * Converts various data types, such as objects, strings, exceptions, errors,\n * or numbers, into a string representation. Since it offers a more comprehensive format,\n * this function is preferred to `JSON.stringify()`.\n * @param obj Any objects, strings, exceptions, errors, or number\n * @param params.space `''`, allows to configure space in the string representation\n * @param params.decimal `2`, allows to choose the number of decimal to display in the string representation\n * @param params.recursive `false`, allows to serialize recursively every object value, beware if a value refers to a already parsed value an infinite loop will occur.\n * @returns the final string representation\n */\n// Online Javascript Editor for free\n// Write, Edit and Run your Javascript code using JS Online Compiler\nfunction stringify(obj, params = {}) {\n params = Object.assign({ space: ' ', decimal: 2, recursive: 1 }, params);\n if (!obj) {\n return String(obj);\n }\n const error = obj.error || obj.message;\n if (error) {\n // is a error!\n obj = error;\n }\n if (obj.toFixed) {\n return obj.toFixed(Number(params.decimal) || 0);\n }\n if (obj.substring || !params.recursive) {\n // is already a string OR has to be stringified\n return String(obj);\n }\n const space = params.space || '';\n if (Array.isArray(obj)) {\n // Array!\n let res = '';\n for (const value of obj) {\n res += (res ? ',' : '[') + space;\n res += stringify(value, Object.assign(params, { recursive: params.recursive - 1 }));\n }\n return (res += space + ']');\n }\n if (obj.byteLength != null && (obj === null || obj === void 0 ? void 0 : obj[Symbol.iterator])) {\n // Binary!\n return _decoder.decode(obj);\n }\n let res = '';\n for (const name in obj) {\n res += (res ? ',' : '{') + space + name + ':';\n res += stringify(obj[name], Object.assign(params, { recursive: params.recursive - 1 }));\n }\n return (res += space + '}');\n}\nfunction toBin(value) {\n return _encoder.encode(value);\n}var Util=/*#__PURE__*/Object.freeze({__proto__:null,EMPTY_FUNCTION:EMPTY_FUNCTION,VERSION:VERSION,objectEntries:objectEntries,objectFrom:objectFrom,options:options,stringify:stringify,time:time,timeOrigin:timeOrigin,toBin:toBin});/**\n * Copyright 2024 Ceeblue B.V.\n * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.\n * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.\n */\n/**\n * The WebSocketReliable class extends WebSocket to bring up the following improvements:\n * - Fix all possible unintentional closing ways to get always a related error message, {@link onClose | onClose(error?) event}\n * - Make possible message sending while connecting. Indeed no need to wait {@link onOpen} before to send message,\n * you can open the socket and immediately send messages, it will be queue and flushs on connection etablishment\n * - Make possible a delayed connection, or a reconnection. Indeed you can create an unconnected Websocket instance\n * without passing any url argument and starts the conneciton more later with {@link WebSocketReliable.open(url) | open(url)} method\n * - Make possible to control sending/queueing message: send method take an optional queueing=true argument to\n * queue message rather send it, a futur call to flush will send it. Then queueing getter allows to handle the queue\n * if need to purge it or remove some queued message. Use it all together can help to prioritize messages or control overload.\n * @example\n * const ws = new WebSocketReliable(url);\n * ws.onClose = (error?:string) => {\n * if(error) {\n * console.error(error);\n * }\n * // reconnection attempt every seconds\n * setTimeout(() => ws.open(url), 1000);\n * }\n * ws.onMessage = (message:string) => {\n * console.log(message);\n * }\n * ws.send('hello'); // send immediatly a hello message is possible (no need to wait onOpen)\n */\nclass WebSocketReliable extends EventEmitter {\n /**\n * @event `open` fired when socket is connected\n */\n onOpen() { }\n /**\n * @event `message` fired on message reception\n * @param message can be binary or string.\n * If you subscribe to the event with message as string type (and not union),\n * it means that you know that all your messages are distributed in a string format\n */\n onMessage(message) { }\n /**\n * @event `close` fired on websocket close\n * @param error error description on an improper closure\n */\n onClose(error) {\n if (error) {\n console.error(error);\n }\n }\n /**\n * binaryType, fix binary type to arrayBuffer\n */\n get binaryType() {\n return 'arraybuffer';\n }\n /**\n * url of connection\n */\n get url() {\n var _a, _b;\n return (_b = (_a = this._ws) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : '';\n }\n /**\n * extensions negociated by the server\n */\n get extensions() {\n var _a, _b;\n return (_b = (_a = this._ws) === null || _a === void 0 ? void 0 : _a.extensions) !== null && _b !== void 0 ? _b : '';\n }\n /**\n * protocol negociated by the server\n */\n get protocol() {\n var _a, _b;\n return (_b = (_a = this._ws) === null || _a === void 0 ? void 0 : _a.protocol) !== null && _b !== void 0 ? _b : '';\n }\n /**\n * opened equals true when connection is etablished, in other word when onOpen event is fired\n */\n get opened() {\n return this._opened;\n }\n /**\n * {@link https://developer.mozilla.org/docs/Web/API/WebSocket/readyState | Official websocket readyState}\n */\n get readyState() {\n return this._ws ? this._ws.readyState : 3;\n }\n /**\n * True when connection is closed, in other words when {@link onClose} event is fired\n * or when WebSocketReliable is build without url (disconnected creation)\n */\n get closed() {\n return this._closed;\n }\n /**\n * The number of bytes of data that were queued during calls to send() but not yet transmitted to the network\n */\n get bufferedAmount() {\n var _a;\n return this._queueingBytes + (((_a = this._ws) === null || _a === void 0 ? void 0 : _a.bufferedAmount) || 0);\n }\n /**\n * Queued messages from a call to send() waiting to be transmit one time websocket connection opened (or with an explicit call to flush() method)\n */\n get queueing() {\n return this._queueing;\n }\n /**\n * Create a WebSocketReliable object, and open it if an url is passed in argument\n * @param url URL of the WebSocket endpoint or null to start the connection later\n */\n constructor(url, protocols) {\n super();\n this._queueing = [];\n this._queueingBytes = 0;\n this._opened = false;\n this._closed = true;\n if (url) {\n this.open(url, protocols);\n }\n }\n /**\n * Open a WebSocket connection\n * @param url url of the websocket endpoint\n * @returns this\n */\n open(url, protocols) {\n this._closed = false;\n const ws = (this._ws = new WebSocket(url, protocols));\n ws.binaryType = this.binaryType;\n ws.onmessage = e => this.onMessage(e.data);\n // Add details and fix close ways\n ws.onclose = (e) => {\n if (!this._opened) {\n // close during connection\n this.close(url.toString() + ' connection failed (' + String(e.reason || e.code) + ')');\n }\n else if (e.code === 1000 || e.code === 1005) {\n // normal disconnection from server (no error code)\n this.close(url.toString() + ' shutdown');\n }\n else {\n // disconnection from server\n this.close(url.toString() + ' disconnection (' + String(e.reason || e.code) + ')');\n }\n };\n // Wrap send method to queue messages until connection is established.\n ws.onopen = _ => {\n this._opened = true;\n this.flush();\n this.onOpen();\n };\n return this;\n }\n /**\n * Send a message\n * @param message\n * @param queueing When set it reports the sending to a more later call to flush\n * @returns this\n */\n send(message, queueing = false) {\n if (!this._ws) {\n throw Error('Open socket before to send data');\n }\n if (queueing || !this._opened) {\n this._queueing.push(message);\n this._queueingBytes += typeof message === 'string' ? message.length : message.byteLength;\n }\n else {\n this._ws.send(message);\n }\n return this;\n }\n /**\n * Send queueing messages\n */\n flush() {\n if (this._ws) {\n for (const message of this._queueing) {\n this._ws.send(message);\n }\n }\n this._queueing.length = 0;\n this._queueingBytes = 0;\n }\n /**\n * Close websocket\n * @param error the error reason if is not a proper close\n */\n close(error) {\n if (!this._ws || this._closed) {\n return;\n }\n this._closed = true;\n this._ws.onopen = this._ws.onclose = this._ws.onmessage = null; // otherwise can receive message AFTER close!\n this._ws.close(); // Don't set to undefined to keep this._ws properties valid!\n // release resources!\n this._opened = false;\n this._queueing.length = 0;\n this._queueingBytes = 0;\n this.onClose(error);\n }\n}export{BinaryReader,BinaryWriter,BitReader,Connect,EventEmitter,NetAddress,Numbers,Queue,SDP,Util,WebSocketReliable};//# sourceMappingURL=web-utils.js.map\n"],"names":["BinaryReader","constructor","data","this","_data","Uint8Array","buffer","byteOffset","byteLength","_size","_position","_view","DataView","size","available","value","position","reset","shrink","rest","next","count","read8","getUint8","read16","getUint16","read24","read32","getUint32","readFloat","getFloat32","readDouble","getFloat64","read7Bit","bytes","Error","byte","result","readString","String","fromCharCode","read","readHex","hex","toString","slice","subarray","BinaryWriter","view","capacity","dataOrSize","offset","length","_isConst","reserve","clear","write","i","charCodeAt","set","write8","write16","setUint16","write24","setUint8","write32","setUint32","writeFloat","setFloat32","writeDouble","setFloat64","write7Bit","bits","front","writeString","writeHex","parseInt","substring","undefined","BitReader","_bit","gotten","NetAddress","fixProtocol","protocol","address","found","indexOf","charAt","toLowerCase","endsWith","domain","_domain","port","_port","_address","valueOf","defaultPort","pos","lastIndexOf","Type","Connect","Object","freeze","__proto__","buildURL","type","params","url","URL","host","pathname","HESP","streamName","WEBRTC","WEBRTS","META","DATA","console","warn","accessToken","searchParams","key","query","EventEmitter","_events","Map","proto","getPrototypeOf","prototype","name","getOwnPropertyNames","startsWith","Function","events","Set","defaultEvent","defineProperties","get","args","call","event","on","abort","_event","add","signal","addEventListener","delete","once","off","Queue","_queue","_capacity","splice","back","Symbol","iterator","Array","push","pop","shift","Numbers","minimum","_min","maximum","_max","average","_average","_sum","super","Math","max","min","SDP","fromString","lines","isArray","sdp","fingerprint","media","line","split","trim","addAttribute","m","medias","v","o","s","obj","keys","index","isNaN","attribute","_a","a","parseAttribute","oldValue","removeAttribute","current","findIndex","_decoder","TextDecoder","_encoder","TextEncoder","_perf","performance","objectFrom","assign","withType","noEmptyString","val","objectEntries","number","Number","entries","from","Util","EMPTY_FUNCTION","VERSION","options","urlOrQueryOrSearch","location","e","URLSearchParams","stringify","space","decimal","recursive","error","message","toFixed","res","decode","time","floor","now","timeOrigin","toBin","encode","WebSocketReliable","onOpen","onMessage","onClose","binaryType","_b","_ws","extensions","opened","_opened","readyState","closed","_closed","bufferedAmount","_queueingBytes","queueing","_queueing","protocols","open","ws","WebSocket","onmessage","onclose","code","close","reason","onopen","_","flush","send"],"mappings":"AAQA,MAAMA,EACF,WAAAC,CAAYC,GACRC,KAAKC,MACD,WAAYF,EAAO,IAAIG,WAAWH,EAAKI,OAAQJ,EAAKK,WAAYL,EAAKM,YAAc,IAAIH,WAAWH,GACtGC,KAAKM,MAAQN,KAAKC,MAAMI,WACxBL,KAAKO,UAAY,EACjBP,KAAKQ,MAAQ,IAAIC,SAAST,KAAKC,MAAME,OAAQH,KAAKC,MAAMG,WAAYJ,KAAKM,MAC5E,CACD,IAAAP,GACI,OAAOC,KAAKC,KACf,CACD,IAAAS,GACI,OAAOV,KAAKM,KACf,CACD,SAAAK,GACI,OAAOX,KAAKM,MAAQN,KAAKO,SAC5B,CACD,KAAAK,CAAMC,EAAWb,KAAKO,WAClB,OAAOP,KAAKC,MAAMY,EACrB,CACD,QAAAA,GACI,OAAOb,KAAKO,SACf,CACD,KAAAO,C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