5782 lines
209 KiB
JavaScript
5782 lines
209 KiB
JavaScript
!function(t, i) {
|
|
"function" == typeof define && define.amd ? define([], function() {
|
|
(t.dcodeIO = t.dcodeIO || {}).Long = i()
|
|
}) : "function" == typeof require && "object" == typeof module && module && module.exports ? module.exports = i() : (t.dcodeIO = t.dcodeIO || {}).Long = i()
|
|
}(this, function() {
|
|
"use strict";
|
|
function e(t, i, r) {
|
|
this.low = 0 | t,
|
|
this.high = 0 | i,
|
|
this.unsigned = !!r
|
|
}
|
|
function c(t) {
|
|
return !0 === (t && t.t)
|
|
}
|
|
Object.defineProperty(e.prototype, "t", {
|
|
value: !0,
|
|
enumerable: !1,
|
|
configurable: !1
|
|
}),
|
|
e.isLong = c;
|
|
var s = {}
|
|
, o = {};
|
|
function t(t, i) {
|
|
var r, e, n;
|
|
return i ? (n = 0 <= (t >>>= 0) && t < 256) && (e = o[t]) ? e : (r = w(t, (0 | t) < 0 ? -1 : 0, !0),
|
|
n && (o[t] = r),
|
|
r) : (n = -128 <= (t |= 0) && t < 128) && (e = s[t]) ? e : (r = w(t, t < 0 ? -1 : 0, !1),
|
|
n && (s[t] = r),
|
|
r)
|
|
}
|
|
function g(t, i) {
|
|
if (isNaN(t) || !isFinite(t))
|
|
return i ? f : d;
|
|
if (i) {
|
|
if (t < 0)
|
|
return f;
|
|
if (n <= t)
|
|
return m
|
|
} else {
|
|
if (t <= -h)
|
|
return I;
|
|
if (h <= t + 1)
|
|
return b
|
|
}
|
|
return t < 0 ? g(-t, i).neg() : w(t % r | 0, t / r | 0, i)
|
|
}
|
|
function w(t, i, r) {
|
|
return new e(t,i,r)
|
|
}
|
|
e.fromInt = t,
|
|
e.fromNumber = g,
|
|
e.fromBits = w;
|
|
var a = Math.pow;
|
|
function u(t, i, r) {
|
|
if (0 === t.length)
|
|
throw Error("empty string");
|
|
if ("NaN" === t || "Infinity" === t || "+Infinity" === t || "-Infinity" === t)
|
|
return d;
|
|
if (i = "number" == typeof i ? (r = i,
|
|
!1) : !!i,
|
|
(r = r || 10) < 2 || 36 < r)
|
|
throw RangeError("radix");
|
|
var e;
|
|
if (0 < (e = t.indexOf("-")))
|
|
throw Error("interior hyphen");
|
|
if (0 === e)
|
|
return u(t.substring(1), i, r).neg();
|
|
for (var n = g(a(r, 8)), s = d, o = 0; o < t.length; o += 8)
|
|
var h = Math.min(8, t.length - o)
|
|
, f = parseInt(t.substring(o, o + h), r)
|
|
, s = (h < 8 ? (h = g(a(r, h)),
|
|
s.mul(h)) : s = s.mul(n)).add(g(f));
|
|
return s.unsigned = i,
|
|
s
|
|
}
|
|
function p(t) {
|
|
return t instanceof e ? t : "number" == typeof t ? g(t) : "string" == typeof t ? u(t) : w(t.low, t.high, t.unsigned)
|
|
}
|
|
e.fromString = u,
|
|
e.fromValue = p;
|
|
var r = 4294967296
|
|
, n = r * r
|
|
, h = n / 2
|
|
, v = t(1 << 24)
|
|
, d = t(0)
|
|
, f = (e.ZERO = d,
|
|
t(0, !0))
|
|
, l = (e.UZERO = f,
|
|
t(1))
|
|
, y = (e.ONE = l,
|
|
t(1, !0))
|
|
, E = (e.UONE = y,
|
|
t(-1))
|
|
, b = (e.NEG_ONE = E,
|
|
w(-1, 2147483647, !1))
|
|
, m = (e.MAX_VALUE = b,
|
|
w(-1, -1, !0))
|
|
, I = (e.MAX_UNSIGNED_VALUE = m,
|
|
w(0, -2147483648, !1))
|
|
, i = (e.MIN_VALUE = I,
|
|
e.prototype);
|
|
return i.toInt = function() {
|
|
return this.unsigned ? this.low >>> 0 : this.low
|
|
}
|
|
,
|
|
i.toNumber = function() {
|
|
return this.unsigned ? (this.high >>> 0) * r + (this.low >>> 0) : this.high * r + (this.low >>> 0)
|
|
}
|
|
,
|
|
i.toString = function(t) {
|
|
if ((t = t || 10) < 2 || 36 < t)
|
|
throw RangeError("radix");
|
|
if (this.isZero())
|
|
return "0";
|
|
var i, r;
|
|
if (this.isNegative())
|
|
return this.eq(I) ? (r = g(t),
|
|
r = (i = this.div(r)).mul(r).sub(this),
|
|
i.toString(t) + r.toInt().toString(t)) : "-" + this.neg().toString(t);
|
|
for (var e = g(a(t, 6), this.unsigned), n = this, s = ""; ; ) {
|
|
var o = n.div(e)
|
|
, h = (n.sub(o.mul(e)).toInt() >>> 0).toString(t);
|
|
if ((n = o).isZero())
|
|
return h + s;
|
|
for (; h.length < 6; )
|
|
h = "0" + h;
|
|
s = "" + h + s
|
|
}
|
|
}
|
|
,
|
|
i.getHighBits = function() {
|
|
return this.high
|
|
}
|
|
,
|
|
i.getHighBitsUnsigned = function() {
|
|
return this.high >>> 0
|
|
}
|
|
,
|
|
i.getLowBits = function() {
|
|
return this.low
|
|
}
|
|
,
|
|
i.getLowBitsUnsigned = function() {
|
|
return this.low >>> 0
|
|
}
|
|
,
|
|
i.getNumBitsAbs = function() {
|
|
if (this.isNegative())
|
|
return this.eq(I) ? 64 : this.neg().getNumBitsAbs();
|
|
for (var t = 0 != this.high ? this.high : this.low, i = 31; 0 < i && 0 == (t & 1 << i); i--)
|
|
;
|
|
return 0 != this.high ? i + 33 : i + 1
|
|
}
|
|
,
|
|
i.isZero = function() {
|
|
return 0 === this.high && 0 === this.low
|
|
}
|
|
,
|
|
i.isNegative = function() {
|
|
return !this.unsigned && this.high < 0
|
|
}
|
|
,
|
|
i.isPositive = function() {
|
|
return this.unsigned || 0 <= this.high
|
|
}
|
|
,
|
|
i.isOdd = function() {
|
|
return 1 == (1 & this.low)
|
|
}
|
|
,
|
|
i.isEven = function() {
|
|
return 0 == (1 & this.low)
|
|
}
|
|
,
|
|
i.equals = function(t) {
|
|
return c(t) || (t = p(t)),
|
|
(this.unsigned === t.unsigned || this.high >>> 31 != 1 || t.high >>> 31 != 1) && this.high === t.high && this.low === t.low
|
|
}
|
|
,
|
|
i.eq = i.equals,
|
|
i.notEquals = function(t) {
|
|
return !this.eq(t)
|
|
}
|
|
,
|
|
i.neq = i.notEquals,
|
|
i.lessThan = function(t) {
|
|
return this.comp(t) < 0
|
|
}
|
|
,
|
|
i.lt = i.lessThan,
|
|
i.lessThanOrEqual = function(t) {
|
|
return this.comp(t) <= 0
|
|
}
|
|
,
|
|
i.lte = i.lessThanOrEqual,
|
|
i.greaterThan = function(t) {
|
|
return 0 < this.comp(t)
|
|
}
|
|
,
|
|
i.gt = i.greaterThan,
|
|
i.greaterThanOrEqual = function(t) {
|
|
return 0 <= this.comp(t)
|
|
}
|
|
,
|
|
i.gte = i.greaterThanOrEqual,
|
|
i.compare = function(t) {
|
|
var i, r;
|
|
return c(t) || (t = p(t)),
|
|
this.eq(t) ? 0 : (i = this.isNegative(),
|
|
r = t.isNegative(),
|
|
i && !r ? -1 : !i && r ? 1 : this.unsigned ? t.high >>> 0 > this.high >>> 0 || t.high === this.high && t.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(t).isNegative() ? -1 : 1)
|
|
}
|
|
,
|
|
i.comp = i.compare,
|
|
i.negate = function() {
|
|
return !this.unsigned && this.eq(I) ? I : this.not().add(l)
|
|
}
|
|
,
|
|
i.neg = i.negate,
|
|
i.add = function(t) {
|
|
c(t) || (t = p(t));
|
|
var i = this.high >>> 16
|
|
, r = 65535 & this.high
|
|
, e = this.low >>> 16
|
|
, n = 65535 & this.low
|
|
, s = t.high >>> 16
|
|
, o = 65535 & t.high
|
|
, h = t.low >>> 16
|
|
, f = 0
|
|
, a = 0
|
|
, u = 0;
|
|
return a += (n = ((u += n + (65535 & t.low)) >>> 16) + (e + h)) >>> 16,
|
|
w((n &= 65535) << 16 | (u &= 65535), ((f += (a += r + o) >>> 16) + (i + s) & 65535) << 16 | (a &= 65535), this.unsigned)
|
|
}
|
|
,
|
|
i.subtract = function(t) {
|
|
return c(t) || (t = p(t)),
|
|
this.add(t.neg())
|
|
}
|
|
,
|
|
i.sub = i.subtract,
|
|
i.multiply = function(t) {
|
|
var i, r, e, n, s, o, h, f, a, u, l;
|
|
return this.isZero() || (t = c(t) ? t : p(t)).isZero() ? d : this.eq(I) ? t.isOdd() ? I : d : t.eq(I) ? this.isOdd() ? I : d : this.isNegative() ? t.isNegative() ? this.neg().mul(t.neg()) : this.neg().mul(t).neg() : t.isNegative() ? this.mul(t.neg()).neg() : this.lt(v) && t.lt(v) ? g(this.toNumber() * t.toNumber(), this.unsigned) : (i = this.high >>> 16,
|
|
r = 65535 & this.high,
|
|
e = this.low >>> 16,
|
|
n = 65535 & this.low,
|
|
s = t.high >>> 16,
|
|
o = 65535 & t.high,
|
|
h = t.low >>> 16,
|
|
l = (u = f = 0) + ((a = ((u += n * (t = 65535 & t.low)) >>> 16) + e * t) >>> 16) + ((a = (65535 & a) + n * h) >>> 16),
|
|
w((a &= 65535) << 16 | (u &= 65535), ((f += (l += r * t) >>> 16) + ((l = (65535 & l) + e * h) >>> 16) + ((l = (65535 & l) + n * o) >>> 16) + (i * t + r * h + e * o + n * s) & 65535) << 16 | (l &= 65535), this.unsigned))
|
|
}
|
|
,
|
|
i.mul = i.multiply,
|
|
i.divide = function(t) {
|
|
if ((t = c(t) ? t : p(t)).isZero())
|
|
throw Error("division by zero");
|
|
if (this.isZero())
|
|
return this.unsigned ? f : d;
|
|
var i, r;
|
|
if (this.unsigned) {
|
|
if ((t = t.unsigned ? t : t.toUnsigned()).gt(this))
|
|
return f;
|
|
if (t.gt(this.shru(1)))
|
|
return y;
|
|
r = f
|
|
} else {
|
|
if (this.eq(I))
|
|
return t.eq(l) || t.eq(E) ? I : t.eq(I) ? l : (e = this.shr(1).div(t).shl(1)).eq(d) ? t.isNegative() ? l : E : (i = this.sub(t.mul(e)),
|
|
e.add(i.div(t)));
|
|
if (t.eq(I))
|
|
return this.unsigned ? f : d;
|
|
if (this.isNegative())
|
|
return t.isNegative() ? this.neg().div(t.neg()) : this.neg().div(t).neg();
|
|
if (t.isNegative())
|
|
return this.div(t.neg()).neg();
|
|
r = d
|
|
}
|
|
for (i = this; i.gte(t); ) {
|
|
for (var e = Math.max(1, Math.floor(i.toNumber() / t.toNumber())), n = Math.ceil(Math.log(e) / Math.LN2), s = n <= 48 ? 1 : a(2, n - 48), o = g(e), h = o.mul(t); h.isNegative() || h.gt(i); )
|
|
h = (o = g(e -= s, this.unsigned)).mul(t);
|
|
o.isZero() && (o = l),
|
|
r = r.add(o),
|
|
i = i.sub(h)
|
|
}
|
|
return r
|
|
}
|
|
,
|
|
i.div = i.divide,
|
|
i.modulo = function(t) {
|
|
return c(t) || (t = p(t)),
|
|
this.sub(this.div(t).mul(t))
|
|
}
|
|
,
|
|
i.mod = i.modulo,
|
|
i.not = function() {
|
|
return w(~this.low, ~this.high, this.unsigned)
|
|
}
|
|
,
|
|
i.and = function(t) {
|
|
return c(t) || (t = p(t)),
|
|
w(this.low & t.low, this.high & t.high, this.unsigned)
|
|
}
|
|
,
|
|
i.or = function(t) {
|
|
return c(t) || (t = p(t)),
|
|
w(this.low | t.low, this.high | t.high, this.unsigned)
|
|
}
|
|
,
|
|
i.xor = function(t) {
|
|
return c(t) || (t = p(t)),
|
|
w(this.low ^ t.low, this.high ^ t.high, this.unsigned)
|
|
}
|
|
,
|
|
i.shiftLeft = function(t) {
|
|
return c(t) && (t = t.toInt()),
|
|
0 == (t &= 63) ? this : t < 32 ? w(this.low << t, this.high << t | this.low >>> 32 - t, this.unsigned) : w(0, this.low << t - 32, this.unsigned)
|
|
}
|
|
,
|
|
i.shl = i.shiftLeft,
|
|
i.shiftRight = function(t) {
|
|
return c(t) && (t = t.toInt()),
|
|
0 == (t &= 63) ? this : t < 32 ? w(this.low >>> t | this.high << 32 - t, this.high >> t, this.unsigned) : w(this.high >> t - 32, 0 <= this.high ? 0 : -1, this.unsigned)
|
|
}
|
|
,
|
|
i.shr = i.shiftRight,
|
|
i.shiftRightUnsigned = function(t) {
|
|
var i;
|
|
return c(t) && (t = t.toInt()),
|
|
0 == (t &= 63) ? this : (i = this.high,
|
|
t < 32 ? w(this.low >>> t | i << 32 - t, i >>> t, this.unsigned) : w(32 === t ? i : i >>> t - 32, 0, this.unsigned))
|
|
}
|
|
,
|
|
i.shru = i.shiftRightUnsigned,
|
|
i.toSigned = function() {
|
|
return this.unsigned ? w(this.low, this.high, !1) : this
|
|
}
|
|
,
|
|
i.toUnsigned = function() {
|
|
return this.unsigned ? this : w(this.low, this.high, !0)
|
|
}
|
|
,
|
|
i.toBytes = function(t) {
|
|
return t ? this.toBytesLE() : this.toBytesBE()
|
|
}
|
|
,
|
|
i.toBytesLE = function() {
|
|
var t = this.high
|
|
, i = this.low;
|
|
return [255 & i, i >>> 8 & 255, i >>> 16 & 255, i >>> 24 & 255, 255 & t, t >>> 8 & 255, t >>> 16 & 255, t >>> 24 & 255]
|
|
}
|
|
,
|
|
i.toBytesBE = function() {
|
|
var t = this.high
|
|
, i = this.low;
|
|
return [t >>> 24 & 255, t >>> 16 & 255, t >>> 8 & 255, 255 & t, i >>> 24 & 255, i >>> 16 & 255, i >>> 8 & 255, 255 & i]
|
|
}
|
|
,
|
|
e
|
|
}),
|
|
(Paho = "undefined" == typeof Paho ? {} : Paho).MQTT = function(o) {
|
|
function u(t, i) {
|
|
for (var r in t)
|
|
if (t.hasOwnProperty(r)) {
|
|
if (!i.hasOwnProperty(r)) {
|
|
var e = "Unknown property, " + r + ". Valid properties are:";
|
|
for (r in i)
|
|
i.hasOwnProperty(r) && (e = e + " " + r);
|
|
throw new Error(e)
|
|
}
|
|
if (typeof t[r] !== i[r])
|
|
throw new Error(p(c.INVALID_TYPE, [typeof t[r], r]))
|
|
}
|
|
}
|
|
function r(t, i) {
|
|
return function() {
|
|
return t.apply(i, arguments)
|
|
}
|
|
}
|
|
function w(t, i) {
|
|
for (var r in this.type = t,
|
|
i)
|
|
i.hasOwnProperty(r) && (this[r] = i[r])
|
|
}
|
|
var c = {
|
|
OK: {
|
|
code: 0,
|
|
text: "AMQJSC0000I OK."
|
|
},
|
|
CONNECT_TIMEOUT: {
|
|
code: 1,
|
|
text: "AMQJSC0001E Connect timed out."
|
|
},
|
|
SUBSCRIBE_TIMEOUT: {
|
|
code: 2,
|
|
text: "AMQJS0002E Subscribe timed out."
|
|
},
|
|
UNSUBSCRIBE_TIMEOUT: {
|
|
code: 3,
|
|
text: "AMQJS0003E Unsubscribe timed out."
|
|
},
|
|
PING_TIMEOUT: {
|
|
code: 4,
|
|
text: "AMQJS0004E Ping timed out."
|
|
},
|
|
INTERNAL_ERROR: {
|
|
code: 5,
|
|
text: "AMQJS0005E Internal error. Error Message: {0}, Stack trace: {1}"
|
|
},
|
|
CONNACK_RETURNCODE: {
|
|
code: 6,
|
|
text: "AMQJS0006E Bad Connack return code:{0} {1}."
|
|
},
|
|
SOCKET_ERROR: {
|
|
code: 7,
|
|
text: "AMQJS0007E Socket error:{0}."
|
|
},
|
|
SOCKET_CLOSE: {
|
|
code: 8,
|
|
text: "AMQJS0008I Socket closed."
|
|
},
|
|
MALFORMED_UTF: {
|
|
code: 9,
|
|
text: "AMQJS0009E Malformed UTF data:{0} {1} {2}."
|
|
},
|
|
UNSUPPORTED: {
|
|
code: 10,
|
|
text: "AMQJS0010E {0} is not supported by this browser."
|
|
},
|
|
INVALID_STATE: {
|
|
code: 11,
|
|
text: "AMQJS0011E Invalid state {0}."
|
|
},
|
|
INVALID_TYPE: {
|
|
code: 12,
|
|
text: "AMQJS0012E Invalid type {0} for {1}."
|
|
},
|
|
INVALID_ARGUMENT: {
|
|
code: 13,
|
|
text: "AMQJS0013E Invalid argument {0} for {1}."
|
|
},
|
|
UNSUPPORTED_OPERATION: {
|
|
code: 14,
|
|
text: "AMQJS0014E Unsupported operation."
|
|
},
|
|
INVALID_STORED_DATA: {
|
|
code: 15,
|
|
text: "AMQJS0015E Invalid data in local storage key={0} value={1}."
|
|
},
|
|
INVALID_MQTT_MESSAGE_TYPE: {
|
|
code: 16,
|
|
text: "AMQJS0016E Invalid MQTT message type {0}."
|
|
},
|
|
MALFORMED_UNICODE: {
|
|
code: 17,
|
|
text: "AMQJS0017E Malformed Unicode string:{0} {1}."
|
|
}
|
|
}
|
|
, g = {
|
|
0: "Connection Accepted",
|
|
1: "Connection Refused: unacceptable protocol version",
|
|
2: "Connection Refused: identifier rejected",
|
|
3: "Connection Refused: server unavailable",
|
|
4: "Connection Refused: bad user name or password",
|
|
5: "Connection Refused: not authorized"
|
|
}
|
|
, p = function(t, i) {
|
|
var r = t.text;
|
|
if (i)
|
|
for (var e, n, s, o = 0; o < i.length; o++)
|
|
0 < (s = r.indexOf(n = "{" + o + "}")) && (e = r.substring(0, s),
|
|
s = r.substring(s + n.length),
|
|
r = e + i[o] + s);
|
|
return r
|
|
}
|
|
, l = [0, 6, 77, 81, 73, 115, 100, 112, 3]
|
|
, v = [0, 4, 77, 81, 84, 84, 4];
|
|
function d(t, i, r) {
|
|
return i[r++] = t >> 8,
|
|
i[r++] = t % 256,
|
|
r
|
|
}
|
|
function y(t, i, r, e) {
|
|
return h(t, r, e = d(i, r, e)),
|
|
e + i
|
|
}
|
|
function E(t, i) {
|
|
return 256 * t[i] + t[i + 1]
|
|
}
|
|
function b(i, r) {
|
|
let e = 0;
|
|
for (let t = 0; t < 8; t++)
|
|
e = (e *= 256) + i[r + t];
|
|
return e
|
|
}
|
|
function m(t) {
|
|
for (var i = 0, r = 0; r < t.length; r++) {
|
|
var e = t.charCodeAt(r);
|
|
2047 < e ? (55296 <= e && e <= 56319 && (r++,
|
|
i++),
|
|
i += 3) : 127 < e ? i += 2 : i++
|
|
}
|
|
return i
|
|
}
|
|
function h(t, i, r) {
|
|
for (var e = r, n = 0; n < t.length; n++) {
|
|
var s = t.charCodeAt(n);
|
|
if (55296 <= s && s <= 56319) {
|
|
var o = t.charCodeAt(++n);
|
|
if (isNaN(o))
|
|
throw new Error(p(c.MALFORMED_UNICODE, [s, o]));
|
|
s = o - 56320 + (s - 55296 << 10) + 65536
|
|
}
|
|
s <= 127 ? i[e++] = s : (s <= 2047 ? i[e++] = s >> 6 & 31 | 192 : (s <= 65535 ? i[e++] = s >> 12 & 15 | 224 : (i[e++] = s >> 18 & 7 | 240,
|
|
i[e++] = s >> 12 & 63 | 128),
|
|
i[e++] = s >> 6 & 63 | 128),
|
|
i[e++] = 63 & s | 128)
|
|
}
|
|
}
|
|
function I(t, i, r) {
|
|
for (var e, n = "", s = i; s < i + r; ) {
|
|
var o = t[s++];
|
|
if (o < 128)
|
|
e = o;
|
|
else {
|
|
var h = t[s++] - 128;
|
|
if (h < 0)
|
|
throw new Error(p(c.MALFORMED_UTF, [o.toString(16), h.toString(16), ""]));
|
|
if (o < 224)
|
|
e = 64 * (o - 192) + h;
|
|
else {
|
|
var f = t[s++] - 128;
|
|
if (f < 0)
|
|
throw new Error(p(c.MALFORMED_UTF, [o.toString(16), h.toString(16), f.toString(16)]));
|
|
if (o < 240)
|
|
e = 4096 * (o - 224) + 64 * h + f;
|
|
else {
|
|
var a = t[s++] - 128;
|
|
if (a < 0)
|
|
throw new Error(p(c.MALFORMED_UTF, [o.toString(16), h.toString(16), f.toString(16), a.toString(16)]));
|
|
if (!(o < 248))
|
|
throw new Error(p(c.MALFORMED_UTF, [o.toString(16), h.toString(16), f.toString(16), a.toString(16)]));
|
|
e = 262144 * (o - 240) + 4096 * h + 64 * f + a
|
|
}
|
|
}
|
|
}
|
|
65535 < e && (e -= 65536,
|
|
n += String.fromCharCode(55296 + (e >> 10)),
|
|
e = 56320 + (1023 & e)),
|
|
n += String.fromCharCode(e)
|
|
}
|
|
return n
|
|
}
|
|
function e(t, i, r) {
|
|
this.i = t,
|
|
this.o = i,
|
|
this.h = 1e3 * r,
|
|
this.isReset = !1;
|
|
var e = new w(12).encode()
|
|
, n = function(t) {
|
|
return function() {
|
|
return s.apply(t)
|
|
}
|
|
}
|
|
, s = function() {
|
|
this.isReset ? (this.isReset = !1,
|
|
this.i.u("Pinger.doPing", "send PINGREQ"),
|
|
this.i.socket.send(e),
|
|
this.timeout = this.o.setTimeout(n(this), this.h)) : (this.i.u("Pinger.doPing", "Timed out"),
|
|
this.i.l(c.PING_TIMEOUT.code, p(c.PING_TIMEOUT)))
|
|
};
|
|
this.reset = function() {
|
|
this.isReset = !0,
|
|
this.o.clearTimeout(this.timeout),
|
|
0 < this.h && (this.timeout = setTimeout(n(this), this.h))
|
|
}
|
|
,
|
|
this.cancel = function() {
|
|
this.o.clearTimeout(this.timeout)
|
|
}
|
|
}
|
|
function n(t, i, r, e, n) {
|
|
var s, o, h;
|
|
this.o = i,
|
|
r = r || 30,
|
|
this.timeout = setTimeout((s = e,
|
|
o = t,
|
|
h = n,
|
|
function() {
|
|
return s.apply(o, h)
|
|
}
|
|
), 1e3 * r),
|
|
this.cancel = function() {
|
|
this.o.clearTimeout(this.timeout)
|
|
}
|
|
}
|
|
function T(t, i, r, e, n) {
|
|
if (!("WebSocket"in o && null !== o.WebSocket))
|
|
throw new Error(p(c.UNSUPPORTED, ["WebSocket"]));
|
|
if (!("localStorage"in o && null !== o.localStorage))
|
|
throw new Error(p(c.UNSUPPORTED, ["localStorage"]));
|
|
if (!("ArrayBuffer"in o && null !== o.ArrayBuffer))
|
|
throw new Error(p(c.UNSUPPORTED, ["ArrayBuffer"]));
|
|
for (var s in this.u("Paho.MQTT.Client", t, i, r, e, n),
|
|
this.host = i,
|
|
this.port = r,
|
|
this.path = e,
|
|
this.uri = t,
|
|
this.clientId = n,
|
|
this.g = i + ":" + r + ("/mqtt" != e ? ":" + e : "") + ":" + n + ":",
|
|
this.p = [],
|
|
this.v = {},
|
|
this.m = {},
|
|
this.I = {},
|
|
this.A = 1,
|
|
this.k = 0,
|
|
localStorage)
|
|
0 != s.indexOf("Sent:" + this.g) && 0 != s.indexOf("Received:" + this.g) || this.restore(s)
|
|
}
|
|
function t(t, i, o, r) {
|
|
if ("string" != typeof t)
|
|
throw new Error(p(c.INVALID_TYPE, [typeof t, "host"]));
|
|
if (2 == arguments.length) {
|
|
r = i;
|
|
var e = (h = t).match(/^(wss?):\/\/((\[(.+)\])|([^\/]+?))(:(\d+))?(\/.*)$/);
|
|
if (!e)
|
|
throw new Error(p(c.INVALID_ARGUMENT, [t, "host"]));
|
|
t = e[4] || e[2],
|
|
i = parseInt(e[7]),
|
|
o = e[8]
|
|
} else {
|
|
if (3 == arguments.length && (r = o,
|
|
o = "/mqtt"),
|
|
"number" != typeof i || i < 0)
|
|
throw new Error(p(c.INVALID_TYPE, [typeof i, "port"]));
|
|
if ("string" != typeof o)
|
|
throw new Error(p(c.INVALID_TYPE, [typeof o, "path"]));
|
|
var h = "ws://" + (-1 != t.indexOf(":") && "[" != t.slice(0, 1) && "]" != t.slice(-1) ? "[" + t + "]" : t) + ":" + i + o
|
|
}
|
|
for (var n = 0, s = 0; s < r.length; s++) {
|
|
var f = r.charCodeAt(s);
|
|
55296 <= f && f <= 56319 && s++,
|
|
n++
|
|
}
|
|
if ("string" != typeof r || 65535 < n)
|
|
throw new Error(p(c.INVALID_ARGUMENT, [r, "clientId"]));
|
|
var a = new T(h,t,i,o,r);
|
|
this.R = function() {
|
|
return t
|
|
}
|
|
,
|
|
this.O = function() {
|
|
throw new Error(p(c.UNSUPPORTED_OPERATION))
|
|
}
|
|
,
|
|
this.N = function() {
|
|
return i
|
|
}
|
|
,
|
|
this.M = function() {
|
|
throw new Error(p(c.UNSUPPORTED_OPERATION))
|
|
}
|
|
,
|
|
this.S = function() {
|
|
return o
|
|
}
|
|
,
|
|
this.j = function() {
|
|
throw new Error(p(c.UNSUPPORTED_OPERATION))
|
|
}
|
|
,
|
|
this.U = function() {
|
|
return h
|
|
}
|
|
,
|
|
this.C = function() {
|
|
throw new Error(p(c.UNSUPPORTED_OPERATION))
|
|
}
|
|
,
|
|
this._ = function() {
|
|
return a.clientId
|
|
}
|
|
,
|
|
this.B = function() {
|
|
throw new Error(p(c.UNSUPPORTED_OPERATION))
|
|
}
|
|
,
|
|
this.F = function() {
|
|
return a.onConnectionLost
|
|
}
|
|
,
|
|
this.L = function(t) {
|
|
if ("function" != typeof t)
|
|
throw new Error(p(c.INVALID_TYPE, [typeof t, "onConnectionLost"]));
|
|
a.onConnectionLost = t
|
|
}
|
|
,
|
|
this.P = function() {
|
|
return a.onMessageDelivered
|
|
}
|
|
,
|
|
this.$ = function(t) {
|
|
if ("function" != typeof t)
|
|
throw new Error(p(c.INVALID_TYPE, [typeof t, "onMessageDelivered"]));
|
|
a.onMessageDelivered = t
|
|
}
|
|
,
|
|
this.q = function() {
|
|
return a.onMessageArrived
|
|
}
|
|
,
|
|
this.J = function(t) {
|
|
if ("function" != typeof t)
|
|
throw new Error(p(c.INVALID_TYPE, [typeof t, "onMessageArrived"]));
|
|
a.onMessageArrived = t
|
|
}
|
|
,
|
|
this.V = function() {
|
|
return a.traceFunction
|
|
}
|
|
,
|
|
this.D = function(t) {
|
|
if ("function" != typeof t)
|
|
throw new Error(p(c.INVALID_TYPE, [typeof t, "onTrace"]));
|
|
a.traceFunction = t
|
|
}
|
|
,
|
|
this.connect = function(t) {
|
|
if (u(t = t || {}, {
|
|
timeout: "number",
|
|
userName: "string",
|
|
password: "string",
|
|
willMessage: "object",
|
|
keepAliveInterval: "number",
|
|
cleanSession: "boolean",
|
|
useSSL: "boolean",
|
|
invocationContext: "object",
|
|
onSuccess: "function",
|
|
onFailure: "function",
|
|
hosts: "object",
|
|
ports: "object",
|
|
mqttVersion: "number",
|
|
token: "string"
|
|
}),
|
|
void 0 === t.keepAliveInterval && (t.keepAliveInterval = 60),
|
|
4 < t.mqttVersion || t.mqttVersion < 3)
|
|
throw new Error(p(c.INVALID_ARGUMENT, [t.mqttVersion, "connectOptions.mqttVersion"]));
|
|
if (void 0 === t.mqttVersion ? (t.mqttVersionExplicit = !1,
|
|
t.mqttVersion = 4) : t.mqttVersionExplicit = !0,
|
|
void 0 === t.password && void 0 !== t.userName)
|
|
throw new Error(p(c.INVALID_ARGUMENT, [t.password, "connectOptions.password"]));
|
|
if (t.willMessage) {
|
|
if (!(t.willMessage instanceof A))
|
|
throw new Error(p(c.INVALID_TYPE, [t.willMessage, "connectOptions.willMessage"]));
|
|
if (t.willMessage.stringPayload,
|
|
void 0 === t.willMessage.destinationName)
|
|
throw new Error(p(c.INVALID_TYPE, [typeof t.willMessage.destinationName, "connectOptions.willMessage.destinationName"]))
|
|
}
|
|
if (void 0 === t.cleanSession && (t.cleanSession = !0),
|
|
t.hosts) {
|
|
if (!(t.hosts instanceof Array))
|
|
throw new Error(p(c.INVALID_ARGUMENT, [t.hosts, "connectOptions.hosts"]));
|
|
if (t.hosts.length < 1)
|
|
throw new Error(p(c.INVALID_ARGUMENT, [t.hosts, "connectOptions.hosts"]));
|
|
for (var i = !1, r = 0; r < t.hosts.length; r++) {
|
|
if ("string" != typeof t.hosts[r])
|
|
throw new Error(p(c.INVALID_TYPE, [typeof t.hosts[r], "connectOptions.hosts[" + r + "]"]));
|
|
if (/^(wss?):\/\/((\[(.+)\])|([^\/]+?))(:(\d+))?(\/.*)$/.test(t.hosts[r])) {
|
|
if (0 == r)
|
|
i = !0;
|
|
else if (!i)
|
|
throw new Error(p(c.INVALID_ARGUMENT, [t.hosts[r], "connectOptions.hosts[" + r + "]"]))
|
|
} else if (i)
|
|
throw new Error(p(c.INVALID_ARGUMENT, [t.hosts[r], "connectOptions.hosts[" + r + "]"]))
|
|
}
|
|
if (i)
|
|
t.uris = t.hosts;
|
|
else {
|
|
if (!t.ports)
|
|
throw new Error(p(c.INVALID_ARGUMENT, [t.ports, "connectOptions.ports"]));
|
|
if (!(t.ports instanceof Array))
|
|
throw new Error(p(c.INVALID_ARGUMENT, [t.ports, "connectOptions.ports"]));
|
|
if (t.hosts.length != t.ports.length)
|
|
throw new Error(p(c.INVALID_ARGUMENT, [t.ports, "connectOptions.ports"]));
|
|
for (t.uris = [],
|
|
r = 0; r < t.hosts.length; r++) {
|
|
if ("number" != typeof t.ports[r] || t.ports[r] < 0)
|
|
throw new Error(p(c.INVALID_TYPE, [typeof t.ports[r], "connectOptions.ports[" + r + "]"]));
|
|
var e = t.hosts[r]
|
|
, n = t.ports[r]
|
|
, s = -1 != e.indexOf(":");
|
|
h = "ws://" + (s ? "[" + e + "]" : e) + ":" + n + o,
|
|
t.uris.push(h)
|
|
}
|
|
}
|
|
}
|
|
a.connect(t)
|
|
}
|
|
,
|
|
this.subscribe = function(t, i) {
|
|
if ("string" != typeof t)
|
|
throw new Error("Invalid argument:" + t);
|
|
if (u(i = i || {}, {
|
|
qos: "number",
|
|
invocationContext: "object",
|
|
onSuccess: "function",
|
|
onFailure: "function",
|
|
timeout: "number"
|
|
}),
|
|
i.timeout && !i.onFailure)
|
|
throw new Error("subscribeOptions.timeout specified with no onFailure callback.");
|
|
if (void 0 !== i.qos && 0 !== i.qos && 1 !== i.qos && 2 !== i.qos)
|
|
throw new Error(p(c.INVALID_ARGUMENT, [i.qos, "subscribeOptions.qos"]));
|
|
a.subscribe(t, i)
|
|
}
|
|
,
|
|
this.unsubscribe = function(t, i) {
|
|
if ("string" != typeof t)
|
|
throw new Error("Invalid argument:" + t);
|
|
if (u(i = i || {}, {
|
|
invocationContext: "object",
|
|
onSuccess: "function",
|
|
onFailure: "function",
|
|
timeout: "number"
|
|
}),
|
|
i.timeout && !i.onFailure)
|
|
throw new Error("unsubscribeOptions.timeout specified with no onFailure callback.");
|
|
a.unsubscribe(t, i)
|
|
}
|
|
,
|
|
this.send = function(t, i, r, e) {
|
|
var n;
|
|
if (0 == arguments.length)
|
|
throw new Error("Invalid argument.length");
|
|
if (1 == arguments.length) {
|
|
if (!(t instanceof A) && "string" != typeof t)
|
|
throw new Error("Invalid argument:" + typeof t);
|
|
if (void 0 === (n = t).destinationName)
|
|
throw new Error(p(c.INVALID_ARGUMENT, [n.destinationName, "Message.destinationName"]))
|
|
} else
|
|
(n = new A(i)).destinationName = t,
|
|
3 <= arguments.length && (n.qos = r),
|
|
4 <= arguments.length && (n.retained = e);
|
|
a.send(n)
|
|
}
|
|
,
|
|
this.disconnect = function() {
|
|
a.disconnect()
|
|
}
|
|
,
|
|
this.getTraceLog = function() {
|
|
return a.getTraceLog()
|
|
}
|
|
,
|
|
this.startTrace = function() {
|
|
a.startTrace()
|
|
}
|
|
,
|
|
this.stopTrace = function() {
|
|
a.stopTrace()
|
|
}
|
|
,
|
|
this.isConnected = function() {
|
|
return a.connected
|
|
}
|
|
}
|
|
T.prototype.connected = !(w.prototype.encode = function() {
|
|
var t, i = (15 & this.type) << 4, r = 0, e = new Array, n = 0;
|
|
switch (null != this.messageIdentifier && (r += 2),
|
|
this.type) {
|
|
case 1:
|
|
switch (this.mqttVersion) {
|
|
case 3:
|
|
r += l.length + 3;
|
|
break;
|
|
case 4:
|
|
r += v.length + 3
|
|
}
|
|
r += m(this.clientId) + 2,
|
|
null != this.willMessage && (r = (r += m(this.willMessage.destinationName) + 2) + ((t = (t = this.willMessage.payloadBytes)instanceof Uint8Array ? t : new Uint8Array(o)).byteLength + 2)),
|
|
null != this.userName && (r += m(this.userName) + 2),
|
|
null != this.password && (r += m(this.password) + 2);
|
|
break;
|
|
case 8:
|
|
i |= 2;
|
|
for (var s = 0; s < this.topics.length; s++)
|
|
e[s] = m(this.topics[s]),
|
|
r += e[s] + 2;
|
|
r += this.requestedQos.length;
|
|
break;
|
|
case 10:
|
|
for (i |= 2,
|
|
s = 0; s < this.topics.length; s++)
|
|
e[s] = m(this.topics[s]),
|
|
r += e[s] + 2;
|
|
break;
|
|
case 6:
|
|
i |= 2;
|
|
break;
|
|
case 3:
|
|
this.payloadMessage.duplicate && (i |= 8),
|
|
i |= this.payloadMessage.qos << 1,
|
|
this.payloadMessage.retained && (i |= 1);
|
|
var n = m(this.payloadMessage.destinationName)
|
|
, o = this.payloadMessage.payloadBytes
|
|
, r = r + (n + 2) + o.byteLength;
|
|
o instanceof ArrayBuffer ? o = new Uint8Array(o) : o instanceof Uint8Array || (o = new Uint8Array(o.buffer))
|
|
}
|
|
var h = function(t) {
|
|
var i = new Array(1)
|
|
, r = 0;
|
|
do {
|
|
var e = t % 128
|
|
} while (0 < (t >>= 7) && (e |= 128),
|
|
i[r++] = e,
|
|
0 < t && r < 4);
|
|
return i
|
|
}(r)
|
|
, f = h.length + 1
|
|
, a = new ArrayBuffer(r + f)
|
|
, u = new Uint8Array(a);
|
|
if (u[0] = i,
|
|
u.set(h, 1),
|
|
3 == this.type)
|
|
f = y(this.payloadMessage.destinationName, n, u, f);
|
|
else if (1 == this.type) {
|
|
switch (this.mqttVersion) {
|
|
case 3:
|
|
u.set(l, f),
|
|
f += l.length;
|
|
break;
|
|
case 4:
|
|
u.set(v, f),
|
|
f += v.length
|
|
}
|
|
h = 0;
|
|
this.cleanSession && (h = 2),
|
|
null != this.willMessage && (h = 4 | h | this.willMessage.qos << 3,
|
|
this.willMessage.retained) && (h |= 32),
|
|
null != this.userName && (h |= 128),
|
|
null != this.password && (h |= 64),
|
|
u[f++] = h,
|
|
f = d(this.keepAliveInterval, u, f)
|
|
}
|
|
switch (null != this.messageIdentifier && (f = d(this.messageIdentifier, u, f)),
|
|
this.type) {
|
|
case 1:
|
|
f = y(this.clientId, m(this.clientId), u, f),
|
|
null != this.willMessage && (f = y(this.willMessage.destinationName, m(this.willMessage.destinationName), u, f),
|
|
f = d(t.byteLength, u, f),
|
|
u.set(t, f),
|
|
f += t.byteLength),
|
|
null != this.userName && (f = y(this.userName, m(this.userName), u, f)),
|
|
null != this.password && (f = y(this.password, m(this.password), u, f));
|
|
break;
|
|
case 3:
|
|
u.set(o, f);
|
|
break;
|
|
case 8:
|
|
for (s = 0; s < this.topics.length; s++)
|
|
f = y(this.topics[s], e[s], u, f),
|
|
u[f++] = this.requestedQos[s];
|
|
break;
|
|
case 10:
|
|
for (s = 0; s < this.topics.length; s++)
|
|
f = y(this.topics[s], e[s], u, f)
|
|
}
|
|
return a
|
|
}
|
|
),
|
|
T.prototype.maxMessageIdentifier = 65536,
|
|
T.prototype.p = null,
|
|
T.prototype.sendPinger = null,
|
|
T.prototype.receivePinger = null,
|
|
T.prototype.receiveBuffer = null,
|
|
T.prototype.Z = null,
|
|
T.prototype.X = 100,
|
|
T.prototype.connect = function(t) {
|
|
var i = this.G(t, "password");
|
|
this.u("Client.connect", i, this.socket, this.connected),
|
|
(this.connectOptions = t).uris ? (this.hostIndex = 0,
|
|
this.H(t.uris[0])) : this.H(this.uri)
|
|
}
|
|
,
|
|
T.prototype.subscribe = function(t, i) {
|
|
if (this.u("Client.subscribe", t, i),
|
|
!this.connected)
|
|
throw new Error(p(c.INVALID_STATE, ["not connected"]));
|
|
var r = new w(8);
|
|
r.topics = [t],
|
|
null != i.qos ? r.requestedQos = [i.qos] : r.requestedQos = [0],
|
|
i.onSuccess && (r.onSuccess = function(t) {
|
|
i.onSuccess({
|
|
invocationContext: i.invocationContext,
|
|
grantedQos: t
|
|
})
|
|
}
|
|
),
|
|
i.onFailure && (r.onFailure = function(t) {
|
|
i.onFailure({
|
|
invocationContext: i.invocationContext,
|
|
errorCode: t
|
|
})
|
|
}
|
|
),
|
|
i.timeout && (r.timeOut = new n(this,window,i.timeout,i.onFailure,[{
|
|
invocationContext: i.invocationContext,
|
|
errorCode: c.SUBSCRIBE_TIMEOUT.code,
|
|
errorMessage: p(c.SUBSCRIBE_TIMEOUT)
|
|
}])),
|
|
this.Y(r),
|
|
this.K(r)
|
|
}
|
|
,
|
|
T.prototype.unsubscribe = function(t, i) {
|
|
if (this.u("Client.unsubscribe", t, i),
|
|
!this.connected)
|
|
throw new Error(p(c.INVALID_STATE, ["not connected"]));
|
|
var r = new w(10);
|
|
r.topics = [t],
|
|
i.onSuccess && (r.callback = function() {
|
|
i.onSuccess({
|
|
invocationContext: i.invocationContext
|
|
})
|
|
}
|
|
),
|
|
i.timeout && (r.timeOut = new n(this,window,i.timeout,i.onFailure,[{
|
|
invocationContext: i.invocationContext,
|
|
errorCode: c.UNSUBSCRIBE_TIMEOUT.code,
|
|
errorMessage: p(c.UNSUBSCRIBE_TIMEOUT)
|
|
}])),
|
|
this.Y(r),
|
|
this.K(r)
|
|
}
|
|
,
|
|
T.prototype.send = function(t) {
|
|
if (this.u("Client.send", t),
|
|
!this.connected)
|
|
throw new Error(p(c.INVALID_STATE, ["not connected"]));
|
|
0 < ((wireMessage = new w(3)).payloadMessage = t).qos ? this.Y(wireMessage) : this.onMessageDelivered && (this.I[wireMessage] = this.onMessageDelivered(wireMessage.payloadMessage)),
|
|
this.K(wireMessage)
|
|
}
|
|
,
|
|
T.prototype.disconnect = function() {
|
|
if (this.u("Client.disconnect"),
|
|
!this.socket)
|
|
throw new Error(p(c.INVALID_STATE, ["not connecting or connected"]));
|
|
wireMessage = new w(14),
|
|
this.I[wireMessage] = r(this.l, this),
|
|
this.K(wireMessage)
|
|
}
|
|
,
|
|
T.prototype.getTraceLog = function() {
|
|
if (null !== this.Z) {
|
|
for (var t in this.u("Client.getTraceLog", new Date),
|
|
this.u("Client.getTraceLog in flight messages", this.v.length),
|
|
this.v)
|
|
this.u("_sentMessages ", t, this.v[t]);
|
|
for (var t in this.m)
|
|
this.u("_receivedMessages ", t, this.m[t]);
|
|
return this.Z
|
|
}
|
|
}
|
|
,
|
|
T.prototype.startTrace = function() {
|
|
null === this.Z && (this.Z = []),
|
|
this.u("Client.startTrace", new Date, "@VERSION@")
|
|
}
|
|
,
|
|
T.prototype.stopTrace = function() {
|
|
delete this.Z
|
|
}
|
|
,
|
|
T.prototype.H = function(t) {
|
|
var i;
|
|
this.connectOptions.useSSL && ((i = t.split(":"))[0] = "wss",
|
|
t = i.join(":")),
|
|
this.connected = !1,
|
|
this.connectOptions.token ? (this.connectOptions.mqttVersion,
|
|
this.socket = new WebSocket(t,[this.connectOptions.token])) : (this.connectOptions.mqttVersion,
|
|
this.socket = new WebSocket(t)),
|
|
this.socket.binaryType = "arraybuffer",
|
|
this.socket.onopen = r(this.W, this),
|
|
this.socket.onmessage = r(this.tt, this),
|
|
this.socket.onerror = r(this.it, this),
|
|
this.socket.onclose = r(this.rt, this),
|
|
this.sendPinger = new e(this,window,this.connectOptions.keepAliveInterval),
|
|
this.receivePinger = new e(this,window,this.connectOptions.keepAliveInterval),
|
|
this.et = new n(this,window,this.connectOptions.timeout,this.l,[c.CONNECT_TIMEOUT.code, p(c.CONNECT_TIMEOUT)])
|
|
}
|
|
,
|
|
T.prototype.K = function(t) {
|
|
this.p.push(t),
|
|
this.connected && this.nt()
|
|
}
|
|
,
|
|
T.prototype.store = function(t, i) {
|
|
var r = {
|
|
type: i.type,
|
|
messageIdentifier: i.messageIdentifier,
|
|
version: 1
|
|
};
|
|
if (3 !== i.type)
|
|
throw Error(p(c.INVALID_STORED_DATA, [key, r]));
|
|
i.pubRecReceived && (r.pubRecReceived = !0),
|
|
r.payloadMessage = {};
|
|
for (var e = "", n = i.payloadMessage.payloadBytes, s = 0; s < n.length; s++)
|
|
n[s] <= 15 ? e = e + "0" + n[s].toString(16) : e += n[s].toString(16);
|
|
r.payloadMessage.payloadHex = e,
|
|
r.payloadMessage.qos = i.payloadMessage.qos,
|
|
r.payloadMessage.destinationName = i.payloadMessage.destinationName,
|
|
i.payloadMessage.duplicate && (r.payloadMessage.duplicate = !0),
|
|
i.payloadMessage.retained && (r.payloadMessage.retained = !0),
|
|
0 == t.indexOf("Sent:") && (void 0 === i.sequence && (i.sequence = ++this.k),
|
|
r.sequence = i.sequence),
|
|
localStorage.setItem(t + this.g + i.messageIdentifier, JSON.stringify(r))
|
|
}
|
|
,
|
|
T.prototype.restore = function(t) {
|
|
var i = localStorage.getItem(t)
|
|
, r = JSON.parse(i)
|
|
, e = new w(r.type,r);
|
|
if (3 !== r.type)
|
|
throw Error(p(c.INVALID_STORED_DATA, [t, i]));
|
|
for (var n = r.payloadMessage.payloadHex, i = new ArrayBuffer(n.length / 2), s = new Uint8Array(i), o = 0; 2 <= n.length; ) {
|
|
var h = parseInt(n.substring(0, 2), 16)
|
|
, n = n.substring(2, n.length);
|
|
s[o++] = h
|
|
}
|
|
i = new Paho.MQTT.Message(s);
|
|
i.qos = r.payloadMessage.qos,
|
|
i.destinationName = r.payloadMessage.destinationName,
|
|
r.payloadMessage.duplicate && (i.duplicate = !0),
|
|
r.payloadMessage.retained && (i.retained = !0),
|
|
e.payloadMessage = i,
|
|
0 == t.indexOf("Sent:" + this.g) ? (e.payloadMessage.duplicate = !0,
|
|
this.v[e.messageIdentifier] = e) : 0 == t.indexOf("Received:" + this.g) && (this.m[e.messageIdentifier] = e)
|
|
}
|
|
,
|
|
T.prototype.nt = function() {
|
|
for (var t, i = this.p.reverse(); t = i.pop(); )
|
|
this.st(t),
|
|
this.I[t] && (this.I[t](),
|
|
delete this.I[t])
|
|
}
|
|
,
|
|
T.prototype.Y = function(t) {
|
|
var i = Object.keys(this.v).length;
|
|
if (i > this.maxMessageIdentifier)
|
|
throw Error("Too many messages:" + i);
|
|
for (; void 0 !== this.v[this.A]; )
|
|
this.A++;
|
|
t.messageIdentifier = this.A,
|
|
3 === (this.v[t.messageIdentifier] = t).type && this.store("Sent:", t),
|
|
this.A === this.maxMessageIdentifier && (this.A = 1)
|
|
}
|
|
,
|
|
T.prototype.W = function() {
|
|
var t = new w(1,this.connectOptions);
|
|
t.clientId = this.clientId,
|
|
this.st(t)
|
|
}
|
|
,
|
|
T.prototype.tt = function(t) {
|
|
this.u("Client._on_socket_message", t.data),
|
|
this.receivePinger.reset();
|
|
for (var i = this.ot(t.data), r = 0; r < i.length; r += 1)
|
|
this.ht(i[r])
|
|
}
|
|
,
|
|
T.prototype.ot = function(t) {
|
|
var i = new Uint8Array(t);
|
|
this.receiveBuffer && ((t = new Uint8Array(this.receiveBuffer.length + i.length)).set(this.receiveBuffer),
|
|
t.set(i, this.receiveBuffer.length),
|
|
i = t,
|
|
delete this.receiveBuffer);
|
|
try {
|
|
for (var r = 0, e = []; r < i.length; ) {
|
|
var n = function(t, i) {
|
|
var r, e = i, n = t[i], s = n >> 4, o = n &= 15, h = (i += 1,
|
|
0), f = 1;
|
|
do {
|
|
if (i == t.length)
|
|
return [null, e]
|
|
} while (h += (127 & (r = t[i++])) * f,
|
|
f *= 128,
|
|
0 != (128 & r));
|
|
var a = i + h;
|
|
if (a > t.length)
|
|
return [null, e];
|
|
var u = new w(s);
|
|
switch (s) {
|
|
case 2:
|
|
1 & t[i++] && (u.sessionPresent = !0),
|
|
u.returnCode = t[i++];
|
|
break;
|
|
case 3:
|
|
var l = o >> 1 & 3
|
|
, c = E(t, i)
|
|
, g = I(t, i += 2, c)
|
|
, c = (i += c,
|
|
0 < l && (u.messageIdentifier = E(t, i),
|
|
i += 2),
|
|
new Paho.MQTT.Message(t.subarray(i, a)));
|
|
1 == (1 & o) && (c.retained = !0),
|
|
8 == (8 & o) && (c.duplicate = !0),
|
|
c.qos = l,
|
|
c.destinationName = g,
|
|
u.payloadMessage = c;
|
|
break;
|
|
case 4:
|
|
u.messageIdentifier = E(t, i),
|
|
i += 2,
|
|
18 == h && (u.cmid = b(t, i),
|
|
u.mid = b(t, i += 8),
|
|
i += 8);
|
|
break;
|
|
case 5:
|
|
case 6:
|
|
case 7:
|
|
case 11:
|
|
u.messageIdentifier = E(t, i);
|
|
break;
|
|
case 9:
|
|
u.messageIdentifier = E(t, i),
|
|
u.returnCode = t.subarray(i += 2, a)
|
|
}
|
|
return [u, a]
|
|
}(i, r)
|
|
, s = n[0]
|
|
, r = n[1];
|
|
if (null === s)
|
|
break;
|
|
e.push(s)
|
|
}
|
|
r < i.length && (this.receiveBuffer = i.subarray(r))
|
|
} catch (t) {
|
|
return void this.l(c.INTERNAL_ERROR.code, p(c.INTERNAL_ERROR, [t.message, t.stack.toString()]))
|
|
}
|
|
return e
|
|
}
|
|
,
|
|
T.prototype.ht = function(t) {
|
|
this.u("Client._handleMessage", t);
|
|
try {
|
|
switch (t.type) {
|
|
case 2:
|
|
if (this.et.cancel(),
|
|
this.connectOptions.cleanSession) {
|
|
for (var i in this.v) {
|
|
var r = this.v[i];
|
|
localStorage.removeItem("Sent:" + this.g + r.messageIdentifier)
|
|
}
|
|
for (var i in this.v = {},
|
|
this.m) {
|
|
var e = this.m[i];
|
|
localStorage.removeItem("Received:" + this.g + e.messageIdentifier)
|
|
}
|
|
this.m = {}
|
|
}
|
|
if (0 !== t.returnCode)
|
|
this.l(c.CONNACK_RETURNCODE.code, p(c.CONNACK_RETURNCODE, [t.returnCode, g[t.returnCode]]));
|
|
else {
|
|
this.connected = !0,
|
|
this.connectOptions.uris && (this.hostIndex = this.connectOptions.uris.length);
|
|
var n, s = new Array;
|
|
for (n in this.v)
|
|
this.v.hasOwnProperty(n) && s.push(this.v[n]);
|
|
for (var s = s.sort(function(t, i) {
|
|
return t.sequence - i.sequence
|
|
}), o = 0, h = s.length; o < h; o++)
|
|
3 == (r = s[o]).type && r.pubRecReceived ? (u = new w(6,{
|
|
messageIdentifier: r.messageIdentifier
|
|
}),
|
|
this.K(u)) : this.K(r);
|
|
this.connectOptions.onSuccess && this.connectOptions.onSuccess({
|
|
invocationContext: this.connectOptions.invocationContext
|
|
}),
|
|
this.nt()
|
|
}
|
|
break;
|
|
case 3:
|
|
this.ft(t);
|
|
break;
|
|
case 4:
|
|
var f, a;
|
|
(r = this.v[t.messageIdentifier]) && (delete this.v[t.messageIdentifier],
|
|
localStorage.removeItem("Sent:" + this.g + t.messageIdentifier),
|
|
this.onMessageDelivered) && (f = t.mid,
|
|
a = t.cmid,
|
|
f && a ? this.onMessageDelivered(r.payloadMessage, {
|
|
mid: f,
|
|
cmid: a
|
|
}) : this.onMessageDelivered(r.payloadMessage));
|
|
break;
|
|
case 5:
|
|
var u;
|
|
(r = this.v[t.messageIdentifier]) && (r.pubRecReceived = !0,
|
|
u = new w(6,{
|
|
messageIdentifier: t.messageIdentifier
|
|
}),
|
|
this.store("Sent:", r),
|
|
this.K(u));
|
|
break;
|
|
case 6:
|
|
var e = this.m[t.messageIdentifier]
|
|
, l = (localStorage.removeItem("Received:" + this.g + t.messageIdentifier),
|
|
e && (this.ut(e),
|
|
delete this.m[t.messageIdentifier]),
|
|
new w(7,{
|
|
messageIdentifier: t.messageIdentifier
|
|
}));
|
|
this.K(l);
|
|
break;
|
|
case 7:
|
|
r = this.v[t.messageIdentifier],
|
|
delete this.v[t.messageIdentifier],
|
|
localStorage.removeItem("Sent:" + this.g + t.messageIdentifier),
|
|
this.onMessageDelivered && this.onMessageDelivered(r.payloadMessage);
|
|
break;
|
|
case 9:
|
|
(r = this.v[t.messageIdentifier]) && (r.timeOut && r.timeOut.cancel(),
|
|
128 === t.returnCode[0] ? r.onFailure && r.onFailure(t.returnCode) : r.onSuccess && r.onSuccess(t.returnCode),
|
|
delete this.v[t.messageIdentifier]);
|
|
break;
|
|
case 11:
|
|
(r = this.v[t.messageIdentifier]) && (r.timeOut && r.timeOut.cancel(),
|
|
r.callback && r.callback(),
|
|
delete this.v[t.messageIdentifier]);
|
|
break;
|
|
case 13:
|
|
this.sendPinger.reset();
|
|
break;
|
|
default:
|
|
this.l(c.INVALID_MQTT_MESSAGE_TYPE.code, p(c.INVALID_MQTT_MESSAGE_TYPE, [t.type]))
|
|
}
|
|
} catch (t) {
|
|
this.l(c.INTERNAL_ERROR.code, p(c.INTERNAL_ERROR, [t.message, t.stack.toString()]))
|
|
}
|
|
}
|
|
,
|
|
T.prototype.it = function(t) {
|
|
this.l(c.SOCKET_ERROR.code, p(c.SOCKET_ERROR, [t.data]))
|
|
}
|
|
,
|
|
T.prototype.rt = function() {
|
|
this.l(c.SOCKET_CLOSE.code, p(c.SOCKET_CLOSE))
|
|
}
|
|
,
|
|
T.prototype.st = function(t) {
|
|
var i;
|
|
1 == t.type ? (i = this.G(t, "password"),
|
|
this.u("Client._socket_send", i)) : this.u("Client._socket_send", t),
|
|
this.socket.send(t.encode()),
|
|
this.sendPinger.reset()
|
|
}
|
|
,
|
|
T.prototype.ft = function(t) {
|
|
switch (t.payloadMessage.qos) {
|
|
case "undefined":
|
|
case 0:
|
|
this.ut(t);
|
|
break;
|
|
case 1:
|
|
var i = new w(4,{
|
|
messageIdentifier: t.messageIdentifier
|
|
});
|
|
this.K(i),
|
|
this.ut(t);
|
|
break;
|
|
case 2:
|
|
this.m[t.messageIdentifier] = t,
|
|
this.store("Received:", t);
|
|
i = new w(5,{
|
|
messageIdentifier: t.messageIdentifier
|
|
});
|
|
this.K(i);
|
|
break;
|
|
default:
|
|
throw Error("Invaild qos=" + wireMmessage.payloadMessage.qos)
|
|
}
|
|
}
|
|
,
|
|
T.prototype.ut = function(t) {
|
|
this.onMessageArrived && this.onMessageArrived(t.payloadMessage)
|
|
}
|
|
,
|
|
T.prototype.l = function(t, i) {
|
|
this.u("Client._disconnected", t, i),
|
|
this.sendPinger.cancel(),
|
|
this.receivePinger.cancel(),
|
|
this.et && this.et.cancel(),
|
|
this.p = [],
|
|
this.I = {},
|
|
this.socket && (this.socket.onopen = null,
|
|
this.socket.onmessage = null,
|
|
this.socket.onerror = null,
|
|
this.socket.onclose = null,
|
|
1 === this.socket.readyState && this.socket.close(),
|
|
delete this.socket),
|
|
this.connectOptions.uris && this.hostIndex < this.connectOptions.uris.length - 1 ? (this.hostIndex++,
|
|
this.H(this.connectOptions.uris[this.hostIndex])) : (void 0 === t && (t = c.OK.code,
|
|
i = p(c.OK)),
|
|
this.connected ? (this.connected = !1,
|
|
this.onConnectionLost && this.onConnectionLost({
|
|
errorCode: t,
|
|
errorMessage: i
|
|
})) : 4 === this.connectOptions.mqttVersion && !1 === this.connectOptions.mqttVersionExplicit ? (this.u("Failed to connect V4, dropping back to V3"),
|
|
this.connectOptions.mqttVersion = 3,
|
|
this.connectOptions.uris ? (this.hostIndex = 0,
|
|
this.H(this.connectOptions.uris[0])) : this.H(this.uri)) : this.connectOptions.onFailure && this.connectOptions.onFailure({
|
|
invocationContext: this.connectOptions.invocationContext,
|
|
errorCode: t,
|
|
errorMessage: i
|
|
}))
|
|
}
|
|
,
|
|
T.prototype.u = function() {
|
|
if (this.traceFunction) {
|
|
for (var t in arguments)
|
|
void 0 !== arguments[t] && (arguments[t] = JSON.stringify(arguments[t]));
|
|
var i = Array.prototype.slice.call(arguments).join("");
|
|
this.traceFunction({
|
|
severity: "Debug",
|
|
message: i
|
|
})
|
|
}
|
|
if (null !== this.Z)
|
|
for (var t = 0, r = arguments.length; t < r; t++)
|
|
this.Z.length == this.X && this.Z.shift(),
|
|
0 === t || void 0 === arguments[t] ? this.Z.push(arguments[t]) : this.Z.push(" " + JSON.stringify(arguments[t]))
|
|
}
|
|
,
|
|
T.prototype.G = function(t, i) {
|
|
var r, e = {};
|
|
for (r in t)
|
|
t.hasOwnProperty(r) && (e[r] = r == i ? "******" : t[r]);
|
|
return e
|
|
}
|
|
,
|
|
t.prototype = {
|
|
get host() {
|
|
return this.R()
|
|
},
|
|
set host(t) {
|
|
this.O(t)
|
|
},
|
|
get port() {
|
|
return this.N()
|
|
},
|
|
set port(t) {
|
|
this.M(t)
|
|
},
|
|
get path() {
|
|
return this.S()
|
|
},
|
|
set path(t) {
|
|
this.j(t)
|
|
},
|
|
get clientId() {
|
|
return this._()
|
|
},
|
|
set clientId(t) {
|
|
this.B(t)
|
|
},
|
|
get onConnectionLost() {
|
|
return this.F()
|
|
},
|
|
set onConnectionLost(t) {
|
|
this.L(t)
|
|
},
|
|
get onMessageDelivered() {
|
|
return this.P()
|
|
},
|
|
set onMessageDelivered(t) {
|
|
this.$(t)
|
|
},
|
|
get onMessageArrived() {
|
|
return this.q()
|
|
},
|
|
set onMessageArrived(t) {
|
|
this.J(t)
|
|
},
|
|
get trace() {
|
|
return this.V()
|
|
},
|
|
set trace(t) {
|
|
this.D(t)
|
|
}
|
|
};
|
|
var A = function(t) {
|
|
var i;
|
|
if (!("string" == typeof t || t instanceof ArrayBuffer || t instanceof Int8Array || t instanceof Uint8Array || t instanceof Int16Array || t instanceof Uint16Array || t instanceof Int32Array || t instanceof Uint32Array || t instanceof Float32Array || t instanceof Float64Array))
|
|
throw p(c.INVALID_ARGUMENT, [t, "newPayload"]);
|
|
i = t,
|
|
this.ct = function() {
|
|
return "string" == typeof i ? i : I(i, 0, i.length)
|
|
}
|
|
,
|
|
this.wt = function() {
|
|
var t;
|
|
return "string" == typeof i ? (t = new ArrayBuffer(m(i)),
|
|
t = new Uint8Array(t),
|
|
h(i, t, 0),
|
|
t) : i
|
|
}
|
|
;
|
|
var r = void 0
|
|
, e = (this.vt = function() {
|
|
return r
|
|
}
|
|
,
|
|
this.dt = function(t) {
|
|
if ("string" != typeof t)
|
|
throw new Error(p(c.INVALID_ARGUMENT, [t, "newDestinationName"]));
|
|
r = t
|
|
}
|
|
,
|
|
0)
|
|
, n = (this.yt = function() {
|
|
return e
|
|
}
|
|
,
|
|
!(this.Et = function(t) {
|
|
if (0 !== t && 1 !== t && 2 !== t)
|
|
throw new Error("Invalid argument:" + t);
|
|
e = t
|
|
}
|
|
))
|
|
, s = (this.bt = function() {
|
|
return n
|
|
}
|
|
,
|
|
!(this.It = function(t) {
|
|
if ("boolean" != typeof t)
|
|
throw new Error(p(c.INVALID_ARGUMENT, [t, "newRetained"]));
|
|
n = t
|
|
}
|
|
));
|
|
this.Tt = function() {
|
|
return s
|
|
}
|
|
,
|
|
this.At = function(t) {
|
|
s = t
|
|
}
|
|
};
|
|
return A.prototype = {
|
|
get payloadString() {
|
|
return this.ct()
|
|
},
|
|
get payloadBytes() {
|
|
return this.wt()
|
|
},
|
|
get destinationName() {
|
|
return this.vt()
|
|
},
|
|
set destinationName(t) {
|
|
this.dt(t)
|
|
},
|
|
get qos() {
|
|
return this.yt()
|
|
},
|
|
set qos(t) {
|
|
this.Et(t)
|
|
},
|
|
get retained() {
|
|
return this.bt()
|
|
},
|
|
set retained(t) {
|
|
this.It(t)
|
|
},
|
|
get duplicate() {
|
|
return this.Tt()
|
|
},
|
|
set duplicate(t) {
|
|
this.At(t)
|
|
}
|
|
},
|
|
{
|
|
Client: t,
|
|
Message: A,
|
|
ClientImpl: T
|
|
}
|
|
}(window),
|
|
function(t, i) {
|
|
"function" == typeof define && define.amd || "function" != typeof require || "object" != typeof module || !module || !module.exports ? (t.dcodeIO = t.dcodeIO || {}).ByteBuffer = i(t.dcodeIO.Long) : module.exports = function() {
|
|
var t;
|
|
try {
|
|
t = require("long")
|
|
} catch (t) {}
|
|
return i(t)
|
|
}()
|
|
}(this, function(h) {
|
|
"use strict";
|
|
function w(t, i, r) {
|
|
if (void 0 === t && (t = w.DEFAULT_CAPACITY),
|
|
void 0 === i && (i = w.DEFAULT_ENDIAN),
|
|
!(r = void 0 === r ? w.DEFAULT_NOASSERT : r)) {
|
|
if ((t |= 0) < 0)
|
|
throw RangeError("Illegal capacity");
|
|
i = !!i,
|
|
r = !!r
|
|
}
|
|
this.buffer = 0 === t ? s : new ArrayBuffer(t),
|
|
this.view = 0 === t ? null : new Uint8Array(this.buffer),
|
|
this.offset = 0,
|
|
this.markedOffset = -1,
|
|
this.limit = t,
|
|
this.littleEndian = i,
|
|
this.noAssert = r
|
|
}
|
|
w.VERSION = "5.0.1",
|
|
w.LITTLE_ENDIAN = !0,
|
|
w.BIG_ENDIAN = !1,
|
|
w.DEFAULT_CAPACITY = 16,
|
|
w.DEFAULT_ENDIAN = w.BIG_ENDIAN,
|
|
w.DEFAULT_NOASSERT = !1,
|
|
w.Long = h || null;
|
|
var o = w.prototype
|
|
, s = (o.kt,
|
|
Object.defineProperty(o, "kt", {
|
|
value: !0,
|
|
enumerable: !1,
|
|
configurable: !1
|
|
}),
|
|
new ArrayBuffer(0))
|
|
, r = String.fromCharCode;
|
|
function f(t) {
|
|
var i = 0;
|
|
return function() {
|
|
return i < t.length ? t.charCodeAt(i++) : null
|
|
}
|
|
}
|
|
function a() {
|
|
var t = []
|
|
, i = [];
|
|
return function() {
|
|
if (0 === arguments.length)
|
|
return i.join("") + r.apply(String, t);
|
|
1024 < t.length + arguments.length && (i.push(r.apply(String, t)),
|
|
t.length = 0),
|
|
Array.prototype.push.apply(t, arguments)
|
|
}
|
|
}
|
|
function e(t, i, r, e, n) {
|
|
var s, o, h = 8 * n - e - 1, f = (1 << h) - 1, a = f >> 1, u = -7, l = r ? n - 1 : 0, c = r ? -1 : 1, n = t[i + l];
|
|
for (l += c,
|
|
s = n & (1 << -u) - 1,
|
|
n >>= -u,
|
|
u += h; 0 < u; s = 256 * s + t[i + l],
|
|
l += c,
|
|
u -= 8)
|
|
;
|
|
for (o = s & (1 << -u) - 1,
|
|
s >>= -u,
|
|
u += e; 0 < u; o = 256 * o + t[i + l],
|
|
l += c,
|
|
u -= 8)
|
|
;
|
|
if (0 === s)
|
|
s = 1 - a;
|
|
else {
|
|
if (s === f)
|
|
return o ? NaN : 1 / 0 * (n ? -1 : 1);
|
|
o += Math.pow(2, e),
|
|
s -= a
|
|
}
|
|
return (n ? -1 : 1) * o * Math.pow(2, s - e)
|
|
}
|
|
function n(t, i, r, e, n, s) {
|
|
var o, h, f = 8 * s - n - 1, a = (1 << f) - 1, u = a >> 1, l = 23 === n ? Math.pow(2, -24) - Math.pow(2, -77) : 0, c = e ? 0 : s - 1, g = e ? 1 : -1, s = i < 0 || 0 === i && 1 / i < 0 ? 1 : 0;
|
|
for (i = Math.abs(i),
|
|
isNaN(i) || i === 1 / 0 ? (h = isNaN(i) ? 1 : 0,
|
|
o = a) : (o = Math.floor(Math.log(i) / Math.LN2),
|
|
i * (e = Math.pow(2, -o)) < 1 && (o--,
|
|
e *= 2),
|
|
2 <= (i += 1 <= o + u ? l / e : l * Math.pow(2, 1 - u)) * e && (o++,
|
|
e /= 2),
|
|
a <= o + u ? (h = 0,
|
|
o = a) : 1 <= o + u ? (h = (i * e - 1) * Math.pow(2, n),
|
|
o += u) : (h = i * Math.pow(2, u - 1) * Math.pow(2, n),
|
|
o = 0)); 8 <= n; t[r + c] = 255 & h,
|
|
c += g,
|
|
h /= 256,
|
|
n -= 8)
|
|
;
|
|
for (o = o << n | h,
|
|
f += n; 0 < f; t[r + c] = 255 & o,
|
|
c += g,
|
|
o /= 256,
|
|
f -= 8)
|
|
;
|
|
t[r + c - g] |= 128 * s
|
|
}
|
|
w.accessor = function() {
|
|
return Uint8Array
|
|
}
|
|
,
|
|
w.allocate = function(t, i, r) {
|
|
return new w(t,i,r)
|
|
}
|
|
,
|
|
w.concat = function(t, i, r, e) {
|
|
"boolean" != typeof i && "string" == typeof i || (e = r,
|
|
r = i,
|
|
i = void 0);
|
|
for (var n, s = 0, o = 0, h = t.length; o < h; ++o)
|
|
w.isByteBuffer(t[o]) || (t[o] = w.wrap(t[o], i)),
|
|
0 < (n = t[o].limit - t[o].offset) && (s += n);
|
|
if (0 === s)
|
|
return new w(0,r,e);
|
|
for (var f, a = new w(s,r,e), o = 0; o < h; )
|
|
(n = (f = t[o++]).limit - f.offset) <= 0 || (a.view.set(f.view.subarray(f.offset, f.limit), a.offset),
|
|
a.offset += n);
|
|
return a.limit = a.offset,
|
|
a.offset = 0,
|
|
a
|
|
}
|
|
,
|
|
w.isByteBuffer = function(t) {
|
|
return !0 === (t && t.kt)
|
|
}
|
|
,
|
|
w.type = function() {
|
|
return ArrayBuffer
|
|
}
|
|
,
|
|
w.wrap = function(t, i, r, e) {
|
|
if ("string" != typeof i && (e = r,
|
|
r = i,
|
|
i = void 0),
|
|
"string" == typeof t)
|
|
switch (i = void 0 === i ? "utf8" : i) {
|
|
case "base64":
|
|
return w.fromBase64(t, r);
|
|
case "hex":
|
|
return w.fromHex(t, r);
|
|
case "binary":
|
|
return w.fromBinary(t, r);
|
|
case "utf8":
|
|
return w.fromUTF8(t, r);
|
|
case "debug":
|
|
return w.fromDebug(t, r);
|
|
default:
|
|
throw Error("Unsupported encoding: " + i)
|
|
}
|
|
if (null === t || "object" != typeof t)
|
|
throw TypeError("Illegal buffer");
|
|
var n;
|
|
if (w.isByteBuffer(t))
|
|
(n = o.clone.call(t)).markedOffset = -1;
|
|
else if (t instanceof Uint8Array)
|
|
n = new w(0,r,e),
|
|
0 < t.length && (n.buffer = t.buffer,
|
|
n.offset = t.byteOffset,
|
|
n.limit = t.byteOffset + t.byteLength,
|
|
n.view = new Uint8Array(t.buffer));
|
|
else if (t instanceof ArrayBuffer)
|
|
n = new w(0,r,e),
|
|
0 < t.byteLength && (n.buffer = t,
|
|
n.offset = 0,
|
|
n.limit = t.byteLength,
|
|
n.view = 0 < t.byteLength ? new Uint8Array(t) : null);
|
|
else {
|
|
if ("[object Array]" !== Object.prototype.toString.call(t))
|
|
throw TypeError("Illegal buffer");
|
|
(n = new w(t.length,r,e)).limit = t.length;
|
|
for (var s = 0; s < t.length; ++s)
|
|
n.view[s] = t[s]
|
|
}
|
|
return n
|
|
}
|
|
,
|
|
o.writeBitSet = function(t, i) {
|
|
var r = void 0 === i;
|
|
if (r && (i = this.offset),
|
|
!this.noAssert) {
|
|
if (!(t instanceof Array))
|
|
throw TypeError("Illegal BitSet: Not an array");
|
|
if ("number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal offset: " + i + " (not an integer)");
|
|
if ((i >>>= 0) < 0 || i + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + i + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
var e = i
|
|
, n = t.length
|
|
, s = n >> 3
|
|
, o = 0;
|
|
for (i += this.writeVarint32(n, i); s--; )
|
|
f = 1 & !!t[o++] | (1 & !!t[o++]) << 1 | (1 & !!t[o++]) << 2 | (1 & !!t[o++]) << 3 | (1 & !!t[o++]) << 4 | (1 & !!t[o++]) << 5 | (1 & !!t[o++]) << 6 | (1 & !!t[o++]) << 7,
|
|
this.writeByte(f, i++);
|
|
if (o < n) {
|
|
for (var h = 0, f = 0; o < n; )
|
|
f |= (1 & !!t[o++]) << h++;
|
|
this.writeByte(f, i++)
|
|
}
|
|
return r ? (this.offset = i,
|
|
this) : i - e
|
|
}
|
|
,
|
|
o.readBitSet = function(t) {
|
|
var i = void 0 === t
|
|
, r = (i && (t = this.offset),
|
|
this.readVarint32(t))
|
|
, e = r.value
|
|
, n = e >> 3
|
|
, s = 0
|
|
, o = [];
|
|
for (t += r.length; n--; )
|
|
f = this.readByte(t++),
|
|
o[s++] = !!(1 & f),
|
|
o[s++] = !!(2 & f),
|
|
o[s++] = !!(4 & f),
|
|
o[s++] = !!(8 & f),
|
|
o[s++] = !!(16 & f),
|
|
o[s++] = !!(32 & f),
|
|
o[s++] = !!(64 & f),
|
|
o[s++] = !!(128 & f);
|
|
if (s < e)
|
|
for (var h = 0, f = this.readByte(t++); s < e; )
|
|
o[s++] = !!(f >> h++ & 1);
|
|
return i && (this.offset = t),
|
|
o
|
|
}
|
|
,
|
|
o.readBytes = function(t, i) {
|
|
var r = void 0 === i;
|
|
if (r && (i = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal offset: " + i + " (not an integer)");
|
|
if ((i >>>= 0) < 0 || i + t > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + i + " (+" + t + ") <= " + this.buffer.byteLength)
|
|
}
|
|
i = this.slice(i, i + t);
|
|
return r && (this.offset += t),
|
|
i
|
|
}
|
|
,
|
|
o.writeBytes = o.append,
|
|
o.writeInt8 = function(t, i) {
|
|
var r = void 0 === i;
|
|
if (r && (i = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal value: " + t + " (not an integer)");
|
|
if (t |= 0,
|
|
"number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal offset: " + i + " (not an integer)");
|
|
if ((i >>>= 0) < 0 || i + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + i + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
var e = this.buffer.byteLength;
|
|
return e < (i += 1) && this.resize((e *= 2) > i ? e : i),
|
|
this.view[--i] = t,
|
|
r && (this.offset += 1),
|
|
this
|
|
}
|
|
,
|
|
o.writeByte = o.writeInt8,
|
|
o.readInt8 = function(t) {
|
|
var i = void 0 === t;
|
|
if (i && (t = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal offset: " + t + " (not an integer)");
|
|
if ((t >>>= 0) < 0 || t + 1 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + t + " (+1) <= " + this.buffer.byteLength)
|
|
}
|
|
t = this.view[t];
|
|
return 128 == (128 & t) && (t = -(255 - t + 1)),
|
|
i && (this.offset += 1),
|
|
t
|
|
}
|
|
,
|
|
o.readByte = o.readInt8,
|
|
o.writeUint8 = function(t, i) {
|
|
var r = void 0 === i;
|
|
if (r && (i = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal value: " + t + " (not an integer)");
|
|
if (t >>>= 0,
|
|
"number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal offset: " + i + " (not an integer)");
|
|
if ((i >>>= 0) < 0 || i + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + i + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
var e = this.buffer.byteLength;
|
|
return e < (i += 1) && this.resize((e *= 2) > i ? e : i),
|
|
this.view[--i] = t,
|
|
r && (this.offset += 1),
|
|
this
|
|
}
|
|
,
|
|
o.writeUInt8 = o.writeUint8,
|
|
o.readUint8 = function(t) {
|
|
var i = void 0 === t;
|
|
if (i && (t = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal offset: " + t + " (not an integer)");
|
|
if ((t >>>= 0) < 0 || t + 1 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + t + " (+1) <= " + this.buffer.byteLength)
|
|
}
|
|
t = this.view[t];
|
|
return i && (this.offset += 1),
|
|
t
|
|
}
|
|
,
|
|
o.readUInt8 = o.readUint8,
|
|
o.writeInt16 = function(t, i) {
|
|
var r = void 0 === i;
|
|
if (r && (i = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal value: " + t + " (not an integer)");
|
|
if (t |= 0,
|
|
"number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal offset: " + i + " (not an integer)");
|
|
if ((i >>>= 0) < 0 || i + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + i + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
var e = this.buffer.byteLength;
|
|
return e < (i += 2) && this.resize((e *= 2) > i ? e : i),
|
|
i -= 2,
|
|
this.littleEndian ? (this.view[i + 1] = (65280 & t) >>> 8,
|
|
this.view[i] = 255 & t) : (this.view[i] = (65280 & t) >>> 8,
|
|
this.view[i + 1] = 255 & t),
|
|
r && (this.offset += 2),
|
|
this
|
|
}
|
|
,
|
|
o.writeShort = o.writeInt16,
|
|
o.readInt16 = function(t) {
|
|
var i = void 0 === t;
|
|
if (i && (t = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal offset: " + t + " (not an integer)");
|
|
if ((t >>>= 0) < 0 || t + 2 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + t + " (+2) <= " + this.buffer.byteLength)
|
|
}
|
|
var r = 0;
|
|
return this.littleEndian ? (r = this.view[t],
|
|
r |= this.view[t + 1] << 8) : (r = this.view[t] << 8,
|
|
r |= this.view[t + 1]),
|
|
32768 == (32768 & r) && (r = -(65535 - r + 1)),
|
|
i && (this.offset += 2),
|
|
r
|
|
}
|
|
,
|
|
o.readShort = o.readInt16,
|
|
o.writeUint16 = function(t, i) {
|
|
var r = void 0 === i;
|
|
if (r && (i = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal value: " + t + " (not an integer)");
|
|
if (t >>>= 0,
|
|
"number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal offset: " + i + " (not an integer)");
|
|
if ((i >>>= 0) < 0 || i + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + i + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
var e = this.buffer.byteLength;
|
|
return e < (i += 2) && this.resize((e *= 2) > i ? e : i),
|
|
i -= 2,
|
|
this.littleEndian ? (this.view[i + 1] = (65280 & t) >>> 8,
|
|
this.view[i] = 255 & t) : (this.view[i] = (65280 & t) >>> 8,
|
|
this.view[i + 1] = 255 & t),
|
|
r && (this.offset += 2),
|
|
this
|
|
}
|
|
,
|
|
o.writeUInt16 = o.writeUint16,
|
|
o.readUint16 = function(t) {
|
|
var i = void 0 === t;
|
|
if (i && (t = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal offset: " + t + " (not an integer)");
|
|
if ((t >>>= 0) < 0 || t + 2 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + t + " (+2) <= " + this.buffer.byteLength)
|
|
}
|
|
var r = 0;
|
|
return this.littleEndian ? (r = this.view[t],
|
|
r |= this.view[t + 1] << 8) : (r = this.view[t] << 8,
|
|
r |= this.view[t + 1]),
|
|
i && (this.offset += 2),
|
|
r
|
|
}
|
|
,
|
|
o.readUInt16 = o.readUint16,
|
|
o.writeInt32 = function(t, i) {
|
|
var r = void 0 === i;
|
|
if (r && (i = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal value: " + t + " (not an integer)");
|
|
if (t |= 0,
|
|
"number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal offset: " + i + " (not an integer)");
|
|
if ((i >>>= 0) < 0 || i + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + i + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
var e = this.buffer.byteLength;
|
|
return e < (i += 4) && this.resize((e *= 2) > i ? e : i),
|
|
i -= 4,
|
|
this.littleEndian ? (this.view[i + 3] = t >>> 24 & 255,
|
|
this.view[i + 2] = t >>> 16 & 255,
|
|
this.view[i + 1] = t >>> 8 & 255,
|
|
this.view[i] = 255 & t) : (this.view[i] = t >>> 24 & 255,
|
|
this.view[i + 1] = t >>> 16 & 255,
|
|
this.view[i + 2] = t >>> 8 & 255,
|
|
this.view[i + 3] = 255 & t),
|
|
r && (this.offset += 4),
|
|
this
|
|
}
|
|
,
|
|
o.writeInt = o.writeInt32,
|
|
o.readInt32 = function(t) {
|
|
var i = void 0 === t;
|
|
if (i && (t = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal offset: " + t + " (not an integer)");
|
|
if ((t >>>= 0) < 0 || t + 4 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + t + " (+4) <= " + this.buffer.byteLength)
|
|
}
|
|
var r = 0
|
|
, r = this.littleEndian ? (r = this.view[t + 2] << 16,
|
|
(r = (r |= this.view[t + 1] << 8) | this.view[t]) + (this.view[t + 3] << 24 >>> 0)) : (r = this.view[t + 1] << 16,
|
|
(r = (r |= this.view[t + 2] << 8) | this.view[t + 3]) + (this.view[t] << 24 >>> 0));
|
|
return r |= 0,
|
|
i && (this.offset += 4),
|
|
r
|
|
}
|
|
,
|
|
o.readInt = o.readInt32,
|
|
o.writeUint32 = function(t, i) {
|
|
var r = void 0 === i;
|
|
if (r && (i = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal value: " + t + " (not an integer)");
|
|
if (t >>>= 0,
|
|
"number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal offset: " + i + " (not an integer)");
|
|
if ((i >>>= 0) < 0 || i + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + i + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
var e = this.buffer.byteLength;
|
|
return e < (i += 4) && this.resize((e *= 2) > i ? e : i),
|
|
i -= 4,
|
|
this.littleEndian ? (this.view[i + 3] = t >>> 24 & 255,
|
|
this.view[i + 2] = t >>> 16 & 255,
|
|
this.view[i + 1] = t >>> 8 & 255,
|
|
this.view[i] = 255 & t) : (this.view[i] = t >>> 24 & 255,
|
|
this.view[i + 1] = t >>> 16 & 255,
|
|
this.view[i + 2] = t >>> 8 & 255,
|
|
this.view[i + 3] = 255 & t),
|
|
r && (this.offset += 4),
|
|
this
|
|
}
|
|
,
|
|
o.writeUInt32 = o.writeUint32,
|
|
o.readUint32 = function(t) {
|
|
var i = void 0 === t;
|
|
if (i && (t = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal offset: " + t + " (not an integer)");
|
|
if ((t >>>= 0) < 0 || t + 4 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + t + " (+4) <= " + this.buffer.byteLength)
|
|
}
|
|
var r = 0
|
|
, r = this.littleEndian ? (r = this.view[t + 2] << 16,
|
|
(r = (r |= this.view[t + 1] << 8) | this.view[t]) + (this.view[t + 3] << 24 >>> 0)) : (r = this.view[t + 1] << 16,
|
|
(r = (r |= this.view[t + 2] << 8) | this.view[t + 3]) + (this.view[t] << 24 >>> 0));
|
|
return i && (this.offset += 4),
|
|
r
|
|
}
|
|
,
|
|
o.readUInt32 = o.readUint32,
|
|
h && (o.writeInt64 = function(t, i) {
|
|
var r = void 0 === i;
|
|
if (r && (i = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" == typeof t)
|
|
t = h.fromNumber(t);
|
|
else if ("string" == typeof t)
|
|
t = h.fromString(t);
|
|
else if (!(t && t instanceof h))
|
|
throw TypeError("Illegal value: " + t + " (not an integer or Long)");
|
|
if ("number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal offset: " + i + " (not an integer)");
|
|
if ((i >>>= 0) < 0 || i + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + i + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
"number" == typeof t ? t = h.fromNumber(t) : "string" == typeof t && (t = h.fromString(t));
|
|
var e = this.buffer.byteLength
|
|
, e = (e < (i += 8) && this.resize((e *= 2) > i ? e : i),
|
|
i -= 8,
|
|
t.low)
|
|
, t = t.high;
|
|
return this.littleEndian ? (this.view[i + 3] = e >>> 24 & 255,
|
|
this.view[i + 2] = e >>> 16 & 255,
|
|
this.view[i + 1] = e >>> 8 & 255,
|
|
this.view[i] = 255 & e,
|
|
this.view[(i += 4) + 3] = t >>> 24 & 255,
|
|
this.view[i + 2] = t >>> 16 & 255,
|
|
this.view[i + 1] = t >>> 8 & 255,
|
|
this.view[i] = 255 & t) : (this.view[i] = t >>> 24 & 255,
|
|
this.view[i + 1] = t >>> 16 & 255,
|
|
this.view[i + 2] = t >>> 8 & 255,
|
|
this.view[i + 3] = 255 & t,
|
|
this.view[i += 4] = e >>> 24 & 255,
|
|
this.view[i + 1] = e >>> 16 & 255,
|
|
this.view[i + 2] = e >>> 8 & 255,
|
|
this.view[i + 3] = 255 & e),
|
|
r && (this.offset += 8),
|
|
this
|
|
}
|
|
,
|
|
o.writeLong = o.writeInt64,
|
|
o.readInt64 = function(t) {
|
|
var i = void 0 === t;
|
|
if (i && (t = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal offset: " + t + " (not an integer)");
|
|
if ((t >>>= 0) < 0 || t + 8 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + t + " (+8) <= " + this.buffer.byteLength)
|
|
}
|
|
var r = 0
|
|
, e = 0
|
|
, t = (this.littleEndian ? (r = this.view[t + 2] << 16,
|
|
r = (r = (r |= this.view[t + 1] << 8) | this.view[t]) + (this.view[t + 3] << 24 >>> 0),
|
|
e = this.view[(t += 4) + 2] << 16,
|
|
e = (e = (e |= this.view[t + 1] << 8) | this.view[t]) + (this.view[t + 3] << 24 >>> 0)) : (e = this.view[t + 1] << 16,
|
|
e = (e = (e |= this.view[t + 2] << 8) | this.view[t + 3]) + (this.view[t] << 24 >>> 0),
|
|
r = this.view[(t += 4) + 1] << 16,
|
|
r = (r = (r |= this.view[t + 2] << 8) | this.view[t + 3]) + (this.view[t] << 24 >>> 0)),
|
|
new h(r,e,!1));
|
|
return i && (this.offset += 8),
|
|
t
|
|
}
|
|
,
|
|
o.readLong = o.readInt64,
|
|
o.writeUint64 = function(t, i) {
|
|
var r = void 0 === i;
|
|
if (r && (i = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" == typeof t)
|
|
t = h.fromNumber(t);
|
|
else if ("string" == typeof t)
|
|
t = h.fromString(t);
|
|
else if (!(t && t instanceof h))
|
|
throw TypeError("Illegal value: " + t + " (not an integer or Long)");
|
|
if ("number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal offset: " + i + " (not an integer)");
|
|
if ((i >>>= 0) < 0 || i + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + i + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
"number" == typeof t ? t = h.fromNumber(t) : "string" == typeof t && (t = h.fromString(t));
|
|
var e = this.buffer.byteLength
|
|
, e = (e < (i += 8) && this.resize((e *= 2) > i ? e : i),
|
|
i -= 8,
|
|
t.low)
|
|
, t = t.high;
|
|
return this.littleEndian ? (this.view[i + 3] = e >>> 24 & 255,
|
|
this.view[i + 2] = e >>> 16 & 255,
|
|
this.view[i + 1] = e >>> 8 & 255,
|
|
this.view[i] = 255 & e,
|
|
this.view[(i += 4) + 3] = t >>> 24 & 255,
|
|
this.view[i + 2] = t >>> 16 & 255,
|
|
this.view[i + 1] = t >>> 8 & 255,
|
|
this.view[i] = 255 & t) : (this.view[i] = t >>> 24 & 255,
|
|
this.view[i + 1] = t >>> 16 & 255,
|
|
this.view[i + 2] = t >>> 8 & 255,
|
|
this.view[i + 3] = 255 & t,
|
|
this.view[i += 4] = e >>> 24 & 255,
|
|
this.view[i + 1] = e >>> 16 & 255,
|
|
this.view[i + 2] = e >>> 8 & 255,
|
|
this.view[i + 3] = 255 & e),
|
|
r && (this.offset += 8),
|
|
this
|
|
}
|
|
,
|
|
o.writeUInt64 = o.writeUint64,
|
|
o.readUint64 = function(t) {
|
|
var i = void 0 === t;
|
|
if (i && (t = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal offset: " + t + " (not an integer)");
|
|
if ((t >>>= 0) < 0 || t + 8 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + t + " (+8) <= " + this.buffer.byteLength)
|
|
}
|
|
var r = 0
|
|
, e = 0
|
|
, t = (this.littleEndian ? (r = this.view[t + 2] << 16,
|
|
r = (r = (r |= this.view[t + 1] << 8) | this.view[t]) + (this.view[t + 3] << 24 >>> 0),
|
|
e = this.view[(t += 4) + 2] << 16,
|
|
e = (e = (e |= this.view[t + 1] << 8) | this.view[t]) + (this.view[t + 3] << 24 >>> 0)) : (e = this.view[t + 1] << 16,
|
|
e = (e = (e |= this.view[t + 2] << 8) | this.view[t + 3]) + (this.view[t] << 24 >>> 0),
|
|
r = this.view[(t += 4) + 1] << 16,
|
|
r = (r = (r |= this.view[t + 2] << 8) | this.view[t + 3]) + (this.view[t] << 24 >>> 0)),
|
|
new h(r,e,!0));
|
|
return i && (this.offset += 8),
|
|
t
|
|
}
|
|
,
|
|
o.readUInt64 = o.readUint64),
|
|
o.writeFloat32 = function(t, i) {
|
|
var r = void 0 === i;
|
|
if (r && (i = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t)
|
|
throw TypeError("Illegal value: " + t + " (not a number)");
|
|
if ("number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal offset: " + i + " (not an integer)");
|
|
if ((i >>>= 0) < 0 || i + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + i + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
var e = this.buffer.byteLength;
|
|
return e < (i += 4) && this.resize((e *= 2) > i ? e : i),
|
|
n(this.view, t, i -= 4, this.littleEndian, 23, 4),
|
|
r && (this.offset += 4),
|
|
this
|
|
}
|
|
,
|
|
o.writeFloat = o.writeFloat32,
|
|
o.readFloat32 = function(t) {
|
|
var i = void 0 === t;
|
|
if (i && (t = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal offset: " + t + " (not an integer)");
|
|
if ((t >>>= 0) < 0 || t + 4 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + t + " (+4) <= " + this.buffer.byteLength)
|
|
}
|
|
t = e(this.view, t, this.littleEndian, 23, 4);
|
|
return i && (this.offset += 4),
|
|
t
|
|
}
|
|
,
|
|
o.readFloat = o.readFloat32,
|
|
o.writeFloat64 = function(t, i) {
|
|
var r = void 0 === i;
|
|
if (r && (i = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t)
|
|
throw TypeError("Illegal value: " + t + " (not a number)");
|
|
if ("number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal offset: " + i + " (not an integer)");
|
|
if ((i >>>= 0) < 0 || i + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + i + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
var e = this.buffer.byteLength;
|
|
return e < (i += 8) && this.resize((e *= 2) > i ? e : i),
|
|
n(this.view, t, i -= 8, this.littleEndian, 52, 8),
|
|
r && (this.offset += 8),
|
|
this
|
|
}
|
|
,
|
|
o.writeDouble = o.writeFloat64,
|
|
o.readFloat64 = function(t) {
|
|
var i = void 0 === t;
|
|
if (i && (t = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal offset: " + t + " (not an integer)");
|
|
if ((t >>>= 0) < 0 || t + 8 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + t + " (+8) <= " + this.buffer.byteLength)
|
|
}
|
|
t = e(this.view, t, this.littleEndian, 52, 8);
|
|
return i && (this.offset += 8),
|
|
t
|
|
}
|
|
,
|
|
o.readDouble = o.readFloat64,
|
|
w.MAX_VARINT32_BYTES = 5,
|
|
w.calculateVarint32 = function(t) {
|
|
return (t >>>= 0) < 128 ? 1 : t < 16384 ? 2 : t < 1 << 21 ? 3 : t < 1 << 28 ? 4 : 5
|
|
}
|
|
,
|
|
w.zigZagEncode32 = function(t) {
|
|
return ((t |= 0) << 1 ^ t >> 31) >>> 0
|
|
}
|
|
,
|
|
w.zigZagDecode32 = function(t) {
|
|
return t >>> 1 ^ -(1 & t) | 0
|
|
}
|
|
,
|
|
o.writeVarint32 = function(t, i) {
|
|
var r = void 0 === i;
|
|
if (r && (i = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal value: " + t + " (not an integer)");
|
|
if (t |= 0,
|
|
"number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal offset: " + i + " (not an integer)");
|
|
if ((i >>>= 0) < 0 || i + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + i + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
var e = w.calculateVarint32(t)
|
|
, n = this.buffer.byteLength;
|
|
for (n < (i += e) && this.resize((n *= 2) > i ? n : i),
|
|
i -= e,
|
|
t >>>= 0; 128 <= t; )
|
|
this.view[i++] = 127 & t | 128,
|
|
t >>>= 7;
|
|
return this.view[i++] = t,
|
|
r ? (this.offset = i,
|
|
this) : e
|
|
}
|
|
,
|
|
o.writeVarint32ZigZag = function(t, i) {
|
|
return this.writeVarint32(w.zigZagEncode32(t), i)
|
|
}
|
|
,
|
|
o.readVarint32 = function(t) {
|
|
var i = void 0 === t;
|
|
if (i && (t = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal offset: " + t + " (not an integer)");
|
|
if ((t >>>= 0) < 0 || t + 1 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + t + " (+1) <= " + this.buffer.byteLength)
|
|
}
|
|
var r, e = 0, n = 0;
|
|
do {
|
|
if (!this.noAssert && t > this.limit)
|
|
throw (r = Error("Truncated")).truncated = !0,
|
|
r
|
|
} while (r = this.view[t++],
|
|
e < 5 && (n |= (127 & r) << 7 * e),
|
|
++e,
|
|
0 != (128 & r));
|
|
return n |= 0,
|
|
i ? (this.offset = t,
|
|
n) : {
|
|
value: n,
|
|
length: e
|
|
}
|
|
}
|
|
,
|
|
o.readVarint32ZigZag = function(t) {
|
|
t = this.readVarint32(t);
|
|
return "object" == typeof t ? t.value = w.zigZagDecode32(t.value) : t = w.zigZagDecode32(t),
|
|
t
|
|
}
|
|
,
|
|
h && (w.MAX_VARINT64_BYTES = 10,
|
|
w.calculateVarint64 = function(t) {
|
|
"number" == typeof t ? t = h.fromNumber(t) : "string" == typeof t && (t = h.fromString(t));
|
|
var i = t.toInt() >>> 0
|
|
, r = t.shiftRightUnsigned(28).toInt() >>> 0
|
|
, t = t.shiftRightUnsigned(56).toInt() >>> 0;
|
|
return 0 == t ? 0 == r ? i < 16384 ? i < 128 ? 1 : 2 : i < 1 << 21 ? 3 : 4 : r < 16384 ? r < 128 ? 5 : 6 : r < 1 << 21 ? 7 : 8 : t < 128 ? 9 : 10
|
|
}
|
|
,
|
|
w.zigZagEncode64 = function(t) {
|
|
return "number" == typeof t ? t = h.fromNumber(t, !1) : "string" == typeof t ? t = h.fromString(t, !1) : !1 !== t.unsigned && (t = t.toSigned()),
|
|
t.shiftLeft(1).xor(t.shiftRight(63)).toUnsigned()
|
|
}
|
|
,
|
|
w.zigZagDecode64 = function(t) {
|
|
return "number" == typeof t ? t = h.fromNumber(t, !1) : "string" == typeof t ? t = h.fromString(t, !1) : !1 !== t.unsigned && (t = t.toSigned()),
|
|
t.shiftRightUnsigned(1).xor(t.and(h.ONE).toSigned().negate()).toSigned()
|
|
}
|
|
,
|
|
o.writeVarint64 = function(t, i) {
|
|
var r = void 0 === i;
|
|
if (r && (i = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" == typeof t)
|
|
t = h.fromNumber(t);
|
|
else if ("string" == typeof t)
|
|
t = h.fromString(t);
|
|
else if (!(t && t instanceof h))
|
|
throw TypeError("Illegal value: " + t + " (not an integer or Long)");
|
|
if ("number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal offset: " + i + " (not an integer)");
|
|
if ((i >>>= 0) < 0 || i + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + i + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
"number" == typeof t ? t = h.fromNumber(t, !1) : "string" == typeof t ? t = h.fromString(t, !1) : !1 !== t.unsigned && (t = t.toSigned());
|
|
var e = w.calculateVarint64(t)
|
|
, n = t.toInt() >>> 0
|
|
, s = t.shiftRightUnsigned(28).toInt() >>> 0
|
|
, o = t.shiftRightUnsigned(56).toInt() >>> 0
|
|
, t = this.buffer.byteLength;
|
|
switch (t < (i += e) && this.resize((t *= 2) > i ? t : i),
|
|
i -= e,
|
|
e) {
|
|
case 10:
|
|
this.view[i + 9] = o >>> 7 & 1;
|
|
case 9:
|
|
this.view[i + 8] = 9 !== e ? 128 | o : 127 & o;
|
|
case 8:
|
|
this.view[i + 7] = 8 !== e ? s >>> 21 | 128 : s >>> 21 & 127;
|
|
case 7:
|
|
this.view[i + 6] = 7 !== e ? s >>> 14 | 128 : s >>> 14 & 127;
|
|
case 6:
|
|
this.view[i + 5] = 6 !== e ? s >>> 7 | 128 : s >>> 7 & 127;
|
|
case 5:
|
|
this.view[i + 4] = 5 !== e ? 128 | s : 127 & s;
|
|
case 4:
|
|
this.view[i + 3] = 4 !== e ? n >>> 21 | 128 : n >>> 21 & 127;
|
|
case 3:
|
|
this.view[i + 2] = 3 !== e ? n >>> 14 | 128 : n >>> 14 & 127;
|
|
case 2:
|
|
this.view[i + 1] = 2 !== e ? n >>> 7 | 128 : n >>> 7 & 127;
|
|
case 1:
|
|
this.view[i] = 1 !== e ? 128 | n : 127 & n
|
|
}
|
|
return r ? (this.offset += e,
|
|
this) : e
|
|
}
|
|
,
|
|
o.writeVarint64ZigZag = function(t, i) {
|
|
return this.writeVarint64(w.zigZagEncode64(t), i)
|
|
}
|
|
,
|
|
o.readVarint64 = function(t) {
|
|
var i = void 0 === t;
|
|
if (i && (t = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal offset: " + t + " (not an integer)");
|
|
if ((t >>>= 0) < 0 || t + 1 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + t + " (+1) <= " + this.buffer.byteLength)
|
|
}
|
|
var r = t
|
|
, e = 0
|
|
, n = 0
|
|
, s = 0
|
|
, e = 127 & (o = this.view[t++]);
|
|
if (128 & o && (e |= (127 & (o = this.view[t++])) << 7,
|
|
128 & o || this.noAssert && void 0 === o) && (e |= (127 & (o = this.view[t++])) << 14,
|
|
128 & o || this.noAssert && void 0 === o) && (e |= (127 & (o = this.view[t++])) << 21,
|
|
128 & o || this.noAssert && void 0 === o) && (n = 127 & (o = this.view[t++]),
|
|
128 & o || this.noAssert && void 0 === o) && (n |= (127 & (o = this.view[t++])) << 7,
|
|
128 & o || this.noAssert && void 0 === o) && (n |= (127 & (o = this.view[t++])) << 14,
|
|
128 & o || this.noAssert && void 0 === o) && (n |= (127 & (o = this.view[t++])) << 21,
|
|
128 & o || this.noAssert && void 0 === o) && (s = 127 & (o = this.view[t++]),
|
|
128 & o || this.noAssert && void 0 === o) && (s |= (127 & (o = this.view[t++])) << 7,
|
|
128 & o || this.noAssert && void 0 === o))
|
|
throw Error("Buffer overrun");
|
|
var o = h.fromBits(e | n << 28, n >>> 4 | s << 24, !1);
|
|
return i ? (this.offset = t,
|
|
o) : {
|
|
value: o,
|
|
length: t - r
|
|
}
|
|
}
|
|
,
|
|
o.readVarint64ZigZag = function(t) {
|
|
t = this.readVarint64(t);
|
|
return t && t.value instanceof h ? t.value = w.zigZagDecode64(t.value) : t = w.zigZagDecode64(t),
|
|
t
|
|
}
|
|
),
|
|
o.writeCString = function(t, i) {
|
|
var r = void 0 === i;
|
|
r && (i = this.offset);
|
|
var e, n = t.length;
|
|
if (!this.noAssert) {
|
|
if ("string" != typeof t)
|
|
throw TypeError("Illegal str: Not a string");
|
|
for (e = 0; e < n; ++e)
|
|
if (0 === t.charCodeAt(e))
|
|
throw RangeError("Illegal str: Contains NULL-characters");
|
|
if ("number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal offset: " + i + " (not an integer)");
|
|
if ((i >>>= 0) < 0 || i + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + i + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
n = c.calculateUTF16asUTF8(f(t))[1],
|
|
i += n + 1;
|
|
var s = this.buffer.byteLength;
|
|
return s < i && this.resize((s *= 2) > i ? s : i),
|
|
i -= n + 1,
|
|
c.encodeUTF16toUTF8(f(t), function(t) {
|
|
this.view[i++] = t
|
|
}
|
|
.bind(this)),
|
|
this.view[i++] = 0,
|
|
r ? (this.offset = i,
|
|
this) : n
|
|
}
|
|
,
|
|
o.readCString = function(t) {
|
|
var i = void 0 === t;
|
|
if (i && (t = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal offset: " + t + " (not an integer)");
|
|
if ((t >>>= 0) < 0 || t + 1 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + t + " (+1) <= " + this.buffer.byteLength)
|
|
}
|
|
var r, e = t, n = -1;
|
|
return c.decodeUTF8toUTF16(function() {
|
|
if (0 === n)
|
|
return null;
|
|
if (t >= this.limit)
|
|
throw RangeError("Illegal range: Truncated data, " + t + " < " + this.limit);
|
|
return 0 === (n = this.view[t++]) ? null : n
|
|
}
|
|
.bind(this), r = a(), !0),
|
|
i ? (this.offset = t,
|
|
r()) : {
|
|
string: r(),
|
|
length: t - e
|
|
}
|
|
}
|
|
,
|
|
o.writeIString = function(t, i) {
|
|
var r = void 0 === i;
|
|
if (r && (i = this.offset),
|
|
!this.noAssert) {
|
|
if ("string" != typeof t)
|
|
throw TypeError("Illegal str: Not a string");
|
|
if ("number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal offset: " + i + " (not an integer)");
|
|
if ((i >>>= 0) < 0 || i + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + i + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
var e = i
|
|
, n = c.calculateUTF16asUTF8(f(t), this.noAssert)[1]
|
|
, s = (i += 4 + n,
|
|
this.buffer.byteLength);
|
|
if (s < i && this.resize((s *= 2) > i ? s : i),
|
|
i -= 4 + n,
|
|
this.littleEndian ? (this.view[i + 3] = n >>> 24 & 255,
|
|
this.view[i + 2] = n >>> 16 & 255,
|
|
this.view[i + 1] = n >>> 8 & 255,
|
|
this.view[i] = 255 & n) : (this.view[i] = n >>> 24 & 255,
|
|
this.view[i + 1] = n >>> 16 & 255,
|
|
this.view[i + 2] = n >>> 8 & 255,
|
|
this.view[i + 3] = 255 & n),
|
|
i += 4,
|
|
c.encodeUTF16toUTF8(f(t), function(t) {
|
|
this.view[i++] = t
|
|
}
|
|
.bind(this)),
|
|
i !== e + 4 + n)
|
|
throw RangeError("Illegal range: Truncated data, " + i + " == " + (i + 4 + n));
|
|
return r ? (this.offset = i,
|
|
this) : i - e
|
|
}
|
|
,
|
|
o.readIString = function(t) {
|
|
var i = void 0 === t;
|
|
if (i && (t = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal offset: " + t + " (not an integer)");
|
|
if ((t >>>= 0) < 0 || t + 4 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + t + " (+4) <= " + this.buffer.byteLength)
|
|
}
|
|
var r = t
|
|
, e = this.readUint32(t)
|
|
, e = this.readUTF8String(e, w.METRICS_BYTES, t += 4);
|
|
return t += e.length,
|
|
i ? (this.offset = t,
|
|
e.string) : {
|
|
string: e.string,
|
|
length: t - r
|
|
}
|
|
}
|
|
,
|
|
w.METRICS_CHARS = "c",
|
|
w.METRICS_BYTES = "b",
|
|
o.writeUTF8String = function(t, i) {
|
|
var r = void 0 === i;
|
|
if (r && (i = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal offset: " + i + " (not an integer)");
|
|
if ((i >>>= 0) < 0 || i + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + i + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
var e = i
|
|
, n = c.calculateUTF16asUTF8(f(t))[1]
|
|
, s = (i += n,
|
|
this.buffer.byteLength);
|
|
return s < i && this.resize((s *= 2) > i ? s : i),
|
|
i -= n,
|
|
c.encodeUTF16toUTF8(f(t), function(t) {
|
|
this.view[i++] = t
|
|
}
|
|
.bind(this)),
|
|
r ? (this.offset = i,
|
|
this) : i - e
|
|
}
|
|
,
|
|
o.writeString = o.writeUTF8String,
|
|
w.calculateUTF8Chars = function(t) {
|
|
return c.calculateUTF16asUTF8(f(t))[0]
|
|
}
|
|
,
|
|
w.calculateString = w.calculateUTF8Bytes = function(t) {
|
|
return c.calculateUTF16asUTF8(f(t))[1]
|
|
}
|
|
,
|
|
o.readUTF8String = function(t, i, r) {
|
|
"number" == typeof i && (r = i,
|
|
i = void 0);
|
|
var e = void 0 === r;
|
|
if (e && (r = this.offset),
|
|
void 0 === i && (i = w.METRICS_CHARS),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal length: " + t + " (not an integer)");
|
|
if (t |= 0,
|
|
"number" != typeof r || r % 1 != 0)
|
|
throw TypeError("Illegal offset: " + r + " (not an integer)");
|
|
if ((r >>>= 0) < 0 || r + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + r + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
var n, s = 0, o = r;
|
|
if (i === w.METRICS_CHARS) {
|
|
if (n = a(),
|
|
c.decodeUTF8(function() {
|
|
return s < t && r < this.limit ? this.view[r++] : null
|
|
}
|
|
.bind(this), function(t) {
|
|
++s,
|
|
c.UTF8toUTF16(t, n)
|
|
}),
|
|
s !== t)
|
|
throw RangeError("Illegal range: Truncated data, " + s + " == " + t)
|
|
} else {
|
|
if (i !== w.METRICS_BYTES)
|
|
throw TypeError("Unsupported metrics: " + i);
|
|
if (!this.noAssert) {
|
|
if ("number" != typeof r || r % 1 != 0)
|
|
throw TypeError("Illegal offset: " + r + " (not an integer)");
|
|
if ((r >>>= 0) < 0 || r + t > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + r + " (+" + t + ") <= " + this.buffer.byteLength)
|
|
}
|
|
var h = r + t;
|
|
if (c.decodeUTF8toUTF16(function() {
|
|
return r < h ? this.view[r++] : null
|
|
}
|
|
.bind(this), n = a(), this.noAssert),
|
|
r !== h)
|
|
throw RangeError("Illegal range: Truncated data, " + r + " == " + h)
|
|
}
|
|
return e ? (this.offset = r,
|
|
n()) : {
|
|
string: n(),
|
|
length: r - o
|
|
}
|
|
}
|
|
,
|
|
o.readString = o.readUTF8String,
|
|
o.writeVString = function(t, i) {
|
|
var r = void 0 === i;
|
|
if (r && (i = this.offset),
|
|
!this.noAssert) {
|
|
if ("string" != typeof t)
|
|
throw TypeError("Illegal str: Not a string");
|
|
if ("number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal offset: " + i + " (not an integer)");
|
|
if ((i >>>= 0) < 0 || i + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + i + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
var e = i
|
|
, n = c.calculateUTF16asUTF8(f(t), this.noAssert)[1]
|
|
, s = w.calculateVarint32(n)
|
|
, o = (i += s + n,
|
|
this.buffer.byteLength);
|
|
if (o < i && this.resize((o *= 2) > i ? o : i),
|
|
i = (i -= s + n) + this.writeVarint32(n, i),
|
|
c.encodeUTF16toUTF8(f(t), function(t) {
|
|
this.view[i++] = t
|
|
}
|
|
.bind(this)),
|
|
i !== e + n + s)
|
|
throw RangeError("Illegal range: Truncated data, " + i + " == " + (i + n + s));
|
|
return r ? (this.offset = i,
|
|
this) : i - e
|
|
}
|
|
,
|
|
o.readVString = function(t) {
|
|
var i = void 0 === t;
|
|
if (i && (t = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal offset: " + t + " (not an integer)");
|
|
if ((t >>>= 0) < 0 || t + 1 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + t + " (+1) <= " + this.buffer.byteLength)
|
|
}
|
|
var r = t
|
|
, e = this.readVarint32(t)
|
|
, e = this.readUTF8String(e.value, w.METRICS_BYTES, t += e.length);
|
|
return t += e.length,
|
|
i ? (this.offset = t,
|
|
e.string) : {
|
|
string: e.string,
|
|
length: t - r
|
|
}
|
|
}
|
|
,
|
|
o.append = function(t, i, r) {
|
|
"number" != typeof i && "string" == typeof i || (r = i,
|
|
i = void 0);
|
|
var e = void 0 === r;
|
|
if (e && (r = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof r || r % 1 != 0)
|
|
throw TypeError("Illegal offset: " + r + " (not an integer)");
|
|
if ((r >>>= 0) < 0 || r + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + r + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
var n, i = (t = t instanceof w ? t : w.wrap(t, i)).limit - t.offset;
|
|
return i <= 0 || ((n = this.buffer.byteLength) < (r += i) && this.resize((n *= 2) > r ? n : r),
|
|
r -= i,
|
|
this.view.set(t.view.subarray(t.offset, t.limit), r),
|
|
t.offset += i,
|
|
e && (this.offset += i)),
|
|
this
|
|
}
|
|
,
|
|
o.appendTo = function(t, i) {
|
|
return t.append(this, i),
|
|
this
|
|
}
|
|
,
|
|
o.assert = function(t) {
|
|
return this.noAssert = !t,
|
|
this
|
|
}
|
|
,
|
|
o.capacity = function() {
|
|
return this.buffer.byteLength
|
|
}
|
|
,
|
|
o.clear = function() {
|
|
return this.offset = 0,
|
|
this.limit = this.buffer.byteLength,
|
|
this.markedOffset = -1,
|
|
this
|
|
}
|
|
,
|
|
o.clone = function(t) {
|
|
var i = new w(0,this.littleEndian,this.noAssert);
|
|
return t ? (i.buffer = new ArrayBuffer(this.buffer.byteLength),
|
|
i.view = new Uint8Array(i.buffer)) : (i.buffer = this.buffer,
|
|
i.view = this.view),
|
|
i.offset = this.offset,
|
|
i.markedOffset = this.markedOffset,
|
|
i.limit = this.limit,
|
|
i
|
|
}
|
|
,
|
|
o.compact = function(t, i) {
|
|
if (void 0 === t && (t = this.offset),
|
|
void 0 === i && (i = this.limit),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal begin: Not an integer");
|
|
if (t >>>= 0,
|
|
"number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal end: Not an integer");
|
|
if (i >>>= 0,
|
|
t < 0 || i < t || i > this.buffer.byteLength)
|
|
throw RangeError("Illegal range: 0 <= " + t + " <= " + i + " <= " + this.buffer.byteLength)
|
|
}
|
|
var r, e, n;
|
|
return 0 === t && i === this.buffer.byteLength || (0 == (r = i - t) ? (this.buffer = s,
|
|
this.view = null,
|
|
0 <= this.markedOffset && (this.markedOffset -= t),
|
|
this.offset = 0,
|
|
this.limit = 0) : (e = new ArrayBuffer(r),
|
|
(n = new Uint8Array(e)).set(this.view.subarray(t, i)),
|
|
this.buffer = e,
|
|
this.view = n,
|
|
0 <= this.markedOffset && (this.markedOffset -= t),
|
|
this.offset = 0,
|
|
this.limit = r)),
|
|
this
|
|
}
|
|
,
|
|
o.copy = function(t, i) {
|
|
if (void 0 === t && (t = this.offset),
|
|
void 0 === i && (i = this.limit),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal begin: Not an integer");
|
|
if (t >>>= 0,
|
|
"number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal end: Not an integer");
|
|
if (i >>>= 0,
|
|
t < 0 || i < t || i > this.buffer.byteLength)
|
|
throw RangeError("Illegal range: 0 <= " + t + " <= " + i + " <= " + this.buffer.byteLength)
|
|
}
|
|
var r, e;
|
|
return t === i ? new w(0,this.littleEndian,this.noAssert) : ((e = new w(r = i - t,this.littleEndian,this.noAssert)).offset = 0,
|
|
e.limit = r,
|
|
0 <= e.markedOffset && (e.markedOffset -= t),
|
|
this.copyTo(e, 0, t, i),
|
|
e)
|
|
}
|
|
,
|
|
o.copyTo = function(t, i, r, e) {
|
|
var n, s;
|
|
if (!this.noAssert && !w.isByteBuffer(t))
|
|
throw TypeError("Illegal target: Not a ByteBuffer");
|
|
if (i = (s = void 0 === i) ? t.offset : 0 | i,
|
|
r = (n = void 0 === r) ? this.offset : 0 | r,
|
|
e = void 0 === e ? this.limit : 0 | e,
|
|
i < 0 || i > t.buffer.byteLength)
|
|
throw RangeError("Illegal target range: 0 <= " + i + " <= " + t.buffer.byteLength);
|
|
if (r < 0 || e > this.buffer.byteLength)
|
|
throw RangeError("Illegal source range: 0 <= " + r + " <= " + this.buffer.byteLength);
|
|
var o = e - r;
|
|
return 0 == o ? t : (t.ensureCapacity(i + o),
|
|
t.view.set(this.view.subarray(r, e), i),
|
|
n && (this.offset += o),
|
|
s && (t.offset += o),
|
|
this)
|
|
}
|
|
,
|
|
o.ensureCapacity = function(t) {
|
|
var i = this.buffer.byteLength;
|
|
return i < t ? this.resize((i *= 2) > t ? i : t) : this
|
|
}
|
|
,
|
|
o.fill = function(t, i, r) {
|
|
var e = void 0 === i;
|
|
if (e && (i = this.offset),
|
|
"string" == typeof t && 0 < t.length && (t = t.charCodeAt(0)),
|
|
void 0 === i && (i = this.offset),
|
|
void 0 === r && (r = this.limit),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal value: " + t + " (not an integer)");
|
|
if (t |= 0,
|
|
"number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal begin: Not an integer");
|
|
if (i >>>= 0,
|
|
"number" != typeof r || r % 1 != 0)
|
|
throw TypeError("Illegal end: Not an integer");
|
|
if (r >>>= 0,
|
|
i < 0 || r < i || r > this.buffer.byteLength)
|
|
throw RangeError("Illegal range: 0 <= " + i + " <= " + r + " <= " + this.buffer.byteLength)
|
|
}
|
|
if (!(r <= i)) {
|
|
for (; i < r; )
|
|
this.view[i++] = t;
|
|
e && (this.offset = i)
|
|
}
|
|
return this
|
|
}
|
|
,
|
|
o.flip = function() {
|
|
return this.limit = this.offset,
|
|
this.offset = 0,
|
|
this
|
|
}
|
|
,
|
|
o.mark = function(t) {
|
|
if (t = void 0 === t ? this.offset : t,
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal offset: " + t + " (not an integer)");
|
|
if ((t >>>= 0) < 0 || t + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + t + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
return this.markedOffset = t,
|
|
this
|
|
}
|
|
,
|
|
o.order = function(t) {
|
|
if (this.noAssert || "boolean" == typeof t)
|
|
return this.littleEndian = !!t,
|
|
this;
|
|
throw TypeError("Illegal littleEndian: Not a boolean")
|
|
}
|
|
,
|
|
o.LE = function(t) {
|
|
return this.littleEndian = void 0 === t || !!t,
|
|
this
|
|
}
|
|
,
|
|
o.BE = function(t) {
|
|
return this.littleEndian = void 0 !== t && !t,
|
|
this
|
|
}
|
|
,
|
|
o.prepend = function(t, i, r) {
|
|
"number" != typeof i && "string" == typeof i || (r = i,
|
|
i = void 0);
|
|
var e = void 0 === r;
|
|
if (e && (r = this.offset),
|
|
!this.noAssert) {
|
|
if ("number" != typeof r || r % 1 != 0)
|
|
throw TypeError("Illegal offset: " + r + " (not an integer)");
|
|
if ((r >>>= 0) < 0 || r + 0 > this.buffer.byteLength)
|
|
throw RangeError("Illegal offset: 0 <= " + r + " (+0) <= " + this.buffer.byteLength)
|
|
}
|
|
var n, s, o, i = (t = t instanceof w ? t : w.wrap(t, i)).limit - t.offset;
|
|
return i <= 0 || (0 < (n = i - r) ? (s = new ArrayBuffer(this.buffer.byteLength + n),
|
|
(o = new Uint8Array(s)).set(this.view.subarray(r, this.buffer.byteLength), i),
|
|
this.buffer = s,
|
|
this.view = o,
|
|
this.offset += n,
|
|
0 <= this.markedOffset && (this.markedOffset += n),
|
|
this.limit += n,
|
|
r += n) : new Uint8Array(this.buffer),
|
|
this.view.set(t.view.subarray(t.offset, t.limit), r - i),
|
|
t.offset = t.limit,
|
|
e && (this.offset -= i)),
|
|
this
|
|
}
|
|
,
|
|
o.prependTo = function(t, i) {
|
|
return t.prepend(this, i),
|
|
this
|
|
}
|
|
,
|
|
o.printDebug = function(t) {
|
|
(t = "function" != typeof t ? console.log.bind(console) : t)(this.toString() + "\n-------------------------------------------------------------------\n" + this.toDebug(!0))
|
|
}
|
|
,
|
|
o.remaining = function() {
|
|
return this.limit - this.offset
|
|
}
|
|
,
|
|
o.reset = function() {
|
|
return 0 <= this.markedOffset ? (this.offset = this.markedOffset,
|
|
this.markedOffset = -1) : this.offset = 0,
|
|
this
|
|
}
|
|
,
|
|
o.resize = function(t) {
|
|
if (!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal capacity: " + t + " (not an integer)");
|
|
if ((t |= 0) < 0)
|
|
throw RangeError("Illegal capacity: 0 <= " + t)
|
|
}
|
|
var i;
|
|
return this.buffer.byteLength < t && (t = new ArrayBuffer(t),
|
|
(i = new Uint8Array(t)).set(this.view),
|
|
this.buffer = t,
|
|
this.view = i),
|
|
this
|
|
}
|
|
,
|
|
o.reverse = function(t, i) {
|
|
if (void 0 === t && (t = this.offset),
|
|
void 0 === i && (i = this.limit),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal begin: Not an integer");
|
|
if (t >>>= 0,
|
|
"number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal end: Not an integer");
|
|
if (i >>>= 0,
|
|
t < 0 || i < t || i > this.buffer.byteLength)
|
|
throw RangeError("Illegal range: 0 <= " + t + " <= " + i + " <= " + this.buffer.byteLength)
|
|
}
|
|
return t !== i && Array.prototype.reverse.call(this.view.subarray(t, i)),
|
|
this
|
|
}
|
|
,
|
|
o.skip = function(t) {
|
|
if (!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal length: " + t + " (not an integer)");
|
|
t |= 0
|
|
}
|
|
var i = this.offset + t;
|
|
if (!this.noAssert && (i < 0 || i > this.buffer.byteLength))
|
|
throw RangeError("Illegal length: 0 <= " + this.offset + " + " + t + " <= " + this.buffer.byteLength);
|
|
return this.offset = i,
|
|
this
|
|
}
|
|
,
|
|
o.slice = function(t, i) {
|
|
if (void 0 === t && (t = this.offset),
|
|
void 0 === i && (i = this.limit),
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal begin: Not an integer");
|
|
if (t >>>= 0,
|
|
"number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal end: Not an integer");
|
|
if (i >>>= 0,
|
|
t < 0 || i < t || i > this.buffer.byteLength)
|
|
throw RangeError("Illegal range: 0 <= " + t + " <= " + i + " <= " + this.buffer.byteLength)
|
|
}
|
|
var r = this.clone();
|
|
return r.offset = t,
|
|
r.limit = i,
|
|
r
|
|
}
|
|
,
|
|
o.toBuffer = function(t) {
|
|
var i = this.offset
|
|
, r = this.limit;
|
|
if (!this.noAssert) {
|
|
if ("number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal offset: Not an integer");
|
|
if (i >>>= 0,
|
|
"number" != typeof r || r % 1 != 0)
|
|
throw TypeError("Illegal limit: Not an integer");
|
|
if (r >>>= 0,
|
|
i < 0 || r < i || r > this.buffer.byteLength)
|
|
throw RangeError("Illegal range: 0 <= " + i + " <= " + r + " <= " + this.buffer.byteLength)
|
|
}
|
|
return t || 0 !== i || r !== this.buffer.byteLength ? i === r ? s : (t = new ArrayBuffer(r - i),
|
|
new Uint8Array(t).set(new Uint8Array(this.buffer).subarray(i, r), 0),
|
|
t) : this.buffer
|
|
}
|
|
,
|
|
o.toArrayBuffer = o.toBuffer,
|
|
o.toString = function(t, i, r) {
|
|
if (void 0 === t)
|
|
return "ByteBufferAB(offset=" + this.offset + ",markedOffset=" + this.markedOffset + ",limit=" + this.limit + ",capacity=" + this.capacity() + ")";
|
|
switch ("number" == typeof t && (r = i = t = "utf8"),
|
|
t) {
|
|
case "utf8":
|
|
return this.toUTF8(i, r);
|
|
case "base64":
|
|
return this.toBase64(i, r);
|
|
case "hex":
|
|
return this.toHex(i, r);
|
|
case "binary":
|
|
return this.toBinary(i, r);
|
|
case "debug":
|
|
return this.toDebug();
|
|
case "columns":
|
|
return this.toColumns();
|
|
default:
|
|
throw Error("Unsupported encoding: " + t)
|
|
}
|
|
}
|
|
;
|
|
var u, l = function() {
|
|
for (var t = {}, n = [65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47], o = [], i = 0, r = n.length; i < r; ++i)
|
|
o[n[i]] = i;
|
|
return t.encode = function(t, i) {
|
|
for (var r, e; null !== (r = t()); )
|
|
i(n[r >> 2 & 63]),
|
|
e = (3 & r) << 4,
|
|
null !== (r = t()) ? (i(n[63 & ((e |= r >> 4 & 15) | r >> 4 & 15)]),
|
|
e = (15 & r) << 2,
|
|
null !== (r = t()) ? (i(n[63 & (e | r >> 6 & 3)]),
|
|
i(n[63 & r])) : (i(n[63 & e]),
|
|
i(61))) : (i(n[63 & e]),
|
|
i(61),
|
|
i(61))
|
|
}
|
|
,
|
|
t.decode = function(t, i) {
|
|
var r, e, n;
|
|
function s(t) {
|
|
throw Error("Illegal character code: " + t)
|
|
}
|
|
for (; null !== (r = t()); )
|
|
if (void 0 === (e = o[r]) && s(r),
|
|
null !== (r = t()) && (void 0 === (n = o[r]) && s(r),
|
|
i(e << 2 >>> 0 | (48 & n) >> 4),
|
|
null !== (r = t()))) {
|
|
if (void 0 === (e = o[r])) {
|
|
if (61 === r)
|
|
break;
|
|
s(r)
|
|
}
|
|
if (i((15 & n) << 4 >>> 0 | (60 & e) >> 2),
|
|
null !== (r = t())) {
|
|
if (void 0 === (n = o[r])) {
|
|
if (61 === r)
|
|
break;
|
|
s(r)
|
|
}
|
|
i((3 & e) << 6 >>> 0 | n)
|
|
}
|
|
}
|
|
}
|
|
,
|
|
t.test = function(t) {
|
|
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)
|
|
}
|
|
,
|
|
t
|
|
}(), c = (o.toBase64 = function(t, i) {
|
|
if (void 0 === t && (t = this.offset),
|
|
void 0 === i && (i = this.limit),
|
|
i |= 0,
|
|
(t |= 0) < 0 || i > this.capacity || i < t)
|
|
throw RangeError("begin, end");
|
|
var r;
|
|
return l.encode(function() {
|
|
return t < i ? this.view[t++] : null
|
|
}
|
|
.bind(this), r = a()),
|
|
r()
|
|
}
|
|
,
|
|
w.fromBase64 = function(t, i) {
|
|
if ("string" != typeof t)
|
|
throw TypeError("str");
|
|
var r = new w(t.length / 4 * 3,i)
|
|
, e = 0;
|
|
return l.decode(f(t), function(t) {
|
|
r.view[e++] = t
|
|
}),
|
|
r.limit = e,
|
|
r
|
|
}
|
|
,
|
|
w.btoa = function(t) {
|
|
return w.fromBinary(t).toBase64()
|
|
}
|
|
,
|
|
w.atob = function(t) {
|
|
return w.fromBase64(t).toBinary()
|
|
}
|
|
,
|
|
o.toBinary = function(t, i) {
|
|
if (void 0 === t && (t = this.offset),
|
|
void 0 === i && (i = this.limit),
|
|
i |= 0,
|
|
(t |= 0) < 0 || i > this.capacity() || i < t)
|
|
throw RangeError("begin, end");
|
|
if (t === i)
|
|
return "";
|
|
for (var r = [], e = []; t < i; )
|
|
r.push(this.view[t++]),
|
|
1024 <= r.length && (e.push(String.fromCharCode.apply(String, r)),
|
|
r = []);
|
|
return e.join("") + String.fromCharCode.apply(String, r)
|
|
}
|
|
,
|
|
w.fromBinary = function(t, i) {
|
|
if ("string" != typeof t)
|
|
throw TypeError("str");
|
|
for (var r, e = 0, n = t.length, s = new w(n,i); e < n; ) {
|
|
if (255 < (r = t.charCodeAt(e)))
|
|
throw RangeError("illegal char code: " + r);
|
|
s.view[e++] = r
|
|
}
|
|
return s.limit = n,
|
|
s
|
|
}
|
|
,
|
|
o.toDebug = function(t) {
|
|
for (var i, r = -1, e = this.buffer.byteLength, n = "", s = "", o = ""; r < e; ) {
|
|
if (-1 !== r && (n += (i = this.view[r]) < 16 ? "0" + i.toString(16).toUpperCase() : i.toString(16).toUpperCase(),
|
|
t) && (s += 32 < i && i < 127 ? String.fromCharCode(i) : "."),
|
|
++r,
|
|
t && 0 < r && r % 16 == 0 && r !== e) {
|
|
for (; n.length < 51; )
|
|
n += " ";
|
|
o += n + s + "\n",
|
|
n = s = ""
|
|
}
|
|
r === this.offset && r === this.limit ? n += r === this.markedOffset ? "!" : "|" : r === this.offset ? n += r === this.markedOffset ? "[" : "<" : r === this.limit ? n += r === this.markedOffset ? "]" : ">" : n += r === this.markedOffset ? "'" : t || 0 !== r && r !== e ? " " : ""
|
|
}
|
|
if (t && " " !== n) {
|
|
for (; n.length < 51; )
|
|
n += " ";
|
|
o += n + s + "\n"
|
|
}
|
|
return t ? o : n
|
|
}
|
|
,
|
|
w.fromDebug = function(t, i, r) {
|
|
for (var e, n, s = t.length, o = new w((s + 1) / 3 | 0,i,r), h = 0, f = 0, a = !1, u = !1, l = !1, c = !1, g = !1; h < s; ) {
|
|
switch (e = t.charAt(h++)) {
|
|
case "!":
|
|
if (!r) {
|
|
if (u || l || c) {
|
|
g = !0;
|
|
break
|
|
}
|
|
u = l = c = !0
|
|
}
|
|
o.offset = o.markedOffset = o.limit = f,
|
|
a = !1;
|
|
break;
|
|
case "|":
|
|
if (!r) {
|
|
if (u || c) {
|
|
g = !0;
|
|
break
|
|
}
|
|
u = c = !0
|
|
}
|
|
o.offset = o.limit = f,
|
|
a = !1;
|
|
break;
|
|
case "[":
|
|
if (!r) {
|
|
if (u || l) {
|
|
g = !0;
|
|
break
|
|
}
|
|
u = l = !0
|
|
}
|
|
o.offset = o.markedOffset = f,
|
|
a = !1;
|
|
break;
|
|
case "<":
|
|
if (!r) {
|
|
if (u) {
|
|
g = !0;
|
|
break
|
|
}
|
|
u = !0
|
|
}
|
|
o.offset = f,
|
|
a = !1;
|
|
break;
|
|
case "]":
|
|
if (!r) {
|
|
if (c || l) {
|
|
g = !0;
|
|
break
|
|
}
|
|
c = l = !0
|
|
}
|
|
o.limit = o.markedOffset = f,
|
|
a = !1;
|
|
break;
|
|
case ">":
|
|
if (!r) {
|
|
if (c) {
|
|
g = !0;
|
|
break
|
|
}
|
|
c = !0
|
|
}
|
|
o.limit = f,
|
|
a = !1;
|
|
break;
|
|
case "'":
|
|
if (!r) {
|
|
if (l) {
|
|
g = !0;
|
|
break
|
|
}
|
|
l = !0
|
|
}
|
|
o.markedOffset = f,
|
|
a = !1;
|
|
break;
|
|
case " ":
|
|
a = !1;
|
|
break;
|
|
default:
|
|
if (!r && a)
|
|
g = !0;
|
|
else {
|
|
if (n = parseInt(e + t.charAt(h++), 16),
|
|
!r && (isNaN(n) || n < 0 || 255 < n))
|
|
throw TypeError("Illegal str: Not a debug encoded string");
|
|
o.view[f++] = n,
|
|
a = !0
|
|
}
|
|
}
|
|
if (g)
|
|
throw TypeError("Illegal str: Invalid symbol at " + h)
|
|
}
|
|
if (!r) {
|
|
if (!u || !c)
|
|
throw TypeError("Illegal str: Missing offset or limit");
|
|
if (f < o.buffer.byteLength)
|
|
throw TypeError("Illegal str: Not a debug encoded string (is it hex?) " + f + " < " + s)
|
|
}
|
|
return o
|
|
}
|
|
,
|
|
o.toHex = function(t, i) {
|
|
if (t = void 0 === t ? this.offset : t,
|
|
i = void 0 === i ? this.limit : i,
|
|
!this.noAssert) {
|
|
if ("number" != typeof t || t % 1 != 0)
|
|
throw TypeError("Illegal begin: Not an integer");
|
|
if (t >>>= 0,
|
|
"number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal end: Not an integer");
|
|
if (i >>>= 0,
|
|
t < 0 || i < t || i > this.buffer.byteLength)
|
|
throw RangeError("Illegal range: 0 <= " + t + " <= " + i + " <= " + this.buffer.byteLength)
|
|
}
|
|
for (var r, e = new Array(i - t); t < i; )
|
|
(r = this.view[t++]) < 16 ? e.push("0", r.toString(16)) : e.push(r.toString(16));
|
|
return e.join("")
|
|
}
|
|
,
|
|
w.fromHex = function(t, i, r) {
|
|
if (!r) {
|
|
if ("string" != typeof t)
|
|
throw TypeError("Illegal str: Not a string");
|
|
if (t.length % 2 != 0)
|
|
throw TypeError("Illegal str: Length not a multiple of 2")
|
|
}
|
|
for (var e, n = t.length, s = new w(n / 2 | 0,i), o = 0, h = 0; o < n; o += 2) {
|
|
if (e = parseInt(t.substring(o, o + 2), 16),
|
|
!r && (!isFinite(e) || e < 0 || 255 < e))
|
|
throw TypeError("Illegal str: Contains non-hex characters");
|
|
s.view[h++] = e
|
|
}
|
|
return s.limit = h,
|
|
s
|
|
}
|
|
,
|
|
u = {
|
|
MAX_CODEPOINT: 1114111,
|
|
encodeUTF8: function(t, i) {
|
|
var r = null;
|
|
for ("number" == typeof t && (r = t,
|
|
t = function() {
|
|
return null
|
|
}
|
|
); null !== r || null !== (r = t()); )
|
|
r < 128 ? i(127 & r) : (r < 2048 ? i(r >> 6 & 31 | 192) : (r < 65536 ? i(r >> 12 & 15 | 224) : (i(r >> 18 & 7 | 240),
|
|
i(r >> 12 & 63 | 128)),
|
|
i(r >> 6 & 63 | 128)),
|
|
i(63 & r | 128)),
|
|
r = null
|
|
},
|
|
decodeUTF8: function(t, i) {
|
|
for (var r, e, n, s, o = function(t) {
|
|
t = t.slice(0, t.indexOf(null));
|
|
var i = Error(t.toString());
|
|
throw i.name = "TruncatedError",
|
|
i.bytes = t,
|
|
i
|
|
}; null !== (r = t()); )
|
|
if (0 == (128 & r))
|
|
i(r);
|
|
else if (192 == (224 & r))
|
|
null === (e = t()) && o([r, e]),
|
|
i((31 & r) << 6 | 63 & e);
|
|
else if (224 == (240 & r))
|
|
null !== (e = t()) && null !== (n = t()) || o([r, e, n]),
|
|
i((15 & r) << 12 | (63 & e) << 6 | 63 & n);
|
|
else {
|
|
if (240 != (248 & r))
|
|
throw RangeError("Illegal starting byte: " + r);
|
|
null !== (e = t()) && null !== (n = t()) && null !== (s = t()) || o([r, e, n, s]),
|
|
i((7 & r) << 18 | (63 & e) << 12 | (63 & n) << 6 | 63 & s)
|
|
}
|
|
},
|
|
UTF16toUTF8: function(t, i) {
|
|
for (var r, e = null; null !== (r = null !== e ? e : t()); )
|
|
55296 <= r && r <= 57343 && null !== (e = t()) && 56320 <= e && e <= 57343 ? (i(1024 * (r - 55296) + e - 56320 + 65536),
|
|
e = null) : i(r);
|
|
null !== e && i(e)
|
|
},
|
|
UTF8toUTF16: function(t, i) {
|
|
var r = null;
|
|
for ("number" == typeof t && (r = t,
|
|
t = function() {
|
|
return null
|
|
}
|
|
); null !== r || null !== (r = t()); )
|
|
r <= 65535 ? i(r) : (i(55296 + ((r -= 65536) >> 10)),
|
|
i(r % 1024 + 56320)),
|
|
r = null
|
|
},
|
|
encodeUTF16toUTF8: function(t, i) {
|
|
u.UTF16toUTF8(t, function(t) {
|
|
u.encodeUTF8(t, i)
|
|
})
|
|
},
|
|
decodeUTF8toUTF16: function(t, i) {
|
|
u.decodeUTF8(t, function(t) {
|
|
u.UTF8toUTF16(t, i)
|
|
})
|
|
},
|
|
calculateCodePoint: function(t) {
|
|
return t < 128 ? 1 : t < 2048 ? 2 : t < 65536 ? 3 : 4
|
|
},
|
|
calculateUTF8: function(t) {
|
|
for (var i, r = 0; null !== (i = t()); )
|
|
r += i < 128 ? 1 : i < 2048 ? 2 : i < 65536 ? 3 : 4;
|
|
return r
|
|
},
|
|
calculateUTF16asUTF8: function(t) {
|
|
var i = 0
|
|
, r = 0;
|
|
return u.UTF16toUTF8(t, function(t) {
|
|
++i,
|
|
r += t < 128 ? 1 : t < 2048 ? 2 : t < 65536 ? 3 : 4
|
|
}),
|
|
[i, r]
|
|
}
|
|
});
|
|
return o.toUTF8 = function(i, r) {
|
|
if (void 0 === i && (i = this.offset),
|
|
void 0 === r && (r = this.limit),
|
|
!this.noAssert) {
|
|
if ("number" != typeof i || i % 1 != 0)
|
|
throw TypeError("Illegal begin: Not an integer");
|
|
if (i >>>= 0,
|
|
"number" != typeof r || r % 1 != 0)
|
|
throw TypeError("Illegal end: Not an integer");
|
|
if (r >>>= 0,
|
|
i < 0 || r < i || r > this.buffer.byteLength)
|
|
throw RangeError("Illegal range: 0 <= " + i + " <= " + r + " <= " + this.buffer.byteLength)
|
|
}
|
|
var t;
|
|
try {
|
|
c.decodeUTF8toUTF16(function() {
|
|
return i < r ? this.view[i++] : null
|
|
}
|
|
.bind(this), t = a())
|
|
} catch (t) {
|
|
if (i !== r)
|
|
throw RangeError("Illegal range: Truncated data, " + i + " != " + r)
|
|
}
|
|
return t()
|
|
}
|
|
,
|
|
w.fromUTF8 = function(t, i, r) {
|
|
var e, n;
|
|
if (r || "string" == typeof t)
|
|
return e = new w(c.calculateUTF16asUTF8(f(t), !0)[1],i,r),
|
|
n = 0,
|
|
c.encodeUTF16toUTF8(f(t), function(t) {
|
|
e.view[n++] = t
|
|
}),
|
|
e.limit = n,
|
|
e;
|
|
throw TypeError("Illegal str: Not a string")
|
|
}
|
|
,
|
|
w
|
|
}),
|
|
function(t, i) {
|
|
"function" == typeof define && define.amd || "function" != typeof require || "object" != typeof module || !module || !module.exports ? (t.dcodeIO = t.dcodeIO || {}).ProtoBuf = i(t.dcodeIO.ByteBuffer) : module.exports = i(require("bytebuffer"))
|
|
}(this, function(g, t) {
|
|
"use strict";
|
|
var n, s, o, a, i, h, f, w, u, r, l, e, c, p, v, d = {};
|
|
function y(t) {
|
|
this.source = t + "",
|
|
this.index = 0,
|
|
this.line = 1,
|
|
this.stack = [],
|
|
this.Rt = null
|
|
}
|
|
function E(t) {
|
|
this.tn = new y(t),
|
|
this.proto3 = !1
|
|
}
|
|
function b(t, i) {
|
|
var r = -1
|
|
, e = 1;
|
|
if ("-" == t.charAt(0) && (e = -1,
|
|
t = t.substring(1)),
|
|
o.NUMBER_DEC.test(t))
|
|
r = parseInt(t);
|
|
else if (o.NUMBER_HEX.test(t))
|
|
r = parseInt(t.substring(2), 16);
|
|
else {
|
|
if (!o.NUMBER_OCT.test(t))
|
|
throw Error("illegal id value: " + (e < 0 ? "-" : "") + t);
|
|
r = parseInt(t.substring(1), 8)
|
|
}
|
|
if (r = e * r | 0,
|
|
!i && r < 0)
|
|
throw Error("illegal id value: " + (e < 0 ? "-" : "") + t);
|
|
return r
|
|
}
|
|
function m(t) {
|
|
var i = 1;
|
|
if ("-" == t.charAt(0) && (i = -1,
|
|
t = t.substring(1)),
|
|
o.NUMBER_DEC.test(t))
|
|
return i * parseInt(t, 10);
|
|
if (o.NUMBER_HEX.test(t))
|
|
return i * parseInt(t.substring(2), 16);
|
|
if (o.NUMBER_OCT.test(t))
|
|
return i * parseInt(t.substring(1), 8);
|
|
if ("inf" === t)
|
|
return i * (1 / 0);
|
|
if ("nan" === t)
|
|
return NaN;
|
|
if (o.NUMBER_FLT.test(t))
|
|
return i * parseFloat(t);
|
|
throw Error("illegal number value: " + (i < 0 ? "-" : "") + t)
|
|
}
|
|
function I(t, i, r) {
|
|
void 0 === t[i] ? t[i] = r : (Array.isArray(t[i]) || (t[i] = [t[i]]),
|
|
t[i].push(r))
|
|
}
|
|
function T(t) {
|
|
this.ns = new h.Namespace(this,null,""),
|
|
this.ptr = this.ns,
|
|
this.resolved = !1,
|
|
this.result = null,
|
|
this.files = {},
|
|
this.importRoot = null,
|
|
this.options = t || {}
|
|
}
|
|
function A(t, i) {
|
|
if (!t.map)
|
|
throw Error("field is not a map");
|
|
if (this.field = t,
|
|
this.keyElem = new f.Element(t.keyType,null,!0,t.syntax),
|
|
this.valueElem = new f.Element(t.type,t.resolvedType,!1,t.syntax),
|
|
this.map = {},
|
|
Object.defineProperty(this, "size", {
|
|
get: function() {
|
|
return Object.keys(this.map).length
|
|
}
|
|
}),
|
|
i)
|
|
for (var r = Object.keys(i), e = 0; e < r.length; e++) {
|
|
var n = this.keyElem.valueFromString(r[e])
|
|
, s = this.valueElem.verifyValue(i[r[e]]);
|
|
this.map[this.keyElem.valueToString(n)] = {
|
|
key: n,
|
|
value: s
|
|
}
|
|
}
|
|
}
|
|
function k(t) {
|
|
var i = 0;
|
|
return {
|
|
next: function() {
|
|
return i < t.length ? {
|
|
done: !1,
|
|
value: t[i++]
|
|
} : {
|
|
done: !0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return d.ByteBuffer = g,
|
|
d.Long = g.Long || null,
|
|
d.VERSION = "5.0.1",
|
|
d.WIRE_TYPES = {},
|
|
d.WIRE_TYPES.VARINT = 0,
|
|
d.WIRE_TYPES.BITS64 = 1,
|
|
d.WIRE_TYPES.LDELIM = 2,
|
|
d.WIRE_TYPES.STARTGROUP = 3,
|
|
d.WIRE_TYPES.ENDGROUP = 4,
|
|
d.WIRE_TYPES.BITS32 = 5,
|
|
d.PACKABLE_WIRE_TYPES = [d.WIRE_TYPES.VARINT, d.WIRE_TYPES.BITS64, d.WIRE_TYPES.BITS32],
|
|
d.TYPES = {
|
|
int32: {
|
|
name: "int32",
|
|
wireType: d.WIRE_TYPES.VARINT,
|
|
defaultValue: 0
|
|
},
|
|
uint32: {
|
|
name: "uint32",
|
|
wireType: d.WIRE_TYPES.VARINT,
|
|
defaultValue: 0
|
|
},
|
|
sint32: {
|
|
name: "sint32",
|
|
wireType: d.WIRE_TYPES.VARINT,
|
|
defaultValue: 0
|
|
},
|
|
int64: {
|
|
name: "int64",
|
|
wireType: d.WIRE_TYPES.VARINT,
|
|
defaultValue: 0
|
|
},
|
|
uint64: {
|
|
name: "uint64",
|
|
wireType: d.WIRE_TYPES.VARINT,
|
|
defaultValue: d.Long ? d.Long.UZERO : void 0
|
|
},
|
|
sint64: {
|
|
name: "sint64",
|
|
wireType: d.WIRE_TYPES.VARINT,
|
|
defaultValue: d.Long ? d.Long.ZERO : void 0
|
|
},
|
|
bool: {
|
|
name: "bool",
|
|
wireType: d.WIRE_TYPES.VARINT,
|
|
defaultValue: !1
|
|
},
|
|
double: {
|
|
name: "double",
|
|
wireType: d.WIRE_TYPES.BITS64,
|
|
defaultValue: 0
|
|
},
|
|
string: {
|
|
name: "string",
|
|
wireType: d.WIRE_TYPES.LDELIM,
|
|
defaultValue: ""
|
|
},
|
|
bytes: {
|
|
name: "bytes",
|
|
wireType: d.WIRE_TYPES.LDELIM,
|
|
defaultValue: null
|
|
},
|
|
fixed32: {
|
|
name: "fixed32",
|
|
wireType: d.WIRE_TYPES.BITS32,
|
|
defaultValue: 0
|
|
},
|
|
sfixed32: {
|
|
name: "sfixed32",
|
|
wireType: d.WIRE_TYPES.BITS32,
|
|
defaultValue: 0
|
|
},
|
|
fixed64: {
|
|
name: "fixed64",
|
|
wireType: d.WIRE_TYPES.BITS64,
|
|
defaultValue: d.Long ? d.Long.UZERO : void 0
|
|
},
|
|
sfixed64: {
|
|
name: "sfixed64",
|
|
wireType: d.WIRE_TYPES.BITS64,
|
|
defaultValue: d.Long ? d.Long.ZERO : void 0
|
|
},
|
|
float: {
|
|
name: "float",
|
|
wireType: d.WIRE_TYPES.BITS32,
|
|
defaultValue: 0
|
|
},
|
|
enum: {
|
|
name: "enum",
|
|
wireType: d.WIRE_TYPES.VARINT,
|
|
defaultValue: 0
|
|
},
|
|
message: {
|
|
name: "message",
|
|
wireType: d.WIRE_TYPES.LDELIM,
|
|
defaultValue: null
|
|
},
|
|
group: {
|
|
name: "group",
|
|
wireType: d.WIRE_TYPES.STARTGROUP,
|
|
defaultValue: null
|
|
}
|
|
},
|
|
d.MAP_KEY_TYPES = [d.TYPES.int32, d.TYPES.sint32, d.TYPES.sfixed32, d.TYPES.uint32, d.TYPES.fixed32, d.TYPES.int64, d.TYPES.sint64, d.TYPES.sfixed64, d.TYPES.uint64, d.TYPES.fixed64, d.TYPES.bool, d.TYPES.string, d.TYPES.bytes],
|
|
d.ID_MIN = 1,
|
|
d.ID_MAX = 536870911,
|
|
d.convertFieldsToCamelCase = !1,
|
|
d.populateAccessors = !0,
|
|
d.populateDefaults = !0,
|
|
d.Util = ((n = {}).IS_NODE = !("object" != typeof process || process + "" != "[object process]" || process.browser),
|
|
n.XHR = function() {
|
|
for (var t = [function() {
|
|
return new XMLHttpRequest
|
|
}
|
|
, function() {
|
|
return new ActiveXObject("Msxml2.XMLHTTP")
|
|
}
|
|
, function() {
|
|
return new ActiveXObject("Msxml3.XMLHTTP")
|
|
}
|
|
, function() {
|
|
return new ActiveXObject("Microsoft.XMLHTTP")
|
|
}
|
|
], i = null, r = 0; r < t.length; r++) {
|
|
try {
|
|
i = t[r]()
|
|
} catch (t) {
|
|
continue
|
|
}
|
|
break
|
|
}
|
|
if (i)
|
|
return i;
|
|
throw Error("XMLHttpRequest is not supported")
|
|
}
|
|
,
|
|
n.fetch = function(t, r) {
|
|
if (r && "function" != typeof r && (r = null),
|
|
n.IS_NODE) {
|
|
var i = require("fs");
|
|
if (r)
|
|
i.readFile(t, function(t, i) {
|
|
r(t ? null : "" + i)
|
|
});
|
|
else
|
|
try {
|
|
return i.readFileSync(t)
|
|
} catch (t) {
|
|
return null
|
|
}
|
|
} else {
|
|
var e = n.XHR();
|
|
if (e.open("GET", t, !!r),
|
|
e.setRequestHeader("Accept", "text/plain"),
|
|
"function" == typeof e.overrideMimeType && e.overrideMimeType("text/plain"),
|
|
!r)
|
|
return e.send(null),
|
|
200 == e.status || 0 == e.status && "string" == typeof e.responseText ? e.responseText : null;
|
|
e.onreadystatechange = function() {
|
|
4 == e.readyState && (200 == e.status || 0 == e.status && "string" == typeof e.responseText ? r(e.responseText) : r(null))
|
|
}
|
|
,
|
|
4 != e.readyState && e.send(null)
|
|
}
|
|
}
|
|
,
|
|
n.toCamelCase = function(t) {
|
|
return t.replace(/_([a-zA-Z])/g, function(t, i) {
|
|
return i.toUpperCase()
|
|
})
|
|
}
|
|
,
|
|
n),
|
|
d.Lang = {
|
|
DELIM: /[\s\{\}=;:\[\],'"\(\)<>]/g,
|
|
RULE: /^(?:required|optional|repeated|map)$/,
|
|
TYPE: /^(?:double|float|int32|uint32|sint32|int64|uint64|sint64|fixed32|sfixed32|fixed64|sfixed64|bool|string|bytes)$/,
|
|
NAME: /^[a-zA-Z_][a-zA-Z_0-9]*$/,
|
|
TYPEDEF: /^[a-zA-Z][a-zA-Z_0-9]*$/,
|
|
TYPEREF: /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)+$/,
|
|
FQTYPEREF: /^(?:\.[a-zA-Z][a-zA-Z_0-9]*)+$/,
|
|
NUMBER: /^-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+|([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?)|inf|nan)$/,
|
|
NUMBER_DEC: /^(?:[1-9][0-9]*|0)$/,
|
|
NUMBER_HEX: /^0[xX][0-9a-fA-F]+$/,
|
|
NUMBER_OCT: /^0[0-7]+$/,
|
|
NUMBER_FLT: /^([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?|inf|nan)$/,
|
|
BOOL: /^(?:true|false)$/i,
|
|
ID: /^(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,
|
|
NEGID: /^\-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,
|
|
WHITESPACE: /\s/,
|
|
STRING: /(?:"([^"\\]*(?:\\.[^"\\]*)*)")|(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,
|
|
STRING_DQ: /(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,
|
|
STRING_SQ: /(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g
|
|
},
|
|
d.DotProto = (o = (s = d).Lang,
|
|
r = {},
|
|
(e = y.prototype).Ot = function() {
|
|
var t = '"' === this.Rt ? o.STRING_DQ : o.STRING_SQ
|
|
, i = (t.lastIndex = this.index - 1,
|
|
t.exec(this.source));
|
|
if (i)
|
|
return this.index = t.lastIndex,
|
|
this.stack.push(this.Rt),
|
|
this.Rt = null,
|
|
i[1];
|
|
throw Error("unterminated string")
|
|
}
|
|
,
|
|
e.next = function() {
|
|
if (0 < this.stack.length)
|
|
return this.stack.shift();
|
|
if (this.index >= this.source.length)
|
|
return null;
|
|
if (null !== this.Rt)
|
|
return this.Ot();
|
|
var t, i, r;
|
|
do {
|
|
for (t = !1; o.WHITESPACE.test(r = this.source.charAt(this.index)); )
|
|
if ("\n" === r && ++this.line,
|
|
++this.index === this.source.length)
|
|
return null;
|
|
if ("/" === this.source.charAt(this.index)) {
|
|
if (++this.index,
|
|
"/" === this.source.charAt(this.index)) {
|
|
for (; "\n" !== this.source.charAt(++this.index); )
|
|
if (this.index == this.source.length)
|
|
return null;
|
|
++this.index,
|
|
++this.line
|
|
} else {
|
|
if ("*" !== (r = this.source.charAt(this.index)))
|
|
return "/";
|
|
do {
|
|
if ("\n" === r && ++this.line,
|
|
++this.index === this.source.length)
|
|
return null
|
|
} while (i = r,
|
|
r = this.source.charAt(this.index),
|
|
"*" !== i || "/" !== r);
|
|
++this.index
|
|
}
|
|
t = !0
|
|
}
|
|
} while (t);
|
|
if (this.index === this.source.length)
|
|
return null;
|
|
var e = this.index;
|
|
if (o.DELIM.lastIndex = 0,
|
|
!o.DELIM.test(this.source.charAt(e++)))
|
|
for (; e < this.source.length && !o.DELIM.test(this.source.charAt(e)); )
|
|
++e;
|
|
var n = this.source.substring(this.index, this.index = e);
|
|
return '"' !== n && "'" !== n || (this.Rt = n),
|
|
n
|
|
}
|
|
,
|
|
e.peek = function() {
|
|
if (0 === this.stack.length) {
|
|
var t = this.next();
|
|
if (null === t)
|
|
return null;
|
|
this.stack.push(t)
|
|
}
|
|
return this.stack[0]
|
|
}
|
|
,
|
|
e.skip = function(t) {
|
|
var i = this.next();
|
|
if (i !== t)
|
|
throw Error("illegal '" + i + "', '" + t + "' expected")
|
|
}
|
|
,
|
|
e.omit = function(t) {
|
|
return this.peek() === t && (this.next(),
|
|
!0)
|
|
}
|
|
,
|
|
e.toString = function() {
|
|
return "Tokenizer (" + this.index + "/" + this.source.length + " at line " + this.line + ")"
|
|
}
|
|
,
|
|
r.Tokenizer = y,
|
|
(e = E.prototype).parse = function() {
|
|
var t, i, r = {
|
|
name: "[ROOT]",
|
|
package: null,
|
|
messages: [],
|
|
enums: [],
|
|
imports: [],
|
|
options: {},
|
|
services: []
|
|
}, e = !0;
|
|
try {
|
|
for (; t = this.tn.next(); )
|
|
switch (t) {
|
|
case "package":
|
|
if (!e || null !== r.package)
|
|
throw Error("unexpected 'package'");
|
|
if (t = this.tn.next(),
|
|
!o.TYPEREF.test(t))
|
|
throw Error("illegal package name: " + t);
|
|
this.tn.skip(";"),
|
|
r.package = t;
|
|
break;
|
|
case "import":
|
|
if (!e)
|
|
throw Error("unexpected 'import'");
|
|
"public" !== (t = this.tn.peek()) && !(i = "weak" === t) || this.tn.next(),
|
|
t = this.Ot(),
|
|
this.tn.skip(";"),
|
|
i || r.imports.push(t);
|
|
break;
|
|
case "syntax":
|
|
if (!e)
|
|
throw Error("unexpected 'syntax'");
|
|
this.tn.skip("="),
|
|
"proto3" === (r.syntax = this.Ot()) && (this.proto3 = !0),
|
|
this.tn.skip(";");
|
|
break;
|
|
case "message":
|
|
this.Nt(r, null),
|
|
e = !1;
|
|
break;
|
|
case "enum":
|
|
this.Mt(r),
|
|
e = !1;
|
|
break;
|
|
case "option":
|
|
this.St(r);
|
|
break;
|
|
case "service":
|
|
this.jt(r);
|
|
break;
|
|
case "extend":
|
|
this.xt(r);
|
|
break;
|
|
default:
|
|
throw Error("unexpected '" + t + "'")
|
|
}
|
|
} catch (t) {
|
|
throw t.message = "Parse error at line " + this.tn.line + ": " + t.message,
|
|
t
|
|
}
|
|
return delete r.name,
|
|
r
|
|
}
|
|
,
|
|
E.parse = function(t) {
|
|
return new E(t).parse()
|
|
}
|
|
,
|
|
e.Ot = function() {
|
|
var t, i = "";
|
|
do {
|
|
if ("'" !== (t = this.tn.next()) && '"' !== t)
|
|
throw Error("illegal string delimiter: " + t)
|
|
} while (i += this.tn.next(),
|
|
this.tn.skip(t),
|
|
'"' === this.tn.peek());
|
|
return i
|
|
}
|
|
,
|
|
e.Ut = function(t) {
|
|
var i = this.tn.peek();
|
|
if ('"' === i || "'" === i)
|
|
return this.Ot();
|
|
if (this.tn.next(),
|
|
o.NUMBER.test(i))
|
|
return m(i);
|
|
if (o.BOOL.test(i))
|
|
return "true" === i.toLowerCase();
|
|
if (t && o.TYPEREF.test(i))
|
|
return i;
|
|
throw Error("illegal value: " + i)
|
|
}
|
|
,
|
|
e.St = function(t, i) {
|
|
var r = this.tn.next()
|
|
, e = !1;
|
|
if ("(" === r && (e = !0,
|
|
r = this.tn.next()),
|
|
!o.TYPEREF.test(r))
|
|
throw Error("illegal option name: " + r);
|
|
var n = r;
|
|
e && (this.tn.skip(")"),
|
|
n = "(" + n + ")",
|
|
r = this.tn.peek(),
|
|
o.FQTYPEREF.test(r)) && (n += r,
|
|
this.tn.next()),
|
|
this.tn.skip("="),
|
|
this.Ct(t, n),
|
|
i || this.tn.skip(";")
|
|
}
|
|
,
|
|
e.Ct = function(t, i) {
|
|
var r;
|
|
if ("{" !== this.tn.peek())
|
|
I(t.options, i, this.Ut(!0));
|
|
else
|
|
for (this.tn.skip("{"); "}" !== (r = this.tn.next()); ) {
|
|
if (!o.NAME.test(r))
|
|
throw Error("illegal option name: " + i + "." + r);
|
|
this.tn.omit(":") ? I(t.options, i + "." + r, this.Ut(!0)) : this.Ct(t, i + "." + r)
|
|
}
|
|
}
|
|
,
|
|
e.jt = function(t) {
|
|
var i = this.tn.next();
|
|
if (!o.NAME.test(i))
|
|
throw Error("illegal service name at line " + this.tn.line + ": " + i);
|
|
var r = {
|
|
name: i,
|
|
rpc: {},
|
|
options: {}
|
|
};
|
|
for (this.tn.skip("{"); "}" !== (i = this.tn.next()); )
|
|
if ("option" === i)
|
|
this.St(r);
|
|
else {
|
|
if ("rpc" !== i)
|
|
throw Error("illegal service token: " + i);
|
|
this._t(r)
|
|
}
|
|
this.tn.omit(";"),
|
|
t.services.push(r)
|
|
}
|
|
,
|
|
e._t = function(t) {
|
|
var i = this.tn.next();
|
|
if (!o.NAME.test(i))
|
|
throw Error("illegal rpc service method name: " + i);
|
|
var r = i
|
|
, e = {
|
|
request: null,
|
|
response: null,
|
|
request_stream: !1,
|
|
response_stream: !1,
|
|
options: {}
|
|
};
|
|
if (this.tn.skip("("),
|
|
"stream" === (i = this.tn.next()).toLowerCase() && (e.request_stream = !0,
|
|
i = this.tn.next()),
|
|
!o.TYPEREF.test(i))
|
|
throw Error("illegal rpc service request type: " + i);
|
|
if (e.request = i,
|
|
this.tn.skip(")"),
|
|
"returns" !== (i = this.tn.next()).toLowerCase())
|
|
throw Error("illegal rpc service request type delimiter: " + i);
|
|
if (this.tn.skip("("),
|
|
"stream" === (i = this.tn.next()).toLowerCase() && (e.response_stream = !0,
|
|
i = this.tn.next()),
|
|
e.response = i,
|
|
this.tn.skip(")"),
|
|
"{" === (i = this.tn.peek())) {
|
|
for (this.tn.next(); "}" !== (i = this.tn.next()); ) {
|
|
if ("option" !== i)
|
|
throw Error("illegal rpc service token: " + i);
|
|
this.St(e)
|
|
}
|
|
this.tn.omit(";")
|
|
} else
|
|
this.tn.skip(";");
|
|
void 0 === t.rpc && (t.rpc = {}),
|
|
t.rpc[r] = e
|
|
}
|
|
,
|
|
e.Nt = function(t, i) {
|
|
var r = !!i
|
|
, e = this.tn.next()
|
|
, n = {
|
|
name: "",
|
|
fields: [],
|
|
enums: [],
|
|
messages: [],
|
|
options: {},
|
|
services: [],
|
|
oneofs: {}
|
|
};
|
|
if (!o.NAME.test(e))
|
|
throw Error("illegal " + (r ? "group" : "message") + " name: " + e);
|
|
for (n.name = e,
|
|
r && (this.tn.skip("="),
|
|
i.id = b(this.tn.next()),
|
|
n.isGroup = !0),
|
|
"[" === this.tn.peek() && i && this.Bt(i),
|
|
this.tn.skip("{"); "}" !== (e = this.tn.next()); )
|
|
if (o.RULE.test(e))
|
|
this.Ft(n, e);
|
|
else if ("oneof" === e)
|
|
this.Lt(n);
|
|
else if ("enum" === e)
|
|
this.Mt(n);
|
|
else if ("message" === e)
|
|
this.Nt(n);
|
|
else if ("option" === e)
|
|
this.St(n);
|
|
else if ("service" === e)
|
|
this.jt(n);
|
|
else if ("extensions" === e)
|
|
n.hasOwnProperty("extensions") ? n.extensions = n.extensions.concat(this.Pt()) : n.extensions = this.Pt();
|
|
else if ("reserved" === e)
|
|
this.$t();
|
|
else if ("extend" === e)
|
|
this.xt(n);
|
|
else {
|
|
if (!o.TYPEREF.test(e))
|
|
throw Error("illegal message token: " + e);
|
|
if (!this.proto3)
|
|
throw Error("illegal field rule: " + e);
|
|
this.Ft(n, "optional", e)
|
|
}
|
|
return this.tn.omit(";"),
|
|
t.messages.push(n),
|
|
n
|
|
}
|
|
,
|
|
e.$t = function() {
|
|
for (; ";" !== this.tn.peek(); )
|
|
this.tn.next();
|
|
this.tn.skip(";")
|
|
}
|
|
,
|
|
e.Ft = function(t, i, r) {
|
|
if (!o.RULE.test(i))
|
|
throw Error("illegal message field rule: " + i);
|
|
var e, n = {
|
|
rule: i,
|
|
type: "",
|
|
name: "",
|
|
options: {},
|
|
id: 0
|
|
};
|
|
if ("map" === i) {
|
|
if (r)
|
|
throw Error("illegal type: " + r);
|
|
if (this.tn.skip("<"),
|
|
e = this.tn.next(),
|
|
!o.TYPE.test(e) && !o.TYPEREF.test(e))
|
|
throw Error("illegal message field type: " + e);
|
|
if (n.keytype = e,
|
|
this.tn.skip(","),
|
|
e = this.tn.next(),
|
|
!o.TYPE.test(e) && !o.TYPEREF.test(e))
|
|
throw Error("illegal message field: " + e);
|
|
if (n.type = e,
|
|
this.tn.skip(">"),
|
|
e = this.tn.next(),
|
|
!o.NAME.test(e))
|
|
throw Error("illegal message field name: " + e);
|
|
n.name = e,
|
|
this.tn.skip("="),
|
|
n.id = b(this.tn.next()),
|
|
"[" === (e = this.tn.peek()) && this.Bt(n),
|
|
this.tn.skip(";")
|
|
} else if ("group" === (r = void 0 !== r ? r : this.tn.next())) {
|
|
i = this.Nt(t, n);
|
|
if (!/^[A-Z]/.test(i.name))
|
|
throw Error("illegal group name: " + i.name);
|
|
n.type = i.name,
|
|
n.name = i.name.toLowerCase(),
|
|
this.tn.omit(";")
|
|
} else {
|
|
if (!o.TYPE.test(r) && !o.TYPEREF.test(r))
|
|
throw Error("illegal message field type: " + r);
|
|
if (n.type = r,
|
|
e = this.tn.next(),
|
|
!o.NAME.test(e))
|
|
throw Error("illegal message field name: " + e);
|
|
n.name = e,
|
|
this.tn.skip("="),
|
|
n.id = b(this.tn.next()),
|
|
"[" === (e = this.tn.peek()) && this.Bt(n),
|
|
this.tn.skip(";")
|
|
}
|
|
return t.fields.push(n),
|
|
n
|
|
}
|
|
,
|
|
e.Lt = function(t) {
|
|
var i = this.tn.next();
|
|
if (!o.NAME.test(i))
|
|
throw Error("illegal oneof name: " + i);
|
|
var r, e = i, n = [];
|
|
for (this.tn.skip("{"); "}" !== (i = this.tn.next()); )
|
|
(r = this.Ft(t, "optional", i)).oneof = e,
|
|
n.push(r.id);
|
|
this.tn.omit(";"),
|
|
t.oneofs[e] = n
|
|
}
|
|
,
|
|
e.Bt = function(t) {
|
|
this.tn.skip("[");
|
|
for (var i = !0; "]" !== this.tn.peek(); )
|
|
i || this.tn.skip(","),
|
|
this.St(t, !0),
|
|
i = !1;
|
|
this.tn.next()
|
|
}
|
|
,
|
|
e.Mt = function(t) {
|
|
var i = {
|
|
name: "",
|
|
values: [],
|
|
options: {}
|
|
}
|
|
, r = this.tn.next();
|
|
if (!o.NAME.test(r))
|
|
throw Error("illegal name: " + r);
|
|
for (i.name = r,
|
|
this.tn.skip("{"); "}" !== (r = this.tn.next()); )
|
|
if ("option" === r)
|
|
this.St(i);
|
|
else {
|
|
if (!o.NAME.test(r))
|
|
throw Error("illegal name: " + r);
|
|
this.tn.skip("=");
|
|
var e = {
|
|
name: r,
|
|
id: b(this.tn.next(), !0)
|
|
};
|
|
"[" === (r = this.tn.peek()) && this.Bt({
|
|
options: {}
|
|
}),
|
|
this.tn.skip(";"),
|
|
i.values.push(e)
|
|
}
|
|
this.tn.omit(";"),
|
|
t.enums.push(i)
|
|
}
|
|
,
|
|
e.Pt = function() {
|
|
var t, i, r, e = [];
|
|
do {
|
|
for (i = []; ; ) {
|
|
switch (t = this.tn.next()) {
|
|
case "min":
|
|
r = s.ID_MIN;
|
|
break;
|
|
case "max":
|
|
r = s.ID_MAX;
|
|
break;
|
|
default:
|
|
r = m(t)
|
|
}
|
|
if (i.push(r),
|
|
2 === i.length)
|
|
break;
|
|
if ("to" !== this.tn.peek()) {
|
|
i.push(r);
|
|
break
|
|
}
|
|
this.tn.next()
|
|
}
|
|
} while (e.push(i),
|
|
this.tn.omit(","));
|
|
return this.tn.skip(";"),
|
|
e
|
|
}
|
|
,
|
|
e.xt = function(t) {
|
|
var i = this.tn.next();
|
|
if (!o.TYPEREF.test(i))
|
|
throw Error("illegal extend reference: " + i);
|
|
var r = {
|
|
ref: i,
|
|
fields: []
|
|
};
|
|
for (this.tn.skip("{"); "}" !== (i = this.tn.next()); )
|
|
if (o.RULE.test(i))
|
|
this.Ft(r, i);
|
|
else {
|
|
if (!o.TYPEREF.test(i))
|
|
throw Error("illegal extend token: " + i);
|
|
if (!this.proto3)
|
|
throw Error("illegal field rule: " + i);
|
|
this.Ft(r, "optional", i)
|
|
}
|
|
return this.tn.omit(";"),
|
|
t.messages.push(r),
|
|
r
|
|
}
|
|
,
|
|
e.toString = function() {
|
|
return "Parser at line " + this.tn.line
|
|
}
|
|
,
|
|
r.Parser = E,
|
|
r),
|
|
d.Reflect = (w = d,
|
|
u = {},
|
|
(e = R.prototype).fqn = function() {
|
|
for (var t = this.name, i = this; null != (i = i.parent); )
|
|
t = i.name + "." + t;
|
|
return t
|
|
}
|
|
,
|
|
e.toString = function(t) {
|
|
return (t ? this.className + " " : "") + this.fqn()
|
|
}
|
|
,
|
|
e.build = function() {
|
|
throw Error(this.toString(!0) + " cannot be built directly")
|
|
}
|
|
,
|
|
u.T = R,
|
|
(r = O.prototype = Object.create(R.prototype)).getChildren = function(t) {
|
|
if (null == (t = t || null))
|
|
return this.children.slice();
|
|
for (var i = [], r = 0, e = this.children.length; r < e; ++r)
|
|
this.children[r]instanceof t && i.push(this.children[r]);
|
|
return i
|
|
}
|
|
,
|
|
r.addChild = function(t) {
|
|
var i;
|
|
if (i = this.getChild(t.name))
|
|
if (i instanceof l.Field && i.name !== i.originalName && null === this.getChild(i.originalName))
|
|
i.name = i.originalName;
|
|
else {
|
|
if (!(t instanceof l.Field && t.name !== t.originalName && null === this.getChild(t.originalName)))
|
|
throw Error("Duplicate name in namespace " + this.toString(!0) + ": " + t.name);
|
|
t.name = t.originalName
|
|
}
|
|
this.children.push(t)
|
|
}
|
|
,
|
|
r.getChild = function(t) {
|
|
for (var i = "number" == typeof t ? "id" : "name", r = 0, e = this.children.length; r < e; ++r)
|
|
if (this.children[r][i] === t)
|
|
return this.children[r];
|
|
return null
|
|
}
|
|
,
|
|
r.resolve = function(t, i) {
|
|
var r, e = "string" == typeof t ? t.split(".") : t, n = this, s = 0;
|
|
if ("" === e[s]) {
|
|
for (; null !== n.parent; )
|
|
n = n.parent;
|
|
s++
|
|
}
|
|
do {
|
|
do {
|
|
if (!(n instanceof u.Namespace)) {
|
|
n = null;
|
|
break
|
|
}
|
|
if (!(r = n.getChild(e[s])) || !(r instanceof u.T) || i && !(r instanceof u.Namespace)) {
|
|
n = null;
|
|
break
|
|
}
|
|
} while (n = r,
|
|
++s < e.length);
|
|
if (null != n)
|
|
break;
|
|
if (null !== this.parent)
|
|
return this.parent.resolve(t, i)
|
|
} while (null != n);
|
|
return n
|
|
}
|
|
,
|
|
r.qn = function(t) {
|
|
for (var i = [], r = t; i.unshift(r.name),
|
|
null !== (r = r.parent); )
|
|
;
|
|
for (var e = 1; e <= i.length; e++) {
|
|
var n = i.slice(i.length - e);
|
|
if (t === this.resolve(n, t instanceof u.Namespace))
|
|
return n.join(".")
|
|
}
|
|
return t.fqn()
|
|
}
|
|
,
|
|
r.build = function() {
|
|
for (var t, i = {}, r = this.children, e = 0, n = r.length; e < n; ++e)
|
|
(t = r[e])instanceof O && (i[t.name] = t.build());
|
|
return Object.defineProperty && Object.defineProperty(i, "$options", {
|
|
value: this.buildOpt()
|
|
}),
|
|
i
|
|
}
|
|
,
|
|
r.buildOpt = function() {
|
|
for (var t = {}, i = Object.keys(this.options), r = 0, e = i.length; r < e; ++r) {
|
|
var n = i[r]
|
|
, s = this.options[i[r]];
|
|
t[n] = s
|
|
}
|
|
return t
|
|
}
|
|
,
|
|
r.getOption = function(t) {
|
|
return void 0 === t ? this.options : void 0 !== this.options[t] ? this.options[t] : null
|
|
}
|
|
,
|
|
u.Namespace = O,
|
|
e = N.prototype,
|
|
N.defaultFieldValue = function(t) {
|
|
if (void 0 === (t = "string" == typeof t ? w.TYPES[t] : t).defaultValue)
|
|
throw Error("default value for type " + t.name + " is not supported");
|
|
return t == w.TYPES.bytes ? new g(0) : t.defaultValue
|
|
}
|
|
,
|
|
e.toString = function() {
|
|
return (this.name || "") + (this.isMapKey ? "map" : "value") + " element"
|
|
}
|
|
,
|
|
e.verifyValue = function(i) {
|
|
var r = this;
|
|
function e(t, i) {
|
|
throw Error("Illegal value for " + r.toString(!0) + " of type " + r.type.name + ": " + t + " (" + i + ")")
|
|
}
|
|
switch (this.type) {
|
|
case w.TYPES.int32:
|
|
case w.TYPES.sint32:
|
|
case w.TYPES.sfixed32:
|
|
return ("number" != typeof i || i == i && i % 1 != 0) && e(typeof i, "not an integer"),
|
|
4294967295 < i ? 0 | i : i;
|
|
case w.TYPES.uint32:
|
|
case w.TYPES.fixed32:
|
|
return ("number" != typeof i || i == i && i % 1 != 0) && e(typeof i, "not an integer"),
|
|
i < 0 ? i >>> 0 : i;
|
|
case w.TYPES.int64:
|
|
case w.TYPES.sint64:
|
|
case w.TYPES.sfixed64:
|
|
if (w.Long)
|
|
try {
|
|
return M(i, !1)
|
|
} catch (t) {
|
|
e(typeof i, t.message)
|
|
}
|
|
else
|
|
e(typeof i, "requires Long.js");
|
|
case w.TYPES.uint64:
|
|
case w.TYPES.fixed64:
|
|
if (w.Long)
|
|
try {
|
|
return M(i, !0)
|
|
} catch (t) {
|
|
e(typeof i, t.message)
|
|
}
|
|
else
|
|
e(typeof i, "requires Long.js");
|
|
case w.TYPES.bool:
|
|
return "boolean" != typeof i && e(typeof i, "not a boolean"),
|
|
i;
|
|
case w.TYPES.float:
|
|
case w.TYPES.double:
|
|
return "number" != typeof i && e(typeof i, "not a number"),
|
|
i;
|
|
case w.TYPES.string:
|
|
return "string" == typeof i || i && i instanceof String || e(typeof i, "not a string"),
|
|
"" + i;
|
|
case w.TYPES.bytes:
|
|
return g.isByteBuffer(i) ? i : g.wrap(i, "base64");
|
|
case w.TYPES.enum:
|
|
for (var t = this.resolvedType.getChildren(w.Reflect.Enum.Value), n = 0; n < t.length; n++) {
|
|
if (t[n].name == i)
|
|
return t[n].id;
|
|
if (t[n].id == i)
|
|
return t[n].id
|
|
}
|
|
if ("proto3" === this.syntax)
|
|
return ("number" != typeof i || i == i && i % 1 != 0) && e(typeof i, "not an integer"),
|
|
(4294967295 < i || i < 0) && e(typeof i, "not in range for uint32"),
|
|
i;
|
|
e(i, "not a valid enum value");
|
|
case w.TYPES.group:
|
|
case w.TYPES.message:
|
|
if (i && "object" == typeof i || e(typeof i, "object expected"),
|
|
i instanceof this.resolvedType.clazz)
|
|
return i;
|
|
if (i instanceof w.Builder.Message) {
|
|
var s = {};
|
|
for (n in i)
|
|
i.hasOwnProperty(n) && (s[n] = i[n]);
|
|
i = s
|
|
}
|
|
return new this.resolvedType.clazz(i)
|
|
}
|
|
throw Error("[INTERNAL] Illegal value for " + this.toString(!0) + ": " + i + " (undefined type " + this.type + ")")
|
|
}
|
|
,
|
|
e.calculateLength = function(t, i) {
|
|
if (null === i)
|
|
return 0;
|
|
var r;
|
|
switch (this.type) {
|
|
case w.TYPES.int32:
|
|
return i < 0 ? g.calculateVarint64(i) : g.calculateVarint32(i);
|
|
case w.TYPES.uint32:
|
|
return g.calculateVarint32(i);
|
|
case w.TYPES.sint32:
|
|
return g.calculateVarint32(g.zigZagEncode32(i));
|
|
case w.TYPES.fixed32:
|
|
case w.TYPES.sfixed32:
|
|
case w.TYPES.float:
|
|
return 4;
|
|
case w.TYPES.int64:
|
|
case w.TYPES.uint64:
|
|
return g.calculateVarint64(i);
|
|
case w.TYPES.sint64:
|
|
return g.calculateVarint64(g.zigZagEncode64(i));
|
|
case w.TYPES.fixed64:
|
|
case w.TYPES.sfixed64:
|
|
return 8;
|
|
case w.TYPES.bool:
|
|
return 1;
|
|
case w.TYPES.enum:
|
|
return g.calculateVarint32(i);
|
|
case w.TYPES.double:
|
|
return 8;
|
|
case w.TYPES.string:
|
|
return r = g.calculateUTF8Bytes(i),
|
|
g.calculateVarint32(r) + r;
|
|
case w.TYPES.bytes:
|
|
if (i.remaining() < 0)
|
|
throw Error("Illegal value for " + this.toString(!0) + ": " + i.remaining() + " bytes remaining");
|
|
return g.calculateVarint32(i.remaining()) + i.remaining();
|
|
case w.TYPES.message:
|
|
return r = this.resolvedType.calculate(i),
|
|
g.calculateVarint32(r) + r;
|
|
case w.TYPES.group:
|
|
return (r = this.resolvedType.calculate(i)) + g.calculateVarint32(t << 3 | w.WIRE_TYPES.ENDGROUP)
|
|
}
|
|
throw Error("[INTERNAL] Illegal value to encode in " + this.toString(!0) + ": " + i + " (unknown type)")
|
|
}
|
|
,
|
|
e.encodeValue = function(t, i, r) {
|
|
if (null !== i)
|
|
switch (this.type) {
|
|
case w.TYPES.int32:
|
|
i < 0 ? r.writeVarint64(i) : r.writeVarint32(i);
|
|
break;
|
|
case w.TYPES.uint32:
|
|
r.writeVarint32(i);
|
|
break;
|
|
case w.TYPES.sint32:
|
|
r.writeVarint32ZigZag(i);
|
|
break;
|
|
case w.TYPES.fixed32:
|
|
r.writeUint32(i);
|
|
break;
|
|
case w.TYPES.sfixed32:
|
|
r.writeInt32(i);
|
|
break;
|
|
case w.TYPES.int64:
|
|
case w.TYPES.uint64:
|
|
r.writeVarint64(i);
|
|
break;
|
|
case w.TYPES.sint64:
|
|
r.writeVarint64ZigZag(i);
|
|
break;
|
|
case w.TYPES.fixed64:
|
|
r.writeUint64(i);
|
|
break;
|
|
case w.TYPES.sfixed64:
|
|
r.writeInt64(i);
|
|
break;
|
|
case w.TYPES.bool:
|
|
"string" == typeof i ? r.writeVarint32("false" === i.toLowerCase() ? 0 : !!i) : r.writeVarint32(i ? 1 : 0);
|
|
break;
|
|
case w.TYPES.enum:
|
|
r.writeVarint32(i);
|
|
break;
|
|
case w.TYPES.float:
|
|
r.writeFloat32(i);
|
|
break;
|
|
case w.TYPES.double:
|
|
r.writeFloat64(i);
|
|
break;
|
|
case w.TYPES.string:
|
|
r.writeVString(i);
|
|
break;
|
|
case w.TYPES.bytes:
|
|
if (i.remaining() < 0)
|
|
throw Error("Illegal value for " + this.toString(!0) + ": " + i.remaining() + " bytes remaining");
|
|
var e = i.offset;
|
|
r.writeVarint32(i.remaining()),
|
|
r.append(i),
|
|
i.offset = e;
|
|
break;
|
|
case w.TYPES.message:
|
|
e = (new g).LE();
|
|
this.resolvedType.encode(i, e),
|
|
r.writeVarint32(e.offset),
|
|
r.append(e.flip());
|
|
break;
|
|
case w.TYPES.group:
|
|
this.resolvedType.encode(i, r),
|
|
r.writeVarint32(t << 3 | w.WIRE_TYPES.ENDGROUP);
|
|
break;
|
|
default:
|
|
throw Error("[INTERNAL] Illegal value to encode in " + this.toString(!0) + ": " + i + " (unknown type)")
|
|
}
|
|
return r
|
|
}
|
|
,
|
|
e.decode = function(t, i, r) {
|
|
if (i != this.type.wireType)
|
|
throw Error("Unexpected wire type for element");
|
|
var e, n;
|
|
switch (this.type) {
|
|
case w.TYPES.int32:
|
|
return 0 | t.readVarint32();
|
|
case w.TYPES.uint32:
|
|
return t.readVarint32() >>> 0;
|
|
case w.TYPES.sint32:
|
|
return 0 | t.readVarint32ZigZag();
|
|
case w.TYPES.fixed32:
|
|
return t.readUint32() >>> 0;
|
|
case w.TYPES.sfixed32:
|
|
return 0 | t.readInt32();
|
|
case w.TYPES.int64:
|
|
return t.readVarint64();
|
|
case w.TYPES.uint64:
|
|
return t.readVarint64().toUnsigned();
|
|
case w.TYPES.sint64:
|
|
return t.readVarint64ZigZag();
|
|
case w.TYPES.fixed64:
|
|
return t.readUint64();
|
|
case w.TYPES.sfixed64:
|
|
return t.readInt64();
|
|
case w.TYPES.bool:
|
|
return !!t.readVarint32();
|
|
case w.TYPES.enum:
|
|
return t.readVarint32();
|
|
case w.TYPES.float:
|
|
return t.readFloat();
|
|
case w.TYPES.double:
|
|
return t.readDouble();
|
|
case w.TYPES.string:
|
|
return t.readVString();
|
|
case w.TYPES.bytes:
|
|
if (n = t.readVarint32(),
|
|
t.remaining() < n)
|
|
throw Error("Illegal number of bytes for " + this.toString(!0) + ": " + n + " required but got only " + t.remaining());
|
|
return (e = t.clone()).limit = e.offset + n,
|
|
t.offset += n,
|
|
e;
|
|
case w.TYPES.message:
|
|
return n = t.readVarint32(),
|
|
this.resolvedType.decode(t, n);
|
|
case w.TYPES.group:
|
|
return this.resolvedType.decode(t, -1, r)
|
|
}
|
|
throw Error("[INTERNAL] Illegal decode type")
|
|
}
|
|
,
|
|
e.valueFromString = function(t) {
|
|
if (!this.isMapKey)
|
|
throw Error("valueFromString() called on non-map-key element");
|
|
switch (this.type) {
|
|
case w.TYPES.int32:
|
|
case w.TYPES.sint32:
|
|
case w.TYPES.sfixed32:
|
|
case w.TYPES.uint32:
|
|
case w.TYPES.fixed32:
|
|
return this.verifyValue(parseInt(t));
|
|
case w.TYPES.int64:
|
|
case w.TYPES.sint64:
|
|
case w.TYPES.sfixed64:
|
|
case w.TYPES.uint64:
|
|
case w.TYPES.fixed64:
|
|
return this.verifyValue(t);
|
|
case w.TYPES.bool:
|
|
return "true" === t;
|
|
case w.TYPES.string:
|
|
return this.verifyValue(t);
|
|
case w.TYPES.bytes:
|
|
return g.fromBinary(t)
|
|
}
|
|
}
|
|
,
|
|
e.valueToString = function(t) {
|
|
if (this.isMapKey)
|
|
return this.type === w.TYPES.bytes ? t.toString("binary") : t.toString();
|
|
throw Error("valueToString() called on non-map-key element")
|
|
}
|
|
,
|
|
u.Element = N,
|
|
(e = (l = function(t, i, r, e, n, s) {
|
|
O.call(this, t, i, r, e, s),
|
|
this.className = "Message",
|
|
this.extensions = void 0,
|
|
this.clazz = null,
|
|
this.isGroup = !!n,
|
|
this.qt = null,
|
|
this.Jt = null,
|
|
this.Vt = null
|
|
}
|
|
).prototype = Object.create(O.prototype)).build = function(t) {
|
|
if (this.clazz && !t)
|
|
return this.clazz;
|
|
var i = function(l, o) {
|
|
function h(t, i) {
|
|
l.Builder.Message.call(this);
|
|
for (var r, e = 0, n = a.length; e < n; ++e)
|
|
this[a[e].name] = null;
|
|
for (e = 0,
|
|
n = f.length; e < n; ++e) {
|
|
var s = f[e];
|
|
this[s.name] = s.repeated ? [] : s.map ? new l.Map(s) : null,
|
|
!s.required && "proto3" !== o.syntax || null === s.defaultValue || (this[s.name] = s.defaultValue)
|
|
}
|
|
if (0 < arguments.length)
|
|
if (1 !== arguments.length || null === t || "object" != typeof t || !("function" != typeof t.encode || t instanceof h) || Array.isArray(t) || t instanceof l.Map || g.isByteBuffer(t) || t instanceof ArrayBuffer || l.Long && t instanceof l.Long)
|
|
for (e = 0,
|
|
n = arguments.length; e < n; ++e)
|
|
void 0 !== (r = arguments[e]) && this.$set(f[e].name, r);
|
|
else
|
|
this.$set(t)
|
|
}
|
|
var f = o.getChildren(l.Reflect.Message.Field)
|
|
, a = o.getChildren(l.Reflect.Message.OneOf)
|
|
, s = h.prototype = Object.create(l.Builder.Message.prototype);
|
|
s.add = function(t, i, r) {
|
|
var e = o.Vt[t];
|
|
if (!r) {
|
|
if (!e)
|
|
throw Error(this + "#" + t + " is undefined");
|
|
if (!(e instanceof l.Reflect.Message.Field))
|
|
throw Error(this + "#" + t + " is not a field: " + e.toString(!0));
|
|
if (!e.repeated)
|
|
throw Error(this + "#" + t + " is not a repeated field");
|
|
i = e.verifyValue(i, !0)
|
|
}
|
|
return null === this[t] && (this[t] = []),
|
|
this[t].push(i),
|
|
this
|
|
}
|
|
,
|
|
s.$add = s.add,
|
|
s.set = function(t, i, r) {
|
|
if (t && "object" == typeof t)
|
|
for (var e in r = i,
|
|
t)
|
|
t.hasOwnProperty(e) && void 0 !== (i = t[e]) && this.$set(e, i, r);
|
|
else {
|
|
var n, s = o.Vt[t];
|
|
if (r)
|
|
this[t] = i;
|
|
else {
|
|
if (!s)
|
|
throw Error(this + "#" + t + " is not a field: undefined");
|
|
if (!(s instanceof l.Reflect.Message.Field))
|
|
throw Error(this + "#" + t + " is not a field: " + s.toString(!0));
|
|
this[s.name] = i = s.verifyValue(i)
|
|
}
|
|
s && s.oneof && (n = this[s.oneof.name],
|
|
null !== i ? (null !== n && n !== s.name && (this[n] = null),
|
|
this[s.oneof.name] = s.name) : n === t && (this[s.oneof.name] = null))
|
|
}
|
|
return this
|
|
}
|
|
,
|
|
s.$set = s.set,
|
|
s.get = function(t, i) {
|
|
if (i)
|
|
return this[t];
|
|
i = o.Vt[t];
|
|
if (!(i && i instanceof l.Reflect.Message.Field))
|
|
throw Error(this + "#" + t + " is not a field: undefined");
|
|
if (i instanceof l.Reflect.Message.Field)
|
|
return this[i.name];
|
|
throw Error(this + "#" + t + " is not a field: " + i.toString(!0))
|
|
}
|
|
,
|
|
s.$get = s.get;
|
|
for (var t = 0; t < f.length; t++) {
|
|
var i = f[t];
|
|
i instanceof l.Reflect.Message.ExtensionField || o.builder.options.populateAccessors && !function(r) {
|
|
function t(t, i) {
|
|
return this[r.name] = i ? t : r.verifyValue(t),
|
|
this
|
|
}
|
|
function i() {
|
|
return this[r.name]
|
|
}
|
|
var e = (e = r.originalName.replace(/(_[a-zA-Z])/g, function(t) {
|
|
return t.toUpperCase().replace("_", "")
|
|
})).substring(0, 1).toUpperCase() + e.substring(1)
|
|
, n = r.originalName.replace(/([A-Z])/g, function(t) {
|
|
return "_" + t
|
|
});
|
|
null === o.getChild("set" + e) && (s["set" + e] = t),
|
|
null === o.getChild("set_" + n) && (s["set_" + n] = t),
|
|
null === o.getChild("get" + e) && (s["get" + e] = i),
|
|
null === o.getChild("get_" + n) && (s["get_" + n] = i)
|
|
}(i)
|
|
}
|
|
function c(t, r, e, n) {
|
|
if (null === t || "object" != typeof t) {
|
|
if (n && n instanceof l.Reflect.Enum) {
|
|
var i = l.Reflect.Enum.getName(n.object, t);
|
|
if (null !== i)
|
|
return i
|
|
}
|
|
return t
|
|
}
|
|
if (g.isByteBuffer(t))
|
|
return r ? t.toBase64() : t.toBuffer();
|
|
if (l.Long.isLong(t))
|
|
return e ? t.toString() : l.Long.fromValue(t);
|
|
var s;
|
|
if (Array.isArray(t))
|
|
s = [],
|
|
t.forEach(function(t, i) {
|
|
s[i] = c(t, r, e, n)
|
|
});
|
|
else if (s = {},
|
|
t instanceof l.Map)
|
|
for (var o = t.entries(), h = o.next(); !h.done; h = o.next())
|
|
s[t.keyElem.valueToString(h.value[0])] = c(h.value[1], r, e, t.valueElem.resolvedType);
|
|
else {
|
|
var f, a = t.$type, u = void 0;
|
|
for (f in t)
|
|
t.hasOwnProperty(f) && (a && (u = a.getChild(f)) ? s[f] = c(t[f], r, e, u.resolvedType) : s[f] = c(t[f], r, e))
|
|
}
|
|
return s
|
|
}
|
|
return s.encode = function(i, t) {
|
|
"boolean" == typeof i && (t = i,
|
|
i = void 0);
|
|
var r = !1
|
|
, e = (i || (i = new g,
|
|
r = !0),
|
|
i.littleEndian);
|
|
try {
|
|
return o.encode(this, i.LE(), t),
|
|
(r ? i.flip() : i).LE(e)
|
|
} catch (t) {
|
|
throw i.LE(e),
|
|
t
|
|
}
|
|
}
|
|
,
|
|
h.encode = function(t, i, r) {
|
|
return new h(t).encode(i, r)
|
|
}
|
|
,
|
|
s.calculate = function() {
|
|
return o.calculate(this)
|
|
}
|
|
,
|
|
s.encodeDelimited = function(t, i) {
|
|
var r = !1
|
|
, e = (t || (t = new g,
|
|
r = !0),
|
|
(new g).LE());
|
|
return o.encode(this, e, i).flip(),
|
|
t.writeVarint32(e.remaining()),
|
|
t.append(e),
|
|
r ? t.flip() : t
|
|
}
|
|
,
|
|
s.encodeAB = function() {
|
|
try {
|
|
return this.encode().toArrayBuffer()
|
|
} catch (t) {
|
|
throw t.encoded && (t.encoded = t.encoded.toArrayBuffer()),
|
|
t
|
|
}
|
|
}
|
|
,
|
|
s.toArrayBuffer = s.encodeAB,
|
|
s.encodeNB = function() {
|
|
try {
|
|
return this.encode().toBuffer()
|
|
} catch (t) {
|
|
throw t.encoded && (t.encoded = t.encoded.toBuffer()),
|
|
t
|
|
}
|
|
}
|
|
,
|
|
s.toBuffer = s.encodeNB,
|
|
s.encode64 = function() {
|
|
try {
|
|
return this.encode().toBase64()
|
|
} catch (t) {
|
|
throw t.encoded && (t.encoded = t.encoded.toBase64()),
|
|
t
|
|
}
|
|
}
|
|
,
|
|
s.toBase64 = s.encode64,
|
|
s.encodeHex = function() {
|
|
try {
|
|
return this.encode().toHex()
|
|
} catch (t) {
|
|
throw t.encoded && (t.encoded = t.encoded.toHex()),
|
|
t
|
|
}
|
|
}
|
|
,
|
|
s.toHex = s.encodeHex,
|
|
s.toRaw = function(t, i) {
|
|
return c(this, !!t, !!i, this.$type)
|
|
}
|
|
,
|
|
s.encodeJSON = function() {
|
|
return JSON.stringify(c(this, !0, !0, this.$type))
|
|
}
|
|
,
|
|
h.decode = function(i, t, r) {
|
|
"string" == typeof t && (r = t,
|
|
t = -1),
|
|
"string" == typeof i ? i = g.wrap(i, r || "base64") : g.isByteBuffer(i) || (i = g.wrap(i));
|
|
r = i.littleEndian;
|
|
try {
|
|
var e = o.decode(i.LE(), t);
|
|
return i.LE(r),
|
|
e
|
|
} catch (t) {
|
|
throw i.LE(r),
|
|
t
|
|
}
|
|
}
|
|
,
|
|
h.decodeDelimited = function(i, t) {
|
|
if ("string" == typeof i ? i = g.wrap(i, t || "base64") : g.isByteBuffer(i) || (i = g.wrap(i)),
|
|
i.remaining() < 1)
|
|
return null;
|
|
var t = i.offset
|
|
, r = i.readVarint32();
|
|
if (i.remaining() < r)
|
|
return i.offset = t,
|
|
null;
|
|
try {
|
|
var e = o.decode(i.slice(i.offset, i.offset + r).LE());
|
|
return i.offset += r,
|
|
e
|
|
} catch (t) {
|
|
throw i.offset += r,
|
|
t
|
|
}
|
|
}
|
|
,
|
|
h.decode64 = function(t) {
|
|
return h.decode(t, "base64")
|
|
}
|
|
,
|
|
h.decodeHex = function(t) {
|
|
return h.decode(t, "hex")
|
|
}
|
|
,
|
|
h.decodeJSON = function(t) {
|
|
return new h(JSON.parse(t))
|
|
}
|
|
,
|
|
s.toString = function() {
|
|
return o.toString()
|
|
}
|
|
,
|
|
Object.defineProperty && (Object.defineProperty(h, "$options", {
|
|
value: o.buildOpt()
|
|
}),
|
|
Object.defineProperty(s, "$options", {
|
|
value: h.$options
|
|
}),
|
|
Object.defineProperty(h, "$type", {
|
|
value: o
|
|
}),
|
|
Object.defineProperty(s, "$type", {
|
|
value: o
|
|
})),
|
|
h
|
|
}(w, this);
|
|
this.qt = [],
|
|
this.Jt = {},
|
|
this.Vt = {};
|
|
for (var r, e = 0, n = this.children.length; e < n; e++)
|
|
if ((r = this.children[e])instanceof c || r instanceof l || r instanceof v) {
|
|
if (i.hasOwnProperty(r.name))
|
|
throw Error("Illegal reflect child of " + this.toString(!0) + ": " + r.toString(!0) + " cannot override static property '" + r.name + "'");
|
|
i[r.name] = r.build()
|
|
} else if (r instanceof l.Field)
|
|
r.build(),
|
|
this.qt.push(r),
|
|
this.Jt[r.id] = r,
|
|
this.Vt[r.name] = r;
|
|
else if (!(r instanceof l.OneOf || r instanceof p))
|
|
throw Error("Illegal reflect child of " + this.toString(!0) + ": " + this.children[e].toString(!0));
|
|
return this.clazz = i
|
|
}
|
|
,
|
|
e.encode = function(t, i, r) {
|
|
for (var e, n, s, o = null, h = 0, f = this.qt.length; h < f; ++h)
|
|
n = t[(e = this.qt[h]).name],
|
|
e.required && null === n ? null === o && (o = e) : e.encode(r ? n : e.verifyValue(n), i, t);
|
|
if (null !== o)
|
|
throw (s = Error("Missing at least one required field for " + this.toString(!0) + ": " + o)).encoded = i,
|
|
s;
|
|
return i
|
|
}
|
|
,
|
|
e.calculate = function(t) {
|
|
for (var i, r, e = 0, n = 0, s = this.qt.length; n < s; ++n) {
|
|
if (r = t[(i = this.qt[n]).name],
|
|
i.required && null === r)
|
|
throw Error("Missing at least one required field for " + this.toString(!0) + ": " + i);
|
|
e += i.calculate(r, t)
|
|
}
|
|
return e
|
|
}
|
|
,
|
|
e.decode = function(t, i, r) {
|
|
"number" != typeof i && (i = -1);
|
|
for (var e, n, s, o, h = t.offset, f = new this.clazz; t.offset < h + i || -1 === i && 0 < t.remaining(); ) {
|
|
if (n = (o = t.readVarint32()) >>> 3,
|
|
(e = 7 & o) === w.WIRE_TYPES.ENDGROUP) {
|
|
if (n !== r)
|
|
throw Error("Illegal group end indicator for " + this.toString(!0) + ": " + n + " (" + (r ? r + " expected" : "not a group") + ")");
|
|
break
|
|
}
|
|
if (s = this.Jt[n])
|
|
s.repeated && !s.options.packed ? f[s.name].push(s.decode(e, t)) : s.map ? (o = s.decode(e, t),
|
|
f[s.name].set(o[0], o[1])) : (f[s.name] = s.decode(e, t),
|
|
s.oneof && (null !== (o = f[s.oneof.name]) && o !== s.name && (f[o] = null),
|
|
f[s.oneof.name] = s.name));
|
|
else
|
|
switch (e) {
|
|
case w.WIRE_TYPES.VARINT:
|
|
t.readVarint32();
|
|
break;
|
|
case w.WIRE_TYPES.BITS32:
|
|
t.offset += 4;
|
|
break;
|
|
case w.WIRE_TYPES.BITS64:
|
|
t.offset += 8;
|
|
break;
|
|
case w.WIRE_TYPES.LDELIM:
|
|
var a = t.readVarint32();
|
|
t.offset += a;
|
|
break;
|
|
case w.WIRE_TYPES.STARTGROUP:
|
|
for (; function t(i, r) {
|
|
var e = r.readVarint32()
|
|
, n = 7 & e
|
|
, s = e >>> 3;
|
|
switch (n) {
|
|
case w.WIRE_TYPES.VARINT:
|
|
for (; 128 == (128 & (e = r.readUint8())); )
|
|
;
|
|
break;
|
|
case w.WIRE_TYPES.BITS64:
|
|
r.offset += 8;
|
|
break;
|
|
case w.WIRE_TYPES.LDELIM:
|
|
e = r.readVarint32(),
|
|
r.offset += e;
|
|
break;
|
|
case w.WIRE_TYPES.STARTGROUP:
|
|
t(s, r);
|
|
break;
|
|
case w.WIRE_TYPES.ENDGROUP:
|
|
if (s === i)
|
|
return;
|
|
throw Error("Illegal GROUPEND after unknown group: " + s + " (" + i + " expected)");
|
|
case w.WIRE_TYPES.BITS32:
|
|
r.offset += 4;
|
|
break;
|
|
default:
|
|
throw Error("Illegal wire type in unknown group " + i + ": " + n)
|
|
}
|
|
return 1
|
|
}(n, t); )
|
|
;
|
|
break;
|
|
default:
|
|
throw Error("Illegal wire type for unknown field " + n + " in " + this.toString(!0) + "#decode: " + e)
|
|
}
|
|
}
|
|
for (var u, l = 0, c = this.qt.length; l < c; ++l)
|
|
if (null === f[(s = this.qt[l]).name])
|
|
if ("proto3" === this.syntax)
|
|
f[s.name] = s.defaultValue;
|
|
else {
|
|
if (s.required)
|
|
throw (u = Error("Missing at least one required field for " + this.toString(!0) + ": " + s.name)).decoded = f,
|
|
u;
|
|
w.populateDefaults && null !== s.defaultValue && (f[s.name] = s.defaultValue)
|
|
}
|
|
return f
|
|
}
|
|
,
|
|
u.Message = l,
|
|
(e = S.prototype = Object.create(R.prototype)).build = function() {
|
|
this.element = new N(this.type,this.resolvedType,!1,this.syntax,this.name),
|
|
this.map && (this.keyElement = new N(this.keyType,void 0,!0,this.syntax,this.name)),
|
|
"proto3" !== this.syntax || this.repeated || this.map ? void 0 !== this.options.default && (this.defaultValue = this.verifyValue(this.options.default)) : this.defaultValue = N.defaultFieldValue(this.type)
|
|
}
|
|
,
|
|
e.verifyValue = function(t, i) {
|
|
i = i || !1;
|
|
var r = this;
|
|
function e(t, i) {
|
|
throw Error("Illegal value for " + r.toString(!0) + " of type " + r.type.name + ": " + t + " (" + i + ")")
|
|
}
|
|
if (null === t)
|
|
return this.required && e(typeof t, "required"),
|
|
"proto3" === this.syntax && this.type !== w.TYPES.message && e(typeof t, "proto3 field without field presence cannot be null"),
|
|
null;
|
|
if (!this.repeated || i)
|
|
return this.map && !i ? t instanceof w.Map ? t : (t instanceof Object || e(typeof t, "expected ProtoBuf.Map or raw object for map field"),
|
|
new w.Map(this,t)) : (!this.repeated && Array.isArray(t) && e(typeof t, "no array expected"),
|
|
this.element.verifyValue(t));
|
|
Array.isArray(t) || (t = [t]);
|
|
for (var n = [], s = 0; s < t.length; s++)
|
|
n.push(this.element.verifyValue(t[s]));
|
|
return n
|
|
}
|
|
,
|
|
e.hasWirePresence = function(t, i) {
|
|
if ("proto3" !== this.syntax)
|
|
return null !== t;
|
|
if (this.oneof && i[this.oneof.name] === this.name)
|
|
return !0;
|
|
switch (this.type) {
|
|
case w.TYPES.int32:
|
|
case w.TYPES.sint32:
|
|
case w.TYPES.sfixed32:
|
|
case w.TYPES.uint32:
|
|
case w.TYPES.fixed32:
|
|
return 0 !== t;
|
|
case w.TYPES.int64:
|
|
case w.TYPES.sint64:
|
|
case w.TYPES.sfixed64:
|
|
case w.TYPES.uint64:
|
|
case w.TYPES.fixed64:
|
|
return 0 !== t.low || 0 !== t.high;
|
|
case w.TYPES.bool:
|
|
return t;
|
|
case w.TYPES.float:
|
|
case w.TYPES.double:
|
|
return 0 !== t;
|
|
case w.TYPES.string:
|
|
return 0 < t.length;
|
|
case w.TYPES.bytes:
|
|
return 0 < t.remaining();
|
|
case w.TYPES.enum:
|
|
return 0 !== t;
|
|
case w.TYPES.message:
|
|
return null !== t;
|
|
default:
|
|
return !0
|
|
}
|
|
}
|
|
,
|
|
e.encode = function(i, n, t) {
|
|
if (null === this.type || "object" != typeof this.type)
|
|
throw Error("[INTERNAL] Unresolved type in " + this.toString(!0) + ": " + this.type);
|
|
if (!(null === i || this.repeated && 0 == i.length))
|
|
try {
|
|
if (this.repeated)
|
|
if (this.options.packed && 0 <= w.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)) {
|
|
n.writeVarint32(this.id << 3 | w.WIRE_TYPES.LDELIM),
|
|
n.ensureCapacity(n.offset += 1);
|
|
for (var r = n.offset, e = 0; e < i.length; e++)
|
|
this.element.encodeValue(this.id, i[e], n);
|
|
var s, o = n.offset - r, h = g.calculateVarint32(o);
|
|
1 < h && (s = n.slice(r, n.offset),
|
|
r += h - 1,
|
|
n.offset = r,
|
|
n.append(s)),
|
|
n.writeVarint32(o, r - h)
|
|
} else
|
|
for (e = 0; e < i.length; e++)
|
|
n.writeVarint32(this.id << 3 | this.type.wireType),
|
|
this.element.encodeValue(this.id, i[e], n);
|
|
else
|
|
this.map ? i.forEach(function(t, i, r) {
|
|
var e = g.calculateVarint32(8 | this.keyType.wireType) + this.keyElement.calculateLength(1, i) + g.calculateVarint32(16 | this.type.wireType) + this.element.calculateLength(2, t);
|
|
n.writeVarint32(this.id << 3 | w.WIRE_TYPES.LDELIM),
|
|
n.writeVarint32(e),
|
|
n.writeVarint32(8 | this.keyType.wireType),
|
|
this.keyElement.encodeValue(1, i, n),
|
|
n.writeVarint32(16 | this.type.wireType),
|
|
this.element.encodeValue(2, t, n)
|
|
}, this) : this.hasWirePresence(i, t) && (n.writeVarint32(this.id << 3 | this.type.wireType),
|
|
this.element.encodeValue(this.id, i, n))
|
|
} catch (t) {
|
|
throw Error("Illegal value for " + this.toString(!0) + ": " + i + " (" + t + ")")
|
|
}
|
|
return n
|
|
}
|
|
,
|
|
e.calculate = function(i, t) {
|
|
if (i = this.verifyValue(i),
|
|
null === this.type || "object" != typeof this.type)
|
|
throw Error("[INTERNAL] Unresolved type in " + this.toString(!0) + ": " + this.type);
|
|
if (null === i || this.repeated && 0 == i.length)
|
|
return 0;
|
|
var r, e, n = 0;
|
|
try {
|
|
if (this.repeated)
|
|
if (this.options.packed && 0 <= w.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)) {
|
|
for (n += g.calculateVarint32(this.id << 3 | w.WIRE_TYPES.LDELIM),
|
|
r = e = 0; r < i.length; r++)
|
|
e += this.element.calculateLength(this.id, i[r]);
|
|
n = n + g.calculateVarint32(e) + e
|
|
} else
|
|
for (r = 0; r < i.length; r++)
|
|
n = (n += g.calculateVarint32(this.id << 3 | this.type.wireType)) + this.element.calculateLength(this.id, i[r]);
|
|
else
|
|
this.map ? i.forEach(function(t, i, r) {
|
|
i = g.calculateVarint32(8 | this.keyType.wireType) + this.keyElement.calculateLength(1, i) + g.calculateVarint32(16 | this.type.wireType) + this.element.calculateLength(2, t);
|
|
n = (n += g.calculateVarint32(this.id << 3 | w.WIRE_TYPES.LDELIM)) + g.calculateVarint32(i) + i
|
|
}, this) : this.hasWirePresence(i, t) && (n = (n += g.calculateVarint32(this.id << 3 | this.type.wireType)) + this.element.calculateLength(this.id, i))
|
|
} catch (t) {
|
|
throw Error("Illegal value for " + this.toString(!0) + ": " + i + " (" + t + ")")
|
|
}
|
|
return n
|
|
}
|
|
,
|
|
e.decode = function(t, i, r) {
|
|
if (!(!this.map && t == this.type.wireType || !r && this.repeated && this.options.packed && t == w.WIRE_TYPES.LDELIM || this.map && t == w.WIRE_TYPES.LDELIM))
|
|
throw Error("Illegal wire type for field " + this.toString(!0) + ": " + t + " (" + this.type.wireType + " expected)");
|
|
if (t == w.WIRE_TYPES.LDELIM && this.repeated && this.options.packed && 0 <= w.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType) && !r) {
|
|
for (var e = i.readVarint32(), e = i.offset + e, n = []; i.offset < e; )
|
|
n.push(this.decode(this.type.wireType, i, !0));
|
|
return n
|
|
}
|
|
if (this.map) {
|
|
var s = N.defaultFieldValue(this.keyType)
|
|
, o = N.defaultFieldValue(this.type);
|
|
if (e = i.readVarint32(),
|
|
i.remaining() < e)
|
|
throw Error("Illegal number of bytes for " + this.toString(!0) + ": " + e + " required but got only " + i.remaining());
|
|
var h = i.clone();
|
|
for (h.limit = h.offset + e,
|
|
i.offset += e; 0 < h.remaining(); ) {
|
|
var f = h.readVarint32()
|
|
, f = (t = 7 & f,
|
|
f >>> 3);
|
|
if (1 == f)
|
|
s = this.keyElement.decode(h, t, f);
|
|
else {
|
|
if (2 != f)
|
|
throw Error("Unexpected tag in map field key/value submessage");
|
|
o = this.element.decode(h, t, f)
|
|
}
|
|
}
|
|
return [s, o]
|
|
}
|
|
return this.element.decode(i, t, this.id)
|
|
}
|
|
,
|
|
u.Message.Field = S,
|
|
j.prototype = Object.create(S.prototype),
|
|
u.Message.ExtensionField = j,
|
|
u.Message.OneOf = function(t, i, r) {
|
|
R.call(this, t, i, r),
|
|
this.fields = []
|
|
}
|
|
,
|
|
(c = function(t, i, r, e, n) {
|
|
O.call(this, t, i, r, e, n),
|
|
this.className = "Enum",
|
|
this.object = null
|
|
}
|
|
).getName = function(t, i) {
|
|
for (var r, e = Object.keys(t), n = 0; n < e.length; ++n)
|
|
if (t[r = e[n]] === i)
|
|
return r;
|
|
return null
|
|
}
|
|
,
|
|
(c.prototype = Object.create(O.prototype)).build = function(t) {
|
|
if (this.object && !t)
|
|
return this.object;
|
|
for (var i = new w.Builder.Enum, r = this.getChildren(c.Value), e = 0, n = r.length; e < n; ++e)
|
|
i[r[e].name] = r[e].id;
|
|
return Object.defineProperty && Object.defineProperty(i, "$options", {
|
|
value: this.buildOpt(),
|
|
enumerable: !1
|
|
}),
|
|
this.object = i
|
|
}
|
|
,
|
|
u.Enum = c,
|
|
x.prototype = Object.create(R.prototype),
|
|
u.Enum.Value = x,
|
|
(p = function(t, i, r, e) {
|
|
R.call(this, t, i, r),
|
|
this.field = e
|
|
}
|
|
).prototype = Object.create(R.prototype),
|
|
u.Extension = p,
|
|
((v = function(t, i, r, e) {
|
|
O.call(this, t, i, r, e),
|
|
this.className = "Service",
|
|
this.clazz = null
|
|
}
|
|
).prototype = Object.create(O.prototype)).build = function(t) {
|
|
return this.clazz && !t ? this.clazz : this.clazz = function(i, n) {
|
|
for (var s = function(t) {
|
|
i.Builder.Service.call(this),
|
|
this.rpcImpl = t || function(t, i, r) {
|
|
setTimeout(r.bind(this, Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")), 0)
|
|
}
|
|
}, t = s.prototype = Object.create(i.Builder.Service.prototype), r = n.getChildren(i.Reflect.Service.RPCMethod), e = 0; e < r.length; e++)
|
|
!function(e) {
|
|
t[e.name] = function(t, r) {
|
|
try {
|
|
try {
|
|
t = e.resolvedRequestType.clazz.decode(g.wrap(t))
|
|
} catch (t) {
|
|
if (!(t instanceof TypeError))
|
|
throw t
|
|
}
|
|
if (null === t || "object" != typeof t)
|
|
throw Error("Illegal arguments");
|
|
t instanceof e.resolvedRequestType.clazz || (t = new e.resolvedRequestType.clazz(t)),
|
|
this.rpcImpl(e.fqn(), t, function(t, i) {
|
|
if (t)
|
|
r(t);
|
|
else {
|
|
null === i && (i = "");
|
|
try {
|
|
i = e.resolvedResponseType.clazz.decode(i)
|
|
} catch (t) {}
|
|
i && i instanceof e.resolvedResponseType.clazz ? r(null, i) : r(Error("Illegal response type received in service method " + n.name + "#" + e.name))
|
|
}
|
|
})
|
|
} catch (t) {
|
|
setTimeout(r.bind(this, t), 0)
|
|
}
|
|
}
|
|
,
|
|
s[e.name] = function(t, i, r) {
|
|
new s(t)[e.name](i, r)
|
|
}
|
|
,
|
|
Object.defineProperty && (Object.defineProperty(s[e.name], "$options", {
|
|
value: e.buildOpt()
|
|
}),
|
|
Object.defineProperty(t[e.name], "$options", {
|
|
value: s[e.name].$options
|
|
}))
|
|
}(r[e]);
|
|
return Object.defineProperty && (Object.defineProperty(s, "$options", {
|
|
value: n.buildOpt()
|
|
}),
|
|
Object.defineProperty(t, "$options", {
|
|
value: s.$options
|
|
}),
|
|
Object.defineProperty(s, "$type", {
|
|
value: n
|
|
}),
|
|
Object.defineProperty(t, "$type", {
|
|
value: n
|
|
})),
|
|
s
|
|
}(w, this)
|
|
}
|
|
,
|
|
u.Service = v,
|
|
(U.prototype = Object.create(R.prototype)).buildOpt = r.buildOpt,
|
|
u.Service.Method = U,
|
|
C.prototype = Object.create(U.prototype),
|
|
u.Service.RPCMethod = C,
|
|
u),
|
|
d.Builder = (i = (a = d).Lang,
|
|
h = d.Reflect,
|
|
e = T.prototype,
|
|
T.isMessage = function(t) {
|
|
return "string" == typeof t.name && void 0 === t.values && void 0 === t.rpc
|
|
}
|
|
,
|
|
T.isMessageField = function(t) {
|
|
return "string" == typeof t.rule && "string" == typeof t.name && "string" == typeof t.type && void 0 !== t.id
|
|
}
|
|
,
|
|
T.isEnum = function(t) {
|
|
return "string" == typeof t.name && !(void 0 === t.values || !Array.isArray(t.values) || 0 === t.values.length)
|
|
}
|
|
,
|
|
T.isService = function(t) {
|
|
return !("string" != typeof t.name || "object" != typeof t.rpc || !t.rpc)
|
|
}
|
|
,
|
|
T.isExtend = function(t) {
|
|
return "string" == typeof t.ref
|
|
}
|
|
,
|
|
e.reset = function() {
|
|
return this.ptr = this.ns,
|
|
this
|
|
}
|
|
,
|
|
e.define = function(t) {
|
|
if ("string" == typeof t && i.TYPEREF.test(t))
|
|
return t.split(".").forEach(function(t) {
|
|
var i = this.ptr.getChild(t);
|
|
null === i && this.ptr.addChild(i = new h.Namespace(this,this.ptr,t)),
|
|
this.ptr = i
|
|
}, this),
|
|
this;
|
|
throw Error("illegal namespace: " + t)
|
|
}
|
|
,
|
|
e.create = function(t) {
|
|
if (t) {
|
|
if (Array.isArray(t)) {
|
|
if (0 === t.length)
|
|
return this;
|
|
t = t.slice()
|
|
} else
|
|
t = [t];
|
|
for (var i = [t]; 0 < i.length; ) {
|
|
if (t = i.pop(),
|
|
!Array.isArray(t))
|
|
throw Error("not a valid namespace: " + JSON.stringify(t));
|
|
for (; 0 < t.length; ) {
|
|
var r = t.shift();
|
|
if (T.isMessage(r)) {
|
|
var n = new h.Message(this,this.ptr,r.name,r.options,r.isGroup,r.syntax)
|
|
, e = {}
|
|
, s = (r.oneofs && Object.keys(r.oneofs).forEach(function(t) {
|
|
n.addChild(e[t] = new h.Message.OneOf(this,n,t))
|
|
}, this),
|
|
r.fields && r.fields.forEach(function(t) {
|
|
if (null !== n.getChild(0 | t.id))
|
|
throw Error("duplicate or invalid field id in " + n.name + ": " + t.id);
|
|
if (t.options && "object" != typeof t.options)
|
|
throw Error("illegal field options in " + n.name + "#" + t.name);
|
|
var i = null;
|
|
if ("string" == typeof t.oneof && !(i = e[t.oneof]))
|
|
throw Error("illegal oneof in " + n.name + "#" + t.name + ": " + t.oneof);
|
|
t = new h.Message.Field(this,n,t.rule,t.keytype,t.type,t.name,t.id,t.options,i,r.syntax),
|
|
i && i.fields.push(t),
|
|
n.addChild(t)
|
|
}, this),
|
|
[]);
|
|
if (r.enums && r.enums.forEach(function(t) {
|
|
s.push(t)
|
|
}),
|
|
r.messages && r.messages.forEach(function(t) {
|
|
s.push(t)
|
|
}),
|
|
r.services && r.services.forEach(function(t) {
|
|
s.push(t)
|
|
}),
|
|
r.extensions && ("number" == typeof r.extensions[0] ? n.extensions = [r.extensions] : n.extensions = r.extensions),
|
|
this.ptr.addChild(n),
|
|
0 < s.length) {
|
|
i.push(t),
|
|
t = s,
|
|
s = null,
|
|
this.ptr = n,
|
|
n = null;
|
|
continue
|
|
}
|
|
s = null
|
|
} else if (T.isEnum(r))
|
|
n = new h.Enum(this,this.ptr,r.name,r.options,r.syntax),
|
|
r.values.forEach(function(t) {
|
|
n.addChild(new h.Enum.Value(this,n,t.name,t.id))
|
|
}, this),
|
|
this.ptr.addChild(n);
|
|
else if (T.isService(r))
|
|
n = new h.Service(this,this.ptr,r.name,r.options),
|
|
Object.keys(r.rpc).forEach(function(t) {
|
|
var i = r.rpc[t];
|
|
n.addChild(new h.Service.RPCMethod(this,n,t,i.request,i.response,!!i.request_stream,!!i.response_stream,i.options))
|
|
}, this),
|
|
this.ptr.addChild(n);
|
|
else {
|
|
if (!T.isExtend(r))
|
|
throw Error("not a valid definition: " + JSON.stringify(r));
|
|
if (n = this.ptr.resolve(r.ref, !0))
|
|
r.fields.forEach(function(i) {
|
|
if (null !== n.getChild(0 | i.id))
|
|
throw Error("duplicate extended field id in " + n.name + ": " + i.id);
|
|
if (n.extensions) {
|
|
var r = !1;
|
|
if (n.extensions.forEach(function(t) {
|
|
i.id >= t[0] && i.id <= t[1] && (r = !0)
|
|
}),
|
|
!r)
|
|
throw Error("illegal extended field id in " + n.name + ": " + i.id + " (not within valid ranges)")
|
|
}
|
|
var t = i.name
|
|
, t = (this.options.convertFieldsToCamelCase && (t = a.Util.toCamelCase(t)),
|
|
new h.Message.ExtensionField(this,n,i.rule,i.type,this.ptr.fqn() + "." + t,i.id,i.options))
|
|
, e = new h.Extension(this,this.ptr,i.name,t);
|
|
t.extension = e,
|
|
this.ptr.addChild(e),
|
|
n.addChild(t)
|
|
}, this);
|
|
else if (!/\.?google\.protobuf\./.test(r.ref))
|
|
throw Error("extended message " + r.ref + " is not defined")
|
|
}
|
|
n = r = null
|
|
}
|
|
t = null,
|
|
this.ptr = this.ptr.parent
|
|
}
|
|
this.resolved = !1,
|
|
this.result = null
|
|
}
|
|
return this
|
|
}
|
|
,
|
|
e.import = function(i, t) {
|
|
var r = "/";
|
|
if ("string" == typeof t) {
|
|
if (a.Util.IS_NODE && (t = require("path").resolve(t)),
|
|
!0 === this.files[t])
|
|
return this.reset();
|
|
this.files[t] = !0
|
|
} else if ("object" == typeof t) {
|
|
var e = t.root
|
|
, e = ((0 <= (e = a.Util.IS_NODE ? require("path").resolve(e) : e).indexOf("\\") || 0 <= t.file.indexOf("\\")) && (r = "\\"),
|
|
e + r + t.file);
|
|
if (!0 === this.files[e])
|
|
return this.reset();
|
|
this.files[e] = !0
|
|
}
|
|
if (i.imports && 0 < i.imports.length) {
|
|
var n, e = !1;
|
|
"object" == typeof t ? (this.importRoot = t.root,
|
|
e = !0,
|
|
n = this.importRoot,
|
|
t = t.file,
|
|
(0 <= n.indexOf("\\") || 0 <= t.indexOf("\\")) && (r = "\\")) : "string" == typeof t ? this.importRoot ? n = this.importRoot : 0 <= t.indexOf("/") ? "" === (n = t.replace(/\/[^\/]*$/, "")) && (n = "/") : 0 <= t.indexOf("\\") ? (n = t.replace(/\\[^\\]*$/, ""),
|
|
r = "\\") : n = "." : n = null;
|
|
for (var s = 0; s < i.imports.length; s++)
|
|
if ("string" == typeof i.imports[s]) {
|
|
if (!n)
|
|
throw Error("cannot determine import root");
|
|
var o = i.imports[s];
|
|
if ("google/protobuf/descriptor.proto" !== o && !0 !== this.files[o = n + r + o]) {
|
|
/\.proto$/i.test(o) && !a.DotProto && (o = o.replace(/\.proto$/, ".json"));
|
|
var h = a.Util.fetch(o);
|
|
if (null === h)
|
|
throw Error("failed to import '" + o + "' in '" + t + "': file not found");
|
|
/\.json$/i.test(o) ? this.import(JSON.parse(h + ""), o) : this.import(a.DotProto.Parser.parse(h), o)
|
|
}
|
|
} else
|
|
t ? /\.(\w+)$/.test(t) ? this.import(i.imports[s], t.replace(/^(.+)\.(\w+)$/, function(t, i, r) {
|
|
return i + "_import" + s + "." + r
|
|
})) : this.import(i.imports[s], t + "_import" + s) : this.import(i.imports[s]);
|
|
e && (this.importRoot = null)
|
|
}
|
|
i.package && this.define(i.package),
|
|
i.syntax && function i(r) {
|
|
r.messages && r.messages.forEach(function(t) {
|
|
t.syntax = r.syntax,
|
|
i(t)
|
|
}),
|
|
r.enums && r.enums.forEach(function(t) {
|
|
t.syntax = r.syntax
|
|
})
|
|
}(i);
|
|
var f = this.ptr;
|
|
return i.options && Object.keys(i.options).forEach(function(t) {
|
|
f.options[t] = i.options[t]
|
|
}),
|
|
i.messages && (this.create(i.messages),
|
|
this.ptr = f),
|
|
i.enums && (this.create(i.enums),
|
|
this.ptr = f),
|
|
i.services && (this.create(i.services),
|
|
this.ptr = f),
|
|
i.extends && this.create(i.extends),
|
|
this.reset()
|
|
}
|
|
,
|
|
e.resolveAll = function() {
|
|
var t;
|
|
if (null == this.ptr || "object" == typeof this.ptr.type)
|
|
return this;
|
|
if (this.ptr instanceof h.Namespace)
|
|
this.ptr.children.forEach(function(t) {
|
|
this.ptr = t,
|
|
this.resolveAll()
|
|
}, this);
|
|
else if (this.ptr instanceof h.Message.Field) {
|
|
if (i.TYPE.test(this.ptr.type))
|
|
this.ptr.type = a.TYPES[this.ptr.type];
|
|
else {
|
|
if (!i.TYPEREF.test(this.ptr.type))
|
|
throw Error("illegal type reference in " + this.ptr.toString(!0) + ": " + this.ptr.type);
|
|
if (!(t = (this.ptr instanceof h.Message.ExtensionField ? this.ptr.extension : this.ptr).parent.resolve(this.ptr.type, !0)))
|
|
throw Error("unresolvable type reference in " + this.ptr.toString(!0) + ": " + this.ptr.type);
|
|
if ((this.ptr.resolvedType = t)instanceof h.Enum) {
|
|
if (this.ptr.type = a.TYPES.enum,
|
|
"proto3" === this.ptr.syntax && "proto3" !== t.syntax)
|
|
throw Error("proto3 message cannot reference proto2 enum")
|
|
} else {
|
|
if (!(t instanceof h.Message))
|
|
throw Error("illegal type reference in " + this.ptr.toString(!0) + ": " + this.ptr.type);
|
|
this.ptr.type = t.isGroup ? a.TYPES.group : a.TYPES.message
|
|
}
|
|
}
|
|
if (this.ptr.map) {
|
|
if (!i.TYPE.test(this.ptr.keyType))
|
|
throw Error("illegal key type for map field in " + this.ptr.toString(!0) + ": " + this.ptr.keyType);
|
|
this.ptr.keyType = a.TYPES[this.ptr.keyType]
|
|
}
|
|
} else if (this.ptr instanceof a.Reflect.Service.Method) {
|
|
if (!(this.ptr instanceof a.Reflect.Service.RPCMethod))
|
|
throw Error("illegal service type in " + this.ptr.toString(!0));
|
|
if (!((t = this.ptr.parent.resolve(this.ptr.requestName, !0)) && t instanceof a.Reflect.Message))
|
|
throw Error("Illegal type reference in " + this.ptr.toString(!0) + ": " + this.ptr.requestName);
|
|
if (this.ptr.resolvedRequestType = t,
|
|
!((t = this.ptr.parent.resolve(this.ptr.responseName, !0)) && t instanceof a.Reflect.Message))
|
|
throw Error("Illegal type reference in " + this.ptr.toString(!0) + ": " + this.ptr.responseName);
|
|
this.ptr.resolvedResponseType = t
|
|
} else if (!(this.ptr instanceof a.Reflect.Message.OneOf || this.ptr instanceof a.Reflect.Extension || this.ptr instanceof a.Reflect.Enum.Value))
|
|
throw Error("illegal object in namespace: " + typeof this.ptr + ": " + this.ptr);
|
|
return this.reset()
|
|
}
|
|
,
|
|
e.build = function(t) {
|
|
if (this.reset(),
|
|
this.resolved || (this.resolveAll(),
|
|
this.resolved = !0,
|
|
this.result = null),
|
|
null === this.result && (this.result = this.ns.build()),
|
|
!t)
|
|
return this.result;
|
|
for (var i = "string" == typeof t ? t.split(".") : t, r = this.result, e = 0; e < i.length; e++) {
|
|
if (!r[i[e]]) {
|
|
r = null;
|
|
break
|
|
}
|
|
r = r[i[e]]
|
|
}
|
|
return r
|
|
}
|
|
,
|
|
e.lookup = function(t, i) {
|
|
return t ? this.ns.resolve(t, i) : this.ns
|
|
}
|
|
,
|
|
e.toString = function() {
|
|
return "Builder"
|
|
}
|
|
,
|
|
T.Message = function() {}
|
|
,
|
|
T.Enum = function() {}
|
|
,
|
|
T.Service = function() {}
|
|
,
|
|
T),
|
|
d.Map = (f = d.Reflect,
|
|
(r = A.prototype).clear = function() {
|
|
this.map = {}
|
|
}
|
|
,
|
|
r.delete = function(t) {
|
|
var t = this.keyElem.valueToString(this.keyElem.verifyValue(t))
|
|
, i = t in this.map;
|
|
return delete this.map[t],
|
|
i
|
|
}
|
|
,
|
|
r.entries = function() {
|
|
for (var t, i = [], r = Object.keys(this.map), e = 0; e < r.length; e++)
|
|
i.push([(t = this.map[r[e]]).key, t.value]);
|
|
return k(i)
|
|
}
|
|
,
|
|
r.keys = function() {
|
|
for (var t = [], i = Object.keys(this.map), r = 0; r < i.length; r++)
|
|
t.push(this.map[i[r]].key);
|
|
return k(t)
|
|
}
|
|
,
|
|
r.values = function() {
|
|
for (var t = [], i = Object.keys(this.map), r = 0; r < i.length; r++)
|
|
t.push(this.map[i[r]].value);
|
|
return k(t)
|
|
}
|
|
,
|
|
r.forEach = function(t, i) {
|
|
for (var r, e = Object.keys(this.map), n = 0; n < e.length; n++)
|
|
t.call(i, (r = this.map[e[n]]).value, r.key, this)
|
|
}
|
|
,
|
|
r.set = function(t, i) {
|
|
t = this.keyElem.verifyValue(t),
|
|
i = this.valueElem.verifyValue(i);
|
|
return this.map[this.keyElem.valueToString(t)] = {
|
|
key: t,
|
|
value: i
|
|
},
|
|
this
|
|
}
|
|
,
|
|
r.get = function(t) {
|
|
t = this.keyElem.valueToString(this.keyElem.verifyValue(t));
|
|
if (t in this.map)
|
|
return this.map[t].value
|
|
}
|
|
,
|
|
r.has = function(t) {
|
|
return this.keyElem.valueToString(this.keyElem.verifyValue(t))in this.map
|
|
}
|
|
,
|
|
A),
|
|
d.loadProto = function(t, i, r) {
|
|
return ("string" == typeof i || i && "string" == typeof i.file && "string" == typeof i.root) && (r = i,
|
|
i = void 0),
|
|
d.loadJson(d.DotProto.Parser.parse(t), i, r)
|
|
}
|
|
,
|
|
d.protoFromString = d.loadProto,
|
|
d.loadProtoFile = function(i, r, e) {
|
|
var t;
|
|
return r && "object" == typeof r ? (e = r,
|
|
r = null) : r && "function" == typeof r || (r = null),
|
|
r ? d.Util.fetch("string" == typeof i ? i : i.root + "/" + i.file, function(t) {
|
|
if (null === t)
|
|
r(Error("Failed to fetch file"));
|
|
else
|
|
try {
|
|
r(null, d.loadProto(t, e, i))
|
|
} catch (t) {
|
|
r(t)
|
|
}
|
|
}) : null === (t = d.Util.fetch("object" == typeof i ? i.root + "/" + i.file : i)) ? null : d.loadProto(t, e, i)
|
|
}
|
|
,
|
|
d.protoFromFile = d.loadProtoFile,
|
|
d.newBuilder = function(t) {
|
|
return void 0 === (t = t || {}).convertFieldsToCamelCase && (t.convertFieldsToCamelCase = d.convertFieldsToCamelCase),
|
|
void 0 === t.populateAccessors && (t.populateAccessors = d.populateAccessors),
|
|
new d.Builder(t)
|
|
}
|
|
,
|
|
d.loadJson = function(t, i, r) {
|
|
return ("string" == typeof i || i && "string" == typeof i.file && "string" == typeof i.root) && (r = i,
|
|
i = null),
|
|
i && "object" == typeof i || (i = d.newBuilder()),
|
|
"string" == typeof t && (t = JSON.parse(t)),
|
|
i.import(t, r),
|
|
i.resolveAll(),
|
|
i
|
|
}
|
|
,
|
|
d.loadJsonFile = function(i, r, e) {
|
|
var t;
|
|
return r && "object" == typeof r ? (e = r,
|
|
r = null) : r && "function" == typeof r || (r = null),
|
|
r ? d.Util.fetch("string" == typeof i ? i : i.root + "/" + i.file, function(t) {
|
|
if (null === t)
|
|
r(Error("Failed to fetch file"));
|
|
else
|
|
try {
|
|
r(null, d.loadJson(JSON.parse(t), e, i))
|
|
} catch (t) {
|
|
r(t)
|
|
}
|
|
}) : null === (t = d.Util.fetch("object" == typeof i ? i.root + "/" + i.file : i)) ? null : d.loadJson(JSON.parse(t), e, i)
|
|
}
|
|
,
|
|
d;
|
|
function R(t, i, r) {
|
|
this.builder = t,
|
|
this.parent = i,
|
|
this.name = r,
|
|
this.className
|
|
}
|
|
function O(t, i, r, e, n) {
|
|
R.call(this, t, i, r),
|
|
this.className = "Namespace",
|
|
this.children = [],
|
|
this.options = e || {},
|
|
this.syntax = n || "proto2"
|
|
}
|
|
function N(t, i, r, e, n) {
|
|
if (this.type = t,
|
|
this.resolvedType = i,
|
|
this.isMapKey = r,
|
|
this.syntax = e,
|
|
this.name = n,
|
|
r && w.MAP_KEY_TYPES.indexOf(t) < 0)
|
|
throw Error("Invalid map key type: " + t.name)
|
|
}
|
|
function M(t, i) {
|
|
if (t && "number" == typeof t.low && "number" == typeof t.high && "boolean" == typeof t.unsigned && t.low == t.low && t.high == t.high)
|
|
return new w.Long(t.low,t.high,void 0 === i ? t.unsigned : i);
|
|
if ("string" == typeof t)
|
|
return w.Long.fromString(t, i || !1, 10);
|
|
if ("number" == typeof t)
|
|
return w.Long.fromNumber(t, i || !1);
|
|
throw Error("not convertible to Long")
|
|
}
|
|
function S(t, i, r, e, n, s, o, h, f, a) {
|
|
R.call(this, t, i, s),
|
|
this.className = "Message.Field",
|
|
this.required = "required" === r,
|
|
this.repeated = "repeated" === r,
|
|
this.map = "map" === r,
|
|
this.keyType = e || null,
|
|
this.type = n,
|
|
this.resolvedType = null,
|
|
this.id = o,
|
|
this.options = h || {},
|
|
this.defaultValue = null,
|
|
this.oneof = f || null,
|
|
this.syntax = a || "proto2",
|
|
this.originalName = this.name,
|
|
this.element = null,
|
|
this.keyElement = null,
|
|
!this.builder.options.convertFieldsToCamelCase || this instanceof l.ExtensionField || (this.name = w.Util.toCamelCase(this.name))
|
|
}
|
|
function j(t, i, r, e, n, s, o) {
|
|
S.call(this, t, i, r, null, e, n, s, o),
|
|
this.extension
|
|
}
|
|
function x(t, i, r, e) {
|
|
R.call(this, t, i, r),
|
|
this.className = "Enum.Value",
|
|
this.id = e
|
|
}
|
|
function U(t, i, r, e) {
|
|
R.call(this, t, i, r),
|
|
this.className = "Service.Method",
|
|
this.options = e || {}
|
|
}
|
|
function C(t, i, r, e, n, s, o, h) {
|
|
U.call(this, t, i, r, h),
|
|
this.className = "Service.RPCMethod",
|
|
this.requestName = e,
|
|
this.responseName = n,
|
|
this.requestStream = s,
|
|
this.responseStream = o,
|
|
this.resolvedRequestType = null,
|
|
this.resolvedResponseType = null
|
|
}
|
|
});
|