browser-sync-ui
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -9,12 +9,22 @@ var urls = require("../../urls"); | ||
var connectedClients = Immutable.Map(); | ||
/** | ||
* Use heart-beat information to decorate connected client | ||
* info with things like height/width etc. | ||
* @param registry | ||
* @param connectedClients | ||
* @returns {*} | ||
*/ | ||
function decorateClients(registry, connectedClients) { | ||
function decorateClients(connectedClients) { | ||
return connectedClients; | ||
//return connectedClients.map(function (client) { | ||
// return { | ||
// browser: uaParser.setUA(client.handshake.headers["user-agent"]).getBrowser(), | ||
// id: client.id | ||
// } | ||
//}); | ||
return registry.map(function (item) { | ||
connectedClients.forEach(function (client) { | ||
if (item.id === client.id) { | ||
item.data = client.data; | ||
return false; | ||
} | ||
}); | ||
return item; | ||
}); | ||
} | ||
@@ -27,14 +37,5 @@ | ||
function sendUpdated(socket, connectedClients) { | ||
//console.log(decorateClients(connectedClients)); | ||
socket.emit("cp:connections:update", decorateClients(connectedClients)); | ||
socket.emit("cp:connections:update", connectedClients); | ||
} | ||
/** | ||
* @param socketIoClients | ||
* @param connectedClients | ||
*/ | ||
function cleanupConnections (connectedClients) { | ||
} | ||
var currentConnections = []; | ||
@@ -65,4 +66,4 @@ | ||
if (typeof match === "number") { | ||
console.log("Updating dupe: ", client.id); | ||
currentConnections[match].timestamp = new Date().getTime(); | ||
currentConnections[match].data = data; | ||
} | ||
@@ -73,3 +74,4 @@ } else { | ||
timestamp: new Date().getTime(), | ||
browser: uaParser.setUA(client.handshake.headers["user-agent"]).getBrowser() | ||
browser: uaParser.setUA(client.handshake.headers["user-agent"]).getBrowser(), | ||
data: data | ||
}); | ||
@@ -95,13 +97,16 @@ } | ||
var recent = getRecentClients(currentConnections, 1000); | ||
if (recent.length) { | ||
temp = Immutable.List(recent); | ||
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() | ||
}); | ||
})); | ||
if (!registry) { | ||
registry = temp; | ||
sendUpdated(cp.socket, registry.toJS()); | ||
sendUpdated(cp.socket, decorateClients(registry.toJS(), currentConnections)); | ||
} else { | ||
if (Immutable.is(registry, temp)) { | ||
if (!initialSent) { | ||
sendUpdated(cp.socket, registry.toJS()); | ||
sendUpdated(cp.socket, decorateClients(registry.toJS(), currentConnections)); | ||
initialSent = true; | ||
@@ -111,9 +116,9 @@ } | ||
registry = temp; | ||
sendUpdated(cp.socket, registry.toJS()); | ||
sendUpdated(cp.socket, decorateClients(registry.toJS(), currentConnections)); | ||
} | ||
} | ||
} else { | ||
sendUpdated(cp.socket, []); | ||
} | ||
count += 1; | ||
}, 1000); | ||
@@ -172,14 +177,2 @@ | ||
/** | ||
* @param immSet | ||
* @param client | ||
* @returns {*} | ||
*/ | ||
//function addClient (immSet, client) { | ||
// return immSet.push({ | ||
// id: client.id, | ||
// browser: uaParser.setUA(client.handshake.headers["user-agent"]).getBrowser() | ||
// }); | ||
//} | ||
function getRecentClients (clients, timeout) { | ||
@@ -186,0 +179,0 @@ var diff = new Date().getTime(); |
{ | ||
"name": "browser-sync-ui", | ||
"description": "User Interface for BrowserSync", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"homepage": "http://www.browsersync.io/", | ||
@@ -6,0 +6,0 @@ "author": { |
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
3580589
5435