From 208c54ee5a8077a2ea1f9d5f8ce1bddd8f7d7638 Mon Sep 17 00:00:00 2001 From: Caleb Sander Date: Thu, 17 Nov 2016 19:53:44 -0500 Subject: [PATCH] Fixed #42; version bump --- compiled/download.js | 36 +++++++++++----------- compiled/upload-download.js | 36 +++++++++++----------- compiled/upload.js | 52 ++++++++++++++++---------------- docs/ArrayType.html | 4 +-- docs/ChoiceType.html | 4 +-- docs/EnumType.html | 4 +-- docs/GrowableBuffer.html | 2 +- docs/MapType.html | 4 +-- docs/NamedChoiceType.html | 4 +-- docs/OptionalType.html | 4 +-- docs/PointerType.html | 4 +-- docs/RecursiveType.html | 4 +-- docs/SetType.html | 4 +-- docs/lib_growable-buffer.js.html | 1 + docs/structure-types.js.html | 9 ++++-- package.json | 4 +-- structure-types.js | 9 ++++-- test/value-bytes/struct.js | 22 +++++++++++++- 18 files changed, 119 insertions(+), 88 deletions(-) diff --git a/compiled/download.js b/compiled/download.js index 6605194..c03b1cd 100644 --- a/compiled/download.js +++ b/compiled/download.js @@ -41,7 +41,7 @@ g)),n=Number(d(b,g)),l=l+n+h,h=0;10<=l;)l-=10,h++;0===l?t++:(z=String(l)+c(z,t), b){y(a);y(b);if(!I(a,b))throw Error("x must be greater or equal to y");for(var k=Math.max(a.length,b.length),z="",h=0,t=0,l=0;ld)throw Error("Illegal state");}};a.div=function(a,c,b){b=void 0===b?!1:b;x(a);x(c);var d=z(H(a),H(c))[0];l(a,c)||(d=Q(d));!b||D(t(d,c),a)||l(a,c)||(d=O(d,"1"));return d};var D=a.eq=function(a,c){return K(a)===K(c)},k=a.lt=function(a,c){return g(a)&&N(c)?!0:N(a)&&g(c)?!1:g(a)&&g(c)?!D(a,c)&&!r(H(a), -H(c)):r(a,c)},I=a.ge=function(a,c){return!k(a,c)},p=a.gt=function(a,c){return D(a,c)?!1:I(a,c)},g=a.isNegative=function(a){x(a);return 0===a.indexOf("-")},N=a.isPositive=function(a){return!g(a)},H=a.abs=function(a){return g(a)?Q(a):a},Q=a.negate=function(a){return"0"===a?"0":g(a)?a.slice(1):"-"+a},V=/^(-?)0*([1-9][0-9]*)$/,W=/^0+$/,K=a.normalize=function(a){if(W.test(a))return"0";var c=V.exec(a);if(!c)throw Error("Illegal strint format: "+a);return c[1]+c[2]}})();a.LONG_UPPER_SHIFT="4294967296";a.BYTE_SHIFT= +H(c)):r(a,c)},I=a.ge=function(a,c){return!k(a,c)},p=a.gt=function(a,c){return D(a,c)?!1:I(a,c)},g=a.isNegative=function(a){x(a);return 0===a.indexOf("-")},N=a.isPositive=function(a){return!g(a)},H=a.abs=function(a){return g(a)?Q(a):a},Q=a.negate=function(a){return"0"===a?"0":g(a)?a.slice(1):"-"+a},W=/^(-?)0*([1-9][0-9]*)$/,X=/^0+$/,K=a.normalize=function(a){if(X.test(a))return"0";var c=W.exec(a);if(!c)throw Error("Illegal strint format: "+a);return c[1]+c[2]}})();a.LONG_UPPER_SHIFT="4294967296";a.BYTE_SHIFT= "256";e.exports=a},{}],"/lib/util-inspect.js":[function(b,e,a){a.inspect=function(b){if(void 0===b)return"undefined";if(null===b||b.constructor===Object||b.constructor===Array||b.constructor===String||b.constructor===Number||b.constructor===Boolean||b.constructor===Date)return JSON.stringify(b);if(b.constructor===Set){var d="Set {";b=b.values();for(var c=b.next();!c.done;)d+=a.inspect(c.value),c=b.next(),c.done||(d+=", ");return d+"}"}if(b.constructor===Map){d="Map {";b=b.entries();for(c=b.next();!c.done;)d+= a.inspect(c.value[0]),d+=" \x3d\x3e ",d+=a.inspect(c.value[1]),c=b.next(),c.done||(d+=", ");return d+"}"}return b.constructor.name?b.constructor.name+" "+JSON.stringify(b):JSON.stringify(b)}},{}],1:[function(b){(function(){function e(){var a={},b;for(b in c)a[b]={sig:c[b].sig,type:h.fromByteArray(new Uint8Array(c[b].type.toBuffer()))};localStorage.typeCache=JSON.stringify(a)}b("/client-side/common.js");var a=b("/lib/assert.js"),h=b("base64-js"),d=b("/read.js"),c={};if(localStorage.typeCache){var u= JSON.parse(localStorage.typeCache),r;for(r in u)c[r]={sig:u[r].sig,type:d.type((new Uint8Array(h.toByteArray(u[r].type))).buffer)}}else e();sb.download=function(b,l){function h(a,c,b){if(r){r instanceof Array||(r=[r]);for(var d=f.makeIterator(r),l=d.next();!l.done;l=d.next())l=l.value,l(a,c,b)}}a.instanceOf(b,String);a.instanceOf(l,Object);l.dataType="arraybuffer";var n;c[b]?(n=!0,l.headers||(l.headers={}),l.headers.sig=c[b].sig):n=!1;var r=l.success;l.success=function(a,l,r){var q=r.getResponseHeader("sig"); @@ -75,13 +75,13 @@ case q.REPEATED_TYPE:t=e+2;l.assert(a.byteLength>=b+t,"Buffer is not long enough q.ShortType,q.IntType,q.LongType,q.BigIntType,q.UnsignedByteType,q.UnsignedShortType,q.UnsignedIntType,q.UnsignedLongType,q.BigUnsignedIntType,q.DateType,q.DayType,q.TimeType,q.FloatType,q.DoubleType,q.BooleanType,q.BooleanArrayType,q.CharType,q.StringType,q.OctetsType],G=new WeakMap,L=new WeakMap;e.exports={_consumeType:n,type:function(a,b){b=void 0===b?!0:b;l.instanceOf(a,ArrayBuffer);var c=n(a,0),d=c.value,c=c.length;b&&l.assert(c===a.byteLength,"Did not consume all of the buffer");return d},value:function(a){var b= a.buffer,c=a.type;a=void 0===a.offset?0:a.offset;l.instanceOf(b,ArrayBuffer);l.instanceOf(c,q.Type);l.instanceOf(a,Number);return r({buffer:b,offset:a,type:c,pointerStart:a}).value}}}).call(this,"/")},{"/lib/util-inspect.js":"/lib/util-inspect.js"}],"/recursive-registry.js":[function(b,e){(function(a){"/"===a&&(a="");var h=b(a+"/lib/assert.js"),d=b(a+"/structure-types.js"),c=new Map;e.exports={registerType:function(a){var b=a.type;a=a.name;h.instanceOf(b,[d.ArrayType,d.MapType,d.SetType,d.StructType, d.TupleType]);h.instanceOf(a,String);h.assert(!c.has(a),'"'+a+'" is already a registered type');c.set(a,b)},getType:function(a){h.instanceOf(a,String);var b=c.get(a);h.assert(void 0!==b,'"'+a+'" is not a registered type');return b},isRegistered:function(a){return c.has(a)}}}).call(this,"/")},{}],"/structure-types.js":[function(b,e){(function(a){function h(a){m.instanceOf(a,w);this.type=a}function d(a){w.call(this);m.instanceOf(a,F);this.type=a}function c(a){w.call(this);m.instanceOf(a,String);this.name= -a}function u(a){w.call(this);m.instanceOf(a,Map);try{m.byteUnsignedInteger(a.size)}catch(X){m.fail(String(a.size)+" types is too many")}this.indexConstructors=new Map;this.constructorTypes=Array(a.size);var b=new Set;a=f.makeIterator(a);for(var c=a.next();!c.done;c=a.next()){var d=f.makeIterator(c.value),c=d.next().value,d=d.next().value;m.instanceOf(c,Function);var B=c.name;m.assert(B,'Function "'+String(B)+'" does not have a name');m.assert(!b.has(B),'Function name "'+B+'" is repeated');b.add(B); -var e=S.fromString(B);try{m.byteUnsignedInteger(e.byteLength)}catch(X){m.fail('Function name "'+B+'" is too long')}m.instanceOf(d,y);B=this.indexConstructors.size;this.indexConstructors.set(B,c);this.constructorTypes[B]={nameBuffer:e,type:d}}}function r(a){w.call(this);m.instanceOf(a,Array);try{m.byteUnsignedInteger(a.length)}catch(ra){m.fail(String(a.length)+" types is too many")}for(var b=f.makeIterator(a),c=b.next();!c.done;c=b.next())m.instanceOf(c.value,F);this.types=a}function n(a){var b=a.type; -a=a.values;m.instanceOf(b,w);m.instanceOf(a,Array);try{m.byteUnsignedInteger(a.length)}catch(X){m.fail(String(a.length)+" values is too many")}for(var c=new Map,d=0;db.name)return 1})}function E(a){var b=a.type;a=a.length;w.call(this);m.instanceOf(b,F);m.fourByteUnsignedInteger(a);this.type=b;this.length=a}function v(a){w.apply(this,arguments)}function q(a){w.apply(this,arguments)}function J(a){w.apply(this,arguments)}function O(a){w.apply(this,arguments)}function G(a){w.call(this);m.fourByteUnsignedInteger(a);this.length=a}function L(a){w.apply(this,arguments)} -function t(a){D.apply(this,arguments)}function z(a){D.apply(this,arguments)}function D(a){w.apply(this,arguments)}function k(a){g.apply(this,arguments)}function I(a){g.apply(this,arguments)}function p(a){g.apply(this,arguments)}function g(a){w.apply(this,arguments)}function N(a){K.apply(this,arguments)}function H(a){K.apply(this,arguments)}function Q(a){K.apply(this,arguments)}function V(a){K.apply(this,arguments)}function W(a){K.apply(this,arguments)}function K(a){w.apply(this,arguments)}function Y(a){P.apply(this, -arguments)}function Z(a){P.apply(this,arguments)}function aa(a){P.apply(this,arguments)}function ba(a){P.apply(this,arguments)}function ca(a){P.apply(this,arguments)}function P(a){w.apply(this,arguments)}function w(a){F.apply(this,arguments)}function F(){}function U(a){var b=new ArrayBuffer(4);(new DataView(b)).setUint32(0,a);return b}function R(a,b){if(b&&(b=fa.get(a))){b=f.makeIterator(b);for(var c=b.next();!c.done;c=b.next()){var d=f.makeIterator(c.value),c=d.next().value,d=d.next().value,e=a.length; +function t(a){D.apply(this,arguments)}function z(a){D.apply(this,arguments)}function D(a){w.apply(this,arguments)}function k(a){g.apply(this,arguments)}function I(a){g.apply(this,arguments)}function p(a){g.apply(this,arguments)}function g(a){w.apply(this,arguments)}function N(a){K.apply(this,arguments)}function H(a){K.apply(this,arguments)}function Q(a){K.apply(this,arguments)}function W(a){K.apply(this,arguments)}function X(a){K.apply(this,arguments)}function K(a){w.apply(this,arguments)}function Y(a){P.apply(this, +arguments)}function Z(a){P.apply(this,arguments)}function aa(a){P.apply(this,arguments)}function ba(a){P.apply(this,arguments)}function ca(a){P.apply(this,arguments)}function P(a){w.apply(this,arguments)}function w(a){F.apply(this,arguments)}function F(){}function V(a){var b=new ArrayBuffer(4);(new DataView(b)).setUint32(0,a);return b}function R(a,b){if(b&&(b=fa.get(a))){b=f.makeIterator(b);for(var c=b.next();!c.done;c=b.next()){var d=f.makeIterator(c.value),c=d.next().value,d=d.next().value,e=a.length; a.addAll(S.fromBinaryString(c));c=new ArrayBuffer(4);(new DataView(c)).setUint32(0,e);d=f.makeIterator(d);for(e=d.next();!e.done;e=d.next())a.setAll(e.value,c)}}}function T(a){if(a&&a.constructor===String&&(a=Number(a),!isNaN(a)))return a}function la(a,b){m.instanceOf(a,A);m.instanceOf(b,String);(C.gt(b,"9223372036854775807")||C.lt(b,"-9223372036854775808"))&&m.fail("Value out of range");var c=C.div(b,C.LONG_UPPER_SHIFT,!0);b=C.sub(b,C.mul(c,C.LONG_UPPER_SHIFT));var d=new ArrayBuffer(8),e=new DataView(d); e.setInt32(0,Number(c));e.setUint32(4,Number(b));a.addAll(d)}function ma(a,b){m.instanceOf(b,Array);for(var c=ga(b.length),d=ha(b.length),c=new ArrayBuffer(c?d+1:d),d=new Uint8Array(c),e=0;e>8);d.setUint8(2,b&255);a.addAll(c)};f.global.Object.defineProperties(I,{_value:{configurable:!0,enumerable:!0,get:function(){return 27}}}); f.inherits(k,g);k.prototype.writeValue=function(a,b){m.instanceOf(b,Date);var c=new ArrayBuffer(4);(new DataView(c)).setUint32(0,b.getTime()%864E5);a.addAll(c)};f.global.Object.defineProperties(k,{_value:{configurable:!0,enumerable:!0,get:function(){return 28}}});f.inherits(D,w);f.inherits(z,D);z.prototype.writeValue=function(a,b){m.instanceOf(a,A);var c=T(b);void 0!==c&&(b=c);m.instanceOf(b,Number);c=new ArrayBuffer(4);(new DataView(c)).setFloat32(0,b);a.addAll(c)};f.global.Object.defineProperties(z, {_value:{configurable:!0,enumerable:!0,get:function(){return 32}}});f.inherits(t,D);t.prototype.writeValue=function(a,b){m.instanceOf(a,A);var c=T(b);void 0!==c&&(b=c);m.instanceOf(b,Number);c=new ArrayBuffer(8);(new DataView(c)).setFloat64(0,b);a.addAll(c)};f.global.Object.defineProperties(t,{_value:{configurable:!0,enumerable:!0,get:function(){return 33}}});f.inherits(L,w);L.prototype.writeValue=function(a,b){m.instanceOf(a,A);m.instanceOf(b,Boolean);b?a.add(255):a.add(0)};f.global.Object.defineProperties(L, -{_value:{configurable:!0,enumerable:!0,get:function(){return 48}}});f.inherits(G,w);G.prototype.addToBuffer=function(a){w.prototype.addToBuffer.call(this,a)&&a.addAll(U(this.length))};G.prototype.writeValue=function(a,b){m.instanceOf(a,A);m.instanceOf(b,Array);b.length!==this.length&&m.fail("Length does not match");ma(a,b)};f.global.Object.defineProperties(G,{_value:{configurable:!0,enumerable:!0,get:function(){return 49}}});f.inherits(O,w);O.prototype.writeValue=function(a,b){m.instanceOf(b,Array); -m.fourByteUnsignedInteger(b.length);a.addAll(U(b.length));ma(a,b)};f.global.Object.defineProperties(O,{_value:{configurable:!0,enumerable:!0,get:function(){return 50}}});f.inherits(J,w);J.prototype.writeValue=function(a,b){m.instanceOf(a,A);m.instanceOf(b,String);m.assert(1===b.length,"String must contain only 1 character");a.addAll(S.fromString(b))};f.global.Object.defineProperties(J,{_value:{configurable:!0,enumerable:!0,get:function(){return 64}}});f.inherits(q,w);q.prototype.writeValue=function(a, -b){m.instanceOf(a,A);m.instanceOf(b,String);b=S.fromString(b);a.addAll(b);a.add(0)};f.global.Object.defineProperties(q,{_value:{configurable:!0,enumerable:!0,get:function(){return 65}}});f.inherits(v,w);v.prototype.writeValue=function(a,b){m.instanceOf(a,A);m.instanceOf(b,ArrayBuffer);m.fourByteUnsignedInteger(b.byteLength);a.addAll(U(b.byteLength));a.addAll(b)};f.global.Object.defineProperties(v,{_value:{configurable:!0,enumerable:!0,get:function(){return 66}}});f.inherits(E,w);E.prototype.addToBuffer= -function(a){w.prototype.addToBuffer.call(this,a)&&(this.type.addToBuffer(a),a.addAll(U(this.length)))};E.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;m.instanceOf(a,A);m.instanceOf(b,Array);b.length!==this.length&&m.fail("Length does not match: expected "+String(this.length)+" but got "+b.length);b=f.makeIterator(b);for(var d=b.next();!d.done;d=b.next())this.type.writeValue(a,d.value,!1);R(a,c)};f.global.Object.defineProperties(E,{_value:{configurable:!0,enumerable:!0,get:function(){return 80}}}); -f.inherits(y,w);y.prototype.addToBuffer=function(a){if(w.prototype.addToBuffer.call(this,a)){a.add(this.fields.length);for(var b=f.makeIterator(this.fields),c=b.next();!c.done;c=b.next()){var c=c.value,d=c.buffer;a.add(d.byteLength);a.addAll(d);c.type.addToBuffer(a)}}};y.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;m.instanceOf(a,A);m.instanceOf(b,Object);for(var d=f.makeIterator(this.fields),e=d.next();!e.done;e=d.next()){var e=e.value,g=b[e.name];void 0===g&&m.fail('Value for field "'+ -e.name+'" missing');e.type.writeValue(a,g,!1)}R(a,c)};f.global.Object.defineProperties(y,{_value:{configurable:!0,enumerable:!0,get:function(){return 81}}});f.inherits(x,w);x.prototype.addToBuffer=function(a){w.prototype.addToBuffer.call(this,a)&&this.type.addToBuffer(a)};x.prototype._writeValue=function(a,b,c){m.instanceOf(a,A);var d=b.length;void 0===d&&(d=b.size);m.fourByteUnsignedInteger(d);a.addAll(U(d));b=f.makeIterator(b);for(d=b.next();!d.done;d=b.next())this.type.writeValue(a,d.value,!1); -R(a,c)};x.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;m.instanceOf(b,Array);this._writeValue(a,b,c)};f.global.Object.defineProperties(x,{_value:{configurable:!0,enumerable:!0,get:function(){return 82}}});f.inherits(M,x);M.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;m.instanceOf(b,Set);this._writeValue(a,b,c)};f.global.Object.defineProperties(M,{_value:{configurable:!0,enumerable:!0,get:function(){return 83}}});f.inherits(l,w);l.prototype.addToBuffer=function(a){w.prototype.addToBuffer.call(this, -a)&&(this.keyType.addToBuffer(a),this.valueType.addToBuffer(a))};l.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;m.instanceOf(a,A);m.instanceOf(b,Map);m.fourByteUnsignedInteger(b.size);a.addAll(U(b.size));b=f.makeIterator(b);for(var d=b.next();!d.done;d=b.next()){var e=f.makeIterator(d.value),d=e.next().value,e=e.next().value;this.keyType.writeValue(a,d,!1);this.valueType.writeValue(a,e,!1)}R(a,c)};f.global.Object.defineProperties(l,{_value:{configurable:!0,enumerable:!0,get:function(){return 84}}}); +{_value:{configurable:!0,enumerable:!0,get:function(){return 48}}});f.inherits(G,w);G.prototype.addToBuffer=function(a){w.prototype.addToBuffer.call(this,a)&&a.addAll(V(this.length))};G.prototype.writeValue=function(a,b){m.instanceOf(a,A);m.instanceOf(b,Array);b.length!==this.length&&m.fail("Length does not match");ma(a,b)};f.global.Object.defineProperties(G,{_value:{configurable:!0,enumerable:!0,get:function(){return 49}}});f.inherits(O,w);O.prototype.writeValue=function(a,b){m.instanceOf(b,Array); +m.fourByteUnsignedInteger(b.length);a.addAll(V(b.length));ma(a,b)};f.global.Object.defineProperties(O,{_value:{configurable:!0,enumerable:!0,get:function(){return 50}}});f.inherits(J,w);J.prototype.writeValue=function(a,b){m.instanceOf(a,A);m.instanceOf(b,String);m.assert(1===b.length,"String must contain only 1 character");a.addAll(S.fromString(b))};f.global.Object.defineProperties(J,{_value:{configurable:!0,enumerable:!0,get:function(){return 64}}});f.inherits(q,w);q.prototype.writeValue=function(a, +b){m.instanceOf(a,A);m.instanceOf(b,String);b=S.fromString(b);a.addAll(b);a.add(0)};f.global.Object.defineProperties(q,{_value:{configurable:!0,enumerable:!0,get:function(){return 65}}});f.inherits(v,w);v.prototype.writeValue=function(a,b){m.instanceOf(a,A);m.instanceOf(b,ArrayBuffer);m.fourByteUnsignedInteger(b.byteLength);a.addAll(V(b.byteLength));a.addAll(b)};f.global.Object.defineProperties(v,{_value:{configurable:!0,enumerable:!0,get:function(){return 66}}});f.inherits(E,w);E.prototype.addToBuffer= +function(a){w.prototype.addToBuffer.call(this,a)&&(this.type.addToBuffer(a),a.addAll(V(this.length)))};E.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;m.instanceOf(a,A);m.instanceOf(b,Array);b.length!==this.length&&m.fail("Length does not match: expected "+String(this.length)+" but got "+b.length);b=f.makeIterator(b);for(var d=b.next();!d.done;d=b.next())this.type.writeValue(a,d.value,!1);R(a,c)};f.global.Object.defineProperties(E,{_value:{configurable:!0,enumerable:!0,get:function(){return 80}}}); +f.inherits(y,w);y.prototype.addToBuffer=function(a){if(w.prototype.addToBuffer.call(this,a)){a.add(this.fields.length);for(var b=f.makeIterator(this.fields),c=b.next();!c.done;c=b.next()){var c=c.value,d=c.buffer;a.add(d.byteLength);a.addAll(d);c.type.addToBuffer(a)}}};y.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;m.instanceOf(a,A);m.instanceOf(b,Object);for(var d=f.makeIterator(this.fields),e=d.next();!e.done;e=d.next()){var e=e.value,g=b[e.name];try{e.type.writeValue(a,g,!1)}catch(U){throw void 0=== +g&&m.fail('Value for field "'+e.name+'" missing'),U;}}R(a,c)};f.global.Object.defineProperties(y,{_value:{configurable:!0,enumerable:!0,get:function(){return 81}}});f.inherits(x,w);x.prototype.addToBuffer=function(a){w.prototype.addToBuffer.call(this,a)&&this.type.addToBuffer(a)};x.prototype._writeValue=function(a,b,c){m.instanceOf(a,A);var d=b.length;void 0===d&&(d=b.size);m.fourByteUnsignedInteger(d);a.addAll(V(d));b=f.makeIterator(b);for(d=b.next();!d.done;d=b.next())this.type.writeValue(a,d.value, +!1);R(a,c)};x.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;m.instanceOf(b,Array);this._writeValue(a,b,c)};f.global.Object.defineProperties(x,{_value:{configurable:!0,enumerable:!0,get:function(){return 82}}});f.inherits(M,x);M.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;m.instanceOf(b,Set);this._writeValue(a,b,c)};f.global.Object.defineProperties(M,{_value:{configurable:!0,enumerable:!0,get:function(){return 83}}});f.inherits(l,w);l.prototype.addToBuffer=function(a){w.prototype.addToBuffer.call(this, +a)&&(this.keyType.addToBuffer(a),this.valueType.addToBuffer(a))};l.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;m.instanceOf(a,A);m.instanceOf(b,Map);m.fourByteUnsignedInteger(b.size);a.addAll(V(b.size));b=f.makeIterator(b);for(var d=b.next();!d.done;d=b.next()){var e=f.makeIterator(d.value),d=e.next().value,e=e.next().value;this.keyType.writeValue(a,d,!1);this.valueType.writeValue(a,e,!1)}R(a,c)};f.global.Object.defineProperties(l,{_value:{configurable:!0,enumerable:!0,get:function(){return 84}}}); f.inherits(n,F);n.prototype.addToBuffer=function(a){if(F.prototype.addToBuffer.call(this,a)){this.type.addToBuffer(a);a.add(this.valueIndices.size);for(var b=f.makeIterator(this.valueIndices),c=b.next();!c.done;c=b.next()){var c=f.makeIterator(c.value),d=c.next().value;c.next();a.addAll(S.fromBinaryString(d))}}};n.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;m.instanceOf(a,A);var d=new A;this.type.writeValue(d,b,!1);d=this.valueIndices.get(S.toBinaryString(d.toBuffer()));m.assert(void 0!== d,"Not a valid enum value: "+da.inspect(b));a.add(d);R(a,c)};f.global.Object.defineProperties(n,{_value:{configurable:!0,enumerable:!0,get:function(){return 85}}});f.inherits(r,w);r.prototype.addToBuffer=function(a){if(w.prototype.addToBuffer.call(this,a)){a.add(this.types.length);for(var b=f.makeIterator(this.types),c=b.next();!c.done;c=b.next())c.value.addToBuffer(a)}};r.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;m.instanceOf(a,A);for(var d=!1,e=0;ed)throw Error("Illegal state");}};a.div=function(a,b,c){c=void 0===c?!1:c;x(a);x(b);var d=z(H(a),H(b))[0];m(a,b)||(d=Q(d));!c||D(u(d,b),a)||m(a,b)||(d=O(d,"1"));return d};var D=a.eq=function(a,b){return K(a)===K(b)},k=a.lt=function(a,b){return g(a)&&N(b)?!0:N(a)&&g(b)?!1:g(a)&&g(b)?!D(a,b)&&!r(H(a), -H(b)):r(a,b)},I=a.ge=function(a,b){return!k(a,b)},p=a.gt=function(a,b){return D(a,b)?!1:I(a,b)},g=a.isNegative=function(a){x(a);return 0===a.indexOf("-")},N=a.isPositive=function(a){return!g(a)},H=a.abs=function(a){return g(a)?Q(a):a},Q=a.negate=function(a){return"0"===a?"0":g(a)?a.slice(1):"-"+a},V=/^(-?)0*([1-9][0-9]*)$/,W=/^0+$/,K=a.normalize=function(a){if(W.test(a))return"0";var b=V.exec(a);if(!b)throw Error("Illegal strint format: "+a);return b[1]+b[2]}})();a.LONG_UPPER_SHIFT="4294967296";a.BYTE_SHIFT= +H(b)):r(a,b)},I=a.ge=function(a,b){return!k(a,b)},p=a.gt=function(a,b){return D(a,b)?!1:I(a,b)},g=a.isNegative=function(a){x(a);return 0===a.indexOf("-")},N=a.isPositive=function(a){return!g(a)},H=a.abs=function(a){return g(a)?Q(a):a},Q=a.negate=function(a){return"0"===a?"0":g(a)?a.slice(1):"-"+a},W=/^(-?)0*([1-9][0-9]*)$/,X=/^0+$/,K=a.normalize=function(a){if(X.test(a))return"0";var b=W.exec(a);if(!b)throw Error("Illegal strint format: "+a);return b[1]+b[2]}})();a.LONG_UPPER_SHIFT="4294967296";a.BYTE_SHIFT= "256";e.exports=a},{}],"/lib/util-inspect.js":[function(b,e,a){a.inspect=function(b){if(void 0===b)return"undefined";if(null===b||b.constructor===Object||b.constructor===Array||b.constructor===String||b.constructor===Number||b.constructor===Boolean||b.constructor===Date)return JSON.stringify(b);if(b.constructor===Set){var d="Set {";b=b.values();for(var c=b.next();!c.done;)d+=a.inspect(c.value),c=b.next(),c.done||(d+=", ");return d+"}"}if(b.constructor===Map){d="Map {";b=b.entries();for(c=b.next();!c.done;)d+= a.inspect(c.value[0]),d+=" \x3d\x3e ",d+=a.inspect(c.value[1]),c=b.next(),c.done||(d+=", ");return d+"}"}return b.constructor.name?b.constructor.name+" "+JSON.stringify(b):JSON.stringify(b)}},{}],1:[function(b){(function(){b("/client-side/common.js");var e=b("/lib/assert.js");sb.upload=function(a,b){var d=a.type;a=a.value;e.instanceOf(d,sb.Type);e.instanceOf(b,Object);"POST"!==b.type&&"POST"!==b.method&&e.fail("Must use POST when uploading");b.processData=!1;b.data=d.valueBuffer(a);$.ajax(b)}})(); (function(){function e(){var a={},b;for(b in c)a[b]={sig:c[b].sig,type:h.fromByteArray(new Uint8Array(c[b].type.toBuffer()))};localStorage.typeCache=JSON.stringify(a)}b("/client-side/common.js");var a=b("/lib/assert.js"),h=b("base64-js"),d=b("/read.js"),c={};if(localStorage.typeCache){var t=JSON.parse(localStorage.typeCache),r;for(r in t)c[r]={sig:t[r].sig,type:d.type((new Uint8Array(h.toByteArray(t[r].type))).buffer)}}else e();sb.download=function(b,m){function h(a,b,c){if(r){r instanceof Array|| @@ -75,13 +75,13 @@ a.length;E.registerType({type:a.value,name:u})}c=new q.RecursiveType(u);break;ca a&&(a="");var m=b(a+"/lib/assert.js"),M=b(a+"/lib/bit-math.js"),x=b(a+"/lib/buffer-string.js"),y=b(a+"/constructor-registry.js"),E=b(a+"/recursive-registry.js"),v=b(a+"/lib/strint.js"),q=b(a+"/structure-types.js"),J=b("/lib/util-inspect.js"),O=[q.ByteType,q.ShortType,q.IntType,q.LongType,q.BigIntType,q.UnsignedByteType,q.UnsignedShortType,q.UnsignedIntType,q.UnsignedLongType,q.BigUnsignedIntType,q.DateType,q.DayType,q.TimeType,q.FloatType,q.DoubleType,q.BooleanType,q.BooleanArrayType,q.CharType,q.StringType, q.OctetsType],G=new WeakMap,L=new WeakMap;e.exports={_consumeType:l,type:function(a,b){b=void 0===b?!0:b;m.instanceOf(a,ArrayBuffer);var c=l(a,0),d=c.value,c=c.length;b&&m.assert(c===a.byteLength,"Did not consume all of the buffer");return d},value:function(a){var b=a.buffer,c=a.type;a=void 0===a.offset?0:a.offset;m.instanceOf(b,ArrayBuffer);m.instanceOf(c,q.Type);m.instanceOf(a,Number);return r({buffer:b,offset:a,type:c,pointerStart:a}).value}}}).call(this,"/")},{"/lib/util-inspect.js":"/lib/util-inspect.js"}], "/recursive-registry.js":[function(b,e){(function(a){"/"===a&&(a="");var h=b(a+"/lib/assert.js"),d=b(a+"/structure-types.js"),c=new Map;e.exports={registerType:function(a){var b=a.type;a=a.name;h.instanceOf(b,[d.ArrayType,d.MapType,d.SetType,d.StructType,d.TupleType]);h.instanceOf(a,String);h.assert(!c.has(a),'"'+a+'" is already a registered type');c.set(a,b)},getType:function(a){h.instanceOf(a,String);var b=c.get(a);h.assert(void 0!==b,'"'+a+'" is not a registered type');return b},isRegistered:function(a){return c.has(a)}}}).call(this, -"/")},{}],"/structure-types.js":[function(b,e){(function(a){function h(a){n.instanceOf(a,w);this.type=a}function d(a){w.call(this);n.instanceOf(a,F);this.type=a}function c(a){w.call(this);n.instanceOf(a,String);this.name=a}function t(a){w.call(this);n.instanceOf(a,Map);try{n.byteUnsignedInteger(a.size)}catch(X){n.fail(String(a.size)+" types is too many")}this.indexConstructors=new Map;this.constructorTypes=Array(a.size);var b=new Set;a=f.makeIterator(a);for(var c=a.next();!c.done;c=a.next()){var d= -f.makeIterator(c.value),c=d.next().value,d=d.next().value;n.instanceOf(c,Function);var B=c.name;n.assert(B,'Function "'+String(B)+'" does not have a name');n.assert(!b.has(B),'Function name "'+B+'" is repeated');b.add(B);var e=S.fromString(B);try{n.byteUnsignedInteger(e.byteLength)}catch(X){n.fail('Function name "'+B+'" is too long')}n.instanceOf(d,y);B=this.indexConstructors.size;this.indexConstructors.set(B,c);this.constructorTypes[B]={nameBuffer:e,type:d}}}function r(a){w.call(this);n.instanceOf(a, -Array);try{n.byteUnsignedInteger(a.length)}catch(ra){n.fail(String(a.length)+" types is too many")}for(var b=f.makeIterator(a),c=b.next();!c.done;c=b.next())n.instanceOf(c.value,F);this.types=a}function l(a){var b=a.type;a=a.values;n.instanceOf(b,w);n.instanceOf(a,Array);try{n.byteUnsignedInteger(a.length)}catch(X){n.fail(String(a.length)+" values is too many")}for(var c=new Map,d=0;db.name)return 1})}function E(a){var b=a.type;a=a.length;w.call(this);n.instanceOf(b,F);n.fourByteUnsignedInteger(a);this.type=b;this.length=a}function v(a){w.apply(this,arguments)} +"/")},{}],"/structure-types.js":[function(b,e){(function(a){function h(a){n.instanceOf(a,w);this.type=a}function d(a){w.call(this);n.instanceOf(a,F);this.type=a}function c(a){w.call(this);n.instanceOf(a,String);this.name=a}function t(a){w.call(this);n.instanceOf(a,Map);try{n.byteUnsignedInteger(a.size)}catch(U){n.fail(String(a.size)+" types is too many")}this.indexConstructors=new Map;this.constructorTypes=Array(a.size);var b=new Set;a=f.makeIterator(a);for(var c=a.next();!c.done;c=a.next()){var d= +f.makeIterator(c.value),c=d.next().value,d=d.next().value;n.instanceOf(c,Function);var B=c.name;n.assert(B,'Function "'+String(B)+'" does not have a name');n.assert(!b.has(B),'Function name "'+B+'" is repeated');b.add(B);var e=S.fromString(B);try{n.byteUnsignedInteger(e.byteLength)}catch(U){n.fail('Function name "'+B+'" is too long')}n.instanceOf(d,y);B=this.indexConstructors.size;this.indexConstructors.set(B,c);this.constructorTypes[B]={nameBuffer:e,type:d}}}function r(a){w.call(this);n.instanceOf(a, +Array);try{n.byteUnsignedInteger(a.length)}catch(ra){n.fail(String(a.length)+" types is too many")}for(var b=f.makeIterator(a),c=b.next();!c.done;c=b.next())n.instanceOf(c.value,F);this.types=a}function l(a){var b=a.type;a=a.values;n.instanceOf(b,w);n.instanceOf(a,Array);try{n.byteUnsignedInteger(a.length)}catch(U){n.fail(String(a.length)+" values is too many")}for(var c=new Map,d=0;db.name)return 1})}function E(a){var b=a.type;a=a.length;w.call(this);n.instanceOf(b,F);n.fourByteUnsignedInteger(a);this.type=b;this.length=a}function v(a){w.apply(this,arguments)} function q(a){w.apply(this,arguments)}function J(a){w.apply(this,arguments)}function O(a){w.apply(this,arguments)}function G(a){w.call(this);n.fourByteUnsignedInteger(a);this.length=a}function L(a){w.apply(this,arguments)}function u(a){D.apply(this,arguments)}function z(a){D.apply(this,arguments)}function D(a){w.apply(this,arguments)}function k(a){g.apply(this,arguments)}function I(a){g.apply(this,arguments)}function p(a){g.apply(this,arguments)}function g(a){w.apply(this,arguments)}function N(a){K.apply(this, -arguments)}function H(a){K.apply(this,arguments)}function Q(a){K.apply(this,arguments)}function V(a){K.apply(this,arguments)}function W(a){K.apply(this,arguments)}function K(a){w.apply(this,arguments)}function Y(a){P.apply(this,arguments)}function Z(a){P.apply(this,arguments)}function aa(a){P.apply(this,arguments)}function ba(a){P.apply(this,arguments)}function ca(a){P.apply(this,arguments)}function P(a){w.apply(this,arguments)}function w(a){F.apply(this,arguments)}function F(){}function U(a){var b= +arguments)}function H(a){K.apply(this,arguments)}function Q(a){K.apply(this,arguments)}function W(a){K.apply(this,arguments)}function X(a){K.apply(this,arguments)}function K(a){w.apply(this,arguments)}function Y(a){P.apply(this,arguments)}function Z(a){P.apply(this,arguments)}function aa(a){P.apply(this,arguments)}function ba(a){P.apply(this,arguments)}function ca(a){P.apply(this,arguments)}function P(a){w.apply(this,arguments)}function w(a){F.apply(this,arguments)}function F(){}function V(a){var b= new ArrayBuffer(4);(new DataView(b)).setUint32(0,a);return b}function R(a,b){if(b&&(b=fa.get(a))){b=f.makeIterator(b);for(var c=b.next();!c.done;c=b.next()){var d=f.makeIterator(c.value),c=d.next().value,d=d.next().value,e=a.length;a.addAll(S.fromBinaryString(c));c=new ArrayBuffer(4);(new DataView(c)).setUint32(0,e);d=f.makeIterator(d);for(e=d.next();!e.done;e=d.next())a.setAll(e.value,c)}}}function T(a){if(a&&a.constructor===String&&(a=Number(a),!isNaN(a)))return a}function la(a,b){n.instanceOf(a, A);n.instanceOf(b,String);(C.gt(b,"9223372036854775807")||C.lt(b,"-9223372036854775808"))&&n.fail("Value out of range");var c=C.div(b,C.LONG_UPPER_SHIFT,!0);b=C.sub(b,C.mul(c,C.LONG_UPPER_SHIFT));var d=new ArrayBuffer(8),e=new DataView(d);e.setInt32(0,Number(c));e.setUint32(4,Number(b));a.addAll(d)}function ma(a,b){n.instanceOf(b,Array);for(var c=ga(b.length),d=ha(b.length),c=new ArrayBuffer(c?d+1:d),d=new Uint8Array(c),e=0;e>8);d.setUint8(2,b&255);a.addAll(c)};f.global.Object.defineProperties(I,{_value:{configurable:!0,enumerable:!0,get:function(){return 27}}});f.inherits(k,g);k.prototype.writeValue=function(a,b){n.instanceOf(b,Date);var c=new ArrayBuffer(4);(new DataView(c)).setUint32(0,b.getTime()%864E5);a.addAll(c)};f.global.Object.defineProperties(k,{_value:{configurable:!0,enumerable:!0,get:function(){return 28}}}); f.inherits(D,w);f.inherits(z,D);z.prototype.writeValue=function(a,b){n.instanceOf(a,A);var c=T(b);void 0!==c&&(b=c);n.instanceOf(b,Number);c=new ArrayBuffer(4);(new DataView(c)).setFloat32(0,b);a.addAll(c)};f.global.Object.defineProperties(z,{_value:{configurable:!0,enumerable:!0,get:function(){return 32}}});f.inherits(u,D);u.prototype.writeValue=function(a,b){n.instanceOf(a,A);var c=T(b);void 0!==c&&(b=c);n.instanceOf(b,Number);c=new ArrayBuffer(8);(new DataView(c)).setFloat64(0,b);a.addAll(c)}; -f.global.Object.defineProperties(u,{_value:{configurable:!0,enumerable:!0,get:function(){return 33}}});f.inherits(L,w);L.prototype.writeValue=function(a,b){n.instanceOf(a,A);n.instanceOf(b,Boolean);b?a.add(255):a.add(0)};f.global.Object.defineProperties(L,{_value:{configurable:!0,enumerable:!0,get:function(){return 48}}});f.inherits(G,w);G.prototype.addToBuffer=function(a){w.prototype.addToBuffer.call(this,a)&&a.addAll(U(this.length))};G.prototype.writeValue=function(a,b){n.instanceOf(a,A);n.instanceOf(b, -Array);b.length!==this.length&&n.fail("Length does not match");ma(a,b)};f.global.Object.defineProperties(G,{_value:{configurable:!0,enumerable:!0,get:function(){return 49}}});f.inherits(O,w);O.prototype.writeValue=function(a,b){n.instanceOf(b,Array);n.fourByteUnsignedInteger(b.length);a.addAll(U(b.length));ma(a,b)};f.global.Object.defineProperties(O,{_value:{configurable:!0,enumerable:!0,get:function(){return 50}}});f.inherits(J,w);J.prototype.writeValue=function(a,b){n.instanceOf(a,A);n.instanceOf(b, +f.global.Object.defineProperties(u,{_value:{configurable:!0,enumerable:!0,get:function(){return 33}}});f.inherits(L,w);L.prototype.writeValue=function(a,b){n.instanceOf(a,A);n.instanceOf(b,Boolean);b?a.add(255):a.add(0)};f.global.Object.defineProperties(L,{_value:{configurable:!0,enumerable:!0,get:function(){return 48}}});f.inherits(G,w);G.prototype.addToBuffer=function(a){w.prototype.addToBuffer.call(this,a)&&a.addAll(V(this.length))};G.prototype.writeValue=function(a,b){n.instanceOf(a,A);n.instanceOf(b, +Array);b.length!==this.length&&n.fail("Length does not match");ma(a,b)};f.global.Object.defineProperties(G,{_value:{configurable:!0,enumerable:!0,get:function(){return 49}}});f.inherits(O,w);O.prototype.writeValue=function(a,b){n.instanceOf(b,Array);n.fourByteUnsignedInteger(b.length);a.addAll(V(b.length));ma(a,b)};f.global.Object.defineProperties(O,{_value:{configurable:!0,enumerable:!0,get:function(){return 50}}});f.inherits(J,w);J.prototype.writeValue=function(a,b){n.instanceOf(a,A);n.instanceOf(b, String);n.assert(1===b.length,"String must contain only 1 character");a.addAll(S.fromString(b))};f.global.Object.defineProperties(J,{_value:{configurable:!0,enumerable:!0,get:function(){return 64}}});f.inherits(q,w);q.prototype.writeValue=function(a,b){n.instanceOf(a,A);n.instanceOf(b,String);b=S.fromString(b);a.addAll(b);a.add(0)};f.global.Object.defineProperties(q,{_value:{configurable:!0,enumerable:!0,get:function(){return 65}}});f.inherits(v,w);v.prototype.writeValue=function(a,b){n.instanceOf(a, -A);n.instanceOf(b,ArrayBuffer);n.fourByteUnsignedInteger(b.byteLength);a.addAll(U(b.byteLength));a.addAll(b)};f.global.Object.defineProperties(v,{_value:{configurable:!0,enumerable:!0,get:function(){return 66}}});f.inherits(E,w);E.prototype.addToBuffer=function(a){w.prototype.addToBuffer.call(this,a)&&(this.type.addToBuffer(a),a.addAll(U(this.length)))};E.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;n.instanceOf(a,A);n.instanceOf(b,Array);b.length!==this.length&&n.fail("Length does not match: expected "+ +A);n.instanceOf(b,ArrayBuffer);n.fourByteUnsignedInteger(b.byteLength);a.addAll(V(b.byteLength));a.addAll(b)};f.global.Object.defineProperties(v,{_value:{configurable:!0,enumerable:!0,get:function(){return 66}}});f.inherits(E,w);E.prototype.addToBuffer=function(a){w.prototype.addToBuffer.call(this,a)&&(this.type.addToBuffer(a),a.addAll(V(this.length)))};E.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;n.instanceOf(a,A);n.instanceOf(b,Array);b.length!==this.length&&n.fail("Length does not match: expected "+ String(this.length)+" but got "+b.length);b=f.makeIterator(b);for(var d=b.next();!d.done;d=b.next())this.type.writeValue(a,d.value,!1);R(a,c)};f.global.Object.defineProperties(E,{_value:{configurable:!0,enumerable:!0,get:function(){return 80}}});f.inherits(y,w);y.prototype.addToBuffer=function(a){if(w.prototype.addToBuffer.call(this,a)){a.add(this.fields.length);for(var b=f.makeIterator(this.fields),c=b.next();!c.done;c=b.next()){var c=c.value,d=c.buffer;a.add(d.byteLength);a.addAll(d);c.type.addToBuffer(a)}}}; -y.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;n.instanceOf(a,A);n.instanceOf(b,Object);for(var d=f.makeIterator(this.fields),e=d.next();!e.done;e=d.next()){var e=e.value,g=b[e.name];void 0===g&&n.fail('Value for field "'+e.name+'" missing');e.type.writeValue(a,g,!1)}R(a,c)};f.global.Object.defineProperties(y,{_value:{configurable:!0,enumerable:!0,get:function(){return 81}}});f.inherits(x,w);x.prototype.addToBuffer=function(a){w.prototype.addToBuffer.call(this,a)&&this.type.addToBuffer(a)}; -x.prototype._writeValue=function(a,b,c){n.instanceOf(a,A);var d=b.length;void 0===d&&(d=b.size);n.fourByteUnsignedInteger(d);a.addAll(U(d));b=f.makeIterator(b);for(d=b.next();!d.done;d=b.next())this.type.writeValue(a,d.value,!1);R(a,c)};x.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;n.instanceOf(b,Array);this._writeValue(a,b,c)};f.global.Object.defineProperties(x,{_value:{configurable:!0,enumerable:!0,get:function(){return 82}}});f.inherits(M,x);M.prototype.writeValue=function(a,b,c){c= -void 0===c?!0:c;n.instanceOf(b,Set);this._writeValue(a,b,c)};f.global.Object.defineProperties(M,{_value:{configurable:!0,enumerable:!0,get:function(){return 83}}});f.inherits(m,w);m.prototype.addToBuffer=function(a){w.prototype.addToBuffer.call(this,a)&&(this.keyType.addToBuffer(a),this.valueType.addToBuffer(a))};m.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;n.instanceOf(a,A);n.instanceOf(b,Map);n.fourByteUnsignedInteger(b.size);a.addAll(U(b.size));b=f.makeIterator(b);for(var d=b.next();!d.done;d= -b.next()){var e=f.makeIterator(d.value),d=e.next().value,e=e.next().value;this.keyType.writeValue(a,d,!1);this.valueType.writeValue(a,e,!1)}R(a,c)};f.global.Object.defineProperties(m,{_value:{configurable:!0,enumerable:!0,get:function(){return 84}}});f.inherits(l,F);l.prototype.addToBuffer=function(a){if(F.prototype.addToBuffer.call(this,a)){this.type.addToBuffer(a);a.add(this.valueIndices.size);for(var b=f.makeIterator(this.valueIndices),c=b.next();!c.done;c=b.next()){var c=f.makeIterator(c.value), -d=c.next().value;c.next();a.addAll(S.fromBinaryString(d))}}};l.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;n.instanceOf(a,A);var d=new A;this.type.writeValue(d,b,!1);d=this.valueIndices.get(S.toBinaryString(d.toBuffer()));n.assert(void 0!==d,"Not a valid enum value: "+da.inspect(b));a.add(d);R(a,c)};f.global.Object.defineProperties(l,{_value:{configurable:!0,enumerable:!0,get:function(){return 85}}});f.inherits(r,w);r.prototype.addToBuffer=function(a){if(w.prototype.addToBuffer.call(this, +y.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;n.instanceOf(a,A);n.instanceOf(b,Object);for(var d=f.makeIterator(this.fields),e=d.next();!e.done;e=d.next()){var e=e.value,g=b[e.name];try{e.type.writeValue(a,g,!1)}catch(U){throw void 0===g&&n.fail('Value for field "'+e.name+'" missing'),U;}}R(a,c)};f.global.Object.defineProperties(y,{_value:{configurable:!0,enumerable:!0,get:function(){return 81}}});f.inherits(x,w);x.prototype.addToBuffer=function(a){w.prototype.addToBuffer.call(this,a)&& +this.type.addToBuffer(a)};x.prototype._writeValue=function(a,b,c){n.instanceOf(a,A);var d=b.length;void 0===d&&(d=b.size);n.fourByteUnsignedInteger(d);a.addAll(V(d));b=f.makeIterator(b);for(d=b.next();!d.done;d=b.next())this.type.writeValue(a,d.value,!1);R(a,c)};x.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;n.instanceOf(b,Array);this._writeValue(a,b,c)};f.global.Object.defineProperties(x,{_value:{configurable:!0,enumerable:!0,get:function(){return 82}}});f.inherits(M,x);M.prototype.writeValue= +function(a,b,c){c=void 0===c?!0:c;n.instanceOf(b,Set);this._writeValue(a,b,c)};f.global.Object.defineProperties(M,{_value:{configurable:!0,enumerable:!0,get:function(){return 83}}});f.inherits(m,w);m.prototype.addToBuffer=function(a){w.prototype.addToBuffer.call(this,a)&&(this.keyType.addToBuffer(a),this.valueType.addToBuffer(a))};m.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;n.instanceOf(a,A);n.instanceOf(b,Map);n.fourByteUnsignedInteger(b.size);a.addAll(V(b.size));b=f.makeIterator(b); +for(var d=b.next();!d.done;d=b.next()){var e=f.makeIterator(d.value),d=e.next().value,e=e.next().value;this.keyType.writeValue(a,d,!1);this.valueType.writeValue(a,e,!1)}R(a,c)};f.global.Object.defineProperties(m,{_value:{configurable:!0,enumerable:!0,get:function(){return 84}}});f.inherits(l,F);l.prototype.addToBuffer=function(a){if(F.prototype.addToBuffer.call(this,a)){this.type.addToBuffer(a);a.add(this.valueIndices.size);for(var b=f.makeIterator(this.valueIndices),c=b.next();!c.done;c=b.next()){var c= +f.makeIterator(c.value),d=c.next().value;c.next();a.addAll(S.fromBinaryString(d))}}};l.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;n.instanceOf(a,A);var d=new A;this.type.writeValue(d,b,!1);d=this.valueIndices.get(S.toBinaryString(d.toBuffer()));n.assert(void 0!==d,"Not a valid enum value: "+da.inspect(b));a.add(d);R(a,c)};f.global.Object.defineProperties(l,{_value:{configurable:!0,enumerable:!0,get:function(){return 85}}});f.inherits(r,w);r.prototype.addToBuffer=function(a){if(w.prototype.addToBuffer.call(this, a)){a.add(this.types.length);for(var b=f.makeIterator(this.types),c=b.next();!c.done;c=b.next())c.value.addToBuffer(a)}};r.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;n.instanceOf(a,A);for(var d=!1,e=0;ed)throw Error("Illegal state");}};a.div= function(a,b,c){c=void 0===c?!1:c;n(a);n(b);var d=S(E(a),E(b))[0];R(a,b)||(d=N(d));!c||v(Q(d,b),a)||R(a,b)||(d=O(d,"1"));return d};var v=a.eq=function(a,b){return H(a)===H(b)},G=a.lt=function(a,b){return z(a)&&I(b)?!0:I(a)&&z(b)?!1:z(a)&&z(b)?!v(a,b)&&!k(E(a),E(b)):k(a,b)},F=a.ge=function(a,b){return!G(a,b)},W=a.gt=function(a,b){return v(a,b)?!1:F(a,b)},z=a.isNegative=function(a){n(a);return 0===a.indexOf("-")},I=a.isPositive=function(a){return!z(a)},E=a.abs=function(a){return z(a)?N(a):a},N=a.negate= -function(a){return"0"===a?"0":z(a)?a.slice(1):"-"+a},Y=/^(-?)0*([1-9][0-9]*)$/,Z=/^0+$/,H=a.normalize=function(a){if(Z.test(a))return"0";var b=Y.exec(a);if(!b)throw Error("Illegal strint format: "+a);return b[1]+b[2]}})();a.LONG_UPPER_SHIFT="4294967296";a.BYTE_SHIFT="256";g.exports=a},{}],"/lib/util-inspect.js":[function(c,g,a){a.inspect=function(c){if(void 0===c)return"undefined";if(null===c||c.constructor===Object||c.constructor===Array||c.constructor===String||c.constructor===Number||c.constructor=== +function(a){return"0"===a?"0":z(a)?a.slice(1):"-"+a},Z=/^(-?)0*([1-9][0-9]*)$/,aa=/^0+$/,H=a.normalize=function(a){if(aa.test(a))return"0";var b=Z.exec(a);if(!b)throw Error("Illegal strint format: "+a);return b[1]+b[2]}})();a.LONG_UPPER_SHIFT="4294967296";a.BYTE_SHIFT="256";g.exports=a},{}],"/lib/util-inspect.js":[function(c,g,a){a.inspect=function(c){if(void 0===c)return"undefined";if(null===c||c.constructor===Object||c.constructor===Array||c.constructor===String||c.constructor===Number||c.constructor=== Boolean||c.constructor===Date)return JSON.stringify(c);if(c.constructor===Set){var d="Set {";c=c.values();for(var b=c.next();!b.done;)d+=a.inspect(b.value),b=c.next(),b.done||(d+=", ");return d+"}"}if(c.constructor===Map){d="Map {";c=c.entries();for(b=c.next();!b.done;)d+=a.inspect(b.value[0]),d+=" \x3d\x3e ",d+=a.inspect(b.value[1]),b=c.next(),b.done||(d+=", ");return d+"}"}return c.constructor.name?c.constructor.name+" "+JSON.stringify(c):JSON.stringify(c)}},{}],1:[function(c){(function(){c("/client-side/common.js"); var g=c("/lib/assert.js");sb.upload=function(a,c){var d=a.type;a=a.value;g.instanceOf(d,sb.Type);g.instanceOf(c,Object);"POST"!==c.type&&"POST"!==c.method&&g.fail("Must use POST when uploading");c.processData=!1;c.data=d.valueBuffer(a);$.ajax(c)}})()},{"/client-side/common.js":"/client-side/common.js","/lib/assert.js":"/lib/assert.js"}],2:[function(c,g,a){function e(a){var b=a.length;if(0>18&63]+b[c>>12&63]+b[c>>6&63]+b[c&63]);return g.join("")}a.byteLength=function(a){return 3*a.length/4-e(a)};a.toByteArray=function(a){var b,c,d,g,l;b=a.length;g=e(a);l=new k(3*b/4-g);c=0>16&255,l[u++]=d>>8&255,l[u++]=d&255;2===g?(d=m[a.charCodeAt(b)]<<2|m[a.charCodeAt(b+1)]>> @@ -51,14 +51,14 @@ function d(a,c,d){for(var g=[],e=c;ev;v++){if(16>v)m[v]=l[A+v]|0;else{var G=m[v-15],F=m[v-2];m[v]=((G<<25|G>>>7)^(G<<14|G>>>18)^G>>>3)+m[v-7]+((F<<15|F>>>17)^(F<<13|F>>>19)^F>>>10)+m[v-16]}G=S+((B<<26|B>>>6)^(B<<21|B>>>11)^(B<<7|B>>>25))+(B&P^~B&Q)+b[v]+m[v];F=((u<<30|u>>>2)^(u<<19|u>>>13)^(u<<10|u>>>22))+(u&K^u&J^K&J);S=Q;Q=P;P=B;B=O+G|0;O=J;J=K;K=u;u=G+F|0}e[0]=e[0]+u|0;e[1]=e[1]+K|0;e[2]=e[2]+J|0;e[3]=e[3]+O|0;e[4]=e[4]+B|0;e[5]=e[5]+P|0;e[6]=e[6]+Q|0;e[7]=e[7]+S|0}k=[];for(a=0;a<32*g.length;a+=8)k.push(g[a>>>5]>>>24- a%32&255);return c&&c.asBytes?k:c&&c.asString?d.convertString.bytesToString(k):d.bytesToHex(k)}var d={};"undefined"!==typeof g&&g.exports?(d.bytesToHex=c("convert-hex").bytesToHex,d.convertString=c("convert-string"),g.exports=e):(d.bytesToHex=a.convertHex.bytesToHex,d.convertString=a.convertString,a.sha256=e);var b=[];!function(){function a(a){for(var b=Math.sqrt(a),c=2;c<=b;c++)if(!(a%c))return!1;return!0}function c(a){return 4294967296*(a-(a|0))|0}for(var d=2,e=0;64>e;)a(d)&&(b[e]=c(Math.pow(d, 1/3)),e++),d++}();var m=[];e.x2=function(a,b){return e(e(a,{asBytes:!0}),b)}}(this)},{"convert-hex":3,"convert-string":4}],"/recursive-registry.js":[function(c,g){(function(a){"/"===a&&(a="");var e=c(a+"/lib/assert.js"),d=c(a+"/structure-types.js"),b=new Map;g.exports={registerType:function(a){var c=a.type;a=a.name;e.instanceOf(c,[d.ArrayType,d.MapType,d.SetType,d.StructType,d.TupleType]);e.instanceOf(a,String);e.assert(!b.has(a),'"'+a+'" is already a registered type');b.set(a,c)},getType:function(a){e.instanceOf(a, -String);var c=b.get(a);e.assert(void 0!==c,'"'+a+'" is not a registered type');return c},isRegistered:function(a){return b.has(a)}}}).call(this,"/")},{}],"/structure-types.js":[function(c,g){(function(a){function e(a){h.instanceOf(a,p);this.type=a}function d(a){p.call(this);h.instanceOf(a,w);this.type=a}function b(a){p.call(this);h.instanceOf(a,String);this.name=a}function m(a){p.call(this);h.instanceOf(a,Map);try{h.byteUnsignedInteger(a.size)}catch(aa){h.fail(String(a.size)+" types is too many")}this.indexConstructors= -new Map;this.constructorTypes=Array(a.size);var b=new Set;a=f.makeIterator(a);for(var c=a.next();!c.done;c=a.next()){var C=f.makeIterator(c.value),c=C.next().value,C=C.next().value;h.instanceOf(c,Function);var d=c.name;h.assert(d,'Function "'+String(d)+'" does not have a name');h.assert(!b.has(d),'Function name "'+d+'" is repeated');b.add(d);var e=U.fromString(d);try{h.byteUnsignedInteger(e.byteLength)}catch(aa){h.fail('Function name "'+d+'" is too long')}h.instanceOf(C,q);d=this.indexConstructors.size; -this.indexConstructors.set(d,c);this.constructorTypes[d]={nameBuffer:e,type:C}}}function k(a){p.call(this);h.instanceOf(a,Array);try{h.byteUnsignedInteger(a.length)}catch(ra){h.fail(String(a.length)+" types is too many")}for(var b=f.makeIterator(a),c=b.next();!c.done;c=b.next())h.instanceOf(c.value,w);this.types=a}function l(a){var b=a.type;a=a.values;h.instanceOf(b,p);h.instanceOf(a,Array);try{h.byteUnsignedInteger(a.length)}catch(aa){h.fail(String(a.length)+" values is too many")}for(var c=new Map, -d=0;db.name)return 1})}function A(a){var b=a.type;a=a.length;p.call(this);h.instanceOf(b, +String);var c=b.get(a);e.assert(void 0!==c,'"'+a+'" is not a registered type');return c},isRegistered:function(a){return b.has(a)}}}).call(this,"/")},{}],"/structure-types.js":[function(c,g){(function(a){function e(a){h.instanceOf(a,p);this.type=a}function d(a){p.call(this);h.instanceOf(a,w);this.type=a}function b(a){p.call(this);h.instanceOf(a,String);this.name=a}function m(a){p.call(this);h.instanceOf(a,Map);try{h.byteUnsignedInteger(a.size)}catch(X){h.fail(String(a.size)+" types is too many")}this.indexConstructors= +new Map;this.constructorTypes=Array(a.size);var b=new Set;a=f.makeIterator(a);for(var c=a.next();!c.done;c=a.next()){var C=f.makeIterator(c.value),c=C.next().value,C=C.next().value;h.instanceOf(c,Function);var d=c.name;h.assert(d,'Function "'+String(d)+'" does not have a name');h.assert(!b.has(d),'Function name "'+d+'" is repeated');b.add(d);var e=U.fromString(d);try{h.byteUnsignedInteger(e.byteLength)}catch(X){h.fail('Function name "'+d+'" is too long')}h.instanceOf(C,q);d=this.indexConstructors.size; +this.indexConstructors.set(d,c);this.constructorTypes[d]={nameBuffer:e,type:C}}}function k(a){p.call(this);h.instanceOf(a,Array);try{h.byteUnsignedInteger(a.length)}catch(ra){h.fail(String(a.length)+" types is too many")}for(var b=f.makeIterator(a),c=b.next();!c.done;c=b.next())h.instanceOf(c.value,w);this.types=a}function l(a){var b=a.type;a=a.values;h.instanceOf(b,p);h.instanceOf(a,Array);try{h.byteUnsignedInteger(a.length)}catch(X){h.fail(String(a.length)+" values is too many")}for(var c=new Map, +d=0;db.name)return 1})}function A(a){var b=a.type;a=a.length;p.call(this);h.instanceOf(b, w);h.fourByteUnsignedInteger(a);this.type=b;this.length=a}function u(a){p.apply(this,arguments)}function K(a){p.apply(this,arguments)}function J(a){p.apply(this,arguments)}function O(a){p.apply(this,arguments)}function B(a){p.call(this);h.fourByteUnsignedInteger(a);this.length=a}function P(a){p.apply(this,arguments)}function Q(a){v.apply(this,arguments)}function S(a){v.apply(this,arguments)}function v(a){p.apply(this,arguments)}function G(a){z.apply(this,arguments)}function F(a){z.apply(this,arguments)} -function W(a){z.apply(this,arguments)}function z(a){p.apply(this,arguments)}function I(a){H.apply(this,arguments)}function E(a){H.apply(this,arguments)}function N(a){H.apply(this,arguments)}function Y(a){H.apply(this,arguments)}function Z(a){H.apply(this,arguments)}function H(a){p.apply(this,arguments)}function y(a){M.apply(this,arguments)}function L(a){M.apply(this,arguments)}function ba(a){M.apply(this,arguments)}function ca(a){M.apply(this,arguments)}function da(a){M.apply(this,arguments)}function M(a){p.apply(this, -arguments)}function p(a){w.apply(this,arguments)}function w(){}function X(a){var b=new ArrayBuffer(4);(new DataView(b)).setUint32(0,a);return b}function T(a,b){if(b&&(b=ga.get(a))){b=f.makeIterator(b);for(var c=b.next();!c.done;c=b.next()){var d=f.makeIterator(c.value),c=d.next().value,d=d.next().value,D=a.length;a.addAll(U.fromBinaryString(c));c=new ArrayBuffer(4);(new DataView(c)).setUint32(0,D);d=f.makeIterator(d);for(D=d.next();!D.done;D=d.next())a.setAll(D.value,c)}}}function V(a){if(a&&a.constructor=== +function W(a){z.apply(this,arguments)}function z(a){p.apply(this,arguments)}function I(a){H.apply(this,arguments)}function E(a){H.apply(this,arguments)}function N(a){H.apply(this,arguments)}function Z(a){H.apply(this,arguments)}function aa(a){H.apply(this,arguments)}function H(a){p.apply(this,arguments)}function y(a){M.apply(this,arguments)}function L(a){M.apply(this,arguments)}function ba(a){M.apply(this,arguments)}function ca(a){M.apply(this,arguments)}function da(a){M.apply(this,arguments)}function M(a){p.apply(this, +arguments)}function p(a){w.apply(this,arguments)}function w(){}function Y(a){var b=new ArrayBuffer(4);(new DataView(b)).setUint32(0,a);return b}function T(a,b){if(b&&(b=ga.get(a))){b=f.makeIterator(b);for(var c=b.next();!c.done;c=b.next()){var d=f.makeIterator(c.value),c=d.next().value,d=d.next().value,D=a.length;a.addAll(U.fromBinaryString(c));c=new ArrayBuffer(4);(new DataView(c)).setUint32(0,D);d=f.makeIterator(d);for(D=d.next();!D.done;D=d.next())a.setAll(D.value,c)}}}function V(a){if(a&&a.constructor=== String&&(a=Number(a),!isNaN(a)))return a}function la(a,b){h.instanceOf(a,r);h.instanceOf(b,String);(t.gt(b,"9223372036854775807")||t.lt(b,"-9223372036854775808"))&&h.fail("Value out of range");var c=t.div(b,t.LONG_UPPER_SHIFT,!0);b=t.sub(b,t.mul(c,t.LONG_UPPER_SHIFT));var d=new ArrayBuffer(8),D=new DataView(d);D.setInt32(0,Number(c));D.setUint32(4,Number(b));a.addAll(d)}function ma(a,b){h.instanceOf(b,Array);for(var c=ha(b.length),d=ia(b.length),c=new ArrayBuffer(c?d+1:d),d=new Uint8Array(c),D=0;D< b.length;D++){var C=b[D];h.instanceOf(C,Boolean);var e=ha(~ha(D));C?d[ia(D)]|=1<>8);d.setUint8(2,b&255);a.addAll(c)};f.global.Object.defineProperties(F,{_value:{configurable:!0,enumerable:!0,get:function(){return 27}}});f.inherits(G,z);G.prototype.writeValue=function(a,b){h.instanceOf(b,Date);var c=new ArrayBuffer(4);(new DataView(c)).setUint32(0,b.getTime()%864E5);a.addAll(c)};f.global.Object.defineProperties(G, {_value:{configurable:!0,enumerable:!0,get:function(){return 28}}});f.inherits(v,p);f.inherits(S,v);S.prototype.writeValue=function(a,b){h.instanceOf(a,r);var c=V(b);void 0!==c&&(b=c);h.instanceOf(b,Number);c=new ArrayBuffer(4);(new DataView(c)).setFloat32(0,b);a.addAll(c)};f.global.Object.defineProperties(S,{_value:{configurable:!0,enumerable:!0,get:function(){return 32}}});f.inherits(Q,v);Q.prototype.writeValue=function(a,b){h.instanceOf(a,r);var c=V(b);void 0!==c&&(b=c);h.instanceOf(b,Number); -c=new ArrayBuffer(8);(new DataView(c)).setFloat64(0,b);a.addAll(c)};f.global.Object.defineProperties(Q,{_value:{configurable:!0,enumerable:!0,get:function(){return 33}}});f.inherits(P,p);P.prototype.writeValue=function(a,b){h.instanceOf(a,r);h.instanceOf(b,Boolean);b?a.add(255):a.add(0)};f.global.Object.defineProperties(P,{_value:{configurable:!0,enumerable:!0,get:function(){return 48}}});f.inherits(B,p);B.prototype.addToBuffer=function(a){p.prototype.addToBuffer.call(this,a)&&a.addAll(X(this.length))}; -B.prototype.writeValue=function(a,b){h.instanceOf(a,r);h.instanceOf(b,Array);b.length!==this.length&&h.fail("Length does not match");ma(a,b)};f.global.Object.defineProperties(B,{_value:{configurable:!0,enumerable:!0,get:function(){return 49}}});f.inherits(O,p);O.prototype.writeValue=function(a,b){h.instanceOf(b,Array);h.fourByteUnsignedInteger(b.length);a.addAll(X(b.length));ma(a,b)};f.global.Object.defineProperties(O,{_value:{configurable:!0,enumerable:!0,get:function(){return 50}}});f.inherits(J, +c=new ArrayBuffer(8);(new DataView(c)).setFloat64(0,b);a.addAll(c)};f.global.Object.defineProperties(Q,{_value:{configurable:!0,enumerable:!0,get:function(){return 33}}});f.inherits(P,p);P.prototype.writeValue=function(a,b){h.instanceOf(a,r);h.instanceOf(b,Boolean);b?a.add(255):a.add(0)};f.global.Object.defineProperties(P,{_value:{configurable:!0,enumerable:!0,get:function(){return 48}}});f.inherits(B,p);B.prototype.addToBuffer=function(a){p.prototype.addToBuffer.call(this,a)&&a.addAll(Y(this.length))}; +B.prototype.writeValue=function(a,b){h.instanceOf(a,r);h.instanceOf(b,Array);b.length!==this.length&&h.fail("Length does not match");ma(a,b)};f.global.Object.defineProperties(B,{_value:{configurable:!0,enumerable:!0,get:function(){return 49}}});f.inherits(O,p);O.prototype.writeValue=function(a,b){h.instanceOf(b,Array);h.fourByteUnsignedInteger(b.length);a.addAll(Y(b.length));ma(a,b)};f.global.Object.defineProperties(O,{_value:{configurable:!0,enumerable:!0,get:function(){return 50}}});f.inherits(J, p);J.prototype.writeValue=function(a,b){h.instanceOf(a,r);h.instanceOf(b,String);h.assert(1===b.length,"String must contain only 1 character");a.addAll(U.fromString(b))};f.global.Object.defineProperties(J,{_value:{configurable:!0,enumerable:!0,get:function(){return 64}}});f.inherits(K,p);K.prototype.writeValue=function(a,b){h.instanceOf(a,r);h.instanceOf(b,String);b=U.fromString(b);a.addAll(b);a.add(0)};f.global.Object.defineProperties(K,{_value:{configurable:!0,enumerable:!0,get:function(){return 65}}}); -f.inherits(u,p);u.prototype.writeValue=function(a,b){h.instanceOf(a,r);h.instanceOf(b,ArrayBuffer);h.fourByteUnsignedInteger(b.byteLength);a.addAll(X(b.byteLength));a.addAll(b)};f.global.Object.defineProperties(u,{_value:{configurable:!0,enumerable:!0,get:function(){return 66}}});f.inherits(A,p);A.prototype.addToBuffer=function(a){p.prototype.addToBuffer.call(this,a)&&(this.type.addToBuffer(a),a.addAll(X(this.length)))};A.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;h.instanceOf(a,r);h.instanceOf(b, +f.inherits(u,p);u.prototype.writeValue=function(a,b){h.instanceOf(a,r);h.instanceOf(b,ArrayBuffer);h.fourByteUnsignedInteger(b.byteLength);a.addAll(Y(b.byteLength));a.addAll(b)};f.global.Object.defineProperties(u,{_value:{configurable:!0,enumerable:!0,get:function(){return 66}}});f.inherits(A,p);A.prototype.addToBuffer=function(a){p.prototype.addToBuffer.call(this,a)&&(this.type.addToBuffer(a),a.addAll(Y(this.length)))};A.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;h.instanceOf(a,r);h.instanceOf(b, Array);b.length!==this.length&&h.fail("Length does not match: expected "+String(this.length)+" but got "+b.length);b=f.makeIterator(b);for(var d=b.next();!d.done;d=b.next())this.type.writeValue(a,d.value,!1);T(a,c)};f.global.Object.defineProperties(A,{_value:{configurable:!0,enumerable:!0,get:function(){return 80}}});f.inherits(q,p);q.prototype.addToBuffer=function(a){if(p.prototype.addToBuffer.call(this,a)){a.add(this.fields.length);for(var b=f.makeIterator(this.fields),c=b.next();!c.done;c=b.next()){var c= -c.value,d=c.buffer;a.add(d.byteLength);a.addAll(d);c.type.addToBuffer(a)}}};q.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;h.instanceOf(a,r);h.instanceOf(b,Object);for(var d=f.makeIterator(this.fields),e=d.next();!e.done;e=d.next()){var e=e.value,g=b[e.name];void 0===g&&h.fail('Value for field "'+e.name+'" missing');e.type.writeValue(a,g,!1)}T(a,c)};f.global.Object.defineProperties(q,{_value:{configurable:!0,enumerable:!0,get:function(){return 81}}});f.inherits(n,p);n.prototype.addToBuffer= -function(a){p.prototype.addToBuffer.call(this,a)&&this.type.addToBuffer(a)};n.prototype._writeValue=function(a,b,c){h.instanceOf(a,r);var d=b.length;void 0===d&&(d=b.size);h.fourByteUnsignedInteger(d);a.addAll(X(d));b=f.makeIterator(b);for(d=b.next();!d.done;d=b.next())this.type.writeValue(a,d.value,!1);T(a,c)};n.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;h.instanceOf(b,Array);this._writeValue(a,b,c)};f.global.Object.defineProperties(n,{_value:{configurable:!0,enumerable:!0,get:function(){return 82}}}); -f.inherits(x,n);x.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;h.instanceOf(b,Set);this._writeValue(a,b,c)};f.global.Object.defineProperties(x,{_value:{configurable:!0,enumerable:!0,get:function(){return 83}}});f.inherits(R,p);R.prototype.addToBuffer=function(a){p.prototype.addToBuffer.call(this,a)&&(this.keyType.addToBuffer(a),this.valueType.addToBuffer(a))};R.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;h.instanceOf(a,r);h.instanceOf(b,Map);h.fourByteUnsignedInteger(b.size); -a.addAll(X(b.size));b=f.makeIterator(b);for(var d=b.next();!d.done;d=b.next()){var e=f.makeIterator(d.value),d=e.next().value,e=e.next().value;this.keyType.writeValue(a,d,!1);this.valueType.writeValue(a,e,!1)}T(a,c)};f.global.Object.defineProperties(R,{_value:{configurable:!0,enumerable:!0,get:function(){return 84}}});f.inherits(l,w);l.prototype.addToBuffer=function(a){if(w.prototype.addToBuffer.call(this,a)){this.type.addToBuffer(a);a.add(this.valueIndices.size);for(var b=f.makeIterator(this.valueIndices), -c=b.next();!c.done;c=b.next()){var c=f.makeIterator(c.value),d=c.next().value;c.next();a.addAll(U.fromBinaryString(d))}}};l.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;h.instanceOf(a,r);var d=new r;this.type.writeValue(d,b,!1);d=this.valueIndices.get(U.toBinaryString(d.toBuffer()));h.assert(void 0!==d,"Not a valid enum value: "+ea.inspect(b));a.add(d);T(a,c)};f.global.Object.defineProperties(l,{_value:{configurable:!0,enumerable:!0,get:function(){return 85}}});f.inherits(k,p);k.prototype.addToBuffer= -function(a){if(p.prototype.addToBuffer.call(this,a)){a.add(this.types.length);for(var b=f.makeIterator(this.types),c=b.next();!c.done;c=b.next())c.value.addToBuffer(a)}};k.prototype.writeValue=function(a,b,c){c=void 0===c?!0:c;h.instanceOf(a,r);for(var d=!1,e=0;eParameters:
Source:
@@ -1152,7 +1152,7 @@
Parameters:
Source:
diff --git a/docs/ChoiceType.html b/docs/ChoiceType.html index bc58d9e..757edc4 100644 --- a/docs/ChoiceType.html +++ b/docs/ChoiceType.html @@ -145,7 +145,7 @@
Parameters:
Source:
@@ -1159,7 +1159,7 @@
Parameters:
Source:
diff --git a/docs/EnumType.html b/docs/EnumType.html index c69679d..d96d640 100644 --- a/docs/EnumType.html +++ b/docs/EnumType.html @@ -214,7 +214,7 @@
Properties
Source:
@@ -1232,7 +1232,7 @@
Parameters:
Source:
diff --git a/docs/GrowableBuffer.html b/docs/GrowableBuffer.html index 55fcc51..fdee1dc 100644 --- a/docs/GrowableBuffer.html +++ b/docs/GrowableBuffer.html @@ -1338,7 +1338,7 @@

toBufferSource:
diff --git a/docs/MapType.html b/docs/MapType.html index 5148989..d9a91d8 100644 --- a/docs/MapType.html +++ b/docs/MapType.html @@ -164,7 +164,7 @@
Parameters:
Source:
@@ -1178,7 +1178,7 @@
Parameters:
Source:
diff --git a/docs/NamedChoiceType.html b/docs/NamedChoiceType.html index 8b0c0b0..d75a307 100644 --- a/docs/NamedChoiceType.html +++ b/docs/NamedChoiceType.html @@ -156,7 +156,7 @@
Parameters:
Source:
@@ -1189,7 +1189,7 @@
Parameters:
Source:
diff --git a/docs/OptionalType.html b/docs/OptionalType.html index 037d65a..452a98a 100644 --- a/docs/OptionalType.html +++ b/docs/OptionalType.html @@ -142,7 +142,7 @@
Parameters:
Source:
@@ -1162,7 +1162,7 @@
Parameters:
Source:
diff --git a/docs/PointerType.html b/docs/PointerType.html index b20c28d..9869d7b 100644 --- a/docs/PointerType.html +++ b/docs/PointerType.html @@ -144,7 +144,7 @@
Parameters:
Source:
@@ -1165,7 +1165,7 @@
Parameters:
Source:
diff --git a/docs/RecursiveType.html b/docs/RecursiveType.html index 9244a28..3059ef7 100644 --- a/docs/RecursiveType.html +++ b/docs/RecursiveType.html @@ -145,7 +145,7 @@
Parameters:
Source:
@@ -1163,7 +1163,7 @@
Parameters:
Source:
diff --git a/docs/SetType.html b/docs/SetType.html index 12eb8c1..3ca3b68 100644 --- a/docs/SetType.html +++ b/docs/SetType.html @@ -93,7 +93,7 @@

new SetTypeSource:
@@ -1104,7 +1104,7 @@
Parameters:
Source:
diff --git a/docs/lib_growable-buffer.js.html b/docs/lib_growable-buffer.js.html index dfbb760..a5ce603 100644 --- a/docs/lib_growable-buffer.js.html +++ b/docs/lib_growable-buffer.js.html @@ -162,6 +162,7 @@

Source: lib/growable-buffer.js

* @return {GrowableBuffer} {@link this} */ addAll(buffer) { + assert.instanceOf(buffer, ArrayBuffer) const oldSize = this.size const newSize = this.size + buffer.byteLength this.grow(newSize) diff --git a/docs/structure-types.js.html b/docs/structure-types.js.html index 1c3c0e0..e85c150 100644 --- a/docs/structure-types.js.html +++ b/docs/structure-types.js.html @@ -1011,8 +1011,13 @@

Source: structure-types.js

assert.instanceOf(value, Object) for (const field of this.fields) { const fieldValue = value[field[NAME]] - if (fieldValue === undefined) assert.fail('Value for field "' + field[NAME] + '" missing') - field[TYPE].writeValue(buffer, fieldValue, false) + try { field[TYPE].writeValue(buffer, fieldValue, false) } + catch (writeError) { + //Reporting that field is missing is more useful than, for example, + //Saying "undefined is not an instance of Number" + if (fieldValue === undefined) assert.fail('Value for field "' + field[NAME] + '" missing') + throw writeError //throw original error if field is defined, but just invalid + } } setPointers(buffer, root) } diff --git a/package.json b/package.json index cfe1965..f792fa3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "structure-bytes", - "version": "2.20.9", + "version": "2.21.9", "description": "A library for more efficient data transfers by separating the structure from the values and efficiently storing each as binary data", "main": "index.js", "dependencies": { @@ -15,7 +15,7 @@ "browserify": "13.1.x", "coveralls": "2.11.x", "google-closure-compiler-js": "20161024.0.0", - "nyc": "8.4.x" + "nyc": "9.0.x" }, "directories": { "test": "test" diff --git a/structure-types.js b/structure-types.js index c3b8dae..d9189bb 100644 --- a/structure-types.js +++ b/structure-types.js @@ -983,8 +983,13 @@ class StructType extends AbsoluteType { assert.instanceOf(value, Object) for (const field of this.fields) { const fieldValue = value[field[NAME]] - if (fieldValue === undefined) assert.fail('Value for field "' + field[NAME] + '" missing') - field[TYPE].writeValue(buffer, fieldValue, false) + try { field[TYPE].writeValue(buffer, fieldValue, false) } + catch (writeError) { + //Reporting that field is missing is more useful than, for example, + //Saying "undefined is not an instance of Number" + if (fieldValue === undefined) assert.fail('Value for field "' + field[NAME] + '" missing') + throw writeError //throw original error if field is defined, but just invalid + } } setPointers(buffer, root) } diff --git a/test/value-bytes/struct.js b/test/value-bytes/struct.js index 7dc2009..bae1c9a 100644 --- a/test/value-bytes/struct.js +++ b/test/value-bytes/struct.js @@ -9,6 +9,10 @@ assert.throws( () => type.writeValue(gb, {b: [true]}), 'Value for field "i" missing' ) +assert.throws( + () => type.writeValue(gb, {b: 2}), + '2 is not an instance of Array' +) const VALUE = { b: [true, false, true], i: 675, @@ -17,4 +21,20 @@ const VALUE = { gb = new GrowableBuffer type.writeValue(gb, VALUE) assert.equal(gb.toBuffer(), bufferFrom([0, 0, 0, 3, 0b10100000, 0x00, 0x00, 0x02, 0xa3, 0xc3, 0xa0, 0xc3, 0x9f, 0xc3, 0xa7, 0xc3, 0xb0, 0xc3, 0xaa, 0])) -assert.equal(r.value({buffer: gb.toBuffer(), type}), VALUE) \ No newline at end of file +assert.equal(r.value({buffer: gb.toBuffer(), type}), VALUE) + +let typeWithOptionalField = new t.StructType({ + optional: new t.OptionalType(new t.StringType), + required: new t.DoubleType +}) +assert.equal(typeWithOptionalField.valueBuffer({ + required: 2.0, optional: 'test' +}), bufferFrom([ + 0xff, + 0x74, 0x65, 0x73, 0x74, 0, //eslint-disable-line indent + 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +])) +assert.equal(typeWithOptionalField.valueBuffer({required: 2.0}), bufferFrom([ + 0, + 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +])) \ No newline at end of file