@ceeblue/web-utils 1.0.1 → 1.1.0

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/README.md CHANGED
@@ -1,3 +1,21 @@
1
1
  # Ceeblue web framework
2
2
 
3
3
  This is a web framework for CeeblueTV's web libraries. It is a collection of tools and utilities that are used across all of CeeblueTV's web projects.
4
+
5
+ ## Installation
6
+
7
+ You can install the package using npm:
8
+
9
+ ```bash
10
+ npm install @ceeblue/web-utils
11
+ ```
12
+
13
+ Or manually add it to your `package.json` file:
14
+
15
+ ```json
16
+ {
17
+ "dependencies": {
18
+ "@ceeblue/web-utils": "latest"
19
+ }
20
+ }
21
+ ```
package/dist/web-utils.js CHANGED
@@ -1109,7 +1109,7 @@ const _perf = performance; // to increase x10 now performance!
1109
1109
  /**
1110
1110
  * Version of the library
1111
1111
  */
1112
- const VERSION = '1.0.1';
1112
+ const VERSION = '1.1.0';
1113
1113
  /**
1114
1114
  * An empty lambda function, pratical to disable default behavior of function or events which are not expected to be null
1115
1115
  * @example
@@ -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 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
+ 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.1.0",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 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,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,GAAWjB,KAAKQ,MAAMc,UAAUtB,KAAKO,UAAY,GAAK,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P,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.1.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,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,CAAMD,EAAW,GACbb,KAAKO,UAAYM,EAAWb,KAAKM,MAAQN,KAAKM,M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QnL,OAASmL,EAAQ/N,YAG9EL,KAAKoP,IAAIuB,KAAKvC,GAEXpO,IACV,CAID,KAAA0Q,GACI,GAAI1Q,KAAKoP,IACL,IAAK,MAAMhB,KAAWpO,KAAK8P,UACvB9P,KAAKoP,IAAIuB,KAAKvC,GAGtBpO,KAAK8P,UAAU7M,OAAS,EACxBjD,KAAK4P,eAAiB,CACzB,CAKD,KAAAU,CAAMnC,GACGnO,KAAKoP,MAAOpP,KAAK0P,UAGtB1P,KAAK0P,SAAU,EACf1P,KAAKoP,IAAIoB,OAASxQ,KAAKoP,IAAIgB,QAAUpQ,KAAKoP,IAAIe,UAAY,KAC1DnQ,KAAKoP,IAAIkB,QAETtQ,KAAKuP,SAAU,EACfvP,KAAK8P,UAAU7M,OAAS,EACxBjD,KAAK4P,eAAiB,EACtB5P,KAAKiP,QAAQd,GAChB,SACLtO,kBAAA+C,kBAAAgC,eAAAsB,aAAAuB,kBAAA1C,gBAAAgF,aAAAX,WAAAuB,SAAA4C,UAAAuB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ceeblue/web-utils",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Ceeblue web framework",
5
5
  "keywords": [
6
6
  "utils"
@@ -67,6 +67,6 @@
67
67
  }
68
68
  },
69
69
  "publishConfig": {
70
- "access": "restricted"
70
+ "access": "public"
71
71
  }
72
72
  }