@promptctl/rich-js 0.17.0 → 0.18.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/README.md +13 -26
- package/package.json +7 -3
- package/dist/core/box.d.ts +0 -144
- package/dist/core/box.js +0 -391
- package/dist/core/cells.d.ts +0 -148
- package/dist/core/cells.js +0 -266
- package/dist/core/color.d.ts +0 -250
- package/dist/core/color.js +0 -1029
- package/dist/core/console.d.ts +0 -156
- package/dist/core/console.js +0 -472
- package/dist/core/emoji.d.ts +0 -24
- package/dist/core/emoji.js +0 -391
- package/dist/core/export-html.d.ts +0 -24
- package/dist/core/export-html.js +0 -106
- package/dist/core/export-lines.d.ts +0 -121
- package/dist/core/export-lines.js +0 -141
- package/dist/core/highlighter.d.ts +0 -33
- package/dist/core/highlighter.js +0 -124
- package/dist/core/json.d.ts +0 -27
- package/dist/core/json.js +0 -53
- package/dist/core/markup.d.ts +0 -97
- package/dist/core/markup.js +0 -619
- package/dist/core/measure.d.ts +0 -27
- package/dist/core/measure.js +0 -61
- package/dist/core/oklch.d.ts +0 -161
- package/dist/core/oklch.js +0 -312
- package/dist/core/osc8.d.ts +0 -68
- package/dist/core/osc8.js +0 -90
- package/dist/core/pretty.d.ts +0 -141
- package/dist/core/pretty.js +0 -472
- package/dist/core/protocol.d.ts +0 -137
- package/dist/core/protocol.js +0 -101
- package/dist/core/render.d.ts +0 -84
- package/dist/core/render.js +0 -145
- package/dist/core/segment.d.ts +0 -142
- package/dist/core/segment.js +0 -433
- package/dist/core/spinnerData.d.ts +0 -10
- package/dist/core/spinnerData.js +0 -115
- package/dist/core/strip.d.ts +0 -145
- package/dist/core/strip.js +0 -308
- package/dist/core/style.d.ts +0 -144
- package/dist/core/style.js +0 -723
- package/dist/core/subscription.d.ts +0 -12
- package/dist/core/subscription.js +0 -12
- package/dist/core/text.d.ts +0 -255
- package/dist/core/text.js +0 -990
- package/dist/core/wrap.d.ts +0 -41
- package/dist/core/wrap.js +0 -127
- package/dist/host/host-stream.d.ts +0 -30
- package/dist/host/host-stream.js +0 -35
- package/dist/host/index.d.ts +0 -3
- package/dist/host/index.js +0 -2
- package/dist/host/terminal-host.d.ts +0 -143
- package/dist/host/terminal-host.js +0 -132
- package/dist/index.d.ts +0 -87
- package/dist/index.js +0 -104
- package/dist/node/prompt.d.ts +0 -21
- package/dist/node/prompt.js +0 -30
- package/dist/node/save.d.ts +0 -17
- package/dist/node/save.js +0 -21
- package/dist/node/terminal-host.d.ts +0 -84
- package/dist/node/terminal-host.js +0 -160
- package/dist/node/traceback.d.ts +0 -27
- package/dist/node/traceback.js +0 -112
- package/dist/renderables/align.d.ts +0 -16
- package/dist/renderables/align.js +0 -46
- package/dist/renderables/columns.d.ts +0 -61
- package/dist/renderables/columns.js +0 -168
- package/dist/renderables/constrain.d.ts +0 -15
- package/dist/renderables/constrain.js +0 -37
- package/dist/renderables/flexStrip.d.ts +0 -41
- package/dist/renderables/flexStrip.js +0 -200
- package/dist/renderables/group.d.ts +0 -11
- package/dist/renderables/group.js +0 -15
- package/dist/renderables/layout.d.ts +0 -92
- package/dist/renderables/layout.js +0 -315
- package/dist/renderables/live.d.ts +0 -47
- package/dist/renderables/live.js +0 -131
- package/dist/renderables/markdown.d.ts +0 -24
- package/dist/renderables/markdown.js +0 -182
- package/dist/renderables/padding.d.ts +0 -38
- package/dist/renderables/padding.js +0 -140
- package/dist/renderables/panel.d.ts +0 -116
- package/dist/renderables/panel.js +0 -322
- package/dist/renderables/progress.d.ts +0 -90
- package/dist/renderables/progress.js +0 -241
- package/dist/renderables/progressBar.d.ts +0 -31
- package/dist/renderables/progressBar.js +0 -52
- package/dist/renderables/prompt.d.ts +0 -49
- package/dist/renderables/prompt.js +0 -125
- package/dist/renderables/rule.d.ts +0 -24
- package/dist/renderables/rule.js +0 -90
- package/dist/renderables/spinner.d.ts +0 -29
- package/dist/renderables/spinner.js +0 -64
- package/dist/renderables/status.d.ts +0 -23
- package/dist/renderables/status.js +0 -60
- package/dist/renderables/syntax.d.ts +0 -35
- package/dist/renderables/syntax.js +0 -114
- package/dist/renderables/table.d.ts +0 -182
- package/dist/renderables/table.js +0 -697
- package/dist/renderables/traceback.d.ts +0 -31
- package/dist/renderables/traceback.js +0 -109
- package/dist/renderables/tree.d.ts +0 -54
- package/dist/renderables/tree.js +0 -159
- package/dist/template-bindings/color-funcs.d.ts +0 -87
- package/dist/template-bindings/color-funcs.js +0 -219
- package/dist/template-bindings/helpers.d.ts +0 -24
- package/dist/template-bindings/helpers.js +0 -48
- package/dist/template-bindings/index.d.ts +0 -107
- package/dist/template-bindings/index.js +0 -144
- package/dist/template-bindings/palette-funcs.d.ts +0 -94
- package/dist/template-bindings/palette-funcs.js +0 -151
- package/dist/template-bindings/style-funcs.d.ts +0 -28
- package/dist/template-bindings/style-funcs.js +0 -151
- package/dist/themes/buildPalette.d.ts +0 -36
- package/dist/themes/buildPalette.js +0 -56
- package/dist/themes/colorMath.d.ts +0 -82
- package/dist/themes/colorMath.js +0 -254
- package/dist/themes/colorRef.d.ts +0 -51
- package/dist/themes/colorRef.js +0 -96
- package/dist/themes/data/atom-one-dark.d.ts +0 -3
- package/dist/themes/data/atom-one-dark.js +0 -158
- package/dist/themes/data/atom-one-light.d.ts +0 -3
- package/dist/themes/data/atom-one-light.js +0 -158
- package/dist/themes/data/catppuccin-frappe.d.ts +0 -3
- package/dist/themes/data/catppuccin-frappe.js +0 -158
- package/dist/themes/data/catppuccin-latte.d.ts +0 -3
- package/dist/themes/data/catppuccin-latte.js +0 -158
- package/dist/themes/data/catppuccin-macchiato.d.ts +0 -3
- package/dist/themes/data/catppuccin-macchiato.js +0 -158
- package/dist/themes/data/catppuccin-mocha.d.ts +0 -3
- package/dist/themes/data/catppuccin-mocha.js +0 -158
- package/dist/themes/data/cyberpunk.d.ts +0 -17
- package/dist/themes/data/cyberpunk.js +0 -191
- package/dist/themes/data/default.d.ts +0 -3
- package/dist/themes/data/default.js +0 -158
- package/dist/themes/data/dracula.d.ts +0 -3
- package/dist/themes/data/dracula.js +0 -158
- package/dist/themes/data/flexoki.d.ts +0 -3
- package/dist/themes/data/flexoki.js +0 -158
- package/dist/themes/data/gruvbox.d.ts +0 -3
- package/dist/themes/data/gruvbox.js +0 -158
- package/dist/themes/data/index.d.ts +0 -35
- package/dist/themes/data/index.js +0 -64
- package/dist/themes/data/monokai.d.ts +0 -3
- package/dist/themes/data/monokai.js +0 -158
- package/dist/themes/data/nord.d.ts +0 -3
- package/dist/themes/data/nord.js +0 -158
- package/dist/themes/data/rose-pine-dawn.d.ts +0 -3
- package/dist/themes/data/rose-pine-dawn.js +0 -158
- package/dist/themes/data/rose-pine-moon.d.ts +0 -3
- package/dist/themes/data/rose-pine-moon.js +0 -158
- package/dist/themes/data/rose-pine.d.ts +0 -3
- package/dist/themes/data/rose-pine.js +0 -158
- package/dist/themes/data/solarized-dark.d.ts +0 -3
- package/dist/themes/data/solarized-dark.js +0 -158
- package/dist/themes/data/solarized-light.d.ts +0 -3
- package/dist/themes/data/solarized-light.js +0 -158
- package/dist/themes/data/svg-export.d.ts +0 -3
- package/dist/themes/data/svg-export.js +0 -158
- package/dist/themes/data/textual-ansi.d.ts +0 -3
- package/dist/themes/data/textual-ansi.js +0 -158
- package/dist/themes/data/textual-dark.d.ts +0 -3
- package/dist/themes/data/textual-dark.js +0 -158
- package/dist/themes/data/textual-light.d.ts +0 -3
- package/dist/themes/data/textual-light.js +0 -158
- package/dist/themes/data/tokyo-night.d.ts +0 -3
- package/dist/themes/data/tokyo-night.js +0 -158
- package/dist/themes/data/types.d.ts +0 -15
- package/dist/themes/data/types.js +0 -1
- package/dist/themes/palette.d.ts +0 -21
- package/dist/themes/palette.js +0 -28
- package/dist/themes/ramp.d.ts +0 -83
- package/dist/themes/ramp.js +0 -122
- package/dist/themes/registry.d.ts +0 -43
- package/dist/themes/registry.js +0 -82
- package/dist/themes/terminalThemes.d.ts +0 -54
- package/dist/themes/terminalThemes.js +0 -68
- package/dist/themes/transpose.d.ts +0 -87
- package/dist/themes/transpose.js +0 -138
- package/dist/widgets/button.d.ts +0 -49
- package/dist/widgets/button.js +0 -206
- package/dist/widgets/checkbox.d.ts +0 -41
- package/dist/widgets/checkbox.js +0 -155
- package/dist/widgets/dropdown.d.ts +0 -67
- package/dist/widgets/dropdown.js +0 -453
- package/dist/widgets/event-router.d.ts +0 -78
- package/dist/widgets/event-router.js +0 -622
- package/dist/widgets/focus-manager.d.ts +0 -26
- package/dist/widgets/focus-manager.js +0 -193
- package/dist/widgets/index.d.ts +0 -22
- package/dist/widgets/index.js +0 -15
- package/dist/widgets/screen.d.ts +0 -98
- package/dist/widgets/screen.js +0 -530
- package/dist/widgets/slider.d.ts +0 -57
- package/dist/widgets/slider.js +0 -270
- package/dist/widgets/static-item.d.ts +0 -40
- package/dist/widgets/static-item.js +0 -60
- package/dist/widgets/text-input.d.ts +0 -274
- package/dist/widgets/text-input.js +0 -1162
- package/dist/widgets/toggle.d.ts +0 -44
- package/dist/widgets/toggle.js +0 -179
- package/dist/widgets/types.d.ts +0 -108
- package/dist/widgets/types.js +0 -31
- package/dist/widgets/widget-base.d.ts +0 -42
- package/dist/widgets/widget-base.js +0 -173
package/dist/core/style.js
DELETED
|
@@ -1,723 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Immutable style descriptors — colors, text attributes, links, metadata.
|
|
3
|
-
*/
|
|
4
|
-
import { COLOR_NAMES, ColorSpec, SURFACE_BLACK, } from "./color.js";
|
|
5
|
-
// [LAW:one-way-deps] `core/style` depends only on `core/color`. The substrate
|
|
6
|
-
// a translucent colour is flattened over is `SURFACE_BLACK`, defined beside
|
|
7
|
-
// `compositeOver`.
|
|
8
|
-
// --- Attribute definitions ---
|
|
9
|
-
/**
|
|
10
|
-
* Canonical text-attribute inventory. Single source of truth consumed by
|
|
11
|
-
* `Style.parse` / `Style.toString` and the template bindings — adding an
|
|
12
|
-
* attribute here propagates to every styling surface without a second
|
|
13
|
-
* list to keep in sync. [LAW:one-source-of-truth]
|
|
14
|
-
*/
|
|
15
|
-
export const ATTRIBUTE_NAMES = [
|
|
16
|
-
"bold",
|
|
17
|
-
"dim",
|
|
18
|
-
"italic",
|
|
19
|
-
"underline",
|
|
20
|
-
"blink",
|
|
21
|
-
"blink2",
|
|
22
|
-
"reverse",
|
|
23
|
-
"conceal",
|
|
24
|
-
"strike",
|
|
25
|
-
"underline2",
|
|
26
|
-
"frame",
|
|
27
|
-
"encircle",
|
|
28
|
-
"overline",
|
|
29
|
-
];
|
|
30
|
-
// The SGR parameter that turns each attribute on
|
|
31
|
-
const ATTRIBUTE_SGR = {
|
|
32
|
-
bold: 1,
|
|
33
|
-
dim: 2,
|
|
34
|
-
italic: 3,
|
|
35
|
-
underline: 4,
|
|
36
|
-
blink: 5,
|
|
37
|
-
blink2: 6,
|
|
38
|
-
reverse: 7,
|
|
39
|
-
conceal: 8,
|
|
40
|
-
strike: 9,
|
|
41
|
-
underline2: 21,
|
|
42
|
-
frame: 51,
|
|
43
|
-
encircle: 52,
|
|
44
|
-
overline: 53,
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Canonical short-attribute aliases (`b` → `bold`, `i` → `italic`, …).
|
|
48
|
-
* Single source of truth consumed by `Style.parse` and the template
|
|
49
|
-
* bindings — adding an alias here makes it available everywhere.
|
|
50
|
-
* [LAW:one-source-of-truth]
|
|
51
|
-
*/
|
|
52
|
-
export const ATTRIBUTE_SHORT_ALIASES = {
|
|
53
|
-
b: "bold",
|
|
54
|
-
d: "dim",
|
|
55
|
-
i: "italic",
|
|
56
|
-
u: "underline",
|
|
57
|
-
s: "strike",
|
|
58
|
-
r: "reverse",
|
|
59
|
-
o: "overline",
|
|
60
|
-
uu: "underline2",
|
|
61
|
-
};
|
|
62
|
-
export class StyleSyntaxError extends Error {
|
|
63
|
-
constructor(message, options) {
|
|
64
|
-
super(message, options);
|
|
65
|
-
this.name = "StyleSyntaxError";
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
// [LAW:one-source-of-truth] Parse cache is the single source for parsed Style instances
|
|
69
|
-
const styleParseCache = new Map();
|
|
70
|
-
// --- Style ---
|
|
71
|
-
export class Style {
|
|
72
|
-
color;
|
|
73
|
-
bgcolor;
|
|
74
|
-
bold;
|
|
75
|
-
dim;
|
|
76
|
-
italic;
|
|
77
|
-
underline;
|
|
78
|
-
blink;
|
|
79
|
-
blink2;
|
|
80
|
-
reverse;
|
|
81
|
-
conceal;
|
|
82
|
-
strike;
|
|
83
|
-
underline2;
|
|
84
|
-
frame;
|
|
85
|
-
encircle;
|
|
86
|
-
overline;
|
|
87
|
-
link;
|
|
88
|
-
meta;
|
|
89
|
-
constructor(options) {
|
|
90
|
-
if (!options) {
|
|
91
|
-
this.color = undefined;
|
|
92
|
-
this.bgcolor = undefined;
|
|
93
|
-
this.bold = undefined;
|
|
94
|
-
this.dim = undefined;
|
|
95
|
-
this.italic = undefined;
|
|
96
|
-
this.underline = undefined;
|
|
97
|
-
this.blink = undefined;
|
|
98
|
-
this.blink2 = undefined;
|
|
99
|
-
this.reverse = undefined;
|
|
100
|
-
this.conceal = undefined;
|
|
101
|
-
this.strike = undefined;
|
|
102
|
-
this.underline2 = undefined;
|
|
103
|
-
this.frame = undefined;
|
|
104
|
-
this.encircle = undefined;
|
|
105
|
-
this.overline = undefined;
|
|
106
|
-
this.link = undefined;
|
|
107
|
-
this.meta = undefined;
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
this.color = resolveColor(options.color);
|
|
111
|
-
this.bgcolor = resolveColor(options.bgcolor);
|
|
112
|
-
this.bold = options.bold;
|
|
113
|
-
this.dim = options.dim;
|
|
114
|
-
this.italic = options.italic;
|
|
115
|
-
this.underline = options.underline;
|
|
116
|
-
this.blink = options.blink;
|
|
117
|
-
this.blink2 = options.blink2;
|
|
118
|
-
this.reverse = options.reverse;
|
|
119
|
-
this.conceal = options.conceal;
|
|
120
|
-
this.strike = options.strike;
|
|
121
|
-
this.underline2 = options.underline2;
|
|
122
|
-
this.frame = options.frame;
|
|
123
|
-
this.encircle = options.encircle;
|
|
124
|
-
this.overline = options.overline;
|
|
125
|
-
this.link = options.link;
|
|
126
|
-
this.meta = options.meta;
|
|
127
|
-
}
|
|
128
|
-
get isNull() {
|
|
129
|
-
return (this.color === undefined &&
|
|
130
|
-
this.bgcolor === undefined &&
|
|
131
|
-
this.bold === undefined &&
|
|
132
|
-
this.dim === undefined &&
|
|
133
|
-
this.italic === undefined &&
|
|
134
|
-
this.underline === undefined &&
|
|
135
|
-
this.blink === undefined &&
|
|
136
|
-
this.blink2 === undefined &&
|
|
137
|
-
this.reverse === undefined &&
|
|
138
|
-
this.conceal === undefined &&
|
|
139
|
-
this.strike === undefined &&
|
|
140
|
-
this.underline2 === undefined &&
|
|
141
|
-
this.frame === undefined &&
|
|
142
|
-
this.encircle === undefined &&
|
|
143
|
-
this.overline === undefined &&
|
|
144
|
-
this.link === undefined &&
|
|
145
|
-
this.meta === undefined);
|
|
146
|
-
}
|
|
147
|
-
get transparentBackground() {
|
|
148
|
-
return this.bgcolor === undefined || this.bgcolor.isDefault;
|
|
149
|
-
}
|
|
150
|
-
get backgroundStyle() {
|
|
151
|
-
return new Style({ bgcolor: this.bgcolor });
|
|
152
|
-
}
|
|
153
|
-
get withoutColor() {
|
|
154
|
-
return new Style({
|
|
155
|
-
bold: this.bold,
|
|
156
|
-
dim: this.dim,
|
|
157
|
-
italic: this.italic,
|
|
158
|
-
underline: this.underline,
|
|
159
|
-
blink: this.blink,
|
|
160
|
-
blink2: this.blink2,
|
|
161
|
-
reverse: this.reverse,
|
|
162
|
-
conceal: this.conceal,
|
|
163
|
-
strike: this.strike,
|
|
164
|
-
underline2: this.underline2,
|
|
165
|
-
frame: this.frame,
|
|
166
|
-
encircle: this.encircle,
|
|
167
|
-
overline: this.overline,
|
|
168
|
-
link: this.link,
|
|
169
|
-
meta: this.meta,
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
// [LAW:types-are-the-program] Structural clone helper — pure rearrangement
|
|
173
|
-
// of fields, no policy. Sanitization of the URL is the trust boundary's
|
|
174
|
-
// job (see RichText in text.ts); Style stays a faithful container so
|
|
175
|
-
// callers that have already sanitized are not silently re-mutated.
|
|
176
|
-
withLink(link) {
|
|
177
|
-
return new Style({
|
|
178
|
-
color: this.color,
|
|
179
|
-
bgcolor: this.bgcolor,
|
|
180
|
-
bold: this.bold,
|
|
181
|
-
dim: this.dim,
|
|
182
|
-
italic: this.italic,
|
|
183
|
-
underline: this.underline,
|
|
184
|
-
blink: this.blink,
|
|
185
|
-
blink2: this.blink2,
|
|
186
|
-
reverse: this.reverse,
|
|
187
|
-
conceal: this.conceal,
|
|
188
|
-
strike: this.strike,
|
|
189
|
-
underline2: this.underline2,
|
|
190
|
-
frame: this.frame,
|
|
191
|
-
encircle: this.encircle,
|
|
192
|
-
overline: this.overline,
|
|
193
|
-
link,
|
|
194
|
-
meta: this.meta,
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
clearMetaAndLinks() {
|
|
198
|
-
return new Style({
|
|
199
|
-
color: this.color,
|
|
200
|
-
bgcolor: this.bgcolor,
|
|
201
|
-
bold: this.bold,
|
|
202
|
-
dim: this.dim,
|
|
203
|
-
italic: this.italic,
|
|
204
|
-
underline: this.underline,
|
|
205
|
-
blink: this.blink,
|
|
206
|
-
blink2: this.blink2,
|
|
207
|
-
reverse: this.reverse,
|
|
208
|
-
conceal: this.conceal,
|
|
209
|
-
strike: this.strike,
|
|
210
|
-
underline2: this.underline2,
|
|
211
|
-
frame: this.frame,
|
|
212
|
-
encircle: this.encircle,
|
|
213
|
-
overline: this.overline,
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Merges two styles. `other`'s values take priority.
|
|
218
|
-
*/
|
|
219
|
-
add(other) {
|
|
220
|
-
if (!other || other.isNull)
|
|
221
|
-
return this;
|
|
222
|
-
if (this.isNull)
|
|
223
|
-
return other;
|
|
224
|
-
return new Style({
|
|
225
|
-
color: other.color ?? this.color,
|
|
226
|
-
bgcolor: other.bgcolor ?? this.bgcolor,
|
|
227
|
-
bold: other.bold ?? this.bold,
|
|
228
|
-
dim: other.dim ?? this.dim,
|
|
229
|
-
italic: other.italic ?? this.italic,
|
|
230
|
-
underline: other.underline ?? this.underline,
|
|
231
|
-
blink: other.blink ?? this.blink,
|
|
232
|
-
blink2: other.blink2 ?? this.blink2,
|
|
233
|
-
reverse: other.reverse ?? this.reverse,
|
|
234
|
-
conceal: other.conceal ?? this.conceal,
|
|
235
|
-
strike: other.strike ?? this.strike,
|
|
236
|
-
underline2: other.underline2 ?? this.underline2,
|
|
237
|
-
frame: other.frame ?? this.frame,
|
|
238
|
-
encircle: other.encircle ?? this.encircle,
|
|
239
|
-
overline: other.overline ?? this.overline,
|
|
240
|
-
link: other.link ?? this.link,
|
|
241
|
-
meta: other.meta && this.meta
|
|
242
|
-
? { ...this.meta, ...other.meta }
|
|
243
|
-
: other.meta ?? this.meta,
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
equals(other) {
|
|
247
|
-
if (this === other)
|
|
248
|
-
return true;
|
|
249
|
-
return (this.color?.name === other.color?.name &&
|
|
250
|
-
this.bgcolor?.name === other.bgcolor?.name &&
|
|
251
|
-
this.bold === other.bold &&
|
|
252
|
-
this.dim === other.dim &&
|
|
253
|
-
this.italic === other.italic &&
|
|
254
|
-
this.underline === other.underline &&
|
|
255
|
-
this.blink === other.blink &&
|
|
256
|
-
this.blink2 === other.blink2 &&
|
|
257
|
-
this.reverse === other.reverse &&
|
|
258
|
-
this.conceal === other.conceal &&
|
|
259
|
-
this.strike === other.strike &&
|
|
260
|
-
this.underline2 === other.underline2 &&
|
|
261
|
-
this.frame === other.frame &&
|
|
262
|
-
this.encircle === other.encircle &&
|
|
263
|
-
this.overline === other.overline &&
|
|
264
|
-
this.link === other.link);
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* The colours this style puts on screen at `colorSystem`: each flattened
|
|
268
|
-
* onto what lies beneath it — the background onto the terminal's black, the
|
|
269
|
-
* foreground onto that background — then downgraded to the depth. The one
|
|
270
|
-
* account of what a style draws: `toSgrCodes` encodes exactly these, and a
|
|
271
|
-
* renderable choosing between two ways of drawing measures them.
|
|
272
|
-
*/
|
|
273
|
-
drawnColors(colorSystem) {
|
|
274
|
-
// [LAW:dataflow-not-control-flow] Always resolve a substrate and flatten
|
|
275
|
-
// alpha before downgrade. Opaque colors short-circuit inside compositeOver,
|
|
276
|
-
// so the same code path runs every render — the alpha value is the data,
|
|
277
|
-
// not a branch.
|
|
278
|
-
const surface = SURFACE_BLACK;
|
|
279
|
-
const bgFlat = this.bgcolor?.flattenAlpha(surface);
|
|
280
|
-
const fgSubstrate = bgFlat?.getTruecolor(undefined, false) ?? surface;
|
|
281
|
-
const fgFlat = this.color?.flattenAlpha(fgSubstrate);
|
|
282
|
-
const at = (c) => colorSystem !== undefined ? c.downgrade(colorSystem) : c;
|
|
283
|
-
return {
|
|
284
|
-
color: fgFlat === undefined ? undefined : at(fgFlat),
|
|
285
|
-
bgcolor: bgFlat === undefined ? undefined : at(bgFlat),
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Returns the SGR parameter list this style emits (e.g. `"1;31;48;2;0;0;255"`),
|
|
290
|
-
* or `""` when the style has no SGR contribution. Excludes OSC 8 link bytes —
|
|
291
|
-
* links are not SGR. The segment encoder (`segmentsToString`) uses this
|
|
292
|
-
* string as the group key for adjacent-same-style coalescing and wraps it in
|
|
293
|
-
* `\x1b[...m`; styled text reaches the wire only through that encoder.
|
|
294
|
-
*
|
|
295
|
-
* [LAW:one-source-of-truth] One computation of SGR codes.
|
|
296
|
-
*/
|
|
297
|
-
toSgrCodes(colorSystem) {
|
|
298
|
-
if (this.isNull)
|
|
299
|
-
return "";
|
|
300
|
-
const attrs = [];
|
|
301
|
-
const drawn = this.drawnColors(colorSystem);
|
|
302
|
-
if (drawn.color)
|
|
303
|
-
attrs.push(...drawn.color.getAnsiCodes(true));
|
|
304
|
-
if (drawn.bgcolor)
|
|
305
|
-
attrs.push(...drawn.bgcolor.getAnsiCodes(false));
|
|
306
|
-
// An attribute set false writes nothing, as in Python Rich 9d8f9a3's
|
|
307
|
-
// `_make_ansi_codes`. It overrides an inherited attribute when styles
|
|
308
|
-
// combine, and every styled run is written after a reset, so no off
|
|
309
|
-
// code is ever needed.
|
|
310
|
-
attrs.push(...ATTRIBUTE_NAMES.filter((name) => this[name] === true).map((name) => `${ATTRIBUTE_SGR[name]}`));
|
|
311
|
-
return attrs.join(";");
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Serializes to a canonical string that round-trips through `Style.parse()`.
|
|
315
|
-
*/
|
|
316
|
-
toString() {
|
|
317
|
-
if (this.isNull)
|
|
318
|
-
return "none";
|
|
319
|
-
const parts = [];
|
|
320
|
-
// Negated attributes first
|
|
321
|
-
for (const name of ATTRIBUTE_NAMES) {
|
|
322
|
-
if (this[name] === false)
|
|
323
|
-
parts.push(`not ${name}`);
|
|
324
|
-
}
|
|
325
|
-
// Positive attributes
|
|
326
|
-
for (const name of ATTRIBUTE_NAMES) {
|
|
327
|
-
if (this[name] === true)
|
|
328
|
-
parts.push(name);
|
|
329
|
-
}
|
|
330
|
-
if (this.color)
|
|
331
|
-
parts.push(this.color.name);
|
|
332
|
-
if (this.bgcolor)
|
|
333
|
-
parts.push(`on ${this.bgcolor.name}`);
|
|
334
|
-
if (this.link)
|
|
335
|
-
parts.push(`link ${this.link}`);
|
|
336
|
-
return parts.join(" ") || "none";
|
|
337
|
-
}
|
|
338
|
-
// --- Static methods ---
|
|
339
|
-
static null() {
|
|
340
|
-
return NULL_STYLE;
|
|
341
|
-
}
|
|
342
|
-
static fromColor(color, bgcolor) {
|
|
343
|
-
return new Style({ color, bgcolor });
|
|
344
|
-
}
|
|
345
|
-
static fromMeta(meta) {
|
|
346
|
-
return new Style({ meta });
|
|
347
|
-
}
|
|
348
|
-
static pickFirst(...args) {
|
|
349
|
-
for (const a of args) {
|
|
350
|
-
if (a !== undefined)
|
|
351
|
-
return a;
|
|
352
|
-
}
|
|
353
|
-
throw new Error("All arguments are undefined");
|
|
354
|
-
}
|
|
355
|
-
static combine(styles) {
|
|
356
|
-
let result = NULL_STYLE;
|
|
357
|
-
for (const s of styles) {
|
|
358
|
-
if (s)
|
|
359
|
-
result = result.add(s);
|
|
360
|
-
}
|
|
361
|
-
return result;
|
|
362
|
-
}
|
|
363
|
-
static chain(...styles) {
|
|
364
|
-
return Style.combine(styles);
|
|
365
|
-
}
|
|
366
|
-
static normalize(definition) {
|
|
367
|
-
return definition.trim().replace(/\s+/g, " ");
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Parse a space-separated style definition. Cached.
|
|
371
|
-
*
|
|
372
|
-
* A definition only: `"bold red"` parses, `"repr.number"` does not. Names
|
|
373
|
-
* belong to a `Theme`, and `Theme.resolve` is where one is looked up.
|
|
374
|
-
*/
|
|
375
|
-
static parse(definition) {
|
|
376
|
-
const normalized = Style.normalize(definition);
|
|
377
|
-
if (normalized === "" || normalized === "none")
|
|
378
|
-
return NULL_STYLE;
|
|
379
|
-
const cached = styleParseCache.get(normalized);
|
|
380
|
-
if (cached)
|
|
381
|
-
return cached;
|
|
382
|
-
const result = parseStyleDefinition(normalized);
|
|
383
|
-
styleParseCache.set(normalized, result);
|
|
384
|
-
return result;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
export const NULL_STYLE = new Style();
|
|
388
|
-
// --- StyleStack ---
|
|
389
|
-
export class StyleStack {
|
|
390
|
-
stack;
|
|
391
|
-
constructor(base = NULL_STYLE) {
|
|
392
|
-
this.stack = [base];
|
|
393
|
-
}
|
|
394
|
-
get current() {
|
|
395
|
-
return this.stack[this.stack.length - 1];
|
|
396
|
-
}
|
|
397
|
-
push(style) {
|
|
398
|
-
this.stack.push(this.current.add(style));
|
|
399
|
-
}
|
|
400
|
-
pop() {
|
|
401
|
-
if (this.stack.length <= 1) {
|
|
402
|
-
throw new Error("Cannot pop the base style from StyleStack");
|
|
403
|
-
}
|
|
404
|
-
return this.stack.pop();
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
// --- Theme ---
|
|
408
|
-
const STYLE_NAME_RE = /^[a-z][a-z0-9._-]*$/;
|
|
409
|
-
export class Theme {
|
|
410
|
-
styles;
|
|
411
|
-
constructor(definitions = {}, options) {
|
|
412
|
-
this.styles = new Map();
|
|
413
|
-
const inherit = options?.inherit !== false;
|
|
414
|
-
if (inherit) {
|
|
415
|
-
for (const [name, style] of Object.entries(DEFAULT_STYLES)) {
|
|
416
|
-
this.styles.set(name, style);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
for (const [name, def] of Object.entries(definitions)) {
|
|
420
|
-
if (!STYLE_NAME_RE.test(name)) {
|
|
421
|
-
throw new Error(`Invalid style name: "${name}" (must be lowercase, start with letter, contain only letters, digits, ".", "-", "_")`);
|
|
422
|
-
}
|
|
423
|
-
this.styles.set(name, Style.parse(def));
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
get(name) {
|
|
427
|
-
return this.styles.get(name);
|
|
428
|
-
}
|
|
429
|
-
/**
|
|
430
|
-
* The style a `string | Style` stands for under this theme: a name this
|
|
431
|
-
* theme defines, otherwise a definition for `Style.parse`, which throws
|
|
432
|
-
* `StyleSyntaxError` when the string is neither.
|
|
433
|
-
*
|
|
434
|
-
* [LAW:one-source-of-truth] The theme is the one map from names to styles.
|
|
435
|
-
* The lookup stays outside `Style.parse`'s process-wide cache on purpose:
|
|
436
|
-
* cached there, the first console to resolve `repr.number` would decide it
|
|
437
|
-
* for every console after it, whatever theme each was given.
|
|
438
|
-
*/
|
|
439
|
-
resolve(style) {
|
|
440
|
-
if (style instanceof Style)
|
|
441
|
-
return style;
|
|
442
|
-
return this.styles.get(style) ?? Style.parse(style);
|
|
443
|
-
}
|
|
444
|
-
has(name) {
|
|
445
|
-
return this.styles.has(name);
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
// --- Parse helpers ---
|
|
449
|
-
const ATTRIBUTE_SET = new Set(ATTRIBUTE_NAMES);
|
|
450
|
-
// The words each position of a definition can hold: a bare token is a keyword,
|
|
451
|
-
// an attribute or a colour name; `on` takes a colour name; `not` an attribute.
|
|
452
|
-
// The short aliases are left out, since `b` is no help to someone who typed
|
|
453
|
-
// `bolt` and a one-letter name sits one edit from every other short word.
|
|
454
|
-
// [LAW:one-source-of-truth] Derived from the lists the parser accepts from; the
|
|
455
|
-
// keywords are the three `parseStyleDefinition` reads before anything else.
|
|
456
|
-
const FOREGROUND_WORDS = ["not", "on", "link", ...ATTRIBUTE_NAMES, ...COLOR_NAMES];
|
|
457
|
-
/**
|
|
458
|
-
* Optimal string alignment distance: insertions, deletions, substitutions, and
|
|
459
|
-
* swaps of two neighbouring letters each cost one edit, so `cyna` is as near
|
|
460
|
-
* `cyan` as `rd` is to `red`. Kept to three rows, since only the two before the
|
|
461
|
-
* current one are ever read.
|
|
462
|
-
*/
|
|
463
|
-
function editDistance(a, b) {
|
|
464
|
-
let before = [];
|
|
465
|
-
let previous = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
466
|
-
for (let i = 1; i <= a.length; i++) {
|
|
467
|
-
const current = [i];
|
|
468
|
-
for (let j = 1; j <= b.length; j++) {
|
|
469
|
-
const swap = i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1];
|
|
470
|
-
current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + Number(a[i - 1] !== b[j - 1]), swap ? before[j - 2] + 1 : Infinity);
|
|
471
|
-
}
|
|
472
|
-
[before, previous] = [previous, current];
|
|
473
|
-
}
|
|
474
|
-
return previous[b.length];
|
|
475
|
-
}
|
|
476
|
-
/**
|
|
477
|
-
* The ` (did you mean …?)` clause for a word no position accepted, or `""`
|
|
478
|
-
* when nothing in `words` is a plausible typo of it.
|
|
479
|
-
*
|
|
480
|
-
* Plausible means within one edit per three letters, at least one, which lets
|
|
481
|
-
* `rd` reach `red` and keeps `hello` from reaching `yellow`. Every name tied
|
|
482
|
-
* for nearest is offered: `gold` is one edit from `bold` and from three
|
|
483
|
-
* `goldN` colours, and choosing among them would be a guess the reader cannot
|
|
484
|
-
* tell from a finding. Case is not an edit, because the colour parser ignores
|
|
485
|
-
* it: `Cyna` is as near `cyan` as `cyna` is.
|
|
486
|
-
*
|
|
487
|
-
* This runs on every render that meets the bad style, since only successful
|
|
488
|
-
* parses are cached. Two words differ by at least their difference in length,
|
|
489
|
-
* so a name outside the budget on length alone is never measured — which is
|
|
490
|
-
* also what keeps a long garbage token from costing length × length per name.
|
|
491
|
-
*/
|
|
492
|
-
function nearMiss(word, words) {
|
|
493
|
-
const typed = word.toLowerCase();
|
|
494
|
-
const budget = Math.max(1, Math.floor(typed.length / 3));
|
|
495
|
-
const scored = words
|
|
496
|
-
.filter((name) => Math.abs(name.length - typed.length) <= budget)
|
|
497
|
-
.map((name) => ({ name, distance: editDistance(typed, name) }));
|
|
498
|
-
const nearest = Math.min(budget, ...scored.map((s) => s.distance));
|
|
499
|
-
const names = scored
|
|
500
|
-
.filter((s) => s.distance === nearest)
|
|
501
|
-
.map((s) => `"${s.name}"`)
|
|
502
|
-
.sort();
|
|
503
|
-
return names.length === 0 ? "" : ` (did you mean ${names.join(" or ")}?)`;
|
|
504
|
-
}
|
|
505
|
-
/**
|
|
506
|
-
* A style token read as a colour. The colour parser's own error is the reason
|
|
507
|
-
* the token failed, so it rides along twice: in the message, for a reader with
|
|
508
|
-
* only the text, and as `cause`, for code that wants the original error.
|
|
509
|
-
*
|
|
510
|
-
* [LAW:single-enforcer] Both colour positions in a definition rewrap here, and
|
|
511
|
-
* the near miss is named here rather than by the colour parser: only a
|
|
512
|
-
* definition knows whether the token could also have been an attribute.
|
|
513
|
-
*/
|
|
514
|
-
function parseStyleColor(token, failure, words) {
|
|
515
|
-
try {
|
|
516
|
-
return ColorSpec.parse(token);
|
|
517
|
-
}
|
|
518
|
-
catch (cause) {
|
|
519
|
-
throw new StyleSyntaxError(`${failure} "${token}"${nearMiss(token, words)}: ${String(cause)}`, {
|
|
520
|
-
cause,
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
function parseStyleDefinition(definition) {
|
|
525
|
-
const tokens = definition.split(/\s+/);
|
|
526
|
-
const opts = {};
|
|
527
|
-
let i = 0;
|
|
528
|
-
while (i < tokens.length) {
|
|
529
|
-
const token = tokens[i];
|
|
530
|
-
// "not <attr>"
|
|
531
|
-
if (token === "not") {
|
|
532
|
-
i++;
|
|
533
|
-
const next = tokens[i];
|
|
534
|
-
if (!next) {
|
|
535
|
-
throw new StyleSyntaxError(`Expected attribute after "not" in style definition`);
|
|
536
|
-
}
|
|
537
|
-
const attrName = ATTRIBUTE_SHORT_ALIASES[next] ?? next;
|
|
538
|
-
if (!ATTRIBUTE_SET.has(attrName)) {
|
|
539
|
-
throw new StyleSyntaxError(`Invalid attribute: "${next}"${nearMiss(next, ATTRIBUTE_NAMES)}`);
|
|
540
|
-
}
|
|
541
|
-
opts[attrName] = false;
|
|
542
|
-
i++;
|
|
543
|
-
continue;
|
|
544
|
-
}
|
|
545
|
-
// "on <color>"
|
|
546
|
-
if (token === "on") {
|
|
547
|
-
i++;
|
|
548
|
-
const next = tokens[i];
|
|
549
|
-
if (!next) {
|
|
550
|
-
throw new StyleSyntaxError(`Expected color after "on" in style definition`);
|
|
551
|
-
}
|
|
552
|
-
opts.bgcolor = parseStyleColor(next, "Invalid background color", COLOR_NAMES);
|
|
553
|
-
i++;
|
|
554
|
-
continue;
|
|
555
|
-
}
|
|
556
|
-
// "link <url>"
|
|
557
|
-
if (token === "link") {
|
|
558
|
-
i++;
|
|
559
|
-
const url = tokens[i];
|
|
560
|
-
if (url) {
|
|
561
|
-
opts.link = url;
|
|
562
|
-
}
|
|
563
|
-
i++;
|
|
564
|
-
continue;
|
|
565
|
-
}
|
|
566
|
-
// Attribute (full name)
|
|
567
|
-
const resolvedAttr = ATTRIBUTE_SHORT_ALIASES[token] ?? token;
|
|
568
|
-
if (ATTRIBUTE_SET.has(resolvedAttr)) {
|
|
569
|
-
opts[resolvedAttr] = true;
|
|
570
|
-
i++;
|
|
571
|
-
continue;
|
|
572
|
-
}
|
|
573
|
-
// Must be a color
|
|
574
|
-
opts.color = parseStyleColor(token, "Invalid style definition", FOREGROUND_WORDS);
|
|
575
|
-
i++;
|
|
576
|
-
}
|
|
577
|
-
return new Style(opts);
|
|
578
|
-
}
|
|
579
|
-
function resolveColor(c) {
|
|
580
|
-
if (c === undefined)
|
|
581
|
-
return undefined;
|
|
582
|
-
if (c instanceof ColorSpec)
|
|
583
|
-
return c;
|
|
584
|
-
return ColorSpec.parse(c);
|
|
585
|
-
}
|
|
586
|
-
// --- DEFAULT_STYLES ---
|
|
587
|
-
// [LAW:one-source-of-truth] Single canonical mapping of semantic names to styles
|
|
588
|
-
export const DEFAULT_STYLES = {
|
|
589
|
-
none: NULL_STYLE,
|
|
590
|
-
reset: new Style({
|
|
591
|
-
color: ColorSpec.default(),
|
|
592
|
-
bgcolor: ColorSpec.default(),
|
|
593
|
-
bold: false,
|
|
594
|
-
dim: false,
|
|
595
|
-
italic: false,
|
|
596
|
-
underline: false,
|
|
597
|
-
blink: false,
|
|
598
|
-
blink2: false,
|
|
599
|
-
reverse: false,
|
|
600
|
-
conceal: false,
|
|
601
|
-
strike: false,
|
|
602
|
-
underline2: false,
|
|
603
|
-
frame: false,
|
|
604
|
-
encircle: false,
|
|
605
|
-
overline: false,
|
|
606
|
-
}),
|
|
607
|
-
bold: new Style({ bold: true }),
|
|
608
|
-
dim: new Style({ dim: true }),
|
|
609
|
-
italic: new Style({ italic: true }),
|
|
610
|
-
underline: new Style({ underline: true }),
|
|
611
|
-
blink: new Style({ blink: true }),
|
|
612
|
-
blink2: new Style({ blink2: true }),
|
|
613
|
-
reverse: new Style({ reverse: true }),
|
|
614
|
-
conceal: new Style({ conceal: true }),
|
|
615
|
-
strike: new Style({ strike: true }),
|
|
616
|
-
underline2: new Style({ underline2: true }),
|
|
617
|
-
frame: new Style({ frame: true }),
|
|
618
|
-
encircle: new Style({ encircle: true }),
|
|
619
|
-
overline: new Style({ overline: true }),
|
|
620
|
-
// Table
|
|
621
|
-
"table.header": new Style({ bold: true }),
|
|
622
|
-
"table.footer": new Style({ bold: true }),
|
|
623
|
-
"table.cell": NULL_STYLE,
|
|
624
|
-
"table.title": new Style({ italic: true }),
|
|
625
|
-
"table.caption": new Style({ italic: true, dim: true }),
|
|
626
|
-
// Repr/highlighting
|
|
627
|
-
"repr.str": Style.parse("green"),
|
|
628
|
-
"repr.number": Style.parse("cyan"),
|
|
629
|
-
"repr.bool": Style.parse("italic bright_magenta"),
|
|
630
|
-
"repr.none": Style.parse("italic magenta"),
|
|
631
|
-
"repr.url": Style.parse("not italic underline bright_blue"),
|
|
632
|
-
"repr.uuid": Style.parse("bright_yellow"),
|
|
633
|
-
"repr.error": Style.parse("bold red"),
|
|
634
|
-
"repr.indent": Style.parse("dim green"),
|
|
635
|
-
"repr.attrib_name": Style.parse("yellow"),
|
|
636
|
-
"repr.attrib_value": Style.parse("magenta"),
|
|
637
|
-
"repr.attrib_equal": Style.parse("bold"),
|
|
638
|
-
"repr.tag_start": Style.parse("bold"),
|
|
639
|
-
"repr.tag_name": Style.parse("bright_magenta"),
|
|
640
|
-
"repr.tag_contents": Style.parse("default"),
|
|
641
|
-
"repr.tag_end": Style.parse("bold"),
|
|
642
|
-
// Log
|
|
643
|
-
"log.time": Style.parse("cyan dim"),
|
|
644
|
-
"log.message": NULL_STYLE,
|
|
645
|
-
"log.path": Style.parse("dim"),
|
|
646
|
-
"log.line_no": Style.parse("cyan"),
|
|
647
|
-
"log.level": NULL_STYLE,
|
|
648
|
-
// Rule
|
|
649
|
-
"rule.line": Style.parse("green"),
|
|
650
|
-
"rule.text": Style.parse("bold"),
|
|
651
|
-
// JSON
|
|
652
|
-
"json.brace": Style.parse("bold"),
|
|
653
|
-
"json.bool_true": Style.parse("italic bright_green"),
|
|
654
|
-
"json.bool_false": Style.parse("italic bright_red"),
|
|
655
|
-
"json.key": Style.parse("bold blue"),
|
|
656
|
-
"json.null": Style.parse("italic magenta"),
|
|
657
|
-
"json.number": Style.parse("bold not italic cyan"),
|
|
658
|
-
"json.str": Style.parse("not bold not italic green"),
|
|
659
|
-
// Markdown
|
|
660
|
-
"markdown.h1": Style.parse("bold underline"),
|
|
661
|
-
"markdown.h2": Style.parse("bold"),
|
|
662
|
-
"markdown.h3": Style.parse("bold dim"),
|
|
663
|
-
"markdown.h4": Style.parse("bold dim italic"),
|
|
664
|
-
"markdown.code": Style.parse("cyan on grey11"),
|
|
665
|
-
"markdown.hr": Style.parse("yellow"),
|
|
666
|
-
"markdown.link": Style.parse("bright_blue"),
|
|
667
|
-
"markdown.link_url": Style.parse("blue"),
|
|
668
|
-
// Progress
|
|
669
|
-
"progress.description": NULL_STYLE,
|
|
670
|
-
"progress.percentage": Style.parse("cyan"),
|
|
671
|
-
"progress.remaining": Style.parse("cyan"),
|
|
672
|
-
"progress.elapsed": Style.parse("cyan"),
|
|
673
|
-
"progress.spinner": Style.parse("green"),
|
|
674
|
-
"progress.download": Style.parse("green"),
|
|
675
|
-
"progress.filesize": Style.parse("green"),
|
|
676
|
-
"progress.filesize.total": Style.parse("green"),
|
|
677
|
-
"progress.data.speed": Style.parse("red"),
|
|
678
|
-
// Bar
|
|
679
|
-
"bar.back": Style.parse("grey23"),
|
|
680
|
-
"bar.complete": Style.parse("magenta"),
|
|
681
|
-
"bar.finished": Style.parse("green"),
|
|
682
|
-
"bar.pulse": Style.parse("magenta"),
|
|
683
|
-
// Tree
|
|
684
|
-
"tree": NULL_STYLE,
|
|
685
|
-
"tree.guide": NULL_STYLE,
|
|
686
|
-
// Status
|
|
687
|
-
"status.spinner": Style.parse("green"),
|
|
688
|
-
"status.message": NULL_STYLE,
|
|
689
|
-
// Prompt
|
|
690
|
-
"prompt": Style.parse("bold"),
|
|
691
|
-
"prompt.choices": Style.parse("magenta"),
|
|
692
|
-
"prompt.default": Style.parse("cyan"),
|
|
693
|
-
// Inspect
|
|
694
|
-
"inspect.attr": Style.parse("yellow italic"),
|
|
695
|
-
"inspect.attr.dunder": Style.parse("yellow italic dim"),
|
|
696
|
-
"inspect.callable": Style.parse("bold magenta"),
|
|
697
|
-
"inspect.error": Style.parse("bold red"),
|
|
698
|
-
"inspect.help": Style.parse("cyan"),
|
|
699
|
-
"inspect.doc": Style.parse("dim"),
|
|
700
|
-
"inspect.value.border": Style.parse("green"),
|
|
701
|
-
// Traceback
|
|
702
|
-
"traceback.border": Style.parse("red"),
|
|
703
|
-
"traceback.text": Style.parse("red"),
|
|
704
|
-
"traceback.title": Style.parse("bold red"),
|
|
705
|
-
"traceback.exc_type": Style.parse("bold bright_red"),
|
|
706
|
-
"traceback.exc_value": NULL_STYLE,
|
|
707
|
-
"traceback.offset": Style.parse("bold bright_red"),
|
|
708
|
-
// Scope
|
|
709
|
-
"scope.border": Style.parse("blue"),
|
|
710
|
-
"scope.key": Style.parse("italic"),
|
|
711
|
-
"scope.key.special": Style.parse("dim italic"),
|
|
712
|
-
// Pretty
|
|
713
|
-
"pretty": NULL_STYLE,
|
|
714
|
-
// ISO8601
|
|
715
|
-
"iso8601.date": Style.parse("cyan"),
|
|
716
|
-
"iso8601.time": Style.parse("cyan"),
|
|
717
|
-
"iso8601.timezone": Style.parse("bright_blue"),
|
|
718
|
-
};
|
|
719
|
-
/**
|
|
720
|
-
* The theme a render resolves names against when nothing supplied one — what
|
|
721
|
-
* a renderable sees outside a `Console`, as in `renderToString`.
|
|
722
|
-
*/
|
|
723
|
-
export const DEFAULT_THEME = new Theme();
|