1 | (function () {
|
2 | 'use strict';
|
3 |
|
4 | var babelHelpers = {};
|
5 | babelHelpers.typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
|
6 | return typeof obj;
|
7 | } : function (obj) {
|
8 | return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
9 | };
|
10 |
|
11 | babelHelpers.classCallCheck = function (instance, Constructor) {
|
12 | if (!(instance instanceof Constructor)) {
|
13 | throw new TypeError("Cannot call a class as a function");
|
14 | }
|
15 | };
|
16 |
|
17 | babelHelpers.createClass = function () {
|
18 | function defineProperties(target, props) {
|
19 | for (var i = 0; i < props.length; i++) {
|
20 | var descriptor = props[i];
|
21 | descriptor.enumerable = descriptor.enumerable || false;
|
22 | descriptor.configurable = true;
|
23 | if ("value" in descriptor) descriptor.writable = true;
|
24 | Object.defineProperty(target, descriptor.key, descriptor);
|
25 | }
|
26 | }
|
27 |
|
28 | return function (Constructor, protoProps, staticProps) {
|
29 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
30 | if (staticProps) defineProperties(Constructor, staticProps);
|
31 | return Constructor;
|
32 | };
|
33 | }();
|
34 |
|
35 | babelHelpers;
|
36 |
|
37 |
|
38 | var __commonjs_global = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : this;
|
39 | function __commonjs(fn, module) { return module = { exports: {} }, fn(module, module.exports, __commonjs_global), module.exports; }
|
40 |
|
41 | |
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | var csModClientid = function csModClientid() {
|
52 | var d = new Date().getTime();
|
53 | var uuid = 'client-xxxxxxxx'.replace(/[xy]/g, function (c) {
|
54 | var r = (d + Math.random() * 16) % 16 | 0;
|
55 | d = Math.floor(d / 16);
|
56 | return (c === 'x' ? r : r & 0x3 | 0x8).toString(16);
|
57 | });
|
58 | return uuid;
|
59 | };
|
60 |
|
61 | var msgpack_min = __commonjs(function (module, exports, global) {
|
62 | !function (t) {
|
63 | if ("object" == (typeof exports === "undefined" ? "undefined" : babelHelpers.typeof(exports)) && "undefined" != typeof module) module.exports = t();else if ("function" == typeof define && define.amd) define([], t);else {
|
64 | var r;r = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : this, r.msgpack = t();
|
65 | }
|
66 | }(function () {
|
67 | return function t(r, e, n) {
|
68 | function o(f, u) {
|
69 | if (!e[f]) {
|
70 | if (!r[f]) {
|
71 | var a = "function" == typeof require && require;if (!u && a) return a(f, !0);if (i) return i(f, !0);var s = new Error("Cannot find module '" + f + "'");throw s.code = "MODULE_NOT_FOUND", s;
|
72 | }var c = e[f] = { exports: {} };r[f][0].call(c.exports, function (t) {
|
73 | var e = r[f][1][t];return o(e ? e : t);
|
74 | }, c, c.exports, t, r, e, n);
|
75 | }return e[f].exports;
|
76 | }for (var i = "function" == typeof require && require, f = 0; f < n.length; f++) {
|
77 | o(n[f]);
|
78 | }return o;
|
79 | }({ 1: [function (t, r, e) {
|
80 | e.encode = t("./encode").encode, e.decode = t("./decode").decode, e.Encoder = t("./encoder").Encoder, e.Decoder = t("./decoder").Decoder, e.createCodec = t("./ext").createCodec, e.codec = t("./codec").codec;
|
81 | }, { "./codec": 3, "./decode": 6, "./decoder": 7, "./encode": 9, "./encoder": 10, "./ext": 13 }], 2: [function (t, r, e) {
|
82 | function n(t, r) {
|
83 | for (var e = this, n = r || 0, o = t.length, i = 0; o > i; i++) {
|
84 | var f = t.charCodeAt(i);128 > f ? e[n++] = f : 2048 > f ? (e[n++] = 192 | f >> 6, e[n++] = 128 | 63 & f) : (e[n++] = 224 | f >> 12, e[n++] = 128 | f >> 6 & 63, e[n++] = 128 | 63 & f);
|
85 | }return n - r;
|
86 | }function o(t, r) {
|
87 | var e = this,
|
88 | n = t - 0 || 0;r || (r = e.length);var o = r - t;o > s && (o = s);for (var i = []; r > n;) {
|
89 | for (var f = new Array(o), u = 0; o > u && r > n;) {
|
90 | var a = e[n++];a = 128 > a ? a : 224 > a ? (63 & a) << 6 | 63 & e[n++] : (63 & a) << 12 | (63 & e[n++]) << 6 | 63 & e[n++], f[u++] = a;
|
91 | }o > u && (f = f.slice(0, u)), i.push(String.fromCharCode.apply("", f));
|
92 | }return i.length > 1 ? i.join("") : i.length ? i.shift() : "";
|
93 | }function i(t) {
|
94 | var r = 0;return Array.prototype.forEach.call(t, function (t) {
|
95 | var e = t.charCodeAt(0);r += 128 > e ? 1 : 2048 > e ? 2 : 3;
|
96 | }), r;
|
97 | }function f(t, r, e, n) {
|
98 | var o;e || (e = 0), n || 0 === n || (n = this.length), r || (r = 0);var i = n - e;if (t === this && r > e && n > r) for (o = i - 1; o >= 0; o--) {
|
99 | t[o + r] = this[o + e];
|
100 | } else for (o = 0; i > o; o++) {
|
101 | t[o + r] = this[o + e];
|
102 | }return i;
|
103 | }function u(t, r) {
|
104 | for (var e = 7; e >= 0; e--) {
|
105 | this[r + e] = 255 & t, t /= 256;
|
106 | }
|
107 | }function a(t, r) {
|
108 | if (t > 0) return u.call(this, t, r);t++;for (var e = 7; e >= 0; e--) {
|
109 | this[r + e] = 255 & -t ^ 255, t /= 256;
|
110 | }
|
111 | }var s = 8192;e.writeString = n, e.readString = o, e.byteLength = i, e.copy = f, e.writeUint64BE = u, e.writeInt64BE = a;
|
112 | }, {}], 3: [function (t, r, e) {
|
113 | e.codec = { preset: t("./ext-preset").preset };
|
114 | }, { "./ext-preset": 12 }], 4: [function (t, r, e) {
|
115 | e.BUFFER_SHORTAGE = new Error("BUFFER_SHORTAGE");
|
116 | }, {}], 5: [function (t, r, e) {
|
117 | (function (r) {
|
118 | function n(t) {
|
119 | return this instanceof n ? (this.options = t || i, void (this.codec = this.options.codec || o)) : new n(t);
|
120 | }e.DecodeBuffer = n;var o = t("./ext-preset").preset,
|
121 | i = {};n.prototype.push = Array.prototype.push, n.prototype.read = Array.prototype.shift, n.prototype.append = function (t) {
|
122 | var e = this.offset ? this.buffer.slice(this.offset) : this.buffer;this.buffer = e ? r.concat([e, t]) : t, this.offset = 0;
|
123 | };
|
124 | }).call(this, t("buffer").Buffer);
|
125 | }, { "./ext-preset": 12, buffer: 22 }], 6: [function (t, r, e) {
|
126 | function n(t, r) {
|
127 | var e = new o(r);return e.append(t), n(e);
|
128 | }e.decode = n;var o = t("./decode-buffer").DecodeBuffer,
|
129 | n = t("./read-core").decode;
|
130 | }, { "./decode-buffer": 5, "./read-core": 15 }], 7: [function (t, r, e) {
|
131 | function n(t) {
|
132 | return this instanceof n ? void i.call(this, t) : new n(t);
|
133 | }e.Decoder = n;var o = t("event-lite"),
|
134 | i = t("./decode-buffer").DecodeBuffer,
|
135 | f = t("./read-core").decodeAsync;n.prototype = new i(), o.mixin(n.prototype), n.prototype.decode = function (t) {
|
136 | t && this.append(t), f(this);
|
137 | }, n.prototype.push = function (t) {
|
138 | this.emit("data", t);
|
139 | }, n.prototype.end = function (t) {
|
140 | this.decode(t), this.emit("end");
|
141 | };
|
142 | }, { "./decode-buffer": 5, "./read-core": 15, "event-lite": 25 }], 8: [function (t, r, e) {
|
143 | (function (r) {
|
144 | function n(t) {
|
145 | return this instanceof n ? (this.options = t || u, void (this.codec = this.options.codec || o)) : new n(t);
|
146 | }e.EncodeBuffer = n;var o = t("./ext-preset").preset,
|
147 | i = 2048,
|
148 | f = 65536,
|
149 | u = {};n.prototype.push = function (t) {
|
150 | var r = this.buffers || (this.buffers = []);r.push(t);
|
151 | }, n.prototype.read = function () {
|
152 | this.flush();var t = this.buffers;if (t) {
|
153 | var e = t.length > 1 ? r.concat(t) : t[0];return t.length = 0, e;
|
154 | }
|
155 | }, n.prototype.flush = function () {
|
156 | this.start < this.offset && (this.push(this.buffer.slice(this.start, this.offset)), this.start = this.offset);
|
157 | }, n.prototype.reserve = function (t) {
|
158 | if (!this.buffer) return this.alloc(t);var r = this.buffer.length;this.offset + t < r || (this.offset && this.flush(), this.alloc(Math.max(t, Math.min(2 * r, f))));
|
159 | }, n.prototype.alloc = function (t) {
|
160 | this.buffer = new r(t > i ? t : i), this.start = 0, this.offset = 0;
|
161 | }, n.prototype.send = function (t) {
|
162 | var r = this.offset + t.length;this.buffer && r < this.buffer.length ? (t.copy(this.buffer, this.offset), this.offset = r) : (this.flush(), this.push(t));
|
163 | };
|
164 | }).call(this, t("buffer").Buffer);
|
165 | }, { "./ext-preset": 12, buffer: 22 }], 9: [function (t, r, e) {
|
166 | function n(t, r) {
|
167 | var e = new o(r);return n(e, t), e.read();
|
168 | }e.encode = n;var n = t("./write-core").encode,
|
169 | o = t("./encode-buffer").EncodeBuffer;
|
170 | }, { "./encode-buffer": 8, "./write-core": 18 }], 10: [function (t, r, e) {
|
171 | function n(t) {
|
172 | return this instanceof n ? void f.call(this, t) : new n(t);
|
173 | }e.Encoder = n;var o = t("event-lite"),
|
174 | i = t("./write-core").encode,
|
175 | f = t("./encode-buffer").EncodeBuffer;n.prototype = new f(), o.mixin(n.prototype), n.prototype.encode = function (t) {
|
176 | i(this, t), this.emit("data", this.read());
|
177 | }, n.prototype.end = function (t) {
|
178 | arguments.length && this.encode(t), this.flush(), this.emit("end");
|
179 | };
|
180 | }, { "./encode-buffer": 8, "./write-core": 18, "event-lite": 25 }], 11: [function (t, r, e) {
|
181 | function n(t, r) {
|
182 | return this instanceof n ? (this.buffer = t, void (this.type = r)) : new n(t, r);
|
183 | }e.ExtBuffer = n;
|
184 | }, {}], 12: [function (t, r, e) {
|
185 | (function (r) {
|
186 | function n() {
|
187 | y.addExtPacker(14, Error, [a, g]), y.addExtPacker(1, EvalError, [a, g]), y.addExtPacker(2, RangeError, [a, g]), y.addExtPacker(3, ReferenceError, [a, g]), y.addExtPacker(4, SyntaxError, [a, g]), y.addExtPacker(5, TypeError, [a, g]), y.addExtPacker(6, URIError, [a, g]), y.addExtUnpacker(14, [v, s(Error)]), y.addExtUnpacker(1, [v, s(EvalError)]), y.addExtUnpacker(2, [v, s(RangeError)]), y.addExtUnpacker(3, [v, s(ReferenceError)]), y.addExtUnpacker(4, [v, s(SyntaxError)]), y.addExtUnpacker(5, [v, s(TypeError)]), y.addExtUnpacker(6, [v, s(URIError)]), y.addExtPacker(10, RegExp, [f, g]), y.addExtPacker(11, Boolean, [i, g]), y.addExtPacker(12, String, [i, g]), y.addExtPacker(13, Date, [Number, g]), y.addExtPacker(15, Number, [i, g]), y.addExtUnpacker(10, [v, u]), y.addExtUnpacker(11, [v, c(Boolean)]), y.addExtUnpacker(12, [v, c(String)]), y.addExtUnpacker(13, [v, c(Date)]), y.addExtUnpacker(15, [v, c(Number)]), "undefined" != typeof Uint8Array && (y.addExtPacker(17, Int8Array, o), y.addExtPacker(18, Uint8Array, o), y.addExtPacker(19, Int16Array, h), y.addExtPacker(20, Uint16Array, h), y.addExtPacker(21, Int32Array, h), y.addExtPacker(22, Uint32Array, h), y.addExtPacker(23, Float32Array, h), y.addExtUnpacker(17, c(Int8Array)), y.addExtUnpacker(18, c(Uint8Array)), y.addExtUnpacker(19, [l, c(Int16Array)]), y.addExtUnpacker(20, [l, c(Uint16Array)]), y.addExtUnpacker(21, [l, c(Int32Array)]), y.addExtUnpacker(22, [l, c(Uint32Array)]), y.addExtUnpacker(23, [l, c(Float32Array)]), "undefined" != typeof Float64Array && (y.addExtPacker(24, Float64Array, h), y.addExtUnpacker(24, [l, c(Float64Array)])), "undefined" != typeof Uint8ClampedArray && (y.addExtPacker(25, Uint8ClampedArray, o), y.addExtUnpacker(25, c(Uint8ClampedArray))), y.addExtPacker(26, ArrayBuffer, p), y.addExtPacker(29, DataView, h), y.addExtUnpacker(26, l), y.addExtUnpacker(29, [l, c(DataView)]));
|
188 | }function o(t) {
|
189 | return new r(t);
|
190 | }function i(t) {
|
191 | return t.valueOf();
|
192 | }function f(t) {
|
193 | t = RegExp.prototype.toString.call(t).split("/"), t.shift();var r = [t.pop()];return r.unshift(t.join("/")), r;
|
194 | }function u(t) {
|
195 | return RegExp.apply(null, t);
|
196 | }function a(t) {
|
197 | var r = {};for (var e in E) {
|
198 | r[e] = t[e];
|
199 | }return r;
|
200 | }function s(t) {
|
201 | return function (r) {
|
202 | var e = new t();for (var n in E) {
|
203 | e[n] = r[n];
|
204 | }return e;
|
205 | };
|
206 | }function c(t) {
|
207 | return function (r) {
|
208 | return new t(r);
|
209 | };
|
210 | }function h(t) {
|
211 | return new r(new Uint8Array(t.buffer));
|
212 | }function p(t) {
|
213 | return new r(new Uint8Array(t));
|
214 | }function l(t) {
|
215 | return new Uint8Array(t).buffer;
|
216 | }var d = t("./ext").Ext,
|
217 | y = e.preset = new d(),
|
218 | g = t("./encode").encode,
|
219 | v = t("./decode").decode,
|
220 | E = { name: 1, message: 1, stack: 1, columnNumber: 1, fileName: 1, lineNumber: 1 };n();
|
221 | }).call(this, t("buffer").Buffer);
|
222 | }, { "./decode": 6, "./encode": 9, "./ext": 13, buffer: 22 }], 13: [function (t, r, e) {
|
223 | function n() {
|
224 | return this instanceof n ? (this.extPackers = {}, void (this.extUnpackers = [])) : new n();
|
225 | }function o() {
|
226 | return new n();
|
227 | }function i(t) {
|
228 | function r(t, r) {
|
229 | return r(t);
|
230 | }return t = t.slice(), function (e) {
|
231 | return t.reduce(r, e);
|
232 | };
|
233 | }e.Ext = n, e.createCodec = o;var f = t("./ext-buffer").ExtBuffer,
|
234 | u = t("./is-array");n.prototype.addExtPacker = function (t, r, e) {
|
235 | function n(r) {
|
236 | var n = e(r);return new f(n, t);
|
237 | }u(e) && (e = i(e));var o = r.name;if (o && "Object" !== o) this.extPackers[o] = n;else {
|
238 | var a = this.extEncoderList || (this.extEncoderList = []);a.unshift([r, n]);
|
239 | }
|
240 | }, n.prototype.addExtUnpacker = function (t, r) {
|
241 | this.extUnpackers[t] = u(r) ? i(r) : r;
|
242 | }, n.prototype.getExtPacker = function (t) {
|
243 | var r = t.constructor,
|
244 | e = r && r.name && this.extPackers[r.name];if (e) return e;var n = this.extEncoderList;if (n) for (var o = n.length, i = 0; o > i; i++) {
|
245 | var f = n[i];if (r === f[0]) return f[1];
|
246 | }
|
247 | }, n.prototype.getExtUnpacker = function (t) {
|
248 | function r(r) {
|
249 | return new f(r, t);
|
250 | }return this.extUnpackers[t] || r;
|
251 | };
|
252 | }, { "./ext-buffer": 11, "./is-array": 14 }], 14: [function (t, r, e) {
|
253 | r.exports = Array.isArray || function (t) {
|
254 | return "[object Array]" === Object.prototype.toString.call(t);
|
255 | };
|
256 | }, {}], 15: [function (t, r, e) {
|
257 | function n(t) {
|
258 | var r = i(t),
|
259 | e = f[r];if (!e) throw new Error("Invalid type: " + (r ? "0x" + r.toString(16) : r));return e(t);
|
260 | }function o(t) {
|
261 | for (; t.offset < t.buffer.length;) {
|
262 | var r,
|
263 | e = t.offset;try {
|
264 | r = n(t);
|
265 | } catch (o) {
|
266 | if (o !== u) throw o;t.offset = e;break;
|
267 | }t.push(r);
|
268 | }
|
269 | }e.decode = n, e.decodeAsync = o;var i = t("./read-format").format.uint8,
|
270 | f = t("./read-token").token,
|
271 | u = t("./common").BUFFER_SHORTAGE;
|
272 | }, { "./common": 4, "./read-format": 16, "./read-token": 17 }], 16: [function (t, r, e) {
|
273 | (function (r) {
|
274 | function n(t, r) {
|
275 | var e,
|
276 | n = {},
|
277 | o = new Array(r),
|
278 | i = new Array(r);for (e = 0; r > e; e++) {
|
279 | o[e] = E(t), i[e] = E(t);
|
280 | }for (e = 0; r > e; e++) {
|
281 | n[o[e]] = i[e];
|
282 | }return n;
|
283 | }function o(t, r) {
|
284 | for (var e = new Array(r), n = 0; r > n; n++) {
|
285 | e[n] = E(t);
|
286 | }return e;
|
287 | }function i(t, e) {
|
288 | var n = t.offset,
|
289 | o = t.offset = n + e,
|
290 | i = t.buffer;if (o > i.length) throw w;return x || !r.isBuffer(i) ? v.readString.call(i, n, o) : i.toString("utf-8", n, o);
|
291 | }function f(t, r) {
|
292 | var e = t.offset,
|
293 | n = t.offset = e + r;if (n > t.buffer.length) throw w;return y.call(t.buffer, e, n);
|
294 | }function u(t, r) {
|
295 | var e = t.offset,
|
296 | n = t.offset = e + r + 1;if (n > t.buffer.length) throw w;var o = t.buffer[e],
|
297 | i = t.codec.getExtUnpacker(o);if (!i) throw new Error("Invalid ext type: " + (o ? "0x" + o.toString(16) : o));var f = y.call(t.buffer, e + 1, n);return i(f);
|
298 | }function a(t) {
|
299 | var r = t.buffer;if (t.offset >= r.length) throw w;return r[t.offset++];
|
300 | }function s(t) {
|
301 | var r = t.buffer;if (t.offset + 2 > r.length) throw w;return r[t.offset++] << 8 | r[t.offset++];
|
302 | }function c(t, r) {
|
303 | return function (e) {
|
304 | var n = e.offset,
|
305 | o = e.offset = n + t;if (o > e.buffer.length) throw w;return r.call(e.buffer, n, U);
|
306 | };
|
307 | }function h(t, r) {
|
308 | var e = A.call(this, t, r),
|
309 | n = A.call(this, t + 4, r);return e ? 4294967296 * e + n : n;
|
310 | }function p(t, r) {
|
311 | var e = b.call(this, t, r),
|
312 | n = A.call(this, t + 4, r);return e ? 4294967296 * e + n : n;
|
313 | }function l(t) {
|
314 | return this.readFloatBE ? this.readFloatBE(t) : g.read(this, t, !1, 23, 4);
|
315 | }function d(t) {
|
316 | return this.readDoubleBE ? this.readDoubleBE(t) : g.read(this, t, !1, 52, 8);
|
317 | }function y(t, e) {
|
318 | var n = this.slice || Array.prototype.slice,
|
319 | o = n.call(this, t, e);return r.isBuffer(o) || (o = r(o)), o;
|
320 | }e.format = { map: n, array: o, str: i, bin: f, ext: u, uint8: a, uint16: s, uint32: c(4, r.prototype.readUInt32BE), uint64: c(8, h), int8: c(1, r.prototype.readInt8), int16: c(2, r.prototype.readInt16BE), int32: c(4, r.prototype.readInt32BE), int64: c(8, p), float32: c(4, l), float64: c(8, d) };var g = t("ieee754"),
|
321 | v = t("./buffer-lite"),
|
322 | E = t("./read-core").decode,
|
323 | w = t("./common").BUFFER_SHORTAGE,
|
324 | b = r.prototype.readInt32BE,
|
325 | A = r.prototype.readUInt32BE,
|
326 | x = "TYPED_ARRAY_SUPPORT" in r,
|
327 | U = !0;
|
328 | }).call(this, t("buffer").Buffer);
|
329 | }, { "./buffer-lite": 2, "./common": 4, "./read-core": 15, buffer: 22, ieee754: 26 }], 17: [function (t, r, e) {
|
330 | function n() {
|
331 | var t;for (t = 0; 127 >= t; t++) {
|
332 | u[t] = o(t);
|
333 | }for (t = 128; 143 >= t; t++) {
|
334 | u[t] = f(t - 128, a.map);
|
335 | }for (t = 144; 159 >= t; t++) {
|
336 | u[t] = f(t - 144, a.array);
|
337 | }for (t = 160; 191 >= t; t++) {
|
338 | u[t] = f(t - 160, a.str);
|
339 | }for (u[192] = o(null), u[193] = null, u[194] = o(!1), u[195] = o(!0), u[196] = i(a.uint8, a.bin), u[197] = i(a.uint16, a.bin), u[198] = i(a.uint32, a.bin), u[199] = i(a.uint8, a.ext), u[200] = i(a.uint16, a.ext), u[201] = i(a.uint32, a.ext), u[202] = a.float32, u[203] = a.float64, u[204] = a.uint8, u[205] = a.uint16, u[206] = a.uint32, u[207] = a.uint64, u[208] = a.int8, u[209] = a.int16, u[210] = a.int32, u[211] = a.int64, u[212] = f(1, a.ext), u[213] = f(2, a.ext), u[214] = f(4, a.ext), u[215] = f(8, a.ext), u[216] = f(16, a.ext), u[217] = i(a.uint8, a.str), u[218] = i(a.uint16, a.str), u[219] = i(a.uint32, a.str), u[220] = i(a.uint16, a.array), u[221] = i(a.uint32, a.array), u[222] = i(a.uint16, a.map), u[223] = i(a.uint32, a.map), t = 224; 255 >= t; t++) {
|
340 | u[t] = o(t - 256);
|
341 | }
|
342 | }function o(t) {
|
343 | return function () {
|
344 | return t;
|
345 | };
|
346 | }function i(t, r) {
|
347 | return function (e) {
|
348 | var n = t(e);return r(e, n);
|
349 | };
|
350 | }function f(t, r) {
|
351 | return function (e) {
|
352 | return r(e, t);
|
353 | };
|
354 | }var u = e.token = new Array(256),
|
355 | a = t("./read-format").format;n();
|
356 | }, { "./read-format": 16 }], 18: [function (t, r, e) {
|
357 | function n(t, r) {
|
358 | var e = o[typeof r === "undefined" ? "undefined" : babelHelpers.typeof(r)];if (!e) throw new Error('Unsupported type "' + (typeof r === "undefined" ? "undefined" : babelHelpers.typeof(r)) + '": ' + r);e(t, r);
|
359 | }e.encode = n;var o = t("./write-type").type;
|
360 | }, { "./write-type": 20 }], 19: [function (t, r, e) {
|
361 | (function (r) {
|
362 | function n() {
|
363 | for (var t = 0; 255 >= t; t++) {
|
364 | c[t] = p[t];
|
365 | }y ? i() : o();
|
366 | }function o() {
|
367 | c[196] = f(196), c[197] = u(197), c[198] = a(198), c[199] = f(199), c[200] = u(200), c[201] = a(201), c[202] = s(202, 4, r.prototype.writeFloatBE), c[203] = s(203, 8, r.prototype.writeDoubleBE), c[204] = f(204), c[205] = u(205), c[206] = a(206), c[207] = s(207, 8, h.writeUint64BE), c[208] = f(208), c[209] = u(209), c[210] = a(210), c[211] = s(211, 8, h.writeUint64BE), c[217] = f(217), c[218] = u(218), c[219] = a(219), c[220] = u(220), c[221] = a(221), c[222] = u(222), c[223] = a(223);
|
368 | }function i() {
|
369 | c[196] = s(196, 1, r.prototype.writeUInt8), c[197] = s(197, 2, r.prototype.writeUInt16BE), c[198] = s(198, 4, r.prototype.writeUInt32BE), c[199] = s(199, 1, r.prototype.writeUInt8), c[200] = s(200, 2, r.prototype.writeUInt16BE), c[201] = s(201, 4, r.prototype.writeUInt32BE), c[202] = s(202, 4, r.prototype.writeFloatBE), c[203] = s(203, 8, r.prototype.writeDoubleBE), c[204] = s(204, 1, r.prototype.writeUInt8), c[205] = s(205, 2, r.prototype.writeUInt16BE), c[206] = s(206, 4, r.prototype.writeUInt32BE), c[207] = s(207, 8, h.writeUint64BE), c[208] = s(208, 1, r.prototype.writeInt8), c[209] = s(209, 2, r.prototype.writeInt16BE), c[210] = s(210, 4, r.prototype.writeInt32BE), c[211] = s(211, 8, h.writeUint64BE), c[217] = s(217, 1, r.prototype.writeUInt8), c[218] = s(218, 2, r.prototype.writeUInt16BE), c[219] = s(219, 4, r.prototype.writeUInt32BE), c[220] = s(220, 2, r.prototype.writeUInt16BE), c[221] = s(221, 4, r.prototype.writeUInt32BE), c[222] = s(222, 2, r.prototype.writeUInt16BE), c[223] = s(223, 4, r.prototype.writeUInt32BE);
|
370 | }function f(t) {
|
371 | return function (r, e) {
|
372 | r.reserve(2);var n = r.buffer,
|
373 | o = r.offset;n[o++] = t, n[o++] = e, r.offset = o;
|
374 | };
|
375 | }function u(t) {
|
376 | return function (r, e) {
|
377 | r.reserve(3);var n = r.buffer,
|
378 | o = r.offset;n[o++] = t, n[o++] = e >>> 8, n[o++] = e, r.offset = o;
|
379 | };
|
380 | }function a(t) {
|
381 | return function (r, e) {
|
382 | r.reserve(5);var n = r.buffer,
|
383 | o = r.offset;n[o++] = t, n[o++] = e >>> 24, n[o++] = e >>> 16, n[o++] = e >>> 8, n[o++] = e, r.offset = o;
|
384 | };
|
385 | }function s(t, r, e) {
|
386 | return function (n, o) {
|
387 | n.reserve(r + 1), n.buffer[n.offset++] = t, e.call(n.buffer, o, n.offset, l), n.offset += r;
|
388 | };
|
389 | }var c = e.token = new Array(256),
|
390 | h = t("./buffer-lite"),
|
391 | p = t("./write-uint8").uint8,
|
392 | l = !0,
|
393 | d = "TYPED_ARRAY_SUPPORT" in r,
|
394 | y = d && !r.TYPED_ARRAY_SUPPORT;n();
|
395 | }).call(this, t("buffer").Buffer);
|
396 | }, { "./buffer-lite": 2, "./write-uint8": 21, buffer: 22 }], 20: [function (t, r, e) {
|
397 | (function (r) {
|
398 | function n(t, r) {
|
399 | var e = r ? 195 : 194;l[e](t, r);
|
400 | }function o(t, r) {
|
401 | var e,
|
402 | n = 0 | r;return r !== n ? (e = 203, void l[e](t, r)) : (e = n >= -32 && 127 >= n ? 255 & n : n >= 0 ? 255 >= n ? 204 : 65535 >= n ? 205 : 206 : n >= -128 ? 208 : n >= -32768 ? 209 : 210, void l[e](t, n));
|
403 | }function i(t, r) {
|
404 | var e = r.length,
|
405 | n = 5 + 3 * e;t.reserve(n);var o = 32 > e ? 1 : 255 >= e ? 2 : 65535 >= e ? 3 : 5,
|
406 | i = t.offset + o;e = p.writeString.call(t.buffer, r, i);var f = 32 > e ? 1 : 255 >= e ? 2 : 65535 >= e ? 3 : 5;if (o !== f) {
|
407 | var u = t.offset + f,
|
408 | a = i + e;v ? p.copy.call(t.buffer, t.buffer, u, i, a) : t.buffer.copy(t.buffer, u, i, a);
|
409 | }var s = 1 === f ? 160 + e : 3 >= f ? 215 + f : 219;l[s](t, e), t.offset += e;
|
410 | }function f(t, e) {
|
411 | if (E(e)) return a(t, e);if (null === e) return u(t, e);if (r.isBuffer(e)) return s(t, e);var n = t.codec.getExtPacker(e);return n && (e = n(e)), e instanceof g ? c(t, e) : void h(t, e);
|
412 | }function u(t, r) {
|
413 | var e = 192;l[e](t, r);
|
414 | }function a(t, r) {
|
415 | var e = r.length,
|
416 | n = 16 > e ? 144 + e : 65535 >= e ? 220 : 221;l[n](t, e);for (var o = 0; e > o; o++) {
|
417 | d(t, r[o]);
|
418 | }
|
419 | }function s(t, r) {
|
420 | var e = r.length,
|
421 | n = 255 > e ? 196 : 65535 >= e ? 197 : 198;l[n](t, e), t.send(r);
|
422 | }function c(t, r) {
|
423 | var e = r.buffer,
|
424 | n = e.length,
|
425 | o = w[n] || (255 > n ? 199 : 65535 >= n ? 200 : 201);l[o](t, n), y[r.type](t), t.send(e);
|
426 | }function h(t, r) {
|
427 | var e = Object.keys(r),
|
428 | n = e.length,
|
429 | o = 16 > n ? 128 + n : 65535 >= n ? 222 : 223;l[o](t, n), e.forEach(function (e) {
|
430 | d(t, e), d(t, r[e]);
|
431 | });
|
432 | }e.type = { "boolean": n, "function": u, number: o, object: f, string: i, symbol: u, undefined: u };var p = t("./buffer-lite"),
|
433 | l = t("./write-token").token,
|
434 | d = t("./write-core").encode,
|
435 | y = t("./write-uint8").uint8,
|
436 | g = t("./ext-buffer").ExtBuffer,
|
437 | v = "TYPED_ARRAY_SUPPORT" in r,
|
438 | E = t("./is-array"),
|
439 | w = [];w[1] = 212, w[2] = 213, w[4] = 214, w[8] = 215, w[16] = 216;
|
440 | }).call(this, t("buffer").Buffer);
|
441 | }, { "./buffer-lite": 2, "./ext-buffer": 11, "./is-array": 14, "./write-core": 18, "./write-token": 19, "./write-uint8": 21, buffer: 22 }], 21: [function (t, r, e) {
|
442 | function n(t) {
|
443 | return function (r) {
|
444 | r.reserve(1), r.buffer[r.offset++] = t;
|
445 | };
|
446 | }for (var o = e.uint8 = new Array(256), i = 0; 255 >= i; i++) {
|
447 | o[i] = n(i);
|
448 | }
|
449 | }, {}], 22: [function (t, r, e) {
|
450 | (function (r) {
|
451 | "use strict";
|
452 | function n() {
|
453 | try {
|
454 | var t = new Uint8Array(1);return t.foo = function () {
|
455 | return 42;
|
456 | }, 42 === t.foo() && "function" == typeof t.subarray && 0 === t.subarray(1, 1).byteLength;
|
457 | } catch (r) {
|
458 | return !1;
|
459 | }
|
460 | }function o() {
|
461 | return i.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823;
|
462 | }function i(t) {
|
463 | return this instanceof i ? (i.TYPED_ARRAY_SUPPORT || (this.length = 0, this.parent = void 0), "number" == typeof t ? f(this, t) : "string" == typeof t ? u(this, t, arguments.length > 1 ? arguments[1] : "utf8") : a(this, t)) : arguments.length > 1 ? new i(t, arguments[1]) : new i(t);
|
464 | }function f(t, r) {
|
465 | if (t = y(t, 0 > r ? 0 : 0 | g(r)), !i.TYPED_ARRAY_SUPPORT) for (var e = 0; r > e; e++) {
|
466 | t[e] = 0;
|
467 | }return t;
|
468 | }function u(t, r, e) {
|
469 | "string" == typeof e && "" !== e || (e = "utf8");var n = 0 | E(r, e);return t = y(t, n), t.write(r, e), t;
|
470 | }function a(t, r) {
|
471 | if (i.isBuffer(r)) return s(t, r);if (K(r)) return c(t, r);if (null == r) throw new TypeError("must start with number, buffer, array or string");if ("undefined" != typeof ArrayBuffer) {
|
472 | if (r.buffer instanceof ArrayBuffer) return h(t, r);if (r instanceof ArrayBuffer) return p(t, r);
|
473 | }return r.length ? l(t, r) : d(t, r);
|
474 | }function s(t, r) {
|
475 | var e = 0 | g(r.length);return t = y(t, e), r.copy(t, 0, 0, e), t;
|
476 | }function c(t, r) {
|
477 | var e = 0 | g(r.length);t = y(t, e);for (var n = 0; e > n; n += 1) {
|
478 | t[n] = 255 & r[n];
|
479 | }return t;
|
480 | }function h(t, r) {
|
481 | var e = 0 | g(r.length);t = y(t, e);for (var n = 0; e > n; n += 1) {
|
482 | t[n] = 255 & r[n];
|
483 | }return t;
|
484 | }function p(t, r) {
|
485 | return r.byteLength, i.TYPED_ARRAY_SUPPORT ? (t = new Uint8Array(r), t.__proto__ = i.prototype) : t = h(t, new Uint8Array(r)), t;
|
486 | }function l(t, r) {
|
487 | var e = 0 | g(r.length);t = y(t, e);for (var n = 0; e > n; n += 1) {
|
488 | t[n] = 255 & r[n];
|
489 | }return t;
|
490 | }function d(t, r) {
|
491 | var e,
|
492 | n = 0;"Buffer" === r.type && K(r.data) && (e = r.data, n = 0 | g(e.length)), t = y(t, n);for (var o = 0; n > o; o += 1) {
|
493 | t[o] = 255 & e[o];
|
494 | }return t;
|
495 | }function y(t, r) {
|
496 | i.TYPED_ARRAY_SUPPORT ? (t = new Uint8Array(r), t.__proto__ = i.prototype) : t.length = r;var e = 0 !== r && r <= i.poolSize >>> 1;return e && (t.parent = Q), t;
|
497 | }function g(t) {
|
498 | if (t >= o()) throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + o().toString(16) + " bytes");return 0 | t;
|
499 | }function v(t, r) {
|
500 | if (!(this instanceof v)) return new v(t, r);var e = new i(t, r);return delete e.parent, e;
|
501 | }function E(t, r) {
|
502 | "string" != typeof t && (t = "" + t);var e = t.length;if (0 === e) return 0;for (var n = !1;;) {
|
503 | switch (r) {case "ascii":case "binary":case "raw":case "raws":
|
504 | return e;case "utf8":case "utf-8":
|
505 | return z(t).length;case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":
|
506 | return 2 * e;case "hex":
|
507 | return e >>> 1;case "base64":
|
508 | return V(t).length;default:
|
509 | if (n) return z(t).length;r = ("" + r).toLowerCase(), n = !0;}
|
510 | }
|
511 | }function w(t, r, e) {
|
512 | var n = !1;if (r = 0 | r, e = void 0 === e || e === 1 / 0 ? this.length : 0 | e, t || (t = "utf8"), 0 > r && (r = 0), e > this.length && (e = this.length), r >= e) return "";for (;;) {
|
513 | switch (t) {case "hex":
|
514 | return T(this, r, e);case "utf8":case "utf-8":
|
515 | return m(this, r, e);case "ascii":
|
516 | return k(this, r, e);case "binary":
|
517 | return S(this, r, e);case "base64":
|
518 | return B(this, r, e);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":
|
519 | return I(this, r, e);default:
|
520 | if (n) throw new TypeError("Unknown encoding: " + t);t = (t + "").toLowerCase(), n = !0;}
|
521 | }
|
522 | }function b(t, r, e, n) {
|
523 | e = Number(e) || 0;var o = t.length - e;n ? (n = Number(n), n > o && (n = o)) : n = o;var i = r.length;if (i % 2 !== 0) throw new Error("Invalid hex string");n > i / 2 && (n = i / 2);for (var f = 0; n > f; f++) {
|
524 | var u = parseInt(r.substr(2 * f, 2), 16);if (isNaN(u)) throw new Error("Invalid hex string");t[e + f] = u;
|
525 | }return f;
|
526 | }function A(t, r, e, n) {
|
527 | return X(z(r, t.length - e), t, e, n);
|
528 | }function x(t, r, e, n) {
|
529 | return X(G(r), t, e, n);
|
530 | }function U(t, r, e, n) {
|
531 | return x(t, r, e, n);
|
532 | }function P(t, r, e, n) {
|
533 | return X(V(r), t, e, n);
|
534 | }function R(t, r, e, n) {
|
535 | return X(H(r, t.length - e), t, e, n);
|
536 | }function B(t, r, e) {
|
537 | return 0 === r && e === t.length ? J.fromByteArray(t) : J.fromByteArray(t.slice(r, e));
|
538 | }function m(t, r, e) {
|
539 | e = Math.min(t.length, e);for (var n = [], o = r; e > o;) {
|
540 | var i = t[o],
|
541 | f = null,
|
542 | u = i > 239 ? 4 : i > 223 ? 3 : i > 191 ? 2 : 1;if (e >= o + u) {
|
543 | var a, s, c, h;switch (u) {case 1:
|
544 | 128 > i && (f = i);break;case 2:
|
545 | a = t[o + 1], 128 === (192 & a) && (h = (31 & i) << 6 | 63 & a, h > 127 && (f = h));break;case 3:
|
546 | a = t[o + 1], s = t[o + 2], 128 === (192 & a) && 128 === (192 & s) && (h = (15 & i) << 12 | (63 & a) << 6 | 63 & s, h > 2047 && (55296 > h || h > 57343) && (f = h));break;case 4:
|
547 | a = t[o + 1], s = t[o + 2], c = t[o + 3], 128 === (192 & a) && 128 === (192 & s) && 128 === (192 & c) && (h = (15 & i) << 18 | (63 & a) << 12 | (63 & s) << 6 | 63 & c, h > 65535 && 1114112 > h && (f = h));}
|
548 | }null === f ? (f = 65533, u = 1) : f > 65535 && (f -= 65536, n.push(f >>> 10 & 1023 | 55296), f = 56320 | 1023 & f), n.push(f), o += u;
|
549 | }return _(n);
|
550 | }function _(t) {
|
551 | var r = t.length;if (W >= r) return String.fromCharCode.apply(String, t);for (var e = "", n = 0; r > n;) {
|
552 | e += String.fromCharCode.apply(String, t.slice(n, n += W));
|
553 | }return e;
|
554 | }function k(t, r, e) {
|
555 | var n = "";e = Math.min(t.length, e);for (var o = r; e > o; o++) {
|
556 | n += String.fromCharCode(127 & t[o]);
|
557 | }return n;
|
558 | }function S(t, r, e) {
|
559 | var n = "";e = Math.min(t.length, e);for (var o = r; e > o; o++) {
|
560 | n += String.fromCharCode(t[o]);
|
561 | }return n;
|
562 | }function T(t, r, e) {
|
563 | var n = t.length;(!r || 0 > r) && (r = 0), (!e || 0 > e || e > n) && (e = n);for (var o = "", i = r; e > i; i++) {
|
564 | o += q(t[i]);
|
565 | }return o;
|
566 | }function I(t, r, e) {
|
567 | for (var n = t.slice(r, e), o = "", i = 0; i < n.length; i += 2) {
|
568 | o += String.fromCharCode(n[i] + 256 * n[i + 1]);
|
569 | }return o;
|
570 | }function Y(t, r, e) {
|
571 | if (t % 1 !== 0 || 0 > t) throw new RangeError("offset is not uint");if (t + r > e) throw new RangeError("Trying to access beyond buffer length");
|
572 | }function D(t, r, e, n, o, f) {
|
573 | if (!i.isBuffer(t)) throw new TypeError("buffer must be a Buffer instance");if (r > o || f > r) throw new RangeError("value is out of bounds");if (e + n > t.length) throw new RangeError("index out of range");
|
574 | }function O(t, r, e, n) {
|
575 | 0 > r && (r = 65535 + r + 1);for (var o = 0, i = Math.min(t.length - e, 2); i > o; o++) {
|
576 | t[e + o] = (r & 255 << 8 * (n ? o : 1 - o)) >>> 8 * (n ? o : 1 - o);
|
577 | }
|
578 | }function C(t, r, e, n) {
|
579 | 0 > r && (r = 4294967295 + r + 1);for (var o = 0, i = Math.min(t.length - e, 4); i > o; o++) {
|
580 | t[e + o] = r >>> 8 * (n ? o : 3 - o) & 255;
|
581 | }
|
582 | }function M(t, r, e, n, o, i) {
|
583 | if (e + n > t.length) throw new RangeError("index out of range");if (0 > e) throw new RangeError("index out of range");
|
584 | }function L(t, r, e, n, o) {
|
585 | return o || M(t, r, e, 4, 3.4028234663852886e38, -3.4028234663852886e38), Z.write(t, r, e, n, 23, 4), e + 4;
|
586 | }function F(t, r, e, n, o) {
|
587 | return o || M(t, r, e, 8, 1.7976931348623157e308, -1.7976931348623157e308), Z.write(t, r, e, n, 52, 8), e + 8;
|
588 | }function N(t) {
|
589 | if (t = j(t).replace($, ""), t.length < 2) return "";for (; t.length % 4 !== 0;) {
|
590 | t += "=";
|
591 | }return t;
|
592 | }function j(t) {
|
593 | return t.trim ? t.trim() : t.replace(/^\s+|\s+$/g, "");
|
594 | }function q(t) {
|
595 | return 16 > t ? "0" + t.toString(16) : t.toString(16);
|
596 | }function z(t, r) {
|
597 | r = r || 1 / 0;for (var e, n = t.length, o = null, i = [], f = 0; n > f; f++) {
|
598 | if (e = t.charCodeAt(f), e > 55295 && 57344 > e) {
|
599 | if (!o) {
|
600 | if (e > 56319) {
|
601 | (r -= 3) > -1 && i.push(239, 191, 189);continue;
|
602 | }if (f + 1 === n) {
|
603 | (r -= 3) > -1 && i.push(239, 191, 189);continue;
|
604 | }o = e;continue;
|
605 | }if (56320 > e) {
|
606 | (r -= 3) > -1 && i.push(239, 191, 189), o = e;continue;
|
607 | }e = (o - 55296 << 10 | e - 56320) + 65536;
|
608 | } else o && (r -= 3) > -1 && i.push(239, 191, 189);if (o = null, 128 > e) {
|
609 | if ((r -= 1) < 0) break;i.push(e);
|
610 | } else if (2048 > e) {
|
611 | if ((r -= 2) < 0) break;i.push(e >> 6 | 192, 63 & e | 128);
|
612 | } else if (65536 > e) {
|
613 | if ((r -= 3) < 0) break;i.push(e >> 12 | 224, e >> 6 & 63 | 128, 63 & e | 128);
|
614 | } else {
|
615 | if (!(1114112 > e)) throw new Error("Invalid code point");if ((r -= 4) < 0) break;i.push(e >> 18 | 240, e >> 12 & 63 | 128, e >> 6 & 63 | 128, 63 & e | 128);
|
616 | }
|
617 | }return i;
|
618 | }function G(t) {
|
619 | for (var r = [], e = 0; e < t.length; e++) {
|
620 | r.push(255 & t.charCodeAt(e));
|
621 | }return r;
|
622 | }function H(t, r) {
|
623 | for (var e, n, o, i = [], f = 0; f < t.length && !((r -= 2) < 0); f++) {
|
624 | e = t.charCodeAt(f), n = e >> 8, o = e % 256, i.push(o), i.push(n);
|
625 | }return i;
|
626 | }function V(t) {
|
627 | return J.toByteArray(N(t));
|
628 | }function X(t, r, e, n) {
|
629 | for (var o = 0; n > o && !(o + e >= r.length || o >= t.length); o++) {
|
630 | r[o + e] = t[o];
|
631 | }return o;
|
632 | }var J = t("base64-js"),
|
633 | Z = t("ieee754"),
|
634 | K = t("isarray");e.Buffer = i, e.SlowBuffer = v, e.INSPECT_MAX_BYTES = 50, i.poolSize = 8192;var Q = {};i.TYPED_ARRAY_SUPPORT = void 0 !== r.TYPED_ARRAY_SUPPORT ? r.TYPED_ARRAY_SUPPORT : n(), i._augment = function (t) {
|
635 | return t.__proto__ = i.prototype, t;
|
636 | }, i.TYPED_ARRAY_SUPPORT ? (i.prototype.__proto__ = Uint8Array.prototype, i.__proto__ = Uint8Array, "undefined" != typeof Symbol && Symbol.species && i[Symbol.species] === i && Object.defineProperty(i, Symbol.species, { value: null, configurable: !0 })) : (i.prototype.length = void 0, i.prototype.parent = void 0), i.isBuffer = function (t) {
|
637 | return !(null == t || !t._isBuffer);
|
638 | }, i.compare = function (t, r) {
|
639 | if (!i.isBuffer(t) || !i.isBuffer(r)) throw new TypeError("Arguments must be Buffers");if (t === r) return 0;for (var e = t.length, n = r.length, o = 0, f = Math.min(e, n); f > o && t[o] === r[o];) {
|
640 | ++o;
|
641 | }return o !== f && (e = t[o], n = r[o]), n > e ? -1 : e > n ? 1 : 0;
|
642 | }, i.isEncoding = function (t) {
|
643 | switch (String(t).toLowerCase()) {case "hex":case "utf8":case "utf-8":case "ascii":case "binary":case "base64":case "raw":case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":
|
644 | return !0;default:
|
645 | return !1;}
|
646 | }, i.concat = function (t, r) {
|
647 | if (!K(t)) throw new TypeError("list argument must be an Array of Buffers.");if (0 === t.length) return new i(0);var e;if (void 0 === r) for (r = 0, e = 0; e < t.length; e++) {
|
648 | r += t[e].length;
|
649 | }var n = new i(r),
|
650 | o = 0;for (e = 0; e < t.length; e++) {
|
651 | var f = t[e];f.copy(n, o), o += f.length;
|
652 | }return n;
|
653 | }, i.byteLength = E, i.prototype._isBuffer = !0, i.prototype.toString = function () {
|
654 | var t = 0 | this.length;return 0 === t ? "" : 0 === arguments.length ? m(this, 0, t) : w.apply(this, arguments);
|
655 | }, i.prototype.equals = function (t) {
|
656 | if (!i.isBuffer(t)) throw new TypeError("Argument must be a Buffer");return this === t ? !0 : 0 === i.compare(this, t);
|
657 | }, i.prototype.inspect = function () {
|
658 | var t = "",
|
659 | r = e.INSPECT_MAX_BYTES;return this.length > 0 && (t = this.toString("hex", 0, r).match(/.{2}/g).join(" "), this.length > r && (t += " ... ")), "<Buffer " + t + ">";
|
660 | }, i.prototype.compare = function (t) {
|
661 | if (!i.isBuffer(t)) throw new TypeError("Argument must be a Buffer");return this === t ? 0 : i.compare(this, t);
|
662 | }, i.prototype.indexOf = function (t, r) {
|
663 | function e(t, r, e) {
|
664 | for (var n = -1, o = 0; e + o < t.length; o++) {
|
665 | if (t[e + o] === r[-1 === n ? 0 : o - n]) {
|
666 | if (-1 === n && (n = o), o - n + 1 === r.length) return e + n;
|
667 | } else n = -1;
|
668 | }return -1;
|
669 | }if (r > 2147483647 ? r = 2147483647 : -2147483648 > r && (r = -2147483648), r >>= 0, 0 === this.length) return -1;if (r >= this.length) return -1;if (0 > r && (r = Math.max(this.length + r, 0)), "string" == typeof t) return 0 === t.length ? -1 : String.prototype.indexOf.call(this, t, r);if (i.isBuffer(t)) return e(this, t, r);if ("number" == typeof t) return i.TYPED_ARRAY_SUPPORT && "function" === Uint8Array.prototype.indexOf ? Uint8Array.prototype.indexOf.call(this, t, r) : e(this, [t], r);throw new TypeError("val must be string, number or Buffer");
|
670 | }, i.prototype.write = function (t, r, e, n) {
|
671 | if (void 0 === r) n = "utf8", e = this.length, r = 0;else if (void 0 === e && "string" == typeof r) n = r, e = this.length, r = 0;else if (isFinite(r)) r = 0 | r, isFinite(e) ? (e = 0 | e, void 0 === n && (n = "utf8")) : (n = e, e = void 0);else {
|
672 | var o = n;n = r, r = 0 | e, e = o;
|
673 | }var i = this.length - r;if ((void 0 === e || e > i) && (e = i), t.length > 0 && (0 > e || 0 > r) || r > this.length) throw new RangeError("attempt to write outside buffer bounds");n || (n = "utf8");for (var f = !1;;) {
|
674 | switch (n) {case "hex":
|
675 | return b(this, t, r, e);case "utf8":case "utf-8":
|
676 | return A(this, t, r, e);case "ascii":
|
677 | return x(this, t, r, e);case "binary":
|
678 | return U(this, t, r, e);case "base64":
|
679 | return P(this, t, r, e);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":
|
680 | return R(this, t, r, e);default:
|
681 | if (f) throw new TypeError("Unknown encoding: " + n);n = ("" + n).toLowerCase(), f = !0;}
|
682 | }
|
683 | }, i.prototype.toJSON = function () {
|
684 | return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) };
|
685 | };var W = 4096;i.prototype.slice = function (t, r) {
|
686 | var e = this.length;t = ~ ~t, r = void 0 === r ? e : ~ ~r, 0 > t ? (t += e, 0 > t && (t = 0)) : t > e && (t = e), 0 > r ? (r += e, 0 > r && (r = 0)) : r > e && (r = e), t > r && (r = t);var n;if (i.TYPED_ARRAY_SUPPORT) n = this.subarray(t, r), n.__proto__ = i.prototype;else {
|
687 | var o = r - t;n = new i(o, void 0);for (var f = 0; o > f; f++) {
|
688 | n[f] = this[f + t];
|
689 | }
|
690 | }return n.length && (n.parent = this.parent || this), n;
|
691 | }, i.prototype.readUIntLE = function (t, r, e) {
|
692 | t = 0 | t, r = 0 | r, e || Y(t, r, this.length);for (var n = this[t], o = 1, i = 0; ++i < r && (o *= 256);) {
|
693 | n += this[t + i] * o;
|
694 | }return n;
|
695 | }, i.prototype.readUIntBE = function (t, r, e) {
|
696 | t = 0 | t, r = 0 | r, e || Y(t, r, this.length);for (var n = this[t + --r], o = 1; r > 0 && (o *= 256);) {
|
697 | n += this[t + --r] * o;
|
698 | }return n;
|
699 | }, i.prototype.readUInt8 = function (t, r) {
|
700 | return r || Y(t, 1, this.length), this[t];
|
701 | }, i.prototype.readUInt16LE = function (t, r) {
|
702 | return r || Y(t, 2, this.length), this[t] | this[t + 1] << 8;
|
703 | }, i.prototype.readUInt16BE = function (t, r) {
|
704 | return r || Y(t, 2, this.length), this[t] << 8 | this[t + 1];
|
705 | }, i.prototype.readUInt32LE = function (t, r) {
|
706 | return r || Y(t, 4, this.length), (this[t] | this[t + 1] << 8 | this[t + 2] << 16) + 16777216 * this[t + 3];
|
707 | }, i.prototype.readUInt32BE = function (t, r) {
|
708 | return r || Y(t, 4, this.length), 16777216 * this[t] + (this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3]);
|
709 | }, i.prototype.readIntLE = function (t, r, e) {
|
710 | t = 0 | t, r = 0 | r, e || Y(t, r, this.length);for (var n = this[t], o = 1, i = 0; ++i < r && (o *= 256);) {
|
711 | n += this[t + i] * o;
|
712 | }return o *= 128, n >= o && (n -= Math.pow(2, 8 * r)), n;
|
713 | }, i.prototype.readIntBE = function (t, r, e) {
|
714 | t = 0 | t, r = 0 | r, e || Y(t, r, this.length);for (var n = r, o = 1, i = this[t + --n]; n > 0 && (o *= 256);) {
|
715 | i += this[t + --n] * o;
|
716 | }return o *= 128, i >= o && (i -= Math.pow(2, 8 * r)), i;
|
717 | }, i.prototype.readInt8 = function (t, r) {
|
718 | return r || Y(t, 1, this.length), 128 & this[t] ? -1 * (255 - this[t] + 1) : this[t];
|
719 | }, i.prototype.readInt16LE = function (t, r) {
|
720 | r || Y(t, 2, this.length);var e = this[t] | this[t + 1] << 8;return 32768 & e ? 4294901760 | e : e;
|
721 | }, i.prototype.readInt16BE = function (t, r) {
|
722 | r || Y(t, 2, this.length);var e = this[t + 1] | this[t] << 8;return 32768 & e ? 4294901760 | e : e;
|
723 | }, i.prototype.readInt32LE = function (t, r) {
|
724 | return r || Y(t, 4, this.length), this[t] | this[t + 1] << 8 | this[t + 2] << 16 | this[t + 3] << 24;
|
725 | }, i.prototype.readInt32BE = function (t, r) {
|
726 | return r || Y(t, 4, this.length), this[t] << 24 | this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3];
|
727 | }, i.prototype.readFloatLE = function (t, r) {
|
728 | return r || Y(t, 4, this.length), Z.read(this, t, !0, 23, 4);
|
729 | }, i.prototype.readFloatBE = function (t, r) {
|
730 | return r || Y(t, 4, this.length), Z.read(this, t, !1, 23, 4);
|
731 | }, i.prototype.readDoubleLE = function (t, r) {
|
732 | return r || Y(t, 8, this.length), Z.read(this, t, !0, 52, 8);
|
733 | }, i.prototype.readDoubleBE = function (t, r) {
|
734 | return r || Y(t, 8, this.length), Z.read(this, t, !1, 52, 8);
|
735 | }, i.prototype.writeUIntLE = function (t, r, e, n) {
|
736 | t = +t, r = 0 | r, e = 0 | e, n || D(this, t, r, e, Math.pow(2, 8 * e), 0);var o = 1,
|
737 | i = 0;for (this[r] = 255 & t; ++i < e && (o *= 256);) {
|
738 | this[r + i] = t / o & 255;
|
739 | }return r + e;
|
740 | }, i.prototype.writeUIntBE = function (t, r, e, n) {
|
741 | t = +t, r = 0 | r, e = 0 | e, n || D(this, t, r, e, Math.pow(2, 8 * e), 0);var o = e - 1,
|
742 | i = 1;for (this[r + o] = 255 & t; --o >= 0 && (i *= 256);) {
|
743 | this[r + o] = t / i & 255;
|
744 | }return r + e;
|
745 | }, i.prototype.writeUInt8 = function (t, r, e) {
|
746 | return t = +t, r = 0 | r, e || D(this, t, r, 1, 255, 0), i.TYPED_ARRAY_SUPPORT || (t = Math.floor(t)), this[r] = 255 & t, r + 1;
|
747 | }, i.prototype.writeUInt16LE = function (t, r, e) {
|
748 | return t = +t, r = 0 | r, e || D(this, t, r, 2, 65535, 0), i.TYPED_ARRAY_SUPPORT ? (this[r] = 255 & t, this[r + 1] = t >>> 8) : O(this, t, r, !0), r + 2;
|
749 | }, i.prototype.writeUInt16BE = function (t, r, e) {
|
750 | return t = +t, r = 0 | r, e || D(this, t, r, 2, 65535, 0), i.TYPED_ARRAY_SUPPORT ? (this[r] = t >>> 8, this[r + 1] = 255 & t) : O(this, t, r, !1), r + 2;
|
751 | }, i.prototype.writeUInt32LE = function (t, r, e) {
|
752 | return t = +t, r = 0 | r, e || D(this, t, r, 4, 4294967295, 0), i.TYPED_ARRAY_SUPPORT ? (this[r + 3] = t >>> 24, this[r + 2] = t >>> 16, this[r + 1] = t >>> 8, this[r] = 255 & t) : C(this, t, r, !0), r + 4;
|
753 | }, i.prototype.writeUInt32BE = function (t, r, e) {
|
754 | return t = +t, r = 0 | r, e || D(this, t, r, 4, 4294967295, 0), i.TYPED_ARRAY_SUPPORT ? (this[r] = t >>> 24, this[r + 1] = t >>> 16, this[r + 2] = t >>> 8, this[r + 3] = 255 & t) : C(this, t, r, !1), r + 4;
|
755 | }, i.prototype.writeIntLE = function (t, r, e, n) {
|
756 | if (t = +t, r = 0 | r, !n) {
|
757 | var o = Math.pow(2, 8 * e - 1);D(this, t, r, e, o - 1, -o);
|
758 | }var i = 0,
|
759 | f = 1,
|
760 | u = 0 > t ? 1 : 0;for (this[r] = 255 & t; ++i < e && (f *= 256);) {
|
761 | this[r + i] = (t / f >> 0) - u & 255;
|
762 | }return r + e;
|
763 | }, i.prototype.writeIntBE = function (t, r, e, n) {
|
764 | if (t = +t, r = 0 | r, !n) {
|
765 | var o = Math.pow(2, 8 * e - 1);D(this, t, r, e, o - 1, -o);
|
766 | }var i = e - 1,
|
767 | f = 1,
|
768 | u = 0 > t ? 1 : 0;for (this[r + i] = 255 & t; --i >= 0 && (f *= 256);) {
|
769 | this[r + i] = (t / f >> 0) - u & 255;
|
770 | }return r + e;
|
771 | }, i.prototype.writeInt8 = function (t, r, e) {
|
772 | return t = +t, r = 0 | r, e || D(this, t, r, 1, 127, -128), i.TYPED_ARRAY_SUPPORT || (t = Math.floor(t)), 0 > t && (t = 255 + t + 1), this[r] = 255 & t, r + 1;
|
773 | }, i.prototype.writeInt16LE = function (t, r, e) {
|
774 | return t = +t, r = 0 | r, e || D(this, t, r, 2, 32767, -32768), i.TYPED_ARRAY_SUPPORT ? (this[r] = 255 & t, this[r + 1] = t >>> 8) : O(this, t, r, !0), r + 2;
|
775 | }, i.prototype.writeInt16BE = function (t, r, e) {
|
776 | return t = +t, r = 0 | r, e || D(this, t, r, 2, 32767, -32768), i.TYPED_ARRAY_SUPPORT ? (this[r] = t >>> 8, this[r + 1] = 255 & t) : O(this, t, r, !1), r + 2;
|
777 | }, i.prototype.writeInt32LE = function (t, r, e) {
|
778 | return t = +t, r = 0 | r, e || D(this, t, r, 4, 2147483647, -2147483648), i.TYPED_ARRAY_SUPPORT ? (this[r] = 255 & t, this[r + 1] = t >>> 8, this[r + 2] = t >>> 16, this[r + 3] = t >>> 24) : C(this, t, r, !0), r + 4;
|
779 | }, i.prototype.writeInt32BE = function (t, r, e) {
|
780 | return t = +t, r = 0 | r, e || D(this, t, r, 4, 2147483647, -2147483648), 0 > t && (t = 4294967295 + t + 1), i.TYPED_ARRAY_SUPPORT ? (this[r] = t >>> 24, this[r + 1] = t >>> 16, this[r + 2] = t >>> 8, this[r + 3] = 255 & t) : C(this, t, r, !1), r + 4;
|
781 | }, i.prototype.writeFloatLE = function (t, r, e) {
|
782 | return L(this, t, r, !0, e);
|
783 | }, i.prototype.writeFloatBE = function (t, r, e) {
|
784 | return L(this, t, r, !1, e);
|
785 | }, i.prototype.writeDoubleLE = function (t, r, e) {
|
786 | return F(this, t, r, !0, e);
|
787 | }, i.prototype.writeDoubleBE = function (t, r, e) {
|
788 | return F(this, t, r, !1, e);
|
789 | }, i.prototype.copy = function (t, r, e, n) {
|
790 | if (e || (e = 0), n || 0 === n || (n = this.length), r >= t.length && (r = t.length), r || (r = 0), n > 0 && e > n && (n = e), n === e) return 0;if (0 === t.length || 0 === this.length) return 0;if (0 > r) throw new RangeError("targetStart out of bounds");if (0 > e || e >= this.length) throw new RangeError("sourceStart out of bounds");if (0 > n) throw new RangeError("sourceEnd out of bounds");n > this.length && (n = this.length), t.length - r < n - e && (n = t.length - r + e);var o,
|
791 | f = n - e;if (this === t && r > e && n > r) for (o = f - 1; o >= 0; o--) {
|
792 | t[o + r] = this[o + e];
|
793 | } else if (1e3 > f || !i.TYPED_ARRAY_SUPPORT) for (o = 0; f > o; o++) {
|
794 | t[o + r] = this[o + e];
|
795 | } else Uint8Array.prototype.set.call(t, this.subarray(e, e + f), r);return f;
|
796 | }, i.prototype.fill = function (t, r, e) {
|
797 | if (t || (t = 0), r || (r = 0), e || (e = this.length), r > e) throw new RangeError("end < start");if (e !== r && 0 !== this.length) {
|
798 | if (0 > r || r >= this.length) throw new RangeError("start out of bounds");if (0 > e || e > this.length) throw new RangeError("end out of bounds");var n;if ("number" == typeof t) for (n = r; e > n; n++) {
|
799 | this[n] = t;
|
800 | } else {
|
801 | var o = z(t.toString()),
|
802 | i = o.length;for (n = r; e > n; n++) {
|
803 | this[n] = o[n % i];
|
804 | }
|
805 | }return this;
|
806 | }
|
807 | };var $ = /[^+\/0-9A-Za-z-_]/g;
|
808 | }).call(this, "undefined" != typeof global ? global : "undefined" != typeof self ? self : "undefined" != typeof window ? window : {});
|
809 | }, { "base64-js": 23, ieee754: 26, isarray: 24 }], 23: [function (t, r, e) {
|
810 | !function (t) {
|
811 | "use strict";
|
812 | function r(t) {
|
813 | var r = c[t.charCodeAt(0)];return void 0 !== r ? r : -1;
|
814 | }function e(t) {
|
815 | function e(t) {
|
816 | a[c++] = t;
|
817 | }var n, o, i, f, u, a;if (t.length % 4 > 0) throw new Error("Invalid string. Length must be a multiple of 4");var s = t.length;u = "=" === t.charAt(s - 2) ? 2 : "=" === t.charAt(s - 1) ? 1 : 0, a = new h(3 * t.length / 4 - u), i = u > 0 ? t.length - 4 : t.length;var c = 0;for (n = 0, o = 0; i > n; n += 4, o += 3) {
|
818 | f = r(t.charAt(n)) << 18 | r(t.charAt(n + 1)) << 12 | r(t.charAt(n + 2)) << 6 | r(t.charAt(n + 3)), e((16711680 & f) >> 16), e((65280 & f) >> 8), e(255 & f);
|
819 | }return 2 === u ? (f = r(t.charAt(n)) << 2 | r(t.charAt(n + 1)) >> 4, e(255 & f)) : 1 === u && (f = r(t.charAt(n)) << 10 | r(t.charAt(n + 1)) << 4 | r(t.charAt(n + 2)) >> 2, e(f >> 8 & 255), e(255 & f)), a;
|
820 | }function n(t) {
|
821 | return s[t];
|
822 | }function o(t) {
|
823 | return n(t >> 18 & 63) + n(t >> 12 & 63) + n(t >> 6 & 63) + n(63 & t);
|
824 | }function i(t, r, e) {
|
825 | for (var n, i = [], f = r; e > f; f += 3) {
|
826 | n = (t[f] << 16) + (t[f + 1] << 8) + t[f + 2], i.push(o(n));
|
827 | }return i.join("");
|
828 | }function f(t) {
|
829 | var r,
|
830 | e,
|
831 | o,
|
832 | f = t.length % 3,
|
833 | u = "",
|
834 | a = [],
|
835 | s = 16383;for (r = 0, o = t.length - f; o > r; r += s) {
|
836 | a.push(i(t, r, r + s > o ? o : r + s));
|
837 | }switch (f) {case 1:
|
838 | e = t[t.length - 1], u += n(e >> 2), u += n(e << 4 & 63), u += "==";break;case 2:
|
839 | e = (t[t.length - 2] << 8) + t[t.length - 1], u += n(e >> 10), u += n(e >> 4 & 63), u += n(e << 2 & 63), u += "=";}return a.push(u), a.join("");
|
840 | }var u,
|
841 | a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
|
842 | s = [];for (u = 0; u < a.length; u++) {
|
843 | s[u] = a[u];
|
844 | }var c = [];for (u = 0; u < a.length; ++u) {
|
845 | c[a.charCodeAt(u)] = u;
|
846 | }c["-".charCodeAt(0)] = 62, c["_".charCodeAt(0)] = 63;var h = "undefined" != typeof Uint8Array ? Uint8Array : Array;t.toByteArray = e, t.fromByteArray = f;
|
847 | }("undefined" == typeof e ? this.base64js = {} : e);
|
848 | }, {}], 24: [function (t, r, e) {
|
849 | var n = {}.toString;r.exports = Array.isArray || function (t) {
|
850 | return "[object Array]" == n.call(t);
|
851 | };
|
852 | }, {}], 25: [function (t, r, e) {
|
853 | function n() {
|
854 | return this instanceof n ? void 0 : new n();
|
855 | }!function (t) {
|
856 | function e(t) {
|
857 | for (var r in s) {
|
858 | t[r] = s[r];
|
859 | }return t;
|
860 | }function n(t, r) {
|
861 | return u(this, t).push(r), this;
|
862 | }function o(t, r) {
|
863 | function e() {
|
864 | i.call(n, t, e), r.apply(this, arguments);
|
865 | }var n = this;return e.originalListener = r, u(n, t).push(e), n;
|
866 | }function i(t, r) {
|
867 | function e(t) {
|
868 | return t !== r && t.originalListener !== r;
|
869 | }var n,
|
870 | o = this;if (arguments.length) {
|
871 | if (r) {
|
872 | if (n = u(o, t, !0)) {
|
873 | if (n = n.filter(e), !n.length) return i.call(o, t);o[a][t] = n;
|
874 | }
|
875 | } else if (n = o[a], n && (delete n[t], !Object.keys(n).length)) return i.call(o);
|
876 | } else delete o[a];return o;
|
877 | }function f(t, r) {
|
878 | function e(t) {
|
879 | t.call(i);
|
880 | }function n(t) {
|
881 | t.call(i, r);
|
882 | }function o(t) {
|
883 | t.apply(i, s);
|
884 | }var i = this,
|
885 | f = u(i, t, !0);if (!f) return !1;var a = arguments.length;if (1 === a) f.forEach(e);else if (2 === a) f.forEach(n);else {
|
886 | var s = Array.prototype.slice.call(arguments, 1);f.forEach(o);
|
887 | }return !!f.length;
|
888 | }function u(t, r, e) {
|
889 | if (!e || t[a]) {
|
890 | var n = t[a] || (t[a] = {});return n[r] || (n[r] = []);
|
891 | }
|
892 | }"undefined" != typeof r && (r.exports = t);var a = "listeners",
|
893 | s = { on: n, once: o, off: i, emit: f };e(t.prototype), t.mixin = e;
|
894 | }(n);
|
895 | }, {}], 26: [function (t, r, e) {
|
896 | e.read = function (t, r, e, n, o) {
|
897 | var i,
|
898 | f,
|
899 | u = 8 * o - n - 1,
|
900 | a = (1 << u) - 1,
|
901 | s = a >> 1,
|
902 | c = -7,
|
903 | h = e ? o - 1 : 0,
|
904 | p = e ? -1 : 1,
|
905 | l = t[r + h];for (h += p, i = l & (1 << -c) - 1, l >>= -c, c += u; c > 0; i = 256 * i + t[r + h], h += p, c -= 8) {}for (f = i & (1 << -c) - 1, i >>= -c, c += n; c > 0; f = 256 * f + t[r + h], h += p, c -= 8) {}if (0 === i) i = 1 - s;else {
|
906 | if (i === a) return f ? NaN : (l ? -1 : 1) * (1 / 0);f += Math.pow(2, n), i -= s;
|
907 | }return (l ? -1 : 1) * f * Math.pow(2, i - n);
|
908 | }, e.write = function (t, r, e, n, o, i) {
|
909 | var f,
|
910 | u,
|
911 | a,
|
912 | s = 8 * i - o - 1,
|
913 | c = (1 << s) - 1,
|
914 | h = c >> 1,
|
915 | p = 23 === o ? Math.pow(2, -24) - Math.pow(2, -77) : 0,
|
916 | l = n ? 0 : i - 1,
|
917 | d = n ? 1 : -1,
|
918 | y = 0 > r || 0 === r && 0 > 1 / r ? 1 : 0;for (r = Math.abs(r), isNaN(r) || r === 1 / 0 ? (u = isNaN(r) ? 1 : 0, f = c) : (f = Math.floor(Math.log(r) / Math.LN2), r * (a = Math.pow(2, -f)) < 1 && (f--, a *= 2), r += f + h >= 1 ? p / a : p * Math.pow(2, 1 - h), r * a >= 2 && (f++, a /= 2), f + h >= c ? (u = 0, f = c) : f + h >= 1 ? (u = (r * a - 1) * Math.pow(2, o), f += h) : (u = r * Math.pow(2, h - 1) * Math.pow(2, o), f = 0)); o >= 8; t[e + l] = 255 & u, l += d, u /= 256, o -= 8) {}for (f = f << o | u, s += o; s > 0; t[e + l] = 255 & f, l += d, f /= 256, s -= 8) {}t[e + l - d] |= 128 * y;
|
919 | };
|
920 | }, {}] }, {}, [1])(1);
|
921 | });
|
922 | });
|
923 |
|
924 | var msgpack = (msgpack_min && typeof msgpack_min === 'object' && 'default' in msgpack_min ? msgpack_min['default'] : msgpack_min);
|
925 |
|
926 | |
927 |
|
928 |
|
929 |
|
930 |
|
931 |
|
932 |
|
933 |
|
934 |
|
935 | var csModStringify = function csModStringify(data, callback) {
|
936 | try {
|
937 | callback(msgpack.encode(data));
|
938 | } catch (e) {
|
939 | console.warn('attempted to send invalid data to the pubsub server.');
|
940 | }
|
941 | };
|
942 |
|
943 | |
944 |
|
945 |
|
946 |
|
947 |
|
948 |
|
949 |
|
950 |
|
951 | var csModPublish = function csModPublish(channel, data, privateKey, _this) {
|
952 |
|
953 | if (_this.connected) {
|
954 |
|
955 | _this.stringify({
|
956 | channel: channel,
|
957 | privateKey: privateKey,
|
958 | payload: data,
|
959 | metadata: {
|
960 | time: Date.now(),
|
961 | client: _this.client,
|
962 | commonName: _this.commonName,
|
963 | type: 'publish'
|
964 | }
|
965 | }, function (payload) {
|
966 |
|
967 | _this.socket.send(payload);
|
968 | });
|
969 | } else {
|
970 |
|
971 | console.warn('Failed to connect, attempting again in 1 second.');
|
972 | setTimeout(function () {
|
973 |
|
974 | _this.publish(channel, data, privateKey);
|
975 | }, 500);
|
976 | }
|
977 | };
|
978 |
|
979 | |
980 |
|
981 |
|
982 |
|
983 |
|
984 |
|
985 |
|
986 |
|
987 | var csModInfo = function csModInfo(channel, data, opts, _this) {
|
988 |
|
989 |
|
990 |
|
991 | var options = opts ? opts : {};
|
992 | var privateKey = options.privateKey ? options.privateKey : false;
|
993 |
|
994 |
|
995 | if (_this.connected) {
|
996 |
|
997 | _this.stringify({
|
998 | channel: channel,
|
999 | privateKey: privateKey,
|
1000 | payload: data,
|
1001 | metadata: {
|
1002 | time: Date.now(),
|
1003 | client: _this.client,
|
1004 | commonName: _this.commonName,
|
1005 | type: 'info'
|
1006 | }
|
1007 | }, function (payload) {
|
1008 |
|
1009 | _this.socket.send(payload);
|
1010 | });
|
1011 | } else {
|
1012 |
|
1013 | console.warn('Failed to connect, attempting again in 1 second.');
|
1014 | setTimeout(function () {
|
1015 |
|
1016 | _this.info(channel, data, opts);
|
1017 | }, 500);
|
1018 | }
|
1019 | };
|
1020 |
|
1021 | |
1022 |
|
1023 |
|
1024 |
|
1025 |
|
1026 |
|
1027 |
|
1028 |
|
1029 | var csModSubscribe = function csModSubscribe(channel, callback, opts, _this) {
|
1030 |
|
1031 |
|
1032 |
|
1033 | var options = opts ? opts : {};
|
1034 |
|
1035 | var privateKey = options.privateKey ? options.privateKey : false;
|
1036 |
|
1037 | if (_this.connected) {
|
1038 |
|
1039 | _this.stringify({
|
1040 | channel: channel,
|
1041 | privateKey: privateKey,
|
1042 | noself: options.noself ? options.noself : false,
|
1043 | secret: options.accessToken ? options.accessToken : false,
|
1044 | private: options.private ? options.private : false,
|
1045 | metadata: {
|
1046 | time: Date.now(),
|
1047 | client: _this.client,
|
1048 | commonName: _this.commonName,
|
1049 | type: 'subscribe'
|
1050 | }
|
1051 | }, function (payload) {
|
1052 |
|
1053 | _this.socket.send(payload);
|
1054 |
|
1055 |
|
1056 | _this.socket.onmessage = function (msg) {
|
1057 | var decodedMsg = msgpack.decode(new Uint8Array(msg.data));
|
1058 | if (decodedMsg.channel === channel) {
|
1059 | callback(decodedMsg);
|
1060 | }
|
1061 | };
|
1062 |
|
1063 |
|
1064 | window.onbeforeunload = function () {
|
1065 | _this.stringify({
|
1066 | channel: channel,
|
1067 | privateKey: privateKey,
|
1068 | metadata: {
|
1069 | time: Date.now(),
|
1070 | client: _this.client,
|
1071 | commonName: _this.commonName,
|
1072 | type: 'unsubscribe'
|
1073 | }
|
1074 | }, function (payload) {
|
1075 | _this.socket.send(payload);
|
1076 | });
|
1077 | };
|
1078 | });
|
1079 | } else {
|
1080 |
|
1081 | console.warn('Failed to connect, attempting again in 1 second.');
|
1082 | setTimeout(function () {
|
1083 |
|
1084 | _this.subscribe(channel, callback, opts);
|
1085 | }, 500);
|
1086 | }
|
1087 | };
|
1088 |
|
1089 | |
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 |
|
1095 |
|
1096 |
|
1097 | var csModDeny = function csModDeny(channel, client, secret, _this) {
|
1098 |
|
1099 | if (_this.connected) {
|
1100 |
|
1101 | _this.stringify({
|
1102 | channel: channel,
|
1103 | client: client,
|
1104 | secret: secret,
|
1105 | metadata: {
|
1106 | time: Date.now(),
|
1107 | client: _this.client,
|
1108 | commonName: _this.commonName,
|
1109 | type: 'deny'
|
1110 | }
|
1111 | }, function (payload) {
|
1112 |
|
1113 | _this.socket.send(payload);
|
1114 | });
|
1115 | } else {
|
1116 |
|
1117 | console.warn('Failed to connect, attempting again in 1 second.');
|
1118 | setTimeout(function () {
|
1119 |
|
1120 | _this.info(channel, data, opts);
|
1121 | }, 500);
|
1122 | }
|
1123 | };
|
1124 |
|
1125 | |
1126 |
|
1127 |
|
1128 |
|
1129 |
|
1130 |
|
1131 |
|
1132 |
|
1133 | var csModHistory = function csModHistory(channel, limit, opts, _this) {
|
1134 |
|
1135 |
|
1136 |
|
1137 | var options = opts ? opts : {};
|
1138 | var privateKey = options.privateKey ? options.privateKey : false;
|
1139 |
|
1140 |
|
1141 | if (_this.connected) {
|
1142 |
|
1143 | _this.stringify({
|
1144 | channel: channel,
|
1145 | privateKey: privateKey,
|
1146 | limit: limit,
|
1147 | metadata: {
|
1148 | time: Date.now(),
|
1149 | client: _this.client,
|
1150 | commonName: _this.commonName,
|
1151 | type: 'history'
|
1152 | }
|
1153 | }, function (payload) {
|
1154 |
|
1155 | _this.socket.send(payload);
|
1156 | });
|
1157 | } else {
|
1158 |
|
1159 | console.warn('Failed to connect, attempting again in 1 second.');
|
1160 | setTimeout(function () {
|
1161 |
|
1162 | _this.history(channel, limit, opts);
|
1163 | }, 500);
|
1164 | }
|
1165 | };
|
1166 |
|
1167 | |
1168 |
|
1169 |
|
1170 |
|
1171 |
|
1172 | var CatSnake = function () {
|
1173 | |
1174 |
|
1175 |
|
1176 |
|
1177 |
|
1178 |
|
1179 | function CatSnake(address, options) {
|
1180 | var _this = this;
|
1181 |
|
1182 | babelHelpers.classCallCheck(this, CatSnake);
|
1183 |
|
1184 | this.socket = new WebSocket(address);
|
1185 | this.socket.binaryType = 'arraybuffer';
|
1186 |
|
1187 | this.connected = false;
|
1188 |
|
1189 |
|
1190 | this.client = csModClientid();
|
1191 |
|
1192 | this.commonName = options.commonName ? options.commonName : config.defaultName;
|
1193 |
|
1194 |
|
1195 | this.socket.onopen = function (event) {
|
1196 | _this.connected = true;
|
1197 |
|
1198 |
|
1199 | window.onbeforeunload = function () {
|
1200 | _this.socket.close();
|
1201 | };
|
1202 | };
|
1203 | }
|
1204 |
|
1205 | babelHelpers.createClass(CatSnake, [{
|
1206 | key: 'stringify',
|
1207 | value: function stringify(data, callback) {
|
1208 | |
1209 |
|
1210 |
|
1211 |
|
1212 |
|
1213 |
|
1214 | return csModStringify(data, callback);
|
1215 | }
|
1216 |
|
1217 | |
1218 |
|
1219 |
|
1220 |
|
1221 |
|
1222 |
|
1223 |
|
1224 |
|
1225 | }, {
|
1226 | key: 'publish',
|
1227 | value: function publish(channel, data, privateKey) {
|
1228 | csModPublish(channel, data, privateKey, this);
|
1229 | }
|
1230 |
|
1231 | |
1232 |
|
1233 |
|
1234 |
|
1235 |
|
1236 |
|
1237 |
|
1238 |
|
1239 |
|
1240 | }, {
|
1241 | key: 'info',
|
1242 | value: function info(channel, data, opts) {
|
1243 | csModInfo(channel, data, opts, this);
|
1244 | }
|
1245 |
|
1246 | |
1247 |
|
1248 |
|
1249 |
|
1250 |
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 | }, {
|
1256 | key: 'history',
|
1257 | value: function history(channel, limit, opts) {
|
1258 | csModHistory(channel, limit, opts, this);
|
1259 | }
|
1260 |
|
1261 | |
1262 |
|
1263 |
|
1264 |
|
1265 |
|
1266 |
|
1267 |
|
1268 |
|
1269 |
|
1270 |
|
1271 |
|
1272 |
|
1273 |
|
1274 | }, {
|
1275 | key: 'subscribe',
|
1276 | value: function subscribe(channel, callback, opts) {
|
1277 | csModSubscribe(channel, callback, opts, this);
|
1278 | }
|
1279 |
|
1280 | |
1281 |
|
1282 |
|
1283 |
|
1284 |
|
1285 |
|
1286 |
|
1287 |
|
1288 | }, {
|
1289 | key: 'deny',
|
1290 | value: function deny(channel, client, secret) {
|
1291 | return csModDeny(channel, client, secret, this);
|
1292 | }
|
1293 |
|
1294 | |
1295 |
|
1296 |
|
1297 |
|
1298 |
|
1299 |
|
1300 |
|
1301 |
|
1302 | }, {
|
1303 | key: 'grant',
|
1304 | value: function grant(channel, client, secret) {
|
1305 | return cdModGrant(channel, client, secret, this);
|
1306 | }
|
1307 | }]);
|
1308 | return CatSnake;
|
1309 | }();
|
1310 |
|
1311 | }()); |
\ | No newline at end of file |