@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
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
export declare function isProgressSupported(): boolean;
|
|
11
|
+
export declare function defineProgressElement(): void;
|
package/client/progress.js
CHANGED
|
@@ -1,130 +1,197 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var __extends = (this && this.__extends) || (function () {
|
|
11
|
-
var extendStatics = function (d, b) {
|
|
12
|
-
extendStatics = Object.setPrototypeOf ||
|
|
13
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
14
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
15
|
-
return extendStatics(d, b);
|
|
16
|
-
};
|
|
17
|
-
return function (d, b) {
|
|
18
|
-
if (typeof b !== "function" && b !== null)
|
|
19
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
20
|
-
extendStatics(d, b);
|
|
21
|
-
function __() { this.constructor = d; }
|
|
22
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
23
|
-
};
|
|
24
|
-
})();
|
|
25
|
-
export function isProgressSupported() {
|
|
26
|
-
return ('customElements' in self && Boolean(HTMLElement.prototype.attachShadow));
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
3
|
+
value: value,
|
|
4
|
+
enumerable: true,
|
|
5
|
+
configurable: true,
|
|
6
|
+
writable: true
|
|
7
|
+
});
|
|
8
|
+
else obj[key] = value;
|
|
9
|
+
return obj;
|
|
27
10
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
_this.attachShadow({ mode: 'open' });
|
|
37
|
-
_this.maxDashOffset = -219.99078369140625;
|
|
38
|
-
_this.animationTimer = undefined;
|
|
39
|
-
_this.type = 'circular';
|
|
40
|
-
_this.initialProgress = 0;
|
|
41
|
-
return _this;
|
|
42
|
-
}
|
|
43
|
-
WebpackDevServerProgress.prototype.reset = function () {
|
|
44
|
-
var _a;
|
|
11
|
+
function isProgressSupported() {
|
|
12
|
+
return 'customElements' in self && Boolean(HTMLElement.prototype.attachShadow);
|
|
13
|
+
}
|
|
14
|
+
function defineProgressElement() {
|
|
15
|
+
if (customElements.get('wds-progress')) return;
|
|
16
|
+
class WebpackDevServerProgress extends HTMLElement {
|
|
17
|
+
reset() {
|
|
18
|
+
var _this_getAttribute;
|
|
45
19
|
clearTimeout(this.animationTimer);
|
|
46
|
-
this.animationTimer =
|
|
47
|
-
|
|
48
|
-
this.type =
|
|
49
|
-
|
|
50
|
-
? WebpackDevServerProgress.circularTemplate()
|
|
51
|
-
: WebpackDevServerProgress.linearTemplate();
|
|
20
|
+
this.animationTimer = void 0;
|
|
21
|
+
const typeAttr = null == (_this_getAttribute = this.getAttribute('type')) ? void 0 : _this_getAttribute.toLowerCase();
|
|
22
|
+
this.type = 'circular' === typeAttr ? 'circular' : 'linear';
|
|
23
|
+
const innerHTML = 'circular' === this.type ? WebpackDevServerProgress.circularTemplate() : WebpackDevServerProgress.linearTemplate();
|
|
52
24
|
this.shadowRoot.innerHTML = innerHTML;
|
|
53
|
-
|
|
25
|
+
const progressValue = this.getAttribute('progress');
|
|
54
26
|
this.initialProgress = progressValue ? Number(progressValue) : 0;
|
|
55
27
|
this.update(this.initialProgress);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
28
|
+
}
|
|
29
|
+
static circularTemplate() {
|
|
30
|
+
return `
|
|
31
|
+
<style>
|
|
32
|
+
:host {
|
|
33
|
+
width: 200px;
|
|
34
|
+
height: 200px;
|
|
35
|
+
position: fixed;
|
|
36
|
+
right: 5%;
|
|
37
|
+
top: 5%;
|
|
38
|
+
pointer-events: none;
|
|
39
|
+
transition: opacity .25s ease-in-out;
|
|
40
|
+
z-index: 2147483645;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
circle {
|
|
44
|
+
fill: #282d35;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
path {
|
|
48
|
+
fill: rgba(0, 0, 0, 0);
|
|
49
|
+
stroke: rgb(186, 223, 172);
|
|
50
|
+
stroke-dasharray: 219.99078369140625;
|
|
51
|
+
stroke-dashoffset: -219.99078369140625;
|
|
52
|
+
stroke-width: 10;
|
|
53
|
+
transform: rotate(90deg) translate(0px, -80px);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
text {
|
|
57
|
+
font-family: 'Open Sans', sans-serif;
|
|
58
|
+
font-size: 18px;
|
|
59
|
+
fill: #ffffff;
|
|
60
|
+
dominant-baseline: middle;
|
|
61
|
+
text-anchor: middle;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
tspan#percent-super {
|
|
65
|
+
fill: #bdc3c7;
|
|
66
|
+
font-size: 0.45em;
|
|
67
|
+
baseline-shift: 10%;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@keyframes fade {
|
|
71
|
+
0% { opacity: 1; transform: scale(1); }
|
|
72
|
+
100% { opacity: 0; transform: scale(0); }
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.disappear {
|
|
76
|
+
animation: fade 0.3s;
|
|
77
|
+
animation-fill-mode: forwards;
|
|
78
|
+
animation-delay: 0.5s;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.hidden {
|
|
82
|
+
display: none;
|
|
83
|
+
}
|
|
84
|
+
</style>
|
|
85
|
+
<svg id="progress" class="hidden noselect" viewBox="0 0 80 80">
|
|
86
|
+
<circle cx="50%" cy="50%" r="35"></circle>
|
|
87
|
+
<path d="M5,40a35,35 0 1,0 70,0a35,35 0 1,0 -70,0"></path>
|
|
88
|
+
<text x="50%" y="51%">
|
|
89
|
+
<tspan id="percent-value">0</tspan>
|
|
90
|
+
<tspan id="percent-super">%</tspan>
|
|
91
|
+
</text>
|
|
92
|
+
</svg>
|
|
93
|
+
`;
|
|
94
|
+
}
|
|
95
|
+
static linearTemplate() {
|
|
96
|
+
return `
|
|
97
|
+
<style>
|
|
98
|
+
:host {
|
|
99
|
+
position: fixed;
|
|
100
|
+
top: 0;
|
|
101
|
+
left: 0;
|
|
102
|
+
pointer-events: none;
|
|
103
|
+
height: 4px;
|
|
104
|
+
width: 100vw;
|
|
105
|
+
z-index: 2147483645;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
#bar {
|
|
109
|
+
width: 0%;
|
|
110
|
+
height: 4px;
|
|
111
|
+
background-color: rgb(186, 223, 172);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@keyframes fade {
|
|
115
|
+
0% { opacity: 1; }
|
|
116
|
+
100% { opacity: 0; }
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.disappear {
|
|
120
|
+
animation: fade 0.3s;
|
|
121
|
+
animation-fill-mode: forwards;
|
|
122
|
+
animation-delay: 0.5s;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.hidden {
|
|
126
|
+
display: none;
|
|
127
|
+
}
|
|
128
|
+
</style>
|
|
129
|
+
<div id="progress"></div>
|
|
130
|
+
`;
|
|
131
|
+
}
|
|
132
|
+
connectedCallback() {
|
|
64
133
|
this.reset();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
var element = shadowRoot.querySelector('#progress');
|
|
84
|
-
if (this.type === 'circular') {
|
|
85
|
-
var path = shadowRoot.querySelector('path');
|
|
86
|
-
var value = shadowRoot.querySelector('#percent-value');
|
|
87
|
-
var offset = ((100 - percent) / 100) * this.maxDashOffset;
|
|
134
|
+
}
|
|
135
|
+
static get observedAttributes() {
|
|
136
|
+
return [
|
|
137
|
+
'progress',
|
|
138
|
+
'type'
|
|
139
|
+
];
|
|
140
|
+
}
|
|
141
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
142
|
+
if ('progress' === name) this.update(Number(newValue));
|
|
143
|
+
else if ('type' === name) this.reset();
|
|
144
|
+
}
|
|
145
|
+
update(percent) {
|
|
146
|
+
const shadowRoot = this.shadowRoot;
|
|
147
|
+
const element = shadowRoot.querySelector('#progress');
|
|
148
|
+
if ('circular' === this.type) {
|
|
149
|
+
const path = shadowRoot.querySelector('path');
|
|
150
|
+
const value = shadowRoot.querySelector('#percent-value');
|
|
151
|
+
const offset = (100 - percent) / 100 * this.maxDashOffset;
|
|
88
152
|
path.style.strokeDashoffset = String(offset);
|
|
89
153
|
value.textContent = String(percent);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
else if (percent > 0) {
|
|
98
|
-
this.show();
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
WebpackDevServerProgress.prototype.show = function () {
|
|
102
|
-
var shadowRoot = this.shadowRoot;
|
|
103
|
-
var element = shadowRoot.querySelector('#progress');
|
|
154
|
+
} else element.style.width = `${percent}%`;
|
|
155
|
+
if (percent >= 100) this.hide();
|
|
156
|
+
else if (percent > 0) this.show();
|
|
157
|
+
}
|
|
158
|
+
show() {
|
|
159
|
+
const shadowRoot = this.shadowRoot;
|
|
160
|
+
const element = shadowRoot.querySelector('#progress');
|
|
104
161
|
element.classList.remove('hidden');
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (this.type === 'circular') {
|
|
162
|
+
}
|
|
163
|
+
hide() {
|
|
164
|
+
const shadowRoot = this.shadowRoot;
|
|
165
|
+
const element = shadowRoot.querySelector('#progress');
|
|
166
|
+
if ('circular' === this.type) {
|
|
111
167
|
element.classList.add('disappear');
|
|
112
|
-
element.addEventListener('animationend',
|
|
168
|
+
element.addEventListener('animationend', ()=>{
|
|
113
169
|
element.classList.add('hidden');
|
|
114
|
-
|
|
115
|
-
}, {
|
|
116
|
-
|
|
117
|
-
|
|
170
|
+
this.update(0);
|
|
171
|
+
}, {
|
|
172
|
+
once: true
|
|
173
|
+
});
|
|
174
|
+
} else if ('linear' === this.type) {
|
|
118
175
|
element.classList.add('disappear');
|
|
119
|
-
this.animationTimer = setTimeout(
|
|
176
|
+
this.animationTimer = setTimeout(()=>{
|
|
120
177
|
element.classList.remove('disappear');
|
|
121
178
|
element.classList.add('hidden');
|
|
122
179
|
element.style.width = '0%';
|
|
123
|
-
|
|
180
|
+
this.animationTimer = void 0;
|
|
124
181
|
}, 800);
|
|
125
182
|
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
183
|
+
}
|
|
184
|
+
constructor(){
|
|
185
|
+
super(), _define_property(this, "maxDashOffset", void 0), _define_property(this, "animationTimer", void 0), _define_property(this, "type", void 0), _define_property(this, "initialProgress", void 0);
|
|
186
|
+
this.attachShadow({
|
|
187
|
+
mode: 'open'
|
|
188
|
+
});
|
|
189
|
+
this.maxDashOffset = -219.99078369140625;
|
|
190
|
+
this.animationTimer = void 0;
|
|
191
|
+
this.type = 'circular';
|
|
192
|
+
this.initialProgress = 0;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
129
195
|
customElements.define('wds-progress', WebpackDevServerProgress);
|
|
130
196
|
}
|
|
197
|
+
export { defineProgressElement, isProgressSupported };
|
|
@@ -0,0 +1,15 @@
|
|
|
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 { CommunicationClient, EXPECTED_ANY } from './type.js';
|
|
11
|
+
export declare let client: CommunicationClient | null;
|
|
12
|
+
declare function socket(url: string, handlers: {
|
|
13
|
+
[handler: string]: (data?: EXPECTED_ANY, params?: EXPECTED_ANY) => EXPECTED_ANY;
|
|
14
|
+
}, reconnect?: number): void;
|
|
15
|
+
export default socket;
|
package/client/socket.js
CHANGED
|
@@ -1,60 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* https://github.com/webpack/webpack-dev-server/blob/main/LICENSE
|
|
9
|
-
*/
|
|
10
|
-
import WebSocketClient from './clients/WebSocketClient.js';
|
|
11
|
-
import { log } from './utils/log.js';
|
|
12
|
-
// this WebsocketClient is here as a default fallback, in case the client is not injected
|
|
13
|
-
var Client = typeof __webpack_dev_server_client__ !== 'undefined'
|
|
14
|
-
? typeof __webpack_dev_server_client__.default !== 'undefined'
|
|
15
|
-
? __webpack_dev_server_client__.default
|
|
16
|
-
: __webpack_dev_server_client__
|
|
17
|
-
: WebSocketClient;
|
|
18
|
-
var retries = 0;
|
|
19
|
-
var maxRetries = 10;
|
|
20
|
-
// Initialized client is exported so external consumers can utilize the same instance
|
|
21
|
-
// It is mutable to enforce singleton
|
|
22
|
-
export var client = null;
|
|
23
|
-
var timeout;
|
|
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;
|
|
24
8
|
function socket(url, handlers, reconnect) {
|
|
25
9
|
client = new Client(url);
|
|
26
|
-
client.onOpen(
|
|
10
|
+
client.onOpen(()=>{
|
|
27
11
|
retries = 0;
|
|
28
|
-
if (timeout)
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
if (typeof reconnect !== 'undefined') {
|
|
32
|
-
maxRetries = reconnect;
|
|
33
|
-
}
|
|
12
|
+
if (timeout) clearTimeout(timeout);
|
|
13
|
+
if (void 0 !== reconnect) maxRetries = reconnect;
|
|
34
14
|
});
|
|
35
|
-
client.onClose(
|
|
36
|
-
if (
|
|
37
|
-
handlers.close();
|
|
38
|
-
}
|
|
39
|
-
// Try to reconnect.
|
|
15
|
+
client.onClose(()=>{
|
|
16
|
+
if (0 === retries) handlers.close();
|
|
40
17
|
client = null;
|
|
41
|
-
// After 10 retries stop trying, to prevent logspam.
|
|
42
18
|
if (retries < maxRetries) {
|
|
43
|
-
|
|
44
|
-
// Respectfully copied from the package `got`.
|
|
45
|
-
var retryInMs = 1000 * Math.pow(2, retries) + Math.random() * 100;
|
|
19
|
+
const retryInMs = 1000 * Math.pow(2, retries) + 100 * Math.random();
|
|
46
20
|
retries += 1;
|
|
47
21
|
log.info('Trying to reconnect...');
|
|
48
|
-
timeout = setTimeout(
|
|
22
|
+
timeout = setTimeout(()=>{
|
|
49
23
|
socket(url, handlers, reconnect);
|
|
50
24
|
}, retryInMs);
|
|
51
25
|
}
|
|
52
26
|
});
|
|
53
|
-
client.onMessage(
|
|
54
|
-
|
|
55
|
-
if (handlers[message.type])
|
|
56
|
-
handlers[message.type](message.data, message.params);
|
|
57
|
-
}
|
|
27
|
+
client.onMessage((data)=>{
|
|
28
|
+
const message = JSON.parse(data);
|
|
29
|
+
if (handlers[message.type]) handlers[message.type](message.data, message.params);
|
|
58
30
|
});
|
|
59
31
|
}
|
|
60
|
-
|
|
32
|
+
const client_src_socket = socket;
|
|
33
|
+
export { client, client_src_socket as default };
|
|
@@ -0,0 +1,30 @@
|
|
|
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;
|