From baca54ba26121b82527abbdbf0c6a77b132250b1 Mon Sep 17 00:00:00 2001 From: "ionut.stan" Date: Thu, 20 Apr 2017 20:58:55 +0300 Subject: [PATCH] Wrote tests and fixed bugs for bidirectional jsonrpc over ws from within the browser. --- README.MD | 2 +- builds/browser/es5/jsonrpc.min.js | 4 +- builds/browser/es5/jsonrpc.min.js.map | 2 +- builds/browser/es7/jsonrpc.min.js | 30305 ++++++++++++++++++++++++ builds/browser/es7/jsonrpc.min.js.map | 1 + package.json | 2 +- src/IncomingRequest.js | 2 +- tests/AllTests.js | 34 +- tests/Browser/TestEndpoint.js | 67 + tests/Browser/index.html | 122 +- tests/TestEndpoint.js | 10 +- webpack.config.js | 10 +- 12 files changed, 30522 insertions(+), 39 deletions(-) create mode 100644 builds/browser/es7/jsonrpc.min.js create mode 100644 builds/browser/es7/jsonrpc.min.js.map create mode 100644 tests/Browser/TestEndpoint.js diff --git a/README.MD b/README.MD index 452f3e5..05dc624 100644 --- a/README.MD +++ b/README.MD @@ -212,7 +212,7 @@ const wsJSONRPCRouter = new JSONRPC.BidirectionalWebsocketRouter(jsonrpcServer); // Optional. wsJSONRPCRouter.on("madeReverseCallsClient", (clientReverseCalls) => { /*add plugins or just setup the client even further*/ }); - +// Alternatively reuse existing web server: const webSocketServer = new WebSocketServer({server: httpServerInstance}); const webSocketServer = new WebSocketServer({port: 8080}); webSocketServer.on("error", (error) => {console.error(error); process.exit(1);}); diff --git a/builds/browser/es5/jsonrpc.min.js b/builds/browser/es5/jsonrpc.min.js index 21a09a4..5916d22 100644 --- a/builds/browser/es5/jsonrpc.min.js +++ b/builds/browser/es5/jsonrpc.min.js @@ -1,8 +1,8 @@ /** - jsonrpc-bidirectional v2.1.11 + jsonrpc-bidirectional v2.1.41 Bidirectional JSONRPC over web sockets or HTTP with extensive plugin support. https://github.com/bigstepinc/jsonrpc-bidirectional https://github.com/bigstepinc/jsonrpc-bidirectional/blob/master/LICENSE */ -!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("WebSocket"));else if("function"==typeof define&&define.amd)define(["WebSocket"],t);else{var n=t("object"==typeof exports?require("WebSocket"):e.WebSocket);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=416)}([function(e,t,n){var r=n(2),i=n(27),o=n(15),a=n(16),s=n(28),c=function(e,t,n){var u,f,l,h,p=e&c.F,d=e&c.G,v=e&c.S,b=e&c.P,g=e&c.B,y=d?r:v?r[t]||(r[t]={}):(r[t]||{}).prototype,_=d?i:i[t]||(i[t]={}),m=_.prototype||(_.prototype={});d&&(n=t);for(u in n)f=!p&&y&&void 0!==y[u],l=(f?y:n)[u],h=g&&f?s(l,r):b&&"function"==typeof l?s(Function.call,l):l,y&&a(y,u,l,e&c.U),_[u]!=l&&o(_,u,h),b&&m[u]!=l&&(m[u]=l)};r.core=i,c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,e.exports=c},function(e,t,n){var r=n(5);e.exports=function(e){if(!r(e))throw TypeError(e+" is not an object!");return e}},function(e,t){var n=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},function(e,t){e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t,n){"use strict";(function(e){function r(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(e,t){if(r()=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|e}function v(e){return+e!=e&&(e=0),o.alloc(+e)}function b(e,t){if(o.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return Z(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Y(e).length;default:if(r)return Z(e).length;t=(""+t).toLowerCase(),r=!0}}function g(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if(n>>>=0,t>>>=0,n<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,n);case"utf8":case"utf-8":return A(this,t,n);case"ascii":return T(this,t,n);case"latin1":case"binary":return j(this,t,n);case"base64":return O(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function y(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function _(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=o.from(t,r)),o.isBuffer(t))return 0===t.length?-1:m(e,t,n,r,i);if("number"==typeof t)return t&=255,o.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):m(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function m(e,t,n,r,i){function o(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}var a=1,s=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,s/=2,c/=2,n/=2}var u;if(i){var f=-1;for(u=n;us&&(n=s-c),u=n;u>=0;u--){for(var l=!0,h=0;hi&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var a=0;a239?4:o>223?3:o>191?2:1;if(i+s<=n){var c,u,f,l;switch(s){case 1:o<128&&(a=o);break;case 2:c=e[i+1],128==(192&c)&&(l=(31&o)<<6|63&c)>127&&(a=l);break;case 3:c=e[i+1],u=e[i+2],128==(192&c)&&128==(192&u)&&(l=(15&o)<<12|(63&c)<<6|63&u)>2047&&(l<55296||l>57343)&&(a=l);break;case 4:c=e[i+1],u=e[i+2],f=e[i+3],128==(192&c)&&128==(192&u)&&128==(192&f)&&(l=(15&o)<<18|(63&c)<<12|(63&u)<<6|63&f)>65535&&l<1114112&&(a=l)}}null===a?(a=65533,s=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|1023&a),r.push(a),i+=s}return P(r)}function P(e){var t=e.length;if(t<=Q)return String.fromCharCode.apply(String,e);for(var n="",r=0;rr)&&(n=r);for(var i="",o=t;on)throw new RangeError("Trying to access beyond buffer length")}function I(e,t,n,r,i,a){if(!o.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function L(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i>>8*(r?i:1-i)}function M(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i>>8*(r?i:3-i)&255}function U(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function D(e,t,n,r,i){return i||U(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),X.write(e,t,n,r,23,4),n+4}function F(e,t,n,r,i){return i||U(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),X.write(e,t,n,r,52,8),n+8}function z(e){if(e=q(e).replace(ee,""),e.length<2)return"";for(;e.length%4!=0;)e+="=";return e}function q(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function W(e){return e<16?"0"+e.toString(16):e.toString(16)}function Z(e,t){t=t||1/0;for(var n,r=e.length,i=null,o=[],a=0;a55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function H(e){for(var t=[],n=0;n>8,i=n%256,o.push(i),o.push(r);return o}function Y(e){return K.toByteArray(z(e))}function G(e,t,n,r){for(var i=0;i=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function V(e){return e!==e}var K=n(171),X=n(381),$=n(146);t.Buffer=o,t.SlowBuffer=v,t.INSPECT_MAX_BYTES=50,o.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=r(),o.poolSize=8192,o._augment=function(e){return e.__proto__=o.prototype,e},o.from=function(e,t,n){return a(null,e,t,n)},o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0})),o.alloc=function(e,t,n){return c(null,e,t,n)},o.allocUnsafe=function(e){return u(null,e)},o.allocUnsafeSlow=function(e){return u(null,e)},o.isBuffer=function(e){return!(null==e||!e._isBuffer)},o.compare=function(e,t){if(!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,a=Math.min(n,r);i0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},o.prototype.compare=function(e,t,n,r,i){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;for(var a=i-r,s=n-t,c=Math.min(a,s),u=this.slice(r,i),f=e.slice(t,n),l=0;li)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return w(this,e,t,n);case"utf8":case"utf-8":return S(this,e,t,n);case"ascii":return x(this,e,t,n);case"latin1":case"binary":return k(this,e,t,n);case"base64":return E(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Q=4096;o.prototype.slice=function(e,t){var n=this.length;e=~~e,t=void 0===t?n:~~t,e<0?(e+=n)<0&&(e=0):e>n&&(e=n),t<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)r+=this[e+--t]*i;return r},o.prototype.readUInt8=function(e,t){return t||N(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return t||N(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return t||N(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return t||N(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},o.prototype.readUInt32BE=function(e,t){return t||N(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||N(e,t,this.length);for(var r=this[e],i=1,o=0;++o=i&&(r-=Math.pow(2,8*t)),r},o.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||N(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},o.prototype.readInt8=function(e,t){return t||N(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},o.prototype.readInt16LE=function(e,t){t||N(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt16BE=function(e,t){t||N(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt32LE=function(e,t){return t||N(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return t||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return t||N(e,4,this.length),X.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return t||N(e,4,this.length),X.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return t||N(e,8,this.length),X.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return t||N(e,8,this.length),X.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t|=0,n|=0,!r){I(this,e,t,n,Math.pow(2,8*n)-1,0)}var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+n},o.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,1,255,0),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):L(this,e,t,!0),t+2},o.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):L(this,e,t,!1),t+2},o.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):M(this,e,t,!0),t+4},o.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},o.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);I(this,e,t,n,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+n},o.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);I(this,e,t,n,i-1,-i)}var o=n-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+n},o.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,1,127,-128),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):L(this,e,t,!0),t+2},o.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):L(this,e,t,!1),t+2},o.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):M(this,e,t,!0),t+4},o.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},o.prototype.writeFloatLE=function(e,t,n){return D(this,e,t,!0,n)},o.prototype.writeFloatBE=function(e,t,n){return D(this,e,t,!1,n)},o.prototype.writeDoubleLE=function(e,t,n){return F(this,e,t,!0,n)},o.prototype.writeDoubleBE=function(e,t,n){return F(this,e,t,!1,n)},o.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t=0;--i)e[i+t]=this[i+n];else if(a<1e3||!o.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,n=void 0===n?this.length:n>>>0,e||(e=0);var a;if("number"==typeof e)for(a=t;a0?i(r(e),9007199254740991):0}},function(e,t,n){var r=n(22);e.exports=function(e){return Object(r(e))}},function(e,t){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function i(e){if(f===setTimeout)return setTimeout(e,0);if((f===n||!f)&&setTimeout)return f=setTimeout,setTimeout(e,0);try{return f(e,0)}catch(t){try{return f.call(null,e,0)}catch(t){return f.call(this,e,0)}}}function o(e){if(l===clearTimeout)return clearTimeout(e);if((l===r||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(e);try{return l(e)}catch(t){try{return l.call(null,e)}catch(t){return l.call(this,e)}}}function a(){v&&p&&(v=!1,p.length?d=p.concat(d):b=-1,d.length&&s())}function s(){if(!v){var e=i(a);v=!0;for(var t=d.length;t;){for(p=d,d=[];++b1)for(var n=1;n"+i+""};e.exports=function(e,t){var n={};n[e]=t(a),r(r.P+r.F*i(function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3}),"String",n)}},function(e,t,n){var r=n(56),i=n(22);e.exports=function(e){return r(i(e))}},function(e,t,n){var r=n(57),i=n(34),o=n(18),a=n(26),s=n(13),c=n(124),u=Object.getOwnPropertyDescriptor;t.f=n(7)?u:function(e,t){if(e=o(e),t=a(t,!0),c)try{return u(e,t)}catch(e){}if(s(e,t))return i(!r.f.call(e,t),e[t])}},function(e,t,n){var r=n(13),i=n(10),o=n(94)("IE_PROTO"),a=Object.prototype;e.exports=Object.getPrototypeOf||function(e){return e=i(e),r(e,o)?e[o]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?a:null}},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t){e.exports=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}},function(e,t,n){var r=n(3);e.exports=function(e,t){return!!e&&r(function(){t?e.call(null,function(){},1):e.call(null)})}},function(e,t,n){var r=n(28),i=n(56),o=n(10),a=n(9),s=n(177);e.exports=function(e,t){var n=1==e,c=2==e,u=3==e,f=4==e,l=6==e,h=5==e||l,p=t||s;return function(t,s,d){for(var v,b,g=o(t),y=i(g),_=r(s,d,3),m=a(y.length),w=0,S=n?p(t,m):c?p(t,0):void 0;m>w;w++)if((h||w in y)&&(v=y[w],b=_(v,w,g),e))if(n)S[w]=b;else if(b)switch(e){case 3:return!0;case 5:return v;case 6:return w;case 2:S.push(v)}else if(f)return!1;return l?-1:u||f?f:S}}},function(e,t,n){var r=n(0),i=n(27),o=n(3);e.exports=function(e,t){var n=(i.Object||{})[e]||Object[e],a={};a[e]=t(n),r(r.S+r.F*o(function(){n(1)}),"Object",a)}},function(e,t,n){var r=n(5);e.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;if("function"==typeof(n=e.valueOf)&&!r(i=n.call(e)))return i;if(!t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;throw TypeError("Can't convert object to primitive value")}},function(e,t){var n=e.exports={version:"2.4.0"};"number"==typeof __e&&(__e=n)},function(e,t,n){var r=n(14);e.exports=function(e,t,n){if(r(e),void 0===t)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},function(e,t,n){var r=n(140),i=n(0),o=n(73)("metadata"),a=o.store||(o.store=new(n(143))),s=function(e,t,n){var i=a.get(e);if(!i){if(!n)return;a.set(e,i=new r)}var o=i.get(t);if(!o){if(!n)return;i.set(t,o=new r)}return o},c=function(e,t,n){var r=s(t,n,!1);return void 0!==r&&r.has(e)},u=function(e,t,n){var r=s(t,n,!1);return void 0===r?void 0:r.get(e)},f=function(e,t,n,r){s(n,r,!0).set(e,t)},l=function(e,t){var n=s(e,t,!1),r=[];return n&&n.forEach(function(e,t){r.push(t)}),r},h=function(e){return void 0===e||"symbol"==typeof e?e:String(e)},p=function(e){i(i.S,"Reflect",e)};e.exports={store:a,map:s,has:c,get:u,set:f,keys:l,key:h,exp:p}},function(e,t,n){"use strict";if(n(7)){var r=n(38),i=n(2),o=n(3),a=n(0),s=n(74),c=n(101),u=n(28),f=n(37),l=n(34),h=n(15),p=n(42),d=n(35),v=n(9),b=n(44),g=n(26),y=n(13),_=n(137),m=n(55),w=n(5),S=n(10),x=n(86),k=n(39),E=n(20),R=n(40).f,O=n(103),A=n(45),P=n(6),T=n(24),j=n(64),C=n(95),B=n(104),N=n(51),I=n(70),L=n(43),M=n(79),U=n(117),D=n(8),F=n(19),z=D.f,q=F.f,W=i.RangeError,Z=i.TypeError,H=i.Uint8Array,J=Array.prototype,Y=c.ArrayBuffer,G=c.DataView,V=T(0),K=T(2),X=T(3),$=T(4),Q=T(5),ee=T(6),te=j(!0),ne=j(!1),re=B.values,ie=B.keys,oe=B.entries,ae=J.lastIndexOf,se=J.reduce,ce=J.reduceRight,ue=J.join,fe=J.sort,le=J.slice,he=J.toString,pe=J.toLocaleString,de=P("iterator"),ve=P("toStringTag"),be=A("typed_constructor"),ge=A("def_constructor"),ye=s.CONSTR,_e=s.TYPED,me=s.VIEW,we=T(1,function(e,t){return Oe(C(e,e[ge]),t)}),Se=o(function(){return 1===new H(new Uint16Array([1]).buffer)[0]}),xe=!!H&&!!H.prototype.set&&o(function(){new H(1).set({})}),ke=function(e,t){if(void 0===e)throw Z("Wrong length!");var n=+e,r=v(e);if(t&&!_(n,r))throw W("Wrong length!");return r},Ee=function(e,t){var n=d(e);if(n<0||n%t)throw W("Wrong offset!");return n},Re=function(e){if(w(e)&&_e in e)return e;throw Z(e+" is not a typed array!")},Oe=function(e,t){if(!(w(e)&&be in e))throw Z("It is not a typed array constructor!");return new e(t)},Ae=function(e,t){return Pe(C(e,e[ge]),t)},Pe=function(e,t){for(var n=0,r=t.length,i=Oe(e,r);r>n;)i[n]=t[n++];return i},Te=function(e,t,n){z(e,t,{get:function(){return this._d[n]}})},je=function(e){var t,n,r,i,o,a,s=S(e),c=arguments.length,f=c>1?arguments[1]:void 0,l=void 0!==f,h=O(s);if(void 0!=h&&!x(h)){for(a=h.call(s),r=[],t=0;!(o=a.next()).done;t++)r.push(o.value);s=r}for(l&&c>2&&(f=u(f,arguments[2],2)),t=0,n=v(s.length),i=Oe(this,n);n>t;t++)i[t]=l?f(s[t],t):s[t];return i},Ce=function(){for(var e=0,t=arguments.length,n=Oe(this,t);t>e;)n[e]=arguments[e++];return n},Be=!!H&&o(function(){pe.call(new H(1))}),Ne=function(){return pe.apply(Be?le.call(Re(this)):Re(this),arguments)},Ie={copyWithin:function(e,t){return U.call(Re(this),e,t,arguments.length>2?arguments[2]:void 0)},every:function(e){return $(Re(this),e,arguments.length>1?arguments[1]:void 0)},fill:function(e){return M.apply(Re(this),arguments)},filter:function(e){return Ae(this,K(Re(this),e,arguments.length>1?arguments[1]:void 0))},find:function(e){return Q(Re(this),e,arguments.length>1?arguments[1]:void 0)},findIndex:function(e){return ee(Re(this),e,arguments.length>1?arguments[1]:void 0)},forEach:function(e){V(Re(this),e,arguments.length>1?arguments[1]:void 0)},indexOf:function(e){return ne(Re(this),e,arguments.length>1?arguments[1]:void 0)},includes:function(e){return te(Re(this),e,arguments.length>1?arguments[1]:void 0)},join:function(e){return ue.apply(Re(this),arguments)},lastIndexOf:function(e){return ae.apply(Re(this),arguments)},map:function(e){return we(Re(this),e,arguments.length>1?arguments[1]:void 0)},reduce:function(e){return se.apply(Re(this),arguments)},reduceRight:function(e){return ce.apply(Re(this),arguments)},reverse:function(){for(var e,t=this,n=Re(t).length,r=Math.floor(n/2),i=0;i1?arguments[1]:void 0)},sort:function(e){return fe.call(Re(this),e)},subarray:function(e,t){var n=Re(this),r=n.length,i=b(e,r);return new(C(n,n[ge]))(n.buffer,n.byteOffset+i*n.BYTES_PER_ELEMENT,v((void 0===t?r:b(t,r))-i))}},Le=function(e,t){return Ae(this,le.call(Re(this),e,t))},Me=function(e){Re(this);var t=Ee(arguments[1],1),n=this.length,r=S(e),i=v(r.length),o=0;if(i+t>n)throw W("Wrong length!");for(;o255?255:255&r),i.v[d](n*t+i.o,r,Se)},P=function(e,t){z(e,t,{get:function(){return O(this,t)},set:function(e){return A(this,t,e)},enumerable:!0})};_?(b=n(function(e,n,r,i){f(e,b,u,"_d");var o,a,s,c,l=0,p=0;if(w(n)){if(!(n instanceof Y||"ArrayBuffer"==(c=m(n))||"SharedArrayBuffer"==c))return _e in n?Pe(b,n):je.call(b,n);o=n,p=Ee(r,t);var d=n.byteLength;if(void 0===i){if(d%t)throw W("Wrong length!");if((a=d-p)<0)throw W("Wrong length!")}else if((a=v(i)*t)+p>d)throw W("Wrong length!");s=a/t}else s=ke(n,!0),a=s*t,o=new Y(a);for(h(e,"_d",{b:o,o:p,l:a,e:s,v:new G(o)});l=0;s--)if(c[s]!==u[s])return!1;for(s=c.length-1;s>=0;s--)if(a=c[s],!p(e[a],t[a],n,r))return!1;return!0}function b(e,t,n){p(e,t,!0)&&l(e,t,n,"notDeepStrictEqual",b)}function g(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function y(e){var t;try{e()}catch(e){t=e}return t}function _(e,t,n,r){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof n&&(r=n,n=null),i=y(t),r=(n&&n.name?" ("+n.name+").":".")+(r?" "+r:"."),e&&!i&&l(i,n,"Missing expected exception"+r);var o="string"==typeof r,a=!e&&m.isError(i),s=!e&&i&&!n;if((a&&o&&g(i,n)||s)&&l(i,n,"Got unwanted exception"+r),e&&i&&n&&!g(i,n)||!e&&i)throw i}var m=n(113),w=Object.prototype.hasOwnProperty,S=Array.prototype.slice,x=function(){return"foo"===function(){}.name}(),k=e.exports=h,E=/\s*function\s+([^\(\s]*)\s*/;k.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=f(this),this.generatedMessage=!0);var t=e.stackStartFunction||l;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var n=new Error;if(n.stack){var r=n.stack,i=s(t),o=r.indexOf("\n"+i);if(o>=0){var a=r.indexOf("\n",o+1);r=r.substring(a+1)}this.stack=r}}},m.inherits(k.AssertionError,Error),k.fail=l,k.ok=h,k.equal=function(e,t,n){e!=t&&l(e,t,n,"==",k.equal)},k.notEqual=function(e,t,n){e==t&&l(e,t,n,"!=",k.notEqual)},k.deepEqual=function(e,t,n){p(e,t,!1)||l(e,t,n,"deepEqual",k.deepEqual)},k.deepStrictEqual=function(e,t,n){p(e,t,!0)||l(e,t,n,"deepStrictEqual",k.deepStrictEqual)},k.notDeepEqual=function(e,t,n){p(e,t,!1)&&l(e,t,n,"notDeepEqual",k.notDeepEqual)},k.notDeepStrictEqual=b,k.strictEqual=function(e,t,n){e!==t&&l(e,t,n,"===",k.strictEqual)},k.notStrictEqual=function(e,t,n){e===t&&l(e,t,n,"!==",k.notStrictEqual)},k.throws=function(e,t,n){_(!0,e,t,n)},k.doesNotThrow=function(e,t,n){_(!1,e,t,n)},k.ifError=function(e){if(e)throw e};var R=Object.keys||function(e){var t=[];for(var n in e)w.call(e,n)&&t.push(n);return t}}).call(t,n(12))},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;n0?r:n)(e)}},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},function(e,t){e.exports=function(e,t,n,r){if(!(e instanceof t)||void 0!==r&&r in e)throw TypeError(n+": incorrect invocation!");return e}},function(e,t){e.exports=!1},function(e,t,n){var r=n(1),i=n(130),o=n(82),a=n(94)("IE_PROTO"),s=function(){},c=function(){var e,t=n(81)("iframe"),r=o.length;for(t.style.display="none",n(84).appendChild(t),t.src="javascript:",e=t.contentWindow.document,e.open(),e.write(" + diff --git a/tests/TestEndpoint.js b/tests/TestEndpoint.js index c2703e4..4413a92 100644 --- a/tests/TestEndpoint.js +++ b/tests/TestEndpoint.js @@ -21,6 +21,7 @@ class TestEndpoint extends JSONRPC.EndpointBase ); this.fnResolveWaitForWebPage = null; + this.nWaitForWebPageRemainingCallsCount = null; //Object.seal(this); } @@ -47,8 +48,15 @@ class TestEndpoint extends JSONRPC.EndpointBase { await incomingRequest.reverseCallsClient.rpc("ping", [strATeamCharacterName + " called back to confirm this: " + strReturn + "!", /*bRandomSleep*/ true]); } + else if(strReturn === "Calling from html es5 client, bidirectional websocket mode.") + { + await incomingRequest.reverseCallsClient.rpc("ping", ["This is node. You, the browser, called back earlier to confirm this: " + strReturn + "!", /*bRandomSleep*/ false, "CallMeBackOnceAgain"]); + } - if(this.fnResolveWaitForWebPage !== null) + if( + this.fnResolveWaitForWebPage !== null + && --this.nWaitForWebPageRemainingCallsCount === 0 + ) { this.fnResolveWaitForWebPage(); this.fnResolveWaitForWebPage = null; diff --git a/webpack.config.js b/webpack.config.js index 9eb6d99..95707de 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,7 @@ const path = require("path"); const fs = require("fs"); const webpack = require("webpack"); +const recursiveKeys = require("recursive-keys"); const objPackageJSON = JSON.parse(fs.readFileSync("package.json")); @@ -51,7 +52,14 @@ module.exports = [ minimize: true, sourceMap: true, compress: { screw_ie8: true }, - mangle: { screw_ie8: true }, + mangle: { + screw_ie8: true, + except: recursiveKeys.dumpKeysRecursively(require("./index_webpack")).map( + (strClassName) => { + return strClassName.split(".").pop(); + } + ) + }, output: { screw_ie8: true, comments: false,