browser-sync-ui
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -13,2 +13,6 @@ var async = require("./async"); | ||
{ | ||
step: "Setting available URLS for UI", | ||
fn: async.setUrlOptions | ||
}, | ||
{ | ||
step: "Starting the Control Panel Server", | ||
@@ -28,3 +32,7 @@ fn: async.startServer | ||
fn: async.addOptionsEvent | ||
}, | ||
{ | ||
step: "Logging info about Running UI", | ||
fn: async.logInfo | ||
} | ||
]; |
var Immutable = require("immutable"); | ||
var url = require("url"); | ||
@@ -46,2 +47,24 @@ module.exports = { | ||
/** | ||
* @param ui | ||
* @param done | ||
*/ | ||
setUrlOptions: function (ui, done) { | ||
var port = ui.options.get("port"); | ||
var bsUrls = ui.bs.getOptionIn(["urls"]).toJS(); | ||
var urls = { | ||
local: "http://localhost:" + port | ||
}; | ||
if (bsUrls.external) { | ||
urls["external"] = ["http://", url.parse(bsUrls.external).hostname, ":", port].join(""); | ||
} | ||
done(null, { | ||
options: { | ||
urls: Immutable.fromJS(urls) | ||
} | ||
}); | ||
}, | ||
/** | ||
* Simple static file server with some middlewares for custom | ||
@@ -141,3 +164,13 @@ * scripts/routes. | ||
done(); | ||
}, | ||
/** | ||
* @param ui | ||
* @param done | ||
*/ | ||
logInfo: function (ui, done) { | ||
ui.options.get("urls").map(function (url) { | ||
ui.logger.info("Running at: {magenta:%s", url); | ||
}); | ||
done(); | ||
} | ||
}; |
@@ -17,3 +17,3 @@ var fs = require("fs"); | ||
var item = ui.getOptionIn([CLIENT_FILES_OPT, file.name]).toJS(); | ||
if (item.active) { | ||
@@ -20,0 +20,0 @@ return; |
@@ -8,2 +8,3 @@ "use strict"; | ||
socket.on("connection", function (options) { | ||
bs.socket.emit("urls:client:connected", { | ||
@@ -13,2 +14,3 @@ href: window.location.href, | ||
}); | ||
window.setInterval(function () { | ||
@@ -55,3 +57,3 @@ socket.emit("client:heartbeat", { | ||
socket.on("cp:element:add", function (data) { | ||
var elem = document.getElementById(data.id); | ||
@@ -58,0 +60,0 @@ |
@@ -38,2 +38,4 @@ var urls = require("../../urls"); | ||
var currentConnections = []; | ||
/** | ||
@@ -53,3 +55,21 @@ * @type {{plugin: Function, plugin:name: string, markup: string}} | ||
client.on("client:heartbeat", function (data) { | ||
// console.log(data, client.id); | ||
var match; | ||
if (currentConnections.some(function (item, index) { | ||
if (item.id === client.id) { | ||
match = index; | ||
return true; | ||
} | ||
return false; | ||
})) { | ||
if (typeof match === "number") { | ||
console.log("Updating dupe: ", client.id); | ||
currentConnections[match].timestamp = new Date().getTime(); | ||
} | ||
} else { | ||
currentConnections.push({ | ||
id: client.id, | ||
timestamp: new Date().getTime(), | ||
browser: uaParser.setUA(client.handshake.headers["user-agent"]).getBrowser() | ||
}); | ||
} | ||
// todo add window size stuff | ||
@@ -73,9 +93,6 @@ }); | ||
if (cp.clients.sockets.length) { | ||
temp = Immutable.List(cp.clients.sockets.map(function (client) { | ||
return Immutable.fromJS({ | ||
id: client.id, | ||
browser: uaParser.setUA(client.handshake.headers["user-agent"]).getBrowser() | ||
}); | ||
})); | ||
var recent = getRecentClients(currentConnections, 1000); | ||
if (recent.length) { | ||
temp = Immutable.List(recent); | ||
if (!registry) { | ||
@@ -96,3 +113,5 @@ registry = temp; | ||
} | ||
count += 1; | ||
}, 1000); | ||
@@ -156,7 +175,25 @@ | ||
*/ | ||
function addClient (immSet, client) { | ||
return immSet.push({ | ||
id: client.id, | ||
browser: uaParser.setUA(client.handshake.headers["user-agent"]).getBrowser() | ||
//function addClient (immSet, client) { | ||
// return immSet.push({ | ||
// id: client.id, | ||
// browser: uaParser.setUA(client.handshake.headers["user-agent"]).getBrowser() | ||
// }); | ||
//} | ||
function getRecentClients (clients, timeout) { | ||
var diff = new Date().getTime(); | ||
return clients.filter(function (client) { | ||
if ((diff - client.timestamp) < timeout) { | ||
return true; | ||
} | ||
}); | ||
} | ||
function getClientList (sockets, uaParser) { | ||
return sockets.map(function (client) { | ||
return Immutable.fromJS({ | ||
id: client.id, | ||
browser: uaParser.setUA(client.handshake.headers["user-agent"]).getBrowser() | ||
}); | ||
}); | ||
} |
@@ -18,3 +18,3 @@ var urls = require("../../urls"); | ||
"plugin": function (cp, bs) { | ||
/* noop */ | ||
}, | ||
@@ -25,3 +25,3 @@ /** | ||
"hooks": { | ||
"markup": fs.readFileSync(path.join(__dirname, "help.html")), | ||
"markup": fs.readFileSync(path.join(__dirname, "/../../../static/content/help.content.html")), | ||
"client:js": require("fs").readFileSync(__dirname + "/help.client.js"), | ||
@@ -28,0 +28,0 @@ "templates": [ |
@@ -75,8 +75,18 @@ (function (angular) { | ||
$scope.removeVisited = function (data) { | ||
History.remove(data); | ||
$scope.visited = $scope.visited.map(function (item) { | ||
item.success = false; | ||
return item; | ||
}); | ||
$scope.removeVisited = function (item) { | ||
History.remove(item); | ||
}; | ||
$scope.sendAllTo = function (path) { | ||
Clients.sendAllTo(path); | ||
$scope.sendAllTo = function (url) { | ||
url.success = true; | ||
Clients.sendAllTo(url.path); | ||
setTimeout(function () { | ||
url.success = false; | ||
$scope.$digest(); | ||
}, 1000); | ||
}; | ||
@@ -83,0 +93,0 @@ } |
@@ -20,3 +20,3 @@ var files = [ | ||
src: "/browser-sync/pesticide.css", | ||
tagline: "Add simple CSS outlines to all elements. (powered by <a href=\"http://pesticide.io\">Pesticide.io</a>)", | ||
tagline: "Add simple CSS outlines to all elements. (powered by <a href=\"http://pesticide.io\" target=\"_blank\">Pesticide.io</a>)", | ||
hidden: "" | ||
@@ -34,3 +34,3 @@ }, | ||
src: "/browser-sync/pesticide-depth.css", | ||
tagline: "Add CSS box-shadows to all elements. (powered by <a href=\"http://pesticide.io\">Pesticide.io</a>)", | ||
tagline: "Add CSS box-shadows to all elements. (powered by <a href=\"http://pesticide.io\" target=\"_blank\">Pesticide.io</a>)", | ||
hidden: "" | ||
@@ -37,0 +37,0 @@ } |
@@ -10,2 +10,3 @@ var urls = require("../../urls"); | ||
const PLUGIN_NAME = "Remote Debug"; | ||
var timeout = 0; | ||
@@ -76,2 +77,15 @@ /** | ||
ui.disableElement(file); | ||
} | ||
} | ||
/** | ||
* @returns {Function} | ||
*/ | ||
function throttleMiddleware () { | ||
return function (req, res, next) { | ||
setTimeout(function () { | ||
next(); | ||
}, timeout); | ||
} | ||
} | ||
module.exports.throttleMiddleware = throttleMiddleware; |
@@ -154,4 +154,7 @@ var config = require("./config"); | ||
return function (err) { | ||
if (err) { | ||
ui.logger.setOnce("useLevelPrefixes", true).error(err.message || err); | ||
} | ||
ui.events.emit("cp:running", {instance: ui, options: ui.options}); | ||
ui.logger.info("Running at: {magenta:http://localhost:%s", ui.options.get("port")); | ||
}; | ||
@@ -158,0 +161,0 @@ } |
{ | ||
"name": "browser-sync-ui", | ||
"description": "User Interface for BrowserSync", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"homepage": "http://www.browsersync.io/", | ||
@@ -52,3 +52,3 @@ "author": { | ||
"async": "^0.9.0", | ||
"browser-sync": "git://github.com/shakyshane/browser-sync#v2-rc2.9", | ||
"browser-sync": "git://github.com/shakyshane/browser-sync#v2-rc3.4", | ||
"bs-html-injector": "^1.2.1", | ||
@@ -55,0 +55,0 @@ "chai": "^1.9.1", |
@@ -297,3 +297,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){ | ||
scope: {}, | ||
template: '<section bs-overlay ng-class="{\'active\': ui.visible}"><p><icon icon="block"></icon></p><h1>{{ui.heading}} {{ui.message}}</h1><p>Possible reasons are:</p><ul bs-list><li>1. Your process was exited by another tool</li></ul></section>', // jshint:ignore | ||
template: '<section bs-overlay ng-class="{\'active\': ui.visible}">\n <p><icon icon="block"></icon></p>\n <h1>{{ui.heading}} {{ui.message}}</h1>\n <p>Possible reasons are:</p>\n <ul bs-list>\n <li>1. Your process was exited by another tool</li>\n </ul>\n <p>You should check your terminal window to see what happened. <br/>(Or simply try reloading this page.)</p>\n</section>', // jshint:ignore | ||
controller: ["$scope", "$rootScope", "$window", disconnectController] | ||
@@ -300,0 +300,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3577986
138
5439