@jrichman/ink 6.5.1-beta.1 → 6.5.1-beta.2
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/build/components/Static.js +1 -1
- package/build/components/Static.js.map +1 -1
- package/build/components/StaticRender.js +0 -7
- package/build/components/StaticRender.js.map +1 -1
- package/build/devtools.js +0 -2
- package/build/devtools.js.map +1 -1
- package/build/dom.d.ts +4 -4
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/ink.d.ts +1 -1
- package/build/ink.js +0 -4
- package/build/ink.js.map +1 -1
- package/build/log-update.d.ts +2 -2
- package/build/log-update.js +4 -5
- package/build/log-update.js.map +1 -1
- package/build/measure-element.js +16 -46
- package/build/measure-element.js.map +1 -1
- package/build/measure-text.d.ts +9 -23
- package/build/measure-text.js +94 -132
- package/build/measure-text.js.map +1 -1
- package/build/output.d.ts +6 -12
- package/build/output.js +35 -51
- package/build/output.js.map +1 -1
- package/build/render-cached.d.ts +1 -1
- package/build/render-cached.js +8 -5
- package/build/render-cached.js.map +1 -1
- package/build/render-container.d.ts +1 -1
- package/build/render-node-to-output.d.ts +1 -1
- package/build/render-scrollbar.d.ts +5 -3
- package/build/render-scrollbar.js +8 -7
- package/build/render-scrollbar.js.map +1 -1
- package/build/render-sticky.d.ts +3 -8
- package/build/render-sticky.js.map +1 -1
- package/build/render-text-node.d.ts +3 -8
- package/build/render-text-node.js +62 -40
- package/build/render-text-node.js.map +1 -1
- package/build/render.d.ts +1 -1
- package/build/renderer.d.ts +2 -2
- package/build/renderer.js +1 -3
- package/build/renderer.js.map +1 -1
- package/build/replay.js +4 -16
- package/build/replay.js.map +1 -1
- package/build/selection.d.ts +3 -3
- package/build/selection.js +27 -18
- package/build/selection.js.map +1 -1
- package/build/serialization.d.ts +2 -5
- package/build/serialization.js +55 -86
- package/build/serialization.js.map +1 -1
- package/build/styled-line.d.ts +73 -0
- package/build/styled-line.js +412 -0
- package/build/styled-line.js.map +1 -0
- package/build/terminal-buffer.d.ts +2 -2
- package/build/terminal-buffer.js +3 -2
- package/build/terminal-buffer.js.map +1 -1
- package/build/text-wrap.d.ts +6 -6
- package/build/text-wrap.js +65 -46
- package/build/text-wrap.js.map +1 -1
- package/build/tokenize.d.ts +3 -33
- package/build/tokenize.js +14 -115
- package/build/tokenize.js.map +1 -1
- package/build/worker/canvas.d.ts +6 -16
- package/build/worker/canvas.js +10 -21
- package/build/worker/canvas.js.map +1 -1
- package/build/worker/compositor.js +15 -9
- package/build/worker/compositor.js.map +1 -1
- package/build/worker/render-worker.js +2 -8
- package/build/worker/render-worker.js.map +1 -1
- package/build/worker/scene-manager.js +2 -1
- package/build/worker/scene-manager.js.map +1 -1
- package/build/worker/terminal-writer.d.ts +4 -4
- package/build/worker/terminal-writer.js +34 -64
- package/build/worker/terminal-writer.js.map +1 -1
- package/package.json +11 -11
package/build/measure-text.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StyledLine } from './styled-line.js';
|
|
2
2
|
import { type DOMNode } from './dom.js';
|
|
3
3
|
export type StringWidth = (text: string) => number;
|
|
4
4
|
/**
|
|
@@ -19,32 +19,18 @@ export declare function setEnableToStyledCharactersCache(enabled: boolean): void
|
|
|
19
19
|
export declare function setStringWidthFunction(fn: StringWidth): void;
|
|
20
20
|
export declare function clearStringWidthCache(): void;
|
|
21
21
|
export declare function clearToStyledCharactersCache(): void;
|
|
22
|
-
export declare function toStyledCharacters(text: string):
|
|
23
|
-
export declare function styledCharsWidth(
|
|
22
|
+
export declare function toStyledCharacters(text: string): StyledLine;
|
|
23
|
+
export declare function styledCharsWidth(line: StyledLine): number;
|
|
24
24
|
export declare function inkCharacterWidth(text: string): number;
|
|
25
|
-
export declare function wordBreakStyledChars(
|
|
26
|
-
export declare function splitStyledCharsByNewline(
|
|
27
|
-
export declare function widestLineFromStyledChars(lines:
|
|
28
|
-
export declare function styledCharsToString(
|
|
29
|
-
export declare function measureStyledChars(
|
|
25
|
+
export declare function wordBreakStyledChars(line: StyledLine): StyledLine[];
|
|
26
|
+
export declare function splitStyledCharsByNewline(line: StyledLine): StyledLine[];
|
|
27
|
+
export declare function widestLineFromStyledChars(lines: StyledLine[]): number;
|
|
28
|
+
export declare function styledCharsToString(line: StyledLine): string;
|
|
29
|
+
export declare function measureStyledChars(line: StyledLine): {
|
|
30
30
|
width: number;
|
|
31
31
|
height: number;
|
|
32
32
|
};
|
|
33
|
-
|
|
34
|
-
* Calculate row and column position at a given character offset.
|
|
35
|
-
* This is the unified cursor position calculation logic used by both
|
|
36
|
-
* render-node-to-output.ts and output.ts.
|
|
37
|
-
*
|
|
38
|
-
* The character offset counting method matches CharOffsetMap used in
|
|
39
|
-
* selection.ts and squash-text-nodes.ts, ensuring consistent behavior
|
|
40
|
-
* between cursor positioning and text selection.
|
|
41
|
-
*
|
|
42
|
-
* Character counting rules:
|
|
43
|
-
* - Each StyledChar counts by its value.length (handles combining marks)
|
|
44
|
-
* - Newlines ('\n') advance row and reset column
|
|
45
|
-
* - Other characters add their visual width to column
|
|
46
|
-
*/
|
|
47
|
-
export declare function getPositionAtOffset(styledChars: StyledChar[], targetOffset: number): {
|
|
33
|
+
export declare function getPositionAtOffset(line: StyledLine, targetOffset: number): {
|
|
48
34
|
row: number;
|
|
49
35
|
col: number;
|
|
50
36
|
};
|
package/build/measure-text.js
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import stringWidth from 'string-width';
|
|
2
|
-
import { tokenize,
|
|
2
|
+
import { tokenize, styledLineFromTokens } from './tokenize.js';
|
|
3
|
+
import { StyledLine } from './styled-line.js';
|
|
3
4
|
import { DataLimitedLruMap } from './data-limited-lru-map.js';
|
|
4
5
|
const defaultStringWidth = stringWidth;
|
|
5
6
|
let currentStringWidth = defaultStringWidth;
|
|
6
7
|
// This cache must be cleared each time the string width function is changed.
|
|
7
|
-
// The strings passed as input are single characters so there is no need to
|
|
8
|
-
// limit the size of the cache as there are only a limited number of valid
|
|
9
|
-
// characters.
|
|
10
8
|
const widthCache = new Map();
|
|
11
9
|
// This cache can persist for the lifetime of the application.
|
|
12
|
-
// The keys for this cache can be very large so we need to limit the size
|
|
13
|
-
// of the data cached as well as the number of keys cached to prevent
|
|
14
|
-
// memory issues.
|
|
15
10
|
const toStyledCharactersCache = new DataLimitedLruMap(2000, 100_000);
|
|
16
11
|
let toStyledCharactersCacheEnabled = true;
|
|
17
12
|
export function setEnableToStyledCharactersCache(enabled) {
|
|
@@ -22,7 +17,6 @@ export function setEnableToStyledCharactersCache(enabled) {
|
|
|
22
17
|
}
|
|
23
18
|
export function setStringWidthFunction(fn) {
|
|
24
19
|
currentStringWidth = fn;
|
|
25
|
-
// Clear the width cache to avoid stale values.
|
|
26
20
|
clearStringWidthCache();
|
|
27
21
|
}
|
|
28
22
|
export function clearStringWidthCache() {
|
|
@@ -39,102 +33,83 @@ export function toStyledCharacters(text) {
|
|
|
39
33
|
}
|
|
40
34
|
}
|
|
41
35
|
const tokens = tokenize(text);
|
|
42
|
-
const characters =
|
|
43
|
-
const
|
|
36
|
+
const characters = styledLineFromTokens(tokens);
|
|
37
|
+
const combinedLine = new StyledLine();
|
|
44
38
|
for (let i = 0; i < characters.length; i++) {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
39
|
+
const value = characters.getValue(i);
|
|
40
|
+
const formatFlags = characters.getFormatFlags(i);
|
|
41
|
+
const fgColor = characters.getFgColor(i);
|
|
42
|
+
const bgColor = characters.getBgColor(i);
|
|
43
|
+
const link = characters.getLink(i);
|
|
44
|
+
if (value === '\t') {
|
|
45
|
+
for (let j = 0; j < 4; j++) {
|
|
46
|
+
combinedLine.pushChar(' ', formatFlags, fgColor, bgColor, link);
|
|
47
|
+
}
|
|
52
48
|
continue;
|
|
53
49
|
}
|
|
54
|
-
if (
|
|
50
|
+
if (value === '\b') {
|
|
55
51
|
continue;
|
|
56
52
|
}
|
|
57
|
-
let
|
|
53
|
+
let combinedValue = value;
|
|
58
54
|
let isCombined = false;
|
|
59
|
-
const firstCodePoint =
|
|
55
|
+
const firstCodePoint = combinedValue.codePointAt(0);
|
|
60
56
|
// 1. Regional Indicators (Flags)
|
|
61
|
-
// These combine in pairs.
|
|
62
|
-
// See: https://en.wikipedia.org/wiki/Regional_indicator_symbol
|
|
63
57
|
if (firstCodePoint &&
|
|
64
58
|
firstCodePoint >= 0x1_f1_e6 &&
|
|
65
59
|
firstCodePoint <= 0x1_f1_ff &&
|
|
66
60
|
i + 1 < characters.length) {
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
combinedCharacters.push(character.copyWith({ value }));
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
61
|
+
const nextValue = characters.getValue(i + 1);
|
|
62
|
+
const nextFirstCodePoint = nextValue.codePointAt(0);
|
|
63
|
+
if (nextFirstCodePoint &&
|
|
64
|
+
nextFirstCodePoint >= 0x1_f1_e6 &&
|
|
65
|
+
nextFirstCodePoint <= 0x1_f1_ff) {
|
|
66
|
+
combinedValue += nextValue;
|
|
67
|
+
i++;
|
|
68
|
+
isCombined = true;
|
|
78
69
|
}
|
|
79
70
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
// Merge with previous character
|
|
110
|
-
value += nextCharacter.getValue();
|
|
111
|
-
i++; // Consume next character.
|
|
112
|
-
isCombined = true;
|
|
113
|
-
// If it was a ZWJ, also consume the character after it.
|
|
114
|
-
if (isZeroWidthJoiner && i + 1 < characters.length) {
|
|
115
|
-
const characterAfterZwj = characters[i + 1];
|
|
116
|
-
if (characterAfterZwj) {
|
|
117
|
-
value += characterAfterZwj.getValue();
|
|
118
|
-
i++; // Consume character after ZWJ.
|
|
71
|
+
if (!isCombined) {
|
|
72
|
+
// 2. Other combining characters
|
|
73
|
+
while (i + 1 < characters.length) {
|
|
74
|
+
const nextValue = characters.getValue(i + 1);
|
|
75
|
+
if (!nextValue)
|
|
76
|
+
break;
|
|
77
|
+
const nextFirstCodePoint = nextValue.codePointAt(0);
|
|
78
|
+
if (!nextFirstCodePoint)
|
|
79
|
+
break;
|
|
80
|
+
const isUnicodeMark = /\p{Mark}/u.test(nextValue);
|
|
81
|
+
const isSkinToneModifier = nextFirstCodePoint >= 0x1_f3_fb && nextFirstCodePoint <= 0x1_f3_ff;
|
|
82
|
+
const isZeroWidthJoiner = nextFirstCodePoint === 0x20_0d;
|
|
83
|
+
const isTagsBlock = nextFirstCodePoint >= 0xe_00_00 && nextFirstCodePoint <= 0xe_00_7f;
|
|
84
|
+
const isCombining = isUnicodeMark ||
|
|
85
|
+
isSkinToneModifier ||
|
|
86
|
+
isZeroWidthJoiner ||
|
|
87
|
+
isTagsBlock;
|
|
88
|
+
if (!isCombining) {
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
combinedValue += nextValue;
|
|
92
|
+
i++;
|
|
93
|
+
if (isZeroWidthJoiner && i + 1 < characters.length) {
|
|
94
|
+
const characterAfterZwj = characters.getValue(i + 1);
|
|
95
|
+
if (characterAfterZwj) {
|
|
96
|
+
combinedValue += characterAfterZwj;
|
|
97
|
+
i++;
|
|
98
|
+
}
|
|
119
99
|
}
|
|
120
100
|
}
|
|
121
101
|
}
|
|
122
|
-
|
|
123
|
-
combinedCharacters.push(character.copyWith({ value }));
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
combinedCharacters.push(character);
|
|
127
|
-
}
|
|
102
|
+
combinedLine.pushChar(combinedValue, formatFlags, fgColor, bgColor, link);
|
|
128
103
|
}
|
|
129
104
|
if (toStyledCharactersCacheEnabled) {
|
|
130
|
-
toStyledCharactersCache.set(text,
|
|
105
|
+
toStyledCharactersCache.set(text, combinedLine);
|
|
131
106
|
}
|
|
132
|
-
return
|
|
107
|
+
return combinedLine;
|
|
133
108
|
}
|
|
134
|
-
export function styledCharsWidth(
|
|
109
|
+
export function styledCharsWidth(line) {
|
|
135
110
|
let length = 0;
|
|
136
|
-
for (
|
|
137
|
-
length += inkCharacterWidth(
|
|
111
|
+
for (let i = 0; i < line.length; i++) {
|
|
112
|
+
length += inkCharacterWidth(line.getValue(i));
|
|
138
113
|
}
|
|
139
114
|
return length;
|
|
140
115
|
}
|
|
@@ -148,27 +123,32 @@ export function inkCharacterWidth(text) {
|
|
|
148
123
|
calculatedWidth = currentStringWidth(text);
|
|
149
124
|
}
|
|
150
125
|
catch {
|
|
151
|
-
// Ignore errors and use default width of 1.
|
|
152
|
-
// We catch this result to avoid throwing exceptions repeatedly.
|
|
153
126
|
calculatedWidth = 1;
|
|
154
127
|
console.warn(`Failed to calculate string width for ${JSON.stringify(text)}`);
|
|
155
128
|
}
|
|
156
129
|
widthCache.set(text, calculatedWidth);
|
|
157
130
|
return calculatedWidth;
|
|
158
131
|
}
|
|
159
|
-
export function wordBreakStyledChars(
|
|
132
|
+
export function wordBreakStyledChars(line) {
|
|
160
133
|
const words = [];
|
|
161
|
-
let currentWord =
|
|
162
|
-
for (
|
|
163
|
-
|
|
134
|
+
let currentWord = new StyledLine();
|
|
135
|
+
for (let i = 0; i < line.length; i++) {
|
|
136
|
+
const val = line.getValue(i);
|
|
137
|
+
const flags = line.getFormatFlags(i);
|
|
138
|
+
const fg = line.getFgColor(i);
|
|
139
|
+
const bg = line.getBgColor(i);
|
|
140
|
+
const link = line.getLink(i);
|
|
141
|
+
if (val === '\n' || val === ' ') {
|
|
164
142
|
if (currentWord.length > 0) {
|
|
165
143
|
words.push(currentWord);
|
|
166
144
|
}
|
|
167
|
-
currentWord =
|
|
168
|
-
|
|
145
|
+
currentWord = new StyledLine();
|
|
146
|
+
const spaceLine = new StyledLine();
|
|
147
|
+
spaceLine.pushChar(val, flags, fg, bg, link);
|
|
148
|
+
words.push(spaceLine);
|
|
169
149
|
}
|
|
170
150
|
else {
|
|
171
|
-
currentWord.
|
|
151
|
+
currentWord.pushChar(val, flags, fg, bg, link);
|
|
172
152
|
}
|
|
173
153
|
}
|
|
174
154
|
if (currentWord.length > 0) {
|
|
@@ -176,14 +156,17 @@ export function wordBreakStyledChars(styledChars) {
|
|
|
176
156
|
}
|
|
177
157
|
return words;
|
|
178
158
|
}
|
|
179
|
-
export function splitStyledCharsByNewline(
|
|
180
|
-
const lines = [
|
|
181
|
-
for (
|
|
182
|
-
|
|
183
|
-
|
|
159
|
+
export function splitStyledCharsByNewline(line) {
|
|
160
|
+
const lines = [new StyledLine()];
|
|
161
|
+
for (let i = 0; i < line.length; i++) {
|
|
162
|
+
const val = line.getValue(i);
|
|
163
|
+
if (val === '\n') {
|
|
164
|
+
lines.push(new StyledLine());
|
|
184
165
|
}
|
|
185
166
|
else {
|
|
186
|
-
lines
|
|
167
|
+
lines
|
|
168
|
+
.at(-1)
|
|
169
|
+
.pushChar(val, line.getFormatFlags(i), line.getFgColor(i), line.getBgColor(i), line.getLink(i));
|
|
187
170
|
}
|
|
188
171
|
}
|
|
189
172
|
return lines;
|
|
@@ -195,56 +178,35 @@ export function widestLineFromStyledChars(lines) {
|
|
|
195
178
|
}
|
|
196
179
|
return maxWidth;
|
|
197
180
|
}
|
|
198
|
-
export function styledCharsToString(
|
|
199
|
-
|
|
200
|
-
for (const char of styledChars) {
|
|
201
|
-
result += char.getValue();
|
|
202
|
-
}
|
|
203
|
-
return result;
|
|
181
|
+
export function styledCharsToString(line) {
|
|
182
|
+
return line.getValues().join('');
|
|
204
183
|
}
|
|
205
|
-
export function measureStyledChars(
|
|
206
|
-
if (
|
|
207
|
-
return {
|
|
208
|
-
width: 0,
|
|
209
|
-
height: 0,
|
|
210
|
-
};
|
|
184
|
+
export function measureStyledChars(line) {
|
|
185
|
+
if (line.length === 0) {
|
|
186
|
+
return { width: 0, height: 0 };
|
|
211
187
|
}
|
|
212
|
-
const lines = splitStyledCharsByNewline(
|
|
188
|
+
const lines = splitStyledCharsByNewline(line);
|
|
213
189
|
const width = widestLineFromStyledChars(lines);
|
|
214
190
|
const height = lines.length;
|
|
215
|
-
|
|
216
|
-
return dimensions;
|
|
191
|
+
return { width, height };
|
|
217
192
|
}
|
|
218
|
-
|
|
219
|
-
* Calculate row and column position at a given character offset.
|
|
220
|
-
* This is the unified cursor position calculation logic used by both
|
|
221
|
-
* render-node-to-output.ts and output.ts.
|
|
222
|
-
*
|
|
223
|
-
* The character offset counting method matches CharOffsetMap used in
|
|
224
|
-
* selection.ts and squash-text-nodes.ts, ensuring consistent behavior
|
|
225
|
-
* between cursor positioning and text selection.
|
|
226
|
-
*
|
|
227
|
-
* Character counting rules:
|
|
228
|
-
* - Each StyledChar counts by its value.length (handles combining marks)
|
|
229
|
-
* - Newlines ('\n') advance row and reset column
|
|
230
|
-
* - Other characters add their visual width to column
|
|
231
|
-
*/
|
|
232
|
-
export function getPositionAtOffset(styledChars, targetOffset) {
|
|
193
|
+
export function getPositionAtOffset(line, targetOffset) {
|
|
233
194
|
let row = 0;
|
|
234
195
|
let col = 0;
|
|
235
196
|
let charCount = 0;
|
|
236
|
-
for (
|
|
197
|
+
for (let i = 0; i < line.length; i++) {
|
|
237
198
|
if (charCount >= targetOffset) {
|
|
238
199
|
break;
|
|
239
200
|
}
|
|
240
|
-
|
|
201
|
+
const val = line.getValue(i);
|
|
202
|
+
if (val === '\n') {
|
|
241
203
|
row++;
|
|
242
204
|
col = 0;
|
|
243
205
|
}
|
|
244
206
|
else {
|
|
245
|
-
col += inkCharacterWidth(
|
|
207
|
+
col += inkCharacterWidth(val);
|
|
246
208
|
}
|
|
247
|
-
charCount +=
|
|
209
|
+
charCount += val.length;
|
|
248
210
|
}
|
|
249
211
|
return { row, col };
|
|
250
212
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measure-text.js","sourceRoot":"","sources":["../src/measure-text.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"measure-text.js","sourceRoot":"","sources":["../src/measure-text.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,QAAQ,EAAE,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AAkB5D,MAAM,kBAAkB,GAAgB,WAAW,CAAC;AAEpD,IAAI,kBAAkB,GAAgB,kBAAkB,CAAC;AAEzD,6EAA6E;AAC7E,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;AAE7C,8DAA8D;AAC9D,MAAM,uBAAuB,GAAG,IAAI,iBAAiB,CACpD,IAAI,EACJ,OAAO,CACP,CAAC;AAEF,IAAI,8BAA8B,GAAG,IAAI,CAAC;AAE1C,MAAM,UAAU,gCAAgC,CAAC,OAAgB;IAChE,8BAA8B,GAAG,OAAO,CAAC;IACzC,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,uBAAuB,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;AACF,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,EAAe;IACrD,kBAAkB,GAAG,EAAE,CAAC;IACxB,qBAAqB,EAAE,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,qBAAqB;IACpC,UAAU,CAAC,KAAK,EAAE,CAAC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ACP,GAAG,IAAI,iBAAiB,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC;QAED,SAAS,IAAI,GAAG,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,OAAO,EAAC,GAAG,EAAE,GAAG,EAAC,CAAC;AACnB,CAAC"}
|
package/build/output.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type StyledChar } from './tokenize.js';
|
|
2
1
|
import { type OutputTransformer } from './render-node-to-output.js';
|
|
3
2
|
import { type CursorPosition } from './log-update.js';
|
|
4
3
|
import { type StickyHeader, type DOMElement } from './dom.js';
|
|
@@ -9,7 +8,8 @@ Handles the positioning and saving of the output of each node in the tree. Also
|
|
|
9
8
|
|
|
10
9
|
Used to generate the final output of all nodes before writing it to actual output stream (e.g. stdout)
|
|
11
10
|
*/
|
|
12
|
-
|
|
11
|
+
import { StyledLine } from './styled-line.js';
|
|
12
|
+
export declare function clampCursorColumn(line: StyledLine, col: number): number;
|
|
13
13
|
type Options = {
|
|
14
14
|
width: number;
|
|
15
15
|
height: number;
|
|
@@ -55,8 +55,8 @@ export type Region = {
|
|
|
55
55
|
y: number;
|
|
56
56
|
width: number;
|
|
57
57
|
height: number;
|
|
58
|
-
readonly lines:
|
|
59
|
-
readonly styledOutput:
|
|
58
|
+
readonly lines: readonly StyledLine[];
|
|
59
|
+
readonly styledOutput: readonly StyledLine[];
|
|
60
60
|
isScrollable: boolean;
|
|
61
61
|
isVerticallyScrollable?: boolean;
|
|
62
62
|
isHorizontallyScrollable?: boolean;
|
|
@@ -198,7 +198,7 @@ export default class Output {
|
|
|
198
198
|
}): void;
|
|
199
199
|
endChildRegion(): void;
|
|
200
200
|
addStickyHeader(header: StickyHeader): void;
|
|
201
|
-
write(x: number, y: number, items: string |
|
|
201
|
+
write(x: number, y: number, items: string | StyledLine, options: {
|
|
202
202
|
transformers: OutputTransformer[];
|
|
203
203
|
lineIndex?: number;
|
|
204
204
|
preserveBackgroundColor?: boolean;
|
|
@@ -217,12 +217,6 @@ export default class Output {
|
|
|
217
217
|
private clearRange;
|
|
218
218
|
private clipChars;
|
|
219
219
|
}
|
|
220
|
-
/**
|
|
221
|
-
* Flattens a hierarchy of nested regions into a single 2D array of styled characters
|
|
222
|
-
* that represents the final visual output to be written to the terminal.
|
|
223
|
-
* This effectively renders the nested region tree (much like compositing layers
|
|
224
|
-
* in a web browser) into a single screen buffer.
|
|
225
|
-
*/
|
|
226
220
|
export declare function flattenRegion(root: Region, options?: {
|
|
227
221
|
context?: {
|
|
228
222
|
cursorPosition?: {
|
|
@@ -232,7 +226,7 @@ export declare function flattenRegion(root: Region, options?: {
|
|
|
232
226
|
};
|
|
233
227
|
skipScrollbars?: boolean;
|
|
234
228
|
skipStickyHeaders?: boolean;
|
|
235
|
-
}):
|
|
229
|
+
}): StyledLine[];
|
|
236
230
|
export declare const extractSelectableText: (spans: Array<{
|
|
237
231
|
y: number;
|
|
238
232
|
startX: number;
|