@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/render.d.ts
CHANGED
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
*
|
|
13
13
|
* [LAW:single-enforcer] The Segment-to-ANSI conversion lives in `segmentToString`
|
|
14
14
|
* and is the single way a segment becomes wire bytes. `segmentsToString` is
|
|
15
|
-
* that encoding joined, and `Console._writeSegments`, `
|
|
15
|
+
* that encoding joined, and `Console._writeSegments`, `Renderer` (every `Live`
|
|
16
16
|
* and `App` frame) and `renderToString` all go through it, so terminal output,
|
|
17
17
|
* live and app frames and string export agree by construction.
|
|
18
18
|
*
|
|
19
19
|
* [LAW:one-source-of-truth] What the encoding needs from where it writes
|
|
20
|
-
* arrives as one `
|
|
20
|
+
* arrives as one `OutputTarget` value. Each caller resolves its destination
|
|
21
21
|
* once — spec, detection, and its own overrides — and hands it through whole,
|
|
22
22
|
* so a depth is never paired with a link setting taken from somewhere else.
|
|
23
23
|
*
|
|
@@ -34,18 +34,18 @@
|
|
|
34
34
|
* cell lines do. A link split across segments still hovers as one link,
|
|
35
35
|
* because every pair it becomes carries the id `osc8Open` derives from the URL.
|
|
36
36
|
*
|
|
37
|
-
*
|
|
37
|
+
* Color and hyperlinks are two facts about the destination:
|
|
38
38
|
* `colorSystem === null` empties every segment's SGR codes, and
|
|
39
|
-
* `hyperlinks === false` drops every segment's link. A
|
|
40
|
-
* removes a link — a hyperlink is not a
|
|
39
|
+
* `hyperlinks === false` drops every segment's link. A color depth never
|
|
40
|
+
* removes a link — a hyperlink is not a color, and a NO_COLOR terminal still
|
|
41
41
|
* follows OSC 8. This is where the port departs from the reference, whose
|
|
42
|
-
* `Style.render` returns bare text for a null
|
|
42
|
+
* `Style.render` returns bare text for a null color system.
|
|
43
43
|
*
|
|
44
44
|
* The third fact, `reducedMotion`, changes the segment rather than its
|
|
45
45
|
* encoding: `shownOn` takes the style's blink out before it is encoded.
|
|
46
46
|
*/
|
|
47
47
|
import { ColorDepth } from "./color.js";
|
|
48
|
-
import type { ColorSystemName,
|
|
48
|
+
import type { ColorSystemName, OutputTarget } from "./color.js";
|
|
49
49
|
import type { Env } from "./env.js";
|
|
50
50
|
import { Segment } from "./segment.js";
|
|
51
51
|
import type { Renderable, RenderOptions } from "./protocol.js";
|
|
@@ -74,7 +74,7 @@ export interface RenderToStringOptions extends Pick<RenderOptions, "asciiOnly" |
|
|
|
74
74
|
noColor?: boolean;
|
|
75
75
|
/**
|
|
76
76
|
* Whether OSC 8 hyperlinks are emitted. Independent of `colorSystem`: a
|
|
77
|
-
* null
|
|
77
|
+
* null color system strips SGR and keeps links. Default: what the
|
|
78
78
|
* destination takes — true for an explicit depth, detected under `"auto"`
|
|
79
79
|
* (no TTY or TERM=dumb: false). `false` with `colorSystem: null` is plain text.
|
|
80
80
|
*/
|
|
@@ -89,17 +89,17 @@ export interface RenderToStringOptions extends Pick<RenderOptions, "asciiOnly" |
|
|
|
89
89
|
* what was drawn, after `render`. The encoder writes what this returns, and a
|
|
90
90
|
* recording console records it, so every export replays what was written.
|
|
91
91
|
*/
|
|
92
|
-
export declare function shownOn(segment: Segment, destination:
|
|
92
|
+
export declare function shownOn(segment: Segment, destination: OutputTarget): Segment;
|
|
93
93
|
/**
|
|
94
94
|
* Encodes one segment as ANSI bytes for `destination`: the reference's
|
|
95
95
|
* `Style.render` for that segment, and nothing for a control segment. It seals
|
|
96
96
|
* the segment alone, and a `logical` row's isolate spans its segments, so a row
|
|
97
97
|
* goes through `segmentsToString` whole.
|
|
98
98
|
*/
|
|
99
|
-
export declare function segmentToString(segment: Segment, destination:
|
|
99
|
+
export declare function segmentToString(segment: Segment, destination: OutputTarget): string;
|
|
100
100
|
/**
|
|
101
101
|
* Encodes a sequence of segments as ANSI bytes for `destination`, one segment
|
|
102
102
|
* at a time, over what `sealed` lets reach the wire.
|
|
103
103
|
*/
|
|
104
|
-
export declare function segmentsToString(segments: Iterable<Segment>, destination:
|
|
104
|
+
export declare function segmentsToString(segments: Iterable<Segment>, destination: OutputTarget): string;
|
|
105
105
|
export declare function renderToString(renderable: Renderable, options?: RenderToStringOptions): string;
|
package/dist/core/render.js
CHANGED
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
*
|
|
13
13
|
* [LAW:single-enforcer] The Segment-to-ANSI conversion lives in `segmentToString`
|
|
14
14
|
* and is the single way a segment becomes wire bytes. `segmentsToString` is
|
|
15
|
-
* that encoding joined, and `Console._writeSegments`, `
|
|
15
|
+
* that encoding joined, and `Console._writeSegments`, `Renderer` (every `Live`
|
|
16
16
|
* and `App` frame) and `renderToString` all go through it, so terminal output,
|
|
17
17
|
* live and app frames and string export agree by construction.
|
|
18
18
|
*
|
|
19
19
|
* [LAW:one-source-of-truth] What the encoding needs from where it writes
|
|
20
|
-
* arrives as one `
|
|
20
|
+
* arrives as one `OutputTarget` value. Each caller resolves its destination
|
|
21
21
|
* once — spec, detection, and its own overrides — and hands it through whole,
|
|
22
22
|
* so a depth is never paired with a link setting taken from somewhere else.
|
|
23
23
|
*
|
|
@@ -34,17 +34,17 @@
|
|
|
34
34
|
* cell lines do. A link split across segments still hovers as one link,
|
|
35
35
|
* because every pair it becomes carries the id `osc8Open` derives from the URL.
|
|
36
36
|
*
|
|
37
|
-
*
|
|
37
|
+
* Color and hyperlinks are two facts about the destination:
|
|
38
38
|
* `colorSystem === null` empties every segment's SGR codes, and
|
|
39
|
-
* `hyperlinks === false` drops every segment's link. A
|
|
40
|
-
* removes a link — a hyperlink is not a
|
|
39
|
+
* `hyperlinks === false` drops every segment's link. A color depth never
|
|
40
|
+
* removes a link — a hyperlink is not a color, and a NO_COLOR terminal still
|
|
41
41
|
* follows OSC 8. This is where the port departs from the reference, whose
|
|
42
|
-
* `Style.render` returns bare text for a null
|
|
42
|
+
* `Style.render` returns bare text for a null color system.
|
|
43
43
|
*
|
|
44
44
|
* The third fact, `reducedMotion`, changes the segment rather than its
|
|
45
45
|
* encoding: `shownOn` takes the style's blink out before it is encoded.
|
|
46
46
|
*/
|
|
47
|
-
import { ColorDepth,
|
|
47
|
+
import { ColorDepth, resolveOutputTarget } from "./color.js";
|
|
48
48
|
import { Segment } from "./segment.js";
|
|
49
49
|
import { render } from "./protocol.js";
|
|
50
50
|
import { OSC8_CLOSE, osc8Open } from "./osc8.js";
|
|
@@ -79,8 +79,8 @@ function encoded(segment, destination) {
|
|
|
79
79
|
// As the reference's `if not text` and `if style:` — no pair around nothing.
|
|
80
80
|
if (text.length === 0 || style === undefined)
|
|
81
81
|
return text;
|
|
82
|
-
// [LAW:one-type-per-behavior]
|
|
83
|
-
// their own fact. Coupling them let a
|
|
82
|
+
// [LAW:one-type-per-behavior] Color depth governs SGR only; hyperlinks are
|
|
83
|
+
// their own fact. Coupling them let a color setting delete every control.
|
|
84
84
|
const codes = destination.colorSystem === null ? "" : style.toSgrCodes(destination.colorSystem);
|
|
85
85
|
const styled = codes.length > 0 ? `\x1b[${codes}m${text}\x1b[0m` : text;
|
|
86
86
|
const link = destination.hyperlinks ? style.link : undefined;
|
|
@@ -100,7 +100,7 @@ export function renderToString(renderable, options) {
|
|
|
100
100
|
const width = options?.width ?? DEFAULT_WIDTH;
|
|
101
101
|
// [LAW:dataflow-not-control-flow] An absent spec is truecolor; an explicit
|
|
102
102
|
// `null` stays null (`??` would collapse it).
|
|
103
|
-
// [LAW:single-enforcer] Specs resolve through `
|
|
103
|
+
// [LAW:single-enforcer] Specs resolve through `resolveOutputTarget`.
|
|
104
104
|
// Stated, never detected: this call's bytes have no known destination, and
|
|
105
105
|
// its output is deterministic.
|
|
106
106
|
const destinationOptions = { reducedMotion: options?.reducedMotion, textOrder: options?.textOrder ?? "plain" };
|
|
@@ -109,10 +109,10 @@ export function renderToString(renderable, options) {
|
|
|
109
109
|
if (options?.isTTY !== undefined)
|
|
110
110
|
destinationOptions.isTTY = options.isTTY;
|
|
111
111
|
const rawSpec = options?.colorSystem;
|
|
112
|
-
const resolved =
|
|
112
|
+
const resolved = resolveOutputTarget(rawSpec === undefined ? ColorDepth.TRUECOLOR : rawSpec, destinationOptions);
|
|
113
113
|
// [LAW:single-enforcer] This call's overrides are applied here, once, to
|
|
114
114
|
// make the one destination everything below is drawn for. `noColor` is a
|
|
115
|
-
//
|
|
115
|
+
// color choice, so it overrides the depth and leaves hyperlinks to the
|
|
116
116
|
// destination; an explicit `hyperlinks` overrides what the destination takes.
|
|
117
117
|
const destination = {
|
|
118
118
|
...resolved,
|
package/dist/core/segment.d.ts
CHANGED
|
@@ -69,15 +69,15 @@ export declare class Segment {
|
|
|
69
69
|
* again: a frame of frames answers the next frame's start, a transition
|
|
70
70
|
* `t` until it is done, still content never.
|
|
71
71
|
*/
|
|
72
|
-
static
|
|
72
|
+
static validUntil(segments: Iterable<Segment>): number;
|
|
73
73
|
/**
|
|
74
74
|
* Since when what `segments` show has been what it is, on the same
|
|
75
75
|
* timeline: the latest `Style.hold` among them, the other end of the
|
|
76
|
-
* hold `
|
|
76
|
+
* hold `validUntil` reads — `t` for a frame something in moves every
|
|
77
77
|
* frame, `-Infinity` for one that always was. What a host running its
|
|
78
78
|
* timeline backwards asks before drawing again.
|
|
79
79
|
*/
|
|
80
|
-
static
|
|
80
|
+
static validFrom(segments: Iterable<Segment>): number;
|
|
81
81
|
/**
|
|
82
82
|
* The anchor of the cell at column `x` of row `y` in a composed frame, or
|
|
83
83
|
* `undefined` when that cell was drawn by no owner or lies outside the frame.
|
package/dist/core/segment.js
CHANGED
|
@@ -99,23 +99,23 @@ export class Segment {
|
|
|
99
99
|
* again: a frame of frames answers the next frame's start, a transition
|
|
100
100
|
* `t` until it is done, still content never.
|
|
101
101
|
*/
|
|
102
|
-
static
|
|
102
|
+
static validUntil(segments) {
|
|
103
103
|
let soonest = Number.POSITIVE_INFINITY;
|
|
104
104
|
for (const segment of segments)
|
|
105
|
-
soonest = Math.min(soonest, segment.style?.
|
|
105
|
+
soonest = Math.min(soonest, segment.style?.validity.validUntil ?? Number.POSITIVE_INFINITY);
|
|
106
106
|
return soonest;
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
109
|
* Since when what `segments` show has been what it is, on the same
|
|
110
110
|
* timeline: the latest `Style.hold` among them, the other end of the
|
|
111
|
-
* hold `
|
|
111
|
+
* hold `validUntil` reads — `t` for a frame something in moves every
|
|
112
112
|
* frame, `-Infinity` for one that always was. What a host running its
|
|
113
113
|
* timeline backwards asks before drawing again.
|
|
114
114
|
*/
|
|
115
|
-
static
|
|
115
|
+
static validFrom(segments) {
|
|
116
116
|
let latest = Number.NEGATIVE_INFINITY;
|
|
117
117
|
for (const segment of segments)
|
|
118
|
-
latest = Math.max(latest, segment.style?.
|
|
118
|
+
latest = Math.max(latest, segment.style?.validity.validFrom ?? Number.NEGATIVE_INFINITY);
|
|
119
119
|
return latest;
|
|
120
120
|
}
|
|
121
121
|
/**
|
package/dist/core/strip.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Strip +
|
|
2
|
+
* Strip + Separator — edge-aware horizontal layout primitive.
|
|
3
3
|
*
|
|
4
|
-
* A `Strip` renders a horizontal sequence of styled items with a `
|
|
4
|
+
* A `Strip` renders a horizontal sequence of styled items with a `Separator`
|
|
5
5
|
* deciding how each transition between adjacent items looks. The joiner is
|
|
6
6
|
* a pure function of `(leftItem | null, rightItem | null) -> Renderable`,
|
|
7
7
|
* so endpoint joins (the start and end of the strip) are explicit positions
|
|
@@ -35,12 +35,12 @@ import { type Measurable, type Renderable, type RenderOptions } from "./protocol
|
|
|
35
35
|
* transition glyph at each boundary.
|
|
36
36
|
*
|
|
37
37
|
* `edgeStyle("left", options)` reports the style of the item's leftmost cell
|
|
38
|
-
* column; `edgeStyle("right", options)` reports the rightmost.
|
|
38
|
+
* column; `edgeStyle("right", options)` reports the rightmost. Separators read
|
|
39
39
|
* only these — the item's interior may carry any per-column variation without
|
|
40
40
|
* breaking the join.
|
|
41
41
|
*
|
|
42
42
|
* The edge is asked in a render, with that render's options, because a style
|
|
43
|
-
* name only becomes a
|
|
43
|
+
* name only becomes a color against the render's theme. A joiner therefore
|
|
44
44
|
* reads edges inside the `render` of what it returns, never in `join`.
|
|
45
45
|
*/
|
|
46
46
|
export interface StyledRenderable extends Renderable {
|
|
@@ -56,7 +56,7 @@ export interface StyledRenderable extends Renderable {
|
|
|
56
56
|
export interface JoinContext {
|
|
57
57
|
readonly index: number;
|
|
58
58
|
}
|
|
59
|
-
export interface
|
|
59
|
+
export interface Separator<T extends StyledRenderable = StyledRenderable> {
|
|
60
60
|
/**
|
|
61
61
|
* `left === null` marks the start endpoint; `right === null` marks the end
|
|
62
62
|
* endpoint. The joiner decides what an endpoint looks like — typically
|
|
@@ -66,21 +66,21 @@ export interface Joiner<T extends StyledRenderable = StyledRenderable> {
|
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* The owner every cell a strip's joiner draws is stamped with
|
|
69
|
-
* (`Segment.anchorLines`), whatever the
|
|
69
|
+
* (`Segment.anchorLines`), whatever the separator: a seam is told by what drew
|
|
70
70
|
* it, never by its glyph, which an ASCII joiner draws otherwise and a lead may
|
|
71
71
|
* not draw at all. An effect reads it to leave a seam out of the words it
|
|
72
72
|
* keeps legible (`drawnOf`, `../renderables/effect.ts`).
|
|
73
73
|
*
|
|
74
|
-
* Inside it, every cell a `
|
|
74
|
+
* Inside it, every cell a `CellSeparator` draws is stamped with what it was
|
|
75
75
|
* resolved from (`JoinedCell`), so a cell whose neighbours an effect moves is
|
|
76
76
|
* resolved again from where they moved to.
|
|
77
77
|
*/
|
|
78
78
|
export declare const JOIN: object;
|
|
79
79
|
/**
|
|
80
|
-
* [LAW:single-enforcer] What `
|
|
80
|
+
* [LAW:single-enforcer] What `separator` draws at one join, every cell stamped
|
|
81
81
|
* as `JOIN`'s: the one way `Strip` and `FlexStrip` draw a join.
|
|
82
82
|
*/
|
|
83
|
-
export declare function drawJoin<T extends StyledRenderable>(
|
|
83
|
+
export declare function drawJoin<T extends StyledRenderable>(separator: Separator<T>, left: T | null, right: T | null, context: JoinContext): Renderable;
|
|
84
84
|
/**
|
|
85
85
|
* [LAW:single-enforcer] What `item` draws, every cell stamped as the item's,
|
|
86
86
|
* so whoever holds the composed row reads which item drew a cell however the
|
|
@@ -90,8 +90,8 @@ export declare function drawJoin<T extends StyledRenderable>(joiner: Joiner<T>,
|
|
|
90
90
|
export declare function drawItem(item: StyledRenderable): Renderable;
|
|
91
91
|
export declare class Strip<T extends StyledRenderable = StyledRenderable> implements Renderable, Measurable {
|
|
92
92
|
readonly items: readonly T[];
|
|
93
|
-
readonly
|
|
94
|
-
constructor(items: readonly T[],
|
|
93
|
+
readonly separator: Separator<T>;
|
|
94
|
+
constructor(items: readonly T[], separator: Separator<T>);
|
|
95
95
|
render(options: RenderOptions): Iterable<Segment>;
|
|
96
96
|
/**
|
|
97
97
|
* [LAW:one-source-of-truth] The width of the one row it draws, and that is
|
|
@@ -106,13 +106,13 @@ export declare class Strip<T extends StyledRenderable = StyledRenderable> implem
|
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
|
-
* A
|
|
109
|
+
* A color a joiner's cell is drawn in. Each variant names where the color
|
|
110
110
|
* comes from when the join is drawn:
|
|
111
111
|
* • an `edge` — a neighbour's ground (`bg`) or text (`fg`) at the column
|
|
112
112
|
* facing the join, read through `StyledRenderable.edgeStyle`;
|
|
113
113
|
* • a `role` — a style name, resolved against the render's theme, whose
|
|
114
|
-
* foreground
|
|
115
|
-
* • a `mix` — two
|
|
114
|
+
* foreground color is the color;
|
|
115
|
+
* • a `mix` — two colors blended at `t` (0 is the first, 1 the second).
|
|
116
116
|
*/
|
|
117
117
|
export type Paint = {
|
|
118
118
|
readonly edge: "left" | "right";
|
|
@@ -123,11 +123,11 @@ export type Paint = {
|
|
|
123
123
|
readonly mix: readonly [Paint, Paint, number];
|
|
124
124
|
};
|
|
125
125
|
/**
|
|
126
|
-
* A `Paint`, or `"ground"`: the terminal's own background, whose
|
|
126
|
+
* A `Paint`, or `"ground"`: the terminal's own background, whose color nobody
|
|
127
127
|
* knows. That is why it is never mixed (`Paint` excludes it), and why a cell
|
|
128
128
|
* may put it on one side only. As a cell's `fg` it is drawn in reverse video —
|
|
129
129
|
* the glyph's ink shows the terminal's background through a cell filled with
|
|
130
|
-
* the `bg`
|
|
130
|
+
* the `bg` color — so an inverted shape is the same glyph, never a glyph of
|
|
131
131
|
* its own.
|
|
132
132
|
*/
|
|
133
133
|
export type CellColor = Paint | "ground";
|
|
@@ -137,7 +137,7 @@ export type CellColor = Paint | "ground";
|
|
|
137
137
|
* measure a join by rendering it. Which member stands is hashed from the
|
|
138
138
|
* join's part, its `index` and the cell's place in it, so it holds still from
|
|
139
139
|
* frame to frame while the items before it do, and differs from seam to seam
|
|
140
|
-
* even between the same two
|
|
140
|
+
* even between the same two colors.
|
|
141
141
|
*/
|
|
142
142
|
export interface JoinCell {
|
|
143
143
|
readonly glyph: string | {
|
|
@@ -175,15 +175,15 @@ export interface CapsForm {
|
|
|
175
175
|
readonly tail: readonly JoinCell[];
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
178
|
-
* The middle of a
|
|
178
|
+
* The middle of a separator: its seam, and the `ascii` seam an ASCII-only output
|
|
179
179
|
* draws instead. Picked apart from the caps, so any seam ends in any caps.
|
|
180
180
|
*/
|
|
181
|
-
export interface
|
|
181
|
+
export interface SeparatorSeam {
|
|
182
182
|
readonly glyph: SeamForm;
|
|
183
183
|
readonly ascii: SeamForm;
|
|
184
184
|
}
|
|
185
|
-
/** The ends of a
|
|
186
|
-
export interface
|
|
185
|
+
/** The ends of a separator: its caps, and the `ascii` caps an ASCII-only output draws instead. */
|
|
186
|
+
export interface EndCaps {
|
|
187
187
|
readonly glyph: CapsForm;
|
|
188
188
|
readonly ascii: CapsForm;
|
|
189
189
|
}
|
|
@@ -219,19 +219,19 @@ export interface EdgeMove {
|
|
|
219
219
|
readonly bgcolor?: ColorSpec;
|
|
220
220
|
}
|
|
221
221
|
/**
|
|
222
|
-
* A cell a `
|
|
222
|
+
* A cell a `CellSeparator` drew, as what it is: one function of its two
|
|
223
223
|
* neighbours' edges. It holds the cell's paints, the neighbour each side of
|
|
224
224
|
* them reads, and the edges and render it was resolved from, and it is stamped
|
|
225
225
|
* on the cell as the owner of its innermost anchor level.
|
|
226
226
|
*
|
|
227
|
-
* [LAW:one-source-of-truth] A seam's
|
|
227
|
+
* [LAW:one-source-of-truth] A seam's colors are its neighbours', so nothing
|
|
228
228
|
* paints them but this resolution. An effect paints a strip's items and never
|
|
229
229
|
* a join cell that `follows` them; once the items are painted, each such cell
|
|
230
230
|
* is handed what moved at the item cells beside it and resolved again through
|
|
231
231
|
* `cellStyle`, the path the join was drawn by, lift included
|
|
232
232
|
* (`../renderables/effect.ts`). A seam then follows its neighbours wherever an
|
|
233
233
|
* effect takes them, a mix of the two included, and an effect that paints
|
|
234
|
-
* both one
|
|
234
|
+
* both one color leaves the seam's ink lifted off it. A cell painted from
|
|
235
235
|
* roles and the terminal's ground alone, as `plain`'s separator is, follows
|
|
236
236
|
* nobody, and an effect paints it as it paints any cell.
|
|
237
237
|
*/
|
|
@@ -272,11 +272,11 @@ export declare class JoinedCell {
|
|
|
272
272
|
readonly style: Style;
|
|
273
273
|
} | undefined;
|
|
274
274
|
}
|
|
275
|
-
/** The record a `
|
|
275
|
+
/** The record a `CellSeparator` stamped on the cell `anchor` names, or none for a cell no `CellSeparator` drew. */
|
|
276
276
|
export declare function joinedCell(anchor: Anchor | undefined): JoinedCell | undefined;
|
|
277
277
|
/**
|
|
278
|
-
* The one
|
|
279
|
-
* `
|
|
278
|
+
* The one separator: what it draws is a `SeparatorSeam` between neighbours and a
|
|
279
|
+
* `EndCaps` at the ends of each run, picked independently, so a new joiner is
|
|
280
280
|
* a pair of values, never a class.
|
|
281
281
|
*
|
|
282
282
|
* Which part a join draws is read off its two neighbours. A neighbour is
|
|
@@ -291,11 +291,11 @@ export declare function joinedCell(anchor: Anchor | undefined): JoinedCell | und
|
|
|
291
291
|
*
|
|
292
292
|
* An ASCII-only output draws the `ascii` form of both, whole.
|
|
293
293
|
*/
|
|
294
|
-
export declare class
|
|
295
|
-
readonly seam:
|
|
296
|
-
readonly caps:
|
|
294
|
+
export declare class CellSeparator<T extends StyledRenderable = StyledRenderable> implements Separator<T> {
|
|
295
|
+
readonly seam: SeparatorSeam;
|
|
296
|
+
readonly caps: EndCaps;
|
|
297
297
|
private readonly _forms;
|
|
298
|
-
constructor(seam:
|
|
298
|
+
constructor(seam: SeparatorSeam, caps: EndCaps);
|
|
299
299
|
join(left: T | null, right: T | null, { index }: JoinContext): Renderable;
|
|
300
300
|
}
|
|
301
301
|
/**
|
|
@@ -303,65 +303,65 @@ export declare class CellJoiner<T extends StyledRenderable = StyledRenderable> i
|
|
|
303
303
|
* What each draws is `docs/strip.md`'s "Seams"; any of them ends in any of
|
|
304
304
|
* `CAPS`.
|
|
305
305
|
*/
|
|
306
|
-
export declare const
|
|
307
|
-
powerline:
|
|
308
|
-
prism:
|
|
309
|
-
slant:
|
|
310
|
-
backslant:
|
|
311
|
-
flame:
|
|
312
|
-
pixel:
|
|
313
|
-
ice:
|
|
314
|
-
bubble:
|
|
315
|
-
capsule:
|
|
316
|
-
wrapper:
|
|
317
|
-
metro:
|
|
318
|
-
stitch:
|
|
319
|
-
torn:
|
|
320
|
-
plain:
|
|
306
|
+
export declare const SEPARATORS: Readonly<{
|
|
307
|
+
powerline: SeparatorSeam;
|
|
308
|
+
prism: SeparatorSeam;
|
|
309
|
+
slant: SeparatorSeam;
|
|
310
|
+
backslant: SeparatorSeam;
|
|
311
|
+
flame: SeparatorSeam;
|
|
312
|
+
pixel: SeparatorSeam;
|
|
313
|
+
ice: SeparatorSeam;
|
|
314
|
+
bubble: SeparatorSeam;
|
|
315
|
+
capsule: SeparatorSeam;
|
|
316
|
+
wrapper: SeparatorSeam;
|
|
317
|
+
metro: SeparatorSeam;
|
|
318
|
+
stitch: SeparatorSeam;
|
|
319
|
+
torn: SeparatorSeam;
|
|
320
|
+
plain: SeparatorSeam;
|
|
321
321
|
}>;
|
|
322
322
|
/**
|
|
323
323
|
* The bundled caps, by name: what a joiner draws where a run begins and ends.
|
|
324
324
|
* What each draws is `docs/strip.md`'s "Caps"; any of them ends any of
|
|
325
|
-
* `
|
|
325
|
+
* `SEPARATORS`.
|
|
326
326
|
*/
|
|
327
|
-
export declare const
|
|
328
|
-
powerline:
|
|
329
|
-
slant:
|
|
330
|
-
backslant:
|
|
331
|
-
flame:
|
|
332
|
-
pixel:
|
|
333
|
-
ice:
|
|
334
|
-
bubble:
|
|
335
|
-
capsule:
|
|
336
|
-
wrapper:
|
|
337
|
-
flat:
|
|
327
|
+
export declare const END_CAPS: Readonly<{
|
|
328
|
+
powerline: EndCaps;
|
|
329
|
+
slant: EndCaps;
|
|
330
|
+
backslant: EndCaps;
|
|
331
|
+
flame: EndCaps;
|
|
332
|
+
pixel: EndCaps;
|
|
333
|
+
ice: EndCaps;
|
|
334
|
+
bubble: EndCaps;
|
|
335
|
+
capsule: EndCaps;
|
|
336
|
+
wrapper: EndCaps;
|
|
337
|
+
flat: EndCaps;
|
|
338
338
|
}>;
|
|
339
339
|
/**
|
|
340
|
-
* The bundled joiners, by name: each a seam from `
|
|
340
|
+
* The bundled joiners, by name: each a seam from `SEPARATORS` ended in caps from
|
|
341
341
|
* `CAPS`. What each draws is `docs/strip.md`'s "Built-in joiners"; a name from
|
|
342
|
-
* config is read with `
|
|
342
|
+
* config is read with `separatorNamed`.
|
|
343
343
|
*/
|
|
344
|
-
export declare const
|
|
345
|
-
powerline:
|
|
346
|
-
prism:
|
|
347
|
-
slant:
|
|
348
|
-
backslant:
|
|
349
|
-
flame:
|
|
350
|
-
pixel:
|
|
351
|
-
ice:
|
|
352
|
-
bubble:
|
|
353
|
-
capsule:
|
|
354
|
-
wrapper:
|
|
355
|
-
metro:
|
|
356
|
-
stitch:
|
|
357
|
-
torn:
|
|
358
|
-
plain:
|
|
344
|
+
export declare const SEPARATOR_STYLES: Readonly<{
|
|
345
|
+
powerline: CellSeparator<StyledRenderable>;
|
|
346
|
+
prism: CellSeparator<StyledRenderable>;
|
|
347
|
+
slant: CellSeparator<StyledRenderable>;
|
|
348
|
+
backslant: CellSeparator<StyledRenderable>;
|
|
349
|
+
flame: CellSeparator<StyledRenderable>;
|
|
350
|
+
pixel: CellSeparator<StyledRenderable>;
|
|
351
|
+
ice: CellSeparator<StyledRenderable>;
|
|
352
|
+
bubble: CellSeparator<StyledRenderable>;
|
|
353
|
+
capsule: CellSeparator<StyledRenderable>;
|
|
354
|
+
wrapper: CellSeparator<StyledRenderable>;
|
|
355
|
+
metro: CellSeparator<StyledRenderable>;
|
|
356
|
+
stitch: CellSeparator<StyledRenderable>;
|
|
357
|
+
torn: CellSeparator<StyledRenderable>;
|
|
358
|
+
plain: CellSeparator<StyledRenderable>;
|
|
359
359
|
}>;
|
|
360
360
|
/**
|
|
361
|
-
* A joiner as config names it: one of `
|
|
361
|
+
* A joiner as config names it: one of `SEPARATOR_STYLES`, or a seam from `SEPARATORS` ended
|
|
362
362
|
* in caps from `CAPS`, each named apart.
|
|
363
363
|
*/
|
|
364
|
-
export type
|
|
364
|
+
export type SeparatorSpec = string | {
|
|
365
365
|
readonly seam: string;
|
|
366
366
|
readonly caps: string;
|
|
367
367
|
};
|
|
@@ -370,17 +370,17 @@ export type JoinerSpec = string | {
|
|
|
370
370
|
* name its table lacks, naming the ones there are; an own-key test, so
|
|
371
371
|
* `toString` and the rest of `Object.prototype` are no one's name.
|
|
372
372
|
*/
|
|
373
|
-
export declare function
|
|
373
|
+
export declare function separatorNamed(spec: SeparatorSpec): CellSeparator;
|
|
374
374
|
/**
|
|
375
375
|
* A ramp of `steps` cells from the left ground to the right, each cell filled
|
|
376
|
-
* with one
|
|
376
|
+
* with one color: cell `i` is the color `(i + 1/2) / steps` of the way
|
|
377
377
|
* across, so no cell is either neighbour's ground. A cell is a space whose ink
|
|
378
|
-
* is the terminal's ground, so its one
|
|
379
|
-
* Beside a neighbour with no ground there is no
|
|
378
|
+
* is the terminal's ground, so its one color is its fill, the same in ASCII.
|
|
379
|
+
* Beside a neighbour with no ground there is no color to ramp toward, so that
|
|
380
380
|
* join draws the caps the ramp is ended in.
|
|
381
381
|
*
|
|
382
382
|
* [LAW:dataflow-not-control-flow] A ramp cell is fill alone: a space has no
|
|
383
|
-
* ink, and `"ground"` as its `fg` is the absence of a
|
|
383
|
+
* ink, and `"ground"` as its `fg` is the absence of a color on that side
|
|
384
384
|
* (`cellStyle`). So the lift, the path every seam cell is drawn by, has no ink
|
|
385
385
|
* to hold off its ground, and the ramp is the blend, monotone however close
|
|
386
386
|
* its grounds or however many its steps. Two samples to a cell, ink over
|
|
@@ -388,5 +388,5 @@ export declare function joinerNamed(spec: JoinerSpec): CellJoiner;
|
|
|
388
388
|
* `steps` such cells rise without turning back only between grounds `steps`
|
|
389
389
|
* floors apart.
|
|
390
390
|
*/
|
|
391
|
-
export declare function gradientSeam(steps?: number):
|
|
391
|
+
export declare function gradientSeam(steps?: number): SeparatorSeam;
|
|
392
392
|
export {};
|