/* global alert */ const { Connector } = require('./connector'); const { Timer } = require('./timer'); const { Options } = require('./options'); const { Reloader } = require('./reloader'); const { ProtocolError } = require('./protocol'); class LiveReload { constructor (window) { this.window = window; this.listeners = {}; this.plugins = []; this.pluginIdentifiers = {}; // i can haz console? this.console = this.window.console && this.window.console.log && this.window.console.error ? this.window.location.href.match(/LR-verbose/) ? this.window.console : { log () {}, error: this.window.console.error.bind(this.window.console) } : { log () {}, error () {} }; // i can haz sockets? 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; } // i can haz options? if ('LiveReloadOptions' in window) { this.options = new Options(); for (const k of Object.keys(window.LiveReloadOptions || {})) { const v = window.LiveReloadOptions[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