@rspack/dev-server 1.2.1 → 2.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -17
- package/client/clients/WebSocketClient.d.ts +17 -0
- package/client/clients/WebSocketClient.js +28 -28
- package/client/index.d.ts +17 -0
- package/client/index.js +224 -363
- package/client/modules/logger/Logger.d.ts +40 -0
- package/client/modules/logger/Logger.js +123 -0
- package/client/modules/logger/createConsoleLogger.d.ts +12 -0
- package/client/modules/logger/createConsoleLogger.js +119 -0
- package/client/modules/logger/index.d.ts +18 -0
- package/client/modules/logger/index.js +20 -712
- package/client/modules/types.d.ts +45 -0
- package/client/modules/types.js +17 -0
- package/client/overlay.d.ts +44 -0
- package/client/overlay.js +243 -292
- package/client/progress.d.ts +11 -0
- package/client/progress.js +178 -111
- package/client/socket.d.ts +15 -0
- package/client/socket.js +19 -46
- package/client/utils/ansiHTML.d.ts +30 -0
- package/client/utils/ansiHTML.js +98 -145
- package/client/utils/log.d.ts +13 -0
- package/client/utils/log.js +7 -17
- package/{dist/servers/SockJSServer.d.ts → client/utils/sendMessage.d.ts} +2 -1
- package/client/utils/sendMessage.js +6 -15
- package/dist/0~launch-editor.js +618 -0
- package/dist/0~open.js +547 -0
- package/dist/0~p-retry.js +158 -0
- package/dist/131.js +1398 -0
- package/dist/config.d.ts +1 -3
- package/dist/getPort.d.ts +4 -1
- package/dist/index.js +1 -5
- package/dist/rslib-runtime.js +66 -0
- package/dist/server.d.ts +7 -18
- package/dist/servers/WebsocketServer.d.ts +8 -1
- package/dist/types.d.ts +14 -29
- package/package.json +74 -103
- package/client/clients/SockJSClient.js +0 -34
- package/client/modules/sockjs-client/index.js +0 -4506
- package/dist/config.js +0 -2
- package/dist/getPort.js +0 -131
- package/dist/options.json +0 -1034
- package/dist/server.js +0 -2222
- package/dist/servers/BaseServer.js +0 -20
- package/dist/servers/SockJSServer.js +0 -110
- package/dist/servers/WebsocketServer.js +0 -72
- package/dist/types.js +0 -5
package/dist/config.js
DELETED
package/dist/getPort.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* The following code is modified based on
|
|
4
|
-
* https://github.com/webpack/webpack-dev-server
|
|
5
|
-
*
|
|
6
|
-
* MIT Licensed
|
|
7
|
-
* Author Tobias Koppers @sokra
|
|
8
|
-
* Copyright (c) JS Foundation and other contributors
|
|
9
|
-
* https://github.com/webpack/webpack-dev-server/blob/main/LICENSE
|
|
10
|
-
*/
|
|
11
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
-
if (k2 === undefined) k2 = k;
|
|
13
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
-
}
|
|
17
|
-
Object.defineProperty(o, k2, desc);
|
|
18
|
-
}) : (function(o, m, k, k2) {
|
|
19
|
-
if (k2 === undefined) k2 = k;
|
|
20
|
-
o[k2] = m[k];
|
|
21
|
-
}));
|
|
22
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
-
}) : function(o, v) {
|
|
25
|
-
o["default"] = v;
|
|
26
|
-
});
|
|
27
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
/*
|
|
36
|
-
* Based on the packages get-port https://www.npmjs.com/package/get-port
|
|
37
|
-
* and portfinder https://www.npmjs.com/package/portfinder
|
|
38
|
-
* The code structure is similar to get-port, but it searches
|
|
39
|
-
* ports deterministically like portfinder
|
|
40
|
-
*/
|
|
41
|
-
const net = __importStar(require("node:net"));
|
|
42
|
-
const os = __importStar(require("node:os"));
|
|
43
|
-
const minPort = 1024;
|
|
44
|
-
const maxPort = 65535;
|
|
45
|
-
/**
|
|
46
|
-
* Get all local hosts
|
|
47
|
-
*/
|
|
48
|
-
const getLocalHosts = () => {
|
|
49
|
-
const interfaces = os.networkInterfaces();
|
|
50
|
-
// Add undefined value for createServer function to use default host,
|
|
51
|
-
// and default IPv4 host in case createServer defaults to IPv6.
|
|
52
|
-
const results = new Set([undefined, '0.0.0.0']);
|
|
53
|
-
for (const _interface of Object.values(interfaces)) {
|
|
54
|
-
if (_interface) {
|
|
55
|
-
for (const config of _interface) {
|
|
56
|
-
results.add(config.address);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return results;
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Check if a port is available on a given host
|
|
64
|
-
*/
|
|
65
|
-
const checkAvailablePort = (basePort, host) => new Promise((resolve, reject) => {
|
|
66
|
-
const server = net.createServer();
|
|
67
|
-
server.unref();
|
|
68
|
-
server.on('error', reject);
|
|
69
|
-
server.listen(basePort, host, () => {
|
|
70
|
-
// Next line should return AddressInfo because we're calling it after listen() and before close()
|
|
71
|
-
const { port } = server.address();
|
|
72
|
-
server.close(() => {
|
|
73
|
-
resolve(port);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
/**
|
|
78
|
-
* Get available port from hosts
|
|
79
|
-
*/
|
|
80
|
-
const getAvailablePort = async (port, hosts) => {
|
|
81
|
-
/**
|
|
82
|
-
* Errors that mean that host is not available.
|
|
83
|
-
*/
|
|
84
|
-
const nonExistentInterfaceErrors = new Set(['EADDRNOTAVAIL', 'EINVAL']);
|
|
85
|
-
/* Check if the post is available on every local host name */
|
|
86
|
-
for (const host of hosts) {
|
|
87
|
-
try {
|
|
88
|
-
await checkAvailablePort(port, host);
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
/* We throw an error only if the interface exists */
|
|
92
|
-
if (!nonExistentInterfaceErrors.has(error.code || '')) {
|
|
93
|
-
throw error;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return port;
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Get available ports
|
|
101
|
-
*/
|
|
102
|
-
async function getPorts(basePort, host) {
|
|
103
|
-
if (basePort < minPort || basePort > maxPort) {
|
|
104
|
-
throw new Error(`Port number must lie between ${minPort} and ${maxPort}`);
|
|
105
|
-
}
|
|
106
|
-
let port = basePort;
|
|
107
|
-
const localhosts = getLocalHosts();
|
|
108
|
-
const hosts = host && !localhosts.has(host)
|
|
109
|
-
? new Set([host])
|
|
110
|
-
: /* If the host is equivalent to localhost
|
|
111
|
-
we need to check every equivalent host
|
|
112
|
-
else the port might falsely appear as available
|
|
113
|
-
on some operating systems */
|
|
114
|
-
localhosts;
|
|
115
|
-
const portUnavailableErrors = new Set(['EADDRINUSE', 'EACCES']);
|
|
116
|
-
while (port <= maxPort) {
|
|
117
|
-
try {
|
|
118
|
-
const availablePort = await getAvailablePort(port, hosts);
|
|
119
|
-
return availablePort;
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
/* Try next port if port is busy; throw for any other error */
|
|
123
|
-
if (!portUnavailableErrors.has(error.code || '')) {
|
|
124
|
-
throw error;
|
|
125
|
-
}
|
|
126
|
-
port += 1;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
throw new Error('No available ports found');
|
|
130
|
-
}
|
|
131
|
-
module.exports = getPorts;
|