@flowtty/core 1.0.0-alpha.1 → 1.0.0-alpha.11
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/dist/backend-CT8SGLO5.d.ts +103 -0
- package/dist/cells-C-GthybI.d.ts +43 -0
- package/dist/host/index.d.ts +6 -8
- package/dist/host/index.js +338 -312
- package/dist/host-C98WW3Ai.d.ts +184 -0
- package/dist/index.d.ts +104 -54
- package/dist/index.js +699 -360
- package/dist/keys-Ck-RALk_.js +40 -0
- package/dist/testing/index.d.ts +39 -31
- package/dist/testing/index.js +140 -65
- package/dist/wrap-D5f0P1iA.js +180 -0
- package/package.json +3 -3
- package/dist/backend-BcB7VR87.d.ts +0 -74
- package/dist/cells-CaXEx4lH.d.ts +0 -31
- package/dist/chunk-D6HW2BNM.js +0 -106
- package/dist/host-DttBG-OZ.d.ts +0 -151
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { t as Buffer } from "./cells-C-GthybI.js";
|
|
2
|
+
//#region src/keys.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Every multi-character key name a backend produces. A printable key's name is
|
|
5
|
+
* the character itself (`' '`, `':'`, `'a'`) — there is no `'space'`, `'enter'`
|
|
6
|
+
* or `'colon'`. Sequences the key parser does not recognize surface under a
|
|
7
|
+
* `csi-…` name, which is deliberately not listed here.
|
|
8
|
+
*/
|
|
9
|
+
declare const NAMED_KEYS: readonly ["return", "escape", "tab", "backspace", "delete", "insert", "up", "down", "left", "right", "home", "end", "pageup", "pagedown", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12", "paste", "wheelup", "wheeldown"];
|
|
10
|
+
type NamedKey = typeof NAMED_KEYS[number];
|
|
11
|
+
/** A key name: a named key, or the character itself for a printable key. The
|
|
12
|
+
* `string & {}` arm keeps any character valid while editors still complete the
|
|
13
|
+
* named ones — it cannot reject a typo like `'space'`; `TestBackend.press` does. */
|
|
14
|
+
type KeyName = NamedKey | (string & {});
|
|
15
|
+
interface Key {
|
|
16
|
+
/**
|
|
17
|
+
* Canonical name of the key. For printable ASCII characters this is the
|
|
18
|
+
* character itself ('a', '!', ' '). For named keys: 'return', 'escape',
|
|
19
|
+
* 'tab', 'backspace', 'delete', 'up', 'down', 'left', 'right', 'home',
|
|
20
|
+
* 'end', 'pageup', 'pagedown'. A bracketed paste is one key named 'paste'
|
|
21
|
+
* whose content is in `text`. Mouse wheel steps are 'wheelup' / 'wheeldown',
|
|
22
|
+
* positioned by `x` / `y`.
|
|
23
|
+
*/
|
|
24
|
+
name: KeyName;
|
|
25
|
+
/**
|
|
26
|
+
* Payload of a 'paste' key: the pasted text, line endings normalized to `\n`.
|
|
27
|
+
* A paste is delivered whole — its newlines and letters are text, never
|
|
28
|
+
* 'return' or single-letter keys — so an app inserts it instead of acting on it.
|
|
29
|
+
* Undefined for every other key.
|
|
30
|
+
*/
|
|
31
|
+
text?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Cell under the pointer for a mouse key ('wheelup' / 'wheeldown'): 0-based
|
|
34
|
+
* column and row, the same coordinates `onLayout` rects use. Undefined for
|
|
35
|
+
* every other key.
|
|
36
|
+
*/
|
|
37
|
+
x?: number;
|
|
38
|
+
y?: number;
|
|
39
|
+
/** Raw byte sequence as received from the source (empty for synthetic keys). */
|
|
40
|
+
sequence: string;
|
|
41
|
+
ctrl: boolean;
|
|
42
|
+
meta: boolean;
|
|
43
|
+
shift: boolean;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/backend.d.ts
|
|
47
|
+
interface Backend {
|
|
48
|
+
size(): {
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
};
|
|
52
|
+
draw(buffer: Buffer): void;
|
|
53
|
+
/**
|
|
54
|
+
* Subscribe to raw key events. Returns an unsubscribe function.
|
|
55
|
+
* Backends without an input source omit this method.
|
|
56
|
+
*/
|
|
57
|
+
onKey?(handler: (key: Key) => void): () => void;
|
|
58
|
+
/**
|
|
59
|
+
* Subscribe to terminal-resize events. Returns an unsubscribe function.
|
|
60
|
+
* Handlers are called AFTER `size()` reflects the new dimensions.
|
|
61
|
+
* Backends with fixed dimensions (e.g. the test backend) omit this method.
|
|
62
|
+
*/
|
|
63
|
+
onResize?(handler: () => void): () => void;
|
|
64
|
+
dispose?(): void;
|
|
65
|
+
/**
|
|
66
|
+
* Append plain (already-styled, ANSI-ready) lines ABOVE the live region.
|
|
67
|
+
* The lines scroll naturally into the terminal's scrollback. Backends
|
|
68
|
+
* that own the whole screen (alt-screen TTY) or are headless (TestBackend)
|
|
69
|
+
* may omit this; components like <Static> check for presence at runtime
|
|
70
|
+
* and degrade gracefully when absent.
|
|
71
|
+
*/
|
|
72
|
+
printStatic?(lines: string[]): void;
|
|
73
|
+
/**
|
|
74
|
+
* Whether this backend owns the entire render area — i.e. components can
|
|
75
|
+
* use the full `size()` for layout and overlay larger panels (Menu cascade,
|
|
76
|
+
* full-screen DialogHost) on top.
|
|
77
|
+
*
|
|
78
|
+
* true — TtyBackend (alt-screen), TestBackend (full buffer)
|
|
79
|
+
* false — @flowtty/inline-tty-backend (only the live region is yours;
|
|
80
|
+
* scrollback above is append-only and out of layout control)
|
|
81
|
+
*
|
|
82
|
+
* Defaults to `true` when omitted — preserves the behavior of existing
|
|
83
|
+
* backends that don't declare the flag. Inline-style backends MUST set
|
|
84
|
+
* it to `false` so capability-sensitive components (e.g. <Menu>) can
|
|
85
|
+
* refuse to render rather than produce broken overflow UI.
|
|
86
|
+
*/
|
|
87
|
+
fullScreen?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Whether this backend can emit OSC 8 terminal hyperlinks (clickable links).
|
|
90
|
+
*
|
|
91
|
+
* true — TTY backends (alt-screen + inline) wrap linked cells in the
|
|
92
|
+
* OSC 8 escape, so a `<Link>` is clickable in supporting terminals.
|
|
93
|
+
* omitted — treated as false. The headless TestBackend and any output that
|
|
94
|
+
* /false can't render clickable links leave them out, so `<Link>` should
|
|
95
|
+
* degrade to styled text plus a visible URL.
|
|
96
|
+
*
|
|
97
|
+
* Feature-detected like `fullScreen`: components read it (via useBackend())
|
|
98
|
+
* rather than assuming a capability.
|
|
99
|
+
*/
|
|
100
|
+
hyperlinks?: boolean;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { NamedKey as a, NAMED_KEYS as i, Key as n, KeyName as r, Backend as t };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region src/colors.d.ts
|
|
2
|
+
declare const NAMED_COLORS: readonly ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "gray", "grey", "blackBright", "redBright", "greenBright", "yellowBright", "blueBright", "magentaBright", "cyanBright", "whiteBright"];
|
|
3
|
+
type NamedColor = typeof NAMED_COLORS[number];
|
|
4
|
+
/**
|
|
5
|
+
* A color value: a named color, or any string for the other accepted forms —
|
|
6
|
+
* `#rgb`, `#rrggbb`, `rgb(r, g, b)`. The `string & {}` arm keeps those valid
|
|
7
|
+
* while editors still complete the names. It cannot reject a misspelled name;
|
|
8
|
+
* the TTY backends report unknown names when they exit.
|
|
9
|
+
*/
|
|
10
|
+
type Color = NamedColor | (string & {});
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/cells.d.ts
|
|
13
|
+
interface Style {
|
|
14
|
+
fg?: Color;
|
|
15
|
+
bg?: Color;
|
|
16
|
+
bold?: boolean;
|
|
17
|
+
dim?: boolean;
|
|
18
|
+
underline?: boolean;
|
|
19
|
+
inverse?: boolean;
|
|
20
|
+
strikethrough?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Target URL for an OSC 8 terminal hyperlink. Backends that can emit
|
|
23
|
+
* clickable links (TTY / inline TTY) wrap this cell's char in the hyperlink
|
|
24
|
+
* escape; backends that can't (headless test surface) ignore it. Carried in
|
|
25
|
+
* Style so it threads through the same paint + diff path as visual attrs.
|
|
26
|
+
*/
|
|
27
|
+
link?: string;
|
|
28
|
+
}
|
|
29
|
+
interface Cell {
|
|
30
|
+
char: string;
|
|
31
|
+
style: Style;
|
|
32
|
+
}
|
|
33
|
+
declare class Buffer {
|
|
34
|
+
readonly width: number;
|
|
35
|
+
readonly height: number;
|
|
36
|
+
private readonly cells;
|
|
37
|
+
constructor(width: number, height: number);
|
|
38
|
+
set(x: number, y: number, char: string, style?: Style): void;
|
|
39
|
+
get(x: number, y: number): Cell;
|
|
40
|
+
toString(): string;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { NAMED_COLORS as a, Color as i, Cell as n, NamedColor as o, Style as r, Buffer as t };
|
package/dist/host/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export { Container, paint };
|
|
1
|
+
import { D as getYoga, E as YogaNode, T as Yoga, _ as computeLayout, c as applyProps, d as insertBefore, f as measureText, g as Rect, h as removeChild, i as Instance, l as createInstance, m as refreshMeasure, n as Container, o as TextInstance, p as ownText, r as HostType, s as appendChild, u as createTextInstance, v as layoutOf, y as BORDER_CHARS } from "../host-C98WW3Ai.js";
|
|
2
|
+
import { t as Buffer } from "../cells-C-GthybI.js";
|
|
3
|
+
//#region src/host/paint.d.ts
|
|
4
|
+
export declare function paint(container: Container, width: number, height: number): Buffer;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { BORDER_CHARS, type Container, type HostType, type Instance, type Rect, type TextInstance, type Yoga, type YogaNode, appendChild, applyProps, computeLayout, createInstance, createTextInstance, getYoga, insertBefore, layoutOf, measureText, ownText, refreshMeasure, removeChild };
|