From 79f352efde388df52113148c39efd9fe105e6ccd Mon Sep 17 00:00:00 2001 From: Stefan Thomas Date: Wed, 7 Nov 2012 19:04:15 -0800 Subject: [PATCH 1/2] Change from ws.on('message') to ws.onmessage for browser compat. --- src/js/remote.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/js/remote.js b/src/js/remote.js index 793db9311..488df0b42 100644 --- a/src/js/remote.js +++ b/src/js/remote.js @@ -385,15 +385,14 @@ Remote.prototype._connect_start = function () { self._connect_retry(); }; - - // Node's ws module doesn't pass arguments to onmessage. - ws.on('message', function (json, flags) { - self._connect_message(ws, json, flags); - }); + + ws.onmessage = function (json) { + self._connect_message(ws, json.data); + }; }; // It is possible for messages to be dispatched after the connection is closed. -Remote.prototype._connect_message = function (ws, json, flags) { +Remote.prototype._connect_message = function (ws, json) { var message = JSON.parse(json); var unexpected = false; var request; From 82c3f8c36fb0684a82b393deacb4da72e1179da9 Mon Sep 17 00:00:00 2001 From: Stefan Thomas Date: Thu, 8 Nov 2012 14:02:39 -0800 Subject: [PATCH 2/2] Added ability to watch files and rebuild automatically. --- webpack.js | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/webpack.js b/webpack.js index d4cd81441..fe21a57d8 100644 --- a/webpack.js +++ b/webpack.js @@ -5,7 +5,13 @@ var extend = require("extend"); var programPath = __dirname + "/src/js/remote.js"; -console.log('Compiling Ripple JavaScript...'); +var watch = false; +process.argv.forEach(function (arg) { + if (arg === '-w' || arg === '--watch') { + watch = true; + } +}); + var builds = [{ filename: 'ripple-'+pkg.version+'.js', },{ @@ -20,8 +26,10 @@ var defaultOpts = { // [sic] Yes, this is the spelling upstream. libary: 'ripple', // However, it's fixed in webpack 0.8, so we include the correct spelling too: - library: 'ripple' + library: 'ripple', + watch: watch }; + function build(opts) { var opts = extend({}, defaultOpts, opts); opts.output = __dirname + "/build/"+opts.filename; @@ -29,13 +37,23 @@ function build(opts) { var filename = opts.filename; webpack(programPath, opts, function (err, result) { console.log(' '+filename, result.hash, '['+result.modulesCount+']'); - callback(err); + if ("function" === typeof callback) { + callback(err); + } }); } } -async.series(builds.map(build), function (err) { - if (err) { - console.error(err); - } -}); +if (!watch) { + console.log('Compiling Ripple JavaScript...'); + async.series(builds.map(build), function (err) { + if (err) { + console.error(err); + } + }); +} else { + console.log('Watching files for changes...'); + builds.map(build).forEach(function (build) { + build(); + }); +}