Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

protobufjs

Package Overview
Dependencies
Maintainers
1
Versions
168
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

protobufjs - npm Package Compare versions

Comparing version 1.0.0-b5 to 1.0.0-b6

8

externs/ProtoBuf.js

@@ -175,3 +175,3 @@ /*

/**
* @return {string}
* @return {?string}
* @throws {Error}

@@ -182,2 +182,8 @@ */

/**
* @return {?string}
* @thorws {Error}
*/
ProtoBuf.DotProto.Tokenizer.prototype.peek = function() {};
/**
* @return {string}

@@ -184,0 +190,0 @@ * @nosideeffects

2

package.json
{
"name": "protobufjs",
"version": "1.0.0-b5",
"version": "1.0.0-b6",
"description": "ProtoBuf.js: protobuf for JavaScript. No compilation step required, works out of the box.",

@@ -5,0 +5,0 @@ "author": "Daniel Wirtz <dcode@dcode.io>",

@@ -6,62 +6,63 @@ /*

*/
(function(p){function q(n){if(!n||!n.zigZagEncode32)throw Error("ProtoBuf.js requires ByteBuffer.js >=1.1.0: Get it at https://github.com/dcodeIO/ByteBuffer.js");var f={VERSION:"1.0.0-b5",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.TYPES={int32:{name:"int32",wireType:f.WIRE_TYPES.VARINT},uint32:{name:"uint32",wireType:f.WIRE_TYPES.VARINT},sint32:{name:"sint32",wireType:f.WIRE_TYPES.VARINT},
(function(p){function q(n){if(!n||!n.zigZagEncode32)throw Error("ProtoBuf.js requires ByteBuffer.js >=1.1.0: Get it at https://github.com/dcodeIO/ByteBuffer.js");var f={VERSION:"1.0.0-b6",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.TYPES={int32:{name:"int32",wireType:f.WIRE_TYPES.VARINT},uint32:{name:"uint32",wireType:f.WIRE_TYPES.VARINT},sint32:{name:"sint32",wireType:f.WIRE_TYPES.VARINT},
int64:{name:"int64",wireType:f.WIRE_TYPES.VARINT},uint64:{name:"uint64",wireType:f.WIRE_TYPES.VARINT},sint64:{name:"sint64",wireType:f.WIRE_TYPES.VARINT},bool:{name:"bool",wireType:f.WIRE_TYPES.VARINT},"double":{name:"double",wireType:f.WIRE_TYPES.BITS64},string:{name:"string",wireType:f.WIRE_TYPES.LDELIM},bytes:{name:"bytes",wireType:f.WIRE_TYPES.LDELIM},fixed32:{name:"fixed32",wireType:f.WIRE_TYPES.BITS32},sfixed32:{name:"sfixed32",wireType:f.WIRE_TYPES.BITS32},fixed64:{name:"fixed64",wireType:f.WIRE_TYPES.BITS64},
sfixed64:{name:"sfixed64",wireType:f.WIRE_TYPES.BITS64},"float":{name:"float",wireType:f.WIRE_TYPES.BITS32},"enum":{name:"enum",wireType:f.WIRE_TYPES.VARINT},message:{name:"message",wireType:f.WIRE_TYPES.LDELIM}};f.Long=n.Long;f.Util=function(){Object.create||(Object.create=function(b){function c(){}if(1<arguments.length)throw Error("Object.create implementation only accepts the first parameter.");c.prototype=b;return new c});var c={};c.IS_NODE=("undefined"==typeof window||!window.window)&&"function"==
typeof require;c.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")}],c=null,h=0;h<b.length;h++){try{c=b[h]()}catch(a){continue}break}if(!c)throw Error("XMLHttpRequest is not supported");return c};c.fetch=function(b,m){m&&"function"!=typeof m&&(m=null);if(c.IS_NODE)if(m)require("fs").readFile(b,function(a,h){a?m(null):m(""+
h)});else try{return require("fs").readFileSync(b)}catch(h){return null}else{var a=c.XHR();a.open("GET",b,m?!0:!1);a.setRequestHeader("User-Agent","XMLHTTP/1.0");a.setRequestHeader("Accept","text/plain");if(m)a.onreadystatechange=function(){4==a.readyState&&(200==a.status?m(a.responseText):m(null))},4!=a.readyState&&a.send(null);else return a.send(null),a.responseText}};return c}();f.Lang={OPEN:"{",CLOSE:"}",OPTOPEN:"[",OPTCLOSE:"]",OPTEND:",",EQUAL:"=",END:";",DELIM:/[\s\{\}=;\[\],"\(\)]/g,KEYWORD:/package|option|import|message|enum|extend|service|syntax|extensions/,
typeof require;c.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")}],c=null,h=0;h<b.length;h++){try{c=b[h]()}catch(a){continue}break}if(!c)throw Error("XMLHttpRequest is not supported");return c};c.fetch=function(b,m){m&&"function"!=typeof m&&(m=null);if(c.IS_NODE)if(m)require("fs").readFile(b,function(a,b){a?m(null):m(""+
b)});else try{return require("fs").readFileSync(b)}catch(h){return null}else{var a=c.XHR();a.open("GET",b,m?!0:!1);a.setRequestHeader("User-Agent","XMLHTTP/1.0");a.setRequestHeader("Accept","text/plain");if(m)a.onreadystatechange=function(){4==a.readyState&&(200==a.status?m(a.responseText):m(null))},4!=a.readyState&&a.send(null);else return a.send(null),a.responseText}};return c}();f.Lang={OPEN:"{",CLOSE:"}",OPTOPEN:"[",OPTCLOSE:"]",OPTEND:",",EQUAL:"=",END:";",DELIM:/[\s\{\}=;\[\],"\(\)]/g,KEYWORD:/package|option|import|message|enum|extend|service|syntax|extensions/,
RULE:/required|optional|repeated/,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])*/,NUMBER:/^-?(?:[1-9][0-9]*|0|0x[0-9a-fA-F]+|0[0-7]+|[0-9]*\.[0-9]+)$/,NUMBER_DEC:/^(?:[1-9][0-9]*|0)$/,NUMBER_HEX:/^0x[0-9a-fA-F]+$/,NUMBER_OCT:/^0[0-7]+$/,NUMBER_FLT:/^[0-9]*\.[0-9]+$/,ID:/^(?:[1-9][0-9]*|0|0x[0-9a-fA-F]+|0[0-7]+)$/,WHITESPACE:/\s/,
STRING:/"([^"\\]*(\\.[^"\\]*)*)"/g,STRINGOPEN:'"',STRINGCLOSE:'"',COPTOPEN:"(",COPTCLOSE:")"};f.DotProto={};f.DotProto.Tokenizer=function(c){var b=function(b){this.source=""+b;this.index=0;this.stack=[];this.readingString=!1};b.prototype._readString=function(){c.STRING.lastIndex=this.index-1;var b;if(null!==(b=c.STRING.exec(this.source)))return b=b[1],this.index=c.STRING.lastIndex,this.stack.push(c.STRINGCLOSE),b;throw Error("Illegal string value at index "+this.index);};b.prototype.next=function(){if(0<
this.stack.length)return this.stack.pop();if(this.index>=this.source.length)return null;if(this.readingString)return this.readingString=!1,this._readString();var b;do{for(b=!1;c.WHITESPACE.test(this.source.charAt(this.index));)if(this.index++,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++;b=!0}else if("*"==this.source.charAt(this.index)){for(b=
"";"*/"!=b+(b=this.source.charAt(this.index));)if(this.index++,this.index==this.source.length)return null;this.index++;b=!0}else throw Error("Invalid comment: /"+this.source.charAt(this.index)+" ('/' or '*' expected)");}while(b);if(this.index==this.source.length)return null;b=this.index;c.DELIM.lastIndex=0;if(c.DELIM.test(this.source.charAt(b)))b++;else for(b++;b<this.source.length&&!c.DELIM.test(this.source.charAt(b));)b++;b=this.source.substring(this.index,this.index=b);b==c.STRINGOPEN&&(this.readingString=
!0);return b};b.prototype.toString=function(){return"Tokenizer("+this.index+"/"+this.source.length+")"};return b}(f.Lang);f.DotProto.Parser=function(c,b,f){c=function(b){this.tn=new f(b)};c.prototype.parse=function(){var b={name:"[ROOT]","package":null,messages:[],enums:[],imports:[],options:{}},a,d=!0;do{a=this.tn.next();if(null==a)break;if("package"==a){if(!d)throw Error("Illegal package definition: Must be declared before the first message or enum");if(null!==b["package"])throw Error("Illegal package definition: Package already declared");
b["package"]=this._parsePackage(a)}else if("import"==a){if(!d)throw Error("Illegal import definition: Must be declared before the first message or enum");b.imports.push(this._parseImport(a))}else if("message"==a)this._parseMessage(b,a),d=!1;else if("enum"==a)this._parseEnum(b,a),d=!1;else if("option"==a){if(!d)throw Error("Illegal option definition: Must be declared before the first message or enum");this._parseOption(b,a)}else if("extend"==a||"service"==a)this._parseIgnoredBlock(b,a);else if("syntax"==
a)this._parseIgnoredStatement(b,a);else throw Error("Illegal top level declaration: "+a);}while(1);delete b.name;return b};c.prototype._parseNumber=function(c){var a=1;"-"==c.charAt(0)&&(a=-1,c=c.substring(1));if(b.NUMBER_DEC.test(c))return a*parseInt(c,10);if(b.NUMBER_HEX.test(c))return a*parseInt(c.substring(2),16);if(b.NUMBER_OCT.test(c))return a*parseInt(c.substring(1),8);if(b.NUMBER_FLT.test(c))return a*parseFloat(c);throw Error("Illegal number value: "+(0>a?"-":"")+c);};c.prototype._parseId=
function(c){var a=-1;b.NUMBER_DEC.test(c)?a=parseInt(c):b.NUMBER_HEX.test(c)?a=parseInt(c.substring(2),16):b.NUMBER_OCT.test(c)&&(a=parseInt(c.substring(1),8));if(0>a)throw Error("Illegal ID value: "+(0>sign?"-":"")+c);return a};c.prototype._parsePackage=function(c){c=this.tn.next();if(!b.TYPEDEF.test(c))throw Error("Illegal package name: "+c);var a=c;c=this.tn.next();if(c!=b.END)throw Error("Illegal end of package definition: "+c+" ('"+b.END+"' expected)");return a};c.prototype._parseImport=function(c){c=
this.tn.next();"public"==c&&(c=this.tn.next());if(c!=b.STRINGOPEN)throw Error("Illegal begin of import value: "+c+" ('"+b.STRINGOPEN+"' expected)");var a=this.tn.next();c=this.tn.next();if(c!=b.STRINGCLOSE)throw Error("Illegal end of import value: "+c+" ('"+b.STRINGCLOSE+"' expected)");c=this.tn.next();if(c!=b.END)throw Error("Illegal end of import definition: "+c+" ('"+b.END+"' expected)");return a};c.prototype._parseOption=function(c,a){a=this.tn.next();var d=!1;a==b.COPTOPEN&&(d=!0,a=this.tn.next());
if(!b.NAME.test(a))throw Error("Illegal option name in message "+c.name+": "+a);var e=a;a=this.tn.next();if(d){if(a!=b.COPTCLOSE)throw Error("Illegal custom option name delimiter in message "+c.name+", option "+e+": "+a+" ('"+b.COPTCLOSE+"' expected)");a=this.tn.next()}if(a!=b.EQUAL)throw Error("Illegal option operator in message "+c.name+", option "+e+": "+a+" ('"+b.EQUAL+"' expected)");a=this.tn.next();if(a==b.STRINGOPEN){if(d=this.tn.next(),a=this.tn.next(),a!=b.STRINGCLOSE)throw Error("Illegal end of option value in message "+
c.name+", option "+e+": "+a+" ('"+b.STRINGCLOSE+"' expected)");}else if(b.NUMBER.test(a))d=this._parseNumber(a,!0);else if(b.NAME.test(a))d=a;else throw Error("Illegal option value in message "+c.name+", option "+e+": "+a);a=this.tn.next();if(a!=b.END)throw Error("Illegal end of option in message "+c.name+", option "+e+": "+a+" ('"+b.END+"' expected)");c.options[e]=d};c.prototype._parseIgnoredBlock=function(c,a){var d=this.tn.next();if(!b.TYPEREF.test(d))throw Error("Illegal "+a+" type in "+c.name+
": "+d);var e=d,d=this.tn.next();if(d!=b.OPEN)throw Error("Illegal OPEN in "+c.name+" after "+a+" "+e+": "+d);var g=1;do{d=this.tn.next();if(null===d)throw Error("Unexpected EOF in "+c.name+", "+a+" (ignored), "+e);if(d==b.OPEN)g++;else if(d==b.CLOSE&&(g--,0==g))break}while(1)};c.prototype._parseIgnoredStatement=function(c,a){do{var d=this.tn.next();if(null===d)throw Error("Unexpected EOF in "+c.name+", "+a+" (ignored)");if(d==b.END)break}while(1)};c.prototype._parseMessage=function(c,a){var d={};
a=this.tn.next();if(!b.NAME.test(a))throw Error("Illegal message name"+(c?" in message "+c.name:"")+": "+a);d.name=a;a=this.tn.next();if(a!=b.OPEN)throw Error("Illegal OPEN after message "+d.name+": "+a+" ('"+b.OPEN+"' expected)");d.fields=[];d.enums=[];d.messages=[];d.options={};do if(a=this.tn.next(),a==b.CLOSE)break;else if(b.RULE.test(a))this._parseMessageField(d,a);else if("enum"==a)this._parseEnum(d,a);else if("message"==a)this._parseMessage(d,a);else if("option"==a)this._parseOption(d,a);else if("extensions"==
a)this._parseIgnoredStatement(d,a);else throw Error("Illegal token in message "+d.name+": "+a+" (type or '"+b.CLOSE+"' expected)");while(1);c.messages.push(d);return d};c.prototype._parseMessageField=function(c,a){var d={};d.rule=a;a=this.tn.next();if(!b.TYPE.test(a)&&!b.TYPEREF.test(a))throw Error("Illegal field type in message "+c.name+": "+a);d.type=a;a=this.tn.next();if(!b.NAME.test(a))throw Error("Illegal field name in message "+c.name+": "+a);d.name=a;a=this.tn.next();if(a!=b.EQUAL)throw Error("Illegal field number operator in message "+
c.name+"#"+d.name+": "+a+" ('"+b.EQUAL+"' expected)");a=this.tn.next();try{d.id=this._parseId(a)}catch(e){throw Error("Illegal field id in message "+c.name+"#"+d.name+": "+a);}d.options={};a=this.tn.next();a==b.OPTOPEN&&(this._parseFieldOptions(c,d,a),a=this.tn.next());if(a!=b.END)throw Error("Illegal field delimiter in message "+c.name+"#"+d.name+": "+a+" ('"+b.END+"' expected)");c.fields.push(d)};c.prototype._parseFieldOptions=function(c,a,d){var e=!0;do{d=this.tn.next();if(d==b.OPTCLOSE)break;
else if(d==b.OPTEND){if(e)throw Error("Illegal start of message field options in message "+c.name+"#"+a.name+": "+d);d=this.tn.next()}this._parseFieldOption(c,a,d);e=!1}while(1)};c.prototype._parseFieldOption=function(c,a,d){var e=!1;d==b.COPTOPEN&&(d=this.tn.next(),e=!0);if(!b.NAME.test(d))throw Error("Illegal field option in message "+c.name+"#"+a.name+": "+d);var g=d;d=this.tn.next();if(e){if(d!=b.COPTCLOSE)throw Error("Illegal custom field option name delimiter in message "+c.name+"#"+a.name+
": "+d+" (')' expected)");d=this.tn.next()}if(d!=b.EQUAL)throw Error("Illegal field option operation in message "+c.name+"#"+a.name+": "+d+" ('=' expected)");d=this.tn.next();if(d==b.STRINGOPEN){if(e=this.tn.next(),d=this.tn.next(),d!=b.STRINGCLOSE)throw Error("Illegal end of field value in message "+c.name+"#"+a.name+", option "+g+": "+d+" ('"+b.STRINGCLOSE+"' expected)");}else if(b.NUMBER.test(d,!0))e=this._parseNumber(d,!0);else if(b.TYPEREF.test(d))e=d;else throw Error("Illegal field option value in message "+
c.name+"#"+a.name+", option "+g+": "+d);a.options[g]=e};c.prototype._parseEnum=function(c,a){var d={};a=this.tn.next();if(!b.NAME.test(a))throw Error("Illegal enum name in message "+c.name+": "+a);d.name=a;a=this.tn.next();if(a!=b.OPEN)throw Error("Illegal OPEN after enum "+d.name+": "+a);d.values=[];d.options={};do{a=this.tn.next();if(a==b.CLOSE)break;if("option"==a)this._parseOption(d,a);else{if(!b.NAME.test(a))throw Error("Illegal enum value name in enum "+d.name+": "+a);this._parseEnumValue(d,
a)}}while(1);c.enums.push(d)};c.prototype._parseEnumValue=function(c,a){var d={};d.name=a;a=this.tn.next();if(a!=b.EQUAL)throw Error("Illegal enum value operator in enum "+c.name+": "+a+" ('"+b.EQUAL+"' expected)");a=this.tn.next();try{d.id=this._parseId(a)}catch(e){throw Error("Illegal enum value id in enum "+c.name+": "+a);}c.values.push(d);a=this.tn.next();a==b.OPTOPEN&&(this._parseFieldOptions(c,{options:{}},a),a=this.tn.next());if(a!=b.END)throw Error("Illegal enum value delimiter in enum "+
c.name+": "+a+" ('"+b.END+"' expected)");};c.prototype.toString=function(){return"Parser"};return c}(f,f.Lang,f.DotProto.Tokenizer);f.Reflect=function(c){var b={},f=function(a,c){this.parent=a;this.name=c;this.resolvedType=null};f.prototype.toString=function(c){var k=this.name,d=this;do{d=d.parent;if(null==d)break;k=d.name+"."+k}while(1);c&&(this instanceof b.Message?k="Message "+k:this instanceof a.Field?k="Message.Field "+k:this instanceof e?k="Enum "+k:this instanceof e.Value?k="Enum.Value "+k:
this instanceof h&&(k="Namespace "+k));return k};f.prototype.build=function(){throw Error(this.toString(!0)+" cannot be built directly");};b.T=f;var h=function(a,c,b){f.call(this,a,c);this.children=[];this.options=b||{}};h.prototype=Object.create(f.prototype);h.prototype.getChildren=function(a){a=a||null;if(null==a)return this.children.slice();for(var c=[],b=0;b<this.children.length;b++)this.children[b]instanceof a&&c.push(this.children[b]);return c};h.prototype.addChild=function(a){if(this.hasChild(a.name))throw Error("Duplicate name in namespace "+
this.toString(!0)+": "+a.name);this.children.push(a)};h.prototype.hasChild=function(c){var b;if("number"==typeof c)for(b=0;b<this.children.length;b++){if(this.children[b]instanceof a.Field&&this.children[b].id==c)return!0}else for(b=0;b<this.children.length;b++)if(this.children[b].name==c)return!0;return!1};h.prototype.getChild=function(c){var b;if("number"==typeof c)for(b=0;b<this.children.length;b++){if(this.children[b]instanceof a.Field&&this.children[b].id==c)return this.children[b]}else for(b=
0;b<this.children.length;b++)if(this.children[b].name==c)return this.children[b];return null};h.prototype.resolve=function(a){var c=a.split("."),d=this,e=0;if(""==c[e]){for(;null!=d.parent;)d=d.parent;e++}do{do{d=d.getChild(c[e]);if(!d||!(d instanceof b.T)){d=null;break}e++}while(e<c.length);if(null!=d)break;if(null!==this.parent)return this.parent.resolve(a)}while(null!=d);return d};h.prototype.build=function(){for(var a={},c=this.getChildren(),b,d=0;d<c.length;d++)b=c[d],b instanceof h&&(a[b.name]=
b.build());Object.defineProperty&&Object.defineProperty(a,"$options",{value:this.buildOpt(),enumerable:!1,configurable:!1,writable:!1});return a};h.prototype.buildOpt=function(){for(var a={},c=Object.keys(this.options),b=0;b<c.length;b++)a[c[b]]=this.options[c[b]];return a};h.prototype.getOption=function(a){return"undefined"==typeof a?this.options:"undefined"!=typeof this.options[a]?this.options[a]:null};b.Namespace=h;var a=function(a,c,b){h.call(this,a,c,b);this.built=null};a.prototype=Object.create(h.prototype);
a.prototype.build=function(){for(var d=function(a,b){var d=b.getChildren(a.Message.Field),g=eval("0, (function "+b.name+"() { this.__construct.apply(this, arguments); })");g.prototype.__construct=function(a){var b,g;for(b=0;b<d.length;b++)g=d[b],this[g.name]=g.repeated?[]:null;for(b=0;b<d.length;b++)if(g=d[b],"undefined"!=typeof g.options["default"])try{this.set(g.name,g.options["default"])}catch(k){throw Error("[INTERNAL ERROR] "+k);}if(1==arguments.length&&"object"==typeof a&&"function"!=typeof a.encode&&
!(a instanceof Array)&&!(a instanceof n)&&!(a instanceof ArrayBuffer)&&!(c.Long&&a instanceof c.Long)){g=Object.keys(a);for(b=0;b<g.length;b++)this.set(g[b],a[g[b]])}else for(b=0;b<arguments.length;b++)b<d.length&&this.set(d[b].name,arguments[b])};g.prototype.add=function(c,d){var g=b.getChild(c);if(!g)throw Error(this+"#"+c+" is undefined");if(!(g instanceof a.Message.Field))throw Error(this+"#"+c+" is not a field: "+g.toString(!0));if(!g.repeated)throw Error(this+"#"+c+" is not a repeated field");
null===this[g.name]&&(this[g.name]=[]);this[g.name].push(g.verifyValue(d,!0))};g.prototype.set=function(c,d){var g=b.getChild(c);if(!g)throw Error(this+"#"+c+" is not a field: undefined");if(!(g instanceof a.Message.Field))throw Error(this+"#"+c+" is not a field: "+g.toString(!0));this[g.name]=g.verifyValue(d)};g.prototype.get=function(c){var d=b.getChild(c);if(!d||!(d instanceof a.Message.Field))throw Error(this+"#"+c+" is not a field: undefined");if(!(d instanceof a.Message.Field))throw Error(this+
"#"+c+" is not a field: "+d.toString(!0));return this[d.name]};for(var k=0;k<d.length;k++)(function(a){var c=a.name.replace(/(_[a-zA-Z])/g,function(a){return a.toUpperCase().replace("_","")}),c=c.substring(0,1).toUpperCase()+c.substring(1),d=a.name.replace(/([A-Z])/g,function(a){return"_"+a});b.hasChild("set"+c)||(g.prototype["set"+c]=function(c){this.set(a.name,c)});b.hasChild("set_"+d)||(g.prototype["set_"+d]=function(c){this.set(a.name,c)});b.hasChild("get"+c)||(g.prototype["get"+c]=function(){return this.get(a.name)});
b.hasChild("get_"+d)||(g.prototype["get_"+d]=function(){return this.get(a.name)})})(d[k]);g.prototype.encode=function(a){a=a||new n;var c=a.littleEndian,d=b.encode(this,a.LE()).flip();a.littleEndian=c;return d};g.prototype.toArrayBuffer=function(){return this.encode().toArrayBuffer()};g.decode=function(a){a=a?a instanceof n?a:n.wrap(a):new n;var c=a.littleEndian,d=b.decode(a.LE());a.littleEndian=c;return d};g.prototype.toString=function(){return b.toString()};Object.defineProperty&&Object.defineProperty(g,
"$options",{value:b.buildOpt(),enumerable:!1,configurable:!1,writable:!1});return g}(b,this),k=this.getChildren(),l=0;l<k.length;l++)if(k[l]instanceof e)d[k[l].name]=k[l].build();else if(k[l]instanceof a)d[k[l].name]=k[l].build();else if(!(k[l]instanceof a.Field))throw Error("Illegal reflect child of "+this.toString(!0)+": "+k[l].toString(!0));return this.built=d};a.prototype.encode=function(c,b){for(var d=this.getChildren(a.Field),e=0;e<d.length;e++)d[e].encode(c.get(d[e].name),b);return b};a.prototype.decode=
function(a,c){c=c||-1;for(var d=a.offset,e=new this.built;a.offset<d+c||-1==c&&0<a.remaining();){var f=a.readVarint32(),h=f&7,f=f>>3,m=this.getChild(f);if(!m)throw Error("Illegal field id in "+this.toString(!0)+"#decode: "+f);m.repeated&&!m.options.packed?e.add(m.name,m.decode(h,a)):e.set(m.name,m.decode(h,a))}d=this.getChildren(b.Field);for(h=0;h<d.length;h++)if(d[h].required&&null===e[d[h].name])throw d=Error("Missing field "+d[h].toString(!0)+" in "+this.toString(!0)+"#decode"),d.msg=e,d;return e};
b.Message=a;var d=function(a,c,b,d,e,h){f.call(this,a,d);this.required="required"==c;this.repeated="repeated"==c;this.type=b;this.id=e;this.options=h||{}};d.prototype=Object.create(f.prototype);d.prototype.verifyValue=function(a,b){b=b||!1;if(null===a){if(this.required)throw Error("Illegal value for "+this.toString(!0)+": "+a+" (required)");return null}var d;if(this.repeated&&!b){a instanceof Array||(a=[a]);var f=[];for(d=0;d<a.length;d++)f.push(this.verifyValue(a[d],!0));return f}if(!this.repeated&&
a instanceof Array)throw Error("Illegal value for "+this.toString(!0)+": "+a+" (no array expected)");if(this.type==c.TYPES.int32||this.type==c.TYPES.sint32||this.type==c.TYPES.sfixed32)return parseInt(a,10)|0;if(this.type==c.TYPES.uint32||this.type==c.TYPES.fixed32)return parseInt(a,10)>>>0;if(c.Long){if(this.type==c.TYPES.int64||this.type==c.TYPES.sint64||this.type==c.TYPES.sfixed64)return!("object"==typeof a&&a instanceof c.Long)?c.Long.fromNumber(a,!1):a.unsigned?a.toSigned():a;if(this.type==c.TYPES.uint64||
this.type==c.TYPES.fixed64)return!("object"==typeof a&&a instanceof c.Long)?c.Long.fromNumber(a,!0):a.unsigned?a:a.toUnsigned()}if(this.type==c.TYPES.bool)return!!a;if(this.type==c.TYPES["float"]||this.type==c.TYPES["double"])return parseFloat(a);if(this.type==c.TYPES.string)return""+a;if(this.type==c.TYPES.bytes)return"object"==typeof a&&a instanceof n?a:n.wrap(a);if(this.type==c.TYPES["enum"]){f=this.resolvedType.getChildren(e.Value);for(d=0;d<f.length;d++)if(f[d].name==a||f[d].id==a)return f[d].id;
throw Error("Illegal value for "+this.toString(!0)+": "+a+" (not a valid enum value)");}if(this.type==c.TYPES.message){if("object"!=typeof a)throw Error("Illegal value for "+this.toString(!0)+": "+a+" (object expected)");return a instanceof this.resolvedType.built?a:new this.resolvedType.built(a)}throw Error("[INTERNAL ERROR] Illegal value for "+this.toString(!0)+": "+a+" (undefined type "+this.type+")");};d.prototype.encode=function(a,b){a=this.verifyValue(a);if(null==this.type||"object"!=typeof this.type)throw Error("[INTERNAL ERROR] Unresolved type in "+
this.toString(!0)+": "+this.type);if(null===a||this.repeated&&0==a.length)return b;try{if(this.repeated){var d;if(this.options.packed){b.writeVarint32(this.id<<3|c.WIRE_TYPES.LDELIM);b.ensureCapacity(b.offset+=1);var e=b.offset;for(d=0;d<a.length;d++)this.encodeValue(a[d],b);var f=b.offset-e,h=n.calculateVarint32(f);if(1<h){var m=b.slice(e,b.offset),e=e+(h-1);b.offset=e;b.append(m)}b.writeVarint32(f,e-h)}else for(d=0;d<a.length;d++)b.writeVarint32(this.id<<3|this.type.wireType),this.encodeValue(a[d],
b)}else b.writeVarint32(this.id<<3|this.type.wireType),this.encodeValue(a,b)}catch(p){throw b.littleEndian=le,Error("Illegal value for "+this.toString(!0)+": "+a+" ("+p+")");}return b};d.prototype.encodeValue=function(a,b){if(null!==a){if(this.type==c.TYPES.int32||this.type==c.TYPES.uint32)b.writeVarint32(a);else if(this.type==c.TYPES.sint32)b.writeZigZagVarint32(a);else if(this.type==c.TYPES.fixed32)b.writeUint32(a);else if(this.type==c.TYPES.sfixed32)b.writeInt32(a);else if(this.type==c.TYPES.int64||
this.type==c.TYPES.uint64)b.writeVarint64(a);else if(this.type==c.TYPES.sint64)b.writeZigZagVarint64(a);else if(this.type==c.TYPES.fixed64)b.writeUint64(a);else if(this.type==c.TYPES.sfixed64)b.writeInt64(a);else if(this.type==c.TYPES.bool)b.writeVarint32(a?1:0);else if(this.type==c.TYPES["enum"])b.writeVarint32(a);else if(this.type==c.TYPES["float"])b.writeFloat32(a);else if(this.type==c.TYPES["double"])b.writeFloat64(a);else if(this.type==c.TYPES.string)b.writeVString(a);else if(this.type==c.TYPES.bytes)a.offset>
a.length&&(b=b.clone().flip()),b.writeVarint32(a.remaining()),b.append(a);else if(this.type==c.TYPES.message){var d=(new n).LE();this.resolvedType.encode(a,d);b.writeVarint32(d.offset);b.append(d.flip())}else throw Error("[INTERNAL ERROR] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");return b}};d.prototype.decode=function(a,b,d){if(a!=this.type.wireType&&(d||a!=c.WIRE_TYPES.LDELIM||!this.repeated))throw Error("Illegal wire type for field "+this.toString(!0)+": "+a+" ("+
this.type.wireType+" expected)");if(a==c.WIRE_TYPES.LDELIM&&(this.repeated&&this.options.packed)&&!d){a=b.readVarint32();a=b.offset+a;for(d=[];b.offset<a;)d.push(this.decode(this.type.wireType,b,!0));return d}if(this.type==c.TYPES.int32)return b.readVarint32()|0;if(this.type==c.TYPES.uint32)return b.readVarint32()>>>0;if(this.type==c.TYPES.sint32)return b.readZigZagVarint32()|0;if(this.type==c.TYPES.fixed32)return b.readUint32()>>>0;if(this.type==c.TYPES.sfixed32)return b.readInt32()|0;if(this.type==
c.TYPES.int64)return b.readVarint64();if(this.type==c.TYPES.uint64)return b.readVarint64().toUnsigned();if(this.type==c.TYPES.sint64)return b.readZigZagVarint64();if(this.type==c.TYPES.fixed64)return b.readUint64();if(this.type==c.TYPES.sfixed64)return b.readInt64();if(this.type==c.TYPES.bool)return!!b.readVarint32();if(this.type==c.TYPES["enum"])return b.readVarint32();if(this.type==c.TYPES["float"])return b.readFloat();if(this.type==c.TYPES["double"])return b.readDouble();if(this.type==c.TYPES.string)return b.readVString();
if(this.type==c.TYPES.bytes)return a=b.readVarint32(),d=b.clone(),d.length=d.offset+a,b.offset+=a,d;if(this.type==c.TYPES.message)return a=b.readVarint32(),this.resolvedType.decode(b,a);throw Error("[INTERNAL ERROR] Illegal wire type for "+this.toString(!0)+": "+a);};b.Message.Field=d;var e=function(a,b,c){h.call(this,a,b,c);this.built=null};e.prototype=Object.create(h.prototype);e.prototype.build=function(){for(var a={},b=this.getChildren(e.Value),c=0;c<b.length;c++)a[b[c].name]=b[c].id;Object.defineProperty&&
Object.defineProperty(a,"$options",{value:this.buildOpt(),enumerable:!1,configurable:!1,writable:!1});return this.built=a};b.Enum=e;d=function(a,b,c){f.call(this,a,b);this.id=c};d.prototype=Object.create(f.prototype);b.Enum.Value=d;return b}(f);f.Builder=function(c,b,f){var h=function(){this.ptr=this.ns=new f.Namespace(null,"");this.resolved=!1;this.result=null};h.prototype.reset=function(){this.ptr=this.ns};h.prototype.define=function(a,c){if("string"!=typeof a||!b.TYPEDEF.test(a))throw Error("Illegal package name: "+
a);var e=a.split("."),g;for(g=0;g<e.length;g++)if(!b.NAME.test(e[g]))throw Error("Illegal package name: "+e[g]);for(g=0;g<e.length;g++)this.ptr.hasChild(e[g])||this.ptr.addChild(new f.Namespace(this.ptr,e[g],c)),this.ptr=this.ptr.getChild(e[g]);return this};h.isValidMessage=function(a){if("string"!=typeof a.name||!b.NAME.test(a.name)||"undefined"!=typeof a.values)return!1;var c;if("undefined"!=typeof a.fields){if(!(a.fields instanceof Array))return console.log("3"),!1;var e=[],f;for(c=0;c<a.fields.length;c++){if(!h.isValidMessageField(a.fields[c]))return!1;
f=parseInt(a.id,10);if(0<=e.indexOf(f))return!1;e.push(f)}}if("undefined"!=typeof a.enums){if(!(a.enums instanceof Array))return!1;for(c=0;c<a.enums.length;c++)if(!h.isValidEnum(a.enums[c]))return!1}if("undefined"!=typeof a.messages){if(!(a.messages instanceof Array))return!1;for(c=0;c<a.messages.length;c++)if(!h.isValidMessage(a.messages[c]))return!1}return!0};h.isValidMessageField=function(a){if("string"!=typeof a.rule||"string"!=typeof a.name||"string"!=typeof a.type||"undefined"==typeof a.id||
!b.RULE.test(a.rule)||!b.NAME.test(a.name)||!b.TYPEREF.test(a.type)||!b.ID.test(""+a.id))return!1;if("undefined"!=typeof a.options){if("object"!=typeof a.options)return!1;for(var c=Object.keys(a.options),e=0;e<c.length;e++)if(!b.NAME.test(c[e])||"string"!=typeof a.options[c[e]]&&"number"!=typeof a.options[c[e]])return!1}return!0};h.isValidEnum=function(a){if("string"!=typeof a.name||!b.NAME.test(a.name)||"undefined"==typeof a.values||!(a.values instanceof Array)||0==a.values.length)return!1;for(var c=
0;c<a.values.length;c++)if("object"!=typeof a.values[c]||"string"!=typeof a.values[c].name||"undefined"==typeof a.values[c].id||!b.NAME.test(a.values[c].name)||!b.ID.test(""+a.values[c].id))return!1;return!0};h.prototype.create=function(a){if(a&&(a instanceof Array||(a=[a]),0!=a.length)){var c=[],e,g,k,l,n;for(c.push(a);0<c.length;){a=c.pop();if(a instanceof Array)for(;0<a.length;)if(e=a.shift(),h.isValidMessage(e)){g=new f.Message(this.ptr,e.name,e.options);if(e.fields&&0<e.fields.length)for(l=0;l<
e.fields.length;l++){if(!h.isValidMessageField(e.fields[l]))throw Error("Not a valid message field definition in message "+g.name+": "+JSON.stringify(e.fields[l]));if(g.hasChild(e.fields[l].id))throw Error("Duplicate field id in message "+g.name+": "+e.fields[l].id);if(e.fields[l].options){k=Object.keys(e.fields[l].options);for(n=0;n<k.length;n++){if(!b.NAME.test(k[n]))throw Error("Illegal field option name in message "+g.name+"#"+e.fields[l].name+": "+k[n]);if("string"!=typeof e.fields[l].options[k[n]]&&
"number"!=typeof e.fields[l].options[k[n]])throw Error("Illegal field option value in message "+g.name+"#"+e.fields[l].name+"#"+k[n]+": "+e.fields[l].options[k[n]]);}}g.addChild(new f.Message.Field(g,e.fields[l].rule,e.fields[l].type,e.fields[l].name,e.fields[l].id,e.fields[l].options))}k=[];if("undefined"!=typeof e.enums&&0<e.enums.length)for(l=0;l<e.enums.length;l++)k.push(e.enums[l]);if(e.messages&&0<e.messages.length)for(l=0;l<e.messages.length;l++)k.push(e.messages[l]);this.ptr.addChild(g);0<
k.length&&(c.push(a),a=k,this.ptr=g)}else if(h.isValidEnum(e)){g=new f.Enum(this.ptr,e.name,e.options);for(l=0;l<e.values.length;l++)g.addChild(new f.Enum.Value(g,e.values[l].name,e.values[l].id));this.ptr.addChild(g)}else throw Error("Not a valid message or enum definition: "+JSON.stringify(e));else throw Error("Not a valid namespace definition: "+JSON.stringify(a));this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this}};h.isValidImport=function(a){return!/google\/protobuf\//.test(a)};
h.prototype["import"]=function(a,b){a["package"]&&this.define(a["package"],a.options);a.messages&&this.create(a.messages);this.reset();a["package"]&&this.define(a["package"],a.options);a.enums&&this.create(a.enums);this.reset();if(a.imports&&0<a.imports.length){if(!b)throw Error("Cannot determine import root: File name is unknown");for(var e=b.replace(/[\/\\][^\/\\]*$/,""),f=0;f<a.imports.length;f++){var k=e+"/"+a.imports[f];if(/\.json$/i.test(k)){var l=c.Util.fetch(k);if(null===l)throw Error("Failed to import '"+
k+"' in '"+b+"': File not found");this["import"](JSON.parse(l),k)}else if(h.isValidImport(k)){l=c.Util.fetch(k);if(null===l)throw Error("Failed to import '"+k+"' in '"+b+"': File not found");l=new c.DotProto.Parser(l+"");this["import"](l.parse(),k)}}}return this};h.prototype.resolveAll=function(){if(!(null==this.ptr||"object"==typeof this.ptr.type)){if(this.ptr instanceof f.Namespace)for(var a=this.ptr.getChildren(),d=0;d<a.length;d++)this.ptr=a[d],this.resolveAll();else if(this.ptr instanceof f.Message.Field)if(b.TYPE.test(this.ptr.type))this.ptr.type=
c.TYPES[this.ptr.type];else{if(!b.TYPEREF.test(this.ptr.type))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);a=this.ptr.parent.resolve(this.ptr.type);if(!a)throw Error("Unresolvable type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);this.ptr.resolvedType=a;if(a instanceof f.Enum)this.ptr.type=c.TYPES["enum"];else if(a instanceof f.Message)this.ptr.type=c.TYPES.message;else throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);
}else if(!(this.ptr instanceof c.Reflect.Enum.Value))throw Error("Illegal object type in namespace: "+typeof this.ptr+":"+this.ptr);this.reset()}};h.prototype.build=function(a){this.reset();this.resolved||(this.resolveAll(),this.resolved=!0,this.result=null);null==this.result&&(this.result=this.ns.build());if(a){a=a.split(".");for(var b=this.result,c=0;c<a.length;c++)if(b[a[c]])b=b[a[c]];else{b=null;break}return b}return this.result};h.prototype.toString=function(){return"Builder"};return h}(f,f.Lang,
f.Reflect);f.protoFromString=function(c,b,m){"string"==typeof b&&(m=b,b=null);c=(new f.DotProto.Parser(c+"")).parse();b="object"==typeof b?b:new f.Builder;null!==c["package"]&&b.define(c["package"],c.options);b.create(c.messages);b.reset();null!==c["package"]&&b.define(c["package"],c.options);b.create(c.enums);b.reset();if(m&&0<c.imports.length)b["import"]({imports:c.imports},m);b.resolveAll();b.build();return b};f.protoFromFile=function(c,b,m){if(b&&"object"==typeof b)m=b,b=null;else if(!b||"function"!=
typeof b)b=null;if(b)f.Util.fetch(c,function(a){b(f.protoFromString(a,m,c))});else{var h=f.Util.fetch(c);return null!==h?f.protoFromString(h,m,c):null}};f.newBuilder=function(c,b){var m=new f.Builder;"undefined"!=typeof c&&m.define(c,b);return m};return f}"undefined"!=typeof module&&module.exports?module.exports=q(require("bytebuffer")):"undefined"!=typeof define&&define.amd?define("ProtoBuf",["ByteBuffer"],q):(p.dcodeIO||(p.dcodeIO={}),p.dcodeIO.ProtoBuf=q(p.dcodeIO.ByteBuffer))})(this);
this.stack.length)return this.stack.shift();if(this.index>=this.source.length)return null;if(this.readingString)return this.readingString=!1,this._readString();var b;do{for(b=!1;c.WHITESPACE.test(this.source.charAt(this.index));)if(this.index++,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++;b=!0}else if("*"==
this.source.charAt(this.index)){for(b="";"*/"!=b+(b=this.source.charAt(this.index));)if(this.index++,this.index==this.source.length)return null;this.index++;b=!0}else throw Error("Invalid comment: /"+this.source.charAt(this.index)+" ('/' or '*' expected)");}while(b);if(this.index==this.source.length)return null;b=this.index;c.DELIM.lastIndex=0;if(c.DELIM.test(this.source.charAt(b)))b++;else for(b++;b<this.source.length&&!c.DELIM.test(this.source.charAt(b));)b++;b=this.source.substring(this.index,
this.index=b);b==c.STRINGOPEN&&(this.readingString=!0);return b};b.prototype.peek=function(){if(0==this.stack.length){var b=this.next();if(null===b)return null;this.stack.push(b)}return this.stack[0]};b.prototype.toString=function(){return"Tokenizer("+this.index+"/"+this.source.length+")"};return b}(f.Lang);f.DotProto.Parser=function(c,b,f){c=function(b){this.tn=new f(b)};c.prototype.parse=function(){var b={name:"[ROOT]","package":null,messages:[],enums:[],imports:[],options:{}},a,d=!0;do{a=this.tn.next();
if(null==a)break;if("package"==a){if(!d)throw Error("Illegal package definition: Must be declared before the first message or enum");if(null!==b["package"])throw Error("Illegal package definition: Package already declared");b["package"]=this._parsePackage(a)}else if("import"==a){if(!d)throw Error("Illegal import definition: Must be declared before the first message or enum");b.imports.push(this._parseImport(a))}else if("message"==a)this._parseMessage(b,a),d=!1;else if("enum"==a)this._parseEnum(b,
a),d=!1;else if("option"==a){if(!d)throw Error("Illegal option definition: Must be declared before the first message or enum");this._parseOption(b,a)}else if("extend"==a||"service"==a)this._parseIgnoredBlock(b,a);else if("syntax"==a)this._parseIgnoredStatement(b,a);else throw Error("Illegal top level declaration: "+a);}while(1);delete b.name;return b};c.prototype._parseNumber=function(c){var a=1;"-"==c.charAt(0)&&(a=-1,c=c.substring(1));if(b.NUMBER_DEC.test(c))return a*parseInt(c,10);if(b.NUMBER_HEX.test(c))return a*
parseInt(c.substring(2),16);if(b.NUMBER_OCT.test(c))return a*parseInt(c.substring(1),8);if(b.NUMBER_FLT.test(c))return a*parseFloat(c);throw Error("Illegal number value: "+(0>a?"-":"")+c);};c.prototype._parseId=function(c){var a=-1;b.NUMBER_DEC.test(c)?a=parseInt(c):b.NUMBER_HEX.test(c)?a=parseInt(c.substring(2),16):b.NUMBER_OCT.test(c)&&(a=parseInt(c.substring(1),8));if(0>a)throw Error("Illegal ID value: "+(0>sign?"-":"")+c);return a};c.prototype._parsePackage=function(c){c=this.tn.next();if(!b.TYPEDEF.test(c))throw Error("Illegal package name: "+
c);var a=c;c=this.tn.next();if(c!=b.END)throw Error("Illegal end of package definition: "+c+" ('"+b.END+"' expected)");return a};c.prototype._parseImport=function(c){c=this.tn.next();"public"==c&&(c=this.tn.next());if(c!=b.STRINGOPEN)throw Error("Illegal begin of import value: "+c+" ('"+b.STRINGOPEN+"' expected)");var a=this.tn.next();c=this.tn.next();if(c!=b.STRINGCLOSE)throw Error("Illegal end of import value: "+c+" ('"+b.STRINGCLOSE+"' expected)");c=this.tn.next();if(c!=b.END)throw Error("Illegal end of import definition: "+
c+" ('"+b.END+"' expected)");return a};c.prototype._parseOption=function(c,a){a=this.tn.next();var d=!1;a==b.COPTOPEN&&(d=!0,a=this.tn.next());if(!b.NAME.test(a))throw Error("Illegal option name in message "+c.name+": "+a);var e=a;a=this.tn.next();if(d){if(a!=b.COPTCLOSE)throw Error("Illegal custom option name delimiter in message "+c.name+", option "+e+": "+a+" ('"+b.COPTCLOSE+"' expected)");a=this.tn.next()}if(a!=b.EQUAL)throw Error("Illegal option operator in message "+c.name+", option "+e+": "+
a+" ('"+b.EQUAL+"' expected)");a=this.tn.next();if(a==b.STRINGOPEN){if(d=this.tn.next(),a=this.tn.next(),a!=b.STRINGCLOSE)throw Error("Illegal end of option value in message "+c.name+", option "+e+": "+a+" ('"+b.STRINGCLOSE+"' expected)");}else if(b.NUMBER.test(a))d=this._parseNumber(a,!0);else if(b.NAME.test(a))d=a;else throw Error("Illegal option value in message "+c.name+", option "+e+": "+a);a=this.tn.next();if(a!=b.END)throw Error("Illegal end of option in message "+c.name+", option "+e+": "+
a+" ('"+b.END+"' expected)");c.options[e]=d};c.prototype._parseIgnoredBlock=function(c,a){var d=this.tn.next();if(!b.TYPEREF.test(d))throw Error("Illegal "+a+" type in "+c.name+": "+d);var e=d,d=this.tn.next();if(d!=b.OPEN)throw Error("Illegal OPEN in "+c.name+" after "+a+" "+e+": "+d);var g=1;do{d=this.tn.next();if(null===d)throw Error("Unexpected EOF in "+c.name+", "+a+" (ignored), "+e);if(d==b.OPEN)g++;else if(d==b.CLOSE&&(d=this.tn.peek(),d==b.END&&this.tn.next(),g--,0==g))break}while(1)};c.prototype._parseIgnoredStatement=
function(c,a){do{var d=this.tn.next();if(null===d)throw Error("Unexpected EOF in "+c.name+", "+a+" (ignored)");if(d==b.END)break}while(1)};c.prototype._parseMessage=function(c,a){var d={};a=this.tn.next();if(!b.NAME.test(a))throw Error("Illegal message name"+(c?" in message "+c.name:"")+": "+a);d.name=a;a=this.tn.next();if(a!=b.OPEN)throw Error("Illegal OPEN after message "+d.name+": "+a+" ('"+b.OPEN+"' expected)");d.fields=[];d.enums=[];d.messages=[];d.options={};do if(a=this.tn.next(),a==b.CLOSE){a=
this.tn.peek();a==b.END&&this.tn.next();break}else if(b.RULE.test(a))this._parseMessageField(d,a);else if("enum"==a)this._parseEnum(d,a);else if("message"==a)this._parseMessage(d,a);else if("option"==a)this._parseOption(d,a);else if("extensions"==a)this._parseIgnoredStatement(d,a);else throw Error("Illegal token in message "+d.name+": "+a+" (type or '"+b.CLOSE+"' expected)");while(1);c.messages.push(d);return d};c.prototype._parseMessageField=function(c,a){var d={};d.rule=a;a=this.tn.next();if(!b.TYPE.test(a)&&
!b.TYPEREF.test(a))throw Error("Illegal field type in message "+c.name+": "+a);d.type=a;a=this.tn.next();if(!b.NAME.test(a))throw Error("Illegal field name in message "+c.name+": "+a);d.name=a;a=this.tn.next();if(a!=b.EQUAL)throw Error("Illegal field number operator in message "+c.name+"#"+d.name+": "+a+" ('"+b.EQUAL+"' expected)");a=this.tn.next();try{d.id=this._parseId(a)}catch(e){throw Error("Illegal field id in message "+c.name+"#"+d.name+": "+a);}d.options={};a=this.tn.next();a==b.OPTOPEN&&(this._parseFieldOptions(c,
d,a),a=this.tn.next());if(a!=b.END)throw Error("Illegal field delimiter in message "+c.name+"#"+d.name+": "+a+" ('"+b.END+"' expected)");c.fields.push(d)};c.prototype._parseFieldOptions=function(c,a,d){var e=!0;do{d=this.tn.next();if(d==b.OPTCLOSE)break;else if(d==b.OPTEND){if(e)throw Error("Illegal start of message field options in message "+c.name+"#"+a.name+": "+d);d=this.tn.next()}this._parseFieldOption(c,a,d);e=!1}while(1)};c.prototype._parseFieldOption=function(c,a,d){var e=!1;d==b.COPTOPEN&&
(d=this.tn.next(),e=!0);if(!b.NAME.test(d))throw Error("Illegal field option in message "+c.name+"#"+a.name+": "+d);var g=d;d=this.tn.next();if(e){if(d!=b.COPTCLOSE)throw Error("Illegal custom field option name delimiter in message "+c.name+"#"+a.name+": "+d+" (')' expected)");d=this.tn.next()}if(d!=b.EQUAL)throw Error("Illegal field option operation in message "+c.name+"#"+a.name+": "+d+" ('=' expected)");d=this.tn.next();if(d==b.STRINGOPEN){if(e=this.tn.next(),d=this.tn.next(),d!=b.STRINGCLOSE)throw Error("Illegal end of field value in message "+
c.name+"#"+a.name+", option "+g+": "+d+" ('"+b.STRINGCLOSE+"' expected)");}else if(b.NUMBER.test(d,!0))e=this._parseNumber(d,!0);else if(b.TYPEREF.test(d))e=d;else throw Error("Illegal field option value in message "+c.name+"#"+a.name+", option "+g+": "+d);a.options[g]=e};c.prototype._parseEnum=function(c,a){var d={};a=this.tn.next();if(!b.NAME.test(a))throw Error("Illegal enum name in message "+c.name+": "+a);d.name=a;a=this.tn.next();if(a!=b.OPEN)throw Error("Illegal OPEN after enum "+d.name+": "+
a);d.values=[];d.options={};do{a=this.tn.next();if(a==b.CLOSE){a=this.tn.peek();a==b.END&&this.tn.next();break}if("option"==a)this._parseOption(d,a);else{if(!b.NAME.test(a))throw Error("Illegal enum value name in enum "+d.name+": "+a);this._parseEnumValue(d,a)}}while(1);c.enums.push(d)};c.prototype._parseEnumValue=function(c,a){var d={};d.name=a;a=this.tn.next();if(a!=b.EQUAL)throw Error("Illegal enum value operator in enum "+c.name+": "+a+" ('"+b.EQUAL+"' expected)");a=this.tn.next();try{d.id=this._parseId(a)}catch(e){throw Error("Illegal enum value id in enum "+
c.name+": "+a);}c.values.push(d);a=this.tn.next();a==b.OPTOPEN&&(this._parseFieldOptions(c,{options:{}},a),a=this.tn.next());if(a!=b.END)throw Error("Illegal enum value delimiter in enum "+c.name+": "+a+" ('"+b.END+"' expected)");};c.prototype.toString=function(){return"Parser"};return c}(f,f.Lang,f.DotProto.Tokenizer);f.Reflect=function(c){var b={},f=function(a,c){this.parent=a;this.name=c;this.resolvedType=null};f.prototype.toString=function(c){var k=this.name,d=this;do{d=d.parent;if(null==d)break;
k=d.name+"."+k}while(1);c&&(this instanceof b.Message?k="Message "+k:this instanceof a.Field?k="Message.Field "+k:this instanceof e?k="Enum "+k:this instanceof e.Value?k="Enum.Value "+k:this instanceof h&&(k="Namespace "+k));return k};f.prototype.build=function(){throw Error(this.toString(!0)+" cannot be built directly");};b.T=f;var h=function(a,c,b){f.call(this,a,c);this.children=[];this.options=b||{}};h.prototype=Object.create(f.prototype);h.prototype.getChildren=function(a){a=a||null;if(null==
a)return this.children.slice();for(var c=[],b=0;b<this.children.length;b++)this.children[b]instanceof a&&c.push(this.children[b]);return c};h.prototype.addChild=function(a){if(this.hasChild(a.name))throw Error("Duplicate name in namespace "+this.toString(!0)+": "+a.name);this.children.push(a)};h.prototype.hasChild=function(c){var b;if("number"==typeof c)for(b=0;b<this.children.length;b++){if(this.children[b]instanceof a.Field&&this.children[b].id==c)return!0}else for(b=0;b<this.children.length;b++)if(this.children[b].name==
c)return!0;return!1};h.prototype.getChild=function(c){var b;if("number"==typeof c)for(b=0;b<this.children.length;b++){if(this.children[b]instanceof a.Field&&this.children[b].id==c)return this.children[b]}else for(b=0;b<this.children.length;b++)if(this.children[b].name==c)return this.children[b];return null};h.prototype.resolve=function(a){var c=a.split("."),d=this,e=0;if(""==c[e]){for(;null!=d.parent;)d=d.parent;e++}do{do{d=d.getChild(c[e]);if(!d||!(d instanceof b.T)){d=null;break}e++}while(e<c.length);
if(null!=d)break;if(null!==this.parent)return this.parent.resolve(a)}while(null!=d);return d};h.prototype.build=function(){for(var a={},c=this.getChildren(),b,d=0;d<c.length;d++)b=c[d],b instanceof h&&(a[b.name]=b.build());Object.defineProperty&&Object.defineProperty(a,"$options",{value:this.buildOpt(),enumerable:!1,configurable:!1,writable:!1});return a};h.prototype.buildOpt=function(){for(var a={},c=Object.keys(this.options),b=0;b<c.length;b++)a[c[b]]=this.options[c[b]];return a};h.prototype.getOption=
function(a){return"undefined"==typeof a?this.options:"undefined"!=typeof this.options[a]?this.options[a]:null};b.Namespace=h;var a=function(a,c,b){h.call(this,a,c,b);this.built=null};a.prototype=Object.create(h.prototype);a.prototype.build=function(){for(var d=function(a,b){var d=b.getChildren(a.Message.Field),g=eval("0, (function "+b.name+"() { this.__construct.apply(this, arguments); })");g.prototype.__construct=function(a){var b,g;for(b=0;b<d.length;b++)g=d[b],this[g.name]=g.repeated?[]:null;for(b=
0;b<d.length;b++)if(g=d[b],"undefined"!=typeof g.options["default"])try{this.set(g.name,g.options["default"])}catch(k){throw Error("[INTERNAL ERROR] "+k);}if(1==arguments.length&&"object"==typeof a&&"function"!=typeof a.encode&&!(a instanceof Array)&&!(a instanceof n)&&!(a instanceof ArrayBuffer)&&!(c.Long&&a instanceof c.Long)){g=Object.keys(a);for(b=0;b<g.length;b++)this.set(g[b],a[g[b]])}else for(b=0;b<arguments.length;b++)b<d.length&&this.set(d[b].name,arguments[b])};g.prototype.add=function(c,
d){var g=b.getChild(c);if(!g)throw Error(this+"#"+c+" is undefined");if(!(g instanceof a.Message.Field))throw Error(this+"#"+c+" is not a field: "+g.toString(!0));if(!g.repeated)throw Error(this+"#"+c+" is not a repeated field");null===this[g.name]&&(this[g.name]=[]);this[g.name].push(g.verifyValue(d,!0))};g.prototype.set=function(c,d){var g=b.getChild(c);if(!g)throw Error(this+"#"+c+" is not a field: undefined");if(!(g instanceof a.Message.Field))throw Error(this+"#"+c+" is not a field: "+g.toString(!0));
this[g.name]=g.verifyValue(d)};g.prototype.get=function(c){var d=b.getChild(c);if(!d||!(d instanceof a.Message.Field))throw Error(this+"#"+c+" is not a field: undefined");if(!(d instanceof a.Message.Field))throw Error(this+"#"+c+" is not a field: "+d.toString(!0));return this[d.name]};for(var k=0;k<d.length;k++)(function(a){var c=a.name.replace(/(_[a-zA-Z])/g,function(a){return a.toUpperCase().replace("_","")}),c=c.substring(0,1).toUpperCase()+c.substring(1),d=a.name.replace(/([A-Z])/g,function(a){return"_"+
a});b.hasChild("set"+c)||(g.prototype["set"+c]=function(c){this.set(a.name,c)});b.hasChild("set_"+d)||(g.prototype["set_"+d]=function(c){this.set(a.name,c)});b.hasChild("get"+c)||(g.prototype["get"+c]=function(){return this.get(a.name)});b.hasChild("get_"+d)||(g.prototype["get_"+d]=function(){return this.get(a.name)})})(d[k]);g.prototype.encode=function(a){a=a||new n;var c=a.littleEndian,d=b.encode(this,a.LE()).flip();a.littleEndian=c;return d};g.prototype.toArrayBuffer=function(){return this.encode().toArrayBuffer()};
g.decode=function(a){a=a?a instanceof n?a:n.wrap(a):new n;var c=a.littleEndian,d=b.decode(a.LE());a.littleEndian=c;return d};g.prototype.toString=function(){return b.toString()};Object.defineProperty&&Object.defineProperty(g,"$options",{value:b.buildOpt(),enumerable:!1,configurable:!1,writable:!1});return g}(b,this),k=this.getChildren(),l=0;l<k.length;l++)if(k[l]instanceof e)d[k[l].name]=k[l].build();else if(k[l]instanceof a)d[k[l].name]=k[l].build();else if(!(k[l]instanceof a.Field))throw Error("Illegal reflect child of "+
this.toString(!0)+": "+k[l].toString(!0));return this.built=d};a.prototype.encode=function(c,b){for(var d=this.getChildren(a.Field),e=0;e<d.length;e++)d[e].encode(c.get(d[e].name),b);return b};a.prototype.decode=function(a,c){c=c||-1;for(var d=a.offset,e=new this.built;a.offset<d+c||-1==c&&0<a.remaining();){var f=a.readVarint32(),h=f&7,f=f>>3,m=this.getChild(f);if(!m)throw Error("Illegal field id in "+this.toString(!0)+"#decode: "+f);m.repeated&&!m.options.packed?e.add(m.name,m.decode(h,a)):e.set(m.name,
m.decode(h,a))}d=this.getChildren(b.Field);for(h=0;h<d.length;h++)if(d[h].required&&null===e[d[h].name])throw d=Error("Missing field "+d[h].toString(!0)+" in "+this.toString(!0)+"#decode"),d.msg=e,d;return e};b.Message=a;var d=function(a,c,b,d,e,h){f.call(this,a,d);this.required="required"==c;this.repeated="repeated"==c;this.type=b;this.id=e;this.options=h||{}};d.prototype=Object.create(f.prototype);d.prototype.verifyValue=function(a,b){b=b||!1;if(null===a){if(this.required)throw Error("Illegal value for "+
this.toString(!0)+": "+a+" (required)");return null}var d;if(this.repeated&&!b){a instanceof Array||(a=[a]);var f=[];for(d=0;d<a.length;d++)f.push(this.verifyValue(a[d],!0));return f}if(!this.repeated&&a instanceof Array)throw Error("Illegal value for "+this.toString(!0)+": "+a+" (no array expected)");if(this.type==c.TYPES.int32||this.type==c.TYPES.sint32||this.type==c.TYPES.sfixed32)return parseInt(a,10)|0;if(this.type==c.TYPES.uint32||this.type==c.TYPES.fixed32)return parseInt(a,10)>>>0;if(c.Long){if(this.type==
c.TYPES.int64||this.type==c.TYPES.sint64||this.type==c.TYPES.sfixed64)return!("object"==typeof a&&a instanceof c.Long)?c.Long.fromNumber(a,!1):a.unsigned?a.toSigned():a;if(this.type==c.TYPES.uint64||this.type==c.TYPES.fixed64)return!("object"==typeof a&&a instanceof c.Long)?c.Long.fromNumber(a,!0):a.unsigned?a:a.toUnsigned()}if(this.type==c.TYPES.bool)return!!a;if(this.type==c.TYPES["float"]||this.type==c.TYPES["double"])return parseFloat(a);if(this.type==c.TYPES.string)return""+a;if(this.type==c.TYPES.bytes)return"object"==
typeof a&&a instanceof n?a:n.wrap(a);if(this.type==c.TYPES["enum"]){f=this.resolvedType.getChildren(e.Value);for(d=0;d<f.length;d++)if(f[d].name==a||f[d].id==a)return f[d].id;throw Error("Illegal value for "+this.toString(!0)+": "+a+" (not a valid enum value)");}if(this.type==c.TYPES.message){if("object"!=typeof a)throw Error("Illegal value for "+this.toString(!0)+": "+a+" (object expected)");return a instanceof this.resolvedType.built?a:new this.resolvedType.built(a)}throw Error("[INTERNAL ERROR] Illegal value for "+
this.toString(!0)+": "+a+" (undefined type "+this.type+")");};d.prototype.encode=function(a,b){a=this.verifyValue(a);if(null==this.type||"object"!=typeof this.type)throw Error("[INTERNAL ERROR] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===a||this.repeated&&0==a.length)return b;try{if(this.repeated){var d;if(this.options.packed){b.writeVarint32(this.id<<3|c.WIRE_TYPES.LDELIM);b.ensureCapacity(b.offset+=1);var e=b.offset;for(d=0;d<a.length;d++)this.encodeValue(a[d],b);var f=b.offset-
e,h=n.calculateVarint32(f);if(1<h){var m=b.slice(e,b.offset),e=e+(h-1);b.offset=e;b.append(m)}b.writeVarint32(f,e-h)}else for(d=0;d<a.length;d++)b.writeVarint32(this.id<<3|this.type.wireType),this.encodeValue(a[d],b)}else b.writeVarint32(this.id<<3|this.type.wireType),this.encodeValue(a,b)}catch(p){throw b.littleEndian=le,Error("Illegal value for "+this.toString(!0)+": "+a+" ("+p+")");}return b};d.prototype.encodeValue=function(a,b){if(null!==a){if(this.type==c.TYPES.int32||this.type==c.TYPES.uint32)b.writeVarint32(a);
else if(this.type==c.TYPES.sint32)b.writeZigZagVarint32(a);else if(this.type==c.TYPES.fixed32)b.writeUint32(a);else if(this.type==c.TYPES.sfixed32)b.writeInt32(a);else if(this.type==c.TYPES.int64||this.type==c.TYPES.uint64)b.writeVarint64(a);else if(this.type==c.TYPES.sint64)b.writeZigZagVarint64(a);else if(this.type==c.TYPES.fixed64)b.writeUint64(a);else if(this.type==c.TYPES.sfixed64)b.writeInt64(a);else if(this.type==c.TYPES.bool)b.writeVarint32(a?1:0);else if(this.type==c.TYPES["enum"])b.writeVarint32(a);
else if(this.type==c.TYPES["float"])b.writeFloat32(a);else if(this.type==c.TYPES["double"])b.writeFloat64(a);else if(this.type==c.TYPES.string)b.writeVString(a);else if(this.type==c.TYPES.bytes)a.offset>a.length&&(b=b.clone().flip()),b.writeVarint32(a.remaining()),b.append(a);else if(this.type==c.TYPES.message){var d=(new n).LE();this.resolvedType.encode(a,d);b.writeVarint32(d.offset);b.append(d.flip())}else throw Error("[INTERNAL ERROR] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");
return b}};d.prototype.decode=function(a,b,d){if(a!=this.type.wireType&&(d||a!=c.WIRE_TYPES.LDELIM||!this.repeated))throw Error("Illegal wire type for field "+this.toString(!0)+": "+a+" ("+this.type.wireType+" expected)");if(a==c.WIRE_TYPES.LDELIM&&(this.repeated&&this.options.packed)&&!d){a=b.readVarint32();a=b.offset+a;for(d=[];b.offset<a;)d.push(this.decode(this.type.wireType,b,!0));return d}if(this.type==c.TYPES.int32)return b.readVarint32()|0;if(this.type==c.TYPES.uint32)return b.readVarint32()>>>
0;if(this.type==c.TYPES.sint32)return b.readZigZagVarint32()|0;if(this.type==c.TYPES.fixed32)return b.readUint32()>>>0;if(this.type==c.TYPES.sfixed32)return b.readInt32()|0;if(this.type==c.TYPES.int64)return b.readVarint64();if(this.type==c.TYPES.uint64)return b.readVarint64().toUnsigned();if(this.type==c.TYPES.sint64)return b.readZigZagVarint64();if(this.type==c.TYPES.fixed64)return b.readUint64();if(this.type==c.TYPES.sfixed64)return b.readInt64();if(this.type==c.TYPES.bool)return!!b.readVarint32();
if(this.type==c.TYPES["enum"])return b.readVarint32();if(this.type==c.TYPES["float"])return b.readFloat();if(this.type==c.TYPES["double"])return b.readDouble();if(this.type==c.TYPES.string)return b.readVString();if(this.type==c.TYPES.bytes)return a=b.readVarint32(),d=b.clone(),d.length=d.offset+a,b.offset+=a,d;if(this.type==c.TYPES.message)return a=b.readVarint32(),this.resolvedType.decode(b,a);throw Error("[INTERNAL ERROR] Illegal wire type for "+this.toString(!0)+": "+a);};b.Message.Field=d;var e=
function(a,b,c){h.call(this,a,b,c);this.built=null};e.prototype=Object.create(h.prototype);e.prototype.build=function(){for(var a={},b=this.getChildren(e.Value),c=0;c<b.length;c++)a[b[c].name]=b[c].id;Object.defineProperty&&Object.defineProperty(a,"$options",{value:this.buildOpt(),enumerable:!1,configurable:!1,writable:!1});return this.built=a};b.Enum=e;d=function(a,b,c){f.call(this,a,b);this.id=c};d.prototype=Object.create(f.prototype);b.Enum.Value=d;return b}(f);f.Builder=function(c,b,f){var h=
function(){this.ptr=this.ns=new f.Namespace(null,"");this.resolved=!1;this.result=null};h.prototype.reset=function(){this.ptr=this.ns};h.prototype.define=function(a,c){if("string"!=typeof a||!b.TYPEDEF.test(a))throw Error("Illegal package name: "+a);var e=a.split("."),g;for(g=0;g<e.length;g++)if(!b.NAME.test(e[g]))throw Error("Illegal package name: "+e[g]);for(g=0;g<e.length;g++)this.ptr.hasChild(e[g])||this.ptr.addChild(new f.Namespace(this.ptr,e[g],c)),this.ptr=this.ptr.getChild(e[g]);return this};
h.isValidMessage=function(a){if("string"!=typeof a.name||!b.NAME.test(a.name)||"undefined"!=typeof a.values)return!1;var c;if("undefined"!=typeof a.fields){if(!(a.fields instanceof Array))return console.log("3"),!1;var e=[],f;for(c=0;c<a.fields.length;c++){if(!h.isValidMessageField(a.fields[c]))return!1;f=parseInt(a.id,10);if(0<=e.indexOf(f))return!1;e.push(f)}}if("undefined"!=typeof a.enums){if(!(a.enums instanceof Array))return!1;for(c=0;c<a.enums.length;c++)if(!h.isValidEnum(a.enums[c]))return!1}if("undefined"!=
typeof a.messages){if(!(a.messages instanceof Array))return!1;for(c=0;c<a.messages.length;c++)if(!h.isValidMessage(a.messages[c]))return!1}return!0};h.isValidMessageField=function(a){if("string"!=typeof a.rule||"string"!=typeof a.name||"string"!=typeof a.type||"undefined"==typeof a.id||!b.RULE.test(a.rule)||!b.NAME.test(a.name)||!b.TYPEREF.test(a.type)||!b.ID.test(""+a.id))return!1;if("undefined"!=typeof a.options){if("object"!=typeof a.options)return!1;for(var c=Object.keys(a.options),e=0;e<c.length;e++)if(!b.NAME.test(c[e])||
"string"!=typeof a.options[c[e]]&&"number"!=typeof a.options[c[e]])return!1}return!0};h.isValidEnum=function(a){if("string"!=typeof a.name||!b.NAME.test(a.name)||"undefined"==typeof a.values||!(a.values instanceof Array)||0==a.values.length)return!1;for(var c=0;c<a.values.length;c++)if("object"!=typeof a.values[c]||"string"!=typeof a.values[c].name||"undefined"==typeof a.values[c].id||!b.NAME.test(a.values[c].name)||!b.ID.test(""+a.values[c].id))return!1;return!0};h.prototype.create=function(a){if(a&&
(a instanceof Array||(a=[a]),0!=a.length)){var c=[],e,g,k,l,n;for(c.push(a);0<c.length;){a=c.pop();if(a instanceof Array)for(;0<a.length;)if(e=a.shift(),h.isValidMessage(e)){g=new f.Message(this.ptr,e.name,e.options);if(e.fields&&0<e.fields.length)for(l=0;l<e.fields.length;l++){if(!h.isValidMessageField(e.fields[l]))throw Error("Not a valid message field definition in message "+g.name+": "+JSON.stringify(e.fields[l]));if(g.hasChild(e.fields[l].id))throw Error("Duplicate field id in message "+g.name+
": "+e.fields[l].id);if(e.fields[l].options){k=Object.keys(e.fields[l].options);for(n=0;n<k.length;n++){if(!b.NAME.test(k[n]))throw Error("Illegal field option name in message "+g.name+"#"+e.fields[l].name+": "+k[n]);if("string"!=typeof e.fields[l].options[k[n]]&&"number"!=typeof e.fields[l].options[k[n]])throw Error("Illegal field option value in message "+g.name+"#"+e.fields[l].name+"#"+k[n]+": "+e.fields[l].options[k[n]]);}}g.addChild(new f.Message.Field(g,e.fields[l].rule,e.fields[l].type,e.fields[l].name,
e.fields[l].id,e.fields[l].options))}k=[];if("undefined"!=typeof e.enums&&0<e.enums.length)for(l=0;l<e.enums.length;l++)k.push(e.enums[l]);if(e.messages&&0<e.messages.length)for(l=0;l<e.messages.length;l++)k.push(e.messages[l]);this.ptr.addChild(g);0<k.length&&(c.push(a),a=k,this.ptr=g)}else if(h.isValidEnum(e)){g=new f.Enum(this.ptr,e.name,e.options);for(l=0;l<e.values.length;l++)g.addChild(new f.Enum.Value(g,e.values[l].name,e.values[l].id));this.ptr.addChild(g)}else throw Error("Not a valid message or enum definition: "+
JSON.stringify(e));else throw Error("Not a valid namespace definition: "+JSON.stringify(a));this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this}};h.isValidImport=function(a){return!/google\/protobuf\//.test(a)};h.prototype["import"]=function(a,b){a["package"]&&this.define(a["package"],a.options);a.messages&&this.create(a.messages);this.reset();a["package"]&&this.define(a["package"],a.options);a.enums&&this.create(a.enums);this.reset();if(a.imports&&0<a.imports.length){if(!b)throw Error("Cannot determine import root: File name is unknown");
for(var e=b.replace(/[\/\\][^\/\\]*$/,""),f=0;f<a.imports.length;f++){var k=e+"/"+a.imports[f];if(/\.json$/i.test(k)){var l=c.Util.fetch(k);if(null===l)throw Error("Failed to import '"+k+"' in '"+b+"': File not found");this["import"](JSON.parse(l),k)}else if(h.isValidImport(k)){l=c.Util.fetch(k);if(null===l)throw Error("Failed to import '"+k+"' in '"+b+"': File not found");l=new c.DotProto.Parser(l+"");this["import"](l.parse(),k)}}}return this};h.prototype.resolveAll=function(){if(!(null==this.ptr||
"object"==typeof this.ptr.type)){if(this.ptr instanceof f.Namespace)for(var a=this.ptr.getChildren(),d=0;d<a.length;d++)this.ptr=a[d],this.resolveAll();else if(this.ptr instanceof f.Message.Field)if(b.TYPE.test(this.ptr.type))this.ptr.type=c.TYPES[this.ptr.type];else{if(!b.TYPEREF.test(this.ptr.type))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);a=this.ptr.parent.resolve(this.ptr.type);if(!a)throw Error("Unresolvable type reference in "+this.ptr.toString(!0)+": "+
this.ptr.type);this.ptr.resolvedType=a;if(a instanceof f.Enum)this.ptr.type=c.TYPES["enum"];else if(a instanceof f.Message)this.ptr.type=c.TYPES.message;else throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);}else if(!(this.ptr instanceof c.Reflect.Enum.Value))throw Error("Illegal object type in namespace: "+typeof this.ptr+":"+this.ptr);this.reset()}};h.prototype.build=function(a){this.reset();this.resolved||(this.resolveAll(),this.resolved=!0,this.result=null);null==
this.result&&(this.result=this.ns.build());if(a){a=a.split(".");for(var b=this.result,c=0;c<a.length;c++)if(b[a[c]])b=b[a[c]];else{b=null;break}return b}return this.result};h.prototype.toString=function(){return"Builder"};return h}(f,f.Lang,f.Reflect);f.protoFromString=function(c,b,m){"string"==typeof b&&(m=b,b=null);c=(new f.DotProto.Parser(c+"")).parse();b="object"==typeof b?b:new f.Builder;null!==c["package"]&&b.define(c["package"],c.options);b.create(c.messages);b.reset();null!==c["package"]&&
b.define(c["package"],c.options);b.create(c.enums);b.reset();if(m&&0<c.imports.length)b["import"]({imports:c.imports},m);b.resolveAll();b.build();return b};f.protoFromFile=function(c,b,m){if(b&&"object"==typeof b)m=b,b=null;else if(!b||"function"!=typeof b)b=null;if(b)f.Util.fetch(c,function(a){b(f.protoFromString(a,m,c))});else{var h=f.Util.fetch(c);return null!==h?f.protoFromString(h,m,c):null}};f.newBuilder=function(c,b){var m=new f.Builder;"undefined"!=typeof c&&m.define(c,b);return m};return f}
"undefined"!=typeof module&&module.exports?module.exports=q(require("bytebuffer")):"undefined"!=typeof define&&define.amd?define("ProtoBuf",["ByteBuffer"],q):(p.dcodeIO||(p.dcodeIO={}),p.dcodeIO.ProtoBuf=q(p.dcodeIO.ByteBuffer))})(this);

@@ -6,3 +6,3 @@ /*

*/
(function(p){function q(n){if(!n||!n.zigZagEncode32)throw Error("ProtoBuf.js requires ByteBuffer.js >=1.1.0: Get it at https://github.com/dcodeIO/ByteBuffer.js");var h={VERSION:"1.0.0-b5",WIRE_TYPES:{}};h.WIRE_TYPES.VARINT=0;h.WIRE_TYPES.BITS64=1;h.WIRE_TYPES.LDELIM=2;h.WIRE_TYPES.STARTGROUP=3;h.WIRE_TYPES.ENDGROUP=4;h.WIRE_TYPES.BITS32=5;h.TYPES={int32:{name:"int32",wireType:h.WIRE_TYPES.VARINT},uint32:{name:"uint32",wireType:h.WIRE_TYPES.VARINT},sint32:{name:"sint32",wireType:h.WIRE_TYPES.VARINT},
(function(p){function q(n){if(!n||!n.zigZagEncode32)throw Error("ProtoBuf.js requires ByteBuffer.js >=1.1.0: Get it at https://github.com/dcodeIO/ByteBuffer.js");var h={VERSION:"1.0.0-b6",WIRE_TYPES:{}};h.WIRE_TYPES.VARINT=0;h.WIRE_TYPES.BITS64=1;h.WIRE_TYPES.LDELIM=2;h.WIRE_TYPES.STARTGROUP=3;h.WIRE_TYPES.ENDGROUP=4;h.WIRE_TYPES.BITS32=5;h.TYPES={int32:{name:"int32",wireType:h.WIRE_TYPES.VARINT},uint32:{name:"uint32",wireType:h.WIRE_TYPES.VARINT},sint32:{name:"sint32",wireType:h.WIRE_TYPES.VARINT},
int64:{name:"int64",wireType:h.WIRE_TYPES.VARINT},uint64:{name:"uint64",wireType:h.WIRE_TYPES.VARINT},sint64:{name:"sint64",wireType:h.WIRE_TYPES.VARINT},bool:{name:"bool",wireType:h.WIRE_TYPES.VARINT},"double":{name:"double",wireType:h.WIRE_TYPES.BITS64},string:{name:"string",wireType:h.WIRE_TYPES.LDELIM},bytes:{name:"bytes",wireType:h.WIRE_TYPES.LDELIM},fixed32:{name:"fixed32",wireType:h.WIRE_TYPES.BITS32},sfixed32:{name:"sfixed32",wireType:h.WIRE_TYPES.BITS32},fixed64:{name:"fixed64",wireType:h.WIRE_TYPES.BITS64},

@@ -9,0 +9,0 @@ sfixed64:{name:"sfixed64",wireType:h.WIRE_TYPES.BITS64},"float":{name:"float",wireType:h.WIRE_TYPES.BITS32},"enum":{name:"enum",wireType:h.WIRE_TYPES.VARINT},message:{name:"message",wireType:h.WIRE_TYPES.LDELIM}};h.Long=n.Long;h.Util=function(){Object.create||(Object.create=function(d){function g(){}if(1<arguments.length)throw Error("Object.create implementation only accepts the first parameter.");g.prototype=d;return new g});var d={};d.IS_NODE=("undefined"==typeof window||!window.window)&&"function"==

![ProtoBuf.js - protobuf for JavaScript](https://raw.github.com/dcodeIO/ProtoBuf.js/master/ProtoBuf.png)
=====================================
A protobuf implementation on top of [ByteBuffer.js](https://github.com/dcodeIO/ByteBuffer.js) including a .proto parser,
reflection, message class building and simple encoding and decoding in plain JavaScript. No compilation step required,
works out of the box on .proto files. It's also used for the cross-platform multiplayer component in
[eSoccer](http://www.esoccer.me), an HTML5 game developed at [University of Applied Sciences Bonn](http://www.h-brs.de).
When working with binary data on the network level, Google's Protocol Buffers aka protobuf is probably the best tool for
the job as it supports putting together entire message and even sub-message structures assembled from a variety of
useful data types while still remaining extensible for future cases.
Unfortunately, Google's reference implementations are available for C and Java only. Because of this, some protobuf
implementations have popped up for JavaScript lately but most of them have some fundamental restrictions.
Some of them implement just a subset of protobuf's functionality while others require some level of cross-compilation
towards using Google's protoc. As a result I found myself compiling things that didn't work or, if they did, missing
features that I really need. **Fortunately, that's where ProtoBuf.js comes into play!**
**ProtoBuf.js** is a protobuf implementation on top of [ByteBuffer.js](https://github.com/dcodeIO/ByteBuffer.js) including
a .proto parser, reflection, message class building and simple encoding and decoding in plain JavaScript. There is no
compilation step required, it's super easy to use and it works out of the box on .proto files!
Usage
-----
In the process of ProtoBuf.js becoming mature, documentation had been extended to cover so many details, that it's best to
split it up to a few easy to grasp sections. So:
* Step 1: Become familar with [Google's Protocol Buffers (protobuf)](https://developers.google.com/protocol-buffers/docs/overview)
* Step 2: Head straight to our wiki for up to date [usage, examples and further documentation](https://github.com/dcodeIO/ProtoBuf.js/wiki)
* Step 3: Build something cool! :-)
Features

@@ -13,4 +31,4 @@ --------

* [RequireJS](http://requirejs.org/)/AMD compatible
* Shim compatible (include the script, then use `var ProtoBuf = dcodeIO.ProtoBuf;`)
* [node.js](http://nodejs.org) compatible, also available via [npm](https://npmjs.org/package/protobufjs)
* Browser compatible
* [Closure Compiler](https://developers.google.com/closure/compiler/) compatible (fully annotated, [externs](https://github.com/dcodeIO/ProtoBuf.js/tree/master/externs))

@@ -21,458 +39,14 @@ * Fully documented using [jsdoc3](https://github.com/jsdoc3/jsdoc)

* Small footprint (even smaller if you use a noparse build)
* proto2js command line tool
Builder
-------
Probably the core component of ProtoBuf.js. Resolves all type references, performs all the necessary checks and returns
ready to use classes. Can be created from a .proto file or from a JSON definition. The later does not even require the
.proto parser to be included ([see](https://github.com/dcodeIO/ProtoBuf.js#using-json-without-the-proto-parser)).
Documentation
-------------
* [Read our wiki](https://github.com/dcodeIO/ProtoBuf.js/wiki)
* [Read the API docs](http://htmlpreview.github.com/?http://github.com/dcodeIO/ProtoBuf.js/master/docs/ProtoBuf.html)
Install: `npm install protobufjs`
Tests [![Build Status](https://travis-ci.org/dcodeIO/ProtoBuf.js.png?branch=master)](https://travis-ci.org/dcodeIO/ProtoBuf.js)
------------------
* [View source](https://github.com/dcodeIO/ProtoBuf.js/blob/master/tests/suite.js)
* [View report](https://travis-ci.org/dcodeIO/ProtoBuf.js)
#### Using .proto files ####
Example: [tests/complex.proto](https://github.com/dcodeIO/ProtoBuf.js/tree/master/tests/complex.proto)
```javascript
var ProtoBuf = require("protobufjs");
var builder = ProtoBuf.protoFromFile("tests/complex.proto");
var Game = builder.build("Game");
var Car = Game.Cars.Car;
// Construct with arguments list in field order:
var car = new Car("Rusty", new Car.Vendor("Iron Inc.", new Car.Vendor.Address("US")), Car.Speed.SUPERFAST);
// OR: Construct with values from an object, implicit message creation (address) and enum values as strings:
var car = new Car({
"model": "Rusty",
"vendor": {
"name": "Iron Inc.",
"address": {
"country": "US"
}
},
"speed": "SUPERFAST" // also equivalent to "speed": 2
});
// OR: It's also possible to mix all of this!
// Afterwards, just encode your message:
var buffer = car.encode();
// And send it over the wire:
var socket = ...;
socket.send(buffer.toArrayBuffer());
// OR: Short...
socket.send(car.toArrayBuffer());
```
#### Putting multiple .proto files into a common namespace ####
Example: [tests/example1.proto](https://github.com/dcodeIO/ProtoBuf.js/tree/master/tests/example1.proto),
[tests/example2.proto](https://github.com/dcodeIO/ProtoBuf.js/tree/master/tests/example2.proto)
```javascript
var builder = ProtoBuf.protoFromFile("tests/example1.proto");
ProtoBuf.protoFromFile("tests/example2.proto", builder);
var root = builder.build();
var test1 = new root.Test1(123);
var test2 = new root.Test2("123");
...
```
#### Using JSON without the .proto parser ####
Example: [tests/complex.json](https://github.com/dcodeIO/ProtoBuf.js/tree/master/tests/complex.json)
```javascript
var ProtoBuf = require("protobufjs");
var builder = ProtoBuf.newBuilder(); // Alternatively:
builder.define("Game"); // var builder = ProtoBuf.newBuilder("Game");
builder.create([
{
"name": "Car",
"fields": [
{
"rule": "required",
"type": "string",
"name": "model",
"id": 1
},
...
],
"messages": [
{
"name": "Vendor",
"fields": ...,
},
...
],
"enums": [
{
"name": "Speed",
"values": [
{
"name": "FAST",
"id": 1
},
...
]
}
]
}
]);
var Game = builder.build("Game");
var Car = Game.Cars.Car;
... actually the same as above ...
```
When using JSON only, you can use [ProtoBuf.noparse.js](https://github.com/dcodeIO/ProtoBuf.js/blob/master/ProtoBuf.noparse.js)
/ [ProtoBuf.noparse.min.js](https://github.com/dcodeIO/ProtoBuf.js/blob/master/ProtoBuf.noparse.min.js) instead, which
do NOT include the `ProtoBuf.DotProto` package for parsing and are therefore even smaller.
Encoder / Decoder
-----------------
Built into all message classes. Just call `YourMessage#encode([buffer])` respectively `YourMessage.decode(buffer)`.
#### Encoding a message ####
```javascript
...
var YourMessage = builder.build("YourMessage");
var myMessage = new YourMessage(...);
var byteBuffer = myMessage.encode();
var buffer = byteBuffer.toArrayBuffer();
// OR: Short...
var buffer = myMessage.toArrayBuffer();
var socket = ...; // E.g. a WebSocket
socket.send(buffer);
```
#### Decoding from an ArrayBuffer/ByteBuffer ####
```javascript
...
var YourMessage = builder.build("YourMessage");
var buffer = ...; // E.g. a buffer received on a WebSocket
var myMessage = YourMessage.decode(buffer);
```
#### Handling truncated messages
If a message is missing a required field when decoding, the library will throw an `Error` that still contains the rest
of the decoded message as its `msg` property. Example:
```javascript
try {
var myMessage = YourMessage.decode(bufferWithMisstingRequiredField);
...
} catch (e) {
if (e.msg) { // Truncated
myMessage = e.msg; // Decoded message with missing required fields
...
} else { // General error
...
}
}
```
Command line utility
--------------------
It's also possible to transform .proto files into their JSON counterparts or to transform entire namespaces into
ready-to-use message classes and enum objects by using the `proto2js` command line utility.
```
Usage: proto2js protoFile [-class[=My.Package]|-commonjs[=My.Package]|-amd[=My.Package]] [-min] [> outFile]
Options:
-class[=My.Package] Creates the classes instead of just a JSON definition.
If you do not specify a package, the package
declaration from the .proto file is used instead.
-commonjs[=My.Package] Creates a CommonJS export instead of just a JSON def.
If you do not specify a package, the package
declaration from the .proto file is used instead.
-amd[=My.Package] Creates an AMD define instead of just a JSON def.
If you do not specify a package, the package
declaration from the .proto file is used instead.
-min Minifies the output.
```
So, to create a JSON definition from the [tests/complex.proto](https://github.com/dcodeIO/ProtoBuf.js/blob/master/tests/complex.proto)
file, run:
```bash
proto2js tests/complex.proto > tests/complex.json
```
Or to create classes/a CommonJS export/an AMD define for the entire `Game` namespace, run:
```bash
proto2js tests/complex.proto -class=Game > tests/complex.js
```
```bash
proto2js tests/complex.proto -commonjs=Game > tests/complex.js
# ^ The resulting code will implicitly call require("protobufjs");
```
```bash
proto2js tests/complex.proto -amd=Game.Cars > tests/complex.js
# ^ The resulting code will implicitly use ["ProtoBuf"] as its
# declared dependencies and "Game/Cars" as the module name
```
Parser
------
Only available in the full build (i.e. not in "noparse" builds). Compliant with the protobuf parser to the following extend:
* Required, optional, repeated and packed repeated fields:
```protobuf
message Test {
required int32 a = 1;
optional int32 b = 2 [default=100];
repeated int32 c = 3;
repeated int32 c = 4 [packed=true];
}
```
* Data types: int32, uint32, sint32, fixed32, sfixed32, int64, uint64, sint64, fixed64, sfixed64, bool, enum, string,
bytes, messages, embedded messages, float, double
```protobuf
message Test {
required int32 a = 1; // Varint encoded
required uint32 b = 2; // Varint encoded
required sint32 c = 3; // Varint zigzag encoded
required bool d = 4; // Varint encoded
enum Priority {
LOW = 1;
MEDIUM = 2;
HIGH = 3;
}
optional Priority e = 5 [default=MEDIUM]; // Varint encoded
required string f = 6; // Varint length delimited
required bytes g = 7; // Varint length delimited
required Embedded h = 8; // Varint length delimited
message Embedded {
repeated int32 a = 1; // Multiple tags
repeated int32 b = 2 [packed=true]; // One tag, length delimited
required sfixed32 c = 3; // Fixed 4 bytes int32
required fixed32 d = 4; // Fixed 4 bytes uint32
required float e = 5; // Fixed 4 bytes
required double f = 6; // Fixed 8 bytes
// Through ByteBuffer.js loaded with Long.js:
optional int64 g = 7; // Varint encoded
optional uint64 h = 8; // Varint encoded
optional sint64 i = 9; // Varint zigzag encoded
required sfixed64 j = 10; // Fixed 8 bytes int64
required fixed64 k = 11; // Fixed 8 bytes uint64
}
}
```
* Packages
```protobuf
package My.Game;
message Test {
...
}
message Test2 {
required My.Game.Test test = 1;
}
```
* Qualified and fully qualified name resolving:
```protobuf
package My.Game;
message Test {
...
enum Priority {
LOW = 1;
MEDIUM = 2;
HIGH = 3;
}
}
message Test2 {
required .My.Game.Test.Priority priority_fqn = 1 [default=LOW];
required Test.Priority priority_qn = 2 [default=MEDIUM];
}
```
* Options on all levels:
```protobuf
option toplevel_1 = 10;
option toplevel_2 = "Hello!";
message Test {
option inmessage = "World!";
optional int32 somenumber = 1 [default=123]; // Actually the only one used
}
```
Paranthesis around option names, like `option (inmessage) = ...` are ignored for compatibility with custom options.
Accessing arbitrary options on namespace objects emitted by a builder is also possible (requires an ECMAScript 5 /
Javascript 1.8.5 compatible environment, e.g. node.js or any modern browser):
```javascript
...
var root = builder.build();
console.log(root.$options); // { 'toplevel_1': 10, 'toplevel_2': 'Hello!' }
console.log(root.Test.$options); // { 'inmessage': 'World!' }
```
* Imports:
```protobuf
package My; // Not used by the following imports
import public "example1.proto"; // The "public" keyword is ignored
import "example2.proto";
message Test2 {
required Test1 test1 = 0; // Unique name
required .Test2 test2 = 1; // Duplicate name resolved absolutely
}
```
See also: [example1.proto](https://github.com/dcodeIO/ProtoBuf.js/tree/master/tests/example1.proto),
[example2.proto](https://github.com/dcodeIO/ProtoBuf.js/tree/master/tests/example2.proto)
```javascript
var builder = ProtoBuf.protoFromFile("tests/imports.proto");
var root = builder.build();
// root now contains:
// - .Test1
// - .Test2
// - .My.Test2 using .Test1 for field 'test1' and .Test2 for field 'test2'
```
**NOTE:** Importing .proto files is available in the full build (not in the noparse build) only. Importing the .json
counterpart of a .proto file (e.g. generated by proto2js) is supported regardless of the build you are using. Imports
are also always fetched *synchronously*, so it's a good idea to package everything into a single file when using it in
the browser.
* Extensions:
```protobuf
extend something {
...
}
```
```protobuf
import "google/protobuf/descriptor.proto";
```
These statements are actually simply ignored to make existing definitions compile fine. Low-level bootstrapping
is not required by ProtoBuf.js.
#### Not (yet) supported ####
* *Extensions* (what for?) and *services* (you roll your own, don't you?). If you need anything of this, please open an
issue and explain your exact requirements. It's just that I have no idea how to benefit from that and therefore I am
not sure how to design it.
#### Calling the parser on your own ####
```javascript
var ProtoBuf = require("protobufjs"),
fs = require("fs"),
util = require("util");
var parser = new ProtoBuf.DotProto.Parser(fs.readFileSync("tests/complex.proto"));
var ast = parser.parse();
console.log(util.inspect(ast, false, null, true));
```
CommonJS, AMD and browser (shim)
--------------------------------
#### node.js / CommonJS ####
```bash
npm install protobufjs
```
```javascript
var ProtoBuf = require("protobufjs");
...
```
#### RequireJS / AMD ####
Requires [ByteBuffer.js](http://github.com/dcodeIO/ByteBuffer.js). Optionally depends on [Long.js](https://github.com/dcodeIO/Long.js)
for long (int64) support. If you do not require long support, you can skip the Long.js config. [Require.js](http://requirejs.org/)
example:
```javascript
require.config({
...
"paths": {
"Long": "/path/to/Long.js",
"ByteBuffer": "/path/to/ByteBuffer.js",
"ProtoBuf": "/path/to/ProtoBuf.js"
},
...
});
require(["ProtoBuf"], function(ProtoBuf) {
...
});
```
Or as a module dependency:
```javascript
define("MyModule", ["ProtoBuf"], function(ProtoBuf) {
...
});
```
#### Browser (shim) ####
Requires [ByteBuffer.js](http://github.com/dcodeIO/ByteBuffer.js). Optionally depends on [Long.js](https://github.com/dcodeIO/Long.js)
for long (int64) support. If you do not require long support, you can skip the Long.js include.
```html
<script src="//raw.github.com/dcodeIO/Long.js/master/Long.min.js"></script>
<script src="//raw.github.com/dcodeIO/ByteBuffer.js/master/ByteBuffer.min.js"></script>
<script src="//raw.github.com/dcodeIO/ProtoBuf.js/master/ProtoBuf.min.js"></script>
```
```javascript
var ProtoBuf = dcodeIO.ProtoBuf;
...
```
On long (int64) support
-----------------------
Full 64bit support is available since 0.10.0 and requires ByteBuffer.js >=1.2.3 with Long.js >=1.1.2.
* [See also](https://github.com/dcodeIO/ByteBuffer.js#on-long-int64-support)
On endianess before 0.11
--------------------------
Till 0.10, ProtoBuf.js mistakenly used big endian byte order when en-/decoding non-varint values as [reported by
bertdouglas](https://github.com/dcodeIO/ProtoBuf.js/pull/5). This has been corrected in 0.11.0. However, versions before
0.11 are now to consider **incompatible** with later versions when using non-varint values, so please upgrade to the
latest version to ensure compatibility with the official protobuf specification.
Downloads

@@ -483,17 +57,6 @@ ---------

Documentation
-------------
* [View documentation](http://htmlpreview.github.com/?http://github.com/dcodeIO/ProtoBuf.js/master/docs/ProtoBuf.html)
Tests (& Examples) [![Build Status](https://travis-ci.org/dcodeIO/ProtoBuf.js.png?branch=master)](https://travis-ci.org/dcodeIO/ProtoBuf.js)
------------------
* [View source](https://github.com/dcodeIO/ProtoBuf.js/blob/master/tests/suite.js)
* [View report](https://travis-ci.org/dcodeIO/ProtoBuf.js)
Contributors
------------
[Frank Xu](https://github.com/yyfrankyy), [Dretch](https://github.com/Dretch), [shirmin](https://github.com/shirmin)
[Daniel Wirtz](https://github.com/dcodeIO) (maintainer), [Frank Xu](https://github.com/yyfrankyy), [Dretch](https://github.com/Dretch), [shirmin](https://github.com/shirmin)
License
-------
Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.html
**License:** [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html)

@@ -268,2 +268,4 @@ // #ifdef UNDEFINED

} else if (token == Lang.CLOSE) {
token = this.tn.peek();
if (token == Lang.END) this.tn.next();
depth--;

@@ -321,2 +323,4 @@ if (depth == 0) {

if (token == Lang.CLOSE) {
token = this.tn.peek();
if (token == Lang.END) this.tn.next();
break;

@@ -480,2 +484,4 @@ } else if (Lang.RULE.test(token)) {

if (token == Lang.CLOSE) {
token = this.tn.peek();
if (token == Lang.END) this.tn.next();
break;

@@ -482,0 +488,0 @@ }

@@ -81,4 +81,4 @@ // #ifdef UNDEFINED

/**
* Gets the next token.
* @return {string} Token
* Gets the next token and advances by one.
* @return {?string} Token or `null` on EOF
* @throws {Error} If it's not a valid proto file

@@ -89,3 +89,3 @@ * @expose

if (this.stack.length > 0) {
return this.stack.pop();
return this.stack.shift();
}

@@ -151,2 +151,17 @@ if (this.index >= this.source.length) {

/**
* Peeks for the next token.
* @return {?string} Token or `null` on EOF
* @throws {Error} If it's not a valid proto file
* @expose
*/
Tokenizer.prototype.peek = function() {
if (this.stack.length == 0) {
var token = this.next();
if (token === null) return null;
this.stack.push(token);
}
return this.stack[0];
};
/**
* Returns a string representation of this object.

@@ -153,0 +168,0 @@ * @return {string} String representation as of "Tokenizer(index/length)"

@@ -222,3 +222,3 @@ /*

"numberformats": function(test) {
"numberFormats": function(test) {
try {

@@ -367,3 +367,3 @@ var builder = ProtoBuf.protoFromFile(__dirname+"/numberformats.proto");

"emptydefaultstring": function(test) {
"emptyDefaultString": function(test) {
try {

@@ -383,2 +383,14 @@ var builder = ProtoBuf.protoFromString("message Test1 { optional string test = 1 [default = \"\"]; }");

"trailingSemicolon": function(test) {
try {
var builder = ProtoBuf.protoFromString("message Test1 { optional string test = 1; };");
test.doesNotThrow(function() {
var Test1 = builder.build("Test1");
});
} catch (e) {
fail(e);
}
test.done();
},
"inner": {

@@ -546,3 +558,3 @@

// Builder reused to add definitions from multiple sources
"multibuilder": function(test) {
"multiBuilder": function(test) {
try {

@@ -653,3 +665,3 @@ var builder = ProtoBuf.protoFromFile(__dirname+"/example1.proto");

"x64_fixed": function(test) {
"x64Fixed": function(test) {
try {

@@ -685,3 +697,3 @@ var builder = ProtoBuf.protoFromFile(__dirname+"/x64.proto");

"x64_varint": function(test) {
"x64Varint": function(test) {
try {

@@ -754,3 +766,3 @@ var builder = ProtoBuf.protoFromFile(__dirname+"/x64.proto");

"imports-toplevel": function(test) {
"importsToplevel": function(test) {
try {

@@ -757,0 +769,0 @@ var builder = ProtoBuf.protoFromFile(__dirname+"/imports-toplevel.proto");

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc