mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 13:42:20 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
1036
web/node_modules/webpack-dev-server/lib/Server.js
generated
vendored
Normal file
1036
web/node_modules/webpack-dev-server/lib/Server.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
499
web/node_modules/webpack-dev-server/lib/options.json
generated
vendored
Normal file
499
web/node_modules/webpack-dev-server/lib/options.json
generated
vendored
Normal file
|
@ -0,0 +1,499 @@
|
|||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"after": {
|
||||
"instanceof": "Function"
|
||||
},
|
||||
"allowedHosts": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"before": {
|
||||
"instanceof": "Function"
|
||||
},
|
||||
"bonjour": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"ca": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"instanceof": "Buffer"
|
||||
}
|
||||
]
|
||||
},
|
||||
"cert": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"instanceof": "Buffer"
|
||||
}
|
||||
]
|
||||
},
|
||||
"clientLogLevel": {
|
||||
"enum": [
|
||||
"info",
|
||||
"warn",
|
||||
"error",
|
||||
"debug",
|
||||
"trace",
|
||||
"silent",
|
||||
"none",
|
||||
"warning"
|
||||
]
|
||||
},
|
||||
"compress": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"contentBasePublicPath": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"minItems": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"contentBase": {
|
||||
"anyOf": [
|
||||
{
|
||||
"enum": [false]
|
||||
},
|
||||
{
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"minItems": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"disableHostCheck": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"features": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"filename": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"instanceof": "RegExp"
|
||||
},
|
||||
{
|
||||
"instanceof": "Function"
|
||||
}
|
||||
]
|
||||
},
|
||||
"fs": {
|
||||
"type": "object"
|
||||
},
|
||||
"headers": {
|
||||
"type": "object"
|
||||
},
|
||||
"historyApiFallback": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
},
|
||||
"host": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"hot": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hotOnly": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"http2": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"https": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
}
|
||||
]
|
||||
},
|
||||
"index": {
|
||||
"type": "string"
|
||||
},
|
||||
"injectClient": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"instanceof": "Function"
|
||||
}
|
||||
]
|
||||
},
|
||||
"injectHot": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"instanceof": "Function"
|
||||
}
|
||||
]
|
||||
},
|
||||
"inline": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"key": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"instanceof": "Buffer"
|
||||
}
|
||||
]
|
||||
},
|
||||
"lazy": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"liveReload": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"log": {
|
||||
"instanceof": "Function"
|
||||
},
|
||||
"logLevel": {
|
||||
"enum": ["info", "warn", "error", "debug", "trace", "silent"]
|
||||
},
|
||||
"logTime": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"mimeTypes": {
|
||||
"type": "object"
|
||||
},
|
||||
"noInfo": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"onListening": {
|
||||
"instanceof": "Function"
|
||||
},
|
||||
"open": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
},
|
||||
"openPage": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"minItems": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"overlay": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"errors": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"warnings": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"pfx": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"instanceof": "Buffer"
|
||||
}
|
||||
]
|
||||
},
|
||||
"pfxPassphrase": {
|
||||
"type": "string"
|
||||
},
|
||||
"port": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"profile": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"progress": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"proxy": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"instanceof": "Function"
|
||||
}
|
||||
]
|
||||
},
|
||||
"minItems": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"public": {
|
||||
"type": "string"
|
||||
},
|
||||
"publicPath": {
|
||||
"type": "string"
|
||||
},
|
||||
"quiet": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"reporter": {
|
||||
"instanceof": "Function"
|
||||
},
|
||||
"requestCert": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"serveIndex": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"serverSideRender": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"setup": {
|
||||
"instanceof": "Function"
|
||||
},
|
||||
"sockHost": {
|
||||
"type": "string"
|
||||
},
|
||||
"sockPath": {
|
||||
"type": "string"
|
||||
},
|
||||
"sockPort": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"socket": {
|
||||
"type": "string"
|
||||
},
|
||||
"staticOptions": {
|
||||
"type": "object"
|
||||
},
|
||||
"stats": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
"none",
|
||||
"errors-only",
|
||||
"errors-warnings",
|
||||
"minimal",
|
||||
"normal",
|
||||
"verbose"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"transportMode": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"client": {
|
||||
"type": "string"
|
||||
},
|
||||
"server": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"instanceof": "Function"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"enum": ["sockjs", "ws"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"useLocalIp": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"warn": {
|
||||
"instanceof": "Function"
|
||||
},
|
||||
"watchContentBase": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"watchOptions": {
|
||||
"type": "object"
|
||||
},
|
||||
"writeToDisk": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"instanceof": "Function"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"errorMessage": {
|
||||
"properties": {
|
||||
"after": "should be {Function} (https://webpack.js.org/configuration/dev-server/#devserverafter)",
|
||||
"allowedHosts": "should be {Array} (https://webpack.js.org/configuration/dev-server/#devserverallowedhosts)",
|
||||
"before": "should be {Function} (https://webpack.js.org/configuration/dev-server/#devserverbefore)",
|
||||
"bonjour": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverbonjour)",
|
||||
"ca": "should be {String|Buffer}",
|
||||
"cert": "should be {String|Buffer}",
|
||||
"clientLogLevel": "should be {String} and equal to one of the allowed values\n\n [ 'none', 'silent', 'info', 'debug', 'trace', 'error', 'warning', 'warn' ]\n\n (https://webpack.js.org/configuration/dev-server/#devserverclientloglevel)",
|
||||
"compress": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devservercompress)",
|
||||
"contentBase": "should be {Number|String|Array} (https://webpack.js.org/configuration/dev-server/#devservercontentbase)",
|
||||
"disableHostCheck": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverdisablehostcheck)",
|
||||
"features": "should be {Array}",
|
||||
"filename": "should be {String|RegExp|Function} (https://webpack.js.org/configuration/dev-server/#devserverfilename-)",
|
||||
"fs": "should be {Object} (https://github.com/webpack/webpack-dev-middleware#fs)",
|
||||
"headers": "should be {Object} (https://webpack.js.org/configuration/dev-server/#devserverheaders-)",
|
||||
"historyApiFallback": "should be {Boolean|Object} (https://webpack.js.org/configuration/dev-server/#devserverhistoryapifallback)",
|
||||
"host": "should be {String|Null} (https://webpack.js.org/configuration/dev-server/#devserverhost)",
|
||||
"hot": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverhot)",
|
||||
"hotOnly": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverhotonly)",
|
||||
"http2": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverhttp2)",
|
||||
"https": "should be {Object|Boolean} (https://webpack.js.org/configuration/dev-server/#devserverhttps)",
|
||||
"index": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserverindex)",
|
||||
"injectClient": "should be {Boolean|Function} (https://webpack.js.org/configuration/dev-server/#devserverinjectclient)",
|
||||
"injectHot": "should be {Boolean|Function} (https://webpack.js.org/configuration/dev-server/#devserverinjecthot)",
|
||||
"inline": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverinline)",
|
||||
"key": "should be {String|Buffer}",
|
||||
"lazy": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverlazy-)",
|
||||
"liveReload": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverlivereload-)",
|
||||
"log": "should be {Function}",
|
||||
"logLevel": "should be {String} and equal to one of the allowed values\n\n [ 'info', 'warn', 'error', 'debug', 'trace', 'silent' ]\n\n (https://github.com/webpack/webpack-dev-middleware#loglevel)",
|
||||
"logTime": "should be {Boolean} (https://github.com/webpack/webpack-dev-middleware#logtime)",
|
||||
"mimeTypes": "should be {Object} (https://webpack.js.org/configuration/dev-server/#devservermimetypes-)",
|
||||
"noInfo": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devservernoinfo-)",
|
||||
"onListening": "should be {Function} (https://webpack.js.org/configuration/dev-server/#onlistening)",
|
||||
"open": "should be {String|Boolean|Object} (https://webpack.js.org/configuration/dev-server/#devserveropen)",
|
||||
"openPage": "should be {String|Array} (https://webpack.js.org/configuration/dev-server/#devserveropenpage)",
|
||||
"overlay": "should be {Boolean|Object} (https://webpack.js.org/configuration/dev-server/#devserveroverlay)",
|
||||
"pfx": "should be {String|Buffer} (https://webpack.js.org/configuration/dev-server/#devserverpfx)",
|
||||
"pfxPassphrase": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserverpfxpassphrase)",
|
||||
"port": "should be {Number|String|Null} (https://webpack.js.org/configuration/dev-server/#devserverport)",
|
||||
"profile": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverprofile)",
|
||||
"progress": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverprogress---cli-only)",
|
||||
"proxy": "should be {Object|Array} (https://webpack.js.org/configuration/dev-server/#devserverproxy)",
|
||||
"public": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserverpublic)",
|
||||
"publicPath": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserverpublicpath-)",
|
||||
"quiet": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverquiet-)",
|
||||
"reporter": "should be {Function} (https://github.com/webpack/webpack-dev-middleware#reporter)",
|
||||
"requestCert": "should be {Boolean}",
|
||||
"contentBasePublicPath": "should be {String|Array} (https://webpack.js.org/configuration/dev-server/#devservercontentbasepublicpath)",
|
||||
"serveIndex": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverserveindex)",
|
||||
"serverSideRender": "should be {Boolean} (https://github.com/webpack/webpack-dev-middleware#serversiderender)",
|
||||
"setup": "should be {Function} (https://webpack.js.org/configuration/dev-server/#devserversetup)",
|
||||
"sockHost": "should be {String|Null} (https://webpack.js.org/configuration/dev-server/#devserversockhost)",
|
||||
"sockPath": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserversockpath)",
|
||||
"sockPort": "should be {Number|String|Null} (https://webpack.js.org/configuration/dev-server/#devserversockport)",
|
||||
"socket": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserversocket)",
|
||||
"staticOptions": "should be {Object} (https://webpack.js.org/configuration/dev-server/#devserverstaticoptions)",
|
||||
"stats": "should be {Object|Boolean} (https://webpack.js.org/configuration/dev-server/#devserverstats-)",
|
||||
"transportMode": "should be {String|Object} (https://webpack.js.org/configuration/dev-server/#devservertransportmode)",
|
||||
"useLocalIp": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserveruselocalip)",
|
||||
"warn": "should be {Function}",
|
||||
"watchContentBase": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverwatchcontentbase)",
|
||||
"watchOptions": "should be {Object} (https://webpack.js.org/configuration/dev-server/#devserverwatchoptions-)",
|
||||
"writeToDisk": "should be {Boolean|Function} (https://webpack.js.org/configuration/dev-server/#devserverwritetodisk-)"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
9
web/node_modules/webpack-dev-server/lib/servers/BaseServer.js
generated
vendored
Normal file
9
web/node_modules/webpack-dev-server/lib/servers/BaseServer.js
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
// base class that users should extend if they are making their own
|
||||
// server implementation
|
||||
module.exports = class BaseServer {
|
||||
constructor(server) {
|
||||
this.server = server;
|
||||
}
|
||||
};
|
74
web/node_modules/webpack-dev-server/lib/servers/SockJSServer.js
generated
vendored
Normal file
74
web/node_modules/webpack-dev-server/lib/servers/SockJSServer.js
generated
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
'use strict';
|
||||
|
||||
/* eslint-disable
|
||||
class-methods-use-this,
|
||||
func-names
|
||||
*/
|
||||
const sockjs = require('sockjs');
|
||||
const BaseServer = require('./BaseServer');
|
||||
|
||||
// Workaround for sockjs@~0.3.19
|
||||
// sockjs will remove Origin header, however Origin header is required for checking host.
|
||||
// See https://github.com/webpack/webpack-dev-server/issues/1604 for more information
|
||||
{
|
||||
const SockjsSession = require('sockjs/lib/transport').Session;
|
||||
const decorateConnection = SockjsSession.prototype.decorateConnection;
|
||||
SockjsSession.prototype.decorateConnection = function(req) {
|
||||
decorateConnection.call(this, req);
|
||||
const connection = this.connection;
|
||||
if (
|
||||
connection.headers &&
|
||||
!('origin' in connection.headers) &&
|
||||
'origin' in req.headers
|
||||
) {
|
||||
connection.headers.origin = req.headers.origin;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = class SockJSServer extends BaseServer {
|
||||
// options has: error (function), debug (function), server (http/s server), path (string)
|
||||
constructor(server) {
|
||||
super(server);
|
||||
this.socket = sockjs.createServer({
|
||||
// Use provided up-to-date sockjs-client
|
||||
sockjs_url: '/__webpack_dev_server__/sockjs.bundle.js',
|
||||
// Limit useless logs
|
||||
log: (severity, line) => {
|
||||
if (severity === 'error') {
|
||||
this.server.log.error(line);
|
||||
} else {
|
||||
this.server.log.debug(line);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
this.socket.installHandlers(this.server.listeningApp, {
|
||||
prefix: this.server.sockPath,
|
||||
});
|
||||
}
|
||||
|
||||
send(connection, message) {
|
||||
// prevent cases where the server is trying to send data while connection is closing
|
||||
if (connection.readyState !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
connection.write(message);
|
||||
}
|
||||
|
||||
close(connection) {
|
||||
connection.close();
|
||||
}
|
||||
|
||||
// f should be passed the resulting connection and the connection headers
|
||||
onConnection(f) {
|
||||
this.socket.on('connection', (connection) => {
|
||||
f(connection, connection ? connection.headers : null);
|
||||
});
|
||||
}
|
||||
|
||||
onConnectionClose(connection, f) {
|
||||
connection.on('close', f);
|
||||
}
|
||||
};
|
72
web/node_modules/webpack-dev-server/lib/servers/WebsocketServer.js
generated
vendored
Normal file
72
web/node_modules/webpack-dev-server/lib/servers/WebsocketServer.js
generated
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
'use strict';
|
||||
|
||||
/* eslint-disable
|
||||
class-methods-use-this
|
||||
*/
|
||||
const ws = require('ws');
|
||||
const BaseServer = require('./BaseServer');
|
||||
|
||||
module.exports = class WebsocketServer extends BaseServer {
|
||||
constructor(server) {
|
||||
super(server);
|
||||
this.wsServer = new ws.Server({
|
||||
noServer: true,
|
||||
path: this.server.sockPath,
|
||||
});
|
||||
|
||||
this.server.listeningApp.on('upgrade', (req, sock, head) => {
|
||||
if (!this.wsServer.shouldHandle(req)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.wsServer.handleUpgrade(req, sock, head, (connection) => {
|
||||
this.wsServer.emit('connection', connection, req);
|
||||
});
|
||||
});
|
||||
|
||||
this.wsServer.on('error', (err) => {
|
||||
this.server.log.error(err.message);
|
||||
});
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
setInterval(() => {
|
||||
this.wsServer.clients.forEach((socket) => {
|
||||
if (socket.isAlive === false) {
|
||||
return socket.terminate();
|
||||
}
|
||||
|
||||
socket.isAlive = false;
|
||||
socket.ping(noop);
|
||||
});
|
||||
}, this.server.heartbeatInterval);
|
||||
}
|
||||
|
||||
send(connection, message) {
|
||||
// prevent cases where the server is trying to send data while connection is closing
|
||||
if (connection.readyState !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
connection.send(message);
|
||||
}
|
||||
|
||||
close(connection) {
|
||||
connection.close();
|
||||
}
|
||||
|
||||
// f should be passed the resulting connection and the connection headers
|
||||
onConnection(f) {
|
||||
this.wsServer.on('connection', (connection, req) => {
|
||||
connection.isAlive = true;
|
||||
connection.on('pong', () => {
|
||||
connection.isAlive = true;
|
||||
});
|
||||
f(connection, req.headers);
|
||||
});
|
||||
}
|
||||
|
||||
onConnectionClose(connection, f) {
|
||||
connection.on('close', f);
|
||||
}
|
||||
};
|
160
web/node_modules/webpack-dev-server/lib/utils/addEntries.js
generated
vendored
Normal file
160
web/node_modules/webpack-dev-server/lib/utils/addEntries.js
generated
vendored
Normal file
|
@ -0,0 +1,160 @@
|
|||
'use strict';
|
||||
|
||||
const webpack = require('webpack');
|
||||
const createDomain = require('./createDomain');
|
||||
|
||||
/**
|
||||
* A Entry, it can be of type string or string[] or Object<string | string[],string>
|
||||
* @typedef {(string[] | string | Object<string | string[],string>)} Entry
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add entries Method
|
||||
* @param {?Object} config - Webpack config
|
||||
* @param {?Object} options - Dev-Server options
|
||||
* @param {?Object} server
|
||||
* @returns {void}
|
||||
*/
|
||||
function addEntries(config, options, server) {
|
||||
if (options.inline !== false) {
|
||||
// we're stubbing the app in this method as it's static and doesn't require
|
||||
// a server to be supplied. createDomain requires an app with the
|
||||
// address() signature.
|
||||
|
||||
const app = server || {
|
||||
address() {
|
||||
return { port: options.port };
|
||||
},
|
||||
};
|
||||
|
||||
/** @type {string} */
|
||||
const domain = createDomain(options, app);
|
||||
/** @type {string} */
|
||||
const sockHost = options.sockHost ? `&sockHost=${options.sockHost}` : '';
|
||||
/** @type {string} */
|
||||
const sockPath = options.sockPath ? `&sockPath=${options.sockPath}` : '';
|
||||
/** @type {string} */
|
||||
const sockPort = options.sockPort ? `&sockPort=${options.sockPort}` : '';
|
||||
/** @type {string} */
|
||||
const clientEntry = `${require.resolve(
|
||||
'../../client/'
|
||||
)}?${domain}${sockHost}${sockPath}${sockPort}`;
|
||||
|
||||
/** @type {(string[] | string)} */
|
||||
let hotEntry;
|
||||
|
||||
if (options.hotOnly) {
|
||||
hotEntry = require.resolve('webpack/hot/only-dev-server');
|
||||
} else if (options.hot) {
|
||||
hotEntry = require.resolve('webpack/hot/dev-server');
|
||||
}
|
||||
/**
|
||||
* prependEntry Method
|
||||
* @param {Entry} originalEntry
|
||||
* @param {Entry} additionalEntries
|
||||
* @returns {Entry}
|
||||
*/
|
||||
const prependEntry = (originalEntry, additionalEntries) => {
|
||||
if (typeof originalEntry === 'function') {
|
||||
return () =>
|
||||
Promise.resolve(originalEntry()).then((entry) =>
|
||||
prependEntry(entry, additionalEntries)
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof originalEntry === 'object' && !Array.isArray(originalEntry)) {
|
||||
/** @type {Object<string,string>} */
|
||||
const clone = {};
|
||||
|
||||
Object.keys(originalEntry).forEach((key) => {
|
||||
// entry[key] should be a string here
|
||||
const entryDescription = originalEntry[key];
|
||||
if (typeof entryDescription === 'object' && entryDescription.import) {
|
||||
clone[key] = Object.assign({}, entryDescription, {
|
||||
import: prependEntry(entryDescription.import, additionalEntries),
|
||||
});
|
||||
} else {
|
||||
clone[key] = prependEntry(entryDescription, additionalEntries);
|
||||
}
|
||||
});
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
// in this case, entry is a string or an array.
|
||||
// make sure that we do not add duplicates.
|
||||
/** @type {Entry} */
|
||||
const entriesClone = additionalEntries.slice(0);
|
||||
[].concat(originalEntry).forEach((newEntry) => {
|
||||
if (!entriesClone.includes(newEntry)) {
|
||||
entriesClone.push(newEntry);
|
||||
}
|
||||
});
|
||||
return entriesClone;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* Description of the option for checkInject method
|
||||
* @typedef {Function} checkInjectOptionsParam
|
||||
* @param {Object} _config - compilerConfig
|
||||
* @return {Boolean}
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Boolean | checkInjectOptionsParam} option - inject(Hot|Client) it is Boolean | fn => Boolean
|
||||
* @param {Object} _config
|
||||
* @param {Boolean} defaultValue
|
||||
* @return {Boolean}
|
||||
*/
|
||||
// eslint-disable-next-line no-shadow
|
||||
const checkInject = (option, _config, defaultValue) => {
|
||||
if (typeof option === 'boolean') return option;
|
||||
if (typeof option === 'function') return option(_config);
|
||||
return defaultValue;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line no-shadow
|
||||
[].concat(config).forEach((config) => {
|
||||
/** @type {Boolean} */
|
||||
const webTarget = [
|
||||
'web',
|
||||
'webworker',
|
||||
'electron-renderer',
|
||||
'node-webkit',
|
||||
undefined, // eslint-disable-line
|
||||
null,
|
||||
].includes(config.target);
|
||||
/** @type {Entry} */
|
||||
const additionalEntries = checkInject(
|
||||
options.injectClient,
|
||||
config,
|
||||
webTarget
|
||||
)
|
||||
? [clientEntry]
|
||||
: [];
|
||||
|
||||
if (hotEntry && checkInject(options.injectHot, config, true)) {
|
||||
additionalEntries.push(hotEntry);
|
||||
}
|
||||
|
||||
config.entry = prependEntry(config.entry || './src', additionalEntries);
|
||||
|
||||
if (options.hot || options.hotOnly) {
|
||||
config.plugins = config.plugins || [];
|
||||
if (
|
||||
!config.plugins.find(
|
||||
// Check for the name rather than the constructor reference in case
|
||||
// there are multiple copies of webpack installed
|
||||
(plugin) => plugin.constructor.name === 'HotModuleReplacementPlugin'
|
||||
)
|
||||
) {
|
||||
config.plugins.push(new webpack.HotModuleReplacementPlugin());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = addEntries;
|
22
web/node_modules/webpack-dev-server/lib/utils/colors.js
generated
vendored
Normal file
22
web/node_modules/webpack-dev-server/lib/utils/colors.js
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
'use strict';
|
||||
|
||||
const colors = {
|
||||
info(useColor, msg) {
|
||||
if (useColor) {
|
||||
// Make text blue and bold, so it *pops*
|
||||
return `\u001b[1m\u001b[34m${msg}\u001b[39m\u001b[22m`;
|
||||
}
|
||||
|
||||
return msg;
|
||||
},
|
||||
error(useColor, msg) {
|
||||
if (useColor) {
|
||||
// Make text red and bold, so it *pops*
|
||||
return `\u001b[1m\u001b[31m${msg}\u001b[39m\u001b[22m`;
|
||||
}
|
||||
|
||||
return msg;
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = colors;
|
69
web/node_modules/webpack-dev-server/lib/utils/createCertificate.js
generated
vendored
Normal file
69
web/node_modules/webpack-dev-server/lib/utils/createCertificate.js
generated
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
'use strict';
|
||||
|
||||
const selfsigned = require('selfsigned');
|
||||
|
||||
function createCertificate(attributes) {
|
||||
return selfsigned.generate(attributes, {
|
||||
algorithm: 'sha256',
|
||||
days: 30,
|
||||
keySize: 2048,
|
||||
extensions: [
|
||||
// {
|
||||
// name: 'basicConstraints',
|
||||
// cA: true,
|
||||
// },
|
||||
{
|
||||
name: 'keyUsage',
|
||||
keyCertSign: true,
|
||||
digitalSignature: true,
|
||||
nonRepudiation: true,
|
||||
keyEncipherment: true,
|
||||
dataEncipherment: true,
|
||||
},
|
||||
{
|
||||
name: 'extKeyUsage',
|
||||
serverAuth: true,
|
||||
clientAuth: true,
|
||||
codeSigning: true,
|
||||
timeStamping: true,
|
||||
},
|
||||
{
|
||||
name: 'subjectAltName',
|
||||
altNames: [
|
||||
{
|
||||
// type 2 is DNS
|
||||
type: 2,
|
||||
value: 'localhost',
|
||||
},
|
||||
{
|
||||
type: 2,
|
||||
value: 'localhost.localdomain',
|
||||
},
|
||||
{
|
||||
type: 2,
|
||||
value: 'lvh.me',
|
||||
},
|
||||
{
|
||||
type: 2,
|
||||
value: '*.lvh.me',
|
||||
},
|
||||
{
|
||||
type: 2,
|
||||
value: '[::1]',
|
||||
},
|
||||
{
|
||||
// type 7 is IP
|
||||
type: 7,
|
||||
ip: '127.0.0.1',
|
||||
},
|
||||
{
|
||||
type: 7,
|
||||
ip: 'fe80::1',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = createCertificate;
|
233
web/node_modules/webpack-dev-server/lib/utils/createConfig.js
generated
vendored
Normal file
233
web/node_modules/webpack-dev-server/lib/utils/createConfig.js
generated
vendored
Normal file
|
@ -0,0 +1,233 @@
|
|||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const isAbsoluteUrl = require('is-absolute-url');
|
||||
const defaultTo = require('./defaultTo');
|
||||
|
||||
function createConfig(config, argv, { port }) {
|
||||
const firstWpOpt = Array.isArray(config) ? config[0] : config;
|
||||
const options = firstWpOpt.devServer || {};
|
||||
|
||||
// This updates both config and firstWpOpt
|
||||
firstWpOpt.mode = defaultTo(firstWpOpt.mode, 'development');
|
||||
|
||||
if (argv.bonjour) {
|
||||
options.bonjour = true;
|
||||
}
|
||||
|
||||
if (argv.host && (argv.host !== 'localhost' || !options.host)) {
|
||||
options.host = argv.host;
|
||||
}
|
||||
|
||||
if (argv.allowedHosts) {
|
||||
options.allowedHosts = argv.allowedHosts.split(',');
|
||||
}
|
||||
|
||||
if (argv.public) {
|
||||
options.public = argv.public;
|
||||
}
|
||||
|
||||
if (argv.socket) {
|
||||
options.socket = argv.socket;
|
||||
}
|
||||
|
||||
if (argv.sockHost) {
|
||||
options.sockHost = argv.sockHost;
|
||||
}
|
||||
|
||||
if (argv.sockPath) {
|
||||
options.sockPath = argv.sockPath;
|
||||
}
|
||||
|
||||
if (argv.sockPort) {
|
||||
options.sockPort = argv.sockPort;
|
||||
}
|
||||
|
||||
if (argv.liveReload === false) {
|
||||
options.liveReload = false;
|
||||
}
|
||||
|
||||
if (argv.profile) {
|
||||
options.profile = argv.profile;
|
||||
}
|
||||
|
||||
if (argv.progress) {
|
||||
options.progress = argv.progress;
|
||||
}
|
||||
|
||||
if (argv.overlay) {
|
||||
options.overlay = argv.overlay;
|
||||
}
|
||||
|
||||
if (!options.publicPath) {
|
||||
// eslint-disable-next-line
|
||||
options.publicPath =
|
||||
(firstWpOpt.output && firstWpOpt.output.publicPath) || '';
|
||||
|
||||
if (
|
||||
!isAbsoluteUrl(String(options.publicPath)) &&
|
||||
options.publicPath[0] !== '/'
|
||||
) {
|
||||
options.publicPath = `/${options.publicPath}`;
|
||||
}
|
||||
}
|
||||
|
||||
if (!options.filename && firstWpOpt.output && firstWpOpt.output.filename) {
|
||||
options.filename = firstWpOpt.output && firstWpOpt.output.filename;
|
||||
}
|
||||
|
||||
if (!options.watchOptions && firstWpOpt.watchOptions) {
|
||||
options.watchOptions = firstWpOpt.watchOptions;
|
||||
}
|
||||
|
||||
if (argv.stdin) {
|
||||
process.stdin.on('end', () => {
|
||||
// eslint-disable-next-line no-process-exit
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
process.stdin.resume();
|
||||
}
|
||||
|
||||
// TODO https://github.com/webpack/webpack-dev-server/issues/616 (v4)
|
||||
// We should prefer CLI arg under config, now we always prefer `hot` from `devServer`
|
||||
if (!options.hot) {
|
||||
options.hot = argv.hot;
|
||||
}
|
||||
|
||||
// TODO https://github.com/webpack/webpack-dev-server/issues/616 (v4)
|
||||
// We should prefer CLI arg under config, now we always prefer `hotOnly` from `devServer`
|
||||
if (!options.hotOnly) {
|
||||
options.hotOnly = argv.hotOnly;
|
||||
}
|
||||
|
||||
// TODO https://github.com/webpack/webpack-dev-server/issues/616 (v4)
|
||||
// We should prefer CLI arg under config, now we always prefer `clientLogLevel` from `devServer`
|
||||
if (!options.clientLogLevel && argv.clientLogLevel) {
|
||||
options.clientLogLevel = argv.clientLogLevel;
|
||||
}
|
||||
|
||||
if (argv.contentBase) {
|
||||
options.contentBase = argv.contentBase;
|
||||
|
||||
if (Array.isArray(options.contentBase)) {
|
||||
options.contentBase = options.contentBase.map((p) => path.resolve(p));
|
||||
} else if (/^[0-9]$/.test(options.contentBase)) {
|
||||
options.contentBase = +options.contentBase;
|
||||
} else if (!isAbsoluteUrl(String(options.contentBase))) {
|
||||
options.contentBase = path.resolve(options.contentBase);
|
||||
}
|
||||
}
|
||||
// It is possible to disable the contentBase by using
|
||||
// `--no-content-base`, which results in arg["content-base"] = false
|
||||
else if (argv.contentBase === false) {
|
||||
options.contentBase = false;
|
||||
}
|
||||
|
||||
if (argv.watchContentBase) {
|
||||
options.watchContentBase = true;
|
||||
}
|
||||
|
||||
if (!options.stats) {
|
||||
options.stats = defaultTo(firstWpOpt.stats, {
|
||||
cached: false,
|
||||
cachedAssets: false,
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
typeof options.stats === 'object' &&
|
||||
typeof options.stats.colors === 'undefined' &&
|
||||
argv.color
|
||||
) {
|
||||
options.stats = Object.assign({}, options.stats, { colors: argv.color });
|
||||
}
|
||||
|
||||
if (argv.lazy) {
|
||||
options.lazy = true;
|
||||
}
|
||||
|
||||
// TODO remove in `v4`
|
||||
if (!argv.info) {
|
||||
options.noInfo = true;
|
||||
}
|
||||
|
||||
// TODO remove in `v4`
|
||||
if (argv.quiet) {
|
||||
options.quiet = true;
|
||||
}
|
||||
|
||||
if (argv.https) {
|
||||
options.https = true;
|
||||
}
|
||||
|
||||
if (argv.http2) {
|
||||
options.http2 = true;
|
||||
}
|
||||
|
||||
if (argv.key) {
|
||||
options.key = argv.key;
|
||||
}
|
||||
|
||||
if (argv.cert) {
|
||||
options.cert = argv.cert;
|
||||
}
|
||||
|
||||
if (argv.cacert) {
|
||||
options.ca = argv.cacert;
|
||||
}
|
||||
|
||||
if (argv.pfx) {
|
||||
options.pfx = argv.pfx;
|
||||
}
|
||||
|
||||
if (argv.pfxPassphrase) {
|
||||
options.pfxPassphrase = argv.pfxPassphrase;
|
||||
}
|
||||
|
||||
if (argv.inline === false) {
|
||||
options.inline = false;
|
||||
}
|
||||
|
||||
if (argv.historyApiFallback) {
|
||||
options.historyApiFallback = true;
|
||||
}
|
||||
|
||||
if (argv.compress) {
|
||||
options.compress = true;
|
||||
}
|
||||
|
||||
if (argv.disableHostCheck) {
|
||||
options.disableHostCheck = true;
|
||||
}
|
||||
|
||||
if (argv.openPage) {
|
||||
options.open = true;
|
||||
options.openPage = argv.openPage.split(',');
|
||||
}
|
||||
|
||||
if (typeof argv.open !== 'undefined') {
|
||||
options.open = argv.open !== '' ? argv.open : true;
|
||||
}
|
||||
|
||||
if (options.open && !options.openPage) {
|
||||
options.openPage = '';
|
||||
}
|
||||
|
||||
if (argv.useLocalIp) {
|
||||
options.useLocalIp = true;
|
||||
}
|
||||
|
||||
// Kind of weird, but ensures prior behavior isn't broken in cases
|
||||
// that wouldn't throw errors. E.g. both argv.port and options.port
|
||||
// were specified, but since argv.port is 8080, options.port will be
|
||||
// tried first instead.
|
||||
options.port =
|
||||
argv.port === port
|
||||
? defaultTo(options.port, argv.port)
|
||||
: defaultTo(argv.port, options.port);
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
module.exports = createConfig;
|
29
web/node_modules/webpack-dev-server/lib/utils/createDomain.js
generated
vendored
Normal file
29
web/node_modules/webpack-dev-server/lib/utils/createDomain.js
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
'use strict';
|
||||
|
||||
const url = require('url');
|
||||
const ip = require('internal-ip');
|
||||
|
||||
function createDomain(options, server) {
|
||||
const protocol = options.https ? 'https' : 'http';
|
||||
const hostname = options.useLocalIp
|
||||
? ip.v4.sync() || 'localhost'
|
||||
: options.host || 'localhost';
|
||||
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
const port = options.socket ? 0 : server ? server.address().port : 0;
|
||||
// use explicitly defined public url
|
||||
// (prefix with protocol if not explicitly given)
|
||||
if (options.public) {
|
||||
return /^[a-zA-Z]+:\/\//.test(options.public)
|
||||
? `${options.public}`
|
||||
: `${protocol}://${options.public}`;
|
||||
}
|
||||
// the formatted domain (url without path) of the webpack server
|
||||
return url.format({
|
||||
protocol,
|
||||
hostname,
|
||||
port,
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = createDomain;
|
23
web/node_modules/webpack-dev-server/lib/utils/createLogger.js
generated
vendored
Normal file
23
web/node_modules/webpack-dev-server/lib/utils/createLogger.js
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
'use strict';
|
||||
|
||||
const log = require('webpack-log');
|
||||
|
||||
function createLogger(options = {}) {
|
||||
let level = options.logLevel || 'info';
|
||||
|
||||
if (options.noInfo === true) {
|
||||
level = 'warn';
|
||||
}
|
||||
|
||||
if (options.quiet === true) {
|
||||
level = 'silent';
|
||||
}
|
||||
|
||||
return log({
|
||||
name: 'wds',
|
||||
level,
|
||||
timestamp: options.logTime,
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = createLogger;
|
3
web/node_modules/webpack-dev-server/lib/utils/defaultPort.js
generated
vendored
Normal file
3
web/node_modules/webpack-dev-server/lib/utils/defaultPort.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = 8080;
|
7
web/node_modules/webpack-dev-server/lib/utils/defaultTo.js
generated
vendored
Normal file
7
web/node_modules/webpack-dev-server/lib/utils/defaultTo.js
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
function defaultTo(value, def) {
|
||||
return value == null ? def : value;
|
||||
}
|
||||
|
||||
module.exports = defaultTo;
|
39
web/node_modules/webpack-dev-server/lib/utils/findPort.js
generated
vendored
Normal file
39
web/node_modules/webpack-dev-server/lib/utils/findPort.js
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
'use strict';
|
||||
|
||||
const pRetry = require('p-retry');
|
||||
const portfinder = require('portfinder');
|
||||
const defaultPort = require('./defaultPort');
|
||||
const defaultTo = require('./defaultTo');
|
||||
const tryParseInt = require('./tryParseInt');
|
||||
|
||||
function runPortFinder() {
|
||||
return new Promise((resolve, reject) => {
|
||||
portfinder.basePort = defaultPort;
|
||||
portfinder.getPort((error, port) => {
|
||||
if (error) {
|
||||
return reject(error);
|
||||
}
|
||||
|
||||
return resolve(port);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function findPort(port) {
|
||||
if (port) {
|
||||
return Promise.resolve(port);
|
||||
}
|
||||
|
||||
// Try to find unused port and listen on it for 3 times,
|
||||
// if port is not specified in options.
|
||||
// Because NaN == null is false, defaultTo fails if parseInt returns NaN
|
||||
// so the tryParseInt function is introduced to handle NaN
|
||||
const defaultPortRetry = defaultTo(
|
||||
tryParseInt(process.env.DEFAULT_PORT_RETRY),
|
||||
3
|
||||
);
|
||||
|
||||
return pRetry(runPortFinder, { retries: defaultPortRetry });
|
||||
}
|
||||
|
||||
module.exports = findPort;
|
45
web/node_modules/webpack-dev-server/lib/utils/getCertificate.js
generated
vendored
Normal file
45
web/node_modules/webpack-dev-server/lib/utils/getCertificate.js
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const del = require('del');
|
||||
const createCertificate = require('./createCertificate');
|
||||
|
||||
function getCertificate(logger) {
|
||||
// Use a self-signed certificate if no certificate was configured.
|
||||
// Cycle certs every 24 hours
|
||||
const certificatePath = path.join(__dirname, '../../ssl/server.pem');
|
||||
|
||||
let certificateExists = fs.existsSync(certificatePath);
|
||||
|
||||
if (certificateExists) {
|
||||
const certificateTtl = 1000 * 60 * 60 * 24;
|
||||
const certificateStat = fs.statSync(certificatePath);
|
||||
|
||||
const now = new Date();
|
||||
|
||||
// cert is more than 30 days old, kill it with fire
|
||||
if ((now - certificateStat.ctime) / certificateTtl > 30) {
|
||||
logger.info('SSL Certificate is more than 30 days old. Removing.');
|
||||
|
||||
del.sync([certificatePath], { force: true });
|
||||
|
||||
certificateExists = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!certificateExists) {
|
||||
logger.info('Generating SSL Certificate');
|
||||
|
||||
const attributes = [{ name: 'commonName', value: 'localhost' }];
|
||||
const pems = createCertificate(attributes);
|
||||
|
||||
fs.writeFileSync(certificatePath, pems.private + pems.cert, {
|
||||
encoding: 'utf8',
|
||||
});
|
||||
}
|
||||
|
||||
return fs.readFileSync(certificatePath);
|
||||
}
|
||||
|
||||
module.exports = getCertificate;
|
37
web/node_modules/webpack-dev-server/lib/utils/getSocketClientPath.js
generated
vendored
Normal file
37
web/node_modules/webpack-dev-server/lib/utils/getSocketClientPath.js
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
'use strict';
|
||||
|
||||
function getSocketClientPath(options) {
|
||||
let ClientImplementation;
|
||||
let clientImplFound = true;
|
||||
switch (typeof options.transportMode.client) {
|
||||
case 'string':
|
||||
// could be 'sockjs', 'ws', or a path that should be required
|
||||
if (options.transportMode.client === 'sockjs') {
|
||||
ClientImplementation = require('../../client/clients/SockJSClient');
|
||||
} else if (options.transportMode.client === 'ws') {
|
||||
ClientImplementation = require('../../client/clients/WebsocketClient');
|
||||
} else {
|
||||
try {
|
||||
// eslint-disable-next-line import/no-dynamic-require
|
||||
ClientImplementation = require(options.transportMode.client);
|
||||
} catch (e) {
|
||||
clientImplFound = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
clientImplFound = false;
|
||||
}
|
||||
|
||||
if (!clientImplFound) {
|
||||
throw new Error(
|
||||
"transportMode.client must be a string denoting a default implementation (e.g. 'sockjs', 'ws') or a full path to " +
|
||||
'a JS file which exports a class extending BaseClient (webpack-dev-server/client-src/clients/BaseClient) ' +
|
||||
'via require.resolve(...)'
|
||||
);
|
||||
}
|
||||
|
||||
return ClientImplementation.getClientPath(options);
|
||||
}
|
||||
|
||||
module.exports = getSocketClientPath;
|
42
web/node_modules/webpack-dev-server/lib/utils/getSocketServerImplementation.js
generated
vendored
Normal file
42
web/node_modules/webpack-dev-server/lib/utils/getSocketServerImplementation.js
generated
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
'use strict';
|
||||
|
||||
function getSocketServerImplementation(options) {
|
||||
let ServerImplementation;
|
||||
let serverImplFound = true;
|
||||
switch (typeof options.transportMode.server) {
|
||||
case 'string':
|
||||
// could be 'sockjs', in the future 'ws', or a path that should be required
|
||||
if (options.transportMode.server === 'sockjs') {
|
||||
ServerImplementation = require('../servers/SockJSServer');
|
||||
} else if (options.transportMode.server === 'ws') {
|
||||
ServerImplementation = require('../servers/WebsocketServer');
|
||||
} else {
|
||||
try {
|
||||
// eslint-disable-next-line import/no-dynamic-require
|
||||
ServerImplementation = require(options.transportMode.server);
|
||||
} catch (e) {
|
||||
serverImplFound = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'function':
|
||||
// potentially do more checks here to confirm that the user implemented this properlly
|
||||
// since errors could be difficult to understand
|
||||
ServerImplementation = options.transportMode.server;
|
||||
break;
|
||||
default:
|
||||
serverImplFound = false;
|
||||
}
|
||||
|
||||
if (!serverImplFound) {
|
||||
throw new Error(
|
||||
"transportMode.server must be a string denoting a default implementation (e.g. 'sockjs', 'ws'), a full path to " +
|
||||
'a JS file which exports a class extending BaseServer (webpack-dev-server/lib/servers/BaseServer) ' +
|
||||
'via require.resolve(...), or the class itself which extends BaseServer'
|
||||
);
|
||||
}
|
||||
|
||||
return ServerImplementation;
|
||||
}
|
||||
|
||||
module.exports = getSocketServerImplementation;
|
10
web/node_modules/webpack-dev-server/lib/utils/getVersions.js
generated
vendored
Normal file
10
web/node_modules/webpack-dev-server/lib/utils/getVersions.js
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
function getVersions() {
|
||||
return (
|
||||
`webpack-dev-server ${require('../../package.json').version}\n` +
|
||||
`webpack ${require('webpack/package.json').version}`
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = getVersions;
|
41
web/node_modules/webpack-dev-server/lib/utils/normalizeOptions.js
generated
vendored
Normal file
41
web/node_modules/webpack-dev-server/lib/utils/normalizeOptions.js
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
'use strict';
|
||||
|
||||
/* eslint-disable
|
||||
no-undefined
|
||||
*/
|
||||
|
||||
function normalizeOptions(compiler, options) {
|
||||
// Setup default value
|
||||
options.contentBase =
|
||||
options.contentBase !== undefined ? options.contentBase : process.cwd();
|
||||
|
||||
// Setup default value
|
||||
options.contentBasePublicPath = options.contentBasePublicPath || '/';
|
||||
|
||||
// normalize transportMode option
|
||||
if (options.transportMode === undefined) {
|
||||
options.transportMode = {
|
||||
server: 'sockjs',
|
||||
client: 'sockjs',
|
||||
};
|
||||
} else {
|
||||
switch (typeof options.transportMode) {
|
||||
case 'string':
|
||||
options.transportMode = {
|
||||
server: options.transportMode,
|
||||
client: options.transportMode,
|
||||
};
|
||||
break;
|
||||
// if not a string, it is an object
|
||||
default:
|
||||
options.transportMode.server = options.transportMode.server || 'sockjs';
|
||||
options.transportMode.client = options.transportMode.client || 'sockjs';
|
||||
}
|
||||
}
|
||||
|
||||
if (!options.watchOptions) {
|
||||
options.watchOptions = {};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = normalizeOptions;
|
44
web/node_modules/webpack-dev-server/lib/utils/processOptions.js
generated
vendored
Normal file
44
web/node_modules/webpack-dev-server/lib/utils/processOptions.js
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
'use strict';
|
||||
|
||||
const createConfig = require('./createConfig');
|
||||
const defaultPort = require('./defaultPort');
|
||||
const findPort = require('./findPort');
|
||||
|
||||
function processOptions(config, argv, callback) {
|
||||
// processOptions {Promise}
|
||||
if (typeof config.then === 'function') {
|
||||
config
|
||||
.then((conf) => processOptions(conf, argv, callback))
|
||||
.catch((err) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err.stack || err);
|
||||
// eslint-disable-next-line no-process-exit
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Taken out of yargs because we must know if
|
||||
// it wasn't given by the user, in which case
|
||||
// we should use portfinder.
|
||||
const options = createConfig(config, argv, { port: defaultPort });
|
||||
|
||||
if (options.socket) {
|
||||
callback(config, options);
|
||||
} else {
|
||||
findPort(options.port)
|
||||
.then((port) => {
|
||||
options.port = port;
|
||||
callback(config, options);
|
||||
})
|
||||
.catch((err) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err.stack || err);
|
||||
// eslint-disable-next-line no-process-exit
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = processOptions;
|
98
web/node_modules/webpack-dev-server/lib/utils/routes.js
generated
vendored
Normal file
98
web/node_modules/webpack-dev-server/lib/utils/routes.js
generated
vendored
Normal file
|
@ -0,0 +1,98 @@
|
|||
'use strict';
|
||||
|
||||
const { createReadStream } = require('fs');
|
||||
const { join } = require('path');
|
||||
|
||||
const clientBasePath = join(__dirname, '..', '..', 'client');
|
||||
|
||||
function routes(server) {
|
||||
const app = server.app;
|
||||
const middleware = server.middleware;
|
||||
const options = server.options;
|
||||
|
||||
app.get('/__webpack_dev_server__/live.bundle.js', (req, res) => {
|
||||
res.setHeader('Content-Type', 'application/javascript');
|
||||
|
||||
createReadStream(join(clientBasePath, 'live.bundle.js')).pipe(res);
|
||||
});
|
||||
|
||||
app.get('/__webpack_dev_server__/sockjs.bundle.js', (req, res) => {
|
||||
res.setHeader('Content-Type', 'application/javascript');
|
||||
|
||||
createReadStream(join(clientBasePath, 'sockjs.bundle.js')).pipe(res);
|
||||
});
|
||||
|
||||
app.get('/webpack-dev-server.js', (req, res) => {
|
||||
res.setHeader('Content-Type', 'application/javascript');
|
||||
|
||||
createReadStream(join(clientBasePath, 'index.bundle.js')).pipe(res);
|
||||
});
|
||||
|
||||
app.get('/webpack-dev-server/invalidate', (_req, res) => {
|
||||
server.invalidate();
|
||||
res.end();
|
||||
});
|
||||
|
||||
app.get('/webpack-dev-server/*', (req, res) => {
|
||||
res.setHeader('Content-Type', 'text/html');
|
||||
|
||||
createReadStream(join(clientBasePath, 'live.html')).pipe(res);
|
||||
});
|
||||
|
||||
app.get('/webpack-dev-server', (req, res) => {
|
||||
res.setHeader('Content-Type', 'text/html');
|
||||
|
||||
res.write(
|
||||
'<!DOCTYPE html><html><head><meta charset="utf-8"/></head><body>'
|
||||
);
|
||||
|
||||
const outputPath = middleware.getFilenameFromUrl(options.publicPath || '/');
|
||||
const filesystem = middleware.fileSystem;
|
||||
|
||||
writeDirectory(options.publicPath || '/', outputPath);
|
||||
|
||||
res.end('</body></html>');
|
||||
|
||||
function writeDirectory(baseUrl, basePath) {
|
||||
const content = filesystem.readdirSync(basePath);
|
||||
|
||||
res.write('<ul>');
|
||||
|
||||
content.forEach((item) => {
|
||||
const p = `${basePath}/${item}`;
|
||||
|
||||
if (filesystem.statSync(p).isFile()) {
|
||||
res.write(`<li><a href="${baseUrl + item}">${item}</a></li>`);
|
||||
|
||||
if (/\.js$/.test(item)) {
|
||||
const html = item.substr(0, item.length - 3);
|
||||
const containerHref = baseUrl + html;
|
||||
|
||||
const magicHtmlHref =
|
||||
baseUrl.replace(
|
||||
// eslint-disable-next-line
|
||||
/(^(https?:\/\/[^\/]+)?\/)/,
|
||||
'$1webpack-dev-server/'
|
||||
) + html;
|
||||
|
||||
res.write(
|
||||
`<li><a href="${containerHref}">${html}</a>` +
|
||||
` (magic html for ${item}) (<a href="${magicHtmlHref}">webpack-dev-server</a>)` +
|
||||
`</li>`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
res.write(`<li>${item}<br>`);
|
||||
|
||||
writeDirectory(`${baseUrl + item}/`, p);
|
||||
|
||||
res.write('</li>');
|
||||
}
|
||||
});
|
||||
|
||||
res.write('</ul>');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = routes;
|
21
web/node_modules/webpack-dev-server/lib/utils/runBonjour.js
generated
vendored
Normal file
21
web/node_modules/webpack-dev-server/lib/utils/runBonjour.js
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
'use strict';
|
||||
|
||||
function runBonjour({ port }) {
|
||||
const bonjour = require('bonjour')();
|
||||
const os = require('os');
|
||||
|
||||
bonjour.publish({
|
||||
name: `Webpack Dev Server ${os.hostname()}:${port}`,
|
||||
port,
|
||||
type: 'http',
|
||||
subtypes: ['webpack'],
|
||||
});
|
||||
|
||||
process.on('exit', () => {
|
||||
bonjour.unpublishAll(() => {
|
||||
bonjour.destroy();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = runBonjour;
|
37
web/node_modules/webpack-dev-server/lib/utils/runOpen.js
generated
vendored
Normal file
37
web/node_modules/webpack-dev-server/lib/utils/runOpen.js
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
'use strict';
|
||||
|
||||
const open = require('opn');
|
||||
const isAbsoluteUrl = require('is-absolute-url');
|
||||
|
||||
function runOpen(uri, options, log) {
|
||||
// https://github.com/webpack/webpack-dev-server/issues/1990
|
||||
let openOptions = { wait: false };
|
||||
let openOptionValue = '';
|
||||
|
||||
if (typeof options.open === 'string') {
|
||||
openOptions = Object.assign({}, openOptions, { app: options.open });
|
||||
openOptionValue = `: "${options.open}"`;
|
||||
} else if (typeof options.open === 'object') {
|
||||
openOptions = options.open;
|
||||
openOptionValue = `: "${JSON.stringify(options.open)}"`;
|
||||
}
|
||||
|
||||
const pages =
|
||||
typeof options.openPage === 'string'
|
||||
? [options.openPage]
|
||||
: options.openPage || [''];
|
||||
|
||||
return Promise.all(
|
||||
pages.map((page) => {
|
||||
const pageUrl = page && isAbsoluteUrl(page) ? page : `${uri}${page}`;
|
||||
|
||||
return open(pageUrl, openOptions).catch(() => {
|
||||
log.warn(
|
||||
`Unable to open "${pageUrl}" in browser${openOptionValue}. If you are running in a headless environment, please do not use the --open flag`
|
||||
);
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = runOpen;
|
21
web/node_modules/webpack-dev-server/lib/utils/setupExitSignals.js
generated
vendored
Normal file
21
web/node_modules/webpack-dev-server/lib/utils/setupExitSignals.js
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
'use strict';
|
||||
|
||||
const signals = ['SIGINT', 'SIGTERM'];
|
||||
|
||||
function setupExitSignals(serverData) {
|
||||
signals.forEach((signal) => {
|
||||
process.on(signal, () => {
|
||||
if (serverData && serverData.server) {
|
||||
serverData.server.close(() => {
|
||||
// eslint-disable-next-line no-process-exit
|
||||
process.exit();
|
||||
});
|
||||
} else {
|
||||
// eslint-disable-next-line no-process-exit
|
||||
process.exit();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = setupExitSignals;
|
61
web/node_modules/webpack-dev-server/lib/utils/status.js
generated
vendored
Normal file
61
web/node_modules/webpack-dev-server/lib/utils/status.js
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
'use strict';
|
||||
|
||||
const logger = require('webpack-log');
|
||||
const colors = require('./colors');
|
||||
const runOpen = require('./runOpen');
|
||||
|
||||
// TODO: don't emit logs when webpack-dev-server is used via Node.js API
|
||||
function status(uri, options, log, useColor) {
|
||||
if (options.quiet === true) {
|
||||
// Add temporary logger to output just the status of the dev server
|
||||
log = logger({
|
||||
name: 'wds',
|
||||
level: 'info',
|
||||
timestamp: options.logTime,
|
||||
});
|
||||
}
|
||||
|
||||
const contentBase = Array.isArray(options.contentBase)
|
||||
? options.contentBase.join(', ')
|
||||
: options.contentBase;
|
||||
|
||||
if (options.socket) {
|
||||
log.info(`Listening to socket at ${colors.info(useColor, options.socket)}`);
|
||||
} else {
|
||||
log.info(`Project is running at ${colors.info(useColor, uri)}`);
|
||||
}
|
||||
|
||||
log.info(
|
||||
`webpack output is served from ${colors.info(useColor, options.publicPath)}`
|
||||
);
|
||||
|
||||
if (contentBase) {
|
||||
log.info(
|
||||
`Content not from webpack is served from ${colors.info(
|
||||
useColor,
|
||||
contentBase
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
if (options.historyApiFallback) {
|
||||
log.info(
|
||||
`404s will fallback to ${colors.info(
|
||||
useColor,
|
||||
options.historyApiFallback.index || '/index.html'
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
if (options.bonjour) {
|
||||
log.info(
|
||||
'Broadcasting "http" with subtype of "webpack" via ZeroConf DNS (Bonjour)'
|
||||
);
|
||||
}
|
||||
|
||||
if (options.open) {
|
||||
runOpen(uri, options, log);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = status;
|
13
web/node_modules/webpack-dev-server/lib/utils/tryParseInt.js
generated
vendored
Normal file
13
web/node_modules/webpack-dev-server/lib/utils/tryParseInt.js
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
function tryParseInt(input) {
|
||||
const output = parseInt(input, 10);
|
||||
|
||||
if (Number.isNaN(output)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
module.exports = tryParseInt;
|
73
web/node_modules/webpack-dev-server/lib/utils/updateCompiler.js
generated
vendored
Normal file
73
web/node_modules/webpack-dev-server/lib/utils/updateCompiler.js
generated
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
'use strict';
|
||||
|
||||
/* eslint-disable
|
||||
no-shadow,
|
||||
no-undefined
|
||||
*/
|
||||
const webpack = require('webpack');
|
||||
const addEntries = require('./addEntries');
|
||||
const getSocketClientPath = require('./getSocketClientPath');
|
||||
|
||||
function updateCompiler(compiler, options) {
|
||||
if (options.inline !== false) {
|
||||
const findHMRPlugin = (config) => {
|
||||
if (!config.plugins) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return config.plugins.find(
|
||||
(plugin) => plugin.constructor === webpack.HotModuleReplacementPlugin
|
||||
);
|
||||
};
|
||||
|
||||
const compilers = [];
|
||||
const compilersWithoutHMR = [];
|
||||
let webpackConfig;
|
||||
if (compiler.compilers) {
|
||||
webpackConfig = [];
|
||||
compiler.compilers.forEach((compiler) => {
|
||||
webpackConfig.push(compiler.options);
|
||||
compilers.push(compiler);
|
||||
if (!findHMRPlugin(compiler.options)) {
|
||||
compilersWithoutHMR.push(compiler);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
webpackConfig = compiler.options;
|
||||
compilers.push(compiler);
|
||||
if (!findHMRPlugin(compiler.options)) {
|
||||
compilersWithoutHMR.push(compiler);
|
||||
}
|
||||
}
|
||||
|
||||
// it's possible that we should clone the config before doing
|
||||
// this, but it seems safe not to since it actually reflects
|
||||
// the changes we are making to the compiler
|
||||
// important: this relies on the fact that addEntries now
|
||||
// prevents duplicate new entries.
|
||||
addEntries(webpackConfig, options);
|
||||
compilers.forEach((compiler) => {
|
||||
const config = compiler.options;
|
||||
compiler.hooks.entryOption.call(config.context, config.entry);
|
||||
|
||||
const providePlugin = new webpack.ProvidePlugin({
|
||||
__webpack_dev_server_client__: getSocketClientPath(options),
|
||||
});
|
||||
providePlugin.apply(compiler);
|
||||
});
|
||||
|
||||
// do not apply the plugin unless it didn't exist before.
|
||||
if (options.hot || options.hotOnly) {
|
||||
compilersWithoutHMR.forEach((compiler) => {
|
||||
// addDevServerEntrypoints above should have added the plugin
|
||||
// to the compiler options
|
||||
const plugin = findHMRPlugin(compiler.options);
|
||||
if (plugin) {
|
||||
plugin.apply(compiler);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = updateCompiler;
|
Loading…
Add table
Add a link
Reference in a new issue