diff --git a/bower.json b/bower.json index 1d08a50c7..c9558eb8d 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "protobuf", "description": "Protocol Buffers for JavaScript. Finally.", - "version": "4.0.0", + "version": "4.0.1", "main": "dist/ProtoBuf.js", "license": "Apache-2.0", "homepage": "http://dcode.io/", diff --git a/dist/ProtoBuf-light.js b/dist/ProtoBuf-light.js index 18bf19e18..9a8139d4c 100644 --- a/dist/ProtoBuf-light.js +++ b/dist/ProtoBuf-light.js @@ -24,11 +24,11 @@ /* AMD */ if (typeof define === 'function' && define["amd"]) define(["ByteBuffer"], factory); /* CommonJS */ else if (typeof require === "function" && typeof module === "object" && module && module["exports"]) - module["exports"] = factory(require("bytebuffer")); + module["exports"] = factory(require("bytebuffer"), require); /* Global */ else (global["dcodeIO"] = global["dcodeIO"] || {})["ProtoBuf"] = factory(global["dcodeIO"]["ByteBuffer"]); -})(this, function(ByteBuffer) { +})(this, function(ByteBuffer, nodeRequire) { "use strict"; /** @@ -57,7 +57,7 @@ * @const * @expose */ - ProtoBuf.VERSION = "4.0.0"; + ProtoBuf.VERSION = "4.0.1"; /** * Wire types. @@ -314,8 +314,7 @@ // redundant modules. // * Works for browserify because node-process does not implement toString // https://github.com/defunctzombie/node-process - typeof process === 'object' && - process+'' === '[object process]' + typeof process === 'object' && process+'' === '[object process]' ); /** @@ -357,7 +356,7 @@ callback = null; if (Util.IS_NODE) { if (callback) { - require("fs").readFile(path, function(err, data) { + Util.require("fs").readFile(path, function(err, data) { if (err) callback(null); else @@ -365,7 +364,7 @@ }); } else try { - return require("fs").readFileSync(path); + return Util.require("fs").readFileSync(path); } catch (e) { return null; } @@ -395,6 +394,18 @@ } }; + /** + * Requires a node module. + * @function + * @param {string} path + * @returns {*} + * @throws Error If node require is not supported + * @expose + */ + Util.require = Util.IS_NODE + ? function(path) { return nodeRequire(path); } + : function(path) { throw Error("node require is not supported by this platform")}; + /** * Converts a string to camel case. * @param {string} str @@ -3700,7 +3711,7 @@ BuilderPrototype["import"] = function(json, filename) { if (typeof filename === 'string') { if (ProtoBuf.Util.IS_NODE) - filename = require("path")['resolve'](filename); + filename = ProtoBuf.Util.require("path")['resolve'](filename); if (this.files[filename] === true) { this.reset(); return this; // Skip duplicate imports @@ -3709,7 +3720,7 @@ } else if (typeof filename === 'object') { // Assume object with root, filename. var root = filename.root if (ProtoBuf.Util.IS_NODE) - root = require("path")['resolve'](root); + root = ProtoBuf.Util.require("path")['resolve'](root); var delim = '/'; if (root.indexOf("\\") >= 0 || filename.file.indexOf("\\") >= 0) delim = '\\'; var fname = [root, filename.file].join(delim); diff --git a/dist/ProtoBuf-light.min.js b/dist/ProtoBuf-light.min.js index 1aa17c783..d2cd59cad 100644 --- a/dist/ProtoBuf-light.min.js +++ b/dist/ProtoBuf-light.min.js @@ -3,90 +3,91 @@ Released under the Apache License, Version 2.0 see: https://github.com/dcodeIO/ProtoBuf.js for details */ -(function(h,d){"function"===typeof define&&define.amd?define(["ByteBuffer"],d):"function"===typeof require&&"object"===typeof module&&module&&module.exports?module.exports=d(require("bytebuffer")):(h.dcodeIO=h.dcodeIO||{}).ProtoBuf=d(h.dcodeIO.ByteBuffer)})(this,function(h){var d={};d.ByteBuffer=h;d.Long=h.Long||null;d.VERSION="4.0.0";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:d.Long?d.Long.ZERO:void 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=function(){var b={};b.IS_NODE=!("object"!==typeof process||"[object process]"!==process+"");b.XHR=function(){for(var b=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}], -d=null,h=0;h",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)$/,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,BOOL:/^(?:true|false)$/i};d.Reflect=function(b){function d(a,g){if(a&&"number"===typeof a.low&&"number"===typeof a.high&&"boolean"===typeof a.unsigned&&a.low=== -a.low&&a.high===a.high)return new b.Long(a.low,a.high,"undefined"===typeof g?a.unsigned:g);if("string"===typeof a)return b.Long.fromString(a,g||!1,10);if("number"===typeof a)return b.Long.fromNumber(a,g||!1);throw Error("not convertible to Long");}function u(a,g){var c=g.readVarint32(),e=c&7,c=c>>>3;switch(e){case b.WIRE_TYPES.VARINT:do c=g.readUint8();while(128===(c&128));break;case b.WIRE_TYPES.BITS64:g.offset+=8;break;case b.WIRE_TYPES.LDELIM:c=g.readVarint32();g.offset+=c;break;case b.WIRE_TYPES.STARTGROUP:u(c, -g);break;case b.WIRE_TYPES.ENDGROUP:if(c===a)return!1;throw Error("Illegal GROUPEND after unknown group: "+c+" ("+a+" expected)");case b.WIRE_TYPES.BITS32:g.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+a+": "+e);}return!0}var p={},m=function(a,g,b){this.builder=a;this.parent=g;this.name=b},n=m.prototype;n.fqn=function(){var a=this.name,g=this;do{g=g.parent;if(null==g)break;a=g.name+"."+a}while(1);return a};n.toString=function(a){return(a?this.className+" ":"")+this.fqn()}; -n.build=function(){throw Error(this.toString(!0)+" cannot be built directly");};p.T=m;var c=function(a,g,b,c,e){m.call(this,a,g,b);this.className="Namespace";this.children=[];this.options=c||{};this.syntax=e||"proto2"},n=c.prototype=Object.create(m.prototype);n.getChildren=function(a){a=a||null;if(null==a)return this.children.slice();for(var g=[],b=0,c=this.children.length;bb.MAP_KEY_TYPES.indexOf(a))throw Error("Invalid map key type: "+a.name);},e=f.prototype;e.defaultFieldValue=function(a){"string"===typeof a&&(a=b.TYPES[a]);if("undefined"===typeof a.defaultValue)throw Error("default value for type "+a.name+" is not supported");return a==b.TYPES.bytes?new h(0):a.defaultValue};e.verifyValue=function(a){var g=function(a,g){throw Error("Illegal value for "+ -this.toString(!0)+" of type "+this.type.name+": "+a+" ("+g+")");}.bind(this);switch(this.type){case b.TYPES.int32:case b.TYPES.sint32:case b.TYPES.sfixed32:return("number"!==typeof a||a===a&&0!==a%1)&&g(typeof a,"not an integer"),4294967295a?a>>>0:a;case b.TYPES.int64:case b.TYPES.sint64:case b.TYPES.sfixed64:if(b.Long)try{return d(a,!1)}catch(c){g(typeof a,c.message)}else g(typeof a, -"requires Long.js");case b.TYPES.uint64:case b.TYPES.fixed64:if(b.Long)try{return d(a,!0)}catch(e){g(typeof a,e.message)}else g(typeof a,"requires Long.js");case b.TYPES.bool:return"boolean"!==typeof a&&g(typeof a,"not a boolean"),a;case b.TYPES["float"]:case b.TYPES["double"]:return"number"!==typeof a&&g(typeof a,"not a number"),a;case b.TYPES.string:return"string"===typeof a||a&&a instanceof String||g(typeof a,"not a string"),""+a;case b.TYPES.bytes:return h.isByteBuffer(a)?a:h.wrap(a,"base64"); -case b.TYPES["enum"]:for(var f=this.resolvedType.getChildren(b.Reflect.Enum.Value),s=0;sa)&&g(typeof a,"not in range for uint32"),a;g(a,"not a valid enum value");case b.TYPES.group:case b.TYPES.message:a&&"object"===typeof a||g(typeof a,"object expected");if(a instanceof this.resolvedType.clazz)return a;if(a instanceof b.Builder.Message){var g= -{},s;for(s in a)a.hasOwnProperty(s)&&(g[s]=a[s]);a=g}return new this.resolvedType.clazz(a)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+a+" (undefined type "+this.type+")");};e.calculateLength=function(a,g){if(null===g)return 0;var c;switch(this.type){case b.TYPES.int32:return 0>g?h.calculateVarint64(g):h.calculateVarint32(g);case b.TYPES.uint32:return h.calculateVarint32(g);case b.TYPES.sint32:return h.calculateVarint32(h.zigZagEncode32(g));case b.TYPES.fixed32:case b.TYPES.sfixed32:case b.TYPES["float"]:return 4; +(function(h,v){"function"===typeof define&&define.amd?define(["ByteBuffer"],v):"function"===typeof require&&"object"===typeof module&&module&&module.exports?module.exports=v(require("bytebuffer"),require):(h.dcodeIO=h.dcodeIO||{}).ProtoBuf=v(h.dcodeIO.ByteBuffer)})(this,function(h,v){var e={};e.ByteBuffer=h;e.Long=h.Long||null;e.VERSION="4.0.1";e.WIRE_TYPES={};e.WIRE_TYPES.VARINT=0;e.WIRE_TYPES.BITS64=1;e.WIRE_TYPES.LDELIM=2;e.WIRE_TYPES.STARTGROUP=3;e.WIRE_TYPES.ENDGROUP=4;e.WIRE_TYPES.BITS32=5; +e.PACKABLE_WIRE_TYPES=[e.WIRE_TYPES.VARINT,e.WIRE_TYPES.BITS64,e.WIRE_TYPES.BITS32];e.TYPES={int32:{name:"int32",wireType:e.WIRE_TYPES.VARINT,defaultValue:0},uint32:{name:"uint32",wireType:e.WIRE_TYPES.VARINT,defaultValue:0},sint32:{name:"sint32",wireType:e.WIRE_TYPES.VARINT,defaultValue:0},int64:{name:"int64",wireType:e.WIRE_TYPES.VARINT,defaultValue:e.Long?e.Long.ZERO:void 0},uint64:{name:"uint64",wireType:e.WIRE_TYPES.VARINT,defaultValue:e.Long?e.Long.UZERO:void 0},sint64:{name:"sint64",wireType:e.WIRE_TYPES.VARINT, +defaultValue:e.Long?e.Long.ZERO:void 0},bool:{name:"bool",wireType:e.WIRE_TYPES.VARINT,defaultValue:!1},"double":{name:"double",wireType:e.WIRE_TYPES.BITS64,defaultValue:0},string:{name:"string",wireType:e.WIRE_TYPES.LDELIM,defaultValue:""},bytes:{name:"bytes",wireType:e.WIRE_TYPES.LDELIM,defaultValue:null},fixed32:{name:"fixed32",wireType:e.WIRE_TYPES.BITS32,defaultValue:0},sfixed32:{name:"sfixed32",wireType:e.WIRE_TYPES.BITS32,defaultValue:0},fixed64:{name:"fixed64",wireType:e.WIRE_TYPES.BITS64, +defaultValue:e.Long?e.Long.UZERO:void 0},sfixed64:{name:"sfixed64",wireType:e.WIRE_TYPES.BITS64,defaultValue:e.Long?e.Long.ZERO:void 0},"float":{name:"float",wireType:e.WIRE_TYPES.BITS32,defaultValue:0},"enum":{name:"enum",wireType:e.WIRE_TYPES.VARINT,defaultValue:0},message:{name:"message",wireType:e.WIRE_TYPES.LDELIM,defaultValue:null},group:{name:"group",wireType:e.WIRE_TYPES.STARTGROUP,defaultValue:null}};e.MAP_KEY_TYPES=[e.TYPES.int32,e.TYPES.sint32,e.TYPES.sfixed32,e.TYPES.uint32,e.TYPES.fixed32, +e.TYPES.int64,e.TYPES.sint64,e.TYPES.sfixed64,e.TYPES.uint64,e.TYPES.fixed64,e.TYPES.bool,e.TYPES.string,e.TYPES.bytes];e.ID_MIN=1;e.ID_MAX=536870911;e.convertFieldsToCamelCase=!1;e.populateAccessors=!0;e.populateDefaults=!0;e.Util=function(){var b={};b.IS_NODE=!("object"!==typeof process||"[object process]"!==process+"");b.XHR=function(){for(var b=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}], +e=null,h=0;h",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)$/,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,BOOL:/^(?:true|false)$/i};e.Reflect=function(b){function e(a, +g){if(a&&"number"===typeof a.low&&"number"===typeof a.high&&"boolean"===typeof a.unsigned&&a.low===a.low&&a.high===a.high)return new b.Long(a.low,a.high,"undefined"===typeof g?a.unsigned:g);if("string"===typeof a)return b.Long.fromString(a,g||!1,10);if("number"===typeof a)return b.Long.fromNumber(a,g||!1);throw Error("not convertible to Long");}function u(a,g){var c=g.readVarint32(),d=c&7,c=c>>>3;switch(d){case b.WIRE_TYPES.VARINT:do c=g.readUint8();while(128===(c&128));break;case b.WIRE_TYPES.BITS64:g.offset+= +8;break;case b.WIRE_TYPES.LDELIM:c=g.readVarint32();g.offset+=c;break;case b.WIRE_TYPES.STARTGROUP:u(c,g);break;case b.WIRE_TYPES.ENDGROUP:if(c===a)return!1;throw Error("Illegal GROUPEND after unknown group: "+c+" ("+a+" expected)");case b.WIRE_TYPES.BITS32:g.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+a+": "+d);}return!0}var p={},m=function(a,g,b){this.builder=a;this.parent=g;this.name=b},n=m.prototype;n.fqn=function(){var a=this.name,g=this;do{g=g.parent;if(null==g)break; +a=g.name+"."+a}while(1);return a};n.toString=function(a){return(a?this.className+" ":"")+this.fqn()};n.build=function(){throw Error(this.toString(!0)+" cannot be built directly");};p.T=m;var c=function(a,g,b,c,d){m.call(this,a,g,b);this.className="Namespace";this.children=[];this.options=c||{};this.syntax=d||"proto2"},n=c.prototype=Object.create(m.prototype);n.getChildren=function(a){a=a||null;if(null==a)return this.children.slice();for(var g=[],b=0,c=this.children.length;bb.MAP_KEY_TYPES.indexOf(a))throw Error("Invalid map key type: "+a.name);},d=f.prototype;d.defaultFieldValue=function(a){"string"===typeof a&&(a=b.TYPES[a]);if("undefined"===typeof a.defaultValue)throw Error("default value for type "+a.name+" is not supported");return a==b.TYPES.bytes? +new h(0):a.defaultValue};d.verifyValue=function(a){var g=function(a,b){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+a+" ("+b+")");}.bind(this);switch(this.type){case b.TYPES.int32:case b.TYPES.sint32:case b.TYPES.sfixed32:return("number"!==typeof a||a===a&&0!==a%1)&&g(typeof a,"not an integer"),4294967295a?a>>>0:a;case b.TYPES.int64:case b.TYPES.sint64:case b.TYPES.sfixed64:if(b.Long)try{return e(a, +!1)}catch(c){g(typeof a,c.message)}else g(typeof a,"requires Long.js");case b.TYPES.uint64:case b.TYPES.fixed64:if(b.Long)try{return e(a,!0)}catch(d){g(typeof a,d.message)}else g(typeof a,"requires Long.js");case b.TYPES.bool:return"boolean"!==typeof a&&g(typeof a,"not a boolean"),a;case b.TYPES["float"]:case b.TYPES["double"]:return"number"!==typeof a&&g(typeof a,"not a number"),a;case b.TYPES.string:return"string"===typeof a||a&&a instanceof String||g(typeof a,"not a string"),""+a;case b.TYPES.bytes:return h.isByteBuffer(a)? +a:h.wrap(a,"base64");case b.TYPES["enum"]:for(var f=this.resolvedType.getChildren(b.Reflect.Enum.Value),s=0;sa)&&g(typeof a,"not in range for uint32"),a;g(a,"not a valid enum value");case b.TYPES.group:case b.TYPES.message:a&&"object"===typeof a||g(typeof a,"object expected");if(a instanceof this.resolvedType.clazz)return a;if(a instanceof +b.Builder.Message){var g={},s;for(s in a)a.hasOwnProperty(s)&&(g[s]=a[s]);a=g}return new this.resolvedType.clazz(a)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+a+" (undefined type "+this.type+")");};d.calculateLength=function(a,g){if(null===g)return 0;var c;switch(this.type){case b.TYPES.int32:return 0>g?h.calculateVarint64(g):h.calculateVarint32(g);case b.TYPES.uint32:return h.calculateVarint32(g);case b.TYPES.sint32:return h.calculateVarint32(h.zigZagEncode32(g));case b.TYPES.fixed32:case b.TYPES.sfixed32:case b.TYPES["float"]:return 4; case b.TYPES.int64:case b.TYPES.uint64:return h.calculateVarint64(g);case b.TYPES.sint64:return h.calculateVarint64(h.zigZagEncode64(g));case b.TYPES.fixed64:case b.TYPES.sfixed64:return 8;case b.TYPES.bool:return 1;case b.TYPES["enum"]:return h.calculateVarint32(g);case b.TYPES["double"]:return 8;case b.TYPES.string:return c=h.calculateUTF8Bytes(g),h.calculateVarint32(c)+c;case b.TYPES.bytes:if(0>g.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+g.remaining()+" bytes remaining"); -return h.calculateVarint32(g.remaining())+g.remaining();case b.TYPES.message:return c=this.resolvedType.calculate(g),h.calculateVarint32(c)+c;case b.TYPES.group:return c=this.resolvedType.calculate(g),c+h.calculateVarint32(a<<3|b.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+g+" (unknown type)");};e.encodeValue=function(a,g,c){if(null===g)return c;switch(this.type){case b.TYPES.int32:0>g?c.writeVarint64(g):c.writeVarint32(g);break;case b.TYPES.uint32:c.writeVarint32(g); -break;case b.TYPES.sint32:c.writeVarint32ZigZag(g);break;case b.TYPES.fixed32:c.writeUint32(g);break;case b.TYPES.sfixed32:c.writeInt32(g);break;case b.TYPES.int64:case b.TYPES.uint64:c.writeVarint64(g);break;case b.TYPES.sint64:c.writeVarint64ZigZag(g);break;case b.TYPES.fixed64:c.writeUint64(g);break;case b.TYPES.sfixed64:c.writeInt64(g);break;case b.TYPES.bool:"string"===typeof g?c.writeVarint32("false"===g.toLowerCase()?0:!!g):c.writeVarint32(g?1:0);break;case b.TYPES["enum"]:c.writeVarint32(g); -break;case b.TYPES["float"]:c.writeFloat32(g);break;case b.TYPES["double"]:c.writeFloat64(g);break;case b.TYPES.string:c.writeVString(g);break;case b.TYPES.bytes:if(0>g.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+g.remaining()+" bytes remaining");a=g.offset;c.writeVarint32(g.remaining());c.append(g);g.offset=a;break;case b.TYPES.message:a=(new h).LE();this.resolvedType.encode(g,a);c.writeVarint32(a.offset);c.append(a.flip());break;case b.TYPES.group:this.resolvedType.encode(g, -c);c.writeVarint32(a<<3|b.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+g+" (unknown type)");}return c};e.decode=function(a,c,e){if(c!=this.type.wireType)throw Error("Unexpected wire type for element");switch(this.type){case b.TYPES.int32:return a.readVarint32()|0;case b.TYPES.uint32:return a.readVarint32()>>>0;case b.TYPES.sint32:return a.readVarint32ZigZag()|0;case b.TYPES.fixed32:return a.readUint32()>>>0;case b.TYPES.sfixed32:return a.readInt32()| -0;case b.TYPES.int64:return a.readVarint64();case b.TYPES.uint64:return a.readVarint64().toUnsigned();case b.TYPES.sint64:return a.readVarint64ZigZag();case b.TYPES.fixed64:return a.readUint64();case b.TYPES.sfixed64:return a.readInt64();case b.TYPES.bool:return!!a.readVarint32();case b.TYPES["enum"]:return a.readVarint32();case b.TYPES["float"]:return a.readFloat();case b.TYPES["double"]:return a.readDouble();case b.TYPES.string:return a.readVString();case b.TYPES.bytes:e=a.readVarint32();if(a.remaining()< -e)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+e+" required but got only "+a.remaining());c=a.clone();c.limit=c.offset+e;a.offset+=e;return c;case b.TYPES.message:return e=a.readVarint32(),this.resolvedType.decode(a,e);case b.TYPES.group:return this.resolvedType.decode(a,-1,e)}throw Error("[INTERNAL] Illegal decode type");};e.valueFromString=function(a){if(!this.isMapKey)throw Error("valueFromString() called on non-map-key element");switch(this.type){case b.TYPES.int32:case b.TYPES.sint32:case b.TYPES.sfixed32:case b.TYPES.uint32:case b.TYPES.fixed32:return this.verifyValue(parseInt(a)); -case b.TYPES.int64:case b.TYPES.sint64:case b.TYPES.sfixed64:case b.TYPES.uint64:case b.TYPES.fixed64:return this.verifyValue(a);case b.TYPES.bool:return"true"===a;case b.TYPES.string:return this.verifyValue(a);case b.TYPES.bytes:return h.fromBinary(a)}};e.valueToString=function(a){if(!this.isMapKey)throw Error("valueToString() called on non-map-key element");return this.type===b.TYPES.bytes?a.toString("binary"):a.toString()};p.Element=f;var l=function(a,g,e,f,d,s){c.call(this,a,g,e,f,s);this.className= -"Message";this.extensions=[b.ID_MIN,b.ID_MAX];this.clazz=null;this.isGroup=!!d;this._fieldsByName=this._fieldsById=this._fields=null},e=l.prototype=Object.create(c.prototype);e.build=function(a){if(this.clazz&&!a)return this.clazz;a=function(a,c){function b(c,g,e,f,d){var r=void 0;if(null===c||"object"!==typeof c){if(f==a.TYPES["enum"]){g=d.getChildren(a.Reflect.Enum.Value);for(var l=0;la.remaining())return null;var g=a.offset, -f=a.readVarint32();if(a.remaining()>>3;if(k===b.WIRE_TYPES.ENDGROUP){if(m!==f)throw Error("Illegal group end indicator for "+ -this.toString(!0)+": "+m+" ("+(f?f+" expected":"not a group")+")");break}if(l=this._fieldsById[m])l.repeated&&!l.options.packed?d[l.name].push(l.decode(k,a)):l.map?(k=l.decode(k,a),d[l.name].set(k[0],k[1])):(d[l.name]=l.decode(k,a),l.oneof&&(null!==this[l.oneof.name]&&(this[this[l.oneof.name]]=null),d[l.oneof.name]=l.name));else switch(k){case b.WIRE_TYPES.VARINT:a.readVarint32();break;case b.WIRE_TYPES.BITS32:a.offset+=4;break;case b.WIRE_TYPES.BITS64:a.offset+=8;break;case b.WIRE_TYPES.LDELIM:l= -a.readVarint32();a.offset+=l;break;case b.WIRE_TYPES.STARTGROUP:for(;u(m,a););break;default:throw Error("Illegal wire type for unknown field "+m+" in "+this.toString(!0)+"#decode: "+k);}}a=0;for(c=this._fields.length;a>>=3,1===c)e=this.keyElement.decode(d,a,c);else if(2===c)f= -this.element.decode(d,a,c);else throw Error("Unexpected tag in map field key/value submessage");return[e,f]}return this.element.decode(c,a,this.id)};p.Message.Field=v;e=function(a,c,b,f,e,d,l){v.call(this,a,c,b,null,f,e,d,l)};e.prototype=Object.create(v.prototype);p.Message.ExtensionField=e;p.Message.OneOf=function(a,c,b){m.call(this,a,c,b);this.fields=[]};var q=function(a,b,f,e,d){c.call(this,a,b,f,e,d);this.className="Enum";this.object=null};(q.prototype=Object.create(c.prototype)).build=function(){for(var a= -{},c=this.getChildren(q.Value),b=0,f=c.length;bb.ID_MAX&&(d.extensions[1]=b.ID_MAX));this.ptr.addChild(d);0d.extensions[1])throw Error("Illegal extended field id in message "+d.name+": "+e.fields[k].id+" ("+d.extensions.join(" to ")+" expected)");n=e.fields[k].name;this.options.convertFieldsToCamelCase&&(n=b.Util.toCamelCase(e.fields[k].name));q=new h.Message.ExtensionField(this,d,e.fields[k].rule,e.fields[k].type,this.ptr.fqn()+"."+n,e.fields[k].id,e.fields[k].options);n=new h.Extension(this,this.ptr,e.fields[k].name,q);q.extension=n;this.ptr.addChild(n);d.addChild(q)}else{if(!/\.?google\.protobuf\./.test(e.ref))throw Error("Extended message "+ -e.ref+" is not defined");}else throw Error("Not a valid definition: "+JSON.stringify(e));}else throw Error("Not a valid namespace: "+JSON.stringify(c));this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this};n["import"]=function(c,f){if("string"===typeof f){b.Util.IS_NODE&&(f=require("path").resolve(f));if(!0===this.files[f])return this.reset(),this;this.files[f]=!0}else if("object"===typeof f){var e=f.root;b.Util.IS_NODE&&(e=require("path").resolve(e));e=[e,f.file].join("/");if(!0=== -this.files[e])return this.reset(),this;this.files[e]=!0}if(c.imports&&0c?d.writeVarint64(c):d.writeVarint32(c);break;case b.TYPES.uint32:d.writeVarint32(c); +break;case b.TYPES.sint32:d.writeVarint32ZigZag(c);break;case b.TYPES.fixed32:d.writeUint32(c);break;case b.TYPES.sfixed32:d.writeInt32(c);break;case b.TYPES.int64:case b.TYPES.uint64:d.writeVarint64(c);break;case b.TYPES.sint64:d.writeVarint64ZigZag(c);break;case b.TYPES.fixed64:d.writeUint64(c);break;case b.TYPES.sfixed64:d.writeInt64(c);break;case b.TYPES.bool:"string"===typeof c?d.writeVarint32("false"===c.toLowerCase()?0:!!c):d.writeVarint32(c?1:0);break;case b.TYPES["enum"]:d.writeVarint32(c); +break;case b.TYPES["float"]:d.writeFloat32(c);break;case b.TYPES["double"]:d.writeFloat64(c);break;case b.TYPES.string:d.writeVString(c);break;case b.TYPES.bytes:if(0>c.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+c.remaining()+" bytes remaining");a=c.offset;d.writeVarint32(c.remaining());d.append(c);c.offset=a;break;case b.TYPES.message:a=(new h).LE();this.resolvedType.encode(c,a);d.writeVarint32(a.offset);d.append(a.flip());break;case b.TYPES.group:this.resolvedType.encode(c, +d);d.writeVarint32(a<<3|b.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+c+" (unknown type)");}return d};d.decode=function(a,c,d){if(c!=this.type.wireType)throw Error("Unexpected wire type for element");switch(this.type){case b.TYPES.int32:return a.readVarint32()|0;case b.TYPES.uint32:return a.readVarint32()>>>0;case b.TYPES.sint32:return a.readVarint32ZigZag()|0;case b.TYPES.fixed32:return a.readUint32()>>>0;case b.TYPES.sfixed32:return a.readInt32()| +0;case b.TYPES.int64:return a.readVarint64();case b.TYPES.uint64:return a.readVarint64().toUnsigned();case b.TYPES.sint64:return a.readVarint64ZigZag();case b.TYPES.fixed64:return a.readUint64();case b.TYPES.sfixed64:return a.readInt64();case b.TYPES.bool:return!!a.readVarint32();case b.TYPES["enum"]:return a.readVarint32();case b.TYPES["float"]:return a.readFloat();case b.TYPES["double"]:return a.readDouble();case b.TYPES.string:return a.readVString();case b.TYPES.bytes:d=a.readVarint32();if(a.remaining()< +d)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+d+" required but got only "+a.remaining());c=a.clone();c.limit=c.offset+d;a.offset+=d;return c;case b.TYPES.message:return d=a.readVarint32(),this.resolvedType.decode(a,d);case b.TYPES.group:return this.resolvedType.decode(a,-1,d)}throw Error("[INTERNAL] Illegal decode type");};d.valueFromString=function(a){if(!this.isMapKey)throw Error("valueFromString() called on non-map-key element");switch(this.type){case b.TYPES.int32:case b.TYPES.sint32:case b.TYPES.sfixed32:case b.TYPES.uint32:case b.TYPES.fixed32:return this.verifyValue(parseInt(a)); +case b.TYPES.int64:case b.TYPES.sint64:case b.TYPES.sfixed64:case b.TYPES.uint64:case b.TYPES.fixed64:return this.verifyValue(a);case b.TYPES.bool:return"true"===a;case b.TYPES.string:return this.verifyValue(a);case b.TYPES.bytes:return h.fromBinary(a)}};d.valueToString=function(a){if(!this.isMapKey)throw Error("valueToString() called on non-map-key element");return this.type===b.TYPES.bytes?a.toString("binary"):a.toString()};p.Element=f;var k=function(a,g,d,f,e,s){c.call(this,a,g,d,f,s);this.className= +"Message";this.extensions=[b.ID_MIN,b.ID_MAX];this.clazz=null;this.isGroup=!!e;this._fieldsByName=this._fieldsById=this._fields=null},d=k.prototype=Object.create(c.prototype);d.build=function(a){if(this.clazz&&!a)return this.clazz;a=function(a,c){function b(c,d,g,f,e){var r=void 0;if(null===c||"object"!==typeof c){if(f==a.TYPES["enum"]){d=e.getChildren(a.Reflect.Enum.Value);for(var k=0;ka.remaining())return null;var d=a.offset, +g=a.readVarint32();if(a.remaining()>>3;if(l===b.WIRE_TYPES.ENDGROUP){if(m!==d)throw Error("Illegal group end indicator for "+ +this.toString(!0)+": "+m+" ("+(d?d+" expected":"not a group")+")");break}if(k=this._fieldsById[m])k.repeated&&!k.options.packed?e[k.name].push(k.decode(l,a)):k.map?(l=k.decode(l,a),e[k.name].set(l[0],l[1])):(e[k.name]=k.decode(l,a),k.oneof&&(null!==this[k.oneof.name]&&(this[this[k.oneof.name]]=null),e[k.oneof.name]=k.name));else switch(l){case b.WIRE_TYPES.VARINT:a.readVarint32();break;case b.WIRE_TYPES.BITS32:a.offset+=4;break;case b.WIRE_TYPES.BITS64:a.offset+=8;break;case b.WIRE_TYPES.LDELIM:k= +a.readVarint32();a.offset+=k;break;case b.WIRE_TYPES.STARTGROUP:for(;u(m,a););break;default:throw Error("Illegal wire type for unknown field "+m+" in "+this.toString(!0)+"#decode: "+l);}}a=0;for(c=this._fields.length;a>>=3,1===c)f=this.keyElement.decode(e,a,c);else if(2===c)d= +this.element.decode(e,a,c);else throw Error("Unexpected tag in map field key/value submessage");return[f,d]}return this.element.decode(c,a,this.id)};p.Message.Field=w;d=function(a,c,b,d,f,e,k){w.call(this,a,c,b,null,d,f,e,k)};d.prototype=Object.create(w.prototype);p.Message.ExtensionField=d;p.Message.OneOf=function(a,c,b){m.call(this,a,c,b);this.fields=[]};var q=function(a,b,d,f,e){c.call(this,a,b,d,f,e);this.className="Enum";this.object=null};(q.prototype=Object.create(c.prototype)).build=function(){for(var a= +{},c=this.getChildren(q.Value),b=0,d=c.length;bb.ID_MAX&&(e.extensions[1]=b.ID_MAX));this.ptr.addChild(e);0e.extensions[1])throw Error("Illegal extended field id in message "+e.name+": "+d.fields[l].id+" ("+e.extensions.join(" to ")+" expected)");n=d.fields[l].name;this.options.convertFieldsToCamelCase&&(n=b.Util.toCamelCase(d.fields[l].name));q=new h.Message.ExtensionField(this,e,d.fields[l].rule,d.fields[l].type,this.ptr.fqn()+"."+n,d.fields[l].id,d.fields[l].options);n=new h.Extension(this,this.ptr,d.fields[l].name,q);q.extension=n;this.ptr.addChild(n);e.addChild(q)}else{if(!/\.?google\.protobuf\./.test(d.ref))throw Error("Extended message "+ +d.ref+" is not defined");}else throw Error("Not a valid definition: "+JSON.stringify(d));}else throw Error("Not a valid namespace: "+JSON.stringify(c));this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this};n["import"]=function(c,e){if("string"===typeof e){b.Util.IS_NODE&&(e=b.Util.require("path").resolve(e));if(!0===this.files[e])return this.reset(),this;this.files[e]=!0}else if("object"===typeof e){var d=e.root;b.Util.IS_NODE&&(d=b.Util.require("path").resolve(d));var k="/";if(0<= +d.indexOf("\\")||0<=e.file.indexOf("\\"))k="\\";k=[d,e.file].join(k);if(!0===this.files[k])return this.reset(),this;this.files[k]=!0}if(c.imports&&0= 0 || filename.file.indexOf("\\") >= 0) delim = '\\'; var fname = [root, filename.file].join(delim); diff --git a/dist/ProtoBuf.min.js b/dist/ProtoBuf.min.js index 0cdb2ef18..e1ff44723 100644 --- a/dist/ProtoBuf.min.js +++ b/dist/ProtoBuf.min.js @@ -3,82 +3,82 @@ Released under the Apache License, Version 2.0 see: https://github.com/dcodeIO/ProtoBuf.js for details */ -(function(k,f){"function"===typeof define&&define.amd?define(["ByteBuffer"],f):"function"===typeof require&&"object"===typeof module&&module&&module.exports?module.exports=f(require("bytebuffer")):(k.dcodeIO=k.dcodeIO||{}).ProtoBuf=f(k.dcodeIO.ByteBuffer)})(this,function(k){var f={};f.ByteBuffer=k;f.Long=k.Long||null;f.VERSION="4.0.0";f.WIRE_TYPES={};f.WIRE_TYPES.VARINT=0;f.WIRE_TYPES.BITS64=1;f.WIRE_TYPES.LDELIM=2;f.WIRE_TYPES.STARTGROUP=3;f.WIRE_TYPES.ENDGROUP=4;f.WIRE_TYPES.BITS32=5;f.PACKABLE_WIRE_TYPES= -[f.WIRE_TYPES.VARINT,f.WIRE_TYPES.BITS64,f.WIRE_TYPES.BITS32];f.TYPES={int32:{name:"int32",wireType:f.WIRE_TYPES.VARINT,defaultValue:0},uint32:{name:"uint32",wireType:f.WIRE_TYPES.VARINT,defaultValue:0},sint32:{name:"sint32",wireType:f.WIRE_TYPES.VARINT,defaultValue:0},int64:{name:"int64",wireType:f.WIRE_TYPES.VARINT,defaultValue:f.Long?f.Long.ZERO:void 0},uint64:{name:"uint64",wireType:f.WIRE_TYPES.VARINT,defaultValue:f.Long?f.Long.UZERO:void 0},sint64:{name:"sint64",wireType:f.WIRE_TYPES.VARINT, +(function(k,v){"function"===typeof define&&define.amd?define(["ByteBuffer"],v):"function"===typeof require&&"object"===typeof module&&module&&module.exports?module.exports=v(require("bytebuffer"),require):(k.dcodeIO=k.dcodeIO||{}).ProtoBuf=v(k.dcodeIO.ByteBuffer)})(this,function(k,v){var f={};f.ByteBuffer=k;f.Long=k.Long||null;f.VERSION="4.0.1";f.WIRE_TYPES={};f.WIRE_TYPES.VARINT=0;f.WIRE_TYPES.BITS64=1;f.WIRE_TYPES.LDELIM=2;f.WIRE_TYPES.STARTGROUP=3;f.WIRE_TYPES.ENDGROUP=4;f.WIRE_TYPES.BITS32=5; +f.PACKABLE_WIRE_TYPES=[f.WIRE_TYPES.VARINT,f.WIRE_TYPES.BITS64,f.WIRE_TYPES.BITS32];f.TYPES={int32:{name:"int32",wireType:f.WIRE_TYPES.VARINT,defaultValue:0},uint32:{name:"uint32",wireType:f.WIRE_TYPES.VARINT,defaultValue:0},sint32:{name:"sint32",wireType:f.WIRE_TYPES.VARINT,defaultValue:0},int64:{name:"int64",wireType:f.WIRE_TYPES.VARINT,defaultValue:f.Long?f.Long.ZERO:void 0},uint64:{name:"uint64",wireType:f.WIRE_TYPES.VARINT,defaultValue:f.Long?f.Long.UZERO:void 0},sint64:{name:"sint64",wireType:f.WIRE_TYPES.VARINT, defaultValue:f.Long?f.Long.ZERO:void 0},bool:{name:"bool",wireType:f.WIRE_TYPES.VARINT,defaultValue:!1},"double":{name:"double",wireType:f.WIRE_TYPES.BITS64,defaultValue:0},string:{name:"string",wireType:f.WIRE_TYPES.LDELIM,defaultValue:""},bytes:{name:"bytes",wireType:f.WIRE_TYPES.LDELIM,defaultValue:null},fixed32:{name:"fixed32",wireType:f.WIRE_TYPES.BITS32,defaultValue:0},sfixed32:{name:"sfixed32",wireType:f.WIRE_TYPES.BITS32,defaultValue:0},fixed64:{name:"fixed64",wireType:f.WIRE_TYPES.BITS64, defaultValue:f.Long?f.Long.UZERO:void 0},sfixed64:{name:"sfixed64",wireType:f.WIRE_TYPES.BITS64,defaultValue:f.Long?f.Long.ZERO:void 0},"float":{name:"float",wireType:f.WIRE_TYPES.BITS32,defaultValue:0},"enum":{name:"enum",wireType:f.WIRE_TYPES.VARINT,defaultValue:0},message:{name:"message",wireType:f.WIRE_TYPES.LDELIM,defaultValue:null},group:{name:"group",wireType:f.WIRE_TYPES.STARTGROUP,defaultValue:null}};f.MAP_KEY_TYPES=[f.TYPES.int32,f.TYPES.sint32,f.TYPES.sfixed32,f.TYPES.uint32,f.TYPES.fixed32, f.TYPES.int64,f.TYPES.sint64,f.TYPES.sfixed64,f.TYPES.uint64,f.TYPES.fixed64,f.TYPES.bool,f.TYPES.string,f.TYPES.bytes];f.ID_MIN=1;f.ID_MAX=536870911;f.convertFieldsToCamelCase=!1;f.populateAccessors=!0;f.populateDefaults=!0;f.Util=function(){var c={};c.IS_NODE=!("object"!==typeof process||"[object process]"!==process+"");c.XHR=function(){for(var c=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}], -f=null,k=0;k",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)$/,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,BOOL:/^(?:true|false)$/i};f.DotProto=function(c,e){var f={},k=function(b){this.source=""+b;this.index=0;this.line=1;this.stack=[];this.readingString=!1;this.stringEndsWith= -e.STRINGCLOSE},h=k.prototype;h._readString=function(){e.STRING.lastIndex=this.index-1;var b;if(null!==(b=e.STRING.exec(this.source)))return b="undefined"!==typeof b[1]?b[1]:b[2],this.index=e.STRING.lastIndex,this.stack.push(this.stringEndsWith),b;throw Error("Unterminated string at line "+this.line+", index "+this.index);};h.next=function(){if(0=this.source.length)return null;if(this.readingString)return this.readingString=!1,this._readString(); -var b,a;do{for(b=!1;e.WHITESPACE.test(a=this.source.charAt(this.index));)if(this.index++,"\n"===a&&this.line++,this.index===this.source.length)return null;if("/"===this.source.charAt(this.index))if("/"===this.source.charAt(++this.index)){for(;"\n"!==this.source.charAt(this.index);)if(this.index++,this.index==this.source.length)return null;this.index++;this.line++;b=!0}else if("*"===this.source.charAt(this.index)){for(a="";"*/"!==a+(a=this.source.charAt(this.index));)if(this.index++,"\n"===a&&this.line++, -this.index===this.source.length)return null;this.index++;b=!0}else throw Error("Unterminated comment at line "+this.line+": /"+this.source.charAt(this.index));}while(b);if(this.index===this.source.length)return null;b=this.index;e.DELIM.lastIndex=0;if(e.DELIM.test(this.source.charAt(b)))++b;else for(++b;ba?"-":"")+b);}; -g._parseString=function(){var b="",a,d;do{d=this.tn.next();b+=this.tn.next();a=this.tn.next();if(a!==d)throw Error("Illegal end of string at line "+this.tn.line+": "+a);a=this.tn.peek()}while(a===e.STRINGOPEN||a===e.STRINGOPEN_SQ);return b};g._parseId=function(b,a){var d=-1,c=1;"-"==b.charAt(0)&&(c=-1,b=b.substring(1));if(e.NUMBER_DEC.test(b))d=parseInt(b);else if(e.NUMBER_HEX.test(b))d=parseInt(b.substring(2),16);else if(e.NUMBER_OCT.test(b))d=parseInt(b.substring(1),8);else throw Error("Illegal id at line "+ -this.tn.line+": "+(0>c?"-":"")+b);d=c*d|0;if(!a&&0>d)throw Error("Illegal id at line "+this.tn.line+": "+(0>c?"-":"")+b);return d};g._parsePackage=function(b){b=this.tn.next();if(!e.TYPEREF.test(b))throw Error("Illegal package name at line "+this.tn.line+": "+b);var a=b;b=this.tn.next();if(b!=e.END)throw Error("Illegal end of package at line "+this.tn.line+": "+b);return a};g._parseImport=function(b){b=this.tn.peek();"public"===b&&(this.tn.next(),b=this.tn.peek());if(b!==e.STRINGOPEN&&b!==e.STRINGOPEN_SQ)throw Error("Illegal start of import at line "+ -this.tn.line+": "+b);var a=this._parseString();b=this.tn.next();if(b!==e.END)throw Error("Illegal end of import at line "+this.tn.line+": "+b);return a};g._parseOption=function(b,a){a=this.tn.next();var d=!1;a==e.COPTOPEN&&(d=!0,a=this.tn.next());if(!e.TYPEREF.test(a)&&!/google\.protobuf\./.test(a))throw Error("Illegal option name in message "+b.name+" at line "+this.tn.line+": "+a);var c=a;a=this.tn.next();if(d){if(a!==e.COPTCLOSE)throw Error("Illegal end in message "+b.name+", option "+c+" at line "+ -this.tn.line+": "+a);c="("+c+")";a=this.tn.next();e.FQTYPEREF.test(a)&&(c+=a,a=this.tn.next())}if(a!==e.EQUAL)throw Error("Illegal operator in message "+b.name+", option "+c+" at line "+this.tn.line+": "+a);a=this.tn.peek();if(a===e.STRINGOPEN||a===e.STRINGOPEN_SQ)d=this._parseString();else if(this.tn.next(),e.NUMBER.test(a))d=this._parseNumber(a,!0);else if(e.BOOL.test(a))d="true"===a;else if(e.TYPEREF.test(a))d=a;else throw Error("Illegal option value in message "+b.name+", option "+c+" at line "+ -this.tn.line+": "+a);a=this.tn.next();if(a!==e.END)throw Error("Illegal end of option in message "+b.name+", option "+c+" at line "+this.tn.line+": "+a);b.options[c]=d};g._parseIgnoredStatement=function(b,a){var d;do{d=this.tn.next();if(null===d)throw Error("Unexpected EOF in "+b.name+", "+a+" at line "+this.tn.line);if(d===e.END)break}while(1)};g._parseService=function(b,a){a=this.tn.next();if(!e.NAME.test(a))throw Error("Illegal service name at line "+this.tn.line+": "+a);var d=a,c={name:d,rpc:{}, -options:{}};a=this.tn.next();if(a!==e.OPEN)throw Error("Illegal start of service "+d+" at line "+this.tn.line+": "+a);do if(a=this.tn.next(),"option"===a)this._parseOption(c,a);else if("rpc"===a)this._parseServiceRPC(c,a);else if(a!==e.CLOSE)throw Error("Illegal type of service "+d+" at line "+this.tn.line+": "+a);while(a!==e.CLOSE);b.services.push(c)};g._parseServiceRPC=function(b,a){var d=a;a=this.tn.next();if(!e.NAME.test(a))throw Error("Illegal method name in service "+b.name+" at line "+this.tn.line+ -": "+a);var c=a,f={request:null,response:null,request_stream:!1,response_stream:!1,options:{}};a=this.tn.next();if(a!==e.COPTOPEN)throw Error("Illegal start of request type in service "+b.name+"#"+c+" at line "+this.tn.line+": "+a);a=this.tn.next();"stream"===a.toLowerCase()&&(f.request_stream=!0,a=this.tn.next());if(!e.TYPEREF.test(a))throw Error("Illegal request type in service "+b.name+"#"+c+" at line "+this.tn.line+": "+a);f.request=a;a=this.tn.next();if(a!=e.COPTCLOSE)throw Error("Illegal end of request type in service "+ -b.name+"#"+c+" at line "+this.tn.line+": "+a);a=this.tn.next();if("returns"!==a.toLowerCase())throw Error("Illegal delimiter in service "+b.name+"#"+c+" at line "+this.tn.line+": "+a);a=this.tn.next();if(a!=e.COPTOPEN)throw Error("Illegal start of response type in service "+b.name+"#"+c+" at line "+this.tn.line+": "+a);a=this.tn.next();"stream"===a.toLowerCase()&&(f.response_stream=!0,a=this.tn.next());f.response=a;a=this.tn.next();if(a!==e.COPTCLOSE)throw Error("Illegal end of response type in service "+ -b.name+"#"+c+" at line "+this.tn.line+": "+a);a=this.tn.next();if(a===e.OPEN){do if(a=this.tn.next(),"option"===a)this._parseOption(f,a);else if(a!==e.CLOSE)throw Error("Illegal start of option inservice "+b.name+"#"+c+" at line "+this.tn.line+": "+a);while(a!==e.CLOSE);this.tn.peek()===e.END&&this.tn.next()}else if(a!==e.END)throw Error("Illegal delimiter in service "+b.name+"#"+c+" at line "+this.tn.line+": "+a);"undefined"===typeof b[d]&&(b[d]={});b[d][c]=f};g._parseMessage=function(b,a,d){var c= -{},f="group"===d;d=this.tn.next();if(!e.NAME.test(d))throw Error("Illegal "+(f?"group":"message")+" name"+(b?" in message "+b.name:"")+" at line "+this.tn.line+": "+d);c.name=d;if(f){d=this.tn.next();if(d!==e.EQUAL)throw Error("Illegal id assignment after group "+c.name+" at line "+this.tn.line+": "+d);d=this.tn.next();try{a.id=this._parseId(d)}catch(g){throw Error("Illegal field id value for group "+c.name+"#"+a.name+" at line "+this.tn.line+": "+d);}c.isGroup=!0}c.fields=[];c.enums=[];c.messages= -[];c.options={};c.oneofs={};d=this.tn.next();d===e.OPTOPEN&&a&&(this._parseFieldOptions(c,a,d),d=this.tn.next());if(d!==e.OPEN)throw Error("Illegal start of "+(f?"group":"message")+" "+c.name+" at line "+this.tn.line+": "+d);do if(d=this.tn.next(),d===e.CLOSE){d=this.tn.peek();d===e.END&&this.tn.next();break}else if(e.RULE.test(d))this._parseMessageField(c,d);else if("oneof"===d)this._parseMessageOneOf(c,d);else if("enum"===d)this._parseEnum(c,d);else if("message"===d)this._parseMessage(c,null,d); -else if("option"===d)this._parseOption(c,d);else if("extensions"===d)c.extensions=this._parseExtensions(c,d);else if("extend"===d)this._parseExtend(c,d);else if(e.TYPEREF.test(d))this._parseMessageField(c,"optional",d);else throw Error("Illegal token in message "+c.name+" at line "+this.tn.line+": "+d);while(1);b.messages.push(c);return c};g._parseMessageField=function(b,a,d){var c={},f=null;c.rule=a;c.options={};a="undefined"!==typeof d?d:this.tn.next();if("map"===c.rule){if(a!==e.LT)throw Error("Illegal token in message "+ -b.name+" at line "+this.tn.line+": "+a);a=this.tn.next();if(!e.TYPE.test(a)&&!e.TYPEREF.test(a))throw Error("Illegal token in message "+b.name+" at line "+this.tn.line+": "+a);c.keytype=a;a=this.tn.next();if(a!==e.COMMA)throw Error("Illegal token in message "+b.name+" at line "+this.tn.line+": "+a);a=this.tn.next();if(!e.TYPE.test(a)&&!e.TYPEREF.test(a))throw Error("Illegal token in message "+b.name+" at line "+this.tn.line+": "+a);c.type=a;a=this.tn.next();if(a!==e.GT)throw Error("Illegal token in message "+ -b.name+" at line "+this.tn.line+": "+a);a=this.tn.next();if(!e.NAME.test(a))throw Error("Illegal token in message "+b.name+" at line "+this.tn.line+": "+a);c.name=a;a=this.tn.next();if(a!==e.EQUAL)throw Error("Illegal token in field "+b.name+"#"+c.name+" at line "+this.line+": "+a);a=this.tn.next();try{c.id=this._parseId(a)}catch(g){throw Error("Illegal field id in message "+b.name+"#"+c.name+" at line "+this.tn.line+": "+a);}a=this.tn.next();a===e.OPTOPEN&&(this._parseFieldOptions(b,c,a),a=this.tn.next()); -if(a!==e.END)throw Error("Illegal delimiter in message "+b.name+"#"+c.name+" at line "+this.tn.line+": "+a);}else if("group"===a){f=this._parseMessage(b,c,a);if(!/^[A-Z]/.test(f.name))throw Error("Group names must start with a capital letter");c.type=f.name;c.name=f.name.toLowerCase();a=this.tn.peek();a===e.END&&this.tn.next()}else{if(!e.TYPE.test(a)&&!e.TYPEREF.test(a))throw Error("Illegal field type in message "+b.name+" at line "+this.tn.line+": "+a);c.type=a;a=this.tn.next();if(!e.NAME.test(a))throw Error("Illegal field name in message "+ -b.name+" at line "+this.tn.line+": "+a);c.name=a;a=this.tn.next();if(a!==e.EQUAL)throw Error("Illegal token in field "+b.name+"#"+c.name+" at line "+this.tn.line+": "+a);a=this.tn.next();try{c.id=this._parseId(a)}catch(h){throw Error("Illegal field id in message "+b.name+"#"+c.name+" at line "+this.tn.line+": "+a);}a=this.tn.next();a===e.OPTOPEN&&(this._parseFieldOptions(b,c,a),a=this.tn.next());if(a!==e.END)throw Error("Illegal delimiter in message "+b.name+"#"+c.name+" at line "+this.tn.line+": "+ -a);}b.fields.push(c);return c};g._parseMessageOneOf=function(b,a){a=this.tn.next();if(!e.NAME.test(a))throw Error("Illegal oneof name in message "+b.name+" at line "+this.tn.line+": "+a);var c=a,f,g=[];a=this.tn.next();if(a!==e.OPEN)throw Error("Illegal start of oneof "+c+" at line "+this.tn.line+": "+a);for(;this.tn.peek()!==e.CLOSE;)f=this._parseMessageField(b,"optional"),f.oneof=c,g.push(f.id);this.tn.next();b.oneofs[c]=g};g._parseFieldOptions=function(b,a,c){var f=!0;do{c=this.tn.next();if(c=== -e.OPTCLOSE)break;else if(c===e.OPTEND){if(f)throw Error("Illegal start of options in message "+b.name+"#"+a.name+" at line "+this.tn.line+": "+c);c=this.tn.next()}this._parseFieldOption(b,a,c);f=!1}while(1)};g._parseFieldOption=function(b,a,c){var f=!1;c===e.COPTOPEN&&(c=this.tn.next(),f=!0);if(!e.TYPEREF.test(c))throw Error("Illegal field option in "+b.name+"#"+a.name+" at line "+this.tn.line+": "+c);var g=c;c=this.tn.next();if(f){if(c!==e.COPTCLOSE)throw Error("Illegal delimiter in "+b.name+"#"+ -a.name+" at line "+this.tn.line+": "+c);g="("+g+")";c=this.tn.next();e.FQTYPEREF.test(c)&&(g+=c,c=this.tn.next())}if(c!==e.EQUAL)throw Error("Illegal token in "+b.name+"#"+a.name+" at line "+this.tn.line+": "+c);c=this.tn.peek();if(c===e.STRINGOPEN||c===e.STRINGOPEN_SQ)b=this._parseString();else if(e.NUMBER.test(c,!0))b=this._parseNumber(this.tn.next(),!0);else if(e.BOOL.test(c))b="true"===this.tn.next().toLowerCase();else if(e.TYPEREF.test(c))b=this.tn.next();else throw Error("Illegal value in message "+ -b.name+"#"+a.name+", option "+g+" at line "+this.tn.line+": "+c);a.options[g]=b};g._parseEnum=function(b,a){var c={};a=this.tn.next();if(!e.NAME.test(a))throw Error("Illegal enum name in message "+b.name+" at line "+this.tn.line+": "+a);c.name=a;a=this.tn.next();if(a!==e.OPEN)throw Error("Illegal start of enum "+c.name+" at line "+this.tn.line+": "+a);c.values=[];c.options={};do{a=this.tn.next();if(a===e.CLOSE){a=this.tn.peek();a===e.END&&this.tn.next();break}if("option"==a)this._parseOption(c,a); -else{if(!e.NAME.test(a))throw Error("Illegal name in enum "+c.name+" at line "+this.tn.line+": "+a);this._parseEnumValue(c,a)}}while(1);b.enums.push(c)};g._parseEnumValue=function(b,a){var c={};c.name=a;a=this.tn.next();if(a!==e.EQUAL)throw Error("Illegal token in enum "+b.name+" at line "+this.tn.line+": "+a);a=this.tn.next();try{c.id=this._parseId(a,!0)}catch(f){throw Error("Illegal id in enum "+b.name+" at line "+this.tn.line+": "+a);}b.values.push(c);a=this.tn.next();a===e.OPTOPEN&&(this._parseFieldOptions(b, -{options:{}},a),a=this.tn.next());if(a!==e.END)throw Error("Illegal delimiter in enum "+b.name+" at line "+this.tn.line+": "+a);};g._parseExtensions=function(b,a){var d=[];a=this.tn.next();"min"===a?d.push(c.ID_MIN):"max"===a?d.push(c.ID_MAX):d.push(this._parseNumber(a));a=this.tn.next();if("to"!==a)throw Error("Illegal extensions delimiter in message "+b.name+" at line "+this.tn.line+": "+a);a=this.tn.next();"min"===a?d.push(c.ID_MIN):"max"===a?d.push(c.ID_MAX):d.push(this._parseNumber(a));a=this.tn.next(); -if(a!==e.END)throw Error("Illegal extensions delimiter in message "+b.name+" at line "+this.tn.line+": "+a);return d};g._parseExtend=function(b,a){a=this.tn.next();if(!e.TYPEREF.test(a))throw Error("Illegal message name at line "+this.tn.line+": "+a);var c={};c.ref=a;c.fields=[];a=this.tn.next();if(a!==e.OPEN)throw Error("Illegal start of extend "+c.name+" at line "+this.tn.line+": "+a);do if(a=this.tn.next(),a===e.CLOSE){a=this.tn.peek();a==e.END&&this.tn.next();break}else if(e.RULE.test(a))this._parseMessageField(c, -a);else if(e.TYPEREF.test(a))this._parseMessageField(c,"optional",a);else throw Error("Illegal token in extend "+c.name+" at line "+this.tn.line+": "+a);while(1);b.messages.push(c);return c};g._parseSyntax=function(b){b=this.tn.next();if(b!==e.EQUAL)throw Error("Illegal token at line "+this.tn.line+": "+b);b=this.tn.peek();if(b!==e.STRINGOPEN&&b!==e.STRINGOPEN_SQ)throw Error("Illegal token at line "+this.tn.line+": "+b);var a=this._parseString();b=this.tn.next();if(b!==e.END)throw Error("Illegal token at line "+ -this.tn.line+": "+b);return a};g.toString=function(){return"Parser"};f.Parser=h;return f}(f,f.Lang);f.Reflect=function(c){function e(a,b){if(a&&"number"===typeof a.low&&"number"===typeof a.high&&"boolean"===typeof a.unsigned&&a.low===a.low&&a.high===a.high)return new c.Long(a.low,a.high,"undefined"===typeof b?a.unsigned:b);if("string"===typeof a)return c.Long.fromString(a,b||!1,10);if("number"===typeof a)return c.Long.fromNumber(a,b||!1);throw Error("not convertible to Long");}function f(a,b){var d= -b.readVarint32(),e=d&7,d=d>>>3;switch(e){case c.WIRE_TYPES.VARINT:do d=b.readUint8();while(128===(d&128));break;case c.WIRE_TYPES.BITS64:b.offset+=8;break;case c.WIRE_TYPES.LDELIM:d=b.readVarint32();b.offset+=d;break;case c.WIRE_TYPES.STARTGROUP:f(d,b);break;case c.WIRE_TYPES.ENDGROUP:if(d===a)return!1;throw Error("Illegal GROUPEND after unknown group: "+d+" ("+a+" expected)");case c.WIRE_TYPES.BITS32:b.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+a+": "+e);}return!0} -var p={},h=function(a,b,c){this.builder=a;this.parent=b;this.name=c},g=h.prototype;g.fqn=function(){var a=this.name,b=this;do{b=b.parent;if(null==b)break;a=b.name+"."+a}while(1);return a};g.toString=function(a){return(a?this.className+" ":"")+this.fqn()};g.build=function(){throw Error(this.toString(!0)+" cannot be built directly");};p.T=h;var b=function(a,b,c,d,e){h.call(this,a,b,c);this.className="Namespace";this.children=[];this.options=d||{};this.syntax=e||"proto2"},g=b.prototype=Object.create(h.prototype); -g.getChildren=function(a){a=a||null;if(null==a)return this.children.slice();for(var b=[],c=0,d=this.children.length;cc.MAP_KEY_TYPES.indexOf(a))throw Error("Invalid map key type: "+a.name);},d=a.prototype;d.defaultFieldValue=function(a){"string"===typeof a&& -(a=c.TYPES[a]);if("undefined"===typeof a.defaultValue)throw Error("default value for type "+a.name+" is not supported");return a==c.TYPES.bytes?new k(0):a.defaultValue};d.verifyValue=function(a){var b=function(a,b){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+a+" ("+b+")");}.bind(this);switch(this.type){case c.TYPES.int32:case c.TYPES.sint32:case c.TYPES.sfixed32:return("number"!==typeof a||a===a&&0!==a%1)&&b(typeof a,"not an integer"),4294967295a?a>>>0:a;case c.TYPES.int64:case c.TYPES.sint64:case c.TYPES.sfixed64:if(c.Long)try{return e(a,!1)}catch(d){b(typeof a,d.message)}else b(typeof a,"requires Long.js");case c.TYPES.uint64:case c.TYPES.fixed64:if(c.Long)try{return e(a,!0)}catch(f){b(typeof a,f.message)}else b(typeof a,"requires Long.js");case c.TYPES.bool:return"boolean"!==typeof a&&b(typeof a,"not a boolean"),a;case c.TYPES["float"]:case c.TYPES["double"]:return"number"!==typeof a&& -b(typeof a,"not a number"),a;case c.TYPES.string:return"string"===typeof a||a&&a instanceof String||b(typeof a,"not a string"),""+a;case c.TYPES.bytes:return k.isByteBuffer(a)?a:k.wrap(a,"base64");case c.TYPES["enum"]:for(var g=this.resolvedType.getChildren(c.Reflect.Enum.Value),t=0;ta)&&b(typeof a,"not in range for uint32"), -a;b(a,"not a valid enum value");case c.TYPES.group:case c.TYPES.message:a&&"object"===typeof a||b(typeof a,"object expected");if(a instanceof this.resolvedType.clazz)return a;if(a instanceof c.Builder.Message){var b={},t;for(t in a)a.hasOwnProperty(t)&&(b[t]=a[t]);a=b}return new this.resolvedType.clazz(a)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+a+" (undefined type "+this.type+")");};d.calculateLength=function(a,b){if(null===b)return 0;var d;switch(this.type){case c.TYPES.int32:return 0> -b?k.calculateVarint64(b):k.calculateVarint32(b);case c.TYPES.uint32:return k.calculateVarint32(b);case c.TYPES.sint32:return k.calculateVarint32(k.zigZagEncode32(b));case c.TYPES.fixed32:case c.TYPES.sfixed32:case c.TYPES["float"]:return 4;case c.TYPES.int64:case c.TYPES.uint64:return k.calculateVarint64(b);case c.TYPES.sint64:return k.calculateVarint64(k.zigZagEncode64(b));case c.TYPES.fixed64:case c.TYPES.sfixed64:return 8;case c.TYPES.bool:return 1;case c.TYPES["enum"]:return k.calculateVarint32(b); -case c.TYPES["double"]:return 8;case c.TYPES.string:return d=k.calculateUTF8Bytes(b),k.calculateVarint32(d)+d;case c.TYPES.bytes:if(0>b.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+b.remaining()+" bytes remaining");return k.calculateVarint32(b.remaining())+b.remaining();case c.TYPES.message:return d=this.resolvedType.calculate(b),k.calculateVarint32(d)+d;case c.TYPES.group:return d=this.resolvedType.calculate(b),d+k.calculateVarint32(a<<3|c.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+ -this.toString(!0)+": "+b+" (unknown type)");};d.encodeValue=function(a,b,d){if(null===b)return d;switch(this.type){case c.TYPES.int32:0>b?d.writeVarint64(b):d.writeVarint32(b);break;case c.TYPES.uint32:d.writeVarint32(b);break;case c.TYPES.sint32:d.writeVarint32ZigZag(b);break;case c.TYPES.fixed32:d.writeUint32(b);break;case c.TYPES.sfixed32:d.writeInt32(b);break;case c.TYPES.int64:case c.TYPES.uint64:d.writeVarint64(b);break;case c.TYPES.sint64:d.writeVarint64ZigZag(b);break;case c.TYPES.fixed64:d.writeUint64(b); -break;case c.TYPES.sfixed64:d.writeInt64(b);break;case c.TYPES.bool:"string"===typeof b?d.writeVarint32("false"===b.toLowerCase()?0:!!b):d.writeVarint32(b?1:0);break;case c.TYPES["enum"]:d.writeVarint32(b);break;case c.TYPES["float"]:d.writeFloat32(b);break;case c.TYPES["double"]:d.writeFloat64(b);break;case c.TYPES.string:d.writeVString(b);break;case c.TYPES.bytes:if(0>b.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+b.remaining()+" bytes remaining");a=b.offset;d.writeVarint32(b.remaining()); -d.append(b);b.offset=a;break;case c.TYPES.message:a=(new k).LE();this.resolvedType.encode(b,a);d.writeVarint32(a.offset);d.append(a.flip());break;case c.TYPES.group:this.resolvedType.encode(b,d);d.writeVarint32(a<<3|c.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+b+" (unknown type)");}return d};d.decode=function(a,b,d){if(b!=this.type.wireType)throw Error("Unexpected wire type for element");switch(this.type){case c.TYPES.int32:return a.readVarint32()| -0;case c.TYPES.uint32:return a.readVarint32()>>>0;case c.TYPES.sint32:return a.readVarint32ZigZag()|0;case c.TYPES.fixed32:return a.readUint32()>>>0;case c.TYPES.sfixed32:return a.readInt32()|0;case c.TYPES.int64:return a.readVarint64();case c.TYPES.uint64:return a.readVarint64().toUnsigned();case c.TYPES.sint64:return a.readVarint64ZigZag();case c.TYPES.fixed64:return a.readUint64();case c.TYPES.sfixed64:return a.readInt64();case c.TYPES.bool:return!!a.readVarint32();case c.TYPES["enum"]:return a.readVarint32(); -case c.TYPES["float"]:return a.readFloat();case c.TYPES["double"]:return a.readDouble();case c.TYPES.string:return a.readVString();case c.TYPES.bytes:d=a.readVarint32();if(a.remaining()a.remaining())return null;var d=a.offset,e=a.readVarint32();if(a.remaining()",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)$/,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,BOOL:/^(?:true|false)$/i};f.DotProto=function(c,e){var f= +{},k=function(b){this.source=""+b;this.index=0;this.line=1;this.stack=[];this.readingString=!1;this.stringEndsWith=e.STRINGCLOSE},h=k.prototype;h._readString=function(){e.STRING.lastIndex=this.index-1;var b;if(null!==(b=e.STRING.exec(this.source)))return b="undefined"!==typeof b[1]?b[1]:b[2],this.index=e.STRING.lastIndex,this.stack.push(this.stringEndsWith),b;throw Error("Unterminated string at line "+this.line+", index "+this.index);};h.next=function(){if(0=this.source.length)return null;if(this.readingString)return this.readingString=!1,this._readString();var b,a;do{for(b=!1;e.WHITESPACE.test(a=this.source.charAt(this.index));)if(this.index++,"\n"===a&&this.line++,this.index===this.source.length)return null;if("/"===this.source.charAt(this.index))if("/"===this.source.charAt(++this.index)){for(;"\n"!==this.source.charAt(this.index);)if(this.index++,this.index==this.source.length)return null;this.index++;this.line++;b=!0}else if("*"=== +this.source.charAt(this.index)){for(a="";"*/"!==a+(a=this.source.charAt(this.index));)if(this.index++,"\n"===a&&this.line++,this.index===this.source.length)return null;this.index++;b=!0}else throw Error("Unterminated comment at line "+this.line+": /"+this.source.charAt(this.index));}while(b);if(this.index===this.source.length)return null;b=this.index;e.DELIM.lastIndex=0;if(e.DELIM.test(this.source.charAt(b)))++b;else for(++b;ba?"-":"")+b);};g._parseString=function(){var b="",a,d;do{d=this.tn.next();b+=this.tn.next();a=this.tn.next();if(a!==d)throw Error("Illegal end of string at line "+this.tn.line+": "+a);a=this.tn.peek()}while(a===e.STRINGOPEN||a===e.STRINGOPEN_SQ);return b};g._parseId=function(b,a){var d=-1,c=1;"-"==b.charAt(0)&&(c=-1,b=b.substring(1));if(e.NUMBER_DEC.test(b))d=parseInt(b);else if(e.NUMBER_HEX.test(b))d= +parseInt(b.substring(2),16);else if(e.NUMBER_OCT.test(b))d=parseInt(b.substring(1),8);else throw Error("Illegal id at line "+this.tn.line+": "+(0>c?"-":"")+b);d=c*d|0;if(!a&&0>d)throw Error("Illegal id at line "+this.tn.line+": "+(0>c?"-":"")+b);return d};g._parsePackage=function(b){b=this.tn.next();if(!e.TYPEREF.test(b))throw Error("Illegal package name at line "+this.tn.line+": "+b);var a=b;b=this.tn.next();if(b!=e.END)throw Error("Illegal end of package at line "+this.tn.line+": "+b);return a}; +g._parseImport=function(b){b=this.tn.peek();"public"===b&&(this.tn.next(),b=this.tn.peek());if(b!==e.STRINGOPEN&&b!==e.STRINGOPEN_SQ)throw Error("Illegal start of import at line "+this.tn.line+": "+b);var a=this._parseString();b=this.tn.next();if(b!==e.END)throw Error("Illegal end of import at line "+this.tn.line+": "+b);return a};g._parseOption=function(b,a){a=this.tn.next();var d=!1;a==e.COPTOPEN&&(d=!0,a=this.tn.next());if(!e.TYPEREF.test(a)&&!/google\.protobuf\./.test(a))throw Error("Illegal option name in message "+ +b.name+" at line "+this.tn.line+": "+a);var c=a;a=this.tn.next();if(d){if(a!==e.COPTCLOSE)throw Error("Illegal end in message "+b.name+", option "+c+" at line "+this.tn.line+": "+a);c="("+c+")";a=this.tn.next();e.FQTYPEREF.test(a)&&(c+=a,a=this.tn.next())}if(a!==e.EQUAL)throw Error("Illegal operator in message "+b.name+", option "+c+" at line "+this.tn.line+": "+a);a=this.tn.peek();if(a===e.STRINGOPEN||a===e.STRINGOPEN_SQ)d=this._parseString();else if(this.tn.next(),e.NUMBER.test(a))d=this._parseNumber(a, +!0);else if(e.BOOL.test(a))d="true"===a;else if(e.TYPEREF.test(a))d=a;else throw Error("Illegal option value in message "+b.name+", option "+c+" at line "+this.tn.line+": "+a);a=this.tn.next();if(a!==e.END)throw Error("Illegal end of option in message "+b.name+", option "+c+" at line "+this.tn.line+": "+a);b.options[c]=d};g._parseIgnoredStatement=function(b,a){var d;do{d=this.tn.next();if(null===d)throw Error("Unexpected EOF in "+b.name+", "+a+" at line "+this.tn.line);if(d===e.END)break}while(1)}; +g._parseService=function(b,a){a=this.tn.next();if(!e.NAME.test(a))throw Error("Illegal service name at line "+this.tn.line+": "+a);var d=a,c={name:d,rpc:{},options:{}};a=this.tn.next();if(a!==e.OPEN)throw Error("Illegal start of service "+d+" at line "+this.tn.line+": "+a);do if(a=this.tn.next(),"option"===a)this._parseOption(c,a);else if("rpc"===a)this._parseServiceRPC(c,a);else if(a!==e.CLOSE)throw Error("Illegal type of service "+d+" at line "+this.tn.line+": "+a);while(a!==e.CLOSE);b.services.push(c)}; +g._parseServiceRPC=function(b,a){var d=a;a=this.tn.next();if(!e.NAME.test(a))throw Error("Illegal method name in service "+b.name+" at line "+this.tn.line+": "+a);var c=a,f={request:null,response:null,request_stream:!1,response_stream:!1,options:{}};a=this.tn.next();if(a!==e.COPTOPEN)throw Error("Illegal start of request type in service "+b.name+"#"+c+" at line "+this.tn.line+": "+a);a=this.tn.next();"stream"===a.toLowerCase()&&(f.request_stream=!0,a=this.tn.next());if(!e.TYPEREF.test(a))throw Error("Illegal request type in service "+ +b.name+"#"+c+" at line "+this.tn.line+": "+a);f.request=a;a=this.tn.next();if(a!=e.COPTCLOSE)throw Error("Illegal end of request type in service "+b.name+"#"+c+" at line "+this.tn.line+": "+a);a=this.tn.next();if("returns"!==a.toLowerCase())throw Error("Illegal delimiter in service "+b.name+"#"+c+" at line "+this.tn.line+": "+a);a=this.tn.next();if(a!=e.COPTOPEN)throw Error("Illegal start of response type in service "+b.name+"#"+c+" at line "+this.tn.line+": "+a);a=this.tn.next();"stream"===a.toLowerCase()&& +(f.response_stream=!0,a=this.tn.next());f.response=a;a=this.tn.next();if(a!==e.COPTCLOSE)throw Error("Illegal end of response type in service "+b.name+"#"+c+" at line "+this.tn.line+": "+a);a=this.tn.next();if(a===e.OPEN){do if(a=this.tn.next(),"option"===a)this._parseOption(f,a);else if(a!==e.CLOSE)throw Error("Illegal start of option inservice "+b.name+"#"+c+" at line "+this.tn.line+": "+a);while(a!==e.CLOSE);this.tn.peek()===e.END&&this.tn.next()}else if(a!==e.END)throw Error("Illegal delimiter in service "+ +b.name+"#"+c+" at line "+this.tn.line+": "+a);"undefined"===typeof b[d]&&(b[d]={});b[d][c]=f};g._parseMessage=function(b,a,d){var c={},f="group"===d;d=this.tn.next();if(!e.NAME.test(d))throw Error("Illegal "+(f?"group":"message")+" name"+(b?" in message "+b.name:"")+" at line "+this.tn.line+": "+d);c.name=d;if(f){d=this.tn.next();if(d!==e.EQUAL)throw Error("Illegal id assignment after group "+c.name+" at line "+this.tn.line+": "+d);d=this.tn.next();try{a.id=this._parseId(d)}catch(g){throw Error("Illegal field id value for group "+ +c.name+"#"+a.name+" at line "+this.tn.line+": "+d);}c.isGroup=!0}c.fields=[];c.enums=[];c.messages=[];c.options={};c.oneofs={};d=this.tn.next();d===e.OPTOPEN&&a&&(this._parseFieldOptions(c,a,d),d=this.tn.next());if(d!==e.OPEN)throw Error("Illegal start of "+(f?"group":"message")+" "+c.name+" at line "+this.tn.line+": "+d);do if(d=this.tn.next(),d===e.CLOSE){d=this.tn.peek();d===e.END&&this.tn.next();break}else if(e.RULE.test(d))this._parseMessageField(c,d);else if("oneof"===d)this._parseMessageOneOf(c, +d);else if("enum"===d)this._parseEnum(c,d);else if("message"===d)this._parseMessage(c,null,d);else if("option"===d)this._parseOption(c,d);else if("extensions"===d)c.extensions=this._parseExtensions(c,d);else if("extend"===d)this._parseExtend(c,d);else if(e.TYPEREF.test(d))this._parseMessageField(c,"optional",d);else throw Error("Illegal token in message "+c.name+" at line "+this.tn.line+": "+d);while(1);b.messages.push(c);return c};g._parseMessageField=function(b,a,d){var c={},f=null;c.rule=a;c.options= +{};a="undefined"!==typeof d?d:this.tn.next();if("map"===c.rule){if(a!==e.LT)throw Error("Illegal token in message "+b.name+" at line "+this.tn.line+": "+a);a=this.tn.next();if(!e.TYPE.test(a)&&!e.TYPEREF.test(a))throw Error("Illegal token in message "+b.name+" at line "+this.tn.line+": "+a);c.keytype=a;a=this.tn.next();if(a!==e.COMMA)throw Error("Illegal token in message "+b.name+" at line "+this.tn.line+": "+a);a=this.tn.next();if(!e.TYPE.test(a)&&!e.TYPEREF.test(a))throw Error("Illegal token in message "+ +b.name+" at line "+this.tn.line+": "+a);c.type=a;a=this.tn.next();if(a!==e.GT)throw Error("Illegal token in message "+b.name+" at line "+this.tn.line+": "+a);a=this.tn.next();if(!e.NAME.test(a))throw Error("Illegal token in message "+b.name+" at line "+this.tn.line+": "+a);c.name=a;a=this.tn.next();if(a!==e.EQUAL)throw Error("Illegal token in field "+b.name+"#"+c.name+" at line "+this.line+": "+a);a=this.tn.next();try{c.id=this._parseId(a)}catch(g){throw Error("Illegal field id in message "+b.name+ +"#"+c.name+" at line "+this.tn.line+": "+a);}a=this.tn.next();a===e.OPTOPEN&&(this._parseFieldOptions(b,c,a),a=this.tn.next());if(a!==e.END)throw Error("Illegal delimiter in message "+b.name+"#"+c.name+" at line "+this.tn.line+": "+a);}else if("group"===a){f=this._parseMessage(b,c,a);if(!/^[A-Z]/.test(f.name))throw Error("Group names must start with a capital letter");c.type=f.name;c.name=f.name.toLowerCase();a=this.tn.peek();a===e.END&&this.tn.next()}else{if(!e.TYPE.test(a)&&!e.TYPEREF.test(a))throw Error("Illegal field type in message "+ +b.name+" at line "+this.tn.line+": "+a);c.type=a;a=this.tn.next();if(!e.NAME.test(a))throw Error("Illegal field name in message "+b.name+" at line "+this.tn.line+": "+a);c.name=a;a=this.tn.next();if(a!==e.EQUAL)throw Error("Illegal token in field "+b.name+"#"+c.name+" at line "+this.tn.line+": "+a);a=this.tn.next();try{c.id=this._parseId(a)}catch(h){throw Error("Illegal field id in message "+b.name+"#"+c.name+" at line "+this.tn.line+": "+a);}a=this.tn.next();a===e.OPTOPEN&&(this._parseFieldOptions(b, +c,a),a=this.tn.next());if(a!==e.END)throw Error("Illegal delimiter in message "+b.name+"#"+c.name+" at line "+this.tn.line+": "+a);}b.fields.push(c);return c};g._parseMessageOneOf=function(b,a){a=this.tn.next();if(!e.NAME.test(a))throw Error("Illegal oneof name in message "+b.name+" at line "+this.tn.line+": "+a);var c=a,f,g=[];a=this.tn.next();if(a!==e.OPEN)throw Error("Illegal start of oneof "+c+" at line "+this.tn.line+": "+a);for(;this.tn.peek()!==e.CLOSE;)f=this._parseMessageField(b,"optional"), +f.oneof=c,g.push(f.id);this.tn.next();b.oneofs[c]=g};g._parseFieldOptions=function(b,a,c){var f=!0;do{c=this.tn.next();if(c===e.OPTCLOSE)break;else if(c===e.OPTEND){if(f)throw Error("Illegal start of options in message "+b.name+"#"+a.name+" at line "+this.tn.line+": "+c);c=this.tn.next()}this._parseFieldOption(b,a,c);f=!1}while(1)};g._parseFieldOption=function(b,a,c){var f=!1;c===e.COPTOPEN&&(c=this.tn.next(),f=!0);if(!e.TYPEREF.test(c))throw Error("Illegal field option in "+b.name+"#"+a.name+" at line "+ +this.tn.line+": "+c);var g=c;c=this.tn.next();if(f){if(c!==e.COPTCLOSE)throw Error("Illegal delimiter in "+b.name+"#"+a.name+" at line "+this.tn.line+": "+c);g="("+g+")";c=this.tn.next();e.FQTYPEREF.test(c)&&(g+=c,c=this.tn.next())}if(c!==e.EQUAL)throw Error("Illegal token in "+b.name+"#"+a.name+" at line "+this.tn.line+": "+c);c=this.tn.peek();if(c===e.STRINGOPEN||c===e.STRINGOPEN_SQ)b=this._parseString();else if(e.NUMBER.test(c,!0))b=this._parseNumber(this.tn.next(),!0);else if(e.BOOL.test(c))b= +"true"===this.tn.next().toLowerCase();else if(e.TYPEREF.test(c))b=this.tn.next();else throw Error("Illegal value in message "+b.name+"#"+a.name+", option "+g+" at line "+this.tn.line+": "+c);a.options[g]=b};g._parseEnum=function(b,a){var c={};a=this.tn.next();if(!e.NAME.test(a))throw Error("Illegal enum name in message "+b.name+" at line "+this.tn.line+": "+a);c.name=a;a=this.tn.next();if(a!==e.OPEN)throw Error("Illegal start of enum "+c.name+" at line "+this.tn.line+": "+a);c.values=[];c.options= +{};do{a=this.tn.next();if(a===e.CLOSE){a=this.tn.peek();a===e.END&&this.tn.next();break}if("option"==a)this._parseOption(c,a);else{if(!e.NAME.test(a))throw Error("Illegal name in enum "+c.name+" at line "+this.tn.line+": "+a);this._parseEnumValue(c,a)}}while(1);b.enums.push(c)};g._parseEnumValue=function(b,a){var c={};c.name=a;a=this.tn.next();if(a!==e.EQUAL)throw Error("Illegal token in enum "+b.name+" at line "+this.tn.line+": "+a);a=this.tn.next();try{c.id=this._parseId(a,!0)}catch(f){throw Error("Illegal id in enum "+ +b.name+" at line "+this.tn.line+": "+a);}b.values.push(c);a=this.tn.next();a===e.OPTOPEN&&(this._parseFieldOptions(b,{options:{}},a),a=this.tn.next());if(a!==e.END)throw Error("Illegal delimiter in enum "+b.name+" at line "+this.tn.line+": "+a);};g._parseExtensions=function(b,a){var d=[];a=this.tn.next();"min"===a?d.push(c.ID_MIN):"max"===a?d.push(c.ID_MAX):d.push(this._parseNumber(a));a=this.tn.next();if("to"!==a)throw Error("Illegal extensions delimiter in message "+b.name+" at line "+this.tn.line+ +": "+a);a=this.tn.next();"min"===a?d.push(c.ID_MIN):"max"===a?d.push(c.ID_MAX):d.push(this._parseNumber(a));a=this.tn.next();if(a!==e.END)throw Error("Illegal extensions delimiter in message "+b.name+" at line "+this.tn.line+": "+a);return d};g._parseExtend=function(b,a){a=this.tn.next();if(!e.TYPEREF.test(a))throw Error("Illegal message name at line "+this.tn.line+": "+a);var c={};c.ref=a;c.fields=[];a=this.tn.next();if(a!==e.OPEN)throw Error("Illegal start of extend "+c.name+" at line "+this.tn.line+ +": "+a);do if(a=this.tn.next(),a===e.CLOSE){a=this.tn.peek();a==e.END&&this.tn.next();break}else if(e.RULE.test(a))this._parseMessageField(c,a);else if(e.TYPEREF.test(a))this._parseMessageField(c,"optional",a);else throw Error("Illegal token in extend "+c.name+" at line "+this.tn.line+": "+a);while(1);b.messages.push(c);return c};g._parseSyntax=function(b){b=this.tn.next();if(b!==e.EQUAL)throw Error("Illegal token at line "+this.tn.line+": "+b);b=this.tn.peek();if(b!==e.STRINGOPEN&&b!==e.STRINGOPEN_SQ)throw Error("Illegal token at line "+ +this.tn.line+": "+b);var a=this._parseString();b=this.tn.next();if(b!==e.END)throw Error("Illegal token at line "+this.tn.line+": "+b);return a};g.toString=function(){return"Parser"};f.Parser=h;return f}(f,f.Lang);f.Reflect=function(c){function e(a,b){if(a&&"number"===typeof a.low&&"number"===typeof a.high&&"boolean"===typeof a.unsigned&&a.low===a.low&&a.high===a.high)return new c.Long(a.low,a.high,"undefined"===typeof b?a.unsigned:b);if("string"===typeof a)return c.Long.fromString(a,b||!1,10);if("number"=== +typeof a)return c.Long.fromNumber(a,b||!1);throw Error("not convertible to Long");}function f(a,b){var d=b.readVarint32(),e=d&7,d=d>>>3;switch(e){case c.WIRE_TYPES.VARINT:do d=b.readUint8();while(128===(d&128));break;case c.WIRE_TYPES.BITS64:b.offset+=8;break;case c.WIRE_TYPES.LDELIM:d=b.readVarint32();b.offset+=d;break;case c.WIRE_TYPES.STARTGROUP:f(d,b);break;case c.WIRE_TYPES.ENDGROUP:if(d===a)return!1;throw Error("Illegal GROUPEND after unknown group: "+d+" ("+a+" expected)");case c.WIRE_TYPES.BITS32:b.offset+= +4;break;default:throw Error("Illegal wire type in unknown group "+a+": "+e);}return!0}var p={},h=function(a,b,c){this.builder=a;this.parent=b;this.name=c},g=h.prototype;g.fqn=function(){var a=this.name,b=this;do{b=b.parent;if(null==b)break;a=b.name+"."+a}while(1);return a};g.toString=function(a){return(a?this.className+" ":"")+this.fqn()};g.build=function(){throw Error(this.toString(!0)+" cannot be built directly");};p.T=h;var b=function(a,b,c,d,e){h.call(this,a,b,c);this.className="Namespace";this.children= +[];this.options=d||{};this.syntax=e||"proto2"},g=b.prototype=Object.create(h.prototype);g.getChildren=function(a){a=a||null;if(null==a)return this.children.slice();for(var b=[],c=0,d=this.children.length;cc.MAP_KEY_TYPES.indexOf(a))throw Error("Invalid map key type: "+ +a.name);},d=a.prototype;d.defaultFieldValue=function(a){"string"===typeof a&&(a=c.TYPES[a]);if("undefined"===typeof a.defaultValue)throw Error("default value for type "+a.name+" is not supported");return a==c.TYPES.bytes?new k(0):a.defaultValue};d.verifyValue=function(a){var b=function(a,b){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+a+" ("+b+")");}.bind(this);switch(this.type){case c.TYPES.int32:case c.TYPES.sint32:case c.TYPES.sfixed32:return("number"!==typeof a|| +a===a&&0!==a%1)&&b(typeof a,"not an integer"),4294967295a?a>>>0:a;case c.TYPES.int64:case c.TYPES.sint64:case c.TYPES.sfixed64:if(c.Long)try{return e(a,!1)}catch(d){b(typeof a,d.message)}else b(typeof a,"requires Long.js");case c.TYPES.uint64:case c.TYPES.fixed64:if(c.Long)try{return e(a,!0)}catch(f){b(typeof a,f.message)}else b(typeof a,"requires Long.js");case c.TYPES.bool:return"boolean"!== +typeof a&&b(typeof a,"not a boolean"),a;case c.TYPES["float"]:case c.TYPES["double"]:return"number"!==typeof a&&b(typeof a,"not a number"),a;case c.TYPES.string:return"string"===typeof a||a&&a instanceof String||b(typeof a,"not a string"),""+a;case c.TYPES.bytes:return k.isByteBuffer(a)?a:k.wrap(a,"base64");case c.TYPES["enum"]:for(var g=this.resolvedType.getChildren(c.Reflect.Enum.Value),t=0;ta)&&b(typeof a,"not in range for uint32"),a;b(a,"not a valid enum value");case c.TYPES.group:case c.TYPES.message:a&&"object"===typeof a||b(typeof a,"object expected");if(a instanceof this.resolvedType.clazz)return a;if(a instanceof c.Builder.Message){var b={},t;for(t in a)a.hasOwnProperty(t)&&(b[t]=a[t]);a=b}return new this.resolvedType.clazz(a)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+a+" (undefined type "+ +this.type+")");};d.calculateLength=function(a,b){if(null===b)return 0;var d;switch(this.type){case c.TYPES.int32:return 0>b?k.calculateVarint64(b):k.calculateVarint32(b);case c.TYPES.uint32:return k.calculateVarint32(b);case c.TYPES.sint32:return k.calculateVarint32(k.zigZagEncode32(b));case c.TYPES.fixed32:case c.TYPES.sfixed32:case c.TYPES["float"]:return 4;case c.TYPES.int64:case c.TYPES.uint64:return k.calculateVarint64(b);case c.TYPES.sint64:return k.calculateVarint64(k.zigZagEncode64(b));case c.TYPES.fixed64:case c.TYPES.sfixed64:return 8; +case c.TYPES.bool:return 1;case c.TYPES["enum"]:return k.calculateVarint32(b);case c.TYPES["double"]:return 8;case c.TYPES.string:return d=k.calculateUTF8Bytes(b),k.calculateVarint32(d)+d;case c.TYPES.bytes:if(0>b.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+b.remaining()+" bytes remaining");return k.calculateVarint32(b.remaining())+b.remaining();case c.TYPES.message:return d=this.resolvedType.calculate(b),k.calculateVarint32(d)+d;case c.TYPES.group:return d=this.resolvedType.calculate(b), +d+k.calculateVarint32(a<<3|c.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+b+" (unknown type)");};d.encodeValue=function(a,b,d){if(null===b)return d;switch(this.type){case c.TYPES.int32:0>b?d.writeVarint64(b):d.writeVarint32(b);break;case c.TYPES.uint32:d.writeVarint32(b);break;case c.TYPES.sint32:d.writeVarint32ZigZag(b);break;case c.TYPES.fixed32:d.writeUint32(b);break;case c.TYPES.sfixed32:d.writeInt32(b);break;case c.TYPES.int64:case c.TYPES.uint64:d.writeVarint64(b); +break;case c.TYPES.sint64:d.writeVarint64ZigZag(b);break;case c.TYPES.fixed64:d.writeUint64(b);break;case c.TYPES.sfixed64:d.writeInt64(b);break;case c.TYPES.bool:"string"===typeof b?d.writeVarint32("false"===b.toLowerCase()?0:!!b):d.writeVarint32(b?1:0);break;case c.TYPES["enum"]:d.writeVarint32(b);break;case c.TYPES["float"]:d.writeFloat32(b);break;case c.TYPES["double"]:d.writeFloat64(b);break;case c.TYPES.string:d.writeVString(b);break;case c.TYPES.bytes:if(0>b.remaining())throw Error("Illegal value for "+ +this.toString(!0)+": "+b.remaining()+" bytes remaining");a=b.offset;d.writeVarint32(b.remaining());d.append(b);b.offset=a;break;case c.TYPES.message:a=(new k).LE();this.resolvedType.encode(b,a);d.writeVarint32(a.offset);d.append(a.flip());break;case c.TYPES.group:this.resolvedType.encode(b,d);d.writeVarint32(a<<3|c.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+b+" (unknown type)");}return d};d.decode=function(a,b,d){if(b!=this.type.wireType)throw Error("Unexpected wire type for element"); +switch(this.type){case c.TYPES.int32:return a.readVarint32()|0;case c.TYPES.uint32:return a.readVarint32()>>>0;case c.TYPES.sint32:return a.readVarint32ZigZag()|0;case c.TYPES.fixed32:return a.readUint32()>>>0;case c.TYPES.sfixed32:return a.readInt32()|0;case c.TYPES.int64:return a.readVarint64();case c.TYPES.uint64:return a.readVarint64().toUnsigned();case c.TYPES.sint64:return a.readVarint64ZigZag();case c.TYPES.fixed64:return a.readUint64();case c.TYPES.sfixed64:return a.readInt64();case c.TYPES.bool:return!!a.readVarint32(); +case c.TYPES["enum"]:return a.readVarint32();case c.TYPES["float"]:return a.readFloat();case c.TYPES["double"]:return a.readDouble();case c.TYPES.string:return a.readVString();case c.TYPES.bytes:d=a.readVarint32();if(a.remaining()a.remaining())return null;var d=a.offset,e=a.readVarint32();if(a.remaining()>>3;if(r===c.WIRE_TYPES.ENDGROUP){if(l!==d)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+l+" ("+(d?d+" expected":"not a group")+")");break}if(h=this._fieldsById[l])h.repeated&&!h.options.packed?g[h.name].push(h.decode(r,a)):h.map?(r=h.decode(r,a),g[h.name].set(r[0],r[1])):(g[h.name]= h.decode(r,a),h.oneof&&(null!==this[h.oneof.name]&&(this[this[h.oneof.name]]=null),g[h.oneof.name]=h.name));else switch(r){case c.WIRE_TYPES.VARINT:a.readVarint32();break;case c.WIRE_TYPES.BITS32:a.offset+=4;break;case c.WIRE_TYPES.BITS64:a.offset+=8;break;case c.WIRE_TYPES.LDELIM:h=a.readVarint32();a.offset+=h;break;case c.WIRE_TYPES.STARTGROUP:for(;f(l,a););break;default:throw Error("Illegal wire type for unknown field "+l+" in "+this.toString(!0)+"#decode: "+r);}}a=0;for(b=this._fields.length;a< -b;++a)if(h=this._fields[a],null===g[h.name]){if(h.required)throw a=Error("Missing at least one required field for "+this.toString(!0)+": "+h.name),a.decoded=g,a;c.populateDefaults&&null!==h.defaultValue&&(g[h.name]=h.defaultValue)}return g};p.Message=r;var w=function(a,b,d,e,f,g,l,k,u,v){h.call(this,a,b,g);this.className="Message.Field";this.required="required"===d;this.repeated="repeated"===d;this.map="map"===d;this.keyType=e||null;this.type=f;this.resolvedType=null;this.id=l;this.options=k||{}; -this.defaultValue=null;this.oneof=u||null;this.syntax=v||"proto2";this.originalName=this.name;this.keyElement=this.element=null;!this.builder.options.convertFieldsToCamelCase||this instanceof r.ExtensionField||(this.name=c.Util.toCamelCase(this.name))},d=w.prototype=Object.create(h.prototype);d.build=function(){this.element=new a(this.type,this.resolvedType,!1,this.syntax);this.map&&(this.keyElement=new a(this.keyType,void 0,!0,this.syntax));this.defaultValue="undefined"!==typeof this.options["default"]? +b;++a)if(h=this._fields[a],null===g[h.name]){if(h.required)throw a=Error("Missing at least one required field for "+this.toString(!0)+": "+h.name),a.decoded=g,a;c.populateDefaults&&null!==h.defaultValue&&(g[h.name]=h.defaultValue)}return g};p.Message=r;var x=function(a,b,d,e,f,g,l,k,u,w){h.call(this,a,b,g);this.className="Message.Field";this.required="required"===d;this.repeated="repeated"===d;this.map="map"===d;this.keyType=e||null;this.type=f;this.resolvedType=null;this.id=l;this.options=k||{}; +this.defaultValue=null;this.oneof=u||null;this.syntax=w||"proto2";this.originalName=this.name;this.keyElement=this.element=null;!this.builder.options.convertFieldsToCamelCase||this instanceof r.ExtensionField||(this.name=c.Util.toCamelCase(this.name))},d=x.prototype=Object.create(h.prototype);d.build=function(){this.element=new a(this.type,this.resolvedType,!1,this.syntax);this.map&&(this.keyElement=new a(this.keyType,void 0,!0,this.syntax));this.defaultValue="undefined"!==typeof this.options["default"]? this.verifyValue(this.options["default"]):null;"proto3"!==this.syntax||this.repeated||this.map||(this.defaultValue=this.element.defaultFieldValue(this.type))};d.verifyValue=function(a,b){b=b||!1;var d=function(a,b){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+a+" ("+b+")");}.bind(this);if(null===a)return this.required&&d(typeof a,"required"),"proto3"===this.syntax&&this.type!==c.TYPES.message&&d(typeof a,"proto3 field without field presence cannot be null"),null; if(this.repeated&&!b){Array.isArray(a)||(a=[a]);for(var e=[],d=0;d>>=3,1===b)e=this.keyElement.decode(f,a,b);else if(2===b)d=this.element.decode(f,a,b);else throw Error("Unexpected tag in map field key/value submessage");return[e,d]}return this.element.decode(b,a,this.id)};p.Message.Field=w;d=function(a,b,c,d,e,f,g){w.call(this,a,b,c,null,d,e,f,g)};d.prototype=Object.create(w.prototype);p.Message.ExtensionField=d;p.Message.OneOf=function(a,b,c){h.call(this, +b.remaining());var f=b.clone();f.limit=f.offset+a;for(b.offset+=a;0>>=3,1===b)e=this.keyElement.decode(f,a,b);else if(2===b)d=this.element.decode(f,a,b);else throw Error("Unexpected tag in map field key/value submessage");return[e,d]}return this.element.decode(b,a,this.id)};p.Message.Field=x;d=function(a,b,c,d,e,f,g){x.call(this,a,b,c,null,d,e,f,g)};d.prototype=Object.create(x.prototype);p.Message.ExtensionField=d;p.Message.OneOf=function(a,b,c){h.call(this, a,b,c);this.fields=[]};var u=function(a,c,d,e,f){b.call(this,a,c,d,e,f);this.className="Enum";this.object=null};(u.prototype=Object.create(b.prototype)).build=function(){for(var a={},b=this.getChildren(u.Value),c=0,d=b.length;ce.extensions[1])throw Error("Illegal extended field id in message "+e.name+": "+d.fields[l].id+" ("+e.extensions.join(" to ")+" expected)");g=d.fields[l].name;this.options.convertFieldsToCamelCase&&(g=c.Util.toCamelCase(d.fields[l].name));k=new f.Message.ExtensionField(this,e,d.fields[l].rule,d.fields[l].type, this.ptr.fqn()+"."+g,d.fields[l].id,d.fields[l].options);g=new f.Extension(this,this.ptr,d.fields[l].name,k);k.extension=g;this.ptr.addChild(g);e.addChild(k)}else{if(!/\.?google\.protobuf\./.test(d.ref))throw Error("Extended message "+d.ref+" is not defined");}else throw Error("Not a valid definition: "+JSON.stringify(d));}else throw Error("Not a valid namespace: "+JSON.stringify(b));this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this};g["import"]=function(b,a){if("string"===typeof a){c.Util.IS_NODE&& -(a=require("path").resolve(a));if(!0===this.files[a])return this.reset(),this;this.files[a]=!0}else if("object"===typeof a){var d=a.root;c.Util.IS_NODE&&(d=require("path").resolve(d));d=[d,a.file].join("/");if(!0===this.files[d])return this.reset(),this;this.files[d]=!0}if(b.imports&&0Parameters:
Source:
@@ -299,7 +299,7 @@
Type:
Source:
@@ -365,7 +365,7 @@
Type:
Source:
@@ -431,7 +431,7 @@
Type:
Source:
@@ -497,7 +497,7 @@
Type:
Source:
@@ -664,7 +664,7 @@
Parameters:
Source:
@@ -841,7 +841,7 @@
Parameters:
Source:
@@ -1061,7 +1061,7 @@
Parameters:
Source:
@@ -1229,7 +1229,7 @@
Parameters:
Source:
@@ -1397,7 +1397,7 @@
Parameters:
Source:
@@ -1639,7 +1639,7 @@
Parameters:
Source:
@@ -1855,7 +1855,7 @@
Parameters:
Source:
@@ -2034,7 +2034,7 @@
Parameters:
Source:
@@ -2284,7 +2284,7 @@
Parameters:
Source:
@@ -2504,7 +2504,7 @@
Parameters:
Source:
@@ -2624,7 +2624,7 @@

calculateSource:
@@ -2744,7 +2744,7 @@

encode64Source:
@@ -2864,7 +2864,7 @@

encodeABSource:
@@ -3047,7 +3047,7 @@
Parameters:
Source:
@@ -3167,7 +3167,7 @@

encodeHexSource:
@@ -3287,7 +3287,7 @@

encodeJSON<
Source:
@@ -3380,7 +3380,7 @@

encodeNBSource:
@@ -3587,7 +3587,7 @@
Parameters:
Source:
@@ -3708,7 +3708,7 @@

(abstract) Source:
@@ -3802,7 +3802,7 @@

(abstract) <
Source:
@@ -4025,7 +4025,7 @@
Parameters:
Source:
@@ -4237,7 +4237,7 @@
Parameters:
Source:
@@ -4449,7 +4449,7 @@
Parameters:
Source:
@@ -4569,7 +4569,7 @@

toArrayB
Source:
@@ -4689,7 +4689,7 @@

toBase64Source:
@@ -4809,7 +4809,7 @@

toBufferSource:
@@ -4925,7 +4925,7 @@

toHexSource:
@@ -5136,7 +5136,7 @@
Parameters:
Source:
@@ -5229,7 +5229,7 @@

toStringSource:
@@ -5300,7 +5300,7 @@

Index

Classes