@rushstack/terminal 0.21.0 → 0.22.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/CHANGELOG.json +20 -0
- package/CHANGELOG.md +8 -1
- package/lib-esm/AnsiEscape.js +131 -0
- package/lib-esm/AnsiEscape.js.map +1 -0
- package/lib-esm/CallbackWritable.js +27 -0
- package/lib-esm/CallbackWritable.js.map +1 -0
- package/lib-esm/Colorize.js +158 -0
- package/lib-esm/Colorize.js.map +1 -0
- package/lib-esm/ConsoleTerminalProvider.js +58 -0
- package/lib-esm/ConsoleTerminalProvider.js.map +1 -0
- package/lib-esm/DiscardStdoutTransform.js +90 -0
- package/lib-esm/DiscardStdoutTransform.js.map +1 -0
- package/lib-esm/IProblemCollector.js +4 -0
- package/lib-esm/IProblemCollector.js.map +1 -0
- package/lib-esm/ITerminal.js +4 -0
- package/lib-esm/ITerminal.js.map +1 -0
- package/lib-esm/ITerminalChunk.js +18 -0
- package/lib-esm/ITerminalChunk.js.map +1 -0
- package/lib-esm/ITerminalProvider.js +29 -0
- package/lib-esm/ITerminalProvider.js.map +1 -0
- package/lib-esm/MockWritable.js +28 -0
- package/lib-esm/MockWritable.js.map +1 -0
- package/lib-esm/NoOpTerminalProvider.js +30 -0
- package/lib-esm/NoOpTerminalProvider.js.map +1 -0
- package/lib-esm/NormalizeNewlinesTextRewriter.js +66 -0
- package/lib-esm/NormalizeNewlinesTextRewriter.js.map +1 -0
- package/lib-esm/PrefixProxyTerminalProvider.js +58 -0
- package/lib-esm/PrefixProxyTerminalProvider.js.map +1 -0
- package/lib-esm/PrintUtilities.js +146 -0
- package/lib-esm/PrintUtilities.js.map +1 -0
- package/lib-esm/ProblemCollector.js +85 -0
- package/lib-esm/ProblemCollector.js.map +1 -0
- package/lib-esm/RemoveColorsTextRewriter.js +91 -0
- package/lib-esm/RemoveColorsTextRewriter.js.map +1 -0
- package/lib-esm/SplitterTransform.js +74 -0
- package/lib-esm/SplitterTransform.js.map +1 -0
- package/lib-esm/StdioLineTransform.js +111 -0
- package/lib-esm/StdioLineTransform.js.map +1 -0
- package/lib-esm/StdioSummarizer.js +95 -0
- package/lib-esm/StdioSummarizer.js.map +1 -0
- package/lib-esm/StdioWritable.js +27 -0
- package/lib-esm/StdioWritable.js.map +1 -0
- package/lib-esm/StringBufferTerminalProvider.js +185 -0
- package/lib-esm/StringBufferTerminalProvider.js.map +1 -0
- package/lib-esm/Terminal.js +150 -0
- package/lib-esm/Terminal.js.map +1 -0
- package/lib-esm/TerminalStreamWritable.js +49 -0
- package/lib-esm/TerminalStreamWritable.js.map +1 -0
- package/lib-esm/TerminalTransform.js +53 -0
- package/lib-esm/TerminalTransform.js.map +1 -0
- package/lib-esm/TerminalWritable.js +119 -0
- package/lib-esm/TerminalWritable.js.map +1 -0
- package/lib-esm/TextRewriter.js +35 -0
- package/lib-esm/TextRewriter.js.map +1 -0
- package/lib-esm/TextRewriterTransform.js +90 -0
- package/lib-esm/TextRewriterTransform.js.map +1 -0
- package/lib-esm/index.js +38 -0
- package/lib-esm/index.js.map +1 -0
- package/package.json +27 -5
- /package/{lib → lib-commonjs}/AnsiEscape.js +0 -0
- /package/{lib → lib-commonjs}/AnsiEscape.js.map +0 -0
- /package/{lib → lib-commonjs}/CallbackWritable.js +0 -0
- /package/{lib → lib-commonjs}/CallbackWritable.js.map +0 -0
- /package/{lib → lib-commonjs}/Colorize.js +0 -0
- /package/{lib → lib-commonjs}/Colorize.js.map +0 -0
- /package/{lib → lib-commonjs}/ConsoleTerminalProvider.js +0 -0
- /package/{lib → lib-commonjs}/ConsoleTerminalProvider.js.map +0 -0
- /package/{lib → lib-commonjs}/DiscardStdoutTransform.js +0 -0
- /package/{lib → lib-commonjs}/DiscardStdoutTransform.js.map +0 -0
- /package/{lib → lib-commonjs}/IProblemCollector.js +0 -0
- /package/{lib → lib-commonjs}/IProblemCollector.js.map +0 -0
- /package/{lib → lib-commonjs}/ITerminal.js +0 -0
- /package/{lib → lib-commonjs}/ITerminal.js.map +0 -0
- /package/{lib → lib-commonjs}/ITerminalChunk.js +0 -0
- /package/{lib → lib-commonjs}/ITerminalChunk.js.map +0 -0
- /package/{lib → lib-commonjs}/ITerminalProvider.js +0 -0
- /package/{lib → lib-commonjs}/ITerminalProvider.js.map +0 -0
- /package/{lib → lib-commonjs}/MockWritable.js +0 -0
- /package/{lib → lib-commonjs}/MockWritable.js.map +0 -0
- /package/{lib → lib-commonjs}/NoOpTerminalProvider.js +0 -0
- /package/{lib → lib-commonjs}/NoOpTerminalProvider.js.map +0 -0
- /package/{lib → lib-commonjs}/NormalizeNewlinesTextRewriter.js +0 -0
- /package/{lib → lib-commonjs}/NormalizeNewlinesTextRewriter.js.map +0 -0
- /package/{lib → lib-commonjs}/PrefixProxyTerminalProvider.js +0 -0
- /package/{lib → lib-commonjs}/PrefixProxyTerminalProvider.js.map +0 -0
- /package/{lib → lib-commonjs}/PrintUtilities.js +0 -0
- /package/{lib → lib-commonjs}/PrintUtilities.js.map +0 -0
- /package/{lib → lib-commonjs}/ProblemCollector.js +0 -0
- /package/{lib → lib-commonjs}/ProblemCollector.js.map +0 -0
- /package/{lib → lib-commonjs}/RemoveColorsTextRewriter.js +0 -0
- /package/{lib → lib-commonjs}/RemoveColorsTextRewriter.js.map +0 -0
- /package/{lib → lib-commonjs}/SplitterTransform.js +0 -0
- /package/{lib → lib-commonjs}/SplitterTransform.js.map +0 -0
- /package/{lib → lib-commonjs}/StdioLineTransform.js +0 -0
- /package/{lib → lib-commonjs}/StdioLineTransform.js.map +0 -0
- /package/{lib → lib-commonjs}/StdioSummarizer.js +0 -0
- /package/{lib → lib-commonjs}/StdioSummarizer.js.map +0 -0
- /package/{lib → lib-commonjs}/StdioWritable.js +0 -0
- /package/{lib → lib-commonjs}/StdioWritable.js.map +0 -0
- /package/{lib → lib-commonjs}/StringBufferTerminalProvider.js +0 -0
- /package/{lib → lib-commonjs}/StringBufferTerminalProvider.js.map +0 -0
- /package/{lib → lib-commonjs}/Terminal.js +0 -0
- /package/{lib → lib-commonjs}/Terminal.js.map +0 -0
- /package/{lib → lib-commonjs}/TerminalStreamWritable.js +0 -0
- /package/{lib → lib-commonjs}/TerminalStreamWritable.js.map +0 -0
- /package/{lib → lib-commonjs}/TerminalTransform.js +0 -0
- /package/{lib → lib-commonjs}/TerminalTransform.js.map +0 -0
- /package/{lib → lib-commonjs}/TerminalWritable.js +0 -0
- /package/{lib → lib-commonjs}/TerminalWritable.js.map +0 -0
- /package/{lib → lib-commonjs}/TextRewriter.js +0 -0
- /package/{lib → lib-commonjs}/TextRewriter.js.map +0 -0
- /package/{lib → lib-commonjs}/TextRewriterTransform.js +0 -0
- /package/{lib → lib-commonjs}/TextRewriterTransform.js.map +0 -0
- /package/{lib → lib-commonjs}/index.js +0 -0
- /package/{lib → lib-commonjs}/index.js.map +0 -0
- /package/{lib → lib-dts}/AnsiEscape.d.ts +0 -0
- /package/{lib → lib-dts}/AnsiEscape.d.ts.map +0 -0
- /package/{lib → lib-dts}/CallbackWritable.d.ts +0 -0
- /package/{lib → lib-dts}/CallbackWritable.d.ts.map +0 -0
- /package/{lib → lib-dts}/Colorize.d.ts +0 -0
- /package/{lib → lib-dts}/Colorize.d.ts.map +0 -0
- /package/{lib → lib-dts}/ConsoleTerminalProvider.d.ts +0 -0
- /package/{lib → lib-dts}/ConsoleTerminalProvider.d.ts.map +0 -0
- /package/{lib → lib-dts}/DiscardStdoutTransform.d.ts +0 -0
- /package/{lib → lib-dts}/DiscardStdoutTransform.d.ts.map +0 -0
- /package/{lib → lib-dts}/IProblemCollector.d.ts +0 -0
- /package/{lib → lib-dts}/IProblemCollector.d.ts.map +0 -0
- /package/{lib → lib-dts}/ITerminal.d.ts +0 -0
- /package/{lib → lib-dts}/ITerminal.d.ts.map +0 -0
- /package/{lib → lib-dts}/ITerminalChunk.d.ts +0 -0
- /package/{lib → lib-dts}/ITerminalChunk.d.ts.map +0 -0
- /package/{lib → lib-dts}/ITerminalProvider.d.ts +0 -0
- /package/{lib → lib-dts}/ITerminalProvider.d.ts.map +0 -0
- /package/{lib → lib-dts}/MockWritable.d.ts +0 -0
- /package/{lib → lib-dts}/MockWritable.d.ts.map +0 -0
- /package/{lib → lib-dts}/NoOpTerminalProvider.d.ts +0 -0
- /package/{lib → lib-dts}/NoOpTerminalProvider.d.ts.map +0 -0
- /package/{lib → lib-dts}/NormalizeNewlinesTextRewriter.d.ts +0 -0
- /package/{lib → lib-dts}/NormalizeNewlinesTextRewriter.d.ts.map +0 -0
- /package/{lib → lib-dts}/PrefixProxyTerminalProvider.d.ts +0 -0
- /package/{lib → lib-dts}/PrefixProxyTerminalProvider.d.ts.map +0 -0
- /package/{lib → lib-dts}/PrintUtilities.d.ts +0 -0
- /package/{lib → lib-dts}/PrintUtilities.d.ts.map +0 -0
- /package/{lib → lib-dts}/ProblemCollector.d.ts +0 -0
- /package/{lib → lib-dts}/ProblemCollector.d.ts.map +0 -0
- /package/{lib → lib-dts}/RemoveColorsTextRewriter.d.ts +0 -0
- /package/{lib → lib-dts}/RemoveColorsTextRewriter.d.ts.map +0 -0
- /package/{lib → lib-dts}/SplitterTransform.d.ts +0 -0
- /package/{lib → lib-dts}/SplitterTransform.d.ts.map +0 -0
- /package/{lib → lib-dts}/StdioLineTransform.d.ts +0 -0
- /package/{lib → lib-dts}/StdioLineTransform.d.ts.map +0 -0
- /package/{lib → lib-dts}/StdioSummarizer.d.ts +0 -0
- /package/{lib → lib-dts}/StdioSummarizer.d.ts.map +0 -0
- /package/{lib → lib-dts}/StdioWritable.d.ts +0 -0
- /package/{lib → lib-dts}/StdioWritable.d.ts.map +0 -0
- /package/{lib → lib-dts}/StringBufferTerminalProvider.d.ts +0 -0
- /package/{lib → lib-dts}/StringBufferTerminalProvider.d.ts.map +0 -0
- /package/{lib → lib-dts}/Terminal.d.ts +0 -0
- /package/{lib → lib-dts}/Terminal.d.ts.map +0 -0
- /package/{lib → lib-dts}/TerminalStreamWritable.d.ts +0 -0
- /package/{lib → lib-dts}/TerminalStreamWritable.d.ts.map +0 -0
- /package/{lib → lib-dts}/TerminalTransform.d.ts +0 -0
- /package/{lib → lib-dts}/TerminalTransform.d.ts.map +0 -0
- /package/{lib → lib-dts}/TerminalWritable.d.ts +0 -0
- /package/{lib → lib-dts}/TerminalWritable.d.ts.map +0 -0
- /package/{lib → lib-dts}/TextRewriter.d.ts +0 -0
- /package/{lib → lib-dts}/TextRewriter.d.ts.map +0 -0
- /package/{lib → lib-dts}/TextRewriterTransform.d.ts +0 -0
- /package/{lib → lib-dts}/TextRewriterTransform.d.ts.map +0 -0
- /package/{lib → lib-dts}/index.d.ts +0 -0
- /package/{lib → lib-dts}/index.d.ts.map +0 -0
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/terminal",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.22.0",
|
|
6
|
+
"tag": "@rushstack/terminal_v0.22.0",
|
|
7
|
+
"date": "Thu, 19 Feb 2026 00:04:53 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Normalize package layout. CommonJS is now under `lib-commonjs`, DTS is now under `lib-dts`, and ESM is now under `lib-esm`. Imports to `lib` still work as before, handled by the `\"exports\"` field in `package.json`."
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"dependency": [
|
|
15
|
+
{
|
|
16
|
+
"comment": "Updating dependency \"@rushstack/node-core-library\" to `5.20.0`"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"comment": "Updating dependency \"@rushstack/problem-matcher\" to `0.2.0`"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
4
24
|
{
|
|
5
25
|
"version": "0.21.0",
|
|
6
26
|
"tag": "@rushstack/terminal_v0.21.0",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Change Log - @rushstack/terminal
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 19 Feb 2026 00:04:53 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.22.0
|
|
6
|
+
Thu, 19 Feb 2026 00:04:53 GMT
|
|
7
|
+
|
|
8
|
+
### Minor changes
|
|
9
|
+
|
|
10
|
+
- Normalize package layout. CommonJS is now under `lib-commonjs`, DTS is now under `lib-dts`, and ESM is now under `lib-esm`. Imports to `lib` still work as before, handled by the `"exports"` field in `package.json`.
|
|
4
11
|
|
|
5
12
|
## 0.21.0
|
|
6
13
|
Wed, 07 Jan 2026 01:12:24 GMT
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import { SgrParameterAttribute } from './Colorize';
|
|
4
|
+
/**
|
|
5
|
+
* Operations for working with text strings that contain
|
|
6
|
+
* {@link https://en.wikipedia.org/wiki/ANSI_escape_code | ANSI escape codes}.
|
|
7
|
+
* The most commonly used escape codes set the foreground/background color for console output.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export class AnsiEscape {
|
|
11
|
+
static getEscapeSequenceForAnsiCode(code) {
|
|
12
|
+
return `\u001b[${code}m`;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Returns the input text with all ANSI escape codes removed. For example, this is useful when saving
|
|
16
|
+
* colorized console output to a log file.
|
|
17
|
+
*/
|
|
18
|
+
static removeCodes(text) {
|
|
19
|
+
return text.replace(AnsiEscape._csiRegExp, '');
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Replaces ANSI escape codes with human-readable tokens. This is useful for unit tests
|
|
23
|
+
* that compare text strings in test assertions or snapshot files.
|
|
24
|
+
*/
|
|
25
|
+
static formatForTests(text, options) {
|
|
26
|
+
if (!options) {
|
|
27
|
+
options = {};
|
|
28
|
+
}
|
|
29
|
+
let result = text.replace(AnsiEscape._csiRegExp, (capture, csiCode) => {
|
|
30
|
+
// If it is an SGR code, then try to show a friendly token
|
|
31
|
+
const match = csiCode.match(AnsiEscape._sgrRegExp);
|
|
32
|
+
if (match) {
|
|
33
|
+
const sgrParameter = parseInt(match[1], 10);
|
|
34
|
+
const sgrParameterName = AnsiEscape._tryGetSgrFriendlyName(sgrParameter);
|
|
35
|
+
if (sgrParameterName) {
|
|
36
|
+
// Example: "[black-bg]"
|
|
37
|
+
return `[${sgrParameterName}]`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Otherwise show the raw code, but without the "[" from the CSI prefix
|
|
41
|
+
// Example: "[31m]"
|
|
42
|
+
return `[${csiCode}]`;
|
|
43
|
+
});
|
|
44
|
+
if (options.encodeNewlines) {
|
|
45
|
+
result = result
|
|
46
|
+
.replace(AnsiEscape._backslashNRegExp, '[n]')
|
|
47
|
+
.replace(AnsiEscape._backslashRRegExp, `[r]`);
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
// Returns a human-readable token representing an SGR parameter, or undefined for parameter that is not well-known.
|
|
52
|
+
// The SGR parameter numbers are documented in this table:
|
|
53
|
+
// https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
|
|
54
|
+
static _tryGetSgrFriendlyName(sgiParameter) {
|
|
55
|
+
switch (sgiParameter) {
|
|
56
|
+
case SgrParameterAttribute.BlackForeground:
|
|
57
|
+
return 'black';
|
|
58
|
+
case SgrParameterAttribute.RedForeground:
|
|
59
|
+
return 'red';
|
|
60
|
+
case SgrParameterAttribute.GreenForeground:
|
|
61
|
+
return 'green';
|
|
62
|
+
case SgrParameterAttribute.YellowForeground:
|
|
63
|
+
return 'yellow';
|
|
64
|
+
case SgrParameterAttribute.BlueForeground:
|
|
65
|
+
return 'blue';
|
|
66
|
+
case SgrParameterAttribute.MagentaForeground:
|
|
67
|
+
return 'magenta';
|
|
68
|
+
case SgrParameterAttribute.CyanForeground:
|
|
69
|
+
return 'cyan';
|
|
70
|
+
case SgrParameterAttribute.WhiteForeground:
|
|
71
|
+
return 'white';
|
|
72
|
+
case SgrParameterAttribute.GrayForeground:
|
|
73
|
+
return 'gray';
|
|
74
|
+
case SgrParameterAttribute.DefaultForeground:
|
|
75
|
+
return 'default';
|
|
76
|
+
case SgrParameterAttribute.BlackBackground:
|
|
77
|
+
return 'black-bg';
|
|
78
|
+
case SgrParameterAttribute.RedBackground:
|
|
79
|
+
return 'red-bg';
|
|
80
|
+
case SgrParameterAttribute.GreenBackground:
|
|
81
|
+
return 'green-bg';
|
|
82
|
+
case SgrParameterAttribute.YellowBackground:
|
|
83
|
+
return 'yellow-bg';
|
|
84
|
+
case SgrParameterAttribute.BlueBackground:
|
|
85
|
+
return 'blue-bg';
|
|
86
|
+
case SgrParameterAttribute.MagentaBackground:
|
|
87
|
+
return 'magenta-bg';
|
|
88
|
+
case SgrParameterAttribute.CyanBackground:
|
|
89
|
+
return 'cyan-bg';
|
|
90
|
+
case SgrParameterAttribute.WhiteBackground:
|
|
91
|
+
return 'white-bg';
|
|
92
|
+
case SgrParameterAttribute.GrayBackground:
|
|
93
|
+
return 'gray-bg';
|
|
94
|
+
case SgrParameterAttribute.DefaultBackground:
|
|
95
|
+
return 'default-bg';
|
|
96
|
+
case SgrParameterAttribute.Bold:
|
|
97
|
+
return 'bold';
|
|
98
|
+
case SgrParameterAttribute.Dim:
|
|
99
|
+
return 'dim';
|
|
100
|
+
case SgrParameterAttribute.NormalColorOrIntensity:
|
|
101
|
+
return 'normal';
|
|
102
|
+
case SgrParameterAttribute.Underline:
|
|
103
|
+
return 'underline';
|
|
104
|
+
case SgrParameterAttribute.UnderlineOff:
|
|
105
|
+
return 'underline-off';
|
|
106
|
+
case SgrParameterAttribute.Blink:
|
|
107
|
+
return 'blink';
|
|
108
|
+
case SgrParameterAttribute.BlinkOff:
|
|
109
|
+
return 'blink-off';
|
|
110
|
+
case SgrParameterAttribute.InvertColor:
|
|
111
|
+
return 'invert';
|
|
112
|
+
case SgrParameterAttribute.InvertColorOff:
|
|
113
|
+
return 'invert-off';
|
|
114
|
+
case SgrParameterAttribute.Hidden:
|
|
115
|
+
return 'hidden';
|
|
116
|
+
case SgrParameterAttribute.HiddenOff:
|
|
117
|
+
return 'hidden-off';
|
|
118
|
+
default:
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// For now, we only care about the Control Sequence Introducer (CSI) commands which always start with "[".
|
|
124
|
+
// eslint-disable-next-line no-control-regex
|
|
125
|
+
AnsiEscape._csiRegExp = /\x1b\[([\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e])/gu;
|
|
126
|
+
// Text coloring is performed using Select Graphic Rendition (SGR) codes, which come after the
|
|
127
|
+
// CSI introducer "ESC [". The SGR sequence is a number followed by "m".
|
|
128
|
+
AnsiEscape._sgrRegExp = /([0-9]+)m/u;
|
|
129
|
+
AnsiEscape._backslashNRegExp = /\n/g;
|
|
130
|
+
AnsiEscape._backslashRRegExp = /\r/g;
|
|
131
|
+
//# sourceMappingURL=AnsiEscape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnsiEscape.js","sourceRoot":"","sources":["../src/AnsiEscape.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAanD;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IAYd,MAAM,CAAC,4BAA4B,CAAC,IAAY;QACrD,OAAO,UAAU,IAAI,GAAG,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,WAAW,CAAC,IAAY;QACpC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IACjD,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,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AAC;YACrB,KAAK,qBAAqB,CAAC,YAAY;gBACrC,OAAO,eAAe,CAAC;YACzB,KAAK,qBAAqB,CAAC,KAAK;gBAC9B,OAAO,OAAO,CAAC;YACjB,KAAK,qBAAqB,CAAC,QAAQ;gBACjC,OAAO,WAAW,CAAC;YACrB,KAAK,qBAAqB,CAAC,WAAW;gBACpC,OAAO,QAAQ,CAAC;YAClB,KAAK,qBAAqB,CAAC,cAAc;gBACvC,OAAO,YAAY,CAAC;YACtB,KAAK,qBAAqB,CAAC,MAAM;gBAC/B,OAAO,QAAQ,CAAC;YAClB,KAAK,qBAAqB,CAAC,SAAS;gBAClC,OAAO,YAAY,CAAC;YACtB;gBACE,OAAO,SAAS,CAAC;QACrB,CAAC;IACH,CAAC;;AAjID,0GAA0G;AAC1G,4CAA4C;AACpB,qBAAU,GAAW,+CAA+C,CAAC;AAE7F,8FAA8F;AAC9F,yEAAyE;AACjD,qBAAU,GAAW,YAAY,CAAC;AAElC,4BAAiB,GAAW,KAAK,CAAC;AAClC,4BAAiB,GAAW,KAAK,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { SgrParameterAttribute } from './Colorize';\n\n/**\n * Options for {@link AnsiEscape.formatForTests}.\n * @public\n */\nexport interface IAnsiEscapeConvertForTestsOptions {\n /**\n * If true then `\\n` will be replaced by `[n]`, and `\\r` will be replaced by `[r]`.\n */\n encodeNewlines?: boolean;\n}\n\n/**\n * Operations for working with text strings that contain\n * {@link https://en.wikipedia.org/wiki/ANSI_escape_code | ANSI escape codes}.\n * The most commonly used escape codes set the foreground/background color for console output.\n * @public\n */\nexport class AnsiEscape {\n // For now, we only care about the Control Sequence Introducer (CSI) commands which always start with \"[\".\n // eslint-disable-next-line no-control-regex\n private static readonly _csiRegExp: RegExp = /\\x1b\\[([\\x30-\\x3f]*[\\x20-\\x2f]*[\\x40-\\x7e])/gu;\n\n // Text coloring is performed using Select Graphic Rendition (SGR) codes, which come after the\n // CSI introducer \"ESC [\". The SGR sequence is a number followed by \"m\".\n private static readonly _sgrRegExp: RegExp = /([0-9]+)m/u;\n\n private static readonly _backslashNRegExp: RegExp = /\\n/g;\n private static readonly _backslashRRegExp: RegExp = /\\r/g;\n\n public static getEscapeSequenceForAnsiCode(code: number): string {\n return `\\u001b[${code}m`;\n }\n\n /**\n * Returns the input text with all ANSI escape codes removed. For example, this is useful when saving\n * colorized console output to a log file.\n */\n public static removeCodes(text: string): string {\n return text.replace(AnsiEscape._csiRegExp, '');\n }\n\n /**\n * Replaces ANSI escape codes with human-readable tokens. This is useful for unit tests\n * that compare text strings in test assertions or snapshot files.\n */\n public static formatForTests(text: string, options?: IAnsiEscapeConvertForTestsOptions): string {\n if (!options) {\n options = {};\n }\n\n let result: string = text.replace(AnsiEscape._csiRegExp, (capture: string, csiCode: string) => {\n // If it is an SGR code, then try to show a friendly token\n const match: RegExpMatchArray | null = csiCode.match(AnsiEscape._sgrRegExp);\n if (match) {\n const sgrParameter: number = parseInt(match[1], 10);\n const sgrParameterName: string | undefined = AnsiEscape._tryGetSgrFriendlyName(sgrParameter);\n if (sgrParameterName) {\n // Example: \"[black-bg]\"\n return `[${sgrParameterName}]`;\n }\n }\n\n // Otherwise show the raw code, but without the \"[\" from the CSI prefix\n // Example: \"[31m]\"\n return `[${csiCode}]`;\n });\n\n if (options.encodeNewlines) {\n result = result\n .replace(AnsiEscape._backslashNRegExp, '[n]')\n .replace(AnsiEscape._backslashRRegExp, `[r]`);\n }\n return result;\n }\n\n // Returns a human-readable token representing an SGR parameter, or undefined for parameter that is not well-known.\n // The SGR parameter numbers are documented in this table:\n // https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters\n private static _tryGetSgrFriendlyName(sgiParameter: number): string | undefined {\n switch (sgiParameter) {\n case SgrParameterAttribute.BlackForeground:\n return 'black';\n case SgrParameterAttribute.RedForeground:\n return 'red';\n case SgrParameterAttribute.GreenForeground:\n return 'green';\n case SgrParameterAttribute.YellowForeground:\n return 'yellow';\n case SgrParameterAttribute.BlueForeground:\n return 'blue';\n case SgrParameterAttribute.MagentaForeground:\n return 'magenta';\n case SgrParameterAttribute.CyanForeground:\n return 'cyan';\n case SgrParameterAttribute.WhiteForeground:\n return 'white';\n case SgrParameterAttribute.GrayForeground:\n return 'gray';\n case SgrParameterAttribute.DefaultForeground:\n return 'default';\n\n case SgrParameterAttribute.BlackBackground:\n return 'black-bg';\n case SgrParameterAttribute.RedBackground:\n return 'red-bg';\n case SgrParameterAttribute.GreenBackground:\n return 'green-bg';\n case SgrParameterAttribute.YellowBackground:\n return 'yellow-bg';\n case SgrParameterAttribute.BlueBackground:\n return 'blue-bg';\n case SgrParameterAttribute.MagentaBackground:\n return 'magenta-bg';\n case SgrParameterAttribute.CyanBackground:\n return 'cyan-bg';\n case SgrParameterAttribute.WhiteBackground:\n return 'white-bg';\n case SgrParameterAttribute.GrayBackground:\n return 'gray-bg';\n case SgrParameterAttribute.DefaultBackground:\n return 'default-bg';\n\n case SgrParameterAttribute.Bold:\n return 'bold';\n case SgrParameterAttribute.Dim:\n return 'dim';\n case SgrParameterAttribute.NormalColorOrIntensity:\n return 'normal';\n case SgrParameterAttribute.Underline:\n return 'underline';\n case SgrParameterAttribute.UnderlineOff:\n return 'underline-off';\n case SgrParameterAttribute.Blink:\n return 'blink';\n case SgrParameterAttribute.BlinkOff:\n return 'blink-off';\n case SgrParameterAttribute.InvertColor:\n return 'invert';\n case SgrParameterAttribute.InvertColorOff:\n return 'invert-off';\n case SgrParameterAttribute.Hidden:\n return 'hidden';\n case SgrParameterAttribute.HiddenOff:\n return 'hidden-off';\n default:\n return undefined;\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import { TerminalWritable } from './TerminalWritable';
|
|
4
|
+
/**
|
|
5
|
+
* This class enables very basic {@link TerminalWritable.onWriteChunk} operations to be implemented
|
|
6
|
+
* as a callback function, avoiding the need to define a subclass of `TerminalWritable`.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* `CallbackWritable` is provided as a convenience for very simple situations. For most cases,
|
|
10
|
+
* it is generally preferable to create a proper subclass.
|
|
11
|
+
*
|
|
12
|
+
* @privateRemarks
|
|
13
|
+
* We intentionally do not expose a callback for {@link TerminalWritable.onClose}; if special
|
|
14
|
+
* close behavior is required, it is better to create a subclass.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export class CallbackWritable extends TerminalWritable {
|
|
19
|
+
constructor(options) {
|
|
20
|
+
super();
|
|
21
|
+
this._callback = options.onWriteChunk;
|
|
22
|
+
}
|
|
23
|
+
onWriteChunk(chunk) {
|
|
24
|
+
this._callback(chunk);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=CallbackWritable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CallbackWritable.js","sourceRoot":"","sources":["../src/CallbackWritable.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAWtD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,gBAAiB,SAAQ,gBAAgB;IAGpD,YAAmB,OAAiC;QAClD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC;IACxC,CAAC;IAES,YAAY,CAAC,KAAqB;QAC1C,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { TerminalWritable } from './TerminalWritable';\nimport type { ITerminalChunk } from './ITerminalChunk';\n\n/**\n * Constructor options for {@link CallbackWritable}.\n * @public\n */\nexport interface ICallbackWritableOptions {\n onWriteChunk: (chunk: ITerminalChunk) => void;\n}\n\n/**\n * This class enables very basic {@link TerminalWritable.onWriteChunk} operations to be implemented\n * as a callback function, avoiding the need to define a subclass of `TerminalWritable`.\n *\n * @remarks\n * `CallbackWritable` is provided as a convenience for very simple situations. For most cases,\n * it is generally preferable to create a proper subclass.\n *\n * @privateRemarks\n * We intentionally do not expose a callback for {@link TerminalWritable.onClose}; if special\n * close behavior is required, it is better to create a subclass.\n *\n * @public\n */\nexport class CallbackWritable extends TerminalWritable {\n private readonly _callback: (chunk: ITerminalChunk) => void;\n\n public constructor(options: ICallbackWritableOptions) {\n super();\n this._callback = options.onWriteChunk;\n }\n\n protected onWriteChunk(chunk: ITerminalChunk): void {\n this._callback(chunk);\n }\n}\n"]}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import { AnsiEscape } from './AnsiEscape';
|
|
4
|
+
export var SgrParameterAttribute;
|
|
5
|
+
(function (SgrParameterAttribute) {
|
|
6
|
+
SgrParameterAttribute[SgrParameterAttribute["BlackForeground"] = 30] = "BlackForeground";
|
|
7
|
+
SgrParameterAttribute[SgrParameterAttribute["RedForeground"] = 31] = "RedForeground";
|
|
8
|
+
SgrParameterAttribute[SgrParameterAttribute["GreenForeground"] = 32] = "GreenForeground";
|
|
9
|
+
SgrParameterAttribute[SgrParameterAttribute["YellowForeground"] = 33] = "YellowForeground";
|
|
10
|
+
SgrParameterAttribute[SgrParameterAttribute["BlueForeground"] = 34] = "BlueForeground";
|
|
11
|
+
SgrParameterAttribute[SgrParameterAttribute["MagentaForeground"] = 35] = "MagentaForeground";
|
|
12
|
+
SgrParameterAttribute[SgrParameterAttribute["CyanForeground"] = 36] = "CyanForeground";
|
|
13
|
+
SgrParameterAttribute[SgrParameterAttribute["WhiteForeground"] = 37] = "WhiteForeground";
|
|
14
|
+
SgrParameterAttribute[SgrParameterAttribute["GrayForeground"] = 90] = "GrayForeground";
|
|
15
|
+
SgrParameterAttribute[SgrParameterAttribute["DefaultForeground"] = 39] = "DefaultForeground";
|
|
16
|
+
SgrParameterAttribute[SgrParameterAttribute["BlackBackground"] = 40] = "BlackBackground";
|
|
17
|
+
SgrParameterAttribute[SgrParameterAttribute["RedBackground"] = 41] = "RedBackground";
|
|
18
|
+
SgrParameterAttribute[SgrParameterAttribute["GreenBackground"] = 42] = "GreenBackground";
|
|
19
|
+
SgrParameterAttribute[SgrParameterAttribute["YellowBackground"] = 43] = "YellowBackground";
|
|
20
|
+
SgrParameterAttribute[SgrParameterAttribute["BlueBackground"] = 44] = "BlueBackground";
|
|
21
|
+
SgrParameterAttribute[SgrParameterAttribute["MagentaBackground"] = 45] = "MagentaBackground";
|
|
22
|
+
SgrParameterAttribute[SgrParameterAttribute["CyanBackground"] = 46] = "CyanBackground";
|
|
23
|
+
SgrParameterAttribute[SgrParameterAttribute["WhiteBackground"] = 47] = "WhiteBackground";
|
|
24
|
+
SgrParameterAttribute[SgrParameterAttribute["GrayBackground"] = 100] = "GrayBackground";
|
|
25
|
+
SgrParameterAttribute[SgrParameterAttribute["DefaultBackground"] = 49] = "DefaultBackground";
|
|
26
|
+
SgrParameterAttribute[SgrParameterAttribute["Bold"] = 1] = "Bold";
|
|
27
|
+
// On Linux, the "BoldOff" code instead causes the text to be double-underlined:
|
|
28
|
+
// https://en.wikipedia.org/wiki/Talk:ANSI_escape_code#SGR_21%E2%80%94%60Bold_off%60_not_widely_supported
|
|
29
|
+
// Use "NormalColorOrIntensity" instead
|
|
30
|
+
// BoldOff = 21,
|
|
31
|
+
SgrParameterAttribute[SgrParameterAttribute["Dim"] = 2] = "Dim";
|
|
32
|
+
SgrParameterAttribute[SgrParameterAttribute["NormalColorOrIntensity"] = 22] = "NormalColorOrIntensity";
|
|
33
|
+
SgrParameterAttribute[SgrParameterAttribute["Underline"] = 4] = "Underline";
|
|
34
|
+
SgrParameterAttribute[SgrParameterAttribute["UnderlineOff"] = 24] = "UnderlineOff";
|
|
35
|
+
SgrParameterAttribute[SgrParameterAttribute["Blink"] = 5] = "Blink";
|
|
36
|
+
SgrParameterAttribute[SgrParameterAttribute["BlinkOff"] = 25] = "BlinkOff";
|
|
37
|
+
SgrParameterAttribute[SgrParameterAttribute["InvertColor"] = 7] = "InvertColor";
|
|
38
|
+
SgrParameterAttribute[SgrParameterAttribute["InvertColorOff"] = 27] = "InvertColorOff";
|
|
39
|
+
SgrParameterAttribute[SgrParameterAttribute["Hidden"] = 8] = "Hidden";
|
|
40
|
+
SgrParameterAttribute[SgrParameterAttribute["HiddenOff"] = 28] = "HiddenOff";
|
|
41
|
+
})(SgrParameterAttribute || (SgrParameterAttribute = {}));
|
|
42
|
+
const RAINBOW_SEQUENCE = [
|
|
43
|
+
SgrParameterAttribute.RedForeground,
|
|
44
|
+
SgrParameterAttribute.YellowForeground,
|
|
45
|
+
SgrParameterAttribute.GreenForeground,
|
|
46
|
+
SgrParameterAttribute.CyanForeground,
|
|
47
|
+
SgrParameterAttribute.BlueForeground,
|
|
48
|
+
SgrParameterAttribute.MagentaForeground
|
|
49
|
+
];
|
|
50
|
+
/**
|
|
51
|
+
* The static functions on this class are used to produce colored text
|
|
52
|
+
* for use with a terminal that supports ANSI escape codes.
|
|
53
|
+
*
|
|
54
|
+
* Note that this API always generates color codes, regardless of whether
|
|
55
|
+
* the process's stdout is a TTY. The reason is that, in a complex program, the
|
|
56
|
+
* code that is generating strings often does not know were those strings will end
|
|
57
|
+
* up. In some cases, the same log message may get printed both to a shell
|
|
58
|
+
* that supports color AND to a log file that does not.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* console.log(Colorize.red('Red Text!'))
|
|
63
|
+
* terminal.writeLine(Colorize.green('Green Text!'), ' ', Colorize.blue('Blue Text!'));
|
|
64
|
+
*```
|
|
65
|
+
*
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export class Colorize {
|
|
69
|
+
static black(text) {
|
|
70
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.BlackForeground, SgrParameterAttribute.DefaultForeground, text);
|
|
71
|
+
}
|
|
72
|
+
static red(text) {
|
|
73
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.RedForeground, SgrParameterAttribute.DefaultForeground, text);
|
|
74
|
+
}
|
|
75
|
+
static green(text) {
|
|
76
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.GreenForeground, SgrParameterAttribute.DefaultForeground, text);
|
|
77
|
+
}
|
|
78
|
+
static yellow(text) {
|
|
79
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.YellowForeground, SgrParameterAttribute.DefaultForeground, text);
|
|
80
|
+
}
|
|
81
|
+
static blue(text) {
|
|
82
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.BlueForeground, SgrParameterAttribute.DefaultForeground, text);
|
|
83
|
+
}
|
|
84
|
+
static magenta(text) {
|
|
85
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.MagentaForeground, SgrParameterAttribute.DefaultForeground, text);
|
|
86
|
+
}
|
|
87
|
+
static cyan(text) {
|
|
88
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.CyanForeground, SgrParameterAttribute.DefaultForeground, text);
|
|
89
|
+
}
|
|
90
|
+
static white(text) {
|
|
91
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.WhiteForeground, SgrParameterAttribute.DefaultForeground, text);
|
|
92
|
+
}
|
|
93
|
+
static gray(text) {
|
|
94
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.GrayForeground, SgrParameterAttribute.DefaultForeground, text);
|
|
95
|
+
}
|
|
96
|
+
static blackBackground(text) {
|
|
97
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.BlackBackground, SgrParameterAttribute.DefaultBackground, text);
|
|
98
|
+
}
|
|
99
|
+
static redBackground(text) {
|
|
100
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.RedBackground, SgrParameterAttribute.DefaultBackground, text);
|
|
101
|
+
}
|
|
102
|
+
static greenBackground(text) {
|
|
103
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.GreenBackground, SgrParameterAttribute.DefaultBackground, text);
|
|
104
|
+
}
|
|
105
|
+
static yellowBackground(text) {
|
|
106
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.YellowBackground, SgrParameterAttribute.DefaultBackground, text);
|
|
107
|
+
}
|
|
108
|
+
static blueBackground(text) {
|
|
109
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.BlueBackground, SgrParameterAttribute.DefaultBackground, text);
|
|
110
|
+
}
|
|
111
|
+
static magentaBackground(text) {
|
|
112
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.MagentaBackground, SgrParameterAttribute.DefaultBackground, text);
|
|
113
|
+
}
|
|
114
|
+
static cyanBackground(text) {
|
|
115
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.CyanBackground, SgrParameterAttribute.DefaultBackground, text);
|
|
116
|
+
}
|
|
117
|
+
static whiteBackground(text) {
|
|
118
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.WhiteBackground, SgrParameterAttribute.DefaultBackground, text);
|
|
119
|
+
}
|
|
120
|
+
static grayBackground(text) {
|
|
121
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.GrayBackground, SgrParameterAttribute.DefaultBackground, text);
|
|
122
|
+
}
|
|
123
|
+
static bold(text) {
|
|
124
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.Bold, SgrParameterAttribute.NormalColorOrIntensity, text);
|
|
125
|
+
}
|
|
126
|
+
static dim(text) {
|
|
127
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.Dim, SgrParameterAttribute.NormalColorOrIntensity, text);
|
|
128
|
+
}
|
|
129
|
+
static underline(text) {
|
|
130
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.Underline, SgrParameterAttribute.UnderlineOff, text);
|
|
131
|
+
}
|
|
132
|
+
static blink(text) {
|
|
133
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.Blink, SgrParameterAttribute.BlinkOff, text);
|
|
134
|
+
}
|
|
135
|
+
static invertColor(text) {
|
|
136
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.InvertColor, SgrParameterAttribute.InvertColorOff, text);
|
|
137
|
+
}
|
|
138
|
+
static hidden(text) {
|
|
139
|
+
return Colorize._wrapTextInAnsiEscapeCodes(SgrParameterAttribute.Hidden, SgrParameterAttribute.HiddenOff, text);
|
|
140
|
+
}
|
|
141
|
+
static rainbow(text) {
|
|
142
|
+
return Colorize._applyColorSequence(text, RAINBOW_SEQUENCE);
|
|
143
|
+
}
|
|
144
|
+
static _applyColorSequence(text, sequence) {
|
|
145
|
+
let result = '';
|
|
146
|
+
const sequenceLength = sequence.length;
|
|
147
|
+
for (let i = 0; i < text.length; i++) {
|
|
148
|
+
result += AnsiEscape.getEscapeSequenceForAnsiCode(sequence[i % sequenceLength]) + text[i];
|
|
149
|
+
}
|
|
150
|
+
return result + AnsiEscape.getEscapeSequenceForAnsiCode(SgrParameterAttribute.DefaultForeground);
|
|
151
|
+
}
|
|
152
|
+
static _wrapTextInAnsiEscapeCodes(startCode, endCode, text) {
|
|
153
|
+
return (AnsiEscape.getEscapeSequenceForAnsiCode(startCode) +
|
|
154
|
+
text +
|
|
155
|
+
AnsiEscape.getEscapeSequenceForAnsiCode(endCode));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=Colorize.js.map
|
|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C;IAEM,MAAM,CAAC,MAAM,CAAC,IAAY;QAC/B,OAAO,QAAQ,CAAC,0BAA0B,CACxC,qBAAqB,CAAC,MAAM,EAC5B,qBAAqB,CAAC,SAAS,EAC/B,IAAI,CACL,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,OAAO,CAAC,IAAY;QAChC,OAAO,QAAQ,CAAC,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAC9D,CAAC;IAEO,MAAM,CAAC,mBAAmB,CAAC,IAAY,EAAE,QAAiC;QAChF,IAAI,MAAM,GAAW,EAAE,CAAC;QACxB,MAAM,cAAc,GAAW,QAAQ,CAAC,MAAM,CAAC;QAC/C,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7C,MAAM,IAAI,UAAU,CAAC,4BAA4B,CAAC,QAAQ,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAC5F,CAAC;QAED,OAAO,MAAM,GAAG,UAAU,CAAC,4BAA4B,CAAC,qBAAqB,CAAC,iBAAiB,CAAC,CAAC;IACnG,CAAC;IAEO,MAAM,CAAC,0BAA0B,CAAC,SAAiB,EAAE,OAAe,EAAE,IAAY;QACxF,OAAO,CACL,UAAU,CAAC,4BAA4B,CAAC,SAAS,CAAC;YAClD,IAAI;YACJ,UAAU,CAAC,4BAA4B,CAAC,OAAO,CAAC,CACjD,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { AnsiEscape } from './AnsiEscape';\n\nexport enum SgrParameterAttribute {\n BlackForeground = 30,\n RedForeground = 31,\n GreenForeground = 32,\n YellowForeground = 33,\n BlueForeground = 34,\n MagentaForeground = 35,\n CyanForeground = 36,\n WhiteForeground = 37,\n GrayForeground = 90,\n DefaultForeground = 39,\n\n BlackBackground = 40,\n RedBackground = 41,\n GreenBackground = 42,\n YellowBackground = 43,\n BlueBackground = 44,\n MagentaBackground = 45,\n CyanBackground = 46,\n WhiteBackground = 47,\n GrayBackground = 100,\n DefaultBackground = 49,\n\n Bold = 1,\n\n // On Linux, the \"BoldOff\" code instead causes the text to be double-underlined:\n // https://en.wikipedia.org/wiki/Talk:ANSI_escape_code#SGR_21%E2%80%94%60Bold_off%60_not_widely_supported\n // Use \"NormalColorOrIntensity\" instead\n // BoldOff = 21,\n\n Dim = 2,\n NormalColorOrIntensity = 22,\n Underline = 4,\n UnderlineOff = 24,\n Blink = 5,\n BlinkOff = 25,\n InvertColor = 7,\n InvertColorOff = 27,\n Hidden = 8,\n HiddenOff = 28\n}\n\nconst RAINBOW_SEQUENCE: SgrParameterAttribute[] = [\n SgrParameterAttribute.RedForeground,\n SgrParameterAttribute.YellowForeground,\n SgrParameterAttribute.GreenForeground,\n SgrParameterAttribute.CyanForeground,\n SgrParameterAttribute.BlueForeground,\n SgrParameterAttribute.MagentaForeground\n];\n\n/**\n * The static functions on this class are used to produce colored text\n * for use with a terminal that supports ANSI escape codes.\n *\n * Note that this API always generates color codes, regardless of whether\n * the process's stdout is a TTY. The reason is that, in a complex program, the\n * code that is generating strings often does not know were those strings will end\n * up. In some cases, the same log message may get printed both to a shell\n * that supports color AND to a log file that does not.\n *\n * @example\n * ```ts\n * console.log(Colorize.red('Red Text!'))\n * terminal.writeLine(Colorize.green('Green Text!'), ' ', Colorize.blue('Blue Text!'));\n *```\n *\n * @public\n */\nexport class Colorize {\n public static black(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.BlackForeground,\n SgrParameterAttribute.DefaultForeground,\n text\n );\n }\n\n public static red(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.RedForeground,\n SgrParameterAttribute.DefaultForeground,\n text\n );\n }\n\n public static green(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.GreenForeground,\n SgrParameterAttribute.DefaultForeground,\n text\n );\n }\n\n public static yellow(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.YellowForeground,\n SgrParameterAttribute.DefaultForeground,\n text\n );\n }\n\n public static blue(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.BlueForeground,\n SgrParameterAttribute.DefaultForeground,\n text\n );\n }\n\n public static magenta(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.MagentaForeground,\n SgrParameterAttribute.DefaultForeground,\n text\n );\n }\n\n public static cyan(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.CyanForeground,\n SgrParameterAttribute.DefaultForeground,\n text\n );\n }\n\n public static white(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.WhiteForeground,\n SgrParameterAttribute.DefaultForeground,\n text\n );\n }\n\n public static gray(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.GrayForeground,\n SgrParameterAttribute.DefaultForeground,\n text\n );\n }\n\n public static blackBackground(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.BlackBackground,\n SgrParameterAttribute.DefaultBackground,\n text\n );\n }\n\n public static redBackground(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.RedBackground,\n SgrParameterAttribute.DefaultBackground,\n text\n );\n }\n\n public static greenBackground(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.GreenBackground,\n SgrParameterAttribute.DefaultBackground,\n text\n );\n }\n\n public static yellowBackground(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.YellowBackground,\n SgrParameterAttribute.DefaultBackground,\n text\n );\n }\n\n public static blueBackground(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.BlueBackground,\n SgrParameterAttribute.DefaultBackground,\n text\n );\n }\n\n public static magentaBackground(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.MagentaBackground,\n SgrParameterAttribute.DefaultBackground,\n text\n );\n }\n\n public static cyanBackground(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.CyanBackground,\n SgrParameterAttribute.DefaultBackground,\n text\n );\n }\n\n public static whiteBackground(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.WhiteBackground,\n SgrParameterAttribute.DefaultBackground,\n text\n );\n }\n\n public static grayBackground(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.GrayBackground,\n SgrParameterAttribute.DefaultBackground,\n text\n );\n }\n\n public static bold(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.Bold,\n SgrParameterAttribute.NormalColorOrIntensity,\n text\n );\n }\n\n public static dim(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.Dim,\n SgrParameterAttribute.NormalColorOrIntensity,\n text\n );\n }\n\n public static underline(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.Underline,\n SgrParameterAttribute.UnderlineOff,\n text\n );\n }\n\n public static blink(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.Blink,\n SgrParameterAttribute.BlinkOff,\n text\n );\n }\n\n public static invertColor(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.InvertColor,\n SgrParameterAttribute.InvertColorOff,\n text\n );\n }\n\n public static hidden(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.Hidden,\n SgrParameterAttribute.HiddenOff,\n text\n );\n }\n\n public static rainbow(text: string): string {\n return Colorize._applyColorSequence(text, RAINBOW_SEQUENCE);\n }\n\n private static _applyColorSequence(text: string, sequence: SgrParameterAttribute[]): string {\n let result: string = '';\n const sequenceLength: number = sequence.length;\n for (let i: number = 0; i < text.length; i++) {\n result += AnsiEscape.getEscapeSequenceForAnsiCode(sequence[i % sequenceLength]) + text[i];\n }\n\n return result + AnsiEscape.getEscapeSequenceForAnsiCode(SgrParameterAttribute.DefaultForeground);\n }\n\n private static _wrapTextInAnsiEscapeCodes(startCode: number, endCode: number, text: string): string {\n return (\n AnsiEscape.getEscapeSequenceForAnsiCode(startCode) +\n text +\n AnsiEscape.getEscapeSequenceForAnsiCode(endCode)\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import { EOL } from 'node:os';
|
|
4
|
+
import supportsColor from 'supports-color';
|
|
5
|
+
import { TerminalProviderSeverity } from './ITerminalProvider';
|
|
6
|
+
/**
|
|
7
|
+
* Terminal provider that prints to STDOUT (for log- and verbose-level messages) and
|
|
8
|
+
* STDERR (for warning- and error-level messages).
|
|
9
|
+
*
|
|
10
|
+
* @beta
|
|
11
|
+
*/
|
|
12
|
+
export class ConsoleTerminalProvider {
|
|
13
|
+
constructor(options = {}) {
|
|
14
|
+
/**
|
|
15
|
+
* {@inheritDoc ITerminalProvider.supportsColor}
|
|
16
|
+
*/
|
|
17
|
+
this.supportsColor = ConsoleTerminalProvider.supportsColor;
|
|
18
|
+
this.verboseEnabled = !!options.verboseEnabled;
|
|
19
|
+
this.debugEnabled = !!options.debugEnabled;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* {@inheritDoc ITerminalProvider.write}
|
|
23
|
+
*/
|
|
24
|
+
write(data, severity) {
|
|
25
|
+
switch (severity) {
|
|
26
|
+
case TerminalProviderSeverity.warning:
|
|
27
|
+
case TerminalProviderSeverity.error: {
|
|
28
|
+
process.stderr.write(data);
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
case TerminalProviderSeverity.verbose: {
|
|
32
|
+
if (this.verboseEnabled) {
|
|
33
|
+
process.stdout.write(data);
|
|
34
|
+
}
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
case TerminalProviderSeverity.debug: {
|
|
38
|
+
if (this.debugEnabled) {
|
|
39
|
+
process.stdout.write(data);
|
|
40
|
+
}
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case TerminalProviderSeverity.log:
|
|
44
|
+
default: {
|
|
45
|
+
process.stdout.write(data);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* {@inheritDoc ITerminalProvider.eolCharacter}
|
|
52
|
+
*/
|
|
53
|
+
get eolCharacter() {
|
|
54
|
+
return EOL;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
ConsoleTerminalProvider.supportsColor = !!supportsColor.stdout && !!supportsColor.stderr;
|
|
58
|
+
//# sourceMappingURL=ConsoleTerminalProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConsoleTerminalProvider.js","sourceRoot":"","sources":["../src/ConsoleTerminalProvider.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,aAAa,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAA0B,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAqBvF;;;;;GAKG;AACH,MAAM,OAAO,uBAAuB;IAkBlC,YAAmB,UAAoD,EAAE;QALzE;;WAEG;QACa,kBAAa,GAAY,uBAAuB,CAAC,aAAa,CAAC;QAG7E,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;QAC/C,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;IAC7C,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAY,EAAE,QAAkC;QAC3D,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,wBAAwB,CAAC,OAAO,CAAC;YACtC,KAAK,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;gBACpC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC3B,MAAM;YACR,CAAC;YAED,KAAK,wBAAwB,CAAC,OAAO,CAAC,CAAC,CAAC;gBACtC,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;oBACxB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC7B,CAAC;gBACD,MAAM;YACR,CAAC;YAED,KAAK,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;gBACpC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;oBACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC7B,CAAC;gBACD,MAAM;YACR,CAAC;YAED,KAAK,wBAAwB,CAAC,GAAG,CAAC;YAClC,OAAO,CAAC,CAAC,CAAC;gBACR,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC3B,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,GAAG,CAAC;IACb,CAAC;;AA5DsB,qCAAa,GAAY,CAAC,CAAC,aAAa,CAAC,MAAM,IAAI,CAAC,CAAC,aAAa,CAAC,MAAM,AAA5D,CAA6D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { EOL } from 'node:os';\n\nimport supportsColor from 'supports-color';\n\nimport { type ITerminalProvider, TerminalProviderSeverity } from './ITerminalProvider';\n\n/**\n * Options to be provided to a {@link ConsoleTerminalProvider}\n *\n * @beta\n */\nexport interface IConsoleTerminalProviderOptions {\n /**\n * If true, print verbose logging messages.\n */\n verboseEnabled: boolean;\n\n /**\n * If true, print debug logging messages. Note that \"verbose\" and \"debug\" are considered\n * separate message filters; if you want debug to imply verbose, it is up to your\n * application code to enforce that.\n */\n debugEnabled: boolean;\n}\n\n/**\n * Terminal provider that prints to STDOUT (for log- and verbose-level messages) and\n * STDERR (for warning- and error-level messages).\n *\n * @beta\n */\nexport class ConsoleTerminalProvider implements ITerminalProvider {\n public static readonly supportsColor: boolean = !!supportsColor.stdout && !!supportsColor.stderr;\n\n /**\n * If true, verbose-level messages should be written to the console.\n */\n public verboseEnabled: boolean;\n\n /**\n * If true, debug-level messages should be written to the console.\n */\n public debugEnabled: boolean;\n\n /**\n * {@inheritDoc ITerminalProvider.supportsColor}\n */\n public readonly supportsColor: boolean = ConsoleTerminalProvider.supportsColor;\n\n public constructor(options: Partial<IConsoleTerminalProviderOptions> = {}) {\n this.verboseEnabled = !!options.verboseEnabled;\n this.debugEnabled = !!options.debugEnabled;\n }\n\n /**\n * {@inheritDoc ITerminalProvider.write}\n */\n public write(data: string, severity: TerminalProviderSeverity): void {\n switch (severity) {\n case TerminalProviderSeverity.warning:\n case TerminalProviderSeverity.error: {\n process.stderr.write(data);\n break;\n }\n\n case TerminalProviderSeverity.verbose: {\n if (this.verboseEnabled) {\n process.stdout.write(data);\n }\n break;\n }\n\n case TerminalProviderSeverity.debug: {\n if (this.debugEnabled) {\n process.stdout.write(data);\n }\n break;\n }\n\n case TerminalProviderSeverity.log:\n default: {\n process.stdout.write(data);\n break;\n }\n }\n }\n\n /**\n * {@inheritDoc ITerminalProvider.eolCharacter}\n */\n public get eolCharacter(): string {\n return EOL;\n }\n}\n"]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import { TerminalChunkKind } from './ITerminalChunk';
|
|
4
|
+
import { TerminalTransform } from './TerminalTransform';
|
|
5
|
+
var State;
|
|
6
|
+
(function (State) {
|
|
7
|
+
State[State["Okay"] = 0] = "Okay";
|
|
8
|
+
State[State["StderrFragment"] = 1] = "StderrFragment";
|
|
9
|
+
State[State["InsertLinefeed"] = 2] = "InsertLinefeed";
|
|
10
|
+
})(State || (State = {}));
|
|
11
|
+
/**
|
|
12
|
+
* `DiscardStdoutTransform` discards `stdout` chunks while fixing up malformed `stderr` lines.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* Suppose that a poorly behaved process produces output like this:
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* process.stdout.write('Starting operation...\n');
|
|
19
|
+
* process.stderr.write('An error occurred');
|
|
20
|
+
* process.stdout.write('\nFinishing up\n');
|
|
21
|
+
* process.stderr.write('The process completed with errors\n');
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* When `stdout` and `stderr` are combined on the console, the mistake in the output would not be noticeable:
|
|
25
|
+
* ```
|
|
26
|
+
* Starting operation...
|
|
27
|
+
* An error occurred
|
|
28
|
+
* Finishing up
|
|
29
|
+
* The process completed with errors
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* However, if we discard `stdout`, then `stderr` is missing a newline:
|
|
33
|
+
* ```
|
|
34
|
+
* An error occurredThe process completed with errors
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* Tooling scripts can introduce these sorts of problems via edge cases that are difficult to find and fix.
|
|
38
|
+
* `DiscardStdoutTransform` can discard the `stdout` stream and fix up `stderr`:
|
|
39
|
+
*
|
|
40
|
+
* ```
|
|
41
|
+
* An error occurred
|
|
42
|
+
* The process completed with errors
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @privateRemarks
|
|
46
|
+
* This class is experimental and marked as `@beta`. The algorithm may need some fine-tuning, or there may
|
|
47
|
+
* be better solutions to this problem.
|
|
48
|
+
*
|
|
49
|
+
* @beta
|
|
50
|
+
*/
|
|
51
|
+
export class DiscardStdoutTransform extends TerminalTransform {
|
|
52
|
+
constructor(options) {
|
|
53
|
+
super(options);
|
|
54
|
+
this._state = State.Okay;
|
|
55
|
+
}
|
|
56
|
+
onWriteChunk(chunk) {
|
|
57
|
+
if (chunk.text.indexOf('\r') >= 0) {
|
|
58
|
+
throw new Error('DiscardStdoutTransform expects chunks with normalized newlines');
|
|
59
|
+
}
|
|
60
|
+
if (chunk.kind === TerminalChunkKind.Stdout) {
|
|
61
|
+
if (this._state === State.StderrFragment) {
|
|
62
|
+
if (chunk.text.indexOf('\n') >= 0) {
|
|
63
|
+
this._state = State.InsertLinefeed;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else if (chunk.kind === TerminalChunkKind.Stderr) {
|
|
68
|
+
let correctedText;
|
|
69
|
+
if (this._state === State.InsertLinefeed) {
|
|
70
|
+
correctedText = '\n' + chunk.text;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
correctedText = chunk.text;
|
|
74
|
+
}
|
|
75
|
+
this.destination.writeChunk({ kind: TerminalChunkKind.Stderr, text: correctedText });
|
|
76
|
+
if (correctedText.length > 0) {
|
|
77
|
+
if (correctedText[correctedText.length - 1] === '\n') {
|
|
78
|
+
this._state = State.Okay;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
this._state = State.StderrFragment;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this.destination.writeChunk(chunk);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=DiscardStdoutTransform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DiscardStdoutTransform.js","sourceRoot":"","sources":["../src/DiscardStdoutTransform.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAuB,iBAAiB,EAAE,MAAM,kBAAk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AAU,CAAC,EAAE,IAAI,EAAE,iBAAiB,CAAC,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;YAErF,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC7B,IAAI,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;oBACrD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC;gBAC3B,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,cAAc,CAAC;gBACrC,CAAC;YACH,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { type ITerminalChunk, TerminalChunkKind } from './ITerminalChunk';\nimport { TerminalTransform, type ITerminalTransformOptions } from './TerminalTransform';\n\n/**\n * Constructor options for {@link DiscardStdoutTransform}\n *\n * @beta\n */\nexport interface IDiscardStdoutTransformOptions extends ITerminalTransformOptions {}\n\nenum State {\n Okay,\n StderrFragment,\n InsertLinefeed\n}\n\n/**\n * `DiscardStdoutTransform` discards `stdout` chunks while fixing up malformed `stderr` lines.\n *\n * @remarks\n * Suppose that a poorly behaved process produces output like this:\n *\n * ```ts\n * process.stdout.write('Starting operation...\\n');\n * process.stderr.write('An error occurred');\n * process.stdout.write('\\nFinishing up\\n');\n * process.stderr.write('The process completed with errors\\n');\n * ```\n *\n * When `stdout` and `stderr` are combined on the console, the mistake in the output would not be noticeable:\n * ```\n * Starting operation...\n * An error occurred\n * Finishing up\n * The process completed with errors\n * ```\n *\n * However, if we discard `stdout`, then `stderr` is missing a newline:\n * ```\n * An error occurredThe process completed with errors\n * ```\n *\n * Tooling scripts can introduce these sorts of problems via edge cases that are difficult to find and fix.\n * `DiscardStdoutTransform` can discard the `stdout` stream and fix up `stderr`:\n *\n * ```\n * An error occurred\n * The process completed with errors\n * ```\n *\n * @privateRemarks\n * This class is experimental and marked as `@beta`. The algorithm may need some fine-tuning, or there may\n * be better solutions to this problem.\n *\n * @beta\n */\nexport class DiscardStdoutTransform extends TerminalTransform {\n private _state: State;\n\n public constructor(options: IDiscardStdoutTransformOptions) {\n super(options);\n\n this._state = State.Okay;\n }\n\n protected onWriteChunk(chunk: ITerminalChunk): void {\n if (chunk.text.indexOf('\\r') >= 0) {\n throw new Error('DiscardStdoutTransform expects chunks with normalized newlines');\n }\n\n if (chunk.kind === TerminalChunkKind.Stdout) {\n if (this._state === State.StderrFragment) {\n if (chunk.text.indexOf('\\n') >= 0) {\n this._state = State.InsertLinefeed;\n }\n }\n } else if (chunk.kind === TerminalChunkKind.Stderr) {\n let correctedText: string;\n if (this._state === State.InsertLinefeed) {\n correctedText = '\\n' + chunk.text;\n } else {\n correctedText = chunk.text;\n }\n\n this.destination.writeChunk({ kind: TerminalChunkKind.Stderr, text: correctedText });\n\n if (correctedText.length > 0) {\n if (correctedText[correctedText.length - 1] === '\\n') {\n this._state = State.Okay;\n } else {\n this._state = State.StderrFragment;\n }\n }\n } else {\n this.destination.writeChunk(chunk);\n }\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IProblemCollector.js","sourceRoot":"","sources":["../src/IProblemCollector.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { IProblem } from '@rushstack/problem-matcher';\n\n/**\n * Collects problems (errors/warnings/info) encountered during an operation.\n *\n * @beta\n */\nexport interface IProblemCollector {\n /**\n * Returns the collected problems so far.\n */\n get problems(): ReadonlySet<IProblem>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ITerminal.js","sourceRoot":"","sources":["../src/ITerminal.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { ITerminalProvider } from './ITerminalProvider';\n\n/**\n * @beta\n */\nexport interface ITerminalWriteOptions {\n /**\n * If set to true, SGR parameters will not be replaced by the terminal\n * standard (i.e. - red for errors, yellow for warnings).\n */\n doNotOverrideSgrCodes?: boolean;\n}\n\n/**\n * @beta\n */\nexport type TerminalWriteParameters = string[] | [...string[], ITerminalWriteOptions];\n\n/**\n * @beta\n */\nexport interface ITerminal {\n /**\n * Subscribe a new terminal provider.\n */\n registerProvider(provider: ITerminalProvider): void;\n\n /**\n * Unsubscribe a terminal provider. If the provider isn't subscribed, this function does nothing.\n */\n unregisterProvider(provider: ITerminalProvider): void;\n\n /**\n * Write a generic message to the terminal\n */\n write(...messageParts: TerminalWriteParameters): void;\n\n /**\n * Write a generic message to the terminal, followed by a newline\n */\n writeLine(...messageParts: TerminalWriteParameters): void;\n\n /**\n * Write a warning message to the console with yellow text.\n *\n * @remarks\n * The yellow color takes precedence over any other foreground colors set.\n */\n writeWarning(...messageParts: TerminalWriteParameters): void;\n\n /**\n * Write a warning message to the console with yellow text, followed by a newline.\n *\n * @remarks\n * The yellow color takes precedence over any other foreground colors set.\n */\n writeWarningLine(...messageParts: TerminalWriteParameters): void;\n\n /**\n * Write an error message to the console with red text.\n *\n * @remarks\n * The red color takes precedence over any other foreground colors set.\n */\n writeError(...messageParts: TerminalWriteParameters): void;\n\n /**\n * Write an error message to the console with red text, followed by a newline.\n *\n * @remarks\n * The red color takes precedence over any other foreground colors set.\n */\n writeErrorLine(...messageParts: TerminalWriteParameters): void;\n\n /**\n * Write a verbose-level message.\n */\n writeVerbose(...messageParts: TerminalWriteParameters): void;\n\n /**\n * Write a verbose-level message followed by a newline.\n */\n writeVerboseLine(...messageParts: TerminalWriteParameters): void;\n\n /**\n * Write a debug-level message.\n */\n writeDebug(...messageParts: TerminalWriteParameters): void;\n\n /**\n * Write a debug-level message followed by a newline.\n */\n writeDebugLine(...messageParts: TerminalWriteParameters): void;\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
/**
|
|
4
|
+
* Specifies the kind of data represented by a {@link ITerminalChunk} object.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export var TerminalChunkKind;
|
|
8
|
+
(function (TerminalChunkKind) {
|
|
9
|
+
/**
|
|
10
|
+
* Indicates a `ITerminalChunk` object representing `stdout` console output.
|
|
11
|
+
*/
|
|
12
|
+
TerminalChunkKind["Stdout"] = "O";
|
|
13
|
+
/**
|
|
14
|
+
* Indicates a `ITerminalChunk` object representing `stderr` console output.
|
|
15
|
+
*/
|
|
16
|
+
TerminalChunkKind["Stderr"] = "E";
|
|
17
|
+
})(TerminalChunkKind || (TerminalChunkKind = {}));
|
|
18
|
+
//# sourceMappingURL=ITerminalChunk.js.map
|