Socket
Socket
Sign inDemoInstall

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-b4 to 1.0.0-b5

2

package.json
{
"name": "protobufjs",
"version": "1.0.0-b4",
"version": "1.0.0-b5",
"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,7 +6,7 @@ /*

*/
(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-b4",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-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},
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,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/,
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/,
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/,

@@ -55,8 +55,8 @@ 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<

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!1;var e=[],f;for(c=0;c<a.fields.length;c++){if(!h.isValidMessageField(a.fields[c]))return!1;
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])||!b.NUMBER.test(""+a.options[c[e]])&&!b.TYPEREF.test(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=
!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(!b.NUMBER.test(""+e.fields[l].options[k[n]])&&
!b.TYPEREF.test(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<
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)};

@@ -63,0 +63,0 @@ 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 '"+

@@ -6,13 +6,13 @@ /*

*/
(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-b4",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-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},
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},
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"==
typeof require;d.XHR=function(){for(var d=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],g=null,l=0;l<d.length;l++){try{g=d[l]()}catch(a){continue}break}if(!g)throw Error("XMLHttpRequest is not supported");return g};d.fetch=function(k,g){g&&"function"!=typeof g&&(g=null);if(d.IS_NODE)if(g)require("fs").readFile(k,function(a,d){a?g(null):g(""+
d)});else try{return require("fs").readFileSync(k)}catch(l){return null}else{var a=d.XHR();a.open("GET",k,g?!0:!1);a.setRequestHeader("User-Agent","XMLHTTP/1.0");a.setRequestHeader("Accept","text/plain");if(g)a.onreadystatechange=function(){4==a.readyState&&(200==a.status?g(a.responseText):g(null))},4!=a.readyState&&a.send(null);else return a.send(null),a.responseText}};return d}();h.Lang={OPEN:"{",CLOSE:"}",OPTOPEN:"[",OPTCLOSE:"]",OPTEND:",",EQUAL:"=",END:";",DELIM:/[\s\{\}=;\[\],"\(\)]/g,KEYWORD:/package|option|import|message|enum|extend|service|syntax|extensions/,
typeof require;d.XHR=function(){for(var d=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],g=null,k=0;k<d.length;k++){try{g=d[k]()}catch(a){continue}break}if(!g)throw Error("XMLHttpRequest is not supported");return g};d.fetch=function(l,g){g&&"function"!=typeof g&&(g=null);if(d.IS_NODE)if(g)require("fs").readFile(l,function(a,d){a?g(null):g(""+
d)});else try{return require("fs").readFileSync(l)}catch(k){return null}else{var a=d.XHR();a.open("GET",l,g?!0:!1);a.setRequestHeader("User-Agent","XMLHTTP/1.0");a.setRequestHeader("Accept","text/plain");if(g)a.onreadystatechange=function(){4==a.readyState&&(200==a.status?g(a.responseText):g(null))},4!=a.readyState&&a.send(null);else return a.send(null),a.responseText}};return d}();h.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:")"};h.Reflect=function(d){var k={},g=function(c,b){this.parent=c;this.name=b;this.resolvedType=null};g.prototype.toString=function(c){var b=this.name,e=this;do{e=e.parent;if(null==e)break;b=e.name+"."+b}while(1);c&&(this instanceof k.Message?b="Message "+b:this instanceof a.Field?b="Message.Field "+b:this instanceof f?b="Enum "+b:this instanceof f.Value?b="Enum.Value "+b:this instanceof l&&(b="Namespace "+b));
return b};g.prototype.build=function(){throw Error(this.toString(!0)+" cannot be built directly");};k.T=g;var l=function(c,b,e){g.call(this,c,b);this.children=[];this.options=e||{}};l.prototype=Object.create(g.prototype);l.prototype.getChildren=function(c){c=c||null;if(null==c)return this.children.slice();for(var b=[],e=0;e<this.children.length;e++)this.children[e]instanceof c&&b.push(this.children[e]);return b};l.prototype.addChild=function(c){if(this.hasChild(c.name))throw Error("Duplicate name in namespace "+
this.toString(!0)+": "+c.name);this.children.push(c)};l.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};l.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};l.prototype.resolve=function(c){var b=c.split("."),e=this,a=0;if(""==b[a]){for(;null!=e.parent;)e=e.parent;a++}do{do{e=e.getChild(b[a]);if(!e||!(e instanceof k.T)){e=null;break}a++}while(a<b.length);if(null!=e)break;if(null!==this.parent)return this.parent.resolve(c)}while(null!=e);return e};l.prototype.build=function(){for(var c={},b=this.getChildren(),e,a=0;a<b.length;a++)e=b[a],e instanceof l&&(c[e.name]=
e.build());Object.defineProperty&&Object.defineProperty(c,"$options",{value:this.buildOpt(),enumerable:!1,configurable:!1,writable:!1});return c};l.prototype.buildOpt=function(){for(var c={},b=Object.keys(this.options),e=0;e<b.length;e++)c[b[e]]=this.options[b[e]];return c};l.prototype.getOption=function(c){return"undefined"==typeof c?this.options:"undefined"!=typeof this.options[c]?this.options[c]:null};k.Namespace=l;var a=function(c,b,e){l.call(this,c,b,e);this.built=null};a.prototype=Object.create(l.prototype);
STRING:/"([^"\\]*(\\.[^"\\]*)*)"/g,STRINGOPEN:'"',STRINGCLOSE:'"',COPTOPEN:"(",COPTCLOSE:")"};h.Reflect=function(d){var l={},g=function(c,b){this.parent=c;this.name=b;this.resolvedType=null};g.prototype.toString=function(c){var b=this.name,e=this;do{e=e.parent;if(null==e)break;b=e.name+"."+b}while(1);c&&(this instanceof l.Message?b="Message "+b:this instanceof a.Field?b="Message.Field "+b:this instanceof f?b="Enum "+b:this instanceof f.Value?b="Enum.Value "+b:this instanceof k&&(b="Namespace "+b));
return b};g.prototype.build=function(){throw Error(this.toString(!0)+" cannot be built directly");};l.T=g;var k=function(c,b,e){g.call(this,c,b);this.children=[];this.options=e||{}};k.prototype=Object.create(g.prototype);k.prototype.getChildren=function(c){c=c||null;if(null==c)return this.children.slice();for(var b=[],e=0;e<this.children.length;e++)this.children[e]instanceof c&&b.push(this.children[e]);return b};k.prototype.addChild=function(c){if(this.hasChild(c.name))throw Error("Duplicate name in namespace "+
this.toString(!0)+": "+c.name);this.children.push(c)};k.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};k.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};k.prototype.resolve=function(c){var b=c.split("."),e=this,a=0;if(""==b[a]){for(;null!=e.parent;)e=e.parent;a++}do{do{e=e.getChild(b[a]);if(!e||!(e instanceof l.T)){e=null;break}a++}while(a<b.length);if(null!=e)break;if(null!==this.parent)return this.parent.resolve(c)}while(null!=e);return e};k.prototype.build=function(){for(var c={},b=this.getChildren(),e,a=0;a<b.length;a++)e=b[a],e instanceof k&&(c[e.name]=
e.build());Object.defineProperty&&Object.defineProperty(c,"$options",{value:this.buildOpt(),enumerable:!1,configurable:!1,writable:!1});return c};k.prototype.buildOpt=function(){for(var c={},b=Object.keys(this.options),e=0;e<b.length;e++)c[b[e]]=this.options[b[e]];return c};k.prototype.getOption=function(c){return"undefined"==typeof c?this.options:"undefined"!=typeof this.options[c]?this.options[c]:null};l.Namespace=k;var a=function(c,b,e){k.call(this,c,b,e);this.built=null};a.prototype=Object.create(k.prototype);
a.prototype.build=function(){for(var c=function(c,b){var e=b.getChildren(c.Message.Field),a=eval("0, (function "+b.name+"() { this.__construct.apply(this, arguments); })");a.prototype.__construct=function(c){var b,a;for(b=0;b<e.length;b++)a=e[b],this[a.name]=a.repeated?[]:null;for(b=0;b<e.length;b++)if(a=e[b],"undefined"!=typeof a.options["default"])try{this.set(a.name,a.options["default"])}catch(f){throw Error("[INTERNAL ERROR] "+f);}if(1==arguments.length&&"object"==typeof c&&"function"!=typeof c.encode&&

@@ -23,10 +23,10 @@ !(c instanceof Array)&&!(c instanceof n)&&!(c instanceof ArrayBuffer)&&!(d.Long&&c instanceof d.Long)){a=Object.keys(c);for(b=0;b<a.length;b++)this.set(a[b],c[a[b]])}else for(b=0;b<arguments.length;b++)b<e.length&&this.set(e[b].name,arguments[b])};a.prototype.add=function(a,e){var d=b.getChild(a);if(!d)throw Error(this+"#"+a+" is undefined");if(!(d instanceof c.Message.Field))throw Error(this+"#"+a+" is not a field: "+d.toString(!0));if(!d.repeated)throw Error(this+"#"+a+" is not a repeated field");

b.hasChild("get_"+d)||(a.prototype["get_"+d]=function(){return this.get(c.name)})})(e[f]);a.prototype.encode=function(c){c=c||new n;var a=c.littleEndian,e=b.encode(this,c.LE()).flip();c.littleEndian=a;return e};a.prototype.toArrayBuffer=function(){return this.encode().toArrayBuffer()};a.decode=function(c){c=c?c instanceof n?c:n.wrap(c):new n;var a=c.littleEndian,e=b.decode(c.LE());c.littleEndian=a;return e};a.prototype.toString=function(){return b.toString()};Object.defineProperty&&Object.defineProperty(a,
"$options",{value:b.buildOpt(),enumerable:!1,configurable:!1,writable:!1});return a}(k,this),b=this.getChildren(),e=0;e<b.length;e++)if(b[e]instanceof f)c[b[e].name]=b[e].build();else if(b[e]instanceof a)c[b[e].name]=b[e].build();else if(!(b[e]instanceof a.Field))throw Error("Illegal reflect child of "+this.toString(!0)+": "+b[e].toString(!0));return this.built=c};a.prototype.encode=function(c,b){for(var e=this.getChildren(a.Field),d=0;d<e.length;d++)e[d].encode(c.get(e[d].name),b);return b};a.prototype.decode=
function(c,b){b=b||-1;for(var a=c.offset,d=new this.built;c.offset<a+b||-1==b&&0<c.remaining();){var f=c.readVarint32(),m=f&7,f=f>>3,g=this.getChild(f);if(!g)throw Error("Illegal field id in "+this.toString(!0)+"#decode: "+f);g.repeated&&!g.options.packed?d.add(g.name,g.decode(m,c)):d.set(g.name,g.decode(m,c))}a=this.getChildren(k.Field);for(m=0;m<a.length;m++)if(a[m].required&&null===d[a[m].name])throw a=Error("Missing field "+a[m].toString(!0)+" in "+this.toString(!0)+"#decode"),a.msg=d,a;return d};
k.Message=a;var m=function(c,b,a,d,f,m){g.call(this,c,d);this.required="required"==b;this.repeated="repeated"==b;this.type=a;this.id=f;this.options=m||{}};m.prototype=Object.create(g.prototype);m.prototype.verifyValue=function(c,b){b=b||!1;if(null===c){if(this.required)throw Error("Illegal value for "+this.toString(!0)+": "+c+" (required)");return null}var a;if(this.repeated&&!b){c instanceof Array||(c=[c]);var m=[];for(a=0;a<c.length;a++)m.push(this.verifyValue(c[a],!0));return m}if(!this.repeated&&
"$options",{value:b.buildOpt(),enumerable:!1,configurable:!1,writable:!1});return a}(l,this),b=this.getChildren(),e=0;e<b.length;e++)if(b[e]instanceof f)c[b[e].name]=b[e].build();else if(b[e]instanceof a)c[b[e].name]=b[e].build();else if(!(b[e]instanceof a.Field))throw Error("Illegal reflect child of "+this.toString(!0)+": "+b[e].toString(!0));return this.built=c};a.prototype.encode=function(c,b){for(var e=this.getChildren(a.Field),d=0;d<e.length;d++)e[d].encode(c.get(e[d].name),b);return b};a.prototype.decode=
function(c,b){b=b||-1;for(var a=c.offset,d=new this.built;c.offset<a+b||-1==b&&0<c.remaining();){var f=c.readVarint32(),m=f&7,f=f>>3,g=this.getChild(f);if(!g)throw Error("Illegal field id in "+this.toString(!0)+"#decode: "+f);g.repeated&&!g.options.packed?d.add(g.name,g.decode(m,c)):d.set(g.name,g.decode(m,c))}a=this.getChildren(l.Field);for(m=0;m<a.length;m++)if(a[m].required&&null===d[a[m].name])throw a=Error("Missing field "+a[m].toString(!0)+" in "+this.toString(!0)+"#decode"),a.msg=d,a;return d};
l.Message=a;var m=function(c,b,a,d,f,m){g.call(this,c,d);this.required="required"==b;this.repeated="repeated"==b;this.type=a;this.id=f;this.options=m||{}};m.prototype=Object.create(g.prototype);m.prototype.verifyValue=function(c,b){b=b||!1;if(null===c){if(this.required)throw Error("Illegal value for "+this.toString(!0)+": "+c+" (required)");return null}var a;if(this.repeated&&!b){c instanceof Array||(c=[c]);var m=[];for(a=0;a<c.length;a++)m.push(this.verifyValue(c[a],!0));return m}if(!this.repeated&&
c instanceof Array)throw Error("Illegal value for "+this.toString(!0)+": "+c+" (no array expected)");if(this.type==d.TYPES.int32||this.type==d.TYPES.sint32||this.type==d.TYPES.sfixed32)return parseInt(c,10)|0;if(this.type==d.TYPES.uint32||this.type==d.TYPES.fixed32)return parseInt(c,10)>>>0;if(d.Long){if(this.type==d.TYPES.int64||this.type==d.TYPES.sint64||this.type==d.TYPES.sfixed64)return!("object"==typeof c&&c instanceof d.Long)?d.Long.fromNumber(c,!1):c.unsigned?c.toSigned():c;if(this.type==d.TYPES.uint64||
this.type==d.TYPES.fixed64)return!("object"==typeof c&&c instanceof d.Long)?d.Long.fromNumber(c,!0):c.unsigned?c:c.toUnsigned()}if(this.type==d.TYPES.bool)return!!c;if(this.type==d.TYPES["float"]||this.type==d.TYPES["double"])return parseFloat(c);if(this.type==d.TYPES.string)return""+c;if(this.type==d.TYPES.bytes)return"object"==typeof c&&c instanceof n?c:n.wrap(c);if(this.type==d.TYPES["enum"]){m=this.resolvedType.getChildren(f.Value);for(a=0;a<m.length;a++)if(m[a].name==c||m[a].id==c)return m[a].id;
throw Error("Illegal value for "+this.toString(!0)+": "+c+" (not a valid enum value)");}if(this.type==d.TYPES.message){if("object"!=typeof c)throw Error("Illegal value for "+this.toString(!0)+": "+c+" (object expected)");return c instanceof this.resolvedType.built?c:new this.resolvedType.built(c)}throw Error("[INTERNAL ERROR] Illegal value for "+this.toString(!0)+": "+c+" (undefined type "+this.type+")");};m.prototype.encode=function(c,b){c=this.verifyValue(c);if(null==this.type||"object"!=typeof this.type)throw Error("[INTERNAL ERROR] Unresolved type in "+
this.toString(!0)+": "+this.type);if(null===c||this.repeated&&0==c.length)return b;try{if(this.repeated){var a;if(this.options.packed){b.writeVarint32(this.id<<3|d.WIRE_TYPES.LDELIM);b.ensureCapacity(b.offset+=1);var f=b.offset;for(a=0;a<c.length;a++)this.encodeValue(c[a],b);var m=b.offset-f,g=n.calculateVarint32(m);if(1<g){var k=b.slice(f,b.offset),f=f+(g-1);b.offset=f;b.append(k)}b.writeVarint32(m,f-g)}else for(a=0;a<c.length;a++)b.writeVarint32(this.id<<3|this.type.wireType),this.encodeValue(c[a],
b)}else b.writeVarint32(this.id<<3|this.type.wireType),this.encodeValue(c,b)}catch(l){throw b.littleEndian=le,Error("Illegal value for "+this.toString(!0)+": "+c+" ("+l+")");}return b};m.prototype.encodeValue=function(c,b){if(null!==c){if(this.type==d.TYPES.int32||this.type==d.TYPES.uint32)b.writeVarint32(c);else if(this.type==d.TYPES.sint32)b.writeZigZagVarint32(c);else if(this.type==d.TYPES.fixed32)b.writeUint32(c);else if(this.type==d.TYPES.sfixed32)b.writeInt32(c);else if(this.type==d.TYPES.int64||
this.toString(!0)+": "+this.type);if(null===c||this.repeated&&0==c.length)return b;try{if(this.repeated){var a;if(this.options.packed){b.writeVarint32(this.id<<3|d.WIRE_TYPES.LDELIM);b.ensureCapacity(b.offset+=1);var f=b.offset;for(a=0;a<c.length;a++)this.encodeValue(c[a],b);var m=b.offset-f,g=n.calculateVarint32(m);if(1<g){var l=b.slice(f,b.offset),f=f+(g-1);b.offset=f;b.append(l)}b.writeVarint32(m,f-g)}else for(a=0;a<c.length;a++)b.writeVarint32(this.id<<3|this.type.wireType),this.encodeValue(c[a],
b)}else b.writeVarint32(this.id<<3|this.type.wireType),this.encodeValue(c,b)}catch(k){throw b.littleEndian=le,Error("Illegal value for "+this.toString(!0)+": "+c+" ("+k+")");}return b};m.prototype.encodeValue=function(c,b){if(null!==c){if(this.type==d.TYPES.int32||this.type==d.TYPES.uint32)b.writeVarint32(c);else if(this.type==d.TYPES.sint32)b.writeZigZagVarint32(c);else if(this.type==d.TYPES.fixed32)b.writeUint32(c);else if(this.type==d.TYPES.sfixed32)b.writeInt32(c);else if(this.type==d.TYPES.int64||
this.type==d.TYPES.uint64)b.writeVarint64(c);else if(this.type==d.TYPES.sint64)b.writeZigZagVarint64(c);else if(this.type==d.TYPES.fixed64)b.writeUint64(c);else if(this.type==d.TYPES.sfixed64)b.writeInt64(c);else if(this.type==d.TYPES.bool)b.writeVarint32(c?1:0);else if(this.type==d.TYPES["enum"])b.writeVarint32(c);else if(this.type==d.TYPES["float"])b.writeFloat32(c);else if(this.type==d.TYPES["double"])b.writeFloat64(c);else if(this.type==d.TYPES.string)b.writeVString(c);else if(this.type==d.TYPES.bytes)c.offset>

@@ -36,16 +36,16 @@ c.length&&(b=b.clone().flip()),b.writeVarint32(c.remaining()),b.append(c);else if(this.type==d.TYPES.message){var a=(new n).LE();this.resolvedType.encode(c,a);b.writeVarint32(a.offset);b.append(a.flip())}else throw Error("[INTERNAL ERROR] Illegal value to encode in "+this.toString(!0)+": "+c+" (unknown type)");return b}};m.prototype.decode=function(c,b,a){if(c!=this.type.wireType&&(a||c!=d.WIRE_TYPES.LDELIM||!this.repeated))throw Error("Illegal wire type for field "+this.toString(!0)+": "+c+" ("+

d.TYPES.int64)return b.readVarint64();if(this.type==d.TYPES.uint64)return b.readVarint64().toUnsigned();if(this.type==d.TYPES.sint64)return b.readZigZagVarint64();if(this.type==d.TYPES.fixed64)return b.readUint64();if(this.type==d.TYPES.sfixed64)return b.readInt64();if(this.type==d.TYPES.bool)return!!b.readVarint32();if(this.type==d.TYPES["enum"])return b.readVarint32();if(this.type==d.TYPES["float"])return b.readFloat();if(this.type==d.TYPES["double"])return b.readDouble();if(this.type==d.TYPES.string)return b.readVString();
if(this.type==d.TYPES.bytes)return c=b.readVarint32(),a=b.clone(),a.length=a.offset+c,b.offset+=c,a;if(this.type==d.TYPES.message)return c=b.readVarint32(),this.resolvedType.decode(b,c);throw Error("[INTERNAL ERROR] Illegal wire type for "+this.toString(!0)+": "+c);};k.Message.Field=m;var f=function(a,b,e){l.call(this,a,b,e);this.built=null};f.prototype=Object.create(l.prototype);f.prototype.build=function(){for(var a={},b=this.getChildren(f.Value),e=0;e<b.length;e++)a[b[e].name]=b[e].id;Object.defineProperty&&
Object.defineProperty(a,"$options",{value:this.buildOpt(),enumerable:!1,configurable:!1,writable:!1});return this.built=a};k.Enum=f;m=function(a,b,e){g.call(this,a,b);this.id=e};m.prototype=Object.create(g.prototype);k.Enum.Value=m;return k}(h);h.Builder=function(d,k,g){var l=function(){this.ptr=this.ns=new g.Namespace(null,"");this.resolved=!1;this.result=null};l.prototype.reset=function(){this.ptr=this.ns};l.prototype.define=function(a,d){if("string"!=typeof a||!k.TYPEDEF.test(a))throw Error("Illegal package name: "+
a);var f=a.split("."),c;for(c=0;c<f.length;c++)if(!k.NAME.test(f[c]))throw Error("Illegal package name: "+f[c]);for(c=0;c<f.length;c++)this.ptr.hasChild(f[c])||this.ptr.addChild(new g.Namespace(this.ptr,f[c],d)),this.ptr=this.ptr.getChild(f[c]);return this};l.isValidMessage=function(a){if("string"!=typeof a.name||!k.NAME.test(a.name)||"undefined"!=typeof a.values)return!1;var d;if("undefined"!=typeof a.fields){if(!(a.fields instanceof Array))return!1;var f=[],c;for(d=0;d<a.fields.length;d++){if(!l.isValidMessageField(a.fields[d]))return!1;
c=parseInt(a.id,10);if(0<=f.indexOf(c))return!1;f.push(c)}}if("undefined"!=typeof a.enums){if(!(a.enums instanceof Array))return!1;for(d=0;d<a.enums.length;d++)if(!l.isValidEnum(a.enums[d]))return!1}if("undefined"!=typeof a.messages){if(!(a.messages instanceof Array))return!1;for(d=0;d<a.messages.length;d++)if(!l.isValidMessage(a.messages[d]))return!1}return!0};l.isValidMessageField=function(a){if("string"!=typeof a.rule||"string"!=typeof a.name||"string"!=typeof a.type||"undefined"==typeof a.id||
!k.RULE.test(a.rule)||!k.NAME.test(a.name)||!k.TYPEREF.test(a.type)||!k.ID.test(""+a.id))return!1;if("undefined"!=typeof a.options){if("object"!=typeof a.options)return!1;for(var d=Object.keys(a.options),f=0;f<d.length;f++)if(!k.NAME.test(d[f])||!k.NUMBER.test(""+a.options[d[f]])&&!k.TYPEREF.test(a.options[d[f]]))return!1}return!0};l.isValidEnum=function(a){if("string"!=typeof a.name||!k.NAME.test(a.name)||"undefined"==typeof a.values||!(a.values instanceof Array)||0==a.values.length)return!1;for(var d=
0;d<a.values.length;d++)if("object"!=typeof a.values[d]||"string"!=typeof a.values[d].name||"undefined"==typeof a.values[d].id||!k.NAME.test(a.values[d].name)||!k.ID.test(""+a.values[d].id))return!1;return!0};l.prototype.create=function(a){if(a&&(a instanceof Array||(a=[a]),0!=a.length)){var d=[],f,c,b,e,h;for(d.push(a);0<d.length;){a=d.pop();if(a instanceof Array)for(;0<a.length;)if(f=a.shift(),l.isValidMessage(f)){c=new g.Message(this.ptr,f.name,f.options);if(f.fields&&0<f.fields.length)for(e=0;e<
f.fields.length;e++){if(!l.isValidMessageField(f.fields[e]))throw Error("Not a valid message field definition in message "+c.name+": "+JSON.stringify(f.fields[e]));if(c.hasChild(f.fields[e].id))throw Error("Duplicate field id in message "+c.name+": "+f.fields[e].id);if(f.fields[e].options){b=Object.keys(f.fields[e].options);for(h=0;h<b.length;h++){if(!k.NAME.test(b[h]))throw Error("Illegal field option name in message "+c.name+"#"+f.fields[e].name+": "+b[h]);if(!k.NUMBER.test(""+f.fields[e].options[b[h]])&&
!k.TYPEREF.test(f.fields[e].options[b[h]]))throw Error("Illegal field option value in message "+c.name+"#"+f.fields[e].name+"#"+b[h]+": "+f.fields[e].options[b[h]]);}}c.addChild(new g.Message.Field(c,f.fields[e].rule,f.fields[e].type,f.fields[e].name,f.fields[e].id,f.fields[e].options))}b=[];if("undefined"!=typeof f.enums&&0<f.enums.length)for(e=0;e<f.enums.length;e++)b.push(f.enums[e]);if(f.messages&&0<f.messages.length)for(e=0;e<f.messages.length;e++)b.push(f.messages[e]);this.ptr.addChild(c);0<
b.length&&(d.push(a),a=b,this.ptr=c)}else if(l.isValidEnum(f)){c=new g.Enum(this.ptr,f.name,f.options);for(e=0;e<f.values.length;e++)c.addChild(new g.Enum.Value(c,f.values[e].name,f.values[e].id));this.ptr.addChild(c)}else throw Error("Not a valid message or enum definition: "+JSON.stringify(f));else throw Error("Not a valid namespace definition: "+JSON.stringify(a));this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this}};l.isValidImport=function(a){return!/google\/protobuf\//.test(a)};
l.prototype["import"]=function(a,g){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(!g)throw Error("Cannot determine import root: File name is unknown");for(var f=g.replace(/[\/\\][^\/\\]*$/,""),c=0;c<a.imports.length;c++){var b=f+"/"+a.imports[c];if(/\.json$/i.test(b)){var e=d.Util.fetch(b);if(null===e)throw Error("Failed to import '"+
b+"' in '"+g+"': File not found");this["import"](JSON.parse(e),b)}else throw Error("This build of ProtoBuf.js does not include DotProto support. See: https://github.com/dcodeIO/ProtoBuf.js");}}return this};l.prototype.resolveAll=function(){if(!(null==this.ptr||"object"==typeof this.ptr.type)){if(this.ptr instanceof g.Namespace)for(var a=this.ptr.getChildren(),h=0;h<a.length;h++)this.ptr=a[h],this.resolveAll();else if(this.ptr instanceof g.Message.Field)if(k.TYPE.test(this.ptr.type))this.ptr.type=
d.TYPES[this.ptr.type];else{if(!k.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 g.Enum)this.ptr.type=d.TYPES["enum"];else if(a instanceof g.Message)this.ptr.type=d.TYPES.message;else throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);
}else if(!(this.ptr instanceof d.Reflect.Enum.Value))throw Error("Illegal object type in namespace: "+typeof this.ptr+":"+this.ptr);this.reset()}};l.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 d=this.result,f=0;f<a.length;f++)if(d[a[f]])d=d[a[f]];else{d=null;break}return d}return this.result};l.prototype.toString=function(){return"Builder"};return l}(h,h.Lang,
h.Reflect);h.protoFromString=function(d,h,g){throw Error("This build of ProtoBuf.js does not include DotProto support. See: https://github.com/dcodeIO/ProtoBuf.js");};h.protoFromFile=function(d,k,g){if(k&&"object"==typeof k)g=k,k=null;else if(!k||"function"!=typeof k)k=null;if(k)h.Util.fetch(d,function(a){k(h.protoFromString(a,g,d))});else{var l=h.Util.fetch(d);return null!==l?h.protoFromString(l,g,d):null}};h.newBuilder=function(d,k){var g=new h.Builder;"undefined"!=typeof d&&g.define(d,k);return g};
if(this.type==d.TYPES.bytes)return c=b.readVarint32(),a=b.clone(),a.length=a.offset+c,b.offset+=c,a;if(this.type==d.TYPES.message)return c=b.readVarint32(),this.resolvedType.decode(b,c);throw Error("[INTERNAL ERROR] Illegal wire type for "+this.toString(!0)+": "+c);};l.Message.Field=m;var f=function(a,b,e){k.call(this,a,b,e);this.built=null};f.prototype=Object.create(k.prototype);f.prototype.build=function(){for(var a={},b=this.getChildren(f.Value),e=0;e<b.length;e++)a[b[e].name]=b[e].id;Object.defineProperty&&
Object.defineProperty(a,"$options",{value:this.buildOpt(),enumerable:!1,configurable:!1,writable:!1});return this.built=a};l.Enum=f;m=function(a,b,e){g.call(this,a,b);this.id=e};m.prototype=Object.create(g.prototype);l.Enum.Value=m;return l}(h);h.Builder=function(d,l,g){var k=function(){this.ptr=this.ns=new g.Namespace(null,"");this.resolved=!1;this.result=null};k.prototype.reset=function(){this.ptr=this.ns};k.prototype.define=function(a,d){if("string"!=typeof a||!l.TYPEDEF.test(a))throw Error("Illegal package name: "+
a);var f=a.split("."),c;for(c=0;c<f.length;c++)if(!l.NAME.test(f[c]))throw Error("Illegal package name: "+f[c]);for(c=0;c<f.length;c++)this.ptr.hasChild(f[c])||this.ptr.addChild(new g.Namespace(this.ptr,f[c],d)),this.ptr=this.ptr.getChild(f[c]);return this};k.isValidMessage=function(a){if("string"!=typeof a.name||!l.NAME.test(a.name)||"undefined"!=typeof a.values)return!1;var d;if("undefined"!=typeof a.fields){if(!(a.fields instanceof Array))return console.log("3"),!1;var f=[],c;for(d=0;d<a.fields.length;d++){if(!k.isValidMessageField(a.fields[d]))return!1;
c=parseInt(a.id,10);if(0<=f.indexOf(c))return!1;f.push(c)}}if("undefined"!=typeof a.enums){if(!(a.enums instanceof Array))return!1;for(d=0;d<a.enums.length;d++)if(!k.isValidEnum(a.enums[d]))return!1}if("undefined"!=typeof a.messages){if(!(a.messages instanceof Array))return!1;for(d=0;d<a.messages.length;d++)if(!k.isValidMessage(a.messages[d]))return!1}return!0};k.isValidMessageField=function(a){if("string"!=typeof a.rule||"string"!=typeof a.name||"string"!=typeof a.type||"undefined"==typeof a.id||
!l.RULE.test(a.rule)||!l.NAME.test(a.name)||!l.TYPEREF.test(a.type)||!l.ID.test(""+a.id))return!1;if("undefined"!=typeof a.options){if("object"!=typeof a.options)return!1;for(var d=Object.keys(a.options),f=0;f<d.length;f++)if(!l.NAME.test(d[f])||"string"!=typeof a.options[d[f]]&&"number"!=typeof a.options[d[f]])return!1}return!0};k.isValidEnum=function(a){if("string"!=typeof a.name||!l.NAME.test(a.name)||"undefined"==typeof a.values||!(a.values instanceof Array)||0==a.values.length)return!1;for(var d=
0;d<a.values.length;d++)if("object"!=typeof a.values[d]||"string"!=typeof a.values[d].name||"undefined"==typeof a.values[d].id||!l.NAME.test(a.values[d].name)||!l.ID.test(""+a.values[d].id))return!1;return!0};k.prototype.create=function(a){if(a&&(a instanceof Array||(a=[a]),0!=a.length)){var d=[],f,c,b,e,h;for(d.push(a);0<d.length;){a=d.pop();if(a instanceof Array)for(;0<a.length;)if(f=a.shift(),k.isValidMessage(f)){c=new g.Message(this.ptr,f.name,f.options);if(f.fields&&0<f.fields.length)for(e=0;e<
f.fields.length;e++){if(!k.isValidMessageField(f.fields[e]))throw Error("Not a valid message field definition in message "+c.name+": "+JSON.stringify(f.fields[e]));if(c.hasChild(f.fields[e].id))throw Error("Duplicate field id in message "+c.name+": "+f.fields[e].id);if(f.fields[e].options){b=Object.keys(f.fields[e].options);for(h=0;h<b.length;h++){if(!l.NAME.test(b[h]))throw Error("Illegal field option name in message "+c.name+"#"+f.fields[e].name+": "+b[h]);if("string"!=typeof f.fields[e].options[b[h]]&&
"number"!=typeof f.fields[e].options[b[h]])throw Error("Illegal field option value in message "+c.name+"#"+f.fields[e].name+"#"+b[h]+": "+f.fields[e].options[b[h]]);}}c.addChild(new g.Message.Field(c,f.fields[e].rule,f.fields[e].type,f.fields[e].name,f.fields[e].id,f.fields[e].options))}b=[];if("undefined"!=typeof f.enums&&0<f.enums.length)for(e=0;e<f.enums.length;e++)b.push(f.enums[e]);if(f.messages&&0<f.messages.length)for(e=0;e<f.messages.length;e++)b.push(f.messages[e]);this.ptr.addChild(c);0<
b.length&&(d.push(a),a=b,this.ptr=c)}else if(k.isValidEnum(f)){c=new g.Enum(this.ptr,f.name,f.options);for(e=0;e<f.values.length;e++)c.addChild(new g.Enum.Value(c,f.values[e].name,f.values[e].id));this.ptr.addChild(c)}else throw Error("Not a valid message or enum definition: "+JSON.stringify(f));else throw Error("Not a valid namespace definition: "+JSON.stringify(a));this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this}};k.isValidImport=function(a){return!/google\/protobuf\//.test(a)};
k.prototype["import"]=function(a,g){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(!g)throw Error("Cannot determine import root: File name is unknown");for(var f=g.replace(/[\/\\][^\/\\]*$/,""),c=0;c<a.imports.length;c++){var b=f+"/"+a.imports[c];if(/\.json$/i.test(b)){var e=d.Util.fetch(b);if(null===e)throw Error("Failed to import '"+
b+"' in '"+g+"': File not found");this["import"](JSON.parse(e),b)}else throw Error("This build of ProtoBuf.js does not include DotProto support. See: https://github.com/dcodeIO/ProtoBuf.js");}}return this};k.prototype.resolveAll=function(){if(!(null==this.ptr||"object"==typeof this.ptr.type)){if(this.ptr instanceof g.Namespace)for(var a=this.ptr.getChildren(),h=0;h<a.length;h++)this.ptr=a[h],this.resolveAll();else if(this.ptr instanceof g.Message.Field)if(l.TYPE.test(this.ptr.type))this.ptr.type=
d.TYPES[this.ptr.type];else{if(!l.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 g.Enum)this.ptr.type=d.TYPES["enum"];else if(a instanceof g.Message)this.ptr.type=d.TYPES.message;else throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);
}else if(!(this.ptr instanceof d.Reflect.Enum.Value))throw Error("Illegal object type in namespace: "+typeof this.ptr+":"+this.ptr);this.reset()}};k.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 d=this.result,f=0;f<a.length;f++)if(d[a[f]])d=d[a[f]];else{d=null;break}return d}return this.result};k.prototype.toString=function(){return"Builder"};return k}(h,h.Lang,
h.Reflect);h.protoFromString=function(d,h,g){throw Error("This build of ProtoBuf.js does not include DotProto support. See: https://github.com/dcodeIO/ProtoBuf.js");};h.protoFromFile=function(d,l,g){if(l&&"object"==typeof l)g=l,l=null;else if(!l||"function"!=typeof l)l=null;if(l)h.Util.fetch(d,function(a){l(h.protoFromString(a,g,d))});else{var k=h.Util.fetch(d);return null!==k?h.protoFromString(k,g,d):null}};h.newBuilder=function(d,l){var g=new h.Builder;"undefined"!=typeof d&&g.define(d,l);return g};
return h}"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);

@@ -116,2 +116,3 @@ // #ifdef UNDEFINED

if (!(def["fields"] instanceof Array)) {
console.log("3");
return false;

@@ -174,6 +175,6 @@ }

}
// Options are <string,number|typeref>
// Options are <string,*>
var keys = Object.keys(def["options"]);
for (var i=0; i<keys.length; i++) {
if (!Lang.NAME.test(keys[i]) || (!Lang.NUMBER.test(""+def["options"][keys[i]]) && !Lang.TYPEREF.test(def["options"][keys[i]]))) {
if (!Lang.NAME.test(keys[i]) || (typeof def["options"][keys[i]] != 'string' && typeof def["options"][keys[i]] != 'number')) {
return false;

@@ -257,3 +258,3 @@ }

}
if (!Lang.NUMBER.test(""+def["fields"][i]["options"][subObj[j]]) && !Lang.TYPEREF.test(def["fields"][i]["options"][subObj[j]])) {
if (typeof def["fields"][i]["options"][subObj[j]] != 'string' && typeof def["fields"][i]["options"][subObj[j]] != 'number') {
throw(new Error("Illegal field option value in message "+obj.name+"#"+def["fields"][i]["name"]+"#"+subObj[j]+": "+def["fields"][i]["options"][subObj[j]]));

@@ -260,0 +261,0 @@ }

@@ -384,3 +384,3 @@ // #ifdef UNDEFINED

/**
* Parses a set of field option defintions.
* Parses a set of field option definitions.
* @param {Object} msg Message definition

@@ -387,0 +387,0 @@ * @param {Object} fld Field definition

@@ -366,2 +366,17 @@ /*

"emptydefaultstring": function(test) {
try {
var builder = ProtoBuf.protoFromString("message Test1 { optional string test = 1 [default = \"\"]; }");
var Test1;
test.doesNotThrow(function() {
Test1 = builder.build("Test1");
});
var test1 = new Test1();
test.strictEqual(test1.test, "");
} catch (e) {
fail(e);
}
test.done();
},
"inner": {

@@ -368,0 +383,0 @@

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

Sorry, the diff of this file is not supported yet

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