@yaks/tui 0.0.0-stage → 0.2.36
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/Frame.js +52 -0
- package/Frame.js.map +1 -0
- package/Frame.ts +92 -0
- package/Image.js +10 -0
- package/Image.js.map +1 -0
- package/Image.ts +22 -0
- package/LICENSE +202 -0
- package/README.md +524 -2
- package/RenderedCursor.js +103 -0
- package/RenderedCursor.js.map +1 -0
- package/RenderedCursor.ts +127 -0
- package/Scroll.js +88 -0
- package/Scroll.js.map +1 -0
- package/Scroll.ts +155 -0
- package/Textarea.js +186 -0
- package/Textarea.js.map +1 -0
- package/Textarea.ts +234 -0
- package/VirtualList.js +729 -0
- package/VirtualList.js.map +1 -0
- package/VirtualList.ts +838 -0
- package/_dist/Frame.d.ts +25 -0
- package/_dist/Frame.d.ts.map +1 -0
- package/_dist/Image.d.ts +13 -0
- package/_dist/Image.d.ts.map +1 -0
- package/_dist/RenderedCursor.d.ts +9 -0
- package/_dist/RenderedCursor.d.ts.map +1 -0
- package/_dist/Scroll.d.ts +30 -0
- package/_dist/Scroll.d.ts.map +1 -0
- package/_dist/Textarea.d.ts +26 -0
- package/_dist/Textarea.d.ts.map +1 -0
- package/_dist/VirtualList.d.ts +103 -0
- package/_dist/VirtualList.d.ts.map +1 -0
- package/_dist/guide.d.ts +21 -0
- package/_dist/guide.d.ts.map +1 -0
- package/_dist/history.d.ts +12 -0
- package/_dist/history.d.ts.map +1 -0
- package/_dist/input.d.ts +47 -0
- package/_dist/input.d.ts.map +1 -0
- package/_dist/interaction.d.ts +15 -0
- package/_dist/interaction.d.ts.map +1 -0
- package/_dist/keymap.d.ts +4 -0
- package/_dist/keymap.d.ts.map +1 -0
- package/_dist/mod.d.ts +42 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/mouse.d.ts +15 -0
- package/_dist/mouse.d.ts.map +1 -0
- package/_dist/paint.d.ts +86 -0
- package/_dist/paint.d.ts.map +1 -0
- package/_dist/print.d.ts +20 -0
- package/_dist/print.d.ts.map +1 -0
- package/_dist/run.d.ts +19 -0
- package/_dist/run.d.ts.map +1 -0
- package/_dist/screen.d.ts +22 -0
- package/_dist/screen.d.ts.map +1 -0
- package/_dist/scrollbar.d.ts +7 -0
- package/_dist/scrollbar.d.ts.map +1 -0
- package/_dist/testing.d.ts +19 -0
- package/_dist/testing.d.ts.map +1 -0
- package/_dist/theme.d.ts +11 -0
- package/_dist/theme.d.ts.map +1 -0
- package/_dist/visual.d.ts +28 -0
- package/_dist/visual.d.ts.map +1 -0
- package/deno.json +1 -0
- package/graphics.js +157 -0
- package/graphics.js.map +1 -0
- package/graphics.ts +191 -0
- package/grid.js +38 -0
- package/grid.js.map +1 -0
- package/grid.ts +46 -0
- package/guide.js +144 -0
- package/guide.js.map +1 -0
- package/guide.ts +169 -0
- package/history.js +58 -0
- package/history.js.map +1 -0
- package/history.ts +59 -0
- package/input.js +356 -0
- package/input.js.map +1 -0
- package/input.ts +324 -0
- package/interaction.js +180 -0
- package/interaction.js.map +1 -0
- package/interaction.ts +185 -0
- package/keymap.js +20 -0
- package/keymap.js.map +1 -0
- package/keymap.ts +23 -0
- package/mod.js +39 -0
- package/mod.js.map +1 -0
- package/mod.ts +92 -0
- package/mouse.js +65 -0
- package/mouse.js.map +1 -0
- package/mouse.ts +98 -0
- package/package.json +49 -4
- package/paint.js +1010 -0
- package/paint.js.map +1 -0
- package/paint.ts +1063 -0
- package/print.js +31 -0
- package/print.js.map +1 -0
- package/print.ts +40 -0
- package/run.js +220 -0
- package/run.js.map +1 -0
- package/run.ts +237 -0
- package/screen.js +97 -0
- package/screen.js.map +1 -0
- package/screen.ts +139 -0
- package/scrollbar.js +30 -0
- package/scrollbar.js.map +1 -0
- package/scrollbar.ts +33 -0
- package/table.js +134 -0
- package/table.js.map +1 -0
- package/table.ts +152 -0
- package/testing.js +86 -0
- package/testing.js.map +1 -0
- package/testing.ts +95 -0
- package/textRows.js +38 -0
- package/textRows.js.map +1 -0
- package/textRows.ts +31 -0
- package/theme.js +50 -0
- package/theme.js.map +1 -0
- package/theme.ts +39 -0
- package/visual.js +195 -0
- package/visual.js.map +1 -0
- package/visual.ts +209 -0
package/_dist/Frame.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The screen's shape: a main column with a sidebar of panels on the right. A
|
|
3
|
+
* panel is `{title, Render}` — anything that draws, contributed by whoever
|
|
4
|
+
* knows what belongs there — so the frame itself knows nothing about what it
|
|
5
|
+
* shows. The sidebar takes a fixed or proportional terminal width and folds away
|
|
6
|
+
* below `min` terminal columns.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/ import { type ComponentType, type JSX, type ReactNode } from "@types/react";
|
|
10
|
+
/** One sidebar panel: a heading and whatever draws under it. */ export type Panel = {
|
|
11
|
+
title: string;
|
|
12
|
+
titleClass?: string;
|
|
13
|
+
/** Share remaining sidebar height instead of measuring unbounded content. */ bounded?: boolean;
|
|
14
|
+
/** Shrink to content within a fair share; expanding panels receive unused rows. */ fit?: boolean;
|
|
15
|
+
/** Content already owns a scrolling viewport. */ scrollable?: boolean;
|
|
16
|
+
Render: ComponentType;
|
|
17
|
+
};
|
|
18
|
+
/** Terminal frame with a right sidebar; below `min` columns it is hidden. */ export declare let Frame: ({}: {
|
|
19
|
+
sidebar?: Panel[];
|
|
20
|
+
/** Fixed columns, or minimum columns when ratio is supplied. */ width?: number;
|
|
21
|
+
/** Fraction of terminal width (0–1). Rounded down; leaves one main column. */ ratio?: number;
|
|
22
|
+
min?: number;
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
}) => JSX.Element;
|
|
25
|
+
//# sourceMappingURL=Frame.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Frame.d.ts","sources":["../Frame.ts"],"names":[],"mappings":"AAAA;;;;;;;;CAQC,GAEyC,SACxC,KAAK,aAAa,EAElB,KAAK,GAAG,EACR,KAAK,SAAS,uBACS;AAIzB,8DAA8D,GAC9D,YAAY;EACV,OAAO,MAAM;EACb,aAAa,MAAM;EACnB,2EAA2E,GAC3E,UAAU,OAAO;EACjB,iFAAiF,GACjF,MAAM,OAAO;EACb,+CAA+C,GAC/C,aAAa,OAAO;EACpB,QAAQ;;AAGV,2EAA2E,GAC3E,OAAO,YAAI,QACT;EACE,UAAU;EACV,8DAA8D,GAC9D,QAAQ,MAAM;EACd,4EAA4E,GAC5E,QAAQ,MAAM;EACd,MAAM,MAAM;EACZ,WAAW;CACZ,KACA,IAAI,QAgDN"}
|
package/_dist/Image.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** A graph-independent, lazy terminal image. The backend owns loading and graphics. */ import { type JSX } from "@types/react";
|
|
2
|
+
export type ImageSource = {
|
|
3
|
+
key: string;
|
|
4
|
+
load: () => Promise<Uint8Array>;
|
|
5
|
+
alt: string;
|
|
6
|
+
rows: number;
|
|
7
|
+
};
|
|
8
|
+
/** The ref that makes a `terminal-image` element paint `source`, for a
|
|
9
|
+
* renderer that names its tags rather than its components. */ export declare let showing: (source: ImageSource) => any;
|
|
10
|
+
/** Fixed cell height avoids moving scroll anchors when bytes arrive. */ export declare let Image: ({}: {
|
|
11
|
+
source: ImageSource;
|
|
12
|
+
}) => JSX.Element;
|
|
13
|
+
//# sourceMappingURL=Image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Image.d.ts","sources":["../Image.ts"],"names":[],"mappings":"AAAA,qFAAqF,GAC3C,SAA6B,KAAK,GAAG,uBAA0B;AAIzG,YAAY;EACV,KAAK,MAAM;EACX,YAAY,QAAQ;EACpB,KAAK,MAAM;EACX,MAAM,MAAM;;AAGd;4DAC4D,GAC5D,OAAO,YAAI,UAAW,QAAQ,oBAE7B;AAED,sEAAsE,GACtE,OAAO,YAAI,QACT;EAAc,QAAQ;CAAa,KAClC,IAAI,QAAwD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenderedCursor.d.ts","sources":["../RenderedCursor.ts"],"names":[],"mappings":"AAIA,YAAY;EAAc,IAAI,MAAM;EAAE,KAAK,MAAM;EAAE,KAAK,MAAM;;AAC9D,YAAY,iBAAiB;EAAc,SAAS"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A scrollable region — the transcript. The component holds one number, the
|
|
3
|
+
* offset it hands the painter as a `scroll` attribute; the painter hands back
|
|
4
|
+
* how tall the content turned out to be, which is the only way a widget can
|
|
5
|
+
* know. Follows the bottom while it is at the bottom, and stops following the
|
|
6
|
+
* moment you scroll away — so a transcript that is growing stays pinned and a
|
|
7
|
+
* transcript you are reading holds still.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/ import { type JSX, type ReactNode } from "@types/react";
|
|
11
|
+
import type { Key } from "./input.js";
|
|
12
|
+
/** What a scroll region measured: content lines, and the rows it can show. */ export type View = {
|
|
13
|
+
total: number;
|
|
14
|
+
height: number;
|
|
15
|
+
};
|
|
16
|
+
/** The offset a key moves to, or null when the key does not scroll. */ export declare let scrolled: (top: number, key: Key, v: View) => number | null;
|
|
17
|
+
/** A scrolling window over its children. `id` is how the painter reports it. */ export declare let Scroll: ({}: {
|
|
18
|
+
id: string;
|
|
19
|
+
/** The offset in rows each `id` starts at, such as where a page was
|
|
20
|
+
* left; the region keeps its own from there. */ start?: number;
|
|
21
|
+
/** Hears the offset each time keys, the wheel or a reveal move it. */ onScroll?: (top: number) => void;
|
|
22
|
+
scrollbar?: boolean;
|
|
23
|
+
keyboard?: boolean;
|
|
24
|
+
/** Reveal a logical row when keyboard selection changes; left out, the
|
|
25
|
+
* first row of the element inside marked `reveal`. */ reveal?: number;
|
|
26
|
+
follow?: boolean;
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
[attr: string]: unknown;
|
|
29
|
+
}) => JSX.Element;
|
|
30
|
+
//# sourceMappingURL=Scroll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Scroll.d.ts","sources":["../Scroll.ts"],"names":[],"mappings":"AAAA;;;;;;;;;CASC,GAEyC,SAExC,KAAK,GAAG,EACR,KAAK,SAAS,uBAIS;AAEzB,cAAc,GAAG,qBAAoB;AAGrC,4EAA4E,GAC5E,YAAY;EAAS,OAAO,MAAM;EAAE,QAAQ,MAAM;;AAKlD,qEAAqE,GACrE,OAAO,YAAI,WAAY,KAAK,MAAM,EAAE,KAAK,KAAK,GAAG,SAAO,MAAM,GAAG,IAAI,CAqBpE;AAED,8EAA8E,GAC9E,OAAO,YAAI,SACT;EAWE,IAAI,MAAM;EACV;kDAC8C,GAC9C,QAAQ,MAAM;EACd,oEAAoE,GACpE,YAAY,KAAK,MAAM,KAAK,IAAI;EAChC,YAAY,OAAO;EACnB,WAAW,OAAO;EAClB;wDACoD,GACpD,SAAS,MAAM;EACf,SAAS,OAAO;EAChB,WAAW;GACV,MAAM,MAAM,GAAG,OAAO;CACxB,KACA,IAAI,QAyEN"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type JSX } from "@types/react";
|
|
2
|
+
import type { Key } from "./input.js";
|
|
3
|
+
/** The editor's whole state: the text, and where the cursor sits in it. */ export type Edit = {
|
|
4
|
+
text: string;
|
|
5
|
+
at: number;
|
|
6
|
+
};
|
|
7
|
+
/** The offset of the start of the line the cursor is on. */ export declare let bol: (t: string, i: number) => number;
|
|
8
|
+
/** The offset of the end of the line the cursor is on. */ export declare let eol: (t: string, i: number) => number;
|
|
9
|
+
/** Apply one key to the editor; null when the key is not an edit. */ export declare let edit: (s: Edit, k: Key) => Edit | null;
|
|
10
|
+
/** Where the cursor is, as a row and a column into the text's lines. */ export declare let spot: (s: Edit) => {
|
|
11
|
+
row: number;
|
|
12
|
+
col: number;
|
|
13
|
+
};
|
|
14
|
+
/** The editing box: `onSubmit` gets the text on Enter, and it clears. */ export declare let Textarea: ({}: {
|
|
15
|
+
active?: boolean;
|
|
16
|
+
id?: string;
|
|
17
|
+
max?: number;
|
|
18
|
+
prompt?: string;
|
|
19
|
+
/** Return false to retain a rejected draft; other return values clear it. */ onSubmit?: (text: string) => unknown;
|
|
20
|
+
onChange?: (text: string) => void;
|
|
21
|
+
/** Controlled editor state; onEdit receives cursor-only changes too. */ value?: Edit;
|
|
22
|
+
onEdit?: (next: Edit) => void;
|
|
23
|
+
/** Lets the surrounding app reserve shortcuts for itself without changing
|
|
24
|
+
* the editor's own key bindings. */ passKey?: (key: Key) => boolean;
|
|
25
|
+
}) => JSX.Element;
|
|
26
|
+
//# sourceMappingURL=Textarea.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Textarea.d.ts","sources":["../Textarea.ts"],"names":[],"mappings":"AAe0C,SAA6B,KAAK,GAAG,uBAA4C;AAC3H,cAAc,GAAG,qBAAoB;AASrC,yEAAyE,GACzE,YAAY;EAAS,MAAM,MAAM;EAAE,IAAI,MAAM;;AAiB7C,0DAA0D,GAC1D,OAAO,YAAI,MAAO,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,MAAM,CACf;AAChC,wDAAwD,GACxD,OAAO,YAAI,MAAO,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,MAAM,CAG9C;AAyBD,mEAAmE,GACnE,OAAO,YAAI,OAAQ,GAAG,MAAM,GAAG,QAAM,OAAO,IAAI,CAqC/C;AAsBD,sEAAsE,GACtE,OAAO,YAAI,OAAQ,GAAG;EAAS,KAAK,MAAM;EAAE,KAAK,MAAM;EAGtD;AAED,uEAAuE,GACvE,OAAO,YAAI,WACT;EAWE,SAAS,OAAO;EAChB,KAAK,MAAM;EACX,MAAM,MAAM;EACZ,SAAS,MAAM;EACf,2EAA2E,GAC3E,YAAY,MAAM,MAAM,KAAK,OAAO;EACpC,YAAY,MAAM,MAAM,KAAK,IAAI;EACjC,sEAAsE,GACtE,QAAQ;EACR,UAAU,MAAM,SAAS,IAAI;EAC7B;sCACkC,GAClC,WAAW,KAAK,QAAQ,OAAO;CAChC,KACA,IAAI,QAiEN"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { type RenderedCursor } from "./RenderedCursor.js";
|
|
2
|
+
import { type ScrollPosition } from "./scrollbar.js";
|
|
3
|
+
import type { MouseEvent } from "./mouse.js";
|
|
4
|
+
/** An identity-anchored, lazily measured viewport. No total-height pass. */ import { type ReactElement, type ReactNode } from "@types/react";
|
|
5
|
+
import { type Line } from "./paint.js";
|
|
6
|
+
import type { Style } from "@yaks/ui/sheet";
|
|
7
|
+
import type { Key } from "./input.js";
|
|
8
|
+
import { type Anchor, type ViewportState } from "@yaks/ux/anchor";
|
|
9
|
+
export type ListRange = {
|
|
10
|
+
before: boolean;
|
|
11
|
+
after: boolean;
|
|
12
|
+
/** Number of items in the whole list, not just the loaded page. */ total?: number;
|
|
13
|
+
/** Logical index of the first loaded item. Supply together with total. */ offset?: number;
|
|
14
|
+
};
|
|
15
|
+
export type RangeRequest = {
|
|
16
|
+
anchor?: string;
|
|
17
|
+
edge?: 'start' | 'end';
|
|
18
|
+
};
|
|
19
|
+
export type VirtualItem = {
|
|
20
|
+
id: string;
|
|
21
|
+
};
|
|
22
|
+
export type { Anchor };
|
|
23
|
+
/** Also usable without Preact: measure is called only for visited items.
|
|
24
|
+
* Cache is bounded by item count; one very large item still costs its full size.
|
|
25
|
+
*/ export declare class VirtualWindow<T extends VirtualItem> {
|
|
26
|
+
private measure: any;
|
|
27
|
+
private version: any;
|
|
28
|
+
private capacity: any;
|
|
29
|
+
anchor?: Anchor;
|
|
30
|
+
cursor?: RenderedCursor;
|
|
31
|
+
cursorStyle: Style;
|
|
32
|
+
cursorVisible: boolean;
|
|
33
|
+
private cursorStamp: any;
|
|
34
|
+
private reader?: any;
|
|
35
|
+
selected?: string;
|
|
36
|
+
selectionVisible: boolean;
|
|
37
|
+
selectionStyle: Style;
|
|
38
|
+
follow: boolean;
|
|
39
|
+
private items: any;
|
|
40
|
+
private indices: any;
|
|
41
|
+
private retainedOrder: any;
|
|
42
|
+
private cache: any;
|
|
43
|
+
private heights: any;
|
|
44
|
+
private heightWidth: any;
|
|
45
|
+
private heightStyle: any;
|
|
46
|
+
private heightItems?: any;
|
|
47
|
+
private heightOffset: any;
|
|
48
|
+
private height: any;
|
|
49
|
+
private movement: any;
|
|
50
|
+
private start: any;
|
|
51
|
+
private style: any;
|
|
52
|
+
private revealedSelection?: any;
|
|
53
|
+
private revealedWidth: any;
|
|
54
|
+
private revealedHeight: any;
|
|
55
|
+
range: ListRange;
|
|
56
|
+
visibleEnd: number;
|
|
57
|
+
stats: {
|
|
58
|
+
measured: number;
|
|
59
|
+
hits: number;
|
|
60
|
+
};
|
|
61
|
+
constructor(measure: (item: T, width: number) => Line[], version: (item: T) => string, follow?: boolean, capacity?: number);
|
|
62
|
+
update(items: readonly T[]): void;
|
|
63
|
+
/** Item navigation uses only cached heights, never measures intervening history. */ selectionKey(key: Key, selected: string | undefined): string | undefined;
|
|
64
|
+
key(key: Key): boolean;
|
|
65
|
+
/** Move a rendered cursor; only visited items are measured. */ moveCursor(key: Key, point: RenderedCursor): RenderedCursor | undefined;
|
|
66
|
+
copyCursor(point: RenderedCursor): string;
|
|
67
|
+
/** Exact measured rows plus the observed average for unmeasured items.
|
|
68
|
+
* The estimate is presentation only: it never changes the scroll anchor.
|
|
69
|
+
*/ position(width: number): ScrollPosition;
|
|
70
|
+
layout(width: number, height: number, style?: string): Line[];
|
|
71
|
+
}
|
|
72
|
+
/** The viewport owns a bounded line cache, not thousands of mounted components.
|
|
73
|
+
* Width/style changes invalidate lazily, so resize only measures visible items.
|
|
74
|
+
*/ export declare let VirtualList: <T extends VirtualItem>({}: {
|
|
75
|
+
items: readonly T[];
|
|
76
|
+
/** Unloaded neighbors. Boundary requests never imply the data is empty. */ range?: ListRange;
|
|
77
|
+
onRange?: (request: RangeRequest) => void;
|
|
78
|
+
/** Controlled selected item; onSelect enables item-navigation keys. */ selected?: string;
|
|
79
|
+
cursor?: RenderedCursor;
|
|
80
|
+
onCursor?: (cursor: RenderedCursor) => void;
|
|
81
|
+
onYank?: (text: string, error?: boolean) => void;
|
|
82
|
+
/** Keep the logical selection while hiding its painted highlight. */ selectionClass?: string;
|
|
83
|
+
selectionVisible?: boolean;
|
|
84
|
+
onSelect?: (id: string) => void;
|
|
85
|
+
textOf?: (item: T) => string;
|
|
86
|
+
renderItem: (item: T) => ReactNode;
|
|
87
|
+
version?: (item: T) => string;
|
|
88
|
+
scrollbar?: boolean;
|
|
89
|
+
follow?: boolean;
|
|
90
|
+
/** Loading is not an authoritative empty item collection. */ pending?: boolean;
|
|
91
|
+
/** Controlled logical position; measurements and caches remain internal. */ value?: ViewportState;
|
|
92
|
+
onViewportChange?: (value: ViewportState) => void;
|
|
93
|
+
id?: string;
|
|
94
|
+
grow?: string;
|
|
95
|
+
height?: string;
|
|
96
|
+
}) => ReactElement<{
|
|
97
|
+
onWheel: (event: MouseEvent) => void;
|
|
98
|
+
ref: (el: unknown) => void;
|
|
99
|
+
scrollbar?: boolean;
|
|
100
|
+
id?: string;
|
|
101
|
+
grow?: string;
|
|
102
|
+
}>;
|
|
103
|
+
//# sourceMappingURL=VirtualList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VirtualList.d.ts","sources":["../VirtualList.ts"],"names":[],"mappings":"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"}
|
package/_dist/guide.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The style guide in a terminal: `yak ui`, a rendering mode of the CLI
|
|
3
|
+
* (in @yaks/cli). The guide a browser gets at `/ui` (@yaks/ui/guide), painted by
|
|
4
|
+
* @yaks/tui through each part's terminal sheet, and framed as the browser
|
|
5
|
+
* frames it: beside the page, a nav of the guide's contents under the theme
|
|
6
|
+
* switcher. The walk stops where the contents do (the whole guide, each
|
|
7
|
+
* group, each part), and the page is the one the walk is on.
|
|
8
|
+
*
|
|
9
|
+
* Keys: j and k walk the contents, and the page follows; ↑ ↓ PgUp PgDn
|
|
10
|
+
* scroll the page; t paints everything in the next theme; s switches skin; q quits. A press
|
|
11
|
+
* on an entry or a theme picks it.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/ import { type ReactElement } from "@types/react";
|
|
15
|
+
import type { Sheet } from "@yaks/ui/sheet";
|
|
16
|
+
/** A terminal guide instance, with its live composition sheet. */ export declare let terminalGuide: () => {
|
|
17
|
+
App: () => ReactElement;
|
|
18
|
+
sheet: () => Sheet;
|
|
19
|
+
};
|
|
20
|
+
/** Hold the style guide in this terminal until q or Ctrl-C. */ export declare let open: () => Promise<void>;
|
|
21
|
+
//# sourceMappingURL=guide.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guide.d.ts","sources":["../guide.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;CAaC,GAEyC,SAExC,KAAK,YAAY,uBAEM;AAGzB,cAAc,KAAK,8BAAmC;AAMtD,gEAAgE,GAChE,OAAO,YAAI;EACT,WAAW;EACX,aAAa;EAmId;AAED,6DAA6D,GAC7D,OAAO,YAAI,YAAiB,QAAQ,IAAI,EAGvC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HistoryEntry, HistoryPort } from "@yaks/ui/history";
|
|
2
|
+
export type { HistoryEntry, HistoryPort } from "@yaks/ui/history";
|
|
3
|
+
export type HistorySnapshot = {
|
|
4
|
+
entries: HistoryEntry[];
|
|
5
|
+
at: number;
|
|
6
|
+
};
|
|
7
|
+
export type TerminalHistory = HistoryPort & {
|
|
8
|
+
snapshot(): HistorySnapshot;
|
|
9
|
+
restore(snapshot: HistorySnapshot): void;
|
|
10
|
+
};
|
|
11
|
+
export declare let terminalHistory: (initial?: HistoryEntry) => TerminalHistory;
|
|
12
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sources":["../history.ts"],"names":[],"mappings":"AAEA,cAAc,YAAY,EAAE,WAAW,gCAAqC;AAE5E,cAAc,YAAY,EAAE,WAAW,gCAAqC;AAE5E,YAAY;EAAoB,SAAS;EAAgB,IAAI,MAAM;;AACnE,YAAY,kBAAkB;EAC5B,YAAY;EACZ,QAAQ,UAAU,kBAAkB,IAAI;;AAK1C,OAAO,YAAI,kBACT,UAAS,iBACR,gBA0CF"}
|
package/_dist/input.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raw stdin bytes as keys. A terminal cannot express Shift+Enter as a byte of
|
|
3
|
+
* its own — it collapses to CR, the same as a plain Enter — so `run` asks for
|
|
4
|
+
* the kitty keyboard protocol (`ESC[>1u`), under which modified and otherwise
|
|
5
|
+
* ambiguous keys report as CSI-u (`ESC [ code ; mods u`, mods = 1 + a
|
|
6
|
+
* shift/alt/ctrl bitmask). This decodes those, the legacy escape sequences
|
|
7
|
+
* every terminal still sends (arrows, home/end, page keys, SS3), SGR mouse
|
|
8
|
+
* wheel reports and bracketed paste, into one `Key` shape. Runs of printable
|
|
9
|
+
* characters come through as a single `char` key, so a fast typist and a
|
|
10
|
+
* pasted paragraph cost one render each.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/ /** What a key is: a name, its modifiers, and text for `char` and `paste`. */ export type Key = {
|
|
14
|
+
name: Name;
|
|
15
|
+
text?: string;
|
|
16
|
+
ctrl?: boolean;
|
|
17
|
+
alt?: boolean;
|
|
18
|
+
shift?: boolean;
|
|
19
|
+
};
|
|
20
|
+
/** SGR pointer report, in zero-based terminal cells (never a keyboard key). */ export type Mouse = {
|
|
21
|
+
name: 'mouse';
|
|
22
|
+
type: 'wheel' | 'mousedown' | 'mouseup' | 'mousemove';
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
button: number;
|
|
26
|
+
deltaX: number;
|
|
27
|
+
deltaY: number;
|
|
28
|
+
release: boolean;
|
|
29
|
+
shift: boolean;
|
|
30
|
+
alt: boolean;
|
|
31
|
+
ctrl: boolean;
|
|
32
|
+
};
|
|
33
|
+
export type Input = Key | Mouse;
|
|
34
|
+
/** The keys this decoder names. Anything else is dropped. */ export type Name = 'focusin' | 'focusout' | 'char' | 'enter' | 'escape' | 'tab' | 'backspace' | 'delete' | 'insert' | 'left' | 'right' | 'up' | 'down' | 'home' | 'end' | 'pageup' | 'pagedown' | 'paste' | 'wheelup' | 'wheeldown';
|
|
35
|
+
/**
|
|
36
|
+
* Decode one chunk. A bracketed paste without its terminator is taken whole,
|
|
37
|
+
* so a paste split across reads needs `feed()` rather than this.
|
|
38
|
+
*/ export declare let decode: (s: string) => Input[];
|
|
39
|
+
/** Read a chunk, or flush the Escape a chunk may have left held. */ export type Feed = ((chunk: string) => Input[]) & {
|
|
40
|
+
flush: () => Input[];
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Incremental keyboard decoder. Holds partial paste/control replies and routes
|
|
44
|
+
* APC/DCS replies away from keyboard handlers. Call flush after a short idle
|
|
45
|
+
* interval to dispatch a standalone Escape key.
|
|
46
|
+
*/ export declare let feed: (onControl?: (body: string) => void) => Feed;
|
|
47
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","sources":["../input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;CAYC,GAED,2EAA2E,GAC3E,YAAY;EACV,MAAM;EACN,OAAO,MAAM;EACb,OAAO,OAAO;EACd,MAAM,OAAO;EACb,QAAQ,OAAO;;AAGjB,6EAA6E,GAC7E,YAAY;EACV,MAAM;EACN,MAAM,UAAU,cAAc,YAAY;EAC1C,GAAG,MAAM;EACT,GAAG,MAAM;EACT,QAAQ,MAAM;EACd,QAAQ,MAAM;EACd,QAAQ,MAAM;EACd,SAAS,OAAO;EAChB,OAAO,OAAO;EACd,KAAK,OAAO;EACZ,MAAM,OAAO;;AAEf,YAAY,QAAQ,MAAM;AAE1B,2DAA2D,GAC3D,YAAY,OACR,YACA,aACA,SACA,UACA,WACA,QACA,cACA,WACA,WACA,SACA,UACA,OACA,SACA,SACA,QACA,WACA,aACA,UACA,YACA;AA0HJ;;;CAGC,GACD,OAAO,YAAI,SAAU,GAAG,MAAM,KAAG,QA0ChC;AAED,kEAAkE,GAClE,YAAY,SAAS,OAAO,MAAM,KAAK;EAAa,aAAa;;AAEjE;;;;CAIC,GACD,OAAO,YAAI,OACT,aAAY,MAAM,MAAM,KAAK,IAAI,KAChC,KAmFF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Keyboard focus and native form events for any tree painted by the
|
|
2
|
+
* terminal: what a browser does for its controls by itself. Tab walks them,
|
|
3
|
+
* Enter and Space press one, a field takes what is typed, Escape lets go, and
|
|
4
|
+
* every key is a keydown on the element in focus first, so a page's own
|
|
5
|
+
* listeners (vim's keys, @yaks/ux/keys) hear it as they would in a browser.
|
|
6
|
+
* The app owns links and history; this adapter knows only DOM controls. */ import { type TElement } from "@yaks/dom";
|
|
7
|
+
import type { Key } from "./input.js";
|
|
8
|
+
export declare let event: (node: TElement, type: string, props?: Record<string, unknown>) => Event;
|
|
9
|
+
export declare let interaction: (root: TElement, open: (href: string) => void) => {
|
|
10
|
+
press: (k: Key) => boolean;
|
|
11
|
+
focus: (node?: TElement) => void;
|
|
12
|
+
activate: (node: TElement) => void;
|
|
13
|
+
active: () => TElement | null;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=interaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction.d.ts","sources":["../interaction.ts"],"names":[],"mappings":"AAAA;;;;;yEAKyE,GACzE,SAAoC,KAAK,QAAQ,yBAA8B;AAE/E,cAAc,GAAG,qBAAoB;AAiBrC,OAAO,YAAI,QACT,MAAM,UACN,MAAM,MAAM,EACZ,QAAO,OAAO,MAAM,EAAE,OAAO,MAC5B,MAKF;AA+BD,OAAO,YAAI,cACT,MAAM,UACN,OAAO,MAAM,MAAM,KAAK,IAAI;EAE5B,QAAQ,GAAG,QAAQ,OAAO;EAC1B,QAAQ,OAAO,aAAa,IAAI;EAChC,WAAW,MAAM,aAAa,IAAI;EAClC,cAAc,WAAW,IAAI;EAgH9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keymap.d.ts","sources":["../keymap.ts"],"names":[],"mappings":"AAEA,cAAc,GAAG,qBAAoB;KAEhC,WAAW,KAAK,QAAQ,OAAO,GAAG,IAAI;AAQ3C,OAAO,YAAI,YAAa,SAAS,YAAU,IAAI,CAU9C"}
|
package/_dist/mod.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @yaks/tui renders a Preact tree to a terminal. Preact draws into a fake DOM
|
|
3
|
+
* (@yaks/dom); a backend turns that tree into what the screen shows. The
|
|
4
|
+
* backend that ships is a hand-written ANSI painter which repaints only the
|
|
5
|
+
* lines that changed, so a keystroke usually repaints a single line. Swap in
|
|
6
|
+
* another backend without changing a single widget.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createElement as h } from 'react'
|
|
10
|
+
* import { Frame, Scroll, Textarea, run } from '@yaks/tui'
|
|
11
|
+
*
|
|
12
|
+
* let App = () =>
|
|
13
|
+
* h(Frame, { sidebar: [{ title: 'Status', Render: () => h('div', null, 'ok') }] },
|
|
14
|
+
* h(Scroll, { id: 'log', grow: '1' }, h('div', null, 'hello')),
|
|
15
|
+
* h(Textarea, { onSubmit: (text: string) => console.log(text) }))
|
|
16
|
+
*
|
|
17
|
+
* if (import.meta.main) await run(App)
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @module
|
|
21
|
+
*/ export { dispatch, doc, install, onNavigate, onPaint, place, TElement, TNode, touch, TText } from "@yaks/dom";
|
|
22
|
+
export { decode, feed, type Key, type Name } from "./input.js";
|
|
23
|
+
export { ansi, ansiBackend, type Backend, clip, clipboard, lay, type Line, type Metrics, printout, screenful, type Seg, wrap } from "./paint.js";
|
|
24
|
+
export { base } from "./theme.js";
|
|
25
|
+
export type { Sheet, Style } from "@yaks/ui/sheet";
|
|
26
|
+
export { clear, type Keys, measured, metrics, press, size, useKeys, useMetric } from "./screen.js";
|
|
27
|
+
export { quit, run, useHold } from "./run.js";
|
|
28
|
+
export { print } from "./print.js";
|
|
29
|
+
export { Scroll, scrolled, type View } from "./Scroll.js";
|
|
30
|
+
export { bol, type Edit, edit, eol, spot, Textarea } from "./Textarea.js";
|
|
31
|
+
export { Frame, type Panel } from "./Frame.js";
|
|
32
|
+
export { type Anchor, type VirtualItem, VirtualList, VirtualWindow } from "./VirtualList.js";
|
|
33
|
+
export { hit, type MouseEvent, routeMouse } from "./mouse.js";
|
|
34
|
+
export type { Input, Mouse } from "./input.js";
|
|
35
|
+
export { emptyVisual, useTextSurface, useVisualController, type VisualState } from "./visual.js";
|
|
36
|
+
export { Image, type ImageSource, showing } from "./Image.js";
|
|
37
|
+
export { useKeymap } from "./keymap.js";
|
|
38
|
+
export { pressFocused, pressTo } from "./screen.js";
|
|
39
|
+
export { beginVisual, copyText, visualKey } from "./visual.js";
|
|
40
|
+
export { terminalFocused } from "./screen.js";
|
|
41
|
+
export type { RenderedCursor, TextPoint } from "./RenderedCursor.js";
|
|
42
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;CAoBC,GAED,SACE,QAAQ,EACR,GAAG,EACH,OAAO,EACP,UAAU,EACV,OAAO,EACP,KAAK,EACL,QAAQ,EACR,KAAK,EACL,KAAK,EACL,KAAK,yBACsB;AAC7B,SAAS,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI,qBAAoB;AAC9D,SACE,IAAI,EACJ,WAAW,EACX,KAAK,OAAO,EACZ,IAAI,EACJ,SAAS,EACT,GAAG,EACH,KAAK,IAAI,EACT,KAAK,OAAO,EACZ,QAAQ,EACR,SAAS,EACT,KAAK,GAAG,EACR,IAAI,qBACa;AACnB,SAAS,IAAI,qBAAoB;AACjC,cAAc,KAAK,EAAE,KAAK,8BAAmC;AAC7D,SACE,KAAK,EACL,KAAK,IAAI,EACT,QAAQ,EACR,OAAO,EACP,KAAK,EACL,IAAI,EACJ,OAAO,EACP,SAAS,sBACS;AACpB,SAAS,IAAI,EAAE,GAAG,EAAE,OAAO,mBAAkB;AAC7C,SAAS,KAAK,qBAAoB;AAClC,SAAS,MAAM,EAAE,QAAQ,EAAE,KAAK,IAAI,sBAAqB;AACzD,SAAS,GAAG,EAAE,KAAK,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,wBAAuB;AACzE,SAAS,KAAK,EAAE,KAAK,KAAK,qBAAoB;AAC9C,SACE,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,WAAW,EACX,aAAa,2BACU;AAEzB,SAAS,GAAG,EAAE,KAAK,UAAU,EAAE,UAAU,qBAAoB;AAC7D,cAAc,KAAK,EAAE,KAAK,qBAAoB;AAE9C,SACE,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,KAAK,WAAW,sBACE;AAEpB,SAAS,KAAK,EAAE,KAAK,WAAW,EAAE,OAAO,qBAAoB;AAE7D,SAAS,SAAS,sBAAqB;AACvC,SAAS,YAAY,EAAE,OAAO,sBAAqB;AACnD,SAAS,WAAW,EAAE,QAAQ,EAAE,SAAS,sBAAqB;AAE9D,SAAS,eAAe,sBAAqB;AAE7C,cAAc,cAAc,EAAE,SAAS,8BAA6B"}
|
package/_dist/mouse.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TElement } from "@yaks/dom";
|
|
2
|
+
import type { Mouse } from "./input.js";
|
|
3
|
+
import type { Line } from "./paint.js";
|
|
4
|
+
/** DOM-compatible event delivered to Preact onWheel/onMouseDown/onMouseUp. */ export type MouseEvent = Omit<Mouse, 'type'> & {
|
|
5
|
+
type: Mouse['type'] | 'click';
|
|
6
|
+
target: TElement;
|
|
7
|
+
currentTarget: TElement | null;
|
|
8
|
+
defaultPrevented: boolean;
|
|
9
|
+
cancelBubble: boolean;
|
|
10
|
+
preventDefault(): void;
|
|
11
|
+
stopPropagation(): void;
|
|
12
|
+
};
|
|
13
|
+
/** Hit only cells present in the most recent clipped paint, not logical bounds. */ export declare let hit: (lines: Line[], x: number, y: number) => TElement | undefined;
|
|
14
|
+
/** Return true when consumed. A missed report never falls into keyboard focus. */ export declare let routeMouse: (report: Mouse, lines: Line[]) => boolean;
|
|
15
|
+
//# sourceMappingURL=mouse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mouse.d.ts","sources":["../mouse.ts"],"names":[],"mappings":"AACA,SAAS,QAAQ,yBAA8B;AAC/C,cAAc,KAAK,qBAAoB;AACvC,cAAc,IAAI,qBAAoB;AAEtC,4EAA4E,GAC5E,YAAY,aAAa,KAAK,OAAO;EACnC,MAAM,MAAM,UAAU;EACtB,QAAQ;EACR,eAAe,WAAW,IAAI;EAC9B,kBAAkB,OAAO;EACzB,cAAc,OAAO;EACrB,kBAAkB,IAAI;EACtB,mBAAmB,IAAI;;AAGzB,iFAAiF,GACjF,OAAO,YAAI,MACT,OAAO,QACP,GAAG,MAAM,EACT,GAAG,MAAM,KACR,WAAW,SAAS,CAOtB;AAkBD,gFAAgF,GAChF,OAAO,YAAI,aAAc,QAAQ,OAAO,OAAO,WAAS,OAAO,CAkD9D"}
|
package/_dist/paint.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { TElement } from "@yaks/dom";
|
|
2
|
+
import type { Sheet, Style } from "@yaks/ui/sheet";
|
|
3
|
+
import type { ImageSource } from "./Image.js";
|
|
4
|
+
/** A run of text under one style. */ export type Seg = {
|
|
5
|
+
/** Layout decoration, excluded from text selection copies. */ decorative?: boolean;
|
|
6
|
+
/** This segment ends a visual wrap, not a source line break. */ softBreak?: boolean;
|
|
7
|
+
text: string;
|
|
8
|
+
style: Style;
|
|
9
|
+
owner?: TElement;
|
|
10
|
+
image?: {
|
|
11
|
+
source: ImageSource;
|
|
12
|
+
row: number;
|
|
13
|
+
rows: number;
|
|
14
|
+
width: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
/** One screen line, as styled runs. */ export type Line = Seg[];
|
|
18
|
+
/** What a scroll region measured on the last paint, per element id: its
|
|
19
|
+
* content lines, the rows it shows, its width, and the first line of the
|
|
20
|
+
* element inside it marked `reveal`, where one is. */ export type Metrics = Record<string, {
|
|
21
|
+
total: number;
|
|
22
|
+
height: number;
|
|
23
|
+
width: number;
|
|
24
|
+
reveal?: number;
|
|
25
|
+
}>;
|
|
26
|
+
/** The five calls `run()` makes of whatever draws the screen. */ export type Backend = {
|
|
27
|
+
/** Receive an APC/DCS terminal protocol response, never keyboard text. */ control?: (body: string) => void;
|
|
28
|
+
/** The terminal's size, in cells. */ size: () => {
|
|
29
|
+
columns: number;
|
|
30
|
+
rows: number;
|
|
31
|
+
};
|
|
32
|
+
/** Take the screen (alt screen, raw mode's escapes, hidden cursor). */ start: () => void;
|
|
33
|
+
/** Paint the tree; report lines written and what was measured. */ draw: (root: TElement) => {
|
|
34
|
+
written: number;
|
|
35
|
+
metrics: Metrics;
|
|
36
|
+
lines?: Line[];
|
|
37
|
+
/** what the sheet hid */ hidden?: Set<TElement>;
|
|
38
|
+
};
|
|
39
|
+
/** Forget what is on screen, so the next draw repaints every line. */ reset: () => void;
|
|
40
|
+
/** Request clipboard write; terminals may deny it. */ copy?: (text: string) => void;
|
|
41
|
+
/** Give the screen back exactly as it was found. */ stop: () => void;
|
|
42
|
+
};
|
|
43
|
+
type Ctx = {
|
|
44
|
+
sheet: Sheet;
|
|
45
|
+
metrics: Metrics;
|
|
46
|
+
spaced?: boolean;
|
|
47
|
+
columns?: number[];
|
|
48
|
+
/** what the sheet hid, for elements to say they don't show */ hidden?: Set<TElement>;
|
|
49
|
+
};
|
|
50
|
+
/** Ownership travels with the painted cells through windowing, wrapping and clipping. */ export declare let lay: (el: TElement, st: Style, w: number, h: number | null, c: Ctx) => Line[];
|
|
51
|
+
/** Cut a line to a column count, keeping whole segments where it can; with
|
|
52
|
+
* `ellipsis`, a line that is cut ends in `…`. */ export declare let clip: (line: Line, w: number, ellipsis?: boolean) => Line;
|
|
53
|
+
/** Fold at word boundaries (hard-fold long words), preserving every styled
|
|
54
|
+
* character. Uses the same column units as clip; runs before scroll measures. */ export declare let wrap: (line: Line, columns: number) => Line[];
|
|
55
|
+
/** The bytes a line becomes — every escape the terminal sees is emitted here. */ export declare let ansi: (line: Line) => string;
|
|
56
|
+
/** The whole screen a tree produces at a given size — the function the tests
|
|
57
|
+
* assert against. */ export declare let screenful: (root: TElement, columns: number, rows: number, sheet?: Sheet) => {
|
|
58
|
+
lines: Line[];
|
|
59
|
+
metrics: Metrics;
|
|
60
|
+
hidden: Set<TElement>;
|
|
61
|
+
};
|
|
62
|
+
/** A tree painted once, as tall as it is, for a command that prints and exits:
|
|
63
|
+
* the layout and escapes a held screen gets, folded at word boundaries to the
|
|
64
|
+
* terminal's width, with no screen kept. `sheet` extends {@link base}, as it
|
|
65
|
+
* does for {@link ansiBackend}. */ export declare let printout: (root: TElement, columns: number, sheet?: Sheet) => string;
|
|
66
|
+
/**
|
|
67
|
+
* OSC 52: hand text to the clipboard through the terminal — the escape travels
|
|
68
|
+
* the tty like any output, so it works across ssh (tmux needs set-clipboard on).
|
|
69
|
+
*/ export declare let clipboard: (text: string) => string;
|
|
70
|
+
/**
|
|
71
|
+
* The ANSI backend. Paints only the lines that changed since the last frame:
|
|
72
|
+
* a keystroke moves one line, so a keystroke writes one line. `size` and
|
|
73
|
+
* `write` are injected so a test can drive it without a terminal. A `sheet`
|
|
74
|
+
* given as a function is read at every paint, so the theme can change while
|
|
75
|
+
* the app runs.
|
|
76
|
+
*/ export declare let ansiBackend: (opts?: {
|
|
77
|
+
sheet?: Sheet | (() => Sheet);
|
|
78
|
+
size?: () => {
|
|
79
|
+
columns: number;
|
|
80
|
+
rows: number;
|
|
81
|
+
};
|
|
82
|
+
write?: (s: string) => void;
|
|
83
|
+
graphics?: 'kitty' | 'none';
|
|
84
|
+
tmux?: boolean;
|
|
85
|
+
}) => Backend;
|
|
86
|
+
//# sourceMappingURL=paint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paint.d.ts","sources":["../paint.ts"],"names":[],"mappings":"AAwCA,cAAc,QAAQ,yBAAqC;AAK3D,cAAc,KAAK,EAAE,KAAK,8BAAmC;AAE7D,cAAc,WAAW,qBAAoB;AAE7C,mCAAmC,GACnC,YAAY;EACV,4DAA4D,GAC5D,aAAa,OAAO;EACpB,8DAA8D,GAC9D,YAAY,OAAO;EACnB,MAAM,MAAM;EACZ,OAAO;EACP,QAAQ;EACR;IACE,QAAQ;IACR,KAAK,MAAM;IACX,MAAM,MAAM;IACZ,OAAO,MAAM;;;AAmBjB,qCAAqC,GACrC,YAAY,OAAO;AACnB;;oDAEoD,GACpD,YAAY,UAAU,OACpB,MAAM;EACJ,OAAO,MAAM;EAAE,QAAQ,MAAM;EAAE,OAAO,MAAM;EAAE,SAAS,MAAM;;AAGjE,+DAA+D,GAC/D,YAAY;EACV,wEAAwE,GACxE,WAAW,MAAM,MAAM,KAAK,IAAI;EAChC,mCAAmC,GACnC;IAAc,SAAS,MAAM;IAAE,MAAM,MAAM;;EAC3C,qEAAqE,GACrE,aAAa,IAAI;EACjB,gEAAgE,GAChE,OACE,MAAM;IAEN,SAAS,MAAM;IACf,SAAS;IACT,QAAQ;IACR,uBAAuB,GACvB,SAAS,IAAI;;EAEf,oEAAoE,GACpE,aAAa,IAAI;EACjB,oDAAoD,GACpD,QAAQ,MAAM,MAAM,KAAK,IAAI;EAC7B,kDAAkD,GAClD,YAAY,IAAI;;KAyFb;EACH,OAAO;EACP,SAAS;EACT,SAAS,OAAO;EAChB,UAAU,MAAM;EAChB,4DAA4D,GAC5D,SAAS,IAAI;;AA0jBf,uFAAuF,GACvF,OAAO,YAAI,MACT,IAAI,UACJ,IAAI,OACJ,GAAG,MAAM,EACT,GAAG,MAAM,GAAG,IAAI,EAChB,GAAG,QACF,OAWF;AAsCD;+CAC+C,GAC/C,OAAO,YAAI,OAAQ,MAAM,MAAM,GAAG,MAAM,EAAE,uBAAmB,KAkB5D;AAED;+EAC+E,GAC/E,OAAO,YAAI,OAAQ,MAAM,MAAM,SAAS,MAAM,KAAG,OAmChD;AAWD,+EAA+E,GAC/E,OAAO,YAAI,OAAQ,MAAM,SAAO,MAAM,CAezB;AAEb;mBACmB,GACnB,OAAO,YAAI,YACT,MAAM,UACN,SAAS,MAAM,EACf,MAAM,MAAM,EACZ,QAAO;EACJ,OAAO;EAAQ,SAAS;EAAS,QAAQ,IAAI;EAIjD;AAED;;;iCAGiC,GACjC,OAAO,YAAI,WACT,MAAM,UACN,SAAS,MAAM,EACf,QAAO,UACN,MAAM,CAOR;AAID;;;CAGC,GACD,OAAO,YAAI,YAAa,MAAM,MAAM,KAAG,MAAM,CAGrC;AA8BR;;;;;;CAMC,GACD,OAAO,YAAI,cAAe;EACxB,QAAQ,eAAe;EACvB;IAAe,SAAS,MAAM;IAAE,MAAM,MAAM;;EAC5C,SAAS,GAAG,MAAM,KAAK,IAAI;EAC3B,WAAW,UAAU;EACrB,OAAO,OAAO;MACP,QAiDR"}
|
package/_dist/print.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Preact tree painted once, for a command that prints and exits: mounted in
|
|
3
|
+
* the fake document, laid out and colored by the ANSI painter at `columns`
|
|
4
|
+
* wide, then unmounted, with no screen taken and nothing held. Its own entry
|
|
5
|
+
* (`@yaks/tui/print`), so a printout loads the painter without the widgets.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { assertEquals } from '@std/assert'
|
|
9
|
+
* import { createElement as h } from 'react'
|
|
10
|
+
* import { print } from '@yaks/tui/print'
|
|
11
|
+
*
|
|
12
|
+
* let tree = h('dl', null, h('dt', null, 'size'), h('dd', null, h('b', null, 'big')))
|
|
13
|
+
* assertEquals(print(tree, 40), 'size: \x1b[1mbig\x1b[0m')
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/ import type { ReactNode } from "@types/react";
|
|
18
|
+
import type { Sheet } from "@yaks/ui/sheet";
|
|
19
|
+
/** The text a terminal prints for `node`; `sheet` extends the widgets' `base`. */ export declare let print: (node: ReactNode, columns: number, sheet?: Sheet) => string;
|
|
20
|
+
//# sourceMappingURL=print.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print.d.ts","sources":["../print.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;CAgBC,GAEyC,cAAc,SAAS,uBAA0B;AAI3F,cAAc,KAAK,8BAAmC;AAEtD,gFAAgF,GAChF,OAAO,YAAI,QACT,MAAM,WACN,SAAS,MAAM,EACf,QAAO,UACN,MAAM,CAUR"}
|
package/_dist/run.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ComponentType } from "@types/react";
|
|
2
|
+
import { install } from "@yaks/dom";
|
|
3
|
+
import { type Backend } from "./paint.js";
|
|
4
|
+
import type { Sheet } from "@yaks/ui/sheet";
|
|
5
|
+
/** Hold the exit open while this component finishes: the first interrupt
|
|
6
|
+
* waits for `drain`, a second calls `force`. Let go when it unmounts. */ export declare let useHold: (drain: () => Promise<unknown>, force?: () => void) => void;
|
|
7
|
+
/** Ask the running app to exit; the terminal is restored on the way out. */ export declare let quit: () => void;
|
|
8
|
+
/**
|
|
9
|
+
* Run an app until it quits. `backend` swaps the renderer (the ANSI painter by
|
|
10
|
+
* default); `sheet` extends the widgets' `base`, and as a function it is read
|
|
11
|
+
* at every paint; Ctrl-C interrupts the process ({@link useHold}).
|
|
12
|
+
*/ export declare let run: (App: ComponentType, opts?: {
|
|
13
|
+
screen?: ReturnType<typeof install>;
|
|
14
|
+
backend?: Backend;
|
|
15
|
+
sheet?: Sheet | (() => Sheet);
|
|
16
|
+
graphics?: 'kitty' | 'none';
|
|
17
|
+
tmux?: boolean;
|
|
18
|
+
}) => Promise<void>;
|
|
19
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sources":["../run.ts"],"names":[],"mappings":"AAkB0C,SAAS,KAAK,aAAa,uBAAyD;AAG9H,SAAS,OAAO,yBAAqD;AACrE,SAAsB,KAAK,OAAO,qBAAoB;AAKtD,cAAc,KAAK,8BAAmC;AAStD;uEACuE,GACvE,OAAO,YAAI,UACT,aAAa,QAAQ,OAAO,GAC5B,cAAc,IAAI,KACjB,IAAI,CAKa;AAgCpB,0EAA0E,GAC1E,OAAO,YAAI,YAAW,IAAI,CAAa;AAEvC;;;;CAIC,GACD,OAAO,YAAI,MACT,KAAK,eACL;EACE,SAAS,kBAAkB;EAC3B,UAAU;EACV,QAAQ,eAAe;EACvB,WAAW,UAAU;EACrB,OAAO,OAAO;MAEf,QAAQ,IAAI,EA6Id"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Signal } from "@preact/signals-core";
|
|
2
|
+
import type { Key } from "./input.js";
|
|
3
|
+
import type { Metrics } from "./paint.js";
|
|
4
|
+
/** The terminal's size in cells, kept current by `run`. */ export declare let size: Signal<{
|
|
5
|
+
columns: number;
|
|
6
|
+
rows: number;
|
|
7
|
+
}>;
|
|
8
|
+
/** Terminal focus reporting is independent of application/widget focus.
|
|
9
|
+
* Defaults to focused when the terminal does not send focus reports. */ export declare let terminalFocused: Signal<boolean>;
|
|
10
|
+
/** What the last paint measured, per element id. */ export declare let metrics: Signal<Metrics>;
|
|
11
|
+
/** What a key handler returns: true when it consumed the key. */ export type Keys = (key: Key) => boolean | void;
|
|
12
|
+
/** Deliver a command to a named widget without changing keyboard focus. */ export declare let pressTo: (id: string, key: Key) => boolean;
|
|
13
|
+
/** Offer a key to the focus stack, topmost first. */ export declare let press: (key: Key) => boolean;
|
|
14
|
+
/** Forward an already-routed key to the focused widget stack. */ export declare let pressFocused: (key: Key) => boolean;
|
|
15
|
+
/** Take keys while this component is mounted; the newest mount has focus. */ export declare let useKeys: (fn: Keys, id?: string) => void;
|
|
16
|
+
type Metric = Metrics[string];
|
|
17
|
+
/** What the painter measured for an element id on the last paint, or one of
|
|
18
|
+
* its measures. */ export declare function useMetric(id: string): Metric;
|
|
19
|
+
export declare function useMetric<K extends keyof Metric>(id: string, key: K): Metric[K];
|
|
20
|
+
/** Publish a paint's measurements; unchanged measurements re-render nothing. */ export declare let measured: (next: Metrics) => void;
|
|
21
|
+
/** Forget the focus stack — for a test that mounts more than one app. */ export declare let clear: () => void;
|
|
22
|
+
//# sourceMappingURL=screen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screen.d.ts","sources":["../screen.ts"],"names":[],"mappings":"AAcA,SAAmB,KAAK,MAAM,+BAAiD;AAQ/E,cAAc,GAAG,qBAAoB;AACrC,cAAc,OAAO,qBAAoB;AAEzC,yDAAyD,GACzD,OAAO,YAAI,MAAM;EAAS,SAAS,MAAM;EAAE,MAAM,MAAM;GAGrD;AAEF;sEACsE,GACtE,OAAO,YAAI,iBAAiB,OAAO,OAAO,EAAgB;AAE1D,kDAAkD,GAClD,OAAO,YAAI,SAAS,OAAO,SAA8B;AAEzD,+DAA+D,GAC/D,YAAY,QAAQ,KAAK,QAAQ,OAAO,GAAG,IAAI;AAK/C,yEAAyE,GACzE,OAAO,YAAI,UAAW,IAAI,MAAM,EAAE,KAAK,QAAM,OAAO,CAA4B;AAEhF,mDAAmD,GACnD,OAAO,YAAI,QAAS,KAAK,QAAM,OAAO,CAQrC;AAED,+DAA+D,GAC/D,OAAO,YAAI,eAAgB,KAAK,QAAM,OAAO,CAG5C;AAED,2EAA2E,GAC3E,OAAO,YAAI,UAAW,IAAI,MAAM,KAAK,MAAM,KAAG,IAAI,CAwBjD;KAEI,SAAS,QAAQ,MAAM;AAW5B;iBACiB,GACjB,OAAO,iBAAS,UAAU,IAAI,MAAM,GAAG;AACvC,OAAO,iBAAS,UAAU,gBAAgB,QAAQ,IAAI,MAAM,EAAE,KAAK,CAAC,GAAG,OAAO;AAkB9E,8EAA8E,GAC9E,OAAO,YAAI,WAAY,MAAM,YAAU,IAAI,CAQ1C;AAED,uEAAuE,GACvE,OAAO,YAAI,aAAY,IAAI,CAG1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrollbar.d.ts","sources":["../scrollbar.ts"],"names":[],"mappings":"AAIA,YAAY;EACV,OAAO,MAAM;EACb,KAAK,MAAM;EACX,QAAQ,MAAM;EACd,QAAQ,OAAO"}
|