From aee92f2aeef919bdb6fed8894ea4f684daf31e1c Mon Sep 17 00:00:00 2001 From: Anthony Fok Date: Mon, 21 Dec 2015 17:22:00 -0700 Subject: [PATCH] Docs: Upgrade livereload.js from post-2.0.8 to 2.2.1 Note: It is not currently used on http://gohugo.io/ --- docs/static/js/livereload.js | 1961 +++++++++++++++++----------------- 1 file changed, 992 insertions(+), 969 deletions(-) diff --git a/docs/static/js/livereload.js b/docs/static/js/livereload.js index 7ec3a9ab67a..f6c3b7f904d 100644 --- a/docs/static/js/livereload.js +++ b/docs/static/js/livereload.js @@ -1,1132 +1,1155 @@ +(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;o= 0) { - this.protocol = 7; - } else if (__indexOf.call(message.protocols, PROTOCOL_6) >= 0) { - this.protocol = 6; - } else { - throw new ProtocolError("no supported protocols found"); - } - } - return this.handlers.connected(this.protocol); - } else if (this.protocol === 6) { - message = JSON.parse(data); - if (!message.length) { - throw new ProtocolError("protocol 6 messages must be arrays"); - } - command = message[0], options = message[1]; - if (command !== 'refresh') { - throw new ProtocolError("unknown protocol 6 command"); - } - return this.handlers.message({ - command: 'reload', - path: options.path, - liveCSS: (_ref = options.apply_css_live) != null ? _ref : true - }); - } else { - message = this._parseMessage(data, ['reload', 'alert']); - return this.handlers.message(message); - } - } catch (_error) { - e = _error; - if (e instanceof ProtocolError) { - return this.handlers.error(e); - } else { - throw e; + return; } - } - }; + return this._sendCommand(command); + }; - Parser.prototype._parseMessage = function(data, validCommands) { - var e, message, _ref; + Connector.prototype._sendCommand = function(command) { + return this.socket.send(JSON.stringify(command)); + }; - try { - message = JSON.parse(data); - } catch (_error) { - e = _error; - throw new ProtocolError('unparsable JSON', data); - } - if (!message.command) { - throw new ProtocolError('missing "command" key', data); - } - if (_ref = message.command, __indexOf.call(validCommands, _ref) < 0) { - throw new ProtocolError("invalid command '" + message.command + "', only valid commands are: " + (validCommands.join(', ')) + ")", data); - } - return message; - }; + Connector.prototype._closeOnError = function() { + this._handshakeTimeout.stop(); + this._disconnectionReason = 'error'; + return this.socket.close(); + }; - return Parser; - -})(); - -// connector -// Generated by CoffeeScript 1.6.2 -var Connector, PROTOCOL_6, PROTOCOL_7, Parser, Version, _ref; - -_ref = __protocol, Parser = _ref.Parser, PROTOCOL_6 = _ref.PROTOCOL_6, PROTOCOL_7 = _ref.PROTOCOL_7; - -Version = '2.0.8'; - -__connector.Connector = Connector = (function() { - function Connector(options, WebSocket, Timer, handlers) { - var _this = this; - - this.options = options; - this.WebSocket = WebSocket; - this.Timer = Timer; - this.handlers = handlers; - this._uri = "ws://" + this.options.host + ":" + this.options.port + "/livereload"; - this._nextDelay = this.options.mindelay; - this._connectionDesired = false; - this.protocol = 0; - this.protocolParser = new Parser({ - connected: function(protocol) { - _this.protocol = protocol; - _this._handshakeTimeout.stop(); - _this._nextDelay = _this.options.mindelay; - _this._disconnectionReason = 'broken'; - return _this.handlers.connected(protocol); - }, - error: function(e) { - _this.handlers.error(e); - return _this._closeOnError(); - }, - message: function(message) { - return _this.handlers.message(message); + Connector.prototype._onopen = function(e) { + var hello; + this.handlers.socketConnected(); + this._disconnectionReason = 'handshake-failed'; + hello = { + command: 'hello', + protocols: [PROTOCOL_6, PROTOCOL_7] + }; + hello.ver = Version; + if (this.options.ext) { + hello.ext = this.options.ext; } - }); - this._handshakeTimeout = new Timer(function() { - if (!_this._isSocketConnected()) { - return; + if (this.options.extver) { + hello.extver = this.options.extver; } - _this._disconnectionReason = 'handshake-timeout'; - return _this.socket.close(); - }); - this._reconnectTimer = new Timer(function() { - if (!_this._connectionDesired) { - return; + if (this.options.snipver) { + hello.snipver = this.options.snipver; } - return _this.connect(); - }); - this.connect(); - } + this._sendCommand(hello); + return this._handshakeTimeout.start(this.options.handshake_timeout); + }; - Connector.prototype._isSocketConnected = function() { - return this.socket && this.socket.readyState === this.WebSocket.OPEN; - }; + Connector.prototype._onclose = function(e) { + this.protocol = 0; + this.handlers.disconnected(this._disconnectionReason, this._nextDelay); + return this._scheduleReconnection(); + }; - Connector.prototype.connect = function() { - var _this = this; + Connector.prototype._onerror = function(e) {}; - this._connectionDesired = true; - if (this._isSocketConnected()) { - return; - } - this._reconnectTimer.stop(); - this._disconnectionReason = 'cannot-connect'; - this.protocolParser.reset(); - this.handlers.connecting(); - this.socket = new this.WebSocket(this._uri); - this.socket.onopen = function(e) { - return _this._onopen(e); - }; - this.socket.onclose = function(e) { - return _this._onclose(e); + Connector.prototype._onmessage = function(e) { + return this.protocolParser.process(e.data); }; - this.socket.onmessage = function(e) { - return _this._onmessage(e); - }; - return this.socket.onerror = function(e) { - return _this._onerror(e); - }; - }; - - Connector.prototype.disconnect = function() { - this._connectionDesired = false; - this._reconnectTimer.stop(); - if (!this._isSocketConnected()) { - return; - } - this._disconnectionReason = 'manual'; - return this.socket.close(); - }; - Connector.prototype._scheduleReconnection = function() { - if (!this._connectionDesired) { - return; - } - if (!this._reconnectTimer.running) { - this._reconnectTimer.start(this._nextDelay); - return this._nextDelay = Math.min(this.options.maxdelay, this._nextDelay * 2); - } - }; + return Connector; - Connector.prototype.sendCommand = function(command) { - if (this.protocol == null) { - return; - } - return this._sendCommand(command); - }; + })(); - Connector.prototype._sendCommand = function(command) { - return this.socket.send(JSON.stringify(command)); - }; +}).call(this); - Connector.prototype._closeOnError = function() { - this._handshakeTimeout.stop(); - this._disconnectionReason = 'error'; - return this.socket.close(); +},{"./protocol":6}],2:[function(require,module,exports){ +(function() { + var CustomEvents; + + CustomEvents = { + bind: function(element, eventName, handler) { + if (element.addEventListener) { + return element.addEventListener(eventName, handler, false); + } else if (element.attachEvent) { + element[eventName] = 1; + return element.attachEvent('onpropertychange', function(event) { + if (event.propertyName === eventName) { + return handler(); + } + }); + } else { + throw new Error("Attempt to attach custom event " + eventName + " to something which isn't a DOMElement"); + } + }, + fire: function(element, eventName) { + var event; + if (element.addEventListener) { + event = document.createEvent('HTMLEvents'); + event.initEvent(eventName, true, true); + return document.dispatchEvent(event); + } else if (element.attachEvent) { + if (element[eventName]) { + return element[eventName]++; + } + } else { + throw new Error("Attempt to fire custom event " + eventName + " on something which isn't a DOMElement"); + } + } }; - Connector.prototype._onopen = function(e) { - var hello; + exports.bind = CustomEvents.bind; - this.handlers.socketConnected(); - this._disconnectionReason = 'handshake-failed'; - hello = { - command: 'hello', - protocols: [PROTOCOL_6, PROTOCOL_7] - }; - hello.ver = Version; - if (this.options.ext) { - hello.ext = this.options.ext; - } - if (this.options.extver) { - hello.extver = this.options.extver; - } - if (this.options.snipver) { - hello.snipver = this.options.snipver; - } - this._sendCommand(hello); - return this._handshakeTimeout.start(this.options.handshake_timeout); - }; + exports.fire = CustomEvents.fire; - Connector.prototype._onclose = function(e) { - this.protocol = 0; - this.handlers.disconnected(this._disconnectionReason, this._nextDelay); - return this._scheduleReconnection(); - }; +}).call(this); - Connector.prototype._onerror = function(e) {}; +},{}],3:[function(require,module,exports){ +(function() { + var LessPlugin; - Connector.prototype._onmessage = function(e) { - return this.protocolParser.process(e.data); - }; + module.exports = LessPlugin = (function() { + LessPlugin.identifier = 'less'; - return Connector; + LessPlugin.version = '1.0'; -})(); + function LessPlugin(window, host) { + this.window = window; + this.host = host; + } -// customevents -// Generated by CoffeeScript 1.6.2 -var CustomEvents; + LessPlugin.prototype.reload = function(path, options) { + if (this.window.less && this.window.less.refresh) { + if (path.match(/\.less$/i)) { + return this.reloadLess(path); + } + if (options.originalPath.match(/\.less$/i)) { + return this.reloadLess(options.originalPath); + } + } + return false; + }; -CustomEvents = { - bind: function(element, eventName, handler) { - if (element.addEventListener) { - return element.addEventListener(eventName, handler, false); - } else if (element.attachEvent) { - element[eventName] = 1; - return element.attachEvent('onpropertychange', function(event) { - if (event.propertyName === eventName) { - return handler(); + LessPlugin.prototype.reloadLess = function(path) { + var link, links, _i, _len; + links = (function() { + var _i, _len, _ref, _results; + _ref = document.getElementsByTagName('link'); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + link = _ref[_i]; + if (link.href && link.rel.match(/^stylesheet\/less$/i) || (link.rel.match(/stylesheet/i) && link.type.match(/^text\/(x-)?less$/i))) { + _results.push(link); + } } - }); - } else { - throw new Error("Attempt to attach custom event " + eventName + " to something which isn't a DOMElement"); - } - }, - fire: function(element, eventName) { - var event; - - if (element.addEventListener) { - event = document.createEvent('HTMLEvents'); - event.initEvent(eventName, true, true); - return document.dispatchEvent(event); - } else if (element.attachEvent) { - if (element[eventName]) { - return element[eventName]++; + return _results; + })(); + if (links.length === 0) { + return false; } - } else { - throw new Error("Attempt to fire custom event " + eventName + " on something which isn't a DOMElement"); - } - } -}; + for (_i = 0, _len = links.length; _i < _len; _i++) { + link = links[_i]; + link.href = this.host.generateCacheBustUrl(link.href); + } + this.host.console.log("LiveReload is asking LESS to recompile all stylesheets"); + this.window.less.refresh(true); + return true; + }; -__customevents.bind = CustomEvents.bind; + LessPlugin.prototype.analyze = function() { + return { + disable: !!(this.window.less && this.window.less.refresh) + }; + }; -__customevents.fire = CustomEvents.fire; + return LessPlugin; -// less -// Generated by CoffeeScript 1.6.2 -var LessPlugin; + })(); -__less = LessPlugin = (function() { - LessPlugin.identifier = 'less'; +}).call(this); - LessPlugin.version = '1.0'; +},{}],4:[function(require,module,exports){ +(function() { + var Connector, LiveReload, Options, Reloader, Timer; - function LessPlugin(window, host) { - this.window = window; - this.host = host; - } + Connector = require('./connector').Connector; - LessPlugin.prototype.reload = function(path, options) { - if (this.window.less && this.window.less.refresh) { - if (path.match(/\.less$/i)) { - return this.reloadLess(path); - } - if (options.originalPath.match(/\.less$/i)) { - return this.reloadLess(options.originalPath); - } - } - return false; - }; + Timer = require('./timer').Timer; - LessPlugin.prototype.reloadLess = function(path) { - var link, links, _i, _len; + Options = require('./options').Options; - links = (function() { - var _i, _len, _ref, _results; + Reloader = require('./reloader').Reloader; - _ref = document.getElementsByTagName('link'); - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - link = _ref[_i]; - if (link.href && link.rel === 'stylesheet/less' || (link.rel.match(/stylesheet/) && link.type.match(/^text\/(x-)?less$/))) { - _results.push(link); - } + exports.LiveReload = LiveReload = (function() { + function LiveReload(window) { + this.window = window; + this.listeners = {}; + this.plugins = []; + this.pluginIdentifiers = {}; + 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() {} + }; + if (!(this.WebSocket = this.window.WebSocket || this.window.MozWebSocket)) { + this.console.error("LiveReload disabled because the browser does not seem to support web sockets"); + return; } - return _results; - })(); - if (links.length === 0) { - return false; - } - for (_i = 0, _len = links.length; _i < _len; _i++) { - link = links[_i]; - link.href = this.host.generateCacheBustUrl(link.href); + if (!(this.options = Options.extract(this.window.document))) { + this.console.error("LiveReload disabled because it could not find its own