@flyingrobots/bijou-tui 0.10.0 → 1.0.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/dist/accordion.d.ts +46 -5
- package/dist/accordion.d.ts.map +1 -1
- package/dist/accordion.js +41 -5
- package/dist/accordion.js.map +1 -1
- package/dist/animate.d.ts +30 -0
- package/dist/animate.d.ts.map +1 -1
- package/dist/animate.js +33 -0
- package/dist/animate.js.map +1 -1
- package/dist/browsable-list.d.ts +67 -4
- package/dist/browsable-list.d.ts.map +1 -1
- package/dist/browsable-list.js +49 -4
- package/dist/browsable-list.js.map +1 -1
- package/dist/canvas.d.ts +13 -4
- package/dist/canvas.d.ts.map +1 -1
- package/dist/canvas.js +9 -3
- package/dist/canvas.js.map +1 -1
- package/dist/command-palette.d.ts +67 -6
- package/dist/command-palette.d.ts.map +1 -1
- package/dist/command-palette.js +67 -6
- package/dist/command-palette.js.map +1 -1
- package/dist/commands.d.ts +32 -3
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +32 -3
- package/dist/commands.js.map +1 -1
- package/dist/driver.d.ts +14 -0
- package/dist/driver.d.ts.map +1 -1
- package/dist/driver.js +7 -0
- package/dist/driver.js.map +1 -1
- package/dist/eventbus.d.ts +43 -6
- package/dist/eventbus.d.ts.map +1 -1
- package/dist/eventbus.js +9 -0
- package/dist/eventbus.js.map +1 -1
- package/dist/file-picker.d.ts +56 -4
- package/dist/file-picker.d.ts.map +1 -1
- package/dist/file-picker.js +52 -4
- package/dist/file-picker.js.map +1 -1
- package/dist/flex.d.ts +17 -0
- package/dist/flex.d.ts.map +1 -1
- package/dist/flex.js +106 -12
- package/dist/flex.js.map +1 -1
- package/dist/help.d.ts +16 -1
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +13 -0
- package/dist/help.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/inputstack.d.ts +32 -4
- package/dist/inputstack.d.ts.map +1 -1
- package/dist/inputstack.js +11 -0
- package/dist/inputstack.js.map +1 -1
- package/dist/keybindings.d.ts +106 -14
- package/dist/keybindings.d.ts.map +1 -1
- package/dist/keybindings.js +28 -2
- package/dist/keybindings.js.map +1 -1
- package/dist/keys.d.ts +24 -8
- package/dist/keys.d.ts.map +1 -1
- package/dist/keys.js +34 -9
- package/dist/keys.js.map +1 -1
- package/dist/layout.d.ts +26 -0
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +25 -1
- package/dist/layout.js.map +1 -1
- package/dist/navigable-table.d.ts +48 -4
- package/dist/navigable-table.d.ts.map +1 -1
- package/dist/navigable-table.js +44 -4
- package/dist/navigable-table.js.map +1 -1
- package/dist/overlay.d.ts +110 -3
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +87 -7
- package/dist/overlay.js.map +1 -1
- package/dist/pager.d.ts +66 -7
- package/dist/pager.d.ts.map +1 -1
- package/dist/pager.js +56 -7
- package/dist/pager.js.map +1 -1
- package/dist/panels.d.ts +55 -0
- package/dist/panels.d.ts.map +1 -1
- package/dist/panels.js +11 -0
- package/dist/panels.js.map +1 -1
- package/dist/runtime.d.ts +6 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +6 -0
- package/dist/runtime.js.map +1 -1
- package/dist/screen.d.ts +37 -3
- package/dist/screen.d.ts.map +1 -1
- package/dist/screen.js +37 -3
- package/dist/screen.js.map +1 -1
- package/dist/spring.d.ts +56 -7
- package/dist/spring.d.ts.map +1 -1
- package/dist/spring.js +44 -7
- package/dist/spring.js.map +1 -1
- package/dist/status-bar.d.ts +15 -2
- package/dist/status-bar.d.ts.map +1 -1
- package/dist/status-bar.js +9 -0
- package/dist/status-bar.js.map +1 -1
- package/dist/timeline.d.ts +68 -5
- package/dist/timeline.d.ts.map +1 -1
- package/dist/timeline.js +33 -0
- package/dist/timeline.js.map +1 -1
- package/dist/types.d.ts +86 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +27 -3
- package/dist/types.js.map +1 -1
- package/dist/viewport.d.ts +71 -11
- package/dist/viewport.d.ts.map +1 -1
- package/dist/viewport.js +79 -11
- package/dist/viewport.js.map +1 -1
- package/package.json +2 -2
package/dist/eventbus.d.ts
CHANGED
|
@@ -26,21 +26,42 @@
|
|
|
26
26
|
*/
|
|
27
27
|
import type { IOPort } from '@flyingrobots/bijou';
|
|
28
28
|
import type { Cmd, KeyMsg, MouseMsg, ResizeMsg } from './types.js';
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Union of all message types the bus can carry — built-in key, resize,
|
|
31
|
+
* mouse messages plus any app-defined custom message type.
|
|
32
|
+
*
|
|
33
|
+
* @template M - Application-defined custom message type.
|
|
34
|
+
*/
|
|
30
35
|
export type BusMsg<M> = KeyMsg | ResizeMsg | MouseMsg | M;
|
|
36
|
+
/**
|
|
37
|
+
* Centralized event bus that unifies all input sources into a single
|
|
38
|
+
* typed event stream for TEA applications.
|
|
39
|
+
*
|
|
40
|
+
* @template M - Application-defined custom message type.
|
|
41
|
+
*/
|
|
31
42
|
export interface EventBus<M> {
|
|
32
43
|
/**
|
|
33
44
|
* Subscribe to all events. Returns a dispose function.
|
|
34
45
|
* Multiple subscribers are supported — all receive every event.
|
|
46
|
+
*
|
|
47
|
+
* @param handler - Callback invoked for every emitted message.
|
|
48
|
+
* @returns A disposable that removes this subscription.
|
|
35
49
|
*/
|
|
36
50
|
on(handler: (msg: BusMsg<M>) => void): Disposable;
|
|
37
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Emit a message to all subscribers.
|
|
53
|
+
*
|
|
54
|
+
* @param msg - The message to broadcast.
|
|
55
|
+
*/
|
|
38
56
|
emit(msg: BusMsg<M>): void;
|
|
39
57
|
/**
|
|
40
58
|
* Connect keyboard and resize sources from an IOPort.
|
|
41
59
|
* Raw stdin bytes are parsed into KeyMsg automatically.
|
|
42
60
|
* When `options.mouse` is true, SGR mouse sequences are parsed into MouseMsg.
|
|
43
|
-
*
|
|
61
|
+
*
|
|
62
|
+
* @param io - IO port providing raw input and resize events.
|
|
63
|
+
* @param options - Optional flags (e.g. `{ mouse: true }` to enable mouse input).
|
|
64
|
+
* @returns A disposable that disconnects both input and resize listeners.
|
|
44
65
|
*/
|
|
45
66
|
connectIO(io: IOPort, options?: {
|
|
46
67
|
mouse?: boolean;
|
|
@@ -48,25 +69,41 @@ export interface EventBus<M> {
|
|
|
48
69
|
/**
|
|
49
70
|
* Run a command. The command receives the bus's `emit` function to
|
|
50
71
|
* dispatch intermediate messages during execution. When it resolves:
|
|
51
|
-
* - QUIT signal
|
|
52
|
-
* - Message
|
|
53
|
-
* - void/undefined
|
|
72
|
+
* - QUIT signal — fires onQuit handlers
|
|
73
|
+
* - Message — emitted to all subscribers
|
|
74
|
+
* - void/undefined — ignored
|
|
54
75
|
*
|
|
55
76
|
* Rejected commands are logged to stderr via `console.error`.
|
|
77
|
+
*
|
|
78
|
+
* @param cmd - The command to execute.
|
|
56
79
|
*/
|
|
57
80
|
runCmd(cmd: Cmd<M>): void;
|
|
58
81
|
/**
|
|
59
82
|
* Register a quit handler. Called when a command resolves to QUIT.
|
|
60
83
|
* Separate from `on()` so the runtime can handle shutdown without
|
|
61
84
|
* the app needing to filter for it.
|
|
85
|
+
*
|
|
86
|
+
* @param handler - Callback invoked on quit signal.
|
|
87
|
+
* @returns A disposable that removes this quit handler.
|
|
62
88
|
*/
|
|
63
89
|
onQuit(handler: () => void): Disposable;
|
|
64
90
|
/** Disconnect all sources and remove all subscribers. */
|
|
65
91
|
dispose(): void;
|
|
66
92
|
}
|
|
93
|
+
/** Handle for unsubscribing or disconnecting a resource. */
|
|
67
94
|
interface Disposable {
|
|
95
|
+
/** Remove the subscription or disconnect the resource. */
|
|
68
96
|
dispose(): void;
|
|
69
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Create a new event bus.
|
|
100
|
+
*
|
|
101
|
+
* Returns an {@link EventBus} that manages subscribers, I/O connections,
|
|
102
|
+
* command execution, and quit signaling for a TEA runtime.
|
|
103
|
+
*
|
|
104
|
+
* @template M - Application-defined custom message type.
|
|
105
|
+
* @returns A new event bus instance.
|
|
106
|
+
*/
|
|
70
107
|
export declare function createEventBus<M>(): EventBus<M>;
|
|
71
108
|
export {};
|
|
72
109
|
//# sourceMappingURL=eventbus.d.ts.map
|
package/dist/eventbus.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventbus.d.ts","sourceRoot":"","sources":["../src/eventbus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAQnE
|
|
1
|
+
{"version":3,"file":"eventbus.d.ts","sourceRoot":"","sources":["../src/eventbus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAQnE;;;;;GAKG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,CAAC,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB;;;;;;OAMG;IACH,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,UAAU,CAAC;IAElD;;;;OAIG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAE3B;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,UAAU,CAAC;IAEjE;;;;;;;;;;OAUG;IACH,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAE1B;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,UAAU,CAAC;IAExC,yDAAyD;IACzD,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,4DAA4D;AAC5D,UAAU,UAAU;IAClB,0DAA0D;IAC1D,OAAO,IAAI,IAAI,CAAC;CACjB;AAMD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAsG/C"}
|
package/dist/eventbus.js
CHANGED
|
@@ -29,6 +29,15 @@ import { parseKey, parseMouse } from './keys.js';
|
|
|
29
29
|
// ---------------------------------------------------------------------------
|
|
30
30
|
// Implementation
|
|
31
31
|
// ---------------------------------------------------------------------------
|
|
32
|
+
/**
|
|
33
|
+
* Create a new event bus.
|
|
34
|
+
*
|
|
35
|
+
* Returns an {@link EventBus} that manages subscribers, I/O connections,
|
|
36
|
+
* command execution, and quit signaling for a TEA runtime.
|
|
37
|
+
*
|
|
38
|
+
* @template M - Application-defined custom message type.
|
|
39
|
+
* @returns A new event bus instance.
|
|
40
|
+
*/
|
|
32
41
|
export function createEventBus() {
|
|
33
42
|
const subscribers = new Set();
|
|
34
43
|
const quitHandlers = new Set();
|
package/dist/eventbus.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventbus.js","sourceRoot":"","sources":["../src/eventbus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE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Y,EAAE,EAAE;gBACxB,8EAA8E;gBAC9E,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAC;YACrD,CAAC,CAAC,CAAC;QACL,CAAC;QAED,MAAM,CAAC,OAAO;YACZ,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC1B,OAAO;gBACL,OAAO;oBACL,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAC/B,CAAC;aACF,CAAC;QACJ,CAAC;QAED,OAAO;YACL,QAAQ,GAAG,IAAI,CAAC;YAChB,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC;gBAC5B,CAAC,CAAC,OAAO,EAAE,CAAC;YACd,CAAC;YACD,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;YACvB,WAAW,CAAC,KAAK,EAAE,CAAC;YACpB,YAAY,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/file-picker.d.ts
CHANGED
|
@@ -21,27 +21,46 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import type { IOPort } from '@flyingrobots/bijou';
|
|
23
23
|
import { type KeyMap } from './keybindings.js';
|
|
24
|
+
/** A single entry (file or directory) in the file picker listing. */
|
|
24
25
|
export interface FileEntry {
|
|
26
|
+
/** Name of the file or directory (without trailing `/`). */
|
|
25
27
|
name: string;
|
|
28
|
+
/** Whether this entry is a directory. */
|
|
26
29
|
isDirectory: boolean;
|
|
27
30
|
}
|
|
31
|
+
/** Immutable state for the file picker widget. */
|
|
28
32
|
export interface FilePickerState {
|
|
33
|
+
/** Current working directory being browsed. */
|
|
29
34
|
readonly cwd: string;
|
|
35
|
+
/** Sorted entries in the current directory. */
|
|
30
36
|
readonly entries: readonly FileEntry[];
|
|
37
|
+
/** Index of the currently focused entry. */
|
|
31
38
|
readonly focusIndex: number;
|
|
39
|
+
/** Vertical scroll offset (first visible entry index). */
|
|
32
40
|
readonly scrollY: number;
|
|
41
|
+
/** Maximum number of visible entries. */
|
|
33
42
|
readonly height: number;
|
|
43
|
+
/** Optional file extension filter (e.g. `".ts"`). */
|
|
34
44
|
readonly filter?: string;
|
|
35
45
|
}
|
|
46
|
+
/** Options for creating a new file picker state. */
|
|
36
47
|
export interface FilePickerOptions {
|
|
48
|
+
/** Starting directory path. */
|
|
37
49
|
readonly cwd: string;
|
|
50
|
+
/** IO port used for directory listing and path joining. */
|
|
38
51
|
readonly io: IOPort;
|
|
52
|
+
/** Maximum number of visible entries (default: 10). */
|
|
39
53
|
readonly height?: number;
|
|
54
|
+
/** Optional file extension filter (e.g. `".ts"`). */
|
|
40
55
|
readonly filter?: string;
|
|
41
56
|
}
|
|
57
|
+
/** Options for rendering the file picker view. */
|
|
42
58
|
export interface FilePickerRenderOptions {
|
|
59
|
+
/** Character(s) shown next to the focused entry (default: `"\u25b8"`). */
|
|
43
60
|
readonly focusIndicator?: string;
|
|
61
|
+
/** Character(s) shown before directory names (default: `"d"`). */
|
|
44
62
|
readonly dirIndicator?: string;
|
|
63
|
+
/** Character(s) shown before file names (default: `"-"`). */
|
|
45
64
|
readonly fileIndicator?: string;
|
|
46
65
|
}
|
|
47
66
|
/**
|
|
@@ -50,21 +69,50 @@ export interface FilePickerRenderOptions {
|
|
|
50
69
|
* Reads directory contents via `io.readDir()` and parses entries into
|
|
51
70
|
* directories (trailing `/`) and files. Directories are sorted first,
|
|
52
71
|
* then files, both alphabetically.
|
|
72
|
+
*
|
|
73
|
+
* @param options - Starting directory, IO port, height, and optional filter.
|
|
74
|
+
* @returns Fresh file picker state with focus on the first entry.
|
|
53
75
|
*/
|
|
54
76
|
export declare function createFilePickerState(options: FilePickerOptions): FilePickerState;
|
|
55
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* Move focus to the next entry (wraps around).
|
|
79
|
+
*
|
|
80
|
+
* @param state - Current file picker state.
|
|
81
|
+
* @returns Updated state with focus on the next entry.
|
|
82
|
+
*/
|
|
56
83
|
export declare function fpFocusNext(state: FilePickerState): FilePickerState;
|
|
57
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Move focus to the previous entry (wraps around).
|
|
86
|
+
*
|
|
87
|
+
* @param state - Current file picker state.
|
|
88
|
+
* @returns Updated state with focus on the previous entry.
|
|
89
|
+
*/
|
|
58
90
|
export declare function fpFocusPrev(state: FilePickerState): FilePickerState;
|
|
59
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* Enter the focused directory, refreshing the entry list. No-op on files.
|
|
93
|
+
*
|
|
94
|
+
* @param state - Current file picker state.
|
|
95
|
+
* @param io - IO port for filesystem access.
|
|
96
|
+
* @returns Updated state browsing the focused directory, or unchanged if focused on a file.
|
|
97
|
+
*/
|
|
60
98
|
export declare function fpEnter(state: FilePickerState, io: IOPort): FilePickerState;
|
|
61
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Navigate to the parent directory. No-op at filesystem root.
|
|
101
|
+
*
|
|
102
|
+
* @param state - Current file picker state.
|
|
103
|
+
* @param io - IO port for filesystem access.
|
|
104
|
+
* @returns Updated state browsing the parent directory, or unchanged at root.
|
|
105
|
+
*/
|
|
62
106
|
export declare function fpBack(state: FilePickerState, io: IOPort): FilePickerState;
|
|
63
107
|
/**
|
|
64
108
|
* Render the file picker — cwd header followed by the visible entry list.
|
|
65
109
|
*
|
|
66
110
|
* Each entry is prefixed with a focus indicator and a type indicator
|
|
67
111
|
* (directory or file). Directories are suffixed with `/`.
|
|
112
|
+
*
|
|
113
|
+
* @param state - Current file picker state.
|
|
114
|
+
* @param options - Rendering options (focus, dir, and file indicators).
|
|
115
|
+
* @returns Rendered file picker string with cwd header and entry list.
|
|
68
116
|
*/
|
|
69
117
|
export declare function filePicker(state: FilePickerState, options?: FilePickerRenderOptions): string;
|
|
70
118
|
/**
|
|
@@ -80,6 +128,10 @@ export declare function filePicker(state: FilePickerState, options?: FilePickerR
|
|
|
80
128
|
* quit: { type: 'quit' },
|
|
81
129
|
* });
|
|
82
130
|
* ```
|
|
131
|
+
*
|
|
132
|
+
* @template Msg - Application message type dispatched by key bindings.
|
|
133
|
+
* @param actions - Map of navigation and action messages.
|
|
134
|
+
* @returns Preconfigured key map with vim-style file picker bindings.
|
|
83
135
|
*/
|
|
84
136
|
export declare function filePickerKeyMap<Msg>(actions: {
|
|
85
137
|
focusNext: Msg;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-picker.d.ts","sourceRoot":"","sources":["../src/file-picker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAM7D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,SAAS,SAAS,EAAE,CAAC;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,CAAC,EAA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,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,6DAA6D;IAC7D,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAwDD;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,iBAAiB,GAAG,eAAe,CAYjF;AAMD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG,eAAe,CAInE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG,eAAe,CAInE;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,GAAG,eAAe,CAe3E;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,GAAG,eAAe,CAa1E;AA8BD;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,MAAM,CA0B5F;AAMD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE;IAC7C,SAAS,EAAE,GAAG,CAAC;IACf,SAAS,EAAE,GAAG,CAAC;IACf,KAAK,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,GAAG,CAAC;CACX,GAAG,MAAM,CAAC,GAAG,CAAC,CAed"}
|
package/dist/file-picker.js
CHANGED
|
@@ -26,6 +26,11 @@ import { createKeyMap } from './keybindings.js';
|
|
|
26
26
|
/**
|
|
27
27
|
* Safely read and parse directory entries. Returns `[]` if the directory
|
|
28
28
|
* is unreadable (permissions, missing, etc.) instead of throwing.
|
|
29
|
+
*
|
|
30
|
+
* @param io - IO port for filesystem access.
|
|
31
|
+
* @param cwd - Directory path to read.
|
|
32
|
+
* @param filter - Optional file extension filter.
|
|
33
|
+
* @returns Sorted array of file entries, or empty array on error.
|
|
29
34
|
*/
|
|
30
35
|
function safeReadEntries(io, cwd, filter) {
|
|
31
36
|
try {
|
|
@@ -42,6 +47,7 @@ function safeReadEntries(io, cwd, filter) {
|
|
|
42
47
|
* @param filter - Optional extension suffix (e.g. `".ts"`) — only files whose
|
|
43
48
|
* name ends with this suffix are included. Directories are
|
|
44
49
|
* always included regardless of the filter.
|
|
50
|
+
* @returns Sorted array of file entries (directories first, then files).
|
|
45
51
|
*/
|
|
46
52
|
function parseEntries(names, filter) {
|
|
47
53
|
const dirs = [];
|
|
@@ -70,6 +76,9 @@ function parseEntries(names, filter) {
|
|
|
70
76
|
* Reads directory contents via `io.readDir()` and parses entries into
|
|
71
77
|
* directories (trailing `/`) and files. Directories are sorted first,
|
|
72
78
|
* then files, both alphabetically.
|
|
79
|
+
*
|
|
80
|
+
* @param options - Starting directory, IO port, height, and optional filter.
|
|
81
|
+
* @returns Fresh file picker state with focus on the first entry.
|
|
73
82
|
*/
|
|
74
83
|
export function createFilePickerState(options) {
|
|
75
84
|
const height = Math.max(1, options.height ?? 10);
|
|
@@ -86,21 +95,37 @@ export function createFilePickerState(options) {
|
|
|
86
95
|
// ---------------------------------------------------------------------------
|
|
87
96
|
// State transformers
|
|
88
97
|
// ---------------------------------------------------------------------------
|
|
89
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* Move focus to the next entry (wraps around).
|
|
100
|
+
*
|
|
101
|
+
* @param state - Current file picker state.
|
|
102
|
+
* @returns Updated state with focus on the next entry.
|
|
103
|
+
*/
|
|
90
104
|
export function fpFocusNext(state) {
|
|
91
105
|
if (state.entries.length === 0)
|
|
92
106
|
return state;
|
|
93
107
|
const focusIndex = (state.focusIndex + 1) % state.entries.length;
|
|
94
108
|
return { ...state, focusIndex, scrollY: adjustScroll(focusIndex, state.scrollY, state.height, state.entries.length) };
|
|
95
109
|
}
|
|
96
|
-
/**
|
|
110
|
+
/**
|
|
111
|
+
* Move focus to the previous entry (wraps around).
|
|
112
|
+
*
|
|
113
|
+
* @param state - Current file picker state.
|
|
114
|
+
* @returns Updated state with focus on the previous entry.
|
|
115
|
+
*/
|
|
97
116
|
export function fpFocusPrev(state) {
|
|
98
117
|
if (state.entries.length === 0)
|
|
99
118
|
return state;
|
|
100
119
|
const focusIndex = (state.focusIndex - 1 + state.entries.length) % state.entries.length;
|
|
101
120
|
return { ...state, focusIndex, scrollY: adjustScroll(focusIndex, state.scrollY, state.height, state.entries.length) };
|
|
102
121
|
}
|
|
103
|
-
/**
|
|
122
|
+
/**
|
|
123
|
+
* Enter the focused directory, refreshing the entry list. No-op on files.
|
|
124
|
+
*
|
|
125
|
+
* @param state - Current file picker state.
|
|
126
|
+
* @param io - IO port for filesystem access.
|
|
127
|
+
* @returns Updated state browsing the focused directory, or unchanged if focused on a file.
|
|
128
|
+
*/
|
|
104
129
|
export function fpEnter(state, io) {
|
|
105
130
|
if (state.entries.length === 0)
|
|
106
131
|
return state;
|
|
@@ -117,7 +142,13 @@ export function fpEnter(state, io) {
|
|
|
117
142
|
scrollY: 0,
|
|
118
143
|
};
|
|
119
144
|
}
|
|
120
|
-
/**
|
|
145
|
+
/**
|
|
146
|
+
* Navigate to the parent directory. No-op at filesystem root.
|
|
147
|
+
*
|
|
148
|
+
* @param state - Current file picker state.
|
|
149
|
+
* @param io - IO port for filesystem access.
|
|
150
|
+
* @returns Updated state browsing the parent directory, or unchanged at root.
|
|
151
|
+
*/
|
|
121
152
|
export function fpBack(state, io) {
|
|
122
153
|
const newCwd = io.joinPath(state.cwd, '..');
|
|
123
154
|
if (newCwd === state.cwd)
|
|
@@ -134,6 +165,15 @@ export function fpBack(state, io) {
|
|
|
134
165
|
// ---------------------------------------------------------------------------
|
|
135
166
|
// Scroll helper
|
|
136
167
|
// ---------------------------------------------------------------------------
|
|
168
|
+
/**
|
|
169
|
+
* Clamp scroll position so the focused entry stays within the visible window.
|
|
170
|
+
*
|
|
171
|
+
* @param focusIndex - Index of the focused entry.
|
|
172
|
+
* @param scrollY - Current scroll offset.
|
|
173
|
+
* @param height - Viewport height in entries.
|
|
174
|
+
* @param totalItems - Total number of entries.
|
|
175
|
+
* @returns Adjusted scroll offset.
|
|
176
|
+
*/
|
|
137
177
|
function adjustScroll(focusIndex, scrollY, height, totalItems) {
|
|
138
178
|
let newScrollY = scrollY;
|
|
139
179
|
if (focusIndex < newScrollY) {
|
|
@@ -153,6 +193,10 @@ function adjustScroll(focusIndex, scrollY, height, totalItems) {
|
|
|
153
193
|
*
|
|
154
194
|
* Each entry is prefixed with a focus indicator and a type indicator
|
|
155
195
|
* (directory or file). Directories are suffixed with `/`.
|
|
196
|
+
*
|
|
197
|
+
* @param state - Current file picker state.
|
|
198
|
+
* @param options - Rendering options (focus, dir, and file indicators).
|
|
199
|
+
* @returns Rendered file picker string with cwd header and entry list.
|
|
156
200
|
*/
|
|
157
201
|
export function filePicker(state, options) {
|
|
158
202
|
const indicator = options?.focusIndicator ?? '\u25b8';
|
|
@@ -192,6 +236,10 @@ export function filePicker(state, options) {
|
|
|
192
236
|
* quit: { type: 'quit' },
|
|
193
237
|
* });
|
|
194
238
|
* ```
|
|
239
|
+
*
|
|
240
|
+
* @template Msg - Application message type dispatched by key bindings.
|
|
241
|
+
* @param actions - Map of navigation and action messages.
|
|
242
|
+
* @returns Preconfigured key map with vim-style file picker bindings.
|
|
195
243
|
*/
|
|
196
244
|
export function filePickerKeyMap(actions) {
|
|
197
245
|
return createKeyMap()
|
package/dist/file-picker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-picker.js","sourceRoot":"","sources":["../src/file-picker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,YAAY,EAAe,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"file-picker.js","sourceRoot":"","sources":["../src/file-picker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAG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AC;SAC1C,IAAI,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,SAAS,CAAC;SAC7C,IAAI,CAAC,GAAG,EAAE,gBAAgB,EAAE,OAAO,CAAC,SAAS,CAAC;SAC9C,IAAI,CAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,CAAC,SAAS,CAAC,CACjD;SACA,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;SACvB,IAAI,CAAC,OAAO,EAAE,+BAA+B,EAAE,OAAO,CAAC,KAAK,CAAC;SAC7D,IAAI,CAAC,WAAW,EAAE,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC;SACnD,IAAI,CAAC,MAAM,EAAE,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,CAChD;SACA,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC;SAC/B,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;AAC1C,CAAC"}
|
package/dist/flex.d.ts
CHANGED
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
* )
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
|
+
import type { BijouContext, TokenValue } from '@flyingrobots/bijou';
|
|
16
|
+
/**
|
|
17
|
+
* Configuration for the flex layout container.
|
|
18
|
+
*/
|
|
15
19
|
export interface FlexOptions {
|
|
16
20
|
/** Layout direction. Default: 'row'. */
|
|
17
21
|
readonly direction?: 'row' | 'column';
|
|
@@ -21,7 +25,14 @@ export interface FlexOptions {
|
|
|
21
25
|
readonly height: number;
|
|
22
26
|
/** Gap between children (in the main axis). Default: 0. */
|
|
23
27
|
readonly gap?: number;
|
|
28
|
+
/** Background token applied to the entire flex container (gap + padding areas). Requires `bg` field on the token. */
|
|
29
|
+
readonly bgToken?: TokenValue;
|
|
30
|
+
/** Bijou context for styled output (required for bgToken to take effect). */
|
|
31
|
+
readonly ctx?: BijouContext;
|
|
24
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Descriptor for a single child within a flex layout.
|
|
35
|
+
*/
|
|
25
36
|
export interface FlexChild {
|
|
26
37
|
/**
|
|
27
38
|
* Content to render. Either a static string, or a function that
|
|
@@ -38,6 +49,8 @@ export interface FlexChild {
|
|
|
38
49
|
readonly maxSize?: number;
|
|
39
50
|
/** Cross-axis alignment. Default: 'start'. */
|
|
40
51
|
readonly align?: 'start' | 'center' | 'end';
|
|
52
|
+
/** Background token for this child's allocated region. Requires `bg` field on the token and `ctx` on `FlexOptions`. */
|
|
53
|
+
readonly bgToken?: TokenValue;
|
|
41
54
|
}
|
|
42
55
|
/**
|
|
43
56
|
* Lay out children using flexbox-style rules.
|
|
@@ -59,6 +72,10 @@ export interface FlexChild {
|
|
|
59
72
|
* { basis: 1, content: statusLine },
|
|
60
73
|
* )
|
|
61
74
|
* ```
|
|
75
|
+
*
|
|
76
|
+
* @param options - Layout container configuration (direction, dimensions, gap).
|
|
77
|
+
* @param children - Child descriptors with content, flex factors, and constraints.
|
|
78
|
+
* @returns Composed layout string with lines joined by newlines. Empty string if no children.
|
|
62
79
|
*/
|
|
63
80
|
export declare function flex(options: FlexOptions, ...children: FlexChild[]): string;
|
|
64
81
|
//# sourceMappingURL=flex.d.ts.map
|
package/dist/flex.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flex.d.ts","sourceRoot":"","sources":["../src/flex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,MAAM,WAAW,WAAW;IAC1B,wCAAwC;IACxC,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IACtC,kCAAkC;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,gCAAgC;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,2DAA2D;IAC3D,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;
|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