chrome-devtools-frontend 1.0.954271 → 1.0.954427
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.
|
@@ -4,47 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import type * as SDK from '../../core/sdk/sdk.js';
|
|
6
6
|
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const ANSI_COLOR_CODES = new Map([
|
|
11
|
-
// Foreground codes
|
|
12
|
-
[30, 'color:black'],
|
|
13
|
-
[31, 'color:red'],
|
|
14
|
-
[32, 'color:green'],
|
|
15
|
-
[33, 'color:yellow'],
|
|
16
|
-
[34, 'color:blue'],
|
|
17
|
-
[35, 'color:magenta'],
|
|
18
|
-
[36, 'color:cyan'],
|
|
19
|
-
[37, 'color:lightGray'],
|
|
20
|
-
[39, 'color:default'],
|
|
21
|
-
[90, 'color:darkGray'],
|
|
22
|
-
[91, 'color:lightRed'],
|
|
23
|
-
[92, 'color:lightGreen'],
|
|
24
|
-
[93, 'color:lightYellow'],
|
|
25
|
-
[94, 'color:lightBlue'],
|
|
26
|
-
[95, 'color:lightMagenta'],
|
|
27
|
-
[96, 'color:lightCyan'],
|
|
28
|
-
[97, 'color:white'],
|
|
29
|
-
// Background codes
|
|
30
|
-
[40, 'background:black'],
|
|
31
|
-
[41, 'background:red'],
|
|
32
|
-
[42, 'background:green'],
|
|
33
|
-
[43, 'background:yellow'],
|
|
34
|
-
[44, 'background:blue'],
|
|
35
|
-
[45, 'background:magenta'],
|
|
36
|
-
[46, 'background:cyan'],
|
|
37
|
-
[47, 'background:lightGray'],
|
|
38
|
-
[49, 'background:default'],
|
|
39
|
-
[100, 'background:darkGray'],
|
|
40
|
-
[101, 'background:lightRed'],
|
|
41
|
-
[102, 'background:lightGreen'],
|
|
42
|
-
[103, 'background:lightYellow'],
|
|
43
|
-
[104, 'background:lightBlue'],
|
|
44
|
-
[105, 'background:lightMagenta'],
|
|
45
|
-
[106, 'background:lightCyan'],
|
|
46
|
-
[107, 'background:white'],
|
|
47
|
-
]);
|
|
7
|
+
// VGA color palette
|
|
8
|
+
const ANSI_COLORS = ['#000000', '#AA0000', '#00AA00', '#AA5500', '#0000AA', '#AA00AA', '#00AAAA', '#AAAAAA'];
|
|
9
|
+
const ANSI_BRIGHT_COLORS = ['#555555', '#FF5555', '#55FF55', '#FFFF55', '#5555FF', '#FF55FF', '#55FFFF', '#FFFFFF'];
|
|
48
10
|
|
|
49
11
|
export type FormatToken = {
|
|
50
12
|
type: 'generic'|'optimal',
|
|
@@ -71,6 +33,23 @@ export const format = (fmt: string, args: SDK.RemoteObject.RemoteObject[]): {
|
|
|
71
33
|
} => {
|
|
72
34
|
const tokens: FormatToken[] = [];
|
|
73
35
|
|
|
36
|
+
// Current maintained style for ANSI color codes.
|
|
37
|
+
const currentStyle = new Map<string, string>();
|
|
38
|
+
function addTextDecoration(value: string): void {
|
|
39
|
+
const textDecoration = currentStyle.get('text-decoration') ?? '';
|
|
40
|
+
if (!textDecoration.includes(value)) {
|
|
41
|
+
currentStyle.set('text-decoration', `${textDecoration} ${value}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function removeTextDecoration(value: string): void {
|
|
45
|
+
const textDecoration = currentStyle.get('text-decoration')?.replace(` ${value}`, '');
|
|
46
|
+
if (textDecoration) {
|
|
47
|
+
currentStyle.set('text-decoration', textDecoration);
|
|
48
|
+
} else {
|
|
49
|
+
currentStyle.delete('text-decoration');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
74
53
|
function addStringToken(value: string): void {
|
|
75
54
|
if (!value) {
|
|
76
55
|
return;
|
|
@@ -83,7 +62,7 @@ export const format = (fmt: string, args: SDK.RemoteObject.RemoteObject[]): {
|
|
|
83
62
|
}
|
|
84
63
|
|
|
85
64
|
let argIndex = 0;
|
|
86
|
-
const re = /%([%_Oocsdfi])|\x1B\[(\d
|
|
65
|
+
const re = /%([%_Oocsdfi])|\x1B\[([\d;]*)m/;
|
|
87
66
|
for (let match = re.exec(fmt); match !== null; match = re.exec(fmt)) {
|
|
88
67
|
addStringToken(match.input.substring(0, match.index));
|
|
89
68
|
let substitution: number|string|undefined = undefined;
|
|
@@ -134,12 +113,75 @@ export const format = (fmt: string, args: SDK.RemoteObject.RemoteObject[]): {
|
|
|
134
113
|
}
|
|
135
114
|
break;
|
|
136
115
|
case undefined: {
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
116
|
+
const codes = (match[2] || '0').split(';').map(code => code ? parseInt(code, 10) : 0);
|
|
117
|
+
while (codes.length) {
|
|
118
|
+
const code = codes.shift() as number;
|
|
119
|
+
switch (code) {
|
|
120
|
+
case 0:
|
|
121
|
+
currentStyle.clear();
|
|
122
|
+
break;
|
|
123
|
+
case 1:
|
|
124
|
+
currentStyle.set('font-weight', 'bold');
|
|
125
|
+
break;
|
|
126
|
+
case 2:
|
|
127
|
+
currentStyle.set('font-weight', 'lighter');
|
|
128
|
+
break;
|
|
129
|
+
case 3:
|
|
130
|
+
currentStyle.set('font-style', 'italic');
|
|
131
|
+
break;
|
|
132
|
+
case 4:
|
|
133
|
+
addTextDecoration('underline');
|
|
134
|
+
break;
|
|
135
|
+
case 9:
|
|
136
|
+
addTextDecoration('line-through');
|
|
137
|
+
break;
|
|
138
|
+
case 22:
|
|
139
|
+
currentStyle.delete('font-weight');
|
|
140
|
+
break;
|
|
141
|
+
case 23:
|
|
142
|
+
currentStyle.delete('font-style');
|
|
143
|
+
break;
|
|
144
|
+
case 24:
|
|
145
|
+
removeTextDecoration('underline');
|
|
146
|
+
break;
|
|
147
|
+
case 29:
|
|
148
|
+
removeTextDecoration('line-through');
|
|
149
|
+
break;
|
|
150
|
+
case 38:
|
|
151
|
+
case 48:
|
|
152
|
+
if (codes.shift() === 2) {
|
|
153
|
+
const r = codes.shift() ?? 0, g = codes.shift() ?? 0, b = codes.shift() ?? 0;
|
|
154
|
+
currentStyle.set(code === 38 ? 'color' : 'background', `rgb(${r},${g},${b})`);
|
|
155
|
+
}
|
|
156
|
+
break;
|
|
157
|
+
case 39:
|
|
158
|
+
case 49:
|
|
159
|
+
currentStyle.delete(code === 39 ? 'color' : 'background');
|
|
160
|
+
break;
|
|
161
|
+
case 53:
|
|
162
|
+
addTextDecoration('overline');
|
|
163
|
+
break;
|
|
164
|
+
case 55:
|
|
165
|
+
removeTextDecoration('overline');
|
|
166
|
+
break;
|
|
167
|
+
default: {
|
|
168
|
+
const color = ANSI_COLORS[code - 30] ?? ANSI_BRIGHT_COLORS[code - 90];
|
|
169
|
+
if (color !== undefined) {
|
|
170
|
+
currentStyle.set('color', color);
|
|
171
|
+
} else {
|
|
172
|
+
const background = ANSI_COLORS[code - 40] ?? ANSI_BRIGHT_COLORS[code - 100];
|
|
173
|
+
if (background !== undefined) {
|
|
174
|
+
currentStyle.set('background', background);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
142
180
|
}
|
|
181
|
+
const value = [...currentStyle.entries()].map(([key, val]) => `${key}:${val.trimStart()}`).join(';');
|
|
182
|
+
const type = 'style';
|
|
183
|
+
tokens.push({type, value});
|
|
184
|
+
substitution = '';
|
|
143
185
|
break;
|
|
144
186
|
}
|
|
145
187
|
}
|
|
@@ -293,7 +293,7 @@ export class SourcesPanel extends UI.Panel.Panel implements UI.ContextMenu.Provi
|
|
|
293
293
|
Extensions.ExtensionServer.ExtensionServer.instance().addEventListener(
|
|
294
294
|
Extensions.ExtensionServer.Events.SidebarPaneAdded, this.extensionSidebarPaneAdded, this);
|
|
295
295
|
SDK.TargetManager.TargetManager.instance().observeTargets(this);
|
|
296
|
-
this.lastModificationTime =
|
|
296
|
+
this.lastModificationTime = -Infinity;
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
static instance(opts: {
|
package/package.json
CHANGED