Browse files

0.3.1

* renamed arguments to args in parseArgs
* added dist builds with --standalone build and minified version with Google Closure compiler
* added client and server api files
* registred and added support for bower
  • Loading branch information...
1 parent 4613d07 commit b51f6ae6e217c933281f517583e4a8f65a024a3a @ramitos committed Dec 12, 2012
Showing with 3,658 additions and 5 deletions.
  1. +3 −0 .bowerrc
  2. +2 −1 .npmignore
  3. +5 −0 bower.json
  4. +1 −1 component.json
  5. +3,540 −0 dist/restio.js
  6. +69 −0 dist/restio.min.js
  7. +35 −0 docs/client.md
  8. 0 docs/server.md
  9. +1 −1 package.json
  10. +2 −2 src/setup.js
View
3 .bowerrc
@@ -0,0 +1,3 @@
+{
+ "json": "bower.json"
+}
View
3 .npmignore
@@ -3,4 +3,5 @@ node_modules
components
build
component.json
-src/client
+src/client
+dist
View
5 bower.json
@@ -0,0 +1,5 @@
+{
+ "name": "restio",
+ "version": "0.3.1",
+ "main": "./dist/restio.js"
+}
View
2 component.json
@@ -1,7 +1,7 @@
{
"name": "restio",
"license": "MIT",
- "version": "0.3.0",
+ "version": "0.3.1",
"twitter": "@ramitos",
"description": "REST-like syntax for WebSockets",
"main": "src/client/restio.js",
View
3,540 dist/restio.js
3,540 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
69 dist/restio.min.js
@@ -0,0 +1,69 @@
+;(function(){function d(f,c,a){var b=d.resolve(f),g=d.modules[b];if(null==b)throw Error('failed to require "'+(a||f)+'" from "'+(c||"root")+'"');g.exports||(g.exports={},g.client=g.component=!0,g.call(this,g,g.exports,d.relative(b)));return g.exports}d.modules={};d.aliases={};d.resolve=function(f){var c=f+".js",a=f+".json",b=f+"/index.js",g=f+"/index.json";return d.modules[c]&&c||d.modules[a]&&a||d.modules[b]&&b||d.modules[g]&&g||d.modules[f]&&f||d.aliases[b]};d.normalize=function(f,c){var a=[];if("."!=
+c.charAt(0))return c;for(var f=f.split("/"),c=c.split("/"),b=0;b<c.length;++b)".."==c[b]?f.pop():"."!=c[b]&&""!=c[b]&&a.push(c[b]);return f.concat(a).join("/")};d.register=function(f,c){d.modules[f]=c};d.alias=function(f,c){if(!d.modules[f])throw Error('failed to alias "'+f+'", it does not exist');d.aliases[c]=f};d.relative=function(f){function c(b){var a=b,b=c.resolve(b);return d(b,f,a)}var a=d.normalize(f,"..");c.resolve=function(b){if("."!=b.charAt(0)){var c=f.split("/"),e;a:{for(e=c.length;e--;)if("deps"===
+c[e])break a;e=-1}(e+=1)||(e=0);return b=c.slice(0,e+1).join("/")+"/deps/"+b}return d.normalize(a,b)};c.exists=function(b){return!!d.modules[c.resolve(b)]};return c};d.register("component-emitter/index.js",function(f){function c(a){if(a){for(var b in c.prototype)a[b]=c.prototype[b];return a}}f.exports=c;c.prototype.on=function(a,b){this._callbacks=this._callbacks||{};(this._callbacks[a]=this._callbacks[a]||[]).push(b);return this};c.prototype.once=function(a,b){function c(){e.off(a,c);b.apply(this,
+arguments)}var e=this;this._callbacks=this._callbacks||{};b._off=c;this.on(a,c);return this};c.prototype.off=function(a,b){this._callbacks=this._callbacks||{};var c=this._callbacks[a];if(!c)return this;if(1==arguments.length)return delete this._callbacks[a],this;var e=c.indexOf(b._off||b);~e&&c.splice(e,1);return this};c.prototype.emit=function(a){this._callbacks=this._callbacks||{};var b=[].slice.call(arguments,1),c=this._callbacks[a];if(c)for(var c=c.slice(0),e=0,h=c.length;e<h;++e)c[e].apply(this,
+b);return this};c.prototype.listeners=function(a){this._callbacks=this._callbacks||{};return this._callbacks[a]||[]};c.prototype.hasListeners=function(a){return!!this.listeners(a).length}});d.register("visionmedia-debug/index.js",function(f,c,a){f.exports="undefined"==typeof window?a("./lib/debug"):a("./debug")});d.register("visionmedia-debug/debug.js",function(f){function c(a){return!c.enabled(a)?function(){}:function(b){var g=new Date,e=g-(c[a]||g);c[a]=g;b=a+" "+b+" +"+c.humanize(e);window.console&&
+console.log&&Function.prototype.apply.call(console.log,console,arguments)}}f.exports=c;c.names=[];c.skips=[];c.enable=function(a){localStorage.debug=a;for(var b=(a||"").split(/[\s,]+/),g=b.length,e=0;e<g;e++)a=b[e].replace("*",".*?"),"-"===a[0]?c.skips.push(RegExp("^"+a.substr(1)+"$")):c.names.push(RegExp("^"+a+"$"))};c.disable=function(){c.enable("")};c.humanize=function(a){return 36E5<=a?(a/36E5).toFixed(1)+"h":6E4<=a?(a/6E4).toFixed(1)+"m":1E3<=a?(a/1E3|0)+"s":a+"ms"};c.enabled=function(a){for(var b=
+0,g=c.skips.length;b<g;b++)if(c.skips[b].test(a))return!1;b=0;for(g=c.names.length;b<g;b++)if(c.names[b].test(a))return!0;return!1};window.localStorage&&c.enable(localStorage.debug)});d.register("LearnBoost-engine.io-client/lib/index.js",function(f,c,a){f.exports=a("./socket")});d.register("LearnBoost-engine.io-client/lib/parser.js",function(f,c,a){var f=a("./util"),b=c.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},g=f.keys(b),e={type:"error",data:"parser error"};c.encodePacket=
+function(a){var c=b[a.type];void 0!==a.data&&(c+=String(a.data));return""+c};c.decodePacket=function(b){var a=b.charAt(0);return Number(a)!=a||!g[a]?e:1<b.length?{type:g[a],data:b.substring(1)}:{type:g[a]}};c.encodePayload=function(b){if(!b.length)return"0:";for(var a="",i,k=0,j=b.length;k<j;k++)i=c.encodePacket(b[k]),a+=i.length+":"+i;return a};c.decodePayload=function(b){if(""==b)return[e];for(var a=[],i="",k,j,m=0,g=b.length;m<g;m++)if(j=b.charAt(m),":"!=j)i+=j;else{if(""==i||i!=(k=Number(i)))return[e];
+j=b.substr(m+1,k);if(i!=j.length)return[e];if(j.length){i=c.decodePacket(j);if(e.type==i.type&&e.data==i.data)return[e];a.push(i)}m+=k;i=""}return""!=i?[e]:a}});d.register("LearnBoost-engine.io-client/lib/socket.js",function(f,c,a){function b(a,c){if(!(this instanceof b))return new b(a);if("string"==typeof a){var j=g.parseUri(a),a=c||{};a.host=j.host;a.secure="https"==j.protocol||"wss"==j.protocol;a.port=j.port}a=a||{};this.secure=null!=a.secure?a.secure:d.location&&"https:"==location.protocol;this.host=
+a.host||a.hostname||(d.location?location.hostname:"localhost");this.port=a.port||(d.location&&location.port?location.port:this.secure?443:80);this.query=a.query||{};this.query.uid=String(Math.random()).substr(5)+String(Math.random()).substr(5);this.upgrade=!1!==a.upgrade;this.resource=a.resource||"default";this.path=(a.path||"/engine.io").replace(/\/$/,"");this.path+="/"+this.resource+"/";this.forceJSONP=!!a.forceJSONP;this.timestampParam=a.timestampParam||"t";this.timestampRequests=!!a.timestampRequests;
+this.flashPath=a.flashPath||"";this.transports=a.transports||["polling","websocket","flashsocket"];this.readyState="";this.writeBuffer=[];this.policyPort=a.policyPort||843;this.open();b.sockets.push(this);b.sockets.evs.emit("add",this)}var g=a("./util"),e=a("./transports"),c=a("./emitter"),h=a("debug")("engine-client:socket");f.exports=b;var d="undefined"!=typeof window?window:d;c(b.prototype);b.protocol=1;b.sockets=[];b.sockets.evs=new c;b.Socket=b;b.Transport=a("./transport");b.Emitter=a("./emitter");
+b.transports=a("./transports");b.util=a("./util");b.parser=a("./parser");b.prototype.createTransport=function(a){h('creating transport "%s"',a);var b=this.query,c={},m;for(m in b)b.hasOwnProperty(m)&&(c[m]=b[m]);c.transport=a;this.id&&(c.sid=this.id);return new e[a]({host:this.host,port:this.port,secure:this.secure,path:this.path,query:c,forceJSONP:this.forceJSONP,timestampRequests:this.timestampRequests,timestampParam:this.timestampParam,flashPath:this.flashPath,policyPort:this.policyPort})};b.prototype.open=
+function(){this.readyState="opening";var a=this.createTransport(this.transports[0]);a.open();this.setTransport(a)};b.prototype.setTransport=function(a){var b=this;this.transport&&(h("clearing existing transport"),this.transport.removeAllListeners());this.transport=a;a.on("drain",function(){b.flush()}).on("packet",function(a){b.onPacket(a)}).on("error",function(a){b.onError(a)}).on("close",function(){b.onClose("transport close")})};b.prototype.probe=function(a){function b(k){if(!e){e=!0;var f=Error("probe error: "+
+k);f.transport=c.name;c.close();c=null;h('probe transport "%s" failed because of error: %s',a,k);g.emit("error",f)}}h('probing transport "%s"',a);var c=this.createTransport(a,{probe:1}),e=!1,g=this;c.once("open",function(){e||(h('probe transport "%s" opened',a),c.send([{type:"ping",data:"probe"}]),c.once("packet",function(f){e||("pong"==f.type&&"probe"==f.data?(h('probe transport "%s" pong',a),g.upgrading=!0,g.emit("upgrading",c),h('pausing current transport "%s"',g.transport.name),g.transport.pause(function(){if(!e&&
+!("closed"==g.readyState||"closing"==g.readyState))h("changing transport and sending upgrade packet"),c.removeListener("error",b),g.emit("upgrade",c),g.setTransport(c),c.send([{type:"upgrade"}]),c=null,g.upgrading=!1,g.flush()})):(h('probe transport "%s" failed',a),f=Error("probe error"),f.transport=c.name,g.emit("error",f)))}))});c.once("error",b);c.open();this.once("close",function(){c&&(h("socket closed prematurely - aborting probe"),e=!0,c.close(),c=null)});this.once("upgrading",function(a){c&&
+a.name!=c.name&&(h('"%s" works - aborting "%s"',a.name,c.name),c.close(),c=null)})};b.prototype.onOpen=function(){h("socket open");this.readyState="open";this.emit("open");this.onopen&&this.onopen.call(this);this.flush();if("open"==this.readyState&&this.upgrade&&this.transport.pause){h("starting upgrade probes");for(var a=0,b=this.upgrades.length;a<b;a++)this.probe(this.upgrades[a])}};b.prototype.onPacket=function(a){if("opening"==this.readyState||"open"==this.readyState)switch(h('socket receive: type "%s", data "%s"',
+a.type,a.data),this.emit("packet",a),this.emit("heartbeat"),a.type){case "open":this.onHandshake(g.parseJSON(a.data));break;case "pong":this.ping();break;case "error":var b=Error("server error");b.code=a.data;this.emit("error",b);break;case "message":this.emit("message",a.data),b={data:a.data,toString:function(){return a.data}},this.onmessage&&this.onmessage.call(this,b)}else h('packet received with socket readyState "%s"',this.readyState)};b.prototype.onHandshake=function(a){this.emit("handshake",
+a);this.id=a.sid;this.transport.query.sid=a.sid;this.upgrades=a.upgrades;this.pingInterval=a.pingInterval;this.pingTimeout=a.pingTimeout;this.onOpen();this.ping();this.removeListener("heartbeat",this.onHeartbeat);this.on("heartbeat",this.onHeartbeat)};b.prototype.onHeartbeat=function(a){clearTimeout(this.pingTimeoutTimer);var b=this;b.pingTimeoutTimer=setTimeout(function(){if("closed"!=b.readyState)b.onClose("ping timeout")},a||b.pingInterval+b.pingTimeout)};b.prototype.ping=function(){var a=this;
+clearTimeout(a.pingIntervalTimer);a.pingIntervalTimer=setTimeout(function(){h("writing ping packet - expecting pong within %sms",a.pingTimeout);a.sendPacket("ping");a.onHeartbeat(a.pingTimeout)},a.pingInterval)};b.prototype.flush=function(){"closed"!=this.readyState&&(this.transport.writable&&!this.upgrading&&this.writeBuffer.length)&&(h("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.writeBuffer=[])};b.prototype.write=b.prototype.send=function(a){this.sendPacket("message",
+a);return this};b.prototype.sendPacket=function(a,b){var c={type:a,data:b};this.emit("packetCreate",c);this.writeBuffer.push(c);this.flush()};b.prototype.close=function(){if("opening"==this.readyState||"open"==this.readyState)this.onClose("forced close"),h("socket closing - telling transport to close"),this.transport.close(),this.transport.removeAllListeners();return this};b.prototype.onError=function(a){this.emit("error",a);this.onClose("transport error",a)};b.prototype.onClose=function(a,b){"closed"!=
+this.readyState&&(h('socket close with reason: "%s"',a),clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.readyState="closed",this.emit("close",a,b),this.onclose&&this.onclose.call(this),this.id=null)}});d.register("LearnBoost-engine.io-client/lib/transport.js",function(f,c,a){function b(a){this.path=a.path;this.host=a.host;this.port=a.port;this.secure=a.secure;this.query=a.query;this.timestampParam=a.timestampParam;this.timestampRequests=a.timestampRequests;this.readyState=
+""}a("./util");var g=a("./parser"),c=a("./emitter");f.exports=b;c(b.prototype);b.prototype.onError=function(a,b){var c=Error(a);c.type="TransportError";c.description=b;this.emit("error",c);return this};b.prototype.open=function(){if("closed"==this.readyState||""==this.readyState)this.readyState="opening",this.doOpen();return this};b.prototype.close=function(){if("opening"==this.readyState||"open"==this.readyState)this.doClose(),this.onClose();return this};b.prototype.send=function(a){if("open"==this.readyState)this.write(a);
+else throw Error("Transport not open");};b.prototype.onOpen=function(){this.readyState="open";this.writable=!0;this.emit("open")};b.prototype.onData=function(a){this.onPacket(g.decodePacket(a))};b.prototype.onPacket=function(a){this.emit("packet",a)};b.prototype.onClose=function(){this.readyState="closed";this.emit("close")}});d.register("LearnBoost-engine.io-client/lib/emitter.js",function(f,c,a){var b;try{b=a("emitter")}catch(g){b=a("emitter-component")}f.exports=b;b.prototype.addEventListener=
+b.prototype.on;b.prototype.removeEventListener=b.prototype.off;b.prototype.removeListener=b.prototype.off;b.prototype.removeAllListeners=function(){this._callbacks={}}});d.register("LearnBoost-engine.io-client/lib/util.js",function(f,c,a){var b=!1,g="undefined"!=typeof window?window:g;c.inherits=function(a,b){function c(){}c.prototype=b.prototype;a.prototype=new c};c.keys=Object.keys||function(a){var b=[],c=Object.prototype.hasOwnProperty,e;for(e in a)c.call(a,e)&&b.push(e);return b};c.on=function(a,
+b,c,e){a.attachEvent?a.attachEvent("on"+b,c):a.addEventListener&&a.addEventListener(b,c,e)};c.load=function(a){if(g.document&&"complete"===document.readyState||b)return a();c.on(g,"load",a,!1)};"undefined"!=typeof window&&c.load(function(){b=!0});c.defer=function(a){if(!c.ua.webkit||"undefined"!=typeof importScripts)return a();c.load(function(){setTimeout(a,100)})};var e=/^[\],:{}\s]*$/,h=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,d=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,i=
+/(?:^|:|,)(?:\s*\[)+/g,k=/^\s+/,j=/\s+$/;c.parseJSON=function(a){if("string"!=typeof a||!a)return null;a=a.replace(k,"").replace(j,"");if(g.JSON&&JSON.parse)return JSON.parse(a);if(e.test(a.replace(h,"@").replace(d,"]").replace(i,"")))return(new Function("return "+a))()};c.ua={};var f=c.ua,m;if(m="undefined"!=typeof XMLHttpRequest)a:{try{var n=new XMLHttpRequest}catch(p){m=!1;break a}m=void 0!=n.withCredentials}f.hasCORS=m;c.ua.webkit="undefined"!=typeof navigator&&/webkit/i.test(navigator.userAgent);
+c.ua.gecko="undefined"!=typeof navigator&&/gecko/i.test(navigator.userAgent);c.ua.android="undefined"!=typeof navigator&&/android/i.test(navigator.userAgent);c.ua.ios="undefined"!=typeof navigator&&/^(iPad|iPhone|iPod)$/.test(navigator.platform);c.ua.ios6=c.ua.ios&&/OS 6_/.test(navigator.userAgent);c.request=function(b){if("undefined"!=typeof process){var e=a("xmlhttprequest").XMLHttpRequest;return new e}if(b&&"undefined"!=typeof XDomainRequest&&!c.ua.hasCORS)return new XDomainRequest;try{if("undefined"!=
+typeof e&&(!b||c.ua.hasCORS))return new e}catch(k){}if(!b)try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(j){}};var q=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,r="source protocol authority userInfo user password host port relative path directory file query anchor".split(" ");c.parseUri=function(a){for(var a=q.exec(a||""),b={},c=14;c--;)b[r[c]]=
+a[c]||"";return b};c.qs=function(a){var b="",c;for(c in a)a.hasOwnProperty(c)&&(b.length&&(b+="&"),b+=c+"="+encodeURIComponent(a[c]));return b}});d.register("LearnBoost-engine.io-client/lib/transports/index.js",function(f,c,a){var b=a("./polling-xhr"),g=a("./polling-jsonp"),f=a("./websocket"),e=a("./flashsocket"),h=a("../util");c.polling=function(a){var c,e=c=!1;d.location&&(e="https:"==location.protocol,c=location.port,Number(c)!=c&&(c=e?443:80),c=a.host!=location.hostname||c!=a.port,e=a.secure!=
+e);c=h.request(c);return e&&d.XDomainRequest&&c instanceof d.XDomainRequest?new g(a):c&&!a.forceJSONP?new b(a):new g(a)};c.websocket=f;c.flashsocket=e;var d="undefined"!=typeof window?window:d});d.register("LearnBoost-engine.io-client/lib/transports/polling.js",function(f,c,a){function b(a){g.call(this,a)}var g=a("../transport"),e=a("../util"),d=a("../parser"),l=a("debug")("engine.io-client:polling");f.exports=b;var i="undefined"!=typeof window?window:i;e.inherits(b,g);b.prototype.name="polling";
+b.prototype.doOpen=function(){this.poll()};b.prototype.pause=function(a){function b(){l("paused");c.readyState="paused";a()}var c=this;this.readyState="pausing";if(this.polling||!this.writable){var e=0;this.polling&&(l("we are currently polling - waiting to pause"),e++,this.once("pollComplete",function(){l("pre-pause polling complete");--e||b()}));this.writable||(l("we are currently writing - waiting to pause"),e++,this.once("drain",function(){l("pre-pause writing complete");--e||b()}))}else b()};
+b.prototype.poll=function(){l("polling");this.polling=!0;this.doPoll();this.emit("poll")};b.prototype.onData=function(a){l("polling got data %s",a);for(var a=d.decodePayload(a),b=0,c=a.length;b<c;b++){if("opening"==this.readyState)this.onOpen();if("close"==a[b].type){this.onClose();return}this.onPacket(a[b])}this.polling=!1;this.emit("pollComplete");"open"==this.readyState?this.poll():l('ignoring poll - transport state "%s"',this.readyState)};b.prototype.doClose=function(){l("sending close packet");
+this.send([{type:"close"}])};b.prototype.write=function(a){var b=this;this.writable=!1;this.doWrite(d.encodePayload(a),function(){b.writable=!0;b.emit("drain")})};b.prototype.uri=function(){var a=this.query||{},b=this.secure?"https":"http",c="";if(i.ActiveXObject||e.ua.android||e.ua.ios6||this.timestampRequests)a[this.timestampParam]=+new Date;a=e.qs(a);if(this.port&&("https"==b&&443!=this.port||"http"==b&&80!=this.port))c=":"+this.port;a.length&&(a="?"+a);return b+"://"+this.host+c+this.path+a}});
+d.register("LearnBoost-engine.io-client/lib/transports/polling-xhr.js",function(f,c,a){function b(){}function g(a){d.call(this,a);k.location&&(this.xd=a.host!=k.location.hostname||k.location.port!=a.port)}function e(a){this.method=a.method||"GET";this.uri=a.uri;this.xd=!!a.xd;this.async=!1!==a.async;this.data=void 0!=a.data?a.data:null;this.create()}var d=a("./polling"),l=a("../util"),c=a("../emitter"),i=a("debug")("engine.io-client:polling-xhr");f.exports=g;f.exports.Request=e;var k="undefined"!=
+typeof window?window:k,j=k[["Active"].concat("Object").join("X")];l.inherits(g,d);g.prototype.doOpen=function(){var a=this;l.defer(function(){d.prototype.doOpen.call(a)})};g.prototype.request=function(a){a=a||{};a.uri=this.uri();a.xd=this.xd;return new e(a)};g.prototype.doWrite=function(a,b){var c=this.request({method:"POST",data:a}),e=this;c.on("success",b);c.on("error",function(a){e.onError("xhr post error",a)});this.sendXhr=c};g.prototype.doPoll=function(){i("xhr poll");var a=this.request(),b=
+this;a.on("data",function(a){b.onData(a)});a.on("error",function(a){b.onError("xhr poll error",a)});this.pollXhr=a};c(e.prototype);e.prototype.create=function(){var a=this.xhr=l.request(this.xd),c=this;a.open(this.method,this.uri,this.async);if("POST"==this.method)try{a.setRequestHeader?a.setRequestHeader("Content-type","text/plain;charset=UTF-8"):a.contentType="text/plain"}catch(g){}this.xd&&k.XDomainRequest&&a instanceof XDomainRequest?(a.onerror=function(a){c.onError(a)},a.onload=function(){c.onData(a.responseText)},
+a.onprogress=b):("withCredentials"in a&&(a.withCredentials=!0),a.onreadystatechange=function(){var b;try{if(4!=a.readyState)return;if(200==a.status||1223==a.status)b=a.responseText;else c.onError(a.status)}catch(e){c.onError(e)}if(void 0!==b)c.onData(b)});i("sending xhr with url %s | data %s",this.uri,this.data);a.send(this.data);j&&(this.index=e.requestsCount++,e.requests[this.index]=this)};e.prototype.onSuccess=function(){this.emit("success");this.cleanup()};e.prototype.onData=function(a){this.emit("data",
+a);this.onSuccess()};e.prototype.onError=function(a){this.emit("error",a);this.cleanup()};e.prototype.cleanup=function(){this.xhr.onreadystatechange=b;this.xhr.onload=this.xhr.onerror=b;try{this.xhr.abort()}catch(a){}j&&delete e.requests[this.index];this.xhr=null};e.prototype.abort=function(){this.cleanup()};j&&(e.requestsCount=0,e.requests={},k.attachEvent("onunload",function(){for(var a in e.requests)e.requests.hasOwnProperty(a)&&e.requests[a].abort()}))});d.register("LearnBoost-engine.io-client/lib/transports/polling-jsonp.js",
+function(d,c,a){function b(a){g.call(this,a);i||(h.___eio||(h.___eio=[]),i=h.___eio);this.index=i.length;var b=this;i.push(function(a){b.onData(a)});this.query.j=this.index}var g=a("./polling"),e=a("../util");d.exports=b;var h="undefined"!=typeof window?window:h,l=/\n/g,i;e.inherits(b,g);b.prototype.doOpen=function(){var a=this;e.defer(function(){g.prototype.doOpen.call(a)})};b.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null);this.form&&
+(this.form.parentNode.removeChild(this.form),this.form=null);g.prototype.doClose.call(this)};b.prototype.doPoll=function(){var a=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null);a.async=!0;a.src=this.uri();var b=document.getElementsByTagName("script")[0];b.parentNode.insertBefore(a,b);this.script=a;e.ua.gecko&&setTimeout(function(){var a=document.createElement("iframe");document.body.appendChild(a);document.body.removeChild(a)},100)};
+b.prototype.doWrite=function(a,b){function c(){e();b()}function e(){g.iframe&&g.form.removeChild(g.iframe);try{i=document.createElement('<iframe name="'+g.iframeId+'">')}catch(a){i=document.createElement("iframe"),i.name=g.iframeId}i.id=g.iframeId;g.form.appendChild(i);g.iframe=i}var g=this;if(!this.form){var d=document.createElement("form"),f=document.createElement("textarea"),h=this.iframeId="eio_iframe_"+this.index,i;d.className="socketio";d.style.position="absolute";d.style.top="-1000px";d.style.left=
+"-1000px";d.target=h;d.method="POST";d.setAttribute("accept-charset","utf-8");f.name="d";d.appendChild(f);document.body.appendChild(d);this.form=d;this.area=f}this.form.action=this.uri();e();this.area.value=a.replace(l,"\\n");try{this.form.submit()}catch(s){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"==g.iframe.readyState&&c()}:this.iframe.onload=c}});d.register("LearnBoost-engine.io-client/lib/transports/websocket.js",function(d,c,a){function b(a){e.call(this,a)}
+function g(){return"undefined"!=typeof process?a("ws"):i.WebSocket||i.MozWebSocket}var e=a("../transport"),h=a("../parser"),l=a("../util");a("debug")("engine.io-client:websocket");d.exports=b;var i="undefined"!=typeof window?window:i;l.inherits(b,e);b.prototype.name="websocket";b.prototype.doOpen=function(){if(this.check()){var a=this;this.socket=new (g())(this.uri());this.socket.onopen=function(){a.onOpen()};this.socket.onclose=function(){a.onClose()};this.socket.onmessage=function(b){a.onData(b.data)};
+this.socket.onerror=function(b){a.onError("websocket error",b)}}};b.prototype.write=function(a){for(var b=0,c=a.length;b<c;b++)this.socket.send(h.encodePacket(a[b]))};b.prototype.doClose=function(){"undefined"!==typeof this.socket&&this.socket.close()};b.prototype.uri=function(){var a=this.query||{},b=this.secure?"wss":"ws",c="";if(this.port&&("wss"==b&&443!=this.port||"ws"==b&&80!=this.port))c=":"+this.port;this.timestampRequests&&(a[this.timestampParam]=+new Date);a=l.qs(a);a.length&&(a="?"+a);
+return b+"://"+this.host+c+this.path+a};b.prototype.check=function(){var a=g();return!!a&&!("__initialize"in a&&this.name===b.prototype.name)}});d.register("LearnBoost-engine.io-client/lib/transports/flashsocket.js",function(d,c,a){function b(a){g.call(this,a);this.flashPath=a.flashPath;this.policyPort=a.policyPort}var g=a("./websocket"),e=a("../util"),h=a("debug")("engine.io-client:flashsocket");d.exports=b;var l="undefined"!=typeof window?window:l,i=l[["Active"].concat("Object").join("X")];e.inherits(b,
+g);b.prototype.name="flashsocket";b.prototype.doOpen=function(){function a(b){return function(){var a=Array.prototype.join.call(arguments," ");h("[websocketjs %s] %s",b,a)}}if(this.check()){WEB_SOCKET_LOGGER={log:a("debug"),error:a("error")};WEB_SOCKET_DISABLE_AUTO_INITIALIZATION=WEB_SOCKET_SUPPRESS_CROSS_DOMAIN_SWF_ERROR=!0;"undefined"==typeof WEB_SOCKET_SWF_LOCATION&&(WEB_SOCKET_SWF_LOCATION=this.flashPath+"WebSocketMainInsecure.swf");var b=[this.flashPath+"web_socket.js"];"undefined"==typeof swfobject&&
+b.unshift(this.flashPath+"swfobject.js");var c=this,e=function(a){if(b[a]){var d=b[a];if(k[d])e(++a);else{var f=document.createElement("script"),j=!1;h('loading "%s"',d);f.onload=f.onreadystatechange=function(){if(!j&&!k[d]){var b=f.readyState;if(!b||"loaded"==b||"complete"==b)h('loaded "%s"',d),f.onload=f.onreadystatechange=null,j=!0,k[d]=!0,e(++a)}};f.async=1;f.src=d;var i=document.getElementsByTagName("head")[0];i.insertBefore(f,i.firstChild)}}else c.ready(function(){WebSocket.__addTask(function(){g.prototype.doOpen.call(c)})})};
+e(0)}};b.prototype.doClose=function(){if(this.socket){var a=this;WebSocket.__addTask(function(){g.prototype.doClose.call(a)})}};b.prototype.write=function(){var a=this,b=arguments;WebSocket.__addTask(function(){g.prototype.write.apply(a,b)})};b.prototype.ready=function(a){function c(){b.loaded||(843!=d.policyPort&&WebSocket.loadFlashPolicyFile("xmlsocket://"+d.host+":"+d.policyPort),WebSocket.__initialize(),b.loaded=!0);a.call(d)}if(!("undefined"==typeof WebSocket||!("__initialize"in WebSocket)||
+!swfobject)&&!(10>swfobject.getFlashPlayerVersion().major)){var d=this;if(document.body)return c();e.load(c)}};b.prototype.check=function(){if("undefined"!=typeof process||"undefined"!=typeof WebSocket&&!("__initialize"in WebSocket))return!1;if(i){var a=null;try{a=new i("ShockwaveFlash.ShockwaveFlash")}catch(b){}if(a)return!0}else for(var a=0,c=navigator.plugins.length;a<c;a++)for(var e=0,d=navigator.plugins[a].length;e<d;e++)if("Shockwave Flash"==navigator.plugins[a][e].description)return!0;return!1};
+var k={}});d.register("component-path-to-regexp/index.js",function(d){d.exports=function(c,a,b){var b=b||{},d=b.sensitive,b=b.strict,a=a||[];if(c instanceof RegExp)return c;c instanceof Array&&(c="("+c.join("|")+")");c=c.concat(b?"":"/?").replace(/\/\(/g,"(?:/").replace(/\+/g,"__plus__").replace(/(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?/g,function(b,c,d,g,f,j){a.push({name:g,optional:!!j});c=c||"";return""+(j?"":c)+"(?:"+(j?c:"")+(d||"")+(f||d&&"([^/.]+?)"||"([^/]+?)")+")"+(j||"")}).replace(/([\/.])/g,
+"\\$1").replace(/__plus__/g,"(.+)").replace(/\*/g,"(.*)");return RegExp("^"+c+"$",d?"":"i")}});d.register("component-trim/index.js",function(d,c){c=d.exports=function(a){return a.replace(/^\s*|\s*$/g,"")};c.left=function(a){return a.replace(/^\s*/,"")};c.right=function(a){return a.replace(/\s*$/,"")}});d.register("redventures-reduce/index.js",function(d){d.exports=function(c,a,b){for(var d=0,e=c.length,f=3==arguments.length?b:c[d++];d<e;)f=a.call(null,f,c[d],++d,c);return f}});d.register("component-querystring/index.js",
+function(d,c,a){var b=a("trim"),g=a("reduce");c.parse=function(a){if("string"!=typeof a)return{};a=b(a);return""==a?{}:g(a.split("&"),function(a,b){var c=b.split("=");a[c[0]]=null==c[1]?"":decodeURIComponent(c[1]);return a},{})};c.stringify=function(a){if(!a)return"";var b=[],c;for(c in a)b.push(encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b.join("&")}});d.register("component-url/index.js",function(d,c){c.parse=function(a){var b=document.createElement("a");b.href=a;return{href:b.href,
+host:b.host||location.host,port:b.port||location.port,hash:b.hash,hostname:b.hostname||location.hostname,pathname:b.pathname,protocol:!b.protocol||":"==b.protocol?location.protocol:b.protocol,search:b.search,query:b.search.slice(1)}};c.isAbsolute=function(a){return 0==a.indexOf("//")||!!~a.indexOf("://")};c.isRelative=function(a){return!c.isAbsolute(a)};c.isCrossDomain=function(a){a=c.parse(a);return a.hostname!==location.hostname||a.port!==location.port||a.protocol!==location.protocol}});d.register("ramitos-match-route/src/match-route.js",
+function(d,c,a){var b=a("path-to-regexp"),g=a("querystring"),e=a("url");d.exports=function(a,c,d){var f=a.method.toLowerCase(),a=e.parse(a.url),j=g.parse(a.query),m=a.pathname,n={},p=null,q="";c[f]&&Object.keys(c[f]).forEach(function(a){var d=[],e=b(a,d,!1,!1);if(e=m.match(e))e.shift(),p=c[f][a],q=a,e.forEach(function(a,b){n[d[b].name]=a})});d(p,q,n,j)}});d.register("component-type/index.js",function(d){var c=Object.prototype.toString;d.exports=function(a){switch(c.call(a)){case "[object Function]":return"function";
+case "[object Date]":return"date";case "[object RegExp]":return"regexp";case "[object Arguments]":return"arguments";case "[object Array]":return"array"}return null===a?"null":void 0===a?"undefined":a===Object(a)?"object":typeof a}});d.register("ramitos-sgen/src/sgen.js",function(d,c,a){var b=a("./map");d.exports.timestamp=function(a){a||(a=13280544E5);for(var c=((new Date).getTime()-a).toString().split(""),a=[],d="",f=0;f<c.length;f+=1)0===f%2?a.push(c[f]):a[a.length-1]+=c[f];for(c=0;c<a.length;c+=
+1)d+=b[a[c]];return d};d.exports.random=function(a){a||(a=6);for(var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),c=[],d=0;d<a;d+=1)c.push(b[Math.floor(62*Math.random())]);return c.join("")}});d.register("ramitos-sgen/src/map.js",function(d){d.exports={"0":"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9",10:"a",11:"b",12:"c",13:"d",14:"e",15:"f",16:"g",17:"h",18:"i",19:"j",20:"k",21:"l",22:"m",23:"n",24:"o",25:"p",26:"q",27:"r",28:"s",29:"t",30:"u",31:"v",
+32:"w",33:"x",34:"y",35:"z",36:"0a",37:"1b",38:"2c",39:"3d",40:"4e",41:"5f",42:"6g",43:"7h",44:"8i",45:"9j",46:"ak",47:"bl",48:"cm",49:"dn",50:"eo",51:"fp",52:"gq",53:"hr",54:"is",55:"jt",56:"ku",57:"lv",58:"mw",59:"nx",60:"oy",61:"pz",62:"q0",63:"r1",64:"s2",65:"t3",66:"u4",67:"v5",68:"w6",69:"x7",70:"y8",71:"z9",72:"0z",73:"1y",74:"2x",75:"3w",76:"4v",77:"5u",78:"6t",79:"7s",80:"8r",81:"9q",82:"ap",83:"bo",84:"cn",85:"dm",86:"el",87:"fk",88:"gj",89:"hi",90:"ih",91:"jg",92:"kf",93:"le",94:"md",95:"nc",
+96:"ob",97:"pa",98:"q9",99:"r8","01":"s7","02":"t6","03":"u5","04":"v4","05":"x3","06":"y2","07":"z1","08":"a0","09":"ba"}});d.register("component-stack/index.js",function(d){d.exports=function(){var c=Error.prepareStackTrace;Error.prepareStackTrace=function(a,c){return c};var a=Error();Error.captureStackTrace(a,arguments.callee);a=a.stack;Error.prepareStackTrace=c;return a}});d.register("component-assert/index.js",function(d,c,a){var b=a("stack");d.exports=function(a,c){if(!a){if(!c)if(Error.captureStackTrace){var d=
+b()[1],f=d.getFileName(),i=d.getLineNumber()-1,d=d.getColumnNumber()-1,k=new XMLHttpRequest;k.open("GET",f,!1);k.send(null);i=k.responseText.split("\n")[i].slice(d);c=a=i.match(/assert\((.*)\)/)[1].trim()}else c="assertion failed";throw Error(c);}}});d.register("restio/src/client/restio.js",function(d,c,a){var b=a("../methods");a("../packet");var g=a("../setup");a("match-route");var e=a("engine.io"),h=a("../on");d.exports.connect=function(a,c){var d=new e.Socket(a),f={},m={on:{}},n={};b.forEach(function(a){g.methods(a,
+f,n);g.request(a,m,d,f);g.on(a,m,n)});var p=h(d,f,n);p.error=function(a){throw a;};d.on("message",p.message);d.on("error",p.error);d.on("open",function(){c(m)})}});d.register("restio/src/platform.js",function(d){d.exports="undefined"==typeof window?"node":"browser"});d.register("restio/src/methods.js",function(d){d.exports=["get","post","put","delete"]});d.register("restio/src/packet.js",function(d){d.exports.parse=function(c,a,b,d,e){return JSON.stringify({method:c,data:a,url:b,id:d,rsp:e})}});d.register("restio/src/setup.js",
+function(d,c,a){a("./methods");var b=a("engine.io"),g=a("./packet"),e=a("assert"),h=a("./type"),l=a("sgen"),i=function(){};d.exports.methods=function(a,b,c){b[a]={};c[a]={}};d.exports.on=function(a,b,c){b.on[a]=function(b,d){e("string"==h(b));e("function"==h(d));c[a][b]=d}};d.exports.request=function(a,b,c,d){b[a]=function(){var b;b=arguments;b=Array.prototype.slice.call(b);var f={};b.length?1==b.length?(e("string"==h(b[0])),f.url=b.shift(),f.callback=i,f.data={}):2==b.length&&"function"==h(b[1])?
+(e("string"==h(b[0])),f.url=b.shift(),f.callback=b.shift(),f.data={}):2==b.length&&"object"==h(b[1])?(e("string"==h(b[0])),f.url=b.shift(),f.callback=i,f.data=b.shift()):2==b.length?(e("object"==h(b[1])||"function"==h(b[1])),e("string"==h(b[0]))):(e("function"==h(b[2])),e("object"==h(b[1])),e("string"==h(b[0])),f.url=b.shift(),f.data=b.shift(),f.callback=b.shift()):e(1<=b.length);b=f;var j=l.timestamp();c.send(g.parse(a,b.data,b.url,j,!1));d[a][j]=b.callback;b.callback.tm=setTimeout(function(){clearTimeout(d[a][j].tm);
+d[a][j]=void 0},36E5)}};d.exports.server=function(a){e("string"==h(a)||"object"==h(a));return"string"==h(a)?b.listen(a):b.attach(a)}});d.register("restio/src/type.js",function(d,c,a){c=a("./platform");d.exports="browser"==c?a("type"):a("type-component")});d.register("restio/src/on.js",function(d,c,a){var b=a("./platform"),g=a("./packet"),e=a("match-route");a("./type");d.exports=function(a,c,d){var f={message:function(a){a=JSON.parse(a);a.rsp&&c[a.method][a.id]?f.response(a):a.rsp||f.request(a)},response:function(a){clearTimeout(c[a.method][a.id].tm);
+c[a.method][a.id](a.data);c[a.method][a.id]=void 0},request:function(c){e(c,d,function(d,e,f,i){d({socket:"node"==b?a:void 0,params:f,body:c.data,query:i},function(b){a.send(g.parse(c.method,b,c.url,c.id,!0))})})}};return f}});d.alias("LearnBoost-engine.io-client/lib/index.js","restio/deps/engine.io/lib/index.js");d.alias("LearnBoost-engine.io-client/lib/parser.js","restio/deps/engine.io/lib/parser.js");d.alias("LearnBoost-engine.io-client/lib/socket.js","restio/deps/engine.io/lib/socket.js");d.alias("LearnBoost-engine.io-client/lib/transport.js",
+"restio/deps/engine.io/lib/transport.js");d.alias("LearnBoost-engine.io-client/lib/emitter.js","restio/deps/engine.io/lib/emitter.js");d.alias("LearnBoost-engine.io-client/lib/util.js","restio/deps/engine.io/lib/util.js");d.alias("LearnBoost-engine.io-client/lib/transports/index.js","restio/deps/engine.io/lib/transports/index.js");d.alias("LearnBoost-engine.io-client/lib/transports/polling.js","restio/deps/engine.io/lib/transports/polling.js");d.alias("LearnBoost-engine.io-client/lib/transports/polling-xhr.js",
+"restio/deps/engine.io/lib/transports/polling-xhr.js");d.alias("LearnBoost-engine.io-client/lib/transports/polling-jsonp.js","restio/deps/engine.io/lib/transports/polling-jsonp.js");d.alias("LearnBoost-engine.io-client/lib/transports/websocket.js","restio/deps/engine.io/lib/transports/websocket.js");d.alias("LearnBoost-engine.io-client/lib/transports/flashsocket.js","restio/deps/engine.io/lib/transports/flashsocket.js");d.alias("LearnBoost-engine.io-client/lib/index.js","restio/deps/engine.io/index.js");
+d.alias("component-emitter/index.js","LearnBoost-engine.io-client/deps/emitter/index.js");d.alias("visionmedia-debug/index.js","LearnBoost-engine.io-client/deps/debug/index.js");d.alias("visionmedia-debug/debug.js","LearnBoost-engine.io-client/deps/debug/debug.js");d.alias("ramitos-match-route/src/match-route.js","restio/deps/match-route/src/match-route.js");d.alias("ramitos-match-route/src/match-route.js","restio/deps/match-route/index.js");d.alias("component-path-to-regexp/index.js","ramitos-match-route/deps/path-to-regexp/index.js");
+d.alias("component-querystring/index.js","ramitos-match-route/deps/querystring/index.js");d.alias("component-trim/index.js","component-querystring/deps/trim/index.js");d.alias("redventures-reduce/index.js","component-querystring/deps/reduce/index.js");d.alias("component-url/index.js","ramitos-match-route/deps/url/index.js");d.alias("component-type/index.js","restio/deps/type/index.js");d.alias("ramitos-sgen/src/sgen.js","restio/deps/sgen/src/sgen.js");d.alias("ramitos-sgen/src/map.js","restio/deps/sgen/src/map.js");
+d.alias("ramitos-sgen/src/sgen.js","restio/deps/sgen/index.js");d.alias("component-assert/index.js","restio/deps/assert/index.js");d.alias("component-stack/index.js","component-assert/deps/stack/index.js");d.alias("restio/src/client/restio.js","restio/index.js");"undefined"==typeof module?window.restio=d("restio"):module.exports=d("restio")})();
View
35 docs/client.md
@@ -0,0 +1,35 @@
+# installation
+
+#### with [component(1)](https://github.com/component/component)
+
+```bash
+$ component install [--dev] ramitos/restio
+```
+
+#### with [bower](https://github.com/twitter/bower)
+
+```bash
+$ bower install [--save] restio
+```
+
+#### without any package manager
+
+download the [regular](https://raw.github.com/ramitos/restio/master/dist/restio.js) or [minified](https://raw.github.com/ramitos/restio/master/dist/restio..min.js) versions and use them as regular scripts
+
+```html
+<script src='js/vendor/restio.min.js'></script>
+```
+
+# usage
+
+#### with [component(1)](https://github.com/component/component)
+
+```js
+var restio = require('restio');
+```
+
+#### with [bower](https://github.com/twitter/bower) or as a regular script
+
+```js
+var restio = window.restio;
+```
View
0 docs/server.md
No changes.
View
2 package.json
@@ -1,7 +1,7 @@
{
"name": "restio",
"license": "MIT",
- "version": "0.3.0",
+ "version": "0.3.1",
"author": "Sérgio Ramos",
"description": "REST-like syntax for WebSockets",
"main": "src/server/restio.js",
View
4 src/setup.js
@@ -47,8 +47,8 @@ var isNode = function () {
return window == undefined;
};
-var parseArgs = function (arguments) {
- var args = Array.prototype.slice.call(arguments);
+var parseArgs = function (args) {
+ args = Array.prototype.slice.call(args);
var returns = {};
if(!args.length) {

0 comments on commit b51f6ae

Please sign in to comment.