@orz/ui-ansi 0.0.0-stage → 0.0.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/LICENSE +29 -0
- package/README.md +232 -2
- package/dist/content.d.ts +20 -0
- package/dist/content.d.ts.map +1 -0
- package/dist/content.js +90 -0
- package/dist/content.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/parse/index.d.ts +6 -0
- package/dist/parse/index.d.ts.map +1 -0
- package/dist/parse/index.js +5 -0
- package/dist/parse/index.js.map +1 -0
- package/dist/parse/level-tracker.d.ts +14 -0
- package/dist/parse/level-tracker.d.ts.map +1 -0
- package/dist/parse/level-tracker.js +87 -0
- package/dist/parse/level-tracker.js.map +1 -0
- package/dist/parse/levels.d.ts +19 -0
- package/dist/parse/levels.d.ts.map +1 -0
- package/dist/parse/levels.js +167 -0
- package/dist/parse/levels.js.map +1 -0
- package/dist/parse/line.d.ts +49 -0
- package/dist/parse/line.d.ts.map +1 -0
- package/dist/parse/line.js +289 -0
- package/dist/parse/line.js.map +1 -0
- package/dist/parse/palette.d.ts +12 -0
- package/dist/parse/palette.d.ts.map +1 -0
- package/dist/parse/palette.js +40 -0
- package/dist/parse/palette.js.map +1 -0
- package/dist/parse/parser.d.ts +18 -0
- package/dist/parse/parser.d.ts.map +1 -0
- package/dist/parse/parser.js +178 -0
- package/dist/parse/parser.js.map +1 -0
- package/dist/parse/sgr.d.ts +7 -0
- package/dist/parse/sgr.d.ts.map +1 -0
- package/dist/parse/sgr.js +179 -0
- package/dist/parse/sgr.js.map +1 -0
- package/dist/parse/styles.d.ts +15 -0
- package/dist/parse/styles.d.ts.map +1 -0
- package/dist/parse/styles.js +75 -0
- package/dist/parse/styles.js.map +1 -0
- package/dist/parse/tokenizer.d.ts +36 -0
- package/dist/parse/tokenizer.d.ts.map +1 -0
- package/dist/parse/tokenizer.js +287 -0
- package/dist/parse/tokenizer.js.map +1 -0
- package/dist/parse/types.d.ts +50 -0
- package/dist/parse/types.d.ts.map +1 -0
- package/dist/parse/types.js +2 -0
- package/dist/parse/types.js.map +1 -0
- package/dist/view/ansi-view.d.ts +27 -0
- package/dist/view/ansi-view.d.ts.map +1 -0
- package/dist/view/ansi-view.js +675 -0
- package/dist/view/ansi-view.js.map +1 -0
- package/dist/view/geometry.d.ts +30 -0
- package/dist/view/geometry.d.ts.map +1 -0
- package/dist/view/geometry.js +125 -0
- package/dist/view/geometry.js.map +1 -0
- package/dist/view/metrics.d.ts +17 -0
- package/dist/view/metrics.d.ts.map +1 -0
- package/dist/view/metrics.js +69 -0
- package/dist/view/metrics.js.map +1 -0
- package/dist/view/row.d.ts +41 -0
- package/dist/view/row.d.ts.map +1 -0
- package/dist/view/row.js +113 -0
- package/dist/view/row.js.map +1 -0
- package/dist/view/run-style.d.ts +11 -0
- package/dist/view/run-style.d.ts.map +1 -0
- package/dist/view/run-style.js +87 -0
- package/dist/view/run-style.js.map +1 -0
- package/dist/view/search.d.ts +28 -0
- package/dist/view/search.d.ts.map +1 -0
- package/dist/view/search.js +76 -0
- package/dist/view/search.js.map +1 -0
- package/dist/view/shown-lines.d.ts +15 -0
- package/dist/view/shown-lines.d.ts.map +1 -0
- package/dist/view/shown-lines.js +50 -0
- package/dist/view/shown-lines.js.map +1 -0
- package/dist/view/time-slices.d.ts +9 -0
- package/dist/view/time-slices.d.ts.map +1 -0
- package/dist/view/time-slices.js +35 -0
- package/dist/view/time-slices.js.map +1 -0
- package/dist/view/toolbar.d.ts +47 -0
- package/dist/view/toolbar.d.ts.map +1 -0
- package/dist/view/toolbar.js +58 -0
- package/dist/view/toolbar.js.map +1 -0
- package/dist/view/use-ansi-lines.d.ts +28 -0
- package/dist/view/use-ansi-lines.d.ts.map +1 -0
- package/dist/view/use-ansi-lines.js +103 -0
- package/dist/view/use-ansi-lines.js.map +1 -0
- package/dist/view/use-search.d.ts +37 -0
- package/dist/view/use-search.d.ts.map +1 -0
- package/dist/view/use-search.js +205 -0
- package/dist/view/use-search.js.map +1 -0
- package/dist/view/virtual-rows.d.ts +36 -0
- package/dist/view/virtual-rows.d.ts.map +1 -0
- package/dist/view/virtual-rows.js +156 -0
- package/dist/view/virtual-rows.js.map +1 -0
- package/package.json +58 -3
- package/styles.css +110 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/** In code order: a level's code is its index + 1, and 0 is no level. */
|
|
2
|
+
export const LEVELS = [
|
|
3
|
+
"fatal",
|
|
4
|
+
"error",
|
|
5
|
+
"warn",
|
|
6
|
+
"info",
|
|
7
|
+
"debug",
|
|
8
|
+
"trace",
|
|
9
|
+
];
|
|
10
|
+
/** Set on a level code that a continuation line took from the line above. */
|
|
11
|
+
export const LEVEL_INHERITED = 0x80;
|
|
12
|
+
export function levelCode(level) {
|
|
13
|
+
return LEVELS.indexOf(level) + 1;
|
|
14
|
+
}
|
|
15
|
+
export function levelOfCode(code) {
|
|
16
|
+
return LEVELS[(code & ~LEVEL_INHERITED) - 1] ?? null;
|
|
17
|
+
}
|
|
18
|
+
/** How much of a line the detector reads. */
|
|
19
|
+
export const LEVEL_WINDOW = 256;
|
|
20
|
+
const WORDS = new Map();
|
|
21
|
+
for (const [level, words] of [
|
|
22
|
+
["fatal", "fatal critical crit emerg emergency alert panic"],
|
|
23
|
+
["error", "error err severe"],
|
|
24
|
+
["warn", "warning warn"],
|
|
25
|
+
["info", "info information notice"],
|
|
26
|
+
["debug", "debug dbg fine"],
|
|
27
|
+
["trace", "trace verbose finer finest"],
|
|
28
|
+
]) {
|
|
29
|
+
for (const word of words.split(" "))
|
|
30
|
+
WORDS.set(word, level);
|
|
31
|
+
}
|
|
32
|
+
const WORD_ALT = [...WORDS.keys()]
|
|
33
|
+
.sort((a, b) => b.length - a.length)
|
|
34
|
+
.join("|");
|
|
35
|
+
// `d`: the offsets of the value, which the row colours.
|
|
36
|
+
const JSON_LEVEL = /"(?:level|lvl|severity|loglevel)"\s*:\s*(?:"(\w+)"|(\d+))/dgi;
|
|
37
|
+
const LOGFMT_LEVEL = /(?:^|\s)(?:level|lvl|severity)=(?:"(\w+)"|(\w+))/dgi;
|
|
38
|
+
const SYSLOG = /^<(\d{1,3})>/;
|
|
39
|
+
const KLOG = /^([IWEF])[01]\d[0-3]\d [0-2]\d:[0-5]\d:[0-5]\d/;
|
|
40
|
+
// The brief form wants a tag and a colon, so that a line opening with
|
|
41
|
+
// "I/O error" is not read as info. logcat pads a short tag to eight cells
|
|
42
|
+
// before the pid.
|
|
43
|
+
const LOGCAT_BRIEF = /^([VDIWEFA])\/[^\s(:]+(?:\s*\(\s*\d+\))?:(?:\s|$)/;
|
|
44
|
+
const LOGCAT_THREADTIME = /^\d\d-\d\d \d\d:\d\d:\d\d\.\d{3}\s+\d+\s+\d+ ([VDIWEFA]) /d;
|
|
45
|
+
const TRACEBACK = /^Traceback \(most recent call last\):/;
|
|
46
|
+
const UPPER_WORD = new RegExp(`\\b(${WORD_ALT.toUpperCase()})\\b`, "d");
|
|
47
|
+
// One alternative per bracket pair, so that "(level < warn)" is not a bracket.
|
|
48
|
+
const BRACKETED_WORD = new RegExp(`\\[\\s*(${WORD_ALT})\\s*\\]|<\\s*(${WORD_ALT})\\s*>|\\(\\s*(${WORD_ALT})\\s*\\)`, "di");
|
|
49
|
+
const COLON_WORD = new RegExp(`\\b(${WORD_ALT}):`, "di");
|
|
50
|
+
// Lazy, so that a level word opening the line wins over the second word.
|
|
51
|
+
const LEADING_WORD = new RegExp(`^(?:\\S+[ \\t]+)??(${WORD_ALT})\\b`, "di");
|
|
52
|
+
/** Rule 7's forms, in tie-break order. */
|
|
53
|
+
const WORD_FORMS = [UPPER_WORD, BRACKETED_WORD, COLON_WORD, LEADING_WORD];
|
|
54
|
+
const KLOG_LEVELS = {
|
|
55
|
+
I: "info",
|
|
56
|
+
W: "warn",
|
|
57
|
+
E: "error",
|
|
58
|
+
F: "fatal",
|
|
59
|
+
};
|
|
60
|
+
const LOGCAT_LEVELS = {
|
|
61
|
+
V: "trace",
|
|
62
|
+
D: "debug",
|
|
63
|
+
I: "info",
|
|
64
|
+
W: "warn",
|
|
65
|
+
E: "error",
|
|
66
|
+
A: "fatal",
|
|
67
|
+
F: "fatal",
|
|
68
|
+
};
|
|
69
|
+
function pinoLevel(n) {
|
|
70
|
+
if (n >= 60)
|
|
71
|
+
return "fatal";
|
|
72
|
+
if (n >= 50)
|
|
73
|
+
return "error";
|
|
74
|
+
if (n >= 40)
|
|
75
|
+
return "warn";
|
|
76
|
+
if (n >= 30)
|
|
77
|
+
return "info";
|
|
78
|
+
if (n >= 20)
|
|
79
|
+
return "debug";
|
|
80
|
+
return "trace";
|
|
81
|
+
}
|
|
82
|
+
function syslogLevel(severity) {
|
|
83
|
+
if (severity <= 2)
|
|
84
|
+
return "fatal";
|
|
85
|
+
if (severity === 3)
|
|
86
|
+
return "error";
|
|
87
|
+
if (severity === 4)
|
|
88
|
+
return "warn";
|
|
89
|
+
if (severity <= 6)
|
|
90
|
+
return "info";
|
|
91
|
+
return "debug";
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* `m[group]`'s level and offsets, or null when the group is not set, is not
|
|
95
|
+
* in `toLevel`, or runs into the end of a window cut from a longer line: it
|
|
96
|
+
* may be the head of a longer word ("ERRORS") or number.
|
|
97
|
+
*/
|
|
98
|
+
function found(m, group, toLevel, window, cut) {
|
|
99
|
+
const value = m?.[group];
|
|
100
|
+
if (value === undefined)
|
|
101
|
+
return null;
|
|
102
|
+
const level = toLevel(value);
|
|
103
|
+
const span = m?.indices?.[group];
|
|
104
|
+
if (!level || !span)
|
|
105
|
+
return null;
|
|
106
|
+
const [from, to] = span;
|
|
107
|
+
if (cut && to === window.length)
|
|
108
|
+
return null;
|
|
109
|
+
return { level, from, to };
|
|
110
|
+
}
|
|
111
|
+
const wordLevel = (value) => WORDS.get(value.toLowerCase());
|
|
112
|
+
const pinoValue = (value) => pinoLevel(Number(value));
|
|
113
|
+
/** The first key whose value is a level word, or for JSON a number. */
|
|
114
|
+
function keyed(re, window, cut) {
|
|
115
|
+
re.lastIndex = 0;
|
|
116
|
+
for (let m = re.exec(window); m; m = re.exec(window)) {
|
|
117
|
+
const hit = found(m, 1, wordLevel, window, cut) ??
|
|
118
|
+
found(m, 2, re === JSON_LEVEL ? pinoValue : wordLevel, window, cut);
|
|
119
|
+
if (hit)
|
|
120
|
+
return hit;
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
/** The default detector. Pure; reads at most the first 256 UTF-16 units. */
|
|
125
|
+
export function detectLevel(text) {
|
|
126
|
+
const window = text.slice(0, LEVEL_WINDOW);
|
|
127
|
+
const cut = text.length > LEVEL_WINDOW;
|
|
128
|
+
if (window.startsWith("{")) {
|
|
129
|
+
const hit = keyed(JSON_LEVEL, window, cut);
|
|
130
|
+
if (hit)
|
|
131
|
+
return hit;
|
|
132
|
+
}
|
|
133
|
+
const logfmt = keyed(LOGFMT_LEVEL, window, cut);
|
|
134
|
+
if (logfmt)
|
|
135
|
+
return logfmt;
|
|
136
|
+
let m = SYSLOG.exec(window);
|
|
137
|
+
if (m) {
|
|
138
|
+
const pri = Number(m[1]);
|
|
139
|
+
if (pri <= 191) {
|
|
140
|
+
return { level: syslogLevel(pri % 8), from: 0, to: m[0].length };
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
m = KLOG.exec(window);
|
|
144
|
+
if (m)
|
|
145
|
+
return { level: KLOG_LEVELS[m[1]], from: 0, to: 1 };
|
|
146
|
+
m = LOGCAT_BRIEF.exec(window);
|
|
147
|
+
if (m)
|
|
148
|
+
return { level: LOGCAT_LEVELS[m[1]], from: 0, to: 1 };
|
|
149
|
+
const threadtime = found(LOGCAT_THREADTIME.exec(window), 1, (letter) => LOGCAT_LEVELS[letter], window, false);
|
|
150
|
+
if (threadtime)
|
|
151
|
+
return threadtime;
|
|
152
|
+
if (TRACEBACK.test(window))
|
|
153
|
+
return { level: "error", from: 0, to: 9 };
|
|
154
|
+
let best = null;
|
|
155
|
+
for (const re of WORD_FORMS) {
|
|
156
|
+
const m = re.exec(window);
|
|
157
|
+
// Only BRACKETED_WORD has groups 2 and 3; elsewhere they read as unset.
|
|
158
|
+
const hit = found(m, 1, wordLevel, window, cut) ??
|
|
159
|
+
found(m, 2, wordLevel, window, cut) ??
|
|
160
|
+
found(m, 3, wordLevel, window, cut);
|
|
161
|
+
// Strictly earlier, so that an equal offset keeps the form listed first.
|
|
162
|
+
if (hit && (!best || hit.from < best.from))
|
|
163
|
+
best = hit;
|
|
164
|
+
}
|
|
165
|
+
return best;
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=levels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"levels.js","sourceRoot":"","sources":["../../src/parse/levels.ts"],"names":[],"mappings":"AAWA,yEAAyE;AACzE,MAAM,CAAC,MAAM,MAAM,GAAwB;IACzC,OAAO;IACP,OAAO;IACP,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;CACR,CAAC;AAEF,6EAA6E;AAC7E,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC;AAEpC,MAAM,UAAU,SAAS,CAAC,KAAe;IACvC,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,MAAM,CAAC,CAAC,IAAI,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC;AACvD,CAAC;AAED,6CAA6C;AAC7C,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAEhC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAoB,CAAC;AAC1C,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI;IAC3B,CAAC,OAAO,EAAE,iDAAiD,CAAC;IAC5D,CAAC,OAAO,EAAE,kBAAk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rogate takes 1. */
|
|
3
|
+
export declare function codePointCells(codePoint: number): 0 | 1 | 2;
|
|
4
|
+
/**
|
|
5
|
+
* Builds one line at a time. Text that only moves the cursor forwards is
|
|
6
|
+
* appended to `text` and `runs` directly; the first backward move switches
|
|
7
|
+
* the line to a cell buffer, compacted back at `finish`.
|
|
8
|
+
*/
|
|
9
|
+
export declare class LineBuilder {
|
|
10
|
+
private text;
|
|
11
|
+
private cells;
|
|
12
|
+
private runs;
|
|
13
|
+
private runCount;
|
|
14
|
+
private slow;
|
|
15
|
+
private crPending;
|
|
16
|
+
private chars;
|
|
17
|
+
private ids;
|
|
18
|
+
private cursor;
|
|
19
|
+
private prefix;
|
|
20
|
+
private prefixId;
|
|
21
|
+
/**
|
|
22
|
+
* Writes `chunk[start, end)`, printable code points only. `cells` is its
|
|
23
|
+
* width; the cell buffer measures each code point again instead.
|
|
24
|
+
*/
|
|
25
|
+
write(chunk: string, start: number, end: number, cells: number, id: number): void;
|
|
26
|
+
carriageReturn(): void;
|
|
27
|
+
backspace(): void;
|
|
28
|
+
tab(id: number): void;
|
|
29
|
+
/** `CSI n C`. */
|
|
30
|
+
forward(n: number): void;
|
|
31
|
+
/** `CSI n D`, and `\b` as one cell. */
|
|
32
|
+
backward(n: number): void;
|
|
33
|
+
/** `CSI n G`, with `column` 0-based. */
|
|
34
|
+
column(column: number): void;
|
|
35
|
+
/** `CSI n K`: 0 to the end, 1 from the start, 2 the whole line. */
|
|
36
|
+
erase(mode: number): void;
|
|
37
|
+
/** Ends the line and starts the next one. */
|
|
38
|
+
finish(): AnsiLine;
|
|
39
|
+
private flushFast;
|
|
40
|
+
private compact;
|
|
41
|
+
private append;
|
|
42
|
+
private appendText;
|
|
43
|
+
private resolve;
|
|
44
|
+
/** Replays the fast path's text into the cell buffer. */
|
|
45
|
+
private toSlow;
|
|
46
|
+
private pad;
|
|
47
|
+
private put;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=line.d.ts.map
|
|
@@ -0,0 +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AAS;IAMjB,OAAO,CAAC,OAAO;IAaf,OAAO,CAAC,MAAM;IAqBd,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,OAAO;IAOf,yDAAyD;IACzD,OAAO,CAAC,MAAM;IAed,OAAO,CAAC,GAAG;IAOX,OAAO,CAAC,GAAG;CA4BZ"}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { cellWidth } from "@orz/ui/lib/cell-width";
|
|
2
|
+
/** The cell width of a code point that is not a control; a lone surrogate takes 1. */
|
|
3
|
+
export function codePointCells(codePoint) {
|
|
4
|
+
if (codePoint < 0x300 || (codePoint >= 0xd800 && codePoint <= 0xdfff)) {
|
|
5
|
+
return 1;
|
|
6
|
+
}
|
|
7
|
+
return cellWidth(codePoint);
|
|
8
|
+
}
|
|
9
|
+
/** Marks the right half of a wide character in the cell buffer. */
|
|
10
|
+
const CONTINUATION = "";
|
|
11
|
+
const TAB = 8;
|
|
12
|
+
const EMPTY_RUNS = new Uint32Array(0);
|
|
13
|
+
/**
|
|
14
|
+
* Builds one line at a time. Text that only moves the cursor forwards is
|
|
15
|
+
* appended to `text` and `runs` directly; the first backward move switches
|
|
16
|
+
* the line to a cell buffer, compacted back at `finish`.
|
|
17
|
+
*/
|
|
18
|
+
export class LineBuilder {
|
|
19
|
+
text = "";
|
|
20
|
+
cells = 0;
|
|
21
|
+
runs = new Uint32Array(64);
|
|
22
|
+
runCount = 0;
|
|
23
|
+
slow = false;
|
|
24
|
+
// `\r` is resolved lazily, so a CRLF line never leaves the fast path.
|
|
25
|
+
crPending = false;
|
|
26
|
+
chars = [];
|
|
27
|
+
ids = [];
|
|
28
|
+
cursor = 0;
|
|
29
|
+
// Zero-width code points with no cell before them to attach to.
|
|
30
|
+
prefix = "";
|
|
31
|
+
prefixId = 0;
|
|
32
|
+
/**
|
|
33
|
+
* Writes `chunk[start, end)`, printable code points only. `cells` is its
|
|
34
|
+
* width; the cell buffer measures each code point again instead.
|
|
35
|
+
*/
|
|
36
|
+
write(chunk, start, end, cells, id) {
|
|
37
|
+
if (start >= end)
|
|
38
|
+
return;
|
|
39
|
+
this.resolve();
|
|
40
|
+
if (!this.slow) {
|
|
41
|
+
this.append(chunk.slice(start, end), cells, id);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
let i = start;
|
|
45
|
+
while (i < end) {
|
|
46
|
+
const c = chunk.charCodeAt(i);
|
|
47
|
+
let next = i + 1;
|
|
48
|
+
let codePoint = c;
|
|
49
|
+
if (c >= 0xd800 && c <= 0xdbff && next < end) {
|
|
50
|
+
const d = chunk.charCodeAt(next);
|
|
51
|
+
if (d >= 0xdc00 && d <= 0xdfff) {
|
|
52
|
+
codePoint = ((c - 0xd800) << 10) + (d - 0xdc00) + 0x10000;
|
|
53
|
+
next++;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
this.put(chunk.slice(i, next), codePointCells(codePoint), id);
|
|
57
|
+
i = next;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
carriageReturn() {
|
|
61
|
+
if (this.slow)
|
|
62
|
+
this.cursor = 0;
|
|
63
|
+
else if (this.cells > 0)
|
|
64
|
+
this.crPending = true;
|
|
65
|
+
}
|
|
66
|
+
backspace() {
|
|
67
|
+
this.backward(1);
|
|
68
|
+
}
|
|
69
|
+
tab(id) {
|
|
70
|
+
this.resolve();
|
|
71
|
+
if (!this.slow) {
|
|
72
|
+
const n = TAB - (this.cells % TAB);
|
|
73
|
+
this.append(" ".repeat(n), n, id);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const target = (Math.floor(this.cursor / TAB) + 1) * TAB;
|
|
77
|
+
this.pad(this.cursor);
|
|
78
|
+
while (this.chars.length < target) {
|
|
79
|
+
this.chars.push(" ");
|
|
80
|
+
this.ids.push(id);
|
|
81
|
+
}
|
|
82
|
+
this.cursor = target;
|
|
83
|
+
}
|
|
84
|
+
/** `CSI n C`. */
|
|
85
|
+
forward(n) {
|
|
86
|
+
this.resolve();
|
|
87
|
+
if (!this.slow) {
|
|
88
|
+
this.append(" ".repeat(n), n, 0);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
this.cursor += n;
|
|
92
|
+
this.pad(this.cursor);
|
|
93
|
+
}
|
|
94
|
+
/** `CSI n D`, and `\b` as one cell. */
|
|
95
|
+
backward(n) {
|
|
96
|
+
this.resolve();
|
|
97
|
+
if (!this.slow) {
|
|
98
|
+
if (this.cells === 0)
|
|
99
|
+
return;
|
|
100
|
+
this.toSlow();
|
|
101
|
+
}
|
|
102
|
+
this.cursor = Math.max(0, this.cursor - n);
|
|
103
|
+
}
|
|
104
|
+
/** `CSI n G`, with `column` 0-based. */
|
|
105
|
+
column(column) {
|
|
106
|
+
this.resolve();
|
|
107
|
+
if (!this.slow) {
|
|
108
|
+
if (column >= this.cells) {
|
|
109
|
+
const n = column - this.cells;
|
|
110
|
+
if (n > 0)
|
|
111
|
+
this.append(" ".repeat(n), n, 0);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
this.toSlow();
|
|
115
|
+
}
|
|
116
|
+
this.cursor = column;
|
|
117
|
+
this.pad(column);
|
|
118
|
+
}
|
|
119
|
+
/** `CSI n K`: 0 to the end, 1 from the start, 2 the whole line. */
|
|
120
|
+
erase(mode) {
|
|
121
|
+
this.resolve();
|
|
122
|
+
if (!this.slow) {
|
|
123
|
+
// The cursor is at the end, so there is nothing after it to erase,
|
|
124
|
+
// unless it is at column 0 behind zero-width code points alone.
|
|
125
|
+
if (this.text === "" || (mode === 0 && this.cells > 0))
|
|
126
|
+
return;
|
|
127
|
+
this.toSlow();
|
|
128
|
+
}
|
|
129
|
+
const { chars, ids } = this;
|
|
130
|
+
const at = this.cursor;
|
|
131
|
+
if (mode === 0) {
|
|
132
|
+
if (at === 0)
|
|
133
|
+
this.prefix = "";
|
|
134
|
+
if (at >= chars.length)
|
|
135
|
+
return;
|
|
136
|
+
// The erase cut a wide character in half.
|
|
137
|
+
if (chars[at] === CONTINUATION)
|
|
138
|
+
chars[at - 1] = " ";
|
|
139
|
+
chars.length = at;
|
|
140
|
+
ids.length = at;
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
this.prefix = "";
|
|
144
|
+
if (mode === 2) {
|
|
145
|
+
chars.length = 0;
|
|
146
|
+
ids.length = 0;
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const last = Math.min(this.cursor, chars.length - 1);
|
|
150
|
+
for (let x = 0; x <= last; x++) {
|
|
151
|
+
chars[x] = " ";
|
|
152
|
+
ids[x] = 0;
|
|
153
|
+
}
|
|
154
|
+
if (chars[last + 1] === CONTINUATION)
|
|
155
|
+
chars[last + 1] = " ";
|
|
156
|
+
}
|
|
157
|
+
/** Ends the line and starts the next one. */
|
|
158
|
+
finish() {
|
|
159
|
+
const line = this.slow ? this.compact() : this.flushFast();
|
|
160
|
+
this.text = "";
|
|
161
|
+
this.cells = 0;
|
|
162
|
+
this.runCount = 0;
|
|
163
|
+
this.slow = false;
|
|
164
|
+
this.crPending = false;
|
|
165
|
+
this.chars.length = 0;
|
|
166
|
+
this.ids.length = 0;
|
|
167
|
+
this.cursor = 0;
|
|
168
|
+
this.prefix = "";
|
|
169
|
+
this.prefixId = 0;
|
|
170
|
+
return line;
|
|
171
|
+
}
|
|
172
|
+
flushFast() {
|
|
173
|
+
const runs = this.runCount === 0 ? EMPTY_RUNS : this.runs.slice(0, this.runCount * 2);
|
|
174
|
+
return { text: this.text, runs, cells: this.cells };
|
|
175
|
+
}
|
|
176
|
+
compact() {
|
|
177
|
+
this.text = "";
|
|
178
|
+
this.runCount = 0;
|
|
179
|
+
if (this.prefix !== "")
|
|
180
|
+
this.appendText(this.prefix, this.prefixId);
|
|
181
|
+
const { chars, ids } = this;
|
|
182
|
+
for (let x = 0; x < chars.length; x++) {
|
|
183
|
+
const char = chars[x];
|
|
184
|
+
if (char !== CONTINUATION)
|
|
185
|
+
this.appendText(char, ids[x]);
|
|
186
|
+
}
|
|
187
|
+
this.cells = chars.length;
|
|
188
|
+
return this.flushFast();
|
|
189
|
+
}
|
|
190
|
+
append(text, cells, id) {
|
|
191
|
+
const n = this.runCount;
|
|
192
|
+
let rest = text;
|
|
193
|
+
if (n > 0 && this.runs[n * 2 - 1] !== id) {
|
|
194
|
+
// Zero-width code points belong to the cell before them, so they keep
|
|
195
|
+
// its style, as they do in the cell buffer.
|
|
196
|
+
let i = 0;
|
|
197
|
+
while (i < text.length) {
|
|
198
|
+
const codePoint = text.codePointAt(i);
|
|
199
|
+
if (codePointCells(codePoint) !== 0)
|
|
200
|
+
break;
|
|
201
|
+
i += codePoint > 0xffff ? 2 : 1;
|
|
202
|
+
}
|
|
203
|
+
if (i > 0) {
|
|
204
|
+
this.text += text.slice(0, i);
|
|
205
|
+
rest = text.slice(i);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (rest !== "")
|
|
209
|
+
this.appendText(rest, id);
|
|
210
|
+
this.cells += cells;
|
|
211
|
+
}
|
|
212
|
+
appendText(text, id) {
|
|
213
|
+
const n = this.runCount;
|
|
214
|
+
if (n === 0 || this.runs[n * 2 - 1] !== id) {
|
|
215
|
+
if (n * 2 + 2 > this.runs.length) {
|
|
216
|
+
const grown = new Uint32Array(this.runs.length * 2);
|
|
217
|
+
grown.set(this.runs);
|
|
218
|
+
this.runs = grown;
|
|
219
|
+
}
|
|
220
|
+
this.runs[n * 2] = this.text.length;
|
|
221
|
+
this.runs[n * 2 + 1] = id;
|
|
222
|
+
this.runCount = n + 1;
|
|
223
|
+
}
|
|
224
|
+
this.text += text;
|
|
225
|
+
}
|
|
226
|
+
resolve() {
|
|
227
|
+
if (!this.crPending)
|
|
228
|
+
return;
|
|
229
|
+
this.crPending = false;
|
|
230
|
+
this.toSlow();
|
|
231
|
+
this.cursor = 0;
|
|
232
|
+
}
|
|
233
|
+
/** Replays the fast path's text into the cell buffer. */
|
|
234
|
+
toSlow() {
|
|
235
|
+
const { text, runs, runCount } = this;
|
|
236
|
+
this.slow = true;
|
|
237
|
+
let run = 0;
|
|
238
|
+
let i = 0;
|
|
239
|
+
while (i < text.length) {
|
|
240
|
+
while (run + 1 < runCount && runs[(run + 1) * 2] <= i)
|
|
241
|
+
run++;
|
|
242
|
+
const id = runs[run * 2 + 1];
|
|
243
|
+
const codePoint = text.codePointAt(i);
|
|
244
|
+
const next = i + (codePoint > 0xffff ? 2 : 1);
|
|
245
|
+
this.put(text.slice(i, next), codePointCells(codePoint), id);
|
|
246
|
+
i = next;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
pad(to) {
|
|
250
|
+
while (this.chars.length < to) {
|
|
251
|
+
this.chars.push(" ");
|
|
252
|
+
this.ids.push(0);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
put(char, width, id) {
|
|
256
|
+
const { chars, ids } = this;
|
|
257
|
+
if (width === 0) {
|
|
258
|
+
this.pad(this.cursor);
|
|
259
|
+
let x = this.cursor - 1;
|
|
260
|
+
if (x >= 0 && chars[x] === CONTINUATION)
|
|
261
|
+
x--;
|
|
262
|
+
if (x < 0) {
|
|
263
|
+
if (this.prefix === "")
|
|
264
|
+
this.prefixId = id;
|
|
265
|
+
this.prefix += char;
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
chars[x] += char;
|
|
269
|
+
}
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
const at = this.cursor;
|
|
273
|
+
this.pad(at);
|
|
274
|
+
const end = at + width;
|
|
275
|
+
// Overwriting either half of a wide character blanks the other half.
|
|
276
|
+
if (chars[at] === CONTINUATION && at > 0)
|
|
277
|
+
chars[at - 1] = " ";
|
|
278
|
+
if (chars[end] === CONTINUATION)
|
|
279
|
+
chars[end] = " ";
|
|
280
|
+
chars[at] = char;
|
|
281
|
+
ids[at] = id;
|
|
282
|
+
if (width === 2) {
|
|
283
|
+
chars[at + 1] = CONTINUATION;
|
|
284
|
+
ids[at + 1] = id;
|
|
285
|
+
}
|
|
286
|
+
this.cursor = end;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
//# sourceMappingURL=line.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line.js","sourceRoot":"","sources":["../../src/parse/line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAInD,sFAAsF;AACtF,MAAM,UAAU,cAAc,CAAC,SAAiB;IAC9C,IAAI,SAAS,GAAG,KAAK,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,SAAS,IAAI,MAAM,CAAC,EAAE,CAAC;QACtE,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,SAAS,CAAC,SAAS,CAAC,CAAC;AAC9B,CAAC;AAED,mEAAmE;AACnE,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,GAAG,GAAG,CAAC,CAAC;AACd,MAAM,UAAU,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;AAEtC;;;;GAIG;AACH,MAAM,OAAO,WAAW;IACd,IAAI,GAAG,EAAE,CAAC;IACV,KAAK,GAAG,CAAC,CAAC;IACV,IAAI,GAAG,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC;IAC3B,QAAQ,GAAG,CAAC,CAAC;IAEb,IAAI,GAAG,KAAK,CAAC;IACrB,sEAAsE;IAC9D,SAAS,GAAG,KAAK,CAAC;IAClB,KAAK,GAAa,EAAE,CAAC;IACrB,GAAG,GAAa,EAAE,CAAC;IACnB,MAAM,GAAG,CAAC,CAAC;IACnB,gEAAgE;IACxD,MAAM,GAAG,EAAE,CAAC;IACZ,QAAQ,GAAG,CAAC,CAAC;IAErB;;;OAGG;IACH,KAAK,CACH,KAAa,EACb,KAAa,EACb,GAAW,EACX,KAAa,EACb,EAAU;QAEV,IAAI,KAAK,IAAI,GAAG;YAAE,OAAO;QACzB,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,IAAI,CAA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IAAI,CAAC,MAAM,IAAI,IAAI,CAAC;YACtB,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;YACnB,CAAC;YACD,OAAO;QACT,CAAC;QACD,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC;QACvB,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACb,MAAM,GAAG,GAAG,EAAE,GAAG,KAAK,CAAC;QACvB,qEAAqE;QACrE,IAAI,KAAK,CAAC,EAAE,CAAC,KAAK,YAAY,IAAI,EAAE,GAAG,CAAC;YAAE,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;QAC9D,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,YAAY;YAAE,KAAK,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;QAClD,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;QACjB,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC;QACb,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YAChB,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,YAAY,CAAC;YAC7B,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QACnB,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;IACpB,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The names of palette colours 0–15, as in the `--ansi-<name>` theme tokens. */
|
|
2
|
+
export declare const PALETTE_NAMES: readonly ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "bright-black", "bright-red", "bright-green", "bright-yellow", "bright-blue", "bright-magenta", "bright-cyan", "bright-white"];
|
|
3
|
+
/**
|
|
4
|
+
* xterm's fixed value for palette colour 16–255: the 6×6×6 cube, then 24
|
|
5
|
+
* greys. Colours 0–15 belong to the theme, so they have no fixed value.
|
|
6
|
+
*/
|
|
7
|
+
export declare function xterm256(index: number): {
|
|
8
|
+
r: number;
|
|
9
|
+
g: number;
|
|
10
|
+
b: number;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=palette.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../src/parse/palette.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,eAAO,MAAM,aAAa,YACxB,OAAO,EACP,KAAK,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,SAAS,EACT,MAAM,EACN,OAAO,EACP,cAAc,EACd,YAAY,EACZ,cAAc,EACd,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,cAAc,CACN,CAAC;AAIX;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAc3E"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** The names of palette colours 0–15, as in the `--ansi-<name>` theme tokens. */
|
|
2
|
+
export const PALETTE_NAMES = [
|
|
3
|
+
"black",
|
|
4
|
+
"red",
|
|
5
|
+
"green",
|
|
6
|
+
"yellow",
|
|
7
|
+
"blue",
|
|
8
|
+
"magenta",
|
|
9
|
+
"cyan",
|
|
10
|
+
"white",
|
|
11
|
+
"bright-black",
|
|
12
|
+
"bright-red",
|
|
13
|
+
"bright-green",
|
|
14
|
+
"bright-yellow",
|
|
15
|
+
"bright-blue",
|
|
16
|
+
"bright-magenta",
|
|
17
|
+
"bright-cyan",
|
|
18
|
+
"bright-white",
|
|
19
|
+
];
|
|
20
|
+
const CUBE = [0, 95, 135, 175, 215, 255];
|
|
21
|
+
/**
|
|
22
|
+
* xterm's fixed value for palette colour 16–255: the 6×6×6 cube, then 24
|
|
23
|
+
* greys. Colours 0–15 belong to the theme, so they have no fixed value.
|
|
24
|
+
*/
|
|
25
|
+
export function xterm256(index) {
|
|
26
|
+
if (!Number.isInteger(index) || index < 16 || index > 255) {
|
|
27
|
+
throw new RangeError(`xterm256: ${index} is not in 16–255`);
|
|
28
|
+
}
|
|
29
|
+
if (index >= 232) {
|
|
30
|
+
const level = 8 + 10 * (index - 232);
|
|
31
|
+
return { r: level, g: level, b: level };
|
|
32
|
+
}
|
|
33
|
+
const n = index - 16;
|
|
34
|
+
return {
|
|
35
|
+
r: CUBE[Math.floor(n / 36)],
|
|
36
|
+
g: CUBE[Math.floor(n / 6) % 6],
|
|
37
|
+
b: CUBE[n % 6],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=palette.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"palette.js","sourceRoot":"","sources":["../../src/parse/palette.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,OAAO;IACP,KAAK;IACL,OAAO;IACP,QAAQ;IACR,MAAM;IACN,SAAS;IACT,MAAM;IACN,OAAO;IACP,cAAc;IACd,YAAY;IACZ,cAAc;IACd,eAAe;IACf,aAAa;IACb,gBAAgB;IAChB,aAAa;IACb,cAAc;CACN,CAAC;AAEX,MAAM,IAAI,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAEzC;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,EAAE,IAAI,KAAK,GAAG,GAAG,EAAE,CAAC;QAC1D,MAAM,IAAI,UAAU,CAAC,aAAa,KAAK,mBAAmB,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;QACjB,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC;QACrC,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC;IAC1C,CAAC;IACD,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;IACrB,OAAO;QACL,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,CAAW;QACrC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAW;QACxC,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAW;KACzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AnsiParse, AnsiParser } from "./types.ts";
|
|
2
|
+
/** The longest OSC 8 URI that becomes a link. */
|
|
3
|
+
export declare const LINK_URI_MAX = 2048;
|
|
4
|
+
/**
|
|
5
|
+
* The furthest one `CSI C` or `CSI G` moves. It pads with real spaces, so an
|
|
6
|
+
* unbounded count would let a few bytes allocate gigabytes.
|
|
7
|
+
*/
|
|
8
|
+
export declare const CURSOR_MOVE_MAX = 1024;
|
|
9
|
+
/**
|
|
10
|
+
* An incremental parser: `push` the text in chunks split anywhere, then
|
|
11
|
+
* `end`. `lines` holds the complete lines so far.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createAnsiParser(): AnsiParser;
|
|
14
|
+
/** Parses a whole text at once. */
|
|
15
|
+
export declare function parseAnsi(text: string): AnsiParse;
|
|
16
|
+
/** The text with every escape removed and cursor moves applied, lines joined with `\n`. */
|
|
17
|
+
export declare function stripAnsi(text: string): string;
|
|
18
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/parse/parser.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAY,SAAS,EAAE,UAAU,EAAa,MAAM,YAAY,CAAC;AAE7E,iDAAiD;AACjD,eAAO,MAAM,YAAY,OAAO,CAAC;AACjC;;;GAGG;AACH,eAAO,MAAM,eAAe,OAAO,CAAC;AA4JpC;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,UAAU,CAE7C;AAED,mCAAmC;AACnC,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CASjD;AAED,2FAA2F;AAC3F,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI9C"}
|