Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

client code recompiled

  • Loading branch information...
commit 7b1e1bf7add425d4d5a3f5ff40c6832adafa9052 1 parent 809c19f
@dimsmol authored
View
68 client/apis.amd.js
@@ -815,14 +815,32 @@ module.exports = JsonpRequest;
},{"./http_request":5,"./errors":3,"inh":9}],9:[function(require,module,exports){
"use strict";
-var inherits = function(childCtor, parentCtor) {
- var TempCtor = function () {};
- TempCtor.prototype = parentCtor.prototype;
- childCtor.super_ = parentCtor;
- childCtor.prototype = new TempCtor();
- childCtor.prototype.constructor = childCtor;
-};
-
+var inherits;
+
+if (typeof Object.create === 'function') {
+ // implementation from standard node.js 'util' module
+ inherits = function(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ ctor.prototype = Object.create(superCtor.prototype, {
+ constructor: {
+ value: ctor,
+ enumerable: false,
+ writable: true,
+ configurable: true
+ }
+ });
+ };
+}
+else {
+ // old school shim for old browsers
+ inherits = function(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ var TempCtor = function () {};
+ TempCtor.prototype = superCtor.prototype;
+ ctor.prototype = new TempCtor();
+ ctor.prototype.constructor = ctor;
+ };
+}
module.exports = inherits;
@@ -894,14 +912,32 @@ module.exports = ErrorBase;
},{"inh":10}],10:[function(require,module,exports){
"use strict";
-var inherits = function(childCtor, parentCtor) {
- var TempCtor = function () {};
- TempCtor.prototype = parentCtor.prototype;
- childCtor.super_ = parentCtor;
- childCtor.prototype = new TempCtor();
- childCtor.prototype.constructor = childCtor;
-};
-
+var inherits;
+
+if (typeof Object.create === 'function') {
+ // implementation from standard node.js 'util' module
+ inherits = function(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ ctor.prototype = Object.create(superCtor.prototype, {
+ constructor: {
+ value: ctor,
+ enumerable: false,
+ writable: true,
+ configurable: true
+ }
+ });
+ };
+}
+else {
+ // old school shim for old browsers
+ inherits = function(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ var TempCtor = function () {};
+ TempCtor.prototype = superCtor.prototype;
+ ctor.prototype = new TempCtor();
+ ctor.prototype.constructor = ctor;
+ };
+}
module.exports = inherits;
View
2  client/apis.amd.min.js
@@ -1 +1 @@
-(function(t,e,r,o){function s(o){if(!r[o]){if(!e[o]){if(t)return t(o);throw Error("Cannot find module '"+o+"'")}var n=r[o]={exports:{}};e[o][0](function(t){var r=e[o][1][t];return s(r?r:t)},n,n.exports)}return r[o].exports}for(var n=0;o.length>n;n++)s(o[n]);return s})("undefined"!=typeof require&&require,{1:[function(t,e,r){define("apis",[],function(){return t("../../lib/client")})},{"../../lib/client":2}],2:[function(t,e,r){"use strict";var o=t("./errors"),s=t("./http"),n=t("./http_request"),a=t("./jsonp_request"),i=t("./socket");e.exports={errors:o,Http:s,HttpRequest:n,JsonpRequest:a,Socket:i}},{"./errors":3,"./http":4,"./http_request":5,"./jsonp_request":6,"./socket":7}],4:[function(t,e,r){"use strict";var o=t("./http_request"),s=t("./jsonp_request"),n=function(t){this.baseUri=t};n.prototype.send=function(t,e,r,o,s,n){var a;if(null==s||null==s.crossDomain)a=this.sendHttp(t,e,r,o,s,n);else switch(s.crossDomain){case"jsonp":a=this.sendJsonp(t,e,r,o,s,n);break;default:throw Error("Unsupported crossDomain option "+s.crossDomain)}return a},n.prototype.sendHttp=function(t,e,r,s,n,a){return new o(this,t,e,r,s,n,a).send()},n.prototype.sendJsonp=function(t,e,r,o,n,a){return new s(this,t,e,r,o,n,a).send()},e.exports=n},{"./http_request":5,"./jsonp_request":6}],5:[function(t,e,r){"use strict";var o=t("./errors"),s=function(t,e,r,o,s,n,a){this.http=t,this.options=n||{},this.path=e,this.method=r,this.headers=o||{},this.data=s,this.cb=a,this.url=null,this.body=null,this.transport=null,this.isAborted=!1,this.timeout=null};s.prototype.methodHttpHeaderName="X-Method",s.prototype.authHttpHeaderName="X-Auth",s.prototype.authExpectedHttpHeaderName="X-AuthExpected",s.prototype.authRenewalHttpHeaderName="X-AuthRenewal",s.prototype.authRenewalIssuedHttpHeaderName="X-AuthRenewalIssued",s.prototype.authRenewalMaxAgeHttpHeaderName="X-AuthRenewalMaxAge",s.prototype.headersUrlKey="headers",s.prototype.bodyUrlKey="body",s.prototype.xdomainUrlKey="xdomain",s.prototype.defaultContentType="application/json",s.prototype.send=function(){return this.createTimeout(),this.url=this.createUrl(),this.body=this.createBody(),this.transport=this.createTransport(),this.createCallback(),this.sendInternal(),this},s.prototype.abort=function(){this.isAborted=!0,this.clearTimeout(),null!=this.transport&&(this.transport.onreadystatechange=null,this.transport.abort())},s.prototype.createTimeout=function(){var t=this.options.timeout;if(null!=t){var e=this;this.timeout=setTimeout(function(){e.handleTimeout()},t)}},s.prototype.handleTimeout=function(){this.abort(),this.cb(new o.TimeoutError)},s.prototype.clearTimeout=function(){null!=this.timeout&&clearTimeout(this.timeout)},s.prototype.createUrl=function(){var t=this.path;return this.http.baseUri&&(t=this.http.baseUri+this.path),t},s.prototype.createBody=function(){var t;return t=void 0===this.data?"":JSON.stringify(this.data)},s.prototype.createTransport=function(){return new XMLHttpRequest},s.prototype.createCallback=function(){var t=this;this.transport.onreadystatechange=function(){4==t.transport.readyState&&(t.transport.onreadystatechange=null,t.isNetworkError()?t.handleNetworkError():t.handleResponse())}},s.prototype.isNetworkError=function(){return!this.transport.status},s.prototype.handleNetworkError=function(){this.clearTimeout(),this.cb(new o.NetworkError)},s.prototype.sendInternal=function(){"get"==this.method?this.sendGet():this.sendPost()},s.prototype.sendGet=function(){this.transport.open("GET",this.createGetUrl()),this.setHttpHeaders(),this.transport.send()},s.prototype.createGetUrl=function(){var t=this.createGetUrlParts(),e=this.url;return t.length>0&&(e+="?"+t.join("&")),e},s.prototype.createGetUrlParts=function(t){var e=t||[];return this.body&&e.push(this.bodyUrlKey+"="+encodeURIComponent(this.body)),e},s.prototype.sendPost=function(){var t=this.transport;t.open("POST",this.url),this.setContentTypeHttpHeader(),this.setMethodHttpHeader(),this.setHttpHeaders(),t.send(this.body)},s.prototype.setHttpHeaders=function(){var t=this.createHttpHeaders(),e=this.transport;for(var r in t)e.setRequestHeader(r,t[r])},s.prototype.createHttpHeaders=function(){var t=this.headers,e=t.http||{};return delete t.http,t.auth&&(e[this.authHttpHeaderName]=t.auth),t.authExpected&&(e[this.authExpectedHttpHeaderName]=t.authExpected),e},s.prototype.setContentTypeHttpHeader=function(){var t=this.headers.http&&this.headers.http["Content-type"]||this.headers.contentType||this.defaultContentType;this.transport.setRequestHeader("Content-type",t)},s.prototype.setMethodHttpHeader=function(){"create"!=this.method&&this.transport.setRequestHeader(this.methodHttpHeaderName,this.method)},s.prototype.handleResponse=function(){this.clearTimeout();var t=this.createResult(),e=this.extractError(t);null!=e?this.cb(e):this.cb(null,t)},s.prototype.createResult=function(){var t={headers:this.getResultHeaders(),data:this.getResultData()},e=this.getResultStatus();null!=e&&(t.status=e);var r=this.getTransportForResult();return null!=r&&(t.transport=r),t},s.prototype.getTransportForResult=function(){return this.transport},s.prototype.getResultStatus=function(){return this.transport.status},s.prototype.getResultHeaders=function(){var t={},e=this.transport.getResponseHeader(this.authRenewalHttpHeaderName);if(e){var r={token:e};t.authRenewal=r;var o=this.transport.getResponseHeader(this.authRenewalIssuedHttpHeaderName);o&&(r.issued=new Date(o));var s=this.transport.getResponseHeader(this.authRenewalMaxAgeHttpHeaderName);s&&(r.maxAge=parseInt(s,10))}return t},s.prototype.getResultData=function(){var t=this.getResultBody();return t?JSON.parse(t):void 0},s.prototype.getResultBody=function(){return this.transport.responseText},s.prototype.extractError=function(t){var e=t.status,r=null;return 200!=e&&204!=e&&(r=new o.WebError(t)),r},e.exports=s},{"./errors":3}],7:[function(t,e,r){"use strict";var o=t("./errors"),s=function(t,e,r){this.basePath=t,this.socketUri=e||this.defaultSocketUri,this.protocols=r,this.onSocketCreated=null,this.onMessage=null,this.customWebSocketClass=null,this.socket=null,this.requests={},this.abortFunc=this.createAbortFunc()};s.prototype.defaultSocketUri="/socket",s.prototype.headerSeparator="\n\n",s.prototype.defaultTimeout=null,s.prototype.getWebSocketClass=function(){return this.customWebSocketClass||WebSocket},s.prototype.createAbortFunc=function(){var t=this;return function(){t.handleAbort(this)}},s.prototype.createSocket=function(){var t=this.getWebSocketClass();return new t(this.socketUri,this.protocols)},s.prototype.connect=function(t){if(null!=this.socket)switch(this.socket.readyState){case 0:t&&this.socket.addEventListener("open",function(){t()});break;case 1:t&&t();break;default:this.socket=null}if(null==this.socket){this.socket=this.createSocket(),this.onSocketCreated&&this.onSocketCreated(this.socket),t&&this.socket.addEventListener("open",function(){t()});var e=this;this.socket.addEventListener("message",function(t){e.handleMessage(t)}),this.socket.addEventListener("close",function(t){e.handleClose(t)})}},s.prototype.handleMessage=function(t){var e=this.parse(t.data),r=null!=e.headers?e.headers.requestId:null;if(null!=r){var o=this.requests[r];if(o){var s=o.cb;this.clearRequest(o,r);var n=this.extractError(e);null!=n?s(n):s(null,e)}}else null!=this.onMessage&&this.onMessage(e)},s.prototype.createRequestId=function(){for(var t=""+(new Date).getTime(),e=0,r=t;r in this.requests;)r=t+"_"+e++;return r},s.prototype.clearRequest=function(t){delete this.requests[t.id];var e=t.timeout;null!=e&&clearTimeout(e)},s.prototype.close=function(){null!=this.socket&&this.socket.close()},s.prototype.send=function(t,e,r,o,s,n){var a=this;this.connect(function(){a.sendInternal(t,e,r,o,s,n)})},s.prototype.sendInternal=function(t,e,r,o,s,n){r=r||{},r.method=e,r.path=this.getEffectivePath(t);var a;n&&(a=this.createRequest(s,n),r.requestId=a.id);var i;i=void 0===o?"":JSON.stringify(o);var p=[JSON.stringify(r),i].join(this.headerSeparator);return this.socket.send(p),a},s.prototype.getEffectivePath=function(t){var e=t;return this.basePath&&(e=this.basePath+t),e},s.prototype.createRequest=function(t,e){var r=this.createRequestId(),o={id:r,cb:e,options:t,abort:this.abortFunc};return o.timeout=this.createTimeout(o),this.requests[r]=o,o},s.prototype.createTimeout=function(t){var e=t.options,r=null,o=null!=e&&null!=e.timeout?e.timeout:this.defaultTimeout;if(null!=o){var s=this;r=setTimeout(function(){s.handleTimeout(t)},o)}return r},s.prototype.handleTimeout=function(t){var e=t.cb;this.clearRequest(t),e(new o.TimeoutError)},s.prototype.handleAbort=function(t){this.clearRequest(t)},s.prototype.handleClose=function(t){for(var e in this.requests){var r=this.requests[e],s=r.cb;this.clearRequest(r),s(new o.ConnectionCloseError(t))}},s.prototype.parse=function(t){var e=t.indexOf(this.headerSeparator),r=t.substring(0,e),o=t.substring(e+this.headerSeparator.length),s=JSON.parse(r),n={headers:s,data:this.parseBody(o)};return null!=s.status&&(n.status=s.status),n},s.prototype.parseBody=function(t){var e;return t&&(e=JSON.parse(t)),e},s.prototype.extractError=function(t){var e=t.status,r=null;return 200!=e&&204!=e&&(r=new o.WebError(t)),r},e.exports=s},{"./errors":3}],3:[function(t,e,r){"use strict";var o=t("inh"),s=t("nerr/lib/error_base"),n=function(t){s.call(this),this.response=t,this.status=t.status;var e=t.data||{};this._message=e.message,this.status=t.status,this.code=e.code};o(n,s),n.prototype.name="WebError",n.prototype.getMessage=function(){return this._message};var a=function(){s.call(this)};o(a,s),a.prototype.name="NetworkError";var i=function(){s.call(this)};o(i,s),i.prototype.name="TimeoutError";var p=function(t){s.call(this),this.closeEvent=t};o(p,s),p.prototype.name="ConnectionCloseError",p.prototype.getMessage=function(){return this.closeEvent.reason},e.exports={WebError:n,NetworkError:a,TimeoutError:i,ConnectionCloseError:p}},{"nerr/lib/error_base":8,inh:9}],6:[function(t,e,r){"use strict";var o=t("inh"),s=t("./http_request"),n=t("./errors"),a=function(t,e,r,o,n,a,i){s.call(this,t,e,r,o,n,a,i),this.callbacks=this.getCallbacks(),this.scriptEl=null,this.callbackId=null,this.response=null};o(a,s),a.callbacks=null,a.prototype.callbacksGlobalPath="apis.jsonp.callbacks",a.prototype.xdomainValue="jsonp",a.prototype.jsonpCallbackUrlKey="callback",a.prototype.abort=function(){this.isAborted=!0,this.clearTimeout()},a.prototype.getCallbacks=function(){if(null==a.callbacks){for(var t=this.callbacksGlobalPath.split("."),e=window,r=0;t.length>r;r++){var o=t[r],s=e[o]||{};e[o]=s,e=s}a.callbacks=e}return a.callbacks},a.prototype.createTransport=function(){var t=document.createElement("script");t.async=!0;var e=this;return t.onerror=function(t){e.handleScriptErrorEvent(t)},this.scriptEl=t,t},a.prototype.handleScriptErrorEvent=function(t){this.cleanup(),this.isAborted||this.cb(new n.NetworkError)},a.prototype.createCallback=function(){var t=this;this.callbackId=this.createCallbackId(),this.callbacks[this.callbackId]=function(e){t.response=e,t.handleResponse()}},a.prototype.createCallbackId=function(){for(var t="cb"+(new Date).getTime(),e=0,r=t;r in this.callbacks;)r=t+"_"+e++;return r},a.prototype.sendInternal=function(){this.scriptEl.src=this.createGetUrl();var t=document.head||document.getElementsByTagName("head")[0]||document.documentElement,e=t.firstChild;e?t.insertBefore(this.scriptEl,t.firstChild):t.appendChild(this.scriptEl)},a.prototype.createGetUrlParts=function(t){var e=t||[],r=this.headers;return"get"!=this.method&&(r=r||{},r.method=this.method),r&&e.push(this.headersUrlKey+"="+encodeURIComponent(JSON.stringify(r))),a.super_.prototype.createGetUrlParts.call(this,e),e.push(this.xdomainUrlKey+"="+this.xdomainValue),e.push(this.jsonpCallbackUrlKey+"="+encodeURIComponent(this.createCallbackName())),e},a.prototype.createCallbackName=function(){return this.callbacksGlobalPath+"."+this.callbackId},a.prototype.setHttpHeaders=function(){},a.prototype.handleResponse=function(){this.cleanup(),this.isAborted||a.super_.prototype.handleResponse.call(this)},a.prototype.cleanup=function(){this.clearTimeout(),this.removeCallback(),this.removeScripEl()},a.prototype.removeCallback=function(){delete this.callbacks[this.callbackId]},a.prototype.removeScripEl=function(){var t=this.scriptEl;null!=t&&t.parentNode&&(t.parentNode.removeChild(t),this.scriptEl=null)},a.prototype.getTransportForResult=function(){return null},a.prototype.getResultStatus=function(){var t=this.getResultHeaders();return t.status},a.prototype.getResultHeaders=function(){return this.response.headers||{}},a.prototype.getResultData=function(){return this.response.data},e.exports=a},{"./http_request":5,"./errors":3,inh:9}],9:[function(t,e,r){"use strict";var o=function(t,e){var r=function(){};r.prototype=e.prototype,t.super_=e,t.prototype=new r,t.prototype.constructor=t};e.exports=o},{}],8:[function(t,e,r){"use strict";var o=t("inh"),s=function(){Error.call(this),this.captureStackTrace()};o(s,Error),s.prototype.name="ErrorBase",s.prototype.captureStackTrace=function(){if(Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);else{var t=Error(),e=this;t.toString=function(){return""+e};var r=function(){return t.stack};Object.defineProperties?Object.defineProperties({stack:r}):this.getStackTrace=r}},s.prototype.toString=function(){var t=this.name,e=this.getMessage();return e&&(t=[t,e].join(": ")),t},s.prototype.getMessage=function(){return null},s.prototype.getStackTrace=function(){return this.stack},Object.defineProperties&&Object.defineProperties(s.prototype,{message:{get:function(){return this.getMessage()}}}),e.exports=s},{inh:10}],10:[function(t,e,r){"use strict";var o=function(t,e){var r=function(){};r.prototype=e.prototype,t.super_=e,t.prototype=new r,t.prototype.constructor=t};e.exports=o},{}]},{},[1]);
+(function(t,e,r,o){function s(o){if(!r[o]){if(!e[o]){if(t)return t(o);throw Error("Cannot find module '"+o+"'")}var n=r[o]={exports:{}};e[o][0](function(t){var r=e[o][1][t];return s(r?r:t)},n,n.exports)}return r[o].exports}for(var n=0;o.length>n;n++)s(o[n]);return s})("undefined"!=typeof require&&require,{1:[function(t,e,r){define("apis",[],function(){return t("../../lib/client")})},{"../../lib/client":2}],2:[function(t,e,r){"use strict";var o=t("./errors"),s=t("./http"),n=t("./http_request"),a=t("./jsonp_request"),i=t("./socket");e.exports={errors:o,Http:s,HttpRequest:n,JsonpRequest:a,Socket:i}},{"./errors":3,"./http":4,"./http_request":5,"./jsonp_request":6,"./socket":7}],4:[function(t,e,r){"use strict";var o=t("./http_request"),s=t("./jsonp_request"),n=function(t){this.baseUri=t};n.prototype.send=function(t,e,r,o,s,n){var a;if(null==s||null==s.crossDomain)a=this.sendHttp(t,e,r,o,s,n);else switch(s.crossDomain){case"jsonp":a=this.sendJsonp(t,e,r,o,s,n);break;default:throw Error("Unsupported crossDomain option "+s.crossDomain)}return a},n.prototype.sendHttp=function(t,e,r,s,n,a){return new o(this,t,e,r,s,n,a).send()},n.prototype.sendJsonp=function(t,e,r,o,n,a){return new s(this,t,e,r,o,n,a).send()},e.exports=n},{"./http_request":5,"./jsonp_request":6}],5:[function(t,e,r){"use strict";var o=t("./errors"),s=function(t,e,r,o,s,n,a){this.http=t,this.options=n||{},this.path=e,this.method=r,this.headers=o||{},this.data=s,this.cb=a,this.url=null,this.body=null,this.transport=null,this.isAborted=!1,this.timeout=null};s.prototype.methodHttpHeaderName="X-Method",s.prototype.authHttpHeaderName="X-Auth",s.prototype.authExpectedHttpHeaderName="X-AuthExpected",s.prototype.authRenewalHttpHeaderName="X-AuthRenewal",s.prototype.authRenewalIssuedHttpHeaderName="X-AuthRenewalIssued",s.prototype.authRenewalMaxAgeHttpHeaderName="X-AuthRenewalMaxAge",s.prototype.headersUrlKey="headers",s.prototype.bodyUrlKey="body",s.prototype.xdomainUrlKey="xdomain",s.prototype.defaultContentType="application/json",s.prototype.send=function(){return this.createTimeout(),this.url=this.createUrl(),this.body=this.createBody(),this.transport=this.createTransport(),this.createCallback(),this.sendInternal(),this},s.prototype.abort=function(){this.isAborted=!0,this.clearTimeout(),null!=this.transport&&(this.transport.onreadystatechange=null,this.transport.abort())},s.prototype.createTimeout=function(){var t=this.options.timeout;if(null!=t){var e=this;this.timeout=setTimeout(function(){e.handleTimeout()},t)}},s.prototype.handleTimeout=function(){this.abort(),this.cb(new o.TimeoutError)},s.prototype.clearTimeout=function(){null!=this.timeout&&clearTimeout(this.timeout)},s.prototype.createUrl=function(){var t=this.path;return this.http.baseUri&&(t=this.http.baseUri+this.path),t},s.prototype.createBody=function(){var t;return t=void 0===this.data?"":JSON.stringify(this.data)},s.prototype.createTransport=function(){return new XMLHttpRequest},s.prototype.createCallback=function(){var t=this;this.transport.onreadystatechange=function(){4==t.transport.readyState&&(t.transport.onreadystatechange=null,t.isNetworkError()?t.handleNetworkError():t.handleResponse())}},s.prototype.isNetworkError=function(){return!this.transport.status},s.prototype.handleNetworkError=function(){this.clearTimeout(),this.cb(new o.NetworkError)},s.prototype.sendInternal=function(){"get"==this.method?this.sendGet():this.sendPost()},s.prototype.sendGet=function(){this.transport.open("GET",this.createGetUrl()),this.setHttpHeaders(),this.transport.send()},s.prototype.createGetUrl=function(){var t=this.createGetUrlParts(),e=this.url;return t.length>0&&(e+="?"+t.join("&")),e},s.prototype.createGetUrlParts=function(t){var e=t||[];return this.body&&e.push(this.bodyUrlKey+"="+encodeURIComponent(this.body)),e},s.prototype.sendPost=function(){var t=this.transport;t.open("POST",this.url),this.setContentTypeHttpHeader(),this.setMethodHttpHeader(),this.setHttpHeaders(),t.send(this.body)},s.prototype.setHttpHeaders=function(){var t=this.createHttpHeaders(),e=this.transport;for(var r in t)e.setRequestHeader(r,t[r])},s.prototype.createHttpHeaders=function(){var t=this.headers,e=t.http||{};return delete t.http,t.auth&&(e[this.authHttpHeaderName]=t.auth),t.authExpected&&(e[this.authExpectedHttpHeaderName]=t.authExpected),e},s.prototype.setContentTypeHttpHeader=function(){var t=this.headers.http&&this.headers.http["Content-type"]||this.headers.contentType||this.defaultContentType;this.transport.setRequestHeader("Content-type",t)},s.prototype.setMethodHttpHeader=function(){"create"!=this.method&&this.transport.setRequestHeader(this.methodHttpHeaderName,this.method)},s.prototype.handleResponse=function(){this.clearTimeout();var t=this.createResult(),e=this.extractError(t);null!=e?this.cb(e):this.cb(null,t)},s.prototype.createResult=function(){var t={headers:this.getResultHeaders(),data:this.getResultData()},e=this.getResultStatus();null!=e&&(t.status=e);var r=this.getTransportForResult();return null!=r&&(t.transport=r),t},s.prototype.getTransportForResult=function(){return this.transport},s.prototype.getResultStatus=function(){return this.transport.status},s.prototype.getResultHeaders=function(){var t={},e=this.transport.getResponseHeader(this.authRenewalHttpHeaderName);if(e){var r={token:e};t.authRenewal=r;var o=this.transport.getResponseHeader(this.authRenewalIssuedHttpHeaderName);o&&(r.issued=new Date(o));var s=this.transport.getResponseHeader(this.authRenewalMaxAgeHttpHeaderName);s&&(r.maxAge=parseInt(s,10))}return t},s.prototype.getResultData=function(){var t=this.getResultBody();return t?JSON.parse(t):void 0},s.prototype.getResultBody=function(){return this.transport.responseText},s.prototype.extractError=function(t){var e=t.status,r=null;return 200!=e&&204!=e&&(r=new o.WebError(t)),r},e.exports=s},{"./errors":3}],7:[function(t,e,r){"use strict";var o=t("./errors"),s=function(t,e,r){this.basePath=t,this.socketUri=e||this.defaultSocketUri,this.protocols=r,this.onSocketCreated=null,this.onMessage=null,this.customWebSocketClass=null,this.socket=null,this.requests={},this.abortFunc=this.createAbortFunc()};s.prototype.defaultSocketUri="/socket",s.prototype.headerSeparator="\n\n",s.prototype.defaultTimeout=null,s.prototype.getWebSocketClass=function(){return this.customWebSocketClass||WebSocket},s.prototype.createAbortFunc=function(){var t=this;return function(){t.handleAbort(this)}},s.prototype.createSocket=function(){var t=this.getWebSocketClass();return new t(this.socketUri,this.protocols)},s.prototype.connect=function(t){if(null!=this.socket)switch(this.socket.readyState){case 0:t&&this.socket.addEventListener("open",function(){t()});break;case 1:t&&t();break;default:this.socket=null}if(null==this.socket){this.socket=this.createSocket(),this.onSocketCreated&&this.onSocketCreated(this.socket),t&&this.socket.addEventListener("open",function(){t()});var e=this;this.socket.addEventListener("message",function(t){e.handleMessage(t)}),this.socket.addEventListener("close",function(t){e.handleClose(t)})}},s.prototype.handleMessage=function(t){var e=this.parse(t.data),r=null!=e.headers?e.headers.requestId:null;if(null!=r){var o=this.requests[r];if(o){var s=o.cb;this.clearRequest(o,r);var n=this.extractError(e);null!=n?s(n):s(null,e)}}else null!=this.onMessage&&this.onMessage(e)},s.prototype.createRequestId=function(){for(var t=""+(new Date).getTime(),e=0,r=t;r in this.requests;)r=t+"_"+e++;return r},s.prototype.clearRequest=function(t){delete this.requests[t.id];var e=t.timeout;null!=e&&clearTimeout(e)},s.prototype.close=function(){null!=this.socket&&this.socket.close()},s.prototype.send=function(t,e,r,o,s,n){var a=this;this.connect(function(){a.sendInternal(t,e,r,o,s,n)})},s.prototype.sendInternal=function(t,e,r,o,s,n){r=r||{},r.method=e,r.path=this.getEffectivePath(t);var a;n&&(a=this.createRequest(s,n),r.requestId=a.id);var i;i=void 0===o?"":JSON.stringify(o);var p=[JSON.stringify(r),i].join(this.headerSeparator);return this.socket.send(p),a},s.prototype.getEffectivePath=function(t){var e=t;return this.basePath&&(e=this.basePath+t),e},s.prototype.createRequest=function(t,e){var r=this.createRequestId(),o={id:r,cb:e,options:t,abort:this.abortFunc};return o.timeout=this.createTimeout(o),this.requests[r]=o,o},s.prototype.createTimeout=function(t){var e=t.options,r=null,o=null!=e&&null!=e.timeout?e.timeout:this.defaultTimeout;if(null!=o){var s=this;r=setTimeout(function(){s.handleTimeout(t)},o)}return r},s.prototype.handleTimeout=function(t){var e=t.cb;this.clearRequest(t),e(new o.TimeoutError)},s.prototype.handleAbort=function(t){this.clearRequest(t)},s.prototype.handleClose=function(t){for(var e in this.requests){var r=this.requests[e],s=r.cb;this.clearRequest(r),s(new o.ConnectionCloseError(t))}},s.prototype.parse=function(t){var e=t.indexOf(this.headerSeparator),r=t.substring(0,e),o=t.substring(e+this.headerSeparator.length),s=JSON.parse(r),n={headers:s,data:this.parseBody(o)};return null!=s.status&&(n.status=s.status),n},s.prototype.parseBody=function(t){var e;return t&&(e=JSON.parse(t)),e},s.prototype.extractError=function(t){var e=t.status,r=null;return 200!=e&&204!=e&&(r=new o.WebError(t)),r},e.exports=s},{"./errors":3}],3:[function(t,e,r){"use strict";var o=t("inh"),s=t("nerr/lib/error_base"),n=function(t){s.call(this),this.response=t,this.status=t.status;var e=t.data||{};this._message=e.message,this.status=t.status,this.code=e.code};o(n,s),n.prototype.name="WebError",n.prototype.getMessage=function(){return this._message};var a=function(){s.call(this)};o(a,s),a.prototype.name="NetworkError";var i=function(){s.call(this)};o(i,s),i.prototype.name="TimeoutError";var p=function(t){s.call(this),this.closeEvent=t};o(p,s),p.prototype.name="ConnectionCloseError",p.prototype.getMessage=function(){return this.closeEvent.reason},e.exports={WebError:n,NetworkError:a,TimeoutError:i,ConnectionCloseError:p}},{"nerr/lib/error_base":8,inh:9}],6:[function(t,e,r){"use strict";var o=t("inh"),s=t("./http_request"),n=t("./errors"),a=function(t,e,r,o,n,a,i){s.call(this,t,e,r,o,n,a,i),this.callbacks=this.getCallbacks(),this.scriptEl=null,this.callbackId=null,this.response=null};o(a,s),a.callbacks=null,a.prototype.callbacksGlobalPath="apis.jsonp.callbacks",a.prototype.xdomainValue="jsonp",a.prototype.jsonpCallbackUrlKey="callback",a.prototype.abort=function(){this.isAborted=!0,this.clearTimeout()},a.prototype.getCallbacks=function(){if(null==a.callbacks){for(var t=this.callbacksGlobalPath.split("."),e=window,r=0;t.length>r;r++){var o=t[r],s=e[o]||{};e[o]=s,e=s}a.callbacks=e}return a.callbacks},a.prototype.createTransport=function(){var t=document.createElement("script");t.async=!0;var e=this;return t.onerror=function(t){e.handleScriptErrorEvent(t)},this.scriptEl=t,t},a.prototype.handleScriptErrorEvent=function(t){this.cleanup(),this.isAborted||this.cb(new n.NetworkError)},a.prototype.createCallback=function(){var t=this;this.callbackId=this.createCallbackId(),this.callbacks[this.callbackId]=function(e){t.response=e,t.handleResponse()}},a.prototype.createCallbackId=function(){for(var t="cb"+(new Date).getTime(),e=0,r=t;r in this.callbacks;)r=t+"_"+e++;return r},a.prototype.sendInternal=function(){this.scriptEl.src=this.createGetUrl();var t=document.head||document.getElementsByTagName("head")[0]||document.documentElement,e=t.firstChild;e?t.insertBefore(this.scriptEl,t.firstChild):t.appendChild(this.scriptEl)},a.prototype.createGetUrlParts=function(t){var e=t||[],r=this.headers;return"get"!=this.method&&(r=r||{},r.method=this.method),r&&e.push(this.headersUrlKey+"="+encodeURIComponent(JSON.stringify(r))),a.super_.prototype.createGetUrlParts.call(this,e),e.push(this.xdomainUrlKey+"="+this.xdomainValue),e.push(this.jsonpCallbackUrlKey+"="+encodeURIComponent(this.createCallbackName())),e},a.prototype.createCallbackName=function(){return this.callbacksGlobalPath+"."+this.callbackId},a.prototype.setHttpHeaders=function(){},a.prototype.handleResponse=function(){this.cleanup(),this.isAborted||a.super_.prototype.handleResponse.call(this)},a.prototype.cleanup=function(){this.clearTimeout(),this.removeCallback(),this.removeScripEl()},a.prototype.removeCallback=function(){delete this.callbacks[this.callbackId]},a.prototype.removeScripEl=function(){var t=this.scriptEl;null!=t&&t.parentNode&&(t.parentNode.removeChild(t),this.scriptEl=null)},a.prototype.getTransportForResult=function(){return null},a.prototype.getResultStatus=function(){var t=this.getResultHeaders();return t.status},a.prototype.getResultHeaders=function(){return this.response.headers||{}},a.prototype.getResultData=function(){return this.response.data},e.exports=a},{"./http_request":5,"./errors":3,inh:9}],9:[function(t,e,r){"use strict";var o;o="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t},e.exports=o},{}],8:[function(t,e,r){"use strict";var o=t("inh"),s=function(){Error.call(this),this.captureStackTrace()};o(s,Error),s.prototype.name="ErrorBase",s.prototype.captureStackTrace=function(){if(Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);else{var t=Error(),e=this;t.toString=function(){return""+e};var r=function(){return t.stack};Object.defineProperties?Object.defineProperties({stack:r}):this.getStackTrace=r}},s.prototype.toString=function(){var t=this.name,e=this.getMessage();return e&&(t=[t,e].join(": ")),t},s.prototype.getMessage=function(){return null},s.prototype.getStackTrace=function(){return this.stack},Object.defineProperties&&Object.defineProperties(s.prototype,{message:{get:function(){return this.getMessage()}}}),e.exports=s},{inh:10}],10:[function(t,e,r){"use strict";var o;o="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t},e.exports=o},{}]},{},[1]);
View
68 client/apis.global.js
@@ -829,14 +829,32 @@ module.exports = JsonpRequest;
},{"./http_request":5,"./errors":3,"inh":9}],9:[function(require,module,exports){
"use strict";
-var inherits = function(childCtor, parentCtor) {
- var TempCtor = function () {};
- TempCtor.prototype = parentCtor.prototype;
- childCtor.super_ = parentCtor;
- childCtor.prototype = new TempCtor();
- childCtor.prototype.constructor = childCtor;
-};
-
+var inherits;
+
+if (typeof Object.create === 'function') {
+ // implementation from standard node.js 'util' module
+ inherits = function(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ ctor.prototype = Object.create(superCtor.prototype, {
+ constructor: {
+ value: ctor,
+ enumerable: false,
+ writable: true,
+ configurable: true
+ }
+ });
+ };
+}
+else {
+ // old school shim for old browsers
+ inherits = function(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ var TempCtor = function () {};
+ TempCtor.prototype = superCtor.prototype;
+ ctor.prototype = new TempCtor();
+ ctor.prototype.constructor = ctor;
+ };
+}
module.exports = inherits;
@@ -908,14 +926,32 @@ module.exports = ErrorBase;
},{"inh":10}],10:[function(require,module,exports){
"use strict";
-var inherits = function(childCtor, parentCtor) {
- var TempCtor = function () {};
- TempCtor.prototype = parentCtor.prototype;
- childCtor.super_ = parentCtor;
- childCtor.prototype = new TempCtor();
- childCtor.prototype.constructor = childCtor;
-};
-
+var inherits;
+
+if (typeof Object.create === 'function') {
+ // implementation from standard node.js 'util' module
+ inherits = function(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ ctor.prototype = Object.create(superCtor.prototype, {
+ constructor: {
+ value: ctor,
+ enumerable: false,
+ writable: true,
+ configurable: true
+ }
+ });
+ };
+}
+else {
+ // old school shim for old browsers
+ inherits = function(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ var TempCtor = function () {};
+ TempCtor.prototype = superCtor.prototype;
+ ctor.prototype = new TempCtor();
+ ctor.prototype.constructor = ctor;
+ };
+}
module.exports = inherits;
View
2  client/apis.global.min.js
@@ -1 +1 @@
-(function(t,e,r,o){function s(o){if(!r[o]){if(!e[o]){if(t)return t(o);throw Error("Cannot find module '"+o+"'")}var n=r[o]={exports:{}};e[o][0](function(t){var r=e[o][1][t];return s(r?r:t)},n,n.exports)}return r[o].exports}for(var n=0;o.length>n;n++)s(o[n]);return s})("undefined"!=typeof require&&require,{1:[function(t,e,r){"use strict";var o=t("../../lib/client"),s="apis"in window,n=window.apis;window.apis=o,o.noConflict=function(){return s?window.apis=n:delete window.apis,o}},{"../../lib/client":2}],2:[function(t,e,r){"use strict";var o=t("./errors"),s=t("./http"),n=t("./http_request"),a=t("./jsonp_request"),i=t("./socket");e.exports={errors:o,Http:s,HttpRequest:n,JsonpRequest:a,Socket:i}},{"./errors":3,"./http":4,"./http_request":5,"./jsonp_request":6,"./socket":7}],4:[function(t,e,r){"use strict";var o=t("./http_request"),s=t("./jsonp_request"),n=function(t){this.baseUri=t};n.prototype.send=function(t,e,r,o,s,n){var a;if(null==s||null==s.crossDomain)a=this.sendHttp(t,e,r,o,s,n);else switch(s.crossDomain){case"jsonp":a=this.sendJsonp(t,e,r,o,s,n);break;default:throw Error("Unsupported crossDomain option "+s.crossDomain)}return a},n.prototype.sendHttp=function(t,e,r,s,n,a){return new o(this,t,e,r,s,n,a).send()},n.prototype.sendJsonp=function(t,e,r,o,n,a){return new s(this,t,e,r,o,n,a).send()},e.exports=n},{"./http_request":5,"./jsonp_request":6}],5:[function(t,e,r){"use strict";var o=t("./errors"),s=function(t,e,r,o,s,n,a){this.http=t,this.options=n||{},this.path=e,this.method=r,this.headers=o||{},this.data=s,this.cb=a,this.url=null,this.body=null,this.transport=null,this.isAborted=!1,this.timeout=null};s.prototype.methodHttpHeaderName="X-Method",s.prototype.authHttpHeaderName="X-Auth",s.prototype.authExpectedHttpHeaderName="X-AuthExpected",s.prototype.authRenewalHttpHeaderName="X-AuthRenewal",s.prototype.authRenewalIssuedHttpHeaderName="X-AuthRenewalIssued",s.prototype.authRenewalMaxAgeHttpHeaderName="X-AuthRenewalMaxAge",s.prototype.headersUrlKey="headers",s.prototype.bodyUrlKey="body",s.prototype.xdomainUrlKey="xdomain",s.prototype.defaultContentType="application/json",s.prototype.send=function(){return this.createTimeout(),this.url=this.createUrl(),this.body=this.createBody(),this.transport=this.createTransport(),this.createCallback(),this.sendInternal(),this},s.prototype.abort=function(){this.isAborted=!0,this.clearTimeout(),null!=this.transport&&(this.transport.onreadystatechange=null,this.transport.abort())},s.prototype.createTimeout=function(){var t=this.options.timeout;if(null!=t){var e=this;this.timeout=setTimeout(function(){e.handleTimeout()},t)}},s.prototype.handleTimeout=function(){this.abort(),this.cb(new o.TimeoutError)},s.prototype.clearTimeout=function(){null!=this.timeout&&clearTimeout(this.timeout)},s.prototype.createUrl=function(){var t=this.path;return this.http.baseUri&&(t=this.http.baseUri+this.path),t},s.prototype.createBody=function(){var t;return t=void 0===this.data?"":JSON.stringify(this.data)},s.prototype.createTransport=function(){return new XMLHttpRequest},s.prototype.createCallback=function(){var t=this;this.transport.onreadystatechange=function(){4==t.transport.readyState&&(t.transport.onreadystatechange=null,t.isNetworkError()?t.handleNetworkError():t.handleResponse())}},s.prototype.isNetworkError=function(){return!this.transport.status},s.prototype.handleNetworkError=function(){this.clearTimeout(),this.cb(new o.NetworkError)},s.prototype.sendInternal=function(){"get"==this.method?this.sendGet():this.sendPost()},s.prototype.sendGet=function(){this.transport.open("GET",this.createGetUrl()),this.setHttpHeaders(),this.transport.send()},s.prototype.createGetUrl=function(){var t=this.createGetUrlParts(),e=this.url;return t.length>0&&(e+="?"+t.join("&")),e},s.prototype.createGetUrlParts=function(t){var e=t||[];return this.body&&e.push(this.bodyUrlKey+"="+encodeURIComponent(this.body)),e},s.prototype.sendPost=function(){var t=this.transport;t.open("POST",this.url),this.setContentTypeHttpHeader(),this.setMethodHttpHeader(),this.setHttpHeaders(),t.send(this.body)},s.prototype.setHttpHeaders=function(){var t=this.createHttpHeaders(),e=this.transport;for(var r in t)e.setRequestHeader(r,t[r])},s.prototype.createHttpHeaders=function(){var t=this.headers,e=t.http||{};return delete t.http,t.auth&&(e[this.authHttpHeaderName]=t.auth),t.authExpected&&(e[this.authExpectedHttpHeaderName]=t.authExpected),e},s.prototype.setContentTypeHttpHeader=function(){var t=this.headers.http&&this.headers.http["Content-type"]||this.headers.contentType||this.defaultContentType;this.transport.setRequestHeader("Content-type",t)},s.prototype.setMethodHttpHeader=function(){"create"!=this.method&&this.transport.setRequestHeader(this.methodHttpHeaderName,this.method)},s.prototype.handleResponse=function(){this.clearTimeout();var t=this.createResult(),e=this.extractError(t);null!=e?this.cb(e):this.cb(null,t)},s.prototype.createResult=function(){var t={headers:this.getResultHeaders(),data:this.getResultData()},e=this.getResultStatus();null!=e&&(t.status=e);var r=this.getTransportForResult();return null!=r&&(t.transport=r),t},s.prototype.getTransportForResult=function(){return this.transport},s.prototype.getResultStatus=function(){return this.transport.status},s.prototype.getResultHeaders=function(){var t={},e=this.transport.getResponseHeader(this.authRenewalHttpHeaderName);if(e){var r={token:e};t.authRenewal=r;var o=this.transport.getResponseHeader(this.authRenewalIssuedHttpHeaderName);o&&(r.issued=new Date(o));var s=this.transport.getResponseHeader(this.authRenewalMaxAgeHttpHeaderName);s&&(r.maxAge=parseInt(s,10))}return t},s.prototype.getResultData=function(){var t=this.getResultBody();return t?JSON.parse(t):void 0},s.prototype.getResultBody=function(){return this.transport.responseText},s.prototype.extractError=function(t){var e=t.status,r=null;return 200!=e&&204!=e&&(r=new o.WebError(t)),r},e.exports=s},{"./errors":3}],7:[function(t,e,r){"use strict";var o=t("./errors"),s=function(t,e,r){this.basePath=t,this.socketUri=e||this.defaultSocketUri,this.protocols=r,this.onSocketCreated=null,this.onMessage=null,this.customWebSocketClass=null,this.socket=null,this.requests={},this.abortFunc=this.createAbortFunc()};s.prototype.defaultSocketUri="/socket",s.prototype.headerSeparator="\n\n",s.prototype.defaultTimeout=null,s.prototype.getWebSocketClass=function(){return this.customWebSocketClass||WebSocket},s.prototype.createAbortFunc=function(){var t=this;return function(){t.handleAbort(this)}},s.prototype.createSocket=function(){var t=this.getWebSocketClass();return new t(this.socketUri,this.protocols)},s.prototype.connect=function(t){if(null!=this.socket)switch(this.socket.readyState){case 0:t&&this.socket.addEventListener("open",function(){t()});break;case 1:t&&t();break;default:this.socket=null}if(null==this.socket){this.socket=this.createSocket(),this.onSocketCreated&&this.onSocketCreated(this.socket),t&&this.socket.addEventListener("open",function(){t()});var e=this;this.socket.addEventListener("message",function(t){e.handleMessage(t)}),this.socket.addEventListener("close",function(t){e.handleClose(t)})}},s.prototype.handleMessage=function(t){var e=this.parse(t.data),r=null!=e.headers?e.headers.requestId:null;if(null!=r){var o=this.requests[r];if(o){var s=o.cb;this.clearRequest(o,r);var n=this.extractError(e);null!=n?s(n):s(null,e)}}else null!=this.onMessage&&this.onMessage(e)},s.prototype.createRequestId=function(){for(var t=""+(new Date).getTime(),e=0,r=t;r in this.requests;)r=t+"_"+e++;return r},s.prototype.clearRequest=function(t){delete this.requests[t.id];var e=t.timeout;null!=e&&clearTimeout(e)},s.prototype.close=function(){null!=this.socket&&this.socket.close()},s.prototype.send=function(t,e,r,o,s,n){var a=this;this.connect(function(){a.sendInternal(t,e,r,o,s,n)})},s.prototype.sendInternal=function(t,e,r,o,s,n){r=r||{},r.method=e,r.path=this.getEffectivePath(t);var a;n&&(a=this.createRequest(s,n),r.requestId=a.id);var i;i=void 0===o?"":JSON.stringify(o);var p=[JSON.stringify(r),i].join(this.headerSeparator);return this.socket.send(p),a},s.prototype.getEffectivePath=function(t){var e=t;return this.basePath&&(e=this.basePath+t),e},s.prototype.createRequest=function(t,e){var r=this.createRequestId(),o={id:r,cb:e,options:t,abort:this.abortFunc};return o.timeout=this.createTimeout(o),this.requests[r]=o,o},s.prototype.createTimeout=function(t){var e=t.options,r=null,o=null!=e&&null!=e.timeout?e.timeout:this.defaultTimeout;if(null!=o){var s=this;r=setTimeout(function(){s.handleTimeout(t)},o)}return r},s.prototype.handleTimeout=function(t){var e=t.cb;this.clearRequest(t),e(new o.TimeoutError)},s.prototype.handleAbort=function(t){this.clearRequest(t)},s.prototype.handleClose=function(t){for(var e in this.requests){var r=this.requests[e],s=r.cb;this.clearRequest(r),s(new o.ConnectionCloseError(t))}},s.prototype.parse=function(t){var e=t.indexOf(this.headerSeparator),r=t.substring(0,e),o=t.substring(e+this.headerSeparator.length),s=JSON.parse(r),n={headers:s,data:this.parseBody(o)};return null!=s.status&&(n.status=s.status),n},s.prototype.parseBody=function(t){var e;return t&&(e=JSON.parse(t)),e},s.prototype.extractError=function(t){var e=t.status,r=null;return 200!=e&&204!=e&&(r=new o.WebError(t)),r},e.exports=s},{"./errors":3}],3:[function(t,e,r){"use strict";var o=t("inh"),s=t("nerr/lib/error_base"),n=function(t){s.call(this),this.response=t,this.status=t.status;var e=t.data||{};this._message=e.message,this.status=t.status,this.code=e.code};o(n,s),n.prototype.name="WebError",n.prototype.getMessage=function(){return this._message};var a=function(){s.call(this)};o(a,s),a.prototype.name="NetworkError";var i=function(){s.call(this)};o(i,s),i.prototype.name="TimeoutError";var p=function(t){s.call(this),this.closeEvent=t};o(p,s),p.prototype.name="ConnectionCloseError",p.prototype.getMessage=function(){return this.closeEvent.reason},e.exports={WebError:n,NetworkError:a,TimeoutError:i,ConnectionCloseError:p}},{"nerr/lib/error_base":8,inh:9}],6:[function(t,e,r){"use strict";var o=t("inh"),s=t("./http_request"),n=t("./errors"),a=function(t,e,r,o,n,a,i){s.call(this,t,e,r,o,n,a,i),this.callbacks=this.getCallbacks(),this.scriptEl=null,this.callbackId=null,this.response=null};o(a,s),a.callbacks=null,a.prototype.callbacksGlobalPath="apis.jsonp.callbacks",a.prototype.xdomainValue="jsonp",a.prototype.jsonpCallbackUrlKey="callback",a.prototype.abort=function(){this.isAborted=!0,this.clearTimeout()},a.prototype.getCallbacks=function(){if(null==a.callbacks){for(var t=this.callbacksGlobalPath.split("."),e=window,r=0;t.length>r;r++){var o=t[r],s=e[o]||{};e[o]=s,e=s}a.callbacks=e}return a.callbacks},a.prototype.createTransport=function(){var t=document.createElement("script");t.async=!0;var e=this;return t.onerror=function(t){e.handleScriptErrorEvent(t)},this.scriptEl=t,t},a.prototype.handleScriptErrorEvent=function(t){this.cleanup(),this.isAborted||this.cb(new n.NetworkError)},a.prototype.createCallback=function(){var t=this;this.callbackId=this.createCallbackId(),this.callbacks[this.callbackId]=function(e){t.response=e,t.handleResponse()}},a.prototype.createCallbackId=function(){for(var t="cb"+(new Date).getTime(),e=0,r=t;r in this.callbacks;)r=t+"_"+e++;return r},a.prototype.sendInternal=function(){this.scriptEl.src=this.createGetUrl();var t=document.head||document.getElementsByTagName("head")[0]||document.documentElement,e=t.firstChild;e?t.insertBefore(this.scriptEl,t.firstChild):t.appendChild(this.scriptEl)},a.prototype.createGetUrlParts=function(t){var e=t||[],r=this.headers;return"get"!=this.method&&(r=r||{},r.method=this.method),r&&e.push(this.headersUrlKey+"="+encodeURIComponent(JSON.stringify(r))),a.super_.prototype.createGetUrlParts.call(this,e),e.push(this.xdomainUrlKey+"="+this.xdomainValue),e.push(this.jsonpCallbackUrlKey+"="+encodeURIComponent(this.createCallbackName())),e},a.prototype.createCallbackName=function(){return this.callbacksGlobalPath+"."+this.callbackId},a.prototype.setHttpHeaders=function(){},a.prototype.handleResponse=function(){this.cleanup(),this.isAborted||a.super_.prototype.handleResponse.call(this)},a.prototype.cleanup=function(){this.clearTimeout(),this.removeCallback(),this.removeScripEl()},a.prototype.removeCallback=function(){delete this.callbacks[this.callbackId]},a.prototype.removeScripEl=function(){var t=this.scriptEl;null!=t&&t.parentNode&&(t.parentNode.removeChild(t),this.scriptEl=null)},a.prototype.getTransportForResult=function(){return null},a.prototype.getResultStatus=function(){var t=this.getResultHeaders();return t.status},a.prototype.getResultHeaders=function(){return this.response.headers||{}},a.prototype.getResultData=function(){return this.response.data},e.exports=a},{"./http_request":5,"./errors":3,inh:9}],9:[function(t,e,r){"use strict";var o=function(t,e){var r=function(){};r.prototype=e.prototype,t.super_=e,t.prototype=new r,t.prototype.constructor=t};e.exports=o},{}],8:[function(t,e,r){"use strict";var o=t("inh"),s=function(){Error.call(this),this.captureStackTrace()};o(s,Error),s.prototype.name="ErrorBase",s.prototype.captureStackTrace=function(){if(Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);else{var t=Error(),e=this;t.toString=function(){return""+e};var r=function(){return t.stack};Object.defineProperties?Object.defineProperties({stack:r}):this.getStackTrace=r}},s.prototype.toString=function(){var t=this.name,e=this.getMessage();return e&&(t=[t,e].join(": ")),t},s.prototype.getMessage=function(){return null},s.prototype.getStackTrace=function(){return this.stack},Object.defineProperties&&Object.defineProperties(s.prototype,{message:{get:function(){return this.getMessage()}}}),e.exports=s},{inh:10}],10:[function(t,e,r){"use strict";var o=function(t,e){var r=function(){};r.prototype=e.prototype,t.super_=e,t.prototype=new r,t.prototype.constructor=t};e.exports=o},{}]},{},[1]);
+(function(t,e,r,o){function s(o){if(!r[o]){if(!e[o]){if(t)return t(o);throw Error("Cannot find module '"+o+"'")}var n=r[o]={exports:{}};e[o][0](function(t){var r=e[o][1][t];return s(r?r:t)},n,n.exports)}return r[o].exports}for(var n=0;o.length>n;n++)s(o[n]);return s})("undefined"!=typeof require&&require,{1:[function(t,e,r){"use strict";var o=t("../../lib/client"),s="apis"in window,n=window.apis;window.apis=o,o.noConflict=function(){return s?window.apis=n:delete window.apis,o}},{"../../lib/client":2}],2:[function(t,e,r){"use strict";var o=t("./errors"),s=t("./http"),n=t("./http_request"),a=t("./jsonp_request"),i=t("./socket");e.exports={errors:o,Http:s,HttpRequest:n,JsonpRequest:a,Socket:i}},{"./errors":3,"./http":4,"./http_request":5,"./jsonp_request":6,"./socket":7}],4:[function(t,e,r){"use strict";var o=t("./http_request"),s=t("./jsonp_request"),n=function(t){this.baseUri=t};n.prototype.send=function(t,e,r,o,s,n){var a;if(null==s||null==s.crossDomain)a=this.sendHttp(t,e,r,o,s,n);else switch(s.crossDomain){case"jsonp":a=this.sendJsonp(t,e,r,o,s,n);break;default:throw Error("Unsupported crossDomain option "+s.crossDomain)}return a},n.prototype.sendHttp=function(t,e,r,s,n,a){return new o(this,t,e,r,s,n,a).send()},n.prototype.sendJsonp=function(t,e,r,o,n,a){return new s(this,t,e,r,o,n,a).send()},e.exports=n},{"./http_request":5,"./jsonp_request":6}],5:[function(t,e,r){"use strict";var o=t("./errors"),s=function(t,e,r,o,s,n,a){this.http=t,this.options=n||{},this.path=e,this.method=r,this.headers=o||{},this.data=s,this.cb=a,this.url=null,this.body=null,this.transport=null,this.isAborted=!1,this.timeout=null};s.prototype.methodHttpHeaderName="X-Method",s.prototype.authHttpHeaderName="X-Auth",s.prototype.authExpectedHttpHeaderName="X-AuthExpected",s.prototype.authRenewalHttpHeaderName="X-AuthRenewal",s.prototype.authRenewalIssuedHttpHeaderName="X-AuthRenewalIssued",s.prototype.authRenewalMaxAgeHttpHeaderName="X-AuthRenewalMaxAge",s.prototype.headersUrlKey="headers",s.prototype.bodyUrlKey="body",s.prototype.xdomainUrlKey="xdomain",s.prototype.defaultContentType="application/json",s.prototype.send=function(){return this.createTimeout(),this.url=this.createUrl(),this.body=this.createBody(),this.transport=this.createTransport(),this.createCallback(),this.sendInternal(),this},s.prototype.abort=function(){this.isAborted=!0,this.clearTimeout(),null!=this.transport&&(this.transport.onreadystatechange=null,this.transport.abort())},s.prototype.createTimeout=function(){var t=this.options.timeout;if(null!=t){var e=this;this.timeout=setTimeout(function(){e.handleTimeout()},t)}},s.prototype.handleTimeout=function(){this.abort(),this.cb(new o.TimeoutError)},s.prototype.clearTimeout=function(){null!=this.timeout&&clearTimeout(this.timeout)},s.prototype.createUrl=function(){var t=this.path;return this.http.baseUri&&(t=this.http.baseUri+this.path),t},s.prototype.createBody=function(){var t;return t=void 0===this.data?"":JSON.stringify(this.data)},s.prototype.createTransport=function(){return new XMLHttpRequest},s.prototype.createCallback=function(){var t=this;this.transport.onreadystatechange=function(){4==t.transport.readyState&&(t.transport.onreadystatechange=null,t.isNetworkError()?t.handleNetworkError():t.handleResponse())}},s.prototype.isNetworkError=function(){return!this.transport.status},s.prototype.handleNetworkError=function(){this.clearTimeout(),this.cb(new o.NetworkError)},s.prototype.sendInternal=function(){"get"==this.method?this.sendGet():this.sendPost()},s.prototype.sendGet=function(){this.transport.open("GET",this.createGetUrl()),this.setHttpHeaders(),this.transport.send()},s.prototype.createGetUrl=function(){var t=this.createGetUrlParts(),e=this.url;return t.length>0&&(e+="?"+t.join("&")),e},s.prototype.createGetUrlParts=function(t){var e=t||[];return this.body&&e.push(this.bodyUrlKey+"="+encodeURIComponent(this.body)),e},s.prototype.sendPost=function(){var t=this.transport;t.open("POST",this.url),this.setContentTypeHttpHeader(),this.setMethodHttpHeader(),this.setHttpHeaders(),t.send(this.body)},s.prototype.setHttpHeaders=function(){var t=this.createHttpHeaders(),e=this.transport;for(var r in t)e.setRequestHeader(r,t[r])},s.prototype.createHttpHeaders=function(){var t=this.headers,e=t.http||{};return delete t.http,t.auth&&(e[this.authHttpHeaderName]=t.auth),t.authExpected&&(e[this.authExpectedHttpHeaderName]=t.authExpected),e},s.prototype.setContentTypeHttpHeader=function(){var t=this.headers.http&&this.headers.http["Content-type"]||this.headers.contentType||this.defaultContentType;this.transport.setRequestHeader("Content-type",t)},s.prototype.setMethodHttpHeader=function(){"create"!=this.method&&this.transport.setRequestHeader(this.methodHttpHeaderName,this.method)},s.prototype.handleResponse=function(){this.clearTimeout();var t=this.createResult(),e=this.extractError(t);null!=e?this.cb(e):this.cb(null,t)},s.prototype.createResult=function(){var t={headers:this.getResultHeaders(),data:this.getResultData()},e=this.getResultStatus();null!=e&&(t.status=e);var r=this.getTransportForResult();return null!=r&&(t.transport=r),t},s.prototype.getTransportForResult=function(){return this.transport},s.prototype.getResultStatus=function(){return this.transport.status},s.prototype.getResultHeaders=function(){var t={},e=this.transport.getResponseHeader(this.authRenewalHttpHeaderName);if(e){var r={token:e};t.authRenewal=r;var o=this.transport.getResponseHeader(this.authRenewalIssuedHttpHeaderName);o&&(r.issued=new Date(o));var s=this.transport.getResponseHeader(this.authRenewalMaxAgeHttpHeaderName);s&&(r.maxAge=parseInt(s,10))}return t},s.prototype.getResultData=function(){var t=this.getResultBody();return t?JSON.parse(t):void 0},s.prototype.getResultBody=function(){return this.transport.responseText},s.prototype.extractError=function(t){var e=t.status,r=null;return 200!=e&&204!=e&&(r=new o.WebError(t)),r},e.exports=s},{"./errors":3}],7:[function(t,e,r){"use strict";var o=t("./errors"),s=function(t,e,r){this.basePath=t,this.socketUri=e||this.defaultSocketUri,this.protocols=r,this.onSocketCreated=null,this.onMessage=null,this.customWebSocketClass=null,this.socket=null,this.requests={},this.abortFunc=this.createAbortFunc()};s.prototype.defaultSocketUri="/socket",s.prototype.headerSeparator="\n\n",s.prototype.defaultTimeout=null,s.prototype.getWebSocketClass=function(){return this.customWebSocketClass||WebSocket},s.prototype.createAbortFunc=function(){var t=this;return function(){t.handleAbort(this)}},s.prototype.createSocket=function(){var t=this.getWebSocketClass();return new t(this.socketUri,this.protocols)},s.prototype.connect=function(t){if(null!=this.socket)switch(this.socket.readyState){case 0:t&&this.socket.addEventListener("open",function(){t()});break;case 1:t&&t();break;default:this.socket=null}if(null==this.socket){this.socket=this.createSocket(),this.onSocketCreated&&this.onSocketCreated(this.socket),t&&this.socket.addEventListener("open",function(){t()});var e=this;this.socket.addEventListener("message",function(t){e.handleMessage(t)}),this.socket.addEventListener("close",function(t){e.handleClose(t)})}},s.prototype.handleMessage=function(t){var e=this.parse(t.data),r=null!=e.headers?e.headers.requestId:null;if(null!=r){var o=this.requests[r];if(o){var s=o.cb;this.clearRequest(o,r);var n=this.extractError(e);null!=n?s(n):s(null,e)}}else null!=this.onMessage&&this.onMessage(e)},s.prototype.createRequestId=function(){for(var t=""+(new Date).getTime(),e=0,r=t;r in this.requests;)r=t+"_"+e++;return r},s.prototype.clearRequest=function(t){delete this.requests[t.id];var e=t.timeout;null!=e&&clearTimeout(e)},s.prototype.close=function(){null!=this.socket&&this.socket.close()},s.prototype.send=function(t,e,r,o,s,n){var a=this;this.connect(function(){a.sendInternal(t,e,r,o,s,n)})},s.prototype.sendInternal=function(t,e,r,o,s,n){r=r||{},r.method=e,r.path=this.getEffectivePath(t);var a;n&&(a=this.createRequest(s,n),r.requestId=a.id);var i;i=void 0===o?"":JSON.stringify(o);var p=[JSON.stringify(r),i].join(this.headerSeparator);return this.socket.send(p),a},s.prototype.getEffectivePath=function(t){var e=t;return this.basePath&&(e=this.basePath+t),e},s.prototype.createRequest=function(t,e){var r=this.createRequestId(),o={id:r,cb:e,options:t,abort:this.abortFunc};return o.timeout=this.createTimeout(o),this.requests[r]=o,o},s.prototype.createTimeout=function(t){var e=t.options,r=null,o=null!=e&&null!=e.timeout?e.timeout:this.defaultTimeout;if(null!=o){var s=this;r=setTimeout(function(){s.handleTimeout(t)},o)}return r},s.prototype.handleTimeout=function(t){var e=t.cb;this.clearRequest(t),e(new o.TimeoutError)},s.prototype.handleAbort=function(t){this.clearRequest(t)},s.prototype.handleClose=function(t){for(var e in this.requests){var r=this.requests[e],s=r.cb;this.clearRequest(r),s(new o.ConnectionCloseError(t))}},s.prototype.parse=function(t){var e=t.indexOf(this.headerSeparator),r=t.substring(0,e),o=t.substring(e+this.headerSeparator.length),s=JSON.parse(r),n={headers:s,data:this.parseBody(o)};return null!=s.status&&(n.status=s.status),n},s.prototype.parseBody=function(t){var e;return t&&(e=JSON.parse(t)),e},s.prototype.extractError=function(t){var e=t.status,r=null;return 200!=e&&204!=e&&(r=new o.WebError(t)),r},e.exports=s},{"./errors":3}],3:[function(t,e,r){"use strict";var o=t("inh"),s=t("nerr/lib/error_base"),n=function(t){s.call(this),this.response=t,this.status=t.status;var e=t.data||{};this._message=e.message,this.status=t.status,this.code=e.code};o(n,s),n.prototype.name="WebError",n.prototype.getMessage=function(){return this._message};var a=function(){s.call(this)};o(a,s),a.prototype.name="NetworkError";var i=function(){s.call(this)};o(i,s),i.prototype.name="TimeoutError";var p=function(t){s.call(this),this.closeEvent=t};o(p,s),p.prototype.name="ConnectionCloseError",p.prototype.getMessage=function(){return this.closeEvent.reason},e.exports={WebError:n,NetworkError:a,TimeoutError:i,ConnectionCloseError:p}},{"nerr/lib/error_base":8,inh:9}],6:[function(t,e,r){"use strict";var o=t("inh"),s=t("./http_request"),n=t("./errors"),a=function(t,e,r,o,n,a,i){s.call(this,t,e,r,o,n,a,i),this.callbacks=this.getCallbacks(),this.scriptEl=null,this.callbackId=null,this.response=null};o(a,s),a.callbacks=null,a.prototype.callbacksGlobalPath="apis.jsonp.callbacks",a.prototype.xdomainValue="jsonp",a.prototype.jsonpCallbackUrlKey="callback",a.prototype.abort=function(){this.isAborted=!0,this.clearTimeout()},a.prototype.getCallbacks=function(){if(null==a.callbacks){for(var t=this.callbacksGlobalPath.split("."),e=window,r=0;t.length>r;r++){var o=t[r],s=e[o]||{};e[o]=s,e=s}a.callbacks=e}return a.callbacks},a.prototype.createTransport=function(){var t=document.createElement("script");t.async=!0;var e=this;return t.onerror=function(t){e.handleScriptErrorEvent(t)},this.scriptEl=t,t},a.prototype.handleScriptErrorEvent=function(t){this.cleanup(),this.isAborted||this.cb(new n.NetworkError)},a.prototype.createCallback=function(){var t=this;this.callbackId=this.createCallbackId(),this.callbacks[this.callbackId]=function(e){t.response=e,t.handleResponse()}},a.prototype.createCallbackId=function(){for(var t="cb"+(new Date).getTime(),e=0,r=t;r in this.callbacks;)r=t+"_"+e++;return r},a.prototype.sendInternal=function(){this.scriptEl.src=this.createGetUrl();var t=document.head||document.getElementsByTagName("head")[0]||document.documentElement,e=t.firstChild;e?t.insertBefore(this.scriptEl,t.firstChild):t.appendChild(this.scriptEl)},a.prototype.createGetUrlParts=function(t){var e=t||[],r=this.headers;return"get"!=this.method&&(r=r||{},r.method=this.method),r&&e.push(this.headersUrlKey+"="+encodeURIComponent(JSON.stringify(r))),a.super_.prototype.createGetUrlParts.call(this,e),e.push(this.xdomainUrlKey+"="+this.xdomainValue),e.push(this.jsonpCallbackUrlKey+"="+encodeURIComponent(this.createCallbackName())),e},a.prototype.createCallbackName=function(){return this.callbacksGlobalPath+"."+this.callbackId},a.prototype.setHttpHeaders=function(){},a.prototype.handleResponse=function(){this.cleanup(),this.isAborted||a.super_.prototype.handleResponse.call(this)},a.prototype.cleanup=function(){this.clearTimeout(),this.removeCallback(),this.removeScripEl()},a.prototype.removeCallback=function(){delete this.callbacks[this.callbackId]},a.prototype.removeScripEl=function(){var t=this.scriptEl;null!=t&&t.parentNode&&(t.parentNode.removeChild(t),this.scriptEl=null)},a.prototype.getTransportForResult=function(){return null},a.prototype.getResultStatus=function(){var t=this.getResultHeaders();return t.status},a.prototype.getResultHeaders=function(){return this.response.headers||{}},a.prototype.getResultData=function(){return this.response.data},e.exports=a},{"./http_request":5,"./errors":3,inh:9}],9:[function(t,e,r){"use strict";var o;o="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t},e.exports=o},{}],8:[function(t,e,r){"use strict";var o=t("inh"),s=function(){Error.call(this),this.captureStackTrace()};o(s,Error),s.prototype.name="ErrorBase",s.prototype.captureStackTrace=function(){if(Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);else{var t=Error(),e=this;t.toString=function(){return""+e};var r=function(){return t.stack};Object.defineProperties?Object.defineProperties({stack:r}):this.getStackTrace=r}},s.prototype.toString=function(){var t=this.name,e=this.getMessage();return e&&(t=[t,e].join(": ")),t},s.prototype.getMessage=function(){return null},s.prototype.getStackTrace=function(){return this.stack},Object.defineProperties&&Object.defineProperties(s.prototype,{message:{get:function(){return this.getMessage()}}}),e.exports=s},{inh:10}],10:[function(t,e,r){"use strict";var o;o="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t},e.exports=o},{}]},{},[1]);
View
68 client/apis.js
@@ -820,14 +820,32 @@ module.exports = JsonpRequest;
},{"./http_request":5,"./errors":3,"inh":9}],9:[function(require,module,exports){
"use strict";
-var inherits = function(childCtor, parentCtor) {
- var TempCtor = function () {};
- TempCtor.prototype = parentCtor.prototype;
- childCtor.super_ = parentCtor;
- childCtor.prototype = new TempCtor();
- childCtor.prototype.constructor = childCtor;
-};
-
+var inherits;
+
+if (typeof Object.create === 'function') {
+ // implementation from standard node.js 'util' module
+ inherits = function(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ ctor.prototype = Object.create(superCtor.prototype, {
+ constructor: {
+ value: ctor,
+ enumerable: false,
+ writable: true,
+ configurable: true
+ }
+ });
+ };
+}
+else {
+ // old school shim for old browsers
+ inherits = function(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ var TempCtor = function () {};
+ TempCtor.prototype = superCtor.prototype;
+ ctor.prototype = new TempCtor();
+ ctor.prototype.constructor = ctor;
+ };
+}
module.exports = inherits;
@@ -899,14 +917,32 @@ module.exports = ErrorBase;
},{"inh":10}],10:[function(require,module,exports){
"use strict";
-var inherits = function(childCtor, parentCtor) {
- var TempCtor = function () {};
- TempCtor.prototype = parentCtor.prototype;
- childCtor.super_ = parentCtor;
- childCtor.prototype = new TempCtor();
- childCtor.prototype.constructor = childCtor;
-};
-
+var inherits;
+
+if (typeof Object.create === 'function') {
+ // implementation from standard node.js 'util' module
+ inherits = function(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ ctor.prototype = Object.create(superCtor.prototype, {
+ constructor: {
+ value: ctor,
+ enumerable: false,
+ writable: true,
+ configurable: true
+ }
+ });
+ };
+}
+else {
+ // old school shim for old browsers
+ inherits = function(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ var TempCtor = function () {};
+ TempCtor.prototype = superCtor.prototype;
+ ctor.prototype = new TempCtor();
+ ctor.prototype.constructor = ctor;
+ };
+}
module.exports = inherits;
View
2  client/apis.min.js
@@ -1 +1 @@
-(function(t,e,r,o){function s(o){if(!r[o]){if(!e[o]){if(t)return t(o);throw Error("Cannot find module '"+o+"'")}var n=r[o]={exports:{}};e[o][0](function(t){var r=e[o][1][t];return s(r?r:t)},n,n.exports)}return r[o].exports}for(var n=0;o.length>n;n++)s(o[n]);return s})("undefined"!=typeof require&&require,{1:[function(t,e,r){"use strict";var o=t("../../lib/client"),s=window.require;window.require=function(t){return"apis"==t?o:s(t)}},{"../../lib/client":2}],2:[function(t,e,r){"use strict";var o=t("./errors"),s=t("./http"),n=t("./http_request"),a=t("./jsonp_request"),i=t("./socket");e.exports={errors:o,Http:s,HttpRequest:n,JsonpRequest:a,Socket:i}},{"./errors":3,"./http":4,"./http_request":5,"./jsonp_request":6,"./socket":7}],4:[function(t,e,r){"use strict";var o=t("./http_request"),s=t("./jsonp_request"),n=function(t){this.baseUri=t};n.prototype.send=function(t,e,r,o,s,n){var a;if(null==s||null==s.crossDomain)a=this.sendHttp(t,e,r,o,s,n);else switch(s.crossDomain){case"jsonp":a=this.sendJsonp(t,e,r,o,s,n);break;default:throw Error("Unsupported crossDomain option "+s.crossDomain)}return a},n.prototype.sendHttp=function(t,e,r,s,n,a){return new o(this,t,e,r,s,n,a).send()},n.prototype.sendJsonp=function(t,e,r,o,n,a){return new s(this,t,e,r,o,n,a).send()},e.exports=n},{"./http_request":5,"./jsonp_request":6}],5:[function(t,e,r){"use strict";var o=t("./errors"),s=function(t,e,r,o,s,n,a){this.http=t,this.options=n||{},this.path=e,this.method=r,this.headers=o||{},this.data=s,this.cb=a,this.url=null,this.body=null,this.transport=null,this.isAborted=!1,this.timeout=null};s.prototype.methodHttpHeaderName="X-Method",s.prototype.authHttpHeaderName="X-Auth",s.prototype.authExpectedHttpHeaderName="X-AuthExpected",s.prototype.authRenewalHttpHeaderName="X-AuthRenewal",s.prototype.authRenewalIssuedHttpHeaderName="X-AuthRenewalIssued",s.prototype.authRenewalMaxAgeHttpHeaderName="X-AuthRenewalMaxAge",s.prototype.headersUrlKey="headers",s.prototype.bodyUrlKey="body",s.prototype.xdomainUrlKey="xdomain",s.prototype.defaultContentType="application/json",s.prototype.send=function(){return this.createTimeout(),this.url=this.createUrl(),this.body=this.createBody(),this.transport=this.createTransport(),this.createCallback(),this.sendInternal(),this},s.prototype.abort=function(){this.isAborted=!0,this.clearTimeout(),null!=this.transport&&(this.transport.onreadystatechange=null,this.transport.abort())},s.prototype.createTimeout=function(){var t=this.options.timeout;if(null!=t){var e=this;this.timeout=setTimeout(function(){e.handleTimeout()},t)}},s.prototype.handleTimeout=function(){this.abort(),this.cb(new o.TimeoutError)},s.prototype.clearTimeout=function(){null!=this.timeout&&clearTimeout(this.timeout)},s.prototype.createUrl=function(){var t=this.path;return this.http.baseUri&&(t=this.http.baseUri+this.path),t},s.prototype.createBody=function(){var t;return t=void 0===this.data?"":JSON.stringify(this.data)},s.prototype.createTransport=function(){return new XMLHttpRequest},s.prototype.createCallback=function(){var t=this;this.transport.onreadystatechange=function(){4==t.transport.readyState&&(t.transport.onreadystatechange=null,t.isNetworkError()?t.handleNetworkError():t.handleResponse())}},s.prototype.isNetworkError=function(){return!this.transport.status},s.prototype.handleNetworkError=function(){this.clearTimeout(),this.cb(new o.NetworkError)},s.prototype.sendInternal=function(){"get"==this.method?this.sendGet():this.sendPost()},s.prototype.sendGet=function(){this.transport.open("GET",this.createGetUrl()),this.setHttpHeaders(),this.transport.send()},s.prototype.createGetUrl=function(){var t=this.createGetUrlParts(),e=this.url;return t.length>0&&(e+="?"+t.join("&")),e},s.prototype.createGetUrlParts=function(t){var e=t||[];return this.body&&e.push(this.bodyUrlKey+"="+encodeURIComponent(this.body)),e},s.prototype.sendPost=function(){var t=this.transport;t.open("POST",this.url),this.setContentTypeHttpHeader(),this.setMethodHttpHeader(),this.setHttpHeaders(),t.send(this.body)},s.prototype.setHttpHeaders=function(){var t=this.createHttpHeaders(),e=this.transport;for(var r in t)e.setRequestHeader(r,t[r])},s.prototype.createHttpHeaders=function(){var t=this.headers,e=t.http||{};return delete t.http,t.auth&&(e[this.authHttpHeaderName]=t.auth),t.authExpected&&(e[this.authExpectedHttpHeaderName]=t.authExpected),e},s.prototype.setContentTypeHttpHeader=function(){var t=this.headers.http&&this.headers.http["Content-type"]||this.headers.contentType||this.defaultContentType;this.transport.setRequestHeader("Content-type",t)},s.prototype.setMethodHttpHeader=function(){"create"!=this.method&&this.transport.setRequestHeader(this.methodHttpHeaderName,this.method)},s.prototype.handleResponse=function(){this.clearTimeout();var t=this.createResult(),e=this.extractError(t);null!=e?this.cb(e):this.cb(null,t)},s.prototype.createResult=function(){var t={headers:this.getResultHeaders(),data:this.getResultData()},e=this.getResultStatus();null!=e&&(t.status=e);var r=this.getTransportForResult();return null!=r&&(t.transport=r),t},s.prototype.getTransportForResult=function(){return this.transport},s.prototype.getResultStatus=function(){return this.transport.status},s.prototype.getResultHeaders=function(){var t={},e=this.transport.getResponseHeader(this.authRenewalHttpHeaderName);if(e){var r={token:e};t.authRenewal=r;var o=this.transport.getResponseHeader(this.authRenewalIssuedHttpHeaderName);o&&(r.issued=new Date(o));var s=this.transport.getResponseHeader(this.authRenewalMaxAgeHttpHeaderName);s&&(r.maxAge=parseInt(s,10))}return t},s.prototype.getResultData=function(){var t=this.getResultBody();return t?JSON.parse(t):void 0},s.prototype.getResultBody=function(){return this.transport.responseText},s.prototype.extractError=function(t){var e=t.status,r=null;return 200!=e&&204!=e&&(r=new o.WebError(t)),r},e.exports=s},{"./errors":3}],7:[function(t,e,r){"use strict";var o=t("./errors"),s=function(t,e,r){this.basePath=t,this.socketUri=e||this.defaultSocketUri,this.protocols=r,this.onSocketCreated=null,this.onMessage=null,this.customWebSocketClass=null,this.socket=null,this.requests={},this.abortFunc=this.createAbortFunc()};s.prototype.defaultSocketUri="/socket",s.prototype.headerSeparator="\n\n",s.prototype.defaultTimeout=null,s.prototype.getWebSocketClass=function(){return this.customWebSocketClass||WebSocket},s.prototype.createAbortFunc=function(){var t=this;return function(){t.handleAbort(this)}},s.prototype.createSocket=function(){var t=this.getWebSocketClass();return new t(this.socketUri,this.protocols)},s.prototype.connect=function(t){if(null!=this.socket)switch(this.socket.readyState){case 0:t&&this.socket.addEventListener("open",function(){t()});break;case 1:t&&t();break;default:this.socket=null}if(null==this.socket){this.socket=this.createSocket(),this.onSocketCreated&&this.onSocketCreated(this.socket),t&&this.socket.addEventListener("open",function(){t()});var e=this;this.socket.addEventListener("message",function(t){e.handleMessage(t)}),this.socket.addEventListener("close",function(t){e.handleClose(t)})}},s.prototype.handleMessage=function(t){var e=this.parse(t.data),r=null!=e.headers?e.headers.requestId:null;if(null!=r){var o=this.requests[r];if(o){var s=o.cb;this.clearRequest(o,r);var n=this.extractError(e);null!=n?s(n):s(null,e)}}else null!=this.onMessage&&this.onMessage(e)},s.prototype.createRequestId=function(){for(var t=""+(new Date).getTime(),e=0,r=t;r in this.requests;)r=t+"_"+e++;return r},s.prototype.clearRequest=function(t){delete this.requests[t.id];var e=t.timeout;null!=e&&clearTimeout(e)},s.prototype.close=function(){null!=this.socket&&this.socket.close()},s.prototype.send=function(t,e,r,o,s,n){var a=this;this.connect(function(){a.sendInternal(t,e,r,o,s,n)})},s.prototype.sendInternal=function(t,e,r,o,s,n){r=r||{},r.method=e,r.path=this.getEffectivePath(t);var a;n&&(a=this.createRequest(s,n),r.requestId=a.id);var i;i=void 0===o?"":JSON.stringify(o);var p=[JSON.stringify(r),i].join(this.headerSeparator);return this.socket.send(p),a},s.prototype.getEffectivePath=function(t){var e=t;return this.basePath&&(e=this.basePath+t),e},s.prototype.createRequest=function(t,e){var r=this.createRequestId(),o={id:r,cb:e,options:t,abort:this.abortFunc};return o.timeout=this.createTimeout(o),this.requests[r]=o,o},s.prototype.createTimeout=function(t){var e=t.options,r=null,o=null!=e&&null!=e.timeout?e.timeout:this.defaultTimeout;if(null!=o){var s=this;r=setTimeout(function(){s.handleTimeout(t)},o)}return r},s.prototype.handleTimeout=function(t){var e=t.cb;this.clearRequest(t),e(new o.TimeoutError)},s.prototype.handleAbort=function(t){this.clearRequest(t)},s.prototype.handleClose=function(t){for(var e in this.requests){var r=this.requests[e],s=r.cb;this.clearRequest(r),s(new o.ConnectionCloseError(t))}},s.prototype.parse=function(t){var e=t.indexOf(this.headerSeparator),r=t.substring(0,e),o=t.substring(e+this.headerSeparator.length),s=JSON.parse(r),n={headers:s,data:this.parseBody(o)};return null!=s.status&&(n.status=s.status),n},s.prototype.parseBody=function(t){var e;return t&&(e=JSON.parse(t)),e},s.prototype.extractError=function(t){var e=t.status,r=null;return 200!=e&&204!=e&&(r=new o.WebError(t)),r},e.exports=s},{"./errors":3}],3:[function(t,e,r){"use strict";var o=t("inh"),s=t("nerr/lib/error_base"),n=function(t){s.call(this),this.response=t,this.status=t.status;var e=t.data||{};this._message=e.message,this.status=t.status,this.code=e.code};o(n,s),n.prototype.name="WebError",n.prototype.getMessage=function(){return this._message};var a=function(){s.call(this)};o(a,s),a.prototype.name="NetworkError";var i=function(){s.call(this)};o(i,s),i.prototype.name="TimeoutError";var p=function(t){s.call(this),this.closeEvent=t};o(p,s),p.prototype.name="ConnectionCloseError",p.prototype.getMessage=function(){return this.closeEvent.reason},e.exports={WebError:n,NetworkError:a,TimeoutError:i,ConnectionCloseError:p}},{"nerr/lib/error_base":8,inh:9}],6:[function(t,e,r){"use strict";var o=t("inh"),s=t("./http_request"),n=t("./errors"),a=function(t,e,r,o,n,a,i){s.call(this,t,e,r,o,n,a,i),this.callbacks=this.getCallbacks(),this.scriptEl=null,this.callbackId=null,this.response=null};o(a,s),a.callbacks=null,a.prototype.callbacksGlobalPath="apis.jsonp.callbacks",a.prototype.xdomainValue="jsonp",a.prototype.jsonpCallbackUrlKey="callback",a.prototype.abort=function(){this.isAborted=!0,this.clearTimeout()},a.prototype.getCallbacks=function(){if(null==a.callbacks){for(var t=this.callbacksGlobalPath.split("."),e=window,r=0;t.length>r;r++){var o=t[r],s=e[o]||{};e[o]=s,e=s}a.callbacks=e}return a.callbacks},a.prototype.createTransport=function(){var t=document.createElement("script");t.async=!0;var e=this;return t.onerror=function(t){e.handleScriptErrorEvent(t)},this.scriptEl=t,t},a.prototype.handleScriptErrorEvent=function(t){this.cleanup(),this.isAborted||this.cb(new n.NetworkError)},a.prototype.createCallback=function(){var t=this;this.callbackId=this.createCallbackId(),this.callbacks[this.callbackId]=function(e){t.response=e,t.handleResponse()}},a.prototype.createCallbackId=function(){for(var t="cb"+(new Date).getTime(),e=0,r=t;r in this.callbacks;)r=t+"_"+e++;return r},a.prototype.sendInternal=function(){this.scriptEl.src=this.createGetUrl();var t=document.head||document.getElementsByTagName("head")[0]||document.documentElement,e=t.firstChild;e?t.insertBefore(this.scriptEl,t.firstChild):t.appendChild(this.scriptEl)},a.prototype.createGetUrlParts=function(t){var e=t||[],r=this.headers;return"get"!=this.method&&(r=r||{},r.method=this.method),r&&e.push(this.headersUrlKey+"="+encodeURIComponent(JSON.stringify(r))),a.super_.prototype.createGetUrlParts.call(this,e),e.push(this.xdomainUrlKey+"="+this.xdomainValue),e.push(this.jsonpCallbackUrlKey+"="+encodeURIComponent(this.createCallbackName())),e},a.prototype.createCallbackName=function(){return this.callbacksGlobalPath+"."+this.callbackId},a.prototype.setHttpHeaders=function(){},a.prototype.handleResponse=function(){this.cleanup(),this.isAborted||a.super_.prototype.handleResponse.call(this)},a.prototype.cleanup=function(){this.clearTimeout(),this.removeCallback(),this.removeScripEl()},a.prototype.removeCallback=function(){delete this.callbacks[this.callbackId]},a.prototype.removeScripEl=function(){var t=this.scriptEl;null!=t&&t.parentNode&&(t.parentNode.removeChild(t),this.scriptEl=null)},a.prototype.getTransportForResult=function(){return null},a.prototype.getResultStatus=function(){var t=this.getResultHeaders();return t.status},a.prototype.getResultHeaders=function(){return this.response.headers||{}},a.prototype.getResultData=function(){return this.response.data},e.exports=a},{"./http_request":5,"./errors":3,inh:9}],9:[function(t,e,r){"use strict";var o=function(t,e){var r=function(){};r.prototype=e.prototype,t.super_=e,t.prototype=new r,t.prototype.constructor=t};e.exports=o},{}],8:[function(t,e,r){"use strict";var o=t("inh"),s=function(){Error.call(this),this.captureStackTrace()};o(s,Error),s.prototype.name="ErrorBase",s.prototype.captureStackTrace=function(){if(Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);else{var t=Error(),e=this;t.toString=function(){return""+e};var r=function(){return t.stack};Object.defineProperties?Object.defineProperties({stack:r}):this.getStackTrace=r}},s.prototype.toString=function(){var t=this.name,e=this.getMessage();return e&&(t=[t,e].join(": ")),t},s.prototype.getMessage=function(){return null},s.prototype.getStackTrace=function(){return this.stack},Object.defineProperties&&Object.defineProperties(s.prototype,{message:{get:function(){return this.getMessage()}}}),e.exports=s},{inh:10}],10:[function(t,e,r){"use strict";var o=function(t,e){var r=function(){};r.prototype=e.prototype,t.super_=e,t.prototype=new r,t.prototype.constructor=t};e.exports=o},{}]},{},[1]);
+(function(t,e,r,o){function s(o){if(!r[o]){if(!e[o]){if(t)return t(o);throw Error("Cannot find module '"+o+"'")}var n=r[o]={exports:{}};e[o][0](function(t){var r=e[o][1][t];return s(r?r:t)},n,n.exports)}return r[o].exports}for(var n=0;o.length>n;n++)s(o[n]);return s})("undefined"!=typeof require&&require,{1:[function(t,e,r){"use strict";var o=t("../../lib/client"),s=window.require;window.require=function(t){return"apis"==t?o:s(t)}},{"../../lib/client":2}],2:[function(t,e,r){"use strict";var o=t("./errors"),s=t("./http"),n=t("./http_request"),a=t("./jsonp_request"),i=t("./socket");e.exports={errors:o,Http:s,HttpRequest:n,JsonpRequest:a,Socket:i}},{"./errors":3,"./http":4,"./http_request":5,"./jsonp_request":6,"./socket":7}],4:[function(t,e,r){"use strict";var o=t("./http_request"),s=t("./jsonp_request"),n=function(t){this.baseUri=t};n.prototype.send=function(t,e,r,o,s,n){var a;if(null==s||null==s.crossDomain)a=this.sendHttp(t,e,r,o,s,n);else switch(s.crossDomain){case"jsonp":a=this.sendJsonp(t,e,r,o,s,n);break;default:throw Error("Unsupported crossDomain option "+s.crossDomain)}return a},n.prototype.sendHttp=function(t,e,r,s,n,a){return new o(this,t,e,r,s,n,a).send()},n.prototype.sendJsonp=function(t,e,r,o,n,a){return new s(this,t,e,r,o,n,a).send()},e.exports=n},{"./http_request":5,"./jsonp_request":6}],5:[function(t,e,r){"use strict";var o=t("./errors"),s=function(t,e,r,o,s,n,a){this.http=t,this.options=n||{},this.path=e,this.method=r,this.headers=o||{},this.data=s,this.cb=a,this.url=null,this.body=null,this.transport=null,this.isAborted=!1,this.timeout=null};s.prototype.methodHttpHeaderName="X-Method",s.prototype.authHttpHeaderName="X-Auth",s.prototype.authExpectedHttpHeaderName="X-AuthExpected",s.prototype.authRenewalHttpHeaderName="X-AuthRenewal",s.prototype.authRenewalIssuedHttpHeaderName="X-AuthRenewalIssued",s.prototype.authRenewalMaxAgeHttpHeaderName="X-AuthRenewalMaxAge",s.prototype.headersUrlKey="headers",s.prototype.bodyUrlKey="body",s.prototype.xdomainUrlKey="xdomain",s.prototype.defaultContentType="application/json",s.prototype.send=function(){return this.createTimeout(),this.url=this.createUrl(),this.body=this.createBody(),this.transport=this.createTransport(),this.createCallback(),this.sendInternal(),this},s.prototype.abort=function(){this.isAborted=!0,this.clearTimeout(),null!=this.transport&&(this.transport.onreadystatechange=null,this.transport.abort())},s.prototype.createTimeout=function(){var t=this.options.timeout;if(null!=t){var e=this;this.timeout=setTimeout(function(){e.handleTimeout()},t)}},s.prototype.handleTimeout=function(){this.abort(),this.cb(new o.TimeoutError)},s.prototype.clearTimeout=function(){null!=this.timeout&&clearTimeout(this.timeout)},s.prototype.createUrl=function(){var t=this.path;return this.http.baseUri&&(t=this.http.baseUri+this.path),t},s.prototype.createBody=function(){var t;return t=void 0===this.data?"":JSON.stringify(this.data)},s.prototype.createTransport=function(){return new XMLHttpRequest},s.prototype.createCallback=function(){var t=this;this.transport.onreadystatechange=function(){4==t.transport.readyState&&(t.transport.onreadystatechange=null,t.isNetworkError()?t.handleNetworkError():t.handleResponse())}},s.prototype.isNetworkError=function(){return!this.transport.status},s.prototype.handleNetworkError=function(){this.clearTimeout(),this.cb(new o.NetworkError)},s.prototype.sendInternal=function(){"get"==this.method?this.sendGet():this.sendPost()},s.prototype.sendGet=function(){this.transport.open("GET",this.createGetUrl()),this.setHttpHeaders(),this.transport.send()},s.prototype.createGetUrl=function(){var t=this.createGetUrlParts(),e=this.url;return t.length>0&&(e+="?"+t.join("&")),e},s.prototype.createGetUrlParts=function(t){var e=t||[];return this.body&&e.push(this.bodyUrlKey+"="+encodeURIComponent(this.body)),e},s.prototype.sendPost=function(){var t=this.transport;t.open("POST",this.url),this.setContentTypeHttpHeader(),this.setMethodHttpHeader(),this.setHttpHeaders(),t.send(this.body)},s.prototype.setHttpHeaders=function(){var t=this.createHttpHeaders(),e=this.transport;for(var r in t)e.setRequestHeader(r,t[r])},s.prototype.createHttpHeaders=function(){var t=this.headers,e=t.http||{};return delete t.http,t.auth&&(e[this.authHttpHeaderName]=t.auth),t.authExpected&&(e[this.authExpectedHttpHeaderName]=t.authExpected),e},s.prototype.setContentTypeHttpHeader=function(){var t=this.headers.http&&this.headers.http["Content-type"]||this.headers.contentType||this.defaultContentType;this.transport.setRequestHeader("Content-type",t)},s.prototype.setMethodHttpHeader=function(){"create"!=this.method&&this.transport.setRequestHeader(this.methodHttpHeaderName,this.method)},s.prototype.handleResponse=function(){this.clearTimeout();var t=this.createResult(),e=this.extractError(t);null!=e?this.cb(e):this.cb(null,t)},s.prototype.createResult=function(){var t={headers:this.getResultHeaders(),data:this.getResultData()},e=this.getResultStatus();null!=e&&(t.status=e);var r=this.getTransportForResult();return null!=r&&(t.transport=r),t},s.prototype.getTransportForResult=function(){return this.transport},s.prototype.getResultStatus=function(){return this.transport.status},s.prototype.getResultHeaders=function(){var t={},e=this.transport.getResponseHeader(this.authRenewalHttpHeaderName);if(e){var r={token:e};t.authRenewal=r;var o=this.transport.getResponseHeader(this.authRenewalIssuedHttpHeaderName);o&&(r.issued=new Date(o));var s=this.transport.getResponseHeader(this.authRenewalMaxAgeHttpHeaderName);s&&(r.maxAge=parseInt(s,10))}return t},s.prototype.getResultData=function(){var t=this.getResultBody();return t?JSON.parse(t):void 0},s.prototype.getResultBody=function(){return this.transport.responseText},s.prototype.extractError=function(t){var e=t.status,r=null;return 200!=e&&204!=e&&(r=new o.WebError(t)),r},e.exports=s},{"./errors":3}],7:[function(t,e,r){"use strict";var o=t("./errors"),s=function(t,e,r){this.basePath=t,this.socketUri=e||this.defaultSocketUri,this.protocols=r,this.onSocketCreated=null,this.onMessage=null,this.customWebSocketClass=null,this.socket=null,this.requests={},this.abortFunc=this.createAbortFunc()};s.prototype.defaultSocketUri="/socket",s.prototype.headerSeparator="\n\n",s.prototype.defaultTimeout=null,s.prototype.getWebSocketClass=function(){return this.customWebSocketClass||WebSocket},s.prototype.createAbortFunc=function(){var t=this;return function(){t.handleAbort(this)}},s.prototype.createSocket=function(){var t=this.getWebSocketClass();return new t(this.socketUri,this.protocols)},s.prototype.connect=function(t){if(null!=this.socket)switch(this.socket.readyState){case 0:t&&this.socket.addEventListener("open",function(){t()});break;case 1:t&&t();break;default:this.socket=null}if(null==this.socket){this.socket=this.createSocket(),this.onSocketCreated&&this.onSocketCreated(this.socket),t&&this.socket.addEventListener("open",function(){t()});var e=this;this.socket.addEventListener("message",function(t){e.handleMessage(t)}),this.socket.addEventListener("close",function(t){e.handleClose(t)})}},s.prototype.handleMessage=function(t){var e=this.parse(t.data),r=null!=e.headers?e.headers.requestId:null;if(null!=r){var o=this.requests[r];if(o){var s=o.cb;this.clearRequest(o,r);var n=this.extractError(e);null!=n?s(n):s(null,e)}}else null!=this.onMessage&&this.onMessage(e)},s.prototype.createRequestId=function(){for(var t=""+(new Date).getTime(),e=0,r=t;r in this.requests;)r=t+"_"+e++;return r},s.prototype.clearRequest=function(t){delete this.requests[t.id];var e=t.timeout;null!=e&&clearTimeout(e)},s.prototype.close=function(){null!=this.socket&&this.socket.close()},s.prototype.send=function(t,e,r,o,s,n){var a=this;this.connect(function(){a.sendInternal(t,e,r,o,s,n)})},s.prototype.sendInternal=function(t,e,r,o,s,n){r=r||{},r.method=e,r.path=this.getEffectivePath(t);var a;n&&(a=this.createRequest(s,n),r.requestId=a.id);var i;i=void 0===o?"":JSON.stringify(o);var p=[JSON.stringify(r),i].join(this.headerSeparator);return this.socket.send(p),a},s.prototype.getEffectivePath=function(t){var e=t;return this.basePath&&(e=this.basePath+t),e},s.prototype.createRequest=function(t,e){var r=this.createRequestId(),o={id:r,cb:e,options:t,abort:this.abortFunc};return o.timeout=this.createTimeout(o),this.requests[r]=o,o},s.prototype.createTimeout=function(t){var e=t.options,r=null,o=null!=e&&null!=e.timeout?e.timeout:this.defaultTimeout;if(null!=o){var s=this;r=setTimeout(function(){s.handleTimeout(t)},o)}return r},s.prototype.handleTimeout=function(t){var e=t.cb;this.clearRequest(t),e(new o.TimeoutError)},s.prototype.handleAbort=function(t){this.clearRequest(t)},s.prototype.handleClose=function(t){for(var e in this.requests){var r=this.requests[e],s=r.cb;this.clearRequest(r),s(new o.ConnectionCloseError(t))}},s.prototype.parse=function(t){var e=t.indexOf(this.headerSeparator),r=t.substring(0,e),o=t.substring(e+this.headerSeparator.length),s=JSON.parse(r),n={headers:s,data:this.parseBody(o)};return null!=s.status&&(n.status=s.status),n},s.prototype.parseBody=function(t){var e;return t&&(e=JSON.parse(t)),e},s.prototype.extractError=function(t){var e=t.status,r=null;return 200!=e&&204!=e&&(r=new o.WebError(t)),r},e.exports=s},{"./errors":3}],3:[function(t,e,r){"use strict";var o=t("inh"),s=t("nerr/lib/error_base"),n=function(t){s.call(this),this.response=t,this.status=t.status;var e=t.data||{};this._message=e.message,this.status=t.status,this.code=e.code};o(n,s),n.prototype.name="WebError",n.prototype.getMessage=function(){return this._message};var a=function(){s.call(this)};o(a,s),a.prototype.name="NetworkError";var i=function(){s.call(this)};o(i,s),i.prototype.name="TimeoutError";var p=function(t){s.call(this),this.closeEvent=t};o(p,s),p.prototype.name="ConnectionCloseError",p.prototype.getMessage=function(){return this.closeEvent.reason},e.exports={WebError:n,NetworkError:a,TimeoutError:i,ConnectionCloseError:p}},{"nerr/lib/error_base":8,inh:9}],6:[function(t,e,r){"use strict";var o=t("inh"),s=t("./http_request"),n=t("./errors"),a=function(t,e,r,o,n,a,i){s.call(this,t,e,r,o,n,a,i),this.callbacks=this.getCallbacks(),this.scriptEl=null,this.callbackId=null,this.response=null};o(a,s),a.callbacks=null,a.prototype.callbacksGlobalPath="apis.jsonp.callbacks",a.prototype.xdomainValue="jsonp",a.prototype.jsonpCallbackUrlKey="callback",a.prototype.abort=function(){this.isAborted=!0,this.clearTimeout()},a.prototype.getCallbacks=function(){if(null==a.callbacks){for(var t=this.callbacksGlobalPath.split("."),e=window,r=0;t.length>r;r++){var o=t[r],s=e[o]||{};e[o]=s,e=s}a.callbacks=e}return a.callbacks},a.prototype.createTransport=function(){var t=document.createElement("script");t.async=!0;var e=this;return t.onerror=function(t){e.handleScriptErrorEvent(t)},this.scriptEl=t,t},a.prototype.handleScriptErrorEvent=function(t){this.cleanup(),this.isAborted||this.cb(new n.NetworkError)},a.prototype.createCallback=function(){var t=this;this.callbackId=this.createCallbackId(),this.callbacks[this.callbackId]=function(e){t.response=e,t.handleResponse()}},a.prototype.createCallbackId=function(){for(var t="cb"+(new Date).getTime(),e=0,r=t;r in this.callbacks;)r=t+"_"+e++;return r},a.prototype.sendInternal=function(){this.scriptEl.src=this.createGetUrl();var t=document.head||document.getElementsByTagName("head")[0]||document.documentElement,e=t.firstChild;e?t.insertBefore(this.scriptEl,t.firstChild):t.appendChild(this.scriptEl)},a.prototype.createGetUrlParts=function(t){var e=t||[],r=this.headers;return"get"!=this.method&&(r=r||{},r.method=this.method),r&&e.push(this.headersUrlKey+"="+encodeURIComponent(JSON.stringify(r))),a.super_.prototype.createGetUrlParts.call(this,e),e.push(this.xdomainUrlKey+"="+this.xdomainValue),e.push(this.jsonpCallbackUrlKey+"="+encodeURIComponent(this.createCallbackName())),e},a.prototype.createCallbackName=function(){return this.callbacksGlobalPath+"."+this.callbackId},a.prototype.setHttpHeaders=function(){},a.prototype.handleResponse=function(){this.cleanup(),this.isAborted||a.super_.prototype.handleResponse.call(this)},a.prototype.cleanup=function(){this.clearTimeout(),this.removeCallback(),this.removeScripEl()},a.prototype.removeCallback=function(){delete this.callbacks[this.callbackId]},a.prototype.removeScripEl=function(){var t=this.scriptEl;null!=t&&t.parentNode&&(t.parentNode.removeChild(t),this.scriptEl=null)},a.prototype.getTransportForResult=function(){return null},a.prototype.getResultStatus=function(){var t=this.getResultHeaders();return t.status},a.prototype.getResultHeaders=function(){return this.response.headers||{}},a.prototype.getResultData=function(){return this.response.data},e.exports=a},{"./http_request":5,"./errors":3,inh:9}],9:[function(t,e,r){"use strict";var o;o="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t},e.exports=o},{}],8:[function(t,e,r){"use strict";var o=t("inh"),s=function(){Error.call(this),this.captureStackTrace()};o(s,Error),s.prototype.name="ErrorBase",s.prototype.captureStackTrace=function(){if(Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);else{var t=Error(),e=this;t.toString=function(){return""+e};var r=function(){return t.stack};Object.defineProperties?Object.defineProperties({stack:r}):this.getStackTrace=r}},s.prototype.toString=function(){var t=this.name,e=this.getMessage();return e&&(t=[t,e].join(": ")),t},s.prototype.getMessage=function(){return null},s.prototype.getStackTrace=function(){return this.stack},Object.defineProperties&&Object.defineProperties(s.prototype,{message:{get:function(){return this.getMessage()}}}),e.exports=s},{inh:10}],10:[function(t,e,r){"use strict";var o;o="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t},e.exports=o},{}]},{},[1]);
View
68 public/static/test_page/js/test_page.js
@@ -1163,14 +1163,32 @@ module.exports = JsonpRequest;
},{"./http_request":6,"./errors":4,"inh":10}],10:[function(require,module,exports){
"use strict";
-var inherits = function(childCtor, parentCtor) {
- var TempCtor = function () {};
- TempCtor.prototype = parentCtor.prototype;
- childCtor.super_ = parentCtor;
- childCtor.prototype = new TempCtor();
- childCtor.prototype.constructor = childCtor;
-};
-
+var inherits;
+
+if (typeof Object.create === 'function') {
+ // implementation from standard node.js 'util' module
+ inherits = function(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ ctor.prototype = Object.create(superCtor.prototype, {
+ constructor: {
+ value: ctor,
+ enumerable: false,
+ writable: true,
+ configurable: true
+ }
+ });
+ };
+}
+else {
+ // old school shim for old browsers
+ inherits = function(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ var TempCtor = function () {};
+ TempCtor.prototype = superCtor.prototype;
+ ctor.prototype = new TempCtor();
+ ctor.prototype.constructor = ctor;
+ };
+}
module.exports = inherits;
@@ -1242,14 +1260,32 @@ module.exports = ErrorBase;
},{"inh":11}],11:[function(require,module,exports){
"use strict";
-var inherits = function(childCtor, parentCtor) {
- var TempCtor = function () {};
- TempCtor.prototype = parentCtor.prototype;
- childCtor.super_ = parentCtor;
- childCtor.prototype = new TempCtor();
- childCtor.prototype.constructor = childCtor;
-};
-
+var inherits;
+
+if (typeof Object.create === 'function') {
+ // implementation from standard node.js 'util' module
+ inherits = function(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ ctor.prototype = Object.create(superCtor.prototype, {
+ constructor: {
+ value: ctor,
+ enumerable: false,
+ writable: true,
+ configurable: true
+ }
+ });
+ };
+}
+else {
+ // old school shim for old browsers
+ inherits = function(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ var TempCtor = function () {};
+ TempCtor.prototype = superCtor.prototype;
+ ctor.prototype = new TempCtor();
+ ctor.prototype.constructor = ctor;
+ };
+}
module.exports = inherits;
Please sign in to comment.
Something went wrong with that request. Please try again.