ld31-space-diggers/node_modules/browser-sync/node_modules/browser-sync-client/lib/index.js
Ruben Müller 760c1838ed Add game
2014-12-07 20:57:49 +01:00

70 lines
2 KiB
JavaScript

"use strict";
var socket = require("./socket");
var shims = require("./client-shims");
var notify = require("./notify");
var codeSync = require("./code-sync");
var BrowserSync = require("./browser-sync");
var ghostMode = require("./ghostmode");
var emitter = require("./emitter");
var events = require("./events");
var utils = require("./browser.utils").utils;
var shouldReload = false;
/**
* @param options
*/
exports.init = function (options) {
if (shouldReload) {
utils.reloadBrowser();
}
var BS = window.___browserSync___ || {};
if (!BS.client) {
BS.client = true;
var browserSync = new BrowserSync(options);
// Always init on page load
ghostMode.init(browserSync);
codeSync.init(browserSync);
if (options.notify) {
notify.init(browserSync);
notify.flash("Connected to BrowserSync");
}
}
};
/**
* Handle individual socket connections
*/
socket.on("connection", exports.init);
socket.on("disconnect", function () {
notify.flash("Disconnected From BrowserSync");
shouldReload = true;
});
/**debug:start**/
if (window.__karma__) {
window.__bs_scroll__ = require("./ghostmode.scroll");
window.__bs_clicks__ = require("./ghostmode.clicks");
window.__bs_location__ = require("./ghostmode.location");
window.__bs_inputs__ = require("./ghostmode.forms.input");
window.__bs_toggles__ = require("./ghostmode.forms.toggles");
window.__bs_submit__ = require("./ghostmode.forms.submit");
window.__bs_forms__ = require("./ghostmode.forms");
window.__bs_utils__ = require("./browser.utils");
window.__bs_emitter__ = emitter;
window.__bs = BrowserSync;
window.__bs_notify__ = notify;
window.__bs_code_sync__ = codeSync;
window.__bs_ghost_mode__ = ghostMode;
window.__bs_socket__ = socket;
window.__bs_index__ = exports;
}
/**debug:end**/