diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ffc56c26..2f1bf03c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/ea7ba8b83890084d61012cb5386dc11dadfb3908) Fixed release links in README files
## New -[:hash:](https://github.com/dcodeIO/protobuf.js/commit/9078a37fbf7bff8ba829d979073e3df91f1bcfc5) Updated non-bundled common google types folder with field_mask, source_context, type and wrappers
+[:hash:](https://github.com/dcodeIO/protobuf.js/commit/aed134aa1cd7edd801de77c736cf5efe6fa61cb0) Updated non-bundled google types folder with missing descriptors and added wrappers to core
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/0b0de2458a1ade1ccd4ceb789697be13290f856b) Replaced the ieee754 implementation for old browsers with a faster, use-case specific one + simple test case
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/99ad9cc08721b834a197d4bbb67fa152d7ad79aa) Added .create to statically generated types and uppercase nested elements to reflection namespaces, see [#576](https://github.com/dcodeIO/protobuf.js/issues/576)
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/99ad9cc08721b834a197d4bbb67fa152d7ad79aa) Also added Namespace#getEnum for completeness, see [#576](https://github.com/dcodeIO/protobuf.js/issues/576)
diff --git a/dist/protobuf.js b/dist/protobuf.js index 041aa045d..2459a1491 100644 --- a/dist/protobuf.js +++ b/dist/protobuf.js @@ -1,7 +1,7 @@ /*! * protobuf.js v6.3.0 (c) 2016, Daniel Wirtz - * Compiled Tue, 20 Dec 2016 23:35:43 UTC - * Licensed under the BSD-3-Clause license + * Compiled Wed, 21 Dec 2016 00:40:56 UTC + * Licensed under the BSD-3-Clause License * see: https://github.com/dcodeIO/protobuf.js for details */ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o1&&"="===t.charAt(e);)++n;return Math.ceil(3*t.length)/4-n};for(var i=new Array(64),s=new Array(123),o=0;o<64;)s[i[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;r.encode=function(t,e,n){for(var r,s=[],o=0,u=0;e>2],r=(3&a)<<4,u=1;break;case 1:s[o++]=i[r|a>>4],r=(15&a)<<2,u=2;break;case 2:s[o++]=i[r|a>>6],s[o++]=i[63&a],u=0}}return u&&(s[o++]=i[r],s[o]=61,1===u&&(s[o+1]=61)),String.fromCharCode.apply(String,s)};var u="invalid encoding";r.decode=function(t,e,n){for(var r,i=n,o=0,a=0;a1)break;if(void 0===(f=s[f]))throw Error(u);switch(o){case 0:r=f,o=1;break;case 1:e[n++]=r<<2|(48&f)>>4,r=f,o=2;break;case 2:e[n++]=(15&r)<<4|(60&f)>>2,r=f,o=3;break;case 3:e[n++]=(3&r)<<6|f,o=0}}if(1===o)throw Error(u);return n-i}},{}],3:[function(t,e,n){"use strict";function r(){function t(){for(var e=[],n=0;n ").replace(/\t/g," "));var s=Object.keys(n||(n={}));return Function.apply(null,s.concat("return "+i)).apply(null,s.map(function(t){return n[t]}))}for(var l=[],h=[],c=1,d=!1,p=0;p0?e.splice(--s,2):n?e.splice(s,1):++s:"."===e[s]?e.splice(s,1):++s;return r+e.join("/")};r.resolve=function(t,e,n){return n||(e=s(e)),i(e)?e:(n||(t=s(t)),(t=t.replace(/(?:\/|^)[^\/]+$/,"")).length?s(t+"/"+e):e)}},{}],9:[function(t,e,n){"use strict";function r(t,e,n){var r=n||8192,i=r>>>1,s=null,o=r;return function(n){if(n<1||n>i)return t(n);o+n>r&&(s=t(r),o=0);var u=e.call(s,o,o+=n);return 7&o&&(o=(7|o)+1),u}}e.exports=r},{}],10:[function(t,e,n){"use strict";var r=n;r.length=function(t){for(var e=0,n=0,r=0;r191&&i<224?o[u++]=(31&i)<<6|63&t[e++]:i>239&&i<365?(i=((7&i)<<18|(63&t[e++])<<12|(63&t[e++])<<6|63&t[e++])-65536,o[u++]=55296+(i>>10),o[u++]=56320+(1023&i)):o[u++]=(15&i)<<12|(63&t[e++])<<6|63&t[e++],u>8191&&(s.push(String.fromCharCode.apply(String,o)),u=0);return u&&s.push(String.fromCharCode.apply(String,o.slice(0,u))),s.join("")},r.write=function(t,e,n){for(var r,i,s=n,o=0;o>6|192,e[n++]=63&r|128):55296===(64512&r)&&56320===(64512&(i=t.charCodeAt(o+1)))?(r=65536+((1023&r)<<10)+(1023&i),++o,e[n++]=r>>18|240,e[n++]=r>>12&63|128,e[n++]=r>>6&63|128,e[n++]=63&r|128):(e[n++]=r>>12|224,e[n++]=r>>6&63|128,e[n++]=63&r|128);return n-s}},{}],11:[function(t,e,n){"use strict";function r(t){return i(t)}function i(e,n){if(s||(s=t(31)),!(e instanceof s))throw a("type","a Type");if(n){if("function"!=typeof n)throw a("ctor","a function")}else n=function(t){return function(e){t.call(this,e)}}(o);n.constructor=r;var i=n.prototype=new o;return i.constructor=n,u.merge(n,o,!0),n.$type=e,i.$type=e,e.getFieldsArray().forEach(function(t){i[t.name]=Array.isArray(t.resolve().defaultValue)?u.emptyArray:u.isObject(t.defaultValue)?u.emptyObject:t.defaultValue}),e.getOneofsArray().forEach(function(t){u.prop(i,t.resolve().name,{get:function(){for(var e=Object.keys(this),n=e.length-1;n>-1;--n)if(t.oneof.indexOf(e[n])>-1)return e[n]},set:function(e){for(var n=t.oneof,r=0;r>>3){");for(var r=0;r>>0,(e.id<<3|4)>>>0):i||e.required?t("types[%d].encode(%s,w.uint32(%d).fork()).ldelim()",n,r,(e.id<<3|2)>>>0):t("types[%d].encode(%s,w.fork()).len&&w.ldelim(%d)||w.reset()",n,r,e.id)}function i(t){for(var e,n=t.getFieldsArray(),i=t.getOneofsArray(),f=u.codegen("m","w")("w||(w=Writer.create())"),e=0;e>>0,8|o.mapKey[p],p),void 0===c?f("types[%d].encode(m%s[ks[i]],w.uint32(18).fork()).ldelim()",e,d):f("w.uint32(%d).%s(m%s[ks[i]])",16|c,h,d),f("w.ldelim()")("}")("}")}else l.repeated?l.packed&&void 0!==o.packed[h]?f("if(m%s&&m%s.length){",d,d)("w.uint32(%d).fork()",(l.id<<3|2)>>>0)("for(var i=0;i>>0,h,d)):l.partOf||(l.required||(l.long?f("if(m%s!==undefined&&util.longNe(m%s,%d,%d))",d,d,l.defaultValue.low,l.defaultValue.high):f("if(m%s!==undefined&&m%s!==%j)",d,d,l.defaultValue)),void 0===c?r(f,l,e,"m"+d):f("w.uint32(%d).%s(m%s)",(l.id<<3|c)>>>0,h,d))}for(var e=0;e>>0,h,d),f("break;")}f("}")}return f("return w")}e.exports=i;var s=t(15),o=t(32),u=t(33),a=u.safeProp},{15:15,32:32,33:33}],15:[function(t,e,n){"use strict";function r(t,e,n){s.call(this,t,n),this.values=e||{},this.c=null}function i(t){return t.c=null,t}e.exports=r;var s=t(21),o=s.extend(r);r.className="Enum";var u=t(33),a=u.b;u.props(o,{valuesById:{get:function(){return this.c||(this.c={},Object.keys(this.values).forEach(function(t){var e=this.values[t];if(this.c[e])throw Error("duplicate id "+e+" in "+this);this.c[e]=t},this)),this.c}}}),r.testJSON=function(t){return Boolean(t&&t.values)},r.fromJSON=function(t,e){return new r(t,e.values,e.options)},o.toJSON=function(){return{options:this.options,values:this.values}},o.add=function(t,e){if(!u.isString(t))throw a("name");if(!u.isInteger(e)||e<0)throw a("id","a non-negative integer");if(void 0!==this.values[t])throw Error("duplicate name '"+t+"' in "+this);if(void 0!==this.getValuesById()[e])throw Error("duplicate id "+e+" in "+this);return this.values[t]=e,i(this)},o.remove=function(t){if(!u.isString(t))throw a("name");if(void 0===this.values[t])throw Error("'"+t+"' is not a name of "+this);return delete this.values[t],i(this)}},{21:21,33:33}],16:[function(t,e,n){"use strict";function r(t,e,n,r,s,o){if(h.isObject(r)?(o=r,r=s=void 0):h.isObject(s)&&(o=s,s=void 0),i.call(this,t,o),!h.isInteger(e)||e<0)throw c("id","a non-negative integer");if(!h.isString(n))throw c("type");if(void 0!==s&&!h.isString(s))throw c("extend");if(void 0!==r&&!/^required|optional|repeated$/.test(r=r.toString().toLowerCase()))throw c("rule","a valid rule string");this.rule=r&&"optional"!==r?r:void 0,this.type=n,this.id=e,this.extend=s||void 0,this.required="required"===r,this.optional=!this.required,this.repeated="repeated"===r,this.map=!1,this.message=null,this.partOf=null,this.defaultValue=null,this.long=!!h.Long&&void 0!==l.long[n],this.bytes="bytes"===n,this.resolvedType=null,this.extensionField=null,this.declaringField=null,this.d=null}e.exports=r;var i=t(21),s=i.extend(r);r.className="Field";var o,u,a=t(18),f=t(15),l=t(32),h=t(33),c=h.b;h.props(s,{packed:{get:s.isPacked=function(){return null===this.d&&(this.d=this.getOption("packed")!==!1),this.d}}}),s.setOption=function(t,e,n){return"packed"===t&&(this.d=null),i.prototype.setOption.call(this,t,e,n)},r.testJSON=function(t){return Boolean(t&&void 0!==t.id)},r.fromJSON=function(e,n){return void 0!==n.keyType?(u||(u=t(17)),u.fromJSON(e,n)):new r(e,n.id,n.type,n.rule,n.extend,n.options)},s.toJSON=function(){return{rule:"optional"!==this.rule&&this.rule||void 0,type:this.type,id:this.id,extend:this.extend,options:this.options}},s.resolve=function(){if(this.resolved)return this;var e=l.defaults[this.type];if(void 0===e)if(o||(o=t(31)),this.resolvedType=this.parent.lookup(this.type,o))e=null;else{if(!(this.resolvedType=this.parent.lookup(this.type,f)))throw Error("unresolvable field type: "+this.type);e=0}var n;return this.map?this.defaultValue={}:this.repeated?this.defaultValue=[]:this.options&&void 0!==(n=this.options.default)?this.defaultValue=n:this.defaultValue=e,this.long&&(this.defaultValue=h.Long.fromValue(this.defaultValue)),i.prototype.resolve.call(this)},s.jsonConvert=function(t,e){if(e){if(t instanceof a)return t.asJSON(e);if(this.resolvedType instanceof f&&e.enum===String)return this.resolvedType.getValuesById()[t];if(e.long&&this.long)return e.long===Number?"number"==typeof t?t:h.LongBits.from(t).toNumber("u"===this.type.charAt(0)):h.Long.fromValue(t,"u"===this.type.charAt(0)).toString();if(e.bytes&&this.bytes){if(e.bytes===String)return h.base64.encode(t,0,t.length);if(e.bytes===Array)return Array.prototype.slice.call(t);if(e.bytes===h.Buffer&&!h.Buffer.isBuffer(t))return h.Buffer.from?h.Buffer.from(t):new h.Buffer(t)}}return t}},{15:15,17:17,18:18,21:21,31:31,32:32,33:33}],17:[function(t,e,n){"use strict";function r(t,e,n,r,s){if(i.call(this,t,e,r,s),!a.isString(n))throw a.b("keyType");this.keyType=n,this.resolvedKeyType=null,this.map=!0}e.exports=r;var i=t(16),s=i.prototype,o=i.extend(r);r.className="MapField";var u=t(32),a=t(33);r.testJSON=function(t){return i.testJSON(t)&&void 0!==t.keyType},r.fromJSON=function(t,e){return new r(t,e.id,e.keyType,e.type,e.options)},o.toJSON=function(){return{keyType:this.keyType,type:this.type,id:this.id,extend:this.extend,options:this.options}},o.resolve=function(){if(this.resolved)return this;if(void 0===u.mapKey[this.keyType])throw Error("invalid key type: "+this.keyType);return s.resolve.call(this)}},{16:16,32:32,33:33}],18:[function(t,e,n){"use strict";function r(t){if(t)for(var e=Object.keys(t),n=0;n0;){var r=t.shift();if(n.nested&&n.nested[r]){if(n=n.nested[r],!(n instanceof i))throw Error("path conflicts with non-namespace objects")}else n.add(n=new i(r))}return e&&n.addJSON(e),n},a.resolve=function(){f||(f=t(31)),l||(f=t(29));for(var e=this.getNestedArray(),n=0;n-1&&this.oneof.splice(e,1),t.parent&&t.parent.remove(t),t.partOf=null,this},o.onAdd=function(t){s.prototype.onAdd.call(this,t),i(this)},o.onRemove=function(t){this.i.forEach(function(t){t.parent&&t.parent.remove(t)}),s.prototype.onRemove.call(this,t)}},{16:16,21:21,33:33}],23:[function(t,e,n){"use strict";function r(t){return/^[a-zA-Z_][a-zA-Z_0-9]*$/.test(t)}function i(t){return/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)+$/.test(t)}function s(t){return/^(?:\.[a-zA-Z][a-zA-Z_0-9]*)+$/.test(t)}function o(t){return null===t?null:t.toLowerCase()}function u(t,e,n){function b(t,e){var n=u.filename;return u.filename=null,Error("illegal "+(e||"token")+" '"+t+"' ("+(n?n+", ":"")+"line "+Z.line()+")")}function w(){var t,e=[];do{if('"'!==(t=K())&&"'"!==t)throw b(t);e.push(K()),G(t),t=X()}while('"'===t||"'"===t);return e.join("")}function k(t){var e=K();switch(o(e)){case"'":case'"':return W(e),w();case"true":return!0;case"false":return!1}try{return O(e)}catch(n){if(t&&i(e))return e;throw b(e,"value")}}function x(){var t=N(K()),e=t;return G("to",!0)&&(e=N(K())),G(";"),[t,e]}function O(t){var e=1;"-"===t.charAt(0)&&(e=-1,t=t.substring(1));var n=o(t);switch(n){case"inf":return e*(1/0);case"nan":return NaN;case"0":return 0}if(/^[1-9][0-9]*$/.test(t))return e*parseInt(t,10);if(/^0[x][0-9a-f]+$/.test(n))return e*parseInt(t,16);if(/^0[0-7]+$/.test(t))return e*parseInt(t,8);if(/^(?!e)[0-9]*(?:\.[0-9]*)?(?:[e][+-]?[0-9]+)?$/.test(n))return e*parseFloat(t);throw b(t,"number")}function N(t,e){var n=o(t);switch(n){case"max":return 536870911;case"0":return 0}if("-"===t.charAt(0)&&!e)throw b(t,"id");if(/^-?[1-9][0-9]*$/.test(t))return parseInt(t,10);if(/^-?0[x][0-9a-f]+$/.test(n))return parseInt(t,16);if(/^-?0[0-7]+$/.test(t))return parseInt(t,8);throw b(t,"id")}function A(){if(void 0!==D)throw b("package");if(D=K(),!i(D))throw b(D,"name");et=et.define(D),G(";")}function S(){var t,e=X();switch(e){case"weak":t=_||(_=[]),K();break;case"public":K();default:t=P||(P=[])}e=w(),G(";"),t.push(e)}function j(){if(G("="),H=o(w()),Y="proto3"===H,!Y&&"proto2"!==H)throw b(H,"syntax");G(";")}function T(t,e){switch(e){case"option":return $(t,e),G(";"),!0;case"message":return E(t,e),!0;case"enum":return V(t,e),!0;case"service":return R(t,e),!0;case"extend":return U(t,e),!0}return!1}function E(t,e){var n=K();if(!r(n))throw b(n,"type name");var s=new l(n);if(G("{",!0)){for(;"}"!==(e=K());){var u=o(e);if(!T(s,e))switch(u){case"map":J(s,u);break;case"required":case"optional":case"repeated":F(s,u);break;case"oneof":q(s,u);break;case"extensions":(s.extensions||(s.extensions=[])).push(x(s,u));break;case"reserved":(s.reserved||(s.reserved=[])).push(x(s,u));break;default:if(!Y||!i(e))throw b(e);W(e),F(s,"optional")}}G(";",!0)}else G(";");t.add(s)}function F(t,e,n){var s=K();if("group"===o(s))return void B(t,e);if(!i(s))throw b(s,"type");var u=K();if(!r(u))throw b(u,"name");u=nt(u),G("=");var a=N(K()),f=C(new h(u,a,s,e,n));f.repeated&&void 0!==m.packed[s]&&!Y&&f.setOption("packed",!1,!0),t.add(f)}function B(t,e){var n=K();if(!r(n))throw b(n,"name");var i=g.lcFirst(n);n===i&&(n=g.ucFirst(n)),G("=");var s=N(K()),u=new l(n);u.group=!0;var a=new h(i,s,n,e);for(G("{");"}"!==(tt=K());)switch(tt=o(tt)){case"option":$(u,tt),G(";");break;case"required":case"optional":case"repeated":F(u,tt);break;default:throw b(tt)}G(";",!0),t.add(u).add(a)}function J(t){G("<");var e=K();if(void 0===m.mapKey[e])throw b(e,"type");G(",");var n=K();if(!i(n))throw b(n,"type");G(">");var s=K();if(!r(s))throw b(s,"name");s=nt(s),G("=");var o=N(K()),u=C(new c(s,o,e,n));t.add(u)}function q(t,e){var n=K();if(!r(n))throw b(n,"name");n=nt(n);var i=new d(n);if(G("{",!0)){for(;"}"!==(e=K());)"option"===e?($(i,e),G(";")):(W(e),F(i,"optional"));G(";",!0)}else G(";");t.add(i)}function V(t,e){var n=K();if(!r(n))throw b(n,"name");var i={},s=new p(n,i);if(G("{",!0)){for(;"}"!==(e=K());)"option"===o(e)?($(s,e),G(";")):L(s,e);G(";",!0)}else G(";");t.add(s)}function L(t,e){if(!r(e))throw b(e,"name");var n=e;G("=");var i=N(K(),!0);t.values[n]=i,C({})}function $(t,e){var n=G("(",!0),r=K();if(!i(r))throw b(r,"name");n&&(G(")"),r="("+r+")",e=X(),s(e)||(r+=e,K())),G("="),z(t,r)}function z(t,e){if(G("{",!0))for(;"}"!==(tt=K());){if(!r(tt))throw b(tt,"name");e=e+"."+tt,G(":",!0)?I(t,e,k(!0)):z(t,e)}else I(t,e,k(!0))}function I(t,e,n){t.setOption?t.setOption(e,n):t[e]=n}function C(t){if(G("[",!0)){do $(t,"option");while(G(",",!0));G("]")}return G(";"),t}function R(t,e){if(e=K(),!r(e))throw b(e,"service name");var n=e,i=new v(n);if(G("{",!0)){for(;"}"!==(e=K());){var s=o(e);switch(s){case"option":$(i,s),G(";");break;case"rpc":M(i,s);break;default:throw b(e)}}G(";",!0)}else G(";");t.add(i)}function M(t,e){var n=e,s=K();if(!r(s))throw b(s,"name");var u,a,f,l;G("(");var h;if(G(h="stream",!0)&&(a=!0),!i(e=K()))throw b(e);if(u=e,G(")"),G("returns"),G("("),G(h,!0)&&(l=!0),!i(e=K()))throw b(e);f=e,G(")");var c=new y(s,n,u,f,a,l);if(G("{",!0)){for(;"}"!==(e=K());){var d=o(e);switch(d){case"option":$(c,d),G(";");break;default:throw b(e)}}G(";",!0)}else G(";");t.add(c)}function U(t,e){var n=K();if(!i(n))throw b(n,"reference");if(G("{",!0)){for(;"}"!==(e=K());){var r=o(e);switch(r){case"required":case"repeated":case"optional":F(t,r,n);break;default:if(!Y||!i(e))throw b(e);W(e),F(t,"optional",n)}}G(";",!0)}else G(";")}e instanceof f?n||(n={}):(e=new f,n=e||{});var D,P,_,H,Z=a(t),K=Z.next,W=Z.push,X=Z.peek,G=Z.skip,Q=!0,Y=!1;e||(e=new f);for(var tt,et=e,nt=n.keepCase?function(t){return t}:g.camelCase;null!==(tt=K());){var rt=o(tt);switch(rt){case"package":if(!Q)throw b(tt);A();break;case"import":if(!Q)throw b(tt);S();break;case"syntax":if(!Q)throw b(tt);j();break;case"option":if(!Q)throw b(tt);$(et,tt),G(";");break;default:if(T(et,tt)){Q=!1;continue}throw b(tt)}}return u.filename=null,{package:D,imports:P,weakImports:_,syntax:H,root:e}}e.exports=u;var a=t(30),f=t(26),l=t(31),h=t(16),c=t(17),d=t(22),p=t(15),v=t(29),y=t(19),m=t(32),g=t(33)},{15:15,16:16,17:17,19:19,22:22,26:26,29:29,30:30,31:31,32:32,33:33}],24:[function(t,e,n){"use strict";function r(t,e){return RangeError("index out of range: "+t.pos+" + "+(e||1)+" > "+t.len)}function i(t){this.buf=t,this.pos=0,this.len=t.length}function s(){var t=new k(0,0),e=0;if(this.len-this.pos>4){for(e=0;e<4;++e)if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*e)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(127&this.buf[this.pos])<<28)>>>0,t.hi=(t.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return t}else{for(e=0;e<4;++e){if(this.pos>=this.len)throw r(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*e)>>>0,this.buf[this.pos++]<128)return t}if(this.pos>=this.len)throw r(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<28)>>>0,t.hi=(t.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return t}if(this.len-this.pos>4){for(e=0;e<5;++e)if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*e+3)>>>0,this.buf[this.pos++]<128)return t}else for(e=0;e<5;++e){if(this.pos>=this.len)throw r(this);if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*e+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}function o(){return s.call(this).toLong()}function u(){return s.call(this).toNumber()}function a(){return s.call(this).toLong(!0)}function f(){return s.call(this).toNumber(!0)}function l(){return s.call(this).zzDecode().toLong()}function h(){return s.call(this).zzDecode().toNumber()}function c(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}function d(){if(this.pos+8>this.len)throw r(this,8);return new k(c(this.buf,this.pos+=4),c(this.buf,this.pos+=4))}function p(){return d.call(this).toLong(!0)}function v(){return d.call(this).toNumber(!0)}function y(){return d.call(this).zzDecode().toLong()}function m(){return d.call(this).zzDecode().toNumber()}function g(){w.Long?(N.int64=o,N.uint64=a,N.sint64=l,N.fixed64=p,N.sfixed64=y):(N.int64=u,N.uint64=f,N.sint64=h,N.fixed64=v,N.sfixed64=m)}e.exports=i;var b,w=t(35),k=w.LongBits,x=w.utf8,O="undefined"!=typeof Uint8Array?Uint8Array:Array; diff --git a/dist/protobuf.min.js.gz b/dist/protobuf.min.js.gz index 1e5eb81ac..49e93690b 100644 Binary files a/dist/protobuf.min.js.gz and b/dist/protobuf.min.js.gz differ diff --git a/dist/runtime/protobuf.js b/dist/runtime/protobuf.js index 58335a094..5b60093c9 100644 --- a/dist/runtime/protobuf.js +++ b/dist/runtime/protobuf.js @@ -1,7 +1,7 @@ /*! * protobuf.js v6.3.0 (c) 2016, Daniel Wirtz - * Compiled Tue, 20 Dec 2016 23:35:43 UTC - * Licensed under the BSD-3-Clause license + * Compiled Wed, 21 Dec 2016 00:40:56 UTC + * Licensed under the BSD-3-Clause License * see: https://github.com/dcodeIO/protobuf.js for details */ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o1&&"="===t.charAt(i);)++n;return Math.ceil(3*t.length)/4-n};for(var e=new Array(64),o=new Array(123),s=0;s<64;)o[e[s]=s<26?s+65:s<52?s+71:s<62?s-4:s-59|43]=s++;r.encode=function(t,i,n){for(var r,o=[],s=0,u=0;i>2],r=(3&h)<<4,u=1;break;case 1:o[s++]=e[r|h>>4],r=(15&h)<<2,u=2;break;case 2:o[s++]=e[r|h>>6],o[s++]=e[63&h],u=0}}return u&&(o[s++]=e[r],o[s]=61,1===u&&(o[s+1]=61)),String.fromCharCode.apply(String,o)};var u="invalid encoding";r.decode=function(t,i,n){for(var r,e=n,s=0,h=0;h1)break;if(void 0===(f=o[f]))throw Error(u);switch(s){case 0:r=f,s=1;break;case 1:i[n++]=r<<2|(48&f)>>4,r=f,s=2;break;case 2:i[n++]=(15&r)<<4|(60&f)>>2,r=f,s=3;break;case 3:i[n++]=(3&r)<<6|f,s=0}}if(1===s)throw Error(u);return n-e}},{}],2:[function(require,module,exports){"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(t){}return null}module.exports=inquire},{}],3:[function(t,i,n){"use strict";function r(t,i,n){var r=n||8192,e=r>>>1,o=null,s=r;return function(n){if(n<1||n>e)return t(n);s+n>r&&(o=t(r),s=0);var u=i.call(o,s,s+=n);return 7&s&&(s=(7|s)+1),u}}i.exports=r},{}],4:[function(t,i,n){"use strict";var r=n;r.length=function(t){for(var i=0,n=0,r=0;r191&&e<224?s[u++]=(31&e)<<6|63&t[i++]:e>239&&e<365?(e=((7&e)<<18|(63&t[i++])<<12|(63&t[i++])<<6|63&t[i++])-65536,s[u++]=55296+(e>>10),s[u++]=56320+(1023&e)):s[u++]=(15&e)<<12|(63&t[i++])<<6|63&t[i++],u>8191&&(o.push(String.fromCharCode.apply(String,s)),u=0);return u&&o.push(String.fromCharCode.apply(String,s.slice(0,u))),o.join("")},r.write=function(t,i,n){for(var r,e,o=n,s=0;s>6|192,i[n++]=63&r|128):55296===(64512&r)&&56320===(64512&(e=t.charCodeAt(s+1)))?(r=65536+((1023&r)<<10)+(1023&e),++s,i[n++]=r>>18|240,i[n++]=r>>12&63|128,i[n++]=r>>6&63|128,i[n++]=63&r|128):(i[n++]=r>>12|224,i[n++]=r>>6&63|128,i[n++]=63&r|128);return n-o}},{}],5:[function(t,i,n){function r(){Reader.a()}var e=n;e.Writer=t(10),e.BufferWriter=t(11),e.Reader=t(6),e.BufferReader=t(7),e.util=t(9),e.roots={},e.configure=r,"function"==typeof define&&define.amd&&define(["long"],function(t){return t&&(e.util.Long=t,r()),e})},{10:10,11:11,6:6,7:7,9:9}],6:[function(t,i,n){"use strict";function r(t,i){return RangeError("index out of range: "+t.pos+" + "+(i||1)+" > "+t.len)}function e(t){this.buf=t,this.pos=0,this.len=t.length}function o(){var t=new x(0,0),i=0;if(this.len-this.pos>4){for(i=0;i<4;++i)if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*i)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(127&this.buf[this.pos])<<28)>>>0,t.hi=(t.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return t}else{for(i=0;i<4;++i){if(this.pos>=this.len)throw r(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*i)>>>0,this.buf[this.pos++]<128)return t}if(this.pos>=this.len)throw r(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<28)>>>0,t.hi=(t.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return t}if(this.len-this.pos>4){for(i=0;i<5;++i)if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*i+3)>>>0,this.buf[this.pos++]<128)return t}else for(i=0;i<5;++i){if(this.pos>=this.len)throw r(this);if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*i+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}function s(){return o.call(this).toLong()}function u(){return o.call(this).toNumber()}function h(){return o.call(this).toLong(!0)}function f(){return o.call(this).toNumber(!0)}function a(){return o.call(this).zzDecode().toLong()}function c(){return o.call(this).zzDecode().toNumber()}function l(t,i){return(t[i-4]|t[i-3]<<8|t[i-2]<<16|t[i-1]<<24)>>>0}function p(){if(this.pos+8>this.len)throw r(this,8);return new x(l(this.buf,this.pos+=4),l(this.buf,this.pos+=4))}function d(){return p.call(this).toLong(!0)}function b(){return p.call(this).toNumber(!0)}function g(){return p.call(this).zzDecode().toLong()}function v(){return p.call(this).zzDecode().toNumber()}function y(){m.Long?(L.int64=s,L.uint64=h,L.sint64=a,L.fixed64=d,L.sfixed64=g):(L.int64=u,L.uint64=f,L.sint64=c,L.fixed64=b,L.sfixed64=v)}i.exports=e;var w,m=t(9),x=m.LongBits,N=m.utf8,A="undefined"!=typeof Uint8Array?Uint8Array:Array;e.create=m.Buffer?function(i){return w||(w=t(7)),(e.create=function(t){return new w(t)})(i)}:function(t){return new e(t)};var L=e.prototype;L.b=A.prototype.subarray||A.prototype.slice,L.uint32=function(){var t=4294967295;return function(){if(t=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return t;if(t=(t|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return t;if(t=(t|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return t;if(t=(t|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return t;if(t=(t|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return t;if((this.pos+=5)>this.len)throw this.pos=this.len,r(this,10);return t}}(),L.int32=function(){return 0|this.uint32()},L.sint32=function(){var t=this.uint32();return t>>>1^-(1&t)|0},L.bool=function(){return 0!==this.uint32()},L.fixed32=function(){if(this.pos+4>this.len)throw r(this,4);return l(this.buf,this.pos+=4)},L.sfixed32=function(){var t=this.fixed32();return t>>>1^-(1&t)};var B="undefined"!=typeof Float32Array?function(){var t=new Float32Array(1),i=new Uint8Array(t.buffer);return t[0]=-0,i[3]?function(n,r){return i[0]=n[r],i[1]=n[r+1],i[2]=n[r+2],i[3]=n[r+3],t[0]}:function(n,r){return i[3]=n[r],i[2]=n[r+1],i[1]=n[r+2],i[0]=n[r+3],t[0]}}():function(t,i){var n=l(t,i+4),r=2*(n>>31)+1,e=n>>>23&255,o=8388607&n;return 255===e?o?NaN:r*(1/0):0===e?1.401298464324817e-45*r*o:r*Math.pow(2,e-150)*(o+8388608)};L.float=function(){if(this.pos+4>this.len)throw r(this,4);var t=B(this.buf,this.pos);return this.pos+=4,t};var z="undefined"!=typeof Float64Array?function(){var t=new Float64Array(1),i=new Uint8Array(t.buffer);return t[0]=-0,i[7]?function(n,r){return i[0]=n[r],i[1]=n[r+1],i[2]=n[r+2],i[3]=n[r+3],i[4]=n[r+4],i[5]=n[r+5],i[6]=n[r+6],i[7]=n[r+7],t[0]}:function(n,r){return i[7]=n[r],i[6]=n[r+1],i[5]=n[r+2],i[4]=n[r+3],i[3]=n[r+4],i[2]=n[r+5],i[1]=n[r+6],i[0]=n[r+7],t[0]}}():function(t,i){var n=l(t,i+4),r=l(t,i+8),e=2*(r>>31)+1,o=r>>>20&2047,s=4294967296*(1048575&r)+n;return 2047===o?s?NaN:e*(1/0):0===o?5e-324*e*s:e*Math.pow(2,o-1075)*(s+4503599627370496)};L.double=function(){if(this.pos+8>this.len)throw r(this,4);var t=z(this.buf,this.pos);return this.pos+=8,t},L.bytes=function(){var t=this.uint32(),i=this.pos,n=this.pos+t;if(n>this.len)throw r(this,t);return this.pos+=t,i===n?new this.buf.constructor(0):this.b.call(this.buf,i,n)},L.string=function(){var t=this.bytes();return N.read(t,0,t.length)},L.skip=function(t){if("number"==typeof t){if(this.pos+t>this.len)throw r(this,t);this.pos+=t}else do if(this.pos>=this.len)throw r(this);while(128&this.buf[this.pos++]);return this},L.skipType=function(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;;){if(4===(t=7&this.uint32()))break;this.skipType(t)}break;case 5:this.skip(4);break;default:throw Error("invalid wire type: "+t)}return this},e.a=y,y()},{7:7,9:9}],7:[function(t,i,n){"use strict";function r(t){e.call(this,t)}i.exports=r;var e=t(6),o=r.prototype=Object.create(e.prototype);o.constructor=r;var s=t(9);s.Buffer&&(o.b=s.Buffer.prototype.slice),o.string=function(){var t=this.uint32();return this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len))}},{6:6,9:9}],8:[function(t,i,n){"use strict";function r(t,i){this.lo=t,this.hi=i}i.exports=r;var e=t(9),o=r.prototype,s=r.zero=new r(0,0);s.toNumber=function(){return 0},s.zzEncode=s.zzDecode=function(){return this},s.length=function(){return 1},r.fromNumber=function(t){if(0===t)return s;var i=t<0;t=Math.abs(t);var n=t>>>0,e=(t-n)/4294967296>>>0;return i&&(e=~e>>>0,n=~n>>>0,++n>4294967295&&(n=0,++e>4294967295&&(e=0))),new r(n,e)},r.from=function(t){if("number"==typeof t)return r.fromNumber(t);if("string"==typeof t){if(!e.Long)return r.fromNumber(parseInt(t,10));t=e.Long.fromString(t)}return t.low||t.high?new r(t.low>>>0,t.high>>>0):s},o.toNumber=function(t){return!t&&this.hi>>>31?(this.lo=~this.lo+1>>>0,this.hi=~this.hi>>>0,this.lo||(this.hi=this.hi+1>>>0),-(this.lo+4294967296*this.hi)):this.lo+4294967296*this.hi},o.toLong=function(t){return e.Long?new e.Long(0|this.lo,0|this.hi,Boolean(t)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(t)}};var u=String.prototype.charCodeAt;r.fromHash=function(t){return new r((u.call(t,0)|u.call(t,1)<<8|u.call(t,2)<<16|u.call(t,3)<<24)>>>0,(u.call(t,4)|u.call(t,5)<<8|u.call(t,6)<<16|u.call(t,7)<<24)>>>0)},o.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},o.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this},o.zzDecode=function(){var t=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this},o.length=function(){var t=this.lo,i=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return 0===n?0===i?t<16384?t<128?1:2:t<2097152?3:4:i<16384?i<128?5:6:i<2097152?7:8:n<128?9:10}},{9:9}],9:[function(t,i,n){(function(i){"use strict";var r=n;r.LongBits=t(8),r.base64=t(1),r.inquire=t(2),r.utf8=t(4),r.pool=t(3),r.isNode=Boolean(i.process&&i.process.versions&&i.process.versions.node),r.Buffer=(r.Buffer=r.inquire("buffer"))&&r.Buffer.Buffer||null,r.Buffer&&!r.Buffer.prototype.utf8Write&&(r.Buffer=null),r.Long=i.dcodeIO&&i.dcodeIO.Long||r.inquire("long"),r.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},r.isString=function(t){return"string"==typeof t||t instanceof String},r.isObject=function(t){return t&&"object"==typeof t},r.longToHash=function(t){return t?r.LongBits.from(t).toHash():"\0\0\0\0\0\0\0\0"},r.longFromHash=function(t,i){var n=r.LongBits.fromHash(t);return r.Long?r.Long.fromBits(n.lo,n.hi,i):n.toNumber(Boolean(i))},r.longNeq=function(t,i){return"number"==typeof t?"number"==typeof i?t!==i:(t=r.LongBits.fromNumber(t)).lo!==i.low||t.hi!==i.high:"number"==typeof i?(i=r.LongBits.fromNumber(i)).lo!==t.low||i.hi!==t.high:t.low!==i.low||t.high!==i.high},r.longNe=function(t,i,n){if("object"==typeof t)return t.low!==i||t.high!==n;var e=r.LongBits.from(t);return e.lo!==i||e.hi!==n},r.props=function(t,i){Object.keys(i).forEach(function(n){r.prop(t,n,i[n])})},r.prop=function(t,i,n){var r=!-[1],e=i.substring(0,1).toUpperCase()+i.substring(1);n.get&&(t["get"+e]=n.get),n.set&&(t["set"+e]=r?function(t){n.set.call(this,t),this[i]=t}:n.set),r?void 0!==n.value&&(t[i]=n.value):Object.defineProperty(t,i,n)},r.emptyArray=Object.freeze?Object.freeze([]):[],r.emptyObject=Object.freeze?Object.freeze({}):{}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{1:1,2:2,3:3,4:4,8:8}],10:[function(t,i,n){"use strict";function r(t,i,n){this.fn=t,this.len=i,this.next=void 0,this.val=n}function e(){}function o(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}function s(){this.len=0,this.head=new r(e,0,0),this.tail=this.head,this.states=null}function u(t,i,n){i[n]=255&t}function h(t,i,n){for(;t>127;)i[n++]=127&t|128,t>>>=7;i[n]=t}function f(t,i,n){for(;t.hi;)i[n++]=127&t.lo|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)i[n++]=127&t.lo|128,t.lo=t.lo>>>7;i[n++]=t.lo}function a(t,i,n){i[n++]=255&t,i[n++]=t>>>8&255,i[n++]=t>>>16&255,i[n]=t>>>24}i.exports=s;var c,l=t(9),p=l.LongBits,d=l.base64,b=l.utf8,g="undefined"!=typeof Uint8Array?Uint8Array:Array;s.create=l.Buffer?function(){return c||(c=t(11)),(s.create=function(){return new c})()}:function(){return new s},s.alloc=function(t){return new g(t)},g!==Array&&(s.alloc=l.pool(s.alloc,g.prototype.subarray));var v=s.prototype;v.push=function(t,i,n){return this.tail=this.tail.next=new r(t,i,n),this.len+=i,this},v.uint32=function(t){return t>>>=0,this.push(h,t<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)},v.int32=function(t){return t<0?this.push(f,10,p.fromNumber(t)):this.uint32(t)},v.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)},v.uint64=function(t){var i=p.from(t);return this.push(f,i.length(),i)},v.int64=v.uint64,v.sint64=function(t){var i=p.from(t).zzEncode();return this.push(f,i.length(),i)},v.bool=function(t){return this.push(u,1,t?1:0)},v.fixed32=function(t){return this.push(a,4,t>>>0)},v.sfixed32=function(t){return this.push(a,4,t<<1^t>>31)},v.fixed64=function(t){var i=p.from(t);return this.push(a,4,i.lo).push(a,4,i.hi)},v.sfixed64=function(t){var i=p.from(t).zzEncode();return this.push(a,4,i.lo).push(a,4,i.hi)};var y="undefined"!=typeof Float32Array?function(){var t=new Float32Array(1),i=new Uint8Array(t.buffer);return t[0]=-0,i[3]?function(n,r,e){t[0]=n,r[e++]=i[0],r[e++]=i[1],r[e++]=i[2],r[e]=i[3]}:function(n,r,e){t[0]=n,r[e++]=i[3],r[e++]=i[2],r[e++]=i[1],r[e]=i[0]}}():function(t,i,n){var r=t<0?1:0;if(r&&(t=-t),0===t)a(1/t>0?0:2147483648,i,n);else if(isNaN(t))a(2147483647,i,n);else if(t>3.4028234663852886e38)a((r<<31|2139095040)>>>0,i,n);else if(t<1.1754943508222875e-38)a((r<<31|Math.round(t/1.401298464324817e-45))>>>0,i,n);else{var e=Math.floor(Math.log(t)/Math.LN2),o=8388607&Math.round(t*Math.pow(2,-e)*8388608);a((r<<31|e+127<<23|o)>>>0,i,n)}};v.float=function(t){return this.push(y,4,t)};var w="undefined"!=typeof Float64Array?function(){var t=new Float64Array(1),i=new Uint8Array(t.buffer);return t[0]=-0,i[7]?function(n,r,e){t[0]=n,r[e++]=i[0],r[e++]=i[1],r[e++]=i[2],r[e++]=i[3],r[e++]=i[4],r[e++]=i[5],r[e++]=i[6],r[e]=i[7]}:function(n,r,e){t[0]=n,r[e++]=i[7],r[e++]=i[6],r[e++]=i[5],r[e++]=i[4],r[e++]=i[3],r[e++]=i[2],r[e++]=i[1],r[e]=i[0]}}():function(t,i,n){var r=t<0?1:0;if(r&&(t=-t),0===t)a(0,i,n),a(1/t>0?0:2147483648,i,n+4);else if(isNaN(t))a(4294967295,i,n),a(2147483647,i,n+4);else if(t>1.7976931348623157e308)a(0,i,n),a((r<<31|2146435072)>>>0,i,n+4);else{var e;if(t<2.2250738585072014e-308)e=t/5e-324,a(e>>>0,i,n),a((r<<31|e/4294967296)>>>0,i,n+4);else{var o=Math.floor(Math.log(t)/Math.LN2);1024===o&&(o=1023),e=t*Math.pow(2,-o),a(4503599627370496*e>>>0,i,n),a((r<<31|o+1023<<20|1048576*e&1048575)>>>0,i,n+4)}}};v.double=function(t){return this.push(w,8,t)};var m=g.prototype.set?function(t,i,n){i.set(t,n)}:function(t,i,n){for(var r=0;r>>0;if("string"==typeof t&&i){var n=s.alloc(i=d.length(t));d.decode(t,n,0),t=n}return i?this.uint32(i).push(m,i,t):this.push(u,1,0)},v.string=function(t){var i=b.length(t);return i?this.uint32(i).push(b.write,i,t):this.push(u,1,0)},v.fork=function(){return this.states=new o(this),this.head=this.tail=new r(e,0,0),this.len=0,this},v.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new r(e,0,0),this.len=0),this},v.ldelim=function(t){var i=this.head,n=this.tail,r=this.len;return this.reset(),"number"==typeof t&&this.uint32((t<<3|2)>>>0),this.uint32(r),this.tail.next=i.next,this.tail=n,this.len+=r,this},v.finish=function(){for(var t=this.head.next,i=this.constructor.alloc(this.len),n=0;t;)t.fn(t.val,i,n),n+=t.len,t=t.next;return i}},{11:11,9:9}],11:[function(t,i,n){"use strict";function r(){o.call(this)}function e(t,i,n){t.length<40?h.write(t,i,n):i.utf8Write(t,n)}i.exports=r;var o=t(10),s=r.prototype=Object.create(o.prototype);s.constructor=r;var u=t(9),h=u.utf8,f=u.Buffer;r.alloc=function(t){return(r.alloc=f.allocUnsafe?f.allocUnsafe:function(t){return new f(t)})(t)};var a=f&&f.from&&"s"===f.prototype.set.name[0]?function(t,i,n){i.set(t,n)}:function(t,i,n){t.copy(i,n,0,t.length)},c=f&&f.from||function(t,i){return new f(t,i)};s.bytes=function(t){"string"==typeof t&&(t=c(t,"base64"));var i=t.length>>>0;return this.uint32(i),i&&this.push(a,i,t),this},s.string=function(t){var i=f.byteLength(t);return this.uint32(i),i&&this.push(e,i,t),this}},{10:10,9:9}]},{},[5]); diff --git a/dist/runtime/protobuf.min.js.gz b/dist/runtime/protobuf.min.js.gz index d903d5831..f12875d5a 100644 Binary files a/dist/runtime/protobuf.min.js.gz and b/dist/runtime/protobuf.min.js.gz differ diff --git a/gulpfile.js b/gulpfile.js index 1e36de4a2..29cfb50c0 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,5 +1,4 @@ -var gulp = require("gulp"), - gzip = require('gulp-gzip'); +var gulp = require("gulp"); var bundle = require("./scripts/bundle"); @@ -14,14 +13,18 @@ gulp.task("bundle-production" , bundle.bind(this, false, false)); gulp.task("bundle-development-runtime", bundle.bind(this, true , true)); gulp.task("bundle-production-runtime" , bundle.bind(this, false, true)); -gulp.task("gzip-production", [ "bundle-production" ], function() { - return gulp.src('./dist/protobuf.min.js') - .pipe(gzip({ gzipOptions: { level: 9 } })) - .pipe(gulp.dest('./dist')); +gulp.task("gzip-production", [ "bundle-production" ], function(cb) { + bundle.compress( + "./dist/protobuf.min.js", + "./dist/protobuf.min.js.gz", + cb + ); }); -gulp.task("gzip-production-runtime", [ "bundle-production-runtime" ], function() { - return gulp.src('./dist/runtime/protobuf.min.js') - .pipe(gzip({ gzipOptions: { level: 9 } })) - .pipe(gulp.dest('./dist/runtime')); +gulp.task("gzip-production-runtime", [ "bundle-production-runtime" ], function(cb) { + bundle.compress( + "./dist/runtime/protobuf.min.js", + "./dist/runtime/protobuf.min.js.gz", + cb + ); }); diff --git a/package.json b/package.json index 525716b49..f5cfd2968 100644 --- a/package.json +++ b/package.json @@ -76,6 +76,7 @@ "jaguarjs-jsdoc": "dcodeIO/jaguarjs-jsdoc", "jsdoc": "^3.4.2", "minimist": "^1.2.0", + "node-zopfli": "^2.0.2", "tap-spec": "^4.1.1", "tape": "^4.6.3", "typescript": "^2.1.4", diff --git a/scripts/bundle.js b/scripts/bundle.js index a801c997a..fb108653d 100644 --- a/scripts/bundle.js +++ b/scripts/bundle.js @@ -1,28 +1,28 @@ module.exports = bundle; -var path = require('path'); +var path = require("path"); -var browserify = require('browserify'); +var browserify = require("browserify"); -var header = require('gulp-header'); -var gulpif = require('gulp-if'); -var sourcemaps = require('gulp-sourcemaps'); -var uglify = require('gulp-uglify'); -var gutil = require('gulp-util'); +var header = require("gulp-header"); +var gulpif = require("gulp-if"); +var sourcemaps = require("gulp-sourcemaps"); +var uglify = require("gulp-uglify"); +var gutil = require("gulp-util"); -var buffer = require('vinyl-buffer'); -var vinylfs = require('vinyl-fs'); -var source = require('vinyl-source-stream'); +var buffer = require("vinyl-buffer"); +var vinylfs = require("vinyl-fs"); +var source = require("vinyl-source-stream"); -var pkg = require(__dirname + '/../package.json'); +var pkg = require(__dirname + "/../package.json"); var license = [ "/*!", " * protobuf.js v${version} (c) 2016, Daniel Wirtz", " * Compiled ${date}", - " * Licensed under the BSD-3-Clause license", + " * Licensed under the BSD-3-Clause License", " * see: https://github.com/dcodeIO/protobuf.js for details", " */" -].join('\n') + '\n'; +].join("\n") + "\n"; function bundle(compress, runtime) { var src = runtime @@ -40,9 +40,9 @@ function bundle(compress, runtime) { .external("long") .exclude("process") .exclude("_process") - .plugin(require('bundle-collapser/plugin')) + .plugin(require("bundle-collapser/plugin")) .bundle() - .pipe(source(compress ? 'protobuf.min.js' : 'protobuf.js')) + .pipe(source(compress ? "protobuf.min.js" : "protobuf.js")) .pipe(buffer()) .pipe(sourcemaps.init({ loadMaps: true })) .pipe( @@ -53,11 +53,25 @@ function bundle(compress, runtime) { })) ) .pipe(header(license, { - date: (new Date()).toUTCString().replace('GMT', 'UTC'), + date: (new Date()).toUTCString().replace("GMT", "UTC"), version: pkg.version })) - .pipe(sourcemaps.write('.', { sourceRoot: '' })) + .pipe(sourcemaps.write(".", { sourceRoot: "" })) .pipe(vinylfs.dest(dst)) .on("log", gutil.log) .on("error", gutil.log); } + +var fs = require("fs"); +var zopfli = require("node-zopfli"); + +bundle.compress = function compress(sourceFile, destinationFile, callback) { + var src = fs.createReadStream(sourceFile); + var dst = fs.createWriteStream(destinationFile); + src.on("error", callback); + dst.on("error", callback); + dst.on("close", function() { + callback(null); + }); + src.pipe(zopfli.createGzip()).pipe(dst); +}; diff --git a/types/protobuf.js.d.ts b/types/protobuf.js.d.ts index 7b4ce9fa2..f6039b0db 100644 --- a/types/protobuf.js.d.ts +++ b/types/protobuf.js.d.ts @@ -1,5 +1,5 @@ // $> pbts --name protobufjs --out types/protobuf.js.d.ts src -// Generated Tue, 20 Dec 2016 21:38:11 UTC +// Generated Wed, 21 Dec 2016 00:40:53 UTC declare module "protobufjs" { /** @@ -86,6 +86,7 @@ declare module "protobufjs" { * @property {Object} google/protobuf/empty.proto Empty * @property {Object} google/protobuf/struct.proto Struct, Value, NullValue and ListValue * @property {Object} google/protobuf/timestamp.proto Timestamp + * @property {Object} google/protobuf/wrappers.proto Wrappers */ function common(name: string, json: Object): void;