From 0f95440e9b391e71ae089188732e0229ec9a4b6b Mon Sep 17 00:00:00 2001 From: Muhammed Thanish Date: Wed, 22 Jun 2016 18:16:03 +0530 Subject: [PATCH 1/2] Remove socket.io Fixes issue where the connection only works when JS debugging is enabled --- dist/client/_vendor/patched-socket.io.js | 1790 ----- dist/client/index.js | 2 +- dist/client/preview/components/Preview.js | 84 +- dist/server/index.js | 54 +- dist/server/public/manager.js | 7513 +-------------------- package.json | 3 +- src/client/_vendor/patched-socket.io.js | 7253 -------------------- src/client/index.js | 2 +- src/client/manager/provider.js | 76 +- src/client/preview/components/Preview.js | 75 +- src/server/index.js | 48 +- 11 files changed, 284 insertions(+), 16616 deletions(-) delete mode 100644 dist/client/_vendor/patched-socket.io.js delete mode 100644 src/client/_vendor/patched-socket.io.js diff --git a/dist/client/_vendor/patched-socket.io.js b/dist/client/_vendor/patched-socket.io.js deleted file mode 100644 index 3937703..0000000 --- a/dist/client/_vendor/patched-socket.io.js +++ /dev/null @@ -1,1790 +0,0 @@ -"use strict";var _typeof=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(obj){return typeof obj;}:function(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol?"symbol":typeof obj;};(function(f){if((typeof exports==="undefined"?"undefined":_typeof(exports))==="object"&&typeof module!=="undefined"){module.exports=f();}else if(typeof define==="function"&&define.amd){define([],f);}else {var g;if(typeof window!=="undefined"){g=window;}else if(typeof global!=="undefined"){g=global;}else if(typeof self!=="undefined"){g=self;}else {g=this;}g.io=f();}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f;}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e);},l,l.exports,e,t,n,r);}return n[o].exports;}var i=typeof require=="function"&&require;for(var o=0;o0){this.extraHeaders=opts.extraHeaders;}}this.open();}Socket.priorWebsocketSuccess=false; /** - * Mix in `Emitter`. - */Emitter(Socket.prototype); /** - * Protocol version. - * - * @api public - */Socket.protocol=parser.protocol; // this is an int -/** - * Expose deps for legacy compatibility - * and standalone browser access. - */Socket.Socket=Socket;Socket.Transport=_dereq_('./transport');Socket.transports=_dereq_('./transports');Socket.parser=_dereq_('engine.io-parser'); /** - * Creates transport of the given type. - * - * @param {String} transport name - * @return {Transport} - * @api private - */Socket.prototype.createTransport=function(name){debug('creating transport "%s"',name);var query=clone(this.query); // append engine.io protocol identifier -query.EIO=parser.protocol; // transport name -query.transport=name; // session id if we already have one -if(this.id)query.sid=this.id;var transport=new transports[name]({agent:this.agent,hostname:this.hostname,port:this.port,secure:this.secure,path:this.path,query:query,forceJSONP:this.forceJSONP,jsonp:this.jsonp,forceBase64:this.forceBase64,enablesXDR:this.enablesXDR,timestampRequests:this.timestampRequests,timestampParam:this.timestampParam,policyPort:this.policyPort,socket:this,pfx:this.pfx,key:this.key,passphrase:this.passphrase,cert:this.cert,ca:this.ca,ciphers:this.ciphers,rejectUnauthorized:this.rejectUnauthorized,perMessageDeflate:this.perMessageDeflate,extraHeaders:this.extraHeaders});return transport;};function clone(obj){var o={};for(var i in obj){if(obj.hasOwnProperty(i)){o[i]=obj[i];}}return o;} /** - * Initializes transport to use and starts probe. - * - * @api private - */Socket.prototype.open=function(){var transport;if(this.rememberUpgrade&&Socket.priorWebsocketSuccess&&this.transports.indexOf('websocket')!=-1){transport='websocket';}else if(0===this.transports.length){ // Emit error on next tick so it can be listened to -var self=this;setTimeout(function(){self.emit('error','No transports available');},0);return;}else {transport=this.transports[0];}this.readyState='opening'; // Retry with the next transport if the transport is disabled (jsonp: false) -try{transport=this.createTransport(transport);}catch(e){this.transports.shift();this.open();return;}transport.open();this.setTransport(transport);}; /** - * Sets the current transport. Disables the existing one (if any). - * - * @api private - */Socket.prototype.setTransport=function(transport){debug('setting transport %s',transport.name);var self=this;if(this.transport){debug('clearing existing transport %s',this.transport.name);this.transport.removeAllListeners();} // set up transport -this.transport=transport; // set up transport listeners -transport.on('drain',function(){self.onDrain();}).on('packet',function(packet){self.onPacket(packet);}).on('error',function(e){self.onError(e);}).on('close',function(){self.onClose('transport close');});}; /** - * Probes a transport. - * - * @param {String} transport name - * @api private - */Socket.prototype.probe=function(name){debug('probing transport "%s"',name);var transport=this.createTransport(name,{probe:1}),failed=false,self=this;Socket.priorWebsocketSuccess=false;function onTransportOpen(){if(self.onlyBinaryUpgrades){var upgradeLosesBinary=!this.supportsBinary&&self.transport.supportsBinary;failed=failed||upgradeLosesBinary;}if(failed)return;debug('probe transport "%s" opened',name);transport.send([{type:'ping',data:'probe'}]);transport.once('packet',function(msg){if(failed)return;if('pong'==msg.type&&'probe'==msg.data){debug('probe transport "%s" pong',name);self.upgrading=true;self.emit('upgrading',transport);if(!transport)return;Socket.priorWebsocketSuccess='websocket'==transport.name;debug('pausing current transport "%s"',self.transport.name);self.transport.pause(function(){if(failed)return;if('closed'==self.readyState)return;debug('changing transport and sending upgrade packet');cleanup();self.setTransport(transport);transport.send([{type:'upgrade'}]);self.emit('upgrade',transport);transport=null;self.upgrading=false;self.flush();});}else {debug('probe transport "%s" failed',name);var err=new Error('probe error');err.transport=transport.name;self.emit('upgradeError',err);}});}function freezeTransport(){if(failed)return; // Any callback called by transport should be ignored since now -failed=true;cleanup();transport.close();transport=null;} //Handle any error that happens while probing -function onerror(err){var error=new Error('probe error: '+err);error.transport=transport.name;freezeTransport();debug('probe transport "%s" failed because of error: %s',name,err);self.emit('upgradeError',error);}function onTransportClose(){onerror("transport closed");} //When the socket is closed while we're probing -function onclose(){onerror("socket closed");} //When the socket is upgraded while we're probing -function onupgrade(to){if(transport&&to.name!=transport.name){debug('"%s" works - aborting "%s"',to.name,transport.name);freezeTransport();}} //Remove all listeners on the transport and on self -function cleanup(){transport.removeListener('open',onTransportOpen);transport.removeListener('error',onerror);transport.removeListener('close',onTransportClose);self.removeListener('close',onclose);self.removeListener('upgrading',onupgrade);}transport.once('open',onTransportOpen);transport.once('error',onerror);transport.once('close',onTransportClose);this.once('close',onclose);this.once('upgrading',onupgrade);transport.open();}; /** - * Called when connection is deemed open. - * - * @api public - */Socket.prototype.onOpen=function(){debug('socket open');this.readyState='open';Socket.priorWebsocketSuccess='websocket'==this.transport.name;this.emit('open');this.flush(); // we check for `readyState` in case an `open` -// listener already closed the socket -if('open'==this.readyState&&this.upgrade&&this.transport.pause){debug('starting upgrade probes');for(var i=0,l=this.upgrades.length;i