Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

javascript.go 20KB

123456
  1. package livereload
  2. // SEE https://github.com/livereload/livereload-js
  3. // http://feedback.livereload.com/knowledgebase/articles/86174-livereload-protocol
  4. // 2015-06-19 Ver2.2.2@jscompress.com
  5. var javascript = []byte(`!function e(t,n,o){function i(s,l){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!l&&c)return c(s,!0);if(r)return r(s,!0);var a=new Error("Cannot find module '"+s+"'");throw a.code="MODULE_NOT_FOUND",a}var h=n[s]={exports:{}};t[s][0].call(h.exports,function(e){var n=t[s][1][e];return i(n?n:e)},h,h.exports,e,t,n,o)}return n[s].exports}for(var r="function"==typeof require&&require,s=0;s<o.length;s++)i(o[s]);return i}({1:[function(e,t,n){(function(){var t,o,i,r,s,l;l=e("./protocol"),r=l.Parser,o=l.PROTOCOL_6,i=l.PROTOCOL_7,s="2.2.2",n.Connector=t=function(){function e(e,t,n,o){this.options=e,this.WebSocket=t,this.Timer=n,this.handlers=o,this._uri="ws"+(this.options.https?"s":"")+"://"+this.options.host+":"+this.options.port+"/livereload",this._nextDelay=this.options.mindelay,this._connectionDesired=!1,this.protocol=0,this.protocolParser=new r({connected:function(e){return function(t){return e.protocol=t,e._handshakeTimeout.stop(),e._nextDelay=e.options.mindelay,e._disconnectionReason="broken",e.handlers.connected(t)}}(this),error:function(e){return function(t){return e.handlers.error(t),e._closeOnError()}}(this),message:function(e){return function(t){return e.handlers.message(t)}}(this)}),this._handshakeTimeout=new n(function(e){return function(){return e._isSocketConnected()?(e._disconnectionReason="handshake-timeout",e.socket.close()):void 0}}(this)),this._reconnectTimer=new n(function(e){return function(){return e._connectionDesired?e.connect():void 0}}(this)),this.connect()}return e.prototype._isSocketConnected=function(){return this.socket&&this.socket.readyState===this.WebSocket.OPEN},e.prototype.connect=function(){return this._connectionDesired=!0,this._isSocketConnected()?void 0:(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 function(t){return e._onopen(t)}}(this),this.socket.onclose=function(e){return function(t){return e._onclose(t)}}(this),this.socket.onmessage=function(e){return function(t){return e._onmessage(t)}}(this),this.socket.onerror=function(e){return function(t){return e._onerror(t)}}(this))},e.prototype.disconnect=function(){return this._connectionDesired=!1,this._reconnectTimer.stop(),this._isSocketConnected()?(this._disconnectionReason="manual",this.socket.close()):void 0},e.prototype._scheduleReconnection=function(){return this._connectionDesired?this._reconnectTimer.running?void 0:(this._reconnectTimer.start(this._nextDelay),this._nextDelay=Math.min(this.options.maxdelay,2*this._nextDelay)):void 0},e.prototype.sendCommand=function(e){return null!=this.protocol?this._sendCommand(e):void 0},e.prototype._sendCommand=function(e){return this.socket.send(JSON.stringify(e))},e.prototype._closeOnError=function(){return this._handshakeTimeout.stop(),this._disconnectionReason="error",this.socket.close()},e.prototype._onopen=function(){var e;return this.handlers.socketConnected(),this._disconnectionReason="handshake-failed",e={command:"hello",protocols:[o,i]},e.ver=s,this.options.ext&&(e.ext=this.options.ext),this.options.extver&&(e.extver=this.options.extver),this.options.snipver&&(e.snipver=this.options.snipver),this._sendCommand(e),this._handshakeTimeout.start(this.options.handshake_timeout)},e.prototype._onclose=function(){return this.protocol=0,this.handlers.disconnected(this._disconnectionReason,this._nextDelay),this._scheduleReconnection()},e.prototype._onerror=function(){},e.prototype._onmessage=function(e){return this.protocolParser.process(e.data)},e}()}).call(this)},{"./protocol":6}],2:[function(e,t,n){(function(){var e;e={bind:function(e,t,n){if(e.addEventListener)return e.addEventListener(t,n,!1);if(e.attachEvent)return e[t]=1,e.attachEvent("onpropertychange",function(e){return e.propertyName===t?n():void 0});throw new Error("Attempt to attach custom event "+t+" to something which isn't a DOMElement")},fire:function(e,t){var n;if(e.addEventListener)return n=document.createEvent("HTMLEvents"),n.initEvent(t,!0,!0),document.dispatchEvent(n);if(!e.attachEvent)throw new Error("Attempt to fire custom event "+t+" on something which isn't a DOMElement");return e[t]?e[t]++:void 0}},n.bind=e.bind,n.fire=e.fire}).call(this)},{}],3:[function(e,t){(function(){var e;t.exports=e=function(){function e(e,t){this.window=e,this.host=t}return e.identifier="less",e.version="1.0",e.prototype.reload=function(e,t){if(this.window.less&&this.window.less.refresh){if(e.match(/\.less$/i))return this.reloadLess(e);if(t.originalPath.match(/\.less$/i))return this.reloadLess(t.originalPath)}return!1},e.prototype.reloadLess=function(){var e,t,n,o;if(t=function(){var t,n,o,i;for(o=document.getElementsByTagName("link"),i=[],t=0,n=o.length;n>t;t++)e=o[t],(e.href&&e.rel.match(/^stylesheet\/less$/i)||e.rel.match(/stylesheet/i)&&e.type.match(/^text\/(x-)?less$/i))&&i.push(e);return i}(),0===t.length)return!1;for(n=0,o=t.length;o>n;n++)e=t[n],e.href=this.host.generateCacheBustUrl(e.href);return this.host.console.log("LiveReload is asking LESS to recompile all stylesheets"),this.window.less.refresh(!0),!0},e.prototype.analyze=function(){return{disable:!(!this.window.less||!this.window.less.refresh)}},e}()}).call(this)},{}],4:[function(e,t,n){(function(){var t,o,i,r,s,l={}.hasOwnProperty;t=e("./connector").Connector,s=e("./timer").Timer,i=e("./options").Options,r=e("./reloader").Reloader,n.LiveReload=o=function(){function e(e){var n,o,c;if(this.window=e,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)}:{log:function(){},error:function(){}},!(this.WebSocket=this.window.WebSocket||this.window.MozWebSocket))return void this.console.error("LiveReload disabled because the browser does not seem to support web sockets");if("LiveReloadOptions"in e){this.options=new i,c=e.LiveReloadOptions;for(n in c)l.call(c,n)&&(o=c[n],this.options.set(n,o))}else if(this.options=i.extract(this.window.document),!this.options)return void this.console.error("LiveReload disabled because it could not find its own <SCRIPT> tag");this.reloader=new r(this.window,this.console,s),this.connector=new t(this.options,this.WebSocket,s,{connecting:function(){return function(){}}(this),socketConnected:function(){return function(){}}(this),connected:function(e){return function(t){var n;return"function"==typeof(n=e.listeners).connect&&n.connect(),e.log("LiveReload is connected to "+e.options.host+":"+e.options.port+" (protocol v"+t+")."),e.analyze()}}(this),error:function(){return function(e){if(e instanceof ProtocolError){if("undefined"!=typeof console&&null!==console)return console.log(""+e.message+".")}else if("undefined"!=typeof console&&null!==console)return console.log("LiveReload internal error: "+e.message)}}(this),disconnected:function(e){return function(t,n){var o;switch("function"==typeof(o=e.listeners).disconnect&&o.disconnect(),t){case"cannot-connect":return e.log("LiveReload cannot connect to "+e.options.host+":"+e.options.port+", will retry in "+n+" sec.");case"broken":return e.log("LiveReload disconnected from "+e.options.host+":"+e.options.port+", reconnecting in "+n+" sec.");case"handshake-timeout":return e.log("LiveReload cannot connect to "+e.options.host+":"+e.options.port+" (handshake timeout), will retry in "+n+" sec.");case"handshake-failed":return e.log("LiveReload cannot connect to "+e.options.host+":"+e.options.port+" (handshake failed), will retry in "+n+" sec.");case"manual":break;case"error":break;default:return e.log("LiveReload disconnected from "+e.options.host+":"+e.options.port+" ("+t+"), reconnecting in "+n+" sec.")}}}(this),message:function(e){return function(t){switch(t.command){case"reload":return e.performReload(t);case"alert":return e.performAlert(t)}}}(this)}),this.initialized=!0}return e.prototype.on=function(e,t){return this.listeners[e]=t},e.prototype.log=function(e){return this.console.log(""+e)},e.prototype.performReload=function(e){var t,n;return this.log("LiveReload received reload request: "+JSON.stringify(e,null,2)),this.reloader.reload(e.path,{liveCSS:null!=(t=e.liveCSS)?t:!0,liveImg:null!=(n=e.liveImg)?n:!0,originalPath:e.originalPath||"",overrideURL:e.overrideURL||"",serverURL:"http://"+this.options.host+":"+this.options.port})},e.prototype.performAlert=function(e){return alert(e.message)},e.prototype.shutDown=function(){var e;if(this.initialized)return this.connector.disconnect(),this.log("LiveReload disconnected."),"function"==typeof(e=this.listeners).shutdown?e.shutdown():void 0},e.prototype.hasPlugin=function(e){return!!this.pluginIdentifiers[e]},e.prototype.addPlugin=function(e){var t;this.initialized&&(this.hasPlugin(e.identifier)||(this.pluginIdentifiers[e.identifier]=!0,t=new e(this.window,{_livereload:this,_reloader:this.reloader,_connector:this.connector,console:this.console,Timer:s,generateCacheBustUrl:function(e){return function(t){return e.reloader.generateCacheBustUrl(t)}}(this)}),this.plugins.push(t),this.reloader.addPlugin(t)))},e.prototype.analyze=function(){var e,t,n,o,i,r;if(this.initialized&&this.connector.protocol>=7){for(n={},r=this.plugins,o=0,i=r.length;i>o;o++)e=r[o],n[e.constructor.identifier]=t=("function"==typeof e.analyze?e.analyze():void 0)||{},t.version=e.constructor.version;this.connector.sendCommand({command:"info",plugins:n,url:this.window.location.href})}},e}()}).call(this)},{"./connector":1,"./options":5,"./reloader":7,"./timer":9}],5:[function(e,t,n){(function(){var e;n.Options=e=function(){function e(){this.https=!1,this.host=null,this.port=35729,this.snipver=null,this.ext=null,this.extver=null,this.mindelay=1e3,this.maxdelay=6e4,this.handshake_timeout=5e3}return e.prototype.set=function(e,t){return"undefined"!=typeof t?(isNaN(+t)||(t=+t),this[e]=t):void 0},e}(),e.extract=function(t){var n,o,i,r,s,l,c,a,h,u,d,f,p;for(f=t.getElementsByTagName("script"),a=0,u=f.length;u>a;a++)if(n=f[a],(c=n.src)&&(i=c.match(/^[^:]+:\/\/(.*)\/z?livereload\.js(?:\?(.*))?$/))){if(s=new e,s.https=0===c.indexOf("https"),(r=i[1].match(/^([^\/:]+)(?::(\d+))?$/))&&(s.host=r[1],r[2]&&(s.port=parseInt(r[2],10))),i[2])for(p=i[2].split("&"),h=0,d=p.length;d>h;h++)l=p[h],(o=l.split("=")).length>1&&s.set(o[0].replace(/-/g,"_"),o.slice(1).join("="));return s}return null}}).call(this)},{}],6:[function(e,t,n){(function(){var e,t,o,i,r=[].indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(t in this&&this[t]===e)return t;return-1};n.PROTOCOL_6=e="http://livereload.com/protocols/official-6",n.PROTOCOL_7=t="http://livereload.com/protocols/official-7",n.ProtocolError=i=function(){function e(e,t){this.message="LiveReload protocol error ("+e+') after receiving data: "'+t+'".'}return e}(),n.Parser=o=function(){function n(e){this.handlers=e,this.reset()}return n.prototype.reset=function(){return this.protocol=null},n.prototype.process=function(n){var o,s,l,c,a;try{if(null==this.protocol){if(n.match(/^!!ver:([\d.]+)$/))this.protocol=6;else if(l=this._parseMessage(n,["hello"])){if(!l.protocols.length)throw new i("no protocols specified in handshake message");if(r.call(l.protocols,t)>=0)this.protocol=7;else{if(!(r.call(l.protocols,e)>=0))throw new i("no supported protocols found");this.protocol=6}}return this.handlers.connected(this.protocol)}if(6===this.protocol){if(l=JSON.parse(n),!l.length)throw new i("protocol 6 messages must be arrays");if(o=l[0],c=l[1],"refresh"!==o)throw new i("unknown protocol 6 command");return this.handlers.message({command:"reload",path:c.path,liveCSS:null!=(a=c.apply_css_live)?a:!0})}return l=this._parseMessage(n,["reload","alert"]),this.handlers.message(l)}catch(h){if(s=h,s instanceof i)return this.handlers.error(s);throw s}},n.prototype._parseMessage=function(e,t){var n,o,s;try{o=JSON.parse(e)}catch(l){throw n=l,new i("unparsable JSON",e)}if(!o.command)throw new i('missing "command" key',e);if(s=o.command,r.call(t,s)<0)throw new i("invalid command '"+o.command+"', only valid commands are: "+t.join(", ")+")",e);return o},n}()}).call(this)},{}],7:[function(e,t,n){(function(){var e,t,o,i,r,s,l;l=function(e){var t,n,o;return(n=e.indexOf("#"))>=0?(t=e.slice(n),e=e.slice(0,n)):t="",(n=e.indexOf("?"))>=0?(o=e.slice(n),e=e.slice(0,n)):o="",{url:e,params:o,hash:t}},i=function(e){var t;return e=l(e).url,t=0===e.indexOf("file://")?e.replace(/^file:\/\/(localhost)?/,""):e.replace(/^([^:]+:)?\/\/([^:\/]+)(:\d*)?\//,"/"),decodeURIComponent(t)},s=function(e,t,n){var i,r,s,l,c;for(i={score:0},l=0,c=t.length;c>l;l++)r=t[l],s=o(e,n(r)),s>i.score&&(i={object:r,score:s});return i.score>0?i:null},o=function(e,t){var n,o,i,r;if(e=e.replace(/^\/+/,"").toLowerCase(),t=t.replace(/^\/+/,"").toLowerCase(),e===t)return 1e4;for(n=e.split("/").reverse(),o=t.split("/").reverse(),r=Math.min(n.length,o.length),i=0;r>i&&n[i]===o[i];)++i;return i},r=function(e,t){return o(e,t)>0},e=[{selector:"background",styleNames:["backgroundImage"]},{selector:"border",styleNames:["borderImage","webkitBorderImage","MozBorderImage"]}],n.Reloader=t=function(){function t(e,t,n){this.window=e,this.console=t,this.Timer=n,this.document=this.window.document,this.importCacheWaitPeriod=200,this.plugins=[]}return t.prototype.addPlugin=function(e){return this.plugins.push(e)},t.prototype.analyze=function(){return results},t.prototype.reload=function(e,t){var n,o,i,r,s;for(this.options=t,null==(o=this.options).stylesheetReloadTimeout&&(o.stylesheetReloadTimeout=15e3),s=this.plugins,i=0,r=s.length;r>i;i++)if(n=s[i],n.reload&&n.reload(e,t))return;return t.liveCSS&&e.match(/\.css$/i)&&this.reloadStylesheet(e)?void 0:t.liveImg&&e.match(/\.(jpe?g|png|gif)$/i)?void this.reloadImages(e):this.reloadPage()},t.prototype.reloadPage=function(){return this.window.document.location.reload()},t.prototype.reloadImages=function(t){var n,o,s,l,c,a,h,u,d,f,p,m,g,v,y,w,R,_;for(n=this.generateUniqueString(),v=this.document.images,a=0,f=v.length;f>a;a++)o=v[a],r(t,i(o.src))&&(o.src=this.generateCacheBustUrl(o.src,n));if(this.document.querySelectorAll)for(h=0,p=e.length;p>h;h++)for(y=e[h],s=y.selector,l=y.styleNames,w=this.document.querySelectorAll("[style*="+s+"]"),u=0,m=w.length;m>u;u++)o=w[u],this.reloadStyleImages(o.style,l,t,n);if(this.document.styleSheets){for(R=this.document.styleSheets,_=[],d=0,g=R.length;g>d;d++)c=R[d],_.push(this.reloadStylesheetImages(c,t,n));return _}},t.prototype.reloadStylesheetImages=function(t,n,o){var i,r,s,l,c,a,h,u;try{s=null!=t?t.cssRules:void 0}catch(d){i=d}if(s)for(c=0,h=s.length;h>c;c++)switch(r=s[c],r.type){case CSSRule.IMPORT_RULE:this.reloadStylesheetImages(r.styleSheet,n,o);break;case CSSRule.STYLE_RULE:for(a=0,u=e.length;u>a;a++)l=e[a].styleNames,this.reloadStyleImages(r.style,l,n,o);break;case CSSRule.MEDIA_RULE:this.reloadStylesheetImages(r,n,o)}},t.prototype.reloadStyleImages=function(e,t,n,o){var s,l,c,a,h;for(a=0,h=t.length;h>a;a++)l=t[a],c=e[l],"string"==typeof c&&(s=c.replace(/\burl\s*\(([^)]*)\)/,function(e){return function(t,s){return r(n,i(s))?"url("+e.generateCacheBustUrl(s,o)+")":t}}(this)),s!==c&&(e[l]=s))},t.prototype.reloadStylesheet=function(e){var t,n,o,r,l,c,a,h,u,d,f,p,m,g,v;for(o=function(){var e,t,o,i;for(o=this.document.getElementsByTagName("link"),i=[],e=0,t=o.length;t>e;e++)n=o[e],n.rel.match(/^stylesheet$/i)&&!n.__LiveReload_pendingRemoval&&i.push(n);return i}.call(this),t=[],g=this.document.getElementsByTagName("style"),c=0,d=g.length;d>c;c++)l=g[c],l.sheet&&this.collectImportedStylesheets(l,l.sheet,t);for(a=0,f=o.length;f>a;a++)n=o[a],this.collectImportedStylesheets(n,n.sheet,t);if(this.window.StyleFix&&this.document.querySelectorAll)for(v=this.document.querySelectorAll("style[data-href]"),h=0,p=v.length;p>h;h++)l=v[h],o.push(l);if(this.console.log("LiveReload found "+o.length+" LINKed stylesheets, "+t.length+" @imported stylesheets"),r=s(e,o.concat(t),function(e){return function(t){return i(e.linkHref(t))}}(this)))r.object.rule?(this.console.log("LiveReload is reloading imported stylesheet: "+r.object.href),this.reattachImportedRule(r.object)):(this.console.log("LiveReload is reloading stylesheet: "+this.linkHref(r.object)),this.reattachStylesheetLink(r.object));else for(this.console.log("LiveReload will reload all stylesheets because path '"+e+"' did not match any specific one"),u=0,m=o.length;m>u;u++)n=o[u],this.reattachStylesheetLink(n);return!0},t.prototype.collectImportedStylesheets=function(e,t,n){var o,i,r,s,l,c;try{s=null!=t?t.cssRules:void 0}catch(a){o=a}if(s&&s.length)for(i=l=0,c=s.length;c>l;i=++l)switch(r=s[i],r.type){case CSSRule.CHARSET_RULE:continue;case CSSRule.IMPORT_RULE:n.push({link:e,rule:r,index:i,href:r.href}),this.collectImportedStylesheets(e,r.styleSheet,n)}},t.prototype.waitUntilCssLoads=function(e,t){var n,o,i;return n=!1,o=function(){return function(){return n?void 0:(n=!0,t())}}(this),e.onload=function(e){return function(){return e.console.log("LiveReload: the new stylesheet has finished loading"),e.knownToSupportCssOnLoad=!0,o()}}(this),this.knownToSupportCssOnLoad||(i=function(t){return function(){return e.sheet?(t.console.log("LiveReload is polling until the new CSS finishes loading..."),o()):t.Timer.start(50,i)}}(this))(),this.Timer.start(this.options.stylesheetReloadTimeout,o)},t.prototype.linkHref=function(e){return e.href||e.getAttribute("data-href")},t.prototype.reattachStylesheetLink=function(e){var t,n;if(!e.__LiveReload_pendingRemoval)return e.__LiveReload_pendingRemoval=!0,"STYLE"===e.tagName?(t=this.document.createElement("link"),t.rel="stylesheet",t.media=e.media,t.disabled=e.disabled):t=e.cloneNode(!1),t.href=this.generateCacheBustUrl(this.linkHref(e)),n=e.parentNode,n.lastChild===e?n.appendChild(t):n.insertBefore(t,e.nextSibling),this.waitUntilCssLoads(t,function(n){return function(){var o;return o=/AppleWebKit/.test(navigator.userAgent)?5:200,n.Timer.start(o,function(){var o;if(e.parentNode)return e.parentNode.removeChild(e),t.onreadystatechange=null,null!=(o=n.window.StyleFix)?o.link(t):void 0})}}(this))},t.prototype.reattachImportedRule=function(e){var t,n,o,i,r,s,l,c;return l=e.rule,n=e.index,o=e.link,s=l.parentStyleSheet,t=this.generateCacheBustUrl(l.href),i=l.media.length?[].join.call(l.media,", "):"",r='@import url("'+t+'") '+i+";",l.__LiveReload_newHref=t,c=this.document.createElement("link"),c.rel="stylesheet",c.href=t,c.__LiveReload_pendingRemoval=!0,o.parentNode&&o.parentNode.insertBefore(c,o),this.Timer.start(this.importCacheWaitPeriod,function(e){return function(){return c.parentNode&&c.parentNode.removeChild(c),l.__LiveReload_newHref===t?(s.insertRule(r,n),s.deleteRule(n+1),l=s.cssRules[n],l.__LiveReload_newHref=t,e.Timer.start(e.importCacheWaitPeriod,function(){return l.__LiveReload_newHref===t?(s.insertRule(r,n),s.deleteRule(n+1)):void 0})):void 0}}(this))},t.prototype.generateUniqueString=function(){return"livereload="+Date.now()},t.prototype.generateCacheBustUrl=function(e,t){var n,o,i,r,s;return null==t&&(t=this.generateUniqueString()),s=l(e),e=s.url,n=s.hash,o=s.params,this.options.overrideURL&&e.indexOf(this.options.serverURL)<0&&(i=e,e=this.options.serverURL+this.options.overrideURL+"?url="+encodeURIComponent(e),this.console.log("LiveReload is overriding source URL "+i+" with "+e)),r=o.replace(/(\?|&)livereload=(\d+)/,function(e,n){return""+n+t}),r===o&&(r=0===o.length?"?"+t:""+o+"&"+t),e+r+n},t}()}).call(this)},{}],8:[function(e){(function(){var t,n,o;t=e("./customevents"),n=window.LiveReload=new(e("./livereload").LiveReload)(window);for(o in window)o.match(/^LiveReloadPlugin/)&&n.addPlugin(window[o]);n.addPlugin(e("./less")),n.on("shutdown",function(){return delete window.LiveReload}),n.on("connect",function(){return t.fire(document,"LiveReloadConnect")}),n.on("disconnect",function(){return t.fire(document,"LiveReloadDisconnect")}),t.bind(document,"LiveReloadShutDown",function(){return n.shutDown()})}).call(this)},{"./customevents":2,"./less":3,"./livereload":4}],9:[function(e,t,n){(function(){var e;n.Timer=e=function(){function e(e){this.func=e,this.running=!1,this.id=null,this._handler=function(e){return function(){return e.running=!1,e.id=null,e.func()}}(this)}return e.prototype.start=function(e){return this.running&&clearTimeout(this.id),this.id=setTimeout(this._handler,e),this.running=!0},e.prototype.stop=function(){return this.running?(clearTimeout(this.id),this.running=!1,this.id=null):void 0},e}(),e.start=function(e,t){return setTimeout(t,e)}}).call(this)},{}]},{},[8]);`)