spawn-term 3.5.5 → 3.5.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/dist/cjs/components/ExpandedOutput.js +9 -1
- package/dist/cjs/components/ExpandedOutput.js.map +1 -1
- package/dist/cjs/lib/AnsiText.js +214 -0
- package/dist/cjs/lib/AnsiText.js.map +1 -0
- package/dist/cjs/src/lib/AnsiText.d.ts +9 -0
- package/dist/esm/components/ExpandedOutput.js +4 -1
- package/dist/esm/components/ExpandedOutput.js.map +1 -1
- package/dist/esm/lib/AnsiText.js +121 -0
- package/dist/esm/lib/AnsiText.js.map +1 -0
- package/dist/esm/src/lib/AnsiText.d.ts +9 -0
- package/package.json +1 -1
|
@@ -12,6 +12,12 @@ var _jsxruntime = require("react/jsx-runtime");
|
|
|
12
12
|
var _ink = require("ink");
|
|
13
13
|
var _react = require("react");
|
|
14
14
|
var _constantsts = require("../constants.js");
|
|
15
|
+
var _AnsiTextts = /*#__PURE__*/ _interop_require_default(require("../lib/AnsiText.js"));
|
|
16
|
+
function _interop_require_default(obj) {
|
|
17
|
+
return obj && obj.__esModule ? obj : {
|
|
18
|
+
default: obj
|
|
19
|
+
};
|
|
20
|
+
}
|
|
15
21
|
var isMac = process.platform === 'darwin';
|
|
16
22
|
var _default = /*#__PURE__*/ (0, _react.memo)(function ExpandedOutput(param) {
|
|
17
23
|
var lines = param.lines, scrollOffset = param.scrollOffset, _param_maxVisible = param.maxVisible, maxVisible = _param_maxVisible === void 0 ? _constantsts.EXPANDED_MAX_VISIBLE_LINES : _param_maxVisible;
|
|
@@ -36,7 +42,9 @@ var _default = /*#__PURE__*/ (0, _react.memo)(function ExpandedOutput(param) {
|
|
|
36
42
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_ink.Text, {
|
|
37
43
|
children: [
|
|
38
44
|
"│ ",
|
|
39
|
-
|
|
45
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_AnsiTextts.default, {
|
|
46
|
+
children: line.text || ' '
|
|
47
|
+
})
|
|
40
48
|
]
|
|
41
49
|
}, scrollOffset + i));
|
|
42
50
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ExpandedOutput.tsx"],"sourcesContent":["import { Box, Text } from 'ink';\nimport { memo } from 'react';\nimport { EXPANDED_MAX_VISIBLE_LINES } from '../constants.ts';\nimport type { Line } from '../types.ts';\n\nconst isMac = process.platform === 'darwin';\n\ntype Props = {\n lines: Line[];\n scrollOffset: number;\n maxVisible?: number;\n};\n\nexport default memo(function ExpandedOutput({ lines, scrollOffset, maxVisible = EXPANDED_MAX_VISIBLE_LINES }: Props) {\n const visibleLines = lines.slice(scrollOffset, scrollOffset + maxVisible);\n const hasMore = lines.length > scrollOffset + maxVisible;\n const remaining = lines.length - scrollOffset - maxVisible;\n\n if (lines.length === 0) {\n return (\n <Box paddingLeft={2}>\n <Text dimColor>│ (no output)</Text>\n </Box>\n );\n }\n\n return (\n <Box flexDirection=\"column\" paddingLeft={2}>\n {visibleLines.map((line, i) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: Lines have no unique ID, index is stable for this scrolling view\n <Text key={scrollOffset + i}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ExpandedOutput.tsx"],"sourcesContent":["import { Box, Text } from 'ink';\nimport { memo } from 'react';\nimport { EXPANDED_MAX_VISIBLE_LINES } from '../constants.ts';\nimport AnsiText from '../lib/AnsiText.ts';\nimport type { Line } from '../types.ts';\n\nconst isMac = process.platform === 'darwin';\n\ntype Props = {\n lines: Line[];\n scrollOffset: number;\n maxVisible?: number;\n};\n\nexport default memo(function ExpandedOutput({ lines, scrollOffset, maxVisible = EXPANDED_MAX_VISIBLE_LINES }: Props) {\n const visibleLines = lines.slice(scrollOffset, scrollOffset + maxVisible);\n const hasMore = lines.length > scrollOffset + maxVisible;\n const remaining = lines.length - scrollOffset - maxVisible;\n\n if (lines.length === 0) {\n return (\n <Box paddingLeft={2}>\n <Text dimColor>│ (no output)</Text>\n </Box>\n );\n }\n\n return (\n <Box flexDirection=\"column\" paddingLeft={2}>\n {visibleLines.map((line, i) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: Lines have no unique ID, index is stable for this scrolling view\n <Text key={scrollOffset + i}>\n │ <AnsiText>{line.text || ' '}</AnsiText>\n </Text>\n ))}\n {hasMore ? (\n <Text dimColor>\n │ [+{remaining} more, Tab/⇧Tab page, {isMac ? '⌥↑/↓' : 'g/G'} top/bottom, ↵ close]\n </Text>\n ) : (\n <Text dimColor>│ [↵ close]</Text>\n )}\n </Box>\n );\n});\n"],"names":["isMac","process","platform","memo","ExpandedOutput","lines","scrollOffset","maxVisible","EXPANDED_MAX_VISIBLE_LINES","visibleLines","slice","hasMore","length","remaining","Box","paddingLeft","Text","dimColor","flexDirection","map","line","i","AnsiText","text"],"mappings":";;;;+BAcA;;;eAAA;;;;mBAd0B;qBACL;2BACsB;iEACtB;;;;;;AAGrB,IAAMA,QAAQC,QAAQC,QAAQ,KAAK;IAQnC,yBAAeC,IAAAA,WAAI,EAAC,SAASC,eAAe,KAAuE;QAArEC,QAAF,MAAEA,OAAOC,eAAT,MAASA,kCAAT,MAAuBC,YAAAA,4CAAaC,uCAA0B;IACxG,IAAMC,eAAeJ,MAAMK,KAAK,CAACJ,cAAcA,eAAeC;IAC9D,IAAMI,UAAUN,MAAMO,MAAM,GAAGN,eAAeC;IAC9C,IAAMM,YAAYR,MAAMO,MAAM,GAAGN,eAAeC;IAEhD,IAAIF,MAAMO,MAAM,KAAK,GAAG;QACtB,qBACE,qBAACE,QAAG;YAACC,aAAa;sBAChB,cAAA,qBAACC,SAAI;gBAACC,QAAQ;0BAAC;;;IAGrB;IAEA,qBACE,sBAACH,QAAG;QAACI,eAAc;QAASH,aAAa;;YACtCN,aAAaU,GAAG,CAAC,SAACC,MAAMC;uBACvB,iHAAiH;8BACjH,sBAACL,SAAI;;wBAAwB;sCACzB,qBAACM,mBAAQ;sCAAEF,KAAKG,IAAI,IAAI;;;mBADjBjB,eAAee;;YAI3BV,wBACC,sBAACK,SAAI;gBAACC,QAAQ;;oBAAC;oBACRJ;oBAAU;oBAAuBb,QAAQ,SAAS;oBAAM;;+BAG/D,qBAACgB,SAAI;gBAACC,QAAQ;0BAAC;;;;AAIvB"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, /**
|
|
6
|
+
* Component that renders text with ANSI escape codes as styled Ink Text components.
|
|
7
|
+
* Parses ANSI color and style codes and applies them as Ink props.
|
|
8
|
+
*/ "default", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function() {
|
|
11
|
+
return _default;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
var _jsxruntime = require("react/jsx-runtime");
|
|
15
|
+
var _ink = require("ink");
|
|
16
|
+
var _react = require("react");
|
|
17
|
+
function _array_like_to_array(arr, len) {
|
|
18
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
19
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
20
|
+
return arr2;
|
|
21
|
+
}
|
|
22
|
+
function _array_with_holes(arr) {
|
|
23
|
+
if (Array.isArray(arr)) return arr;
|
|
24
|
+
}
|
|
25
|
+
function _define_property(obj, key, value) {
|
|
26
|
+
if (key in obj) {
|
|
27
|
+
Object.defineProperty(obj, key, {
|
|
28
|
+
value: value,
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true
|
|
32
|
+
});
|
|
33
|
+
} else {
|
|
34
|
+
obj[key] = value;
|
|
35
|
+
}
|
|
36
|
+
return obj;
|
|
37
|
+
}
|
|
38
|
+
function _iterable_to_array_limit(arr, i) {
|
|
39
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
40
|
+
if (_i == null) return;
|
|
41
|
+
var _arr = [];
|
|
42
|
+
var _n = true;
|
|
43
|
+
var _d = false;
|
|
44
|
+
var _s, _e;
|
|
45
|
+
try {
|
|
46
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
47
|
+
_arr.push(_s.value);
|
|
48
|
+
if (i && _arr.length === i) break;
|
|
49
|
+
}
|
|
50
|
+
} catch (err) {
|
|
51
|
+
_d = true;
|
|
52
|
+
_e = err;
|
|
53
|
+
} finally{
|
|
54
|
+
try {
|
|
55
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
56
|
+
} finally{
|
|
57
|
+
if (_d) throw _e;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return _arr;
|
|
61
|
+
}
|
|
62
|
+
function _non_iterable_rest() {
|
|
63
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
64
|
+
}
|
|
65
|
+
function _object_spread(target) {
|
|
66
|
+
for(var i = 1; i < arguments.length; i++){
|
|
67
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
68
|
+
var ownKeys = Object.keys(source);
|
|
69
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
70
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
71
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
ownKeys.forEach(function(key) {
|
|
75
|
+
_define_property(target, key, source[key]);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return target;
|
|
79
|
+
}
|
|
80
|
+
function _sliced_to_array(arr, i) {
|
|
81
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
82
|
+
}
|
|
83
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
84
|
+
if (!o) return;
|
|
85
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
86
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
87
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
88
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
89
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
90
|
+
}
|
|
91
|
+
// ANSI color codes to Ink color mapping
|
|
92
|
+
// Based on standard ANSI SGR (Select Graphic Rendition) parameters
|
|
93
|
+
var ANSI_COLORS = {
|
|
94
|
+
'\x1b[30m': 'black',
|
|
95
|
+
'\x1b[31m': 'red',
|
|
96
|
+
'\x1b[32m': 'green',
|
|
97
|
+
'\x1b[33m': 'yellow',
|
|
98
|
+
'\x1b[34m': 'blue',
|
|
99
|
+
'\x1b[35m': 'magenta',
|
|
100
|
+
'\x1b[36m': 'cyan',
|
|
101
|
+
'\x1b[37m': 'white',
|
|
102
|
+
// Bright colors
|
|
103
|
+
'\x1b[90m': 'gray',
|
|
104
|
+
'\x1b[91m': 'redBright',
|
|
105
|
+
'\x1b[92m': 'greenBright',
|
|
106
|
+
'\x1b[93m': 'yellowBright',
|
|
107
|
+
'\x1b[94m': 'blueBright',
|
|
108
|
+
'\x1b[95m': 'magentaBright',
|
|
109
|
+
'\x1b[96m': 'cyanBright',
|
|
110
|
+
'\x1b[97m': 'whiteBright'
|
|
111
|
+
};
|
|
112
|
+
// ANSI style codes
|
|
113
|
+
var ANSI_STYLES = {
|
|
114
|
+
'\x1b[1m': 'bold',
|
|
115
|
+
'\x1b[2m': 'dim',
|
|
116
|
+
'\x1b[3m': 'italic',
|
|
117
|
+
'\x1b[4m': 'underline',
|
|
118
|
+
'\x1b[9m': 'strikethrough',
|
|
119
|
+
'\x1b[7m': 'inverse'
|
|
120
|
+
};
|
|
121
|
+
// Reset codes
|
|
122
|
+
var RESET_CODES = [
|
|
123
|
+
'\x1b[0m',
|
|
124
|
+
'\x1b[39m',
|
|
125
|
+
'\x1b[49m'
|
|
126
|
+
];
|
|
127
|
+
/**
|
|
128
|
+
* Parse a string with ANSI codes into segments with styling information.
|
|
129
|
+
*/ function parseAnsiString(input) {
|
|
130
|
+
var segments = [];
|
|
131
|
+
var currentSegment = {
|
|
132
|
+
text: ''
|
|
133
|
+
};
|
|
134
|
+
var i = 0;
|
|
135
|
+
while(i < input.length){
|
|
136
|
+
// Check for ANSI escape sequence
|
|
137
|
+
if (input[i] === '\x1b' && input[i + 1] === '[') {
|
|
138
|
+
// Find the end of the escape sequence (ends with a letter)
|
|
139
|
+
var j = i + 2;
|
|
140
|
+
while(j < input.length && !/[a-zA-Z]/.test(input[j])){
|
|
141
|
+
j++;
|
|
142
|
+
}
|
|
143
|
+
j++; // Include the letter
|
|
144
|
+
var code = input.slice(i, j);
|
|
145
|
+
// If we have accumulated text, save it
|
|
146
|
+
if (currentSegment.text.length > 0) {
|
|
147
|
+
segments.push(currentSegment);
|
|
148
|
+
currentSegment = _object_spread({
|
|
149
|
+
text: ''
|
|
150
|
+
}, Object.fromEntries(Object.entries(currentSegment).filter(function(param) {
|
|
151
|
+
var _param = _sliced_to_array(param, 1), key = _param[0];
|
|
152
|
+
return key !== 'text';
|
|
153
|
+
}).filter(function(param) {
|
|
154
|
+
var _param = _sliced_to_array(param, 2), _ = _param[0], value = _param[1];
|
|
155
|
+
return value !== undefined;
|
|
156
|
+
})));
|
|
157
|
+
}
|
|
158
|
+
// Apply the style
|
|
159
|
+
if (RESET_CODES.includes(code)) {
|
|
160
|
+
// Reset all styles
|
|
161
|
+
currentSegment = {
|
|
162
|
+
text: ''
|
|
163
|
+
};
|
|
164
|
+
} else if (ANSI_COLORS[code]) {
|
|
165
|
+
currentSegment.color = ANSI_COLORS[code];
|
|
166
|
+
} else if (ANSI_STYLES[code]) {
|
|
167
|
+
var style = ANSI_STYLES[code];
|
|
168
|
+
currentSegment[style] = true;
|
|
169
|
+
}
|
|
170
|
+
i = j;
|
|
171
|
+
} else {
|
|
172
|
+
// Regular character
|
|
173
|
+
currentSegment.text += input[i];
|
|
174
|
+
i++;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// Add the last segment if it has text
|
|
178
|
+
if (currentSegment.text.length > 0) {
|
|
179
|
+
segments.push(currentSegment);
|
|
180
|
+
}
|
|
181
|
+
return segments;
|
|
182
|
+
}
|
|
183
|
+
var _default = /*#__PURE__*/ (0, _react.memo)(function AnsiText(param) {
|
|
184
|
+
var children = param.children;
|
|
185
|
+
// If the input is empty or has no ANSI codes, just render it directly
|
|
186
|
+
if (!children || !children.includes('\x1b')) {
|
|
187
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_react.Fragment, {
|
|
188
|
+
children: children
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
var segments = parseAnsiString(children);
|
|
192
|
+
// If parsing resulted in a single unstyled segment, render it directly
|
|
193
|
+
if (segments.length === 1 && !segments[0].color && !segments[0].bold && !segments[0].dim && !segments[0].italic && !segments[0].underline && !segments[0].strikethrough && !segments[0].inverse) {
|
|
194
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_react.Fragment, {
|
|
195
|
+
children: segments[0].text
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_react.Fragment, {
|
|
199
|
+
children: segments.map(function(segment, index) {
|
|
200
|
+
return(// biome-ignore lint/suspicious/noArrayIndexKey: Segments have no unique ID, index is stable for parsed content
|
|
201
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_ink.Text, {
|
|
202
|
+
color: segment.color,
|
|
203
|
+
bold: segment.bold,
|
|
204
|
+
dimColor: segment.dim,
|
|
205
|
+
italic: segment.italic,
|
|
206
|
+
underline: segment.underline,
|
|
207
|
+
strikethrough: segment.strikethrough,
|
|
208
|
+
inverse: segment.inverse,
|
|
209
|
+
children: segment.text
|
|
210
|
+
}, index));
|
|
211
|
+
})
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/AnsiText.tsx"],"sourcesContent":["import { Text } from 'ink';\nimport { Fragment, memo } from 'react';\n\n// ANSI color codes to Ink color mapping\n// Based on standard ANSI SGR (Select Graphic Rendition) parameters\nconst ANSI_COLORS: Record<string, string> = {\n '\\x1b[30m': 'black',\n '\\x1b[31m': 'red',\n '\\x1b[32m': 'green',\n '\\x1b[33m': 'yellow',\n '\\x1b[34m': 'blue',\n '\\x1b[35m': 'magenta',\n '\\x1b[36m': 'cyan',\n '\\x1b[37m': 'white',\n // Bright colors\n '\\x1b[90m': 'gray',\n '\\x1b[91m': 'redBright',\n '\\x1b[92m': 'greenBright',\n '\\x1b[93m': 'yellowBright',\n '\\x1b[94m': 'blueBright',\n '\\x1b[95m': 'magentaBright',\n '\\x1b[96m': 'cyanBright',\n '\\x1b[97m': 'whiteBright',\n};\n\n// ANSI style codes\nconst ANSI_STYLES: Record<string, string> = {\n '\\x1b[1m': 'bold',\n '\\x1b[2m': 'dim',\n '\\x1b[3m': 'italic',\n '\\x1b[4m': 'underline',\n '\\x1b[9m': 'strikethrough',\n '\\x1b[7m': 'inverse',\n};\n\n// Reset codes\nconst RESET_CODES = ['\\x1b[0m', '\\x1b[39m', '\\x1b[49m'];\n\ntype TextSegment = {\n text: string;\n color?: string;\n bold?: boolean;\n dim?: boolean;\n italic?: boolean;\n underline?: boolean;\n strikethrough?: boolean;\n inverse?: boolean;\n};\n\n/**\n * Parse a string with ANSI codes into segments with styling information.\n */\nfunction parseAnsiString(input: string): TextSegment[] {\n const segments: TextSegment[] = [];\n let currentSegment: TextSegment = { text: '' };\n let i = 0;\n\n while (i < input.length) {\n // Check for ANSI escape sequence\n if (input[i] === '\\x1b' && input[i + 1] === '[') {\n // Find the end of the escape sequence (ends with a letter)\n let j = i + 2;\n while (j < input.length && !/[a-zA-Z]/.test(input[j])) {\n j++;\n }\n j++; // Include the letter\n\n const code = input.slice(i, j);\n\n // If we have accumulated text, save it\n if (currentSegment.text.length > 0) {\n segments.push(currentSegment);\n currentSegment = {\n text: '',\n ...Object.fromEntries(\n Object.entries(currentSegment)\n .filter(([key]) => key !== 'text')\n .filter(([_, value]) => value !== undefined)\n ),\n } as TextSegment;\n }\n\n // Apply the style\n if (RESET_CODES.includes(code)) {\n // Reset all styles\n currentSegment = { text: '' };\n } else if (ANSI_COLORS[code]) {\n currentSegment.color = ANSI_COLORS[code];\n } else if (ANSI_STYLES[code]) {\n const style = ANSI_STYLES[code] as keyof Omit<TextSegment, 'text' | 'color'>;\n currentSegment[style] = true;\n }\n\n i = j;\n } else {\n // Regular character\n currentSegment.text += input[i];\n i++;\n }\n }\n\n // Add the last segment if it has text\n if (currentSegment.text.length > 0) {\n segments.push(currentSegment);\n }\n\n return segments;\n}\n\ntype Props = {\n children: string;\n};\n\n/**\n * Component that renders text with ANSI escape codes as styled Ink Text components.\n * Parses ANSI color and style codes and applies them as Ink props.\n */\nexport default memo(function AnsiText({ children }: Props) {\n // If the input is empty or has no ANSI codes, just render it directly\n if (!children || !children.includes('\\x1b')) {\n return <Fragment>{children}</Fragment>;\n }\n\n const segments = parseAnsiString(children);\n\n // If parsing resulted in a single unstyled segment, render it directly\n if (segments.length === 1 && !segments[0].color && !segments[0].bold && !segments[0].dim && !segments[0].italic && !segments[0].underline && !segments[0].strikethrough && !segments[0].inverse) {\n return <Fragment>{segments[0].text}</Fragment>;\n }\n\n return (\n <Fragment>\n {segments.map((segment, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: Segments have no unique ID, index is stable for parsed content\n <Text key={index} color={segment.color} bold={segment.bold} dimColor={segment.dim} italic={segment.italic} underline={segment.underline} strikethrough={segment.strikethrough} inverse={segment.inverse}>\n {segment.text}\n </Text>\n ))}\n </Fragment>\n );\n});\n"],"names":["ANSI_COLORS","ANSI_STYLES","RESET_CODES","parseAnsiString","input","segments","currentSegment","text","i","length","j","test","code","slice","push","Object","fromEntries","entries","filter","key","_","value","undefined","includes","color","style","memo","AnsiText","children","Fragment","bold","dim","italic","underline","strikethrough","inverse","map","segment","index","Text","dimColor"],"mappings":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
children: string;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Component that renders text with ANSI escape codes as styled Ink Text components.
|
|
6
|
+
* Parses ANSI color and style codes and applies them as Ink props.
|
|
7
|
+
*/
|
|
8
|
+
declare const _default: import("react").NamedExoticComponent<Props>;
|
|
9
|
+
export default _default;
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Box, Text } from 'ink';
|
|
3
3
|
import { memo } from 'react';
|
|
4
4
|
import { EXPANDED_MAX_VISIBLE_LINES } from '../constants.js';
|
|
5
|
+
import AnsiText from '../lib/AnsiText.js';
|
|
5
6
|
const isMac = process.platform === 'darwin';
|
|
6
7
|
export default /*#__PURE__*/ memo(function ExpandedOutput({ lines, scrollOffset, maxVisible = EXPANDED_MAX_VISIBLE_LINES }) {
|
|
7
8
|
const visibleLines = lines.slice(scrollOffset, scrollOffset + maxVisible);
|
|
@@ -24,7 +25,9 @@ export default /*#__PURE__*/ memo(function ExpandedOutput({ lines, scrollOffset,
|
|
|
24
25
|
/*#__PURE__*/ _jsxs(Text, {
|
|
25
26
|
children: [
|
|
26
27
|
"│ ",
|
|
27
|
-
|
|
28
|
+
/*#__PURE__*/ _jsx(AnsiText, {
|
|
29
|
+
children: line.text || ' '
|
|
30
|
+
})
|
|
28
31
|
]
|
|
29
32
|
}, scrollOffset + i)),
|
|
30
33
|
hasMore ? /*#__PURE__*/ _jsxs(Text, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ExpandedOutput.tsx"],"sourcesContent":["import { Box, Text } from 'ink';\nimport { memo } from 'react';\nimport { EXPANDED_MAX_VISIBLE_LINES } from '../constants.ts';\nimport type { Line } from '../types.ts';\n\nconst isMac = process.platform === 'darwin';\n\ntype Props = {\n lines: Line[];\n scrollOffset: number;\n maxVisible?: number;\n};\n\nexport default memo(function ExpandedOutput({ lines, scrollOffset, maxVisible = EXPANDED_MAX_VISIBLE_LINES }: Props) {\n const visibleLines = lines.slice(scrollOffset, scrollOffset + maxVisible);\n const hasMore = lines.length > scrollOffset + maxVisible;\n const remaining = lines.length - scrollOffset - maxVisible;\n\n if (lines.length === 0) {\n return (\n <Box paddingLeft={2}>\n <Text dimColor>│ (no output)</Text>\n </Box>\n );\n }\n\n return (\n <Box flexDirection=\"column\" paddingLeft={2}>\n {visibleLines.map((line, i) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: Lines have no unique ID, index is stable for this scrolling view\n <Text key={scrollOffset + i}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ExpandedOutput.tsx"],"sourcesContent":["import { Box, Text } from 'ink';\nimport { memo } from 'react';\nimport { EXPANDED_MAX_VISIBLE_LINES } from '../constants.ts';\nimport AnsiText from '../lib/AnsiText.ts';\nimport type { Line } from '../types.ts';\n\nconst isMac = process.platform === 'darwin';\n\ntype Props = {\n lines: Line[];\n scrollOffset: number;\n maxVisible?: number;\n};\n\nexport default memo(function ExpandedOutput({ lines, scrollOffset, maxVisible = EXPANDED_MAX_VISIBLE_LINES }: Props) {\n const visibleLines = lines.slice(scrollOffset, scrollOffset + maxVisible);\n const hasMore = lines.length > scrollOffset + maxVisible;\n const remaining = lines.length - scrollOffset - maxVisible;\n\n if (lines.length === 0) {\n return (\n <Box paddingLeft={2}>\n <Text dimColor>│ (no output)</Text>\n </Box>\n );\n }\n\n return (\n <Box flexDirection=\"column\" paddingLeft={2}>\n {visibleLines.map((line, i) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: Lines have no unique ID, index is stable for this scrolling view\n <Text key={scrollOffset + i}>\n │ <AnsiText>{line.text || ' '}</AnsiText>\n </Text>\n ))}\n {hasMore ? (\n <Text dimColor>\n │ [+{remaining} more, Tab/⇧Tab page, {isMac ? '⌥↑/↓' : 'g/G'} top/bottom, ↵ close]\n </Text>\n ) : (\n <Text dimColor>│ [↵ close]</Text>\n )}\n </Box>\n );\n});\n"],"names":["Box","Text","memo","EXPANDED_MAX_VISIBLE_LINES","AnsiText","isMac","process","platform","ExpandedOutput","lines","scrollOffset","maxVisible","visibleLines","slice","hasMore","length","remaining","paddingLeft","dimColor","flexDirection","map","line","i","text"],"mappings":";AAAA,SAASA,GAAG,EAAEC,IAAI,QAAQ,MAAM;AAChC,SAASC,IAAI,QAAQ,QAAQ;AAC7B,SAASC,0BAA0B,QAAQ,kBAAkB;AAC7D,OAAOC,cAAc,qBAAqB;AAG1C,MAAMC,QAAQC,QAAQC,QAAQ,KAAK;AAQnC,6BAAeL,KAAK,SAASM,eAAe,EAAEC,KAAK,EAAEC,YAAY,EAAEC,aAAaR,0BAA0B,EAAS;IACjH,MAAMS,eAAeH,MAAMI,KAAK,CAACH,cAAcA,eAAeC;IAC9D,MAAMG,UAAUL,MAAMM,MAAM,GAAGL,eAAeC;IAC9C,MAAMK,YAAYP,MAAMM,MAAM,GAAGL,eAAeC;IAEhD,IAAIF,MAAMM,MAAM,KAAK,GAAG;QACtB,qBACE,KAACf;YAAIiB,aAAa;sBAChB,cAAA,KAAChB;gBAAKiB,QAAQ;0BAAC;;;IAGrB;IAEA,qBACE,MAAClB;QAAImB,eAAc;QAASF,aAAa;;YACtCL,aAAaQ,GAAG,CAAC,CAACC,MAAMC,IACvB,iHAAiH;8BACjH,MAACrB;;wBAA4B;sCACzB,KAACG;sCAAUiB,KAAKE,IAAI,IAAI;;;mBADjBb,eAAeY;YAI3BR,wBACC,MAACb;gBAAKiB,QAAQ;;oBAAC;oBACRF;oBAAU;oBAAuBX,QAAQ,SAAS;oBAAM;;+BAG/D,KAACJ;gBAAKiB,QAAQ;0BAAC;;;;AAIvB,GAAG"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from 'ink';
|
|
3
|
+
import { Fragment, memo } from 'react';
|
|
4
|
+
// ANSI color codes to Ink color mapping
|
|
5
|
+
// Based on standard ANSI SGR (Select Graphic Rendition) parameters
|
|
6
|
+
const ANSI_COLORS = {
|
|
7
|
+
'\x1b[30m': 'black',
|
|
8
|
+
'\x1b[31m': 'red',
|
|
9
|
+
'\x1b[32m': 'green',
|
|
10
|
+
'\x1b[33m': 'yellow',
|
|
11
|
+
'\x1b[34m': 'blue',
|
|
12
|
+
'\x1b[35m': 'magenta',
|
|
13
|
+
'\x1b[36m': 'cyan',
|
|
14
|
+
'\x1b[37m': 'white',
|
|
15
|
+
// Bright colors
|
|
16
|
+
'\x1b[90m': 'gray',
|
|
17
|
+
'\x1b[91m': 'redBright',
|
|
18
|
+
'\x1b[92m': 'greenBright',
|
|
19
|
+
'\x1b[93m': 'yellowBright',
|
|
20
|
+
'\x1b[94m': 'blueBright',
|
|
21
|
+
'\x1b[95m': 'magentaBright',
|
|
22
|
+
'\x1b[96m': 'cyanBright',
|
|
23
|
+
'\x1b[97m': 'whiteBright'
|
|
24
|
+
};
|
|
25
|
+
// ANSI style codes
|
|
26
|
+
const ANSI_STYLES = {
|
|
27
|
+
'\x1b[1m': 'bold',
|
|
28
|
+
'\x1b[2m': 'dim',
|
|
29
|
+
'\x1b[3m': 'italic',
|
|
30
|
+
'\x1b[4m': 'underline',
|
|
31
|
+
'\x1b[9m': 'strikethrough',
|
|
32
|
+
'\x1b[7m': 'inverse'
|
|
33
|
+
};
|
|
34
|
+
// Reset codes
|
|
35
|
+
const RESET_CODES = [
|
|
36
|
+
'\x1b[0m',
|
|
37
|
+
'\x1b[39m',
|
|
38
|
+
'\x1b[49m'
|
|
39
|
+
];
|
|
40
|
+
/**
|
|
41
|
+
* Parse a string with ANSI codes into segments with styling information.
|
|
42
|
+
*/ function parseAnsiString(input) {
|
|
43
|
+
const segments = [];
|
|
44
|
+
let currentSegment = {
|
|
45
|
+
text: ''
|
|
46
|
+
};
|
|
47
|
+
let i = 0;
|
|
48
|
+
while(i < input.length){
|
|
49
|
+
// Check for ANSI escape sequence
|
|
50
|
+
if (input[i] === '\x1b' && input[i + 1] === '[') {
|
|
51
|
+
// Find the end of the escape sequence (ends with a letter)
|
|
52
|
+
let j = i + 2;
|
|
53
|
+
while(j < input.length && !/[a-zA-Z]/.test(input[j])){
|
|
54
|
+
j++;
|
|
55
|
+
}
|
|
56
|
+
j++; // Include the letter
|
|
57
|
+
const code = input.slice(i, j);
|
|
58
|
+
// If we have accumulated text, save it
|
|
59
|
+
if (currentSegment.text.length > 0) {
|
|
60
|
+
segments.push(currentSegment);
|
|
61
|
+
currentSegment = {
|
|
62
|
+
text: '',
|
|
63
|
+
...Object.fromEntries(Object.entries(currentSegment).filter(([key])=>key !== 'text').filter(([_, value])=>value !== undefined))
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
// Apply the style
|
|
67
|
+
if (RESET_CODES.includes(code)) {
|
|
68
|
+
// Reset all styles
|
|
69
|
+
currentSegment = {
|
|
70
|
+
text: ''
|
|
71
|
+
};
|
|
72
|
+
} else if (ANSI_COLORS[code]) {
|
|
73
|
+
currentSegment.color = ANSI_COLORS[code];
|
|
74
|
+
} else if (ANSI_STYLES[code]) {
|
|
75
|
+
const style = ANSI_STYLES[code];
|
|
76
|
+
currentSegment[style] = true;
|
|
77
|
+
}
|
|
78
|
+
i = j;
|
|
79
|
+
} else {
|
|
80
|
+
// Regular character
|
|
81
|
+
currentSegment.text += input[i];
|
|
82
|
+
i++;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Add the last segment if it has text
|
|
86
|
+
if (currentSegment.text.length > 0) {
|
|
87
|
+
segments.push(currentSegment);
|
|
88
|
+
}
|
|
89
|
+
return segments;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Component that renders text with ANSI escape codes as styled Ink Text components.
|
|
93
|
+
* Parses ANSI color and style codes and applies them as Ink props.
|
|
94
|
+
*/ export default /*#__PURE__*/ memo(function AnsiText({ children }) {
|
|
95
|
+
// If the input is empty or has no ANSI codes, just render it directly
|
|
96
|
+
if (!children || !children.includes('\x1b')) {
|
|
97
|
+
return /*#__PURE__*/ _jsx(Fragment, {
|
|
98
|
+
children: children
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
const segments = parseAnsiString(children);
|
|
102
|
+
// If parsing resulted in a single unstyled segment, render it directly
|
|
103
|
+
if (segments.length === 1 && !segments[0].color && !segments[0].bold && !segments[0].dim && !segments[0].italic && !segments[0].underline && !segments[0].strikethrough && !segments[0].inverse) {
|
|
104
|
+
return /*#__PURE__*/ _jsx(Fragment, {
|
|
105
|
+
children: segments[0].text
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return /*#__PURE__*/ _jsx(Fragment, {
|
|
109
|
+
children: segments.map((segment, index)=>// biome-ignore lint/suspicious/noArrayIndexKey: Segments have no unique ID, index is stable for parsed content
|
|
110
|
+
/*#__PURE__*/ _jsx(Text, {
|
|
111
|
+
color: segment.color,
|
|
112
|
+
bold: segment.bold,
|
|
113
|
+
dimColor: segment.dim,
|
|
114
|
+
italic: segment.italic,
|
|
115
|
+
underline: segment.underline,
|
|
116
|
+
strikethrough: segment.strikethrough,
|
|
117
|
+
inverse: segment.inverse,
|
|
118
|
+
children: segment.text
|
|
119
|
+
}, index))
|
|
120
|
+
});
|
|
121
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/AnsiText.tsx"],"sourcesContent":["import { Text } from 'ink';\nimport { Fragment, memo } from 'react';\n\n// ANSI color codes to Ink color mapping\n// Based on standard ANSI SGR (Select Graphic Rendition) parameters\nconst ANSI_COLORS: Record<string, string> = {\n '\\x1b[30m': 'black',\n '\\x1b[31m': 'red',\n '\\x1b[32m': 'green',\n '\\x1b[33m': 'yellow',\n '\\x1b[34m': 'blue',\n '\\x1b[35m': 'magenta',\n '\\x1b[36m': 'cyan',\n '\\x1b[37m': 'white',\n // Bright colors\n '\\x1b[90m': 'gray',\n '\\x1b[91m': 'redBright',\n '\\x1b[92m': 'greenBright',\n '\\x1b[93m': 'yellowBright',\n '\\x1b[94m': 'blueBright',\n '\\x1b[95m': 'magentaBright',\n '\\x1b[96m': 'cyanBright',\n '\\x1b[97m': 'whiteBright',\n};\n\n// ANSI style codes\nconst ANSI_STYLES: Record<string, string> = {\n '\\x1b[1m': 'bold',\n '\\x1b[2m': 'dim',\n '\\x1b[3m': 'italic',\n '\\x1b[4m': 'underline',\n '\\x1b[9m': 'strikethrough',\n '\\x1b[7m': 'inverse',\n};\n\n// Reset codes\nconst RESET_CODES = ['\\x1b[0m', '\\x1b[39m', '\\x1b[49m'];\n\ntype TextSegment = {\n text: string;\n color?: string;\n bold?: boolean;\n dim?: boolean;\n italic?: boolean;\n underline?: boolean;\n strikethrough?: boolean;\n inverse?: boolean;\n};\n\n/**\n * Parse a string with ANSI codes into segments with styling information.\n */\nfunction parseAnsiString(input: string): TextSegment[] {\n const segments: TextSegment[] = [];\n let currentSegment: TextSegment = { text: '' };\n let i = 0;\n\n while (i < input.length) {\n // Check for ANSI escape sequence\n if (input[i] === '\\x1b' && input[i + 1] === '[') {\n // Find the end of the escape sequence (ends with a letter)\n let j = i + 2;\n while (j < input.length && !/[a-zA-Z]/.test(input[j])) {\n j++;\n }\n j++; // Include the letter\n\n const code = input.slice(i, j);\n\n // If we have accumulated text, save it\n if (currentSegment.text.length > 0) {\n segments.push(currentSegment);\n currentSegment = {\n text: '',\n ...Object.fromEntries(\n Object.entries(currentSegment)\n .filter(([key]) => key !== 'text')\n .filter(([_, value]) => value !== undefined)\n ),\n } as TextSegment;\n }\n\n // Apply the style\n if (RESET_CODES.includes(code)) {\n // Reset all styles\n currentSegment = { text: '' };\n } else if (ANSI_COLORS[code]) {\n currentSegment.color = ANSI_COLORS[code];\n } else if (ANSI_STYLES[code]) {\n const style = ANSI_STYLES[code] as keyof Omit<TextSegment, 'text' | 'color'>;\n currentSegment[style] = true;\n }\n\n i = j;\n } else {\n // Regular character\n currentSegment.text += input[i];\n i++;\n }\n }\n\n // Add the last segment if it has text\n if (currentSegment.text.length > 0) {\n segments.push(currentSegment);\n }\n\n return segments;\n}\n\ntype Props = {\n children: string;\n};\n\n/**\n * Component that renders text with ANSI escape codes as styled Ink Text components.\n * Parses ANSI color and style codes and applies them as Ink props.\n */\nexport default memo(function AnsiText({ children }: Props) {\n // If the input is empty or has no ANSI codes, just render it directly\n if (!children || !children.includes('\\x1b')) {\n return <Fragment>{children}</Fragment>;\n }\n\n const segments = parseAnsiString(children);\n\n // If parsing resulted in a single unstyled segment, render it directly\n if (segments.length === 1 && !segments[0].color && !segments[0].bold && !segments[0].dim && !segments[0].italic && !segments[0].underline && !segments[0].strikethrough && !segments[0].inverse) {\n return <Fragment>{segments[0].text}</Fragment>;\n }\n\n return (\n <Fragment>\n {segments.map((segment, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: Segments have no unique ID, index is stable for parsed content\n <Text key={index} color={segment.color} bold={segment.bold} dimColor={segment.dim} italic={segment.italic} underline={segment.underline} strikethrough={segment.strikethrough} inverse={segment.inverse}>\n {segment.text}\n </Text>\n ))}\n </Fragment>\n );\n});\n"],"names":["Text","Fragment","memo","ANSI_COLORS","ANSI_STYLES","RESET_CODES","parseAnsiString","input","segments","currentSegment","text","i","length","j","test","code","slice","push","Object","fromEntries","entries","filter","key","_","value","undefined","includes","color","style","AnsiText","children","bold","dim","italic","underline","strikethrough","inverse","map","segment","index","dimColor"],"mappings":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
children: string;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Component that renders text with ANSI escape codes as styled Ink Text components.
|
|
6
|
+
* Parses ANSI color and style codes and applies them as Ink props.
|
|
7
|
+
*/
|
|
8
|
+
declare const _default: import("react").NamedExoticComponent<Props>;
|
|
9
|
+
export default _default;
|