Template Upload
This commit is contained in:
17
node_modules/browser-sync/lib/public/exit.js
generated
vendored
Normal file
17
node_modules/browser-sync/lib/public/exit.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* @param {BrowserSync} browserSync
|
||||
* @returns {Function}
|
||||
*/
|
||||
module.exports = function (browserSync) {
|
||||
|
||||
function exit() {
|
||||
if (browserSync.active) {
|
||||
browserSync.events.emit("service:exit");
|
||||
browserSync.cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
return exit;
|
||||
};
|
32
node_modules/browser-sync/lib/public/init.js
generated
vendored
Normal file
32
node_modules/browser-sync/lib/public/init.js
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
|
||||
var _ = require("../../lodash.custom");
|
||||
var merge = require("../cli/cli-options").merge;
|
||||
|
||||
/**
|
||||
* @param {BrowserSync} browserSync
|
||||
* @param {String} [name] - instance name
|
||||
* @param {Object} pjson
|
||||
* @returns {Function}
|
||||
*/
|
||||
module.exports = function (browserSync, name, pjson) {
|
||||
|
||||
return function () {
|
||||
|
||||
/**
|
||||
* Handle new + old signatures for init.
|
||||
*/
|
||||
var args = require("../args")(_.toArray(arguments));
|
||||
|
||||
/**
|
||||
* If the current instance is already running, just return an error
|
||||
*/
|
||||
if (browserSync.active) {
|
||||
return args.cb(new Error("Instance: " + name + " is already running!"));
|
||||
}
|
||||
|
||||
args.config.version = pjson.version;
|
||||
|
||||
return browserSync.init(merge(args.config), args.cb);
|
||||
};
|
||||
};
|
19
node_modules/browser-sync/lib/public/notify.js
generated
vendored
Normal file
19
node_modules/browser-sync/lib/public/notify.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* @param {BrowserSync} browserSync
|
||||
* @returns {Function}
|
||||
*/
|
||||
module.exports = function (browserSync) {
|
||||
|
||||
return function (msg, timeout) {
|
||||
|
||||
if (msg) {
|
||||
browserSync.events.emit("browser:notify", {
|
||||
message: msg,
|
||||
timeout: timeout || 2000,
|
||||
override: true
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
12
node_modules/browser-sync/lib/public/pause.js
generated
vendored
Normal file
12
node_modules/browser-sync/lib/public/pause.js
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* @param {BrowserSync} browserSync
|
||||
* @returns {Function}
|
||||
*/
|
||||
module.exports = function (browserSync) {
|
||||
|
||||
return function () {
|
||||
browserSync.paused = true;
|
||||
};
|
||||
};
|
65
node_modules/browser-sync/lib/public/public-utils.js
generated
vendored
Normal file
65
node_modules/browser-sync/lib/public/public-utils.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
"use strict";
|
||||
|
||||
var _ = require("../../lodash.custom");
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Emit the internal `file:change` event
|
||||
* @param {EventEmitter} emitter
|
||||
* @param {string} path
|
||||
* @param {boolean} [log]
|
||||
*/
|
||||
emitChangeEvent: function emitChangeEvent (emitter, path, log) {
|
||||
emitter.emit("file:changed", {
|
||||
path: path,
|
||||
log: log,
|
||||
namespace: "core",
|
||||
event: "change"
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Emit the internal `browser:reload` event
|
||||
* @param {EventEmitter} emitter
|
||||
*/
|
||||
emitBrowserReload: function emitChangeEvent (emitter) {
|
||||
emitter.emit("_browser:reload");
|
||||
},
|
||||
/**
|
||||
* Emit the internal `stream:changed` event
|
||||
* @param {EventEmitter} emitter
|
||||
* @param {Array} changed
|
||||
*/
|
||||
emitStreamChangedEvent: function (emitter, changed) {
|
||||
emitter.emit("stream:changed", {changed: changed});
|
||||
},
|
||||
/**
|
||||
* This code handles the switch between .reload & .stream
|
||||
* since 2.6.0
|
||||
* @param name
|
||||
* @param args
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isStreamArg: function (name, args) {
|
||||
|
||||
if (name === "stream") {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (name !== "reload") {
|
||||
return false;
|
||||
}
|
||||
|
||||
var firstArg = args[0];
|
||||
|
||||
/**
|
||||
* If here, it's reload with args
|
||||
*/
|
||||
if (_.isObject(firstArg)) {
|
||||
if (!Array.isArray(firstArg) && Object.keys(firstArg).length) {
|
||||
return firstArg.stream === true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
67
node_modules/browser-sync/lib/public/reload.js
generated
vendored
Normal file
67
node_modules/browser-sync/lib/public/reload.js
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
|
||||
var utils = require("../utils");
|
||||
var publicUtils = require("./public-utils");
|
||||
var _ = require("../../lodash.custom");
|
||||
var defaultConfig = require("../default-config");
|
||||
var stream = require("./stream");
|
||||
|
||||
/**
|
||||
* @param emitter
|
||||
* @returns {Function}
|
||||
*/
|
||||
module.exports = function (emitter) {
|
||||
|
||||
/**
|
||||
* Inform browsers about file changes.
|
||||
*
|
||||
* eg: reload("core.css")
|
||||
*/
|
||||
function browserSyncReload (opts) {
|
||||
|
||||
/**
|
||||
* BACKWARDS COMPATIBILITY:
|
||||
* Passing an object as the only arg to the `reload`
|
||||
* method with at *least* the key-value pair of {stream: true},
|
||||
* was only ever used for streams support - so it's safe to check
|
||||
* for that signature here and defer to the
|
||||
* dedicated `.stream()` method instead.
|
||||
*/
|
||||
if (_.isObject(opts)) {
|
||||
if (!Array.isArray(opts) && Object.keys(opts).length) {
|
||||
if (opts.stream === true) {
|
||||
return stream(emitter)(opts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle single string paths such as
|
||||
* reload("core.css")
|
||||
*/
|
||||
if (typeof opts === "string" && opts !== "undefined") {
|
||||
return publicUtils.emitChangeEvent(emitter, opts, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an array of file paths such as
|
||||
* reload(["core.css, "ie.css"])
|
||||
*/
|
||||
if (Array.isArray(opts)) {
|
||||
return opts.forEach(function (filepath) {
|
||||
publicUtils.emitChangeEvent(emitter, filepath, true);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* At this point the argument given was neither an object,
|
||||
* array or string so we simply perform a reload. This is to
|
||||
* allow the following syntax to work as expected
|
||||
*
|
||||
* reload();
|
||||
*/
|
||||
return publicUtils.emitBrowserReload(emitter);
|
||||
}
|
||||
|
||||
return browserSyncReload;
|
||||
};
|
12
node_modules/browser-sync/lib/public/resume.js
generated
vendored
Normal file
12
node_modules/browser-sync/lib/public/resume.js
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* @param {BrowserSync} browserSync
|
||||
* @returns {Function}
|
||||
*/
|
||||
module.exports = function (browserSync) {
|
||||
|
||||
return function () {
|
||||
browserSync.paused = false;
|
||||
};
|
||||
};
|
3
node_modules/browser-sync/lib/public/socket.io.min.1.6.0.js
generated
vendored
Normal file
3
node_modules/browser-sync/lib/public/socket.io.min.1.6.0.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
98
node_modules/browser-sync/lib/public/stream.js
generated
vendored
Normal file
98
node_modules/browser-sync/lib/public/stream.js
generated
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
"use strict";
|
||||
|
||||
var path = require("path");
|
||||
var micromatch = require("micromatch");
|
||||
var utils = require("./public-utils");
|
||||
|
||||
/**
|
||||
* @param emitter
|
||||
* @returns {Function}
|
||||
*/
|
||||
module.exports = function (emitter) {
|
||||
|
||||
/**
|
||||
* Return a transform/through stream that listens to file
|
||||
* paths and fires internal Browsersync events.
|
||||
* @param {{once: boolean, match: string|array}} [opts]
|
||||
* @returns {Stream.Transform}
|
||||
*/
|
||||
function browserSyncThroughStream (opts) {
|
||||
|
||||
opts = opts || {};
|
||||
var emitted = false;
|
||||
var Transform = require("stream").Transform;
|
||||
var reload = new Transform({objectMode: true});
|
||||
var changed = [];
|
||||
|
||||
reload._transform = function (file, encoding, next) {
|
||||
|
||||
var stream = this;
|
||||
|
||||
/**
|
||||
* End is always called to send the current file down
|
||||
* stream. Browsersync never acts upon a stream,
|
||||
* we only `listen` to it.
|
||||
*/
|
||||
function end () {
|
||||
stream.push(file); // always send the file down-stream
|
||||
next();
|
||||
}
|
||||
|
||||
/**
|
||||
* If {match: <pattern>} was provided, test the
|
||||
* current filepath against it
|
||||
*/
|
||||
if (opts.match) {
|
||||
if (!micromatch(file.path, opts.match, {dot: true}).length) {
|
||||
return end();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* if {once: true} provided, emit the reload event for the
|
||||
* first file only
|
||||
*/
|
||||
if (opts.once === true && !emitted) {
|
||||
|
||||
utils.emitBrowserReload(emitter);
|
||||
|
||||
emitted = true;
|
||||
|
||||
} else { // handle multiple
|
||||
|
||||
if (opts.once === true && emitted) {
|
||||
|
||||
} else {
|
||||
|
||||
if (file.path) {
|
||||
|
||||
emitted = true;
|
||||
utils.emitChangeEvent(emitter, file.path, false);
|
||||
changed.push(path.basename(file.path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end();
|
||||
};
|
||||
|
||||
/**
|
||||
* When this current operation has finished, emit the
|
||||
* steam:changed event so that any loggers can pick up it
|
||||
* @param next
|
||||
* @private
|
||||
*/
|
||||
reload._flush = function (next) {
|
||||
|
||||
if (changed.length) {
|
||||
utils.emitStreamChangedEvent(emitter, changed);
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
return reload;
|
||||
}
|
||||
|
||||
return browserSyncThroughStream;
|
||||
};
|
Reference in New Issue
Block a user