Socket
Socket
Sign inDemoInstall

browser-sync

Package Overview
Dependencies
Maintainers
1
Versions
300
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-sync - npm Package Compare versions

Comparing version 2.27.7 to 2.27.8

4

dist/async.js

@@ -258,4 +258,4 @@ "use strict";

*/
var opts = uiOpts.update(function (uiOpts) {
var listen = bs.options.get("listen");
const opts = uiOpts.update(uiOpts => {
const listen = bs.options.get("listen");
if (listen) {

@@ -262,0 +262,0 @@ return uiOpts.set("listen", listen);

#!/usr/bin/env node
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var startOpts = require("../cli-options/opts.start.json");
var reloadOpts = require("../cli-options/opts.reload.json");
var recipeOpts = require("../cli-options/opts.recipe.json");
var pkg = require("../package.json");
var utils = require("./utils");
var path_1 = require("path");
var fs_1 = require("fs");
var logger_1 = require("./logger");
var eazy_logger_1 = require("eazy-logger");
var cli_options_1 = require("./cli/cli-options");
exports.BsErrorTypes = exports.BsErrorLevels = void 0;
const startOpts = require("../cli-options/opts.start.json");
const reloadOpts = require("../cli-options/opts.reload.json");
const recipeOpts = require("../cli-options/opts.recipe.json");
const pkg = require("../package.json");
const utils = require("./utils");
const path_1 = require("path");
const fs_1 = require("fs");
const logger_1 = require("./logger");
const eazy_logger_1 = require("eazy-logger");
const cli_options_1 = require("./cli/cli-options");
var BsErrorLevels;

@@ -41,3 +31,3 @@ (function (BsErrorLevels) {

function runFromCli() {
var yargs = require("yargs")
const yargs = require("yargs")
.command("start", "Start the server")

@@ -62,8 +52,8 @@ .command("init", "Create a configuration file")

"To run a proxy, whilst also serving static files",
eazy_logger_1.compile(" $0 https://example.com htdocs/themes/example")
(0, eazy_logger_1.compile)(" $0 https://example.com htdocs/themes/example")
].join("\n"));
var argv = yargs.argv;
var input = argv._;
var command = input[0];
var valid = ["start", "init", "reload", "recipe"];
const argv = yargs.argv;
const input = argv._;
const command = input[0];
const valid = ["start", "init", "reload", "recipe"];
if (valid.indexOf(command) > -1) {

@@ -75,3 +65,3 @@ return handleIncoming(command, yargs.reset());

}
if (fs_1.existsSync("index.html")) {
if ((0, fs_1.existsSync)("index.html")) {
return handleNoCommand(argv, ["."], yargs);

@@ -99,27 +89,27 @@ }

function handleNoCommand(argv, input, yargs) {
var processed = processStart(yargs);
var paths = input.map(function (path) {
var resolved = path_1.resolve(path);
var isUrl = /^https?:\/\//.test(path);
const processed = processStart(yargs);
const paths = input.map(path => {
const resolved = (0, path_1.resolve)(path);
const isUrl = /^https?:\/\//.test(path);
return {
isUrl: isUrl,
isUrl,
userInput: path,
resolved: resolved,
resolved,
errors: isUrl ? [] : pathErrors(path, resolved)
};
});
var withErrors = paths.filter(function (item) { return item.errors.length; });
var withoutErrors = paths.filter(function (item) { return item.errors.length === 0; });
const withErrors = paths.filter(item => item.errors.length);
const withoutErrors = paths.filter(item => item.errors.length === 0);
if (withErrors.length) {
withErrors.forEach(function (item) {
logger_1.logger.unprefixed("error", cli_options_1.printErrors(item.errors));
withErrors.forEach(item => {
logger_1.logger.unprefixed("error", (0, cli_options_1.printErrors)(item.errors));
});
return process.exit(1);
}
var serveStaticPaths = withoutErrors
.filter(function (item) { return item.isUrl === false; })
.map(function (item) { return item.resolved; });
var urls = withoutErrors
.filter(function (item) { return item.isUrl === true; })
.map(function (item) { return item.userInput; });
const serveStaticPaths = withoutErrors
.filter(item => item.isUrl === false)
.map(item => item.resolved);
const urls = withoutErrors
.filter(item => item.isUrl === true)
.map(item => item.userInput);
/**

@@ -130,5 +120,5 @@ * If a URL was given, switch to proxy mode and use

if (urls.length) {
var proxy = urls[0];
var config_1 = __assign({}, processed, { proxy: proxy, serveStatic: serveStaticPaths });
return handleCli({ cli: { flags: config_1, input: ["start"] } });
const proxy = urls[0];
const config = Object.assign(Object.assign({}, processed), { proxy, serveStatic: serveStaticPaths });
return handleCli({ cli: { flags: config, input: ["start"] } });
}

@@ -139,3 +129,3 @@ /**

*/
var config = __assign({}, processed, { server: { baseDir: serveStaticPaths } });
const config = Object.assign(Object.assign({}, processed), { server: { baseDir: serveStaticPaths } });
return handleCli({ cli: { flags: config, input: ["start"] } });

@@ -149,3 +139,3 @@ }

opts.cb = opts.cb || utils.defaultCallback;
var m = require("./cli/command." + opts.cli.input[0]);
const m = require(`./cli/command.${opts.cli.input[0]}`);
if (m.default) {

@@ -163,3 +153,3 @@ return m.default(opts);

.example("$0 start -p www.bbc.co.uk", "- Proxy an existing website")
.default("cwd", function () { return process.cwd(); })
.default("cwd", () => process.cwd())
.help().argv;

@@ -173,3 +163,3 @@ }

function handleIncoming(command, yargs) {
var out;
let out;
if (command === "start") {

@@ -182,3 +172,3 @@ out = processStart(yargs);

.example("$0 init")
.default("cwd", function () { return process.cwd(); })
.default("cwd", () => process.cwd())
.help().argv;

@@ -192,3 +182,3 @@ }

.example("$0 reload --port 4000")
.default("cwd", function () { return process.cwd(); })
.default("cwd", () => process.cwd())
.help().argv;

@@ -202,3 +192,3 @@ }

.example("$0 recipe gulp.sass", "use the gulp.sass recipe")
.default("cwd", function () { return process.cwd(); })
.default("cwd", () => process.cwd())
.help().argv;

@@ -212,3 +202,3 @@ }

function pathErrors(input, resolved) {
if (!fs_1.existsSync(resolved)) {
if (!(0, fs_1.existsSync)(resolved)) {
return [

@@ -220,8 +210,8 @@ {

{
error: new Error("Path not found: " + input),
meta: function () {
error: new Error(`Path not found: ${input}`),
meta() {
return [
"Your Input: {yellow:" + input + "}",
"CWD: {yellow:" + process.cwd() + "}",
"Resolved to: {yellow:" + resolved + "}"
`Your Input: {yellow:${input}}`,
`CWD: {yellow:${process.cwd()}}`,
`Resolved to: {yellow:${resolved}}`
];

@@ -228,0 +218,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var immutable_1 = require("immutable");
var addToFilesOption_1 = require("./transforms/addToFilesOption");
var addDefaultIgnorePatterns_1 = require("./transforms/addDefaultIgnorePatterns");
var copyCLIIgnoreToWatchOptions_1 = require("./transforms/copyCLIIgnoreToWatchOptions");
var handleExtensionsOption_1 = require("./transforms/handleExtensionsOption");
var handleFilesOption_1 = require("./transforms/handleFilesOption");
var handleGhostModeOption_1 = require("./transforms/handleGhostModeOption");
var handlePortsOption_1 = require("./transforms/handlePortsOption");
var handleProxyOption_1 = require("./transforms/handleProxyOption");
var handleServerOption_1 = require("./transforms/handleServerOption");
var appendServerIndexOption_1 = require("./transforms/appendServerIndexOption");
var appendServerDirectoryOption_1 = require("./transforms/appendServerDirectoryOption");
var addCwdToWatchOptions_1 = require("./transforms/addCwdToWatchOptions");
var options_1 = require("../options");
var handleHostOption_1 = require("./transforms/handleHostOption");
var _ = require("../lodash.custom");
var defaultConfig = require("../default-config");
var immDefs = immutable_1.fromJS(defaultConfig);
exports.printErrors = exports.makeFilesArg = exports.explodeFilesArg = exports.merge = void 0;
const immutable_1 = require("immutable");
const addToFilesOption_1 = require("./transforms/addToFilesOption");
const addDefaultIgnorePatterns_1 = require("./transforms/addDefaultIgnorePatterns");
const copyCLIIgnoreToWatchOptions_1 = require("./transforms/copyCLIIgnoreToWatchOptions");
const handleExtensionsOption_1 = require("./transforms/handleExtensionsOption");
const handleFilesOption_1 = require("./transforms/handleFilesOption");
const handleGhostModeOption_1 = require("./transforms/handleGhostModeOption");
const handlePortsOption_1 = require("./transforms/handlePortsOption");
const handleProxyOption_1 = require("./transforms/handleProxyOption");
const handleServerOption_1 = require("./transforms/handleServerOption");
const appendServerIndexOption_1 = require("./transforms/appendServerIndexOption");
const appendServerDirectoryOption_1 = require("./transforms/appendServerDirectoryOption");
const addCwdToWatchOptions_1 = require("./transforms/addCwdToWatchOptions");
const options_1 = require("../options");
const handleHostOption_1 = require("./transforms/handleHostOption");
const _ = require("../lodash.custom");
const defaultConfig = require("../default-config");
const immDefs = (0, immutable_1.fromJS)(defaultConfig);
function merge(input) {
var merged = immDefs.mergeDeep(input);
var transforms = [
const merged = immDefs.mergeDeep(input);
const transforms = [
addToFilesOption_1.addToFilesOption,

@@ -51,6 +52,6 @@ addCwdToWatchOptions_1.addCwdToWatchOptions,

];
var output = transforms.reduce(function (acc, item) {
var current = acc[0], currentErrors = acc[1];
var _a = item.call(null, current), result = _a[0], errors = _a[1];
return [result, currentErrors.concat(errors)];
const output = transforms.reduce((acc, item) => {
const [current, currentErrors] = acc;
const [result, errors] = item.call(null, current);
return [result, [...currentErrors, ...errors]];
}, [merged, []]);

@@ -64,3 +65,3 @@ return output;

function explodeFilesArg(string) {
return string.split(",").map(function (item) { return item.trim(); });
return string.split(",").map(item => item.trim());
}

@@ -73,4 +74,4 @@ exports.explodeFilesArg = explodeFilesArg;

function makeFilesArg(value) {
var globs = [];
var objs = [];
let globs = [];
let objs = [];
if (_.isString(value)) {

@@ -99,16 +100,12 @@ globs = globs.concat(explodeFilesArg(value));

return errors
.map(function (error) {
return [
"Error Type: " + error.type,
"Error Level: " + error.level,
error.errors.map(function (item) {
return [
"Error Message: " + item.error.message,
item.meta ? item.meta().join("\n") : ""
]
.filter(Boolean)
.join("\n");
})
].join("\n");
})
.map(error => [
`Error Type: ${error.type}`,
`Error Level: ${error.level}`,
error.errors.map(item => [
`Error Message: ${item.error.message}`,
item.meta ? item.meta().join("\n") : ""
]
.filter(Boolean)
.join("\n"))
].join("\n"))
.join("\n\n");

@@ -115,0 +112,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var path = require("path");
var fs_1 = require("fs");
var immutable_1 = require("immutable");
var utils = require("../utils");
var cli_options_1 = require("./cli-options");
var _ = require("../lodash.custom");
const path = require("path");
const fs_1 = require("fs");
const immutable_1 = require("immutable");
const utils = require("../utils");
const cli_options_1 = require("./cli-options");
const _ = require("../lodash.custom");
/**

@@ -19,19 +19,19 @@ * $ browser-sync start <options>

function default_1(opts) {
var flags = preprocessFlags(opts.cli.flags);
var cwd = flags.cwd || process.cwd();
var maybepkg = path.resolve(cwd, "package.json");
var input = flags;
const flags = preprocessFlags(opts.cli.flags);
const cwd = flags.cwd || process.cwd();
const maybepkg = path.resolve(cwd, "package.json");
let input = flags;
if (flags.config) {
var maybeconf = path.resolve(cwd, flags.config);
if (fs_1.existsSync(maybeconf)) {
var conf = require(maybeconf);
const maybeconf = path.resolve(cwd, flags.config);
if ((0, fs_1.existsSync)(maybeconf)) {
const conf = require(maybeconf);
input = _.merge({}, conf, flags);
}
else {
utils.fail(true, new Error("Configuration file '" + flags.config + "' not found"), opts.cb);
utils.fail(true, new Error(`Configuration file '${flags.config}' not found`), opts.cb);
}
}
else {
if (fs_1.existsSync(maybepkg)) {
var pkg = require(maybepkg);
if ((0, fs_1.existsSync)(maybepkg)) {
const pkg = require(maybepkg);
if (pkg["browser-sync"]) {

@@ -57,3 +57,3 @@ console.log("> Configuration obtained from package.json");

removeWatchBooleanWhenFalse
].reduce(function (flags, fn) { return fn.call(null, flags); }, flags);
].reduce((flags, fn) => fn.call(null, flags), flags);
}

@@ -67,4 +67,4 @@ /**

function stripUndefined(subject) {
return Object.keys(subject).reduce(function (acc, key) {
var value = subject[key];
return Object.keys(subject).reduce((acc, key) => {
const value = subject[key];
if (typeof value === "undefined") {

@@ -83,3 +83,3 @@ return acc;

if (flags.files && flags.files.length) {
flags.files = flags.files.reduce(function (acc, item) { return acc.concat(cli_options_1.explodeFilesArg(item)); }, []);
flags.files = flags.files.reduce((acc, item) => acc.concat((0, cli_options_1.explodeFilesArg)(item)), []);
}

@@ -96,3 +96,3 @@ return flags;

if (flags.watch === false) {
return immutable_1.fromJS(flags)
return (0, immutable_1.fromJS)(flags)
.delete("watch")

@@ -99,0 +99,0 @@ .toJS();

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addCwdToWatchOptions = void 0;
function addCwdToWatchOptions(incoming) {
var output = incoming.updateIn(["watchOptions", "cwd"], function (watchCwd) {
const output = incoming.updateIn(["watchOptions", "cwd"], watchCwd => {
return watchCwd || incoming.get("cwd");

@@ -6,0 +7,0 @@ });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var immutable_1 = require("immutable");
var defaultIgnorePatterns = [
exports.addDefaultIgnorePatterns = void 0;
const immutable_1 = require("immutable");
const defaultIgnorePatterns = [
/node_modules/,

@@ -16,8 +17,8 @@ /bower_components/,

}
var output = incoming.update("watchOptions", function (watchOptions) {
var userIgnored = immutable_1.List([])
const output = incoming.update("watchOptions", watchOptions => {
const userIgnored = (0, immutable_1.List)([])
.concat(watchOptions.get("ignored"))
.filter(Boolean)
.toSet();
var merged = userIgnored.merge(defaultIgnorePatterns);
const merged = userIgnored.merge(defaultIgnorePatterns);
return watchOptions.merge({

@@ -24,0 +25,0 @@ ignored: merged.toList()

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var immutable_1 = require("immutable");
exports.addToFilesOption = void 0;
const immutable_1 = require("immutable");
function addToFilesOption(incoming) {

@@ -8,5 +9,5 @@ if (!incoming.get("watch")) {

}
var serverPaths = [];
var fromServeStatic = incoming.get("serveStatic", immutable_1.List([])).toArray();
var ssPaths = fromServeStatic.reduce(function (acc, ss) {
let serverPaths = [];
const fromServeStatic = incoming.get("serveStatic", (0, immutable_1.List)([])).toArray();
const ssPaths = fromServeStatic.reduce((acc, ss) => {
if (typeof ss === "string") {

@@ -20,4 +21,4 @@ return acc.concat(ss);

}, []);
ssPaths.forEach(function (p) { return serverPaths.push(p); });
var server = incoming.get("server");
ssPaths.forEach(p => serverPaths.push(p));
const server = incoming.get("server");
if (server) {

@@ -30,15 +31,15 @@ if (server === true) {

}
if (immutable_1.List.isList(server) && server.every(function (x) { return typeof x === "string"; })) {
server.forEach(function (s) { return serverPaths.push(s); });
if (immutable_1.List.isList(server) && server.every(x => typeof x === "string")) {
server.forEach(s => serverPaths.push(s));
}
if (immutable_1.Map.isMap(server)) {
var baseDirProp = server.get("baseDir");
var baseDirs = immutable_1.List([])
const baseDirProp = server.get("baseDir");
const baseDirs = (0, immutable_1.List)([])
.concat(baseDirProp)
.filter(Boolean);
baseDirs.forEach(function (s) { return serverPaths.push(s); });
baseDirs.forEach(s => serverPaths.push(s));
}
}
var output = incoming.update("files", function (files) {
return immutable_1.List([])
const output = incoming.update("files", files => {
return (0, immutable_1.List)([])
.concat(files, serverPaths)

@@ -45,0 +46,0 @@ .filter(Boolean);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.appendServerDirectoryOption = void 0;
function appendServerDirectoryOption(incoming) {

@@ -4,0 +5,0 @@ if (!incoming.get("server"))

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.appendServerIndexOption = void 0;
function appendServerIndexOption(incoming) {
if (!incoming.get("server"))
return [incoming, []];
var value = incoming.get("index");
const value = incoming.get("index");
if (value) {

@@ -8,0 +9,0 @@ return [incoming.setIn(["server", "index"], value), []];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var immutable_1 = require("immutable");
exports.copyCLIIgnoreToWatchOptions = void 0;
const immutable_1 = require("immutable");
function copyCLIIgnoreToWatchOptions(incoming) {

@@ -8,4 +9,4 @@ if (!incoming.get("ignore")) {

}
var output = incoming.updateIn(["watchOptions", "ignored"], immutable_1.List([]), function (ignored) {
return immutable_1.List([]).concat(ignored, incoming.get("ignore"));
const output = incoming.updateIn(["watchOptions", "ignored"], (0, immutable_1.List)([]), ignored => {
return (0, immutable_1.List)([]).concat(ignored, incoming.get("ignore"));
});

@@ -12,0 +13,0 @@ return [output, []];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var immutable_1 = require("immutable");
var cli_options_1 = require("../cli-options");
var _ = require("../../lodash.custom");
exports.handleExtensionsOption = void 0;
const immutable_1 = require("immutable");
const cli_options_1 = require("../cli-options");
const _ = require("../../lodash.custom");
function handleExtensionsOption(incoming) {
var value = incoming.get("extensions");
const value = incoming.get("extensions");
if (_.isString(value)) {
var split = cli_options_1.explodeFilesArg(value);
const split = (0, cli_options_1.explodeFilesArg)(value);
if (split.length) {
return [incoming.set("extensions", immutable_1.List(split)), []];
return [incoming.set("extensions", (0, immutable_1.List)(split)), []];
}

@@ -13,0 +14,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var immutable_1 = require("immutable");
var cli_options_1 = require("../cli-options");
exports.handleFilesOption = void 0;
const immutable_1 = require("immutable");
const cli_options_1 = require("../cli-options");
function handleFilesOption(incoming) {
var value = incoming.get("files");
var namespaces = {
const value = incoming.get("files");
const namespaces = {
core: {

@@ -13,3 +14,3 @@ globs: [],

};
var processed = cli_options_1.makeFilesArg(value);
const processed = (0, cli_options_1.makeFilesArg)(value);
if (processed.globs.length) {

@@ -21,5 +22,5 @@ namespaces.core.globs = processed.globs;

}
return [incoming.set("files", immutable_1.fromJS(namespaces)), []];
return [incoming.set("files", (0, immutable_1.fromJS)(namespaces)), []];
}
exports.handleFilesOption = handleFilesOption;
//# sourceMappingURL=handleFilesOption.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var immutable_1 = require("immutable");
exports.handleGhostModeOption = void 0;
const immutable_1 = require("immutable");
function handleGhostModeOption(incoming) {
var value = incoming.get("ghostMode");
const value = incoming.get("ghostMode");
var trueAll = {

@@ -25,6 +26,6 @@ clicks: true,

if (value === false || value === "false") {
return [incoming.set("ghostMode", immutable_1.fromJS(falseAll)), []];
return [incoming.set("ghostMode", (0, immutable_1.fromJS)(falseAll)), []];
}
if (value === true || value === "true") {
return [incoming.set("ghostMode", immutable_1.fromJS(trueAll)), []];
return [incoming.set("ghostMode", (0, immutable_1.fromJS)(trueAll)), []];
}

@@ -34,3 +35,3 @@ if (value.get("forms") === false) {

incoming.set("ghostMode", value.withMutations(function (map) {
map.set("forms", immutable_1.fromJS({
map.set("forms", (0, immutable_1.fromJS)({
submit: false,

@@ -47,3 +48,3 @@ inputs: false,

incoming.set("ghostMode", value.withMutations(function (map) {
map.set("forms", immutable_1.fromJS({
map.set("forms", (0, immutable_1.fromJS)({
submit: true,

@@ -50,0 +51,0 @@ inputs: true,

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var bin_1 = require("../../bin");
exports.handleHostOption = void 0;
const bin_1 = require("../../bin");
function handleHostOption(incoming) {
var host = incoming.get("host");
var listen = incoming.get("listen");
const host = incoming.get("host");
const listen = incoming.get("listen");
if (host && listen) {

@@ -16,3 +17,3 @@ if (host !== listen) {

error: new Error("Cannot specify both `host` and `listen` options"),
meta: function () {
meta() {
return [

@@ -19,0 +20,0 @@ "",

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var immutable_1 = require("immutable");
exports.handlePortsOption = void 0;
const immutable_1 = require("immutable");
function handlePortsOption(incoming) {
var value = incoming.get("ports");
const value = incoming.get("ports");
if (!value)
return [incoming, []];
var obj = { min: null, max: null };
const obj = { min: null, max: null };
if (typeof value === "string") {
if (~value.indexOf(",")) {
var segs = value.split(",");
const segs = value.split(",");
obj.min = parseInt(segs[0], 10);

@@ -24,5 +25,5 @@ obj.max = parseInt(segs[1], 10);

}
return [incoming.set("ports", immutable_1.Map(obj)), []];
return [incoming.set("ports", (0, immutable_1.Map)(obj)), []];
}
exports.handlePortsOption = handlePortsOption;
//# sourceMappingURL=handlePortsOption.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var url = require("url");
var immutable_1 = require("immutable");
exports.handleProxyOption = void 0;
const url = require("url");
const immutable_1 = require("immutable");
function handleProxyOption(incoming) {
var value = incoming.get("proxy");
var mw;
var target;
let value = incoming.get("proxy");
let mw;
let target;
if (!value || value === true) {

@@ -18,3 +19,3 @@ return [incoming, []];

target = value;
value = immutable_1.Map({});
value = (0, immutable_1.Map)({});
}

@@ -24,9 +25,9 @@ if (!target.match(/^(https?):\/\//)) {

}
var parsedUrl = url.parse(target);
const parsedUrl = url.parse(target);
if (!parsedUrl.port) {
parsedUrl.port = "80";
}
var out = {
const out = {
target: parsedUrl.protocol + "//" + parsedUrl.host,
url: immutable_1.Map(parsedUrl)
url: (0, immutable_1.Map)(parsedUrl)
};

@@ -36,3 +37,3 @@ if (mw) {

}
var proxyOutput = value.mergeDeep(out);
const proxyOutput = value.mergeDeep(out);
return [incoming.set("proxy", proxyOutput), []];

@@ -39,0 +40,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var immutable_1 = require("immutable");
exports.handleServerOption = void 0;
const immutable_1 = require("immutable");
function handleServerOption(incoming) {
var value = incoming.get("server");
const value = incoming.get("server");
if (value === false) {

@@ -11,25 +12,25 @@ return [incoming, []];

if (value === true) {
var obj = {
const obj = {
baseDir: ["./"]
};
return [incoming.set("server", immutable_1.fromJS(obj)), []];
return [incoming.set("server", (0, immutable_1.fromJS)(obj)), []];
}
// server: "./app"
if (typeof value === "string") {
var obj = {
const obj = {
baseDir: [value]
};
return [incoming.set("server", immutable_1.fromJS(obj)), []];
return [incoming.set("server", (0, immutable_1.fromJS)(obj)), []];
}
if (immutable_1.List.isList(value)) {
var obj = {
const obj = {
baseDir: value
};
return [incoming.set("server", immutable_1.fromJS(obj)), []];
return [incoming.set("server", (0, immutable_1.fromJS)(obj)), []];
}
if (immutable_1.Map.isMap(value)) {
var dirs = immutable_1.List([])
const dirs = (0, immutable_1.List)([])
.concat(value.get("baseDir", "./"))
.filter(Boolean);
var merged = value.merge({ baseDir: dirs });
const merged = value.merge({ baseDir: dirs });
return [incoming.set("server", merged), []];

@@ -36,0 +37,0 @@ }

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

enabled: function (options) {
var userValue = options.get("snippet");
const userValue = options.get("snippet");
if (typeof userValue === "boolean") {

@@ -23,0 +23,0 @@ return userValue;

@@ -9,3 +9,3 @@ var utils = require("./utils");

function fileChanges(subject, options) {
var operators = [
const operators = [
{

@@ -20,9 +20,9 @@ option: "reloadThrottle",

];
var scheduler = options.getIn(["debug", "scheduler"]);
const scheduler = options.getIn(["debug", "scheduler"]);
/**
* Create a stream buffered/debounced stream of events
*/
var initial = getAggregatedDebouncedStream(subject, options, scheduler);
const initial = getAggregatedDebouncedStream(subject, options, scheduler);
return applyOperators(operators, initial, options, scheduler).map(function (items) {
var paths = items.map(function (x) { return x.path; });
const paths = items.map(x => x.path);
if (utils.willCauseReload(paths, options.get("injectFileTypes").toJS())) {

@@ -29,0 +29,0 @@ return {

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

var getBody = require("raw-body");
var permittedSocketEvents = [
const permittedSocketEvents = [
"file:reload",

@@ -53,15 +53,15 @@ "browser:reload",

if (err) {
var output_1 = ["Error: could not parse JSON."];
const output = ["Error: could not parse JSON."];
res.writeHead(500, { "Content-Type": "text/plain" });
return res.end(output_1.join("\n"));
return res.end(output.join("\n"));
}
try {
var _a = JSON.parse(body.toString()), name = _a[0], payload = _a[1];
const [name, payload] = JSON.parse(body.toString());
bs.io.sockets.emit(name, payload);
return res.end("Browsersync HTTP Protocol received: " + name + " " + JSON.stringify(payload));
return res.end(`Browsersync HTTP Protocol received: ${name} ${JSON.stringify(payload)}`);
}
catch (e) {
var output_2 = ["Error: " + e.message];
const output = [`Error: ${e.message}`];
res.writeHead(500, { "Content-Type": "text/plain" });
return res.end(output_2.join("\n"));
return res.end(output.join("\n"));
}

@@ -68,0 +68,0 @@ });

@@ -56,7 +56,6 @@ "use strict";

*/
"browser:reload": function (bs, data) {
if (data === void 0) { data = {}; }
"browser:reload": function (bs, data = {}) {
if (canLogFileChange(bs)) {
if (data.files && data.files.length > 1) {
return logger.info("{cyan:Reloading Browsers... (buffered " + data.files.length + " events)");
return logger.info(`{cyan:Reloading Browsers... (buffered ${data.files.length} events)`);
}

@@ -102,3 +101,3 @@ logger.info("{cyan:Reloading Browsers...");

"service:running": function (bs, data) {
var type = data.type;
const type = data.type;
if (bs.options.get("json")) {

@@ -105,0 +104,0 @@ return console.log(JSON.stringify({

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var _ = require("./lodash.custom");
var Immutable = require("immutable");
var defaultConfig = require("./default-config");
exports.setUiPort = exports.setMiddleware = exports.fixSnippetIncludePaths = exports.fixSnippetIgnorePaths = exports.fixRewriteRules = exports.liftExtensionsOptionFromCli = exports.setServerOpts = exports.setNamespace = exports.setStartPath = exports.setScheme = exports.setMode = exports.setOpen = exports.setProxyWs = void 0;
const _ = require("./lodash.custom");
const Immutable = require("immutable");
const defaultConfig = require("./default-config");
/**

@@ -40,3 +41,3 @@ * Move top-level ws options to proxy.ws

function setMode(incoming) {
var output = incoming.set("mode", (function () {
const output = incoming.set("mode", (function () {
if (incoming.get("server")) {

@@ -43,0 +44,0 @@ return "server";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var _ = require("../lodash.custom");
var cli_options_1 = require("../cli/cli-options");
const cli_options_1 = require("../cli/cli-options");
/**

@@ -21,3 +21,3 @@ * @param {BrowserSync} browserSync

if (browserSync.active) {
return args.cb(new Error("Instance: " + name + " is already running!"));
return args.cb(new Error(`Instance: ${name} is already running!`));
}

@@ -27,5 +27,5 @@ // Env specific items

args.config.cwd = args.config.cwd || process.cwd();
var _a = cli_options_1.merge(args.config), opts = _a[0], errors = _a[1];
const [opts, errors] = (0, cli_options_1.merge)(args.config);
if (errors.length) {
return args.cb(new Error(cli_options_1.printErrors(errors)));
return args.cb(new Error((0, cli_options_1.printErrors)(errors)));
}

@@ -32,0 +32,0 @@ return browserSync.init(opts, args.cb);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function default_1() {
var serveStatic = require("serve-static");
const serveStatic = require("serve-static");
/**

@@ -9,3 +9,3 @@ * Adding a custom mime-type for wasm whilst we wait for

*/
var send = require("send");
const send = require("send");
send.mime.define({ "application/wasm": ["wasm"] });

@@ -12,0 +12,0 @@ return serveStatic;

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

});
var mwStack = []
const mwStack = []
.concat(beforeMiddlewares, defaultMiddlewares, afterMiddlewares)

@@ -210,0 +210,0 @@ .filter(Boolean);

@@ -85,5 +85,5 @@ "use strict";

getClientJs: function (port, options) {
return function () {
var script = options.get("minify") ? "index.min.js" : "index.js";
var client = fs.readFileSync(require.resolve("browser-sync-client/dist/" + script), "utf8");
return () => {
const script = options.get("minify") ? "index.min.js" : "index.js";
const client = fs.readFileSync(require.resolve("browser-sync-client/dist/" + script), "utf8");
return [connectUtils.socketConnector(options), client].join(";\n");

@@ -90,0 +90,0 @@ };

"use strict";
var socket = require("socket.io");
var utils = require("./server/utils");
Object.defineProperty(exports, "__esModule", { value: true });
exports.init = exports.plugin = void 0;
const socket_io_1 = require("socket.io");
const utils = require("./server/utils");
/**

@@ -8,5 +10,6 @@ * Plugin interface

*/
module.exports.plugin = function (server, clientEvents, bs) {
function plugin(server, clientEvents, bs) {
return exports.init(server, clientEvents, bs);
};
}
exports.plugin = plugin;
/**

@@ -17,3 +20,3 @@ * @param {http.Server} server

*/
module.exports.init = function (server, clientEvents, bs) {
function init(server, clientEvents, bs) {
var emitter = bs.events;

@@ -31,15 +34,13 @@ var socketConfig = bs.options.get("socket").toJS();

socketIoConfig.path = socketConfig.path;
var io = socket(server, socketIoConfig);
// Override default namespace.
io.sockets = io.of(socketConfig.namespace);
io.set("heartbeat interval", socketConfig.clients.heartbeatTimeout);
// Breaking change was introduced https://socket.io/blog/socket-io-2-4-0/
io.origins(function (_, callback) {
callback(null, true);
const io = new socket_io_1.Server();
io.attach(server, Object.assign(Object.assign({}, socketIoConfig), { pingTimeout: socketConfig.clients.heartbeatTimeout, cors: {
credentials: true,
"origin": (origin, cb) => {
return cb(null, origin);
},
} }));
io.of(socketConfig.namespace).on('connection', (socket) => {
handleConnection(socket);
});
/**
* Listen for new connections
*/
io.sockets.on("connection", handleConnection);
/**
* Handle each new connection

@@ -64,3 +65,3 @@ * @param {Object} client

function addEvent(event) {
client.on(event, function (data) {
client.on(event, data => {
client.broadcast.emit(event, data);

@@ -70,4 +71,7 @@ });

}
// @ts-ignore
io.sockets = io.of(socketConfig.namespace);
return io;
};
}
exports.init = init;
//# sourceMappingURL=sockets.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var devIp = require("dev-ip");
exports.devIp = exports.UAParser = exports.easyExtender = exports.serveStatic = exports.connect = exports.portscanner = exports.defaultCallback = exports.arrayify = exports.eachSeries = exports.verifyConfig = exports.getConfigErrors = exports.isMap = exports.isList = exports.willCauseReload = exports.xip = exports.fail = exports.opnWrapper = exports.openBrowser = exports.getUaString = exports.getPort = exports.getPorts = exports._makeUrl = exports.getUrls = exports.getUrl = exports.getUrlOptions = exports.getHostIp = void 0;
const devIp = require("dev-ip");
exports.devIp = devIp;
var portScanner = require("portscanner");
var path = require("path");
var UAParser = require("ua-parser-js");
const portScanner = require("portscanner");
const path = require("path");
const UAParser = require("ua-parser-js");
exports.UAParser = UAParser;
var Immutable = require("immutable");
var immutable_1 = require("immutable");
var _ = require("./lodash.custom");
var parser = new UAParser();
const Immutable = require("immutable");
const immutable_1 = require("immutable");
const _ = require("./lodash.custom");
const parser = new UAParser();
/**

@@ -35,14 +36,14 @@ * @param {Object} options

function getUrlOptions(options) {
var scheme = options.get("scheme");
var port = options.get("port");
var urls = {};
var listen = options.get("listen");
const scheme = options.get("scheme");
const port = options.get("port");
const urls = {};
const listen = options.get("listen");
if (options.get("online") === false || listen) {
var host = listen || "localhost";
urls.local = getUrl(scheme + "://" + host + ":" + port, options);
const host = listen || "localhost";
urls.local = getUrl(`${scheme}://${host}:${port}`, options);
return Immutable.fromJS(urls);
}
var fn = exports.getHostIp;
var external = xip(fn(options, devIp()), options);
var localhost = "localhost";
const fn = exports.getHostIp;
const external = xip(fn(options, devIp()), options);
let localhost = "localhost";
if (options.get("xip")) {

@@ -141,4 +142,4 @@ localhost = "127.0.0.1";

function openBrowser(url, options, bs) {
var open = options.get("open");
var browser = options.get("browser");
const open = options.get("open");
const browser = options.get("browser");
if (_.isString(open)) {

@@ -149,6 +150,6 @@ if (options.getIn(["urls", open])) {

}
var fn = exports.opnWrapper;
const fn = exports.opnWrapper;
if (open) {
if (browser !== "default") {
if (exports.isList(browser)) {
if ((0, exports.isList)(browser)) {
browser.forEach(function (browser) {

@@ -155,0 +156,0 @@ fn(url, browser, bs);

{
"name": "browser-sync",
"description": "Live CSS Reload & Browser Syncing",
"version": "2.27.7",
"version": "2.27.8",
"homepage": "https://browsersync.io/",

@@ -33,7 +33,8 @@ "author": {

"test": "npm run build && npm run env && npm run unit",
"unit": "mocha --recursive test/specs --timeout 10000 --bail --exit"
"unit": "mocha --recursive test/specs --timeout 10000 --bail --exit",
"watch": "npm run build && node dist/bin test/fixtures -w --no-open"
},
"dependencies": {
"browser-sync-client": "^2.27.7",
"browser-sync-ui": "^2.27.7",
"browser-sync-client": "^2.27.8",
"browser-sync-ui": "^2.27.8",
"bs-recipes": "1.3.4",

@@ -64,3 +65,3 @@ "bs-snippet-injector": "^2.0.1",

"server-destroy": "1.0.1",
"socket.io": "2.4.0",
"socket.io": "^4.4.1",
"ua-parser-js": "1.0.2",

@@ -87,3 +88,3 @@ "yargs": "^15.4.1"

"supertest": "^3",
"typescript": "3.0.3",
"typescript": "^4.6.2",
"vinyl": "1.2.0"

@@ -97,3 +98,3 @@ },

],
"gitHead": "a7c14c873b4ad14fdbdc1e07eaac0fc30af2e645"
"gitHead": "88402821e1bd99ecd05e34f9df159bd9f81ff778"
}

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

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

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