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.
Files changed (37) hide show
  1. package/README.md +4 -0
  2. package/client/cjs/client.cjs +8 -7
  3. package/client/cjs/events.cjs +1 -1
  4. package/client/cjs/hot.cjs +1 -1
  5. package/client/cjs/index.cjs +1 -1
  6. package/client/cjs/main.cjs +1 -1
  7. package/client/cjs/ui/overlay.cjs +170 -169
  8. package/client/cjs/ui/progress.cjs +43 -43
  9. package/client/cjs/ui/{utils/index.cjs → utils.cjs} +19 -13
  10. package/client/esm/client.js +8 -7
  11. package/client/esm/events.js +1 -1
  12. package/client/esm/hot.js +1 -1
  13. package/client/esm/index.js +1 -1
  14. package/client/esm/main.js +1 -1
  15. package/client/esm/ui/overlay.js +168 -167
  16. package/client/esm/ui/progress.js +41 -41
  17. package/client/esm/ui/{utils/index.js → utils.js} +12 -12
  18. package/package.json +8 -7
  19. package/server/cjs/dev.cjs +1 -1
  20. package/server/cjs/hot.cjs +1 -1
  21. package/server/cjs/index.cjs +1 -1
  22. package/server/esm/dev.js +1 -1
  23. package/server/esm/hot.js +1 -1
  24. package/server/esm/index.js +1 -1
  25. package/types/client/ui/overlay.d.ts +1 -1
  26. package/types/client/ui/{utils/index.d.ts → utils.d.ts} +1 -1
  27. package/client/cjs/ui/utils/ansi/index.cjs +0 -441
  28. package/client/cjs/ui/utils/ansi/regexp.cjs +0 -70
  29. package/client/cjs/ui/utils/ansi/utils.cjs +0 -27
  30. package/client/esm/ui/utils/ansi/index.js +0 -439
  31. package/client/esm/ui/utils/ansi/regexp.js +0 -66
  32. package/client/esm/ui/utils/ansi/utils.js +0 -24
  33. package/types/client/ui/utils/ansi/enum.d.ts +0 -12
  34. package/types/client/ui/utils/ansi/index.d.ts +0 -18
  35. package/types/client/ui/utils/ansi/interface.d.ts +0 -68
  36. package/types/client/ui/utils/ansi/regexp.d.ts +0 -6
  37. 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
+ ![Screenshot](https://raw.githubusercontent.com/nuintun/webpack-dev-service/main/screenshot.png)
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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.5.19
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
- debug(`\x1b[0m${name} in ${moduleName}\r\n\x1b[0m${message}`);
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 }) => {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.5.19
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.5.19
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.5.19
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.5.19
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.5.19
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 index = require('./utils/index.cjs');
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
- .${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
- overflow-wrap: break-word;
85
- border-radius: 0 0 4px 4px;
86
- padding: 16px 48px 16px 16px;
87
- }
88
- .${OVERLAY}-name {
89
- font-weight: bold;
90
- font-style: normal;
91
- text-transform: uppercase;
92
- }
93
- .${OVERLAY}-errors-title,
94
- .${OVERLAY}-warnings-title {
95
- color: #ff5f58;
96
- padding-left: 8px;
97
- font-style: normal;
98
- }
99
- .${OVERLAY}-warnings-title {
100
- color: #ffbd2e;
101
- }
102
- .${OVERLAY}-problems {
103
- padding: 0 16px;
104
- overflow-y: auto;
105
- scrollbar-width: none;
106
- -ms-overflow-style: none;
107
- -ms-scroll-chaining: none;
108
- overscroll-behavior: contain;
109
- -webkit-overflow-scrolling: touch;
110
- }
111
- .${OVERLAY}-problems::-webkit-scrollbar {
112
- display: none;
113
- }
114
- .${OVERLAY}-errors,
115
- .${OVERLAY}-warnings {
116
- color: #ddd;
117
- padding: 16px;
118
- margin: 16px 0;
119
- display: block;
120
- line-height: 1.2;
121
- border-radius: 4px;
122
- background: #282d35;
123
- white-space: pre-wrap;
124
- font-family: Consolas, "Lucida Console", monospace;
125
- }
126
- .${OVERLAY}-errors > div,
127
- .${OVERLAY}-warnings > div {
128
- overflow-wrap: break-word;
129
- }
130
- .${OVERLAY}-errors > div + div,
131
- .${OVERLAY}-warnings > div + div {
132
- margin: 16px 0 0;
133
- }
134
- .${OVERLAY}-errors > div > em,
135
- .${OVERLAY}-warnings > div > em {
136
- line-height: 1;
137
- color: #641e16;
138
- padding: 4px 8px;
139
- font-style: normal;
140
- border-radius: 4px;
141
- font-weight: normal;
142
- background: #ff5f58;
143
- display: inline-block;
144
- text-transform: uppercase;
145
- }
146
- .${OVERLAY}-warnings > div > em {
147
- color: #3e2723;
148
- background: #ffbd2e;
149
- }
150
- .${OVERLAY}-errors > div > div,
151
- .${OVERLAY}-warnings > div > div {
152
- font-size: 14px;
153
- padding: 8px 0 0 16px;
154
- overflow-wrap: break-word;
155
- }
156
- .${OVERLAY}-hidden {
157
- display: none;
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
- <aside 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
- <article class="${OVERLAY}-problems">
170
- <pre class="${OVERLAY}-errors ${OVERLAY}-hidden"></pre>
171
- <pre class="${OVERLAY}-warnings ${OVERLAY}-hidden"></pre>
172
- </article>
173
- </aside>
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
- index.injectCSS(CSS);
179
- [this.aside] = index.appendHTML(HTML);
180
- this.name = this.aside.querySelector(`.${OVERLAY}-name`);
181
- this.close = this.aside.querySelector(`.${OVERLAY}-close`);
182
- this.errorsList = this.aside.querySelector(`.${OVERLAY}-errors`);
183
- this.warningsList = this.aside.querySelector(`.${OVERLAY}-warnings`);
184
- this.errorsTitle = this.aside.querySelector(`.${OVERLAY}-errors-title`);
185
- this.warningsTitle = this.aside.querySelector(`.${OVERLAY}-warnings-title`);
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 = 'unknown', message } of problems) {
203
- const src = index.ansiToHTML(moduleName);
204
- const details = index.ansiToHTML(message);
205
- html += `<div><em>${name}</em> in ${src}<div>${details}</div></div>`;
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.aside.classList.add(`${OVERLAY}-show`);
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.aside.classList.remove(`${OVERLAY}-show`);
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.5.19
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 index = require('./utils/index.cjs');
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
- .${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
- `;
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
- <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
- `;
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
- index.injectCSS(CSS);
66
- [this.svg] = index.appendHTML(HTML);
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.5.19
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 index = require('./ansi/index.cjs');
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 index();
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:${textDecorations.join(' ')}`);
101
+ styles.push(`text-decoration: ${textDecorations.join(' ')}`);
96
102
  }
97
103
  const escapedValue = escapeHTML(value);
98
- const href = url ? JSON.stringify(escapeHTML(url)) : null;
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
  }