@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/client/utils/ansiHTML.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const _regANSI = /(?:(?:\u001b\[)|\u009b)(?:(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?[A-M|f-m])|\u001b[A-M]/;
|
|
2
|
+
const _defColors = {
|
|
3
|
+
reset: [
|
|
4
|
+
'fff',
|
|
5
|
+
'000'
|
|
6
|
+
],
|
|
5
7
|
black: '000',
|
|
6
8
|
red: 'ff0000',
|
|
7
9
|
green: '209805',
|
|
@@ -10,9 +12,9 @@ var _defColors = {
|
|
|
10
12
|
magenta: 'ff00ff',
|
|
11
13
|
cyan: '00ffee',
|
|
12
14
|
lightgrey: 'f0f0f0',
|
|
13
|
-
darkgrey: '888'
|
|
15
|
+
darkgrey: '888'
|
|
14
16
|
};
|
|
15
|
-
|
|
17
|
+
const _styles = {
|
|
16
18
|
30: 'black',
|
|
17
19
|
31: 'red',
|
|
18
20
|
32: 'green',
|
|
@@ -20,56 +22,52 @@ var _styles = {
|
|
|
20
22
|
34: 'blue',
|
|
21
23
|
35: 'magenta',
|
|
22
24
|
36: 'cyan',
|
|
23
|
-
37: 'lightgrey'
|
|
25
|
+
37: 'lightgrey'
|
|
24
26
|
};
|
|
25
|
-
|
|
26
|
-
2: 'rgb'
|
|
27
|
+
const _colorMode = {
|
|
28
|
+
2: 'rgb'
|
|
27
29
|
};
|
|
28
|
-
|
|
30
|
+
const _openTags = {
|
|
29
31
|
1: 'font-weight:bold',
|
|
30
32
|
2: 'opacity:0.5',
|
|
31
33
|
3: '<i>',
|
|
32
34
|
4: '<u>',
|
|
33
35
|
8: 'display:none',
|
|
34
36
|
9: '<del>',
|
|
35
|
-
38:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var b = match[3];
|
|
37
|
+
38: (match)=>{
|
|
38
|
+
const mode = _colorMode[match[0]];
|
|
39
|
+
if ('rgb' === mode) {
|
|
40
|
+
const r = match[1];
|
|
41
|
+
const g = match[2];
|
|
42
|
+
const b = match[3];
|
|
42
43
|
match.advance(4);
|
|
43
|
-
return
|
|
44
|
+
return `color: rgb(${r},${g},${b})`;
|
|
44
45
|
}
|
|
45
46
|
},
|
|
46
|
-
48:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var b = match[3];
|
|
47
|
+
48: (match)=>{
|
|
48
|
+
const mode = _colorMode[match[0]];
|
|
49
|
+
if ('rgb' === mode) {
|
|
50
|
+
const r = match[1];
|
|
51
|
+
const g = match[2];
|
|
52
|
+
const b = match[3];
|
|
53
53
|
match.advance(4);
|
|
54
|
-
return
|
|
54
|
+
return `background-color: rgb(${r},${g},${b})`;
|
|
55
55
|
}
|
|
56
|
-
}
|
|
56
|
+
}
|
|
57
57
|
};
|
|
58
|
-
|
|
58
|
+
const _openTagToCloseTag = {
|
|
59
59
|
3: '23',
|
|
60
60
|
4: '24',
|
|
61
|
-
9: '29'
|
|
61
|
+
9: '29'
|
|
62
62
|
};
|
|
63
|
-
|
|
64
|
-
0:
|
|
65
|
-
if (!ansiCodes)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
while ((code = ansiCodes.pop())) {
|
|
72
|
-
var closeTag = _openTagToCloseTag[code];
|
|
63
|
+
const _closeTags = {
|
|
64
|
+
0: (ansiCodes)=>{
|
|
65
|
+
if (!ansiCodes) return '</span>';
|
|
66
|
+
if (!ansiCodes.length) return '';
|
|
67
|
+
let code;
|
|
68
|
+
let ret = '';
|
|
69
|
+
while(code = ansiCodes.pop()){
|
|
70
|
+
const closeTag = _openTagToCloseTag[code];
|
|
73
71
|
if (closeTag) {
|
|
74
72
|
ret += _closeTags[closeTag];
|
|
75
73
|
continue;
|
|
@@ -80,163 +78,118 @@ var _closeTags = {
|
|
|
80
78
|
},
|
|
81
79
|
23: '</i>',
|
|
82
80
|
24: '</u>',
|
|
83
|
-
29: '</del>'
|
|
81
|
+
29: '</del>'
|
|
84
82
|
};
|
|
85
|
-
for (
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
83
|
+
for (const n of [
|
|
84
|
+
21,
|
|
85
|
+
22,
|
|
86
|
+
27,
|
|
87
|
+
28,
|
|
88
|
+
39,
|
|
89
|
+
49
|
|
90
|
+
])_closeTags[n] = '</span>';
|
|
92
91
|
function normalizeSeq(seq) {
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
if (seq.startsWith(';')) {
|
|
96
|
-
return seq.slice(1);
|
|
97
|
-
}
|
|
92
|
+
if (null == seq) return null;
|
|
93
|
+
if (seq.startsWith(';')) return seq.slice(1);
|
|
98
94
|
return seq;
|
|
99
95
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return text;
|
|
107
|
-
}
|
|
108
|
-
// Cache opened sequence.
|
|
109
|
-
var ansiCodes = [];
|
|
110
|
-
// Replace with markup.
|
|
111
|
-
var ret = text.replace(
|
|
112
|
-
//@ts-ignore TS1487 error
|
|
113
|
-
/\033\[(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?m/g, function (m) {
|
|
114
|
-
var _a;
|
|
115
|
-
var match = (_a = m.match(/(;?\d+)/g)) === null || _a === void 0 ? void 0 : _a.map(normalizeSeq);
|
|
96
|
+
function ansiHTML(text) {
|
|
97
|
+
if (!_regANSI.test(text)) return text;
|
|
98
|
+
const ansiCodes = [];
|
|
99
|
+
let ret = text.replace(/\033\[(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?m/g, (m)=>{
|
|
100
|
+
var _m_match;
|
|
101
|
+
const match = null == (_m_match = m.match(/(;?\d+)/g)) ? void 0 : _m_match.map(normalizeSeq);
|
|
116
102
|
Object.defineProperty(match, 'advance', {
|
|
117
|
-
value: function
|
|
103
|
+
value: function(count) {
|
|
118
104
|
this.splice(0, count);
|
|
119
|
-
}
|
|
105
|
+
}
|
|
120
106
|
});
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
while
|
|
107
|
+
let rep = '';
|
|
108
|
+
let seq;
|
|
109
|
+
while(seq = match[0]){
|
|
124
110
|
match.advance(1);
|
|
125
111
|
rep += applySeq(seq);
|
|
126
112
|
}
|
|
127
113
|
return rep;
|
|
128
114
|
function applySeq(seq) {
|
|
129
|
-
|
|
130
|
-
if (other &&
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
var ret_1 = '';
|
|
135
|
-
if (seq === '0') {
|
|
136
|
-
ret_1 += _closeTags[seq](ansiCodes);
|
|
137
|
-
}
|
|
138
|
-
// If current sequence has been opened, close it.
|
|
139
|
-
if (ansiCodes.indexOf(seq) !== -1) {
|
|
115
|
+
let other = _openTags[seq];
|
|
116
|
+
if (other && (other = 'function' == typeof other ? other(match) : other)) {
|
|
117
|
+
let ret = '';
|
|
118
|
+
if ('0' === seq) ret += _closeTags[seq](ansiCodes);
|
|
119
|
+
if (-1 !== ansiCodes.indexOf(seq)) {
|
|
140
120
|
ansiCodes.pop();
|
|
141
121
|
return '</span>';
|
|
142
122
|
}
|
|
143
|
-
// Open tag.
|
|
144
123
|
ansiCodes.push(seq);
|
|
145
|
-
return
|
|
146
|
-
}
|
|
147
|
-
var ct = _closeTags[seq];
|
|
148
|
-
if (typeof ct === 'function') {
|
|
149
|
-
return ct(ansiCodes);
|
|
124
|
+
return ret + ('<' === other[0] ? other : `<span style="${other};">`);
|
|
150
125
|
}
|
|
126
|
+
const ct = _closeTags[seq];
|
|
127
|
+
if ('function' == typeof ct) return ct(ansiCodes);
|
|
151
128
|
if (ct) {
|
|
152
|
-
// Pop sequence
|
|
153
129
|
ansiCodes.pop();
|
|
154
130
|
return ct;
|
|
155
131
|
}
|
|
156
132
|
return '';
|
|
157
133
|
}
|
|
158
134
|
});
|
|
159
|
-
|
|
160
|
-
var l = ansiCodes.length;
|
|
135
|
+
const l = ansiCodes.length;
|
|
161
136
|
l > 0 && (ret += Array(l + 1).join('</span>'));
|
|
162
137
|
return ret;
|
|
163
138
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
throw new Error('`colors` parameter must be an Object.');
|
|
170
|
-
}
|
|
171
|
-
var _finalColors = {};
|
|
172
|
-
for (var key in _defColors) {
|
|
173
|
-
var hex = colors.hasOwnProperty(key) ? colors[key] : null;
|
|
139
|
+
ansiHTML.setColors = (colors)=>{
|
|
140
|
+
if ('object' != typeof colors) throw new Error('`colors` parameter must be an Object.');
|
|
141
|
+
const _finalColors = {};
|
|
142
|
+
for(const key in _defColors){
|
|
143
|
+
let hex = colors.hasOwnProperty(key) ? colors[key] : null;
|
|
174
144
|
if (!hex) {
|
|
175
145
|
_finalColors[key] = _defColors[key];
|
|
176
146
|
continue;
|
|
177
147
|
}
|
|
178
148
|
if ('reset' === key) {
|
|
179
|
-
if (typeof hex
|
|
180
|
-
hex
|
|
181
|
-
|
|
182
|
-
if (!Array.isArray(hex) ||
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
hex[0] = defHexColor[0];
|
|
190
|
-
}
|
|
191
|
-
if (hex.length === 1 || !hex[1]) {
|
|
192
|
-
hex = [hex[0]];
|
|
149
|
+
if ('string' == typeof hex) hex = [
|
|
150
|
+
hex
|
|
151
|
+
];
|
|
152
|
+
if (!Array.isArray(hex) || 0 === hex.length || hex.some((h)=>'string' != typeof h)) throw new Error(`The value of \`${key}\` property must be an Array and each item could only be a hex string, e.g.: FF0000`);
|
|
153
|
+
const defHexColor = _defColors[key];
|
|
154
|
+
if (!hex[0]) hex[0] = defHexColor[0];
|
|
155
|
+
if (1 === hex.length || !hex[1]) {
|
|
156
|
+
hex = [
|
|
157
|
+
hex[0]
|
|
158
|
+
];
|
|
193
159
|
hex.push(defHexColor[1]);
|
|
194
160
|
}
|
|
195
161
|
hex = hex.slice(0, 2);
|
|
196
|
-
}
|
|
197
|
-
else if (typeof hex !== 'string') {
|
|
198
|
-
throw new Error("The value of `".concat(key, "` property must be a hex string, e.g.: FF0000"));
|
|
199
|
-
}
|
|
162
|
+
} else if ('string' != typeof hex) throw new Error(`The value of \`${key}\` property must be a hex string, e.g.: FF0000`);
|
|
200
163
|
_finalColors[key] = hex;
|
|
201
164
|
}
|
|
202
165
|
_setTags(_finalColors);
|
|
203
166
|
};
|
|
204
|
-
|
|
205
|
-
* Reset colors.
|
|
206
|
-
*/
|
|
207
|
-
ansiHTML.reset = function () {
|
|
167
|
+
ansiHTML.reset = ()=>{
|
|
208
168
|
_setTags(_defColors);
|
|
209
169
|
};
|
|
210
|
-
/**
|
|
211
|
-
* Expose tags, including open and close.
|
|
212
|
-
*/
|
|
213
170
|
ansiHTML.tags = {};
|
|
214
171
|
if (Object.defineProperty) {
|
|
215
172
|
Object.defineProperty(ansiHTML.tags, 'open', {
|
|
216
|
-
get:
|
|
173
|
+
get: ()=>_openTags
|
|
217
174
|
});
|
|
218
175
|
Object.defineProperty(ansiHTML.tags, 'close', {
|
|
219
|
-
get:
|
|
176
|
+
get: ()=>_closeTags
|
|
220
177
|
});
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
178
|
+
} else {
|
|
223
179
|
ansiHTML.tags.open = _openTags;
|
|
224
180
|
ansiHTML.tags.close = _closeTags;
|
|
225
181
|
}
|
|
226
182
|
function _setTags(colors) {
|
|
227
|
-
|
|
228
|
-
_openTags['
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
var oriColor = colors[color] || '000';
|
|
237
|
-
_openTags[code] = "color:#".concat(oriColor);
|
|
238
|
-
var codeInt = Number.parseInt(code);
|
|
239
|
-
_openTags[(codeInt + 10).toString()] = "background:#".concat(oriColor);
|
|
183
|
+
_openTags['0'] = `font-weight:normal;opacity:1;color:#${colors.reset[0]};background:#${colors.reset[1]}`;
|
|
184
|
+
_openTags['7'] = `color:#${colors.reset[1]};background:#${colors.reset[0]}`;
|
|
185
|
+
_openTags['90'] = `color:#${colors.darkgrey}`;
|
|
186
|
+
for(const code in _styles){
|
|
187
|
+
const color = _styles[code];
|
|
188
|
+
const oriColor = colors[color] || '000';
|
|
189
|
+
_openTags[code] = `color:#${oriColor}`;
|
|
190
|
+
const codeInt = Number.parseInt(code);
|
|
191
|
+
_openTags[(codeInt + 10).toString()] = `background:#${oriColor}`;
|
|
240
192
|
}
|
|
241
193
|
}
|
|
242
194
|
ansiHTML.reset();
|
|
195
|
+
export { ansiHTML as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The following code is modified based on
|
|
3
|
+
* https://github.com/webpack/webpack-dev-server
|
|
4
|
+
*
|
|
5
|
+
* MIT Licensed
|
|
6
|
+
* Author Tobias Koppers @sokra
|
|
7
|
+
* Copyright (c) JS Foundation and other contributors
|
|
8
|
+
* https://github.com/webpack/webpack-dev-server/blob/main/LICENSE
|
|
9
|
+
*/
|
|
10
|
+
import type { LogLevel } from '../type.js';
|
|
11
|
+
declare function setLogLevel(level: LogLevel): void;
|
|
12
|
+
declare const log: import("../modules/logger/Logger.js").Logger;
|
|
13
|
+
export { log, setLogLevel };
|
package/client/utils/log.js
CHANGED
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* MIT Licensed
|
|
6
|
-
* Author Tobias Koppers @sokra
|
|
7
|
-
* Copyright (c) JS Foundation and other contributors
|
|
8
|
-
* https://github.com/webpack/webpack-dev-server/blob/main/LICENSE
|
|
9
|
-
*/
|
|
10
|
-
import logger from '../modules/logger/index';
|
|
11
|
-
var name = 'webpack-dev-server';
|
|
12
|
-
// default level is set on the client side, so it does not need
|
|
13
|
-
// to be set by the CLI or API
|
|
14
|
-
var defaultLevel = 'info';
|
|
15
|
-
// options new options, merge with old options
|
|
1
|
+
import { logger } from "../modules/logger/index.js";
|
|
2
|
+
const log_name = 'rspack-dev-server';
|
|
3
|
+
const defaultLevel = 'info';
|
|
16
4
|
function setLogLevel(level) {
|
|
17
|
-
logger.configureDefaultLogger({
|
|
5
|
+
logger.configureDefaultLogger({
|
|
6
|
+
level
|
|
7
|
+
});
|
|
18
8
|
}
|
|
19
9
|
setLogLevel(defaultLevel);
|
|
20
|
-
|
|
10
|
+
const log = logger.getLogger(log_name);
|
|
21
11
|
export { log, setLogLevel };
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The following code is modified based on
|
|
3
|
-
* https://github.com/webpack/webpack-dev-server
|
|
4
|
-
*
|
|
5
|
-
* MIT Licensed
|
|
6
|
-
* Author Tobias Koppers @sokra
|
|
7
|
-
* Copyright (c) JS Foundation and other contributors
|
|
8
|
-
* https://github.com/webpack/webpack-dev-server/blob/main/LICENSE
|
|
9
|
-
*/
|
|
10
1
|
function sendMsg(type, data) {
|
|
11
|
-
if (typeof self
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
2
|
+
if ("u" > typeof self && ("u" < typeof WorkerGlobalScope || !(self instanceof WorkerGlobalScope))) self.postMessage({
|
|
3
|
+
type: `webpack${type}`,
|
|
4
|
+
data
|
|
5
|
+
}, '*');
|
|
16
6
|
}
|
|
17
|
-
|
|
7
|
+
const sendMessage = sendMsg;
|
|
8
|
+
export { sendMessage as default };
|