From c791dffae5fc1f528a28fff93a9d1d92bd4167b5 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Fri, 12 May 2017 21:15:50 +0900 Subject: [PATCH] Use livereload properly. Fix #10 --- Cargo.lock | 10 ++++---- src/cmd/livereload.js | 55 ++++++++++++++----------------------------- src/cmd/serve.rs | 15 +++++++++--- 3 files changed, 35 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 52cc3c4a..faa70f87 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,7 +68,7 @@ name = "backtrace-sys" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.46 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -173,7 +173,7 @@ name = "cmake" version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.46 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -257,7 +257,7 @@ dependencies = [ [[package]] name = "gcc" -version = "0.3.45" +version = "0.3.46" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -408,7 +408,7 @@ name = "miniz-sys" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.46 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1096,7 +1096,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc484842f1e2884faf56f529f960cc12ad8c71ce96cc7abba0a067c98fee344" "checksum fsevent 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "dfe593ebcfc76884138b25426999890b10da8e6a46d01b499d7c54c604672c38" "checksum fsevent-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1a772d36c338d07a032d5375a36f15f9a7043bf0cb8ce7cee658e037c6032874" -"checksum gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)" = "40899336fb50db0c78710f53e87afc54d8c7266fb76262fecc78ca1a7f09deae" +"checksum gcc 0.3.46 (registry+https://github.com/rust-lang/crates.io-index)" = "181e3cebba1d663bd92eb90e2da787e10597e027eb00de8d742b260a7850948f" "checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum httparse 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77f756bed9ee3a83ce98774f4155b42a31b787029013f3a7d83eca714e500e21" diff --git a/src/cmd/livereload.js b/src/cmd/livereload.js index fd221102..eaa78b00 100644 --- a/src/cmd/livereload.js +++ b/src/cmd/livereload.js @@ -4,7 +4,7 @@ _ref = require('./protocol'), Parser = _ref.Parser, PROTOCOL_6 = _ref.PROTOCOL_6, PROTOCOL_7 = _ref.PROTOCOL_7; - Version = '2.2.2'; + Version = '2.2.1'; exports.Connector = Connector = (function() { function Connector(options, WebSocket, Timer, handlers) { @@ -12,7 +12,7 @@ this.WebSocket = WebSocket; this.Timer = Timer; this.handlers = handlers; - this._uri = "ws" + (this.options.https ? "s" : "") + "://" + this.options.host + ":" + this.options.port + "/livereload"; + this._uri = "ws://" + this.options.host + ":" + this.options.port + "/livereload"; this._nextDelay = this.options.mindelay; this._connectionDesired = false; this.protocol = 0; @@ -278,8 +278,7 @@ },{}],4:[function(require,module,exports){ (function() { - var Connector, LiveReload, Options, Reloader, Timer, - __hasProp = {}.hasOwnProperty; + var Connector, LiveReload, Options, Reloader, Timer; Connector = require('./connector').Connector; @@ -291,15 +290,11 @@ exports.LiveReload = LiveReload = (function() { function LiveReload(window) { - var k, v, _ref; this.window = window; this.listeners = {}; this.plugins = []; this.pluginIdentifiers = {}; - this.console = this.window.console && this.window.console.log && this.window.console.error ? this.window.location.href.match(/LR-verbose/) ? this.window.console : { - log: function() {}, - error: this.window.console.error.bind(this.window.console) - } : { + this.console = this.window.location.href.match(/LR-verbose/) && this.window.console && this.window.console.log && this.window.console.error ? this.window.console : { log: function() {}, error: function() {} }; @@ -307,20 +302,9 @@ this.console.error("LiveReload disabled because the browser does not seem to support web sockets"); return; } - if ('LiveReloadOptions' in window) { - this.options = new Options(); - _ref = window['LiveReloadOptions']; - for (k in _ref) { - if (!__hasProp.call(_ref, k)) continue; - v = _ref[k]; - this.options.set(k, v); - } - } else { - this.options = Options.extract(this.window.document); - if (!this.options) { - this.console.error("LiveReload disabled because it could not find its own