@restranger/repi-lib 0.0.0-stage → 0.0.1-sha.2ba2721
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/README.md +90 -2
- package/package.json +26 -5
- package/src/completion.ts +61 -0
- package/src/config.ts +109 -0
- package/src/contracts/index.ts +4 -0
- package/src/contracts/modes.ts +31 -0
- package/src/contracts/permissions.ts +201 -0
- package/src/contracts/subagents.ts +18 -0
- package/src/contracts/ui.ts +25 -0
- package/src/contracts.ts +39 -0
- package/src/disposable.ts +29 -0
- package/src/index.ts +13 -0
- package/src/model-scoring.ts +46 -0
- package/src/overlay.ts +207 -0
- package/src/pi.ts +272 -0
- package/src/seam.ts +205 -0
- package/src/session.ts +28 -0
- package/src/shimmer.ts +275 -0
- package/src/text.ts +344 -0
- package/src/view.ts +142 -0
package/src/text.ts
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import type { PiUiCustomTheme } from "./pi.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Terminal text primitives shared by every Repi plugin.
|
|
5
|
+
*
|
|
6
|
+
* A line handed to the TUI is measured in display columns, not string length: SGR sequences and
|
|
7
|
+
* combining marks count 0, East Asian wide characters and emoji count 2. Plugins previously kept
|
|
8
|
+
* two different implementations of this, so the widget and the settings menu disagreed about how
|
|
9
|
+
* wide a line was. This is the single place that walks terminal text.
|
|
10
|
+
*
|
|
11
|
+
* Only SGR styling may pass through. Cursor movement, OSC titles and other control sequences are
|
|
12
|
+
* dropped: a plugin must never move the cursor of the host's screen.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** Remove terminal control sequences and non-printable control characters from display text. */
|
|
16
|
+
export function sanitize(value?: string): string {
|
|
17
|
+
if (typeof value !== "string") {
|
|
18
|
+
return "";
|
|
19
|
+
}
|
|
20
|
+
// Stripping terminal control sequences is the point of this function.
|
|
21
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: OSC terminator
|
|
22
|
+
const osc = /\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g;
|
|
23
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: CSI parameters
|
|
24
|
+
const csi = /\x1b\[[0-9;?<=>]*[ -/]*[@-~]/g;
|
|
25
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: two-byte escapes
|
|
26
|
+
const esc = /\x1b[@-_]/g;
|
|
27
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: remaining control characters
|
|
28
|
+
const control = /[\x00-\x08\x0b-\x1f\x7f-\x9f]/g;
|
|
29
|
+
return value.replace(osc, "").replace(csi, "").replace(esc, "").replace(control, "");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface DisplayToken {
|
|
33
|
+
readonly text: string;
|
|
34
|
+
/** Visible columns; 0 for an SGR style sequence. */
|
|
35
|
+
readonly width: number;
|
|
36
|
+
readonly sgr: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Grapheme segmentation is the same primitive the host renderer measures with, so a plugin line and
|
|
41
|
+
* the host's own width check always agree.
|
|
42
|
+
*/
|
|
43
|
+
const graphemeSegmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Tokenize display text by visible width.
|
|
47
|
+
*
|
|
48
|
+
* SGR sequences are kept as zero-width tokens so `truncate`/`fitWidth` can preserve theme colours;
|
|
49
|
+
* every other escape or control sequence is dropped.
|
|
50
|
+
*/
|
|
51
|
+
function* displayTokens(value: string): Generator<DisplayToken> {
|
|
52
|
+
let index = 0;
|
|
53
|
+
while (index < value.length) {
|
|
54
|
+
const code = value.charCodeAt(index);
|
|
55
|
+
if (code === 0x1b) {
|
|
56
|
+
const next = value[index + 1];
|
|
57
|
+
if (next === "[") {
|
|
58
|
+
let end = index + 2;
|
|
59
|
+
while (end < value.length) {
|
|
60
|
+
const current = value.charCodeAt(end);
|
|
61
|
+
end++;
|
|
62
|
+
if (current >= 0x40 && current <= 0x7e) {
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const sequence = value.slice(index, end);
|
|
67
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: SGR sequence produced by theme.fg
|
|
68
|
+
if (sequence.endsWith("m") && /^\x1b\[[0-9;:?<=>]*m$/.test(sequence)) {
|
|
69
|
+
yield { text: sequence, width: 0, sgr: true };
|
|
70
|
+
}
|
|
71
|
+
index = end;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (next === "]") {
|
|
75
|
+
// OSC: consume until BEL or ST; never forward it to the terminal.
|
|
76
|
+
let end = index + 2;
|
|
77
|
+
while (end < value.length) {
|
|
78
|
+
if (value.charCodeAt(end) === 0x07) {
|
|
79
|
+
end++;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
if (value.charCodeAt(end) === 0x1b && value[end + 1] === "\\") {
|
|
83
|
+
end += 2;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
end++;
|
|
87
|
+
}
|
|
88
|
+
index = end;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
// Two-byte escape or a truncated sequence: drop both bytes.
|
|
92
|
+
index += next === undefined ? 1 : 2;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if ((code < 0x20 && code !== 0x09) || (code >= 0x7f && code <= 0x9f)) {
|
|
96
|
+
index++;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
// Visible run up to the next escape sequence; tabs are the host's three-column tab.
|
|
100
|
+
let end = index;
|
|
101
|
+
while (end < value.length && value.charCodeAt(end) !== 0x1b) {
|
|
102
|
+
end++;
|
|
103
|
+
}
|
|
104
|
+
const run = value
|
|
105
|
+
.slice(index, end)
|
|
106
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: remaining control characters
|
|
107
|
+
.replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g, "")
|
|
108
|
+
.replace(/\t/g, " ");
|
|
109
|
+
for (const { segment } of graphemeSegmenter.segment(run)) {
|
|
110
|
+
yield { text: segment, width: graphemeWidth(segment), sgr: false };
|
|
111
|
+
}
|
|
112
|
+
index = end;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Visible width of a string, used to keep widget and inspector lines inside the terminal. */
|
|
117
|
+
export function displayWidth(value: string): number {
|
|
118
|
+
let width = 0;
|
|
119
|
+
for (const token of displayTokens(value)) {
|
|
120
|
+
width += token.width;
|
|
121
|
+
}
|
|
122
|
+
return width;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Truncate to a terminal width, not a string length.
|
|
127
|
+
*
|
|
128
|
+
* SGR sequences (the colours produced by `theme.fg`) are preserved; all other control sequences
|
|
129
|
+
* are dropped. Docs (`docs/tui.md`) require display width for every line an extension hands the
|
|
130
|
+
* TUI.
|
|
131
|
+
*/
|
|
132
|
+
export function truncate(value: string, max: number): string {
|
|
133
|
+
if (max <= 0) {
|
|
134
|
+
return "";
|
|
135
|
+
}
|
|
136
|
+
const tokens = [...displayTokens(value)];
|
|
137
|
+
const total = tokens.reduce((sum, token) => sum + token.width, 0);
|
|
138
|
+
if (total <= max) {
|
|
139
|
+
return tokens.map((token) => token.text).join("");
|
|
140
|
+
}
|
|
141
|
+
let width = 0;
|
|
142
|
+
let result = "";
|
|
143
|
+
for (const token of tokens) {
|
|
144
|
+
if (token.sgr) {
|
|
145
|
+
result += token.text;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (width + token.width > max - 1) {
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
width += token.width;
|
|
152
|
+
result += token.text;
|
|
153
|
+
}
|
|
154
|
+
return `${result.trimEnd()}…${result.includes("\x1b[") ? "\x1b[0m" : ""}`;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Pad a line to exactly `width` visible columns. */
|
|
158
|
+
export function fitWidth(value: string, width: number): string {
|
|
159
|
+
const clamped = truncate(value, Math.max(0, width));
|
|
160
|
+
return `${clamped}${" ".repeat(Math.max(0, width - displayWidth(clamped)))}`;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Left label with a right-aligned value, both inside `width` columns. */
|
|
164
|
+
export function alignRight(left: string, right: string, width: number): string {
|
|
165
|
+
const rightWidth = displayWidth(right);
|
|
166
|
+
const leftWidth = Math.max(0, width - rightWidth - 1);
|
|
167
|
+
return fitWidth(
|
|
168
|
+
`${fitWidth(left, leftWidth)}${" ".repeat(Math.max(1, width - leftWidth - rightWidth))}${right}`,
|
|
169
|
+
width,
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Wrap one logical line to a visible width, preserving SGR styling.
|
|
175
|
+
*
|
|
176
|
+
* The host renders every returned line on its own, so an SGR sequence cannot be left open across a
|
|
177
|
+
* wrap: each line closes the style it inherited and the next line reopens it.
|
|
178
|
+
*/
|
|
179
|
+
export function wrapDisplay(value: string, width: number): string[] {
|
|
180
|
+
if (width <= 0) {
|
|
181
|
+
return [""];
|
|
182
|
+
}
|
|
183
|
+
const result: string[] = [];
|
|
184
|
+
for (const logical of value.split("\n")) {
|
|
185
|
+
let line = "";
|
|
186
|
+
let lineWidth = 0;
|
|
187
|
+
let hasContent = false;
|
|
188
|
+
let activeSgr = "";
|
|
189
|
+
const push = (): void => {
|
|
190
|
+
result.push(activeSgr ? `${line.trimEnd()}\x1b[0m` : line.trimEnd());
|
|
191
|
+
line = activeSgr;
|
|
192
|
+
lineWidth = 0;
|
|
193
|
+
hasContent = false;
|
|
194
|
+
};
|
|
195
|
+
for (const token of displayTokens(logical)) {
|
|
196
|
+
if (token.sgr) {
|
|
197
|
+
activeSgr = applySgr(activeSgr, token.text);
|
|
198
|
+
line += token.text;
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if (token.width > width) {
|
|
202
|
+
// A single glyph can be wider than the budget (a CJK character in a one-column line).
|
|
203
|
+
// A grapheme cannot be split, and emitting it would hand the host a line wider than the
|
|
204
|
+
// terminal, so the glyph is dropped rather than allowed to overflow.
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if (lineWidth + token.width > width && hasContent) {
|
|
208
|
+
push();
|
|
209
|
+
}
|
|
210
|
+
line += token.text;
|
|
211
|
+
lineWidth += token.width;
|
|
212
|
+
hasContent = true;
|
|
213
|
+
}
|
|
214
|
+
result.push(activeSgr ? `${line.trimEnd()}\x1b[0m` : line.trimEnd());
|
|
215
|
+
}
|
|
216
|
+
return result;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** SGR params that only close styling; seeing one drops the carried prefix. */
|
|
220
|
+
const SGR_RESET_PARAMS = new Set(["0", "", "22", "23", "24", "25", "27", "28", "29", "39", "49"]);
|
|
221
|
+
|
|
222
|
+
/** Carry the styling that is still open after `sgr` so the next wrapped line can reopen it. */
|
|
223
|
+
function applySgr(active: string, sgr: string): string {
|
|
224
|
+
const params = sgr.slice(2, -1).split(";");
|
|
225
|
+
if (params.every((param) => SGR_RESET_PARAMS.has(param))) {
|
|
226
|
+
return "";
|
|
227
|
+
}
|
|
228
|
+
return `${active}${sgr}`;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** `theme.bold` is optional in the structural host contract. */
|
|
232
|
+
export function boldText(theme: PiUiCustomTheme | undefined, text: string): string {
|
|
233
|
+
if (!theme?.bold) {
|
|
234
|
+
return text;
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
return theme.bold(text);
|
|
238
|
+
} catch {
|
|
239
|
+
return text;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** Clusters that occupy no cells at all: marks, joiners, variation selectors, hidden controls. */
|
|
244
|
+
const ZERO_WIDTH_CLUSTER = /^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Mark}|\p{Surrogate})+$/u;
|
|
245
|
+
/** Marks at the start of a cluster are stripped before the base character is measured. */
|
|
246
|
+
const LEADING_NON_PRINTING = /^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Mark}\p{Surrogate}]+/u;
|
|
247
|
+
/** Marks that terminals still allocate a cell for when they are attached to a base character. */
|
|
248
|
+
const TERMINAL_SPACING_MARK = /^\p{Spacing_Mark}$/u;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* `\p{RGI_Emoji}` needs the `v` flag. It is built lazily so a runtime without it falls back to a
|
|
252
|
+
* conservative pictographic test instead of failing to load the plugin.
|
|
253
|
+
*/
|
|
254
|
+
const RGI_EMOJI_PATTERN = "^(?:\\p{RGI_Emoji})$";
|
|
255
|
+
let rgiEmoji: RegExp | undefined;
|
|
256
|
+
function isRgiEmoji(segment: string): boolean {
|
|
257
|
+
if (rgiEmoji === undefined) {
|
|
258
|
+
try {
|
|
259
|
+
// The `v` flag is ES2024; the compiler target is ES2022, so it is only ever built here.
|
|
260
|
+
rgiEmoji = new RegExp(RGI_EMOJI_PATTERN, "v");
|
|
261
|
+
} catch {
|
|
262
|
+
rgiEmoji = /^(?:\p{Extended_Pictographic}|\p{Emoji_Presentation})/u;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return rgiEmoji.test(segment);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** Same pre-filter the host uses, so the expensive emoji regex only sees plausible clusters. */
|
|
269
|
+
function couldBeEmoji(segment: string): boolean {
|
|
270
|
+
const codePoint = segment.codePointAt(0) ?? 0;
|
|
271
|
+
return (
|
|
272
|
+
(codePoint >= 0x1f000 && codePoint <= 0x1fbff) ||
|
|
273
|
+
(codePoint >= 0x2300 && codePoint <= 0x23ff) ||
|
|
274
|
+
(codePoint >= 0x2600 && codePoint <= 0x27bf) ||
|
|
275
|
+
(codePoint >= 0x2b50 && codePoint <= 0x2b55) ||
|
|
276
|
+
segment.includes("\ufe0f") ||
|
|
277
|
+
segment.length > 2
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** Visible width of one grapheme cluster, in terminal columns. */
|
|
282
|
+
function graphemeWidth(segment: string): number {
|
|
283
|
+
let printableAscii = segment.length > 0;
|
|
284
|
+
for (let index = 0; index < segment.length; index++) {
|
|
285
|
+
const code = segment.charCodeAt(index);
|
|
286
|
+
if (code < 0x20 || code > 0x7e) {
|
|
287
|
+
printableAscii = false;
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (printableAscii) {
|
|
292
|
+
return 1;
|
|
293
|
+
}
|
|
294
|
+
if (segment === "\t") {
|
|
295
|
+
return 3;
|
|
296
|
+
}
|
|
297
|
+
if (TERMINAL_SPACING_MARK.test(segment)) {
|
|
298
|
+
return [...segment].length;
|
|
299
|
+
}
|
|
300
|
+
if (ZERO_WIDTH_CLUSTER.test(segment)) {
|
|
301
|
+
return 0;
|
|
302
|
+
}
|
|
303
|
+
if (couldBeEmoji(segment) && isRgiEmoji(segment)) {
|
|
304
|
+
return 2;
|
|
305
|
+
}
|
|
306
|
+
const base = segment.replace(LEADING_NON_PRINTING, "");
|
|
307
|
+
const codePoint = base.codePointAt(0);
|
|
308
|
+
if (codePoint === undefined) {
|
|
309
|
+
return 0;
|
|
310
|
+
}
|
|
311
|
+
// Isolated regional indicators are still drawn two cells wide by most terminals.
|
|
312
|
+
if (codePoint >= 0x1f1e6 && codePoint <= 0x1f1ff) {
|
|
313
|
+
return 2;
|
|
314
|
+
}
|
|
315
|
+
return eastAsianWidth(codePoint);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/** Wide and full-width code points (Unicode East_Asian_Width W/F), counted as two columns. */
|
|
319
|
+
function eastAsianWidth(codePoint: number): number {
|
|
320
|
+
return isWideCodePoint(codePoint) ? 2 : 1;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function isWideCodePoint(codePoint: number): boolean {
|
|
324
|
+
return (
|
|
325
|
+
(codePoint >= 0x1100 && codePoint <= 0x115f) ||
|
|
326
|
+
codePoint === 0x2329 ||
|
|
327
|
+
codePoint === 0x232a ||
|
|
328
|
+
(codePoint >= 0x2e80 && codePoint <= 0x303e) ||
|
|
329
|
+
(codePoint >= 0x3041 && codePoint <= 0x33ff) ||
|
|
330
|
+
(codePoint >= 0x3400 && codePoint <= 0x4dbf) ||
|
|
331
|
+
(codePoint >= 0x4e00 && codePoint <= 0x9fff) ||
|
|
332
|
+
(codePoint >= 0xa000 && codePoint <= 0xa4cf) ||
|
|
333
|
+
(codePoint >= 0xa960 && codePoint <= 0xa97f) ||
|
|
334
|
+
(codePoint >= 0xac00 && codePoint <= 0xd7a3) ||
|
|
335
|
+
(codePoint >= 0xf900 && codePoint <= 0xfaff) ||
|
|
336
|
+
(codePoint >= 0xfe10 && codePoint <= 0xfe19) ||
|
|
337
|
+
(codePoint >= 0xfe30 && codePoint <= 0xfe6f) ||
|
|
338
|
+
(codePoint >= 0xff00 && codePoint <= 0xff60) ||
|
|
339
|
+
(codePoint >= 0xffe0 && codePoint <= 0xffe6) ||
|
|
340
|
+
(codePoint >= 0x1b000 && codePoint <= 0x1b001) ||
|
|
341
|
+
(codePoint >= 0x1f200 && codePoint <= 0x1f251) ||
|
|
342
|
+
(codePoint >= 0x20000 && codePoint <= 0x3fffd)
|
|
343
|
+
);
|
|
344
|
+
}
|
package/src/view.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
export type Tone = "default" | "muted" | "accent" | "success" | "warning" | "danger";
|
|
2
|
+
|
|
3
|
+
export type BorderStyle = "default" | "rounded" | "sharp" | "double" | "minimal" | "none";
|
|
4
|
+
|
|
5
|
+
export type BoxVariant = "card" | "callout" | "minimal";
|
|
6
|
+
|
|
7
|
+
export type BoxSide = "left" | "right" | "top" | "bottom";
|
|
8
|
+
|
|
9
|
+
export interface ActionRef {
|
|
10
|
+
id: string;
|
|
11
|
+
payload?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ListItem {
|
|
15
|
+
id: string;
|
|
16
|
+
text: string;
|
|
17
|
+
tone?: Tone;
|
|
18
|
+
badge?: string;
|
|
19
|
+
done?: boolean;
|
|
20
|
+
status?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type SlotId = "statusline" | "aboveEditor" | "belowEditor" | "header" | "footer" | "overlay";
|
|
24
|
+
|
|
25
|
+
export interface ColNode {
|
|
26
|
+
t: "col";
|
|
27
|
+
id?: string;
|
|
28
|
+
gap?: number;
|
|
29
|
+
children: ViewNode[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface RowNode {
|
|
33
|
+
t: "row";
|
|
34
|
+
id?: string;
|
|
35
|
+
gap?: number;
|
|
36
|
+
children: ViewNode[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface BoxNode {
|
|
40
|
+
t: "box";
|
|
41
|
+
id?: string;
|
|
42
|
+
title?: string;
|
|
43
|
+
tone?: Tone;
|
|
44
|
+
border?: BorderStyle;
|
|
45
|
+
variant?: BoxVariant;
|
|
46
|
+
sides?: BoxSide[];
|
|
47
|
+
children: ViewNode[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface TextNode {
|
|
51
|
+
t: "text";
|
|
52
|
+
id?: string;
|
|
53
|
+
text: string;
|
|
54
|
+
tone?: Tone;
|
|
55
|
+
bold?: boolean;
|
|
56
|
+
wrap?: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface MarkdownNode {
|
|
60
|
+
t: "markdown";
|
|
61
|
+
id?: string;
|
|
62
|
+
md: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface BadgeNode {
|
|
66
|
+
t: "badge";
|
|
67
|
+
id?: string;
|
|
68
|
+
text: string;
|
|
69
|
+
tone?: Tone;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface KeyValueNode {
|
|
73
|
+
t: "kv";
|
|
74
|
+
id?: string;
|
|
75
|
+
items: Array<[string, string]>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface ListNode {
|
|
79
|
+
t: "list";
|
|
80
|
+
id?: string;
|
|
81
|
+
items: ListItem[];
|
|
82
|
+
ordered?: boolean;
|
|
83
|
+
checkbox?: boolean;
|
|
84
|
+
onSelect?: ActionRef;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface TableNode {
|
|
88
|
+
t: "table";
|
|
89
|
+
id?: string;
|
|
90
|
+
head: string[];
|
|
91
|
+
rows: string[][];
|
|
92
|
+
fallback?: ViewNode[];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface DiffNode {
|
|
96
|
+
t: "diff";
|
|
97
|
+
id?: string;
|
|
98
|
+
patch: string;
|
|
99
|
+
fallback?: ViewNode[];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface ProgressNode {
|
|
103
|
+
t: "progress";
|
|
104
|
+
id?: string;
|
|
105
|
+
value: number;
|
|
106
|
+
max?: number;
|
|
107
|
+
label?: string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface SpinnerNode {
|
|
111
|
+
t: "spinner";
|
|
112
|
+
id?: string;
|
|
113
|
+
label?: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface ButtonNode {
|
|
117
|
+
t: "button";
|
|
118
|
+
id?: string;
|
|
119
|
+
label: string;
|
|
120
|
+
action: ActionRef;
|
|
121
|
+
tone?: Tone;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export type ViewNode =
|
|
125
|
+
| ColNode
|
|
126
|
+
| RowNode
|
|
127
|
+
| BoxNode
|
|
128
|
+
| TextNode
|
|
129
|
+
| MarkdownNode
|
|
130
|
+
| BadgeNode
|
|
131
|
+
| KeyValueNode
|
|
132
|
+
| ListNode
|
|
133
|
+
| TableNode
|
|
134
|
+
| DiffNode
|
|
135
|
+
| ProgressNode
|
|
136
|
+
| SpinnerNode
|
|
137
|
+
| ButtonNode;
|
|
138
|
+
|
|
139
|
+
export interface ViewOptions {
|
|
140
|
+
/** Higher priority wins in composition order (`notes/01` §3.9). Defaults to 0. */
|
|
141
|
+
priority?: number;
|
|
142
|
+
}
|