@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/widgets/slider.d.ts
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
import { Segment } from "../core/segment.js";
|
|
21
21
|
import { type RenderOptions } from "../core/protocol.js";
|
|
22
22
|
import type { TerminalTheme } from "../core/color.js";
|
|
23
|
-
import {
|
|
23
|
+
import { ThemedWidget } from "./themed-widget.js";
|
|
24
24
|
import type { KeyEvent, WidgetMouseEvent } from "./types.js";
|
|
25
25
|
export interface SliderOptions {
|
|
26
26
|
value?: number;
|
|
@@ -32,7 +32,7 @@ export interface SliderOptions {
|
|
|
32
32
|
disabled?: boolean;
|
|
33
33
|
theme?: TerminalTheme;
|
|
34
34
|
}
|
|
35
|
-
export declare class Slider extends
|
|
35
|
+
export declare class Slider extends ThemedWidget {
|
|
36
36
|
readonly id: string;
|
|
37
37
|
readonly focusable = true;
|
|
38
38
|
accessor value: number;
|
|
@@ -40,10 +40,8 @@ export declare class Slider extends WidgetBase {
|
|
|
40
40
|
accessor max: number;
|
|
41
41
|
accessor step: number;
|
|
42
42
|
accessor width: number;
|
|
43
|
-
private accessor _theme;
|
|
44
43
|
private _dragging;
|
|
45
44
|
constructor(options?: SliderOptions);
|
|
46
|
-
setTheme(theme: TerminalTheme): void;
|
|
47
45
|
handleKey(event: KeyEvent): void;
|
|
48
46
|
handleMouse(event: WidgetMouseEvent): void;
|
|
49
47
|
private setValue;
|
|
@@ -53,5 +51,4 @@ export declare class Slider extends WidgetBase {
|
|
|
53
51
|
minimum: number;
|
|
54
52
|
maximum: number;
|
|
55
53
|
};
|
|
56
|
-
private resolvePalette;
|
|
57
54
|
}
|
package/dist/widgets/slider.js
CHANGED
|
@@ -54,13 +54,12 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
54
54
|
import { observable, action, observableRef } from "mobx";
|
|
55
55
|
import { Segment } from "../core/segment.js";
|
|
56
56
|
import { Style } from "../core/style.js";
|
|
57
|
-
import { ColorSpec } from "../core/color.js";
|
|
58
|
-
import { DEFAULT_TERMINAL_THEME } from "../themes/terminalThemes.js";
|
|
59
57
|
import { drawable } from "../core/protocol.js";
|
|
60
|
-
import {
|
|
58
|
+
import { ThemedWidget } from "./themed-widget.js";
|
|
59
|
+
import { ink } from "./ink.js";
|
|
61
60
|
const DEFAULT_WIDTH = 20;
|
|
62
61
|
let Slider = (() => {
|
|
63
|
-
let _classSuper =
|
|
62
|
+
let _classSuper = ThemedWidget;
|
|
64
63
|
let _instanceExtraInitializers = [];
|
|
65
64
|
let _value_decorators;
|
|
66
65
|
let _value_initializers = [];
|
|
@@ -77,10 +76,6 @@ let Slider = (() => {
|
|
|
77
76
|
let _width_decorators;
|
|
78
77
|
let _width_initializers = [];
|
|
79
78
|
let _width_extraInitializers = [];
|
|
80
|
-
let __theme_decorators;
|
|
81
|
-
let __theme_initializers = [];
|
|
82
|
-
let __theme_extraInitializers = [];
|
|
83
|
-
let _setTheme_decorators;
|
|
84
79
|
let _handleKey_decorators;
|
|
85
80
|
let _handleMouse_decorators;
|
|
86
81
|
let _setValue_decorators;
|
|
@@ -92,8 +87,6 @@ let Slider = (() => {
|
|
|
92
87
|
_max_decorators = [observableRef];
|
|
93
88
|
_step_decorators = [observableRef];
|
|
94
89
|
_width_decorators = [observableRef];
|
|
95
|
-
__theme_decorators = [observableRef];
|
|
96
|
-
_setTheme_decorators = [action];
|
|
97
90
|
_handleKey_decorators = [action];
|
|
98
91
|
_handleMouse_decorators = [action];
|
|
99
92
|
_setValue_decorators = [action];
|
|
@@ -102,8 +95,6 @@ let Slider = (() => {
|
|
|
102
95
|
__esDecorate(this, null, _max_decorators, { kind: "accessor", name: "max", static: false, private: false, access: { has: obj => "max" in obj, get: obj => obj.max, set: (obj, value) => { obj.max = value; } }, metadata: _metadata }, _max_initializers, _max_extraInitializers);
|
|
103
96
|
__esDecorate(this, null, _step_decorators, { kind: "accessor", name: "step", static: false, private: false, access: { has: obj => "step" in obj, get: obj => obj.step, set: (obj, value) => { obj.step = value; } }, metadata: _metadata }, _step_initializers, _step_extraInitializers);
|
|
104
97
|
__esDecorate(this, null, _width_decorators, { kind: "accessor", name: "width", static: false, private: false, access: { has: obj => "width" in obj, get: obj => obj.width, set: (obj, value) => { obj.width = value; } }, metadata: _metadata }, _width_initializers, _width_extraInitializers);
|
|
105
|
-
__esDecorate(this, null, __theme_decorators, { kind: "accessor", name: "_theme", static: false, private: false, access: { has: obj => "_theme" in obj, get: obj => obj._theme, set: (obj, value) => { obj._theme = value; } }, metadata: _metadata }, __theme_initializers, __theme_extraInitializers);
|
|
106
|
-
__esDecorate(this, null, _setTheme_decorators, { kind: "method", name: "setTheme", static: false, private: false, access: { has: obj => "setTheme" in obj, get: obj => obj.setTheme }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
107
98
|
__esDecorate(this, null, _handleKey_decorators, { kind: "method", name: "handleKey", static: false, private: false, access: { has: obj => "handleKey" in obj, get: obj => obj.handleKey }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
108
99
|
__esDecorate(this, null, _handleMouse_decorators, { kind: "method", name: "handleMouse", static: false, private: false, access: { has: obj => "handleMouse" in obj, get: obj => obj.handleMouse }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
109
100
|
__esDecorate(this, null, _setValue_decorators, { kind: "method", name: "setValue", static: false, private: false, access: { has: obj => "setValue" in obj, get: obj => obj.setValue }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
@@ -126,15 +117,9 @@ let Slider = (() => {
|
|
|
126
117
|
#width_accessor_storage = (__runInitializers(this, _step_extraInitializers), __runInitializers(this, _width_initializers, void 0));
|
|
127
118
|
get width() { return this.#width_accessor_storage; }
|
|
128
119
|
set width(value) { this.#width_accessor_storage = value; }
|
|
129
|
-
|
|
130
|
-
// [LAW:types-are-the-program] @observableRef so setTheme() triggers a
|
|
131
|
-
// re-render — render() reads _theme.palette, so the theme reference must
|
|
132
|
-
// participate in MobX reactivity for Screen's autorun to fire on swap.
|
|
133
|
-
get _theme() { return this.#_theme_accessor_storage; }
|
|
134
|
-
set _theme(value) { this.#_theme_accessor_storage = value; }
|
|
135
|
-
_dragging = (__runInitializers(this, __theme_extraInitializers), false);
|
|
120
|
+
_dragging = (__runInitializers(this, _width_extraInitializers), false);
|
|
136
121
|
constructor(options = {}) {
|
|
137
|
-
super();
|
|
122
|
+
super(options.theme);
|
|
138
123
|
this.id = options.id ?? `slider-${Math.random().toString(36).slice(2, 8)}`;
|
|
139
124
|
this.min = options.min ?? 0;
|
|
140
125
|
this.max = options.max ?? 100;
|
|
@@ -150,9 +135,7 @@ let Slider = (() => {
|
|
|
150
135
|
this.width = width;
|
|
151
136
|
this.value = clampSnap(options.value ?? this.min, this.min, this.max, this.step);
|
|
152
137
|
this.disabled = options.disabled ?? false;
|
|
153
|
-
this._theme = options.theme ?? DEFAULT_TERMINAL_THEME;
|
|
154
138
|
}
|
|
155
|
-
setTheme(theme) { this._theme = theme; }
|
|
156
139
|
// --- Event handlers ---
|
|
157
140
|
handleKey(event) {
|
|
158
141
|
if (this.disabled)
|
|
@@ -225,14 +208,14 @@ let Slider = (() => {
|
|
|
225
208
|
const markerIdx = Math.round(fraction * (this.width - 1));
|
|
226
209
|
const baseAttrs = { underline: this.focused };
|
|
227
210
|
const filledStyle = this.disabled
|
|
228
|
-
? new Style({
|
|
229
|
-
: new Style({
|
|
211
|
+
? new Style({ ...this.disabledInk, ...baseAttrs })
|
|
212
|
+
: new Style({ ...ink(this.theme, "text-primary", "background"), ...baseAttrs });
|
|
230
213
|
const unfilledStyle = this.disabled
|
|
231
|
-
? new Style({
|
|
232
|
-
: new Style({
|
|
214
|
+
? new Style({ ...this.disabledInk, ...baseAttrs })
|
|
215
|
+
: new Style({ ...ink(this.theme, "foreground", "background"), dim: true, ...baseAttrs });
|
|
233
216
|
const markerStyle = this.disabled
|
|
234
|
-
? new Style({
|
|
235
|
-
: new Style({
|
|
217
|
+
? new Style({ ...this.disabledInk, bold: true, ...baseAttrs })
|
|
218
|
+
: new Style({ ...ink(this.theme, "text-primary", "background"), bold: true, ...baseAttrs });
|
|
236
219
|
const segments = [];
|
|
237
220
|
if (markerIdx > 0) {
|
|
238
221
|
segments.push(new Segment(trackChar.repeat(markerIdx), filledStyle));
|
|
@@ -247,12 +230,6 @@ let Slider = (() => {
|
|
|
247
230
|
measure(_options) {
|
|
248
231
|
return { minimum: this.width, maximum: this.width };
|
|
249
232
|
}
|
|
250
|
-
// --- Palette resolution ---
|
|
251
|
-
resolvePalette(key) {
|
|
252
|
-
const rgba = this._theme.palette.get(key);
|
|
253
|
-
// [LAW:no-defensive-null-guards] palette must contain all keys.
|
|
254
|
-
return ColorSpec.fromRgba(rgba);
|
|
255
|
-
}
|
|
256
233
|
};
|
|
257
234
|
})();
|
|
258
235
|
export { Slider };
|
|
@@ -22,10 +22,15 @@
|
|
|
22
22
|
* [LAW:types-are-the-program] Three integer spaces coexist: `CellCol` (terminal
|
|
23
23
|
* cell columns), `CodeUnit` (JS UTF-16 indices), and `CodePoint` (code-unit
|
|
24
24
|
* offsets that are additionally on a Unicode code-point boundary — a subtype of
|
|
25
|
-
* `CodeUnit`). `cursorPosition` is `CodePoint
|
|
26
|
-
*
|
|
25
|
+
* `CodeUnit`). `cursorPosition` is `CodePoint`, and stronger: its setter
|
|
26
|
+
* parses any offset to a grapheme-cluster boundary. Visual positions are `CellCol`. The three are never
|
|
27
27
|
* interchangeable — the type system enforces this at every crossing point.
|
|
28
28
|
*
|
|
29
|
+
* [LAW:one-source-of-truth] The cursor moves, deletes and draws one grapheme
|
|
30
|
+
* cluster at a time (`nextGrapheme` / `prevGrapheme`) — the unit `cellLen`
|
|
31
|
+
* measures — so `👍🏽` is one step and one cursor cell, never a glyph and a
|
|
32
|
+
* stray skin-tone swatch.
|
|
33
|
+
*
|
|
29
34
|
* Keymap (readline / emacs compatible):
|
|
30
35
|
*
|
|
31
36
|
* ─── motion ───
|
|
@@ -57,10 +62,10 @@
|
|
|
57
62
|
*/
|
|
58
63
|
import { Segment } from "../core/segment.js";
|
|
59
64
|
import { Style } from "../core/style.js";
|
|
60
|
-
import { type CellCol, type CodePoint } from "../core/cells.js";
|
|
65
|
+
import { type CellCol, type CodePoint, type CodeUnit } from "../core/cells.js";
|
|
61
66
|
import { type RenderOptions } from "../core/protocol.js";
|
|
62
67
|
import type { TerminalTheme } from "../core/color.js";
|
|
63
|
-
import {
|
|
68
|
+
import { ThemedWidget } from "./themed-widget.js";
|
|
64
69
|
import type { KeyEvent, WidgetMouseEvent } from "./types.js";
|
|
65
70
|
/**
|
|
66
71
|
* A soft-wrap strategy. Given one logical line of text and cell-width budgets,
|
|
@@ -182,13 +187,16 @@ export interface TextInputOptions {
|
|
|
182
187
|
*/
|
|
183
188
|
contentStyle?: Style;
|
|
184
189
|
}
|
|
185
|
-
export declare class TextInput extends
|
|
190
|
+
export declare class TextInput extends ThemedWidget {
|
|
186
191
|
readonly id: string;
|
|
187
192
|
readonly focusable = true;
|
|
188
|
-
accessor
|
|
189
|
-
accessor
|
|
193
|
+
private accessor _value;
|
|
194
|
+
private accessor _cursor;
|
|
195
|
+
get value(): string;
|
|
196
|
+
set value(v: string);
|
|
197
|
+
get cursorPosition(): CodePoint;
|
|
198
|
+
set cursorPosition(p: CodeUnit);
|
|
190
199
|
accessor placeholder: string;
|
|
191
|
-
private _theme;
|
|
192
200
|
private readonly _maxLength;
|
|
193
201
|
private readonly _password;
|
|
194
202
|
private readonly _multiline;
|
|
@@ -217,9 +225,9 @@ export declare class TextInput extends WidgetBase {
|
|
|
217
225
|
private _killBuffer;
|
|
218
226
|
private _scrollStart;
|
|
219
227
|
private _singleLineViewportStart;
|
|
228
|
+
private _singleLineAsciiOnly;
|
|
220
229
|
readonly multiline: boolean;
|
|
221
230
|
constructor(options?: TextInputOptions);
|
|
222
|
-
setTheme(theme: TerminalTheme): void;
|
|
223
231
|
handleKey(event: KeyEvent): void;
|
|
224
232
|
handleMouse(event: WidgetMouseEvent): void;
|
|
225
233
|
setHovered(value: boolean): void;
|
|
@@ -247,7 +255,9 @@ export declare class TextInput extends WidgetBase {
|
|
|
247
255
|
private _lineStart;
|
|
248
256
|
private _lineEnd;
|
|
249
257
|
private _insertText;
|
|
258
|
+
protected get ground(): Style;
|
|
250
259
|
protected draw(options: RenderOptions): Iterable<Segment>;
|
|
260
|
+
private _shown;
|
|
251
261
|
private _renderSingleLine;
|
|
252
262
|
private _renderMultiline;
|
|
253
263
|
private _emitRowContent;
|
|
@@ -270,5 +280,4 @@ export declare class TextInput extends WidgetBase {
|
|
|
270
280
|
* - no render has happened yet (cache is empty).
|
|
271
281
|
*/
|
|
272
282
|
get scrollIndicatorText(): string | undefined;
|
|
273
|
-
private resolvePalette;
|
|
274
283
|
}
|