From 3fe106d47860c7079d14bdf7d71bbfdbaa691eed Mon Sep 17 00:00:00 2001 From: andot Date: Tue, 24 Apr 2018 18:42:22 +0800 Subject: [PATCH] Update to v2.0.3 --- .gitignore | 1 + dist/hprose.js | 5 ++--- dist/hprose.src.js | 35 ++++++++++++++++++++++++++++++++--- dist/regenerator-runtime.js | 2 +- src/Client.js | 33 +++++++++++++++++++++++++++++++-- src/CopyRight.js | 2 +- 6 files changed, 68 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 5148e52..cc1ea7b 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ build/Release # Dependency directories node_modules jspm_packages +package-lock.json # Optional npm cache directory .npm diff --git a/dist/hprose.js b/dist/hprose.js index 0fac0f7..1c0fe53 100644 --- a/dist/hprose.js +++ b/dist/hprose.js @@ -1,8 +1,7 @@ -// Hprose for WeChat App v2.0.2 +// Hprose for WeChat App v2.0.3 // Copyright (c) 2008-2016 http://hprose.com // Hprose is freely distributable under the MIT license. // For all details and documentation: // https://github.com/hprose/hprose-wx -function TimeoutError(e){Error.call(this),this.message=e,this.name=TimeoutError.name,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,TimeoutError)}var hprose=Object.create(null);!function(e){"use strict";function t(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return function(t){return e.apply(t,Array.prototype.slice.call(arguments,1))}}function r(e,r){for(var n=e.prototype,i=0,a=r.length;i>15,i=new Array(r?n+1:n),a=0;a0&&Array.isArray(arguments[0]))for(var u=arguments[0],o=0,f=u.length;o0&&Array.isArray(arguments[0]))for(var s=arguments[0],c=0,f=s.length;c2?g(e).then(function(e){return a(r).then(function(r){return e.reduce(t,r)})}):g(e).then(function(e){return e.reduce(t)})}function M(e,t,r){return arguments.length>2?g(e).then(function(e){return a(r).then(function(r){return e.reduceRight(t,r)})}):g(e).then(function(e){return e.reduceRight(t)})}function F(e,t,r){return g(e).then(function(e){return a(t).then(function(t){return e.indexOf(t,r)})})}function N(e,t,n){return g(e).then(function(e){return a(t).then(function(t){return n===r&&(n=e.length-1),e.lastIndexOf(t,n)})})}function P(e,t,r){return g(e).then(function(e){return a(t).then(function(t){return e.includes(t,r)})})}function W(e,t,r){return r=r||function(){return this}(),g(e).then(function(e){return e.find(t,r)})}function L(e,t,r){return r=r||function(){return this}(),g(e).then(function(e){return e.findIndex(t,r)})}function D(e,t,r){$(function(){try{var n=e(r);t.resolve(n)}catch(e){t.reject(e)}})}function H(e,t,r){e?D(e,t,r):t.resolve(r)}function z(e,t,r){e?D(e,t,r):t.reject(r)}function Q(){var e=new n;Object.defineProperties(this,{future:{value:e},complete:{value:e.resolve},completeError:{value:e.reject},isCompleted:{get:function(){return e._state!==G}}})}function q(e){n.call(this),e(this.resolve,this.reject)}var G=0,J=1,Y=2,$=e.setImmediate,K=Array.prototype.forEach,V=Array.prototype.slice;return E.wrap=A,Object.defineProperties(n,{delayed:{value:o},error:{value:s},sync:{value:f},value:{value:c},all:{value:g},race:{value:y},resolve:{value:c},reject:{value:s},promise:{value:l},isFuture:{value:i},toFuture:{value:a},isPromise:{value:u},toPromise:{value:j},join:{value:v},any:{value:p},settle:{value:w},attempt:{value:d},run:{value:T},thunkify:{value:S},promisify:{value:O},co:{value:E},wrap:{value:A},forEach:{value:C},every:{value:k},some:{value:R},filter:{value:U},map:{value:x},reduce:{value:I},reduceRight:{value:M},indexOf:{value:F},lastIndexOf:{value:N},includes:{value:P},find:{value:W},findIndex:{value:L}}),Object.defineProperties(n.prototype,{_value:{writable:!0},_reason:{writable:!0},_state:{value:G,writable:!0},resolve:{value:function(e){if(e===this)return void this.reject(new TypeError("Self resolution"));if(i(e))return void e.fill(this);if(null!==e&&"object"==typeof e||"function"==typeof e){var t;try{t=e.then}catch(e){return void this.reject(e)}if("function"==typeof t){var r=!0;try{var n=this;return void t.call(e,function(e){r&&(r=!1,n.resolve(e))},function(e){r&&(r=!1,n.reject(e))})}catch(e){r&&(r=!1,this.reject(e))}return}}if(this._state===G){this._state=J,this._value=e;for(var a=this._subscribers;a.length>0;){var u=a.shift();H(u.onfulfill,u.next,e)}}}},reject:{value:function(e){if(this._state===G){this._state=Y,this._reason=e;for(var t=this._subscribers;t.length>0;){var r=t.shift();z(r.onreject,r.next,e)}}}},then:{value:function(e,t){"function"!=typeof e&&(e=null),"function"!=typeof t&&(t=null);var r=new n;return this._state===J?H(e,r,this._value):this._state===Y?z(t,r,this._reason):this._subscribers.push({onfulfill:e,onreject:t,next:r}),r}},done:{value:function(e,t){this.then(e,t).then(null,function(e){$(function(){throw e})})}},inspect:{value:function(){switch(this._state){case G:return{state:"pending"};case J:return{state:"fulfilled",value:this._value};case Y:return{state:"rejected",reason:this._reason}}}},catchError:{value:function(e,t){if("function"==typeof t){var r=this;return this.catch(function(n){if(t(n))return r.catch(e);throw n})}return this.catch(e)}},catch:{value:function(e){return this.then(null,e)}},fail:{value:function(e){this.done(null,e)}},whenComplete:{value:function(e){return this.then(function(t){return e(),t},function(t){throw e(),t})}},complete:{value:function(e){return e=e||function(e){return e},this.then(e,e)}},always:{value:function(e){this.done(e,e)}},fill:{value:function(e){this.then(e.resolve,e.reject)}},timeout:{value:function(e,t){var r=new n,i=setTimeout(function(){r.reject(t||new TimeoutError("timeout"))},e);return this.whenComplete(function(){clearTimeout(i)}).fill(r),r}},delay:{value:function(e){var t=new n;return this.then(function(r){setTimeout(function(){t.resolve(r)},e)},t.reject),t}},tap:{value:function(e,t){return this.then(function(r){return e.call(t,r),r})}},spread:{value:function(e,t){return this.then(function(r){return e.apply(t,r)})}},get:{value:function(e){return this.then(function(t){return t[e]})}},set:{value:function(e,t){return this.then(function(r){return r[e]=t,r})}},apply:{value:function(e,t){return t=t||[],this.then(function(r){return g(t).then(function(t){return r[e].apply(r,t)})})}},call:{value:function(e){var t=V.call(arguments,1);return this.then(function(r){return g(t).then(function(t){return r[e].apply(r,t)})})}},bind:{value:function(e){var t=V.call(arguments);{if(!Array.isArray(e)){t.shift();var r=this;return Object.defineProperty(this,e,{value:function(){var n=V.call(arguments);return r.then(function(r){return g(t.concat(n)).then(function(t){return r[e].apply(r,t)})})}}),this}for(var n=0,i=e.length;n1?I(this,e,t):I(this,e)}},reduceRight:{value:function(e,t){return arguments.length>1?M(this,e,t):M(this,e)}},indexOf:{value:function(e,t){return F(this,e,t)}},lastIndexOf:{value:function(e,t){return N(this,e,t)}},includes:{value:function(e,t){return P(this,e,t)}},find:{value:function(e,t){return W(this,e,t)}},findIndex:{value:function(e,t){return L(this,e,t)}}}),e.Future=n,e.thunkify=S,e.promisify=O,e.co=E,e.co.wrap=e.wrap=A,e.Completer=Q,e.resolved=c,e.rejected=s,e.deferred=function(){var e=new n;return Object.create(null,{promise:{value:e},resolve:{value:e.resolve},reject:{value:e.reject}})},"function"==typeof Promise?(e.Promise=Promise,void(t.Promise=Promise)):(q.prototype=Object.create(n.prototype),q.prototype.constructor=n,Object.defineProperties(q,{all:{value:g},race:{value:y},resolve:{value:c},reject:{value:s}}),e.Promise=q,void(t.Promise=q))}(hprose,global),function(e,t){"use strict";function r(e,t,r){return e[t++]=r>>>24&255,e[t++]=r>>>16&255,e[t++]=r>>>8&255,e[t++]=255&r,t}function n(e,t,r){return e[t++]=255&r,e[t++]=r>>>8&255,e[t++]=r>>>16&255,e[t++]=r>>>24&255,t}function i(e,t,r){for(var n=r.length,i=0;i>6,e[t++]=128|63&a;else{if(!(a<55296||a>57343)){if(i+1>18,e[t++]=128|o>>12&63,e[t++]=128|o>>6&63,e[t++]=128|63&o,++i;continue}}throw new Error("Malformed string")}e[t++]=224|a>>12,e[t++]=128|a>>6&63,e[t++]=128|63&a}}return t}function a(e,t){for(var r=new Array(t),n=0,i=0,a=e.length;n>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:r[n]=u;break;case 12:case 13:if(i>10&1023|55296,r[n]=1023&o|56320;break}throw new Error("Character outside valid Unicode range: 0x"+o.toString(16))}throw new Error("Unfinished UTF-8 octet sequence");default:throw new Error("Bad UTF-8 encoding 0x"+u.toString(16))}}return n>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:n[i]=o;break;case 12:case 13:if(a>10&1023|55296,n[i]=1023&s|56320;break}throw new Error("Character outside valid Unicode range: 0x"+s.toString(16))}throw new Error("Unfinished UTF-8 octet sequence");default:throw new Error("Bad UTF-8 encoding 0x"+o.toString(16))}if(i>=32766){var c=i+1;n.length=c,r.push(String.fromCharCode.apply(String,n)),t-=c,i=-1}}return i>0&&(n.length=i,r.push(String.fromCharCode.apply(String,n))),[r.join(""),a]}function o(e,r){return(r===t||null===r||r<0)&&(r=e.length),0===r?["",0]:r<65535?a(e,r):u(e,r)}function s(e,r){if(r===t&&(r=e.length),0===r)return[g,0];for(var n=0,i=0,a=e.length;n>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break;case 12:case 13:if(i>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e+1}function f(){var e=arguments;switch(e.length){case 1:switch(e[0].constructor){case Uint8Array:this._bytes=e[0],this._length=e[0].length;break;case f:this._bytes=e[0].toBytes(),this._length=e[0].length;break;case String:this.writeString(e[0]);break;case Number:this._bytes=new Uint8Array(e[0]);break;default:this._bytes=new Uint8Array(e[0]),this._length=this._bytes.length}break;case 2:this._bytes=new Uint8Array(e[0],e[1]),this._length=e[1];break;case 3:this._bytes=new Uint8Array(e[0],e[1],e[2]),this._length=e[2]}this.mark()}function l(e){if(0===e.length)return"";switch(e.constructor){case String:return e;case f:e=e.bytes;case ArrayBuffer:e=new Uint8Array(e);case Uint8Array:return o(e,e.length)[0];default:return String.fromCharCode.apply(String,e)}}var h=e.toBinaryString,g=new Uint8Array(0),v=1024;Object.defineProperties(f.prototype,{_bytes:{value:null,writable:!0},_length:{value:0,writable:!0},_wmark:{value:0,writable:!0},_off:{value:0,writable:!0},_rmark:{value:0,writable:!0},_grow:{value:function(e){var t=this._bytes,r=this._length+e,n=c(r);if(t){if(n*=2,n>t.length){var i=new Uint8Array(n);i.set(t),this._bytes=i}}else n=Math.max(n,v),this._bytes=new Uint8Array(n)}},length:{get:function(){return this._length}},capacity:{get:function(){return this._bytes?this._bytes.length:0}},position:{get:function(){return this._off}},bytes:{get:function(){return null===this._bytes?g:this._bytes.subarray(0,this._length)}},buffer:{get:function(){if(null===this._bytes)return g.buffer;if(this._bytes.buffer.slice)return this._bytes.buffer.slice(0,this._length);var e=new Uint8Array(this._length);return e.set(this._bytes.subarray(0,this._length)),e.buffer}},mark:{value:function(){this._wmark=this._length,this._rmark=this._off}},reset:{value:function(){this._length=this._wmark,this._off=this._rmark}},clear:{value:function(){this._bytes=null,this._length=0,this._wmark=0,this._off=0,this._rmark=0}},writeByte:{value:function(e){this._grow(1),this._bytes[this._length++]=e}},writeInt32BE:{value:function(e){if(e===(0|e)&&e<=2147483647)return this._grow(4),void(this._length=r(this._bytes,this._length,e));throw new TypeError("value is out of bounds")}},writeUInt32BE:{value:function(e){if((2147483647&e)+2147483648===e&&e>=0)return this._grow(4),void(this._length=r(this._bytes,this._length,0|e));throw new TypeError("value is out of bounds")}},writeInt32LE:{value:function(e){if(e===(0|e)&&e<=2147483647)return this._grow(4),void(this._length=n(this._bytes,this._length,e));throw new TypeError("value is out of bounds")}},writeUInt32LE:{value:function(e){if((2147483647&e)+2147483648===e&&e>=0)return this._grow(4),void(this._length=n(this._bytes,this._length,0|e));throw new TypeError("value is out of bounds")}},write:{value:function(e){var t=e.byteLength||e.length;if(0!==t){this._grow(t);var r=this._bytes,n=this._length;switch(e.constructor){case ArrayBuffer:r.set(new Uint8Array(e),n);break;case Uint8Array:r.set(e,n);break;case f:r.set(e.bytes,n);break;default:for(var i=0;ithis._length&&(e=this._length-this._off),0===e?g:this._bytes.subarray(this._off,this._off+=e)}},skip:{value:function(e){return this._off+e>this._length?(e=this._length-this._off,this._off=this._length):this._off+=e,e}},readBytes:{value:function(e){var t,r=Array.indexOf(this._bytes,e,this._off);return r===-1?(t=this._bytes.subarray(this._off,this._length),this._off=this._length):(t=this._bytes.subarray(this._off,r+1),this._off=r+1),t}},readUntil:{value:function(e){var t=Array.indexOf(this._bytes,e,this._off),r="";return t===this._off?this._off++:t===-1?(r=o(this._bytes.subarray(this._off,this._length))[0],this._off=this._length):(r=o(this._bytes.subarray(this._off,t))[0],this._off=t+1),r}},readAsciiString:{value:function(e){return this._off+e>this._length&&(e=this._length-this._off),0===e?"":h(this._bytes.subarray(this._off,this._off+=e))}},readStringAsBytes:{value:function(e){var t=s(this._bytes.subarray(this._off,this._length),e);return this._off+=t[1],t[0]}},readString:{value:function(e){var t=o(this._bytes.subarray(this._off,this._length),e);return this._off+=t[1],t[0]}},takeBytes:{value:function(){var e=this.bytes;return this.clear(),e}},toBytes:{value:function(){return new Uint8Array(this.bytes)}},toString:{value:function(){return o(this.bytes,this._length)[0]}},clone:{value:function(){return new f(this.toBytes())}},trunc:{value:function(){this._bytes=this._bytes.subarray(this._off,this._length),this._length=this._bytes.length,this._off=0,this._wmark=0,this._rmark=0}}}),Object.defineProperty(f,"toString",{value:l}),e.BytesIO=f}(hprose),hprose.Tags={TagInteger:105,TagLong:108,TagDouble:100,TagNull:110,TagEmpty:101,TagTrue:116,TagFalse:102,TagNaN:78,TagInfinity:73,TagDate:68,TagTime:84,TagUTC:90,TagBytes:98,TagUTF8Char:117,TagString:115,TagGuid:103,TagList:97,TagMap:109,TagClass:99,TagObject:111,TagRef:114,TagPos:43,TagNeg:45,TagSemicolon:59,TagOpenbrace:123,TagClosebrace:125,TagQuote:34,TagPoint:46,TagFunctions:70,TagCall:67,TagResult:82,TagArgument:65,TagError:69,TagEnd:122},function(e){"use strict";function t(e,t){u.set(e,t),a[t]=e}function r(e){return u.get(e)}function n(e){return a[e]}var i=e.WeakMap,a=Object.create(null),u=new i;e.ClassManager=Object.create(null,{register:{value:t},getClassAlias:{value:r},getClass:{value:n}}),e.register=t,t(Object,"Object")}(hprose),function(e,t){"use strict";function r(e){var t=e.constructor;if(!t)return"Object";var r=j.getClassAlias(t);if(r)return r;if(t.name)r=t.name;else{var n=t.toString();if(r=n.substr(0,n.indexOf("(")).replace(/(^\s*function\s*)|(\s*$)/gi,""),""===r||"Object"===r)return"function"==typeof e.getClassName?e.getClassName():"Object"}return"Object"!==r&&j.register(t,r),r}function n(e){Object.defineProperties(this,{_stream:{value:e},_ref:{value:new B,writable:!0}})}function i(e){return new n(e)}function a(e,t){Object.defineProperties(this,{stream:{value:e},_classref:{value:Object.create(null),writable:!0},_fieldsref:{value:[],writable:!0},_refer:{value:t?E:i(e)}})}function u(e,n){var i=e.stream;if(n===t||null===n)return void i.writeByte(O.TagNull);switch(n.constructor){case Function:return void i.writeByte(O.TagNull);case Number:return void o(e,n);case Boolean:return void f(e,n);case String:switch(n.length){case 0:return void i.writeByte(O.TagEmpty);case 1:return i.writeByte(O.TagUTF8Char),void i.writeString(n)}return void e.writeStringWithRef(n);case Date:return void e.writeDateWithRef(n);case B:return void e.writeMapWithRef(n);case ArrayBuffer:case Uint8Array:case S:return void e.writeBytesWithRef(n);case Int8Array:case Int16Array:case Int32Array:case Uint16Array:case Uint32Array:return void w(e,n);case Float32Array:case Float64Array:return void d(e,n);default:if(Array.isArray(n))e.writeListWithRef(n);else{var a=r(n);"Object"===a?e.writeMapWithRef(n):e.writeObjectWithRef(n)}}}function o(e,t){var r=e.stream;t=t.valueOf(),t===(0|t)?0<=t&&t<=9?r.writeByte(t+48):(r.writeByte(O.TagInteger),r.writeAsciiString(""+t),r.writeByte(O.TagSemicolon)):isNaN(t)?r.writeByte(O.TagNaN):isFinite(t)?(r.writeByte(O.TagDouble),r.writeAsciiString(""+t),r.writeByte(O.TagSemicolon)):(r.writeByte(O.TagInfinity),r.writeByte(t>0?O.TagPos:O.TagNeg))}function s(e,t){var r=e.stream;0<=t&&t<=9?r.writeByte(t+48):(t<-2147483648||t>2147483647?r.writeByte(O.TagLong):r.writeByte(O.TagInteger),r.writeAsciiString(""+t),r.writeByte(O.TagSemicolon))}function c(e,t){var r=e.stream;isNaN(t)?r.writeByte(O.TagNaN):isFinite(t)?(r.writeByte(O.TagDouble),r.writeAsciiString(""+t),r.writeByte(O.TagSemicolon)):(r.writeByte(O.TagInfinity),r.writeByte(t>0?O.TagPos:O.TagNeg))}function f(e,t){e.stream.writeByte(t.valueOf()?O.TagTrue:O.TagFalse)}function l(e,t){e._refer.set(t);var r=e.stream,n=("0000"+t.getUTCFullYear()).slice(-4),i=("00"+(t.getUTCMonth()+1)).slice(-2),a=("00"+t.getUTCDate()).slice(-2),u=("00"+t.getUTCHours()).slice(-2),o=("00"+t.getUTCMinutes()).slice(-2),s=("00"+t.getUTCSeconds()).slice(-2),c=("000"+t.getUTCMilliseconds()).slice(-3);r.writeByte(O.TagDate),r.writeAsciiString(n+i+a),r.writeByte(O.TagTime),r.writeAsciiString(u+o+s),"000"!==c&&(r.writeByte(O.TagPoint),r.writeAsciiString(c)),r.writeByte(O.TagUTC)}function h(e,t){e._refer.set(t);var r=e.stream,n=("0000"+t.getFullYear()).slice(-4),i=("00"+(t.getMonth()+1)).slice(-2),a=("00"+t.getDate()).slice(-2),u=("00"+t.getHours()).slice(-2),o=("00"+t.getMinutes()).slice(-2),s=("00"+t.getSeconds()).slice(-2),c=("000"+t.getMilliseconds()).slice(-3);"00"===u&&"00"===o&&"00"===s&&"000"===c?(r.writeByte(O.TagDate),r.writeAsciiString(n+i+a)):"1970"===n&&"01"===i&&"01"===a?(r.writeByte(O.TagTime),r.writeAsciiString(u+o+s),"000"!==c&&(r.writeByte(O.TagPoint),r.writeAsciiString(c))):(r.writeByte(O.TagDate),r.writeAsciiString(n+i+a),r.writeByte(O.TagTime),r.writeAsciiString(u+o+s),"000"!==c&&(r.writeByte(O.TagPoint),r.writeAsciiString(c))),r.writeByte(O.TagSemicolon)}function g(e,t){e._refer.set(t);var r=e.stream,n=("00"+t.getHours()).slice(-2),i=("00"+t.getMinutes()).slice(-2),a=("00"+t.getSeconds()).slice(-2),u=("000"+t.getMilliseconds()).slice(-3);r.writeByte(O.TagTime),r.writeAsciiString(n+i+a),"000"!==u&&(r.writeByte(O.TagPoint),r.writeAsciiString(u)),r.writeByte(O.TagSemicolon)}function v(e,t){e._refer.set(t);var r=e.stream;r.writeByte(O.TagBytes);var n=t.byteLength||t.length;n>0?(r.writeAsciiString(""+n),r.writeByte(O.TagQuote),r.write(t)):r.writeByte(O.TagQuote),r.writeByte(O.TagQuote)}function y(e,t){e._refer.set(t);var r=e.stream,n=t.length;r.writeByte(O.TagString),n>0?(r.writeAsciiString(""+n),r.writeByte(O.TagQuote),r.writeString(t)):r.writeByte(O.TagQuote),r.writeByte(O.TagQuote)}function p(e,t,r){e._refer.set(t);var n=e.stream,i=t.length;if(n.writeByte(O.TagList),i>0){n.writeAsciiString(""+i),n.writeByte(O.TagOpenbrace);for(var a=0;a0){r.writeAsciiString(""+a),r.writeByte(O.TagOpenbrace);for(var o=0;o0?(r.writeAsciiString(""+n),r.writeByte(O.TagOpenbrace),t.forEach(function(t,r){u(e,r),u(e,t)})):r.writeByte(O.TagOpenbrace),r.writeByte(O.TagClosebrace)}function m(e,t){var n,i,a=e.stream,o=r(t);if(o in e._classref)i=e._classref[o],n=e._fieldsref[i];else{n=[];for(var s in t)t.hasOwnProperty(s)&&"function"!=typeof t[s]&&(n[n.length]=s.toString());i=_(e,o,n)}a.writeByte(O.TagObject),a.writeAsciiString(""+i),a.writeByte(O.TagOpenbrace),e._refer.set(t);for(var c=n.length,f=0;f0){n.writeAsciiString(""+i),n.writeByte(O.TagOpenbrace);for(var a=0;a=48&&u<=57&&(r.skip(2),u=r.readByte(),u>=48&&u<=57&&(r.skip(2),u=r.readByte()))),t=u===X.TagUTC?new Date(Date.UTC(n,i,a,o,s,c,f)):new Date(n,i,a,o,s,c,f)}else t=u===X.TagUTC?new Date(Date.UTC(n,i,a)):new Date(n,i,a);return e.refer.set(t),t}function A(e){var t=e.stream.readByte();switch(t){case X.TagNull:return null;case X.TagDate:return E(e);case X.TagRef:return Y(e);default:r(t)}}function C(e){var t,r=e.stream,n=parseInt(r.readAsciiString(2),10),i=parseInt(r.readAsciiString(2),10),a=parseInt(r.readAsciiString(2),10),u=0,o=r.readByte();return o===X.TagPoint&&(u=parseInt(r.readAsciiString(3),10),o=r.readByte(),o>=48&&o<=57&&(r.skip(2),o=r.readByte(),o>=48&&o<=57&&(r.skip(2),o=r.readByte()))),t=o===X.TagUTC?new Date(Date.UTC(1970,0,1,n,i,a,u)):new Date(1970,0,1,n,i,a,u),e.refer.set(t),t}function k(e){var t=e.stream.readByte();switch(t){case X.TagNull:return null;case X.TagTime:return C(e);case X.TagRef:return Y(e);default:r(t)}}function R(e){var t=e.stream,r=w(t,X.TagQuote),n=t.read(r);return t.skip(1),e.refer.set(n),n}function U(e){var t=e.stream.readByte();switch(t){case X.TagNull:return null;case X.TagEmpty:return new Uint8Array(0);case X.TagBytes:return R(e);case X.TagRef:return Y(e);default:r(t)}}function x(e){return e.stream.readString(1)}function I(e){var t=e.stream,r=t.readString(w(t,X.TagQuote));return t.skip(1),r}function M(e){var t=I(e);return e.refer.set(t),t}function F(e){var t=e.stream.readByte();switch(t){case X.TagNull:return null;case X.TagEmpty:return"";case X.TagUTF8Char:return x(e);case X.TagString:return M(e);case X.TagRef:return Y(e);default:r(t)}}function N(e){var t=e.stream;t.skip(1);var r=t.readAsciiString(36);return t.skip(1),e.refer.set(r),r}function P(e){var t=e.stream.readByte();switch(t){case X.TagNull:return null;case X.TagGuid:return N(e);case X.TagRef:return Y(e);default:r(t)}}function W(e){var t=e.stream,r=[];e.refer.set(r);for(var n=w(t,X.TagOpenbrace),i=0;i=0?n:void r(n,e)}},unserialize:{value:function(){return d(this)}},readInteger:{value:function(){return b(this.stream)}},readLong:{value:function(){return _(this.stream)}},readDouble:{value:function(){return S(this.stream)}},readBoolean:{value:function(){return j(this.stream)}},readDateWithoutTag:{value:function(){return E(this)}},readDate:{value:function(){return A(this)}},readTimeWithoutTag:{value:function(){return C(this)}},readTime:{value:function(){return k(this)}},readBytesWithoutTag:{value:function(){return R(this)}},readBytes:{value:function(){return U(this)}},readStringWithoutTag:{value:function(){return M(this)}},readString:{value:function(){return F(this)}},readGuidWithoutTag:{value:function(){return N(this)}},readGuid:{value:function(){return P(this)}},readListWithoutTag:{value:function(){return W(this)}},readList:{value:function(){return L(this)}},readMapWithoutTag:{value:function(){return this.useHarmonyMap?z(this):D(this)}},readMap:{value:function(){return this.useHarmonyMap?Q(this):H(this)}},readObjectWithoutTag:{value:function(){return q(this)}},readObject:{value:function(){return G(this)}},reset:{value:function(){this.classref.length=0,this.refer.reset()}}}),e.Reader=$}(hprose),function(e){"use strict";function t(e,t){var r=new n,a=new i(r,t);return a.serialize(e),r}function r(e,t,r){return e instanceof n||(e=new n(e)),new a(e,t,r).unserialize()}var n=e.BytesIO,i=e.Writer,a=e.Reader;e.Formatter={serialize:function(e,r){return t(e,r).bytes},unserialize:r},e.serialize=t,e.unserialize=r}(hprose),hprose.ResultMode={Normal:0,Serialized:1,Raw:2,RawWithEndTag:3},hprose.Normal=hprose.ResultMode.Normal,hprose.Serialized=hprose.ResultMode.Serialized,hprose.Raw=hprose.ResultMode.Raw,hprose.RawWithEndTag=hprose.ResultMode.RawWithEndTag,function(e,t){"use strict";function r(){}function n(e,n,i){function a(e,t){for(var r=0,n=Xe.length;r=0;r--)e=Xe[r].inputFilter(e,t);return e}function m(e,t){return e=a(e,t),st(e,t).then(function(e){if(!t.oneway)return g(e,t)})}function _(e,t){return gt.sendAndReceive(e,t).catchError(function(r){var n=O(e,t);if(null!==n)return n;throw r})}function B(e,t,r,n){ot(e,t).then(r,n)}function S(){var e=Pe.length;if(e>1){var t=We+1;t>=e&&(t=0,Ge++),We=t,Ne=Pe[We]}else Ge++;Ve(gt)}function O(e,t){if(t.failswitch&&S(),t.idempotent&&t.retried5e3&&(r=5e3),r>0?h.delayed(r,function(){return _(e,t)}):_(e,t)}return null}function j(e){var r=[Object.create(null)];for(var n in e){var i=e[n].split("_"),a=i.length-1;if(a>0){for(var u=r,o=0;o0||r.byref)&&(i.reset(),i.writeList(t),r.byref&&i.writeBoolean(!0)),n}function M(e,t,r,n){return Je?h.promise(function(i,a){Ye.push({batch:n,name:e,args:t,context:r,resolve:i,reject:a})}):n?D(e,t,r):L(e,t,r)}function F(e,t,r,n){return M(t,r,x(e,t,r,n),n)}function N(e,t,r,n){try{r.onerror?r.onerror(e,t):Ke(e,t),n(t)}catch(e){n(e)}}function P(e,t,r){var n=I(e,t,r);return n.writeByte(o.TagEnd),h.promise(function(e,i){B(n.bytes,r,function(n){if(r.oneway)return void e();var a=null,u=null;try{if(r.mode===s.RawWithEndTag)a=n;else if(r.mode===s.Raw)a=n.subarray(0,n.byteLength-1);else{var f=new c(n),h=new l(f,(!1),r.useHarmonyMap),g=f.readByte();if(g===o.TagResult){if(a=r.mode===s.Serialized?h.readRaw():h.unserialize(),g=f.readByte(),g===o.TagArgument){h.reset();var v=h.readList();R(v,t),g=f.readByte()}}else g===o.TagError&&(u=new Error(h.readString()),g=f.readByte());g!==o.TagEnd&&(u=new Error("Wrong Response:\r\n"+c.toString(n)))}}catch(e){u=e}u?i(u):e(a)},i)})}function W(e){return function(){e&&(Je=!1,u(function(e){e.forEach(function(e){"settings"in e?q(e.settings).then(e.resolve,e.reject):M(e.name,e.args,e.context,e.batch).then(e.resolve,e.reject)})},Ye),Ye=[])}}function L(e,t,r){r.sync&&(Je=!0);var n=h.promise(function(n,i){at(e,t,r).then(function(a){try{if(r.onsuccess)try{r.onsuccess(a,t)}catch(t){r.onerror&&r.onerror(e,t),i(t)}n(a)}catch(e){i(e)}},function(t){N(e,t,r,i)})});return n.whenComplete(W(r.sync)),n}function D(e,t,r){return h.promise(function(n,i){et.push({args:t,name:e,context:r,resolve:n,reject:i})})}function H(e){var t={timeout:He,retry:ze,retried:0,idempotent:Qe,failswitch:qe,oneway:!1,sync:!1,client:gt,userdata:{}};for(var r in e)r in t&&(t[r]=e[r]);return t}function z(e,t){var r=e.reduce(function(e,t){return e.write(I(t.name,t.args,t.context)),e},new c);return r.writeByte(o.TagEnd),h.promise(function(n,i){B(r.bytes,t,function(r){if(t.oneway)return void n(e);var a=-1,u=new c(r),f=new l(u,(!1)),h=u.readByte();try{for(;h!==o.TagEnd;){var g=null,v=null,y=e[++a].context.mode;if(y>=s.Raw&&(g=new c),h===o.TagResult){if(y===s.Serialized?g=f.readRaw():y>=s.Raw?(g.writeByte(o.TagResult),g.write(f.readRaw())):(f.useHarmonyMap=e[a].context.useHarmonyMap,f.reset(),g=f.unserialize()),h=u.readByte(),h===o.TagArgument){if(y>=s.Raw)g.writeByte(o.TagArgument),g.write(f.readRaw());else{f.reset();var p=f.readList();R(p,e[a].args)}h=u.readByte()}}else h===o.TagError&&(y>=s.Raw?(g.writeByte(o.TagError),g.write(f.readRaw())):(f.reset(),v=new Error(f.readString())),h=u.readByte());if([o.TagEnd,o.TagResult,o.TagError].indexOf(h)<0)return void i(new Error("Wrong Response:\r\n"+c.toString(r)));y>=s.Raw?(y===s.RawWithEndTag&&g.writeByte(o.TagEnd),e[a].result=g.bytes):e[a].result=g,e[a].error=v}}catch(e){return void i(e)}n(e)},i)})}function Q(){Ze=!0}function q(e){if(e=e||{},Ze=!1,Je)return h.promise(function(t,r){Ye.push({batch:!0,settings:e,resolve:t,reject:r})});var t=et.length;if(0===t)return h.value([]);var r=H(e);r.sync&&(Je=!0);var n=et;et=[];var i=h.promise(function(e,t){ut(n,r).then(function(t){t.forEach(function(e){if(e.error)N(e.name,e.error,e.context,e.reject);else try{if(e.context.onsuccess)try{e.context.onsuccess(e.result,e.args)}catch(t){e.context.onerror&&e.context.onerror(e.name,t),e.reject(t)}e.resolve(e.result)}catch(t){e.reject(t)}delete e.context,delete e.resolve,delete e.reject}),e(t)},function(e){n.forEach(function(t){"reject"in t&&N(t.name,e,t.context,t.reject)}),t(e)})});return i.whenComplete(W(r.sync)),i}function G(){return Ke}function J(e){typeof e===T&&(Ke=e)}function Y(){return Ve}function $(e){typeof e===T&&(Ve=e)}function K(){return Ne}function V(){return Pe}function X(e){if(typeof e===w)Pe=[e];else{if(!Array.isArray(e))return;Pe=e.slice(0),Pe.sort(function(){return Math.random()-.5})}We=0,Ne=Pe[We]}function Z(){return qe}function ee(e){qe=!!e}function te(){return Ge}function re(){return He}function ne(e){He="number"==typeof e?0|e:0}function ie(){return ze}function ae(e){ze="number"==typeof e?0|e:0}function ue(){return Qe}function oe(e){Qe=!!e}function se(e){it=!!e}function ce(){return it}function fe(){return Le}function le(e){Le=!!e}function he(){return De}function ge(e){De=!!e}function ve(){return $e}function ye(e){$e=!!e}function pe(){return 0===Xe.length?null:1===Xe.length?Xe[0]:Xe.slice()}function we(e){Xe.length=0,Array.isArray(e)?e.forEach(function(e){de(e)}):de(e)}function de(e){e&&"function"==typeof e.inputFilter&&"function"==typeof e.outputFilter&&Xe.push(e)}function Te(e){var t=Xe.indexOf(e);return t!==-1&&(Xe.splice(t,1),!0)}function be(){return Xe}function me(e,r,n){n===t&&(typeof r===p&&(n=r,r=!1),r||(typeof e===p?(n=e,e=!1):(e&&e.constructor===Object||Array.isArray(e))&&(r=e,e=!1)));var i=gt;return n&&(i={}),e||Ne?(e&&(Ne=e),(typeof r===w||r&&r.constructor===Object)&&(r=[r]),Array.isArray(r)?(k(i,r),tt.resolve(i),i):(u(E,i),tt)):new Error("You should set server uri first!")}function _e(e,t,n){var i=arguments.length;if(i<1||typeof e!==w)throw new Error("name must be a string");if(1===i&&(t=[]),2===i&&!Array.isArray(t)){var a=[];typeof t!==T&&a.push(r),a.push(t),t=a}if(i>2){typeof n!==T&&t.push(r);for(var u=2;u=0&&(i[a]=i[i.length-1],i.length--),0===i.length&&delete e[t]}}else delete e[t]}function Ee(e,r,n){if(typeof e!==w)throw new TypeError("topic name must be a string.");if(r===t||null===r){if(typeof n!==T)return void delete rt[e];r=n}if(typeof r===T&&(n=r,r=null),null===r)if(null===nt){if(rt[e]){var i=rt[e];for(r in i)je(i,r,n)}}else nt.then(function(t){Ee(e,t,n)});else h.isPromise(r)?r.then(function(t){Ee(e,t,n)}):je(rt[e],r,n);v(rt[e])&&delete rt[e]}function Ae(e){return!!rt[e]}function Ce(){var e=[];for(var t in rt)e.push(t);return e}function ke(){return nt}function Re(){return null===nt&&(nt=F(gt,"#",[],!1)),nt}function Ue(e){ct.push(e),at=ct.reduceRight(function(e,t){return function(r,n,i){return h.toPromise(t(r,n,i,e))}},P)}function xe(e){ft.push(e),ut=ft.reduceRight(function(e,t){return function(r,n){return h.toPromise(t(r,n,e))}},z)}function Ie(e){lt.push(e),ot=lt.reduceRight(function(e,t){return function(r,n){return h.toPromise(t(r,n,e))}},m)}function Me(e){ht.push(e),st=ht.reduceRight(function(e,t){return function(r,n){return h.toPromise(t(r,n,e))}},_)}function Fe(e){return Ue(e),gt}var Ne,Pe=[],We=-1,Le=!1,De=!1,He=3e4,ze=10,Qe=!1,qe=!1,Ge=0,Je=!1,Ye=[],$e=!1,Ke=r,Ve=r,Xe=[],Ze=!1,et=[],tt=new h,rt=Object.create(null),nt=null,it=!0,at=P,ut=z,ot=m,st=_,ct=[],ft=[],lt=[],ht=[],gt=this;Re.sync=!0,Re.idempotent=!0,Re.failswitch=!0;var vt=Object.create(null,{begin:{value:Q},end:{value:q},use:{value:function(e){return xe(e),vt}}}),yt=Object.create(null,{use:{value:function(e){return Ie(e),yt}}}),pt=Object.create(null,{use:{value:function(e){return Me(e),pt}}});Object.defineProperties(this,{"#":{value:Re},onerror:{get:G,set:J},onfailswitch:{get:Y,set:$},uri:{get:K},uriList:{get:V,set:X},id:{get:ke},failswitch:{get:Z,set:ee},failround:{get:te},timeout:{get:re,set:ne},retry:{get:ie,set:ae},idempotent:{get:ue,set:oe},keepAlive:{get:ce,set:se},byref:{get:fe,set:le},simple:{get:he,set:ge},useHarmonyMap:{get:ve,set:ye},filter:{get:pe,set:we},addFilter:{value:de},removeFilter:{value:Te},filters:{get:be},useService:{value:me},invoke:{value:_e},ready:{value:Be},subscribe:{value:Oe},unsubscribe:{value:Ee},isSubscribed:{value:Ae},subscribedList:{value:Ce},use:{value:Fe},batch:{value:vt},beforeFilter:{value:yt},afterFilter:{value:pt}}),i&&typeof i===b&&["failswitch","timeout","retry","idempotent","keepAlive","byref","simple","useHarmonyMap","filter"].forEach(function(e){e in i&&(gt[e]=i[e])}),e&&(X(e),me(n))}function i(e){var t=g(e),r=t.protocol;if("http:"!==r&&"https:"!==r&&"ws:"!==r&&"wss:"!==r)throw new Error("The "+r+" client isn't implemented.")}function a(t,r,n){try{return e.HttpClient.create(t,r,n)}catch(e){}try{return e.WebSocketClient.create(t,r,n)}catch(e){}if("string"==typeof t)i(t);else if(Array.isArray(t))throw t.forEach(function(e){i(e)}),new Error("Not support multiple protocol.");throw new Error("You should set server uri first!")}var u=e.setImmediate,o=e.Tags,s=e.ResultMode,c=e.BytesIO,f=e.Writer,l=e.Reader,h=e.Future,g=e.parseuri,v=e.isObjectEmpty,y=new Uint8Array(1);y[0]=o.TagEnd;var p="boolean",w="string",d="number",T="function",b="object";Object.defineProperty(n,"create",{value:a}),e.Client=n}(hprose),function(e){"use strict";function t(e,r,n){function u(e){var t,r,n={};for(t in l)n[t]=l[t];if(e)for(t in e)r=e[t],Array.isArray(r)?n[t]=r.join(", "):n[t]=r;return n}function s(e,t){var r=new a,n=u(t.httpHeader);return n["Content-Type"]="text/plain; charset=UTF-8",wx.request({url:h.uri,method:"POST",data:o.toString(e),header:n,timeout:t.timeout,complete:function(e){"undefined"==typeof e.statusCode?r.reject(new Error(e.errMsg)):200===parseInt(e.statusCode,10)?r.resolve(new o(e.data).takeBytes()):r.reject(new Error(e.statusCode+":"+e.data))}}),r}function c(e,t){var r=s(e,t);return t.oneway&&r.resolve(),r}function f(e,t){"content-type"!==e.toLowerCase()&&(t?l[e]=t:delete l[e])}if(this.constructor!==t)return new t(e,r,n);i.call(this,e,r,n);var l=Object.create(null),h=this;Object.defineProperties(this,{setHeader:{value:f},sendAndReceive:{value:c}})}function r(e){var t=u(e);if("http:"!==t.protocol&&"https:"!==t.protocol)throw new Error("This client desn't support "+t.protocol+" scheme.")}function n(e,n,i){if("string"==typeof e)r(e);else{if(!Array.isArray(e))throw new Error("You should set server uri first!");e.forEach(function(e){r(e)})}return new t(e,n,i)}var i=e.Client,a=e.Future,u=e.parseuri,o=e.BytesIO;Object.defineProperties(t,{create:{value:n}}),e.HttpClient=t}(hprose),function(e,t){"use strict";function r(){}function n(e,i,a){function c(){return _<2147483647?++_:_=0}function v(e,t){var r=new u;r.writeInt32BE(e),t.constructor===String?r.writeString(t):r.write(t);var n=r.bytes;wx.sendSocketMessage({data:n.buffer.slice(0,n.length)})}function y(){E=l,j.resolve()}function p(e){var r=new u(e.data),n=r.readInt32BE(),i=S[n];if(delete S[n],i!==t&&(--B,i.resolve(r.read(r.length-4))),B<100&&O.length>0){++B;var a=O.pop();j.then(function(){v(a[0],a[1])})}0!==B||A.keepAlive||m()}function w(e){e&&""!==e.message&&(E=h,S.forEach(function(e,t){e.reject(new Error("websocket can't open")),delete S[t]}),B=0,E=g)}function d(){E=h,S.forEach(function(e,t){e.reject(new Error("websocket closed")),delete S[t]}),B=0,E=g}function T(){E=f,j=new s,wx.connectSocket({url:A.uri}),wx.onSocketOpen(y),wx.onSocketMessage(p),wx.onSocketError(w),wx.onSocketClose(d)}function b(e,t){var r=c(),n=new s;return S[r]=n,t.timeout>0&&(n=n.timeout(t.timeout).catchError(function(e){throw delete S[r],--B,m(),e},function(e){return e instanceof TimeoutError})),E!==h&&E!==g||T(),B<100?(++B,j.then(function(){v(r,e)})):O.push([r,e]),t.oneway&&n.resolve(),n}function m(){E!==h&&E!==g&&(E=h,wx.onSocketOpen(r),wx.onSocketMessage(r),wx.onSocketError(r),wx.onSocketClose(r),wx.closeSocket())}if(this.constructor!==n)return new n(e,i,a);o.call(this,e,i,a);var _=0,B=0,S=[],O=[],j=null,E=g,A=this;Object.defineProperties(this,{sendAndReceive:{value:b},close:{value:m}})}function i(e){var t=c(e);if("ws:"!==t.protocol&&"wss:"!==t.protocol)throw new Error("This client desn't support "+t.protocol+" scheme.")}function a(e,t,r){if("string"==typeof e)i(e);else{if(!Array.isArray(e))throw new Error("You should set server uri first!");e.forEach(function(e){i(e)})}return new n(e,t,r)}var u=e.BytesIO,o=e.Client,s=e.Future,c=e.parseuri,f=1,l=2,h=3,g=4;Object.defineProperty(n,"create",{value:a}),e.WebSocketClient=n}(hprose),function(e){"use strict";function t(e){this.version=e||"2.0"}var r=e.Tags,n=e.BytesIO,i=e.Writer,a=e.Reader,u=1;t.prototype.inputFilter=function(e){var t=n.toString(e);"{"===t.charAt(0)&&(t="["+t+"]");for(var a=JSON.parse(t),u=new n,o=new i(u,(!0)),s=0,c=a.length;s1?JSON.stringify(t):JSON.stringify(t[0])},e.JSONRPCClientFilter=t}(hprose),function(e){function t(e){return function(t){t=t||{};var n=new r;try{t.success=n.resolve,t.fail=n.reject,wx[e](t)}catch(e){n.reject(e)}return n}}var r=e.Future,n=["invoke","showNavigationBarLoading","hideNavigationBarLoading","navigateBack","drawCanvas","canvasToTempFilePath","hideKeyboard","getPublicLibVersion"];e.wx={};for(var i in wx)"function"==typeof wx[i]&&n.indexOf(i)<0&&i.search(/(^(on|create|stop|pause))|((Sync)$)/)<0?e.wx[i]=t(i):e.wx[i]=wx[i]}(hprose),hprose.common={Completer:hprose.Completer,Future:hprose.Future,ResultMode:hprose.ResultMode},hprose.io={BytesIO:hprose.BytesIO,ClassManager:hprose.ClassManager,Tags:hprose.Tags,RawReader:hprose.RawReader,Reader:hprose.Reader,Writer:hprose.Writer,Formatter:hprose.Formatter},hprose.client={Client:hprose.Client,HttpClient:hprose.HttpClient,WebSocketClient:hprose.WebSocketClient},hprose.filter={JSONRPCClientFilter:hprose.JSONRPCClientFilter},module.exports=hprose; \ No newline at end of file +var hprose=Object.create(null);function TimeoutError(e){Error.call(this),this.message=e,this.name=TimeoutError.name,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,TimeoutError)}!function(e){"use strict";function o(t){if("function"!=typeof t)throw new TypeError(t+" is not a function");return function(e){return t.apply(e,Array.prototype.slice.call(arguments,1))}}function t(e,t){for(var r=e.prototype,n=0,i=t.length;n>15,i=new Array(r?n+1:n),a=0;a>>24&255,e[t++]=r>>>16&255,e[t++]=r>>>8&255,e[t++]=255&r,t}function n(e,t,r){return e[t++]=255&r,e[t++]=r>>>8&255,e[t++]=r>>>16&255,e[t++]=r>>>24&255,t}function i(e,t){return(t===o||null===t||t<0)&&(t=e.length),0===t?["",0]:t<65535?function(e,t){for(var r=new Array(t),n=0,i=0,a=e.length;n>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:r[n]=u;break;case 12:case 13:if(i>10&1023|55296,r[n]=1023&o|56320;break}throw new Error("Character outside valid Unicode range: 0x"+o.toString(16))}throw new Error("Unfinished UTF-8 octet sequence");default:throw new Error("Bad UTF-8 encoding 0x"+u.toString(16))}}return n>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:n[i]=o;break;case 12:case 13:if(a>10&1023|55296,n[i]=1023&s|56320;break}throw new Error("Character outside valid Unicode range: 0x"+s.toString(16))}throw new Error("Unfinished UTF-8 octet sequence");default:throw new Error("Bad UTF-8 encoding 0x"+o.toString(16))}if(32766<=i){var c=i+1;n.length=c,r.push(String.fromCharCode.apply(String,n)),t-=c,i=-1}}return 0>1,t|=t>>2,t|=t>>4,t|=t>>8,1+(t|=t>>16));if(r){if((i*=2)>r.length){var a=new Uint8Array(i);a.set(r),this._bytes=a}}else i=Math.max(i,1024),this._bytes=new Uint8Array(i)}},length:{get:function(){return this._length}},capacity:{get:function(){return this._bytes?this._bytes.length:0}},position:{get:function(){return this._off}},bytes:{get:function(){return null===this._bytes?s:this._bytes.subarray(0,this._length)}},buffer:{get:function(){if(null===this._bytes)return s.buffer;if(this._bytes.buffer.slice)return this._bytes.buffer.slice(0,this._length);var e=new Uint8Array(this._length);return e.set(this._bytes.subarray(0,this._length)),e.buffer}},mark:{value:function(){this._wmark=this._length,this._rmark=this._off}},reset:{value:function(){this._length=this._wmark,this._off=this._rmark}},clear:{value:function(){this._bytes=null,this._length=0,this._wmark=0,this._off=0,this._rmark=0}},writeByte:{value:function(e){this._grow(1),this._bytes[this._length++]=e}},writeInt32BE:{value:function(e){if(e===(0|e)&&e<=2147483647)return this._grow(4),void(this._length=r(this._bytes,this._length,e));throw new TypeError("value is out of bounds")}},writeUInt32BE:{value:function(e){if(2147483648+(2147483647&e)===e&&0<=e)return this._grow(4),void(this._length=r(this._bytes,this._length,0|e));throw new TypeError("value is out of bounds")}},writeInt32LE:{value:function(e){if(e===(0|e)&&e<=2147483647)return this._grow(4),void(this._length=n(this._bytes,this._length,e));throw new TypeError("value is out of bounds")}},writeUInt32LE:{value:function(e){if(2147483648+(2147483647&e)===e&&0<=e)return this._grow(4),void(this._length=n(this._bytes,this._length,0|e));throw new TypeError("value is out of bounds")}},write:{value:function(e){var t=e.byteLength||e.length;if(0!==t){this._grow(t);var r=this._bytes,n=this._length;switch(e.constructor){case ArrayBuffer:r.set(new Uint8Array(e),n);break;case Uint8Array:r.set(e,n);break;case a:r.set(e.bytes,n);break;default:for(var i=0;i>6,e[t++]=128|63&a;else{if(!(a<55296||57343>18,e[t++]=128|o>>12&63,e[t++]=128|o>>6&63,e[t++]=128|63&o,++i;continue}}throw new Error("Malformed string")}e[t++]=224|a>>12,e[t++]=128|a>>6&63,e[t++]=128|63&a}}return t}(this._bytes,this._length,e))}},readByte:{value:function(){return this._offthis._length&&(e=this._length-this._off),0===e?s:this._bytes.subarray(this._off,this._off+=e)}},skip:{value:function(e){return this._off+e>this._length?(e=this._length-this._off,this._off=this._length):this._off+=e,e}},readBytes:{value:function(e){var t,r=Array.indexOf(this._bytes,e,this._off);return-1===r?(t=this._bytes.subarray(this._off,this._length),this._off=this._length):(t=this._bytes.subarray(this._off,r+1),this._off=r+1),t}},readUntil:{value:function(e){var t=Array.indexOf(this._bytes,e,this._off),r="";return t===this._off?this._off++:-1===t?(r=i(this._bytes.subarray(this._off,this._length))[0],this._off=this._length):(r=i(this._bytes.subarray(this._off,t))[0],this._off=t+1),r}},readAsciiString:{value:function(e){return this._off+e>this._length&&(e=this._length-this._off),0===e?"":t(this._bytes.subarray(this._off,this._off+=e))}},readStringAsBytes:{value:function(e){var t=function(e,t){if(t===o&&(t=e.length),0===t)return[s,0];for(var r=0,n=0,i=e.length;r>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break;case 12:case 13:if(n=ce.Raw&&(a=new fe),i===se.TagResult){if(o===ce.Serialized?a=n.readRaw():o>=ce.Raw?(a.writeByte(se.TagResult),a.write(n.readRaw())):(n.useHarmonyMap=f[t].context.useHarmonyMap,n.reset(),a=n.unserialize()),(i=r.readByte())===se.TagArgument){if(o>=ce.Raw)a.writeByte(se.TagArgument),a.write(n.readRaw());else n.reset(),D(n.readList(),f[t].args);i=r.readByte()}}else i===se.TagError&&(o>=ce.Raw?(a.writeByte(se.TagError),a.write(n.readRaw())):(n.reset(),u=new Error(n.readString())),i=r.readByte());if([se.TagEnd,se.TagResult,se.TagError].indexOf(i)<0)return void c(new Error("Wrong Response:\r\n"+fe.toString(e)));o>=ce.Raw?(o===ce.RawWithEndTag&&a.writeByte(se.TagEnd),f[t].result=a.bytes):f[t].result=a,f[t].error=u}}catch(e){return void c(e)}s(f)}},c)})}function K(r){if(r=r||{},b=!1,c)return ge.promise(function(e,t){f.push({batch:!0,settings:r,resolve:e,reject:t})});if(0===m.length)return ge.value([]);var n=function(e){var t={timeout:v,retry:y,retried:0,idempotent:p,failswitch:w,oneway:!1,sync:!1,client:x,userdata:{}};for(var r in e)r in t&&(t[r]=e[r]);return t}(r);n.sync&&(c=!0);var i=m;m=[];var e=ge.promise(function(t,e){j(i,n).then(function(e){e.forEach(function(t){if(t.error)G(t.name,t.error,t.context,t.reject);else try{if(t.context.onsuccess)try{t.context.onsuccess(t.result,t.args)}catch(e){t.context.onerror&&t.context.onerror(t.name,e),t.reject(e)}t.resolve(t.result)}catch(e){t.reject(e)}delete t.context,delete t.resolve,delete t.reject}),t(e)},function(t){i.forEach(function(e){"reject"in e&&G(e.name,t,e.context,e.reject)}),e(t)})});return e.whenComplete(Y(n.sync)),e}function V(e){if(typeof e===de)a=[e];else{if(!Array.isArray(e))return;(a=e.slice(0)).sort(function(){return Math.random()-.5})}i=a[u=0]}function X(e){e&&"function"==typeof e.inputFilter&&"function"==typeof e.outputFilter&&T.push(e)}function Z(e,t,r){r===ue&&(typeof t===we&&(r=t,t=!1),t||(typeof e===we?(r=e,e=!1):(e&&e.constructor===Object||Array.isArray(e))&&(t=e,e=!1)));var n=x;return r&&(n={}),e||i?(e&&(i=e),(typeof t===de||t&&t.constructor===Object)&&(t=[t]),Array.isArray(t)?("undefined"==typeof Proxy?L(n,t):n=new Proxy({},new _e(N)),_.resolve(n),n):(oe(P,n),_)):new Error("You should set server uri first!")}function ee(e,t){if(B[e]){var r=B[e];if(r[t])return r[t]}return null}function te(e,t,r){if(e)if(typeof r===be){var n=e[t];if(n){var i=n.callbacks,a=i.indexOf(r);0<=a&&(i[a]=i[i.length-1],i.length--),0===i.length&&delete e[t]}}else delete e[t]}function re(){return null===S&&(S=q(x,"#",[],!1)),S}re.sync=!0,re.idempotent=!0,re.failswitch=!0;var ne=Object.create(null,{begin:{value:function(){b=!0}},end:{value:K},use:{value:function(e){var t;return t=e,k.push(t),j=k.reduceRight(function(r,n){return function(e,t){return ge.toPromise(n(e,t,r))}},$),ne}}}),ie=Object.create(null,{use:{value:function(e){var t;return t=e,R.push(t),E=R.reduceRight(function(r,n){return function(e,t){return ge.toPromise(n(e,t,r))}},I),ie}}}),ae=Object.create(null,{use:{value:function(e){var t;return t=e,U.push(t),A=U.reduceRight(function(r,n){return function(e,t){return ge.toPromise(n(e,t,r))}},M),ae}}});Object.defineProperties(this,{"#":{value:re},onerror:{get:function(){return s},set:function(e){typeof e===be&&(s=e)}},onfailswitch:{get:function(){return l},set:function(e){typeof e===be&&(l=e)}},uri:{get:function(){return i}},uriList:{get:function(){return a},set:V},id:{get:function(){return S}},failswitch:{get:function(){return w},set:function(e){w=!!e}},failround:{get:function(){return o}},timeout:{get:function(){return v},set:function(e){v="number"==typeof e?0|e:0}},retry:{get:function(){return y},set:function(e){y="number"==typeof e?0|e:0}},idempotent:{get:function(){return p},set:function(e){p=!!e}},keepAlive:{get:function(){return n},set:function(e){n=!!e}},byref:{get:function(){return h},set:function(e){h=!!e}},simple:{get:function(){return g},set:function(e){g=!!e}},useHarmonyMap:{get:function(){return d},set:function(e){d=!!e}},filter:{get:function(){return 0===T.length?null:1===T.length?T[0]:T.slice()},set:function(e){T.length=0,Array.isArray(e)?e.forEach(function(e){X(e)}):X(e)}},addFilter:{value:X},removeFilter:{value:function(e){var t=T.indexOf(e);return-1!==t&&(T.splice(t,1),!0)}},filters:{get:function(){return T}},useService:{value:Z},invoke:{value:function(e,t,r){var n=arguments.length;if(n<1||typeof e!==de)throw new Error("name must be a string");if(1===n&&(t=[]),2===n&&!Array.isArray(t)){var i=[];typeof t!==be&&i.push(pe),i.push(t),t=i}if(2 * * * \**********************************************************/ +/* global Proxy */ (function (hprose, undefined) { 'use strict'; var setImmediate = hprose.setImmediate; @@ -3481,6 +3482,29 @@ hprose.RawWithEndTag = hprose.ResultMode.RawWithEndTag; var s_function = 'function'; var s_object = 'object'; + function HproseProxy(setFunction, ns) { + var settings = {}; + this.get = function(target, prop/*, receiver*/) { + var name = prop.toString(); + if (ns) { name = ns + '_' + name; } + if (name === 'then') { return undefined; } + if (!target.hasOwnProperty(name)) { + settings[name] = {}; + var handler = new HproseProxy(setFunction, name); + var func = setFunction(settings, name); + handler.apply = function(target, thisArg, argumentsList) { + return func.apply(null, argumentsList); + } + handler.set = function(target, prop, value/*, receiver*/) { + settings[name][prop] = value; + return true; + }; + target[name] = new Proxy(function() {}, handler); + } + return target[name]; + }; + } + function Client(uri, functions, settings) { // private members @@ -4304,7 +4328,12 @@ hprose.RawWithEndTag = hprose.ResultMode.RawWithEndTag; setImmediate(initService, stub); return _ready; } - setFunctions(stub, functions); + else if (typeof(Proxy) === 'undefined') { + setFunctions(stub, functions); + } + else { + stub = new Proxy({}, new HproseProxy(setFunction)); + } _ready.resolve(stub); return stub; } diff --git a/dist/regenerator-runtime.js b/dist/regenerator-runtime.js index f45e9c5..7f95cb4 100644 --- a/dist/regenerator-runtime.js +++ b/dist/regenerator-runtime.js @@ -1 +1 @@ -!function(t){"use strict";function r(t,r,e,o){var i=r&&r.prototype instanceof n?r:n,a=Object.create(i.prototype),c=new h(o||[]);return a._invoke=f(t,e,c),a}function e(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}function n(){}function o(){}function i(){}function a(t){["next","throw","return"].forEach(function(r){t[r]=function(t){return this._invoke(r,t)}})}function c(t){this.arg=t}function u(t){function r(n,o,i,a){var u=e(t[n],t,o);if("throw"!==u.type){var f=u.arg,l=f.value;return l instanceof c?g.resolve(l.arg).then(function(t){r("next",t,i,a)},function(t){r("throw",t,i,a)}):g.resolve(l).then(function(t){f.value=t,i(f)},a)}a(u.arg)}function n(t,e){function n(){return new g(function(n,o){r(t,e,n,o)})}return o=o?o.then(n,n):n()}"object"==typeof process&&process.domain&&(r=process.domain.bind(r));var o;this._invoke=n}function f(t,r,n){var o=E;return function(i,a){if(o===_)throw new Error("Generator is already running");if(o===k){if("throw"===i)throw a;return y()}for(;;){var c=n.delegate;if(c){if("return"===i||"throw"===i&&c.iterator[i]===v){n.delegate=null;var u=c.iterator.return;if(u){var f=e(u,c.iterator,a);if("throw"===f.type){i="throw",a=f.arg;continue}}if("return"===i)continue}var f=e(c.iterator[i],c.iterator,a);if("throw"===f.type){n.delegate=null,i="throw",a=f.arg;continue}i="next",a=v;var l=f.arg;if(!l.done)return o=j,l;n[c.resultName]=l.value,n.next=c.nextLoc,n.delegate=null}if("next"===i)n.sent=n._sent=a;else if("throw"===i){if(o===E)throw o=k,a;n.dispatchException(a)&&(i="next",a=v)}else"return"===i&&n.abrupt("return",a);o=_;var f=e(t,r,n);if("normal"===f.type){o=n.done?k:j;var l={value:f.arg,done:n.done};if(f.arg!==G)return l;n.delegate&&"next"===i&&(a=v)}else"throw"===f.type&&(o=k,i="throw",a=f.arg)}}}function l(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function s(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function h(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(l,this),this.reset(!0)}function p(t){if(t){var r=t[m];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var e=-1,n=function r(){for(;++e=0;--n){var o=this.tryEntries[n],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var a=d.call(o,"catchLoc"),c=d.call(o,"finallyLoc");if(a&&c){if(this.prev=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&d.call(n,"finallyLoc")&&this.prev=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),s(e),G}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;s(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:p(t),resultName:r,nextLoc:e},G}}}("object"==typeof global?global:"object"==typeof window?window:"object"==typeof self?self:this); \ No newline at end of file +!function(t){"use strict";var s,f=t.Promise,u=Object.prototype.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",e=r.toStringTag||"@@toStringTag",n="object"==typeof module,i=t.regeneratorRuntime;if(i)n&&(module.exports=i);else{(i=t.regeneratorRuntime=n?module.exports:{}).wrap=c;var h="suspendedStart",p="suspendedYield",y="executing",v="completed",g={},a=m.prototype=w.prototype;l.prototype=a.constructor=m,m.constructor=l,m[e]=l.displayName="GeneratorFunction",i.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===l||"GeneratorFunction"===(r.displayName||r.name))},i.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,m):(t.__proto__=m,e in t||(t[e]="GeneratorFunction")),t.prototype=Object.create(a),t},i.awrap=function(t){return new x(t)},L(b.prototype),i.async=function(t,r,e,n){var o=new b(c(t,r,e,n));return i.isGeneratorFunction(r)?o:o.next().then(function(t){return t.done?t.value:o.next()})},L(a),a[o]=function(){return this},a[e]="Generator",a.toString=function(){return"[object Generator]"},i.keys=function(e){var n=[];for(var t in e)n.push(t);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},i.values=k,_.prototype={constructor:_,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=s,this.done=!1,this.delegate=null,this.tryEntries.forEach(j),!t)for(var r in this)"t"===r.charAt(0)&&u.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=s)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function t(t,r){return i.type="throw",i.arg=e,n.next=t,!!r}for(var r=this.tryEntries.length-1;0<=r;--r){var o=this.tryEntries[r],i=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var a=u.call(o,"catchLoc"),c=u.call(o,"finallyLoc");if(a&&c){if(this.prev * * * \**********************************************************/ +/* global Proxy */ (function (hprose, undefined) { 'use strict'; var setImmediate = hprose.setImmediate; @@ -40,6 +41,29 @@ var s_function = 'function'; var s_object = 'object'; + function HproseProxy(setFunction, ns) { + var settings = {}; + this.get = function(target, prop/*, receiver*/) { + var name = prop.toString(); + if (ns) { name = ns + '_' + name; } + if (name === 'then') { return undefined; } + if (!target.hasOwnProperty(name)) { + settings[name] = {}; + var handler = new HproseProxy(setFunction, name); + var func = setFunction(settings, name); + handler.apply = function(target, thisArg, argumentsList) { + return func.apply(null, argumentsList); + } + handler.set = function(target, prop, value/*, receiver*/) { + settings[name][prop] = value; + return true; + }; + target[name] = new Proxy(function() {}, handler); + } + return target[name]; + }; + } + function Client(uri, functions, settings) { // private members @@ -863,7 +887,12 @@ setImmediate(initService, stub); return _ready; } - setFunctions(stub, functions); + else if (typeof(Proxy) === 'undefined') { + setFunctions(stub, functions); + } + else { + stub = new Proxy({}, new HproseProxy(setFunction)); + } _ready.resolve(stub); return stub; } diff --git a/src/CopyRight.js b/src/CopyRight.js index e59036f..4228a56 100644 --- a/src/CopyRight.js +++ b/src/CopyRight.js @@ -1,4 +1,4 @@ -// Hprose for WeChat App v2.0.2 +// Hprose for WeChat App v2.0.3 // Copyright (c) 2008-2016 http://hprose.com // Hprose is freely distributable under the MIT license. // For all details and documentation: