@promptctl/rich-js 0.18.0 → 0.19.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 +9 -7
- package/dist/core/anchor.d.ts +45 -0
- package/dist/core/anchor.js +39 -0
- package/dist/core/ansi.d.ts +65 -0
- package/dist/core/ansi.js +231 -0
- package/dist/core/box.d.ts +145 -0
- package/dist/core/box.js +372 -0
- package/dist/core/cells.d.ts +192 -0
- package/dist/core/cells.js +334 -0
- package/dist/core/clock.d.ts +48 -0
- package/dist/core/clock.js +42 -0
- package/dist/core/color.d.ts +326 -0
- package/dist/core/color.js +1225 -0
- package/dist/core/console.d.ts +196 -0
- package/dist/core/console.js +596 -0
- package/dist/core/easing.d.ts +86 -0
- package/dist/core/easing.js +171 -0
- package/dist/core/emoji.d.ts +24 -0
- package/dist/core/emoji.js +391 -0
- package/dist/core/env.d.ts +16 -0
- package/dist/core/env.js +16 -0
- package/dist/core/export-html.d.ts +59 -0
- package/dist/core/export-html.js +197 -0
- package/dist/core/export-lines.d.ts +130 -0
- package/dist/core/export-lines.js +159 -0
- 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 +33 -0
- package/dist/core/highlighter.js +190 -0
- package/dist/core/json.d.ts +27 -0
- package/dist/core/json.js +53 -0
- package/dist/core/markup.d.ts +140 -0
- package/dist/core/markup.js +654 -0
- package/dist/core/measure.d.ts +27 -0
- package/dist/core/measure.js +67 -0
- package/dist/core/memo.d.ts +19 -0
- package/dist/core/memo.js +34 -0
- package/dist/core/oklch.d.ts +161 -0
- package/dist/core/oklch.js +312 -0
- package/dist/core/osc8.d.ts +68 -0
- package/dist/core/osc8.js +78 -0
- package/dist/core/paint.d.ts +107 -0
- package/dist/core/paint.js +150 -0
- package/dist/core/place.d.ts +30 -0
- package/dist/core/place.js +49 -0
- package/dist/core/pretty.d.ts +247 -0
- package/dist/core/pretty.js +906 -0
- package/dist/core/protocol.d.ts +305 -0
- package/dist/core/protocol.js +183 -0
- package/dist/core/render.d.ts +87 -0
- package/dist/core/render.js +105 -0
- package/dist/core/segment.d.ts +162 -0
- package/dist/core/segment.js +488 -0
- package/dist/core/spinnerData.d.ts +12 -0
- package/dist/core/spinnerData.js +117 -0
- package/dist/core/strip.d.ts +152 -0
- package/dist/core/strip.js +326 -0
- package/dist/core/style.d.ts +189 -0
- package/dist/core/style.js +758 -0
- package/dist/core/subscription.d.ts +12 -0
- package/dist/core/subscription.js +12 -0
- package/dist/core/text.d.ts +283 -0
- package/dist/core/text.js +1097 -0
- package/dist/core/wrap.d.ts +46 -0
- package/dist/core/wrap.js +140 -0
- package/dist/host/app.d.ts +133 -0
- package/dist/host/app.js +285 -0
- package/dist/host/host-environment.d.ts +26 -0
- package/dist/host/host-environment.js +44 -0
- package/dist/host/index.d.ts +6 -0
- package/dist/host/index.js +3 -0
- package/dist/host/terminal-host.d.ts +180 -0
- package/dist/host/terminal-host.js +186 -0
- package/dist/index.d.ts +98 -0
- package/dist/index.js +114 -0
- package/dist/node/prompt.d.ts +34 -0
- package/dist/node/prompt.js +51 -0
- package/dist/node/save.d.ts +18 -0
- package/dist/node/save.js +24 -0
- package/dist/node/terminal-host.d.ts +114 -0
- package/dist/node/terminal-host.js +227 -0
- package/dist/node/traceback.d.ts +38 -0
- package/dist/node/traceback.js +98 -0
- package/dist/renderables/align.d.ts +16 -0
- package/dist/renderables/align.js +26 -0
- package/dist/renderables/columns.d.ts +77 -0
- package/dist/renderables/columns.js +191 -0
- package/dist/renderables/constrain.d.ts +15 -0
- package/dist/renderables/constrain.js +31 -0
- package/dist/renderables/effect.d.ts +98 -0
- package/dist/renderables/effect.js +160 -0
- package/dist/renderables/embed.d.ts +107 -0
- package/dist/renderables/embed.js +160 -0
- package/dist/renderables/flexStrip.d.ts +41 -0
- package/dist/renderables/flexStrip.js +200 -0
- package/dist/renderables/group.d.ts +14 -0
- package/dist/renderables/group.js +22 -0
- package/dist/renderables/layout.d.ts +75 -0
- package/dist/renderables/layout.js +223 -0
- package/dist/renderables/live.d.ts +74 -0
- package/dist/renderables/live.js +188 -0
- package/dist/renderables/markdown.d.ts +38 -0
- package/dist/renderables/markdown.js +587 -0
- package/dist/renderables/padding.d.ts +59 -0
- package/dist/renderables/padding.js +147 -0
- package/dist/renderables/panel.d.ts +114 -0
- package/dist/renderables/panel.js +303 -0
- package/dist/renderables/progress.d.ts +178 -0
- package/dist/renderables/progress.js +362 -0
- package/dist/renderables/progressBar.d.ts +31 -0
- package/dist/renderables/progressBar.js +64 -0
- package/dist/renderables/prompt.d.ts +71 -0
- package/dist/renderables/prompt.js +165 -0
- package/dist/renderables/ratio.d.ts +123 -0
- package/dist/renderables/ratio.js +213 -0
- package/dist/renderables/rule.d.ts +26 -0
- package/dist/renderables/rule.js +86 -0
- package/dist/renderables/spinner.d.ts +57 -0
- package/dist/renderables/spinner.js +103 -0
- package/dist/renderables/status.d.ts +29 -0
- package/dist/renderables/status.js +46 -0
- package/dist/renderables/syntax.d.ts +65 -0
- package/dist/renderables/syntax.js +166 -0
- package/dist/renderables/table.d.ts +232 -0
- package/dist/renderables/table.js +973 -0
- package/dist/renderables/traceback.d.ts +32 -0
- package/dist/renderables/traceback.js +279 -0
- package/dist/renderables/tree.d.ts +76 -0
- package/dist/renderables/tree.js +177 -0
- package/dist/renderables/viewport.d.ts +114 -0
- package/dist/renderables/viewport.js +196 -0
- package/dist/template-bindings/color-funcs.d.ts +109 -0
- package/dist/template-bindings/color-funcs.js +243 -0
- package/dist/template-bindings/helpers.d.ts +26 -0
- package/dist/template-bindings/helpers.js +33 -0
- package/dist/template-bindings/index.d.ts +119 -0
- package/dist/template-bindings/index.js +162 -0
- package/dist/template-bindings/palette-funcs.d.ts +96 -0
- package/dist/template-bindings/palette-funcs.js +145 -0
- package/dist/template-bindings/style-funcs.d.ts +28 -0
- package/dist/template-bindings/style-funcs.js +157 -0
- package/dist/themes/buildPalette.d.ts +57 -0
- package/dist/themes/buildPalette.js +100 -0
- package/dist/themes/colorMath.d.ts +94 -0
- package/dist/themes/colorMath.js +280 -0
- package/dist/themes/colorRef.d.ts +36 -0
- package/dist/themes/colorRef.js +78 -0
- package/dist/themes/data/ansi-tables.d.ts +14 -0
- package/dist/themes/data/ansi-tables.js +49 -0
- package/dist/themes/data/atom-one-dark.d.ts +3 -0
- package/dist/themes/data/atom-one-dark.js +177 -0
- package/dist/themes/data/atom-one-light.d.ts +3 -0
- package/dist/themes/data/atom-one-light.js +177 -0
- package/dist/themes/data/catppuccin-frappe.d.ts +3 -0
- package/dist/themes/data/catppuccin-frappe.js +177 -0
- package/dist/themes/data/catppuccin-latte.d.ts +3 -0
- package/dist/themes/data/catppuccin-latte.js +177 -0
- package/dist/themes/data/catppuccin-macchiato.d.ts +3 -0
- package/dist/themes/data/catppuccin-macchiato.js +177 -0
- package/dist/themes/data/catppuccin-mocha.d.ts +3 -0
- package/dist/themes/data/catppuccin-mocha.js +177 -0
- package/dist/themes/data/cyberpunk.d.ts +17 -0
- package/dist/themes/data/cyberpunk.js +193 -0
- package/dist/themes/data/default.d.ts +3 -0
- package/dist/themes/data/default.js +160 -0
- package/dist/themes/data/dracula.d.ts +3 -0
- package/dist/themes/data/dracula.js +177 -0
- package/dist/themes/data/flexoki.d.ts +3 -0
- package/dist/themes/data/flexoki.js +177 -0
- package/dist/themes/data/gruvbox.d.ts +3 -0
- package/dist/themes/data/gruvbox.js +177 -0
- package/dist/themes/data/index.d.ts +35 -0
- package/dist/themes/data/index.js +64 -0
- package/dist/themes/data/monokai.d.ts +3 -0
- package/dist/themes/data/monokai.js +177 -0
- package/dist/themes/data/nord.d.ts +3 -0
- package/dist/themes/data/nord.js +177 -0
- package/dist/themes/data/rose-pine-dawn.d.ts +3 -0
- package/dist/themes/data/rose-pine-dawn.js +177 -0
- package/dist/themes/data/rose-pine-moon.d.ts +3 -0
- package/dist/themes/data/rose-pine-moon.js +177 -0
- package/dist/themes/data/rose-pine.d.ts +3 -0
- package/dist/themes/data/rose-pine.js +177 -0
- package/dist/themes/data/solarized-dark.d.ts +3 -0
- package/dist/themes/data/solarized-dark.js +177 -0
- package/dist/themes/data/solarized-light.d.ts +3 -0
- package/dist/themes/data/solarized-light.js +177 -0
- package/dist/themes/data/svg-export.d.ts +3 -0
- package/dist/themes/data/svg-export.js +177 -0
- package/dist/themes/data/textual-ansi.d.ts +3 -0
- package/dist/themes/data/textual-ansi.js +160 -0
- package/dist/themes/data/textual-dark.d.ts +3 -0
- package/dist/themes/data/textual-dark.js +160 -0
- package/dist/themes/data/textual-light.d.ts +3 -0
- package/dist/themes/data/textual-light.js +160 -0
- package/dist/themes/data/tokyo-night.d.ts +3 -0
- package/dist/themes/data/tokyo-night.js +177 -0
- package/dist/themes/data/types.d.ts +31 -0
- package/dist/themes/data/types.js +10 -0
- package/dist/themes/palette.d.ts +45 -0
- package/dist/themes/palette.js +71 -0
- package/dist/themes/ramp.d.ts +70 -0
- package/dist/themes/ramp.js +103 -0
- package/dist/themes/registry.d.ts +44 -0
- package/dist/themes/registry.js +105 -0
- package/dist/themes/terminalThemes.d.ts +49 -0
- package/dist/themes/terminalThemes.js +63 -0
- package/dist/themes/transpose.d.ts +87 -0
- package/dist/themes/transpose.js +138 -0
- package/dist/widgets/button.d.ts +45 -0
- package/dist/widgets/button.js +177 -0
- package/dist/widgets/checkbox.d.ts +38 -0
- package/dist/widgets/checkbox.js +135 -0
- package/dist/widgets/dropdown.d.ts +64 -0
- package/dist/widgets/dropdown.js +416 -0
- package/dist/widgets/event-router.d.ts +71 -0
- package/dist/widgets/event-router.js +629 -0
- package/dist/widgets/focus-manager.d.ts +45 -0
- package/dist/widgets/focus-manager.js +191 -0
- package/dist/widgets/hit.d.ts +64 -0
- package/dist/widgets/hit.js +113 -0
- package/dist/widgets/index.d.ts +20 -0
- package/dist/widgets/index.js +14 -0
- package/dist/widgets/ink.d.ts +22 -0
- package/dist/widgets/ink.js +31 -0
- package/dist/widgets/slider.d.ts +54 -0
- package/dist/widgets/slider.js +247 -0
- package/dist/widgets/static-item.d.ts +34 -0
- package/dist/widgets/static-item.js +54 -0
- package/dist/widgets/text-input.d.ts +283 -0
- package/dist/widgets/text-input.js +1174 -0
- package/dist/widgets/themed-widget.d.ts +20 -0
- package/dist/widgets/themed-widget.js +89 -0
- package/dist/widgets/toggle.d.ts +41 -0
- package/dist/widgets/toggle.js +157 -0
- package/dist/widgets/types.d.ts +87 -0
- package/dist/widgets/types.js +30 -0
- package/dist/widgets/widget-app.d.ts +65 -0
- package/dist/widgets/widget-app.js +206 -0
- package/dist/widgets/widget-base.d.ts +42 -0
- package/dist/widgets/widget-base.js +172 -0
- package/package.json +16 -2
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Console — the central orchestrator for rendering styled output to the terminal.
|
|
3
|
+
*/
|
|
4
|
+
import { Style, Theme } from "./style.js";
|
|
5
|
+
import { ColorDepth } from "./color.js";
|
|
6
|
+
import type { ColorSystemName, Destination } from "./color.js";
|
|
7
|
+
import type { Env } from "./env.js";
|
|
8
|
+
import type { TerminalTheme } from "./color.js";
|
|
9
|
+
import { type JSONOptions } from "./json.js";
|
|
10
|
+
import type { Highlighter } from "./highlighter.js";
|
|
11
|
+
import { type RuleOptions } from "../renderables/rule.js";
|
|
12
|
+
import type { Height, OverflowMethod, RenderOptions, StyleErrorHandler } from "./protocol.js";
|
|
13
|
+
import type { Unsubscribe } from "./subscription.js";
|
|
14
|
+
export interface ConsoleSink {
|
|
15
|
+
write(chunk: string | Uint8Array): unknown;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A frame standing on the terminal under the cursor — a running `Live` — that
|
|
19
|
+
* everything the console writes has to go above. `around` returns the bytes
|
|
20
|
+
* that take the frame off the terminal, write `text`, and paint the frame
|
|
21
|
+
* back under it; the console writes them in one piece.
|
|
22
|
+
*/
|
|
23
|
+
export interface LiveRegion {
|
|
24
|
+
around(text: string): string;
|
|
25
|
+
}
|
|
26
|
+
export interface ConsoleStream extends ConsoleSink {
|
|
27
|
+
readonly isTTY?: boolean;
|
|
28
|
+
readonly columns?: number;
|
|
29
|
+
readonly rows?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The host facilities a `Console` consults: an environment map and the two
|
|
33
|
+
* standard streams. Node's `process` satisfies this shape as-is, which is the
|
|
34
|
+
* point — injecting a fake terminal needs no adapter at either end.
|
|
35
|
+
*/
|
|
36
|
+
export interface ConsoleEnvironment {
|
|
37
|
+
readonly env: Env;
|
|
38
|
+
readonly stdout?: ConsoleStream;
|
|
39
|
+
readonly stderr?: ConsoleStream;
|
|
40
|
+
}
|
|
41
|
+
export interface ConsoleOptions {
|
|
42
|
+
/**
|
|
43
|
+
* Color encoding. Accepts a `ColorSystemName` (`"auto"`, `"truecolor"`,
|
|
44
|
+
* `"256"`, `"ansi"`, `"none"`), a `ColorDepth` enum value (use this for
|
|
45
|
+
* `WINDOWS`, which has no name), or `null` for no color. Default `"auto"`.
|
|
46
|
+
* Colour only: an explicit depth, `null` included, keeps hyperlinks.
|
|
47
|
+
*/
|
|
48
|
+
colorSystem?: ColorSystemName | ColorDepth | null;
|
|
49
|
+
/**
|
|
50
|
+
* Whether OSC 8 hyperlinks are emitted. Default: what the destination takes
|
|
51
|
+
* — true for an explicit `colorSystem`, detected under `"auto"` (no TTY or
|
|
52
|
+
* TERM=dumb: false). `false` with `colorSystem: null` writes plain text.
|
|
53
|
+
*/
|
|
54
|
+
hyperlinks?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* The terminal can draw only ASCII: boxes, rules, tree guides and widget
|
|
57
|
+
* marks draw with ASCII characters instead of line-drawing glyphs. A
|
|
58
|
+
* property of the output device, so it is set here once and reaches every
|
|
59
|
+
* renderable this console draws. Default false.
|
|
60
|
+
*/
|
|
61
|
+
asciiOnly?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Static width (cells). Ignored when `getSize` is provided. Falls back to
|
|
64
|
+
* the `COLUMNS` env var / the bound stream's `columns` / 80.
|
|
65
|
+
*/
|
|
66
|
+
width?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Static height (lines). Ignored when `getSize` is provided. Falls back to
|
|
69
|
+
* the `LINES` env var / the bound stream's `rows` / 24.
|
|
70
|
+
*/
|
|
71
|
+
height?: number;
|
|
72
|
+
/**
|
|
73
|
+
* Live size source. When provided, the console reads its width/height from
|
|
74
|
+
* this function on every access, overriding any static `width`/`height` and
|
|
75
|
+
* the bound stream's dimensions. Pass this when the output target's
|
|
76
|
+
* dimensions can change at runtime (e.g. xterm.js in a browser).
|
|
77
|
+
*
|
|
78
|
+
* [LAW:dataflow-not-control-flow] Live size is a function value the
|
|
79
|
+
* console reads, not a branch the call site has to install via
|
|
80
|
+
* `Object.defineProperty`.
|
|
81
|
+
*/
|
|
82
|
+
getSize?: () => {
|
|
83
|
+
width: number;
|
|
84
|
+
height: number;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* The clock `log` stamps each row from, read once per call. Default: the
|
|
88
|
+
* wall clock. Pass a fixed one to make logged output repeatable.
|
|
89
|
+
*/
|
|
90
|
+
getDatetime?: () => Date;
|
|
91
|
+
style?: string | Style;
|
|
92
|
+
forceTerminal?: boolean;
|
|
93
|
+
forceInteractive?: boolean;
|
|
94
|
+
stderr?: boolean;
|
|
95
|
+
file?: ConsoleSink;
|
|
96
|
+
/**
|
|
97
|
+
* Host facilities to consult for colour detection, size detection, and the
|
|
98
|
+
* default output sink. Defaults to the ambient `process`, or — where there
|
|
99
|
+
* is no `process` — an empty environment with no streams. Pass this to drive
|
|
100
|
+
* a `Console` deterministically, or to run one against a simulated terminal.
|
|
101
|
+
*/
|
|
102
|
+
environment?: ConsoleEnvironment;
|
|
103
|
+
record?: boolean;
|
|
104
|
+
markup?: boolean;
|
|
105
|
+
highlight?: boolean;
|
|
106
|
+
theme?: Theme;
|
|
107
|
+
highlighter?: Highlighter;
|
|
108
|
+
/**
|
|
109
|
+
* Called each time a render resolves a style string it cannot parse — a
|
|
110
|
+
* misspelled name, a key the theme lacks — and degrades it to unstyled.
|
|
111
|
+
* Calls are per resolution, not per distinct string: a style read twice, or
|
|
112
|
+
* redrawn by a refresh, is reported again. Throw from it to make rendering
|
|
113
|
+
* strict.
|
|
114
|
+
*/
|
|
115
|
+
onStyleError?: StyleErrorHandler;
|
|
116
|
+
}
|
|
117
|
+
export interface PrintOptions {
|
|
118
|
+
style?: string | Style;
|
|
119
|
+
justify?: "default" | "left" | "center" | "right" | "full";
|
|
120
|
+
overflow?: OverflowMethod;
|
|
121
|
+
highlight?: boolean;
|
|
122
|
+
markup?: boolean;
|
|
123
|
+
softWrap?: boolean;
|
|
124
|
+
crop?: boolean;
|
|
125
|
+
end?: string;
|
|
126
|
+
sep?: string;
|
|
127
|
+
}
|
|
128
|
+
export declare class Console {
|
|
129
|
+
private readonly _destination;
|
|
130
|
+
private _getSize;
|
|
131
|
+
private readonly _getDatetime;
|
|
132
|
+
private _lastLogTime;
|
|
133
|
+
private _style;
|
|
134
|
+
private _isTerminal;
|
|
135
|
+
private readonly _interactive;
|
|
136
|
+
private _file;
|
|
137
|
+
private _stream;
|
|
138
|
+
private _record;
|
|
139
|
+
private _markup;
|
|
140
|
+
private _highlight;
|
|
141
|
+
private _theme;
|
|
142
|
+
private _onStyleError;
|
|
143
|
+
private readonly _asciiOnly;
|
|
144
|
+
private _highlighter;
|
|
145
|
+
private _recorded;
|
|
146
|
+
private _capture;
|
|
147
|
+
private _liveRegion;
|
|
148
|
+
constructor(options?: ConsoleOptions);
|
|
149
|
+
get size(): {
|
|
150
|
+
width: number;
|
|
151
|
+
height: number;
|
|
152
|
+
};
|
|
153
|
+
get width(): number;
|
|
154
|
+
get height(): number;
|
|
155
|
+
get isTerminal(): boolean;
|
|
156
|
+
get isInteractive(): boolean;
|
|
157
|
+
get colorSystem(): ColorDepth | null;
|
|
158
|
+
/**
|
|
159
|
+
* Where this console writes: the colour depth it draws at and whether it
|
|
160
|
+
* emits OSC 8 hyperlinks, overrides applied — the value its output is
|
|
161
|
+
* encoded for, for anything that encodes on its behalf (`Live`).
|
|
162
|
+
*/
|
|
163
|
+
get destination(): Destination;
|
|
164
|
+
get file(): ConsoleSink;
|
|
165
|
+
get theme(): Theme;
|
|
166
|
+
get options(): RenderOptions & {
|
|
167
|
+
height: Height;
|
|
168
|
+
};
|
|
169
|
+
print(...args: unknown[]): void;
|
|
170
|
+
private _draw;
|
|
171
|
+
log(...args: unknown[]): void;
|
|
172
|
+
rule(title?: string, options?: RuleOptions): void;
|
|
173
|
+
printJson(json: string | object, options?: JSONOptions): void;
|
|
174
|
+
/**
|
|
175
|
+
* Hold `region` under everything this console writes until the returned
|
|
176
|
+
* call lets it go. One region at a time: a second would be erased and
|
|
177
|
+
* painted over by the first, so claiming one while another is held throws.
|
|
178
|
+
*/
|
|
179
|
+
claimLiveRegion(region: LiveRegion): Unsubscribe;
|
|
180
|
+
beginCapture(): void;
|
|
181
|
+
endCapture(): string;
|
|
182
|
+
exportText({ clear }?: {
|
|
183
|
+
clear?: boolean;
|
|
184
|
+
}): string;
|
|
185
|
+
exportHtml({ theme, clear }?: {
|
|
186
|
+
theme?: TerminalTheme;
|
|
187
|
+
clear?: boolean;
|
|
188
|
+
}): string;
|
|
189
|
+
exportSvg({ theme, title, clear }?: {
|
|
190
|
+
theme?: TerminalTheme;
|
|
191
|
+
title?: string;
|
|
192
|
+
clear?: boolean;
|
|
193
|
+
}): string;
|
|
194
|
+
private _writeSegments;
|
|
195
|
+
private _write;
|
|
196
|
+
}
|