From d620b15212a31bef98391ebf53f2c72f90731467 Mon Sep 17 00:00:00 2001 From: flxxyz Date: Fri, 17 Jul 2020 03:01:45 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E8=B0=83=E6=95=B4web=E7=AB=AF?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=AD=98=E5=82=A8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/douyudanmaku.js | 2552 +++++--------------------------------- dist/douyudanmaku.js.map | 2 +- dist/douyudanmaku.min.js | 9 +- example/cli.js | 12 +- example/web/index.html | 22 +- src/client.js | 13 +- src/logger.js | 150 +-- src/loggerNode.js | 58 + 8 files changed, 442 insertions(+), 2376 deletions(-) create mode 100644 src/loggerNode.js diff --git a/dist/douyudanmaku.js b/dist/douyudanmaku.js index d3872d5..abfe18e 100644 --- a/dist/douyudanmaku.js +++ b/dist/douyudanmaku.js @@ -142,11 +142,9 @@ var packet = __webpack_require__(/*! ./packet */ "../src/packet.js"); var messageEvent = __webpack_require__(/*! ./messageEvent */ "../src/messageEvent.js"); -var logger = __webpack_require__(/*! ./logger */ "../src/logger.js"); - class Client { constructor(a, b) { - this.roomId = a, this.ws = null, this.heartbeatTask = null, this.messageEvent = messageEvent, this.ignore = [], this.options = this.setOptions(b || {}), this.clientEvent = { + this.roomId = a, this.ws = null, this.logger = null, this.heartbeatTask = null, this.messageEvent = messageEvent, this.ignore = [], this.options = this.setOptions(b || {}), this.clientEvent = { connect: { name: 'open', listener: event.open @@ -199,10 +197,12 @@ class Client { }), clearInterval(this.heartbeatTask); } - run(a) { - var b = a || __webpack_require__(/*! ./websocket */ "../src/websocket.js"); + run(a, b) { + var c = a || __webpack_require__(/*! ./websocket */ "../src/websocket.js"); + + var d = b || __webpack_require__(/*! ./logger */ "../src/logger.js"); - this.initSocket(b); + this.logger = new d(), this.initSocket(c); } setIgnore(a, b) { @@ -222,13 +222,7 @@ class Client { messageHandle(a) { packet.Decode(a, a => { var b = stt.deserialize(a); - - if (this.options.debug) { - var c = util.isBrowser() ? this.roomId : this.options.logfile; - logger.init(c), logger.echo(b); - } - - Object.keys(this.messageEvent).filter(a => !this.ignore.includes(a)).includes(b.type) && this.messageEvent[b.type](b); + this.options.debug && (this.logger.init(util.isBrowser() ? this.roomId : this.options.logfile), this.logger.echo(b)), Object.keys(this.messageEvent).filter(a => !this.ignore.includes(a)).includes(b.type) && this.messageEvent[b.type](b); }); } @@ -271,7 +265,9 @@ function open() { this.login(), this.joinGroup(), this.heartbeat(); } -function error() {} +function error(a) { + console.error(a); +} function close() { this.logout(); @@ -355,97 +351,180 @@ function _asyncToGenerator(a) { return function () { var b = this, c = arguments var util = __webpack_require__(/*! ./util */ "../src/util.js"); -var Logger = function () { - this.dbname = 'unknown', this.db = null, this.inited = false; -}; +class Logger { + constructor() { + this.name = 'unknown', this.inited = false, this.db = null, this.version = 2; + } + + init(a) { + if (!this.inited) { + this.name = a; + var b = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB; + this.DB = b.open('danmaku', this.version), this.DB.addEventListener('success', a => { + console.log('连接数据库', event, a), this.db = a.target.result; + }), this.DB.addEventListener('upgradeneeded', a => { + console.log('升级数据库', event, a), this.db = a.target.result; + var b = this.db.createObjectStore('douyu', { + keyPath: 'id', + autoIncrement: true + }); + b.createIndex('idx_room_id', 'room_id', { + unique: false + }); + }), this.DB.addEventListener('error', a => { + console.log('连接数据库出错 Error:', a); + }), this.inited = true; + } + } + + echo(a) { + if (this.db !== null) { + var b = this.db.transaction('douyu', 'readwrite'); + var c = b.objectStore('douyu'); + c.add({ + room_id: this.name, + timestamp: new Date().getTime(), + frame: a + }); + } + } -Logger.prototype.init = function (a) { - this.inited || (this.dbname = a, util.isBrowser() ? (window.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB, this._sql = indexedDB.open('danmaku', 1), this._sql.addEventListener('success', () => { - void 0, this.db = event.target.result; - }), this._sql.addEventListener('upgradeneeded', () => { - this.db = event.target.result, this.db.createObjectStore(this.dbname, { - keyPath: 'id', - autoIncrement: true - }); - }), this._sql.addEventListener('error', () => {})) : this._fs = __webpack_require__(/*! fs */ "./node_modules/node-libs-browser/mock/empty.js"), this.inited = true); -}, util.isBrowser() ? (Logger.prototype.echo = function (a) { - if (this.db !== null) { - var b = this.db.transaction(this.dbname, 'readwrite'); - var c = b.objectStore(this.dbname); - c.add({ - t: new Date().getTime(), + all(a) { + if (this.db !== null) { + var b = this.db.transaction('douyu', 'readonly'); + var c = b.objectStore('douyu'); + var d = a ? c.index('idx_room_id').getAll(a) : c.getAll(); + return new Promise(function (a, b) { + d.addEventListener('success', function (b) { + a(b.target.result); + }), d.addEventListener('error', function () { + b(false); + }); + }); + } + } + + count(a) { + if (this.db !== null) { + var b = this.db.transaction('douyu', 'readonly'); + var c = b.objectStore('douyu'); + var d = a ? c.index('idx_room_id').count(a) : c.count(); + return new Promise(function (a, b) { + d.addEventListener('success', function () { + a(d.result); + }), d.addEventListener('error', function () { + b(false); + }); + }); + } + } + + export(a) { + var b = this; + return _asyncToGenerator(function* () { + if (b.db !== null) { + var c = yield b.all(a); + var d = c.reduce((c, d) => { + var e = { + timestamp: d.timestamp, + frame: d.frame + }; + return a || (e.roomId = b.name), c.push(JSON.stringify(e)), c; + }, []); + return util.download(b.name, d.join('\n')), d; + } + })(); + } + + clear(a) { + if (this.db !== null) { + var b = this.db.transaction('douyu', 'readwrite'); + var c = b.objectStore('douyu'); + + if (a) { + var d = c.index('idx_room_id'); + var e = d.openCursor(IDBKeyRange.only(a)); + e.addEventListener('success', function () { + var a = e.result; + a && (a.delete(), a.continue()); + }); + } else c.clear(); + } + } + +} + +module.exports = util.isBrowser() ? Logger : __webpack_require__(/*! ./loggerNode */ "../src/loggerNode.js"); + +/***/ }), + +/***/ "../src/loggerNode.js": +/*!****************************!*\ + !*** ../src/loggerNode.js ***! + \****************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +function asyncGeneratorStep(a, b, c, d, e, f, g) { try { var h = a[f](g); var i = h.value; } catch (a) { return void c(a); } h.done ? b(i) : Promise.resolve(i).then(d, e); } + +function _asyncToGenerator(a) { return function () { var b = this, c = arguments; return new Promise(function (d, e) { function f(a) { asyncGeneratorStep(h, d, e, f, g, "next", a); } function g(a) { asyncGeneratorStep(h, d, e, f, g, "throw", a); } var h = a.apply(b, c); f(undefined); }); }; } + +var fs = __webpack_require__(/*! fs */ "./node_modules/node-libs-browser/mock/empty.js"); + +module.exports = class { + constructor() { + this.name = 'unknown', this.inited = false; + } + + init(a) { + this.inited || (this.name = a, this.inited = true); + } + + echo(a) { + var b = "".concat(JSON.stringify({ + timestamp: new Date().getTime(), frame: a + }), "\n"); + fs.appendFile(this.name, b, function (a) { + a && console.error('日志保存出错, Error:', a); }); } -}, Logger.prototype.all = function () { - if (this.db !== null) { - var a = this.db.transaction(this.dbname, 'readonly'); - var b = a.objectStore(this.dbname); - return new Promise(function (a, c) { - var d = b.getAll(); - d.addEventListener('success', function () { - a(d.result); - }), d.addEventListener('error', function () { - c(false); + + all() { + return new Promise((a, b) => { + fs.readFile(this.name, 'utf8', function (c, d) { + c ? b(c) : a(d); }); }); } -}, Logger.prototype.len = function () { - if (this.db !== null) { - var a = this.db.transaction(this.dbname, 'readonly'); - var b = a.objectStore(this.dbname); - return new Promise(function (a, c) { - var d = b.count(); - d.addEventListener('success', function () { - a(d.result); - }), d.addEventListener('error', function () { - c(false); + + count() { + var a = this; + return new Promise( /*#__PURE__*/function () { + var b = _asyncToGenerator(function* (b) { + var c = yield a.all(); + b(c.split('\n').filter(a => a !== '').length); }); - }); + + return function () { + return b.apply(this, arguments); + }; + }()); } -}, Logger.prototype.export = /*#__PURE__*/_asyncToGenerator(function* () { - if (this.db !== null) { - var a = yield this.all(); - var b = ''; - return a.forEach(a => { - b += "".concat(JSON.stringify({ - t: a.t, - frame: a.frame - }), "\n"); - }), util.download(this.dbname, b), b; + + export() { + return fs.readFileSync(this.name, 'utf8'); } -}), Logger.prototype.clear = function () { - if (this.db !== null) { - var a = this.db.transaction(this.dbname, 'readwrite'); - var b = a.objectStore(this.dbname); - b.clear(); + + clear() { + try { + return fs.writeFileSync(this.name, '', 'utf8'); + } catch (a) { + return false; + } } -}) : (Logger.prototype.echo = function (a) { - this._fs.appendFile(this.dbname, JSON.stringify({ - t: new Date().getTime(), - frame: a - }) + '\n', function (a) {}); -}, Logger.prototype.all = function () { - return new Promise((a, b) => { - this._fs.readFile(this.dbname, 'utf8', function (c, d) { - c ? b(c) : a(d); - }); - }); -}, Logger.prototype.len = function () { - var a = this; - return new Promise( /*#__PURE__*/function () { - var b = _asyncToGenerator(function* (b) { - var c = yield a.all(); - b(c.split('\n').filter(a => a !== '').length); - }); - return function () { - return b.apply(this, arguments); - }; - }()); -}, Logger.prototype.export = function () { - return this._fs.readFileSync(this.dbname, 'utf8'); -}, Logger.prototype.clear = function () {}), module.exports = new Logger(); +}; /***/ }), @@ -476,11 +555,63 @@ module.exports = { // best_dlev 最高酬勤等级 // cur_lev 酬勤等级 }, - chatmsg: function chatmsg() {}, - uenter: function uenter() {}, + chatmsg: function chatmsg(a) { + // 弹幕消息 + // 用户在房间发送弹幕时,服务端发此消息给客户端,完整的数据部分应包含的字 段如下: + // 字段说明 + // type 表示为“弹幕”消息,固定为 chatmsg + // gid 弹幕组 id + // rid 房间 id + // uid 发送者 uid + // nn 发送者昵称 + // txt 弹幕文本内容 + // cid 弹幕唯一 ID + // level 用户等级 + // gt 礼物头衔:默认值 0(表示没有头衔) + // col 颜色:默认值 0(表示默认颜色弹幕) + // ct 客户端类型:默认值 0(表示 web 用户) + // rg 房间权限组:默认值 1(表示普通权限用户) + // pg 平台权限组:默认值 1(表示普通权限用户) + // dlv 酬勤等级:默认值 0(表示没有酬勤) + // dc 酬勤数量:默认值 0(表示没有酬勤数量) + // bdlv 最高酬勤等级:默认值 0(表示全站都没有酬勤) + console.log(" [%s] %s", a.level + (a.level < 10 ? ' ' : ''), a.nn, a.txt); + }, + uenter: function uenter(a) { + // 进入直播间 + // 具有特殊属性的用户进入直播间时,服务端发送此消息至客户端。完整的数据部 分应包含的字段如下: + // 字段说明 + // type 表示为“用户进房通知”消息,固定为 uenter + // rid 房间 ID + // gid 弹幕分组 ID + // uid 用户 ID + // nn 用户昵称 + // str 战斗力 + // level 新用户等级 + // gt 礼物头衔:默认值 0(表示没有头衔) + // rg 房间权限组:默认值 1(表示普通权限用户) + // pg 平台身份组:默认值 1(表示普通权限用户) + // dlv 酬勤等级:默认值 0(表示没有酬勤) + // dc 酬勤数量:默认值 0(表示没有酬勤数量) + // bdlv 最高酬勤等级:默认值 0(表示全站都没有酬勤) + console.log("\u6B22\u8FCE").concat(a.nn, "\u8FDB\u5165\u4E86\u76F4\u64AD\u95F4")); + }, upgrade: function upgrade() {// 用户等级提升 }, - rss: function rss() {}, + rss: function rss(a) { + // 房间开播提醒 + // 房间开播提醒主要部分应包含的字段如下: + // 字段说明 + // type 表示为“房间开播提醒”消息,固定为 rss + // rid 房间 id + // gid 弹幕分组 id + // ss 直播状态,1-正在直播, 2-没有直播 + // code 类型 + // rt 开关播原因:0-主播开关播,其他值-其他原因 + // notify 通知类型 + // endtime 关播时间(仅关播时有效) + console.log('[开播提醒]', a.ss == 1 ? config.MSG_LIVE_ON : config.MSG_LIVE_OFF); + }, bc_buy_deserve: function bc_buy_deserve() {// 赠送酬勤通知 // 用户赠送酬勤时,服务端发送此消息至客户端。完整的数据部分应包含的字段如 下: // 字段说明 @@ -503,7 +634,25 @@ module.exports = { // trid 跳转房间 id // content 超级弹幕的内容 }, - spbc: function spbc() {}, + spbc: function spbc(a) { + // 房间内礼物广播 + // 房间内赠送礼物成功后效果主要部分应包含的字段如下: + // 字段说明 + // type 表示为“房间内礼物广播”,固定为 spbc + // rid 房间 id + // gid 弹幕分组 id + // sn 赠送者昵称 + // dn 受赠者昵称 + // gn 礼物名称 + // gc 礼物数量 + // drid 赠送房间 + // gs 广播样式 + // gb 是否有礼包(0-无礼包,1-有礼包) + // es 广播展现样式(1-火箭,2-飞机) + // gfid 礼物 id + // eid 特效 id + console.log("------------- \u611F\u8C22[".concat(a.sn, "] \u8D60\u9001\u7684 ").concat(a.gn, "x").concat(a.gc)); + }, dgb: function dgb() {// 赠送礼物 // 用户在房间赠送礼物时,服务端发送此消息给客户端。完整的数据部分应包含的 字段如下: // 字段说明 @@ -528,7 +677,20 @@ module.exports = { // slt 红包开启剩余时间:默认值 0(表示没有红包) // elt 红包销毁剩余时间:默认值 0(表示没有红包) }, - onlinegift: function onlinegift() {}, + onlinegift: function onlinegift(a) { + // 领取在线鱼丸 + // 在线领取鱼丸时,若出现暴击(鱼丸数大于等于 60)服务则发送领取暴击消息 到客户端。完整的数据部分应包含的字段如下: + // 字段说明 + // type 表示为“领取在线鱼丸”消息,固定为 onlinegift + // rid 房间 ID + // uid 用户 ID + // gid 弹幕分组 ID + // sil 鱼丸数 + // if 领取鱼丸的等级 + // ct 客户端类型标识 + // nn 用户昵称 + console.log("------------- [".concat(a.nn, "] \u9886\u53D6\u9C7C\u4E38x").concat(a.sil)); + }, ggbb: function ggbb() {// 房间用户抢红包 // 房间赠送礼物成功后效果(赠送礼物效果,连击数)主要部分应包含的字段如下: // 字段说明 @@ -608,101 +770,74 @@ module.exports = { /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(Buffer) {__webpack_require__(/*! fast-text-encoding */ "../node_modules/fast-text-encoding/text.min.js"); +__webpack_require__(/*! fast-text-encoding */ "../node_modules/fast-text-encoding/text.min.js"); var util = __webpack_require__(/*! ./util */ "../src/util.js"); -function BufferCoder() { - this.buffer = new ArrayBuffer(0), this.decoder = new TextDecoder(), this.encoder = new TextEncoder(), this.littleEndian = !0, this.readLength = 0; -} - -BufferCoder.prototype.concat = function () { - var a = []; - - for (var b = 0; b < arguments.length; b++) a[b] = arguments[b]; - - return a.reduce(function (a, b) { - var c = b instanceof ArrayBuffer ? new Uint8Array(b) : b; - var d = new Uint8Array(a.length + c.length); - return d.set(a, 0), d.set(c, a.length), d; - }, new Uint8Array(0)); -}, BufferCoder.prototype.Decode = function (a, b, c) { - for (c = c || this.littleEndian, this.buffer = this.concat(this.buffer, a).buffer; this.buffer && this.buffer.byteLength > 0;) { - if (0 === this.readLength) { - if (this.buffer.byteLength < 4) return; - this.readLength = new DataView(this.buffer).getUint32(0, c), this.buffer = this.buffer.slice(4); - } - - if (this.buffer.byteLength < this.readLength) return; - var d = this.decoder.decode(this.buffer.slice(8, this.readLength - 1)); - this.buffer = this.buffer.slice(this.readLength), this.readLength = 0, b(d); - } -}, BufferCoder.prototype.Encode = function (a, b) { - b = b || this.littleEndian; - var c = this.concat(this.encoder.encode(a), Uint8Array.of(0)); - var d = 8 + c.length; - var e = new DataView(new ArrayBuffer(d + 4)); - var f = 0; - return e.setUint32(f, d, b), f += 4, e.setUint32(f, d, b), f += 4, e.setInt16(f, 689, b), f += 2, e.setInt8(f, 0), f += 1, e.setInt8(f, 0), f += 1, (new Uint8Array(e.buffer).set(c, f), e.buffer); -}, BufferCoder.prototype.blob2ab = function (a) { - return new Promise(b => { - var c = new FileReader(); - c.onload = function (a) { - b(a.target.result); - }, c.readAsArrayBuffer(a); - }); -}, BufferCoder.prototype.ab2blob = function (a) { - return new Blob([a]); -}; -var browser = new BufferCoder(); - class Packet { constructor() { - this.HEADER_LEN_SIZE = 4, this.HEADER_LEN_TYPECODE = 2, this.HEADER_LEN_ENCRYPT = 1, this.HEADER_LEN_PLACEHOLDER = 1, this.HEADER_LEN_TOTAL = this.HEADER_LEN_SIZE * 2 + this.HEADER_LEN_TYPECODE + this.HEADER_LEN_ENCRYPT + this.HEADER_LEN_PLACEHOLDER, this.buffer = Buffer.alloc(0); + this.HEADER_LEN_SIZE = 4, this.HEADER_LEN_TYPECODE = 2, this.HEADER_LEN_ENCRYPT = 1, this.HEADER_LEN_PLACEHOLDER = 1, this.HEADER_LEN_TOTAL = this.HEADER_LEN_SIZE * 2 + this.HEADER_LEN_TYPECODE + this.HEADER_LEN_ENCRYPT + this.HEADER_LEN_PLACEHOLDER, this.encoder = new TextEncoder(), this.decoder = new TextDecoder(), this.buffer = new ArrayBuffer(0), this.readLength = 0; } - nodeEncode(a) { - var b = Buffer.alloc(this.HEADER_LEN_TOTAL); - var c = Buffer.from(a, 'utf8'); - var d = c.length + this.HEADER_LEN_TOTAL + 1; - return b.writeInt32LE(d - this.HEADER_LEN_SIZE, 0), b.writeInt32LE(d - this.HEADER_LEN_SIZE, 4), b.writeInt16LE(689, 8), Buffer.concat([b, c], d); - } + concat() { + var a = []; - browserEncode(a) { - return browser.Encode(a); + for (var b = 0; b < arguments.length; b++) a[b] = arguments[b]; + + return a.reduce(function (a, b) { + var c = b instanceof ArrayBuffer ? new Uint8Array(b) : b; + var d = new Uint8Array(a.length + c.length); + return d.set(a, 0), d.set(c, a.length), d; + }, new Uint8Array(0)); } Encode(a) { - return util.isBrowser() ? this.browserEncode(a) : this.nodeEncode(a); + var b = this.concat(this.encoder.encode(a), Uint8Array.of(0)); + var c = b.length + this.HEADER_LEN_SIZE * 2; + var d = b.length + this.HEADER_LEN_TOTAL; + var e = new DataView(new ArrayBuffer(d)); + return e.setUint32(0, c, true), e.setUint32(4, c, true), e.setInt16(8, 689, true), e.setInt16(10, 0, true), (new Uint8Array(e.buffer).set(b, this.HEADER_LEN_TOTAL), e.buffer); } - nodeDecode(a, b) { - this.buffer = Buffer.concat([this.buffer, a]); - - for (var c = 0; this.buffer.length > 0; c = 0) { - if (0 === c) { - if (this.buffer.length < this.HEADER_LEN_SIZE) return; - c = this.buffer.readInt32LE(this.HEADER_LEN_SIZE), this.buffer = this.buffer.slice(this.HEADER_LEN_SIZE); + Decode(a, b) { + for (this.buffer = this.concat(this.buffer, a).buffer; this.buffer && this.buffer.byteLength > 0;) { + if (0 === this.readLength) { + if (this.buffer.byteLength < 4) return; + this.readLength = new DataView(this.buffer).getUint32(0, true), this.buffer = this.buffer.slice(4); } - if (this.buffer.length < c) return; - var d = this.buffer.slice(this.HEADER_LEN_SIZE * 2, c - 1).toString('utf8'); - this.buffer = this.buffer.slice(c), b(d); + if (this.buffer.byteLength < this.readLength) return; + var c = this.decoder.decode(this.buffer.slice(8, this.readLength - 1)); + this.buffer = this.buffer.slice(this.readLength), this.readLength = 0, b(c); } } + /** + * blob转arraybuffer + * @param {Blob} blob 待转换的Blob类型参数 + */ + - browserDecode(a, b) { - browser.Decode(a, b); + Blob2ab(a) { + return new Promise(b => { + var c = new FileReader(); + c.onload = function (a) { + b(a.target.result); + }, c.readAsArrayBuffer(a); + }); } + /** + * arraybuffer转blob + * @param {ArrayBuffer} ab 待转换的ArrayBuffer类型参数 + */ - Decode(a, b) { - util.isBrowser() ? this.browserDecode(a, b) : this.nodeDecode(a, b); + + Ab2blob(a) { + return new Blob([a]); } } module.exports = new Packet(); -/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../build/node_modules/buffer/index.js */ "./node_modules/buffer/index.js").Buffer)) /***/ }), @@ -717,11 +852,11 @@ var util = __webpack_require__(/*! ./util */ "../src/util.js"); class STT { escape(a) { - return util.isUndefined(a) ? '' : a.toString().replace(/\//g, '@S').replace(/@/g, '@A'); + return util.isUndefined(a) ? '' : a.toString().replace(/@/g, '@A').replace(/\//g, '@S'); } unescape(a) { - return util.isUndefined(a) ? '' : a.toString().replace(/@S/g, '/').replace(/@A/g, '@'); + return util.isUndefined(a) ? '' : a.toString().replace(/@A/g, '@').replace(/@S/g, '/'); } serialize(a) { @@ -818,2083 +953,6 @@ __webpack_require__.r(__webpack_exports__); window.douyudanmaku = _src_index__WEBPACK_IMPORTED_MODULE_0___default.a, window.danmaku = _src_index__WEBPACK_IMPORTED_MODULE_0___default.a; -/***/ }), - -/***/ "./node_modules/base64-js/index.js": -/*!*****************************************!*\ - !*** ./node_modules/base64-js/index.js ***! - \*****************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -exports.byteLength = byteLength -exports.toByteArray = toByteArray -exports.fromByteArray = fromByteArray - -var lookup = [] -var revLookup = [] -var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array - -var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -for (var i = 0, len = code.length; i < len; ++i) { - lookup[i] = code[i] - revLookup[code.charCodeAt(i)] = i -} - -// Support decoding URL-safe base64 strings, as Node.js does. -// See: https://en.wikipedia.org/wiki/Base64#URL_applications -revLookup['-'.charCodeAt(0)] = 62 -revLookup['_'.charCodeAt(0)] = 63 - -function getLens (b64) { - var len = b64.length - - if (len % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // Trim off extra bytes after placeholder bytes are found - // See: https://github.com/beatgammit/base64-js/issues/42 - var validLen = b64.indexOf('=') - if (validLen === -1) validLen = len - - var placeHoldersLen = validLen === len - ? 0 - : 4 - (validLen % 4) - - return [validLen, placeHoldersLen] -} - -// base64 is 4/3 + up to two characters of the original data -function byteLength (b64) { - var lens = getLens(b64) - var validLen = lens[0] - var placeHoldersLen = lens[1] - return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen -} - -function _byteLength (b64, validLen, placeHoldersLen) { - return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen -} - -function toByteArray (b64) { - var tmp - var lens = getLens(b64) - var validLen = lens[0] - var placeHoldersLen = lens[1] - - var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) - - var curByte = 0 - - // if there are placeholders, only get up to the last complete 4 chars - var len = placeHoldersLen > 0 - ? validLen - 4 - : validLen - - var i - for (i = 0; i < len; i += 4) { - tmp = - (revLookup[b64.charCodeAt(i)] << 18) | - (revLookup[b64.charCodeAt(i + 1)] << 12) | - (revLookup[b64.charCodeAt(i + 2)] << 6) | - revLookup[b64.charCodeAt(i + 3)] - arr[curByte++] = (tmp >> 16) & 0xFF - arr[curByte++] = (tmp >> 8) & 0xFF - arr[curByte++] = tmp & 0xFF - } - - if (placeHoldersLen === 2) { - tmp = - (revLookup[b64.charCodeAt(i)] << 2) | - (revLookup[b64.charCodeAt(i + 1)] >> 4) - arr[curByte++] = tmp & 0xFF - } - - if (placeHoldersLen === 1) { - tmp = - (revLookup[b64.charCodeAt(i)] << 10) | - (revLookup[b64.charCodeAt(i + 1)] << 4) | - (revLookup[b64.charCodeAt(i + 2)] >> 2) - arr[curByte++] = (tmp >> 8) & 0xFF - arr[curByte++] = tmp & 0xFF - } - - return arr -} - -function tripletToBase64 (num) { - return lookup[num >> 18 & 0x3F] + - lookup[num >> 12 & 0x3F] + - lookup[num >> 6 & 0x3F] + - lookup[num & 0x3F] -} - -function encodeChunk (uint8, start, end) { - var tmp - var output = [] - for (var i = start; i < end; i += 3) { - tmp = - ((uint8[i] << 16) & 0xFF0000) + - ((uint8[i + 1] << 8) & 0xFF00) + - (uint8[i + 2] & 0xFF) - output.push(tripletToBase64(tmp)) - } - return output.join('') -} - -function fromByteArray (uint8) { - var tmp - var len = uint8.length - var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes - var parts = [] - var maxChunkLength = 16383 // must be multiple of 3 - - // go through the array every three bytes, we'll deal with trailing stuff later - for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk( - uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) - )) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - if (extraBytes === 1) { - tmp = uint8[len - 1] - parts.push( - lookup[tmp >> 2] + - lookup[(tmp << 4) & 0x3F] + - '==' - ) - } else if (extraBytes === 2) { - tmp = (uint8[len - 2] << 8) + uint8[len - 1] - parts.push( - lookup[tmp >> 10] + - lookup[(tmp >> 4) & 0x3F] + - lookup[(tmp << 2) & 0x3F] + - '=' - ) - } - - return parts.join('') -} - - -/***/ }), - -/***/ "./node_modules/buffer/index.js": -/*!**************************************!*\ - !*** ./node_modules/buffer/index.js ***! - \**************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -/* WEBPACK VAR INJECTION */(function(global) {/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -/* eslint-disable no-proto */ - - - -var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js") -var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js") -var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js") - -exports.Buffer = Buffer -exports.SlowBuffer = SlowBuffer -exports.INSPECT_MAX_BYTES = 50 - -/** - * If `Buffer.TYPED_ARRAY_SUPPORT`: - * === true Use Uint8Array implementation (fastest) - * === false Use Object implementation (most compatible, even IE6) - * - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, - * Opera 11.6+, iOS 4.2+. - * - * Due to various browser bugs, sometimes the Object implementation will be used even - * when the browser supports typed arrays. - * - * Note: - * - * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, - * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. - * - * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. - * - * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of - * incorrect length in some situations. - - * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they - * get the Object implementation, which is slower but behaves correctly. - */ -Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined - ? global.TYPED_ARRAY_SUPPORT - : typedArraySupport() - -/* - * Export kMaxLength after typed array support is determined. - */ -exports.kMaxLength = kMaxLength() - -function typedArraySupport () { - try { - var arr = new Uint8Array(1) - arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} - return arr.foo() === 42 && // typed array instances can be augmented - typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` - arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` - } catch (e) { - return false - } -} - -function kMaxLength () { - return Buffer.TYPED_ARRAY_SUPPORT - ? 0x7fffffff - : 0x3fffffff -} - -function createBuffer (that, length) { - if (kMaxLength() < length) { - throw new RangeError('Invalid typed array length') - } - if (Buffer.TYPED_ARRAY_SUPPORT) { - // Return an augmented `Uint8Array` instance, for best performance - that = new Uint8Array(length) - that.__proto__ = Buffer.prototype - } else { - // Fallback: Return an object instance of the Buffer class - if (that === null) { - that = new Buffer(length) - } - that.length = length - } - - return that -} - -/** - * The Buffer constructor returns instances of `Uint8Array` that have their - * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of - * `Uint8Array`, so the returned instances will have all the node `Buffer` methods - * and the `Uint8Array` methods. Square bracket notation works as expected -- it - * returns a single octet. - * - * The `Uint8Array` prototype remains unmodified. - */ - -function Buffer (arg, encodingOrOffset, length) { - if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { - return new Buffer(arg, encodingOrOffset, length) - } - - // Common case. - if (typeof arg === 'number') { - if (typeof encodingOrOffset === 'string') { - throw new Error( - 'If encoding is specified then the first argument must be a string' - ) - } - return allocUnsafe(this, arg) - } - return from(this, arg, encodingOrOffset, length) -} - -Buffer.poolSize = 8192 // not used by this implementation - -// TODO: Legacy, not needed anymore. Remove in next major version. -Buffer._augment = function (arr) { - arr.__proto__ = Buffer.prototype - return arr -} - -function from (that, value, encodingOrOffset, length) { - if (typeof value === 'number') { - throw new TypeError('"value" argument must not be a number') - } - - if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { - return fromArrayBuffer(that, value, encodingOrOffset, length) - } - - if (typeof value === 'string') { - return fromString(that, value, encodingOrOffset) - } - - return fromObject(that, value) -} - -/** - * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError - * if value is a number. - * Buffer.from(str[, encoding]) - * Buffer.from(array) - * Buffer.from(buffer) - * Buffer.from(arrayBuffer[, byteOffset[, length]]) - **/ -Buffer.from = function (value, encodingOrOffset, length) { - return from(null, value, encodingOrOffset, length) -} - -if (Buffer.TYPED_ARRAY_SUPPORT) { - Buffer.prototype.__proto__ = Uint8Array.prototype - Buffer.__proto__ = Uint8Array - if (typeof Symbol !== 'undefined' && Symbol.species && - Buffer[Symbol.species] === Buffer) { - // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 - Object.defineProperty(Buffer, Symbol.species, { - value: null, - configurable: true - }) - } -} - -function assertSize (size) { - if (typeof size !== 'number') { - throw new TypeError('"size" argument must be a number') - } else if (size < 0) { - throw new RangeError('"size" argument must not be negative') - } -} - -function alloc (that, size, fill, encoding) { - assertSize(size) - if (size <= 0) { - return createBuffer(that, size) - } - if (fill !== undefined) { - // Only pay attention to encoding if it's a string. This - // prevents accidentally sending in a number that would - // be interpretted as a start offset. - return typeof encoding === 'string' - ? createBuffer(that, size).fill(fill, encoding) - : createBuffer(that, size).fill(fill) - } - return createBuffer(that, size) -} - -/** - * Creates a new filled Buffer instance. - * alloc(size[, fill[, encoding]]) - **/ -Buffer.alloc = function (size, fill, encoding) { - return alloc(null, size, fill, encoding) -} - -function allocUnsafe (that, size) { - assertSize(size) - that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) - if (!Buffer.TYPED_ARRAY_SUPPORT) { - for (var i = 0; i < size; ++i) { - that[i] = 0 - } - } - return that -} - -/** - * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. - * */ -Buffer.allocUnsafe = function (size) { - return allocUnsafe(null, size) -} -/** - * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. - */ -Buffer.allocUnsafeSlow = function (size) { - return allocUnsafe(null, size) -} - -function fromString (that, string, encoding) { - if (typeof encoding !== 'string' || encoding === '') { - encoding = 'utf8' - } - - if (!Buffer.isEncoding(encoding)) { - throw new TypeError('"encoding" must be a valid string encoding') - } - - var length = byteLength(string, encoding) | 0 - that = createBuffer(that, length) - - var actual = that.write(string, encoding) - - if (actual !== length) { - // Writing a hex string, for example, that contains invalid characters will - // cause everything after the first invalid character to be ignored. (e.g. - // 'abxxcd' will be treated as 'ab') - that = that.slice(0, actual) - } - - return that -} - -function fromArrayLike (that, array) { - var length = array.length < 0 ? 0 : checked(array.length) | 0 - that = createBuffer(that, length) - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255 - } - return that -} - -function fromArrayBuffer (that, array, byteOffset, length) { - array.byteLength // this throws if `array` is not a valid ArrayBuffer - - if (byteOffset < 0 || array.byteLength < byteOffset) { - throw new RangeError('\'offset\' is out of bounds') - } - - if (array.byteLength < byteOffset + (length || 0)) { - throw new RangeError('\'length\' is out of bounds') - } - - if (byteOffset === undefined && length === undefined) { - array = new Uint8Array(array) - } else if (length === undefined) { - array = new Uint8Array(array, byteOffset) - } else { - array = new Uint8Array(array, byteOffset, length) - } - - if (Buffer.TYPED_ARRAY_SUPPORT) { - // Return an augmented `Uint8Array` instance, for best performance - that = array - that.__proto__ = Buffer.prototype - } else { - // Fallback: Return an object instance of the Buffer class - that = fromArrayLike(that, array) - } - return that -} - -function fromObject (that, obj) { - if (Buffer.isBuffer(obj)) { - var len = checked(obj.length) | 0 - that = createBuffer(that, len) - - if (that.length === 0) { - return that - } - - obj.copy(that, 0, 0, len) - return that - } - - if (obj) { - if ((typeof ArrayBuffer !== 'undefined' && - obj.buffer instanceof ArrayBuffer) || 'length' in obj) { - if (typeof obj.length !== 'number' || isnan(obj.length)) { - return createBuffer(that, 0) - } - return fromArrayLike(that, obj) - } - - if (obj.type === 'Buffer' && isArray(obj.data)) { - return fromArrayLike(that, obj.data) - } - } - - throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') -} - -function checked (length) { - // Note: cannot use `length < kMaxLength()` here because that fails when - // length is NaN (which is otherwise coerced to zero.) - if (length >= kMaxLength()) { - throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + kMaxLength().toString(16) + ' bytes') - } - return length | 0 -} - -function SlowBuffer (length) { - if (+length != length) { // eslint-disable-line eqeqeq - length = 0 - } - return Buffer.alloc(+length) -} - -Buffer.isBuffer = function isBuffer (b) { - return !!(b != null && b._isBuffer) -} - -Buffer.compare = function compare (a, b) { - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError('Arguments must be Buffers') - } - - if (a === b) return 0 - - var x = a.length - var y = b.length - - for (var i = 0, len = Math.min(x, y); i < len; ++i) { - if (a[i] !== b[i]) { - x = a[i] - y = b[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -Buffer.isEncoding = function isEncoding (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'latin1': - case 'binary': - case 'base64': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false - } -} - -Buffer.concat = function concat (list, length) { - if (!isArray(list)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - - if (list.length === 0) { - return Buffer.alloc(0) - } - - var i - if (length === undefined) { - length = 0 - for (i = 0; i < list.length; ++i) { - length += list[i].length - } - } - - var buffer = Buffer.allocUnsafe(length) - var pos = 0 - for (i = 0; i < list.length; ++i) { - var buf = list[i] - if (!Buffer.isBuffer(buf)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - buf.copy(buffer, pos) - pos += buf.length - } - return buffer -} - -function byteLength (string, encoding) { - if (Buffer.isBuffer(string)) { - return string.length - } - if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && - (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { - return string.byteLength - } - if (typeof string !== 'string') { - string = '' + string - } - - var len = string.length - if (len === 0) return 0 - - // Use a for loop to avoid recursion - var loweredCase = false - for (;;) { - switch (encoding) { - case 'ascii': - case 'latin1': - case 'binary': - return len - case 'utf8': - case 'utf-8': - case undefined: - return utf8ToBytes(string).length - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return len * 2 - case 'hex': - return len >>> 1 - case 'base64': - return base64ToBytes(string).length - default: - if (loweredCase) return utf8ToBytes(string).length // assume utf8 - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} -Buffer.byteLength = byteLength - -function slowToString (encoding, start, end) { - var loweredCase = false - - // No need to verify that "this.length <= MAX_UINT32" since it's a read-only - // property of a typed array. - - // This behaves neither like String nor Uint8Array in that we set start/end - // to their upper/lower bounds if the value passed is out of range. - // undefined is handled specially as per ECMA-262 6th Edition, - // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. - if (start === undefined || start < 0) { - start = 0 - } - // Return early if start > this.length. Done here to prevent potential uint32 - // coercion fail below. - if (start > this.length) { - return '' - } - - if (end === undefined || end > this.length) { - end = this.length - } - - if (end <= 0) { - return '' - } - - // Force coersion to uint32. This will also coerce falsey/NaN values to 0. - end >>>= 0 - start >>>= 0 - - if (end <= start) { - return '' - } - - if (!encoding) encoding = 'utf8' - - while (true) { - switch (encoding) { - case 'hex': - return hexSlice(this, start, end) - - case 'utf8': - case 'utf-8': - return utf8Slice(this, start, end) - - case 'ascii': - return asciiSlice(this, start, end) - - case 'latin1': - case 'binary': - return latin1Slice(this, start, end) - - case 'base64': - return base64Slice(this, start, end) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = (encoding + '').toLowerCase() - loweredCase = true - } - } -} - -// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect -// Buffer instances. -Buffer.prototype._isBuffer = true - -function swap (b, n, m) { - var i = b[n] - b[n] = b[m] - b[m] = i -} - -Buffer.prototype.swap16 = function swap16 () { - var len = this.length - if (len % 2 !== 0) { - throw new RangeError('Buffer size must be a multiple of 16-bits') - } - for (var i = 0; i < len; i += 2) { - swap(this, i, i + 1) - } - return this -} - -Buffer.prototype.swap32 = function swap32 () { - var len = this.length - if (len % 4 !== 0) { - throw new RangeError('Buffer size must be a multiple of 32-bits') - } - for (var i = 0; i < len; i += 4) { - swap(this, i, i + 3) - swap(this, i + 1, i + 2) - } - return this -} - -Buffer.prototype.swap64 = function swap64 () { - var len = this.length - if (len % 8 !== 0) { - throw new RangeError('Buffer size must be a multiple of 64-bits') - } - for (var i = 0; i < len; i += 8) { - swap(this, i, i + 7) - swap(this, i + 1, i + 6) - swap(this, i + 2, i + 5) - swap(this, i + 3, i + 4) - } - return this -} - -Buffer.prototype.toString = function toString () { - var length = this.length | 0 - if (length === 0) return '' - if (arguments.length === 0) return utf8Slice(this, 0, length) - return slowToString.apply(this, arguments) -} - -Buffer.prototype.equals = function equals (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return true - return Buffer.compare(this, b) === 0 -} - -Buffer.prototype.inspect = function inspect () { - var str = '' - var max = exports.INSPECT_MAX_BYTES - if (this.length > 0) { - str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') - if (this.length > max) str += ' ... ' - } - return '' -} - -Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { - if (!Buffer.isBuffer(target)) { - throw new TypeError('Argument must be a Buffer') - } - - if (start === undefined) { - start = 0 - } - if (end === undefined) { - end = target ? target.length : 0 - } - if (thisStart === undefined) { - thisStart = 0 - } - if (thisEnd === undefined) { - thisEnd = this.length - } - - if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { - throw new RangeError('out of range index') - } - - if (thisStart >= thisEnd && start >= end) { - return 0 - } - if (thisStart >= thisEnd) { - return -1 - } - if (start >= end) { - return 1 - } - - start >>>= 0 - end >>>= 0 - thisStart >>>= 0 - thisEnd >>>= 0 - - if (this === target) return 0 - - var x = thisEnd - thisStart - var y = end - start - var len = Math.min(x, y) - - var thisCopy = this.slice(thisStart, thisEnd) - var targetCopy = target.slice(start, end) - - for (var i = 0; i < len; ++i) { - if (thisCopy[i] !== targetCopy[i]) { - x = thisCopy[i] - y = targetCopy[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, -// OR the last index of `val` in `buffer` at offset <= `byteOffset`. -// -// Arguments: -// - buffer - a Buffer to search -// - val - a string, Buffer, or number -// - byteOffset - an index into `buffer`; will be clamped to an int32 -// - encoding - an optional encoding, relevant is val is a string -// - dir - true for indexOf, false for lastIndexOf -function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { - // Empty buffer means no match - if (buffer.length === 0) return -1 - - // Normalize byteOffset - if (typeof byteOffset === 'string') { - encoding = byteOffset - byteOffset = 0 - } else if (byteOffset > 0x7fffffff) { - byteOffset = 0x7fffffff - } else if (byteOffset < -0x80000000) { - byteOffset = -0x80000000 - } - byteOffset = +byteOffset // Coerce to Number. - if (isNaN(byteOffset)) { - // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer - byteOffset = dir ? 0 : (buffer.length - 1) - } - - // Normalize byteOffset: negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = buffer.length + byteOffset - if (byteOffset >= buffer.length) { - if (dir) return -1 - else byteOffset = buffer.length - 1 - } else if (byteOffset < 0) { - if (dir) byteOffset = 0 - else return -1 - } - - // Normalize val - if (typeof val === 'string') { - val = Buffer.from(val, encoding) - } - - // Finally, search either indexOf (if dir is true) or lastIndexOf - if (Buffer.isBuffer(val)) { - // Special case: looking for empty string/buffer always fails - if (val.length === 0) { - return -1 - } - return arrayIndexOf(buffer, val, byteOffset, encoding, dir) - } else if (typeof val === 'number') { - val = val & 0xFF // Search for a byte value [0-255] - if (Buffer.TYPED_ARRAY_SUPPORT && - typeof Uint8Array.prototype.indexOf === 'function') { - if (dir) { - return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) - } else { - return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) - } - } - return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) - } - - throw new TypeError('val must be string, number or Buffer') -} - -function arrayIndexOf (arr, val, byteOffset, encoding, dir) { - var indexSize = 1 - var arrLength = arr.length - var valLength = val.length - - if (encoding !== undefined) { - encoding = String(encoding).toLowerCase() - if (encoding === 'ucs2' || encoding === 'ucs-2' || - encoding === 'utf16le' || encoding === 'utf-16le') { - if (arr.length < 2 || val.length < 2) { - return -1 - } - indexSize = 2 - arrLength /= 2 - valLength /= 2 - byteOffset /= 2 - } - } - - function read (buf, i) { - if (indexSize === 1) { - return buf[i] - } else { - return buf.readUInt16BE(i * indexSize) - } - } - - var i - if (dir) { - var foundIndex = -1 - for (i = byteOffset; i < arrLength; i++) { - if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { - if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === valLength) return foundIndex * indexSize - } else { - if (foundIndex !== -1) i -= i - foundIndex - foundIndex = -1 - } - } - } else { - if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength - for (i = byteOffset; i >= 0; i--) { - var found = true - for (var j = 0; j < valLength; j++) { - if (read(arr, i + j) !== read(val, j)) { - found = false - break - } - } - if (found) return i - } - } - - return -1 -} - -Buffer.prototype.includes = function includes (val, byteOffset, encoding) { - return this.indexOf(val, byteOffset, encoding) !== -1 -} - -Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, true) -} - -Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, false) -} - -function hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - - // must be an even number of digits - var strLen = string.length - if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') - - if (length > strLen / 2) { - length = strLen / 2 - } - for (var i = 0; i < length; ++i) { - var parsed = parseInt(string.substr(i * 2, 2), 16) - if (isNaN(parsed)) return i - buf[offset + i] = parsed - } - return i -} - -function utf8Write (buf, string, offset, length) { - return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) -} - -function asciiWrite (buf, string, offset, length) { - return blitBuffer(asciiToBytes(string), buf, offset, length) -} - -function latin1Write (buf, string, offset, length) { - return asciiWrite(buf, string, offset, length) -} - -function base64Write (buf, string, offset, length) { - return blitBuffer(base64ToBytes(string), buf, offset, length) -} - -function ucs2Write (buf, string, offset, length) { - return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) -} - -Buffer.prototype.write = function write (string, offset, length, encoding) { - // Buffer#write(string) - if (offset === undefined) { - encoding = 'utf8' - length = this.length - offset = 0 - // Buffer#write(string, encoding) - } else if (length === undefined && typeof offset === 'string') { - encoding = offset - length = this.length - offset = 0 - // Buffer#write(string, offset[, length][, encoding]) - } else if (isFinite(offset)) { - offset = offset | 0 - if (isFinite(length)) { - length = length | 0 - if (encoding === undefined) encoding = 'utf8' - } else { - encoding = length - length = undefined - } - // legacy write(string, encoding, offset, length) - remove in v0.13 - } else { - throw new Error( - 'Buffer.write(string, encoding, offset[, length]) is no longer supported' - ) - } - - var remaining = this.length - offset - if (length === undefined || length > remaining) length = remaining - - if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { - throw new RangeError('Attempt to write outside buffer bounds') - } - - if (!encoding) encoding = 'utf8' - - var loweredCase = false - for (;;) { - switch (encoding) { - case 'hex': - return hexWrite(this, string, offset, length) - - case 'utf8': - case 'utf-8': - return utf8Write(this, string, offset, length) - - case 'ascii': - return asciiWrite(this, string, offset, length) - - case 'latin1': - case 'binary': - return latin1Write(this, string, offset, length) - - case 'base64': - // Warning: maxLength not taken into account in base64Write - return base64Write(this, string, offset, length) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return ucs2Write(this, string, offset, length) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} - -Buffer.prototype.toJSON = function toJSON () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) - } -} - -function base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) - } else { - return base64.fromByteArray(buf.slice(start, end)) - } -} - -function utf8Slice (buf, start, end) { - end = Math.min(buf.length, end) - var res = [] - - var i = start - while (i < end) { - var firstByte = buf[i] - var codePoint = null - var bytesPerSequence = (firstByte > 0xEF) ? 4 - : (firstByte > 0xDF) ? 3 - : (firstByte > 0xBF) ? 2 - : 1 - - if (i + bytesPerSequence <= end) { - var secondByte, thirdByte, fourthByte, tempCodePoint - - switch (bytesPerSequence) { - case 1: - if (firstByte < 0x80) { - codePoint = firstByte - } - break - case 2: - secondByte = buf[i + 1] - if ((secondByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) - if (tempCodePoint > 0x7F) { - codePoint = tempCodePoint - } - } - break - case 3: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) - if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { - codePoint = tempCodePoint - } - } - break - case 4: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - fourthByte = buf[i + 3] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) - if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { - codePoint = tempCodePoint - } - } - } - } - - if (codePoint === null) { - // we did not generate a valid codePoint so insert a - // replacement char (U+FFFD) and advance only 1 byte - codePoint = 0xFFFD - bytesPerSequence = 1 - } else if (codePoint > 0xFFFF) { - // encode to utf16 (surrogate pair dance) - codePoint -= 0x10000 - res.push(codePoint >>> 10 & 0x3FF | 0xD800) - codePoint = 0xDC00 | codePoint & 0x3FF - } - - res.push(codePoint) - i += bytesPerSequence - } - - return decodeCodePointsArray(res) -} - -// Based on http://stackoverflow.com/a/22747272/680742, the browser with -// the lowest limit is Chrome, with 0x10000 args. -// We go 1 magnitude less, for safety -var MAX_ARGUMENTS_LENGTH = 0x1000 - -function decodeCodePointsArray (codePoints) { - var len = codePoints.length - if (len <= MAX_ARGUMENTS_LENGTH) { - return String.fromCharCode.apply(String, codePoints) // avoid extra slice() - } - - // Decode in chunks to avoid "call stack size exceeded". - var res = '' - var i = 0 - while (i < len) { - res += String.fromCharCode.apply( - String, - codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) - ) - } - return res -} - -function asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i] & 0x7F) - } - return ret -} - -function latin1Slice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i]) - } - return ret -} - -function hexSlice (buf, start, end) { - var len = buf.length - - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len - - var out = '' - for (var i = start; i < end; ++i) { - out += toHex(buf[i]) - } - return out -} - -function utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) - } - return res -} - -Buffer.prototype.slice = function slice (start, end) { - var len = this.length - start = ~~start - end = end === undefined ? len : ~~end - - if (start < 0) { - start += len - if (start < 0) start = 0 - } else if (start > len) { - start = len - } - - if (end < 0) { - end += len - if (end < 0) end = 0 - } else if (end > len) { - end = len - } - - if (end < start) end = start - - var newBuf - if (Buffer.TYPED_ARRAY_SUPPORT) { - newBuf = this.subarray(start, end) - newBuf.__proto__ = Buffer.prototype - } else { - var sliceLen = end - start - newBuf = new Buffer(sliceLen, undefined) - for (var i = 0; i < sliceLen; ++i) { - newBuf[i] = this[i + start] - } - } - - return newBuf -} - -/* - * Need to make sure that buffer isn't trying to write out of bounds. - */ -function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') - if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') -} - -Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - - return val -} - -Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) { - checkOffset(offset, byteLength, this.length) - } - - var val = this[offset + --byteLength] - var mul = 1 - while (byteLength > 0 && (mul *= 0x100)) { - val += this[offset + --byteLength] * mul - } - - return val -} - -Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { - if (!noAssert) checkOffset(offset, 1, this.length) - return this[offset] -} - -Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - return this[offset] | (this[offset + 1] << 8) -} - -Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - return (this[offset] << 8) | this[offset + 1] -} - -Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return ((this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16)) + - (this[offset + 3] * 0x1000000) -} - -Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) -} - -Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var i = byteLength - var mul = 1 - var val = this[offset + --i] - while (i > 0 && (mul *= 0x100)) { - val += this[offset + --i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { - if (!noAssert) checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) return (this[offset]) - return ((0xff - this[offset] + 1) * -1) -} - -Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset] | (this[offset + 1] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset + 1] | (this[offset] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) -} - -Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) -} - -Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, true, 23, 4) -} - -Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, false, 23, 4) -} - -Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, true, 52, 8) -} - -Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, false, 52, 8) -} - -function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') - if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') - if (offset + ext > buf.length) throw new RangeError('Index out of range') -} - -Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var mul = 1 - var i = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var i = byteLength - 1 - var mul = 1 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) - this[offset] = (value & 0xff) - return offset + 1 -} - -function objectWriteUInt16 (buf, value, offset, littleEndian) { - if (value < 0) value = 0xffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { - buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> - (littleEndian ? i : 1 - i) * 8 - } -} - -Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - } else { - objectWriteUInt16(this, value, offset, true) - } - return offset + 2 -} - -Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - } else { - objectWriteUInt16(this, value, offset, false) - } - return offset + 2 -} - -function objectWriteUInt32 (buf, value, offset, littleEndian) { - if (value < 0) value = 0xffffffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { - buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff - } -} - -Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = (value & 0xff) - } else { - objectWriteUInt32(this, value, offset, true) - } - return offset + 4 -} - -Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - } else { - objectWriteUInt32(this, value, offset, false) - } - return offset + 4 -} - -Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) { - var limit = Math.pow(2, 8 * byteLength - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = 0 - var mul = 1 - var sub = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) { - var limit = Math.pow(2, 8 * byteLength - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = byteLength - 1 - var mul = 1 - var sub = 0 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) - if (value < 0) value = 0xff + value + 1 - this[offset] = (value & 0xff) - return offset + 1 -} - -Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - } else { - objectWriteUInt16(this, value, offset, true) - } - return offset + 2 -} - -Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - } else { - objectWriteUInt16(this, value, offset, false) - } - return offset + 2 -} - -Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - } else { - objectWriteUInt32(this, value, offset, true) - } - return offset + 4 -} - -Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (value < 0) value = 0xffffffff + value + 1 - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - } else { - objectWriteUInt32(this, value, offset, false) - } - return offset + 4 -} - -function checkIEEE754 (buf, value, offset, ext, max, min) { - if (offset + ext > buf.length) throw new RangeError('Index out of range') - if (offset < 0) throw new RangeError('Index out of range') -} - -function writeFloat (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) - } - ieee754.write(buf, value, offset, littleEndian, 23, 4) - return offset + 4 -} - -Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert) -} - -function writeDouble (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) - } - ieee754.write(buf, value, offset, littleEndian, 52, 8) - return offset + 8 -} - -Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert) -} - -// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -Buffer.prototype.copy = function copy (target, targetStart, start, end) { - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (targetStart >= target.length) targetStart = target.length - if (!targetStart) targetStart = 0 - if (end > 0 && end < start) end = start - - // Copy 0 bytes; we're done - if (end === start) return 0 - if (target.length === 0 || this.length === 0) return 0 - - // Fatal error conditions - if (targetStart < 0) { - throw new RangeError('targetStart out of bounds') - } - if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') - if (end < 0) throw new RangeError('sourceEnd out of bounds') - - // Are we oob? - if (end > this.length) end = this.length - if (target.length - targetStart < end - start) { - end = target.length - targetStart + start - } - - var len = end - start - var i - - if (this === target && start < targetStart && targetStart < end) { - // descending copy from end - for (i = len - 1; i >= 0; --i) { - target[i + targetStart] = this[i + start] - } - } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { - // ascending copy from start - for (i = 0; i < len; ++i) { - target[i + targetStart] = this[i + start] - } - } else { - Uint8Array.prototype.set.call( - target, - this.subarray(start, start + len), - targetStart - ) - } - - return len -} - -// Usage: -// buffer.fill(number[, offset[, end]]) -// buffer.fill(buffer[, offset[, end]]) -// buffer.fill(string[, offset[, end]][, encoding]) -Buffer.prototype.fill = function fill (val, start, end, encoding) { - // Handle string cases: - if (typeof val === 'string') { - if (typeof start === 'string') { - encoding = start - start = 0 - end = this.length - } else if (typeof end === 'string') { - encoding = end - end = this.length - } - if (val.length === 1) { - var code = val.charCodeAt(0) - if (code < 256) { - val = code - } - } - if (encoding !== undefined && typeof encoding !== 'string') { - throw new TypeError('encoding must be a string') - } - if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } - } else if (typeof val === 'number') { - val = val & 255 - } - - // Invalid ranges are not set to a default, so can range check early. - if (start < 0 || this.length < start || this.length < end) { - throw new RangeError('Out of range index') - } - - if (end <= start) { - return this - } - - start = start >>> 0 - end = end === undefined ? this.length : end >>> 0 - - if (!val) val = 0 - - var i - if (typeof val === 'number') { - for (i = start; i < end; ++i) { - this[i] = val - } - } else { - var bytes = Buffer.isBuffer(val) - ? val - : utf8ToBytes(new Buffer(val, encoding).toString()) - var len = bytes.length - for (i = 0; i < end - start; ++i) { - this[i + start] = bytes[i % len] - } - } - - return this -} - -// HELPER FUNCTIONS -// ================ - -var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g - -function base64clean (str) { - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = stringtrim(str).replace(INVALID_BASE64_RE, '') - // Node converts strings with length < 2 to '' - if (str.length < 2) return '' - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str = str + '=' - } - return str -} - -function stringtrim (str) { - if (str.trim) return str.trim() - return str.replace(/^\s+|\s+$/g, '') -} - -function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) -} - -function utf8ToBytes (string, units) { - units = units || Infinity - var codePoint - var length = string.length - var leadSurrogate = null - var bytes = [] - - for (var i = 0; i < length; ++i) { - codePoint = string.charCodeAt(i) - - // is surrogate component - if (codePoint > 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (!leadSurrogate) { - // no lead yet - if (codePoint > 0xDBFF) { - // unexpected trail - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else if (i + 1 === length) { - // unpaired lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } - - // valid lead - leadSurrogate = codePoint - - continue - } - - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } - - // valid surrogate pair - codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 - } else if (leadSurrogate) { - // valid bmp char, but last char was a lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - } - - leadSurrogate = null - - // encode utf8 - if (codePoint < 0x80) { - if ((units -= 1) < 0) break - bytes.push(codePoint) - } else if (codePoint < 0x800) { - if ((units -= 2) < 0) break - bytes.push( - codePoint >> 0x6 | 0xC0, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x10000) { - if ((units -= 3) < 0) break - bytes.push( - codePoint >> 0xC | 0xE0, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x110000) { - if ((units -= 4) < 0) break - bytes.push( - codePoint >> 0x12 | 0xF0, - codePoint >> 0xC & 0x3F | 0x80, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else { - throw new Error('Invalid code point') - } - } - - return bytes -} - -function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) - } - return byteArray -} - -function utf16leToBytes (str, units) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - if ((units -= 2) < 0) break - - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) - } - - return byteArray -} - -function base64ToBytes (str) { - return base64.toByteArray(base64clean(str)) -} - -function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; ++i) { - if ((i + offset >= dst.length) || (i >= src.length)) break - dst[i + offset] = src[i] - } - return i -} - -function isnan (val) { - return val !== val // eslint-disable-line no-self-compare -} - -/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"))) - -/***/ }), - -/***/ "./node_modules/ieee754/index.js": -/*!***************************************!*\ - !*** ./node_modules/ieee754/index.js ***! - \***************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -exports.read = function (buffer, offset, isLE, mLen, nBytes) { - var e, m - var eLen = (nBytes * 8) - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var nBits = -7 - var i = isLE ? (nBytes - 1) : 0 - var d = isLE ? -1 : 1 - var s = buffer[offset + i] - - i += d - - e = s & ((1 << (-nBits)) - 1) - s >>= (-nBits) - nBits += eLen - for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} - - m = e & ((1 << (-nBits)) - 1) - e >>= (-nBits) - nBits += mLen - for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} - - if (e === 0) { - e = 1 - eBias - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity) - } else { - m = m + Math.pow(2, mLen) - e = e - eBias - } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen) -} - -exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c - var eLen = (nBytes * 8) - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) - var i = isLE ? 0 : (nBytes - 1) - var d = isLE ? 1 : -1 - var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 - - value = Math.abs(value) - - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0 - e = eMax - } else { - e = Math.floor(Math.log(value) / Math.LN2) - if (value * (c = Math.pow(2, -e)) < 1) { - e-- - c *= 2 - } - if (e + eBias >= 1) { - value += rt / c - } else { - value += rt * Math.pow(2, 1 - eBias) - } - if (value * c >= 2) { - e++ - c /= 2 - } - - if (e + eBias >= eMax) { - m = 0 - e = eMax - } else if (e + eBias >= 1) { - m = ((value * c) - 1) * Math.pow(2, mLen) - e = e + eBias - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) - e = 0 - } - } - - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - - e = (e << mLen) | m - eLen += mLen - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} - - buffer[offset + i - d] |= s * 128 -} - - -/***/ }), - -/***/ "./node_modules/isarray/index.js": -/*!***************************************!*\ - !*** ./node_modules/isarray/index.js ***! - \***************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -var toString = {}.toString; - -module.exports = Array.isArray || function (arr) { - return toString.call(arr) == '[object Array]'; -}; - - /***/ }), /***/ "./node_modules/node-libs-browser/mock/empty.js": diff --git a/dist/douyudanmaku.js.map b/dist/douyudanmaku.js.map index 8ce6a36..0d34577 100644 --- a/dist/douyudanmaku.js.map +++ b/dist/douyudanmaku.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///../node_modules/fast-text-encoding/text.min.js","webpack:///../node_modules/ws/browser.js","webpack:///../src/client.js","webpack:///../src/clientEvent.js","webpack:///../src/config.js","webpack:///../src/index.js","webpack:///../src/logger.js","webpack:///../src/messageEvent.js","webpack:///../src/packet.js","webpack:///../src/stt.js","webpack:///../src/util.js","webpack:///../src/websocket.js","webpack:///./index.js","webpack:///./node_modules/base64-js/index.js","webpack:///./node_modules/buffer/index.js","webpack:///./node_modules/ieee754/index.js","webpack:///./node_modules/isarray/index.js","webpack:///(webpack)/buildin/global.js"],"names":["config","require","event","stt","util","packet","messageEvent","logger","Client","constructor","roomId","opts","ws","heartbeatTask","ignore","options","setOptions","clientEvent","connect","name","listener","open","disconnect","close","error","initSocket","URL","on","bind","message","send","Encode","serialize","login","type","roomid","joinGroup","rid","gid","heartbeat","setInterval","HEARBEAT_INTERVAL","logout","clearInterval","run","websocket","setIgnore","key","value","isObject","i","push","defOpts","debug","logfile","hasOwnProperty","isBoolean","isString","Object","assign","messageHandle","data","Decode","m","r","deserialize","dbname","isBrowser","init","echo","keys","filter","v","includes","method","callback","clientEventName","find","toLocaleLowerCase","cb","res","messageEventName","module","exports","MessageEvent","reader","FileReader","onload","e","target","result","readAsArrayBuffer","port","random","MSG_LIVE_ON","MSG_LIVE_OFF","MSG_ROOM_RSS","MSG_BC_BUY_DESERVE","MSG_SSD","MSG_ROOM_SPBC","danmaku","Websocket","Logger","db","inited","prototype","window","indexedDB","mozIndexedDB","webkitIndexedDB","msIndexedDB","_sql","addEventListener","createObjectStore","keyPath","autoIncrement","_fs","tx","transaction","store","objectStore","add","t","Date","getTime","frame","all","Promise","resolve","reject","req","getAll","len","count","export","text","forEach","JSON","stringify","download","clear","appendFile","err","readFile","str","content","split","length","readFileSync","loginres","chatmsg","uenter","upgrade","rss","bc_buy_deserve","ssd","spbc","dgb","onlinegift","ggbb","rankup","ranklist","mrkl","erquizisn","blab","rri","synexp","noble_num_info","gbroadcast","qausrespond","wiru","wirt","mcspeacsite","rank_change","srres","anbc","frank","BufferCoder","buffer","ArrayBuffer","decoder","TextDecoder","encoder","TextEncoder","littleEndian","readLength","concat","arr","n","arguments","reduce","buf","Uint8Array","set","LE","byteLength","DataView","getUint32","slice","decode","encode","of","offset","setUint32","setInt16","setInt8","blob2ab","blob","ab2blob","ab","Blob","browser","Packet","HEADER_LEN_SIZE","HEADER_LEN_TYPECODE","HEADER_LEN_ENCRYPT","HEADER_LEN_PLACEHOLDER","HEADER_LEN_TOTAL","Buffer","alloc","nodeEncode","msgHeader","msgBody","from","msgTotalLen","writeInt32LE","writeInt16LE","browserEncode","nodeDecode","readInt32LE","toString","browserDecode","STT","escape","isUndefined","replace","unescape","raw","map","k","join","Array","isArray","isNumber","item","o","s","Util","p","call","min","max","Math","floor","filename","element","document","createElement","style","display","href","createObjectURL","body","appendChild","click","revokeObjectURL","removeChild","address","socket","WebSocket","code","reason","eventName","removeEventListener","douyudanmaku"],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;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AzFY;AA0FbC,KAAG,EAAE,eAAa,CACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACH,GApGY;AAqGbC,MAAI,EAAE,gBAAa,CAkBlB,CAvHY;AAwHbC,KAAG,EAAE,eAAa,CACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACH,GAhJY;AAiJbC,YAAU,EAAE,sBAAa,CAaxB,CA9JY;AA+JbC,MAAI,EAAE,gBAAa,CACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACH,GA5KY;AA6KbC,QAAM,EAAE,kBAAa,CACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACH,GA5LY;AA6LbC,UAAQ,EAAE,oBAAa,CACnB;AACH,GA/LY;AAgMbC,MAAI,EAAE,gBAAY,CACd;AACH,GAlMY;AAmMbC,WAAS,EAAE,qBAAY,CACnB;AACH,GArMY;AAsMbC,MAAI,EAAE,gBAAY,CACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACH,GAjNY;AAkNbC,KAAG,EAAE,eAAY,CACb;AACH,GApNY;AAqNbC,QAAM,EAAE,kBAAY,CAEnB,CAvNY;AAwNbC,gBAAc,EAAE,0BAAY,CACxB;AACH,GA1NY;AA2NbC,YAAU,EAAE,sBAAY,CACpB;AACH,GA7NY;AA8NbC,aAAW,EAAE,uBAAY,CACrB;AACH,GAhOY;AAiObC,MAAI,EAAE,gBAAY,CACd;AACH,GAnOY;AAoObC,MAAI,EAAE,gBAAY,CACd;AACH,GAtOY;AAuObC,aAAW,EAAE,uBAAY,CACrB;AACH,GAzOY;AA0ObC,aAAW,EAAE,uBAAY,CACrB;AACH,GA5OY;AA6ObC,OAAK,EAAE,iBAAY,CACf;AACH,GA/OY;AAgPbC,MAAI,EAAE,gBAAY,CACd;AACH,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AAA;AAAA;AAAA;;AACA;AAEAyG,MAAM,CAACwK,YAAP,GAAsBA,iD,EACtBxK,MAAM,CAACN,OAAP,GAAiB8K,iD;;;;;;;;;;;;ACJL;;AAEZ;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,kCAAkC,SAAS;AAC3C;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,SAAS;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,qBAAqB,SAAS;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,0CAA0C,UAAU;AACpD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;;;;;;;;;;;ACvJA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEY;;AAEZ,aAAa,mBAAO,CAAC,oDAAW;AAChC,cAAc,mBAAO,CAAC,gDAAS;AAC/B,cAAc,mBAAO,CAAC,gDAAS;;AAE/B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,qBAAqB,mDAAmD;AACxE;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,mBAAmB,UAAU;AAC7B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,YAAY;AAC7B;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA,uCAAuC,SAAS;AAChD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,iBAAiB;AAChC;AACA;AACA;;AAEA;AACA;AACA,aAAa,iBAAiB;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,gDAAgD,EAAE;AAClD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC;AACzC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA,wBAAwB,eAAe;AACvC;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,wBAAwB,QAAQ;AAChC;AACA,qBAAqB,eAAe;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,YAAY;AAC7B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB,SAAS;AAC9B;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB,SAAS;AAC9B;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,qBAAqB,SAAS;AAC9B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,kBAAkB;AACnC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,mBAAmB,cAAc;AACjC;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uDAAuD,OAAO;AAC9D;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA,uDAAuD,OAAO;AAC9D;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,qBAAqB,QAAQ;AAC7B;AACA;AACA,GAAG;AACH;AACA,eAAe,SAAS;AACxB;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA,mBAAmB,SAAS;AAC5B;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,eAAe,iBAAiB;AAChC;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,iBAAiB,YAAY;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,iBAAiB,YAAY;AAC7B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;;;;;;;;;;;AC5vDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,QAAQ,WAAW;;AAEnB;AACA;AACA;AACA,QAAQ,WAAW;;AAEnB;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA,QAAQ,WAAW;;AAEnB;AACA;AACA,QAAQ,UAAU;;AAElB;AACA;;;;;;;;;;;;ACnFA,iBAAiB;;AAEjB;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;ACJA;;AAEA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;;AAEA;AACA;AACA,4CAA4C;;AAE5C","file":"douyudanmaku.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./index.js\");\n","(function(l){function m(){}function k(b,a){b=void 0===b?\"utf-8\":b;a=void 0===a?{fatal:!1}:a;if(-1==n.indexOf(b.toLowerCase()))throw new RangeError(\"Failed to construct 'TextDecoder': The encoding label provided ('\"+b+\"') is invalid.\");if(a.fatal)throw Error(\"Failed to construct 'TextDecoder': the 'fatal' option is unsupported.\");}if(l.TextEncoder&&l.TextDecoder)return!1;var n=[\"utf-8\",\"utf8\",\"unicode-1-1-utf-8\"];Object.defineProperty(m.prototype,\"encoding\",{value:\"utf-8\"});m.prototype.encode=function(b,\na){a=void 0===a?{stream:!1}:a;if(a.stream)throw Error(\"Failed to encode: the 'stream' option is unsupported.\");a=0;for(var g=b.length,f=0,c=Math.max(32,g+(g>>1)+7),e=new Uint8Array(c>>3<<3);a=d){if(a=d)continue}f+4>e.length&&(c+=8,c*=1+a/b.length*2,c=c>>3<<3,h=new Uint8Array(c),h.set(e),e=h);if(0===(d&4294967168))e[f++]=d;else{if(0===(d&4294965248))e[f++]=\nd>>6&31|192;else if(0===(d&4294901760))e[f++]=d>>12&15|224,e[f++]=d>>6&63|128;else if(0===(d&4292870144))e[f++]=d>>18&7|240,e[f++]=d>>12&63|128,e[f++]=d>>6&63|128;else continue;e[f++]=d&63|128}}return e.slice?e.slice(0,f):e.subarray(0,f)};Object.defineProperty(k.prototype,\"encoding\",{value:\"utf-8\"});Object.defineProperty(k.prototype,\"fatal\",{value:!1});Object.defineProperty(k.prototype,\"ignoreBOM\",{value:!1});k.prototype.decode=function(b,a){a=void 0===a?{stream:!1}:a;if(a.stream)throw Error(\"Failed to decode: the 'stream' option is unsupported.\");\nb.buffer instanceof ArrayBuffer&&(b=b.buffer);b=new Uint8Array(b);a=0;for(var g=[],f=[];;){var c=a>>10&1023|55296),c=56320|c&1023);g.push(c)}}};l.TextEncoder=m;l.TextDecoder=k})(\"undefined\"!==typeof window?window:\"undefined\"!==typeof global?global:this);\n","'use strict';\n\nmodule.exports = function() {\n throw new Error(\n 'ws does not work in the browser. Browser clients must use the native ' +\n 'WebSocket object'\n );\n};\n","const config = require('./config')\r\nconst event = require('./clientEvent')\r\nconst stt = require('./stt')\r\nconst util = require('./util')\r\nconst packet = require('./packet')\r\nconst messageEvent = require('./messageEvent')\r\nconst logger = require('./logger')\r\n\r\nclass Client {\r\n constructor(roomId, opts) {\r\n this.roomId = roomId\r\n this.ws = null\r\n this.heartbeatTask = null\r\n this.messageEvent = messageEvent\r\n this.ignore = []\r\n this.options = this.setOptions(opts || {})\r\n this.clientEvent = {\r\n connect: {\r\n name: 'open',\r\n listener: event.open\r\n },\r\n disconnect: {\r\n name: 'close',\r\n listener: event.close\r\n },\r\n error: {\r\n name: 'error',\r\n listener: event.error\r\n },\r\n }\r\n }\r\n\r\n initSocket(ws) {\r\n this.ws = new ws(config.URL)\r\n this.ws.on('open', this.clientEvent.connect.listener.bind(this))\r\n this.ws.on('error', this.clientEvent.error.listener.bind(this))\r\n this.ws.on('close', this.clientEvent.disconnect.listener.bind(this))\r\n this.ws.on('message', event.message.bind(this))\r\n }\r\n\r\n send(message) {\r\n this.ws.send(packet.Encode(stt.serialize(message)))\r\n }\r\n\r\n login() {\r\n this.send({\r\n type: 'loginreq',\r\n roomid: this.roomId,\r\n })\r\n }\r\n\r\n joinGroup() {\r\n this.send({\r\n type: 'joingroup',\r\n rid: this.roomId,\r\n gid: 0\r\n })\r\n }\r\n\r\n heartbeat() {\r\n this.heartbeatTask = setInterval(() => {\r\n this.send({\r\n type: 'mrkl'\r\n })\r\n }, config.HEARBEAT_INTERVAL * 1000)\r\n }\r\n\r\n logout() {\r\n this.send({\r\n type: 'logout',\r\n })\r\n\r\n clearInterval(this.heartbeatTask)\r\n }\r\n\r\n run(websocket) {\r\n let ws = websocket || require('./websocket')\r\n this.initSocket(ws)\r\n }\r\n\r\n setIgnore(key, value) {\r\n if (util.isObject(key)) {\r\n for (let i in key) {\r\n if (key[i]) {\r\n this.ignore.push(i)\r\n }\r\n }\r\n } else {\r\n if (value) {\r\n this.ignore.push(key)\r\n }\r\n }\r\n\r\n return this\r\n }\r\n\r\n setOptions(opts) {\r\n const defOpts = {\r\n debug: false,\r\n logfile: `${this.roomId}.log`,\r\n }\r\n const options = {}\r\n\r\n if (!util.isObject(opts)) {\r\n return defOpts\r\n }\r\n\r\n if (opts.hasOwnProperty('debug') && util.isBoolean(opts.debug)) {\r\n options.debug = opts.debug\r\n }\r\n\r\n if (opts.hasOwnProperty('logfile') && util.isString(opts.logfile)) {\r\n options.logfile = opts.logfile\r\n }\r\n\r\n return Object.assign(defOpts, options)\r\n }\r\n\r\n messageHandle(data) {\r\n packet.Decode(data, m => {\r\n const r = stt.deserialize(m)\r\n \r\n if (this.options.debug) {\r\n const dbname = util.isBrowser() ? this.roomId : this.options.logfile\r\n logger.init(dbname)\r\n logger.echo(r)\r\n }\r\n\r\n if (Object.keys(this.messageEvent).filter(v => {\r\n return !this.ignore.includes(v)\r\n }).includes(r.type)) {\r\n this.messageEvent[r.type](r)\r\n }\r\n })\r\n }\r\n\r\n on(method, callback) {\r\n const clientEventName = Object.keys(this.clientEvent).find(clientEvent => clientEvent === method.toLocaleLowerCase())\r\n if (clientEventName) {\r\n //在创建连接是触发connect事件时,发送登入,加入组,监听心跳消息\r\n if (clientEventName === 'connect') {\r\n let cb = callback\r\n callback = function (res) {\r\n this.login()\r\n this.joinGroup()\r\n this.heartbeat()\r\n cb.bind(this)(res)\r\n }\r\n }\r\n this.clientEvent[method].listener = callback.bind(this)\r\n }\r\n\r\n const messageEventName = Object.keys(this.messageEvent).find(messageEvent => messageEvent === method.toLocaleLowerCase())\r\n if (messageEventName) {\r\n this.messageEvent[method] = callback.bind(this)\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = Client","function open() {\r\n this.login() //登入\r\n this.joinGroup() //加入组\r\n this.heartbeat() //发送心跳,强制45秒\r\n}\r\n\r\nfunction error(err) {\r\n console.error(err)\r\n}\r\n\r\nfunction close() {\r\n this.logout()\r\n}\r\n\r\nfunction message(data) {\r\n if (typeof MessageEvent !== 'undefined') {\r\n //无MessageEvent类型判断为node环境,转换数据为arraybuffer类型\r\n const reader = new FileReader()\r\n reader.onload = e => this.messageHandle(e.target.result)\r\n reader.readAsArrayBuffer(data.data)\r\n } else {\r\n this.messageHandle(data)\r\n }\r\n}\r\n\r\nmodule.exports = {\r\n open,\r\n error,\r\n close,\r\n message,\r\n}","const util = require('./util')\r\n\r\n//目前已知的弹幕服务器\r\nconst port = 8500 + util.random(1, 6)\r\nconst URL = `wss://danmuproxy.douyu.com:${port}/`\r\n\r\nconst HEARBEAT_INTERVAL = 45\r\n\r\nconst MSG_LIVE_ON = '主播正在直播'\r\nconst MSG_LIVE_OFF = '主播没有直播'\r\nconst MSG_ROOM_RSS = '房间开播提醒'\r\nconst MSG_BC_BUY_DESERVE = '赠送酬勤通知'\r\nconst MSG_SSD = '超级弹幕'\r\nconst MSG_ROOM_SPBC = '房间内礼物广播'\r\n\r\nmodule.exports = {\r\n URL,\r\n HEARBEAT_INTERVAL,\r\n MSG_LIVE_ON,\r\n MSG_LIVE_OFF,\r\n MSG_ROOM_RSS,\r\n MSG_BC_BUY_DESERVE,\r\n MSG_SSD,\r\n MSG_ROOM_SPBC,\r\n}","'use strict';\r\n\r\nconst danmaku = require('./client')\r\ndanmaku.stt = require('./stt')\r\ndanmaku.util = require('./util')\r\ndanmaku.logger = require('./logger')\r\ndanmaku.Websocket = require('./websocket')\r\ndanmaku.packet = require('./packet')\r\n\r\nmodule.exports = danmaku","const util = require('./util')\r\n\r\nconst Logger = function () {\r\n this.dbname = 'unknown'\r\n this.db = null\r\n this.inited = false\r\n}\r\n\r\nLogger.prototype.init = function (dbname) {\r\n if (!this.inited) {\r\n this.dbname = dbname\r\n\r\n if (util.isBrowser()) {\r\n window.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB\r\n this._sql = indexedDB.open('danmaku', 1)\r\n this._sql.addEventListener('success', e => {\r\n console.log('连接数据库成功')\r\n this.db = event.target.result\r\n })\r\n\r\n this._sql.addEventListener('upgradeneeded', e => {\r\n this.db = event.target.result\r\n this.db.createObjectStore(this.dbname, {\r\n keyPath: 'id',\r\n autoIncrement: true\r\n })\r\n })\r\n\r\n this._sql.addEventListener('error', e => {\r\n console.log('连接数据库出错 Error:', e)\r\n })\r\n } else {\r\n this._fs = require('fs')\r\n }\r\n this.inited = true\r\n }\r\n}\r\n\r\nif (!util.isBrowser()) {\r\n Logger.prototype.echo = function (data) {\r\n this._fs.appendFile(\r\n this.dbname,\r\n JSON.stringify({\r\n t: new Date().getTime(),\r\n frame: data\r\n }) + '\\n',\r\n function (err) {\r\n if (err) {\r\n console.error('日志保存出错, Error:', err)\r\n }\r\n })\r\n }\r\n\r\n Logger.prototype.all = function () {\r\n return new Promise((resolve, reject) => {\r\n this._fs.readFile(this.dbname, 'utf8', function (err, str) {\r\n if (err) {\r\n reject(err)\r\n } else {\r\n resolve(str)\r\n }\r\n })\r\n })\r\n }\r\n\r\n Logger.prototype.len = function () {\r\n return new Promise(async (resolve, reject) => {\r\n const content = await this.all()\r\n resolve(content.split('\\n').filter(v => v !== '').length)\r\n })\r\n }\r\n\r\n Logger.prototype.export = function () {\r\n return this._fs.readFileSync(this.dbname, 'utf8')\r\n }\r\n\r\n Logger.prototype.clear = function () {\r\n\r\n }\r\n} else {\r\n Logger.prototype.echo = function (data) {\r\n if (this.db !== null) {\r\n const tx = this.db.transaction(this.dbname, 'readwrite')\r\n const store = tx.objectStore(this.dbname)\r\n store.add({\r\n t: new Date().getTime(),\r\n frame: data\r\n })\r\n }\r\n }\r\n\r\n Logger.prototype.all = function () {\r\n if (this.db !== null) {\r\n const tx = this.db.transaction(this.dbname, 'readonly')\r\n const store = tx.objectStore(this.dbname)\r\n return new Promise(function (resolve, reject) {\r\n const req = store.getAll()\r\n req.addEventListener('success', function (e) {\r\n resolve(req.result)\r\n })\r\n req.addEventListener('error', function (e) {\r\n reject(false)\r\n })\r\n })\r\n }\r\n\r\n }\r\n\r\n Logger.prototype.len = function () {\r\n if (this.db !== null) {\r\n const tx = this.db.transaction(this.dbname, 'readonly')\r\n const store = tx.objectStore(this.dbname)\r\n return new Promise(function (resolve, reject) {\r\n const req = store.count()\r\n req.addEventListener('success', function (e) {\r\n resolve(req.result)\r\n })\r\n req.addEventListener('error', function (e) {\r\n reject(false)\r\n })\r\n })\r\n }\r\n\r\n }\r\n\r\n Logger.prototype.export = async function () {\r\n if (this.db !== null) {\r\n const r = await this.all()\r\n let text = ''\r\n r.forEach((value, index) => {\r\n text += `${JSON.stringify({\r\n t: value.t,\r\n frame: value.frame,\r\n })}\\n`\r\n })\r\n util.download(this.dbname, text)\r\n return text\r\n }\r\n\r\n }\r\n\r\n Logger.prototype.clear = function () {\r\n if (this.db !== null) {\r\n const tx = this.db.transaction(this.dbname, 'readwrite')\r\n const store = tx.objectStore(this.dbname)\r\n store.clear()\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = new Logger()","const config = require('./config')\r\n\r\nmodule.exports = {\r\n loginres: function (r) {\r\n // 登录响应\r\n // 服务端返回登录响应消息,完整的数据部分应包含的字段如下:\r\n // 字段说明\r\n // type 表示为“登录”消息,固定为 loginres\r\n // userid 用户 ID\r\n // roomgroup 房间权限组\r\n // pg 平台权限组\r\n // sessionid 会话 ID\r\n // username 用户名\r\n // nickname 用户昵称\r\n // is_signed 是否已在房间签到\r\n // signed_count 日总签到次数\r\n // live_stat 直播状态\r\n // npv 是否需要手机验证\r\n // best_dlev 最高酬勤等级\r\n // cur_lev 酬勤等级\r\n },\r\n chatmsg: function (r) {\r\n // 弹幕消息\r\n // 用户在房间发送弹幕时,服务端发此消息给客户端,完整的数据部分应包含的字 段如下:\r\n // 字段说明\r\n // type 表示为“弹幕”消息,固定为 chatmsg\r\n // gid 弹幕组 id\r\n // rid 房间 id\r\n // uid 发送者 uid\r\n // nn 发送者昵称\r\n // txt 弹幕文本内容\r\n // cid 弹幕唯一 ID\r\n // level 用户等级\r\n // gt 礼物头衔:默认值 0(表示没有头衔)\r\n // col 颜色:默认值 0(表示默认颜色弹幕)\r\n // ct 客户端类型:默认值 0(表示 web 用户)\r\n // rg 房间权限组:默认值 1(表示普通权限用户)\r\n // pg 平台权限组:默认值 1(表示普通权限用户)\r\n // dlv 酬勤等级:默认值 0(表示没有酬勤)\r\n // dc 酬勤数量:默认值 0(表示没有酬勤数量)\r\n // bdlv 最高酬勤等级:默认值 0(表示全站都没有酬勤)\r\n console.log(\" [%s] %s\", r.level + (r.level < 10 ? ' ' : ''), r.nn, r.txt)\r\n },\r\n uenter: function (r) {\r\n // 进入直播间\r\n // 具有特殊属性的用户进入直播间时,服务端发送此消息至客户端。完整的数据部 分应包含的字段如下:\r\n // 字段说明\r\n // type 表示为“用户进房通知”消息,固定为 uenter\r\n // rid 房间 ID\r\n // gid 弹幕分组 ID\r\n // uid 用户 ID\r\n // nn 用户昵称\r\n // str 战斗力\r\n // level 新用户等级\r\n // gt 礼物头衔:默认值 0(表示没有头衔)\r\n // rg 房间权限组:默认值 1(表示普通权限用户)\r\n // pg 平台身份组:默认值 1(表示普通权限用户)\r\n // dlv 酬勤等级:默认值 0(表示没有酬勤)\r\n // dc 酬勤数量:默认值 0(表示没有酬勤数量)\r\n // bdlv 最高酬勤等级:默认值 0(表示全站都没有酬勤)\r\n console.log(`欢迎${r.nn}进入了直播间`)\r\n },\r\n upgrade: function (r) {\r\n // 用户等级提升\r\n },\r\n rss: function (r) {\r\n // 房间开播提醒\r\n // 房间开播提醒主要部分应包含的字段如下:\r\n // 字段说明\r\n // type 表示为“房间开播提醒”消息,固定为 rss\r\n // rid 房间 id\r\n // gid 弹幕分组 id\r\n // ss 直播状态,1-正在直播, 2-没有直播\r\n // code 类型\r\n // rt 开关播原因:0-主播开关播,其他值-其他原因\r\n // notify 通知类型\r\n // endtime 关播时间(仅关播时有效)\r\n console.log('[开播提醒]', r.ss == 1 ? config.MSG_LIVE_ON : config.MSG_LIVE_OFF)\r\n },\r\n bc_buy_deserve: function (r) {\r\n // 赠送酬勤通知\r\n // 用户赠送酬勤时,服务端发送此消息至客户端。完整的数据部分应包含的字段如 下:\r\n // 字段说明\r\n // type 表示为“赠送酬勤通知”消息,固定为 bc_buy_deserve\r\n // rid 房间 ID\r\n // gid 弹幕分组 ID\r\n // level 用户等级\r\n // cnt 赠送数量\r\n // hits 赠送连击次数\r\n // lev 酬勤等级\r\n // sui 用户信息序列化字符串,详见下文。注意,此处为嵌套序列化,需注 意符号的转义变换。(转义符号参见 2.2 序列化)\r\n },\r\n ssd: function (r) {\r\n // 超级弹幕\r\n // 超级弹幕主要部分应包含的字段如下:\r\n // 字段说明\r\n // type 表示为“超级弹幕”消息,固定为 ssd\r\n // rid 房间 id\r\n // gid 弹幕分组 id\r\n // sdid 超级弹幕 id\r\n // trid 跳转房间 id\r\n // content 超级弹幕的内容\r\n },\r\n spbc: function (r) {\r\n // 房间内礼物广播\r\n // 房间内赠送礼物成功后效果主要部分应包含的字段如下:\r\n // 字段说明\r\n // type 表示为“房间内礼物广播”,固定为 spbc\r\n // rid 房间 id\r\n // gid 弹幕分组 id\r\n // sn 赠送者昵称\r\n // dn 受赠者昵称\r\n // gn 礼物名称\r\n // gc 礼物数量\r\n // drid 赠送房间\r\n // gs 广播样式\r\n // gb 是否有礼包(0-无礼包,1-有礼包)\r\n // es 广播展现样式(1-火箭,2-飞机)\r\n // gfid 礼物 id\r\n // eid 特效 id\r\n console.log(`------------- 感谢[${r.sn}] 赠送的 ${r.gn}x${r.gc}`)\r\n },\r\n dgb: function (r) {\r\n // 赠送礼物\r\n // 用户在房间赠送礼物时,服务端发送此消息给客户端。完整的数据部分应包含的 字段如下:\r\n // 字段说明\r\n // type 表示为“赠送礼物”消息,固定为 dgb\r\n // rid 房间 ID\r\n // gid 弹幕分组 ID\r\n // gfid 礼物 id\r\n // gs 礼物显示样式\r\n // uid 用户 id\r\n // nn 用户昵称\r\n // str 用户战斗力\r\n // level 用户等级\r\n // dw 主播体重\r\n // gfcnt 礼物个数:默认值 1(表示 1 个礼物)\r\n // hits 礼物连击次数:默认值 1(表示 1 连击)\r\n // dlv 酬勤头衔:默认值 0(表示没有酬勤)\r\n // dc 酬勤个数:默认值 0(表示没有酬勤数量)\r\n // bdl 全站最高酬勤等级:默认值 0(表示全站都没有酬勤)\r\n // rg 房间身份组:默认值 1(表示普通权限用户)\r\n // pg 平台身份组:默认值 1(表示普通权限用户)\r\n // rpid 红包 id:默认值 0(表示没有红包)\r\n // slt 红包开启剩余时间:默认值 0(表示没有红包)\r\n // elt 红包销毁剩余时间:默认值 0(表示没有红包)\r\n },\r\n onlinegift: function (r) {\r\n // 领取在线鱼丸\r\n // 在线领取鱼丸时,若出现暴击(鱼丸数大于等于 60)服务则发送领取暴击消息 到客户端。完整的数据部分应包含的字段如下:\r\n // 字段说明\r\n // type 表示为“领取在线鱼丸”消息,固定为 onlinegift\r\n // rid 房间 ID\r\n // uid 用户 ID\r\n // gid 弹幕分组 ID\r\n // sil 鱼丸数\r\n // if 领取鱼丸的等级\r\n // ct 客户端类型标识\r\n // nn 用户昵称\r\n console.log(`------------- [${r.nn}] 领取鱼丸x${r.sil}`)\r\n },\r\n ggbb: function (r) {\r\n // 房间用户抢红包\r\n // 房间赠送礼物成功后效果(赠送礼物效果,连击数)主要部分应包含的字段如下:\r\n // 字段说明\r\n // type 表示“房间用户抢红包”信息,固定为 ggbb\r\n // rid 房间 id\r\n // gid 弹幕分组 id\r\n // sl 抢到的鱼丸数量\r\n // sid 礼包产生者 id\r\n // did 抢礼包者 id\r\n // snk 礼包产生者昵称\r\n // dnk 抢礼包者昵称\r\n // rpt 礼包类型\r\n },\r\n rankup: function (r) {\r\n // 房间内top10变化消息\r\n // 房间内 top10 排行榜变化后,广播。主要部分应包含的字段如下:\r\n // 字段说明\r\n // type 表示为“房间 top10 排行榜变换”,固定为 rankup\r\n // rid 房间 id\r\n // gid 弹幕分组 id\r\n // uid 用户 id\r\n // drid 目标房间 id\r\n // rt 房间所属栏目类型\r\n // bt 广播类型:1-房间内广播,2-栏目广播,4-全站广播\r\n // sz 展示区域:1-聊天区展示,2-flash 展示,3-都显示\r\n // nk 用户昵称\r\n // rkt top10 榜的类型 1-周榜 2-总榜 4-日榜\r\n // rn 上升后的排名\r\n },\r\n ranklist: function (r) {\r\n // 广播排行榜消息\r\n },\r\n mrkl: function(r) {\r\n // 心跳\r\n },\r\n erquizisn: function(r) {\r\n // 鱼丸预言,参数未知\r\n },\r\n blab: function(r) {\r\n // 粉丝等级升级\r\n // 字段说明\r\n // type 表示为“粉丝等级升级”,固定为 blab\r\n // rid 房间 id\r\n // uid 用户 id\r\n // nn 用户昵称\r\n // bl 升级后的等级\r\n // bnn 升级的粉丝牌\r\n // lbl 未知(猜测未升级前的等级)\r\n // ba 未知\r\n },\r\n rri: function(r) {\r\n // 未知的消息事件\r\n },\r\n synexp: function(r) {\r\n\r\n },\r\n noble_num_info: function(r) {\r\n // 未知的消息事件\r\n },\r\n gbroadcast: function(r) {\r\n // 未知的消息事件\r\n },\r\n qausrespond: function(r) {\r\n // 未知的消息事件\r\n },\r\n wiru: function(r) {\r\n // 未知的消息事件\r\n },\r\n wirt: function(r) {\r\n // 未知的消息事件\r\n },\r\n mcspeacsite: function(r) {\r\n // 未知的消息事件\r\n },\r\n rank_change: function(r) {\r\n // 未知的消息事件\r\n },\r\n srres: function(r) {\r\n // 未知的消息事件\r\n },\r\n anbc: function(r) {\r\n // 未知的消息事件\r\n },\r\n frank: function(r) {\r\n // 粉丝排行榜变化\r\n },\r\n}","require('fast-text-encoding')\nconst util = require('./util')\n\nfunction BufferCoder() {\n this.buffer = new ArrayBuffer(0)\n this.decoder = new TextDecoder()\n this.encoder = new TextEncoder()\n this.littleEndian = !0\n this.readLength = 0\n}\n\nBufferCoder.prototype.concat = function () {\n const arr = []\n for (let n = 0; n < arguments.length; n++) arr[n] = arguments[n]\n\n return arr.reduce(function (arr, buf) {\n const message = buf instanceof ArrayBuffer ? new Uint8Array(buf) : buf\n const t = new Uint8Array(arr.length + message.length)\n t.set(arr, 0)\n t.set(message, arr.length)\n return t\n }, new Uint8Array(0))\n}\n\nBufferCoder.prototype.Decode = function (buf, callback, LE) {\n LE = LE || this.littleEndian\n this.buffer = this.concat(this.buffer, buf).buffer\n for (; this.buffer && this.buffer.byteLength > 0;) {\n if (0 === this.readLength) {\n if (this.buffer.byteLength < 4) return;\n\n this.readLength = new DataView(this.buffer).getUint32(0, LE)\n this.buffer = this.buffer.slice(4)\n }\n\n if (this.buffer.byteLength < this.readLength) return;\n\n const str = this.decoder.decode(this.buffer.slice(8, this.readLength - 1))\n this.buffer = this.buffer.slice(this.readLength)\n this.readLength = 0\n callback(str)\n }\n}\n\nBufferCoder.prototype.Encode = function (str, LE) {\n LE = LE || this.littleEndian\n let message = this.concat(this.encoder.encode(str), Uint8Array.of(0))\n let len = 8 + message.length\n let r = new DataView(new ArrayBuffer(len + 4))\n let offset = 0\n\n r.setUint32(offset, len, LE)\n offset += 4\n r.setUint32(offset, len, LE)\n offset += 4\n r.setInt16(offset, 689, LE)\n offset += 2\n r.setInt8(offset, 0)\n offset += 1\n r.setInt8(offset, 0)\n offset += 1\n\n return new Uint8Array(r.buffer).set(message, offset), r.buffer\n}\n\n/**\n * blob转arraybuffer\n * @param {Blob} blob 待转换的Blob类型参数\n */\nBufferCoder.prototype.blob2ab = function (blob) {\n return new Promise((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = function (e) {\n resolve(e.target.result)\n }\n reader.readAsArrayBuffer(blob)\n })\n}\n\n/**\n * arraybuffer转blob\n * @param {ArrayBuffer} ab 待转换的ArrayBuffer类型参数\n */\nBufferCoder.prototype.ab2blob = function (ab) {\n return new Blob([ab])\n}\n\nconst browser = new BufferCoder()\n\nclass Packet {\n constructor() {\n this.HEADER_LEN_SIZE = 4\n this.HEADER_LEN_TYPECODE = 2\n this.HEADER_LEN_ENCRYPT = 1\n this.HEADER_LEN_PLACEHOLDER = 1\n this.HEADER_LEN_TOTAL = this.HEADER_LEN_SIZE * 2 +\n this.HEADER_LEN_TYPECODE +\n this.HEADER_LEN_ENCRYPT +\n this.HEADER_LEN_PLACEHOLDER\n this.buffer = Buffer.alloc(0)\n }\n\n nodeEncode(data) {\n const msgHeader = Buffer.alloc(this.HEADER_LEN_TOTAL)\n const msgBody = Buffer.from(data, 'utf8')\n const msgTotalLen = msgBody.length + this.HEADER_LEN_TOTAL + 1\n msgHeader.writeInt32LE(msgTotalLen - this.HEADER_LEN_SIZE, 0)\n msgHeader.writeInt32LE(msgTotalLen - this.HEADER_LEN_SIZE, 4)\n msgHeader.writeInt16LE(689, 8)\n return Buffer.concat([msgHeader, msgBody], msgTotalLen)\n }\n\n browserEncode(data) {\n return browser.Encode(data)\n }\n\n Encode(data) {\n return util.isBrowser() ? this.browserEncode(data) : this.nodeEncode(data)\n }\n\n nodeDecode(buf, callback) {\n this.buffer = Buffer.concat([this.buffer, buf])\n for (let offset = 0; this.buffer.length > 0; offset = 0) {\n if (0 === offset) {\n if (this.buffer.length < this.HEADER_LEN_SIZE) return;\n offset = this.buffer.readInt32LE(this.HEADER_LEN_SIZE)\n this.buffer = this.buffer.slice(this.HEADER_LEN_SIZE)\n }\n\n if (this.buffer.length < offset) return;\n\n const message = this.buffer.slice(this.HEADER_LEN_SIZE * 2, offset - 1).toString('utf8')\n this.buffer = this.buffer.slice(offset)\n callback(message)\n }\n }\n\n browserDecode(buf, callback) {\n browser.Decode(buf, callback)\n }\n\n Decode(buf, callback) {\n util.isBrowser() ? this.browserDecode(buf, callback) : this.nodeDecode(buf, callback)\n }\n}\n\nmodule.exports = new Packet()","const util = require('./util')\r\n\r\nclass STT {\r\n escape(v) {\r\n return util.isUndefined(v) ? '' : v.toString().replace(/\\//g, '@S').replace(/@/g, '@A')\r\n }\r\n\r\n unescape(v) {\r\n return util.isUndefined(v) ? '' : v.toString().replace(/@S/g, '/').replace(/@A/g, '@')\r\n }\r\n\r\n serialize(raw) {\r\n if (util.isObject(raw)) {\r\n return Object.keys(raw).map(k => `${k}@=${this.escape(this.serialize(raw[k]))}/`).join('')\r\n } else if (Array.isArray(raw)) {\r\n return raw.map(v => `${this.escape(this.serialize(v))}/`).join('')\r\n } else if (util.isString(raw) || util.isNumber(raw)) {\r\n return raw.toString()\r\n }\r\n }\r\n\r\n deserialize(raw) {\r\n if (raw.includes('//')) {\r\n return raw.split('//').filter(e => e !== '').map(item => this.deserialize(item))\r\n }\r\n\r\n if (raw.includes('@=')) {\r\n return raw.split('/').filter(e => e !== '').reduce((o, s) => {\r\n const [k, v] = s.split('@=')\r\n o[k] = this.deserialize(this.unescape(v))\r\n return o\r\n }, {})\r\n } else if (raw.includes('@A=')) {\r\n return this.deserialize(this.unescape(raw))\r\n } else {\r\n return raw.toString()\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = new STT()","function Util() {\r\n [\r\n 'Object',\r\n 'Array',\r\n 'String',\r\n 'Number',\r\n 'Boolean',\r\n 'Function',\r\n 'RegExp',\r\n 'Date',\r\n 'Undefined',\r\n 'Null',\r\n 'Symbol',\r\n 'Blob',\r\n 'ArrayBuffer'\r\n ].forEach(type => {\r\n this[`is${type}`] = (p) => Object.prototype.toString.call(p).slice(8, -1) === type\r\n })\r\n}\r\n\r\n//判断浏览器环境\r\nUtil.prototype.isBrowser = () => (typeof window !== 'undefined') ? true : false\r\n\r\n//随机数生成\r\nUtil.prototype.random = (min, max) => Math.floor(Math.random() * (max - min + 1) + min)\r\n\r\n//web端下载文件\r\nUtil.prototype.download = function(filename, text) {\r\n if (this.isBrowser()) {\r\n let element = document.createElement('a');\r\n element.style.display = 'none'\r\n let blob = new Blob([text])\r\n element.download = `${filename}.log`\r\n element.href = URL.createObjectURL(blob)\r\n document.body.appendChild(element)\r\n element.click()\r\n URL.revokeObjectURL(blob)\r\n document.body.removeChild(element)\r\n }\r\n}\r\n\r\nmodule.exports = new Util()","const util = require('./util')\r\n\r\nclass websocket {\r\n constructor(address) {\r\n this.listener = {}\r\n this.socket = new WebSocket(address)\r\n }\r\n\r\n send(data) {\r\n this.socket.send(data)\r\n }\r\n\r\n close(code, reason) {\r\n this.socket.close(code, reason)\r\n }\r\n\r\n on(method, callback) {\r\n let eventName = ['open', 'error', 'close', 'message'].find(event => event === method.toLocaleLowerCase())\r\n\r\n if (eventName) {\r\n if (Object.keys(this.listener).includes(eventName)) {\r\n this.socket.removeEventListener(eventName, this.listener[eventName])\r\n }\r\n\r\n this.listener[eventName] = callback\r\n this.socket.addEventListener(eventName, callback)\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = util.isBrowser() ? websocket : require('ws')","'use strict'\r\nimport douyudanmaku from '../src/index'\r\n\r\nwindow.douyudanmaku = douyudanmaku\r\nwindow.danmaku = douyudanmaku\r\n","'use strict'\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(\n uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)\n ))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n","/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nvar base64 = require('base64-js')\nvar ieee754 = require('ieee754')\nvar isArray = require('isarray')\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return ''\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n","exports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///../node_modules/fast-text-encoding/text.min.js","webpack:///../node_modules/ws/browser.js","webpack:///../src/client.js","webpack:///../src/clientEvent.js","webpack:///../src/config.js","webpack:///../src/index.js","webpack:///../src/logger.js","webpack:///../src/loggerNode.js","webpack:///../src/messageEvent.js","webpack:///../src/packet.js","webpack:///../src/stt.js","webpack:///../src/util.js","webpack:///../src/websocket.js","webpack:///./index.js","webpack:///(webpack)/buildin/global.js"],"names":["config","require","event","stt","util","packet","messageEvent","Client","constructor","roomId","opts","ws","logger","heartbeatTask","ignore","options","setOptions","clientEvent","connect","name","listener","open","disconnect","close","error","initSocket","URL","on","bind","message","send","Encode","serialize","login","type","roomid","joinGroup","rid","gid","heartbeat","setInterval","HEARBEAT_INTERVAL","logout","clearInterval","run","websocket","Logger","setIgnore","key","value","isObject","i","push","defOpts","debug","logfile","hasOwnProperty","isBoolean","isString","Object","assign","messageHandle","data","Decode","m","r","deserialize","init","isBrowser","echo","keys","filter","v","includes","method","callback","clientEventName","find","toLocaleLowerCase","cb","res","messageEventName","module","exports","err","console","MessageEvent","reader","FileReader","onload","e","target","result","readAsArrayBuffer","port","random","MSG_LIVE_ON","MSG_LIVE_OFF","MSG_ROOM_RSS","MSG_BC_BUY_DESERVE","MSG_SSD","MSG_ROOM_SPBC","danmaku","Websocket","inited","db","version","IndexedDB","window","indexedDB","mozIndexedDB","webkitIndexedDB","msIndexedDB","DB","addEventListener","log","store","createObjectStore","keyPath","autoIncrement","createIndex","unique","tx","transaction","objectStore","add","room_id","timestamp","Date","getTime","frame","all","req","index","getAll","Promise","resolve","reject","count","export","text","reduce","arr","row","JSON","stringify","download","join","clear","openCursor","IDBKeyRange","only","cursor","delete","continue","fs","content","appendFile","readFile","str","split","length","readFileSync","writeFileSync","loginres","chatmsg","level","nn","txt","uenter","upgrade","rss","ss","bc_buy_deserve","ssd","spbc","sn","gn","gc","dgb","onlinegift","sil","ggbb","rankup","ranklist","mrkl","erquizisn","blab","rri","synexp","noble_num_info","gbroadcast","qausrespond","wiru","wirt","mcspeacsite","rank_change","srres","anbc","frank","Packet","HEADER_LEN_SIZE","HEADER_LEN_TYPECODE","HEADER_LEN_ENCRYPT","HEADER_LEN_PLACEHOLDER","HEADER_LEN_TOTAL","encoder","TextEncoder","decoder","TextDecoder","buffer","ArrayBuffer","readLength","concat","n","arguments","buf","Uint8Array","t","set","msgBody","encode","of","msgLen","msgTotalLen","DataView","setUint32","setInt16","byteLength","getUint32","slice","decode","Blob2ab","blob","Ab2blob","ab","Blob","STT","escape","isUndefined","toString","replace","unescape","raw","map","k","Array","isArray","isNumber","item","o","s","Util","forEach","p","prototype","call","min","max","Math","floor","filename","element","document","createElement","style","display","href","createObjectURL","body","appendChild","click","revokeObjectURL","removeChild","address","socket","WebSocket","code","reason","eventName","removeEventListener","douyudanmaku"],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;AClFA,2DAAa,cAAc,gBAAgB,uBAAuB,cAAc,SAAS,GAAG,+IAA+I,iGAAiG,yCAAyC,2CAA2C,8CAA8C,cAAc,EAAE;AAC9d,GAAG,cAA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AAI4M,CAAS,GAAG,CAAC,MAAD,EAAS,OAAT,EAAkB,OAAlB,EAA2B,SAA3B,EAAsC1M,IAAtC,CAA2C3E,CAAK,IAAIA,CAAK,KAAKwE,CAAM,CAACI,iBAAP,EAA9D,CAAhB;AAEIyM,KAHa,KAIT5N,MAAM,CAACW,IAAP,CAAY,KAAKlD,QAAjB,EAA2BqD,QAA3B,CAAoC8M,CAApC,CAJS,IAKT,KAAKJ,MAAL,CAAYK,mBAAZ,CAAgCD,CAAhC,EAA2C,KAAKnQ,QAAL,CAAcmQ,CAAd,CAA3C,CALS,EAQb,KAAKnQ,QAAL,CAAcmQ,CAAd,IAA2B5M,CARd,EASb,KAAKwM,MAAL,CAAYjK,gBAAZ,CAA6BqK,CAA7B,EAAwC5M,CAAxC,CATa;AAWpB;;AAzBW;;AA4BhBO,MAAM,CAACC,OAAP,GAAiB/E,IAAI,CAACgE,SAAL,KAAmBvB,SAAnB,GAA+B5C,mBAAO,CAAC,yCAAD,C;;;;;;;;;;;;AC9BvD;AAAA;AAAA;AAAA;;AACA;AAEA2G,MAAM,CAAC6K,YAAP,GAAsBA,iD,EACtB7K,MAAM,CAACN,OAAP,GAAiBmL,iD;;;;;;;;;;;;;;;;;;;;;;ACJjB;;AAEA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;;AAEA;AACA;AACA,4CAA4C;;AAE5C","file":"douyudanmaku.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./index.js\");\n","(function(l){function m(){}function k(b,a){b=void 0===b?\"utf-8\":b;a=void 0===a?{fatal:!1}:a;if(-1==n.indexOf(b.toLowerCase()))throw new RangeError(\"Failed to construct 'TextDecoder': The encoding label provided ('\"+b+\"') is invalid.\");if(a.fatal)throw Error(\"Failed to construct 'TextDecoder': the 'fatal' option is unsupported.\");}if(l.TextEncoder&&l.TextDecoder)return!1;var n=[\"utf-8\",\"utf8\",\"unicode-1-1-utf-8\"];Object.defineProperty(m.prototype,\"encoding\",{value:\"utf-8\"});m.prototype.encode=function(b,\na){a=void 0===a?{stream:!1}:a;if(a.stream)throw Error(\"Failed to encode: the 'stream' option is unsupported.\");a=0;for(var g=b.length,f=0,c=Math.max(32,g+(g>>1)+7),e=new Uint8Array(c>>3<<3);a=d){if(a=d)continue}f+4>e.length&&(c+=8,c*=1+a/b.length*2,c=c>>3<<3,h=new Uint8Array(c),h.set(e),e=h);if(0===(d&4294967168))e[f++]=d;else{if(0===(d&4294965248))e[f++]=\nd>>6&31|192;else if(0===(d&4294901760))e[f++]=d>>12&15|224,e[f++]=d>>6&63|128;else if(0===(d&4292870144))e[f++]=d>>18&7|240,e[f++]=d>>12&63|128,e[f++]=d>>6&63|128;else continue;e[f++]=d&63|128}}return e.slice?e.slice(0,f):e.subarray(0,f)};Object.defineProperty(k.prototype,\"encoding\",{value:\"utf-8\"});Object.defineProperty(k.prototype,\"fatal\",{value:!1});Object.defineProperty(k.prototype,\"ignoreBOM\",{value:!1});k.prototype.decode=function(b,a){a=void 0===a?{stream:!1}:a;if(a.stream)throw Error(\"Failed to decode: the 'stream' option is unsupported.\");\nb.buffer instanceof ArrayBuffer&&(b=b.buffer);b=new Uint8Array(b);a=0;for(var g=[],f=[];;){var c=a>>10&1023|55296),c=56320|c&1023);g.push(c)}}};l.TextEncoder=m;l.TextDecoder=k})(\"undefined\"!==typeof window?window:\"undefined\"!==typeof global?global:this);\n","'use strict';\n\nmodule.exports = function() {\n throw new Error(\n 'ws does not work in the browser. Browser clients must use the native ' +\n 'WebSocket object'\n );\n};\n","const config = require('./config')\r\nconst event = require('./clientEvent')\r\nconst stt = require('./stt')\r\nconst util = require('./util')\r\nconst packet = require('./packet')\r\nconst messageEvent = require('./messageEvent')\r\n\r\nclass Client {\r\n constructor(roomId, opts) {\r\n this.roomId = roomId\r\n this.ws = null\r\n this.logger = null\r\n this.heartbeatTask = null\r\n this.messageEvent = messageEvent\r\n this.ignore = []\r\n this.options = this.setOptions(opts || {})\r\n this.clientEvent = {\r\n connect: {\r\n name: 'open',\r\n listener: event.open\r\n },\r\n disconnect: {\r\n name: 'close',\r\n listener: event.close\r\n },\r\n error: {\r\n name: 'error',\r\n listener: event.error\r\n },\r\n }\r\n }\r\n\r\n initSocket(ws) {\r\n this.ws = new ws(config.URL)\r\n this.ws.on('open', this.clientEvent.connect.listener.bind(this))\r\n this.ws.on('error', this.clientEvent.error.listener.bind(this))\r\n this.ws.on('close', this.clientEvent.disconnect.listener.bind(this))\r\n this.ws.on('message', event.message.bind(this))\r\n }\r\n\r\n send(message) {\r\n this.ws.send(packet.Encode(stt.serialize(message)))\r\n }\r\n\r\n login() {\r\n this.send({\r\n type: 'loginreq',\r\n roomid: this.roomId,\r\n })\r\n }\r\n\r\n joinGroup() {\r\n this.send({\r\n type: 'joingroup',\r\n rid: this.roomId,\r\n gid: 0\r\n })\r\n }\r\n\r\n heartbeat() {\r\n this.heartbeatTask = setInterval(() => {\r\n this.send({\r\n type: 'mrkl'\r\n })\r\n }, config.HEARBEAT_INTERVAL * 1000)\r\n }\r\n\r\n logout() {\r\n this.send({\r\n type: 'logout',\r\n })\r\n\r\n clearInterval(this.heartbeatTask)\r\n }\r\n\r\n run(websocket, logger) {\r\n const ws = websocket || require('./websocket')\r\n const Logger = logger || require('./logger')\r\n this.logger = new Logger()\r\n this.initSocket(ws)\r\n }\r\n\r\n setIgnore(key, value) {\r\n if (util.isObject(key)) {\r\n for (let i in key) {\r\n if (key[i]) {\r\n this.ignore.push(i)\r\n }\r\n }\r\n } else {\r\n if (value) {\r\n this.ignore.push(key)\r\n }\r\n }\r\n\r\n return this\r\n }\r\n\r\n setOptions(opts) {\r\n const defOpts = {\r\n debug: false,\r\n logfile: `${this.roomId}.log`,\r\n }\r\n const options = {}\r\n\r\n if (!util.isObject(opts)) {\r\n return defOpts\r\n }\r\n\r\n if (opts.hasOwnProperty('debug') && util.isBoolean(opts.debug)) {\r\n options.debug = opts.debug\r\n }\r\n\r\n if (opts.hasOwnProperty('logfile') && util.isString(opts.logfile)) {\r\n options.logfile = opts.logfile\r\n }\r\n\r\n return Object.assign(defOpts, options)\r\n }\r\n\r\n messageHandle(data) {\r\n packet.Decode(data, m => {\r\n const r = stt.deserialize(m)\r\n \r\n if (this.options.debug) {\r\n this.logger.init(util.isBrowser() ? this.roomId : this.options.logfile)\r\n this.logger.echo(r)\r\n }\r\n\r\n if (Object.keys(this.messageEvent).filter(v => {\r\n return !this.ignore.includes(v)\r\n }).includes(r.type)) {\r\n this.messageEvent[r.type](r)\r\n }\r\n })\r\n }\r\n\r\n on(method, callback) {\r\n const clientEventName = Object.keys(this.clientEvent).find(clientEvent => clientEvent === method.toLocaleLowerCase())\r\n if (clientEventName) {\r\n //在创建连接是触发connect事件时,发送登入,加入组,监听心跳消息\r\n if (clientEventName === 'connect') {\r\n let cb = callback\r\n callback = function (res) {\r\n this.login()\r\n this.joinGroup()\r\n this.heartbeat()\r\n cb.bind(this)(res)\r\n }\r\n }\r\n this.clientEvent[method].listener = callback.bind(this)\r\n }\r\n\r\n const messageEventName = Object.keys(this.messageEvent).find(messageEvent => messageEvent === method.toLocaleLowerCase())\r\n if (messageEventName) {\r\n this.messageEvent[method] = callback.bind(this)\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = Client","function open() {\r\n this.login() //登入\r\n this.joinGroup() //加入组\r\n this.heartbeat() //发送心跳,强制45秒\r\n}\r\n\r\nfunction error(err) {\r\n console.error(err)\r\n}\r\n\r\nfunction close() {\r\n this.logout()\r\n}\r\n\r\nfunction message(data) {\r\n if (typeof MessageEvent !== 'undefined') {\r\n //无MessageEvent类型判断为node环境,转换数据为arraybuffer类型\r\n const reader = new FileReader()\r\n reader.onload = e => this.messageHandle(e.target.result)\r\n reader.readAsArrayBuffer(data.data)\r\n } else {\r\n this.messageHandle(data)\r\n }\r\n}\r\n\r\nmodule.exports = {\r\n open,\r\n error,\r\n close,\r\n message,\r\n}","const util = require('./util')\r\n\r\n//目前已知的弹幕服务器\r\nconst port = 8500 + util.random(1, 6)\r\nconst URL = `wss://danmuproxy.douyu.com:${port}/`\r\n\r\nconst HEARBEAT_INTERVAL = 45\r\n\r\nconst MSG_LIVE_ON = '主播正在直播'\r\nconst MSG_LIVE_OFF = '主播没有直播'\r\nconst MSG_ROOM_RSS = '房间开播提醒'\r\nconst MSG_BC_BUY_DESERVE = '赠送酬勤通知'\r\nconst MSG_SSD = '超级弹幕'\r\nconst MSG_ROOM_SPBC = '房间内礼物广播'\r\n\r\nmodule.exports = {\r\n URL,\r\n HEARBEAT_INTERVAL,\r\n MSG_LIVE_ON,\r\n MSG_LIVE_OFF,\r\n MSG_ROOM_RSS,\r\n MSG_BC_BUY_DESERVE,\r\n MSG_SSD,\r\n MSG_ROOM_SPBC,\r\n}","'use strict';\r\n\r\nconst danmaku = require('./client')\r\ndanmaku.stt = require('./stt')\r\ndanmaku.util = require('./util')\r\ndanmaku.logger = require('./logger')\r\ndanmaku.Websocket = require('./websocket')\r\ndanmaku.packet = require('./packet')\r\n\r\nmodule.exports = danmaku","const util = require('./util')\n\nclass Logger {\n constructor() {\n this.name = 'unknown'\n this.inited = false\n this.db = null\n this.version = 2\n }\n\n init(name) {\n if (!this.inited) {\n this.name = name\n\n const IndexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB\n this.DB = IndexedDB.open('danmaku', this.version)\n this.DB.addEventListener('success', e => {\n console.log('连接数据库', event, e)\n this.db = e.target.result\n })\n\n this.DB.addEventListener('upgradeneeded', e => {\n console.log('升级数据库', event, e)\n this.db = e.target.result\n const store = this.db.createObjectStore('douyu', {\n keyPath: 'id',\n autoIncrement: true,\n })\n store.createIndex('idx_room_id', 'room_id', {\n unique: false\n })\n })\n\n this.DB.addEventListener('error', e => {\n console.log('连接数据库出错 Error:', e)\n })\n\n this.inited = true\n }\n }\n\n echo(data) {\n if (this.db !== null) {\n const tx = this.db.transaction('douyu', 'readwrite')\n const store = tx.objectStore('douyu')\n store.add({\n room_id: this.name,\n timestamp: new Date().getTime(),\n frame: data\n })\n }\n }\n\n all(roomId) {\n if (this.db !== null) {\n const tx = this.db.transaction('douyu', 'readonly')\n const store = tx.objectStore('douyu')\n const req = (roomId ? store.index('idx_room_id').getAll(roomId) : store.getAll())\n return new Promise(function (resolve, reject) {\n req.addEventListener('success', function (e) {\n resolve(e.target.result)\n })\n req.addEventListener('error', function (e) {\n reject(false)\n })\n })\n }\n }\n\n count(roomId) {\n if (this.db !== null) {\n const tx = this.db.transaction('douyu', 'readonly')\n const store = tx.objectStore('douyu')\n const req = (roomId ? store.index('idx_room_id').count(roomId) : store.count())\n return new Promise(function (resolve, reject) {\n req.addEventListener('success', function (e) {\n resolve(req.result)\n })\n req.addEventListener('error', function (e) {\n reject(false)\n })\n })\n }\n }\n\n async export (roomId) {\n if (this.db !== null) {\n const r = await this.all(roomId)\n const text = r.reduce((arr, row) => {\n const v = {\n timestamp: row.timestamp,\n frame: row.frame,\n }\n if (!roomId) v.roomId = this.name\n arr.push(JSON.stringify(v))\n return arr\n }, [])\n util.download(this.name, text.join('\\n'))\n return text\n }\n }\n\n clear(roomId) {\n if (this.db !== null) {\n const tx = this.db.transaction('douyu', 'readwrite')\n const store = tx.objectStore('douyu')\n if (roomId) {\n const index = store.index('idx_room_id')\n const req = index.openCursor(IDBKeyRange.only(roomId))\n req.addEventListener('success', function () {\n const cursor = req.result\n if (cursor) {\n cursor.delete()\n cursor.continue()\n }\n })\n } else {\n store.clear()\n }\n }\n }\n}\n\nmodule.exports = util.isBrowser() ? Logger : require('./loggerNode')","const fs = require('fs')\n\nmodule.exports = class Logger {\n constructor() {\n this.name = 'unknown'\n this.inited = false\n }\n\n init(name) {\n if (!this.inited) {\n this.name = name\n this.inited = true\n }\n }\n\n echo(data) {\n const content = `${JSON.stringify({timestamp: new Date().getTime(),frame: data})}\\n`\n fs.appendFile(\n this.name,\n content,\n function (err) {\n if (err) {\n console.error('日志保存出错, Error:', err)\n }\n })\n }\n\n all() {\n return new Promise((resolve, reject) => {\n fs.readFile(this.name, 'utf8', function (err, str) {\n if (err) {\n reject(err)\n } else {\n resolve(str)\n }\n })\n })\n }\n\n count() {\n return new Promise(async (resolve, reject) => {\n const content = await this.all()\n resolve(content.split('\\n').filter(v => v !== '').length)\n })\n }\n\n export () {\n return fs.readFileSync(this.name, 'utf8')\n }\n\n clear() {\n try {\n return fs.writeFileSync(this.name, '', 'utf8')\n } catch (err) {\n return false\n }\n }\n}\n","const config = require('./config')\r\n\r\nmodule.exports = {\r\n loginres: function (r) {\r\n // 登录响应\r\n // 服务端返回登录响应消息,完整的数据部分应包含的字段如下:\r\n // 字段说明\r\n // type 表示为“登录”消息,固定为 loginres\r\n // userid 用户 ID\r\n // roomgroup 房间权限组\r\n // pg 平台权限组\r\n // sessionid 会话 ID\r\n // username 用户名\r\n // nickname 用户昵称\r\n // is_signed 是否已在房间签到\r\n // signed_count 日总签到次数\r\n // live_stat 直播状态\r\n // npv 是否需要手机验证\r\n // best_dlev 最高酬勤等级\r\n // cur_lev 酬勤等级\r\n },\r\n chatmsg: function (r) {\r\n // 弹幕消息\r\n // 用户在房间发送弹幕时,服务端发此消息给客户端,完整的数据部分应包含的字 段如下:\r\n // 字段说明\r\n // type 表示为“弹幕”消息,固定为 chatmsg\r\n // gid 弹幕组 id\r\n // rid 房间 id\r\n // uid 发送者 uid\r\n // nn 发送者昵称\r\n // txt 弹幕文本内容\r\n // cid 弹幕唯一 ID\r\n // level 用户等级\r\n // gt 礼物头衔:默认值 0(表示没有头衔)\r\n // col 颜色:默认值 0(表示默认颜色弹幕)\r\n // ct 客户端类型:默认值 0(表示 web 用户)\r\n // rg 房间权限组:默认值 1(表示普通权限用户)\r\n // pg 平台权限组:默认值 1(表示普通权限用户)\r\n // dlv 酬勤等级:默认值 0(表示没有酬勤)\r\n // dc 酬勤数量:默认值 0(表示没有酬勤数量)\r\n // bdlv 最高酬勤等级:默认值 0(表示全站都没有酬勤)\r\n console.log(\" [%s] %s\", r.level + (r.level < 10 ? ' ' : ''), r.nn, r.txt)\r\n },\r\n uenter: function (r) {\r\n // 进入直播间\r\n // 具有特殊属性的用户进入直播间时,服务端发送此消息至客户端。完整的数据部 分应包含的字段如下:\r\n // 字段说明\r\n // type 表示为“用户进房通知”消息,固定为 uenter\r\n // rid 房间 ID\r\n // gid 弹幕分组 ID\r\n // uid 用户 ID\r\n // nn 用户昵称\r\n // str 战斗力\r\n // level 新用户等级\r\n // gt 礼物头衔:默认值 0(表示没有头衔)\r\n // rg 房间权限组:默认值 1(表示普通权限用户)\r\n // pg 平台身份组:默认值 1(表示普通权限用户)\r\n // dlv 酬勤等级:默认值 0(表示没有酬勤)\r\n // dc 酬勤数量:默认值 0(表示没有酬勤数量)\r\n // bdlv 最高酬勤等级:默认值 0(表示全站都没有酬勤)\r\n console.log(`欢迎${r.nn}进入了直播间`)\r\n },\r\n upgrade: function (r) {\r\n // 用户等级提升\r\n },\r\n rss: function (r) {\r\n // 房间开播提醒\r\n // 房间开播提醒主要部分应包含的字段如下:\r\n // 字段说明\r\n // type 表示为“房间开播提醒”消息,固定为 rss\r\n // rid 房间 id\r\n // gid 弹幕分组 id\r\n // ss 直播状态,1-正在直播, 2-没有直播\r\n // code 类型\r\n // rt 开关播原因:0-主播开关播,其他值-其他原因\r\n // notify 通知类型\r\n // endtime 关播时间(仅关播时有效)\r\n console.log('[开播提醒]', r.ss == 1 ? config.MSG_LIVE_ON : config.MSG_LIVE_OFF)\r\n },\r\n bc_buy_deserve: function (r) {\r\n // 赠送酬勤通知\r\n // 用户赠送酬勤时,服务端发送此消息至客户端。完整的数据部分应包含的字段如 下:\r\n // 字段说明\r\n // type 表示为“赠送酬勤通知”消息,固定为 bc_buy_deserve\r\n // rid 房间 ID\r\n // gid 弹幕分组 ID\r\n // level 用户等级\r\n // cnt 赠送数量\r\n // hits 赠送连击次数\r\n // lev 酬勤等级\r\n // sui 用户信息序列化字符串,详见下文。注意,此处为嵌套序列化,需注 意符号的转义变换。(转义符号参见 2.2 序列化)\r\n },\r\n ssd: function (r) {\r\n // 超级弹幕\r\n // 超级弹幕主要部分应包含的字段如下:\r\n // 字段说明\r\n // type 表示为“超级弹幕”消息,固定为 ssd\r\n // rid 房间 id\r\n // gid 弹幕分组 id\r\n // sdid 超级弹幕 id\r\n // trid 跳转房间 id\r\n // content 超级弹幕的内容\r\n },\r\n spbc: function (r) {\r\n // 房间内礼物广播\r\n // 房间内赠送礼物成功后效果主要部分应包含的字段如下:\r\n // 字段说明\r\n // type 表示为“房间内礼物广播”,固定为 spbc\r\n // rid 房间 id\r\n // gid 弹幕分组 id\r\n // sn 赠送者昵称\r\n // dn 受赠者昵称\r\n // gn 礼物名称\r\n // gc 礼物数量\r\n // drid 赠送房间\r\n // gs 广播样式\r\n // gb 是否有礼包(0-无礼包,1-有礼包)\r\n // es 广播展现样式(1-火箭,2-飞机)\r\n // gfid 礼物 id\r\n // eid 特效 id\r\n console.log(`------------- 感谢[${r.sn}] 赠送的 ${r.gn}x${r.gc}`)\r\n },\r\n dgb: function (r) {\r\n // 赠送礼物\r\n // 用户在房间赠送礼物时,服务端发送此消息给客户端。完整的数据部分应包含的 字段如下:\r\n // 字段说明\r\n // type 表示为“赠送礼物”消息,固定为 dgb\r\n // rid 房间 ID\r\n // gid 弹幕分组 ID\r\n // gfid 礼物 id\r\n // gs 礼物显示样式\r\n // uid 用户 id\r\n // nn 用户昵称\r\n // str 用户战斗力\r\n // level 用户等级\r\n // dw 主播体重\r\n // gfcnt 礼物个数:默认值 1(表示 1 个礼物)\r\n // hits 礼物连击次数:默认值 1(表示 1 连击)\r\n // dlv 酬勤头衔:默认值 0(表示没有酬勤)\r\n // dc 酬勤个数:默认值 0(表示没有酬勤数量)\r\n // bdl 全站最高酬勤等级:默认值 0(表示全站都没有酬勤)\r\n // rg 房间身份组:默认值 1(表示普通权限用户)\r\n // pg 平台身份组:默认值 1(表示普通权限用户)\r\n // rpid 红包 id:默认值 0(表示没有红包)\r\n // slt 红包开启剩余时间:默认值 0(表示没有红包)\r\n // elt 红包销毁剩余时间:默认值 0(表示没有红包)\r\n },\r\n onlinegift: function (r) {\r\n // 领取在线鱼丸\r\n // 在线领取鱼丸时,若出现暴击(鱼丸数大于等于 60)服务则发送领取暴击消息 到客户端。完整的数据部分应包含的字段如下:\r\n // 字段说明\r\n // type 表示为“领取在线鱼丸”消息,固定为 onlinegift\r\n // rid 房间 ID\r\n // uid 用户 ID\r\n // gid 弹幕分组 ID\r\n // sil 鱼丸数\r\n // if 领取鱼丸的等级\r\n // ct 客户端类型标识\r\n // nn 用户昵称\r\n console.log(`------------- [${r.nn}] 领取鱼丸x${r.sil}`)\r\n },\r\n ggbb: function (r) {\r\n // 房间用户抢红包\r\n // 房间赠送礼物成功后效果(赠送礼物效果,连击数)主要部分应包含的字段如下:\r\n // 字段说明\r\n // type 表示“房间用户抢红包”信息,固定为 ggbb\r\n // rid 房间 id\r\n // gid 弹幕分组 id\r\n // sl 抢到的鱼丸数量\r\n // sid 礼包产生者 id\r\n // did 抢礼包者 id\r\n // snk 礼包产生者昵称\r\n // dnk 抢礼包者昵称\r\n // rpt 礼包类型\r\n },\r\n rankup: function (r) {\r\n // 房间内top10变化消息\r\n // 房间内 top10 排行榜变化后,广播。主要部分应包含的字段如下:\r\n // 字段说明\r\n // type 表示为“房间 top10 排行榜变换”,固定为 rankup\r\n // rid 房间 id\r\n // gid 弹幕分组 id\r\n // uid 用户 id\r\n // drid 目标房间 id\r\n // rt 房间所属栏目类型\r\n // bt 广播类型:1-房间内广播,2-栏目广播,4-全站广播\r\n // sz 展示区域:1-聊天区展示,2-flash 展示,3-都显示\r\n // nk 用户昵称\r\n // rkt top10 榜的类型 1-周榜 2-总榜 4-日榜\r\n // rn 上升后的排名\r\n },\r\n ranklist: function (r) {\r\n // 广播排行榜消息\r\n },\r\n mrkl: function(r) {\r\n // 心跳\r\n },\r\n erquizisn: function(r) {\r\n // 鱼丸预言,参数未知\r\n },\r\n blab: function(r) {\r\n // 粉丝等级升级\r\n // 字段说明\r\n // type 表示为“粉丝等级升级”,固定为 blab\r\n // rid 房间 id\r\n // uid 用户 id\r\n // nn 用户昵称\r\n // bl 升级后的等级\r\n // bnn 升级的粉丝牌\r\n // lbl 未知(猜测未升级前的等级)\r\n // ba 未知\r\n },\r\n rri: function(r) {\r\n // 未知的消息事件\r\n },\r\n synexp: function(r) {\r\n\r\n },\r\n noble_num_info: function(r) {\r\n // 未知的消息事件\r\n },\r\n gbroadcast: function(r) {\r\n // 未知的消息事件\r\n },\r\n qausrespond: function(r) {\r\n // 未知的消息事件\r\n },\r\n wiru: function(r) {\r\n // 未知的消息事件\r\n },\r\n wirt: function(r) {\r\n // 未知的消息事件\r\n },\r\n mcspeacsite: function(r) {\r\n // 未知的消息事件\r\n },\r\n rank_change: function(r) {\r\n // 未知的消息事件\r\n },\r\n srres: function(r) {\r\n // 未知的消息事件\r\n },\r\n anbc: function(r) {\r\n // 未知的消息事件\r\n },\r\n frank: function(r) {\r\n // 粉丝排行榜变化\r\n },\r\n}","require('fast-text-encoding')\nconst util = require('./util')\n\nclass Packet {\n constructor() {\n this.HEADER_LEN_SIZE = 4\n this.HEADER_LEN_TYPECODE = 2\n this.HEADER_LEN_ENCRYPT = 1\n this.HEADER_LEN_PLACEHOLDER = 1\n this.HEADER_LEN_TOTAL = this.HEADER_LEN_SIZE * 2 +\n this.HEADER_LEN_TYPECODE +\n this.HEADER_LEN_ENCRYPT +\n this.HEADER_LEN_PLACEHOLDER\n\n this.encoder = new TextEncoder()\n this.decoder = new TextDecoder()\n this.buffer = new ArrayBuffer(0)\n this.readLength = 0\n }\n\n concat() {\n const arr = []\n for (let n = 0; n < arguments.length; n++) arr[n] = arguments[n]\n\n return arr.reduce(function (arr, buf) {\n const message = buf instanceof ArrayBuffer ? new Uint8Array(buf) : buf\n const t = new Uint8Array(arr.length + message.length)\n t.set(arr, 0)\n t.set(message, arr.length)\n return t\n }, new Uint8Array(0))\n }\n\n Encode(data) {\n const msgBody = this.concat(this.encoder.encode(data), Uint8Array.of(0))\n const msgLen = msgBody.length + this.HEADER_LEN_SIZE * 2\n const msgTotalLen = msgBody.length + this.HEADER_LEN_TOTAL\n const r = new DataView(new ArrayBuffer(msgTotalLen))\n\n r.setUint32(0, msgLen, true)\n r.setUint32(4, msgLen, true)\n r.setInt16(8, 689, true)\n r.setInt16(10, 0, true)\n\n return new Uint8Array(r.buffer).set(msgBody, this.HEADER_LEN_TOTAL), r.buffer\n }\n\n Decode(buf, callback) {\n this.buffer = this.concat(this.buffer, buf).buffer\n while (this.buffer && this.buffer.byteLength > 0) {\n if (0 === this.readLength) {\n if (this.buffer.byteLength < 4) return;\n\n this.readLength = new DataView(this.buffer).getUint32(0, true)\n this.buffer = this.buffer.slice(4)\n }\n\n if (this.buffer.byteLength < this.readLength) return;\n\n const message = this.decoder.decode(this.buffer.slice(8, this.readLength - 1))\n this.buffer = this.buffer.slice(this.readLength)\n this.readLength = 0\n callback(message)\n }\n }\n\n /**\n * blob转arraybuffer\n * @param {Blob} blob 待转换的Blob类型参数\n */\n Blob2ab(blob) {\n return new Promise((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = function (e) {\n resolve(e.target.result)\n }\n reader.readAsArrayBuffer(blob)\n })\n }\n\n /**\n * arraybuffer转blob\n * @param {ArrayBuffer} ab 待转换的ArrayBuffer类型参数\n */\n Ab2blob(ab) {\n return new Blob([ab])\n }\n}\n\nmodule.exports = new Packet()","const util = require('./util')\r\n\r\nclass STT {\r\n escape(v) {\r\n return util.isUndefined(v) ? '' : v.toString().replace(/@/g, '@A').replace(/\\//g, '@S')\r\n }\r\n\r\n unescape(v) {\r\n return util.isUndefined(v) ? '' : v.toString().replace(/@A/g, '@').replace(/@S/g, '/')\r\n }\r\n\r\n serialize(raw) {\r\n if (util.isObject(raw)) {\r\n return Object.keys(raw).map(k => `${k}@=${this.escape(this.serialize(raw[k]))}/`).join('')\r\n } else if (Array.isArray(raw)) {\r\n return raw.map(v => `${this.escape(this.serialize(v))}/`).join('')\r\n } else if (util.isString(raw) || util.isNumber(raw)) {\r\n return raw.toString()\r\n }\r\n }\r\n\r\n deserialize(raw) {\r\n if (raw.includes('//')) {\r\n return raw.split('//').filter(e => e !== '').map(item => this.deserialize(item))\r\n }\r\n\r\n if (raw.includes('@=')) {\r\n return raw.split('/').filter(e => e !== '').reduce((o, s) => {\r\n const [k, v] = s.split('@=')\r\n o[k] = this.deserialize(this.unescape(v))\r\n return o\r\n }, {})\r\n } else if (raw.includes('@A=')) {\r\n return this.deserialize(this.unescape(raw))\r\n } else {\r\n return raw.toString()\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = new STT()","function Util() {\r\n [\r\n 'Object',\r\n 'Array',\r\n 'String',\r\n 'Number',\r\n 'Boolean',\r\n 'Function',\r\n 'RegExp',\r\n 'Date',\r\n 'Undefined',\r\n 'Null',\r\n 'Symbol',\r\n 'Blob',\r\n 'ArrayBuffer'\r\n ].forEach(type => {\r\n this[`is${type}`] = (p) => Object.prototype.toString.call(p).slice(8, -1) === type\r\n })\r\n}\r\n\r\n//判断浏览器环境\r\nUtil.prototype.isBrowser = () => (typeof window !== 'undefined') ? true : false\r\n\r\n//随机数生成\r\nUtil.prototype.random = (min, max) => Math.floor(Math.random() * (max - min + 1) + min)\r\n\r\n//web端下载文件\r\nUtil.prototype.download = function(filename, text) {\r\n if (this.isBrowser()) {\r\n let element = document.createElement('a');\r\n element.style.display = 'none'\r\n let blob = new Blob([text])\r\n element.download = `${filename}.log`\r\n element.href = URL.createObjectURL(blob)\r\n document.body.appendChild(element)\r\n element.click()\r\n URL.revokeObjectURL(blob)\r\n document.body.removeChild(element)\r\n }\r\n}\r\n\r\nmodule.exports = new Util()","const util = require('./util')\r\n\r\nclass websocket {\r\n constructor(address) {\r\n this.listener = {}\r\n this.socket = new WebSocket(address)\r\n }\r\n\r\n send(data) {\r\n this.socket.send(data)\r\n }\r\n\r\n close(code, reason) {\r\n this.socket.close(code, reason)\r\n }\r\n\r\n on(method, callback) {\r\n let eventName = ['open', 'error', 'close', 'message'].find(event => event === method.toLocaleLowerCase())\r\n\r\n if (eventName) {\r\n if (Object.keys(this.listener).includes(eventName)) {\r\n this.socket.removeEventListener(eventName, this.listener[eventName])\r\n }\r\n\r\n this.listener[eventName] = callback\r\n this.socket.addEventListener(eventName, callback)\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = util.isBrowser() ? websocket : require('ws')","'use strict'\r\nimport douyudanmaku from '../src/index'\r\n\r\nwindow.douyudanmaku = douyudanmaku\r\nwindow.danmaku = douyudanmaku\r\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/douyudanmaku.min.js b/dist/douyudanmaku.min.js index 00f5974..a84d387 100644 --- a/dist/douyudanmaku.min.js +++ b/dist/douyudanmaku.min.js @@ -1,8 +1 @@ -!function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=8)}([function(t,e){function r(){["Object","Array","String","Number","Boolean","Function","RegExp","Date","Undefined","Null","Symbol","Blob","ArrayBuffer"].forEach(t=>{this["is".concat(t)]=e=>Object.prototype.toString.call(e).slice(8,-1)===t})}r.prototype.isBrowser=()=>"undefined"!=typeof window,r.prototype.random=(t,e)=>Math.floor(Math.random()*(e-t+1)+t),r.prototype.download=function(t,e){if(this.isBrowser()){var r=document.createElement("a");r.style.display="none";var n=new Blob([e]);r.download="".concat(t,".log"),r.href=URL.createObjectURL(n),document.body.appendChild(r),r.click(),URL.revokeObjectURL(n),document.body.removeChild(r)}},t.exports=new r},function(t,e,r){"use strict";var n=r(9);n.stt=r(3),n.util=r(0),n.logger=r(6),n.Websocket=r(7),n.packet=r(4),t.exports=n},function(t,e,r){var n=8500+r(0).random(1,6),i="wss://danmuproxy.douyu.com:".concat(n,"/");t.exports={URL:i,HEARBEAT_INTERVAL:45,MSG_LIVE_ON:"主播正在直播",MSG_LIVE_OFF:"主播没有直播",MSG_ROOM_RSS:"房间开播提醒",MSG_BC_BUY_DESERVE:"赠送酬勤通知",MSG_SSD:"超级弹幕",MSG_ROOM_SPBC:"房间内礼物广播"}},function(t,e,r){var n=r(0);t.exports=new class{escape(t){return n.isUndefined(t)?"":t.toString().replace(/\//g,"@S").replace(/@/g,"@A")}unescape(t){return n.isUndefined(t)?"":t.toString().replace(/@S/g,"/").replace(/@A/g,"@")}serialize(t){return n.isObject(t)?Object.keys(t).map(e=>"".concat(e,"@=").concat(this.escape(this.serialize(t[e])),"/")).join(""):Array.isArray(t)?t.map(t=>"".concat(this.escape(this.serialize(t)),"/")).join(""):n.isString(t)||n.isNumber(t)?t.toString():void 0}deserialize(t){return t.includes("//")?t.split("//").filter(t=>""!==t).map(t=>this.deserialize(t)):t.includes("@=")?t.split("/").filter(t=>""!==t).reduce((t,e)=>{var[r,n]=e.split("@=");return t[r]=this.deserialize(this.unescape(n)),t},{}):t.includes("@A=")?this.deserialize(this.unescape(t)):t.toString()}}},function(t,e,r){(function(e){r(15);var n=r(0);function i(){this.buffer=new ArrayBuffer(0),this.decoder=new TextDecoder,this.encoder=new TextEncoder,this.littleEndian=!0,this.readLength=0}i.prototype.concat=function(){for(var t=[],e=0;e0;){if(0===this.readLength){if(this.buffer.byteLength<4)return;this.readLength=new DataView(this.buffer).getUint32(0,r),this.buffer=this.buffer.slice(4)}if(this.buffer.byteLength{var r=new FileReader;r.onload=function(t){e(t.target.result)},r.readAsArrayBuffer(t)})},i.prototype.ab2blob=function(t){return new Blob([t])};var o=new i;t.exports=new class{constructor(){this.HEADER_LEN_SIZE=4,this.HEADER_LEN_TYPECODE=2,this.HEADER_LEN_ENCRYPT=1,this.HEADER_LEN_PLACEHOLDER=1,this.HEADER_LEN_TOTAL=2*this.HEADER_LEN_SIZE+this.HEADER_LEN_TYPECODE+this.HEADER_LEN_ENCRYPT+this.HEADER_LEN_PLACEHOLDER,this.buffer=e.alloc(0)}nodeEncode(t){var r=e.alloc(this.HEADER_LEN_TOTAL),n=e.from(t,"utf8"),i=n.length+this.HEADER_LEN_TOTAL+1;return r.writeInt32LE(i-this.HEADER_LEN_SIZE,0),r.writeInt32LE(i-this.HEADER_LEN_SIZE,4),r.writeInt16LE(689,8),e.concat([r,n],i)}browserEncode(t){return o.Encode(t)}Encode(t){return n.isBrowser()?this.browserEncode(t):this.nodeEncode(t)}nodeDecode(t,r){this.buffer=e.concat([this.buffer,t]);for(var n=0;this.buffer.length>0;n=0){if(0===n){if(this.buffer.length{this.db=event.target.result}),this._sql.addEventListener("upgradeneeded",()=>{this.db=event.target.result,this.db.createObjectStore(this.dbname,{keyPath:"id",autoIncrement:!0})}),this._sql.addEventListener("error",()=>{})):this._fs=r(17),this.inited=!0)},o.isBrowser()?(s.prototype.echo=function(t){null!==this.db&&this.db.transaction(this.dbname,"readwrite").objectStore(this.dbname).add({t:(new Date).getTime(),frame:t})},s.prototype.all=function(){if(null!==this.db){var t=this.db.transaction(this.dbname,"readonly").objectStore(this.dbname);return new Promise((function(e,r){var n=t.getAll();n.addEventListener("success",(function(){e(n.result)})),n.addEventListener("error",(function(){r(!1)}))}))}},s.prototype.len=function(){if(null!==this.db){var t=this.db.transaction(this.dbname,"readonly").objectStore(this.dbname);return new Promise((function(e,r){var n=t.count();n.addEventListener("success",(function(){e(n.result)})),n.addEventListener("error",(function(){r(!1)}))}))}},s.prototype.export=i((function*(){if(null!==this.db){var t=yield this.all(),e="";return t.forEach(t=>{e+="".concat(JSON.stringify({t:t.t,frame:t.frame}),"\n")}),o.download(this.dbname,e),e}})),s.prototype.clear=function(){null!==this.db&&this.db.transaction(this.dbname,"readwrite").objectStore(this.dbname).clear()}):(s.prototype.echo=function(t){this._fs.appendFile(this.dbname,JSON.stringify({t:(new Date).getTime(),frame:t})+"\n",(function(t){}))},s.prototype.all=function(){return new Promise((t,e)=>{this._fs.readFile(this.dbname,"utf8",(function(r,n){r?e(r):t(n)}))})},s.prototype.len=function(){var t=this;return new Promise(function(){var e=i((function*(e){e((yield t.all()).split("\n").filter(t=>""!==t).length)}));return function(){return e.apply(this,arguments)}}())},s.prototype.export=function(){return this._fs.readFileSync(this.dbname,"utf8")},s.prototype.clear=function(){}),t.exports=new s},function(t,e,r){var n=r(0);t.exports=n.isBrowser()?class{constructor(t){this.listener={},this.socket=new WebSocket(t)}send(t){this.socket.send(t)}close(t,e){this.socket.close(t,e)}on(t,e){var r=["open","error","close","message"].find(e=>e===t.toLocaleLowerCase());r&&(Object.keys(this.listener).includes(r)&&this.socket.removeEventListener(r,this.listener[r]),this.listener[r]=e,this.socket.addEventListener(r,e))}}:r(18)},function(t,e,r){"use strict";r.r(e);var n=r(1),i=r.n(n);window.douyudanmaku=i.a,window.danmaku=i.a},function(t,e,r){var n=r(2),i=r(10),o=r(3),s=r(0),u=r(4),f=r(16),a=r(6);t.exports=class{constructor(t,e){this.roomId=t,this.ws=null,this.heartbeatTask=null,this.messageEvent=f,this.ignore=[],this.options=this.setOptions(e||{}),this.clientEvent={connect:{name:"open",listener:i.open},disconnect:{name:"close",listener:i.close},error:{name:"error",listener:i.error}}}initSocket(t){this.ws=new t(n.URL),this.ws.on("open",this.clientEvent.connect.listener.bind(this)),this.ws.on("error",this.clientEvent.error.listener.bind(this)),this.ws.on("close",this.clientEvent.disconnect.listener.bind(this)),this.ws.on("message",i.message.bind(this))}send(t){this.ws.send(u.Encode(o.serialize(t)))}login(){this.send({type:"loginreq",roomid:this.roomId})}joinGroup(){this.send({type:"joingroup",rid:this.roomId,gid:0})}heartbeat(){this.heartbeatTask=setInterval(()=>{this.send({type:"mrkl"})},1e3*n.HEARBEAT_INTERVAL)}logout(){this.send({type:"logout"}),clearInterval(this.heartbeatTask)}run(t){var e=t||r(7);this.initSocket(e)}setIgnore(t,e){if(s.isObject(t))for(var r in t)t[r]&&this.ignore.push(r);else e&&this.ignore.push(t);return this}setOptions(t){var e={debug:!1,logfile:"".concat(this.roomId,".log")},r={};return s.isObject(t)?(t.hasOwnProperty("debug")&&s.isBoolean(t.debug)&&(r.debug=t.debug),t.hasOwnProperty("logfile")&&s.isString(t.logfile)&&(r.logfile=t.logfile),Object.assign(e,r)):e}messageHandle(t){u.Decode(t,t=>{var e=o.deserialize(t);if(this.options.debug){var r=s.isBrowser()?this.roomId:this.options.logfile;a.init(r),a.echo(e)}Object.keys(this.messageEvent).filter(t=>!this.ignore.includes(t)).includes(e.type)&&this.messageEvent[e.type](e)})}on(t,e){var r=Object.keys(this.clientEvent).find(e=>e===t.toLocaleLowerCase());if(r){if("connect"===r){var n=e;e=function(t){this.login(),this.joinGroup(),this.heartbeat(),n.bind(this)(t)}}this.clientEvent[t].listener=e.bind(this)}Object.keys(this.messageEvent).find(e=>e===t.toLocaleLowerCase())&&(this.messageEvent[t]=e.bind(this))}}},function(t,e){t.exports={open:function(){this.login(),this.joinGroup(),this.heartbeat()},error:function(){},close:function(){this.logout()},message:function(t){if("undefined"!=typeof MessageEvent){var e=new FileReader;e.onload=t=>this.messageHandle(t.target.result),e.readAsArrayBuffer(t.data)}else this.messageHandle(t)}}},function(t,e,r){"use strict";(function(t){ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -var n=r(12),i=r(13),o=r(14);function s(){return f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function u(t,e){if(s()=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function d(t,e){if(f.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return H(t).length;default:if(n)return N(t).length;e=(""+e).toLowerCase(),n=!0}}function g(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return T(this,e,r);case"utf8":case"utf-8":return B(this,e,r);case"ascii":return L(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return S(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=f.from(e,n)),f.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,i);if("number"==typeof e)return e&=255,f.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,i){var o,s=1,u=t.length,f=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,u/=2,f/=2,r/=2}function a(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var h=-1;for(o=r;ou&&(r=u-f),o=r;o>=0;o--){for(var c=!0,l=0;li&&(n=i):n=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function S(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function B(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:a>223?3:a>191?2:1;if(i+c<=r)switch(c){case 1:a<128&&(h=a);break;case 2:128==(192&(o=t[i+1]))&&(f=(31&a)<<6|63&o)>127&&(h=f);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(f=(15&a)<<12|(63&o)<<6|63&s)>2047&&(f<55296||f>57343)&&(h=f);break;case 4:o=t[i+1],s=t[i+2],u=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&u)&&(f=(15&a)<<18|(63&o)<<12|(63&s)<<6|63&u)>65535&&f<1114112&&(h=f)}null===h?(h=65533,c=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=c}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),""},f.prototype.compare=function(t,e,r,n,i){if(!f.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),u=Math.min(o,s),a=this.slice(n,i),h=t.slice(e,r),c=0;ci)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return E(this,t,e,r);case"utf8":case"utf-8":return v(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return A(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function L(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,r,n,i,o){if(!f.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function I(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);i>>8*(n?i:1-i)}function x(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);i>>8*(n?i:3-i)&255}function C(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Y(t,e,r,n,o){return o||C(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function k(t,e,r,n,o){return o||C(t,0,r,8),i.write(t,e,r,n,52,8),r+8}f.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(i*=256);)n+=this[t+--e]*i;return n},f.prototype.readUInt8=function(t,e){return e||U(t,1,this.length),this[t]},f.prototype.readUInt16LE=function(t,e){return e||U(t,2,this.length),this[t]|this[t+1]<<8},f.prototype.readUInt16BE=function(t,e){return e||U(t,2,this.length),this[t]<<8|this[t+1]},f.prototype.readUInt32LE=function(t,e){return e||U(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},f.prototype.readUInt32BE=function(t,e){return e||U(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},f.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||U(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},f.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||U(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},f.prototype.readInt8=function(t,e){return e||U(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},f.prototype.readInt16LE=function(t,e){e||U(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},f.prototype.readInt16BE=function(t,e){e||U(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},f.prototype.readInt32LE=function(t,e){return e||U(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},f.prototype.readInt32BE=function(t,e){return e||U(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},f.prototype.readFloatLE=function(t,e){return e||U(t,4,this.length),i.read(this,t,!0,23,4)},f.prototype.readFloatBE=function(t,e){return e||U(t,4,this.length),i.read(this,t,!1,23,4)},f.prototype.readDoubleLE=function(t,e){return e||U(t,8,this.length),i.read(this,t,!0,52,8)},f.prototype.readDoubleBE=function(t,e){return e||U(t,8,this.length),i.read(this,t,!1,52,8)},f.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||D(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+i]=t/o&255;return e+r},f.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,1,255,0),f.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},f.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},f.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},f.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):x(this,t,e,!0),e+4},f.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):x(this,t,e,!1),e+4},f.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);D(this,t,e,r,i-1,-i)}var o=0,s=1,u=0;for(this[e]=255&t;++o>0)-u&255;return e+r},f.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);D(this,t,e,r,i-1,-i)}var o=r-1,s=1,u=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===u&&0!==this[e+o+1]&&(u=1),this[e+o]=(t/s>>0)-u&255;return e+r},f.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,1,127,-128),f.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},f.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},f.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},f.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,2147483647,-2147483648),f.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):x(this,t,e,!0),e+4},f.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),f.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):x(this,t,e,!1),e+4},f.prototype.writeFloatLE=function(t,e,r){return Y(this,t,e,!0,r)},f.prototype.writeFloatBE=function(t,e,r){return Y(this,t,e,!1,r)},f.prototype.writeDoubleLE=function(t,e,r){return k(this,t,e,!0,r)},f.prototype.writeDoubleBE=function(t,e,r){return k(this,t,e,!1,r)},f.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else if(o<1e3||!f.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function H(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}}).call(this,r(5))},function(t,e,r){"use strict";e.byteLength=function(t){var e=a(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,n=a(t),s=n[0],u=n[1],f=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,u)),h=0,c=u>0?s-4:s;for(r=0;r>16&255,f[h++]=e>>8&255,f[h++]=255&e;2===u&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,f[h++]=255&e);1===u&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,f[h++]=e>>8&255,f[h++]=255&e);return f},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],s=0,u=r-i;su?u:s+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,f=s.length;u0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function h(t,e,r){for(var i,o,s=[],u=e;u>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,r,n,i){var o,s,u=8*i-n-1,f=(1<>1,h=-7,c=r?i-1:0,l=r?-1:1,p=t[e+c];for(c+=l,o=p&(1<<-h)-1,p>>=-h,h+=u;h>0;o=256*o+t[e+c],c+=l,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+t[e+c],c+=l,h-=8);if(0===o)o=1-a;else{if(o===f)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=a}return(p?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,u,f,a=8*o-i-1,h=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-s))<1&&(s--,f*=2),(e+=s+c>=1?l/f:l*Math.pow(2,1-c))*f>=2&&(s++,f/=2),s+c>=h?(u=0,s=h):s+c>=1?(u=(e*f-1)*Math.pow(2,i),s+=c):(u=e*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&u,p+=d,u/=256,i-=8);for(s=s<0;t[r+p]=255&s,p+=d,s/=256,a-=8);t[r+p-d]|=128*g}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e,r){(function(t){!function(t){function e(){}function r(t,e){if(t=void 0===t?"utf-8":t,e=void 0===e?{fatal:!1}:e,-1==n.indexOf(t.toLowerCase()))throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+t+"') is invalid.");if(e.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.")}if(t.TextEncoder&&t.TextDecoder)return!1;var n=["utf-8","utf8","unicode-1-1-utf-8"];Object.defineProperty(e.prototype,"encoding",{value:"utf-8"}),e.prototype.encode=function(t,e){if((e=void 0===e?{stream:!1}:e).stream)throw Error("Failed to encode: the 'stream' option is unsupported.");e=0;for(var r=t.length,n=0,i=Math.max(32,r+(r>>1)+7),o=new Uint8Array(i>>3<<3);e=s){if(e=s)continue}if(n+4>o.length&&(i+=8,i=(i*=1+e/t.length*2)>>3<<3,(u=new Uint8Array(i)).set(o),o=u),0==(4294967168&s))o[n++]=s;else{if(0==(4294965248&s))o[n++]=s>>6&31|192;else if(0==(4294901760&s))o[n++]=s>>12&15|224,o[n++]=s>>6&63|128;else{if(0!=(4292870144&s))continue;o[n++]=s>>18&7|240,o[n++]=s>>12&63|128,o[n++]=s>>6&63|128}o[n++]=63&s|128}}return o.slice?o.slice(0,n):o.subarray(0,n)},Object.defineProperty(r.prototype,"encoding",{value:"utf-8"}),Object.defineProperty(r.prototype,"fatal",{value:!1}),Object.defineProperty(r.prototype,"ignoreBOM",{value:!1}),r.prototype.decode=function(t,e){if((e=void 0===e?{stream:!1}:e).stream)throw Error("Failed to decode: the 'stream' option is unsupported.");t.buffer instanceof ArrayBuffer&&(t=t.buffer),t=new Uint8Array(t),e=0;for(var r=[],n=[];;){var i=e>>10&1023|55296),i=56320|1023&i),r.push(i)}}},t.TextEncoder=e,t.TextDecoder=r}("undefined"!=typeof window?window:void 0!==t?t:this)}).call(this,r(5))},function(t,e,r){r(2);t.exports={loginres:function(){},chatmsg:function(){},uenter:function(){},upgrade:function(){},rss:function(){},bc_buy_deserve:function(){},ssd:function(){},spbc:function(){},dgb:function(){},onlinegift:function(){},ggbb:function(){},rankup:function(){},ranklist:function(){},mrkl:function(){},erquizisn:function(){},blab:function(){},rri:function(){},synexp:function(){},noble_num_info:function(){},gbroadcast:function(){},qausrespond:function(){},wiru:function(){},wirt:function(){},mcspeacsite:function(){},rank_change:function(){},srres:function(){},anbc:function(){},frank:function(){}}},function(t,e){},function(t,e,r){"use strict";t.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}}]); \ No newline at end of file +!function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t){function n(){["Object","Array","String","Number","Boolean","Function","RegExp","Date","Undefined","Null","Symbol","Blob","ArrayBuffer"].forEach(e=>{this["is".concat(e)]=t=>Object.prototype.toString.call(t).slice(8,-1)===e})}n.prototype.isBrowser=()=>"undefined"!=typeof window,n.prototype.random=(e,t)=>Math.floor(Math.random()*(t-e+1)+e),n.prototype.download=function(e,t){if(this.isBrowser()){var n=document.createElement("a");n.style.display="none";var i=new Blob([t]);n.download="".concat(e,".log"),n.href=URL.createObjectURL(i),document.body.appendChild(n),n.click(),URL.revokeObjectURL(i),document.body.removeChild(n)}},e.exports=new n},function(e,t,n){"use strict";var i=n(8);i.stt=n(3),i.util=n(0),i.logger=n(6),i.Websocket=n(5),i.packet=n(4),e.exports=i},function(e,t,n){var i=8500+n(0).random(1,6),r="wss://danmuproxy.douyu.com:".concat(i,"/");e.exports={URL:r,HEARBEAT_INTERVAL:45,MSG_LIVE_ON:"主播正在直播",MSG_LIVE_OFF:"主播没有直播",MSG_ROOM_RSS:"房间开播提醒",MSG_BC_BUY_DESERVE:"赠送酬勤通知",MSG_SSD:"超级弹幕",MSG_ROOM_SPBC:"房间内礼物广播"}},function(e,t,n){var i=n(0);e.exports=new class{escape(e){return i.isUndefined(e)?"":e.toString().replace(/@/g,"@A").replace(/\//g,"@S")}unescape(e){return i.isUndefined(e)?"":e.toString().replace(/@A/g,"@").replace(/@S/g,"/")}serialize(e){return i.isObject(e)?Object.keys(e).map(t=>"".concat(t,"@=").concat(this.escape(this.serialize(e[t])),"/")).join(""):Array.isArray(e)?e.map(e=>"".concat(this.escape(this.serialize(e)),"/")).join(""):i.isString(e)||i.isNumber(e)?e.toString():void 0}deserialize(e){return e.includes("//")?e.split("//").filter(e=>""!==e).map(e=>this.deserialize(e)):e.includes("@=")?e.split("/").filter(e=>""!==e).reduce((e,t)=>{var[n,i]=t.split("@=");return e[n]=this.deserialize(this.unescape(i)),e},{}):e.includes("@A=")?this.deserialize(this.unescape(e)):e.toString()}}},function(e,t,n){n(10);n(0);e.exports=new class{constructor(){this.HEADER_LEN_SIZE=4,this.HEADER_LEN_TYPECODE=2,this.HEADER_LEN_ENCRYPT=1,this.HEADER_LEN_PLACEHOLDER=1,this.HEADER_LEN_TOTAL=2*this.HEADER_LEN_SIZE+this.HEADER_LEN_TYPECODE+this.HEADER_LEN_ENCRYPT+this.HEADER_LEN_PLACEHOLDER,this.encoder=new TextEncoder,this.decoder=new TextDecoder,this.buffer=new ArrayBuffer(0),this.readLength=0}concat(){for(var e=[],t=0;t0;){if(0===this.readLength){if(this.buffer.byteLength<4)return;this.readLength=new DataView(this.buffer).getUint32(0,!0),this.buffer=this.buffer.slice(4)}if(this.buffer.byteLength{var n=new FileReader;n.onload=function(e){t(e.target.result)},n.readAsArrayBuffer(e)})}Ab2blob(e){return new Blob([e])}}},function(e,t,n){var i=n(0);e.exports=i.isBrowser()?class{constructor(e){this.listener={},this.socket=new WebSocket(e)}send(e){this.socket.send(e)}close(e,t){this.socket.close(e,t)}on(e,t){var n=["open","error","close","message"].find(t=>t===e.toLocaleLowerCase());n&&(Object.keys(this.listener).includes(n)&&this.socket.removeEventListener(n,this.listener[n]),this.listener[n]=t,this.socket.addEventListener(n,t))}}:n(13)},function(e,t,n){function i(e,t,n,i,r,o,s){try{var a=e[o](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(i,r)}var r=n(0);e.exports=r.isBrowser()?class{constructor(){this.name="unknown",this.inited=!1,this.db=null,this.version=2}init(e){if(!this.inited){this.name=e;var t=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB;this.DB=t.open("danmaku",this.version),this.DB.addEventListener("success",e=>{console.log("连接数据库",event,e),this.db=e.target.result}),this.DB.addEventListener("upgradeneeded",e=>{console.log("升级数据库",event,e),this.db=e.target.result,this.db.createObjectStore("douyu",{keyPath:"id",autoIncrement:!0}).createIndex("idx_room_id","room_id",{unique:!1})}),this.DB.addEventListener("error",e=>{console.log("连接数据库出错 Error:",e)}),this.inited=!0}}echo(e){null!==this.db&&this.db.transaction("douyu","readwrite").objectStore("douyu").add({room_id:this.name,timestamp:(new Date).getTime(),frame:e})}all(e){if(null!==this.db){var t=this.db.transaction("douyu","readonly").objectStore("douyu"),n=e?t.index("idx_room_id").getAll(e):t.getAll();return new Promise((function(e,t){n.addEventListener("success",(function(t){e(t.target.result)})),n.addEventListener("error",(function(){t(!1)}))}))}}count(e){if(null!==this.db){var t=this.db.transaction("douyu","readonly").objectStore("douyu"),n=e?t.index("idx_room_id").count(e):t.count();return new Promise((function(e,t){n.addEventListener("success",(function(){e(n.result)})),n.addEventListener("error",(function(){t(!1)}))}))}}export(e){var t=this;return function(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){function s(e){i(c,r,o,s,a,"next",e)}function a(e){i(c,r,o,s,a,"throw",e)}var c=e.apply(t,n);s(void 0)}))}}((function*(){if(null!==t.db){var n=(yield t.all(e)).reduce((n,i)=>{var r={timestamp:i.timestamp,frame:i.frame};return e||(r.roomId=t.name),n.push(JSON.stringify(r)),n},[]);return r.download(t.name,n.join("\n")),n}}))()}clear(e){if(null!==this.db){var t=this.db.transaction("douyu","readwrite").objectStore("douyu");if(e){var n=t.index("idx_room_id").openCursor(IDBKeyRange.only(e));n.addEventListener("success",(function(){var e=n.result;e&&(e.delete(),e.continue())}))}else t.clear()}}}:n(14)},function(e,t,n){"use strict";n.r(t);var i=n(1),r=n.n(i);window.douyudanmaku=r.a,window.danmaku=r.a},function(e,t,n){var i=n(2),r=n(9),o=n(3),s=n(0),a=n(4),c=n(12);e.exports=class{constructor(e,t){this.roomId=e,this.ws=null,this.logger=null,this.heartbeatTask=null,this.messageEvent=c,this.ignore=[],this.options=this.setOptions(t||{}),this.clientEvent={connect:{name:"open",listener:r.open},disconnect:{name:"close",listener:r.close},error:{name:"error",listener:r.error}}}initSocket(e){this.ws=new e(i.URL),this.ws.on("open",this.clientEvent.connect.listener.bind(this)),this.ws.on("error",this.clientEvent.error.listener.bind(this)),this.ws.on("close",this.clientEvent.disconnect.listener.bind(this)),this.ws.on("message",r.message.bind(this))}send(e){this.ws.send(a.Encode(o.serialize(e)))}login(){this.send({type:"loginreq",roomid:this.roomId})}joinGroup(){this.send({type:"joingroup",rid:this.roomId,gid:0})}heartbeat(){this.heartbeatTask=setInterval(()=>{this.send({type:"mrkl"})},1e3*i.HEARBEAT_INTERVAL)}logout(){this.send({type:"logout"}),clearInterval(this.heartbeatTask)}run(e,t){var i=e||n(5),r=t||n(6);this.logger=new r,this.initSocket(i)}setIgnore(e,t){if(s.isObject(e))for(var n in e)e[n]&&this.ignore.push(n);else t&&this.ignore.push(e);return this}setOptions(e){var t={debug:!1,logfile:"".concat(this.roomId,".log")},n={};return s.isObject(e)?(e.hasOwnProperty("debug")&&s.isBoolean(e.debug)&&(n.debug=e.debug),e.hasOwnProperty("logfile")&&s.isString(e.logfile)&&(n.logfile=e.logfile),Object.assign(t,n)):t}messageHandle(e){a.Decode(e,e=>{var t=o.deserialize(e);this.options.debug&&(this.logger.init(s.isBrowser()?this.roomId:this.options.logfile),this.logger.echo(t)),Object.keys(this.messageEvent).filter(e=>!this.ignore.includes(e)).includes(t.type)&&this.messageEvent[t.type](t)})}on(e,t){var n=Object.keys(this.clientEvent).find(t=>t===e.toLocaleLowerCase());if(n){if("connect"===n){var i=t;t=function(e){this.login(),this.joinGroup(),this.heartbeat(),i.bind(this)(e)}}this.clientEvent[e].listener=t.bind(this)}Object.keys(this.messageEvent).find(t=>t===e.toLocaleLowerCase())&&(this.messageEvent[e]=t.bind(this))}}},function(e,t){e.exports={open:function(){this.login(),this.joinGroup(),this.heartbeat()},error:function(e){console.error(e)},close:function(){this.logout()},message:function(e){if("undefined"!=typeof MessageEvent){var t=new FileReader;t.onload=e=>this.messageHandle(e.target.result),t.readAsArrayBuffer(e.data)}else this.messageHandle(e)}}},function(e,t,n){(function(e){!function(e){function t(){}function n(e,t){if(e=void 0===e?"utf-8":e,t=void 0===t?{fatal:!1}:t,-1==i.indexOf(e.toLowerCase()))throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+e+"') is invalid.");if(t.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.")}if(e.TextEncoder&&e.TextDecoder)return!1;var i=["utf-8","utf8","unicode-1-1-utf-8"];Object.defineProperty(t.prototype,"encoding",{value:"utf-8"}),t.prototype.encode=function(e,t){if((t=void 0===t?{stream:!1}:t).stream)throw Error("Failed to encode: the 'stream' option is unsupported.");t=0;for(var n=e.length,i=0,r=Math.max(32,n+(n>>1)+7),o=new Uint8Array(r>>3<<3);t=s){if(t=s)continue}if(i+4>o.length&&(r+=8,r=(r*=1+t/e.length*2)>>3<<3,(a=new Uint8Array(r)).set(o),o=a),0==(4294967168&s))o[i++]=s;else{if(0==(4294965248&s))o[i++]=s>>6&31|192;else if(0==(4294901760&s))o[i++]=s>>12&15|224,o[i++]=s>>6&63|128;else{if(0!=(4292870144&s))continue;o[i++]=s>>18&7|240,o[i++]=s>>12&63|128,o[i++]=s>>6&63|128}o[i++]=63&s|128}}return o.slice?o.slice(0,i):o.subarray(0,i)},Object.defineProperty(n.prototype,"encoding",{value:"utf-8"}),Object.defineProperty(n.prototype,"fatal",{value:!1}),Object.defineProperty(n.prototype,"ignoreBOM",{value:!1}),n.prototype.decode=function(e,t){if((t=void 0===t?{stream:!1}:t).stream)throw Error("Failed to decode: the 'stream' option is unsupported.");e.buffer instanceof ArrayBuffer&&(e=e.buffer),e=new Uint8Array(e),t=0;for(var n=[],i=[];;){var r=t>>10&1023|55296),r=56320|1023&r),n.push(r)}}},e.TextEncoder=t,e.TextDecoder=n}("undefined"!=typeof window?window:void 0!==e?e:this)}).call(this,n(11))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){var i=n(2);e.exports={loginres:function(){},chatmsg:function(e){console.log(" [%s] %s",e.level+(e.level<10?" ":""),e.nn,e.txt)},uenter:function(e){console.log("欢迎").concat(e.nn,"进入了直播间"))},upgrade:function(){},rss:function(e){console.log("[开播提醒]",1==e.ss?i.MSG_LIVE_ON:i.MSG_LIVE_OFF)},bc_buy_deserve:function(){},ssd:function(){},spbc:function(e){console.log("------------- 感谢[".concat(e.sn,"] 赠送的 ").concat(e.gn,"x").concat(e.gc))},dgb:function(){},onlinegift:function(e){console.log("------------- [".concat(e.nn,"] 领取鱼丸x").concat(e.sil))},ggbb:function(){},rankup:function(){},ranklist:function(){},mrkl:function(){},erquizisn:function(){},blab:function(){},rri:function(){},synexp:function(){},noble_num_info:function(){},gbroadcast:function(){},qausrespond:function(){},wiru:function(){},wirt:function(){},mcspeacsite:function(){},rank_change:function(){},srres:function(){},anbc:function(){},frank:function(){}}},function(e,t,n){"use strict";e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},function(e,t,n){function i(e,t,n,i,r,o,s){try{var a=e[o](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(i,r)}var r=n(15);e.exports=class{constructor(){this.name="unknown",this.inited=!1}init(e){this.inited||(this.name=e,this.inited=!0)}echo(e){var t="".concat(JSON.stringify({timestamp:(new Date).getTime(),frame:e}),"\n");r.appendFile(this.name,t,(function(e){e&&console.error("日志保存出错, Error:",e)}))}all(){return new Promise((e,t)=>{r.readFile(this.name,"utf8",(function(n,i){n?t(n):e(i)}))})}count(){var e=this;return new Promise(function(){var t=function(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){function s(e){i(c,r,o,s,a,"next",e)}function a(e){i(c,r,o,s,a,"throw",e)}var c=e.apply(t,n);s(void 0)}))}}((function*(t){t((yield e.all()).split("\n").filter(e=>""!==e).length)}));return function(){return t.apply(this,arguments)}}())}export(){return r.readFileSync(this.name,"utf8")}clear(){try{return r.writeFileSync(this.name,"","utf8")}catch(e){return!1}}}},function(e,t){}]); \ No newline at end of file diff --git a/example/cli.js b/example/cli.js index 4a978a8..9bb52cf 100644 --- a/example/cli.js +++ b/example/cli.js @@ -1,9 +1,9 @@ //引入类库 -const douyudanmaku = require('../src/index') +const danmaku = require('../src/index') //设置房间号,初始化 const roomId = 102965 -const room = new douyudanmaku(roomId) +const room = new danmaku(roomId) //系统事件 room.on('connect', function () { @@ -12,18 +12,18 @@ room.on('connect', function () { room.on('disconnect', function () { console.log('[disconnect] roomId=%s', this.roomId) }) -room.on('error', function(err) { +room.on('error', function (err) { console.log('[error] roomId=%s', this.roomId) }) //消息事件 -room.on('chatmsg', function(res) { +room.on('chatmsg', function (res) { console.log('[chatmsg]', ` [${res.nn}] ${res.txt}`) }) -room.on('loginres', function(res) { +room.on('loginres', function (res) { console.log('[loginres]', '登录成功') }) -room.on('uenter', function(res) { +room.on('uenter', function (res) { console.log('[uenter]', `${res.nn}进入房间`) }) diff --git a/example/web/index.html b/example/web/index.html index 70161c1..8fb2107 100644 --- a/example/web/index.html +++ b/example/web/index.html @@ -5,7 +5,7 @@ 演示页面 - +