webpack-dev-service 0.5.2 → 0.5.4
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/client/cjs/client.cjs +111 -109
- package/client/cjs/events.cjs +33 -32
- package/client/cjs/hot.cjs +61 -60
- package/client/cjs/index.cjs +10 -8
- package/client/cjs/main.cjs +63 -60
- package/client/cjs/ui/overlay.cjs +64 -63
- package/client/cjs/ui/progress.cjs +35 -35
- package/client/cjs/ui/utils/ansi/index.cjs +439 -413
- package/client/cjs/ui/utils/ansi/regx.cjs +8 -8
- package/client/cjs/ui/utils/ansi/utils.cjs +14 -14
- package/client/cjs/ui/utils/index.cjs +99 -99
- package/client/esm/client.js +111 -109
- package/client/esm/events.js +33 -32
- package/client/esm/hot.js +61 -60
- package/client/esm/index.js +8 -8
- package/client/esm/main.js +63 -60
- package/client/esm/ui/overlay.js +64 -63
- package/client/esm/ui/progress.js +35 -35
- package/client/esm/ui/utils/ansi/index.js +439 -413
- package/client/esm/ui/utils/ansi/regx.js +8 -8
- package/client/esm/ui/utils/ansi/utils.js +14 -14
- package/client/esm/ui/utils/index.js +99 -99
- package/package.json +11 -11
- package/server/cjs/dev.cjs +30 -36
- package/server/cjs/hot.cjs +174 -177
- package/server/cjs/index.cjs +16 -17
- package/server/esm/dev.js +28 -32
- package/server/esm/hot.js +171 -172
- package/server/esm/index.js +14 -13
- package/types/client/client.d.ts +7 -7
- package/types/client/events.d.ts +10 -10
- package/types/client/message.d.ts +25 -25
- package/types/client/ui/overlay.d.ts +12 -12
- package/types/client/ui/progress.d.ts +8 -8
- package/types/client/ui/utils/ansi/enum.d.ts +7 -7
- package/types/client/ui/utils/ansi/index.d.ts +11 -11
- package/types/client/ui/utils/ansi/interface.d.ts +46 -42
- package/types/server/dev.d.ts +4 -4
- package/types/server/hot.d.ts +5 -5
- package/types/server/index.d.ts +2 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
* @package webpack-dev-service
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @version 0.5.4
|
|
5
|
+
* @author nuintun <nuintun@qq.com>
|
|
6
|
+
* @description A koa 2 middleware for webpack development and hot reloading.
|
|
7
|
+
* @see https://github.com/nuintun/webpack-dev-service#readme
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
12
|
const index = require('./utils/index.cjs');
|
|
@@ -173,64 +173,65 @@ const HTML = `
|
|
|
173
173
|
</aside>
|
|
174
174
|
`;
|
|
175
175
|
class Overlay {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
176
|
+
hidden = true;
|
|
177
|
+
name;
|
|
178
|
+
close;
|
|
179
|
+
aside;
|
|
180
|
+
errorsList;
|
|
181
|
+
errorsTitle;
|
|
182
|
+
warningsList;
|
|
183
|
+
warningsTitle;
|
|
184
|
+
constructor(name) {
|
|
185
|
+
index.injectCSS(CSS);
|
|
186
|
+
[this.aside] = index.appendHTML(HTML);
|
|
187
|
+
this.name = this.aside.querySelector(`.${OVERLAY}-name`);
|
|
188
|
+
this.close = this.aside.querySelector(`.${OVERLAY}-close`);
|
|
189
|
+
this.errorsList = this.aside.querySelector(`.${OVERLAY}-errors`);
|
|
190
|
+
this.warningsList = this.aside.querySelector(`.${OVERLAY}-warnings`);
|
|
191
|
+
this.errorsTitle = this.aside.querySelector(`.${OVERLAY}-errors-title`);
|
|
192
|
+
this.warningsTitle = this.aside.querySelector(`.${OVERLAY}-warnings-title`);
|
|
193
|
+
this.name.innerHTML = `⭕ ${name || DEFAULT_NAME}`;
|
|
194
|
+
this.close.addEventListener('click', () => {
|
|
195
|
+
this.hide();
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
setProblems(type, problems) {
|
|
199
|
+
const count = problems.length;
|
|
200
|
+
const hidden = `${OVERLAY}-hidden`;
|
|
201
|
+
const problemMaps = {
|
|
202
|
+
errors: ['Error', this.errorsTitle, this.errorsList],
|
|
203
|
+
warnings: ['Warning', this.warningsTitle, this.warningsList]
|
|
204
|
+
};
|
|
205
|
+
const [name, problemTitle, problemList] = problemMaps[type];
|
|
206
|
+
if (count > 0) {
|
|
207
|
+
let html = '';
|
|
208
|
+
problemTitle.innerText = `${count} ${name}(s)`;
|
|
209
|
+
for (const { moduleName = 'unknown', message } of problems) {
|
|
210
|
+
const src = index.ansiToHTML(moduleName);
|
|
211
|
+
const details = index.ansiToHTML(message);
|
|
212
|
+
html += `<div><em>${name}</em> in ${src}<div>${details}</div></div>`;
|
|
213
|
+
}
|
|
214
|
+
problemList.innerHTML = html;
|
|
215
|
+
problemList.classList.remove(hidden);
|
|
216
|
+
problemTitle.classList.remove(hidden);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
problemList.classList.add(hidden);
|
|
220
|
+
problemTitle.classList.add(hidden);
|
|
221
|
+
}
|
|
220
222
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
223
|
+
show() {
|
|
224
|
+
if (this.hidden) {
|
|
225
|
+
this.hidden = false;
|
|
226
|
+
this.aside.classList.add(`${OVERLAY}-show`);
|
|
227
|
+
}
|
|
226
228
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
229
|
+
hide() {
|
|
230
|
+
if (!this.hidden) {
|
|
231
|
+
this.hidden = true;
|
|
232
|
+
this.aside.classList.remove(`${OVERLAY}-show`);
|
|
233
|
+
}
|
|
232
234
|
}
|
|
233
|
-
}
|
|
234
235
|
}
|
|
235
236
|
|
|
236
237
|
module.exports = Overlay;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
* @package webpack-dev-service
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @version 0.5.4
|
|
5
|
+
* @author nuintun <nuintun@qq.com>
|
|
6
|
+
* @description A koa 2 middleware for webpack development and hot reloading.
|
|
7
|
+
* @see https://github.com/nuintun/webpack-dev-service#readme
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
12
|
const index = require('./utils/index.cjs');
|
|
@@ -60,35 +60,35 @@ const HTML = `
|
|
|
60
60
|
</svg>
|
|
61
61
|
`;
|
|
62
62
|
class Progress {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
63
|
+
timer;
|
|
64
|
+
hidden = true;
|
|
65
|
+
svg;
|
|
66
|
+
track;
|
|
67
|
+
constructor() {
|
|
68
|
+
index.injectCSS(CSS);
|
|
69
|
+
[this.svg] = index.appendHTML(HTML);
|
|
70
|
+
this.track = this.svg.querySelector(`.${PROGRESS}-track`);
|
|
71
|
+
}
|
|
72
|
+
update(value) {
|
|
73
|
+
value = Math.max(0, Math.min(100, value));
|
|
74
|
+
this.track.style.strokeDashoffset = (((100 - value) / 100) * PERIMETER).toString();
|
|
75
|
+
}
|
|
76
|
+
show() {
|
|
77
|
+
if (this.hidden) {
|
|
78
|
+
this.hidden = false;
|
|
79
|
+
clearTimeout(this.timer);
|
|
80
|
+
this.svg.classList.add(`${PROGRESS}-show`);
|
|
81
|
+
}
|
|
81
82
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
hide() {
|
|
84
|
+
if (!this.hidden) {
|
|
85
|
+
this.hidden = true;
|
|
86
|
+
this.timer = self.setTimeout(() => {
|
|
87
|
+
this.update(0);
|
|
88
|
+
this.svg.classList.remove(`${PROGRESS}-show`);
|
|
89
|
+
}, 300);
|
|
90
|
+
}
|
|
90
91
|
}
|
|
91
|
-
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
module.exports = Progress;
|