@rspack/dev-server 2.0.0 → 2.0.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.
Files changed (43) hide show
  1. package/package.json +28 -29
  2. package/client/clients/WebSocketClient.d.ts +0 -17
  3. package/client/clients/WebSocketClient.js +0 -32
  4. package/client/index.d.ts +0 -17
  5. package/client/index.js +0 -356
  6. package/client/modules/logger/Logger.d.ts +0 -39
  7. package/client/modules/logger/Logger.js +0 -121
  8. package/client/modules/logger/createConsoleLogger.d.ts +0 -12
  9. package/client/modules/logger/createConsoleLogger.js +0 -119
  10. package/client/modules/logger/index.d.ts +0 -26
  11. package/client/modules/logger/index.js +0 -32
  12. package/client/modules/types.d.ts +0 -45
  13. package/client/modules/types.js +0 -17
  14. package/client/overlay.d.ts +0 -47
  15. package/client/overlay.js +0 -454
  16. package/client/progress.d.ts +0 -11
  17. package/client/progress.js +0 -197
  18. package/client/socket.d.ts +0 -15
  19. package/client/socket.js +0 -34
  20. package/client/type.d.ts +0 -15
  21. package/client/type.js +0 -1
  22. package/client/utils/ansiHTML.d.ts +0 -30
  23. package/client/utils/ansiHTML.js +0 -195
  24. package/client/utils/log.d.ts +0 -13
  25. package/client/utils/log.js +0 -11
  26. package/client/utils/sendMessage.d.ts +0 -11
  27. package/client/utils/sendMessage.js +0 -8
  28. package/dist/0~chokidar.js +0 -1477
  29. package/dist/0~chokidar.js.LICENSE.txt +0 -1
  30. package/dist/0~connect-history-api-fallback.js +0 -76
  31. package/dist/0~connect-next.js +0 -1245
  32. package/dist/0~connect-next.js.LICENSE.txt +0 -57
  33. package/dist/0~debug.js +0 -621
  34. package/dist/0~http-proxy-middleware.js +0 -3777
  35. package/dist/0~http-proxy-middleware.js.LICENSE.txt +0 -34
  36. package/dist/0~launch-editor.js +0 -601
  37. package/dist/0~open.js +0 -555
  38. package/dist/0~p-retry.js +0 -161
  39. package/dist/0~serve-static.js +0 -1595
  40. package/dist/0~serve-static.js.LICENSE.txt +0 -108
  41. package/dist/198.js +0 -5113
  42. package/dist/index.d.ts +0 -587
  43. package/dist/index.js +0 -1
package/client/socket.js DELETED
@@ -1,34 +0,0 @@
1
- import WebSocketClient from "./clients/WebSocketClient.js";
2
- import { log } from "./utils/log.js";
3
- const Client = "u" > typeof __rspack_dev_server_client__ ? void 0 !== __rspack_dev_server_client__.default ? __rspack_dev_server_client__.default : __rspack_dev_server_client__ : WebSocketClient;
4
- let retries = 0;
5
- let maxRetries = 10;
6
- let client = null;
7
- let timeout;
8
- function socket(url, handlers, reconnect) {
9
- client = new Client(url);
10
- client.onOpen(()=>{
11
- retries = 0;
12
- if (timeout) clearTimeout(timeout);
13
- if (void 0 !== reconnect) maxRetries = reconnect;
14
- });
15
- client.onClose(()=>{
16
- if (0 === retries) handlers.close();
17
- client = null;
18
- if (retries < maxRetries) {
19
- const retryInMs = 1000 * Math.pow(2, retries) + 100 * Math.random();
20
- retries += 1;
21
- log.info('Trying to reconnect...');
22
- timeout = setTimeout(()=>{
23
- socket(url, handlers, reconnect);
24
- }, retryInMs);
25
- }
26
- });
27
- client.onMessage((data)=>{
28
- const message = JSON.parse(data);
29
- if (handlers[message.type]) handlers[message.type](message.data, message.params);
30
- });
31
- }
32
- const client_src_socket = socket;
33
- export default client_src_socket;
34
- export { client };
package/client/type.d.ts DELETED
@@ -1,15 +0,0 @@
1
- export type LogLevel = false | true | 'none' | 'error' | 'warn' | 'info' | 'log' | 'verbose';
2
- export type EXPECTED_ANY = any;
3
- declare global {
4
- const __resourceQuery: string;
5
- const BUILD_HASH: string;
6
- const RESOURCE_QUERY: string;
7
- }
8
- export interface CommunicationClient {
9
- onOpen(fn: (...args: unknown[]) => void): void;
10
- onClose(fn: (...args: unknown[]) => void): void;
11
- onMessage(fn: (...args: unknown[]) => void): void;
12
- }
13
- export interface CommunicationClientConstructor {
14
- new (url: string): CommunicationClient;
15
- }
package/client/type.js DELETED
@@ -1 +0,0 @@
1
- export { };
@@ -1,30 +0,0 @@
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
- interface AnsiHtmlTags {
11
- open: typeof _openTags;
12
- close: typeof _closeTags;
13
- }
14
- type Option<T> = T | null | undefined;
15
- type Match = {
16
- advance: (n: number) => void;
17
- } & Array<string>;
18
- declare const _defColors: Record<string, string | Array<string>>;
19
- declare const _openTags: Record<string, string | ((m: Match) => Option<string>)>;
20
- declare const _closeTags: Record<string, string | ((ansiCodes: Option<Array<string>>) => string)>;
21
- /**
22
- * Converts text with ANSI color codes to HTML markup.
23
- */
24
- declare function ansiHTML(text: string): string;
25
- declare namespace ansiHTML {
26
- var setColors: (colors: typeof _defColors) => void;
27
- var reset: () => void;
28
- var tags: AnsiHtmlTags;
29
- }
30
- export default ansiHTML;
@@ -1,195 +0,0 @@
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
- ],
7
- black: '000',
8
- red: 'ff0000',
9
- green: '209805',
10
- yellow: 'e8bf03',
11
- blue: '0000ff',
12
- magenta: 'ff00ff',
13
- cyan: '00ffee',
14
- lightgrey: 'f0f0f0',
15
- darkgrey: '888'
16
- };
17
- const _styles = {
18
- 30: 'black',
19
- 31: 'red',
20
- 32: 'green',
21
- 33: 'yellow',
22
- 34: 'blue',
23
- 35: 'magenta',
24
- 36: 'cyan',
25
- 37: 'lightgrey'
26
- };
27
- const _colorMode = {
28
- 2: 'rgb'
29
- };
30
- const _openTags = {
31
- 1: 'font-weight:bold',
32
- 2: 'opacity:0.5',
33
- 3: '<i>',
34
- 4: '<u>',
35
- 8: 'display:none',
36
- 9: '<del>',
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];
43
- match.advance(4);
44
- return `color: rgb(${r},${g},${b})`;
45
- }
46
- },
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
- match.advance(4);
54
- return `background-color: rgb(${r},${g},${b})`;
55
- }
56
- }
57
- };
58
- const _openTagToCloseTag = {
59
- 3: '23',
60
- 4: '24',
61
- 9: '29'
62
- };
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];
71
- if (closeTag) {
72
- ret += _closeTags[closeTag];
73
- continue;
74
- }
75
- ret += '</span>';
76
- }
77
- return ret;
78
- },
79
- 23: '</i>',
80
- 24: '</u>',
81
- 29: '</del>'
82
- };
83
- for (const n of [
84
- 21,
85
- 22,
86
- 27,
87
- 28,
88
- 39,
89
- 49
90
- ])_closeTags[n] = '</span>';
91
- function normalizeSeq(seq) {
92
- if (null == seq) return null;
93
- if (seq.startsWith(';')) return seq.slice(1);
94
- return seq;
95
- }
96
- function ansiHTML(text) {
97
- if (!_regANSI.test(text)) return text;
98
- const ansiCodes = [];
99
- let ret = text.replace(/\x1b\[(?:[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);
102
- Object.defineProperty(match, 'advance', {
103
- value: function(count) {
104
- this.splice(0, count);
105
- }
106
- });
107
- let rep = '';
108
- let seq;
109
- while(seq = match[0]){
110
- match.advance(1);
111
- rep += applySeq(seq);
112
- }
113
- return rep;
114
- function applySeq(seq) {
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)) {
120
- ansiCodes.pop();
121
- return '</span>';
122
- }
123
- ansiCodes.push(seq);
124
- return ret + ('<' === other[0] ? other : `<span style="${other};">`);
125
- }
126
- const ct = _closeTags[seq];
127
- if ('function' == typeof ct) return ct(ansiCodes);
128
- if (ct) {
129
- ansiCodes.pop();
130
- return ct;
131
- }
132
- return '';
133
- }
134
- });
135
- const l = ansiCodes.length;
136
- l > 0 && (ret += Array(l + 1).join('</span>'));
137
- return ret;
138
- }
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;
144
- if (!hex) {
145
- _finalColors[key] = _defColors[key];
146
- continue;
147
- }
148
- if ('reset' === key) {
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
- ];
159
- hex.push(defHexColor[1]);
160
- }
161
- hex = hex.slice(0, 2);
162
- } else if ('string' != typeof hex) throw new Error(`The value of \`${key}\` property must be a hex string, e.g.: FF0000`);
163
- _finalColors[key] = hex;
164
- }
165
- _setTags(_finalColors);
166
- };
167
- ansiHTML.reset = ()=>{
168
- _setTags(_defColors);
169
- };
170
- ansiHTML.tags = {};
171
- if (Object.defineProperty) {
172
- Object.defineProperty(ansiHTML.tags, 'open', {
173
- get: ()=>_openTags
174
- });
175
- Object.defineProperty(ansiHTML.tags, 'close', {
176
- get: ()=>_closeTags
177
- });
178
- } else {
179
- ansiHTML.tags.open = _openTags;
180
- ansiHTML.tags.close = _closeTags;
181
- }
182
- function _setTags(colors) {
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}`;
192
- }
193
- }
194
- ansiHTML.reset();
195
- export default ansiHTML;
@@ -1,13 +0,0 @@
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 };
@@ -1,11 +0,0 @@
1
- import { logger } from "../modules/logger/index.js";
2
- const log_name = 'rspack-dev-server';
3
- const defaultLevel = 'info';
4
- function setLogLevel(level) {
5
- logger.configureDefaultLogger({
6
- level
7
- });
8
- }
9
- setLogLevel(defaultLevel);
10
- const log = logger.getLogger(log_name);
11
- export { log, setLogLevel };
@@ -1,11 +0,0 @@
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
- declare function sendMsg(type: string, data?: any): void;
11
- export default sendMsg;
@@ -1,8 +0,0 @@
1
- function sendMsg(type, data) {
2
- if ("u" > typeof self && ("u" < typeof WorkerGlobalScope || !(self instanceof WorkerGlobalScope))) self.postMessage({
3
- type: `webpack${type}`,
4
- data
5
- }, '*');
6
- }
7
- const sendMessage = sendMsg;
8
- export default sendMessage;