@promptctl/rich-js 0.19.0 → 0.21.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 +3 -2
- package/dist/core/anchor.d.ts +5 -0
- package/dist/core/anchor.js +10 -0
- package/dist/core/color.d.ts +1 -0
- package/dist/core/color.js +14 -3
- package/dist/core/noise.d.ts +31 -0
- package/dist/core/noise.js +94 -0
- package/dist/core/paint.js +13 -2
- package/dist/core/pretty.d.ts +23 -2
- package/dist/core/pretty.js +54 -18
- package/dist/core/protocol.d.ts +2 -0
- package/dist/core/protocol.js +3 -2
- package/dist/core/selection.d.ts +12 -0
- package/dist/core/selection.js +14 -0
- package/dist/core/strip.d.ts +159 -76
- package/dist/core/strip.js +367 -215
- package/dist/core/style.js +10 -7
- package/dist/host/app.d.ts +68 -2
- package/dist/host/app.js +125 -15
- package/dist/host/index.d.ts +3 -1
- package/dist/host/index.js +1 -0
- package/dist/host/input.d.ts +87 -0
- package/dist/host/input.js +517 -0
- package/dist/host/terminal-host.d.ts +12 -0
- package/dist/host/terminal-host.js +2 -0
- package/dist/index.d.ts +11 -6
- package/dist/index.js +7 -4
- package/dist/node/terminal-host.d.ts +7 -0
- package/dist/node/terminal-host.js +7 -0
- package/dist/renderables/effect.d.ts +89 -16
- package/dist/renderables/effect.js +115 -42
- package/dist/renderables/effects.d.ts +260 -0
- package/dist/renderables/effects.js +596 -0
- package/dist/renderables/embed.d.ts +11 -5
- package/dist/renderables/embed.js +13 -6
- package/dist/renderables/flexStrip.d.ts +1 -1
- package/dist/renderables/flexStrip.js +10 -9
- package/dist/renderables/list-view.d.ts +42 -0
- package/dist/renderables/list-view.js +78 -0
- package/dist/renderables/progress.d.ts +6 -0
- package/dist/renderables/progress.js +11 -4
- package/dist/renderables/progressBar.d.ts +22 -2
- package/dist/renderables/progressBar.js +52 -7
- package/dist/renderables/rule.d.ts +2 -2
- package/dist/renderables/rule.js +12 -10
- package/dist/renderables/table.js +5 -7
- package/dist/renderables/viewport.d.ts +30 -0
- package/dist/renderables/viewport.js +59 -3
- package/dist/widgets/dropdown.js +3 -3
- package/dist/widgets/event-router.d.ts +31 -40
- package/dist/widgets/event-router.js +52 -483
- package/dist/widgets/hit.js +2 -4
- package/dist/widgets/index.d.ts +2 -1
- package/dist/widgets/types.d.ts +8 -25
- package/dist/widgets/types.js +8 -0
- package/dist/widgets/widget-app.d.ts +22 -7
- package/dist/widgets/widget-app.js +22 -12
- package/package.json +26 -18
package/dist/widgets/dropdown.js
CHANGED
|
@@ -61,6 +61,7 @@ import { Segment } from "../core/segment.js";
|
|
|
61
61
|
import { Style } from "../core/style.js";
|
|
62
62
|
import { cellLen, setCellSize, splitText, asCellCol } from "../core/cells.js";
|
|
63
63
|
import { drawable } from "../core/protocol.js";
|
|
64
|
+
import { moveSelection } from "../core/selection.js";
|
|
64
65
|
import { ThemedWidget } from "./themed-widget.js";
|
|
65
66
|
import { ink } from "./ink.js";
|
|
66
67
|
let Dropdown = (() => {
|
|
@@ -189,12 +190,11 @@ let Dropdown = (() => {
|
|
|
189
190
|
// expanded
|
|
190
191
|
switch (event.key) {
|
|
191
192
|
case "up":
|
|
192
|
-
this.highlightedIndex =
|
|
193
|
+
this.highlightedIndex = moveSelection(this.highlightedIndex, -1, this.filteredOptions.length);
|
|
193
194
|
event.stop();
|
|
194
195
|
return;
|
|
195
196
|
case "down": {
|
|
196
|
-
|
|
197
|
-
this.highlightedIndex = Math.min(max, this.highlightedIndex + 1);
|
|
197
|
+
this.highlightedIndex = moveSelection(this.highlightedIndex, 1, this.filteredOptions.length);
|
|
198
198
|
event.stop();
|
|
199
199
|
return;
|
|
200
200
|
}
|
|
@@ -1,49 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* EventRouter —
|
|
3
|
-
*
|
|
2
|
+
* EventRouter — dispatches the keys and pointer events an `App` hears to
|
|
3
|
+
* widgets, via a FocusManager and the frame on screen.
|
|
4
4
|
*
|
|
5
|
-
* It
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* [LAW:single-enforcer] ANSI escape parsing lives only here — widgets never
|
|
9
|
-
* see raw bytes. One parser, one dispatch surface.
|
|
10
|
-
*
|
|
11
|
-
* [LAW:dataflow-not-control-flow] The same parse pipeline runs for every
|
|
12
|
-
* input chunk: append → consume one event at a time until the buffer can't
|
|
13
|
-
* yield more. The byte's value, not a side-mode, decides which event is
|
|
14
|
-
* emitted. There is no "are we mid-sequence" mode flag — the buffer head
|
|
15
|
-
* carries all the state we need.
|
|
16
|
-
*
|
|
17
|
-
* Lone-ESC handling: a bare `\x1b` is ambiguous (escape key vs. start of a
|
|
18
|
-
* CSI sequence). When the buffer is drained but ends with a lone ESC, the
|
|
19
|
-
* router defers emission via setTimeout(0). The next chunk cancels the timer
|
|
20
|
-
* if it extends the sequence. Tests can call `flush()` to drain synchronously.
|
|
5
|
+
* It parses nothing and reads no terminal: `App` owns the one parser over its
|
|
6
|
+
* host's input (`host/input`), and `WidgetApp` hands this what the app hears.
|
|
21
7
|
*/
|
|
22
8
|
import { KeyEvent } from "./types.js";
|
|
23
|
-
import type { FrameSource,
|
|
9
|
+
import type { FrameSource, KeyHandlerOptions } from "./types.js";
|
|
24
10
|
import type { Unsubscribe } from "../core/subscription.js";
|
|
25
|
-
import type {
|
|
11
|
+
import type { KeyPress } from "../host/input.js";
|
|
12
|
+
import type { AppMouseEvent } from "../host/app.js";
|
|
13
|
+
import type { Wheel } from "../host/app.js";
|
|
26
14
|
type KeyHandler = (event: KeyEvent) => void;
|
|
27
15
|
export interface EventRouterOptions {
|
|
28
16
|
source: FrameSource;
|
|
29
|
-
/**
|
|
30
|
-
|
|
17
|
+
/** Whether a left-button press focuses the widget under it before it hears the press. */
|
|
18
|
+
focusOnClick: boolean;
|
|
31
19
|
}
|
|
32
20
|
export declare class EventRouter {
|
|
33
21
|
private readonly source;
|
|
34
|
-
private readonly
|
|
35
|
-
private buffer;
|
|
36
|
-
private running;
|
|
37
|
-
private dataUnsubscribe;
|
|
38
|
-
private escTimer;
|
|
22
|
+
private readonly focusOnClick;
|
|
39
23
|
private captured;
|
|
40
24
|
private pointer;
|
|
41
25
|
private hoveredWidget;
|
|
42
26
|
private readonly keyChain;
|
|
43
27
|
private readonly mouseHandlers;
|
|
44
28
|
constructor(options: EventRouterOptions);
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Drop what a run left behind — a captured drag, the pointer, hover — so the
|
|
31
|
+
* router is in the shape a fresh construction would be.
|
|
32
|
+
*
|
|
33
|
+
* [LAW:one-source-of-truth] Per-session state belongs to one session.
|
|
34
|
+
*/
|
|
35
|
+
reset(): void;
|
|
47
36
|
/**
|
|
48
37
|
* Read hover again off the frame just painted: under a pointer that has not
|
|
49
38
|
* moved, a widget may have gone, moved, or arrived.
|
|
@@ -53,17 +42,19 @@ export declare class EventRouter {
|
|
|
53
42
|
*/
|
|
54
43
|
framePainted(): void;
|
|
55
44
|
onKey(handler: KeyHandler, options?: KeyHandlerOptions): Unsubscribe;
|
|
56
|
-
onMouse(handler: (event:
|
|
57
|
-
/**
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
45
|
+
onMouse(handler: (event: AppMouseEvent) => void): Unsubscribe;
|
|
46
|
+
/** Route a key the app heard. */
|
|
47
|
+
key(press: KeyPress): void;
|
|
48
|
+
/** Route a pointer event the app heard. */
|
|
49
|
+
mouse(event: AppMouseEvent): void;
|
|
50
|
+
/**
|
|
51
|
+
* Scroll the innermost viewport under the pointer that can move, a line a
|
|
52
|
+
* notch, past any widget it shows there and whatever a drag captured.
|
|
53
|
+
* Whether one moved is the answer: with none, the app passes the wheel
|
|
54
|
+
* outward.
|
|
55
|
+
*/
|
|
56
|
+
wheel({ x, y, lines }: Wheel): boolean;
|
|
57
|
+
private point;
|
|
67
58
|
private dispatchKey;
|
|
68
59
|
private dispatchMouse;
|
|
69
60
|
private hover;
|