@rspack/dev-server 2.0.0-beta.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 +4 -3
- 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 +241 -290
- 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 +106 -153
- package/client/utils/log.d.ts +13 -0
- package/client/utils/log.js +7 -17
- package/client/utils/sendMessage.d.ts +11 -0
- 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/getPort.d.ts +4 -1
- package/dist/index.js +1 -5
- package/dist/rslib-runtime.js +66 -0
- package/dist/server.d.ts +7 -7
- package/dist/servers/WebsocketServer.d.ts +8 -1
- package/dist/types.d.ts +7 -5
- package/package.json +55 -58
- package/dist/config.js +0 -2
- package/dist/getPort.js +0 -141
- package/dist/server.js +0 -1971
- package/dist/servers/BaseServer.js +0 -20
- package/dist/servers/WebsocketServer.js +0 -72
- package/dist/types.js +0 -5
|
@@ -1,20 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
// base class that users should extend if they are making their own
|
|
13
|
-
// server implementation
|
|
14
|
-
class BaseServer {
|
|
15
|
-
constructor(server) {
|
|
16
|
-
this.server = server;
|
|
17
|
-
this.clients = [];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.default = BaseServer;
|
|
@@ -1,72 +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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const ws_1 = __importDefault(require("ws"));
|
|
16
|
-
const BaseServer_1 = __importDefault(require("./BaseServer"));
|
|
17
|
-
class WebsocketServer extends BaseServer_1.default {
|
|
18
|
-
constructor(server) {
|
|
19
|
-
super(server);
|
|
20
|
-
const options = {
|
|
21
|
-
...this.server.options.webSocketServer
|
|
22
|
-
.options,
|
|
23
|
-
clientTracking: false,
|
|
24
|
-
};
|
|
25
|
-
const isNoServerMode = typeof options.port === 'undefined' &&
|
|
26
|
-
typeof options.server === 'undefined';
|
|
27
|
-
if (isNoServerMode) {
|
|
28
|
-
options.noServer = true;
|
|
29
|
-
}
|
|
30
|
-
this.implementation = new ws_1.default.Server(options);
|
|
31
|
-
this.server.server.on('upgrade', (req, sock, head) => {
|
|
32
|
-
if (!this.implementation.shouldHandle(req)) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
this.implementation.handleUpgrade(req, sock, head, (connection) => {
|
|
36
|
-
this.implementation.emit('connection', connection, req);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
this.implementation.on('error', (err) => {
|
|
40
|
-
this.server.logger.error(err.message);
|
|
41
|
-
});
|
|
42
|
-
const interval = setInterval(() => {
|
|
43
|
-
for (const client of this.clients) {
|
|
44
|
-
if (client.isAlive === false) {
|
|
45
|
-
client.terminate();
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
client.isAlive = false;
|
|
49
|
-
client.ping(() => { });
|
|
50
|
-
}
|
|
51
|
-
}, WebsocketServer.heartbeatInterval);
|
|
52
|
-
this.implementation.on('connection', (client) => {
|
|
53
|
-
this.clients.push(client);
|
|
54
|
-
client.isAlive = true;
|
|
55
|
-
client.on('pong', () => {
|
|
56
|
-
client.isAlive = true;
|
|
57
|
-
});
|
|
58
|
-
client.on('close', () => {
|
|
59
|
-
this.clients.splice(this.clients.indexOf(client), 1);
|
|
60
|
-
});
|
|
61
|
-
// TODO: add a test case for this - https://github.com/webpack/webpack-dev-server/issues/5018
|
|
62
|
-
client.on('error', (err) => {
|
|
63
|
-
this.server.logger.error(err.message);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
this.implementation.on('close', () => {
|
|
67
|
-
clearInterval(interval);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
WebsocketServer.heartbeatInterval = 1000;
|
|
72
|
-
module.exports = WebsocketServer;
|