Template Upload

This commit is contained in:
SOUTHERNCO\x2mjbyrn committed 2017-05-17 13:45:25 -04:00
1 parent 415b9c25f3
commit 7efe7605b8
11476 files changed
+2170865 -34

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
# browser-sync-client [![Build Status](https://travis-ci.org/BrowserSync/browser-sync-client.svg)](https://travis-ci.org/BrowserSync/browser-sync-client)
Client-side script for BrowserSync
## Contributors
```
177 Shane Osbourne
2 Sergey Slipchenko
1 Hugo Dias
1 Shinnosuke Watanabe
1 Tim Schaub
1 Shane Daniel
1 Matthieu Vachon
```
## License
Copyright (c) 2014 Shane Osbourne
Licensed under the MIT license.
View File
Whitespace-only changes.
+2030
View File
File diff suppressed because it is too large. Load diff
+1
View File
@@ -0,0 +1 @@
!function t(e,n,o){function r(s,c){if(!n[s]){if(!e[s]){var a="function"==typeof require&&require;if(!c&&a)return a(s,!0);if(i)return i(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[s]={exports:{}};e[s][0].call(u.exports,function(t){var n=e[s][1][t];return r(n?n:t)},u,u.exports,t,e,n,o)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)r(o[s]);return r}({1:[function(t,e,n){"use strict";function o(t){return"undefined"==typeof t}function r(t,e){for(var n=0,o=e.split("."),r=o.length;r>n;n++){if(!t||"object"!=typeof t)return!1;t=t[o[n]]}return"undefined"==typeof t?!1:t}var i=t("./socket"),s=t("./emitter"),c=(t("./notify"),t("./tab"),t("./browser.utils")),a=function(t){this.options=t,this.socket=i,this.emitter=s,this.utils=c,this.tabHidden=!1;var e=this;i.on("options:set",function(t){s.emit("notify","Setting options..."),e.options=t.options}),s.on("tab:hidden",function(){e.tabHidden=!0}),s.on("tab:visible",function(){e.tabHidden=!1})};a.prototype.canSync=function(t,e){if(t=t||{},t.override)return!0;var n=!0;return e&&(n=this.getOption(e)),n&&t.url===window.location.pathname},a.prototype.getOption=function(t){if(t&&t.match(/\./))return r(this.options,t);var e=this.options[t];return o(e)?!1:e},e.exports=a},{"./browser.utils":2,"./emitter":5,"./notify":16,"./socket":17,"./tab":18}],2:[function(t,e,n){"use strict";var o=n;o.getWindow=function(){return window},o.getDocument=function(){return document},o.getBody=function(){return document.getElementsByTagName("body")[0]},o.getBrowserScrollPosition=function(){var t,e,o=n.getWindow(),r=n.getDocument(),i=r.documentElement,s=r.body;return void 0!==o.pageYOffset?(t=o.pageXOffset,e=o.pageYOffset):(t=i.scrollLeft||s.scrollLeft||0,e=i.scrollTop||s.scrollTop||0),{x:t,y:e}},o.getScrollSpace=function(){var t=n.getDocument(),e=t.documentElement,o=t.body;return{x:o.scrollHeight-e.clientWidth,y:o.scrollHeight-e.clientHeight}},o.saveScrollPosition=function(){var t=o.getBrowserScrollPosition();t=[t.x,t.y],o.getDocument.cookie="bs_scroll_pos="+t.join(",")},o.restoreScrollPosition=function(){var t=o.getDocument().cookie.replace(/(?:(?:^|.*;\s*)bs_scroll_pos\s*\=\s*([^;]*).*$)|^.*$/,"$1").split(",");o.getWindow().scrollTo(t[0],t[1])},o.getElementIndex=function(t,e){var n=o.getDocument().getElementsByTagName(t);return Array.prototype.indexOf.call(n,e)},o.forceChange=function(t){t.blur(),t.focus()},o.getElementData=function(t){var e=t.tagName,n=o.getElementIndex(e,t);return{tagName:e,index:n}},o.getSingleElement=function(t,e){var n=o.getDocument().getElementsByTagName(t);return n[e]},o.getBody=function(){return o.getDocument().getElementsByTagName("body")[0]},o.setScroll=function(t){o.getWindow().scrollTo(t.x,t.y)},o.reloadBrowser=function(){o.getWindow().location.reload(!0)},o.forEach=function(t,e){for(var n=0,o=t.length;o>n;n+=1)e(t[n],n,t)},o.isOldIe=function(){return"undefined"!=typeof o.getWindow().attachEvent},o.getLocation=function(t){var e=o.getDocument().createElement("a");return e.href=t,""===e.host&&(e.href=e.href),e}},{}],3:[function(t,e,n){"indexOf"in Array.prototype||(Array.prototype.indexOf=function(t,e){void 0===e&&(e=0),0>e&&(e+=this.length),0>e&&(e=0);for(var n=this.length;n>e;e+=1)if(e in this&&this[e]===t)return e;return-1}),Array.prototype.map||(Array.prototype.map=function(t,e){var n,o,r;if(null==this)throw new TypeError(" this is null or not defined");var i=Object(this),s=i.length>>>0;if("function"!=typeof t)throw new TypeError(t+" is not a function");for(arguments.length>1&&(n=e),o=new Array(s),r=0;s>r;){var c,a;r in i&&(c=i[r],a=t.call(n,c,r,i),o[r]=a),r++}return o}),Array.prototype.filter||(Array.prototype.filter=function(t){"use strict";if(void 0===this||null===this)throw new TypeError;var e=Object(this),n=e.length>>>0;if("function"!=typeof t)throw new TypeError;for(var o=[],r=arguments.length>=2?arguments[1]:void 0,i=0;n>i;i++)if(i in e){var s=e[i];t.call(r,s,i,e)&&o.push(s)}return o})},{}],4:[function(t,e,n){"use strict";var o,r=t("./events"),i=t("./browser.utils"),s=t("./emitter"),c=n,a={tagNames:{css:"link",jpg:"img",jpeg:"img",png:"img",svg:"img",gif:"img",js:"script"},attrs:{link:"href",img:"src",script:"src"},blacklist:[function(t){return"map"===t.ext}]},l="codeSync",u=function(){return window.location.pathname};c.init=function(t){t.options.tagNames&&(a.tagNames=t.options.tagNames),"window.name"===t.options.scrollRestoreTechnique?c.saveScrollInName(s):c.saveScrollInCookie(i.getWindow(),i.getDocument()),t.socket.on("file:reload",c.reload(t)),t.socket.on("browser:reload",function(){t.canSync({url:u()},l)&&c.reloadBrowser(!0,t)})},c.saveScrollInName=function(){var t="<<BS_START>>",e="<<BS_END>>",n=new RegExp(t+"(.+?)"+e),o=i.getWindow(),r={};s.on("browser:hardReload",function(n){var r=[o.name,t,JSON.stringify({bs:{hardReload:!0,scroll:n.scrollPosition}}),e].join("");o.name=r});try{var c=o.name.match(n);c&&(r=JSON.parse(c[1]))}catch(a){r={}}r.bs&&r.bs.hardReload&&r.bs.scroll&&iLine truncated
+144
View File
@@ -0,0 +1,144 @@
"use strict";
var etag = require("etag");
var fresh = require("fresh");
var fs = require("fs");
var path = require("path");
var zlib = require("zlib");
var minifiedScript = path.join(__dirname, "/dist/index.min.js");
var unminifiedScript = path.join(__dirname, "/dist/index.js");
/**
* Does the current request support compressed encoding?
* @param {Object} req
* @returns {boolean}
*/
function supportsGzip (req) {
var accept = req.headers['accept-encoding'];
return accept && accept.indexOf('gzip') > -1;
}
/**
* Set headers on the response
* @param {Object} res
* @param {String} body
*/
function setHeaders(res, body) {
res.setHeader("Cache-Control", "public, max-age=0");
res.setHeader("Content-Type", "text/javascript");
res.setHeader("ETag", etag(body));
}
/**
* @param {Object} options
* @param {String} connector
* @returns {String}
*/
function getScriptBody(options, connector) {
var script = minifiedScript;
if (options && !options.minify) {
script = unminifiedScript;
}
return connector + fs.readFileSync(script);
}
/**
* @param {Object} req
* @returns {String}
*/
function isConditionalGet(req) {
return req.headers["if-none-match"] || req.headers["if-modified-since"];
}
/**
* Return a not-modified response
* @param {Object} res
*/
function notModified(res) {
res.removeHeader("Content-Type");
res.statusCode = 304;
res.end();
}
/**
* Public method for returning either a middleware fn
* or the content as a string
* @param {Object} options
* @param {String} connector - content to be prepended
* @param {String} type - either `file` or `middleware`
* @returns {*}
*/
function init(options, connector, type) {
var gzipCached;
/**
* Combine string to create the final version
* @type {String}
*/
var requestBody = getScriptBody(options, connector);
/**
* If the user asked for a file, simply return the string.
*/
if (type && type === "file") {
return requestBody;
}
/**
* Otherwise return a function to be used a middleware
*/
return function (req, res) {
/**
* default to using the uncompressed string
* @type {String}
*/
var output = requestBody;
/**
* Set the appropriate headers for caching
*/
setHeaders(res, output);
if (isConditionalGet(req) && fresh(req.headers, res._headers)) {
return notModified(res);
}
/**
* If gzip is supported, compress the string once
* and save for future requests
*/
if (supportsGzip(req)) {
res.setHeader("Content-Encoding", "gzip");
if (!gzipCached) {
var buf = new Buffer(output, "utf-8");
zlib.gzip(buf, function (_, result) {
gzipCached = result;
res.end(result);
});
} else {
res.end(gzipCached);
}
} else {
res.end(output);
}
};
}
module.exports.middleware = init;
module.exports.plugin = init;
module.exports.minified = function () {
return fs.readFileSync(minifiedScript, 'utf8');
};
module.exports.unminified = function () {
return fs.readFileSync(unminifiedScript, 'utf8');
}
+117
View File
@@ -0,0 +1,117 @@
{
"_args": [
[
"browser-sync-client@2.5.0",
"C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\browser-sync"
]
],
"_from": "browser-sync-client@2.5.0",
"_id": "browser-sync-client@2.5.0",
"_inCache": true,
"_location": "/browser-sync-client",
"_nodeVersion": "6.10.1",
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/browser-sync-client-2.5.0.tgz_1494856130857_0.43215389852412045"
},
"_npmUser": {
"email": "shakyshane@gmail.com",
"name": "shakyshane"
},
"_npmVersion": "3.10.10",
"_phantomChildren": {},
"_requested": {
"name": "browser-sync-client",
"raw": "browser-sync-client@2.5.0",
"rawSpec": "2.5.0",
"scope": null,
"spec": "2.5.0",
"type": "version"
},
"_requiredBy": [
"/browser-sync"
],
"_resolved": "https://registry.npmjs.org/browser-sync-client/-/browser-sync-client-2.5.0.tgz",
"_shasum": "29eb4b22a53bd528ee12d97448e0f52576022230",
"_shrinkwrap": null,
"_spec": "browser-sync-client@2.5.0",
"_where": "C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\browser-sync",
"author": {
"email": "shane.osbourne8@gmail.com",
"name": "Shane Osbourne"
},
"bugs": {
"url": "https://github.com/shakyshane/browser-sync-client/issues"
},
"dependencies": {
"etag": "^1.7.0",
"fresh": "^0.3.0"
},
"description": "Client-side scripts for BrowserSync",
"devDependencies": {
"browser-sync": "^2.9.11",
"browserify": "^11.2.0",
"chai": "~1.9.0",
"crossbow": "latest",
"express": "^4.12.3",
"gulp-contribs": "0.0.2",
"gulp-jshint": "~1.4.0",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^0.2.1",
"karma": "^0.13.15",
"karma-chrome-launcher": "^0.1.3",
"karma-coverage": "^0.2.1",
"karma-firefox-launcher": "^0.1.4",
"karma-html2js-preprocessor": "^0.1.0",
"karma-mocha": "~0.1.1",
"karma-sinon": "~1.0.0",
"mocha": "^1.18.2",
"nodemon": "^1.11.0",
"sinon": "~1.8.2",
"supertest": "^0.10.0",
"through2": "^0.4.1",
"vinyl-fs": "^2.4.4",
"vinyl-source-stream": "^1.1.0"
},
"directories": {},
"dist": {
"shasum": "29eb4b22a53bd528ee12d97448e0f52576022230",
"tarball": "https://registry.npmjs.org/browser-sync-client/-/browser-sync-client-2.5.0.tgz"
},
"engines": {
"node": ">=4.0.0"
},
"files": [
"dist",
"index.js"
],
"gitHead": "d43b46e6ef82d0e2bb2d98f5c7fd2e72db609477",
"homepage": "https://github.com/shakyshane/browser-sync-client",
"installable": true,
"keywords": [],
"licenses": [
{
"type": "MIT",
"url": "https://github.com/shakyshane/browser-sync-client/blob/master/LICENSE-MIT"
}
],
"main": "index.js",
"maintainers": [
{
"name": "shakyshane",
"email": "shane.osbourne8@gmail.com"
}
],
"name": "browser-sync-client",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "git://github.com/shakyshane/browser-sync-client.git"
},
"scripts": {
"prepublish": "cb run default",
"start": "cb dev",
"test": "cb test"
},
"version": "2.5.0"
}