This commit is contained in:
lalBi94
2023-03-05 13:23:23 +01:00
commit 7bc56c09b5
14034 changed files with 1834369 additions and 0 deletions

20
node_modules/webpack-dev-server/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,20 @@
Copyright JS Foundation and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

345
node_modules/webpack-dev-server/README.md generated vendored Normal file
View File

@@ -0,0 +1,345 @@
<div align="center">
<a href="https://github.com/webpack/webpack">
<img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg">
</a>
</div>
[![npm][npm]][npm-url]
[![node][node]][node-url]
[![tests][tests]][tests-url]
[![coverage][cover]][cover-url]
[![chat][chat]][chat-url]
[![downloads][downloads]][npm-url]
[![contributors][contributors]][contributors-url]
# webpack-dev-server
Use [webpack](https://webpack.js.org) with a development server that provides
live reloading. This should be used for **development only**.
It uses [webpack-dev-middleware][middleware-url] under the hood, which provides
fast in-memory access to the webpack assets.
## Table of Contents
- [Getting Started](#getting-started)
- [Usage](#usage)
- [With the CLI](#with-the-cli)
- [With NPM Scripts](#with-npm-scripts)
- [With the API](#with-the-api)
- [With TypeScript](#with-typescript)
- [The Result](#the-result)
- [Browser Support](#browser-support)
- [Support](#support)
- [Contributing](#contributing)
- [Attribution](#attribution)
- [License](#license)
## Getting Started
First things first, install the module:
```console
npm install webpack-dev-server --save-dev
```
or
```console
yarn add -D webpack-dev-server
```
or
```console
pnpm add -D webpack-dev-server
```
_Note: While you can install and run webpack-dev-server globally, we recommend
installing it locally. webpack-dev-server will always use a local installation
over a global one._
## Usage
There are two main, recommended methods of using the module:
### With the CLI
The easiest way to use it is with the [webpack CLI](https://webpack.js.org/api/cli/). In the directory where your
`webpack.config.js` is, run:
```console
npx webpack serve
```
Following options are available with `webpack serve`:
```
Usage: webpack serve|server|s [entries...] [options]
Run the webpack dev server.
Options:
-c, --config <value...> Provide path to a webpack configuration file e.g. ./webpack.config.js.
--config-name <value...> Name of the configuration to use.
-m, --merge Merge two or more configurations using 'webpack-merge'.
--env <value...> Environment passed to the configuration when it is a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--progress [value] Print compilation progress during build.
-j, --json [value] Prints result as JSON or store it in a file.
-d, --devtool <value> Determine source maps to use.
--no-devtool Do not generate source maps.
--entry <value...> The entry point(s) of your application e.g. ./src/main.js.
--mode <value> Defines the mode to pass to webpack.
--name <value> Name of the configuration. Used when loading multiple configurations.
-o, --output-path <value> Output location of the file generated by webpack e.g. ./dist/.
--stats [value] It instructs webpack on how to treat the stats e.g. verbose.
--no-stats Disable stats output.
-t, --target <value...> Sets the build target e.g. node.
--no-target Negative 'target' option.
--watch-options-stdin Stop watching when stdin stream has ended.
--no-watch-options-stdin Do not stop watching when stdin stream has ended.
--allowed-hosts <value...> Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto').
--allowed-hosts-reset Clear all items provided in 'allowedHosts' configuration. Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto').
--bonjour Allows to broadcasts dev server via ZeroConf networking on start.
--no-bonjour Disallows to broadcasts dev server via ZeroConf networking on start.
--no-client Disables client script.
--client-logging <value> Allows to set log level in the browser.
--client-overlay Enables a full-screen overlay in the browser when there are compiler errors or warnings.
--no-client-overlay Disables the full-screen overlay in the browser when there are compiler errors or warnings.
--client-overlay-errors Enables a full-screen overlay in the browser when there are compiler errors.
--no-client-overlay-errors Disables the full-screen overlay in the browser when there are compiler errors.
--client-overlay-warnings Enables a full-screen overlay in the browser when there are compiler warnings.
--no-client-overlay-warnings Disables the full-screen overlay in the browser when there are compiler warnings.
--client-overlay-trusted-types-policy-name <value> The name of a Trusted Types policy for the overlay. Defaults to 'webpack-dev-server#overlay'.
--client-progress Prints compilation progress in percentage in the browser.
--no-client-progress Does not print compilation progress in percentage in the browser.
--client-reconnect [value] Tells dev-server the number of times it should try to reconnect the client.
--no-client-reconnect Tells dev-server to not to try to reconnect the client.
--client-web-socket-transport <value> Allows to set custom web socket transport to communicate with dev server.
--client-web-socket-url <value> Allows to specify URL to web socket server (useful when you're proxying dev server and client script does not always know where to connect to).
--client-web-socket-url-hostname <value> Tells clients connected to devServer to use the provided hostname.
--client-web-socket-url-pathname <value> Tells clients connected to devServer to use the provided path to connect.
--client-web-socket-url-password <value> Tells clients connected to devServer to use the provided password to authenticate.
--client-web-socket-url-port <value> Tells clients connected to devServer to use the provided port.
--client-web-socket-url-protocol <value> Tells clients connected to devServer to use the provided protocol.
--client-web-socket-url-username <value> Tells clients connected to devServer to use the provided username to authenticate.
--compress Enables gzip compression for everything served.
--no-compress Disables gzip compression for everything served.
--history-api-fallback Allows to proxy requests through a specified index page (by default 'index.html'), useful for Single Page Applications that utilise the HTML5 History API.
--no-history-api-fallback Disallows to proxy requests through a specified index page.
--host <value> Allows to specify a hostname to use.
--hot [value] Enables Hot Module Replacement.
--no-hot Disables Hot Module Replacement.
--http2 Allows to serve over HTTP/2 using SPDY. Deprecated, use the `server` option.
--no-http2 Does not serve over HTTP/2 using SPDY.
--https Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). Deprecated, use the `server` option.
--no-https Disallows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP).
--https-passphrase <value> Passphrase for a pfx file. Deprecated, use the `server.options.passphrase` option.
--https-request-cert Request for an SSL certificate. Deprecated, use the `server.options.requestCert` option.
--no-https-request-cert Does not request for an SSL certificate.
--https-ca <value...> Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
--https-ca-reset Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
--https-cacert <value...> Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
--https-cacert-reset Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
--https-cert <value...> Path to an SSL certificate or content of an SSL certificate. Deprecated, use the `server.options.cert` option.
--https-cert-reset Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL certificate. Deprecated, use the `server.options.cert` option.
--https-crl <value...> Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, use the `server.options.crl` option.
--https-crl-reset Clear all items provided in 'https.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, use the `server.options.crl` option.
--https-key <value...> Path to an SSL key or content of an SSL key. Deprecated, use the `server.options.key` option.
--https-key-reset Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key. Deprecated, use the `server.options.key` option.
--https-pfx <value...> Path to an SSL pfx file or content of an SSL pfx file. Deprecated, use the `server.options.pfx` option.
--https-pfx-reset Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. Deprecated, use the `server.options.pfx` option.
--ipc [value] Listen to a unix socket.
--live-reload Enables reload/refresh the page(s) when file changes are detected (enabled by default).
--no-live-reload Disables reload/refresh the page(s) when file changes are detected (enabled by default).
--magic-html Tells dev-server whether to enable magic HTML routes (routes corresponding to your webpack output, for example '/main' for 'main.js').
--no-magic-html Disables magic HTML routes (routes corresponding to your webpack output, for example '/main' for 'main.js').
--open [value...] Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to true to open your default browser).
--no-open Does not open the default browser.
--open-target <value...> Opens specified page in browser.
--open-app-name <value...> Open specified browser.
--open-app <value...> Open specified browser. Deprecated: please use '--open-app-name'.
--open-reset Clear all items provided in 'open' configuration. Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to true to open your default browser).
--open-target-reset Clear all items provided in 'open.target' configuration. Opens specified page in browser.
--open-app-name-reset Clear all items provided in 'open.app.name' configuration. Open specified browser.
--port <value> Allows to specify a port to use.
--server-type <value> Allows to set server and options (by default 'http').
--server-options-passphrase <value> Passphrase for a pfx file.
--server-options-request-cert Request for an SSL certificate.
--no-server-options-request-cert Does not request for an SSL certificate.
--server-options-ca <value...> Path to an SSL CA certificate or content of an SSL CA certificate.
--server-options-ca-reset Clear all items provided in 'server.options.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate.
--server-options-cacert <value...> Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
--server-options-cacert-reset Clear all items provided in 'server.options.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
--server-options-cert <value...> Path to an SSL certificate or content of an SSL certificate.
--server-options-cert-reset Clear all items provided in 'server.options.cert' configuration. Path to an SSL certificate or content of an SSL certificate.
--server-options-crl <value...> Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists).
--server-options-crl-reset Clear all items provided in 'server.options.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists).
--server-options-key <value...> Path to an SSL key or content of an SSL key.
--server-options-key-reset Clear all items provided in 'server.options.key' configuration. Path to an SSL key or content of an SSL key.
--server-options-pfx <value...> Path to an SSL pfx file or content of an SSL pfx file.
--server-options-pfx-reset Clear all items provided in 'server.options.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file.
--static [value...] Allows to configure options for serving static files from directory (by default 'public' directory).
--no-static Disallows to configure options for serving static files from directory.
--static-directory <value...> Directory for static contents.
--static-public-path <value...> The static files will be available in the browser under this public path.
--static-serve-index Tells dev server to use serveIndex middleware when enabled.
--no-static-serve-index Does not tell dev server to use serveIndex middleware.
--static-watch Watches for files in static content directory.
--no-static-watch Does not watch for files in static content directory.
--static-reset Clear all items provided in 'static' configuration. Allows to configure options for serving static files from directory (by default 'public' directory).
--static-public-path-reset Clear all items provided in 'static.publicPath' configuration. The static files will be available in the browser under this public path.
--watch-files <value...> Allows to configure list of globs/directories/files to watch for file changes.
--watch-files-reset Clear all items provided in 'watchFiles' configuration. Allows to configure list of globs/directories/files to watch for file changes.
--web-socket-server <value> Deprecated: please use '--web-socket-server-type' option. Allows to set web socket server and options (by default 'ws').
--no-web-socket-server Disallows to set web socket server and options.
--web-socket-server-type <value> Allows to set web socket server and options (by default 'ws').
Global options:
--color Enable colors on console.
--no-color Disable colors on console.
-v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.
-h, --help [verbose] Display help for commands and options.
To see list of all supported commands and options run 'webpack --help=verbose'.
Webpack documentation: https://webpack.js.org/.
CLI documentation: https://webpack.js.org/api/cli/.
Made with ♥ by the webpack team.
```
> **Note**
>
> _Detailed documentation for above options is available on this [link](https://webpack.js.org/configuration/dev-server/)._
### With NPM Scripts
NPM package.json scripts are a convenient and useful means to run locally installed
binaries without having to be concerned about their full paths. Simply define a
script as such:
```json
{
"scripts": {
"serve": "webpack serve"
}
}
```
And run the following in your terminal/console:
```console
npm run serve
```
NPM will automatically refer to the the binary in `node_modules` for you, and
execute the file or command.
### With the API
While it's recommended to run webpack-dev-server via the CLI, you may also choose to start a server via the API.
See the related [API documentation for `webpack-dev-server`](https://webpack.js.org/api/webpack-dev-server/).
### With TypeScript
If you use TypeScript in the webpack config, you'll need to properly type `devServer` property in order to avoid TS errors (e.g. `'devServer' does not exist in type 'Configuration'`). For that use either:
```ts
/// <reference path="node_modules/webpack-dev-server/types/lib/Server.d.ts"/>
import type { Configuration } from "webpack";
// Your logic
```
Or you can import the type from `webpack-dev-server`, i.e.
```ts
import type { Configuration as DevServerConfiguration } from "webpack-dev-server";
import type { Configuration } from "webpack";
const devServer: DevServerConfiguration = {};
const config: Configuration = { devServer };
// module.exports
export default config;
```
### The Result
Either method will start a server instance and begin listening for connections
from `localhost` on port `8080`.
webpack-dev-server is configured by default to support live-reload of files as
you edit your assets while the server is running.
See [**the documentation**][docs-url] for more use cases and options.
## Browser Support
While `webpack-dev-server` transpiles the client (browser) scripts to an ES5
state, the project only officially supports the _last two versions of major
browsers_. We simply don't have the resources to support every whacky
browser out there.
If you find a bug with an obscure / old browser, we would actively welcome a
Pull Request to resolve the bug.
## Support
We do our best to keep issues in the repository focused on bugs, features, and
needed modifications to the code for the module. Because of that, we ask users
with general support, "how-to", or "why isn't this working" questions to try one
of the other support channels that are available.
Your first-stop-shop for support for webpack-dev-server should be the excellent
[documentation][docs-url] for the module. If you see an opportunity for improvement
of those docs, please head over to the [webpack.js.org repo][wjo-url] and open a
pull request.
From there, we encourage users to visit the [webpack Gitter chat][chat-url] and
talk to the fine folks there. If your quest for answers comes up dry in chat,
head over to [StackOverflow][stack-url] and do a quick search or open a new
question. Remember; It's always much easier to answer questions that include your
`webpack.config.js` and relevant files!
If you're twitter-savvy you can tweet [#webpack][hash-url] with your question
and someone should be able to reach out and lend a hand.
If you have discovered a :bug:, have a feature suggestion, or would like to see
a modification, please feel free to create an issue on Github. _Note: The issue
template isn't optional, so please be sure not to remove it, and please fill it
out completely._
## Contributing
We welcome your contributions! Please have a read of [CONTRIBUTING.md](CONTRIBUTING.md) for more information on how to get involved.
## Attribution
This project is heavily inspired by [peerigon/nof5](https://github.com/peerigon/nof5).
## License
#### [MIT](./LICENSE)
[npm]: https://img.shields.io/npm/v/webpack-dev-server.svg
[npm-url]: https://npmjs.com/package/webpack-dev-server
[node]: https://img.shields.io/node/v/webpack-dev-server.svg
[node-url]: https://nodejs.org
[tests]: https://github.com/webpack/webpack-dev-server/workflows/webpack-dev-server/badge.svg
[tests-url]: https://github.com/webpack/webpack-dev-server/actions?query=workflow%3Awebpack-dev-server
[cover]: https://codecov.io/gh/webpack/webpack-dev-server/branch/master/graph/badge.svg
[cover-url]: https://codecov.io/gh/webpack/webpack-dev-server
[chat]: https://badges.gitter.im/webpack/webpack.svg
[chat-url]: https://gitter.im/webpack/webpack
[docs-url]: https://webpack.js.org/configuration/dev-server/#devserver
[hash-url]: https://twitter.com/search?q=webpack
[middleware-url]: https://github.com/webpack/webpack-dev-middleware
[stack-url]: https://stackoverflow.com/questions/tagged/webpack-dev-server
[uglify-url]: https://github.com/webpack-contrib/uglifyjs-webpack-plugin
[wjo-url]: https://github.com/webpack/webpack.js.org
[downloads]: https://img.shields.io/npm/dm/webpack-dev-server.svg
[contributors-url]: https://github.com/webpack/webpack-dev-server/graphs/contributors
[contributors]: https://img.shields.io/github/contributors/webpack/webpack-dev-server.svg

1277
node_modules/webpack-dev-server/bin/cli-flags.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,412 @@
"use strict";
const path = require("path");
// Based on https://github.com/webpack/webpack/blob/master/lib/cli.js
// Please do not modify it
/** @typedef {"unknown-argument" | "unexpected-non-array-in-path" | "unexpected-non-object-in-path" | "multiple-values-unexpected" | "invalid-value"} ProblemType */
/**
* @typedef {Object} Problem
* @property {ProblemType} type
* @property {string} path
* @property {string} argument
* @property {any=} value
* @property {number=} index
* @property {string=} expected
*/
/**
* @typedef {Object} LocalProblem
* @property {ProblemType} type
* @property {string} path
* @property {string=} expected
*/
/**
* @typedef {Object} ArgumentConfig
* @property {string} description
* @property {string} path
* @property {boolean} multiple
* @property {"enum"|"string"|"path"|"number"|"boolean"|"RegExp"|"reset"} type
* @property {any[]=} values
*/
/**
* @typedef {Object} Argument
* @property {string} description
* @property {"string"|"number"|"boolean"} simpleType
* @property {boolean} multiple
* @property {ArgumentConfig[]} configs
*/
const cliAddedItems = new WeakMap();
/**
* @param {any} config configuration
* @param {string} schemaPath path in the config
* @param {number | undefined} index index of value when multiple values are provided, otherwise undefined
* @returns {{ problem?: LocalProblem, object?: any, property?: string | number, value?: any }} problem or object with property and value
*/
const getObjectAndProperty = (config, schemaPath, index = 0) => {
if (!schemaPath) {
return { value: config };
}
const parts = schemaPath.split(".");
const property = parts.pop();
let current = config;
let i = 0;
for (const part of parts) {
const isArray = part.endsWith("[]");
const name = isArray ? part.slice(0, -2) : part;
let value = current[name];
if (isArray) {
// eslint-disable-next-line no-undefined
if (value === undefined) {
value = {};
current[name] = [...Array.from({ length: index }), value];
cliAddedItems.set(current[name], index + 1);
} else if (!Array.isArray(value)) {
return {
problem: {
type: "unexpected-non-array-in-path",
path: parts.slice(0, i).join("."),
},
};
} else {
let addedItems = cliAddedItems.get(value) || 0;
while (addedItems <= index) {
// eslint-disable-next-line no-undefined
value.push(undefined);
// eslint-disable-next-line no-plusplus
addedItems++;
}
cliAddedItems.set(value, addedItems);
const x = value.length - addedItems + index;
// eslint-disable-next-line no-undefined
if (value[x] === undefined) {
value[x] = {};
} else if (value[x] === null || typeof value[x] !== "object") {
return {
problem: {
type: "unexpected-non-object-in-path",
path: parts.slice(0, i).join("."),
},
};
}
value = value[x];
}
// eslint-disable-next-line no-undefined
} else if (value === undefined) {
// eslint-disable-next-line no-multi-assign
value = current[name] = {};
} else if (value === null || typeof value !== "object") {
return {
problem: {
type: "unexpected-non-object-in-path",
path: parts.slice(0, i).join("."),
},
};
}
current = value;
// eslint-disable-next-line no-plusplus
i++;
}
const value = current[/** @type {string} */ (property)];
if (/** @type {string} */ (property).endsWith("[]")) {
const name = /** @type {string} */ (property).slice(0, -2);
// eslint-disable-next-line no-shadow
const value = current[name];
// eslint-disable-next-line no-undefined
if (value === undefined) {
// eslint-disable-next-line no-undefined
current[name] = [...Array.from({ length: index }), undefined];
cliAddedItems.set(current[name], index + 1);
// eslint-disable-next-line no-undefined
return { object: current[name], property: index, value: undefined };
} else if (!Array.isArray(value)) {
// eslint-disable-next-line no-undefined
current[name] = [value, ...Array.from({ length: index }), undefined];
cliAddedItems.set(current[name], index + 1);
// eslint-disable-next-line no-undefined
return { object: current[name], property: index + 1, value: undefined };
}
let addedItems = cliAddedItems.get(value) || 0;
while (addedItems <= index) {
// eslint-disable-next-line no-undefined
value.push(undefined);
// eslint-disable-next-line no-plusplus
addedItems++;
}
cliAddedItems.set(value, addedItems);
const x = value.length - addedItems + index;
// eslint-disable-next-line no-undefined
if (value[x] === undefined) {
value[x] = {};
} else if (value[x] === null || typeof value[x] !== "object") {
return {
problem: {
type: "unexpected-non-object-in-path",
path: schemaPath,
},
};
}
return {
object: value,
property: x,
value: value[x],
};
}
return { object: current, property, value };
};
/**
* @param {ArgumentConfig} argConfig processing instructions
* @param {any} value the value
* @returns {any | undefined} parsed value
*/
const parseValueForArgumentConfig = (argConfig, value) => {
// eslint-disable-next-line default-case
switch (argConfig.type) {
case "string":
if (typeof value === "string") {
return value;
}
break;
case "path":
if (typeof value === "string") {
return path.resolve(value);
}
break;
case "number":
if (typeof value === "number") {
return value;
}
if (typeof value === "string" && /^[+-]?\d*(\.\d*)[eE]\d+$/) {
const n = +value;
if (!isNaN(n)) return n;
}
break;
case "boolean":
if (typeof value === "boolean") {
return value;
}
if (value === "true") {
return true;
}
if (value === "false") {
return false;
}
break;
case "RegExp":
if (value instanceof RegExp) {
return value;
}
if (typeof value === "string") {
// cspell:word yugi
const match = /^\/(.*)\/([yugi]*)$/.exec(value);
if (match && !/[^\\]\//.test(match[1])) {
return new RegExp(match[1], match[2]);
}
}
break;
case "enum":
if (/** @type {any[]} */ (argConfig.values).includes(value)) {
return value;
}
for (const item of /** @type {any[]} */ (argConfig.values)) {
if (`${item}` === value) return item;
}
break;
case "reset":
if (value === true) {
return [];
}
break;
}
};
/**
* @param {ArgumentConfig} argConfig processing instructions
* @returns {string | undefined} expected message
*/
const getExpectedValue = (argConfig) => {
switch (argConfig.type) {
default:
return argConfig.type;
case "boolean":
return "true | false";
case "RegExp":
return "regular expression (example: /ab?c*/)";
case "enum":
return /** @type {any[]} */ (argConfig.values)
.map((v) => `${v}`)
.join(" | ");
case "reset":
return "true (will reset the previous value to an empty array)";
}
};
/**
* @param {any} config configuration
* @param {string} schemaPath path in the config
* @param {any} value parsed value
* @param {number | undefined} index index of value when multiple values are provided, otherwise undefined
* @returns {LocalProblem | null} problem or null for success
*/
const setValue = (config, schemaPath, value, index) => {
const { problem, object, property } = getObjectAndProperty(
config,
schemaPath,
index
);
if (problem) {
return problem;
}
object[/** @type {string} */ (property)] = value;
return null;
};
/**
* @param {ArgumentConfig} argConfig processing instructions
* @param {any} config configuration
* @param {any} value the value
* @param {number | undefined} index the index if multiple values provided
* @returns {LocalProblem | null} a problem if any
*/
const processArgumentConfig = (argConfig, config, value, index) => {
// eslint-disable-next-line no-undefined
if (index !== undefined && !argConfig.multiple) {
return {
type: "multiple-values-unexpected",
path: argConfig.path,
};
}
const parsed = parseValueForArgumentConfig(argConfig, value);
// eslint-disable-next-line no-undefined
if (parsed === undefined) {
return {
type: "invalid-value",
path: argConfig.path,
expected: getExpectedValue(argConfig),
};
}
const problem = setValue(config, argConfig.path, parsed, index);
if (problem) {
return problem;
}
return null;
};
/**
* @param {Record<string, Argument>} args object of arguments
* @param {any} config configuration
* @param {Record<string, string | number | boolean | RegExp | (string | number | boolean | RegExp)[]>} values object with values
* @returns {Problem[] | null} problems or null for success
*/
const processArguments = (args, config, values) => {
/**
* @type {Problem[]}
*/
const problems = [];
for (const key of Object.keys(values)) {
const arg = args[key];
if (!arg) {
problems.push({
type: "unknown-argument",
path: "",
argument: key,
});
// eslint-disable-next-line no-continue
continue;
}
/**
* @param {any} value
* @param {number | undefined} i
*/
const processValue = (value, i) => {
const currentProblems = [];
for (const argConfig of arg.configs) {
const problem = processArgumentConfig(argConfig, config, value, i);
if (!problem) {
return;
}
currentProblems.push({
...problem,
argument: key,
value,
index: i,
});
}
problems.push(...currentProblems);
};
const value = values[key];
if (Array.isArray(value)) {
for (let i = 0; i < value.length; i++) {
processValue(value[i], i);
}
} else {
// eslint-disable-next-line no-undefined
processValue(value, undefined);
}
}
if (problems.length === 0) {
return null;
}
return problems;
};
module.exports = processArguments;

View File

@@ -0,0 +1,177 @@
#!/usr/bin/env node
/* Based on webpack/bin/webpack.js */
/* eslint-disable no-console */
"use strict";
/**
* @param {string} command process to run
* @param {string[]} args command line arguments
* @returns {Promise<void>} promise
*/
const runCommand = (command, args) => {
const cp = require("child_process");
return new Promise((resolve, reject) => {
const executedCommand = cp.spawn(command, args, {
stdio: "inherit",
shell: true,
});
executedCommand.on("error", (error) => {
reject(error);
});
executedCommand.on("exit", (code) => {
if (code === 0) {
resolve();
} else {
reject();
}
});
});
};
/**
* @param {string} packageName name of the package
* @returns {boolean} is the package installed?
*/
const isInstalled = (packageName) => {
if (process.versions.pnp) {
return true;
}
const path = require("path");
const fs = require("graceful-fs");
let dir = __dirname;
do {
try {
if (
fs.statSync(path.join(dir, "node_modules", packageName)).isDirectory()
) {
return true;
}
} catch (_error) {
// Nothing
}
// eslint-disable-next-line no-cond-assign
} while (dir !== (dir = path.dirname(dir)));
return false;
};
/**
* @param {CliOption} cli options
* @returns {void}
*/
const runCli = (cli) => {
if (cli.preprocess) {
cli.preprocess();
}
const path = require("path");
const pkgPath = require.resolve(`${cli.package}/package.json`);
// eslint-disable-next-line import/no-dynamic-require
const pkg = require(pkgPath);
// eslint-disable-next-line import/no-dynamic-require
require(path.resolve(path.dirname(pkgPath), pkg.bin[cli.binName]));
};
/**
* @typedef {Object} CliOption
* @property {string} name display name
* @property {string} package npm package name
* @property {string} binName name of the executable file
* @property {boolean} installed currently installed?
* @property {string} url homepage
* @property {function} preprocess preprocessor
*/
/** @type {CliOption} */
const cli = {
name: "webpack-cli",
package: "webpack-cli",
binName: "webpack-cli",
installed: isInstalled("webpack-cli"),
url: "https://github.com/webpack/webpack-cli",
preprocess() {
process.argv.splice(2, 0, "serve");
},
};
if (!cli.installed) {
const path = require("path");
const fs = require("graceful-fs");
const readLine = require("readline");
const notify = `CLI for webpack must be installed.\n ${cli.name} (${cli.url})\n`;
console.error(notify);
/**
* @type {string}
*/
let packageManager;
if (fs.existsSync(path.resolve(process.cwd(), "yarn.lock"))) {
packageManager = "yarn";
} else if (fs.existsSync(path.resolve(process.cwd(), "pnpm-lock.yaml"))) {
packageManager = "pnpm";
} else {
packageManager = "npm";
}
const installOptions = [packageManager === "yarn" ? "add" : "install", "-D"];
console.error(
`We will use "${packageManager}" to install the CLI via "${packageManager} ${installOptions.join(
" "
)} ${cli.package}".`
);
const question = `Do you want to install 'webpack-cli' (yes/no): `;
const questionInterface = readLine.createInterface({
input: process.stdin,
output: process.stderr,
});
// In certain scenarios (e.g. when STDIN is not in terminal mode), the callback function will not be
// executed. Setting the exit code here to ensure the script exits correctly in those cases. The callback
// function is responsible for clearing the exit code if the user wishes to install webpack-cli.
process.exitCode = 1;
questionInterface.question(question, (answer) => {
questionInterface.close();
const normalizedAnswer = answer.toLowerCase().startsWith("y");
if (!normalizedAnswer) {
console.error(
"You need to install 'webpack-cli' to use webpack via CLI.\n" +
"You can also install the CLI manually."
);
return;
}
process.exitCode = 0;
console.log(
`Installing '${
cli.package
}' (running '${packageManager} ${installOptions.join(" ")} ${
cli.package
}')...`
);
runCommand(packageManager, installOptions.concat(cli.package))
.then(() => {
runCli(cli);
})
.catch((error) => {
console.error(error);
process.exitCode = 1;
});
});
} else {
runCli(cli);
}

View File

@@ -0,0 +1,68 @@
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
import SockJS from "../modules/sockjs-client/index.js";
import { log } from "../utils/log.js";
var SockJSClient = /*#__PURE__*/function () {
/**
* @param {string} url
*/
function SockJSClient(url) {
_classCallCheck(this, SockJSClient);
// SockJS requires `http` and `https` protocols
this.sock = new SockJS(url.replace(/^ws:/i, "http:").replace(/^wss:/i, "https:"));
this.sock.onerror =
/**
* @param {Error} error
*/
function (error) {
log.error(error);
};
}
/**
* @param {(...args: any[]) => void} f
*/
_createClass(SockJSClient, [{
key: "onOpen",
value: function onOpen(f) {
this.sock.onopen = f;
}
/**
* @param {(...args: any[]) => void} f
*/
}, {
key: "onClose",
value: function onClose(f) {
this.sock.onclose = f;
} // call f with the message string as the first argument
/**
* @param {(...args: any[]) => void} f
*/
}, {
key: "onMessage",
value: function onMessage(f) {
this.sock.onmessage =
/**
* @param {Error & { data: string }} e
*/
function (e) {
f(e.data);
};
}
}]);
return SockJSClient;
}();
export { SockJSClient as default };

View File

@@ -0,0 +1,58 @@
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
import { log } from "../utils/log.js";
var WebSocketClient = /*#__PURE__*/function () {
/**
* @param {string} url
*/
function WebSocketClient(url) {
_classCallCheck(this, WebSocketClient);
this.client = new WebSocket(url);
this.client.onerror = function (error) {
log.error(error);
};
}
/**
* @param {(...args: any[]) => void} f
*/
_createClass(WebSocketClient, [{
key: "onOpen",
value: function onOpen(f) {
this.client.onopen = f;
}
/**
* @param {(...args: any[]) => void} f
*/
}, {
key: "onClose",
value: function onClose(f) {
this.client.onclose = f;
} // call f with the message string as the first argument
/**
* @param {(...args: any[]) => void} f
*/
}, {
key: "onMessage",
value: function onMessage(f) {
this.client.onmessage = function (e) {
f(e.data);
};
}
}]);
return WebSocketClient;
}();
export { WebSocketClient as default };

309
node_modules/webpack-dev-server/client/index.js generated vendored Normal file
View File

@@ -0,0 +1,309 @@
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/* global __resourceQuery, __webpack_hash__ */
/// <reference types="webpack/module" />
import webpackHotLog from "webpack/hot/log.js";
import stripAnsi from "./utils/stripAnsi.js";
import parseURL from "./utils/parseURL.js";
import socket from "./socket.js";
import { formatProblem, show, hide } from "./overlay.js";
import { log, logEnabledFeatures, setLogLevel } from "./utils/log.js";
import sendMessage from "./utils/sendMessage.js";
import reloadApp from "./utils/reloadApp.js";
import createSocketURL from "./utils/createSocketURL.js";
/**
* @typedef {Object} Options
* @property {boolean} hot
* @property {boolean} liveReload
* @property {boolean} progress
* @property {boolean | { warnings?: boolean, errors?: boolean, trustedTypesPolicyName?: string }} overlay
* @property {string} [logging]
* @property {number} [reconnect]
*/
/**
* @typedef {Object} Status
* @property {boolean} isUnloading
* @property {string} currentHash
* @property {string} [previousHash]
*/
/**
* @type {Status}
*/
var status = {
isUnloading: false,
// TODO Workaround for webpack v4, `__webpack_hash__` is not replaced without HotModuleReplacement
// eslint-disable-next-line camelcase
currentHash: typeof __webpack_hash__ !== "undefined" ? __webpack_hash__ : ""
};
/** @type {Options} */
var options = {
hot: false,
liveReload: false,
progress: false,
overlay: false
};
var parsedResourceQuery = parseURL(__resourceQuery);
var enabledFeatures = {
"Hot Module Replacement": false,
"Live Reloading": false,
Progress: false,
Overlay: false
};
if (parsedResourceQuery.hot === "true") {
options.hot = true;
enabledFeatures["Hot Module Replacement"] = true;
}
if (parsedResourceQuery["live-reload"] === "true") {
options.liveReload = true;
enabledFeatures["Live Reloading"] = true;
}
if (parsedResourceQuery.progress === "true") {
options.progress = true;
enabledFeatures.Progress = true;
}
if (parsedResourceQuery.overlay) {
try {
options.overlay = JSON.parse(parsedResourceQuery.overlay);
} catch (e) {
log.error("Error parsing overlay options from resource query:", e);
} // Fill in default "true" params for partially-specified objects.
if (typeof options.overlay === "object") {
options.overlay = _objectSpread({
errors: true,
warnings: true
}, options.overlay);
}
enabledFeatures.Overlay = true;
}
if (parsedResourceQuery.logging) {
options.logging = parsedResourceQuery.logging;
}
if (typeof parsedResourceQuery.reconnect !== "undefined") {
options.reconnect = Number(parsedResourceQuery.reconnect);
}
logEnabledFeatures(enabledFeatures);
/**
* @param {string} level
*/
function setAllLogLevel(level) {
// This is needed because the HMR logger operate separately from dev server logger
webpackHotLog.setLogLevel(level === "verbose" || level === "log" ? "info" : level);
setLogLevel(level);
}
if (options.logging) {
setAllLogLevel(options.logging);
}
self.addEventListener("beforeunload", function () {
status.isUnloading = true;
});
var onSocketMessage = {
hot: function hot() {
if (parsedResourceQuery.hot === "false") {
return;
}
options.hot = true;
},
liveReload: function liveReload() {
if (parsedResourceQuery["live-reload"] === "false") {
return;
}
options.liveReload = true;
},
invalid: function invalid() {
log.info("App updated. Recompiling..."); // Fixes #1042. overlay doesn't clear if errors are fixed but warnings remain.
if (options.overlay) {
hide();
}
sendMessage("Invalid");
},
/**
* @param {string} hash
*/
hash: function hash(_hash) {
status.previousHash = status.currentHash;
status.currentHash = _hash;
},
logging: setAllLogLevel,
/**
* @param {boolean} value
*/
overlay: function overlay(value) {
if (typeof document === "undefined") {
return;
}
options.overlay = value;
},
/**
* @param {number} value
*/
reconnect: function reconnect(value) {
if (parsedResourceQuery.reconnect === "false") {
return;
}
options.reconnect = value;
},
/**
* @param {boolean} value
*/
progress: function progress(value) {
options.progress = value;
},
/**
* @param {{ pluginName?: string, percent: number, msg: string }} data
*/
"progress-update": function progressUpdate(data) {
if (options.progress) {
log.info("".concat(data.pluginName ? "[".concat(data.pluginName, "] ") : "").concat(data.percent, "% - ").concat(data.msg, "."));
}
sendMessage("Progress", data);
},
"still-ok": function stillOk() {
log.info("Nothing changed.");
if (options.overlay) {
hide();
}
sendMessage("StillOk");
},
ok: function ok() {
sendMessage("Ok");
if (options.overlay) {
hide();
}
reloadApp(options, status);
},
// TODO: remove in v5 in favor of 'static-changed'
/**
* @param {string} file
*/
"content-changed": function contentChanged(file) {
log.info("".concat(file ? "\"".concat(file, "\"") : "Content", " from static directory was changed. Reloading..."));
self.location.reload();
},
/**
* @param {string} file
*/
"static-changed": function staticChanged(file) {
log.info("".concat(file ? "\"".concat(file, "\"") : "Content", " from static directory was changed. Reloading..."));
self.location.reload();
},
/**
* @param {Error[]} warnings
* @param {any} params
*/
warnings: function warnings(_warnings, params) {
log.warn("Warnings while compiling.");
var printableWarnings = _warnings.map(function (error) {
var _formatProblem = formatProblem("warning", error),
header = _formatProblem.header,
body = _formatProblem.body;
return "".concat(header, "\n").concat(stripAnsi(body));
});
sendMessage("Warnings", printableWarnings);
for (var i = 0; i < printableWarnings.length; i++) {
log.warn(printableWarnings[i]);
}
var needShowOverlayForWarnings = typeof options.overlay === "boolean" ? options.overlay : options.overlay && options.overlay.warnings;
if (needShowOverlayForWarnings) {
var trustedTypesPolicyName = typeof options.overlay === "object" && options.overlay.trustedTypesPolicyName;
show("warning", _warnings, trustedTypesPolicyName || null);
}
if (params && params.preventReloading) {
return;
}
reloadApp(options, status);
},
/**
* @param {Error[]} errors
*/
errors: function errors(_errors) {
log.error("Errors while compiling. Reload prevented.");
var printableErrors = _errors.map(function (error) {
var _formatProblem2 = formatProblem("error", error),
header = _formatProblem2.header,
body = _formatProblem2.body;
return "".concat(header, "\n").concat(stripAnsi(body));
});
sendMessage("Errors", printableErrors);
for (var i = 0; i < printableErrors.length; i++) {
log.error(printableErrors[i]);
}
var needShowOverlayForErrors = typeof options.overlay === "boolean" ? options.overlay : options.overlay && options.overlay.errors;
if (needShowOverlayForErrors) {
var trustedTypesPolicyName = typeof options.overlay === "object" && options.overlay.trustedTypesPolicyName;
show("error", _errors, trustedTypesPolicyName || null);
}
},
/**
* @param {Error} error
*/
error: function error(_error) {
log.error(_error);
},
close: function close() {
log.info("Disconnected!");
if (options.overlay) {
hide();
}
sendMessage("Close");
}
};
var socketURL = createSocketURL(parsedResourceQuery);
socket(socketURL, onSocketMessage, options.reconnect);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

214
node_modules/webpack-dev-server/client/overlay.js generated vendored Normal file
View File

@@ -0,0 +1,214 @@
// The error overlay is inspired (and mostly copied) from Create React App (https://github.com/facebookincubator/create-react-app)
// They, in turn, got inspired by webpack-hot-middleware (https://github.com/glenjamin/webpack-hot-middleware).
import ansiHTML from "ansi-html-community";
import { encode } from "html-entities";
var colors = {
reset: ["transparent", "transparent"],
black: "181818",
red: "E36049",
green: "B3CB74",
yellow: "FFD080",
blue: "7CAFC2",
magenta: "7FACCA",
cyan: "C3C2EF",
lightgrey: "EBE7E3",
darkgrey: "6D7891"
};
/** @type {HTMLIFrameElement | null | undefined} */
var iframeContainerElement;
/** @type {HTMLDivElement | null | undefined} */
var containerElement;
/** @type {Array<(element: HTMLDivElement) => void>} */
var onLoadQueue = [];
/** @type {TrustedTypePolicy | undefined} */
var overlayTrustedTypesPolicy;
ansiHTML.setColors(colors);
/**
* @param {string | null} trustedTypesPolicyName
*/
function createContainer(trustedTypesPolicyName) {
// Enable Trusted Types if they are available in the current browser.
if (window.trustedTypes) {
overlayTrustedTypesPolicy = window.trustedTypes.createPolicy(trustedTypesPolicyName || "webpack-dev-server#overlay", {
createHTML: function createHTML(value) {
return value;
}
});
}
iframeContainerElement = document.createElement("iframe");
iframeContainerElement.id = "webpack-dev-server-client-overlay";
iframeContainerElement.src = "about:blank";
iframeContainerElement.style.position = "fixed";
iframeContainerElement.style.left = 0;
iframeContainerElement.style.top = 0;
iframeContainerElement.style.right = 0;
iframeContainerElement.style.bottom = 0;
iframeContainerElement.style.width = "100vw";
iframeContainerElement.style.height = "100vh";
iframeContainerElement.style.border = "none";
iframeContainerElement.style.zIndex = 9999999999;
iframeContainerElement.onload = function () {
containerElement =
/** @type {Document} */
/** @type {HTMLIFrameElement} */
iframeContainerElement.contentDocument.createElement("div");
containerElement.id = "webpack-dev-server-client-overlay-div";
containerElement.style.position = "fixed";
containerElement.style.boxSizing = "border-box";
containerElement.style.left = 0;
containerElement.style.top = 0;
containerElement.style.right = 0;
containerElement.style.bottom = 0;
containerElement.style.width = "100vw";
containerElement.style.height = "100vh";
containerElement.style.backgroundColor = "rgba(0, 0, 0, 0.85)";
containerElement.style.color = "#E8E8E8";
containerElement.style.fontFamily = "Menlo, Consolas, monospace";
containerElement.style.fontSize = "large";
containerElement.style.padding = "2rem";
containerElement.style.lineHeight = "1.2";
containerElement.style.whiteSpace = "pre-wrap";
containerElement.style.overflow = "auto";
var headerElement = document.createElement("span");
headerElement.innerText = "Compiled with problems:";
var closeButtonElement = document.createElement("button");
closeButtonElement.innerText = "X";
closeButtonElement.style.background = "transparent";
closeButtonElement.style.border = "none";
closeButtonElement.style.fontSize = "20px";
closeButtonElement.style.fontWeight = "bold";
closeButtonElement.style.color = "white";
closeButtonElement.style.cursor = "pointer";
closeButtonElement.style.cssFloat = "right"; // @ts-ignore
closeButtonElement.style.styleFloat = "right";
closeButtonElement.addEventListener("click", function () {
hide();
});
containerElement.appendChild(headerElement);
containerElement.appendChild(closeButtonElement);
containerElement.appendChild(document.createElement("br"));
containerElement.appendChild(document.createElement("br"));
/** @type {Document} */
/** @type {HTMLIFrameElement} */
iframeContainerElement.contentDocument.body.appendChild(containerElement);
onLoadQueue.forEach(function (onLoad) {
onLoad(
/** @type {HTMLDivElement} */
containerElement);
});
onLoadQueue = [];
/** @type {HTMLIFrameElement} */
iframeContainerElement.onload = null;
};
document.body.appendChild(iframeContainerElement);
}
/**
* @param {(element: HTMLDivElement) => void} callback
* @param {string | null} trustedTypesPolicyName
*/
function ensureOverlayExists(callback, trustedTypesPolicyName) {
if (containerElement) {
// Everything is ready, call the callback right away.
callback(containerElement);
return;
}
onLoadQueue.push(callback);
if (iframeContainerElement) {
return;
}
createContainer(trustedTypesPolicyName);
} // Successful compilation.
function hide() {
if (!iframeContainerElement) {
return;
} // Clean up and reset internal state.
document.body.removeChild(iframeContainerElement);
iframeContainerElement = null;
containerElement = null;
}
/**
* @param {string} type
* @param {string | { file?: string, moduleName?: string, loc?: string, message?: string }} item
* @returns {{ header: string, body: string }}
*/
function formatProblem(type, item) {
var header = type === "warning" ? "WARNING" : "ERROR";
var body = "";
if (typeof item === "string") {
body += item;
} else {
var file = item.file || ""; // eslint-disable-next-line no-nested-ternary
var moduleName = item.moduleName ? item.moduleName.indexOf("!") !== -1 ? "".concat(item.moduleName.replace(/^(\s|\S)*!/, ""), " (").concat(item.moduleName, ")") : "".concat(item.moduleName) : "";
var loc = item.loc;
header += "".concat(moduleName || file ? " in ".concat(moduleName ? "".concat(moduleName).concat(file ? " (".concat(file, ")") : "") : file).concat(loc ? " ".concat(loc) : "") : "");
body += item.message || "";
}
return {
header: header,
body: body
};
} // Compilation with errors (e.g. syntax error or missing modules).
/**
* @param {string} type
* @param {Array<string | { file?: string, moduleName?: string, loc?: string, message?: string }>} messages
* @param {string | null} trustedTypesPolicyName
*/
function show(type, messages, trustedTypesPolicyName) {
ensureOverlayExists(function () {
messages.forEach(function (message) {
var entryElement = document.createElement("div");
var typeElement = document.createElement("span");
var _formatProblem = formatProblem(type, message),
header = _formatProblem.header,
body = _formatProblem.body;
typeElement.innerText = header;
typeElement.style.color = "#".concat(colors.red); // Make it look similar to our terminal.
var text = ansiHTML(encode(body));
var messageTextNode = document.createElement("div");
messageTextNode.innerHTML = overlayTrustedTypesPolicy ? overlayTrustedTypesPolicy.createHTML(text) : text;
entryElement.appendChild(typeElement);
entryElement.appendChild(document.createElement("br"));
entryElement.appendChild(document.createElement("br"));
entryElement.appendChild(messageTextNode);
entryElement.appendChild(document.createElement("br"));
entryElement.appendChild(document.createElement("br"));
/** @type {HTMLDivElement} */
containerElement.appendChild(entryElement);
});
}, trustedTypesPolicyName);
}
export { formatProblem, show, hide };

65
node_modules/webpack-dev-server/client/socket.js generated vendored Normal file
View File

@@ -0,0 +1,65 @@
/* global __webpack_dev_server_client__ */
import WebSocketClient from "./clients/WebSocketClient.js";
import { log } from "./utils/log.js"; // this WebsocketClient is here as a default fallback, in case the client is not injected
/* eslint-disable camelcase */
var Client = // eslint-disable-next-line no-nested-ternary
typeof __webpack_dev_server_client__ !== "undefined" ? typeof __webpack_dev_server_client__.default !== "undefined" ? __webpack_dev_server_client__.default : __webpack_dev_server_client__ : WebSocketClient;
/* eslint-enable camelcase */
var retries = 0;
var maxRetries = 10; // Initialized client is exported so external consumers can utilize the same instance
// It is mutable to enforce singleton
// eslint-disable-next-line import/no-mutable-exports
export var client = null;
/**
* @param {string} url
* @param {{ [handler: string]: (data?: any, params?: any) => any }} handlers
* @param {number} [reconnect]
*/
var socket = function initSocket(url, handlers, reconnect) {
client = new Client(url);
client.onOpen(function () {
retries = 0;
if (typeof reconnect !== "undefined") {
maxRetries = reconnect;
}
});
client.onClose(function () {
if (retries === 0) {
handlers.close();
} // Try to reconnect.
client = null; // After 10 retries stop trying, to prevent logspam.
if (retries < maxRetries) {
// Exponentially increase timeout to reconnect.
// Respectfully copied from the package `got`.
// eslint-disable-next-line no-restricted-properties
var retryInMs = 1000 * Math.pow(2, retries) + Math.random() * 100;
retries += 1;
log.info("Trying to reconnect...");
setTimeout(function () {
socket(url, handlers, reconnect);
}, retryInMs);
}
});
client.onMessage(
/**
* @param {any} data
*/
function (data) {
var message = JSON.parse(data);
if (handlers[message.type]) {
handlers[message.type](message.data, message.params);
}
});
};
export default socket;

View File

@@ -0,0 +1,137 @@
/**
* @param {{ protocol?: string, auth?: string, hostname?: string, port?: string, pathname?: string, search?: string, hash?: string, slashes?: boolean }} objURL
* @returns {string}
*/
function format(objURL) {
var protocol = objURL.protocol || "";
if (protocol && protocol.substr(-1) !== ":") {
protocol += ":";
}
var auth = objURL.auth || "";
if (auth) {
auth = encodeURIComponent(auth);
auth = auth.replace(/%3A/i, ":");
auth += "@";
}
var host = "";
if (objURL.hostname) {
host = auth + (objURL.hostname.indexOf(":") === -1 ? objURL.hostname : "[".concat(objURL.hostname, "]"));
if (objURL.port) {
host += ":".concat(objURL.port);
}
}
var pathname = objURL.pathname || "";
if (objURL.slashes) {
host = "//".concat(host || "");
if (pathname && pathname.charAt(0) !== "/") {
pathname = "/".concat(pathname);
}
} else if (!host) {
host = "";
}
var search = objURL.search || "";
if (search && search.charAt(0) !== "?") {
search = "?".concat(search);
}
var hash = objURL.hash || "";
if (hash && hash.charAt(0) !== "#") {
hash = "#".concat(hash);
}
pathname = pathname.replace(/[?#]/g,
/**
* @param {string} match
* @returns {string}
*/
function (match) {
return encodeURIComponent(match);
});
search = search.replace("#", "%23");
return "".concat(protocol).concat(host).concat(pathname).concat(search).concat(hash);
}
/**
* @param {URL & { fromCurrentScript?: boolean }} parsedURL
* @returns {string}
*/
function createSocketURL(parsedURL) {
var hostname = parsedURL.hostname; // Node.js module parses it as `::`
// `new URL(urlString, [baseURLString])` parses it as '[::]'
var isInAddrAny = hostname === "0.0.0.0" || hostname === "::" || hostname === "[::]"; // why do we need this check?
// hostname n/a for file protocol (example, when using electron, ionic)
// see: https://github.com/webpack/webpack-dev-server/pull/384
if (isInAddrAny && self.location.hostname && self.location.protocol.indexOf("http") === 0) {
hostname = self.location.hostname;
}
var socketURLProtocol = parsedURL.protocol || self.location.protocol; // When https is used in the app, secure web sockets are always necessary because the browser doesn't accept non-secure web sockets.
if (socketURLProtocol === "auto:" || hostname && isInAddrAny && self.location.protocol === "https:") {
socketURLProtocol = self.location.protocol;
}
socketURLProtocol = socketURLProtocol.replace(/^(?:http|.+-extension|file)/i, "ws");
var socketURLAuth = ""; // `new URL(urlString, [baseURLstring])` doesn't have `auth` property
// Parse authentication credentials in case we need them
if (parsedURL.username) {
socketURLAuth = parsedURL.username; // Since HTTP basic authentication does not allow empty username,
// we only include password if the username is not empty.
if (parsedURL.password) {
// Result: <username>:<password>
socketURLAuth = socketURLAuth.concat(":", parsedURL.password);
}
} // In case the host is a raw IPv6 address, it can be enclosed in
// the brackets as the brackets are needed in the final URL string.
// Need to remove those as url.format blindly adds its own set of brackets
// if the host string contains colons. That would lead to non-working
// double brackets (e.g. [[::]]) host
//
// All of these web socket url params are optionally passed in through resourceQuery,
// so we need to fall back to the default if they are not provided
var socketURLHostname = (hostname || self.location.hostname || "localhost").replace(/^\[(.*)\]$/, "$1");
var socketURLPort = parsedURL.port;
if (!socketURLPort || socketURLPort === "0") {
socketURLPort = self.location.port;
} // If path is provided it'll be passed in via the resourceQuery as a
// query param so it has to be parsed out of the querystring in order for the
// client to open the socket to the correct location.
var socketURLPathname = "/ws";
if (parsedURL.pathname && !parsedURL.fromCurrentScript) {
socketURLPathname = parsedURL.pathname;
}
return format({
protocol: socketURLProtocol,
auth: socketURLAuth,
hostname: socketURLHostname,
port: socketURLPort,
pathname: socketURLPathname,
slashes: true
});
}
export default createSocketURL;

View File

@@ -0,0 +1,26 @@
/**
* @returns {string}
*/
function getCurrentScriptSource() {
// `document.currentScript` is the most accurate way to find the current script,
// but is not supported in all browsers.
if (document.currentScript) {
return document.currentScript.getAttribute("src");
} // Fallback to getting all scripts running in the document.
var scriptElements = document.scripts || [];
var scriptElementsWithSrc = Array.prototype.filter.call(scriptElements, function (element) {
return element.getAttribute("src");
});
if (scriptElementsWithSrc.length > 0) {
var currentScript = scriptElementsWithSrc[scriptElementsWithSrc.length - 1];
return currentScript.getAttribute("src");
} // Fail as there was no script to use.
throw new Error("[webpack-dev-server] Failed to get current script source.");
}
export default getCurrentScriptSource;

55
node_modules/webpack-dev-server/client/utils/log.js generated vendored Normal file
View File

@@ -0,0 +1,55 @@
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
import logger from "../modules/logger/index.js";
var name = "webpack-dev-server"; // default level is set on the client side, so it does not need
// to be set by the CLI or API
var defaultLevel = "info"; // options new options, merge with old options
/**
* @param {false | true | "none" | "error" | "warn" | "info" | "log" | "verbose"} level
* @returns {void}
*/
function setLogLevel(level) {
logger.configureDefaultLogger({
level: level
});
}
setLogLevel(defaultLevel);
var log = logger.getLogger(name);
var logEnabledFeatures = function logEnabledFeatures(features) {
var enabledFeatures = Object.entries(features);
if (!features || enabledFeatures.length === 0) {
return;
}
var logString = "Server started:"; // Server started: Hot Module Replacement enabled, Live Reloading enabled, Overlay disabled.
for (var _i = 0, _Object$entries = Object.entries(features); _i < _Object$entries.length; _i++) {
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
key = _Object$entries$_i[0],
value = _Object$entries$_i[1];
logString += " ".concat(key, " ").concat(value ? "enabled" : "disabled", ",");
} // replace last comma with a period
logString = logString.slice(0, -1).concat(".");
log.info(logString);
};
export { log, logEnabledFeatures, setLogLevel };

View File

@@ -0,0 +1,41 @@
import getCurrentScriptSource from "./getCurrentScriptSource.js";
/**
* @param {string} resourceQuery
* @returns {{ [key: string]: string | boolean }}
*/
function parseURL(resourceQuery) {
/** @type {{ [key: string]: string }} */
var options = {};
if (typeof resourceQuery === "string" && resourceQuery !== "") {
var searchParams = resourceQuery.slice(1).split("&");
for (var i = 0; i < searchParams.length; i++) {
var pair = searchParams[i].split("=");
options[pair[0]] = decodeURIComponent(pair[1]);
}
} else {
// Else, get the url from the <script> this file was called with.
var scriptSource = getCurrentScriptSource();
var scriptSourceURL;
try {
// The placeholder `baseURL` with `window.location.href`,
// is to allow parsing of path-relative or protocol-relative URLs,
// and will have no effect if `scriptSource` is a fully valid URL.
scriptSourceURL = new URL(scriptSource, self.location.href);
} catch (error) {// URL parsing failed, do nothing.
// We will still proceed to see if we can recover using `resourceQuery`
}
if (scriptSourceURL) {
options = scriptSourceURL;
options.fromCurrentScript = true;
}
}
return options;
}
export default parseURL;

View File

@@ -0,0 +1,72 @@
import hotEmitter from "webpack/hot/emitter.js";
import { log } from "./log.js";
/** @typedef {import("../index").Options} Options
/** @typedef {import("../index").Status} Status
/**
* @param {Options} options
* @param {Status} status
*/
function reloadApp(_ref, status) {
var hot = _ref.hot,
liveReload = _ref.liveReload;
if (status.isUnloading) {
return;
}
var currentHash = status.currentHash,
previousHash = status.previousHash;
var isInitial = currentHash.indexOf(
/** @type {string} */
previousHash) >= 0;
if (isInitial) {
return;
}
/**
* @param {Window} rootWindow
* @param {number} intervalId
*/
function applyReload(rootWindow, intervalId) {
clearInterval(intervalId);
log.info("App updated. Reloading...");
rootWindow.location.reload();
}
var search = self.location.search.toLowerCase();
var allowToHot = search.indexOf("webpack-dev-server-hot=false") === -1;
var allowToLiveReload = search.indexOf("webpack-dev-server-live-reload=false") === -1;
if (hot && allowToHot) {
log.info("App hot update...");
hotEmitter.emit("webpackHotUpdate", status.currentHash);
if (typeof self !== "undefined" && self.window) {
// broadcast update to window
self.postMessage("webpackHotUpdate".concat(status.currentHash), "*");
}
} // allow refreshing the page only if liveReload isn't disabled
else if (liveReload && allowToLiveReload) {
var rootWindow = self; // use parent window for reload (in case we're in an iframe with no valid src)
var intervalId = self.setInterval(function () {
if (rootWindow.location.protocol !== "about:") {
// reload immediately if protocol is valid
applyReload(rootWindow, intervalId);
} else {
rootWindow = rootWindow.parent;
if (rootWindow.parent === rootWindow) {
// if parent equals current window we've reached the root which would continue forever, so trigger a reload anyways
applyReload(rootWindow, intervalId);
}
}
});
}
}
export default reloadApp;

View File

@@ -0,0 +1,17 @@
/* global __resourceQuery WorkerGlobalScope */
// Send messages to the outside, so plugins can consume it.
/**
* @param {string} type
* @param {any} [data]
*/
function sendMsg(type, data) {
if (typeof self !== "undefined" && (typeof WorkerGlobalScope === "undefined" || !(self instanceof WorkerGlobalScope))) {
self.postMessage({
type: "webpack".concat(type),
data: data
}, "*");
}
}
export default sendMsg;

View File

@@ -0,0 +1,20 @@
var ansiRegex = new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|"), "g");
/**
*
* Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string.
* Adapted from code originally released by Sindre Sorhus
* Licensed the MIT License
*
* @param {string} string
* @return {string}
*/
function stripAnsi(string) {
if (typeof string !== "string") {
throw new TypeError("Expected a `string`, got `".concat(typeof string, "`"));
}
return string.replace(ansiRegex, "");
}
export default stripAnsi;

3488
node_modules/webpack-dev-server/lib/Server.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

133
node_modules/webpack-dev-server/lib/getPort.js generated vendored Normal file
View File

@@ -0,0 +1,133 @@
"use strict";
/*
* Based on the packages get-port https://www.npmjs.com/package/get-port
* and portfinder https://www.npmjs.com/package/portfinder
* The code structure is similar to get-port, but it searches
* ports deterministically like portfinder
*/
const net = require("net");
const os = require("os");
const minPort = 1024;
const maxPort = 65_535;
/**
* @return {Set<string|undefined>}
*/
const getLocalHosts = () => {
const interfaces = os.networkInterfaces();
// Add undefined value for createServer function to use default host,
// and default IPv4 host in case createServer defaults to IPv6.
// eslint-disable-next-line no-undefined
const results = new Set([undefined, "0.0.0.0"]);
for (const _interface of Object.values(interfaces)) {
if (_interface) {
for (const config of _interface) {
results.add(config.address);
}
}
}
return results;
};
/**
* @param {number} basePort
* @param {string | undefined} host
* @return {Promise<number>}
*/
const checkAvailablePort = (basePort, host) =>
new Promise((resolve, reject) => {
const server = net.createServer();
server.unref();
server.on("error", reject);
server.listen(basePort, host, () => {
// Next line should return AdressInfo because we're calling it after listen() and before close()
const { port } = /** @type {import("net").AddressInfo} */ (
server.address()
);
server.close(() => {
resolve(port);
});
});
});
/**
* @param {number} port
* @param {Set<string|undefined>} hosts
* @return {Promise<number>}
*/
const getAvailablePort = async (port, hosts) => {
/**
* Errors that mean that host is not available.
* @type {Set<string | undefined>}
*/
const nonExistentInterfaceErrors = new Set(["EADDRNOTAVAIL", "EINVAL"]);
/* Check if the post is available on every local host name */
for (const host of hosts) {
try {
await checkAvailablePort(port, host); // eslint-disable-line no-await-in-loop
} catch (error) {
/* We throw an error only if the interface exists */
if (
!nonExistentInterfaceErrors.has(
/** @type {NodeJS.ErrnoException} */ (error).code
)
) {
throw error;
}
}
}
return port;
};
/**
* @param {number} basePort
* @param {string=} host
* @return {Promise<number>}
*/
async function getPorts(basePort, host) {
if (basePort < minPort || basePort > maxPort) {
throw new Error(`Port number must lie between ${minPort} and ${maxPort}`);
}
let port = basePort;
const localhosts = getLocalHosts();
let hosts;
if (host && !localhosts.has(host)) {
hosts = new Set([host]);
} else {
/* If the host is equivalent to localhost
we need to check every equivalent host
else the port might falsely appear as available
on some operating systems */
hosts = localhosts;
}
/** @type {Set<string | undefined>} */
const portUnavailableErrors = new Set(["EADDRINUSE", "EACCES"]);
while (port <= maxPort) {
try {
const availablePort = await getAvailablePort(port, hosts); // eslint-disable-line no-await-in-loop
return availablePort;
} catch (error) {
/* Try next port if port is busy; throw for any other error */
if (
!portUnavailableErrors.has(
/** @type {NodeJS.ErrnoException} */ (error).code
)
) {
throw error;
}
port += 1;
}
}
throw new Error("No available ports found");
}
module.exports = getPorts;

1235
node_modules/webpack-dev-server/lib/options.json generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,18 @@
"use strict";
/** @typedef {import("../Server").ClientConnection} ClientConnection */
// base class that users should extend if they are making their own
// server implementation
module.exports = class BaseServer {
/**
* @param {import("../Server")} server
*/
constructor(server) {
/** @type {import("../Server")} */
this.server = server;
/** @type {ClientConnection[]} */
this.clients = [];
}
};

View File

@@ -0,0 +1,114 @@
"use strict";
const sockjs = require("sockjs");
const BaseServer = require("./BaseServer");
/** @typedef {import("../Server").WebSocketServerConfiguration} WebSocketServerConfiguration */
/** @typedef {import("../Server").ClientConnection} ClientConnection */
// 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
{
// @ts-ignore
const SockjsSession = require("sockjs/lib/transport").Session;
const decorateConnection = SockjsSession.prototype.decorateConnection;
/**
* @param {import("http").IncomingMessage} req
*/
// eslint-disable-next-line func-names
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)
/**
* @param {import("../Server")} server
*/
constructor(server) {
super(server);
this.implementation = sockjs.createServer({
// Use provided up-to-date sockjs-client
sockjs_url: "/__webpack_dev_server__/sockjs.bundle.js",
// Default logger is very annoy. Limit useless logs.
/**
* @param {string} severity
* @param {string} line
*/
log: (severity, line) => {
if (severity === "error") {
this.server.logger.error(line);
} else if (severity === "info") {
this.server.logger.log(line);
} else {
this.server.logger.debug(line);
}
},
});
/**
* @param {import("sockjs").ServerOptions & { path?: string }} options
* @returns {string | undefined}
*/
const getPrefix = (options) => {
if (typeof options.prefix !== "undefined") {
return options.prefix;
}
return options.path;
};
const options = {
.../** @type {WebSocketServerConfiguration} */
(this.server.options.webSocketServer).options,
prefix: getPrefix(
/** @type {NonNullable<WebSocketServerConfiguration["options"]>} */
(
/** @type {WebSocketServerConfiguration} */
(this.server.options.webSocketServer).options
)
),
};
this.implementation.installHandlers(
/** @type {import("http").Server} */ (this.server.server),
options
);
this.implementation.on("connection", (client) => {
// @ts-ignore
// Implement the the same API as for `ws`
client.send = client.write;
// @ts-ignore
client.terminate = client.close;
this.clients.push(/** @type {ClientConnection} */ (client));
client.on("close", () => {
this.clients.splice(
this.clients.indexOf(/** @type {ClientConnection} */ (client)),
1
);
});
});
// @ts-ignore
this.implementation.close = (callback) => {
callback();
};
}
};

View File

@@ -0,0 +1,105 @@
"use strict";
const WebSocket = require("ws");
const BaseServer = require("./BaseServer");
/** @typedef {import("../Server").WebSocketServerConfiguration} WebSocketServerConfiguration */
/** @typedef {import("../Server").ClientConnection} ClientConnection */
module.exports = class WebsocketServer extends BaseServer {
static heartbeatInterval = 1000;
/**
* @param {import("../Server")} server
*/
constructor(server) {
super(server);
/** @type {import("ws").ServerOptions} */
const options = {
.../** @type {WebSocketServerConfiguration} */
(this.server.options.webSocketServer).options,
clientTracking: false,
};
const isNoServerMode =
typeof options.port === "undefined" &&
typeof options.server === "undefined";
if (isNoServerMode) {
options.noServer = true;
}
this.implementation = new WebSocket.Server(options);
/** @type {import("http").Server} */
(this.server.server).on(
"upgrade",
/**
* @param {import("http").IncomingMessage} req
* @param {import("stream").Duplex} sock
* @param {Buffer} head
*/
(req, sock, head) => {
if (!this.implementation.shouldHandle(req)) {
return;
}
this.implementation.handleUpgrade(req, sock, head, (connection) => {
this.implementation.emit("connection", connection, req);
});
}
);
this.implementation.on(
"error",
/**
* @param {Error} err
*/
(err) => {
this.server.logger.error(err.message);
}
);
const interval = setInterval(() => {
this.clients.forEach(
/**
* @param {ClientConnection} client
*/
(client) => {
if (client.isAlive === false) {
client.terminate();
return;
}
client.isAlive = false;
client.ping(() => {});
}
);
}, WebsocketServer.heartbeatInterval);
this.implementation.on(
"connection",
/**
* @param {ClientConnection} client
*/
(client) => {
this.clients.push(client);
client.isAlive = true;
client.on("pong", () => {
client.isAlive = true;
});
client.on("close", () => {
this.clients.splice(this.clients.indexOf(client), 1);
});
}
);
this.implementation.on("close", () => {
clearInterval(interval);
});
}
};

139
node_modules/webpack-dev-server/package.json generated vendored Normal file
View File

@@ -0,0 +1,139 @@
{
"name": "webpack-dev-server",
"version": "4.10.0",
"description": "Serves a webpack app. Updates the browser on changes.",
"bin": "bin/webpack-dev-server.js",
"main": "lib/Server.js",
"types": "types/lib/Server.d.ts",
"author": "Tobias Koppers @sokra",
"bugs": "https://github.com/webpack/webpack-dev-server/issues",
"homepage": "https://github.com/webpack/webpack-dev-server#readme",
"repository": "https://github.com/webpack/webpack-dev-server",
"license": "MIT",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/webpack"
},
"files": [
"bin",
"lib",
"client",
"types"
],
"engines": {
"node": ">= 12.13.0"
},
"scripts": {
"fmt:check": "prettier \"{**/*,*}.{js,json,md,yml,css,ts}\" --list-different",
"lint:js": "eslint . --cache",
"lint:types": "tsc --pretty --noEmit",
"lint": "npm-run-all -p \"fmt:**\" \"lint:**\"",
"fmt": "npm run fmt:check -- --write",
"fix:js": "npm run lint:js -- --fix",
"fix": "npm-run-all fix:js fmt",
"commitlint": "commitlint --from=master",
"build:client": "rimraf ./client/* && babel client-src/ --out-dir client/ --ignore \"client-src/webpack.config.js\" --ignore \"client-src/modules\" && webpack --config client-src/webpack.config.js",
"build:types": "rimraf ./types/* && tsc --declaration --emitDeclarationOnly --outDir types && node ./scripts/extend-webpack-types.js && prettier \"types/**/*.ts\" --write && prettier \"types/**/*.ts\" --write",
"build": "npm-run-all -p \"build:**\"",
"test:only": "jest",
"test:coverage": "npm run test:only -- --coverage",
"test:watch": "npm run test:coverage --watch",
"test": "npm run test:coverage",
"pretest": "npm run lint",
"prepare": "husky install && npm run build",
"release": "standard-version"
},
"dependencies": {
"@types/bonjour": "^3.5.9",
"@types/connect-history-api-fallback": "^1.3.5",
"@types/express": "^4.17.13",
"@types/serve-index": "^1.9.1",
"@types/serve-static": "^1.13.10",
"@types/sockjs": "^0.3.33",
"@types/ws": "^8.5.1",
"ansi-html-community": "^0.0.8",
"bonjour-service": "^1.0.11",
"chokidar": "^3.5.3",
"colorette": "^2.0.10",
"compression": "^1.7.4",
"connect-history-api-fallback": "^2.0.0",
"default-gateway": "^6.0.3",
"express": "^4.17.3",
"graceful-fs": "^4.2.6",
"html-entities": "^2.3.2",
"http-proxy-middleware": "^2.0.3",
"ipaddr.js": "^2.0.1",
"open": "^8.0.9",
"p-retry": "^4.5.0",
"rimraf": "^3.0.2",
"schema-utils": "^4.0.0",
"selfsigned": "^2.0.1",
"serve-index": "^1.9.1",
"sockjs": "^0.3.24",
"spdy": "^4.0.2",
"webpack-dev-middleware": "^5.3.1",
"ws": "^8.4.2"
},
"devDependencies": {
"@babel/cli": "^7.17.3",
"@babel/core": "^7.17.5",
"@babel/eslint-parser": "^7.17.0",
"@babel/plugin-transform-object-assign": "^7.14.5",
"@babel/plugin-transform-runtime": "^7.17.0",
"@babel/preset-env": "^7.16.11",
"@babel/runtime": "^7.17.2",
"@commitlint/cli": "^16.2.3",
"@commitlint/config-conventional": "^16.2.1",
"@types/compression": "^1.7.2",
"@types/default-gateway": "^3.0.1",
"@types/rimraf": "^3.0.2",
"@types/sockjs-client": "^1.5.1",
"@types/trusted-types": "^2.0.2",
"acorn": "^8.2.4",
"babel-jest": "^27.5.1",
"babel-loader": "^8.2.4",
"body-parser": "^1.19.2",
"core-js": "^3.21.1",
"css-loader": "^5.2.4",
"eslint": "^8.12.0",
"eslint-config-prettier": "^8.4.0",
"eslint-config-webpack": "^1.2.5",
"eslint-plugin-import": "^2.23.2",
"execa": "^5.1.1",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^4.5.2",
"http-proxy": "^1.18.1",
"husky": "^7.0.0",
"jest": "^27.5.1",
"klona": "^2.0.4",
"less": "^4.1.1",
"less-loader": "^7.3.0",
"lint-staged": "^12.3.4",
"marked": "^4.0.12",
"memfs": "^3.2.2",
"npm-run-all": "^4.1.5",
"prettier": "^2.6.1",
"puppeteer": "^13.4.1",
"require-from-string": "^2.0.2",
"rimraf": "^3.0.2",
"sockjs-client": "^1.6.1",
"standard-version": "^9.3.0",
"strip-ansi-v6": "npm:strip-ansi@^6.0.0",
"style-loader": "^2.0.0",
"supertest": "^6.1.3",
"tcp-port-used": "^1.0.2",
"typescript": "^4.7.2",
"url-loader": "^4.1.1",
"webpack": "^5.71.0",
"webpack-cli": "^4.7.2",
"webpack-merge": "^5.8.0"
},
"peerDependencies": {
"webpack": "^4.37.0 || ^5.0.0"
},
"peerDependenciesMeta": {
"webpack-cli": {
"optional": true
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,50 @@
export = processArguments;
/**
* @param {Record<string, Argument>} args object of arguments
* @param {any} config configuration
* @param {Record<string, string | number | boolean | RegExp | (string | number | boolean | RegExp)[]>} values object with values
* @returns {Problem[] | null} problems or null for success
*/
declare function processArguments(
args: Record<string, Argument>,
config: any,
values: Record<
string,
string | number | boolean | RegExp | (string | number | boolean | RegExp)[]
>
): Problem[] | null;
declare namespace processArguments {
export { ProblemType, Problem, LocalProblem, ArgumentConfig, Argument };
}
type Argument = {
description: string;
simpleType: "string" | "number" | "boolean";
multiple: boolean;
configs: ArgumentConfig[];
};
type Problem = {
type: ProblemType;
path: string;
argument: string;
value?: any | undefined;
index?: number | undefined;
expected?: string | undefined;
};
type ProblemType =
| "unknown-argument"
| "unexpected-non-array-in-path"
| "unexpected-non-object-in-path"
| "multiple-values-unexpected"
| "invalid-value";
type LocalProblem = {
type: ProblemType;
path: string;
expected?: string | undefined;
};
type ArgumentConfig = {
description: string;
path: string;
multiple: boolean;
type: "enum" | "string" | "path" | "number" | "boolean" | "RegExp" | "reset";
values?: any[] | undefined;
};

View File

@@ -0,0 +1,27 @@
#!/usr/bin/env node
export type CliOption = {
/**
* display name
*/
name: string;
/**
* npm package name
*/
package: string;
/**
* name of the executable file
*/
binName: string;
/**
* currently installed?
*/
installed: boolean;
/**
* homepage
*/
url: string;
/**
* preprocessor
*/
preprocess: Function;
};

3659
node_modules/webpack-dev-server/types/lib/Server.d.ts generated vendored Normal file

File diff suppressed because it is too large Load Diff

10
node_modules/webpack-dev-server/types/lib/getPort.d.ts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
export = getPorts;
/**
* @param {number} basePort
* @param {string=} host
* @return {Promise<number>}
*/
declare function getPorts(
basePort: number,
host?: string | undefined
): Promise<number>;

View File

@@ -0,0 +1,15 @@
export = BaseServer;
declare class BaseServer {
/**
* @param {import("../Server")} server
*/
constructor(server: import("../Server"));
/** @type {import("../Server")} */
server: import("../Server");
/** @type {ClientConnection[]} */
clients: ClientConnection[];
}
declare namespace BaseServer {
export { ClientConnection };
}
type ClientConnection = import("../Server").ClientConnection;

View File

@@ -0,0 +1,12 @@
export = SockJSServer;
declare class SockJSServer extends BaseServer {
implementation: sockjs.Server;
}
declare namespace SockJSServer {
export { WebSocketServerConfiguration, ClientConnection };
}
import BaseServer = require("./BaseServer");
import sockjs = require("sockjs");
type WebSocketServerConfiguration =
import("../Server").WebSocketServerConfiguration;
type ClientConnection = import("../Server").ClientConnection;

View File

@@ -0,0 +1,13 @@
export = WebsocketServer;
declare class WebsocketServer extends BaseServer {
static heartbeatInterval: number;
implementation: WebSocket.Server<WebSocket.WebSocket>;
}
declare namespace WebsocketServer {
export { WebSocketServerConfiguration, ClientConnection };
}
import BaseServer = require("./BaseServer");
import WebSocket = require("ws");
type WebSocketServerConfiguration =
import("../Server").WebSocketServerConfiguration;
type ClientConnection = import("../Server").ClientConnection;