browser-sync-ui
Advanced tools
Comparing version 0.5.3 to 0.5.4
@@ -38,4 +38,4 @@ var Immutable = require("immutable"); | ||
instance: { | ||
clientJs: ui.pluginManager.hook("client:js"), | ||
templates: ui.pluginManager.hook("templates", ui.getInitialTemplates()), | ||
clientJs: ui.pluginManager.hook("client:js", ui), | ||
templates: ui.pluginManager.hook("templates", ui.getInitialTemplates(), ui), | ||
pagesConfig: out.pagesConfig, | ||
@@ -42,0 +42,0 @@ pages: out.pagesObj, |
@@ -8,2 +8,3 @@ var fs = require("fs"); | ||
var inlineTemp = templateFile("/inline.template.tmpl"); | ||
var pluginItemTmpl = fs.readFileSync(path.resolve(__dirname, "../", "templates/plugin.item.tmpl"), "utf-8"); | ||
@@ -21,6 +22,5 @@ function templateFile (filepath) { | ||
* @param hooks | ||
* @param cp | ||
* @param cb | ||
* @param ui | ||
*/ | ||
"page": function (hooks, cp) { | ||
"page": function (hooks, ui) { | ||
@@ -49,3 +49,5 @@ var config = hooks | ||
pagesObj: config, | ||
pageMarkup: preAngular(cp.pluginManager.plugins, config) | ||
pageMarkup: function () { | ||
return preAngular(ui.pluginManager.plugins, config, ui); | ||
} | ||
}; | ||
@@ -63,5 +65,16 @@ }, | ||
* @param hooks | ||
* @param {UI} ui | ||
* @returns {*|string} | ||
*/ | ||
"client:js": function (hooks) { | ||
"client:js": function (hooks, ui) { | ||
/** | ||
* Add client JS from BrowserSync Plugins | ||
*/ | ||
ui.bsPlugins.forEach(function (plugin) { | ||
if (plugin.has("client:js")) { | ||
hooks.push(plugin.get("client:js")); | ||
} | ||
}); | ||
var out = hooks.reduce(function (all, item) { | ||
@@ -82,6 +95,27 @@ if (typeof item === "string") { | ||
* @param initial | ||
* @param {UI} ui | ||
* @returns {String} | ||
*/ | ||
"templates": function (hooks, initial) { | ||
return createInlineTemplates(hooks.concat([initial])); | ||
"templates": function (hooks, initial, ui) { | ||
/** | ||
* Add templates from BrowserSync Plugins | ||
* @type {string} | ||
*/ | ||
var pluginDirectives = ui.bsPlugins.reduce(function (all, plugin) { | ||
var optPath = ["pkg", "browser-sync:ui", "hooks", "templates"]; | ||
if (plugin.hasIn(optPath)) { | ||
var templatename = path.basename(plugin.getIn(optPath).get(0)); | ||
if (templatename) { | ||
all += angularWrap(templatename, plugin.get("templates")); | ||
} | ||
} | ||
return all; | ||
}, ""); | ||
return [pluginDirectives, createInlineTemplates(hooks.concat([initial]))].join(""); | ||
}, | ||
@@ -168,3 +202,3 @@ /** | ||
*/ | ||
function preAngular (plugins, config) { | ||
function preAngular (plugins, config, ui) { | ||
@@ -176,2 +210,14 @@ return Object.keys(plugins) | ||
.map(function (key) { | ||
if (key === "plugins") { | ||
var pluginMarkup = ui.bsPlugins.reduce(function (all, item, i) { | ||
if (item.has("markup")) { | ||
return all += pluginItemTmpl | ||
.replace("%content%", item.get("markup")) | ||
.replace(/%index%/g, i) | ||
.replace(/%name%/g, item.get("name")); | ||
} | ||
return all; | ||
}, ""); | ||
plugins[key].hooks.markup = plugins[key].hooks.markup.replace("%pluginlist%", pluginMarkup); | ||
} | ||
return angularWrap(config[key].template, bindOnce(plugins[key].hooks.markup, config[key])); | ||
@@ -178,0 +224,0 @@ }) |
@@ -87,3 +87,3 @@ (function (angular) { | ||
Socket.emit("ui", { | ||
Socket.uiEvent({ | ||
namespace: SECTION_NAME, | ||
@@ -100,3 +100,3 @@ event: "server:create", | ||
ctrl.destroyServer = function (item, port) { | ||
Socket.emit("ui", { | ||
Socket.uiEvent({ | ||
namespace: SECTION_NAME, | ||
@@ -103,0 +103,0 @@ event: "server:destroy", |
@@ -42,2 +42,7 @@ /** | ||
var named = filtered.reduce(function (all, item) { | ||
all[item.name] = item; | ||
return all; | ||
}, {}); | ||
/** | ||
@@ -48,10 +53,11 @@ * @type {{loading: boolean}} | ||
loading: false, | ||
plugins: filtered | ||
plugins: filtered, | ||
named: named | ||
}; | ||
/** | ||
* Toggle a plugin | ||
* Toggle a pluginrs | ||
*/ | ||
ctrl.togglePlugin = function (plugin) { | ||
Socket.emit("ui", { | ||
Socket.uiEvent({ | ||
namespace: SECTION_NAME, | ||
@@ -68,3 +74,3 @@ event: "set", | ||
ctrl.setMany = function (value) { | ||
Socket.emit("ui", { | ||
Socket.uiEvent({ | ||
namespace: SECTION_NAME, | ||
@@ -71,0 +77,0 @@ event: "setMany", |
@@ -49,3 +49,3 @@ (function (angular) { | ||
ctrl.toggleWeinre = function (item) { | ||
Socket.emit("ui", { | ||
Socket.uiEvent({ | ||
namespace: SECTION_NAME + ":weinre", | ||
@@ -59,3 +59,3 @@ event: "toggle", | ||
var ns = SECTION_NAME + ":overlay-grid"; | ||
Socket.emit("ui", { | ||
Socket.uiEvent({ | ||
namespace: ns, | ||
@@ -71,3 +71,3 @@ event: "toggle", | ||
Socket.emit("ui", { | ||
Socket.uiEvent({ | ||
namespace: ns, | ||
@@ -80,3 +80,3 @@ event: "toggle", | ||
ctrl.enable = function (item) { | ||
Socket.emit("ui", { | ||
Socket.uiEvent({ | ||
namespace: SECTION_NAME + ":files", | ||
@@ -89,3 +89,3 @@ event: "enableFile", | ||
ctrl.disable = function (item) { | ||
Socket.emit("ui", { | ||
Socket.uiEvent({ | ||
namespace: SECTION_NAME + ":files", | ||
@@ -92,0 +92,0 @@ event: "disableFile", |
@@ -27,3 +27,3 @@ (function (angular) { | ||
ctrl.setMany = function (value) { | ||
Socket.emit("ui", { | ||
Socket.uiEvent({ | ||
namespace: SECTION_NAME, | ||
@@ -46,3 +46,3 @@ event: "setMany", | ||
ctrl.toggleSyncItem = function (item) { | ||
Socket.emit("ui", { | ||
Socket.uiEvent({ | ||
namespace: SECTION_NAME, | ||
@@ -49,0 +49,0 @@ event: "set", |
@@ -46,4 +46,13 @@ var fs = require("fs"); | ||
/** | ||
* | ||
*/ | ||
ui.pluginManager = new bs.utils.easyExtender(defaultPlugins, hooks).init(); | ||
/** | ||
* Transform/save data RE: plugins | ||
* @type {*} | ||
*/ | ||
ui.bsPlugins = require("./resolve-plugins")(bs.getUserPlugins()); | ||
return ui; | ||
@@ -50,0 +59,0 @@ }; |
{ | ||
"name": "browser-sync-ui", | ||
"description": "User Interface for BrowserSync", | ||
"version": "0.5.3", | ||
"version": "0.5.4", | ||
"homepage": "http://www.browsersync.io/", | ||
@@ -47,3 +47,3 @@ "author": { | ||
"angular-mocks": "^1.3.11", | ||
"browser-sync": "^2.5.0", | ||
"browser-sync": "^2.5.2", | ||
"browserify": "^8.1.1", | ||
@@ -53,3 +53,3 @@ "bs-html-injector": "^1.5.2", | ||
"compression": "^1.4.1", | ||
"crossbow": "^0.4.1", | ||
"crossbow": "^0.4.2", | ||
"eazy-logger": "^2.1.0", | ||
@@ -56,0 +56,0 @@ "gulp": "^3.8.10", |
@@ -613,2 +613,5 @@ (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);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.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){ | ||
return deferred.promise; | ||
}, | ||
uiEvent: function (evt) { | ||
socket.emit("ui", evt); | ||
} | ||
@@ -615,0 +618,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
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
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
4527140
170
7126
25