@promptctl/rich-js 0.28.0 → 0.29.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 +7 -7
- package/dist/core/animation.d.ts +37 -37
- package/dist/core/animation.js +61 -61
- package/dist/core/ansi.d.ts +4 -4
- package/dist/core/ansi.js +9 -9
- package/dist/core/bidi.js +6 -6
- package/dist/core/cells.d.ts +1 -1
- package/dist/core/cells.js +5 -5
- package/dist/core/clock.d.ts +1 -1
- package/dist/core/color.d.ts +50 -50
- package/dist/core/color.js +69 -69
- package/dist/core/console.d.ts +8 -8
- package/dist/core/console.js +5 -5
- package/dist/core/control-codes.d.ts +3 -3
- package/dist/core/control-codes.js +7 -7
- package/dist/core/easing.d.ts +40 -40
- package/dist/core/easing.js +40 -40
- package/dist/core/env.d.ts +1 -1
- package/dist/core/env.js +1 -1
- package/dist/core/export-html.js +1 -1
- package/dist/core/export-lines.d.ts +11 -11
- package/dist/core/export-lines.js +12 -12
- package/dist/core/export-svg.d.ts +3 -3
- package/dist/core/export-svg.js +4 -4
- package/dist/core/markup.js +1 -1
- package/dist/core/memo.d.ts +1 -1
- package/dist/core/memo.js +1 -1
- package/dist/core/oklch.d.ts +14 -14
- package/dist/core/oklch.js +10 -10
- package/dist/core/orient.d.ts +3 -3
- package/dist/core/orient.js +3 -3
- package/dist/core/paint.d.ts +9 -9
- package/dist/core/paint.js +3 -3
- package/dist/core/pretty.d.ts +1 -1
- package/dist/core/pretty.js +3 -3
- package/dist/core/protocol.d.ts +26 -26
- package/dist/core/protocol.js +22 -22
- package/dist/core/render.d.ts +11 -11
- package/dist/core/render.js +12 -12
- package/dist/core/segment.d.ts +3 -3
- package/dist/core/segment.js +5 -5
- package/dist/core/strip.d.ts +83 -83
- package/dist/core/strip.js +70 -70
- package/dist/core/style.d.ts +20 -20
- package/dist/core/style.js +55 -55
- package/dist/core/text.d.ts +2 -2
- package/dist/core/text.js +5 -5
- package/dist/core/timeline.d.ts +5 -5
- package/dist/core/timeline.js +9 -9
- package/dist/core/tween.d.ts +6 -6
- package/dist/core/tween.js +10 -10
- package/dist/core/view.d.ts +4 -4
- package/dist/core/view.js +12 -12
- package/dist/host/app.d.ts +9 -9
- package/dist/host/app.js +12 -12
- package/dist/host/host-environment.d.ts +2 -2
- package/dist/host/host-environment.js +2 -2
- package/dist/host/index.d.ts +2 -2
- package/dist/host/input.d.ts +7 -7
- package/dist/host/input.js +4 -4
- package/dist/host/terminal-colors.d.ts +2 -2
- package/dist/host/terminal-colors.js +4 -4
- package/dist/host/terminal-host.d.ts +2 -2
- package/dist/host/terminal-host.js +1 -1
- package/dist/index.d.ts +14 -14
- package/dist/index.js +10 -10
- package/dist/node/prompt.d.ts +1 -1
- package/dist/node/prompt.js +1 -1
- package/dist/node/terminal-host.d.ts +1 -1
- package/dist/node/traceback.js +2 -2
- package/dist/renderables/change.js +2 -2
- package/dist/renderables/effect.d.ts +39 -39
- package/dist/renderables/effect.js +45 -45
- package/dist/renderables/effects.d.ts +81 -81
- package/dist/renderables/effects.js +157 -157
- package/dist/renderables/embed.d.ts +1 -1
- package/dist/renderables/embed.js +2 -2
- package/dist/renderables/flexStrip.d.ts +7 -7
- package/dist/renderables/flexStrip.js +15 -15
- package/dist/renderables/frames.d.ts +6 -6
- package/dist/renderables/frames.js +11 -11
- package/dist/renderables/glyph-effect.d.ts +15 -15
- package/dist/renderables/glyph-effect.js +17 -17
- package/dist/renderables/glyph-effects.d.ts +7 -7
- package/dist/renderables/glyph-effects.js +16 -16
- package/dist/renderables/html-entities.d.ts +1 -1
- package/dist/renderables/html-entities.js +1 -1
- package/dist/renderables/lifecycle.d.ts +4 -4
- package/dist/renderables/lifecycle.js +12 -12
- package/dist/renderables/live.d.ts +2 -2
- package/dist/renderables/live.js +7 -7
- package/dist/renderables/markdown-parse.js +3 -3
- package/dist/renderables/panel.js +3 -3
- package/dist/renderables/progress.d.ts +1 -1
- package/dist/renderables/progress.js +1 -1
- package/dist/renderables/progressBar.d.ts +1 -1
- package/dist/renderables/progressBar.js +6 -6
- package/dist/renderables/prompt.d.ts +1 -1
- package/dist/renderables/scroll.d.ts +1 -1
- package/dist/renderables/scroll.js +3 -3
- package/dist/renderables/spinner.d.ts +4 -4
- package/dist/renderables/spinner.js +10 -10
- package/dist/renderables/syntax.d.ts +2 -2
- package/dist/renderables/syntax.js +2 -2
- package/dist/renderables/table.js +3 -3
- package/dist/renderables/traceback.d.ts +1 -1
- package/dist/renderables/traceback.js +1 -1
- package/dist/renderables/tree.js +3 -3
- package/dist/template-bindings/animation-funcs.d.ts +14 -14
- package/dist/template-bindings/animation-funcs.js +27 -27
- package/dist/template-bindings/color-funcs.d.ts +14 -14
- package/dist/template-bindings/color-funcs.js +25 -25
- package/dist/template-bindings/index.d.ts +9 -9
- package/dist/template-bindings/index.js +9 -9
- package/dist/template-bindings/palette-funcs.d.ts +1 -1
- package/dist/template-bindings/palette-funcs.js +3 -3
- package/dist/template-bindings/style-funcs.d.ts +5 -5
- package/dist/template-bindings/style-funcs.js +16 -16
- package/dist/themes/{transpose.d.ts → adjust.d.ts} +23 -23
- package/dist/themes/{transpose.js → adjust.js} +28 -28
- package/dist/themes/buildPalette.d.ts +3 -3
- package/dist/themes/buildPalette.js +20 -20
- package/dist/themes/colorMath.d.ts +16 -16
- package/dist/themes/colorMath.js +32 -32
- package/dist/themes/data/ansi-tables.d.ts +2 -2
- package/dist/themes/data/ansi-tables.js +2 -2
- package/dist/themes/data/types.d.ts +4 -4
- package/dist/themes/data/types.js +2 -2
- package/dist/themes/palette.d.ts +12 -12
- package/dist/themes/palette.js +16 -16
- package/dist/themes/ramp.d.ts +17 -17
- package/dist/themes/ramp.js +12 -12
- package/dist/themes/registry.js +4 -4
- package/dist/themes/terminalThemes.d.ts +1 -1
- package/dist/themes/terminalThemes.js +1 -1
- package/dist/widgets/button.d.ts +2 -2
- package/dist/widgets/button.js +4 -4
- package/dist/widgets/checkbox.d.ts +2 -2
- package/dist/widgets/checkbox.js +2 -2
- package/dist/widgets/dropdown.d.ts +2 -2
- package/dist/widgets/dropdown.js +3 -3
- package/dist/widgets/event-router.d.ts +6 -6
- package/dist/widgets/event-router.js +2 -2
- package/dist/widgets/focus-manager.d.ts +3 -3
- package/dist/widgets/focus-manager.js +3 -3
- package/dist/widgets/index.d.ts +2 -2
- package/dist/widgets/index.js +1 -1
- package/dist/widgets/ink.d.ts +3 -3
- package/dist/widgets/ink.js +4 -4
- package/dist/widgets/slider.d.ts +2 -2
- package/dist/widgets/static-item.d.ts +2 -2
- package/dist/widgets/text-input.d.ts +2 -2
- package/dist/widgets/text-input.js +5 -5
- package/dist/widgets/themed-widget.js +1 -1
- package/dist/widgets/toggle.d.ts +3 -3
- package/dist/widgets/toggle.js +3 -3
- package/dist/widgets/types.d.ts +6 -6
- package/dist/widgets/types.js +2 -2
- package/dist/widgets/widget-app.d.ts +10 -10
- package/dist/widgets/widget-app.js +8 -8
- package/dist/widgets/widget-base.d.ts +2 -2
- package/package.json +1 -1
package/dist/core/bidi.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* character the algorithm takes out of the text, which has no level.
|
|
13
13
|
*/
|
|
14
14
|
import { BIDI_CLASSES, BRACKET_PAIRS, CLASS_RANGES, JOINING_RANGES, JOINING_TYPES, MIRRORS, PRESENTATION_FORMS } from "./bidi-data.js";
|
|
15
|
-
import {
|
|
15
|
+
import { replaceZeroWidth } from "./cells.js";
|
|
16
16
|
import { pattern } from "./pattern.js";
|
|
17
17
|
/** The level of a character rule X9 removes. */
|
|
18
18
|
export const REMOVED = -1;
|
|
@@ -69,7 +69,7 @@ export function withoutExplicit(text) {
|
|
|
69
69
|
}
|
|
70
70
|
/** `text` as data on show: what the wire would drop, and every explicit control, spelled by `escape`. */
|
|
71
71
|
export function escaped(text, escape) {
|
|
72
|
-
return
|
|
72
|
+
return replaceZeroWidth(text, escape).replace(new RegExp(EXPLICIT.source, "gu"), escape);
|
|
73
73
|
}
|
|
74
74
|
/** `text` with LRM, RLM and ALM gone. */
|
|
75
75
|
export function withoutMarks(text) {
|
|
@@ -572,12 +572,12 @@ const INITIAL = 2;
|
|
|
572
572
|
const MEDIAL = 3;
|
|
573
573
|
const ZWNJ = "\u200c";
|
|
574
574
|
const ZWJ = "\u200d";
|
|
575
|
-
const UNJOINED = { letter: false, toPrevious: false, toNext: false,
|
|
575
|
+
const UNJOINED = { letter: false, toPrevious: false, toNext: false, separator: false };
|
|
576
576
|
function joiningOf(cluster) {
|
|
577
577
|
const base = cluster.codePointAt(0);
|
|
578
578
|
const type = joiningTypeOf(base);
|
|
579
579
|
const toNext = (type === "D" || type === "L" || type === "C") && !cluster.includes(ZWNJ);
|
|
580
|
-
return { letter: FORMS_OF.has(base), toPrevious: type === "D" || type === "R" || type === "C", toNext,
|
|
580
|
+
return { letter: FORMS_OF.has(base), toPrevious: type === "D" || type === "R" || type === "C", toNext, separator: cluster.includes(ZWJ) };
|
|
581
581
|
}
|
|
582
582
|
/**
|
|
583
583
|
* Arabic joining on one row's grapheme clusters, in logical order and in place:
|
|
@@ -605,8 +605,8 @@ export function shaped(clusters) {
|
|
|
605
605
|
if (!own.letter)
|
|
606
606
|
return text;
|
|
607
607
|
const before = neighbour(at, -1);
|
|
608
|
-
const joinsBefore = own.toPrevious && (before.toNext || before.
|
|
609
|
-
const joinsAfter = own.toNext && (own.
|
|
608
|
+
const joinsBefore = own.toPrevious && (before.toNext || before.separator);
|
|
609
|
+
const joinsAfter = own.toNext && (own.separator || neighbour(at, 1).toPrevious);
|
|
610
610
|
const forms = FORMS_OF.get(text.codePointAt(0));
|
|
611
611
|
const wanted = joinsBefore ? (joinsAfter ? MEDIAL : FINAL) : joinsAfter ? INITIAL : ISOLATED;
|
|
612
612
|
const form = forms[wanted] || text.codePointAt(0);
|
package/dist/core/cells.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* across it would need (UAX #29 GB11). So the width of a string stays the sum over
|
|
17
17
|
* the clusters of the text as it was given, and every cut stays exact.
|
|
18
18
|
*/
|
|
19
|
-
export declare function
|
|
19
|
+
export declare function replaceZeroWidth(text: string, replacement: (character: string) => string): string;
|
|
20
20
|
/** `character` as a Unicode escape a reader can see, for data on show. */
|
|
21
21
|
export declare function unicodeEscape(character: string): string;
|
|
22
22
|
/** `text` as the wire may hold it. */
|
package/dist/core/cells.js
CHANGED
|
@@ -9,7 +9,7 @@ const cellLenMemo = new Memo();
|
|
|
9
9
|
const ZWJ = 0x200d;
|
|
10
10
|
const ZWJ_CHARACTER = String.fromCodePoint(ZWJ);
|
|
11
11
|
const VS16 = 0xfe0f;
|
|
12
|
-
const
|
|
12
|
+
const SEPARATOR_STYLES = pattern(/[\u200d\ufe0f]/);
|
|
13
13
|
const PRINTABLE_ASCII = pattern(/^[ -~]*$/);
|
|
14
14
|
// Segmented afresh on every call: a cursor's step costs a few microseconds
|
|
15
15
|
// even in 10k code units, and a cache of segmentations would hold native
|
|
@@ -24,7 +24,7 @@ function dispositionCells(codePoint) {
|
|
|
24
24
|
case "keep": return codePointWidth(codePoint);
|
|
25
25
|
case "line-break": return 0;
|
|
26
26
|
case "pictured": return 0;
|
|
27
|
-
case "
|
|
27
|
+
case "zeroWidth": return 0;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
const WITHHELD = pattern(new RegExp(controlClass((disposition) => disposition !== "keep"), "u"));
|
|
@@ -53,7 +53,7 @@ function selectsAGlyph(text, index) {
|
|
|
53
53
|
* across it would need (UAX #29 GB11). So the width of a string stays the sum over
|
|
54
54
|
* the clusters of the text as it was given, and every cut stays exact.
|
|
55
55
|
*/
|
|
56
|
-
export function
|
|
56
|
+
export function replaceZeroWidth(text, replacement) {
|
|
57
57
|
if (text.match(WITHHELD) === null)
|
|
58
58
|
return text;
|
|
59
59
|
const gone = new Set();
|
|
@@ -97,7 +97,7 @@ export function unicodeEscape(character) {
|
|
|
97
97
|
}
|
|
98
98
|
/** `text` as the wire may hold it. */
|
|
99
99
|
export function wireText(text) {
|
|
100
|
-
return
|
|
100
|
+
return replaceZeroWidth(text, () => "");
|
|
101
101
|
}
|
|
102
102
|
// Rich's `cell_len` over a run of text: each code point the cells Rich's table
|
|
103
103
|
// gives it, but that a ZWJ takes the code point after it into the glyph before
|
|
@@ -138,7 +138,7 @@ function measure(text) {
|
|
|
138
138
|
if (PRINTABLE_ASCII.test(text))
|
|
139
139
|
return text.length;
|
|
140
140
|
const drawn = wireText(text);
|
|
141
|
-
if (!
|
|
141
|
+
if (!SEPARATOR_STYLES.test(drawn))
|
|
142
142
|
return richCells(drawn);
|
|
143
143
|
let cells = 0;
|
|
144
144
|
for (const { segment } of SEGMENTER.segment(drawn))
|
package/dist/core/clock.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export interface Clock {
|
|
|
45
45
|
/**
|
|
46
46
|
* Call `tick` once, when this clock reads `time` — as soon as it can for a
|
|
47
47
|
* time already past — unless the returned function is called first. What
|
|
48
|
-
* a host that knows when its frame next changes (`Segment.
|
|
48
|
+
* a host that knows when its frame next changes (`Segment.validUntil`)
|
|
49
49
|
* waits on. A `time` that is not a finite number of seconds throws; one
|
|
50
50
|
* further off than a platform timer can wait is waited for in turns.
|
|
51
51
|
*/
|
package/dist/core/color.d.ts
CHANGED
|
@@ -35,12 +35,12 @@ export declare class ColorRgba {
|
|
|
35
35
|
compositeOver(bg: ColorRgba): ColorRgba;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
* The surface a terminal draws a translucent
|
|
38
|
+
* The surface a terminal draws a translucent color over. A terminal cannot
|
|
39
39
|
* know what lies under its cells, so the SGR writer (`Style.toSgrCodes`), the
|
|
40
40
|
* exports that picture its output (`resolveLook`), the strip's seam test and
|
|
41
41
|
* the contrast choosers (`themes/colorMath`) all composite over this one
|
|
42
|
-
*
|
|
43
|
-
* the
|
|
42
|
+
* color. [LAW:one-source-of-truth] One constant, so
|
|
43
|
+
* the color text is chosen against is the color the writer draws.
|
|
44
44
|
*/
|
|
45
45
|
export declare const SURFACE_BLACK: ColorRgba;
|
|
46
46
|
/**
|
|
@@ -64,7 +64,7 @@ export declare function rgbDistance(a: ColorRgba, b: ColorRgba): number;
|
|
|
64
64
|
/**
|
|
65
65
|
* An indexed palette: entry `i` of `colors` is terminal index `firstIndex + i`.
|
|
66
66
|
* `firstIndex` lets a table hold only the part of a palette a downgrade may
|
|
67
|
-
* choose (the 256-
|
|
67
|
+
* choose (the 256-color cube and grey ramp start at 16) while every index it
|
|
68
68
|
* reports is the terminal's own.
|
|
69
69
|
*/
|
|
70
70
|
export declare class ColorTable {
|
|
@@ -98,7 +98,7 @@ export declare class ColorTable {
|
|
|
98
98
|
private nearestReadable;
|
|
99
99
|
/**
|
|
100
100
|
* The nearest entry to `value` (the distance `match` uses) among those
|
|
101
|
-
* `accept` takes, given each entry's
|
|
101
|
+
* `accept` takes, given each entry's color and terminal index; `undefined`
|
|
102
102
|
* when it takes none. Entries are offered nearest-first (ties to the lower
|
|
103
103
|
* index) and the first taken wins, so an expensive predicate runs only as
|
|
104
104
|
* far out as the answer. Uncached: the predicate is the caller's, and a
|
|
@@ -126,8 +126,8 @@ declare const COLOR_SYSTEM_DEPTHS: {
|
|
|
126
126
|
readonly none: null;
|
|
127
127
|
};
|
|
128
128
|
/**
|
|
129
|
-
* A
|
|
130
|
-
* other name is a fixed depth — `"none"` no
|
|
129
|
+
* A color system by name: `"auto"` detects it from the environment, and each
|
|
130
|
+
* other name is a fixed depth — `"none"` no color. `ColorDepth.WINDOWS` has
|
|
131
131
|
* no name; pass the enum value where a `ColorDepth` is accepted.
|
|
132
132
|
*/
|
|
133
133
|
export type ColorSystemName = "auto" | keyof typeof COLOR_SYSTEM_DEPTHS;
|
|
@@ -145,14 +145,14 @@ export type ColorSystemName = "auto" | keyof typeof COLOR_SYSTEM_DEPTHS;
|
|
|
145
145
|
export declare function detectColorSystem(options?: DetectColorOptions): ColorDepth | null;
|
|
146
146
|
/**
|
|
147
147
|
* Where segments are written, as everything the serializer (`segmentsToString`)
|
|
148
|
-
* needs to know about it: the
|
|
148
|
+
* needs to know about it: the color depth SGR is drawn at, whether OSC 8
|
|
149
149
|
* hyperlinks are emitted, and whether the reader there asked for reduced
|
|
150
150
|
* motion — under which the terminal's own blink is not asked for
|
|
151
151
|
* (`shownOn`, `./render.ts`). The serializer takes this value whole, so a
|
|
152
152
|
* fact the encoding comes to need joins it here rather than the serializer's
|
|
153
153
|
* signature.
|
|
154
154
|
*/
|
|
155
|
-
export interface
|
|
155
|
+
export interface OutputTarget {
|
|
156
156
|
readonly colorSystem: ColorDepth | null;
|
|
157
157
|
readonly hyperlinks: boolean;
|
|
158
158
|
/**
|
|
@@ -165,7 +165,7 @@ export interface Destination {
|
|
|
165
165
|
readonly textOrder: TextOrder;
|
|
166
166
|
}
|
|
167
167
|
/**
|
|
168
|
-
* What `
|
|
168
|
+
* What `resolveOutputTarget` is told about where it writes beyond the color
|
|
169
169
|
* spec: what detection probes, and the reader's preference for motion, which
|
|
170
170
|
* no spec or terminal reports, so the program hands it in. Absent, everything
|
|
171
171
|
* moves.
|
|
@@ -176,18 +176,18 @@ export interface DestinationOptions extends DetectColorOptions {
|
|
|
176
176
|
textOrder?: TextOrder;
|
|
177
177
|
}
|
|
178
178
|
/**
|
|
179
|
-
* Resolve a
|
|
179
|
+
* Resolve a color spec into an `OutputTarget`.
|
|
180
180
|
*
|
|
181
181
|
* [LAW:single-enforcer] The one place a spec becomes both facts. A hyperlink is
|
|
182
|
-
* not a
|
|
183
|
-
*
|
|
182
|
+
* not a color: an explicit depth — `"none"` and `null` included — states a
|
|
183
|
+
* color choice and keeps links, and under `"auto"` links follow what the
|
|
184
184
|
* terminal can take (no TTY, TERM=dumb: none) while NO_COLOR and FORCE_COLOR=0,
|
|
185
|
-
*
|
|
185
|
+
* color preferences, leave them alone. A FORCE_COLOR that forces color on
|
|
186
186
|
* declares the destination takes escapes, so it keeps links on a pipe too.
|
|
187
187
|
*/
|
|
188
|
-
export declare function
|
|
188
|
+
export declare function resolveOutputTarget(spec: ColorSystemName | ColorDepth | null, options?: DestinationOptions): OutputTarget;
|
|
189
189
|
/**
|
|
190
|
-
* Resolve a
|
|
190
|
+
* Resolve a color system name into a `ColorDepth` (or `null` for no color).
|
|
191
191
|
*
|
|
192
192
|
* `"auto"` triggers env-based detection; every other name is a fixed depth.
|
|
193
193
|
* A name outside the vocabulary — reachable only from untyped JavaScript —
|
|
@@ -208,12 +208,12 @@ export declare class ColorSpec {
|
|
|
208
208
|
constructor(name: string, type: ColorDepth, number?: number, value?: ColorRgba);
|
|
209
209
|
get isDefault(): boolean;
|
|
210
210
|
/**
|
|
211
|
-
* The
|
|
211
|
+
* The color every terminal draws this spec as, where that is fixed — before
|
|
212
212
|
* any alpha is flattened, so a translucent value is drawn composited over
|
|
213
213
|
* its ground (`flattenAlpha`) and should be measured that way: a
|
|
214
|
-
* truecolor value, or a 256-
|
|
214
|
+
* truecolor value, or a 256-color cube or grey-ramp entry (xterm fixes
|
|
215
215
|
* indices 16–255, and `fromAnsi` types only those as EIGHT_BIT). ANSI 0–15,
|
|
216
|
-
* the default
|
|
216
|
+
* the default color and a blend reaching either are the terminal theme's
|
|
217
217
|
* own, so they have none.
|
|
218
218
|
*/
|
|
219
219
|
get fixedValue(): ColorRgba | undefined;
|
|
@@ -250,48 +250,48 @@ export declare class ColorSpec {
|
|
|
250
250
|
static fromRgba(value: ColorRgba): ColorSpec;
|
|
251
251
|
static fromRgb(r: number, g: number, b: number): ColorSpec;
|
|
252
252
|
/**
|
|
253
|
-
* The
|
|
254
|
-
* parses to. Two fixed
|
|
255
|
-
* theme's own
|
|
253
|
+
* The color `t` of the way from `from` to `to`: what `blend(from,to,t)`
|
|
254
|
+
* parses to. Two fixed colors mix to a fixed color. A mix reaching a
|
|
255
|
+
* theme's own color stays a mix until it is drawn, so whatever theme draws
|
|
256
256
|
* an end draws the mix from it: exported under a theme whose `blue` is
|
|
257
257
|
* #61afef, a mix with `blue` starts from #61afef. A terminal is told its RGB
|
|
258
258
|
* under the standard table, the only one a render has.
|
|
259
259
|
*
|
|
260
|
-
* Each end is one opaque
|
|
260
|
+
* Each end is one opaque color: `default` is no color to mix, and a
|
|
261
261
|
* translucent end has no one shade until it is laid on a ground.
|
|
262
262
|
*/
|
|
263
263
|
static blend(from: ColorSpec, to: ColorSpec, t: number): ColorSpec;
|
|
264
264
|
/**
|
|
265
265
|
* The spec that draws `value` nearest to it at `depth` on a terminal known
|
|
266
|
-
* to show `theme`, as the
|
|
266
|
+
* to show `theme`, as the color of the glyph (`foreground`) or of the
|
|
267
267
|
* ground. Where `downgrade` knows no terminal, and so rounds only against
|
|
268
|
-
*
|
|
269
|
-
* sixteen), this rounds against every
|
|
270
|
-
* look `theme` fixes: the default
|
|
271
|
-
*
|
|
272
|
-
* moved a little is drawn as the
|
|
273
|
-
* gives two slots one
|
|
268
|
+
* colors every terminal fixes (or, at sixteen colors, the stock
|
|
269
|
+
* sixteen), this rounds against every color the depth can write whose
|
|
270
|
+
* look `theme` fixes: the default color, the theme's sixteen, and at 256
|
|
271
|
+
* colors the cube and grey ramp too. A color read off any of those and
|
|
272
|
+
* moved a little is drawn as the color it came from — or, where the theme
|
|
273
|
+
* gives two slots one color, as the lower slot, which looks the same.
|
|
274
274
|
*
|
|
275
|
-
* `value` is opaque: a translucent
|
|
275
|
+
* `value` is opaque: a translucent color has no one look until it is laid
|
|
276
276
|
* on a ground (`flattenAlpha`).
|
|
277
277
|
*/
|
|
278
278
|
static matchOn(value: ColorRgba, depth: ColorDepth, theme: TerminalColors, foreground: boolean): ColorSpec;
|
|
279
279
|
/**
|
|
280
|
-
* Every
|
|
280
|
+
* Every color `depth` writes by index, each with the color a terminal
|
|
281
281
|
* known to show `theme` draws it in, lowest index first: the theme's
|
|
282
|
-
* sixteen, and at 256
|
|
283
|
-
* drawn alike as glyph and as ground, which the default
|
|
284
|
-
* it is not among them. Truecolor writes a
|
|
285
|
-
* depth only the default, so neither writes any by index. The
|
|
282
|
+
* sixteen, and at 256 colors the cube and grey ramp after them. Each is
|
|
283
|
+
* drawn alike as glyph and as ground, which the default color is not, so
|
|
284
|
+
* it is not among them. Truecolor writes a color itself and the default
|
|
285
|
+
* depth only the default, so neither writes any by index. The colors
|
|
286
286
|
* `matchOn` rounds to, but for the default, read off the same two tables.
|
|
287
287
|
*/
|
|
288
288
|
static indexed(depth: ColorDepth, theme: TerminalColors): readonly (readonly [ColorSpec, ColorRgba])[];
|
|
289
289
|
/**
|
|
290
|
-
* The spec a slot is written in once its
|
|
290
|
+
* The spec a slot is written in once its color moves from `was`, what its
|
|
291
291
|
* written spec draws on `theme`, to the opaque `now`: `matchOn`'s — or
|
|
292
292
|
* none, where the written spec is as near `now` as that match. A move the
|
|
293
|
-
* depth cannot show is no move, so below truecolor a
|
|
294
|
-
* off any
|
|
293
|
+
* depth cannot show is no move, so below truecolor a color moved a little
|
|
294
|
+
* off any color the depth can write — a theme slot, the default color,
|
|
295
295
|
* the cube — keeps the spec it was written in.
|
|
296
296
|
*/
|
|
297
297
|
static matchMove(was: ColorRgba, now: ColorRgba, depth: ColorDepth, theme: TerminalColors, foreground: boolean): ColorSpec | undefined;
|
|
@@ -302,7 +302,7 @@ export declare class ColorSpec {
|
|
|
302
302
|
static parse(colorString: string): ColorSpec;
|
|
303
303
|
private performDowngrade;
|
|
304
304
|
}
|
|
305
|
-
/** Six hex digits, no `#`, as an opaque
|
|
305
|
+
/** Six hex digits, no `#`, as an opaque color. @throws {ColorParseError} on anything else. */
|
|
306
306
|
export declare function parseRgbHex(hex: string): ColorRgba;
|
|
307
307
|
/** Eight hex digits, no `#`, the last pair alpha. @throws {ColorParseError} on anything else. */
|
|
308
308
|
export declare function parseRgbaHex(hex: string): ColorRgba;
|
|
@@ -313,7 +313,7 @@ export declare function parseRgbaHex(hex: string): ColorRgba;
|
|
|
313
313
|
export declare function parseHexColor(literal: string): ColorRgba;
|
|
314
314
|
export declare function blendRgb(color1: ColorRgba, color2: ColorRgba, crossFade?: number): ColorRgba;
|
|
315
315
|
/**
|
|
316
|
-
* What a terminal draws with: the part of a `TerminalTheme` a
|
|
316
|
+
* What a terminal draws with: the part of a `TerminalTheme` a color resolves
|
|
317
317
|
* against.
|
|
318
318
|
*/
|
|
319
319
|
export declare class TerminalColors {
|
|
@@ -324,12 +324,12 @@ export declare class TerminalColors {
|
|
|
324
324
|
constructor(backgroundColor: ColorRgba, foregroundColor: ColorRgba, ansiColors: ColorTable);
|
|
325
325
|
}
|
|
326
326
|
/**
|
|
327
|
-
* A terminal theme — surface/foreground baseline, the sixteen ANSI
|
|
327
|
+
* A terminal theme — surface/foreground baseline, the sixteen ANSI colors,
|
|
328
328
|
* and a semantic palette.
|
|
329
329
|
*
|
|
330
|
-
* **`ansiColors` is the theme's own sixteen
|
|
330
|
+
* **`ansiColors` is the theme's own sixteen colors**, the shades a terminal
|
|
331
331
|
* showing this theme draws `red`, `blue` and the rest in. `ColorSpec.parse("red")`
|
|
332
|
-
* is ANSI
|
|
332
|
+
* is ANSI color 1 under every theme; which red that is, is the theme's to say,
|
|
333
333
|
* as it is in Rich, where each `TerminalTheme` carries its own table.
|
|
334
334
|
*/
|
|
335
335
|
export declare class TerminalTheme extends TerminalColors {
|
|
@@ -339,15 +339,15 @@ export declare class TerminalTheme extends TerminalColors {
|
|
|
339
339
|
export declare const STANDARD_TABLE: ColorTable;
|
|
340
340
|
export declare const EIGHT_BIT_TABLE: ColorTable;
|
|
341
341
|
/**
|
|
342
|
-
* What a downgrade to 256
|
|
343
|
-
* indices 16–255. Indices 0–15 are the terminal's own ANSI
|
|
342
|
+
* What a downgrade to 256 colors may choose: the cube and the grey ramp,
|
|
343
|
+
* indices 16–255. Indices 0–15 are the terminal's own ANSI colors, which
|
|
344
344
|
* every theme redefines, so their RGB is unknown and a match against them is
|
|
345
345
|
* a guess; Python Rich never picks them either.
|
|
346
346
|
*/
|
|
347
347
|
export declare const EIGHT_BIT_DOWNGRADE_TABLE: ColorTable;
|
|
348
348
|
export declare const WINDOWS_TABLE: ColorTable;
|
|
349
349
|
/**
|
|
350
|
-
* The terminal a
|
|
350
|
+
* The terminal a color at `depth` is drawn by: `theme`, or when a caller names
|
|
351
351
|
* none, the one the depth assumes — the Windows console at WINDOWS, the VGA
|
|
352
352
|
* sixteen otherwise — for `ColorSpec.getTruecolor` and the contrast measurement
|
|
353
353
|
* that reads it. (Widgets fall back to `DEFAULT_TERMINAL_THEME`, which carries a
|
|
@@ -355,9 +355,9 @@ export declare const WINDOWS_TABLE: ColorTable;
|
|
|
355
355
|
*/
|
|
356
356
|
export declare function resolveTerminal(theme: TerminalColors | undefined, depth: ColorDepth): TerminalColors;
|
|
357
357
|
/**
|
|
358
|
-
* The table a downgrade to `depth` rounds a fixed
|
|
359
|
-
* [LAW:one-source-of-truth] `ColorSpec.downgrade` picks the index a
|
|
360
|
-
* written as from it, and colorMath hands back its entries as
|
|
358
|
+
* The table a downgrade to `depth` rounds a fixed color against.
|
|
359
|
+
* [LAW:one-source-of-truth] `ColorSpec.downgrade` picks the index a color is
|
|
360
|
+
* written as from it, and colorMath hands back its entries as colors the
|
|
361
361
|
* writer rounds to those same indices.
|
|
362
362
|
*/
|
|
363
363
|
export declare function downgradeTable(depth: ColorDepth.EIGHT_BIT | ColorDepth.STANDARD | ColorDepth.WINDOWS): ColorTable;
|