esp32tool 1.6.4 → 1.6.6
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/apple-touch-icon.png +0 -0
- package/dist/console.d.ts +4 -0
- package/dist/console.js +54 -2
- package/dist/util/console-color.d.ts +10 -1
- package/dist/util/console-color.js +369 -30
- package/dist/util/line-break-transformer.js +18 -4
- package/dist/util/timestamp-transformer.d.ts +5 -0
- package/dist/util/timestamp-transformer.js +37 -0
- package/icons/icon-128.png +0 -0
- package/icons/icon-144.png +0 -0
- package/icons/icon-152.png +0 -0
- package/icons/icon-192.png +0 -0
- package/icons/icon-384.png +0 -0
- package/icons/icon-512.png +0 -0
- package/icons/icon-72.png +0 -0
- package/icons/icon-96.png +0 -0
- package/js/console.js +52 -3
- package/js/util/console-color.js +513 -211
- package/js/util/line-break-transformer.js +29 -17
- package/js/util/timestamp-transformer.js +37 -0
- package/package.cli.json +1 -1
- package/package.json +13 -12
- package/screenshots/desktop.png +0 -0
- package/screenshots/mobile.png +0 -0
- package/src/console.ts +57 -2
- package/src/util/console-color.ts +373 -32
- package/src/util/line-break-transformer.ts +18 -4
- package/src/util/timestamp-transformer.ts +45 -0
- package/sw.js +1 -1
- package/tsconfig.util.json +9 -0
package/js/util/console-color.js
CHANGED
|
@@ -1,210 +1,506 @@
|
|
|
1
|
+
const ANSI_256 = (() => {
|
|
2
|
+
const t = [];
|
|
3
|
+
// Standard colors 0-7
|
|
4
|
+
t[0] = "rgb(0,0,0)";
|
|
5
|
+
t[1] = "rgb(128,0,0)";
|
|
6
|
+
t[2] = "rgb(0,128,0)";
|
|
7
|
+
t[3] = "rgb(128,128,0)";
|
|
8
|
+
t[4] = "rgb(0,0,128)";
|
|
9
|
+
t[5] = "rgb(128,0,128)";
|
|
10
|
+
t[6] = "rgb(0,128,128)";
|
|
11
|
+
t[7] = "rgb(192,192,192)";
|
|
12
|
+
// Bright colors 8-15
|
|
13
|
+
t[8] = "rgb(128,128,128)";
|
|
14
|
+
t[9] = "rgb(255,0,0)";
|
|
15
|
+
t[10] = "rgb(0,255,0)";
|
|
16
|
+
t[11] = "rgb(255,255,0)";
|
|
17
|
+
t[12] = "rgb(99,153,255)";
|
|
18
|
+
t[13] = "rgb(255,0,255)";
|
|
19
|
+
t[14] = "rgb(0,255,255)";
|
|
20
|
+
t[15] = "rgb(255,255,255)";
|
|
21
|
+
// 6x6x6 color cube 16-231
|
|
22
|
+
for (let i = 0; i < 216; i++) {
|
|
23
|
+
const r = Math.floor(i / 36);
|
|
24
|
+
const g = Math.floor((i % 36) / 6);
|
|
25
|
+
const b = i % 6;
|
|
26
|
+
t[16 + i] =
|
|
27
|
+
"rgb(" +
|
|
28
|
+
(r ? r * 40 + 55 : 0) +
|
|
29
|
+
"," +
|
|
30
|
+
(g ? g * 40 + 55 : 0) +
|
|
31
|
+
"," +
|
|
32
|
+
(b ? b * 40 + 55 : 0) +
|
|
33
|
+
")";
|
|
34
|
+
}
|
|
35
|
+
// Grayscale ramp 232-255
|
|
36
|
+
for (let i = 0; i < 24; i++) {
|
|
37
|
+
const v = i * 10 + 8;
|
|
38
|
+
t[232 + i] = "rgb(" + v + "," + v + "," + v + ")";
|
|
39
|
+
}
|
|
40
|
+
return t;
|
|
41
|
+
})();
|
|
42
|
+
// Maps 256-color indices 0–7 to the named CSS class tokens so that
|
|
43
|
+
// \x1b[38;5;1m renders the same red as \x1b[31m.
|
|
44
|
+
const ANSI_NAMED = [
|
|
45
|
+
"black",
|
|
46
|
+
"red",
|
|
47
|
+
"green",
|
|
48
|
+
"yellow",
|
|
49
|
+
"blue",
|
|
50
|
+
"magenta",
|
|
51
|
+
"cyan",
|
|
52
|
+
"white",
|
|
53
|
+
];
|
|
1
54
|
export class ColoredConsole {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
let i = 0;
|
|
26
|
-
|
|
27
|
-
if (this.state.carriageReturn) {
|
|
28
|
-
if (line !== "\n") {
|
|
29
|
-
// don't remove if \r\n
|
|
30
|
-
if (this.targetElement.lastChild) {
|
|
31
|
-
this.targetElement.removeChild(this.targetElement.lastChild);
|
|
55
|
+
constructor(targetElement) {
|
|
56
|
+
this.targetElement = targetElement;
|
|
57
|
+
this.state = {
|
|
58
|
+
bold: false,
|
|
59
|
+
italic: false,
|
|
60
|
+
underline: false,
|
|
61
|
+
strikethrough: false,
|
|
62
|
+
foregroundColor: null,
|
|
63
|
+
backgroundColor: null,
|
|
64
|
+
fgRgb: null,
|
|
65
|
+
bgRgb: null,
|
|
66
|
+
dim: false,
|
|
67
|
+
reverse: false,
|
|
68
|
+
carriageReturn: false,
|
|
69
|
+
lines: [],
|
|
70
|
+
secret: false,
|
|
71
|
+
blink: false,
|
|
72
|
+
rapidBlink: false,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
logs() {
|
|
76
|
+
if (this.state.lines.length > 0) {
|
|
77
|
+
this.processLines();
|
|
32
78
|
}
|
|
33
|
-
|
|
34
|
-
this.state.carriageReturn = false;
|
|
79
|
+
return this.targetElement.innerText;
|
|
35
80
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
81
|
+
processLine(line) {
|
|
82
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequences
|
|
83
|
+
// eslint-disable-next-line no-control-regex
|
|
84
|
+
const re = /(?:\x1B|\\x1B)(?:\[(.*?)([@-~])|\].*?(?:\x07|\x1B\\))/g;
|
|
85
|
+
let i = 0;
|
|
86
|
+
const lineSpan = document.createElement("span");
|
|
87
|
+
lineSpan.classList.add("line");
|
|
88
|
+
const addSpan = (content) => {
|
|
89
|
+
if (content === "")
|
|
90
|
+
return;
|
|
91
|
+
const span = document.createElement("span");
|
|
92
|
+
if (this.state.bold)
|
|
93
|
+
span.classList.add("log-bold");
|
|
94
|
+
if (this.state.dim)
|
|
95
|
+
span.classList.add("log-dim");
|
|
96
|
+
if (this.state.italic)
|
|
97
|
+
span.classList.add("log-italic");
|
|
98
|
+
if (this.state.underline)
|
|
99
|
+
span.classList.add("log-underline");
|
|
100
|
+
if (this.state.strikethrough)
|
|
101
|
+
span.classList.add("log-strikethrough");
|
|
102
|
+
if (this.state.secret)
|
|
103
|
+
span.classList.add("log-secret");
|
|
104
|
+
if (this.state.blink)
|
|
105
|
+
span.classList.add("log-blink");
|
|
106
|
+
if (this.state.rapidBlink)
|
|
107
|
+
span.classList.add("log-rapid-blink");
|
|
108
|
+
// Resolve colors with reverse-video support
|
|
109
|
+
let fgRgb = this.state.fgRgb;
|
|
110
|
+
let bgRgb = this.state.bgRgb;
|
|
111
|
+
let fg = this.state.foregroundColor;
|
|
112
|
+
let bg = this.state.backgroundColor;
|
|
113
|
+
if (this.state.reverse) {
|
|
114
|
+
fgRgb = this.state.bgRgb;
|
|
115
|
+
bgRgb = this.state.fgRgb;
|
|
116
|
+
fg = this.state.backgroundColor;
|
|
117
|
+
bg = this.state.foregroundColor;
|
|
118
|
+
// When one side is unset, fill in the terminal defaults so the
|
|
119
|
+
// swap is always visible (fg default=#ddd, bg default=#1c1c1c).
|
|
120
|
+
if (!fgRgb && !fg && !bgRgb && !bg) {
|
|
121
|
+
span.classList.add("log-reverse");
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
if (!fgRgb && !fg)
|
|
125
|
+
fgRgb = "rgb(28,28,28)";
|
|
126
|
+
if (!bgRgb && !bg)
|
|
127
|
+
bgRgb = "rgb(221,221,221)";
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Inline rgb() style takes priority over CSS class
|
|
131
|
+
if (fgRgb) {
|
|
132
|
+
span.style.color = fgRgb;
|
|
133
|
+
}
|
|
134
|
+
else if (fg !== null) {
|
|
135
|
+
span.classList.add(`log-fg-${fg}`);
|
|
136
|
+
}
|
|
137
|
+
if (bgRgb) {
|
|
138
|
+
span.style.backgroundColor = bgRgb;
|
|
139
|
+
}
|
|
140
|
+
else if (bg !== null) {
|
|
141
|
+
span.classList.add(`log-bg-${bg}`);
|
|
142
|
+
}
|
|
143
|
+
span.appendChild(document.createTextNode(content));
|
|
144
|
+
lineSpan.appendChild(span);
|
|
145
|
+
if (this.state.secret) {
|
|
146
|
+
const redacted = document.createElement("span");
|
|
147
|
+
redacted.classList.add("log-secret-redacted");
|
|
148
|
+
redacted.appendChild(document.createTextNode("[redacted]"));
|
|
149
|
+
lineSpan.appendChild(redacted);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
while (true) {
|
|
153
|
+
const match = re.exec(line);
|
|
154
|
+
if (match === null)
|
|
155
|
+
break;
|
|
156
|
+
const j = match.index;
|
|
157
|
+
addSpan(line.substring(i, j));
|
|
158
|
+
i = j + match[0].length;
|
|
159
|
+
// Only process SGR sequences (final byte 'm'); skip cursor, erase, etc.
|
|
160
|
+
if (match[1] === undefined || match[2] !== "m")
|
|
161
|
+
continue;
|
|
162
|
+
const rawCodes = match[1] === "" ? [""] : match[1].split(";");
|
|
163
|
+
const codes = [];
|
|
164
|
+
let invalidSgr = false;
|
|
165
|
+
for (const rawCode of rawCodes) {
|
|
166
|
+
if (rawCode === "") {
|
|
167
|
+
codes.push(0);
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
if (!/^\d+$/.test(rawCode)) {
|
|
171
|
+
invalidSgr = true;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
codes.push(Number(rawCode));
|
|
175
|
+
}
|
|
176
|
+
if (invalidSgr)
|
|
177
|
+
continue;
|
|
178
|
+
for (let ci = 0; ci < codes.length; ci++) {
|
|
179
|
+
const code = codes[ci];
|
|
180
|
+
switch (code) {
|
|
181
|
+
case 0:
|
|
182
|
+
this.state.bold = false;
|
|
183
|
+
this.state.dim = false;
|
|
184
|
+
this.state.italic = false;
|
|
185
|
+
this.state.underline = false;
|
|
186
|
+
this.state.strikethrough = false;
|
|
187
|
+
this.state.foregroundColor = null;
|
|
188
|
+
this.state.backgroundColor = null;
|
|
189
|
+
this.state.fgRgb = null;
|
|
190
|
+
this.state.bgRgb = null;
|
|
191
|
+
this.state.reverse = false;
|
|
192
|
+
this.state.secret = false;
|
|
193
|
+
this.state.blink = false;
|
|
194
|
+
this.state.rapidBlink = false;
|
|
195
|
+
break;
|
|
196
|
+
case 1:
|
|
197
|
+
this.state.bold = true;
|
|
198
|
+
break;
|
|
199
|
+
case 2:
|
|
200
|
+
this.state.dim = true;
|
|
201
|
+
break;
|
|
202
|
+
case 3:
|
|
203
|
+
this.state.italic = true;
|
|
204
|
+
break;
|
|
205
|
+
case 4:
|
|
206
|
+
this.state.underline = true;
|
|
207
|
+
break;
|
|
208
|
+
case 5:
|
|
209
|
+
this.state.blink = true;
|
|
210
|
+
this.state.rapidBlink = false;
|
|
211
|
+
break;
|
|
212
|
+
case 6:
|
|
213
|
+
this.state.rapidBlink = true;
|
|
214
|
+
this.state.blink = false;
|
|
215
|
+
break;
|
|
216
|
+
case 7:
|
|
217
|
+
this.state.reverse = true;
|
|
218
|
+
break;
|
|
219
|
+
case 8:
|
|
220
|
+
this.state.secret = true;
|
|
221
|
+
break;
|
|
222
|
+
case 9:
|
|
223
|
+
this.state.strikethrough = true;
|
|
224
|
+
break;
|
|
225
|
+
case 22:
|
|
226
|
+
this.state.bold = false;
|
|
227
|
+
this.state.dim = false;
|
|
228
|
+
break;
|
|
229
|
+
case 23:
|
|
230
|
+
this.state.italic = false;
|
|
231
|
+
break;
|
|
232
|
+
case 24:
|
|
233
|
+
this.state.underline = false;
|
|
234
|
+
break;
|
|
235
|
+
case 25:
|
|
236
|
+
this.state.blink = false;
|
|
237
|
+
this.state.rapidBlink = false;
|
|
238
|
+
break;
|
|
239
|
+
case 27:
|
|
240
|
+
this.state.reverse = false;
|
|
241
|
+
break;
|
|
242
|
+
case 28:
|
|
243
|
+
this.state.secret = false;
|
|
244
|
+
break;
|
|
245
|
+
case 29:
|
|
246
|
+
this.state.strikethrough = false;
|
|
247
|
+
break;
|
|
248
|
+
case 30:
|
|
249
|
+
this.state.foregroundColor = "black";
|
|
250
|
+
this.state.fgRgb = null;
|
|
251
|
+
break;
|
|
252
|
+
case 31:
|
|
253
|
+
this.state.foregroundColor = "red";
|
|
254
|
+
this.state.fgRgb = null;
|
|
255
|
+
break;
|
|
256
|
+
case 32:
|
|
257
|
+
this.state.foregroundColor = "green";
|
|
258
|
+
this.state.fgRgb = null;
|
|
259
|
+
break;
|
|
260
|
+
case 33:
|
|
261
|
+
this.state.foregroundColor = "yellow";
|
|
262
|
+
this.state.fgRgb = null;
|
|
263
|
+
break;
|
|
264
|
+
case 34:
|
|
265
|
+
this.state.foregroundColor = "blue";
|
|
266
|
+
this.state.fgRgb = null;
|
|
267
|
+
break;
|
|
268
|
+
case 35:
|
|
269
|
+
this.state.foregroundColor = "magenta";
|
|
270
|
+
this.state.fgRgb = null;
|
|
271
|
+
break;
|
|
272
|
+
case 36:
|
|
273
|
+
this.state.foregroundColor = "cyan";
|
|
274
|
+
this.state.fgRgb = null;
|
|
275
|
+
break;
|
|
276
|
+
case 37:
|
|
277
|
+
this.state.foregroundColor = "white";
|
|
278
|
+
this.state.fgRgb = null;
|
|
279
|
+
break;
|
|
280
|
+
case 38:
|
|
281
|
+
// Extended foreground: 38;5;n (256-color) or 38;2;r;g;b (true-color)
|
|
282
|
+
if (ci + 1 < codes.length) {
|
|
283
|
+
if (codes[ci + 1] === 5) {
|
|
284
|
+
if (ci + 2 < codes.length) {
|
|
285
|
+
const idx = codes[ci + 2];
|
|
286
|
+
if (idx >= 0 && idx <= 7 && ANSI_NAMED[idx]) {
|
|
287
|
+
this.state.foregroundColor = ANSI_NAMED[idx];
|
|
288
|
+
this.state.fgRgb = null;
|
|
289
|
+
}
|
|
290
|
+
else if (idx >= 0 && idx <= 255 && ANSI_256[idx]) {
|
|
291
|
+
this.state.foregroundColor = null;
|
|
292
|
+
this.state.fgRgb = ANSI_256[idx];
|
|
293
|
+
}
|
|
294
|
+
ci += 2;
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
ci += 1;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
else if (codes[ci + 1] === 2) {
|
|
301
|
+
if (ci + 4 < codes.length) {
|
|
302
|
+
this.state.foregroundColor = null;
|
|
303
|
+
const r = Math.max(0, Math.min(255, codes[ci + 2]));
|
|
304
|
+
const g = Math.max(0, Math.min(255, codes[ci + 3]));
|
|
305
|
+
const b = Math.max(0, Math.min(255, codes[ci + 4]));
|
|
306
|
+
this.state.fgRgb = "rgb(" + r + "," + g + "," + b + ")";
|
|
307
|
+
ci += 4;
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
ci = codes.length - 1;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
break;
|
|
315
|
+
case 39:
|
|
316
|
+
this.state.foregroundColor = null;
|
|
317
|
+
this.state.fgRgb = null;
|
|
318
|
+
break;
|
|
319
|
+
case 40:
|
|
320
|
+
this.state.backgroundColor = "black";
|
|
321
|
+
this.state.bgRgb = null;
|
|
322
|
+
break;
|
|
323
|
+
case 41:
|
|
324
|
+
this.state.backgroundColor = "red";
|
|
325
|
+
this.state.bgRgb = null;
|
|
326
|
+
break;
|
|
327
|
+
case 42:
|
|
328
|
+
this.state.backgroundColor = "green";
|
|
329
|
+
this.state.bgRgb = null;
|
|
330
|
+
break;
|
|
331
|
+
case 43:
|
|
332
|
+
this.state.backgroundColor = "yellow";
|
|
333
|
+
this.state.bgRgb = null;
|
|
334
|
+
break;
|
|
335
|
+
case 44:
|
|
336
|
+
this.state.backgroundColor = "blue";
|
|
337
|
+
this.state.bgRgb = null;
|
|
338
|
+
break;
|
|
339
|
+
case 45:
|
|
340
|
+
this.state.backgroundColor = "magenta";
|
|
341
|
+
this.state.bgRgb = null;
|
|
342
|
+
break;
|
|
343
|
+
case 46:
|
|
344
|
+
this.state.backgroundColor = "cyan";
|
|
345
|
+
this.state.bgRgb = null;
|
|
346
|
+
break;
|
|
347
|
+
case 47:
|
|
348
|
+
this.state.backgroundColor = "white";
|
|
349
|
+
this.state.bgRgb = null;
|
|
350
|
+
break;
|
|
351
|
+
case 48:
|
|
352
|
+
// Extended background: 48;5;n (256-color) or 48;2;r;g;b (true-color)
|
|
353
|
+
if (ci + 1 < codes.length) {
|
|
354
|
+
if (codes[ci + 1] === 5) {
|
|
355
|
+
if (ci + 2 < codes.length) {
|
|
356
|
+
const idx = codes[ci + 2];
|
|
357
|
+
if (idx >= 0 && idx <= 7 && ANSI_NAMED[idx]) {
|
|
358
|
+
this.state.backgroundColor = ANSI_NAMED[idx];
|
|
359
|
+
this.state.bgRgb = null;
|
|
360
|
+
}
|
|
361
|
+
else if (idx >= 0 && idx <= 255 && ANSI_256[idx]) {
|
|
362
|
+
this.state.backgroundColor = null;
|
|
363
|
+
this.state.bgRgb = ANSI_256[idx];
|
|
364
|
+
}
|
|
365
|
+
ci += 2;
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
ci += 1;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
else if (codes[ci + 1] === 2) {
|
|
372
|
+
if (ci + 4 < codes.length) {
|
|
373
|
+
this.state.backgroundColor = null;
|
|
374
|
+
const r = Math.max(0, Math.min(255, codes[ci + 2]));
|
|
375
|
+
const g = Math.max(0, Math.min(255, codes[ci + 3]));
|
|
376
|
+
const b = Math.max(0, Math.min(255, codes[ci + 4]));
|
|
377
|
+
this.state.bgRgb = "rgb(" + r + "," + g + "," + b + ")";
|
|
378
|
+
ci += 4;
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
ci = codes.length - 1;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
break;
|
|
386
|
+
case 49:
|
|
387
|
+
this.state.backgroundColor = null;
|
|
388
|
+
this.state.bgRgb = null;
|
|
389
|
+
break;
|
|
390
|
+
// Bright foreground colors
|
|
391
|
+
case 90:
|
|
392
|
+
this.state.foregroundColor = null;
|
|
393
|
+
this.state.fgRgb = ANSI_256[8];
|
|
394
|
+
break;
|
|
395
|
+
case 91:
|
|
396
|
+
this.state.foregroundColor = null;
|
|
397
|
+
this.state.fgRgb = ANSI_256[9];
|
|
398
|
+
break;
|
|
399
|
+
case 92:
|
|
400
|
+
this.state.foregroundColor = null;
|
|
401
|
+
this.state.fgRgb = ANSI_256[10];
|
|
402
|
+
break;
|
|
403
|
+
case 93:
|
|
404
|
+
this.state.foregroundColor = null;
|
|
405
|
+
this.state.fgRgb = ANSI_256[11];
|
|
406
|
+
break;
|
|
407
|
+
case 94:
|
|
408
|
+
this.state.foregroundColor = null;
|
|
409
|
+
this.state.fgRgb = ANSI_256[12];
|
|
410
|
+
break;
|
|
411
|
+
case 95:
|
|
412
|
+
this.state.foregroundColor = null;
|
|
413
|
+
this.state.fgRgb = ANSI_256[13];
|
|
414
|
+
break;
|
|
415
|
+
case 96:
|
|
416
|
+
this.state.foregroundColor = null;
|
|
417
|
+
this.state.fgRgb = ANSI_256[14];
|
|
418
|
+
break;
|
|
419
|
+
case 97:
|
|
420
|
+
this.state.foregroundColor = null;
|
|
421
|
+
this.state.fgRgb = ANSI_256[15];
|
|
422
|
+
break;
|
|
423
|
+
// Bright background colors
|
|
424
|
+
case 100:
|
|
425
|
+
this.state.backgroundColor = null;
|
|
426
|
+
this.state.bgRgb = ANSI_256[8];
|
|
427
|
+
break;
|
|
428
|
+
case 101:
|
|
429
|
+
this.state.backgroundColor = null;
|
|
430
|
+
this.state.bgRgb = ANSI_256[9];
|
|
431
|
+
break;
|
|
432
|
+
case 102:
|
|
433
|
+
this.state.backgroundColor = null;
|
|
434
|
+
this.state.bgRgb = ANSI_256[10];
|
|
435
|
+
break;
|
|
436
|
+
case 103:
|
|
437
|
+
this.state.backgroundColor = null;
|
|
438
|
+
this.state.bgRgb = ANSI_256[11];
|
|
439
|
+
break;
|
|
440
|
+
case 104:
|
|
441
|
+
this.state.backgroundColor = null;
|
|
442
|
+
this.state.bgRgb = ANSI_256[12];
|
|
443
|
+
break;
|
|
444
|
+
case 105:
|
|
445
|
+
this.state.backgroundColor = null;
|
|
446
|
+
this.state.bgRgb = ANSI_256[13];
|
|
447
|
+
break;
|
|
448
|
+
case 106:
|
|
449
|
+
this.state.backgroundColor = null;
|
|
450
|
+
this.state.bgRgb = ANSI_256[14];
|
|
451
|
+
break;
|
|
452
|
+
case 107:
|
|
453
|
+
this.state.backgroundColor = null;
|
|
454
|
+
this.state.bgRgb = ANSI_256[15];
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
addSpan(line.substring(i));
|
|
460
|
+
return lineSpan;
|
|
39
461
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (match === null) break;
|
|
74
|
-
|
|
75
|
-
const j = match.index;
|
|
76
|
-
addSpan(line.substring(i, j));
|
|
77
|
-
i = j + match[0].length;
|
|
78
|
-
|
|
79
|
-
if (match[1] === undefined) continue;
|
|
80
|
-
|
|
81
|
-
for (const colorCode of match[1].split(";")) {
|
|
82
|
-
switch (parseInt(colorCode)) {
|
|
83
|
-
case 0:
|
|
84
|
-
// reset
|
|
85
|
-
this.state.bold = false;
|
|
86
|
-
this.state.italic = false;
|
|
87
|
-
this.state.underline = false;
|
|
88
|
-
this.state.strikethrough = false;
|
|
89
|
-
this.state.foregroundColor = null;
|
|
90
|
-
this.state.backgroundColor = null;
|
|
91
|
-
this.state.secret = false;
|
|
92
|
-
this.state.blink = false;
|
|
93
|
-
this.state.rapidBlink = false;
|
|
94
|
-
break;
|
|
95
|
-
case 1:
|
|
96
|
-
this.state.bold = true;
|
|
97
|
-
break;
|
|
98
|
-
case 3:
|
|
99
|
-
this.state.italic = true;
|
|
100
|
-
break;
|
|
101
|
-
case 4:
|
|
102
|
-
this.state.underline = true;
|
|
103
|
-
break;
|
|
104
|
-
case 5:
|
|
105
|
-
this.state.blink = true;
|
|
106
|
-
break;
|
|
107
|
-
case 6:
|
|
108
|
-
this.state.rapidBlink = true;
|
|
109
|
-
break;
|
|
110
|
-
case 8:
|
|
111
|
-
this.state.secret = true;
|
|
112
|
-
break;
|
|
113
|
-
case 9:
|
|
114
|
-
this.state.strikethrough = true;
|
|
115
|
-
break;
|
|
116
|
-
case 22:
|
|
117
|
-
this.state.bold = false;
|
|
118
|
-
break;
|
|
119
|
-
case 23:
|
|
120
|
-
this.state.italic = false;
|
|
121
|
-
break;
|
|
122
|
-
case 24:
|
|
123
|
-
this.state.underline = false;
|
|
124
|
-
break;
|
|
125
|
-
case 25:
|
|
126
|
-
this.state.blink = false;
|
|
127
|
-
this.state.rapidBlink = false;
|
|
128
|
-
break;
|
|
129
|
-
case 28:
|
|
130
|
-
this.state.secret = false;
|
|
131
|
-
break;
|
|
132
|
-
case 29:
|
|
133
|
-
this.state.strikethrough = false;
|
|
134
|
-
break;
|
|
135
|
-
case 30:
|
|
136
|
-
this.state.foregroundColor = "black";
|
|
137
|
-
break;
|
|
138
|
-
case 31:
|
|
139
|
-
this.state.foregroundColor = "red";
|
|
140
|
-
break;
|
|
141
|
-
case 32:
|
|
142
|
-
this.state.foregroundColor = "green";
|
|
143
|
-
break;
|
|
144
|
-
case 33:
|
|
145
|
-
this.state.foregroundColor = "yellow";
|
|
146
|
-
break;
|
|
147
|
-
case 34:
|
|
148
|
-
this.state.foregroundColor = "blue";
|
|
149
|
-
break;
|
|
150
|
-
case 35:
|
|
151
|
-
this.state.foregroundColor = "magenta";
|
|
152
|
-
break;
|
|
153
|
-
case 36:
|
|
154
|
-
this.state.foregroundColor = "cyan";
|
|
155
|
-
break;
|
|
156
|
-
case 37:
|
|
157
|
-
this.state.foregroundColor = "white";
|
|
158
|
-
break;
|
|
159
|
-
case 39:
|
|
160
|
-
this.state.foregroundColor = null;
|
|
161
|
-
break;
|
|
162
|
-
case 41:
|
|
163
|
-
this.state.backgroundColor = "red";
|
|
164
|
-
break;
|
|
165
|
-
case 42:
|
|
166
|
-
this.state.backgroundColor = "green";
|
|
167
|
-
break;
|
|
168
|
-
case 43:
|
|
169
|
-
this.state.backgroundColor = "yellow";
|
|
170
|
-
break;
|
|
171
|
-
case 44:
|
|
172
|
-
this.state.backgroundColor = "blue";
|
|
173
|
-
break;
|
|
174
|
-
case 45:
|
|
175
|
-
this.state.backgroundColor = "magenta";
|
|
176
|
-
break;
|
|
177
|
-
case 46:
|
|
178
|
-
this.state.backgroundColor = "cyan";
|
|
179
|
-
break;
|
|
180
|
-
case 47:
|
|
181
|
-
this.state.backgroundColor = "white";
|
|
182
|
-
break;
|
|
183
|
-
case 40:
|
|
184
|
-
this.state.backgroundColor = "black";
|
|
185
|
-
break;
|
|
186
|
-
case 49:
|
|
187
|
-
this.state.backgroundColor = null;
|
|
188
|
-
break;
|
|
462
|
+
processLines() {
|
|
463
|
+
const atBottom = this.targetElement.scrollTop >
|
|
464
|
+
this.targetElement.scrollHeight - this.targetElement.offsetHeight - 50;
|
|
465
|
+
const prevCarriageReturn = this.state.carriageReturn;
|
|
466
|
+
const fragment = document.createDocumentFragment();
|
|
467
|
+
if (this.state.lines.length === 0) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
for (const line of this.state.lines) {
|
|
471
|
+
if (line === "\r") {
|
|
472
|
+
this.state.carriageReturn = true;
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
if (this.state.carriageReturn && line !== "\n") {
|
|
476
|
+
if (fragment.childElementCount) {
|
|
477
|
+
fragment.removeChild(fragment.lastChild);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
const hadCarriageReturn = line.endsWith("\r");
|
|
481
|
+
fragment.appendChild(this.processLine(line.replace(/\r/g, "")));
|
|
482
|
+
this.state.carriageReturn = hadCarriageReturn;
|
|
483
|
+
}
|
|
484
|
+
if (prevCarriageReturn &&
|
|
485
|
+
fragment.childElementCount > 0 &&
|
|
486
|
+
this.targetElement.lastChild) {
|
|
487
|
+
this.targetElement.replaceChild(fragment, this.targetElement.lastChild);
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
this.targetElement.appendChild(fragment);
|
|
491
|
+
}
|
|
492
|
+
this.state.lines = [];
|
|
493
|
+
if (atBottom) {
|
|
494
|
+
this.targetElement.scrollTop = this.targetElement.scrollHeight;
|
|
189
495
|
}
|
|
190
|
-
}
|
|
191
496
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
this.targetElement.scrollHeight - this.targetElement.offsetHeight - scrollThreshold;
|
|
198
|
-
|
|
199
|
-
addSpan(line.substring(i));
|
|
200
|
-
|
|
201
|
-
// Keep scroll at bottom
|
|
202
|
-
if (atBottom) {
|
|
203
|
-
this.targetElement.scrollTop = this.targetElement.scrollHeight;
|
|
497
|
+
addLine(line) {
|
|
498
|
+
if (this.state.lines.length === 0) {
|
|
499
|
+
setTimeout(() => this.processLines(), 0);
|
|
500
|
+
}
|
|
501
|
+
this.state.lines.push(line);
|
|
204
502
|
}
|
|
205
|
-
}
|
|
206
503
|
}
|
|
207
|
-
|
|
208
504
|
export const coloredConsoleStyles = `
|
|
209
505
|
.log {
|
|
210
506
|
flex: 1;
|
|
@@ -215,16 +511,18 @@ export const coloredConsoleStyles = `
|
|
|
215
511
|
padding: 16px;
|
|
216
512
|
overflow: auto;
|
|
217
513
|
line-height: 1.45;
|
|
218
|
-
border-radius:
|
|
514
|
+
border-radius: 3px;
|
|
219
515
|
white-space: pre-wrap;
|
|
220
516
|
overflow-wrap: break-word;
|
|
221
517
|
color: #ddd;
|
|
222
|
-
min-height: 0;
|
|
223
518
|
}
|
|
224
519
|
|
|
225
520
|
.log-bold {
|
|
226
521
|
font-weight: bold;
|
|
227
522
|
}
|
|
523
|
+
.log-dim {
|
|
524
|
+
opacity: 0.5;
|
|
525
|
+
}
|
|
228
526
|
.log-italic {
|
|
229
527
|
font-style: italic;
|
|
230
528
|
}
|
|
@@ -237,6 +535,17 @@ export const coloredConsoleStyles = `
|
|
|
237
535
|
.log-underline.log-strikethrough {
|
|
238
536
|
text-decoration: underline line-through;
|
|
239
537
|
}
|
|
538
|
+
.log-blink {
|
|
539
|
+
animation: blink 1s step-end infinite;
|
|
540
|
+
}
|
|
541
|
+
.log-rapid-blink {
|
|
542
|
+
animation: blink 0.4s step-end infinite;
|
|
543
|
+
}
|
|
544
|
+
@keyframes blink {
|
|
545
|
+
50% {
|
|
546
|
+
opacity: 0;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
240
549
|
.log-secret {
|
|
241
550
|
-webkit-user-select: none;
|
|
242
551
|
-moz-user-select: none;
|
|
@@ -248,16 +557,9 @@ export const coloredConsoleStyles = `
|
|
|
248
557
|
width: 1px;
|
|
249
558
|
font-size: 1px;
|
|
250
559
|
}
|
|
251
|
-
.log-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
.log-rapid-blink {
|
|
255
|
-
animation: blink 0.3s step-start infinite;
|
|
256
|
-
}
|
|
257
|
-
@keyframes blink {
|
|
258
|
-
50% {
|
|
259
|
-
opacity: 0;
|
|
260
|
-
}
|
|
560
|
+
.log-reverse {
|
|
561
|
+
background: #ddd;
|
|
562
|
+
color: #1c1c1c;
|
|
261
563
|
}
|
|
262
564
|
.log-fg-black {
|
|
263
565
|
color: rgb(128, 128, 128);
|