This commit is contained in:
2022-07-18 02:50:52 +00:00
parent befd344ab0
commit 06181b34d6
8569 changed files with 818704 additions and 352705 deletions
+1 -1
View File
@@ -91,7 +91,7 @@ Configuration options can be passed to the client by adding querystring paramete
* **quiet** - Set to `true` to disable all console logging.
* **dynamicPublicPath** - Set to `true` to use webpack `publicPath` as prefix of `path`. (We can set `__webpack_public_path__` dynamically at runtime in the entry point, see note of [output.publicPath](https://webpack.js.org/configuration/output/#output-publicpath))
* **autoConnect** - Set to `false` to use to prevent a connection being automatically opened from the client to the webpack back-end - ideal if you need to modify the options using the `setOptionsAndConnect` function
* **ansiColors** - An object to customize the client overlay colors as mentioned in the [ansi-html](https://github.com/Tjatse/ansi-html/blob/99ec49e431c70af6275b3c4e00c7be34be51753c/README.md#set-colors) package.
* **ansiColors** - An object to customize the client overlay colors as mentioned in the [ansi-html-community](https://github.com/mahdyar/ansi-html-community#set-colors) package.
* **overlayStyles** - An object to let you override or add new inline styles to the client overlay div.
* **overlayWarnings** - Set to `true` to enable client overlay on warnings in addition to errors.
+5 -6
View File
@@ -21,7 +21,7 @@ var styles = {
textAlign: 'left',
};
var ansiHTML = require('ansi-html');
var ansiHTML = require('ansi-html-community');
var colors = {
reset: ['transparent', 'transparent'],
black: '181818',
@@ -35,13 +35,12 @@ var colors = {
darkgrey: '6d7891',
};
var Entities = require('html-entities').AllHtmlEntities;
var entities = new Entities();
var htmlEntities = require('html-entities');
function showProblems(type, lines) {
clientOverlay.innerHTML = '';
lines.forEach(function(msg) {
msg = ansiHTML(entities.encode(msg));
lines.forEach(function (msg) {
msg = ansiHTML(htmlEntities.encode(msg));
var div = document.createElement('div');
div.style.marginBottom = '26px';
div.innerHTML = problemType(type) + ' in ' + msg;
@@ -73,7 +72,7 @@ function problemType(type) {
);
}
module.exports = function(options) {
module.exports = function (options) {
for (var color in options.ansiColors) {
if (color in colors) {
colors[color] = options.ansiColors[color];
+7 -7
View File
@@ -78,7 +78,7 @@ function EventSourceWrapper() {
var listeners = [];
init();
var timer = setInterval(function() {
var timer = setInterval(function () {
if (new Date() - lastActivity > options.timeout) {
handleDisconnect();
}
@@ -110,7 +110,7 @@ function EventSourceWrapper() {
}
return {
addMessageListener: function(fn) {
addMessageListener: function (fn) {
listeners.push(fn);
},
};
@@ -176,7 +176,7 @@ function createReporter() {
var previousProblems = null;
function log(type, obj) {
var newProblems = obj[type]
.map(function(msg) {
.map(function (msg) {
return strip(msg);
})
.join('\n');
@@ -205,10 +205,10 @@ function createReporter() {
}
return {
cleanProblemsCache: function() {
cleanProblemsCache: function () {
previousProblems = null;
},
problems: function(type, obj) {
problems: function (type, obj) {
if (options.warn) {
log(type, obj);
}
@@ -221,10 +221,10 @@ function createReporter() {
}
return true;
},
success: function() {
success: function () {
if (overlay) overlay.clear();
},
useCustomOverlay: function(customOverlay) {
useCustomOverlay: function (customOverlay) {
overlay = customOverlay;
},
};
+1 -1
View File
@@ -1,6 +1,6 @@
var parse = require('url').parse;
exports.pathMatch = function(url, path) {
exports.pathMatch = function (url, path) {
try {
return parse(url).pathname === path;
} catch (e) {
+13 -13
View File
@@ -33,7 +33,7 @@ function webpackHotMiddleware(compiler, opts) {
latestStats = statsResult;
publishStats('built', latestStats, eventStream, opts.log);
}
var middleware = function(req, res, next) {
var middleware = function (req, res, next) {
if (closed) return next();
if (!pathMatch(req.url, opts.path)) return next();
eventStream.handler(req, res);
@@ -43,11 +43,11 @@ function webpackHotMiddleware(compiler, opts) {
publishStats('sync', latestStats, eventStream);
}
};
middleware.publish = function(payload) {
middleware.publish = function (payload) {
if (closed) return;
eventStream.publish(payload);
};
middleware.close = function() {
middleware.close = function () {
if (closed) return;
// Can't remove compiler plugins, so we just set a flag and noop if closed
// https://github.com/webpack/tapable/issues/32#issuecomment-350644466
@@ -62,24 +62,24 @@ function createEventStream(heartbeat) {
var clientId = 0;
var clients = {};
function everyClient(fn) {
Object.keys(clients).forEach(function(id) {
Object.keys(clients).forEach(function (id) {
fn(clients[id]);
});
}
var interval = setInterval(function heartbeatTick() {
everyClient(function(client) {
everyClient(function (client) {
client.write('data: \uD83D\uDC93\n\n');
});
}, heartbeat).unref();
return {
close: function() {
close: function () {
clearInterval(interval);
everyClient(function(client) {
everyClient(function (client) {
if (!client.finished) client.end();
});
clients = {};
},
handler: function(req, res) {
handler: function (req, res) {
var headers = {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'text/event-stream;charset=utf-8',
@@ -101,13 +101,13 @@ function createEventStream(heartbeat) {
res.write('\n');
var id = clientId++;
clients[id] = res;
req.on('close', function() {
req.on('close', function () {
if (!res.finished) res.end();
delete clients[id];
});
},
publish: function(payload) {
everyClient(function(client) {
publish: function (payload) {
everyClient(function (client) {
client.write('data: ' + JSON.stringify(payload) + '\n\n');
});
},
@@ -125,7 +125,7 @@ function publishStats(action, statsResult, eventStream, log) {
});
// For multi-compiler, stats will be an object with a 'children' array of stats
var bundles = extractBundles(stats);
bundles.forEach(function(stats) {
bundles.forEach(function (stats) {
var name = stats.name || '';
// Fallback to compilation name in case of 1 bundle (if it exists)
@@ -168,7 +168,7 @@ function extractBundles(stats) {
function buildModuleMap(modules) {
var map = {};
modules.forEach(function(module) {
modules.forEach(function (module) {
map[module.id] = module.name;
});
return map;
+26 -29
View File
@@ -1,32 +1,32 @@
{
"_args": [
[
"webpack-hot-middleware@2.25.0",
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
"webpack-hot-middleware@2.25.1",
"/home/node/nuxt"
]
],
"_from": "webpack-hot-middleware@2.25.0",
"_id": "webpack-hot-middleware@2.25.0",
"_from": "webpack-hot-middleware@2.25.1",
"_id": "webpack-hot-middleware@2.25.1",
"_inBundle": false,
"_integrity": "sha512-xs5dPOrGPCzuRXNi8F6rwhawWvQQkeli5Ro48PRuQh8pYPCPmNnltP9itiUPT4xI8oW+y0m59lyyeQk54s5VgA==",
"_integrity": "sha512-Koh0KyU/RPYwel/khxbsDz9ibDivmUbrRuKSSQvW42KSDdO4w23WI3SkHpSUKHE76LrFnnM/L7JCrpBwu8AXYw==",
"_location": "/webpack-hot-middleware",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "webpack-hot-middleware@2.25.0",
"raw": "webpack-hot-middleware@2.25.1",
"name": "webpack-hot-middleware",
"escapedName": "webpack-hot-middleware",
"rawSpec": "2.25.0",
"rawSpec": "2.25.1",
"saveSpec": null,
"fetchSpec": "2.25.0"
"fetchSpec": "2.25.1"
},
"_requiredBy": [
"/@nuxt/webpack"
],
"_resolved": "https://registry.npmjs.org/webpack-hot-middleware/-/webpack-hot-middleware-2.25.0.tgz",
"_spec": "2.25.0",
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
"_resolved": "https://registry.npmjs.org/webpack-hot-middleware/-/webpack-hot-middleware-2.25.1.tgz",
"_spec": "2.25.1",
"_where": "/home/node/nuxt",
"author": {
"name": "Glen Mailer",
"email": "glen@stainlessed.co.uk"
@@ -35,21 +35,21 @@
"url": "https://github.com/webpack-contrib/webpack-hot-middleware/issues"
},
"dependencies": {
"ansi-html": "0.0.7",
"html-entities": "^1.2.0",
"ansi-html-community": "0.0.8",
"html-entities": "^2.1.0",
"querystring": "^0.2.0",
"strip-ansi": "^3.0.0"
"strip-ansi": "^6.0.0"
},
"description": "Webpack hot reloading you can attach to your own server",
"devDependencies": {
"eslint": "^5.14.1",
"eslint-plugin-prettier": "^3.0.1",
"express": "^4.13.3",
"istanbul": "^0.4.2",
"mocha": "^5.2.0",
"prettier": "^1.16.4",
"sinon": "^1.12.2",
"supertest": "^3.1.0",
"eslint": "^7.19.0",
"eslint-plugin-prettier": "^3.3.1",
"express": "^4.17.1",
"mocha": "^8.2.1",
"nyc": "^15.1.0",
"prettier": "^2.2.1",
"sinon": "^9.2.4",
"supertest": "^6.1.3",
"webpack": "^4.20.2",
"webpack-dev-middleware": "^3.4.0"
},
@@ -77,13 +77,10 @@
"url": "git+https://github.com/webpack-contrib/webpack-hot-middleware.git"
},
"scripts": {
"ci:coverage": "npm run test:coverage",
"ci:lint": "npm run lint && npm run security",
"ci:test": "npm run test",
"coverage": "nyc npm run test",
"lint": "eslint . --max-warnings 0",
"security": "npm audit",
"test": "mocha",
"test:coverage": "istanbul cover _mocha --"
"prettier": "prettier --write .",
"test": "mocha"
},
"version": "2.25.0"
"version": "2.25.1"
}
+11 -11
View File
@@ -18,17 +18,17 @@ var applyOptions = {
ignoreUnaccepted: true,
ignoreDeclined: true,
ignoreErrored: true,
onUnaccepted: function(data) {
onUnaccepted: function (data) {
console.warn(
'Ignored an update to unaccepted module ' + data.chain.join(' -> ')
);
},
onDeclined: function(data) {
onDeclined: function (data) {
console.warn(
'Ignored an update to declined module ' + data.chain.join(' -> ')
);
},
onErrored: function(data) {
onErrored: function (data) {
console.error(data.error);
console.warn(
'Ignored an error while updating module ' +
@@ -45,7 +45,7 @@ function upToDate(hash) {
return lastHash == __webpack_hash__;
}
module.exports = function(hash, moduleMap, options) {
module.exports = function (hash, moduleMap, options) {
var reload = options.reload;
if (!upToDate(hash) && module.hot.status() == 'idle') {
if (options.log) console.log('[HMR] Checking for updates on the server...');
@@ -53,7 +53,7 @@ module.exports = function(hash, moduleMap, options) {
}
function check() {
var cb = function(err, updatedModules) {
var cb = function (err, updatedModules) {
if (err) return handleError(err);
if (!updatedModules) {
@@ -65,7 +65,7 @@ module.exports = function(hash, moduleMap, options) {
return null;
}
var applyCallback = function(applyErr, renewedModules) {
var applyCallback = function (applyErr, renewedModules) {
if (applyErr) return handleError(applyErr);
if (!upToDate()) check();
@@ -77,7 +77,7 @@ module.exports = function(hash, moduleMap, options) {
// webpack 2 promise
if (applyResult && applyResult.then) {
// HotModuleReplacement.runtime.js refers to the result as `outdatedModules`
applyResult.then(function(outdatedModules) {
applyResult.then(function (outdatedModules) {
applyCallback(null, outdatedModules);
});
applyResult.catch(applyCallback);
@@ -87,7 +87,7 @@ module.exports = function(hash, moduleMap, options) {
var result = module.hot.check(false, cb);
// webpack 2 promise
if (result && result.then) {
result.then(function(updatedModules) {
result.then(function (updatedModules) {
cb(null, updatedModules);
});
result.catch(cb);
@@ -95,7 +95,7 @@ module.exports = function(hash, moduleMap, options) {
}
function logUpdates(updatedModules, renewedModules) {
var unacceptedModules = updatedModules.filter(function(moduleId) {
var unacceptedModules = updatedModules.filter(function (moduleId) {
return renewedModules && renewedModules.indexOf(moduleId) < 0;
});
@@ -110,7 +110,7 @@ module.exports = function(hash, moduleMap, options) {
hmrDocsUrl +
' for more details.'
);
unacceptedModules.forEach(function(moduleId) {
unacceptedModules.forEach(function (moduleId) {
console.warn('[HMR] - ' + (moduleMap[moduleId] || moduleId));
});
}
@@ -123,7 +123,7 @@ module.exports = function(hash, moduleMap, options) {
console.log('[HMR] Nothing hot updated.');
} else {
console.log('[HMR] Updated modules:');
renewedModules.forEach(function(moduleId) {
renewedModules.forEach(function (moduleId) {
console.log('[HMR] - ' + (moduleMap[moduleId] || moduleId));
});
}