@suds-cli/tea 0.0.0 → 0.1.0-alpha.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.
Files changed (49) hide show
  1. package/README.md +260 -0
  2. package/dist/index.cjs +1125 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +337 -0
  5. package/dist/index.d.ts +337 -12
  6. package/dist/index.js +1084 -51
  7. package/dist/index.js.map +1 -1
  8. package/package.json +30 -18
  9. package/dist/commands.d.ts +0 -27
  10. package/dist/commands.d.ts.map +0 -1
  11. package/dist/commands.js +0 -106
  12. package/dist/commands.js.map +0 -1
  13. package/dist/index.d.ts.map +0 -1
  14. package/dist/input.d.ts +0 -8
  15. package/dist/input.d.ts.map +0 -1
  16. package/dist/input.js +0 -98
  17. package/dist/input.js.map +0 -1
  18. package/dist/keys.d.ts +0 -86
  19. package/dist/keys.d.ts.map +0 -1
  20. package/dist/keys.js +0 -317
  21. package/dist/keys.js.map +0 -1
  22. package/dist/messages.d.ts +0 -78
  23. package/dist/messages.d.ts.map +0 -1
  24. package/dist/messages.js +0 -104
  25. package/dist/messages.js.map +0 -1
  26. package/dist/mouse.d.ts +0 -46
  27. package/dist/mouse.d.ts.map +0 -1
  28. package/dist/mouse.js +0 -167
  29. package/dist/mouse.js.map +0 -1
  30. package/dist/program.d.ts +0 -39
  31. package/dist/program.d.ts.map +0 -1
  32. package/dist/program.js +0 -231
  33. package/dist/program.js.map +0 -1
  34. package/dist/renderer.d.ts +0 -19
  35. package/dist/renderer.d.ts.map +0 -1
  36. package/dist/renderer.js +0 -49
  37. package/dist/renderer.js.map +0 -1
  38. package/dist/screen.d.ts +0 -22
  39. package/dist/screen.d.ts.map +0 -1
  40. package/dist/screen.js +0 -35
  41. package/dist/screen.js.map +0 -1
  42. package/dist/terminal.d.ts +0 -32
  43. package/dist/terminal.d.ts.map +0 -1
  44. package/dist/terminal.js +0 -119
  45. package/dist/terminal.js.map +0 -1
  46. package/dist/types.d.ts +0 -36
  47. package/dist/types.d.ts.map +0 -1
  48. package/dist/types.js +0 -3
  49. package/dist/types.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,12 +1,337 @@
1
- export { Program, type ProgramOptions } from "./program.js";
2
- export type { Msg, Cmd, Model, ProgramResult } from "./types.js";
3
- export { QuitMsg, InterruptMsg, SuspendMsg, ResumeMsg, WindowSizeMsg, FocusMsg, BlurMsg, ClearScreenMsg, EnterAltScreenMsg, ExitAltScreenMsg, EnableMouseCellMotionMsg, EnableMouseAllMotionMsg, DisableMouseMsg, ShowCursorMsg, HideCursorMsg, EnableReportFocusMsg, DisableReportFocusMsg, SetWindowTitleMsg, } from "./messages.js";
4
- export { KeyMsg, KeyType, type Key, keyToString } from "./keys.js";
5
- export { MouseMsg, MouseAction, MouseButton, type MouseEvent, } from "./mouse.js";
6
- export { type InputOptions } from "./input.js";
7
- export { type TerminalOptions } from "./terminal.js";
8
- export { type RendererOptions } from "./renderer.js";
9
- export { type EffectFn } from "./types.js";
10
- export { batch, sequence, tick, every, quit, msg } from "./commands.js";
11
- export { clearScreen, enableMouseCellMotion, enableMouseAllMotion, disableMouse, showCursor, hideCursor, setWindowTitle, windowSize, } from "./screen.js";
12
- //# sourceMappingURL=index.d.ts.map
1
+ import { PlatformAdapter } from '@suds-cli/machine';
2
+
3
+ /**
4
+ * Message - any value that triggers an update.
5
+ */
6
+ /**
7
+ * @public
8
+ * Message - must be discriminated for safe matching.
9
+ */
10
+ type Msg = {
11
+ readonly _tag: string;
12
+ };
13
+ type Effect<M extends Msg = Msg> = M | M[] | null | undefined;
14
+ /** @public Function producing an effectful message or messages. */
15
+ type EffectFn<M extends Msg = Msg> = () => Effect<M> | Promise<Effect<M>>;
16
+ /**
17
+ * @public
18
+ * Command - an async side effect that eventually yields a message.
19
+ * Use `null` to indicate no-op.
20
+ */
21
+ type Cmd<M extends Msg = Msg> = EffectFn<M> | null;
22
+ /**
23
+ * @public
24
+ * Elm-like model contract.
25
+ */
26
+ interface Model<M extends Msg = Msg, Self extends Model<M, Self> = any> {
27
+ init(): Cmd<M>;
28
+ update(msg: M): [Self, Cmd<M>];
29
+ view(): string;
30
+ }
31
+ /** @public Outcome of running a program. */
32
+ type ProgramResult<M extends Model> = {
33
+ model: M;
34
+ error?: unknown;
35
+ };
36
+
37
+ /** @public Configure program runtime options. */
38
+ interface ProgramOptions {
39
+ altScreen?: boolean;
40
+ mouseMode?: 'cell' | 'all' | false;
41
+ platform?: PlatformAdapter;
42
+ fps?: number;
43
+ reportFocus?: boolean;
44
+ bracketedPaste?: boolean;
45
+ }
46
+ /** @public Bubble Tea-style program runner. */
47
+ declare class Program<M extends Model<Msg, M>> {
48
+ private model;
49
+ private readonly terminal;
50
+ private readonly renderer;
51
+ private readonly opts;
52
+ private readonly platform;
53
+ private stopInput?;
54
+ private running;
55
+ private queue;
56
+ private draining;
57
+ private result;
58
+ private resolveWait?;
59
+ constructor(model: M, options?: ProgramOptions);
60
+ run(): Promise<ProgramResult<M>>;
61
+ private waitUntilDone;
62
+ send(msg: Msg): void;
63
+ quit(): void;
64
+ kill(): void;
65
+ private drainQueue;
66
+ private handleInternal;
67
+ private runCmd;
68
+ private setupTerminal;
69
+ private startInputLoop;
70
+ private setupSignals;
71
+ private disposeSignals;
72
+ private onSigInt;
73
+ private onSigTerm;
74
+ private shutdown;
75
+ }
76
+
77
+ /** @public Request graceful program termination. */
78
+ declare class QuitMsg {
79
+ readonly _tag = "quit";
80
+ }
81
+ /** @public Interrupt the program (SIGINT). */
82
+ declare class InterruptMsg {
83
+ readonly _tag = "interrupt";
84
+ }
85
+ /** @public Suspend the program (Ctrl+Z). */
86
+ declare class SuspendMsg {
87
+ readonly _tag = "suspend";
88
+ }
89
+ /** @public Resume the program after suspension. */
90
+ declare class ResumeMsg {
91
+ readonly _tag = "resume";
92
+ }
93
+ /** @public Report the current terminal width and height. */
94
+ declare class WindowSizeMsg {
95
+ readonly width: number;
96
+ readonly height: number;
97
+ readonly _tag = "window-size";
98
+ constructor(width: number, height: number);
99
+ }
100
+ /** @public Terminal focus gained. */
101
+ declare class FocusMsg {
102
+ readonly _tag = "focus";
103
+ }
104
+ /** @public Terminal focus lost. */
105
+ declare class BlurMsg {
106
+ readonly _tag = "blur";
107
+ }
108
+ /** @public Clear the terminal screen. */
109
+ declare class ClearScreenMsg {
110
+ readonly _tag = "clear-screen";
111
+ }
112
+ /** @public Enter the alternate screen buffer. */
113
+ declare class EnterAltScreenMsg {
114
+ readonly _tag = "enter-alt-screen";
115
+ }
116
+ /** @public Exit the alternate screen buffer. */
117
+ declare class ExitAltScreenMsg {
118
+ readonly _tag = "exit-alt-screen";
119
+ }
120
+ /** @public Enable cell-based mouse reporting. */
121
+ declare class EnableMouseCellMotionMsg {
122
+ readonly _tag = "enable-mouse-cell-motion";
123
+ }
124
+ /** @public Enable all-motion mouse reporting. */
125
+ declare class EnableMouseAllMotionMsg {
126
+ readonly _tag = "enable-mouse-all-motion";
127
+ }
128
+ /** @public Disable mouse reporting. */
129
+ declare class DisableMouseMsg {
130
+ readonly _tag = "disable-mouse";
131
+ }
132
+ /** @public Show the cursor. */
133
+ declare class ShowCursorMsg {
134
+ readonly _tag = "show-cursor";
135
+ }
136
+ /** @public Hide the cursor. */
137
+ declare class HideCursorMsg {
138
+ readonly _tag = "hide-cursor";
139
+ }
140
+ /** @public Enable focus in/out reporting. */
141
+ declare class EnableReportFocusMsg {
142
+ readonly _tag = "enable-report-focus";
143
+ }
144
+ /** @public Disable focus in/out reporting. */
145
+ declare class DisableReportFocusMsg {
146
+ readonly _tag = "disable-report-focus";
147
+ }
148
+ /** @public Set the terminal window title. */
149
+ declare class SetWindowTitleMsg {
150
+ readonly title: string;
151
+ readonly _tag = "set-window-title";
152
+ constructor(title: string);
153
+ }
154
+
155
+ /** @public Known key types parsed from terminal input. */
156
+ declare enum KeyType {
157
+ Null = "null",
158
+ Break = "break",
159
+ Enter = "enter",
160
+ Backspace = "backspace",
161
+ Tab = "tab",
162
+ Esc = "esc",
163
+ Space = "space",
164
+ Runes = "runes",
165
+ Up = "up",
166
+ Down = "down",
167
+ Right = "right",
168
+ Left = "left",
169
+ ShiftTab = "shift+tab",
170
+ Home = "home",
171
+ End = "end",
172
+ PgUp = "pgup",
173
+ PgDown = "pgdown",
174
+ CtrlPgUp = "ctrl+pgup",
175
+ CtrlPgDown = "ctrl+pgdown",
176
+ Delete = "delete",
177
+ Insert = "insert",
178
+ CtrlUp = "ctrl+up",
179
+ CtrlDown = "ctrl+down",
180
+ CtrlRight = "ctrl+right",
181
+ CtrlLeft = "ctrl+left",
182
+ CtrlHome = "ctrl+home",
183
+ CtrlEnd = "ctrl+end",
184
+ ShiftUp = "shift+up",
185
+ ShiftDown = "shift+down",
186
+ ShiftRight = "shift+right",
187
+ ShiftLeft = "shift+left",
188
+ ShiftHome = "shift+home",
189
+ ShiftEnd = "shift+end",
190
+ CtrlShiftUp = "ctrl+shift+up",
191
+ CtrlShiftDown = "ctrl+shift+down",
192
+ CtrlShiftLeft = "ctrl+shift+left",
193
+ CtrlShiftRight = "ctrl+shift+right",
194
+ CtrlShiftHome = "ctrl+shift+home",
195
+ CtrlShiftEnd = "ctrl+shift+end",
196
+ F1 = "f1",
197
+ F2 = "f2",
198
+ F3 = "f3",
199
+ F4 = "f4",
200
+ F5 = "f5",
201
+ F6 = "f6",
202
+ F7 = "f7",
203
+ F8 = "f8",
204
+ F9 = "f9",
205
+ F10 = "f10",
206
+ F11 = "f11",
207
+ F12 = "f12",
208
+ F13 = "f13",
209
+ F14 = "f14",
210
+ F15 = "f15",
211
+ F16 = "f16",
212
+ F17 = "f17",
213
+ F18 = "f18",
214
+ F19 = "f19",
215
+ F20 = "f20"
216
+ }
217
+ /** @public Parsed key metadata. */
218
+ interface Key {
219
+ type: KeyType;
220
+ runes: string;
221
+ alt: boolean;
222
+ paste: boolean;
223
+ }
224
+ /** @public Message representing a parsed key event. */
225
+ declare class KeyMsg {
226
+ readonly key: Key;
227
+ readonly _tag = "key";
228
+ constructor(key: Key);
229
+ toString(): string;
230
+ }
231
+ /** @public Convert a parsed key to a human-readable string. */
232
+ declare function keyToString(key: Key): string;
233
+
234
+ /** @public Mouse action type. */
235
+ declare enum MouseAction {
236
+ Press = "press",
237
+ Release = "release",
238
+ Motion = "motion"
239
+ }
240
+ /** @public Mouse button identifiers, including wheels. */
241
+ declare enum MouseButton {
242
+ None = "none",
243
+ Left = "left",
244
+ Middle = "middle",
245
+ Right = "right",
246
+ WheelUp = "wheel-up",
247
+ WheelDown = "wheel-down",
248
+ WheelLeft = "wheel-left",
249
+ WheelRight = "wheel-right",
250
+ Backward = "backward",
251
+ Forward = "forward",
252
+ Button10 = "button-10",
253
+ Button11 = "button-11"
254
+ }
255
+ /** @public Parsed mouse event payload. */
256
+ interface MouseEvent {
257
+ x: number;
258
+ y: number;
259
+ shift: boolean;
260
+ alt: boolean;
261
+ ctrl: boolean;
262
+ action: MouseAction;
263
+ button: MouseButton;
264
+ }
265
+ /** @public Message representing a parsed mouse event. */
266
+ declare class MouseMsg {
267
+ readonly event: MouseEvent;
268
+ readonly _tag = "mouse";
269
+ constructor(event: MouseEvent);
270
+ toString(): string;
271
+ }
272
+
273
+ /** @public Options for the input reader. */
274
+ interface InputOptions {
275
+ platform?: PlatformAdapter;
276
+ onMessage: (msg: Msg) => void;
277
+ }
278
+
279
+ /** @public Options for the terminal controller. */
280
+ interface TerminalOptions {
281
+ platform?: PlatformAdapter;
282
+ }
283
+
284
+ /** @public Options for the standard renderer. */
285
+ interface RendererOptions {
286
+ platform?: PlatformAdapter;
287
+ fps?: number;
288
+ }
289
+
290
+ /**
291
+ * @public
292
+ * Run multiple commands concurrently and flatten their results.
293
+ */
294
+ declare function batch<M extends Msg>(...cmds: Array<Cmd<M>>): Cmd<M>;
295
+ /**
296
+ * @public
297
+ * Run commands sequentially, preserving order and skipping nulls.
298
+ */
299
+ declare function sequence<M extends Msg>(...cmds: Array<Cmd<M>>): Cmd<M>;
300
+ /**
301
+ * @public
302
+ * Emit a message after a delay.
303
+ */
304
+ declare function tick<M extends Msg>(ms: number, fn: (t: Date) => M): Cmd<M>;
305
+ /**
306
+ * @public
307
+ * Schedule a single message aligned to the next interval boundary.
308
+ * Call again from your update loop to continue a repeating cadence.
309
+ */
310
+ declare function every<M extends Msg>(ms: number, fn: (t: Date) => M): Cmd<M>;
311
+ /** @public Lift a message into a command. */
312
+ declare const msg: <M extends Msg>(value: M) => Cmd<M>;
313
+ /** @public Command that emits a QuitMsg. */
314
+ declare const quit: () => Cmd<Msg>;
315
+
316
+ /** @public Clear the terminal screen. */
317
+ declare const clearScreen: () => Cmd<Msg>;
318
+ /** @public Enable cell-motion mouse reporting. */
319
+ declare const enableMouseCellMotion: () => Cmd<Msg>;
320
+ /** @public Enable all-motion mouse reporting. */
321
+ declare const enableMouseAllMotion: () => Cmd<Msg>;
322
+ /** @public Disable mouse reporting. */
323
+ declare const disableMouse: () => Cmd<Msg>;
324
+ /** @public Show the cursor. */
325
+ declare const showCursor: () => Cmd<Msg>;
326
+ /** @public Hide the cursor. */
327
+ declare const hideCursor: () => Cmd<Msg>;
328
+ /** @public Set the terminal window title. */
329
+ declare const setWindowTitle: (title: string) => Cmd<Msg>;
330
+ /**
331
+ * @public
332
+ * Emit the current window size.
333
+ * @param platform - Optional platform adapter to get terminal size from
334
+ */
335
+ declare const windowSize: (platform?: PlatformAdapter) => Cmd<Msg>;
336
+
337
+ export { BlurMsg, ClearScreenMsg, type Cmd, DisableMouseMsg, DisableReportFocusMsg, type EffectFn, EnableMouseAllMotionMsg, EnableMouseCellMotionMsg, EnableReportFocusMsg, EnterAltScreenMsg, ExitAltScreenMsg, FocusMsg, HideCursorMsg, type InputOptions, InterruptMsg, type Key, KeyMsg, KeyType, type Model, MouseAction, MouseButton, type MouseEvent, MouseMsg, type Msg, Program, type ProgramOptions, type ProgramResult, QuitMsg, type RendererOptions, ResumeMsg, SetWindowTitleMsg, ShowCursorMsg, SuspendMsg, type TerminalOptions, WindowSizeMsg, batch, clearScreen, disableMouse, enableMouseAllMotion, enableMouseCellMotion, every, hideCursor, keyToString, msg, quit, sequence, setWindowTitle, showCursor, tick, windowSize };