Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

browser-sync-client

Package Overview
Dependencies
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-sync-client - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

9

dist/index.js

@@ -160,3 +160,3 @@ (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);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

* @param opts
* @returns {{elem: *, timeStamp: number}}
* @returns {{elem: HTMLElement, timeStamp: number}}
*/

@@ -1196,8 +1196,11 @@ exports.swapFile = function (elem, attr, opts) {

elem = document.createElement("DIV");
elem.id = "notifyElem";
elem.id = "__bs_notify__";
elem.style.cssText = cssStyles.join(";");
document.getElementsByTagName("body")[0].appendChild(elem);
browserSync.emitter.on("notify", exports.watchEvent());
var flashFn = exports.watchEvent();
browserSync.emitter.on("notify", flashFn);
browserSync.socket.on("browser:notify", flashFn);
return elem;

@@ -1204,0 +1207,0 @@ };

@@ -1,1 +0,1 @@

!function t(e,n,o){function i(c,s){if(!n[c]){if(!e[c]){var a="function"==typeof require&&require;if(!s&&a)return a(c,!0);if(r)return r(c,!0);throw new Error("Cannot find module '"+c+"'")}var u=n[c]={exports:{}};e[c][0].call(u.exports,function(t){var n=e[c][1][t];return i(n?n:t)},u,u.exports,t,e,n,o)}return n[c].exports}for(var r="function"==typeof require&&require,c=0;c<o.length;c++)i(o[c]);return i}({1:[function(t,e,n){"use strict";n.getWindow=function(){return window},n.getDocument=function(){return document},n.utils={getBrowserScrollPosition:function(){var t,e,o=n.getWindow(),i=n.getDocument(),r=i.documentElement,c=i.body;return void 0!==o.pageYOffset?(t=o.pageXOffset,e=o.pageYOffset):(t=r.scrollLeft||c.scrollLeft||0,e=r.scrollTop||c.scrollTop||0),{x:t,y:e}},getScrollSpace:function(){var t=n.getDocument(),e=t.documentElement,o=t.body;return{x:o.scrollHeight-e.clientWidth,y:o.scrollHeight-e.clientHeight}},getElementIndex:function(t,e){var n=document.getElementsByTagName(t);return Array.prototype.indexOf.call(n,e)},forceChange:function(t){t.blur(),t.focus()},getElementData:function(t){var e=t.tagName,o=n.utils.getElementIndex(e,t);return{tagName:e,index:o}},getSingleElement:function(t,e){var n=document.getElementsByTagName(t);return n[e]},getBody:function(){return document.getElementsByTagName("body")[0]}}},{}],2:[function(){"indexOf"in Array.prototype||(Array.prototype.indexOf=function(t,e){void 0===e&&(e=0),0>e&&(e+=this.length),0>e&&(e=0);for(var n=this.length;n>e;e+=1)if(e in this&&this[e]===t)return e;return-1})},{}],3:[function(t,e,n){"use strict";var o={tagNames:{css:"link",jpg:"img",jpeg:"img",png:"img",svg:"img",gif:"img",js:"script"},attrs:{link:"href",img:"src",script:"src"}};n.init=function(t){t.socket.on("file:reload",n.reload(t)),t.socket.on("browser:reload",function(){n.reloadBrowser(!0)})},n.swapFile=function(t,e,n){var o=t[e],i=(new Date).getTime(),r="?rel="+i,c=/^[^\?]+(?=\?)/.exec(o);return c&&(o=c[0]),n&&(n.timestamps||(r="")),t[e]=o+r,{elem:t,timeStamp:i}},n.reload=function(t){return function(e){var o,i=t.opts,r=t.emitter;if((e.url||!i.injectChanges)&&n.reloadBrowser(!0),e.assetFileName&&e.fileExtension){var c=n.getElems(e.fileExtension),s=n.getMatches(c.elems,e.assetFileName,c.attr);s.length&&i.notify&&r.emit("notify",{message:"Injected: "+e.assetFileName});for(var a=0,u=s.length;u>a;a+=1)o=n.swapFile(s[a],c.attr,i)}return o}},n.getTagName=function(t){return o.tagNames[t]},n.getAttr=function(t){return o.attrs[t]},n.getMatches=function(t,e,n){for(var o=[],i=0,r=t.length;r>i;i+=1)-1!==t[i][n].indexOf(e)&&o.push(t[i]);return o},n.getElems=function(t){var e=n.getTagName(t),o=n.getAttr(e);return{elems:document.getElementsByTagName(e),attr:o}},n.getWindow=function(){return window},n.reloadBrowser=function(t){var e=n.getWindow();t&&e.location.reload(!0)}},{}],4:[function(t,e,n){"use strict";n.events={},n.emit=function(t,e){var o,i=n.events[t];if(i&&i.listeners){o=i.listeners;for(var r=0,c=o.length;c>r;r+=1)o[r](e)}},n.on=function(t,e){var o=n.events;o[t]?o[t].listeners.push(e):o[t]={listeners:[e]}}},{}],5:[function(t,e,n){n._ElementCache=function(){var t={},e=1,n="data"+(new Date).getTime();this.getData=function(o){var i=o[n];return i||(i=o[n]=e++,t[i]={}),t[i]},this.removeData=function(e){var o=e[n];if(o){delete t[o];try{delete e[n]}catch(i){e.removeAttribute&&e.removeAttribute(n)}}}},n._fixEvent=function(t){function e(){return!0}function n(){return!1}if(!t||!t.stopPropagation){var o=t||window.event;t={};for(var i in o)t[i]=o[i];if(t.target||(t.target=t.srcElement||document),t.relatedTarget=t.fromElement===t.target?t.toElement:t.fromElement,t.preventDefault=function(){t.returnValue=!1,t.isDefaultPrevented=e},t.isDefaultPrevented=n,t.stopPropagation=function(){t.cancelBubble=!0,t.isPropagationStopped=e},t.isPropagationStopped=n,t.stopImmediatePropagation=function(){this.isImmediatePropagationStopped=e,this.stopPropagation()},t.isImmediatePropagationStopped=n,null!=t.clientX){var r=document.documentElement,c=document.body;t.pageX=t.clientX+(r&&r.scrollLeft||c&&c.scrollLeft||0)-(r&&r.clientLeft||c&&c.clientLeft||0),t.pageY=t.clientY+(r&&r.scrollTop||c&&c.scrollTop||0)-(r&&r.clientTop||c&&c.clientTop||0)}t.which=t.charCode||t.keyCode,null!=t.button&&(t.button=1&t.button?0:4&t.button?1:2&t.button?2:0)}return t},n._EventManager=function(t){function e(e,n){function o(t){for(var e in t)return!1;return!0}var i=t.getData(e);0===i.handlers[n].length&&(delete i.handlers[n],document.removeEventListener?e.removeEventListener(n,i.dispatcher,!1):document.detachEvent&&e.detachEvent("on"+n,i.dispatcher)),o(i.handlers)&&(delete i.handlers,delete i.dispatcher),o(i)&&t.removeData(e)}var o=1;this.addEvent=function(e,i,r){var c=t.getData(e);c.handlers||(c.handlers={}),c.handlers[i]||(c.handlers[i]=[]),r.guid||(r.guid=o++),c.handlers[i].push(r),c.dispatcher||(c.disabled=!1,c.dispatcher=function(t){if(!c.disabled){t=n._fixEvent(t);var o=c.handlers[t.type];if(o)for(var i=0;i<o.length;i++)o[i].call(e,t)}}),1==c.handlers[i].length&&(document.addEventListener?e.addEventListener(i,c.dispatcher,!1):document.attachEvent&&e.attachEvent("on"+i,c.dispatcher))},this.removeEvent=function(n,o,i){var r=t.getData(n);if(r.handlers){var c=function(t){r.handlers[t]=[],e(n,t)};if(o){var s=r.handlers[o];if(s){if(!i)return void c(o);if(i.guid)for(var a=0;a<s.length;a++)s[a].guid===i.guid&&s.splice(a--,1);e(n,o)}}else for(var u in r.handlers)c(u)}},this.proxy=function(t,e){e.guid||(e.guid=o++);var n=function(){return e.apply(t,arguments)};return n.guid=e.guid,n}},n.triggerClick=function(t){var e;document.createEvent?(e=document.createEvent("MouseEvents"),e.initEvent("click",!0,!0),t.dispatchEvent(e)):document.createEventObject&&(e=document.createEventObject(),e.cancelBubble=!0,t.fireEvent("onclick",e))};var o=new n._ElementCache,i=new n._EventManager(o);i.triggerClick=n.triggerClick,n.manager=i},{}],6:[function(t,e,n){"use strict";var o=t("./socket"),i=(t("./client-shims"),t("./notify")),r=t("./code-sync"),c=t("./ghostmode"),s=t("./emitter"),a=t("./browser.utils"),u=function(){this.socket=o,this.emitter=s,this.utils=a.utils};u.prototype.canSync=function(t){return t.url===window.location.pathname};var l;n.init=function(t){l=new u,l.opts=t,t.notify&&(i.init(l),i.flash("Connected to BrowserSync :)")),t.ghostMode&&c.init(l),t.codeSync&&r.init(l)},o.on("connection",n.init)},{"./browser.utils":1,"./client-shims":2,"./code-sync":3,"./emitter":4,"./ghostmode":12,"./ghostmode.clicks":7,"./ghostmode.forms":9,"./ghostmode.forms.input":8,"./ghostmode.forms.submit":10,"./ghostmode.forms.toggles":11,"./ghostmode.location":13,"./ghostmode.scroll":14,"./notify":15,"./socket":16}],7:[function(t,e,n){"use strict";var o="click";n.canEmitEvents=!0,n.init=function(t,e){e.addEvent(document.body,o,n.browserEvent(t)),t.socket.on(o,n.socketEvent(t,e))},n.browserEvent=function(t){return function(e){if(n.canEmitEvents){var i=e.target||e.srcElement;if("checkbox"===i.type||"radio"===i.type)return void t.utils.forceChange(i);t.socket.emit(o,t.utils.getElementData(i))}else n.canEmitEvents=!0}},n.socketEvent=function(t,e){return function(o){if(t.canSync(o)){var i=t.utils.getSingleElement(o.tagName,o.index);i&&(n.canEmitEvents=!1,e.triggerClick(i))}}}},{}],8:[function(t,e,n){"use strict";var o="input:text";n.canEmitEvents=!0,n.init=function(t,e){e.addEvent(document.body,"keyup",n.browserEvent(t)),t.socket.on(o,n.socketEvent(t,e))},n.browserEvent=function(t){return function(e){var i,r=e.target||e.srcElement;n.canEmitEvents?("INPUT"===r.tagName||"TEXTAREA"===r.tagName)&&(i=t.utils.getElementData(r),i.value=r.value,t.socket.emit(o,i)):n.canEmitEvents=!0}},n.socketEvent=function(t){return function(e){if(t.canSync(e)){var n=t.utils.getSingleElement(e.tagName,e.index);if(n)return n.value=e.value,n}return!1}}},{}],9:[function(t,e,n){"use strict";n.plugins={inputs:t("./ghostmode.forms.input"),toggles:t("./ghostmode.forms.toggles"),submit:t("./ghostmode.forms.submit")},n.init=function(t,e){function o(o){n.plugins[o].init(t,e)}var i=!0,r=t.opts.ghostMode.forms;r===!0&&(i=!1);for(var c in n.plugins)i?r[c]&&o(c):o(c)}},{"./ghostmode.forms.input":8,"./ghostmode.forms.submit":10,"./ghostmode.forms.toggles":11}],10:[function(t,e,n){"use strict";var o="form:submit";n.canEmitEvents=!0,n.init=function(t,e){var i=n.browserEvent(t);e.addEvent(document.body,"submit",i),e.addEvent(document.body,"reset",i),t.socket.on(o,n.socketEvent(t,e))},n.browserEvent=function(t){return function(e){if(n.canEmitEvents){var i=e.target||e.srcElement,r=t.utils.getElementData(i);r.type=e.type,t.socket.emit(o,r)}else n.canEmitEvents=!0}},n.socketEvent=function(t){return function(e){if(t.canSync(e)){var o=t.utils.getSingleElement(e.tagName,e.index);return n.canEmitEvents=!1,o&&"submit"===e.type&&o.submit(),o&&"reset"===e.type&&o.reset(),!1}return!1}}},{}],11:[function(t,e,n){"use strict";var o="input:toggles";n.canEmitEvents=!0,n.init=function(t,e){var i=n.browserEvent(t);n.addEvents(e,i),t.socket.on(o,n.socketEvent(t,e))},n.addEvents=function(t,e){function n(n){for(var o=0,i=n.length;i>o;o+=1)t.addEvent(n[o],"change",e)}var o=document.getElementsByTagName("select"),i=document.getElementsByTagName("input");n(o),n(i)},n.browserEvent=function(t){return function(e){if(n.canEmitEvents){var i,r=e.target||e.srcElement;("radio"===r.type||"checkbox"===r.type||"SELECT"===r.tagName)&&(i=t.utils.getElementData(r),i.type=r.type,i.value=r.value,i.checked=r.checked,t.socket.emit(o,i))}else n.canEmitEvents=!0}},n.socketEvent=function(t){return function(e){if(t.canSync(e)){n.canEmitEvents=!1;var o=t.utils.getSingleElement(e.tagName,e.index);return o?("radio"===e.type&&(o.checked=!0),"checkbox"===e.type&&(o.checked=e.checked),"SELECT"===e.tagName&&(o.value=e.value),o):!1}return!1}}},{}],12:[function(t,e,n){"use strict";var o=t("./events").manager;n.plugins={scroll:t("./ghostmode.scroll"),clicks:t("./ghostmode.clicks"),forms:t("./ghostmode.forms"),location:t("./ghostmode.location")},n.init=function(t){function e(e){n.plugins[e].init(t,o)}var i=t.opts.ghostMode;for(var r in n.plugins)i[r]&&e(r)}},{"./events":5,"./ghostmode.clicks":7,"./ghostmode.forms":9,"./ghostmode.location":13,"./ghostmode.scroll":14}],13:[function(t,e,n){"use strict";var o="location";n.canEmitEvents=!0,n.init=function(t){t.socket.on(o,n.socketEvent())},n.socketEvent=function(){return function(t){window.location=t.url}}},{}],14:[function(t,e,n){"use strict";var o,i="scroll";n.canEmitEvents=!0,n.init=function(t,e){o=t.utils,e.addEvent(window,i,n.browserEvent(t)),t.socket.on(i,n.socketEvent(t))},n.socketEvent=function(t){return function(e){var i=o.getScrollSpace();return n.canEmitEvents=!1,t.canSync(e)?t.opts&&t.opts.scrollProportionally?window.scrollTo(0,i.y*e.position.proportional):window.scrollTo(0,e.position.raw):!1}},n.browserEvent=function(t){return function(){var e=n.canEmitEvents;e&&t.socket.emit(i,{position:n.getScrollPosition()}),n.canEmitEvents=!0}},n.getScrollPosition=function(){var t=o.getBrowserScrollPosition();return{raw:t,proportional:n.getScrollTopPercentage(t)}},n.getScrollPercentage=function(t,e){var n=e.x/t.x,o=e.y/t.y;return{x:n||0,y:o}},n.getScrollTopPercentage=function(t){var e=o.getScrollSpace(),i=n.getScrollPercentage(e,t);return i.y}},{}],15:[function(t,e,n){"use strict";var o,i,r,c=(t("./ghostmode.scroll"),["background-color: black","color: white","padding: 10px","display: none","font-family: sans-serif","position: absolute","z-index: 9999","right: 0px","border-bottom-left-radius: 5px"]);n.init=function(t){o=t,r=t.opts;var e=c;return r.notify.styles&&(e=r.notify.styles),i=document.createElement("DIV"),i.id="notifyElem",i.style.cssText=e.join(";"),document.getElementsByTagName("body")[0].appendChild(i),o.emitter.on("notify",n.watchEvent()),i},n.watchEvent=function(){return function(t){n.flash(t.message)}},n.getElem=function(){return i},n.getScrollTop=function(){return o.utils.getBrowserScrollPosition().y},n.flash=function(t,e){var o=n.getElem();if(!o)return!1;var i=document.getElementsByTagName("HTML")[0];return i.style.position="relative",o.innerHTML=t,o.style.top=n.getScrollTop()+"px",o.style.display="block",window.setTimeout(function(){o.style.display="none"},e||2e3),o}},{"./ghostmode.scroll":14}],16:[function(t,e,n){"use strict";n.socket=window.___socket___||{emit:function(){},on:function(){}},n.getPath=function(){return window.location.pathname},n.emit=function(t,e){var o=n.socket;o&&o.emit&&(e.url=n.getPath(),o.emit(t,e))},n.on=function(t,e){n.socket.on(t,e)}},{}]},{},[6]);
!function t(e,n,o){function i(c,s){if(!n[c]){if(!e[c]){var a="function"==typeof require&&require;if(!s&&a)return a(c,!0);if(r)return r(c,!0);throw new Error("Cannot find module '"+c+"'")}var u=n[c]={exports:{}};e[c][0].call(u.exports,function(t){var n=e[c][1][t];return i(n?n:t)},u,u.exports,t,e,n,o)}return n[c].exports}for(var r="function"==typeof require&&require,c=0;c<o.length;c++)i(o[c]);return i}({1:[function(t,e,n){"use strict";n.getWindow=function(){return window},n.getDocument=function(){return document},n.utils={getBrowserScrollPosition:function(){var t,e,o=n.getWindow(),i=n.getDocument(),r=i.documentElement,c=i.body;return void 0!==o.pageYOffset?(t=o.pageXOffset,e=o.pageYOffset):(t=r.scrollLeft||c.scrollLeft||0,e=r.scrollTop||c.scrollTop||0),{x:t,y:e}},getScrollSpace:function(){var t=n.getDocument(),e=t.documentElement,o=t.body;return{x:o.scrollHeight-e.clientWidth,y:o.scrollHeight-e.clientHeight}},getElementIndex:function(t,e){var n=document.getElementsByTagName(t);return Array.prototype.indexOf.call(n,e)},forceChange:function(t){t.blur(),t.focus()},getElementData:function(t){var e=t.tagName,o=n.utils.getElementIndex(e,t);return{tagName:e,index:o}},getSingleElement:function(t,e){var n=document.getElementsByTagName(t);return n[e]},getBody:function(){return document.getElementsByTagName("body")[0]}}},{}],2:[function(){"indexOf"in Array.prototype||(Array.prototype.indexOf=function(t,e){void 0===e&&(e=0),0>e&&(e+=this.length),0>e&&(e=0);for(var n=this.length;n>e;e+=1)if(e in this&&this[e]===t)return e;return-1})},{}],3:[function(t,e,n){"use strict";var o={tagNames:{css:"link",jpg:"img",jpeg:"img",png:"img",svg:"img",gif:"img",js:"script"},attrs:{link:"href",img:"src",script:"src"}};n.init=function(t){t.socket.on("file:reload",n.reload(t)),t.socket.on("browser:reload",function(){n.reloadBrowser(!0)})},n.swapFile=function(t,e,n){var o=t[e],i=(new Date).getTime(),r="?rel="+i,c=/^[^\?]+(?=\?)/.exec(o);return c&&(o=c[0]),n&&(n.timestamps||(r="")),t[e]=o+r,{elem:t,timeStamp:i}},n.reload=function(t){return function(e){var o,i=t.opts,r=t.emitter;if((e.url||!i.injectChanges)&&n.reloadBrowser(!0),e.assetFileName&&e.fileExtension){var c=n.getElems(e.fileExtension),s=n.getMatches(c.elems,e.assetFileName,c.attr);s.length&&i.notify&&r.emit("notify",{message:"Injected: "+e.assetFileName});for(var a=0,u=s.length;u>a;a+=1)o=n.swapFile(s[a],c.attr,i)}return o}},n.getTagName=function(t){return o.tagNames[t]},n.getAttr=function(t){return o.attrs[t]},n.getMatches=function(t,e,n){for(var o=[],i=0,r=t.length;r>i;i+=1)-1!==t[i][n].indexOf(e)&&o.push(t[i]);return o},n.getElems=function(t){var e=n.getTagName(t),o=n.getAttr(e);return{elems:document.getElementsByTagName(e),attr:o}},n.getWindow=function(){return window},n.reloadBrowser=function(t){var e=n.getWindow();t&&e.location.reload(!0)}},{}],4:[function(t,e,n){"use strict";n.events={},n.emit=function(t,e){var o,i=n.events[t];if(i&&i.listeners){o=i.listeners;for(var r=0,c=o.length;c>r;r+=1)o[r](e)}},n.on=function(t,e){var o=n.events;o[t]?o[t].listeners.push(e):o[t]={listeners:[e]}}},{}],5:[function(t,e,n){n._ElementCache=function(){var t={},e=1,n="data"+(new Date).getTime();this.getData=function(o){var i=o[n];return i||(i=o[n]=e++,t[i]={}),t[i]},this.removeData=function(e){var o=e[n];if(o){delete t[o];try{delete e[n]}catch(i){e.removeAttribute&&e.removeAttribute(n)}}}},n._fixEvent=function(t){function e(){return!0}function n(){return!1}if(!t||!t.stopPropagation){var o=t||window.event;t={};for(var i in o)t[i]=o[i];if(t.target||(t.target=t.srcElement||document),t.relatedTarget=t.fromElement===t.target?t.toElement:t.fromElement,t.preventDefault=function(){t.returnValue=!1,t.isDefaultPrevented=e},t.isDefaultPrevented=n,t.stopPropagation=function(){t.cancelBubble=!0,t.isPropagationStopped=e},t.isPropagationStopped=n,t.stopImmediatePropagation=function(){this.isImmediatePropagationStopped=e,this.stopPropagation()},t.isImmediatePropagationStopped=n,null!=t.clientX){var r=document.documentElement,c=document.body;t.pageX=t.clientX+(r&&r.scrollLeft||c&&c.scrollLeft||0)-(r&&r.clientLeft||c&&c.clientLeft||0),t.pageY=t.clientY+(r&&r.scrollTop||c&&c.scrollTop||0)-(r&&r.clientTop||c&&c.clientTop||0)}t.which=t.charCode||t.keyCode,null!=t.button&&(t.button=1&t.button?0:4&t.button?1:2&t.button?2:0)}return t},n._EventManager=function(t){function e(e,n){function o(t){for(var e in t)return!1;return!0}var i=t.getData(e);0===i.handlers[n].length&&(delete i.handlers[n],document.removeEventListener?e.removeEventListener(n,i.dispatcher,!1):document.detachEvent&&e.detachEvent("on"+n,i.dispatcher)),o(i.handlers)&&(delete i.handlers,delete i.dispatcher),o(i)&&t.removeData(e)}var o=1;this.addEvent=function(e,i,r){var c=t.getData(e);c.handlers||(c.handlers={}),c.handlers[i]||(c.handlers[i]=[]),r.guid||(r.guid=o++),c.handlers[i].push(r),c.dispatcher||(c.disabled=!1,c.dispatcher=function(t){if(!c.disabled){t=n._fixEvent(t);var o=c.handlers[t.type];if(o)for(var i=0;i<o.length;i++)o[i].call(e,t)}}),1==c.handlers[i].length&&(document.addEventListener?e.addEventListener(i,c.dispatcher,!1):document.attachEvent&&e.attachEvent("on"+i,c.dispatcher))},this.removeEvent=function(n,o,i){var r=t.getData(n);if(r.handlers){var c=function(t){r.handlers[t]=[],e(n,t)};if(o){var s=r.handlers[o];if(s){if(!i)return void c(o);if(i.guid)for(var a=0;a<s.length;a++)s[a].guid===i.guid&&s.splice(a--,1);e(n,o)}}else for(var u in r.handlers)c(u)}},this.proxy=function(t,e){e.guid||(e.guid=o++);var n=function(){return e.apply(t,arguments)};return n.guid=e.guid,n}},n.triggerClick=function(t){var e;document.createEvent?(e=document.createEvent("MouseEvents"),e.initEvent("click",!0,!0),t.dispatchEvent(e)):document.createEventObject&&(e=document.createEventObject(),e.cancelBubble=!0,t.fireEvent("onclick",e))};var o=new n._ElementCache,i=new n._EventManager(o);i.triggerClick=n.triggerClick,n.manager=i},{}],6:[function(t,e,n){"use strict";var o=t("./socket"),i=(t("./client-shims"),t("./notify")),r=t("./code-sync"),c=t("./ghostmode"),s=t("./emitter"),a=t("./browser.utils"),u=function(){this.socket=o,this.emitter=s,this.utils=a.utils};u.prototype.canSync=function(t){return t.url===window.location.pathname};var l;n.init=function(t){l=new u,l.opts=t,t.notify&&(i.init(l),i.flash("Connected to BrowserSync :)")),t.ghostMode&&c.init(l),t.codeSync&&r.init(l)},o.on("connection",n.init)},{"./browser.utils":1,"./client-shims":2,"./code-sync":3,"./emitter":4,"./ghostmode":12,"./ghostmode.clicks":7,"./ghostmode.forms":9,"./ghostmode.forms.input":8,"./ghostmode.forms.submit":10,"./ghostmode.forms.toggles":11,"./ghostmode.location":13,"./ghostmode.scroll":14,"./notify":15,"./socket":16}],7:[function(t,e,n){"use strict";var o="click";n.canEmitEvents=!0,n.init=function(t,e){e.addEvent(document.body,o,n.browserEvent(t)),t.socket.on(o,n.socketEvent(t,e))},n.browserEvent=function(t){return function(e){if(n.canEmitEvents){var i=e.target||e.srcElement;if("checkbox"===i.type||"radio"===i.type)return void t.utils.forceChange(i);t.socket.emit(o,t.utils.getElementData(i))}else n.canEmitEvents=!0}},n.socketEvent=function(t,e){return function(o){if(t.canSync(o)){var i=t.utils.getSingleElement(o.tagName,o.index);i&&(n.canEmitEvents=!1,e.triggerClick(i))}}}},{}],8:[function(t,e,n){"use strict";var o="input:text";n.canEmitEvents=!0,n.init=function(t,e){e.addEvent(document.body,"keyup",n.browserEvent(t)),t.socket.on(o,n.socketEvent(t,e))},n.browserEvent=function(t){return function(e){var i,r=e.target||e.srcElement;n.canEmitEvents?("INPUT"===r.tagName||"TEXTAREA"===r.tagName)&&(i=t.utils.getElementData(r),i.value=r.value,t.socket.emit(o,i)):n.canEmitEvents=!0}},n.socketEvent=function(t){return function(e){if(t.canSync(e)){var n=t.utils.getSingleElement(e.tagName,e.index);if(n)return n.value=e.value,n}return!1}}},{}],9:[function(t,e,n){"use strict";n.plugins={inputs:t("./ghostmode.forms.input"),toggles:t("./ghostmode.forms.toggles"),submit:t("./ghostmode.forms.submit")},n.init=function(t,e){function o(o){n.plugins[o].init(t,e)}var i=!0,r=t.opts.ghostMode.forms;r===!0&&(i=!1);for(var c in n.plugins)i?r[c]&&o(c):o(c)}},{"./ghostmode.forms.input":8,"./ghostmode.forms.submit":10,"./ghostmode.forms.toggles":11}],10:[function(t,e,n){"use strict";var o="form:submit";n.canEmitEvents=!0,n.init=function(t,e){var i=n.browserEvent(t);e.addEvent(document.body,"submit",i),e.addEvent(document.body,"reset",i),t.socket.on(o,n.socketEvent(t,e))},n.browserEvent=function(t){return function(e){if(n.canEmitEvents){var i=e.target||e.srcElement,r=t.utils.getElementData(i);r.type=e.type,t.socket.emit(o,r)}else n.canEmitEvents=!0}},n.socketEvent=function(t){return function(e){if(t.canSync(e)){var o=t.utils.getSingleElement(e.tagName,e.index);return n.canEmitEvents=!1,o&&"submit"===e.type&&o.submit(),o&&"reset"===e.type&&o.reset(),!1}return!1}}},{}],11:[function(t,e,n){"use strict";var o="input:toggles";n.canEmitEvents=!0,n.init=function(t,e){var i=n.browserEvent(t);n.addEvents(e,i),t.socket.on(o,n.socketEvent(t,e))},n.addEvents=function(t,e){function n(n){for(var o=0,i=n.length;i>o;o+=1)t.addEvent(n[o],"change",e)}var o=document.getElementsByTagName("select"),i=document.getElementsByTagName("input");n(o),n(i)},n.browserEvent=function(t){return function(e){if(n.canEmitEvents){var i,r=e.target||e.srcElement;("radio"===r.type||"checkbox"===r.type||"SELECT"===r.tagName)&&(i=t.utils.getElementData(r),i.type=r.type,i.value=r.value,i.checked=r.checked,t.socket.emit(o,i))}else n.canEmitEvents=!0}},n.socketEvent=function(t){return function(e){if(t.canSync(e)){n.canEmitEvents=!1;var o=t.utils.getSingleElement(e.tagName,e.index);return o?("radio"===e.type&&(o.checked=!0),"checkbox"===e.type&&(o.checked=e.checked),"SELECT"===e.tagName&&(o.value=e.value),o):!1}return!1}}},{}],12:[function(t,e,n){"use strict";var o=t("./events").manager;n.plugins={scroll:t("./ghostmode.scroll"),clicks:t("./ghostmode.clicks"),forms:t("./ghostmode.forms"),location:t("./ghostmode.location")},n.init=function(t){function e(e){n.plugins[e].init(t,o)}var i=t.opts.ghostMode;for(var r in n.plugins)i[r]&&e(r)}},{"./events":5,"./ghostmode.clicks":7,"./ghostmode.forms":9,"./ghostmode.location":13,"./ghostmode.scroll":14}],13:[function(t,e,n){"use strict";var o="location";n.canEmitEvents=!0,n.init=function(t){t.socket.on(o,n.socketEvent())},n.socketEvent=function(){return function(t){window.location=t.url}}},{}],14:[function(t,e,n){"use strict";var o,i="scroll";n.canEmitEvents=!0,n.init=function(t,e){o=t.utils,e.addEvent(window,i,n.browserEvent(t)),t.socket.on(i,n.socketEvent(t))},n.socketEvent=function(t){return function(e){var i=o.getScrollSpace();return n.canEmitEvents=!1,t.canSync(e)?t.opts&&t.opts.scrollProportionally?window.scrollTo(0,i.y*e.position.proportional):window.scrollTo(0,e.position.raw):!1}},n.browserEvent=function(t){return function(){var e=n.canEmitEvents;e&&t.socket.emit(i,{position:n.getScrollPosition()}),n.canEmitEvents=!0}},n.getScrollPosition=function(){var t=o.getBrowserScrollPosition();return{raw:t,proportional:n.getScrollTopPercentage(t)}},n.getScrollPercentage=function(t,e){var n=e.x/t.x,o=e.y/t.y;return{x:n||0,y:o}},n.getScrollTopPercentage=function(t){var e=o.getScrollSpace(),i=n.getScrollPercentage(e,t);return i.y}},{}],15:[function(t,e,n){"use strict";var o,i,r,c=(t("./ghostmode.scroll"),["background-color: black","color: white","padding: 10px","display: none","font-family: sans-serif","position: absolute","z-index: 9999","right: 0px","border-bottom-left-radius: 5px"]);n.init=function(t){o=t,r=t.opts;var e=c;r.notify.styles&&(e=r.notify.styles),i=document.createElement("DIV"),i.id="__bs_notify__",i.style.cssText=e.join(";"),document.getElementsByTagName("body")[0].appendChild(i);var s=n.watchEvent();return o.emitter.on("notify",s),o.socket.on("browser:notify",s),i},n.watchEvent=function(){return function(t){n.flash(t.message)}},n.getElem=function(){return i},n.getScrollTop=function(){return o.utils.getBrowserScrollPosition().y},n.flash=function(t,e){var o=n.getElem();if(!o)return!1;var i=document.getElementsByTagName("HTML")[0];return i.style.position="relative",o.innerHTML=t,o.style.top=n.getScrollTop()+"px",o.style.display="block",window.setTimeout(function(){o.style.display="none"},e||2e3),o}},{"./ghostmode.scroll":14}],16:[function(t,e,n){"use strict";n.socket=window.___socket___||{emit:function(){},on:function(){}},n.getPath=function(){return window.location.pathname},n.emit=function(t,e){var o=n.socket;o&&o.emit&&(e.url=n.getPath(),o.emit(t,e))},n.on=function(t,e){n.socket.on(t,e)}},{}]},{},[6]);

@@ -35,3 +35,3 @@ "use strict";

* @param opts
* @returns {{elem: *, timeStamp: number}}
* @returns {{elem: HTMLElement, timeStamp: number}}
*/

@@ -38,0 +38,0 @@ exports.swapFile = function (elem, attr, opts) {

@@ -37,8 +37,11 @@ "use strict";

elem = document.createElement("DIV");
elem.id = "notifyElem";
elem.id = "__bs_notify__";
elem.style.cssText = cssStyles.join(";");
document.getElementsByTagName("body")[0].appendChild(elem);
browserSync.emitter.on("notify", exports.watchEvent());
var flashFn = exports.watchEvent();
browserSync.emitter.on("notify", flashFn);
browserSync.socket.on("browser:notify", flashFn);
return elem;

@@ -45,0 +48,0 @@ };

{
"name": "browser-sync-client",
"description": "Client-side scripts for BrowserSync",
"version": "0.1.5",
"version": "0.1.6",
"homepage": "https://github.com/shakyshane/browser-sync-client",

@@ -6,0 +6,0 @@ "author": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc