UNPKG

@tizentv/wits

Version:

Instant live reload tool for Tizen Web Application development

1,132 lines (1,128 loc) 208 kB
/*! * Socket.IO v3.1.0 * (c) 2014-2021 Guillermo Rauch * Released under the MIT License. */ !(function (t, e) { 'object' == typeof exports && 'object' == typeof module ? (module.exports = e()) : 'function' == typeof define && define.amd ? define([], e) : 'object' == typeof exports ? (exports.io = e()) : (t.io = e()); })(window, function () { return (function (t) { var e = {}; function n(r) { if (e[r]) return e[r].exports; var o = (e[r] = { i: r, l: !1, exports: {} }); return t[r].call(o.exports, o, o.exports, n), (o.l = !0), o.exports; } return ( (n.m = t), (n.c = e), (n.d = function (t, e, r) { n.o(t, e) || Object.defineProperty(t, e, { enumerable: !0, get: r }); }), (n.r = function (t) { 'undefined' != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t, Symbol.toStringTag, { value: 'Module' }), Object.defineProperty(t, '__esModule', { value: !0 }); }), (n.t = function (t, e) { if ((1 & e && (t = n(t)), 8 & e)) return t; if (4 & e && 'object' == typeof t && t && t.__esModule) return t; var r = Object.create(null); if ( (n.r(r), Object.defineProperty(r, 'default', { enumerable: !0, value: t }), 2 & e && 'string' != typeof t) ) for (var o in t) n.d( r, o, function (e) { return t[e]; }.bind(null, o) ); return r; }), (n.n = function (t) { var e = t && t.__esModule ? function () { return t.default; } : function () { return t; }; return n.d(e, 'a', e), e; }), (n.o = function (t, e) { return Object.prototype.hasOwnProperty.call(t, e); }), (n.p = ''), n((n.s = 17)) ); })([ function (t, e, n) { function r(t) { if (t) return (function (t) { for (var e in r.prototype) t[e] = r.prototype[e]; return t; })(t); } (t.exports = r), (r.prototype.on = r.prototype.addEventListener = function ( t, e ) { return ( (this._callbacks = this._callbacks || {}), (this._callbacks['$' + t] = this._callbacks['$' + t] || []).push(e), this ); }), (r.prototype.once = function (t, e) { function n() { this.off(t, n), e.apply(this, arguments); } return (n.fn = e), this.on(t, n), this; }), (r.prototype.off = r.prototype.removeListener = r.prototype.removeAllListeners = r.prototype.removeEventListener = function ( t, e ) { if ( ((this._callbacks = this._callbacks || {}), 0 == arguments.length) ) return (this._callbacks = {}), this; var n, r = this._callbacks['$' + t]; if (!r) return this; if (1 == arguments.length) return delete this._callbacks['$' + t], this; for (var o = 0; o < r.length; o++) if ((n = r[o]) === e || n.fn === e) { r.splice(o, 1); break; } return ( 0 === r.length && delete this._callbacks['$' + t], this ); }), (r.prototype.emit = function (t) { this._callbacks = this._callbacks || {}; for ( var e = new Array(arguments.length - 1), n = this._callbacks['$' + t], r = 1; r < arguments.length; r++ ) e[r - 1] = arguments[r]; if (n) { r = 0; for (var o = (n = n.slice(0)).length; r < o; ++r) n[r].apply(this, e); } return this; }), (r.prototype.listeners = function (t) { return ( (this._callbacks = this._callbacks || {}), this._callbacks['$' + t] || [] ); }), (r.prototype.hasListeners = function (t) { return !!this.listeners(t).length; }); }, function (t, e, n) { var r = n(23), o = n(24), i = String.fromCharCode(30); t.exports = { protocol: 4, encodePacket: r, encodePayload: function (t, e) { var n = t.length, o = new Array(n), s = 0; t.forEach(function (t, c) { r(t, !1, function (t) { (o[c] = t), ++s === n && e(o.join(i)); }); }); }, decodePacket: o, decodePayload: function (t, e) { for (var n = t.split(i), r = [], s = 0; s < n.length; s++) { var c = o(n[s], e); if ((r.push(c), 'error' === c.type)) break; } return r; } }; }, function (t, e) { t.exports = 'undefined' != typeof self ? self : 'undefined' != typeof window ? window : Function('return this')(); }, function (t, e, n) { function r(t) { return (r = 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator ? function (t) { return typeof t; } : function (t) { return t && 'function' == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? 'symbol' : typeof t; })(t); } function o(t, e) { for (var n = 0; n < e.length; n++) { var r = e[n]; (r.enumerable = r.enumerable || !1), (r.configurable = !0), 'value' in r && (r.writable = !0), Object.defineProperty(t, r.key, r); } } function i(t, e) { return (i = Object.setPrototypeOf || function (t, e) { return (t.__proto__ = e), t; })(t, e); } function s(t) { var e = (function () { if ('undefined' == typeof Reflect || !Reflect.construct) return !1; if (Reflect.construct.sham) return !1; if ('function' == typeof Proxy) return !0; try { return ( Date.prototype.toString.call( Reflect.construct(Date, [], function () {}) ), !0 ); } catch (t) { return !1; } })(); return function () { var n, r = a(t); if (e) { var o = a(this).constructor; n = Reflect.construct(r, arguments, o); } else n = r.apply(this, arguments); return c(this, n); }; } function c(t, e) { return !e || ('object' !== r(e) && 'function' != typeof e) ? (function (t) { if (void 0 === t) throw new ReferenceError( "this hasn't been initialised - super() hasn't been called" ); return t; })(t) : e; } function a(t) { return (a = Object.setPrototypeOf ? Object.getPrototypeOf : function (t) { return t.__proto__ || Object.getPrototypeOf(t); })(t); } var u = n(1), f = (function (t) { !(function (t, e) { if ('function' != typeof e && null !== e) throw new TypeError( 'Super expression must either be null or a function' ); (t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } })), e && i(t, e); })(a, t); var e, n, r, c = s(a); function a(t) { var e; return ( (function (t, e) { if (!(t instanceof e)) throw new TypeError( 'Cannot call a class as a function' ); })(this, a), ((e = c.call(this)).opts = t), (e.query = t.query), (e.readyState = ''), (e.socket = t.socket), e ); } return ( (e = a), (n = [ { key: 'onError', value: function (t, e) { var n = new Error(t); return ( (n.type = 'TransportError'), (n.description = e), this.emit('error', n), this ); } }, { key: 'open', value: function () { return ( ('closed' !== this.readyState && '' !== this.readyState) || ((this.readyState = 'opening'), this.doOpen()), this ); } }, { key: 'close', value: function () { return ( ('opening' !== this.readyState && 'open' !== this.readyState) || (this.doClose(), this.onClose()), this ); } }, { key: 'send', value: function (t) { if ('open' !== this.readyState) throw new Error('Transport not open'); this.write(t); } }, { key: 'onOpen', value: function () { (this.readyState = 'open'), (this.writable = !0), this.emit('open'); } }, { key: 'onData', value: function (t) { var e = u.decodePacket( t, this.socket.binaryType ); this.onPacket(e); } }, { key: 'onPacket', value: function (t) { this.emit('packet', t); } }, { key: 'onClose', value: function () { (this.readyState = 'closed'), this.emit('close'); } } ]) && o(e.prototype, n), r && o(e, r), a ); })(n(0)); t.exports = f; }, function (t, e) { (e.encode = function (t) { var e = ''; for (var n in t) t.hasOwnProperty(n) && (e.length && (e += '&'), (e += encodeURIComponent(n) + '=' + encodeURIComponent(t[n]))); return e; }), (e.decode = function (t) { for ( var e = {}, n = t.split('&'), r = 0, o = n.length; r < o; r++ ) { var i = n[r].split('='); e[decodeURIComponent(i[0])] = decodeURIComponent(i[1]); } return e; }); }, function (t, e, n) { 'use strict'; function r(t) { return (r = 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator ? function (t) { return typeof t; } : function (t) { return t && 'function' == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? 'symbol' : typeof t; })(t); } function o(t, e, n) { return (o = 'undefined' != typeof Reflect && Reflect.get ? Reflect.get : function (t, e, n) { var r = (function (t, e) { for ( ; !Object.prototype.hasOwnProperty.call( t, e ) && null !== (t = a(t)); ); return t; })(t, e); if (r) { var o = Object.getOwnPropertyDescriptor(r, e); return o.get ? o.get.call(n) : o.value; } })(t, e, n || t); } function i(t, e) { return (i = Object.setPrototypeOf || function (t, e) { return (t.__proto__ = e), t; })(t, e); } function s(t) { var e = (function () { if ('undefined' == typeof Reflect || !Reflect.construct) return !1; if (Reflect.construct.sham) return !1; if ('function' == typeof Proxy) return !0; try { return ( Date.prototype.toString.call( Reflect.construct(Date, [], function () {}) ), !0 ); } catch (t) { return !1; } })(); return function () { var n, r = a(t); if (e) { var o = a(this).constructor; n = Reflect.construct(r, arguments, o); } else n = r.apply(this, arguments); return c(this, n); }; } function c(t, e) { return !e || ('object' !== r(e) && 'function' != typeof e) ? (function (t) { if (void 0 === t) throw new ReferenceError( "this hasn't been initialised - super() hasn't been called" ); return t; })(t) : e; } function a(t) { return (a = Object.setPrototypeOf ? Object.getPrototypeOf : function (t) { return t.__proto__ || Object.getPrototypeOf(t); })(t); } function u(t, e) { if (!(t instanceof e)) throw new TypeError('Cannot call a class as a function'); } function f(t, e) { for (var n = 0; n < e.length; n++) { var r = e[n]; (r.enumerable = r.enumerable || !1), (r.configurable = !0), 'value' in r && (r.writable = !0), Object.defineProperty(t, r.key, r); } } function p(t, e, n) { return e && f(t.prototype, e), n && f(t, n), t; } Object.defineProperty(e, '__esModule', { value: !0 }), (e.Decoder = e.Encoder = e.PacketType = e.protocol = void 0); var l, h = n(0), y = n(29), d = n(15); (e.protocol = 5), (function (t) { (t[(t.CONNECT = 0)] = 'CONNECT'), (t[(t.DISCONNECT = 1)] = 'DISCONNECT'), (t[(t.EVENT = 2)] = 'EVENT'), (t[(t.ACK = 3)] = 'ACK'), (t[(t.CONNECT_ERROR = 4)] = 'CONNECT_ERROR'), (t[(t.BINARY_EVENT = 5)] = 'BINARY_EVENT'), (t[(t.BINARY_ACK = 6)] = 'BINARY_ACK'); })((l = e.PacketType || (e.PacketType = {}))); var v = (function () { function t() { u(this, t); } return ( p(t, [ { key: 'encode', value: function (t) { return (t.type !== l.EVENT && t.type !== l.ACK) || !d.hasBinary(t) ? [this.encodeAsString(t)] : ((t.type = t.type === l.EVENT ? l.BINARY_EVENT : l.BINARY_ACK), this.encodeAsBinary(t)); } }, { key: 'encodeAsString', value: function (t) { var e = '' + t.type; return ( (t.type !== l.BINARY_EVENT && t.type !== l.BINARY_ACK) || (e += t.attachments + '-'), t.nsp && '/' !== t.nsp && (e += t.nsp + ','), null != t.id && (e += t.id), null != t.data && (e += JSON.stringify(t.data)), e ); } }, { key: 'encodeAsBinary', value: function (t) { var e = y.deconstructPacket(t), n = this.encodeAsString(e.packet), r = e.buffers; return r.unshift(n), r; } } ]), t ); })(); e.Encoder = v; var b = (function (t) { !(function (t, e) { if ('function' != typeof e && null !== e) throw new TypeError( 'Super expression must either be null or a function' ); (t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } })), e && i(t, e); })(n, t); var e = s(n); function n() { return u(this, n), e.call(this); } return ( p( n, [ { key: 'add', value: function (t) { var e; if ('string' == typeof t) (e = this.decodeString(t)).type === l.BINARY_EVENT || e.type === l.BINARY_ACK ? ((this.reconstructor = new m(e)), 0 === e.attachments && o( a(n.prototype), 'emit', this ).call(this, 'decoded', e)) : o( a(n.prototype), 'emit', this ).call(this, 'decoded', e); else { if (!d.isBinary(t) && !t.base64) throw new Error( 'Unknown type: ' + t ); if (!this.reconstructor) throw new Error( 'got binary data when not reconstructing a packet' ); (e = this.reconstructor.takeBinaryData( t )) && ((this.reconstructor = null), o( a(n.prototype), 'emit', this ).call(this, 'decoded', e)); } } }, { key: 'decodeString', value: function (t) { var e = 0, r = { type: Number(t.charAt(0)) }; if (void 0 === l[r.type]) throw new Error( 'unknown packet type ' + r.type ); if ( r.type === l.BINARY_EVENT || r.type === l.BINARY_ACK ) { for ( var o = e + 1; '-' !== t.charAt(++e) && e != t.length; ); var i = t.substring(o, e); if ( i != Number(i) || '-' !== t.charAt(e) ) throw new Error( 'Illegal attachments' ); r.attachments = Number(i); } if ('/' === t.charAt(e + 1)) { for (var s = e + 1; ++e; ) { if (',' === t.charAt(e)) break; if (e === t.length) break; } r.nsp = t.substring(s, e); } else r.nsp = '/'; var c = t.charAt(e + 1); if ('' !== c && Number(c) == c) { for (var a = e + 1; ++e; ) { var u = t.charAt(e); if (null == u || Number(u) != u) { --e; break; } if (e === t.length) break; } r.id = Number(t.substring(a, e + 1)); } if (t.charAt(++e)) { var f = (function (t) { try { return JSON.parse(t); } catch (t) { return !1; } })(t.substr(e)); if (!n.isPayloadValid(r.type, f)) throw new Error('invalid payload'); r.data = f; } return r; } }, { key: 'destroy', value: function () { this.reconstructor && this.reconstructor.finishedReconstruction(); } } ], [ { key: 'isPayloadValid', value: function (t, e) { switch (t) { case l.CONNECT: return 'object' === r(e); case l.DISCONNECT: return void 0 === e; case l.CONNECT_ERROR: return ( 'string' == typeof e || 'object' === r(e) ); case l.EVENT: case l.BINARY_EVENT: return ( Array.isArray(e) && e.length > 0 ); case l.ACK: case l.BINARY_ACK: return Array.isArray(e); } } } ] ), n ); })(h); e.Decoder = b; var m = (function () { function t(e) { u(this, t), (this.packet = e), (this.buffers = []), (this.reconPack = e); } return ( p(t, [ { key: 'takeBinaryData', value: function (t) { if ( (this.buffers.push(t), this.buffers.length === this.reconPack.attachments) ) { var e = y.reconstructPacket( this.reconPack, this.buffers ); return this.finishedReconstruction(), e; } return null; } }, { key: 'finishedReconstruction', value: function () { (this.reconPack = null), (this.buffers = []); } } ]), t ); })(); }, function (t, e) { var n = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, r = [ 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor' ]; t.exports = function (t) { var e = t, o = t.indexOf('['), i = t.indexOf(']'); -1 != o && -1 != i && (t = t.substring(0, o) + t.substring(o, i).replace(/:/g, ';') + t.substring(i, t.length)); for (var s, c, a = n.exec(t || ''), u = {}, f = 14; f--; ) u[r[f]] = a[f] || ''; return ( -1 != o && -1 != i && ((u.source = e), (u.host = u.host .substring(1, u.host.length - 1) .replace(/;/g, ':')), (u.authority = u.authority .replace('[', '') .replace(']', '') .replace(/;/g, ':')), (u.ipv6uri = !0)), (u.pathNames = (function (t, e) { var n = e.replace(/\/{2,9}/g, '/').split('/'); ('/' != e.substr(0, 1) && 0 !== e.length) || n.splice(0, 1); '/' == e.substr(e.length - 1, 1) && n.splice(n.length - 1, 1); return n; })(0, u.path)), (u.queryKey = ((s = u.query), (c = {}), s.replace( /(?:^|&)([^&=]*)=?([^&]*)/g, function (t, e, n) { e && (c[e] = n); } ), c)), u ); }; }, function (t, e, n) { 'use strict'; function r(t) { return (r = 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator ? function (t) { return typeof t; } : function (t) { return t && 'function' == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? 'symbol' : typeof t; })(t); } function o(t, e) { for (var n = 0; n < e.length; n++) { var r = e[n]; (r.enumerable = r.enumerable || !1), (r.configurable = !0), 'value' in r && (r.writable = !0), Object.defineProperty(t, r.key, r); } } function i(t, e, n) { return (i = 'undefined' != typeof Reflect && Reflect.get ? Reflect.get : function (t, e, n) { var r = (function (t, e) { for ( ; !Object.prototype.hasOwnProperty.call( t, e ) && null !== (t = u(t)); ); return t; })(t, e); if (r) { var o = Object.getOwnPropertyDescriptor(r, e); return o.get ? o.get.call(n) : o.value; } })(t, e, n || t); } function s(t, e) { return (s = Object.setPrototypeOf || function (t, e) { return (t.__proto__ = e), t; })(t, e); } function c(t) { var e = (function () { if ('undefined' == typeof Reflect || !Reflect.construct) return !1; if (Reflect.construct.sham) return !1; if ('function' == typeof Proxy) return !0; try { return ( Date.prototype.toString.call( Reflect.construct(Date, [], function () {}) ), !0 ); } catch (t) { return !1; } })(); return function () { var n, r = u(t); if (e) { var o = u(this).constructor; n = Reflect.construct(r, arguments, o); } else n = r.apply(this, arguments); return a(this, n); }; } function a(t, e) { return !e || ('object' !== r(e) && 'function' != typeof e) ? (function (t) { if (void 0 === t) throw new ReferenceError( "this hasn't been initialised - super() hasn't been called" ); return t; })(t) : e; } function u(t) { return (u = Object.setPrototypeOf ? Object.getPrototypeOf : function (t) { return t.__proto__ || Object.getPrototypeOf(t); })(t); } Object.defineProperty(e, '__esModule', { value: !0 }), (e.Manager = void 0); var f = n(19), p = n(14), l = n(0), h = n(5), y = n(16), d = n(30), v = (function (t) { !(function (t, e) { if ('function' != typeof e && null !== e) throw new TypeError( 'Super expression must either be null or a function' ); (t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } })), e && s(t, e); })(v, t); var e, n, a, l = c(v); function v(t, e) { var n; !(function (t, e) { if (!(t instanceof e)) throw new TypeError( 'Cannot call a class as a function' ); })(this, v), ((n = l.call(this)).nsps = {}), (n.subs = []), t && 'object' === r(t) && ((e = t), (t = void 0)), ((e = e || {}).path = e.path || '/socket.io'), (n.opts = e), n.reconnection(!1 !== e.reconnection), n.reconnectionAttempts( e.reconnectionAttempts || 1 / 0 ), n.reconnectionDelay(e.reconnectionDelay || 1e3), n.reconnectionDelayMax( e.reconnectionDelayMax || 5e3 ), n.randomizationFactor(e.randomizationFactor || 0.5), (n.backoff = new d({ min: n.reconnectionDelay(), max: n.reconnectionDelayMax(), jitter: n.randomizationFactor() })), n.timeout(null == e.timeout ? 2e4 : e.timeout), (n._readyState = 'closed'), (n.uri = t); var o = e.parser || h; return ( (n.encoder = new o.Encoder()), (n.decoder = new o.Decoder()), (n._autoConnect = !1 !== e.autoConnect), n._autoConnect && n.open(), n ); } return ( (e = v), (n = [ { key: 'reconnection', value: function (t) { return arguments.length ? ((this._reconnection = !!t), this) : this._reconnection; } }, { key: 'reconnectionAttempts', value: function (t) { return void 0 === t ? this._reconnectionAttempts : ((this._reconnectionAttempts = t), this); } }, { key: 'reconnectionDelay', value: function (t) { var e; return void 0 === t ? this._reconnectionDelay : ((this._reconnectionDelay = t), null === (e = this.backoff) || void 0 === e || e.setMin(t), this); } }, { key: 'randomizationFactor', value: function (t) { var e; return void 0 === t ? this._randomizationFactor : ((this._randomizationFactor = t), null === (e = this.backoff) || void 0 === e || e.setJitter(t), this); } }, { key: 'reconnectionDelayMax', value: function (t) { var e; return void 0 === t ? this._reconnectionDelayMax : ((this._reconnectionDelayMax = t), null === (e = this.backoff) || void 0 === e || e.setMax(t), this); } }, { key: 'timeout', value: function (t) { return arguments.length ? ((this._timeout = t), this) : this._timeout; } }, { key: 'maybeReconnectOnOpen', value: function () { !this._reconnecting && this._reconnection && 0 === this.backoff.attempts && this.reconnect(); } }, { key: 'open', value: function (t) { var e = this; if (~this._readyState.indexOf('open')) return this; this.engine = f(this.uri, this.opts); var n = this.engine, r = this; (this._readyState = 'opening'), (this.skipReconnect = !1); var o = y.on(n, 'open', function () { r.onopen(), t && t(); }), s = y.on(n, 'error', function (n) { r.cleanup(), (r._readyState = 'closed'), i( u(v.prototype), 'emit', e ).call(e, 'error', n), t ? t(n) : r.maybeReconnectOnOpen(); }); if (!1 !== this._timeout) { var c = this._timeout; 0 === c && o(); var a = setTimeout(function () { o(), n.close(), n.emit( 'error', new Error('timeout')