webpack-dev-service 0.5.19 → 0.6.0
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 -0
- package/client/cjs/client.cjs +8 -7
- package/client/cjs/events.cjs +1 -1
- package/client/cjs/hot.cjs +1 -1
- package/client/cjs/index.cjs +1 -1
- package/client/cjs/main.cjs +1 -1
- package/client/cjs/ui/overlay.cjs +170 -169
- package/client/cjs/ui/progress.cjs +43 -43
- package/client/cjs/ui/{utils/index.cjs → utils.cjs} +19 -13
- package/client/esm/client.js +8 -7
- package/client/esm/events.js +1 -1
- package/client/esm/hot.js +1 -1
- package/client/esm/index.js +1 -1
- package/client/esm/main.js +1 -1
- package/client/esm/ui/overlay.js +168 -167
- package/client/esm/ui/progress.js +41 -41
- package/client/esm/ui/{utils/index.js → utils.js} +12 -12
- package/package.json +8 -7
- package/server/cjs/dev.cjs +1 -1
- package/server/cjs/hot.cjs +1 -1
- package/server/cjs/index.cjs +1 -1
- package/server/esm/dev.js +1 -1
- package/server/esm/hot.js +1 -1
- package/server/esm/index.js +1 -1
- package/types/client/ui/overlay.d.ts +1 -1
- package/types/client/ui/{utils/index.d.ts → utils.d.ts} +1 -1
- package/client/cjs/ui/utils/ansi/index.cjs +0 -441
- package/client/cjs/ui/utils/ansi/regexp.cjs +0 -70
- package/client/cjs/ui/utils/ansi/utils.cjs +0 -27
- package/client/esm/ui/utils/ansi/index.js +0 -439
- package/client/esm/ui/utils/ansi/regexp.js +0 -66
- package/client/esm/ui/utils/ansi/utils.js +0 -24
- package/types/client/ui/utils/ansi/enum.d.ts +0 -12
- package/types/client/ui/utils/ansi/index.d.ts +0 -18
- package/types/client/ui/utils/ansi/interface.d.ts +0 -68
- package/types/client/ui/utils/ansi/regexp.d.ts +0 -6
- package/types/client/ui/utils/ansi/utils.d.ts +0 -6
package/README.md
CHANGED
|
@@ -202,6 +202,10 @@ app.listen(port, () => {
|
|
|
202
202
|
});
|
|
203
203
|
```
|
|
204
204
|
|
|
205
|
+
### Screenshot
|
|
206
|
+
|
|
207
|
+

|
|
208
|
+
|
|
205
209
|
[npm-image]: https://img.shields.io/npm/v/webpack-dev-service?style=flat-square
|
|
206
210
|
[npm-url]: https://www.npmjs.org/package/webpack-dev-service
|
|
207
211
|
[download-image]: https://img.shields.io/npm/dm/webpack-dev-service?style=flat-square
|
package/client/cjs/client.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package webpack-dev-service
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 0.
|
|
4
|
+
* @version 0.6.0
|
|
5
5
|
* @author nuintun <nuintun@qq.com>
|
|
6
6
|
* @description A koa 2 middleware for webpack development and hot reloading.
|
|
7
7
|
* @see https://github.com/nuintun/webpack-dev-service#readme
|
|
@@ -52,17 +52,18 @@ function createClient(options) {
|
|
|
52
52
|
hot.setHash(hash);
|
|
53
53
|
};
|
|
54
54
|
const setProblems = (type, problems) => {
|
|
55
|
-
const maps = {
|
|
56
|
-
errors: ['Error', 'error'],
|
|
57
|
-
warnings: ['Warning', 'warn']
|
|
58
|
-
};
|
|
59
55
|
if (options.overlay) {
|
|
60
56
|
overlay$1.setProblems(type, problems);
|
|
61
57
|
}
|
|
58
|
+
const maps = {
|
|
59
|
+
errors: ['\x1b[38;2;100;30;22m\x1b[48;2;255;95;88m ERROR \x1b[0m', 'error'],
|
|
60
|
+
warnings: ['\x1b[38;2;32;39;35m\x1b[48;2;255;189;46m WARNING \x1b[0m', 'warn']
|
|
61
|
+
};
|
|
62
62
|
const [name, method] = maps[type];
|
|
63
63
|
const debug = console[method];
|
|
64
|
-
for (const { moduleName, message } of problems) {
|
|
65
|
-
|
|
64
|
+
for (const { moduleName, chunkName, message } of problems) {
|
|
65
|
+
const filename = moduleName || chunkName || 'unknown';
|
|
66
|
+
debug(`\x1b[0m${name} in ${filename}\r\n${message}`);
|
|
66
67
|
}
|
|
67
68
|
};
|
|
68
69
|
const onProblems = ({ errors, warnings }) => {
|
package/client/cjs/events.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package webpack-dev-service
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 0.
|
|
4
|
+
* @version 0.6.0
|
|
5
5
|
* @author nuintun <nuintun@qq.com>
|
|
6
6
|
* @description A koa 2 middleware for webpack development and hot reloading.
|
|
7
7
|
* @see https://github.com/nuintun/webpack-dev-service#readme
|
package/client/cjs/hot.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package webpack-dev-service
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 0.
|
|
4
|
+
* @version 0.6.0
|
|
5
5
|
* @author nuintun <nuintun@qq.com>
|
|
6
6
|
* @description A koa 2 middleware for webpack development and hot reloading.
|
|
7
7
|
* @see https://github.com/nuintun/webpack-dev-service#readme
|
package/client/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package webpack-dev-service
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 0.
|
|
4
|
+
* @version 0.6.0
|
|
5
5
|
* @author nuintun <nuintun@qq.com>
|
|
6
6
|
* @description A koa 2 middleware for webpack development and hot reloading.
|
|
7
7
|
* @see https://github.com/nuintun/webpack-dev-service#readme
|
package/client/cjs/main.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package webpack-dev-service
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 0.
|
|
4
|
+
* @version 0.6.0
|
|
5
5
|
* @author nuintun <nuintun@qq.com>
|
|
6
6
|
* @description A koa 2 middleware for webpack development and hot reloading.
|
|
7
7
|
* @see https://github.com/nuintun/webpack-dev-service#readme
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package webpack-dev-service
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 0.
|
|
4
|
+
* @version 0.6.0
|
|
5
5
|
* @author nuintun <nuintun@qq.com>
|
|
6
6
|
* @description A koa 2 middleware for webpack development and hot reloading.
|
|
7
7
|
* @see https://github.com/nuintun/webpack-dev-service#readme
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const utils = require('./utils.cjs');
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @module overlay
|
|
@@ -17,172 +17,173 @@ const index = require('./utils/index.cjs');
|
|
|
17
17
|
*/
|
|
18
18
|
const OVERLAY = 'wds-overlay';
|
|
19
19
|
const CSS = `
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
20
|
+
.${OVERLAY} {
|
|
21
|
+
top:0;
|
|
22
|
+
left: 0;
|
|
23
|
+
right: 0;
|
|
24
|
+
bottom: 0;
|
|
25
|
+
display: flex;
|
|
26
|
+
position: fixed;
|
|
27
|
+
font-size: 16px;
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
font-style: normal;
|
|
30
|
+
font-weight: normal;
|
|
31
|
+
z-index: 2147483646;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
transform-origin: center;
|
|
35
|
+
background: rgba(0, 0, 0, .85);
|
|
36
|
+
transform: scale(0) translateZ(0);
|
|
37
|
+
transition: transform .25s ease-out;
|
|
38
|
+
font-family: Consolas, "Lucida Console", monospace;
|
|
39
|
+
}
|
|
40
|
+
.${OVERLAY}-show {
|
|
41
|
+
transform: scale(1) translateZ(0);
|
|
42
|
+
}
|
|
43
|
+
.${OVERLAY}-close {
|
|
44
|
+
top: 16px;
|
|
45
|
+
right: 16px;
|
|
46
|
+
width: 16px;
|
|
47
|
+
height: 16px;
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
position: absolute;
|
|
50
|
+
border-radius: 16px;
|
|
51
|
+
background: #ff5f58;
|
|
52
|
+
display: inline-block;
|
|
53
|
+
transform-origin: center;
|
|
54
|
+
box-shadow: #ff5f58 0 0 6px;
|
|
55
|
+
transform: rotate(0) translateZ(0);
|
|
56
|
+
transition: transform .25s ease-in-out;
|
|
57
|
+
}
|
|
58
|
+
.${OVERLAY}-close:before,
|
|
59
|
+
.${OVERLAY}-close:after {
|
|
60
|
+
top: 7px;
|
|
61
|
+
left: 3px;
|
|
62
|
+
content: "";
|
|
63
|
+
width: 10px;
|
|
64
|
+
height: 2px;
|
|
65
|
+
position: absolute;
|
|
66
|
+
background-color: white;
|
|
67
|
+
transform-origin: center;
|
|
68
|
+
}
|
|
69
|
+
.${OVERLAY}-close:before {
|
|
70
|
+
transform: rotate(45deg);
|
|
71
|
+
}
|
|
72
|
+
.${OVERLAY}-close:after {
|
|
73
|
+
transform: rotate(-45deg);
|
|
74
|
+
}
|
|
75
|
+
.${OVERLAY}-close:hover {
|
|
76
|
+
transform: rotate(180deg) translateZ(0);
|
|
77
|
+
}
|
|
78
|
+
.${OVERLAY}-title {
|
|
79
|
+
margin: 0;
|
|
80
|
+
color: #fff;
|
|
81
|
+
line-height: 16px;
|
|
82
|
+
text-align: center;
|
|
83
|
+
background: #282d35;
|
|
84
|
+
border-radius: 0 0 4px 4px;
|
|
85
|
+
padding: 16px 48px 16px 16px;
|
|
86
|
+
}
|
|
87
|
+
.${OVERLAY}-name {
|
|
88
|
+
font-weight: bold;
|
|
89
|
+
font-style: normal;
|
|
90
|
+
text-transform: uppercase;
|
|
91
|
+
}
|
|
92
|
+
.${OVERLAY}-errors-title,
|
|
93
|
+
.${OVERLAY}-warnings-title {
|
|
94
|
+
color: #ff5f58;
|
|
95
|
+
padding-left: 8px;
|
|
96
|
+
font-style: normal;
|
|
97
|
+
}
|
|
98
|
+
.${OVERLAY}-warnings-title {
|
|
99
|
+
color: #ffbd2e;
|
|
100
|
+
}
|
|
101
|
+
.${OVERLAY}-problems {
|
|
102
|
+
padding: 0 16px;
|
|
103
|
+
overflow-y: auto;
|
|
104
|
+
scrollbar-width: none;
|
|
105
|
+
-ms-overflow-style: none;
|
|
106
|
+
-ms-scroll-chaining: none;
|
|
107
|
+
overscroll-behavior: contain;
|
|
108
|
+
-webkit-overflow-scrolling: touch;
|
|
109
|
+
}
|
|
110
|
+
.${OVERLAY}-problems::-webkit-scrollbar {
|
|
111
|
+
display: none;
|
|
112
|
+
}
|
|
113
|
+
.${OVERLAY}-errors,
|
|
114
|
+
.${OVERLAY}-warnings {
|
|
115
|
+
color: #ddd;
|
|
116
|
+
padding: 16px;
|
|
117
|
+
margin: 16px 0;
|
|
118
|
+
display: block;
|
|
119
|
+
line-height: 1.2;
|
|
120
|
+
border-radius: 4px;
|
|
121
|
+
background: #282d35;
|
|
122
|
+
}
|
|
123
|
+
.${OVERLAY}-errors > section + section,
|
|
124
|
+
.${OVERLAY}-warnings > section + section {
|
|
125
|
+
margin: 16px 0 0;
|
|
126
|
+
}
|
|
127
|
+
.${OVERLAY}-errors > section > em,
|
|
128
|
+
.${OVERLAY}-warnings > section > em {
|
|
129
|
+
line-height: 1;
|
|
130
|
+
color: #641e16;
|
|
131
|
+
padding: 4px 8px;
|
|
132
|
+
font-style: normal;
|
|
133
|
+
border-radius: 4px;
|
|
134
|
+
font-weight: normal;
|
|
135
|
+
background: #ff5f58;
|
|
136
|
+
display: inline-block;
|
|
137
|
+
text-transform: uppercase;
|
|
138
|
+
}
|
|
139
|
+
.${OVERLAY}-warnings > section > em {
|
|
140
|
+
color: #3e2723;
|
|
141
|
+
background: #ffbd2e;
|
|
142
|
+
}
|
|
143
|
+
.${OVERLAY}-errors > section > pre,
|
|
144
|
+
.${OVERLAY}-warnings > section > pre {
|
|
145
|
+
margin: 0;
|
|
146
|
+
font-size: 14px;
|
|
147
|
+
font-family: inherit;
|
|
148
|
+
padding: 8px 0 0 16px;
|
|
149
|
+
white-space: pre-wrap;
|
|
150
|
+
overflow-wrap: anywhere;
|
|
151
|
+
}
|
|
152
|
+
.${OVERLAY}-errors > section > pre span,
|
|
153
|
+
.${OVERLAY}-warnings > section > pre span {
|
|
154
|
+
display: inline-flex;
|
|
155
|
+
}
|
|
156
|
+
.${OVERLAY}-hidden {
|
|
157
|
+
display: none;
|
|
158
|
+
}
|
|
159
|
+
`;
|
|
160
160
|
const DEFAULT_NAME = 'webpack';
|
|
161
161
|
const HTML = `
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
162
|
+
<div class="${OVERLAY}">
|
|
163
|
+
<i class="${OVERLAY}-close"></i>
|
|
164
|
+
<div class="${OVERLAY}-title">
|
|
165
|
+
<em class="${OVERLAY}-name"></em>
|
|
166
|
+
<em class="${OVERLAY}-errors-title"></em>
|
|
167
|
+
<em class="${OVERLAY}-warnings-title"></em>
|
|
168
|
+
</div>
|
|
169
|
+
<aside class="${OVERLAY}-problems">
|
|
170
|
+
<article class="${OVERLAY}-errors ${OVERLAY}-hidden"></article>
|
|
171
|
+
<article class="${OVERLAY}-warnings ${OVERLAY}-hidden"></article>
|
|
172
|
+
</aside>
|
|
173
|
+
</div>
|
|
174
|
+
`;
|
|
175
175
|
class Overlay {
|
|
176
176
|
constructor(name) {
|
|
177
177
|
this.hidden = true;
|
|
178
|
-
|
|
179
|
-
[
|
|
180
|
-
this.
|
|
181
|
-
this.
|
|
182
|
-
this.
|
|
183
|
-
this.
|
|
184
|
-
this.
|
|
185
|
-
this.
|
|
178
|
+
utils.injectCSS(CSS);
|
|
179
|
+
const [dialog] = utils.appendHTML(HTML);
|
|
180
|
+
this.dialog = dialog;
|
|
181
|
+
this.name = dialog.querySelector(`.${OVERLAY}-name`);
|
|
182
|
+
this.close = dialog.querySelector(`.${OVERLAY}-close`);
|
|
183
|
+
this.errorsList = dialog.querySelector(`.${OVERLAY}-errors`);
|
|
184
|
+
this.warningsList = dialog.querySelector(`.${OVERLAY}-warnings`);
|
|
185
|
+
this.errorsTitle = dialog.querySelector(`.${OVERLAY}-errors-title`);
|
|
186
|
+
this.warningsTitle = dialog.querySelector(`.${OVERLAY}-warnings-title`);
|
|
186
187
|
this.name.innerHTML = `⭕ ${name || DEFAULT_NAME}`;
|
|
187
188
|
this.close.addEventListener('click', () => {
|
|
188
189
|
this.hide();
|
|
@@ -199,10 +200,10 @@ class Overlay {
|
|
|
199
200
|
if (count > 0) {
|
|
200
201
|
let html = '';
|
|
201
202
|
problemTitle.innerText = `${count} ${name}(s)`;
|
|
202
|
-
for (const { moduleName
|
|
203
|
-
const
|
|
204
|
-
const
|
|
205
|
-
html += `<
|
|
203
|
+
for (const { moduleName, chunkName, message } of problems) {
|
|
204
|
+
const details = utils.ansiToHTML(message);
|
|
205
|
+
const filename = moduleName || chunkName || 'unknown';
|
|
206
|
+
html += `<section><em>${name}</em> in ${filename}<pre>${details}</pre></section>`;
|
|
206
207
|
}
|
|
207
208
|
problemList.innerHTML = html;
|
|
208
209
|
problemList.classList.remove(hidden);
|
|
@@ -215,13 +216,13 @@ class Overlay {
|
|
|
215
216
|
show() {
|
|
216
217
|
if (this.hidden) {
|
|
217
218
|
this.hidden = false;
|
|
218
|
-
this.
|
|
219
|
+
this.dialog.classList.add(`${OVERLAY}-show`);
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
222
|
hide() {
|
|
222
223
|
if (!this.hidden) {
|
|
223
224
|
this.hidden = true;
|
|
224
|
-
this.
|
|
225
|
+
this.dialog.classList.remove(`${OVERLAY}-show`);
|
|
225
226
|
}
|
|
226
227
|
}
|
|
227
228
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package webpack-dev-service
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 0.
|
|
4
|
+
* @version 0.6.0
|
|
5
5
|
* @author nuintun <nuintun@qq.com>
|
|
6
6
|
* @description A koa 2 middleware for webpack development and hot reloading.
|
|
7
7
|
* @see https://github.com/nuintun/webpack-dev-service#readme
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const utils = require('./utils.cjs');
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @module progress
|
|
@@ -19,51 +19,51 @@ const index = require('./utils/index.cjs');
|
|
|
19
19
|
const PROGRESS = 'wds-progress';
|
|
20
20
|
const PERIMETER = 2 * Math.PI * 44;
|
|
21
21
|
const CSS = `
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
22
|
+
.${PROGRESS} {
|
|
23
|
+
width: 48px;
|
|
24
|
+
right: 16px;
|
|
25
|
+
height: 48px;
|
|
26
|
+
bottom: 16px;
|
|
27
|
+
display: block;
|
|
28
|
+
font-size: 16px;
|
|
29
|
+
position: fixed;
|
|
30
|
+
cursor: default;
|
|
31
|
+
user-select: none;
|
|
32
|
+
font-style: normal;
|
|
33
|
+
font-weight: normal;
|
|
34
|
+
z-index: 2147483647;
|
|
35
|
+
transform-origin: center;
|
|
36
|
+
transform: scale(0) translateZ(0);
|
|
37
|
+
transition: transform .25s ease-out;
|
|
38
|
+
}
|
|
39
|
+
.${PROGRESS}-show {
|
|
40
|
+
transform: scale(1) translateZ(0);
|
|
41
|
+
}
|
|
42
|
+
.${PROGRESS}-track {
|
|
43
|
+
stroke: #badfac;
|
|
44
|
+
stroke-width: 8;
|
|
45
|
+
stroke-linecap: round;
|
|
46
|
+
fill: rgba(0, 0, 0, 0);
|
|
47
|
+
stroke-dasharray: ${PERIMETER};
|
|
48
|
+
stroke-dashoffset: ${PERIMETER};
|
|
49
|
+
transition: stroke-dashoffset .25s linear;
|
|
50
|
+
transform: matrix(0, -1, 1, 0, 0, 96) translateZ(0);
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
53
|
const HTML = `
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
<svg class="${PROGRESS}" x="0" y="0" viewBox="0 0 96 96">
|
|
55
|
+
<circle fill="#282d35" cx="50%" cy="50%" r="44" />
|
|
56
|
+
<circle class="${PROGRESS}-track" cx="50%" cy="50%" r="44" />
|
|
57
|
+
<path fill="#fff" d="m48,83.213561l-31.122918,-17.60678l0,-35.21356l31.122918,-17.60678l31.122918,17.60678l0,35.21356l-31.122918,17.60678z" />
|
|
58
|
+
<path fill="#8ed6fb" d="m22.434956,31.608089l24.537982,-13.880011l0,10.810563l-15.288554,8.410172l-9.249428,-5.340723zm-1.678513,1.520052l0,29.027711l8.979458,-5.182262l0,-18.657318l-8.979458,-5.188131zm52.908373,-1.520052l-24.537982,-13.880011l0,10.810563l15.288554,8.410172l9.249428,-5.340723zm1.678513,1.520052l0,29.027711l-8.979458,-5.182262l0,-18.657318l8.979458,-5.188131zm-1.050538,30.905767l-25.165957,14.238016l0,-10.452558l16.121941,-8.867948l0.123247,-0.070427l8.920768,5.152918zm-52.485811,0l25.165957,14.238016l0,-10.452558l-16.121941,-8.867948l-0.123247,-0.070427l-8.920768,5.152918z" />
|
|
59
|
+
<path fill="#1c78c0" d="m49.126834,30.997721l15.083141,8.292793l0,16.432994l-15.083141,-8.709487l0,-16.016301zm-2.153896,0l-15.083141,8.292793l0,16.432994l15.083141,-8.709487l0,-16.016301zm16.215844,26.62732l-15.141831,8.328007l-15.141831,-8.328007l15.141831,-8.744701l15.141831,8.744701z" />
|
|
60
|
+
</svg>
|
|
61
|
+
`;
|
|
62
62
|
class Progress {
|
|
63
63
|
constructor() {
|
|
64
64
|
this.hidden = true;
|
|
65
|
-
|
|
66
|
-
[this.svg] =
|
|
65
|
+
utils.injectCSS(CSS);
|
|
66
|
+
[this.svg] = utils.appendHTML(HTML);
|
|
67
67
|
this.track = this.svg.querySelector(`.${PROGRESS}-track`);
|
|
68
68
|
}
|
|
69
69
|
update(value) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package webpack-dev-service
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 0.
|
|
4
|
+
* @version 0.6.0
|
|
5
5
|
* @author nuintun <nuintun@qq.com>
|
|
6
6
|
* @description A koa 2 middleware for webpack development and hot reloading.
|
|
7
7
|
* @see https://github.com/nuintun/webpack-dev-service#readme
|
|
@@ -9,12 +9,18 @@
|
|
|
9
9
|
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const Ansi = require('@nuintun/ansi');
|
|
13
|
+
|
|
14
|
+
function _interopDefault(e) {
|
|
15
|
+
return e && e.__esModule ? e : { default: e };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const Ansi__default = /*#__PURE__*/ _interopDefault(Ansi);
|
|
13
19
|
|
|
14
20
|
/**
|
|
15
21
|
* @module utils
|
|
16
22
|
*/
|
|
17
|
-
const ansi = new
|
|
23
|
+
const ansi = new Ansi__default.default();
|
|
18
24
|
const defaultStyleElement = document.createElement('style');
|
|
19
25
|
function injectCSS(css, styleElement = defaultStyleElement) {
|
|
20
26
|
const { head } = document;
|
|
@@ -58,19 +64,19 @@ function blockToHTML({ style, value, url }) {
|
|
|
58
64
|
const styles = [];
|
|
59
65
|
const textDecorations = [];
|
|
60
66
|
if (style.dim) {
|
|
61
|
-
styles.push(`opacity:0.5`);
|
|
67
|
+
styles.push(`opacity: 0.5`);
|
|
62
68
|
}
|
|
63
69
|
if (style.bold) {
|
|
64
|
-
styles.push(`font-weight:bold`);
|
|
70
|
+
styles.push(`font-weight: bold`);
|
|
65
71
|
}
|
|
66
72
|
if (style.italic) {
|
|
67
|
-
styles.push(`font-style:italic`);
|
|
73
|
+
styles.push(`font-style: italic`);
|
|
68
74
|
}
|
|
69
75
|
if (style.inverse) {
|
|
70
|
-
styles.push(`filter:invert(1)`);
|
|
76
|
+
styles.push(`filter: invert(1)`);
|
|
71
77
|
}
|
|
72
78
|
if (style.hidden) {
|
|
73
|
-
styles.push(`visibility:hidden`);
|
|
79
|
+
styles.push(`visibility: hidden`);
|
|
74
80
|
}
|
|
75
81
|
if (style.blink) {
|
|
76
82
|
textDecorations.push('blink');
|
|
@@ -86,23 +92,23 @@ function blockToHTML({ style, value, url }) {
|
|
|
86
92
|
}
|
|
87
93
|
const { color, background } = style;
|
|
88
94
|
if (color) {
|
|
89
|
-
styles.push(`color:rgb(${color})`);
|
|
95
|
+
styles.push(`color: rgb(${color})`);
|
|
90
96
|
}
|
|
91
97
|
if (background) {
|
|
92
|
-
styles.push(`background-color:rgb(${background})`);
|
|
98
|
+
styles.push(`background-color: rgb(${background})`);
|
|
93
99
|
}
|
|
94
100
|
if (textDecorations.length > 0) {
|
|
95
|
-
styles.push(`text-decoration
|
|
101
|
+
styles.push(`text-decoration: ${textDecorations.join(' ')}`);
|
|
96
102
|
}
|
|
97
103
|
const escapedValue = escapeHTML(value);
|
|
98
|
-
const href = url ? JSON.stringify(
|
|
104
|
+
const href = url ? JSON.stringify(new URL(url).toString()) : null;
|
|
99
105
|
if (styles.length <= 0) {
|
|
100
106
|
if (!href) {
|
|
101
107
|
return escapedValue;
|
|
102
108
|
}
|
|
103
109
|
return `<a href=${href} target="_blank">${escapedValue}</a>`;
|
|
104
110
|
}
|
|
105
|
-
const inlineStyle = JSON.stringify(`${styles.join(';')};`);
|
|
111
|
+
const inlineStyle = JSON.stringify(`${styles.join('; ')};`);
|
|
106
112
|
if (!href) {
|
|
107
113
|
return `<span style=${inlineStyle}>${escapedValue}</span>`;
|
|
108
114
|
}
|