@mogzol/webpackbar 7.1.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/LICENSE +21 -0
- package/README.md +223 -0
- package/dist/rspack.cjs +39 -0
- package/dist/rspack.d.cts +12 -0
- package/dist/rspack.d.mts +12 -0
- package/dist/rspack.d.ts +12 -0
- package/dist/rspack.mjs +33 -0
- package/dist/shared/webpackbar.07fec22c.mjs +1815 -0
- package/dist/shared/webpackbar.28dc8790.d.cts +124 -0
- package/dist/shared/webpackbar.28dc8790.d.mts +124 -0
- package/dist/shared/webpackbar.28dc8790.d.ts +124 -0
- package/dist/shared/webpackbar.67d03d0b.cjs +1825 -0
- package/dist/webpack.cjs +42 -0
- package/dist/webpack.d.cts +2 -0
- package/dist/webpack.d.mts +2 -0
- package/dist/webpack.d.ts +2 -0
- package/dist/webpack.mjs +36 -0
- package/package.json +93 -0
|
@@ -0,0 +1,1815 @@
|
|
|
1
|
+
import { isMinimal } from 'std-env';
|
|
2
|
+
import prettyTime from 'pretty-time';
|
|
3
|
+
import path, { sep, delimiter } from 'node:path';
|
|
4
|
+
import c, { blue, grey, bold } from 'ansis';
|
|
5
|
+
import { consola as consola$1 } from 'consola';
|
|
6
|
+
import process$1 from 'node:process';
|
|
7
|
+
import stringWidth from 'string-width';
|
|
8
|
+
|
|
9
|
+
function first(arr) {
|
|
10
|
+
return arr[0];
|
|
11
|
+
}
|
|
12
|
+
function last(arr) {
|
|
13
|
+
return arr.length > 0 ? arr[arr.length - 1] : null;
|
|
14
|
+
}
|
|
15
|
+
function startCase(str) {
|
|
16
|
+
return str[0].toUpperCase() + str.slice(1);
|
|
17
|
+
}
|
|
18
|
+
function firstMatch(regex, str) {
|
|
19
|
+
const m = regex.exec(str);
|
|
20
|
+
return m ? m[0] : null;
|
|
21
|
+
}
|
|
22
|
+
function hasValue(s) {
|
|
23
|
+
return s && s.length > 0;
|
|
24
|
+
}
|
|
25
|
+
function removeAfter(delimiter, str) {
|
|
26
|
+
return first(str.split(delimiter)) || "";
|
|
27
|
+
}
|
|
28
|
+
function removeBefore(delimiter, str) {
|
|
29
|
+
return last(str.split(delimiter)) || "";
|
|
30
|
+
}
|
|
31
|
+
function range(len) {
|
|
32
|
+
const arr = [];
|
|
33
|
+
for (let i = 0; i < len; i++) {
|
|
34
|
+
arr.push(i);
|
|
35
|
+
}
|
|
36
|
+
return arr;
|
|
37
|
+
}
|
|
38
|
+
function shortenPath(path = "") {
|
|
39
|
+
const cwd = process.cwd() + sep;
|
|
40
|
+
return String(path).replace(cwd, "");
|
|
41
|
+
}
|
|
42
|
+
function objectValues(obj) {
|
|
43
|
+
return Object.keys(obj).map((key) => obj[key]);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// To do: next major: remove.
|
|
47
|
+
/**
|
|
48
|
+
* @typedef {Options} MarkdownTableOptions
|
|
49
|
+
* Configuration.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @typedef Options
|
|
54
|
+
* Configuration.
|
|
55
|
+
* @property {boolean | null | undefined} [alignDelimiters=true]
|
|
56
|
+
* Whether to align the delimiters (default: `true`);
|
|
57
|
+
* they are aligned by default:
|
|
58
|
+
*
|
|
59
|
+
* ```markdown
|
|
60
|
+
* | Alpha | B |
|
|
61
|
+
* | ----- | ----- |
|
|
62
|
+
* | C | Delta |
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* Pass `false` to make them staggered:
|
|
66
|
+
*
|
|
67
|
+
* ```markdown
|
|
68
|
+
* | Alpha | B |
|
|
69
|
+
* | - | - |
|
|
70
|
+
* | C | Delta |
|
|
71
|
+
* ```
|
|
72
|
+
* @property {ReadonlyArray<string | null | undefined> | string | null | undefined} [align]
|
|
73
|
+
* How to align columns (default: `''`);
|
|
74
|
+
* one style for all columns or styles for their respective columns;
|
|
75
|
+
* each style is either `'l'` (left), `'r'` (right), or `'c'` (center);
|
|
76
|
+
* other values are treated as `''`, which doesn’t place the colon in the
|
|
77
|
+
* alignment row but does align left;
|
|
78
|
+
* *only the lowercased first character is used, so `Right` is fine.*
|
|
79
|
+
* @property {boolean | null | undefined} [delimiterEnd=true]
|
|
80
|
+
* Whether to end each row with the delimiter (default: `true`).
|
|
81
|
+
*
|
|
82
|
+
* > 👉 **Note**: please don’t use this: it could create fragile structures
|
|
83
|
+
* > that aren’t understandable to some markdown parsers.
|
|
84
|
+
*
|
|
85
|
+
* When `true`, there are ending delimiters:
|
|
86
|
+
*
|
|
87
|
+
* ```markdown
|
|
88
|
+
* | Alpha | B |
|
|
89
|
+
* | ----- | ----- |
|
|
90
|
+
* | C | Delta |
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* When `false`, there are no ending delimiters:
|
|
94
|
+
*
|
|
95
|
+
* ```markdown
|
|
96
|
+
* | Alpha | B
|
|
97
|
+
* | ----- | -----
|
|
98
|
+
* | C | Delta
|
|
99
|
+
* ```
|
|
100
|
+
* @property {boolean | null | undefined} [delimiterStart=true]
|
|
101
|
+
* Whether to begin each row with the delimiter (default: `true`).
|
|
102
|
+
*
|
|
103
|
+
* > 👉 **Note**: please don’t use this: it could create fragile structures
|
|
104
|
+
* > that aren’t understandable to some markdown parsers.
|
|
105
|
+
*
|
|
106
|
+
* When `true`, there are starting delimiters:
|
|
107
|
+
*
|
|
108
|
+
* ```markdown
|
|
109
|
+
* | Alpha | B |
|
|
110
|
+
* | ----- | ----- |
|
|
111
|
+
* | C | Delta |
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* When `false`, there are no starting delimiters:
|
|
115
|
+
*
|
|
116
|
+
* ```markdown
|
|
117
|
+
* Alpha | B |
|
|
118
|
+
* ----- | ----- |
|
|
119
|
+
* C | Delta |
|
|
120
|
+
* ```
|
|
121
|
+
* @property {boolean | null | undefined} [padding=true]
|
|
122
|
+
* Whether to add a space of padding between delimiters and cells
|
|
123
|
+
* (default: `true`).
|
|
124
|
+
*
|
|
125
|
+
* When `true`, there is padding:
|
|
126
|
+
*
|
|
127
|
+
* ```markdown
|
|
128
|
+
* | Alpha | B |
|
|
129
|
+
* | ----- | ----- |
|
|
130
|
+
* | C | Delta |
|
|
131
|
+
* ```
|
|
132
|
+
*
|
|
133
|
+
* When `false`, there is no padding:
|
|
134
|
+
*
|
|
135
|
+
* ```markdown
|
|
136
|
+
* |Alpha|B |
|
|
137
|
+
* |-----|-----|
|
|
138
|
+
* |C |Delta|
|
|
139
|
+
* ```
|
|
140
|
+
* @property {((value: string) => number) | null | undefined} [stringLength]
|
|
141
|
+
* Function to detect the length of table cell content (optional);
|
|
142
|
+
* this is used when aligning the delimiters (`|`) between table cells;
|
|
143
|
+
* full-width characters and emoji mess up delimiter alignment when viewing
|
|
144
|
+
* the markdown source;
|
|
145
|
+
* to fix this, you can pass this function,
|
|
146
|
+
* which receives the cell content and returns its “visible” size;
|
|
147
|
+
* note that what is and isn’t visible depends on where the text is displayed.
|
|
148
|
+
*
|
|
149
|
+
* Without such a function, the following:
|
|
150
|
+
*
|
|
151
|
+
* ```js
|
|
152
|
+
* markdownTable([
|
|
153
|
+
* ['Alpha', 'Bravo'],
|
|
154
|
+
* ['中文', 'Charlie'],
|
|
155
|
+
* ['👩❤️👩', 'Delta']
|
|
156
|
+
* ])
|
|
157
|
+
* ```
|
|
158
|
+
*
|
|
159
|
+
* Yields:
|
|
160
|
+
*
|
|
161
|
+
* ```markdown
|
|
162
|
+
* | Alpha | Bravo |
|
|
163
|
+
* | - | - |
|
|
164
|
+
* | 中文 | Charlie |
|
|
165
|
+
* | 👩❤️👩 | Delta |
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* With [`string-width`](https://github.com/sindresorhus/string-width):
|
|
169
|
+
*
|
|
170
|
+
* ```js
|
|
171
|
+
* import stringWidth from 'string-width'
|
|
172
|
+
*
|
|
173
|
+
* markdownTable(
|
|
174
|
+
* [
|
|
175
|
+
* ['Alpha', 'Bravo'],
|
|
176
|
+
* ['中文', 'Charlie'],
|
|
177
|
+
* ['👩❤️👩', 'Delta']
|
|
178
|
+
* ],
|
|
179
|
+
* {stringLength: stringWidth}
|
|
180
|
+
* )
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* Yields:
|
|
184
|
+
*
|
|
185
|
+
* ```markdown
|
|
186
|
+
* | Alpha | Bravo |
|
|
187
|
+
* | ----- | ------- |
|
|
188
|
+
* | 中文 | Charlie |
|
|
189
|
+
* | 👩❤️👩 | Delta |
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* @param {string} value
|
|
195
|
+
* Cell value.
|
|
196
|
+
* @returns {number}
|
|
197
|
+
* Cell size.
|
|
198
|
+
*/
|
|
199
|
+
function defaultStringLength(value) {
|
|
200
|
+
return value.length
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Generate a markdown
|
|
205
|
+
* ([GFM](https://docs.github.com/en/github/writing-on-github/working-with-advanced-formatting/organizing-information-with-tables))
|
|
206
|
+
* table.
|
|
207
|
+
*
|
|
208
|
+
* @param {ReadonlyArray<ReadonlyArray<string | null | undefined>>} table
|
|
209
|
+
* Table data (matrix of strings).
|
|
210
|
+
* @param {Readonly<Options> | null | undefined} [options]
|
|
211
|
+
* Configuration (optional).
|
|
212
|
+
* @returns {string}
|
|
213
|
+
* Result.
|
|
214
|
+
*/
|
|
215
|
+
function markdownTable(table, options) {
|
|
216
|
+
const settings = options || {};
|
|
217
|
+
// To do: next major: change to spread.
|
|
218
|
+
const align = (settings.align || []).concat();
|
|
219
|
+
const stringLength = settings.stringLength || defaultStringLength;
|
|
220
|
+
/** @type {Array<number>} Character codes as symbols for alignment per column. */
|
|
221
|
+
const alignments = [];
|
|
222
|
+
/** @type {Array<Array<string>>} Cells per row. */
|
|
223
|
+
const cellMatrix = [];
|
|
224
|
+
/** @type {Array<Array<number>>} Sizes of each cell per row. */
|
|
225
|
+
const sizeMatrix = [];
|
|
226
|
+
/** @type {Array<number>} */
|
|
227
|
+
const longestCellByColumn = [];
|
|
228
|
+
let mostCellsPerRow = 0;
|
|
229
|
+
let rowIndex = -1;
|
|
230
|
+
|
|
231
|
+
// This is a superfluous loop if we don’t align delimiters, but otherwise we’d
|
|
232
|
+
// do superfluous work when aligning, so optimize for aligning.
|
|
233
|
+
while (++rowIndex < table.length) {
|
|
234
|
+
/** @type {Array<string>} */
|
|
235
|
+
const row = [];
|
|
236
|
+
/** @type {Array<number>} */
|
|
237
|
+
const sizes = [];
|
|
238
|
+
let columnIndex = -1;
|
|
239
|
+
|
|
240
|
+
if (table[rowIndex].length > mostCellsPerRow) {
|
|
241
|
+
mostCellsPerRow = table[rowIndex].length;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
while (++columnIndex < table[rowIndex].length) {
|
|
245
|
+
const cell = serialize(table[rowIndex][columnIndex]);
|
|
246
|
+
|
|
247
|
+
if (settings.alignDelimiters !== false) {
|
|
248
|
+
const size = stringLength(cell);
|
|
249
|
+
sizes[columnIndex] = size;
|
|
250
|
+
|
|
251
|
+
if (
|
|
252
|
+
longestCellByColumn[columnIndex] === undefined ||
|
|
253
|
+
size > longestCellByColumn[columnIndex]
|
|
254
|
+
) {
|
|
255
|
+
longestCellByColumn[columnIndex] = size;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
row.push(cell);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
cellMatrix[rowIndex] = row;
|
|
263
|
+
sizeMatrix[rowIndex] = sizes;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Figure out which alignments to use.
|
|
267
|
+
let columnIndex = -1;
|
|
268
|
+
|
|
269
|
+
if (typeof align === 'object' && 'length' in align) {
|
|
270
|
+
while (++columnIndex < mostCellsPerRow) {
|
|
271
|
+
alignments[columnIndex] = toAlignment(align[columnIndex]);
|
|
272
|
+
}
|
|
273
|
+
} else {
|
|
274
|
+
const code = toAlignment(align);
|
|
275
|
+
|
|
276
|
+
while (++columnIndex < mostCellsPerRow) {
|
|
277
|
+
alignments[columnIndex] = code;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Inject the alignment row.
|
|
282
|
+
columnIndex = -1;
|
|
283
|
+
/** @type {Array<string>} */
|
|
284
|
+
const row = [];
|
|
285
|
+
/** @type {Array<number>} */
|
|
286
|
+
const sizes = [];
|
|
287
|
+
|
|
288
|
+
while (++columnIndex < mostCellsPerRow) {
|
|
289
|
+
const code = alignments[columnIndex];
|
|
290
|
+
let before = '';
|
|
291
|
+
let after = '';
|
|
292
|
+
|
|
293
|
+
if (code === 99 /* `c` */) {
|
|
294
|
+
before = ':';
|
|
295
|
+
after = ':';
|
|
296
|
+
} else if (code === 108 /* `l` */) {
|
|
297
|
+
before = ':';
|
|
298
|
+
} else if (code === 114 /* `r` */) {
|
|
299
|
+
after = ':';
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// There *must* be at least one hyphen-minus in each alignment cell.
|
|
303
|
+
let size =
|
|
304
|
+
settings.alignDelimiters === false
|
|
305
|
+
? 1
|
|
306
|
+
: Math.max(
|
|
307
|
+
1,
|
|
308
|
+
longestCellByColumn[columnIndex] - before.length - after.length
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
const cell = before + '-'.repeat(size) + after;
|
|
312
|
+
|
|
313
|
+
if (settings.alignDelimiters !== false) {
|
|
314
|
+
size = before.length + size + after.length;
|
|
315
|
+
|
|
316
|
+
if (size > longestCellByColumn[columnIndex]) {
|
|
317
|
+
longestCellByColumn[columnIndex] = size;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
sizes[columnIndex] = size;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
row[columnIndex] = cell;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Inject the alignment row.
|
|
327
|
+
cellMatrix.splice(1, 0, row);
|
|
328
|
+
sizeMatrix.splice(1, 0, sizes);
|
|
329
|
+
|
|
330
|
+
rowIndex = -1;
|
|
331
|
+
/** @type {Array<string>} */
|
|
332
|
+
const lines = [];
|
|
333
|
+
|
|
334
|
+
while (++rowIndex < cellMatrix.length) {
|
|
335
|
+
const row = cellMatrix[rowIndex];
|
|
336
|
+
const sizes = sizeMatrix[rowIndex];
|
|
337
|
+
columnIndex = -1;
|
|
338
|
+
/** @type {Array<string>} */
|
|
339
|
+
const line = [];
|
|
340
|
+
|
|
341
|
+
while (++columnIndex < mostCellsPerRow) {
|
|
342
|
+
const cell = row[columnIndex] || '';
|
|
343
|
+
let before = '';
|
|
344
|
+
let after = '';
|
|
345
|
+
|
|
346
|
+
if (settings.alignDelimiters !== false) {
|
|
347
|
+
const size =
|
|
348
|
+
longestCellByColumn[columnIndex] - (sizes[columnIndex] || 0);
|
|
349
|
+
const code = alignments[columnIndex];
|
|
350
|
+
|
|
351
|
+
if (code === 114 /* `r` */) {
|
|
352
|
+
before = ' '.repeat(size);
|
|
353
|
+
} else if (code === 99 /* `c` */) {
|
|
354
|
+
if (size % 2) {
|
|
355
|
+
before = ' '.repeat(size / 2 + 0.5);
|
|
356
|
+
after = ' '.repeat(size / 2 - 0.5);
|
|
357
|
+
} else {
|
|
358
|
+
before = ' '.repeat(size / 2);
|
|
359
|
+
after = before;
|
|
360
|
+
}
|
|
361
|
+
} else {
|
|
362
|
+
after = ' '.repeat(size);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if (settings.delimiterStart !== false && !columnIndex) {
|
|
367
|
+
line.push('|');
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (
|
|
371
|
+
settings.padding !== false &&
|
|
372
|
+
// Don’t add the opening space if we’re not aligning and the cell is
|
|
373
|
+
// empty: there will be a closing space.
|
|
374
|
+
!(settings.alignDelimiters === false && cell === '') &&
|
|
375
|
+
(settings.delimiterStart !== false || columnIndex)
|
|
376
|
+
) {
|
|
377
|
+
line.push(' ');
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
if (settings.alignDelimiters !== false) {
|
|
381
|
+
line.push(before);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
line.push(cell);
|
|
385
|
+
|
|
386
|
+
if (settings.alignDelimiters !== false) {
|
|
387
|
+
line.push(after);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
if (settings.padding !== false) {
|
|
391
|
+
line.push(' ');
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
if (
|
|
395
|
+
settings.delimiterEnd !== false ||
|
|
396
|
+
columnIndex !== mostCellsPerRow - 1
|
|
397
|
+
) {
|
|
398
|
+
line.push('|');
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
lines.push(
|
|
403
|
+
settings.delimiterEnd === false
|
|
404
|
+
? line.join('').replace(/ +$/, '')
|
|
405
|
+
: line.join('')
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
return lines.join('\n')
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* @param {string | null | undefined} [value]
|
|
414
|
+
* Value to serialize.
|
|
415
|
+
* @returns {string}
|
|
416
|
+
* Result.
|
|
417
|
+
*/
|
|
418
|
+
function serialize(value) {
|
|
419
|
+
return value === null || value === undefined ? '' : String(value)
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* @param {string | null | undefined} value
|
|
424
|
+
* Value.
|
|
425
|
+
* @returns {number}
|
|
426
|
+
* Alignment.
|
|
427
|
+
*/
|
|
428
|
+
function toAlignment(value) {
|
|
429
|
+
const code = typeof value === 'string' ? value.codePointAt(0) : 0;
|
|
430
|
+
|
|
431
|
+
return code === 67 /* `C` */ || code === 99 /* `c` */
|
|
432
|
+
? 99 /* `c` */
|
|
433
|
+
: code === 76 /* `L` */ || code === 108 /* `l` */
|
|
434
|
+
? 108 /* `l` */
|
|
435
|
+
: code === 82 /* `R` */ || code === 114 /* `r` */
|
|
436
|
+
? 114 /* `r` */
|
|
437
|
+
: 0
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function isUnicodeSupported() {
|
|
441
|
+
const {env} = process$1;
|
|
442
|
+
const {TERM, TERM_PROGRAM} = env;
|
|
443
|
+
|
|
444
|
+
if (process$1.platform !== 'win32') {
|
|
445
|
+
return TERM !== 'linux'; // Linux console (kernel)
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
return Boolean(env.WT_SESSION) // Windows Terminal
|
|
449
|
+
|| Boolean(env.TERMINUS_SUBLIME) // Terminus (<0.2.27)
|
|
450
|
+
|| env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
|
|
451
|
+
|| TERM_PROGRAM === 'Terminus-Sublime'
|
|
452
|
+
|| TERM_PROGRAM === 'vscode'
|
|
453
|
+
|| TERM === 'xterm-256color'
|
|
454
|
+
|| TERM === 'alacritty'
|
|
455
|
+
|| TERM === 'rxvt-unicode'
|
|
456
|
+
|| TERM === 'rxvt-unicode-256color'
|
|
457
|
+
|| env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
const common = {
|
|
461
|
+
circleQuestionMark: '(?)',
|
|
462
|
+
questionMarkPrefix: '(?)',
|
|
463
|
+
square: '█',
|
|
464
|
+
squareDarkShade: '▓',
|
|
465
|
+
squareMediumShade: '▒',
|
|
466
|
+
squareLightShade: '░',
|
|
467
|
+
squareTop: '▀',
|
|
468
|
+
squareBottom: '▄',
|
|
469
|
+
squareLeft: '▌',
|
|
470
|
+
squareRight: '▐',
|
|
471
|
+
squareCenter: '■',
|
|
472
|
+
bullet: '●',
|
|
473
|
+
dot: '․',
|
|
474
|
+
ellipsis: '…',
|
|
475
|
+
pointerSmall: '›',
|
|
476
|
+
triangleUp: '▲',
|
|
477
|
+
triangleUpSmall: '▴',
|
|
478
|
+
triangleDown: '▼',
|
|
479
|
+
triangleDownSmall: '▾',
|
|
480
|
+
triangleLeftSmall: '◂',
|
|
481
|
+
triangleRightSmall: '▸',
|
|
482
|
+
home: '⌂',
|
|
483
|
+
heart: '♥',
|
|
484
|
+
musicNote: '♪',
|
|
485
|
+
musicNoteBeamed: '♫',
|
|
486
|
+
arrowUp: '↑',
|
|
487
|
+
arrowDown: '↓',
|
|
488
|
+
arrowLeft: '←',
|
|
489
|
+
arrowRight: '→',
|
|
490
|
+
arrowLeftRight: '↔',
|
|
491
|
+
arrowUpDown: '↕',
|
|
492
|
+
almostEqual: '≈',
|
|
493
|
+
notEqual: '≠',
|
|
494
|
+
lessOrEqual: '≤',
|
|
495
|
+
greaterOrEqual: '≥',
|
|
496
|
+
identical: '≡',
|
|
497
|
+
infinity: '∞',
|
|
498
|
+
subscriptZero: '₀',
|
|
499
|
+
subscriptOne: '₁',
|
|
500
|
+
subscriptTwo: '₂',
|
|
501
|
+
subscriptThree: '₃',
|
|
502
|
+
subscriptFour: '₄',
|
|
503
|
+
subscriptFive: '₅',
|
|
504
|
+
subscriptSix: '₆',
|
|
505
|
+
subscriptSeven: '₇',
|
|
506
|
+
subscriptEight: '₈',
|
|
507
|
+
subscriptNine: '₉',
|
|
508
|
+
oneHalf: '½',
|
|
509
|
+
oneThird: '⅓',
|
|
510
|
+
oneQuarter: '¼',
|
|
511
|
+
oneFifth: '⅕',
|
|
512
|
+
oneSixth: '⅙',
|
|
513
|
+
oneEighth: '⅛',
|
|
514
|
+
twoThirds: '⅔',
|
|
515
|
+
twoFifths: '⅖',
|
|
516
|
+
threeQuarters: '¾',
|
|
517
|
+
threeFifths: '⅗',
|
|
518
|
+
threeEighths: '⅜',
|
|
519
|
+
fourFifths: '⅘',
|
|
520
|
+
fiveSixths: '⅚',
|
|
521
|
+
fiveEighths: '⅝',
|
|
522
|
+
sevenEighths: '⅞',
|
|
523
|
+
line: '─',
|
|
524
|
+
lineBold: '━',
|
|
525
|
+
lineDouble: '═',
|
|
526
|
+
lineDashed0: '┄',
|
|
527
|
+
lineDashed1: '┅',
|
|
528
|
+
lineDashed2: '┈',
|
|
529
|
+
lineDashed3: '┉',
|
|
530
|
+
lineDashed4: '╌',
|
|
531
|
+
lineDashed5: '╍',
|
|
532
|
+
lineDashed6: '╴',
|
|
533
|
+
lineDashed7: '╶',
|
|
534
|
+
lineDashed8: '╸',
|
|
535
|
+
lineDashed9: '╺',
|
|
536
|
+
lineDashed10: '╼',
|
|
537
|
+
lineDashed11: '╾',
|
|
538
|
+
lineDashed12: '−',
|
|
539
|
+
lineDashed13: '–',
|
|
540
|
+
lineDashed14: '‐',
|
|
541
|
+
lineDashed15: '⁃',
|
|
542
|
+
lineVertical: '│',
|
|
543
|
+
lineVerticalBold: '┃',
|
|
544
|
+
lineVerticalDouble: '║',
|
|
545
|
+
lineVerticalDashed0: '┆',
|
|
546
|
+
lineVerticalDashed1: '┇',
|
|
547
|
+
lineVerticalDashed2: '┊',
|
|
548
|
+
lineVerticalDashed3: '┋',
|
|
549
|
+
lineVerticalDashed4: '╎',
|
|
550
|
+
lineVerticalDashed5: '╏',
|
|
551
|
+
lineVerticalDashed6: '╵',
|
|
552
|
+
lineVerticalDashed7: '╷',
|
|
553
|
+
lineVerticalDashed8: '╹',
|
|
554
|
+
lineVerticalDashed9: '╻',
|
|
555
|
+
lineVerticalDashed10: '╽',
|
|
556
|
+
lineVerticalDashed11: '╿',
|
|
557
|
+
lineDownLeft: '┐',
|
|
558
|
+
lineDownLeftArc: '╮',
|
|
559
|
+
lineDownBoldLeftBold: '┓',
|
|
560
|
+
lineDownBoldLeft: '┒',
|
|
561
|
+
lineDownLeftBold: '┑',
|
|
562
|
+
lineDownDoubleLeftDouble: '╗',
|
|
563
|
+
lineDownDoubleLeft: '╖',
|
|
564
|
+
lineDownLeftDouble: '╕',
|
|
565
|
+
lineDownRight: '┌',
|
|
566
|
+
lineDownRightArc: '╭',
|
|
567
|
+
lineDownBoldRightBold: '┏',
|
|
568
|
+
lineDownBoldRight: '┎',
|
|
569
|
+
lineDownRightBold: '┍',
|
|
570
|
+
lineDownDoubleRightDouble: '╔',
|
|
571
|
+
lineDownDoubleRight: '╓',
|
|
572
|
+
lineDownRightDouble: '╒',
|
|
573
|
+
lineUpLeft: '┘',
|
|
574
|
+
lineUpLeftArc: '╯',
|
|
575
|
+
lineUpBoldLeftBold: '┛',
|
|
576
|
+
lineUpBoldLeft: '┚',
|
|
577
|
+
lineUpLeftBold: '┙',
|
|
578
|
+
lineUpDoubleLeftDouble: '╝',
|
|
579
|
+
lineUpDoubleLeft: '╜',
|
|
580
|
+
lineUpLeftDouble: '╛',
|
|
581
|
+
lineUpRight: '└',
|
|
582
|
+
lineUpRightArc: '╰',
|
|
583
|
+
lineUpBoldRightBold: '┗',
|
|
584
|
+
lineUpBoldRight: '┖',
|
|
585
|
+
lineUpRightBold: '┕',
|
|
586
|
+
lineUpDoubleRightDouble: '╚',
|
|
587
|
+
lineUpDoubleRight: '╙',
|
|
588
|
+
lineUpRightDouble: '╘',
|
|
589
|
+
lineUpDownLeft: '┤',
|
|
590
|
+
lineUpBoldDownBoldLeftBold: '┫',
|
|
591
|
+
lineUpBoldDownBoldLeft: '┨',
|
|
592
|
+
lineUpDownLeftBold: '┥',
|
|
593
|
+
lineUpBoldDownLeftBold: '┩',
|
|
594
|
+
lineUpDownBoldLeftBold: '┪',
|
|
595
|
+
lineUpDownBoldLeft: '┧',
|
|
596
|
+
lineUpBoldDownLeft: '┦',
|
|
597
|
+
lineUpDoubleDownDoubleLeftDouble: '╣',
|
|
598
|
+
lineUpDoubleDownDoubleLeft: '╢',
|
|
599
|
+
lineUpDownLeftDouble: '╡',
|
|
600
|
+
lineUpDownRight: '├',
|
|
601
|
+
lineUpBoldDownBoldRightBold: '┣',
|
|
602
|
+
lineUpBoldDownBoldRight: '┠',
|
|
603
|
+
lineUpDownRightBold: '┝',
|
|
604
|
+
lineUpBoldDownRightBold: '┡',
|
|
605
|
+
lineUpDownBoldRightBold: '┢',
|
|
606
|
+
lineUpDownBoldRight: '┟',
|
|
607
|
+
lineUpBoldDownRight: '┞',
|
|
608
|
+
lineUpDoubleDownDoubleRightDouble: '╠',
|
|
609
|
+
lineUpDoubleDownDoubleRight: '╟',
|
|
610
|
+
lineUpDownRightDouble: '╞',
|
|
611
|
+
lineDownLeftRight: '┬',
|
|
612
|
+
lineDownBoldLeftBoldRightBold: '┳',
|
|
613
|
+
lineDownLeftBoldRightBold: '┯',
|
|
614
|
+
lineDownBoldLeftRight: '┰',
|
|
615
|
+
lineDownBoldLeftBoldRight: '┱',
|
|
616
|
+
lineDownBoldLeftRightBold: '┲',
|
|
617
|
+
lineDownLeftRightBold: '┮',
|
|
618
|
+
lineDownLeftBoldRight: '┭',
|
|
619
|
+
lineDownDoubleLeftDoubleRightDouble: '╦',
|
|
620
|
+
lineDownDoubleLeftRight: '╥',
|
|
621
|
+
lineDownLeftDoubleRightDouble: '╤',
|
|
622
|
+
lineUpLeftRight: '┴',
|
|
623
|
+
lineUpBoldLeftBoldRightBold: '┻',
|
|
624
|
+
lineUpLeftBoldRightBold: '┷',
|
|
625
|
+
lineUpBoldLeftRight: '┸',
|
|
626
|
+
lineUpBoldLeftBoldRight: '┹',
|
|
627
|
+
lineUpBoldLeftRightBold: '┺',
|
|
628
|
+
lineUpLeftRightBold: '┶',
|
|
629
|
+
lineUpLeftBoldRight: '┵',
|
|
630
|
+
lineUpDoubleLeftDoubleRightDouble: '╩',
|
|
631
|
+
lineUpDoubleLeftRight: '╨',
|
|
632
|
+
lineUpLeftDoubleRightDouble: '╧',
|
|
633
|
+
lineUpDownLeftRight: '┼',
|
|
634
|
+
lineUpBoldDownBoldLeftBoldRightBold: '╋',
|
|
635
|
+
lineUpDownBoldLeftBoldRightBold: '╈',
|
|
636
|
+
lineUpBoldDownLeftBoldRightBold: '╇',
|
|
637
|
+
lineUpBoldDownBoldLeftRightBold: '╊',
|
|
638
|
+
lineUpBoldDownBoldLeftBoldRight: '╉',
|
|
639
|
+
lineUpBoldDownLeftRight: '╀',
|
|
640
|
+
lineUpDownBoldLeftRight: '╁',
|
|
641
|
+
lineUpDownLeftBoldRight: '┽',
|
|
642
|
+
lineUpDownLeftRightBold: '┾',
|
|
643
|
+
lineUpBoldDownBoldLeftRight: '╂',
|
|
644
|
+
lineUpDownLeftBoldRightBold: '┿',
|
|
645
|
+
lineUpBoldDownLeftBoldRight: '╃',
|
|
646
|
+
lineUpBoldDownLeftRightBold: '╄',
|
|
647
|
+
lineUpDownBoldLeftBoldRight: '╅',
|
|
648
|
+
lineUpDownBoldLeftRightBold: '╆',
|
|
649
|
+
lineUpDoubleDownDoubleLeftDoubleRightDouble: '╬',
|
|
650
|
+
lineUpDoubleDownDoubleLeftRight: '╫',
|
|
651
|
+
lineUpDownLeftDoubleRightDouble: '╪',
|
|
652
|
+
lineCross: '╳',
|
|
653
|
+
lineBackslash: '╲',
|
|
654
|
+
lineSlash: '╱',
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
const specialMainSymbols = {
|
|
658
|
+
tick: '✔',
|
|
659
|
+
info: 'ℹ',
|
|
660
|
+
warning: '⚠',
|
|
661
|
+
cross: '✘',
|
|
662
|
+
squareSmall: '◻',
|
|
663
|
+
squareSmallFilled: '◼',
|
|
664
|
+
circle: '◯',
|
|
665
|
+
circleFilled: '◉',
|
|
666
|
+
circleDotted: '◌',
|
|
667
|
+
circleDouble: '◎',
|
|
668
|
+
circleCircle: 'ⓞ',
|
|
669
|
+
circleCross: 'ⓧ',
|
|
670
|
+
circlePipe: 'Ⓘ',
|
|
671
|
+
radioOn: '◉',
|
|
672
|
+
radioOff: '◯',
|
|
673
|
+
checkboxOn: '☒',
|
|
674
|
+
checkboxOff: '☐',
|
|
675
|
+
checkboxCircleOn: 'ⓧ',
|
|
676
|
+
checkboxCircleOff: 'Ⓘ',
|
|
677
|
+
pointer: '❯',
|
|
678
|
+
triangleUpOutline: '△',
|
|
679
|
+
triangleLeft: '◀',
|
|
680
|
+
triangleRight: '▶',
|
|
681
|
+
lozenge: '◆',
|
|
682
|
+
lozengeOutline: '◇',
|
|
683
|
+
hamburger: '☰',
|
|
684
|
+
smiley: '㋡',
|
|
685
|
+
mustache: '෴',
|
|
686
|
+
star: '★',
|
|
687
|
+
play: '▶',
|
|
688
|
+
nodejs: '⬢',
|
|
689
|
+
oneSeventh: '⅐',
|
|
690
|
+
oneNinth: '⅑',
|
|
691
|
+
oneTenth: '⅒',
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
const specialFallbackSymbols = {
|
|
695
|
+
tick: '√',
|
|
696
|
+
info: 'i',
|
|
697
|
+
warning: '‼',
|
|
698
|
+
cross: '×',
|
|
699
|
+
squareSmall: '□',
|
|
700
|
+
squareSmallFilled: '■',
|
|
701
|
+
circle: '( )',
|
|
702
|
+
circleFilled: '(*)',
|
|
703
|
+
circleDotted: '( )',
|
|
704
|
+
circleDouble: '( )',
|
|
705
|
+
circleCircle: '(○)',
|
|
706
|
+
circleCross: '(×)',
|
|
707
|
+
circlePipe: '(│)',
|
|
708
|
+
radioOn: '(*)',
|
|
709
|
+
radioOff: '( )',
|
|
710
|
+
checkboxOn: '[×]',
|
|
711
|
+
checkboxOff: '[ ]',
|
|
712
|
+
checkboxCircleOn: '(×)',
|
|
713
|
+
checkboxCircleOff: '( )',
|
|
714
|
+
pointer: '>',
|
|
715
|
+
triangleUpOutline: '∆',
|
|
716
|
+
triangleLeft: '◄',
|
|
717
|
+
triangleRight: '►',
|
|
718
|
+
lozenge: '♦',
|
|
719
|
+
lozengeOutline: '◊',
|
|
720
|
+
hamburger: '≡',
|
|
721
|
+
smiley: '☺',
|
|
722
|
+
mustache: '┌─┐',
|
|
723
|
+
star: '✶',
|
|
724
|
+
play: '►',
|
|
725
|
+
nodejs: '♦',
|
|
726
|
+
oneSeventh: '1/7',
|
|
727
|
+
oneNinth: '1/9',
|
|
728
|
+
oneTenth: '1/10',
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
const mainSymbols = {...common, ...specialMainSymbols};
|
|
732
|
+
const fallbackSymbols = {...common, ...specialFallbackSymbols};
|
|
733
|
+
|
|
734
|
+
const shouldUseMain = isUnicodeSupported();
|
|
735
|
+
const figures = shouldUseMain ? mainSymbols : fallbackSymbols;
|
|
736
|
+
const figures$1 = figures;
|
|
737
|
+
|
|
738
|
+
const { bullet, tick, cross, pointerSmall, radioOff } = figures$1;
|
|
739
|
+
const nodeModules = `${delimiter}node_modules${delimiter}`;
|
|
740
|
+
const BAR_LENGTH = 25;
|
|
741
|
+
const BLOCK_CHAR = "\u2588";
|
|
742
|
+
const BLOCK_CHAR2 = "\u2588";
|
|
743
|
+
const NEXT = " " + blue(pointerSmall) + " ";
|
|
744
|
+
const BULLET = bullet;
|
|
745
|
+
const TICK = tick;
|
|
746
|
+
const CROSS = cross;
|
|
747
|
+
const CIRCLE_OPEN = radioOff;
|
|
748
|
+
|
|
749
|
+
const consola = consola$1.withTag("webpackbar");
|
|
750
|
+
const colorize = (color) => {
|
|
751
|
+
return color[0] === "#" ? c.hex(color) : c[color] || c.reset;
|
|
752
|
+
};
|
|
753
|
+
const renderBar = (progress, color) => {
|
|
754
|
+
const w = progress * (BAR_LENGTH / 100);
|
|
755
|
+
const bg = c.white(BLOCK_CHAR);
|
|
756
|
+
const fg = colorize(color)(BLOCK_CHAR2);
|
|
757
|
+
return range(BAR_LENGTH).map((i) => i < w ? fg : bg).join("");
|
|
758
|
+
};
|
|
759
|
+
function createTable(data) {
|
|
760
|
+
return markdownTable(data);
|
|
761
|
+
}
|
|
762
|
+
function ellipsisLeft(str, n) {
|
|
763
|
+
if (str.length <= n - 3) {
|
|
764
|
+
return str;
|
|
765
|
+
}
|
|
766
|
+
return `...${str.slice(str.length - n - 1)}`;
|
|
767
|
+
}
|
|
768
|
+
function eraseLines(count) {
|
|
769
|
+
let clear = "";
|
|
770
|
+
for (let i = 0; i < count; i++) {
|
|
771
|
+
clear += `\x1B[2K` + (i < count - 1 ? `\x1B[1A` : "");
|
|
772
|
+
}
|
|
773
|
+
if (count)
|
|
774
|
+
clear += `\x1B[G`;
|
|
775
|
+
return clear;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
const parseRequest = (requestStr) => {
|
|
779
|
+
const parts = (requestStr || "").split("!");
|
|
780
|
+
const file = path.relative(
|
|
781
|
+
process.cwd(),
|
|
782
|
+
removeAfter("?", removeBefore(nodeModules, parts.pop()))
|
|
783
|
+
);
|
|
784
|
+
const loaders = parts.map((part) => firstMatch(/[\d@a-z-]+-loader/, part)).filter((v) => hasValue(v));
|
|
785
|
+
return {
|
|
786
|
+
file: hasValue(file) ? file : null,
|
|
787
|
+
loaders
|
|
788
|
+
};
|
|
789
|
+
};
|
|
790
|
+
const formatRequest = (request) => {
|
|
791
|
+
const loaders = request.loaders.join(NEXT);
|
|
792
|
+
if (loaders.length === 0) {
|
|
793
|
+
return request.file || "";
|
|
794
|
+
}
|
|
795
|
+
return `${loaders}${NEXT}${request.file}`;
|
|
796
|
+
};
|
|
797
|
+
function hook(compiler, hookName, fn) {
|
|
798
|
+
if (compiler.hooks) {
|
|
799
|
+
compiler.hooks[hookName].tap("WebpackBar:" + hookName, fn);
|
|
800
|
+
} else {
|
|
801
|
+
compiler.plugin(hookName, fn);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
function ansiRegex({onlyFirst = false} = {}) {
|
|
806
|
+
// Valid string terminator sequences are BEL, ESC\, and 0x9c
|
|
807
|
+
const ST = '(?:\\u0007|\\u001B\\u005C|\\u009C)';
|
|
808
|
+
const pattern = [
|
|
809
|
+
`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
|
|
810
|
+
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))',
|
|
811
|
+
].join('|');
|
|
812
|
+
|
|
813
|
+
return new RegExp(pattern, onlyFirst ? undefined : 'g');
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
const regex = ansiRegex();
|
|
817
|
+
|
|
818
|
+
function stripAnsi(string) {
|
|
819
|
+
if (typeof string !== 'string') {
|
|
820
|
+
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
// Even though the regex is global, we don't need to reset the `.lastIndex`
|
|
824
|
+
// because unlike `.exec()` and `.test()`, `.replace()` does it automatically
|
|
825
|
+
// and doing it manually has a performance penalty.
|
|
826
|
+
return string.replace(regex, '');
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
const ANSI_BACKGROUND_OFFSET = 10;
|
|
830
|
+
|
|
831
|
+
const wrapAnsi16 = (offset = 0) => code => `\u001B[${code + offset}m`;
|
|
832
|
+
|
|
833
|
+
const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
|
|
834
|
+
|
|
835
|
+
const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
|
|
836
|
+
|
|
837
|
+
const styles = {
|
|
838
|
+
modifier: {
|
|
839
|
+
reset: [0, 0],
|
|
840
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
841
|
+
bold: [1, 22],
|
|
842
|
+
dim: [2, 22],
|
|
843
|
+
italic: [3, 23],
|
|
844
|
+
underline: [4, 24],
|
|
845
|
+
overline: [53, 55],
|
|
846
|
+
inverse: [7, 27],
|
|
847
|
+
hidden: [8, 28],
|
|
848
|
+
strikethrough: [9, 29],
|
|
849
|
+
},
|
|
850
|
+
color: {
|
|
851
|
+
black: [30, 39],
|
|
852
|
+
red: [31, 39],
|
|
853
|
+
green: [32, 39],
|
|
854
|
+
yellow: [33, 39],
|
|
855
|
+
blue: [34, 39],
|
|
856
|
+
magenta: [35, 39],
|
|
857
|
+
cyan: [36, 39],
|
|
858
|
+
white: [37, 39],
|
|
859
|
+
|
|
860
|
+
// Bright color
|
|
861
|
+
blackBright: [90, 39],
|
|
862
|
+
gray: [90, 39], // Alias of `blackBright`
|
|
863
|
+
grey: [90, 39], // Alias of `blackBright`
|
|
864
|
+
redBright: [91, 39],
|
|
865
|
+
greenBright: [92, 39],
|
|
866
|
+
yellowBright: [93, 39],
|
|
867
|
+
blueBright: [94, 39],
|
|
868
|
+
magentaBright: [95, 39],
|
|
869
|
+
cyanBright: [96, 39],
|
|
870
|
+
whiteBright: [97, 39],
|
|
871
|
+
},
|
|
872
|
+
bgColor: {
|
|
873
|
+
bgBlack: [40, 49],
|
|
874
|
+
bgRed: [41, 49],
|
|
875
|
+
bgGreen: [42, 49],
|
|
876
|
+
bgYellow: [43, 49],
|
|
877
|
+
bgBlue: [44, 49],
|
|
878
|
+
bgMagenta: [45, 49],
|
|
879
|
+
bgCyan: [46, 49],
|
|
880
|
+
bgWhite: [47, 49],
|
|
881
|
+
|
|
882
|
+
// Bright color
|
|
883
|
+
bgBlackBright: [100, 49],
|
|
884
|
+
bgGray: [100, 49], // Alias of `bgBlackBright`
|
|
885
|
+
bgGrey: [100, 49], // Alias of `bgBlackBright`
|
|
886
|
+
bgRedBright: [101, 49],
|
|
887
|
+
bgGreenBright: [102, 49],
|
|
888
|
+
bgYellowBright: [103, 49],
|
|
889
|
+
bgBlueBright: [104, 49],
|
|
890
|
+
bgMagentaBright: [105, 49],
|
|
891
|
+
bgCyanBright: [106, 49],
|
|
892
|
+
bgWhiteBright: [107, 49],
|
|
893
|
+
},
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
Object.keys(styles.modifier);
|
|
897
|
+
const foregroundColorNames = Object.keys(styles.color);
|
|
898
|
+
const backgroundColorNames = Object.keys(styles.bgColor);
|
|
899
|
+
[...foregroundColorNames, ...backgroundColorNames];
|
|
900
|
+
|
|
901
|
+
function assembleStyles() {
|
|
902
|
+
const codes = new Map();
|
|
903
|
+
|
|
904
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
|
905
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
906
|
+
styles[styleName] = {
|
|
907
|
+
open: `\u001B[${style[0]}m`,
|
|
908
|
+
close: `\u001B[${style[1]}m`,
|
|
909
|
+
};
|
|
910
|
+
|
|
911
|
+
group[styleName] = styles[styleName];
|
|
912
|
+
|
|
913
|
+
codes.set(style[0], style[1]);
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
Object.defineProperty(styles, groupName, {
|
|
917
|
+
value: group,
|
|
918
|
+
enumerable: false,
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
Object.defineProperty(styles, 'codes', {
|
|
923
|
+
value: codes,
|
|
924
|
+
enumerable: false,
|
|
925
|
+
});
|
|
926
|
+
|
|
927
|
+
styles.color.close = '\u001B[39m';
|
|
928
|
+
styles.bgColor.close = '\u001B[49m';
|
|
929
|
+
|
|
930
|
+
styles.color.ansi = wrapAnsi16();
|
|
931
|
+
styles.color.ansi256 = wrapAnsi256();
|
|
932
|
+
styles.color.ansi16m = wrapAnsi16m();
|
|
933
|
+
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
934
|
+
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
935
|
+
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
936
|
+
|
|
937
|
+
// From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js
|
|
938
|
+
Object.defineProperties(styles, {
|
|
939
|
+
rgbToAnsi256: {
|
|
940
|
+
value: (red, green, blue) => {
|
|
941
|
+
// We use the extended greyscale palette here, with the exception of
|
|
942
|
+
// black and white. normal palette only has 4 greyscale shades.
|
|
943
|
+
if (red === green && green === blue) {
|
|
944
|
+
if (red < 8) {
|
|
945
|
+
return 16;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
if (red > 248) {
|
|
949
|
+
return 231;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
return Math.round(((red - 8) / 247) * 24) + 232;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
return 16
|
|
956
|
+
+ (36 * Math.round(red / 255 * 5))
|
|
957
|
+
+ (6 * Math.round(green / 255 * 5))
|
|
958
|
+
+ Math.round(blue / 255 * 5);
|
|
959
|
+
},
|
|
960
|
+
enumerable: false,
|
|
961
|
+
},
|
|
962
|
+
hexToRgb: {
|
|
963
|
+
value: hex => {
|
|
964
|
+
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
965
|
+
if (!matches) {
|
|
966
|
+
return [0, 0, 0];
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
let [colorString] = matches;
|
|
970
|
+
|
|
971
|
+
if (colorString.length === 3) {
|
|
972
|
+
colorString = [...colorString].map(character => character + character).join('');
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
const integer = Number.parseInt(colorString, 16);
|
|
976
|
+
|
|
977
|
+
return [
|
|
978
|
+
/* eslint-disable no-bitwise */
|
|
979
|
+
(integer >> 16) & 0xFF,
|
|
980
|
+
(integer >> 8) & 0xFF,
|
|
981
|
+
integer & 0xFF,
|
|
982
|
+
/* eslint-enable no-bitwise */
|
|
983
|
+
];
|
|
984
|
+
},
|
|
985
|
+
enumerable: false,
|
|
986
|
+
},
|
|
987
|
+
hexToAnsi256: {
|
|
988
|
+
value: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
989
|
+
enumerable: false,
|
|
990
|
+
},
|
|
991
|
+
ansi256ToAnsi: {
|
|
992
|
+
value: code => {
|
|
993
|
+
if (code < 8) {
|
|
994
|
+
return 30 + code;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
if (code < 16) {
|
|
998
|
+
return 90 + (code - 8);
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
let red;
|
|
1002
|
+
let green;
|
|
1003
|
+
let blue;
|
|
1004
|
+
|
|
1005
|
+
if (code >= 232) {
|
|
1006
|
+
red = (((code - 232) * 10) + 8) / 255;
|
|
1007
|
+
green = red;
|
|
1008
|
+
blue = red;
|
|
1009
|
+
} else {
|
|
1010
|
+
code -= 16;
|
|
1011
|
+
|
|
1012
|
+
const remainder = code % 36;
|
|
1013
|
+
|
|
1014
|
+
red = Math.floor(code / 36) / 5;
|
|
1015
|
+
green = Math.floor(remainder / 6) / 5;
|
|
1016
|
+
blue = (remainder % 6) / 5;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
const value = Math.max(red, green, blue) * 2;
|
|
1020
|
+
|
|
1021
|
+
if (value === 0) {
|
|
1022
|
+
return 30;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
// eslint-disable-next-line no-bitwise
|
|
1026
|
+
let result = 30 + ((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));
|
|
1027
|
+
|
|
1028
|
+
if (value === 2) {
|
|
1029
|
+
result += 60;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
return result;
|
|
1033
|
+
},
|
|
1034
|
+
enumerable: false,
|
|
1035
|
+
},
|
|
1036
|
+
rgbToAnsi: {
|
|
1037
|
+
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
1038
|
+
enumerable: false,
|
|
1039
|
+
},
|
|
1040
|
+
hexToAnsi: {
|
|
1041
|
+
value: hex => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
1042
|
+
enumerable: false,
|
|
1043
|
+
},
|
|
1044
|
+
});
|
|
1045
|
+
|
|
1046
|
+
return styles;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
const ansiStyles = assembleStyles();
|
|
1050
|
+
|
|
1051
|
+
const ESCAPES = new Set([
|
|
1052
|
+
'\u001B',
|
|
1053
|
+
'\u009B',
|
|
1054
|
+
]);
|
|
1055
|
+
|
|
1056
|
+
const END_CODE = 39;
|
|
1057
|
+
const ANSI_ESCAPE_BELL = '\u0007';
|
|
1058
|
+
const ANSI_CSI = '[';
|
|
1059
|
+
const ANSI_OSC = ']';
|
|
1060
|
+
const ANSI_SGR_TERMINATOR = 'm';
|
|
1061
|
+
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
1062
|
+
|
|
1063
|
+
const wrapAnsiCode = code => `${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
1064
|
+
const wrapAnsiHyperlink = url => `${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
1065
|
+
|
|
1066
|
+
// Calculate the length of words split on ' ', ignoring
|
|
1067
|
+
// the extra characters added by ansi escape codes
|
|
1068
|
+
const wordLengths = string => string.split(' ').map(character => stringWidth(character));
|
|
1069
|
+
|
|
1070
|
+
// Wrap a long word across multiple rows
|
|
1071
|
+
// Ansi escape codes do not count towards length
|
|
1072
|
+
const wrapWord = (rows, word, columns) => {
|
|
1073
|
+
const characters = [...word];
|
|
1074
|
+
|
|
1075
|
+
let isInsideEscape = false;
|
|
1076
|
+
let isInsideLinkEscape = false;
|
|
1077
|
+
let visible = stringWidth(stripAnsi(rows.at(-1)));
|
|
1078
|
+
|
|
1079
|
+
for (const [index, character] of characters.entries()) {
|
|
1080
|
+
const characterLength = stringWidth(character);
|
|
1081
|
+
|
|
1082
|
+
if (visible + characterLength <= columns) {
|
|
1083
|
+
rows[rows.length - 1] += character;
|
|
1084
|
+
} else {
|
|
1085
|
+
rows.push(character);
|
|
1086
|
+
visible = 0;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
if (ESCAPES.has(character)) {
|
|
1090
|
+
isInsideEscape = true;
|
|
1091
|
+
|
|
1092
|
+
const ansiEscapeLinkCandidate = characters.slice(index + 1, index + 1 + ANSI_ESCAPE_LINK.length).join('');
|
|
1093
|
+
isInsideLinkEscape = ansiEscapeLinkCandidate === ANSI_ESCAPE_LINK;
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
if (isInsideEscape) {
|
|
1097
|
+
if (isInsideLinkEscape) {
|
|
1098
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
1099
|
+
isInsideEscape = false;
|
|
1100
|
+
isInsideLinkEscape = false;
|
|
1101
|
+
}
|
|
1102
|
+
} else if (character === ANSI_SGR_TERMINATOR) {
|
|
1103
|
+
isInsideEscape = false;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
continue;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
visible += characterLength;
|
|
1110
|
+
|
|
1111
|
+
if (visible === columns && index < characters.length - 1) {
|
|
1112
|
+
rows.push('');
|
|
1113
|
+
visible = 0;
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
// It's possible that the last row we copy over is only
|
|
1118
|
+
// ansi escape characters, handle this edge-case
|
|
1119
|
+
if (!visible && rows.at(-1).length > 0 && rows.length > 1) {
|
|
1120
|
+
rows[rows.length - 2] += rows.pop();
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
|
|
1124
|
+
// Trims spaces from a string ignoring invisible sequences
|
|
1125
|
+
const stringVisibleTrimSpacesRight = string => {
|
|
1126
|
+
const words = string.split(' ');
|
|
1127
|
+
let last = words.length;
|
|
1128
|
+
|
|
1129
|
+
while (last > 0) {
|
|
1130
|
+
if (stringWidth(words[last - 1]) > 0) {
|
|
1131
|
+
break;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
last--;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
if (last === words.length) {
|
|
1138
|
+
return string;
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
return words.slice(0, last).join(' ') + words.slice(last).join('');
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1144
|
+
// The wrap-ansi module can be invoked in either 'hard' or 'soft' wrap mode.
|
|
1145
|
+
//
|
|
1146
|
+
// 'hard' will never allow a string to take up more than columns characters.
|
|
1147
|
+
//
|
|
1148
|
+
// 'soft' allows long words to expand past the column length.
|
|
1149
|
+
const exec = (string, columns, options = {}) => {
|
|
1150
|
+
if (options.trim !== false && string.trim() === '') {
|
|
1151
|
+
return '';
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
let returnValue = '';
|
|
1155
|
+
let escapeCode;
|
|
1156
|
+
let escapeUrl;
|
|
1157
|
+
|
|
1158
|
+
const lengths = wordLengths(string);
|
|
1159
|
+
let rows = [''];
|
|
1160
|
+
|
|
1161
|
+
for (const [index, word] of string.split(' ').entries()) {
|
|
1162
|
+
if (options.trim !== false) {
|
|
1163
|
+
rows[rows.length - 1] = rows.at(-1).trimStart();
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
let rowLength = stringWidth(rows.at(-1));
|
|
1167
|
+
|
|
1168
|
+
if (index !== 0) {
|
|
1169
|
+
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
1170
|
+
// If we start with a new word but the current row length equals the length of the columns, add a new row
|
|
1171
|
+
rows.push('');
|
|
1172
|
+
rowLength = 0;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
if (rowLength > 0 || options.trim === false) {
|
|
1176
|
+
rows[rows.length - 1] += ' ';
|
|
1177
|
+
rowLength++;
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
// In 'hard' wrap mode, the length of a line is never allowed to extend past 'columns'
|
|
1182
|
+
if (options.hard && lengths[index] > columns) {
|
|
1183
|
+
const remainingColumns = (columns - rowLength);
|
|
1184
|
+
const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
|
|
1185
|
+
const breaksStartingNextLine = Math.floor((lengths[index] - 1) / columns);
|
|
1186
|
+
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
1187
|
+
rows.push('');
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
wrapWord(rows, word, columns);
|
|
1191
|
+
continue;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) {
|
|
1195
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
1196
|
+
wrapWord(rows, word, columns);
|
|
1197
|
+
continue;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
rows.push('');
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
if (rowLength + lengths[index] > columns && options.wordWrap === false) {
|
|
1204
|
+
wrapWord(rows, word, columns);
|
|
1205
|
+
continue;
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
rows[rows.length - 1] += word;
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
if (options.trim !== false) {
|
|
1212
|
+
rows = rows.map(row => stringVisibleTrimSpacesRight(row));
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
const preString = rows.join('\n');
|
|
1216
|
+
const pre = [...preString];
|
|
1217
|
+
|
|
1218
|
+
// We need to keep a separate index as `String#slice()` works on Unicode code units, while `pre` is an array of codepoints.
|
|
1219
|
+
let preStringIndex = 0;
|
|
1220
|
+
|
|
1221
|
+
for (const [index, character] of pre.entries()) {
|
|
1222
|
+
returnValue += character;
|
|
1223
|
+
|
|
1224
|
+
if (ESCAPES.has(character)) {
|
|
1225
|
+
const {groups} = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(preString.slice(preStringIndex)) || {groups: {}};
|
|
1226
|
+
if (groups.code !== undefined) {
|
|
1227
|
+
const code = Number.parseFloat(groups.code);
|
|
1228
|
+
escapeCode = code === END_CODE ? undefined : code;
|
|
1229
|
+
} else if (groups.uri !== undefined) {
|
|
1230
|
+
escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
const code = ansiStyles.codes.get(Number(escapeCode));
|
|
1235
|
+
|
|
1236
|
+
if (pre[index + 1] === '\n') {
|
|
1237
|
+
if (escapeUrl) {
|
|
1238
|
+
returnValue += wrapAnsiHyperlink('');
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
if (escapeCode && code) {
|
|
1242
|
+
returnValue += wrapAnsiCode(code);
|
|
1243
|
+
}
|
|
1244
|
+
} else if (character === '\n') {
|
|
1245
|
+
if (escapeCode && code) {
|
|
1246
|
+
returnValue += wrapAnsiCode(escapeCode);
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
if (escapeUrl) {
|
|
1250
|
+
returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
preStringIndex += character.length;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
return returnValue;
|
|
1258
|
+
};
|
|
1259
|
+
|
|
1260
|
+
// For each newline, invoke the method separately
|
|
1261
|
+
function wrapAnsi(string, columns, options) {
|
|
1262
|
+
return String(string)
|
|
1263
|
+
.normalize()
|
|
1264
|
+
.replaceAll('\r\n', '\n')
|
|
1265
|
+
.split('\n')
|
|
1266
|
+
.map(line => exec(line, columns, options))
|
|
1267
|
+
.join('\n');
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
var __defProp$3 = Object.defineProperty;
|
|
1271
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1272
|
+
var __publicField$3 = (obj, key, value) => {
|
|
1273
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1274
|
+
return value;
|
|
1275
|
+
};
|
|
1276
|
+
const originalWrite = Symbol("webpackbarWrite");
|
|
1277
|
+
class LogUpdate {
|
|
1278
|
+
constructor() {
|
|
1279
|
+
__publicField$3(this, "keepOnBottom", false);
|
|
1280
|
+
__publicField$3(this, "prevLines");
|
|
1281
|
+
__publicField$3(this, "listening");
|
|
1282
|
+
__publicField$3(this, "extraLines");
|
|
1283
|
+
__publicField$3(this, "_streams");
|
|
1284
|
+
this.prevLines = null;
|
|
1285
|
+
this.listening = false;
|
|
1286
|
+
this.extraLines = "";
|
|
1287
|
+
this._onData = this._onData.bind(this);
|
|
1288
|
+
this._streams = [process.stdout, process.stderr];
|
|
1289
|
+
}
|
|
1290
|
+
render(lines) {
|
|
1291
|
+
this.listen();
|
|
1292
|
+
const wrappedLines = wrapAnsi(lines, this.columns, {
|
|
1293
|
+
trim: false,
|
|
1294
|
+
hard: true,
|
|
1295
|
+
wordWrap: false
|
|
1296
|
+
});
|
|
1297
|
+
const linesToWrite = wrappedLines + "\n" + this.extraLines;
|
|
1298
|
+
this.write(eraseLines(this.lineCount) + linesToWrite);
|
|
1299
|
+
this.prevLines = linesToWrite;
|
|
1300
|
+
}
|
|
1301
|
+
/**
|
|
1302
|
+
* The number of lines currently rendered, based on this.prevLines and the
|
|
1303
|
+
* terminal width. Since the terminal can be resized at any time, this value
|
|
1304
|
+
* should be retrieved immediately before erasing to get an accurate count.
|
|
1305
|
+
*/
|
|
1306
|
+
get lineCount() {
|
|
1307
|
+
if (this.prevLines === null) {
|
|
1308
|
+
return 0;
|
|
1309
|
+
}
|
|
1310
|
+
const splitLines = this.prevLines.split("\n");
|
|
1311
|
+
let lineCount = 0;
|
|
1312
|
+
for (const line of splitLines) {
|
|
1313
|
+
const lineWidth = stringWidth(line);
|
|
1314
|
+
lineCount += Math.max(1, Math.ceil(lineWidth / this.columns));
|
|
1315
|
+
}
|
|
1316
|
+
return lineCount;
|
|
1317
|
+
}
|
|
1318
|
+
get columns() {
|
|
1319
|
+
return (process.stderr.columns || 80) - 2;
|
|
1320
|
+
}
|
|
1321
|
+
write(data) {
|
|
1322
|
+
const stream = process.stderr;
|
|
1323
|
+
if (stream.write[originalWrite]) {
|
|
1324
|
+
stream.write[originalWrite].call(stream, data, "utf8");
|
|
1325
|
+
} else {
|
|
1326
|
+
stream.write(data, "utf8");
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
clear() {
|
|
1330
|
+
this.write(eraseLines(this.lineCount));
|
|
1331
|
+
this.done();
|
|
1332
|
+
}
|
|
1333
|
+
done() {
|
|
1334
|
+
this.stopListen();
|
|
1335
|
+
this.prevLines = null;
|
|
1336
|
+
this.extraLines = "";
|
|
1337
|
+
}
|
|
1338
|
+
_onData(data) {
|
|
1339
|
+
if (this.keepOnBottom) {
|
|
1340
|
+
this.write(eraseLines(this.lineCount));
|
|
1341
|
+
} else {
|
|
1342
|
+
this.prevLines = (this.prevLines ?? "") + data;
|
|
1343
|
+
this.extraLines += data;
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
_afterData() {
|
|
1347
|
+
if (this.keepOnBottom) {
|
|
1348
|
+
this.write(this.prevLines);
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
listen() {
|
|
1352
|
+
if (this.listening) {
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
for (const stream of this._streams) {
|
|
1356
|
+
if (stream.write[originalWrite]) {
|
|
1357
|
+
continue;
|
|
1358
|
+
}
|
|
1359
|
+
const write = (data, ...args) => {
|
|
1360
|
+
if (!stream.write[originalWrite]) {
|
|
1361
|
+
return stream.write(data, ...args);
|
|
1362
|
+
}
|
|
1363
|
+
this._onData(data);
|
|
1364
|
+
const result = stream.write[originalWrite].call(stream, data, ...args);
|
|
1365
|
+
this._afterData();
|
|
1366
|
+
return result;
|
|
1367
|
+
};
|
|
1368
|
+
write[originalWrite] = stream.write;
|
|
1369
|
+
stream.write = write;
|
|
1370
|
+
}
|
|
1371
|
+
this.listening = true;
|
|
1372
|
+
}
|
|
1373
|
+
stopListen() {
|
|
1374
|
+
for (const stream of this._streams) {
|
|
1375
|
+
if (stream.write[originalWrite]) {
|
|
1376
|
+
stream.write = stream.write[originalWrite];
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
this.listening = false;
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
const logUpdate = new LogUpdate();
|
|
1383
|
+
|
|
1384
|
+
let lastRender = Date.now();
|
|
1385
|
+
class FancyReporter {
|
|
1386
|
+
allDone() {
|
|
1387
|
+
logUpdate.done();
|
|
1388
|
+
}
|
|
1389
|
+
done(context) {
|
|
1390
|
+
this._renderStates(context.statesArray);
|
|
1391
|
+
if (context.hasErrors) {
|
|
1392
|
+
logUpdate.done();
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
progress(context) {
|
|
1396
|
+
if (Date.now() - lastRender > 50) {
|
|
1397
|
+
this._renderStates(context.statesArray);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
_renderStates(statesArray) {
|
|
1401
|
+
lastRender = Date.now();
|
|
1402
|
+
const renderedStates = statesArray.map((c) => this._renderState(c)).join("\n\n");
|
|
1403
|
+
logUpdate.render("\n" + renderedStates + "\n");
|
|
1404
|
+
}
|
|
1405
|
+
_renderState(state) {
|
|
1406
|
+
const color = colorize(state.color);
|
|
1407
|
+
let line1;
|
|
1408
|
+
let line2;
|
|
1409
|
+
if (state.progress >= 0 && state.progress < 100) {
|
|
1410
|
+
line1 = [
|
|
1411
|
+
color(BULLET),
|
|
1412
|
+
color(state.name),
|
|
1413
|
+
renderBar(state.progress, state.color),
|
|
1414
|
+
state.message,
|
|
1415
|
+
`(${state.progress || 0}%)`,
|
|
1416
|
+
grey(state.details[0] || ""),
|
|
1417
|
+
grey(state.details[1] || "")
|
|
1418
|
+
].join(" ");
|
|
1419
|
+
line2 = state.request ? " " + grey(ellipsisLeft(formatRequest(state.request), logUpdate.columns)) : "";
|
|
1420
|
+
} else {
|
|
1421
|
+
let icon = " ";
|
|
1422
|
+
if (state.hasErrors) {
|
|
1423
|
+
icon = CROSS;
|
|
1424
|
+
} else if (state.progress === 100) {
|
|
1425
|
+
icon = TICK;
|
|
1426
|
+
} else if (state.progress === -1) {
|
|
1427
|
+
icon = CIRCLE_OPEN;
|
|
1428
|
+
}
|
|
1429
|
+
line1 = color(`${icon} ${state.name}`);
|
|
1430
|
+
line2 = grey(" " + state.message);
|
|
1431
|
+
}
|
|
1432
|
+
return line1 + "\n" + line2;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
class SimpleReporter {
|
|
1437
|
+
start(context) {
|
|
1438
|
+
consola.info(`Compiling ${context.state.name}`);
|
|
1439
|
+
}
|
|
1440
|
+
change(context, { shortPath }) {
|
|
1441
|
+
consola.debug(`${shortPath} changed.`, `Rebuilding ${context.state.name}`);
|
|
1442
|
+
}
|
|
1443
|
+
done(context) {
|
|
1444
|
+
const { hasError, message, name } = context.state;
|
|
1445
|
+
consola[hasError ? "error" : "success"](`${name}: ${message}`);
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
const DB = {
|
|
1450
|
+
loader: {
|
|
1451
|
+
get: (loader) => startCase(loader)
|
|
1452
|
+
},
|
|
1453
|
+
ext: {
|
|
1454
|
+
get: (ext) => `${ext} files`,
|
|
1455
|
+
vue: "Vue Single File components",
|
|
1456
|
+
js: "JavaScript files",
|
|
1457
|
+
sass: "SASS files",
|
|
1458
|
+
scss: "SASS files",
|
|
1459
|
+
unknown: "Unknown files"
|
|
1460
|
+
}
|
|
1461
|
+
};
|
|
1462
|
+
function getDescription(category, keyword) {
|
|
1463
|
+
if (!DB[category]) {
|
|
1464
|
+
return startCase(keyword);
|
|
1465
|
+
}
|
|
1466
|
+
if (DB[category][keyword]) {
|
|
1467
|
+
return DB[category][keyword];
|
|
1468
|
+
}
|
|
1469
|
+
if (DB[category].get) {
|
|
1470
|
+
return DB[category].get(keyword);
|
|
1471
|
+
}
|
|
1472
|
+
return "-";
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
function formatStats(allStats) {
|
|
1476
|
+
const lines = [];
|
|
1477
|
+
for (const category of Object.keys(allStats)) {
|
|
1478
|
+
const stats = allStats[category];
|
|
1479
|
+
lines.push(`> Stats by ${bold(startCase(category))}`);
|
|
1480
|
+
let totalRequests = 0;
|
|
1481
|
+
const totalTime = [0, 0];
|
|
1482
|
+
const data = [
|
|
1483
|
+
[startCase(category), "Requests", "Time", "Time/Request", "Description"]
|
|
1484
|
+
];
|
|
1485
|
+
for (const item of Object.keys(stats)) {
|
|
1486
|
+
const stat = stats[item];
|
|
1487
|
+
totalRequests += stat.count || 0;
|
|
1488
|
+
const description = getDescription(category, item);
|
|
1489
|
+
totalTime[0] += stat.time[0];
|
|
1490
|
+
totalTime[1] += stat.time[1];
|
|
1491
|
+
const avgTime = [stat.time[0] / stat.count, stat.time[1] / stat.count];
|
|
1492
|
+
data.push([
|
|
1493
|
+
item,
|
|
1494
|
+
stat.count || "-",
|
|
1495
|
+
prettyTime(stat.time),
|
|
1496
|
+
prettyTime(avgTime),
|
|
1497
|
+
description
|
|
1498
|
+
]);
|
|
1499
|
+
}
|
|
1500
|
+
data.push(["Total", totalRequests, prettyTime(totalTime), "", ""]);
|
|
1501
|
+
lines.push(createTable(data));
|
|
1502
|
+
}
|
|
1503
|
+
return `${lines.join("\n\n")}
|
|
1504
|
+
`;
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
var __defProp$2 = Object.defineProperty;
|
|
1508
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1509
|
+
var __publicField$2 = (obj, key, value) => {
|
|
1510
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1511
|
+
return value;
|
|
1512
|
+
};
|
|
1513
|
+
class Profiler {
|
|
1514
|
+
constructor() {
|
|
1515
|
+
__publicField$2(this, "requests");
|
|
1516
|
+
this.requests = [];
|
|
1517
|
+
}
|
|
1518
|
+
onRequest(request) {
|
|
1519
|
+
if (!request) {
|
|
1520
|
+
return;
|
|
1521
|
+
}
|
|
1522
|
+
if (this.requests.length > 0) {
|
|
1523
|
+
const lastReq = this.requests.at(-1);
|
|
1524
|
+
if (lastReq.start) {
|
|
1525
|
+
lastReq.time = process.hrtime(lastReq.start);
|
|
1526
|
+
delete lastReq.start;
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
if (!request.file || request.loaders.length === 0) {
|
|
1530
|
+
return;
|
|
1531
|
+
}
|
|
1532
|
+
this.requests.push({
|
|
1533
|
+
request,
|
|
1534
|
+
start: process.hrtime()
|
|
1535
|
+
});
|
|
1536
|
+
}
|
|
1537
|
+
getStats() {
|
|
1538
|
+
const loaderStats = {};
|
|
1539
|
+
const extStats = {};
|
|
1540
|
+
const getStat = (stats, name) => {
|
|
1541
|
+
if (!stats[name]) {
|
|
1542
|
+
stats[name] = {
|
|
1543
|
+
count: 0,
|
|
1544
|
+
time: [0, 0]
|
|
1545
|
+
};
|
|
1546
|
+
}
|
|
1547
|
+
return stats[name];
|
|
1548
|
+
};
|
|
1549
|
+
const addToStat = (stats, name, count, time) => {
|
|
1550
|
+
const stat = getStat(stats, name);
|
|
1551
|
+
stat.count += count;
|
|
1552
|
+
stat.time[0] += time[0];
|
|
1553
|
+
stat.time[1] += time[1];
|
|
1554
|
+
};
|
|
1555
|
+
for (const { request, time = [0, 0] } of this.requests) {
|
|
1556
|
+
for (const loader of request.loaders) {
|
|
1557
|
+
addToStat(loaderStats, loader, 1, time);
|
|
1558
|
+
}
|
|
1559
|
+
const ext = request.file && path.extname(request.file).slice(1);
|
|
1560
|
+
addToStat(extStats, ext && ext.length > 0 ? ext : "unknown", 1, time);
|
|
1561
|
+
}
|
|
1562
|
+
return {
|
|
1563
|
+
ext: extStats,
|
|
1564
|
+
loader: loaderStats
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1567
|
+
getFormattedStats() {
|
|
1568
|
+
return formatStats(this.getStats());
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
class ProfileReporter {
|
|
1573
|
+
progress(context) {
|
|
1574
|
+
if (!context.state.profiler) {
|
|
1575
|
+
context.state.profiler = new Profiler();
|
|
1576
|
+
}
|
|
1577
|
+
context.state.profiler.onRequest(context.state.request);
|
|
1578
|
+
}
|
|
1579
|
+
done(context) {
|
|
1580
|
+
if (context.state.profiler) {
|
|
1581
|
+
context.state.profile = context.state.profiler.getFormattedStats();
|
|
1582
|
+
delete context.state.profiler;
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
allDone(context) {
|
|
1586
|
+
let str = "";
|
|
1587
|
+
for (const state of context.statesArray) {
|
|
1588
|
+
const color = colorize(state.color);
|
|
1589
|
+
if (state.profile) {
|
|
1590
|
+
str += color(`
|
|
1591
|
+
Profile results for ${bold(state.name)}
|
|
1592
|
+
`) + `
|
|
1593
|
+
${state.profile}
|
|
1594
|
+
`;
|
|
1595
|
+
delete state.profile;
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
process.stderr.write(str);
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
var __defProp$1 = Object.defineProperty;
|
|
1603
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1604
|
+
var __publicField$1 = (obj, key, value) => {
|
|
1605
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1606
|
+
return value;
|
|
1607
|
+
};
|
|
1608
|
+
class StatsReporter {
|
|
1609
|
+
constructor(options) {
|
|
1610
|
+
__publicField$1(this, "options");
|
|
1611
|
+
this.options = Object.assign(
|
|
1612
|
+
{
|
|
1613
|
+
chunks: false,
|
|
1614
|
+
children: false,
|
|
1615
|
+
modules: false,
|
|
1616
|
+
colors: true,
|
|
1617
|
+
warnings: true,
|
|
1618
|
+
errors: true
|
|
1619
|
+
},
|
|
1620
|
+
options
|
|
1621
|
+
);
|
|
1622
|
+
}
|
|
1623
|
+
done(context, { stats }) {
|
|
1624
|
+
const str = stats.toString(this.options);
|
|
1625
|
+
if (context.hasErrors) {
|
|
1626
|
+
process.stderr.write("\n" + str + "\n");
|
|
1627
|
+
} else {
|
|
1628
|
+
context.state.statsString = str;
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
allDone(context) {
|
|
1632
|
+
let str = "";
|
|
1633
|
+
for (const state of context.statesArray) {
|
|
1634
|
+
if (state.statsString) {
|
|
1635
|
+
str += "\n" + state.statsString + "\n";
|
|
1636
|
+
delete state.statsString;
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
process.stderr.write(str);
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
const reporters = {
|
|
1644
|
+
__proto__: null,
|
|
1645
|
+
basic: SimpleReporter,
|
|
1646
|
+
fancy: FancyReporter,
|
|
1647
|
+
profile: ProfileReporter,
|
|
1648
|
+
stats: StatsReporter
|
|
1649
|
+
};
|
|
1650
|
+
|
|
1651
|
+
var __defProp = Object.defineProperty;
|
|
1652
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1653
|
+
var __publicField = (obj, key, value) => {
|
|
1654
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1655
|
+
return value;
|
|
1656
|
+
};
|
|
1657
|
+
const DEFAULTS = {
|
|
1658
|
+
name: "build",
|
|
1659
|
+
color: "green",
|
|
1660
|
+
reporters: isMinimal ? ["basic"] : ["fancy"],
|
|
1661
|
+
reporter: null
|
|
1662
|
+
};
|
|
1663
|
+
const DEFAULT_STATE = () => ({
|
|
1664
|
+
start: null,
|
|
1665
|
+
progress: -1,
|
|
1666
|
+
done: false,
|
|
1667
|
+
message: "",
|
|
1668
|
+
details: [],
|
|
1669
|
+
request: null,
|
|
1670
|
+
hasErrors: false
|
|
1671
|
+
});
|
|
1672
|
+
const globalStates = {};
|
|
1673
|
+
class WebpackBar {
|
|
1674
|
+
constructor(options) {
|
|
1675
|
+
__publicField(this, "options");
|
|
1676
|
+
__publicField(this, "reporters");
|
|
1677
|
+
this.options = Object.assign({}, DEFAULTS, options);
|
|
1678
|
+
if (options.keepOnBottom) {
|
|
1679
|
+
logUpdate.keepOnBottom = true;
|
|
1680
|
+
}
|
|
1681
|
+
const _reporters = [
|
|
1682
|
+
...this.options.reporters || [],
|
|
1683
|
+
this.options.reporter
|
|
1684
|
+
].filter(Boolean).map((reporter) => {
|
|
1685
|
+
if (Array.isArray(reporter)) {
|
|
1686
|
+
return { reporter: reporter[0], options: reporter[1] };
|
|
1687
|
+
}
|
|
1688
|
+
if (typeof reporter === "string") {
|
|
1689
|
+
return { reporter };
|
|
1690
|
+
}
|
|
1691
|
+
return { reporter };
|
|
1692
|
+
});
|
|
1693
|
+
if (this.options.profile && !_reporters.some(({ reporter }) => reporter === "profile")) {
|
|
1694
|
+
_reporters.push({ reporter: "profile" });
|
|
1695
|
+
}
|
|
1696
|
+
this.reporters = _reporters.map(({ reporter, options: options2 = {} }) => {
|
|
1697
|
+
if (typeof reporter === "string") {
|
|
1698
|
+
if (this.options[reporter] === false) {
|
|
1699
|
+
return void 0;
|
|
1700
|
+
}
|
|
1701
|
+
options2 = { ...this.options[reporter], ...options2 };
|
|
1702
|
+
reporter = reporters[reporter] || require(reporter);
|
|
1703
|
+
}
|
|
1704
|
+
if (typeof reporter === "function") {
|
|
1705
|
+
try {
|
|
1706
|
+
reporter = new reporter(options2);
|
|
1707
|
+
} catch {
|
|
1708
|
+
reporter = reporter(options2);
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
return reporter;
|
|
1712
|
+
}).filter(Boolean);
|
|
1713
|
+
}
|
|
1714
|
+
callReporters(fn, payload = {}) {
|
|
1715
|
+
for (const reporter of this.reporters) {
|
|
1716
|
+
if (typeof reporter[fn] === "function") {
|
|
1717
|
+
try {
|
|
1718
|
+
reporter[fn](this, payload);
|
|
1719
|
+
} catch (error) {
|
|
1720
|
+
process.stdout.write(error.stack + "\n");
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
get hasRunning() {
|
|
1726
|
+
return objectValues(this.states).some((state) => !state.done);
|
|
1727
|
+
}
|
|
1728
|
+
get hasErrors() {
|
|
1729
|
+
return objectValues(this.states).some((state) => state.hasErrors);
|
|
1730
|
+
}
|
|
1731
|
+
get statesArray() {
|
|
1732
|
+
return objectValues(this.states).sort(
|
|
1733
|
+
(s1, s2) => s1.name.localeCompare(s2.name)
|
|
1734
|
+
);
|
|
1735
|
+
}
|
|
1736
|
+
get states() {
|
|
1737
|
+
return globalStates;
|
|
1738
|
+
}
|
|
1739
|
+
get state() {
|
|
1740
|
+
return globalStates[this.options.name];
|
|
1741
|
+
}
|
|
1742
|
+
_ensureState() {
|
|
1743
|
+
if (!this.states[this.options.name]) {
|
|
1744
|
+
this.states[this.options.name] = {
|
|
1745
|
+
...DEFAULT_STATE(),
|
|
1746
|
+
color: this.options.color,
|
|
1747
|
+
name: startCase(this.options.name)
|
|
1748
|
+
};
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
apply(compiler) {
|
|
1752
|
+
if (compiler.webpackbar) {
|
|
1753
|
+
return;
|
|
1754
|
+
}
|
|
1755
|
+
compiler.webpackbar = this;
|
|
1756
|
+
hook(compiler, "afterPlugins", () => {
|
|
1757
|
+
this._ensureState();
|
|
1758
|
+
});
|
|
1759
|
+
hook(compiler, "compile", () => {
|
|
1760
|
+
this._ensureState();
|
|
1761
|
+
Object.assign(this.state, {
|
|
1762
|
+
...DEFAULT_STATE(),
|
|
1763
|
+
start: process.hrtime()
|
|
1764
|
+
});
|
|
1765
|
+
this.callReporters("start");
|
|
1766
|
+
});
|
|
1767
|
+
hook(compiler, "invalid", (fileName, changeTime) => {
|
|
1768
|
+
this._ensureState();
|
|
1769
|
+
this.callReporters("change", {
|
|
1770
|
+
path: fileName,
|
|
1771
|
+
shortPath: shortenPath(fileName),
|
|
1772
|
+
time: changeTime
|
|
1773
|
+
});
|
|
1774
|
+
});
|
|
1775
|
+
hook(compiler, "done", (stats) => {
|
|
1776
|
+
this._ensureState();
|
|
1777
|
+
if (this.state.done) {
|
|
1778
|
+
return;
|
|
1779
|
+
}
|
|
1780
|
+
const hasErrors = stats.hasErrors();
|
|
1781
|
+
const status = hasErrors ? "with some errors" : "successfully";
|
|
1782
|
+
const time = this.state.start ? " in " + prettyTime(process.hrtime(this.state.start), 2) : "";
|
|
1783
|
+
Object.assign(this.state, {
|
|
1784
|
+
...DEFAULT_STATE(),
|
|
1785
|
+
progress: 100,
|
|
1786
|
+
done: true,
|
|
1787
|
+
message: `Compiled ${status}${time}`,
|
|
1788
|
+
hasErrors
|
|
1789
|
+
});
|
|
1790
|
+
this.callReporters("progress");
|
|
1791
|
+
this.callReporters("done", { stats });
|
|
1792
|
+
if (!this.hasRunning) {
|
|
1793
|
+
this.callReporters("beforeAllDone");
|
|
1794
|
+
this.callReporters("allDone");
|
|
1795
|
+
this.callReporters("afterAllDone");
|
|
1796
|
+
}
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
updateProgress(percent = 0, message = "", details = []) {
|
|
1800
|
+
const progress = Math.floor(percent * 100);
|
|
1801
|
+
const activeModule = details.pop();
|
|
1802
|
+
if (this.state.done) {
|
|
1803
|
+
return;
|
|
1804
|
+
}
|
|
1805
|
+
Object.assign(this.state, {
|
|
1806
|
+
progress,
|
|
1807
|
+
message: message || "",
|
|
1808
|
+
details,
|
|
1809
|
+
request: parseRequest(activeModule)
|
|
1810
|
+
});
|
|
1811
|
+
this.callReporters("progress");
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
export { WebpackBar as W };
|