@promptctl/rich-js 0.18.1 → 0.20.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 +11 -8
- package/dist/core/box.d.ts +3 -1
- package/dist/core/box.js +6 -13
- package/dist/core/cells.d.ts +61 -28
- package/dist/core/cells.js +171 -124
- package/dist/core/clock.d.ts +48 -0
- package/dist/core/clock.js +42 -0
- package/dist/core/color.d.ts +99 -18
- package/dist/core/color.js +334 -146
- package/dist/core/console.d.ts +38 -7
- package/dist/core/console.js +159 -90
- package/dist/core/easing.d.ts +86 -0
- package/dist/core/easing.js +171 -0
- package/dist/core/env.d.ts +16 -0
- package/dist/core/env.js +16 -0
- package/dist/core/export-html.js +1 -4
- package/dist/core/export-lines.d.ts +22 -13
- package/dist/core/export-lines.js +37 -19
- package/dist/core/export-svg.d.ts +49 -0
- package/dist/core/export-svg.js +213 -0
- package/dist/core/fnv1a.d.ts +10 -0
- package/dist/core/fnv1a.js +17 -0
- package/dist/core/highlighter.d.ts +2 -2
- package/dist/core/highlighter.js +113 -47
- package/dist/core/json.js +1 -1
- package/dist/core/markup.d.ts +28 -7
- package/dist/core/markup.js +235 -312
- package/dist/core/measure.d.ts +3 -3
- package/dist/core/measure.js +12 -7
- package/dist/core/memo.d.ts +19 -0
- package/dist/core/memo.js +34 -0
- package/dist/core/noise.d.ts +31 -0
- package/dist/core/noise.js +94 -0
- package/dist/core/osc8.d.ts +6 -6
- package/dist/core/osc8.js +9 -21
- package/dist/core/paint.d.ts +107 -0
- package/dist/core/paint.js +161 -0
- package/dist/core/place.d.ts +1 -1
- package/dist/core/place.js +4 -6
- package/dist/core/pretty.d.ts +126 -2
- package/dist/core/pretty.js +571 -105
- package/dist/core/protocol.d.ts +43 -3
- package/dist/core/protocol.js +23 -2
- package/dist/core/render.d.ts +33 -30
- package/dist/core/render.js +43 -83
- package/dist/core/segment.d.ts +6 -5
- package/dist/core/segment.js +11 -15
- package/dist/core/selection.d.ts +12 -0
- package/dist/core/selection.js +14 -0
- package/dist/core/strip.d.ts +116 -74
- package/dist/core/strip.js +266 -217
- package/dist/core/style.d.ts +27 -7
- package/dist/core/style.js +106 -41
- package/dist/core/text.d.ts +43 -16
- package/dist/core/text.js +180 -59
- package/dist/core/wrap.d.ts +5 -0
- package/dist/core/wrap.js +16 -3
- package/dist/host/app.d.ts +95 -17
- package/dist/host/app.js +201 -61
- package/dist/host/index.d.ts +4 -1
- package/dist/host/index.js +1 -0
- package/dist/host/input.d.ts +84 -0
- package/dist/host/input.js +498 -0
- package/dist/host/terminal-host.d.ts +15 -2
- package/dist/host/terminal-host.js +2 -0
- package/dist/index.d.ts +26 -14
- package/dist/index.js +17 -7
- package/dist/node/prompt.d.ts +13 -0
- package/dist/node/prompt.js +30 -9
- package/dist/node/save.d.ts +4 -3
- package/dist/node/save.js +6 -3
- package/dist/node/terminal-host.d.ts +10 -2
- package/dist/node/terminal-host.js +7 -0
- package/dist/node/traceback.d.ts +2 -1
- package/dist/node/traceback.js +3 -39
- package/dist/renderables/align.js +2 -9
- package/dist/renderables/columns.d.ts +45 -29
- package/dist/renderables/columns.js +142 -103
- package/dist/renderables/constrain.js +6 -12
- package/dist/renderables/effect.d.ts +113 -0
- package/dist/renderables/effect.js +182 -0
- package/dist/renderables/effects.d.ts +252 -0
- package/dist/renderables/effects.js +565 -0
- package/dist/renderables/embed.d.ts +94 -31
- package/dist/renderables/embed.js +141 -45
- package/dist/renderables/group.d.ts +6 -3
- package/dist/renderables/group.js +5 -0
- package/dist/renderables/layout.d.ts +6 -23
- package/dist/renderables/layout.js +24 -113
- package/dist/renderables/list-view.d.ts +42 -0
- package/dist/renderables/list-view.js +78 -0
- package/dist/renderables/live.d.ts +40 -16
- package/dist/renderables/live.js +96 -83
- package/dist/renderables/markdown.d.ts +16 -2
- package/dist/renderables/markdown.js +521 -118
- package/dist/renderables/padding.d.ts +22 -1
- package/dist/renderables/padding.js +30 -24
- package/dist/renderables/panel.d.ts +31 -33
- package/dist/renderables/panel.js +137 -141
- package/dist/renderables/progress.d.ts +110 -16
- package/dist/renderables/progress.js +212 -81
- package/dist/renderables/progressBar.d.ts +24 -4
- package/dist/renderables/progressBar.js +78 -23
- package/dist/renderables/prompt.d.ts +37 -15
- package/dist/renderables/prompt.js +125 -85
- package/dist/renderables/ratio.d.ts +123 -0
- package/dist/renderables/ratio.js +213 -0
- package/dist/renderables/rule.d.ts +3 -2
- package/dist/renderables/rule.js +50 -52
- package/dist/renderables/spinner.d.ts +28 -2
- package/dist/renderables/spinner.js +52 -19
- package/dist/renderables/status.d.ts +13 -7
- package/dist/renderables/status.js +15 -29
- package/dist/renderables/syntax.d.ts +37 -7
- package/dist/renderables/syntax.js +134 -83
- package/dist/renderables/table.d.ts +58 -20
- package/dist/renderables/table.js +373 -197
- package/dist/renderables/traceback.d.ts +5 -4
- package/dist/renderables/traceback.js +239 -68
- package/dist/renderables/tree.d.ts +10 -2
- package/dist/renderables/tree.js +61 -34
- package/dist/renderables/viewport.d.ts +30 -0
- package/dist/renderables/viewport.js +61 -7
- package/dist/template-bindings/color-funcs.d.ts +31 -9
- package/dist/template-bindings/color-funcs.js +40 -14
- package/dist/template-bindings/helpers.d.ts +4 -2
- package/dist/template-bindings/helpers.js +5 -20
- package/dist/template-bindings/index.d.ts +29 -17
- package/dist/template-bindings/index.js +36 -20
- package/dist/template-bindings/palette-funcs.d.ts +3 -1
- package/dist/template-bindings/palette-funcs.js +11 -7
- package/dist/template-bindings/style-funcs.js +4 -2
- package/dist/themes/buildPalette.d.ts +24 -3
- package/dist/themes/buildPalette.js +52 -8
- package/dist/themes/colorMath.d.ts +29 -17
- package/dist/themes/colorMath.js +74 -48
- package/dist/themes/colorRef.d.ts +2 -17
- package/dist/themes/colorRef.js +13 -31
- package/dist/themes/palette.d.ts +24 -0
- package/dist/themes/palette.js +46 -3
- package/dist/themes/ramp.d.ts +21 -34
- package/dist/themes/ramp.js +23 -42
- package/dist/themes/registry.js +39 -28
- package/dist/widgets/button.d.ts +2 -6
- package/dist/widgets/button.js +9 -40
- package/dist/widgets/checkbox.d.ts +2 -5
- package/dist/widgets/checkbox.js +9 -31
- package/dist/widgets/dropdown.d.ts +2 -5
- package/dist/widgets/dropdown.js +17 -51
- package/dist/widgets/event-router.d.ts +31 -40
- package/dist/widgets/event-router.js +52 -483
- package/dist/widgets/index.d.ts +2 -1
- package/dist/widgets/ink.d.ts +22 -0
- package/dist/widgets/ink.js +31 -0
- package/dist/widgets/slider.d.ts +2 -5
- package/dist/widgets/slider.js +11 -34
- package/dist/widgets/text-input.d.ts +19 -10
- package/dist/widgets/text-input.js +156 -147
- package/dist/widgets/themed-widget.d.ts +20 -0
- package/dist/widgets/themed-widget.js +89 -0
- package/dist/widgets/toggle.d.ts +2 -5
- package/dist/widgets/toggle.js +8 -31
- package/dist/widgets/types.d.ts +8 -25
- package/dist/widgets/types.js +8 -0
- package/dist/widgets/widget-app.d.ts +24 -7
- package/dist/widgets/widget-app.js +35 -18
- package/dist/widgets/widget-base.d.ts +2 -0
- package/dist/widgets/widget-base.js +9 -2
- package/package.json +31 -17
package/dist/core/strip.d.ts
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
*/
|
|
28
28
|
import { Segment } from "./segment.js";
|
|
29
29
|
import { Style } from "./style.js";
|
|
30
|
-
import { type Renderable, type RenderOptions } from "./protocol.js";
|
|
30
|
+
import { type Measurable, type Renderable, type RenderOptions } from "./protocol.js";
|
|
31
31
|
/**
|
|
32
32
|
* Items in a `Strip` expose their per-edge style so joiners can paint the
|
|
33
33
|
* transition glyph at each boundary.
|
|
@@ -52,90 +52,132 @@ export interface Joiner<T extends StyledRenderable = StyledRenderable> {
|
|
|
52
52
|
*/
|
|
53
53
|
join(left: T | null, right: T | null): Renderable;
|
|
54
54
|
}
|
|
55
|
-
export declare class Strip<T extends StyledRenderable = StyledRenderable> implements Renderable {
|
|
55
|
+
export declare class Strip<T extends StyledRenderable = StyledRenderable> implements Renderable, Measurable {
|
|
56
56
|
readonly items: readonly T[];
|
|
57
57
|
readonly joiner: Joiner<T>;
|
|
58
58
|
constructor(items: readonly T[], joiner: Joiner<T>);
|
|
59
59
|
render(options: RenderOptions): Iterable<Segment>;
|
|
60
|
+
/**
|
|
61
|
+
* [LAW:one-source-of-truth] The width of the one row it draws, and that is
|
|
62
|
+
* both bounds: the row never wraps and no item is offered less than the whole
|
|
63
|
+
* width, so there is no narrower strip to report as a minimum. Read off the
|
|
64
|
+
* drawing rather than summed from the items' measurements, which describe
|
|
65
|
+
* how an item could be drawn, not how the walk draws it.
|
|
66
|
+
*/
|
|
67
|
+
measure(options: RenderOptions): {
|
|
68
|
+
minimum: number;
|
|
69
|
+
maximum: number;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A colour a joiner's cell is drawn in. Each variant names where the colour
|
|
74
|
+
* comes from when the join is drawn:
|
|
75
|
+
* • an `edge` — a neighbour's ground (`bg`) or text (`fg`) at the column
|
|
76
|
+
* facing the join, read through `StyledRenderable.edgeStyle`;
|
|
77
|
+
* • a `role` — a style name, resolved against the render's theme, whose
|
|
78
|
+
* foreground colour is the colour;
|
|
79
|
+
* • a `mix` — two colours blended at `t` (0 is the first, 1 the second).
|
|
80
|
+
*/
|
|
81
|
+
export type Paint = {
|
|
82
|
+
readonly edge: "left" | "right";
|
|
83
|
+
readonly part: "bg" | "fg";
|
|
84
|
+
} | {
|
|
85
|
+
readonly role: string;
|
|
86
|
+
} | {
|
|
87
|
+
readonly mix: readonly [Paint, Paint, number];
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* A `Paint`, or `"ground"`: the terminal's own background, whose colour nobody
|
|
91
|
+
* knows. That is why it is never mixed (`Paint` excludes it), and why a cell
|
|
92
|
+
* may put it on one side only. As a cell's `fg` it is drawn in reverse video —
|
|
93
|
+
* the glyph's ink shows the terminal's background through a cell filled with
|
|
94
|
+
* the `bg` colour — so an inverted shape is the same glyph, never a glyph of
|
|
95
|
+
* its own.
|
|
96
|
+
*/
|
|
97
|
+
export type CellColor = Paint | "ground";
|
|
98
|
+
/**
|
|
99
|
+
* One styled run of a join. A `oneOf` glyph is a set any member of which may
|
|
100
|
+
* stand in the cell; every member has the same width, because consumers
|
|
101
|
+
* measure a join by rendering it.
|
|
102
|
+
*/
|
|
103
|
+
export interface JoinCell {
|
|
104
|
+
readonly glyph: string | {
|
|
105
|
+
readonly oneOf: readonly string[];
|
|
106
|
+
};
|
|
107
|
+
readonly fg: CellColor;
|
|
108
|
+
readonly bg: CellColor;
|
|
60
109
|
}
|
|
61
110
|
/**
|
|
62
|
-
* The
|
|
63
|
-
*
|
|
64
|
-
*
|
|
111
|
+
* The cells a joiner draws at each kind of join:
|
|
112
|
+
* • `seam` — between two neighbours;
|
|
113
|
+
* • `divider` — in the seam's place where the two grounds are drawn as one
|
|
114
|
+
* colour (see `SEAM_MIN_DELTA_E`), so the seam would vanish into them;
|
|
115
|
+
* the same width as `seam`;
|
|
116
|
+
* • `lead` — where a run is entered from nothing: the strip's start, or a
|
|
117
|
+
* neighbour with no ground for the seam to paint. It cannot name `left`;
|
|
118
|
+
* • `tail` — where a run leaves into nothing. It cannot name `right`.
|
|
119
|
+
*/
|
|
120
|
+
export interface JoinShape {
|
|
121
|
+
readonly seam: readonly JoinCell[];
|
|
122
|
+
readonly divider: readonly JoinCell[];
|
|
123
|
+
readonly lead: readonly JoinCell[];
|
|
124
|
+
readonly tail: readonly JoinCell[];
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The least ΔE_OK two neighbouring backgrounds must differ by for a seam drawn
|
|
128
|
+
* between them to be seen. Below it the seam is drawn in a colour the eye
|
|
129
|
+
* cannot tell from its own background, so the joiner draws the divider
|
|
65
130
|
* instead. Twice the ~.02 threshold of a visible difference, because a seam is
|
|
66
131
|
* one cell wide.
|
|
67
132
|
*/
|
|
68
133
|
export declare const SEAM_MIN_DELTA_E = 0.04;
|
|
69
|
-
export interface PowerlineJoinerOptions {
|
|
70
|
-
/** Glyph for every join between two coloured items. */
|
|
71
|
-
glyph: string;
|
|
72
|
-
/**
|
|
73
|
-
* Glyph drawn between neighbours whose backgrounds the eye cannot tell apart,
|
|
74
|
-
* in the left item's text colour — the arrow itself would vanish into the
|
|
75
|
-
* shared background.
|
|
76
|
-
*/
|
|
77
|
-
divider: string;
|
|
78
|
-
/**
|
|
79
|
-
* Glyph for every join a coloured item is entered from nothing — the strip's
|
|
80
|
-
* start, or a colourless left neighbour — painted in the right item's
|
|
81
|
-
* background. `""` begins a coloured run flat.
|
|
82
|
-
*/
|
|
83
|
-
lead: string;
|
|
84
|
-
/**
|
|
85
|
-
* Glyph for every join a coloured item leaves into nothing — the strip's end,
|
|
86
|
-
* or a colourless right neighbour — painted in the left item's background.
|
|
87
|
-
* `""` ends a coloured run flat.
|
|
88
|
-
*/
|
|
89
|
-
tail: string;
|
|
90
|
-
}
|
|
91
134
|
/**
|
|
92
|
-
* The
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* the
|
|
97
|
-
* with
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
135
|
+
* The one joiner: what it draws at each join is the `JoinShape` it is given,
|
|
136
|
+
* so a new joiner is a value, never a class.
|
|
137
|
+
*
|
|
138
|
+
* Which part a join draws is read off its two neighbours. A neighbour is
|
|
139
|
+
* missing at the strip's ends, and counts as missing — an endpoint — when the
|
|
140
|
+
* shape paints with its ground anywhere and it has none to paint. With both present the
|
|
141
|
+
* join is the seam, or the divider where the two grounds are drawn as one
|
|
142
|
+
* colour at `options.colorSystem`; with only the right, the lead; with only
|
|
143
|
+
* the left, the tail; with neither, nothing.
|
|
144
|
+
*
|
|
145
|
+
* `ascii` is the shape an ASCII-only output draws instead, whole.
|
|
101
146
|
*/
|
|
102
|
-
export declare
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
export interface CapsuleJoinerOptions {
|
|
109
|
-
/** Left-cap glyph (default: U+E0B6, powerline rounded left). */
|
|
110
|
-
left?: string;
|
|
111
|
-
/** Right-cap glyph (default: U+E0B4, powerline rounded right). */
|
|
112
|
-
right?: string;
|
|
113
|
-
/** Separator inserted between adjacent capsules in the middle position. */
|
|
114
|
-
separator?: string;
|
|
115
|
-
}
|
|
116
|
-
export declare class CapsuleJoiner<T extends StyledRenderable = StyledRenderable> implements Joiner<T> {
|
|
117
|
-
private readonly _caps;
|
|
118
|
-
private readonly _separator;
|
|
119
|
-
constructor(options?: CapsuleJoinerOptions);
|
|
120
|
-
_emit(left: T | null, right: T | null, options: RenderOptions): Iterable<Segment>;
|
|
121
|
-
join(left: T | null, right: T | null): Renderable;
|
|
122
|
-
}
|
|
123
|
-
export interface PlainJoinerOptions {
|
|
124
|
-
separator?: string;
|
|
125
|
-
style?: Style;
|
|
126
|
-
}
|
|
127
|
-
export declare class PlainJoiner<T extends StyledRenderable = StyledRenderable> implements Joiner<T> {
|
|
128
|
-
private readonly _separator;
|
|
129
|
-
private readonly _style;
|
|
130
|
-
constructor(options?: PlainJoinerOptions);
|
|
131
|
-
join(left: T | null, right: T | null): Renderable;
|
|
132
|
-
}
|
|
133
|
-
export interface GradientJoinerOptions {
|
|
134
|
-
/** Number of cells between adjacent items (default: 4). */
|
|
135
|
-
steps?: number;
|
|
136
|
-
}
|
|
137
|
-
export declare class GradientJoiner<T extends StyledRenderable = StyledRenderable> implements Joiner<T> {
|
|
138
|
-
private readonly _steps;
|
|
139
|
-
constructor(options?: GradientJoinerOptions);
|
|
147
|
+
export declare class CellJoiner<T extends StyledRenderable = StyledRenderable> implements Joiner<T> {
|
|
148
|
+
readonly shape: JoinShape;
|
|
149
|
+
readonly ascii: JoinShape;
|
|
150
|
+
private readonly _forms;
|
|
151
|
+
constructor(shape: JoinShape, ascii: JoinShape);
|
|
140
152
|
join(left: T | null, right: T | null): Renderable;
|
|
141
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* The powerline joiner: U+E0B0 (right-arrow) in the left ground over the
|
|
156
|
+
* right, divided by U+E0B1 (thin right-arrow) in the left item's text. The
|
|
157
|
+
* lead is the arrow with the left ground replaced by the terminal's — drawn
|
|
158
|
+
* in reverse video it leaves a notch whose base is the cell's left edge, inked
|
|
159
|
+
* in the terminal's background colour. That ink is opaque, so under a
|
|
160
|
+
* translucent terminal the notch does not let what is behind it through. The
|
|
161
|
+
* tail is the arrow over the terminal's ground.
|
|
162
|
+
* ASCII draws `>` everywhere and begins each run flat.
|
|
163
|
+
*/
|
|
164
|
+
export declare const POWERLINE_JOINER: CellJoiner<StyledRenderable>;
|
|
165
|
+
/**
|
|
166
|
+
* Rounded pills: each run opened by U+E0B6 and closed by U+E0B4, both in its
|
|
167
|
+
* ground over the terminal's, a space between pills. ASCII draws `(` and `)`.
|
|
168
|
+
*/
|
|
169
|
+
export declare const CAPSULE_JOINER: CellJoiner<StyledRenderable>;
|
|
170
|
+
/**
|
|
171
|
+
* ` | ` between every pair of items, in the theme's `strip.separator` colour;
|
|
172
|
+
* nothing at the ends. Its shape names no neighbour, so it joins items with no
|
|
173
|
+
* ground too.
|
|
174
|
+
*/
|
|
175
|
+
export declare const PLAIN_JOINER: CellJoiner<StyledRenderable>;
|
|
176
|
+
/**
|
|
177
|
+
* A ramp of `steps` cells from the left ground to the right. Each cell is the
|
|
178
|
+
* half block U+258C, ink on its left half and ground on its right, so it
|
|
179
|
+
* carries two samples; ASCII draws a space, keeping the grounds alone. Nothing
|
|
180
|
+
* at the ends, or beside a neighbour with no ground — there is no colour to
|
|
181
|
+
* ramp toward.
|
|
182
|
+
*/
|
|
183
|
+
export declare function gradientJoiner(steps?: number): CellJoiner;
|