@flyingrobots/bijou-tui 0.9.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 +42 -0
- package/dist/canvas.d.ts.map +1 -0
- package/dist/canvas.js +41 -0
- package/dist/canvas.js.map +1 -0
- 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 +49 -9
- package/dist/eventbus.d.ts.map +1 -1
- package/dist/eventbus.js +22 -4
- 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 +12 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -2
- 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 +29 -3
- package/dist/keys.d.ts.map +1 -1
- package/dist/keys.js +73 -2
- 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 +24 -3
- 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 +102 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +30 -2
- package/dist/types.js.map +1 -1
- package/dist/viewport.d.ts +74 -14
- package/dist/viewport.d.ts.map +1 -1
- package/dist/viewport.js +82 -60
- package/dist/viewport.js.map +1 -1
- package/package.json +2 -2
package/dist/pager.d.ts
CHANGED
|
@@ -18,17 +18,27 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { type ScrollState } from './viewport.js';
|
|
20
20
|
import { type KeyMap } from './keybindings.js';
|
|
21
|
+
/** Immutable state for the pager widget. */
|
|
21
22
|
export interface PagerState {
|
|
23
|
+
/** Underlying scroll position state. */
|
|
22
24
|
readonly scroll: ScrollState;
|
|
25
|
+
/** Full text content displayed in the pager. */
|
|
23
26
|
readonly content: string;
|
|
27
|
+
/** Available width in columns. */
|
|
24
28
|
readonly width: number;
|
|
29
|
+
/** Total available height in rows (including status line). */
|
|
25
30
|
readonly height: number;
|
|
26
31
|
}
|
|
32
|
+
/** Options for creating a new pager state. */
|
|
27
33
|
export interface PagerOptions {
|
|
34
|
+
/** Full text content to display. */
|
|
28
35
|
readonly content: string;
|
|
36
|
+
/** Available width in columns. */
|
|
29
37
|
readonly width: number;
|
|
38
|
+
/** Total available height in rows (one row reserved for status). */
|
|
30
39
|
readonly height: number;
|
|
31
40
|
}
|
|
41
|
+
/** Options for rendering the pager view. */
|
|
32
42
|
export interface PagerRenderOptions {
|
|
33
43
|
/** Show a scrollbar track on the right edge. Default: true. */
|
|
34
44
|
readonly showScrollbar?: boolean;
|
|
@@ -40,24 +50,69 @@ export interface PagerRenderOptions {
|
|
|
40
50
|
*
|
|
41
51
|
* The viewport height is `height - 1` when status is shown (the default),
|
|
42
52
|
* reserving one line for the status indicator.
|
|
53
|
+
*
|
|
54
|
+
* @param options - Content, width, and height for the pager.
|
|
55
|
+
* @returns Fresh pager state with scroll at the top.
|
|
43
56
|
*/
|
|
44
57
|
export declare function createPagerState(options: PagerOptions): PagerState;
|
|
45
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* Scroll by a relative number of lines.
|
|
60
|
+
*
|
|
61
|
+
* @param state - Current pager state.
|
|
62
|
+
* @param dy - Number of lines to scroll (positive = down, negative = up).
|
|
63
|
+
* @returns Updated pager state with new scroll position.
|
|
64
|
+
*/
|
|
46
65
|
export declare function pagerScrollBy(state: PagerState, dy: number): PagerState;
|
|
47
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* Scroll to an absolute line.
|
|
68
|
+
*
|
|
69
|
+
* @param state - Current pager state.
|
|
70
|
+
* @param y - Target line number (zero-based).
|
|
71
|
+
* @returns Updated pager state with new scroll position.
|
|
72
|
+
*/
|
|
48
73
|
export declare function pagerScrollTo(state: PagerState, y: number): PagerState;
|
|
49
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Scroll to the first line.
|
|
76
|
+
*
|
|
77
|
+
* @param state - Current pager state.
|
|
78
|
+
* @returns Updated pager state scrolled to the top.
|
|
79
|
+
*/
|
|
50
80
|
export declare function pagerScrollToTop(state: PagerState): PagerState;
|
|
51
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* Scroll to the last line.
|
|
83
|
+
*
|
|
84
|
+
* @param state - Current pager state.
|
|
85
|
+
* @returns Updated pager state scrolled to the bottom.
|
|
86
|
+
*/
|
|
52
87
|
export declare function pagerScrollToBottom(state: PagerState): PagerState;
|
|
53
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* Page down (one viewport height).
|
|
90
|
+
*
|
|
91
|
+
* @param state - Current pager state.
|
|
92
|
+
* @returns Updated pager state advanced by one page.
|
|
93
|
+
*/
|
|
54
94
|
export declare function pagerPageDown(state: PagerState): PagerState;
|
|
55
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* Page up (one viewport height).
|
|
97
|
+
*
|
|
98
|
+
* @param state - Current pager state.
|
|
99
|
+
* @returns Updated pager state moved back by one page.
|
|
100
|
+
*/
|
|
56
101
|
export declare function pagerPageUp(state: PagerState): PagerState;
|
|
57
|
-
/**
|
|
102
|
+
/**
|
|
103
|
+
* Update content while preserving scroll position (clamped).
|
|
104
|
+
*
|
|
105
|
+
* @param state - Current pager state.
|
|
106
|
+
* @param content - New text content to display.
|
|
107
|
+
* @returns Updated pager state with new content and clamped scroll position.
|
|
108
|
+
*/
|
|
58
109
|
export declare function pagerSetContent(state: PagerState, content: string): PagerState;
|
|
59
110
|
/**
|
|
60
111
|
* Render the pager — viewport content plus optional status line.
|
|
112
|
+
*
|
|
113
|
+
* @param state - Current pager state.
|
|
114
|
+
* @param options - Rendering options (scrollbar, status line).
|
|
115
|
+
* @returns Rendered pager string with viewport and optional status.
|
|
61
116
|
*/
|
|
62
117
|
export declare function pager(state: PagerState, options?: PagerRenderOptions): string;
|
|
63
118
|
/**
|
|
@@ -75,6 +130,10 @@ export declare function pager(state: PagerState, options?: PagerRenderOptions):
|
|
|
75
130
|
* quit: { type: 'quit' },
|
|
76
131
|
* });
|
|
77
132
|
* ```
|
|
133
|
+
*
|
|
134
|
+
* @template Msg - Application message type dispatched by key bindings.
|
|
135
|
+
* @param actions - Map of navigation actions to message values.
|
|
136
|
+
* @returns Preconfigured key map with vim-style pager bindings.
|
|
78
137
|
*/
|
|
79
138
|
export declare function pagerKeyMap<Msg>(actions: {
|
|
80
139
|
scrollUp: Msg;
|
package/dist/pager.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pager.d.ts","sourceRoot":"","sources":["../src/pager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,KAAK,WAAW,EASjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAM7D,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAA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{ createKeyMap } from './keybindings.js';
|
|
|
26
26
|
*
|
|
27
27
|
* The viewport height is `height - 1` when status is shown (the default),
|
|
28
28
|
* reserving one line for the status indicator.
|
|
29
|
+
*
|
|
30
|
+
* @param options - Content, width, and height for the pager.
|
|
31
|
+
* @returns Fresh pager state with scroll at the top.
|
|
29
32
|
*/
|
|
30
33
|
export function createPagerState(options) {
|
|
31
34
|
const { content, width, height } = options;
|
|
@@ -40,31 +43,69 @@ export function createPagerState(options) {
|
|
|
40
43
|
// ---------------------------------------------------------------------------
|
|
41
44
|
// State transformers
|
|
42
45
|
// ---------------------------------------------------------------------------
|
|
43
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Scroll by a relative number of lines.
|
|
48
|
+
*
|
|
49
|
+
* @param state - Current pager state.
|
|
50
|
+
* @param dy - Number of lines to scroll (positive = down, negative = up).
|
|
51
|
+
* @returns Updated pager state with new scroll position.
|
|
52
|
+
*/
|
|
44
53
|
export function pagerScrollBy(state, dy) {
|
|
45
54
|
return { ...state, scroll: scrollBy(state.scroll, dy) };
|
|
46
55
|
}
|
|
47
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Scroll to an absolute line.
|
|
58
|
+
*
|
|
59
|
+
* @param state - Current pager state.
|
|
60
|
+
* @param y - Target line number (zero-based).
|
|
61
|
+
* @returns Updated pager state with new scroll position.
|
|
62
|
+
*/
|
|
48
63
|
export function pagerScrollTo(state, y) {
|
|
49
64
|
return { ...state, scroll: scrollTo(state.scroll, y) };
|
|
50
65
|
}
|
|
51
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* Scroll to the first line.
|
|
68
|
+
*
|
|
69
|
+
* @param state - Current pager state.
|
|
70
|
+
* @returns Updated pager state scrolled to the top.
|
|
71
|
+
*/
|
|
52
72
|
export function pagerScrollToTop(state) {
|
|
53
73
|
return { ...state, scroll: scrollToTop(state.scroll) };
|
|
54
74
|
}
|
|
55
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* Scroll to the last line.
|
|
77
|
+
*
|
|
78
|
+
* @param state - Current pager state.
|
|
79
|
+
* @returns Updated pager state scrolled to the bottom.
|
|
80
|
+
*/
|
|
56
81
|
export function pagerScrollToBottom(state) {
|
|
57
82
|
return { ...state, scroll: scrollToBottom(state.scroll) };
|
|
58
83
|
}
|
|
59
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Page down (one viewport height).
|
|
86
|
+
*
|
|
87
|
+
* @param state - Current pager state.
|
|
88
|
+
* @returns Updated pager state advanced by one page.
|
|
89
|
+
*/
|
|
60
90
|
export function pagerPageDown(state) {
|
|
61
91
|
return { ...state, scroll: pageDown(state.scroll) };
|
|
62
92
|
}
|
|
63
|
-
/**
|
|
93
|
+
/**
|
|
94
|
+
* Page up (one viewport height).
|
|
95
|
+
*
|
|
96
|
+
* @param state - Current pager state.
|
|
97
|
+
* @returns Updated pager state moved back by one page.
|
|
98
|
+
*/
|
|
64
99
|
export function pagerPageUp(state) {
|
|
65
100
|
return { ...state, scroll: pageUp(state.scroll) };
|
|
66
101
|
}
|
|
67
|
-
/**
|
|
102
|
+
/**
|
|
103
|
+
* Update content while preserving scroll position (clamped).
|
|
104
|
+
*
|
|
105
|
+
* @param state - Current pager state.
|
|
106
|
+
* @param content - New text content to display.
|
|
107
|
+
* @returns Updated pager state with new content and clamped scroll position.
|
|
108
|
+
*/
|
|
68
109
|
export function pagerSetContent(state, content) {
|
|
69
110
|
const viewportHeight = Math.max(1, state.height - 1);
|
|
70
111
|
const newScroll = createScrollState(content, viewportHeight);
|
|
@@ -80,6 +121,10 @@ export function pagerSetContent(state, content) {
|
|
|
80
121
|
// ---------------------------------------------------------------------------
|
|
81
122
|
/**
|
|
82
123
|
* Render the pager — viewport content plus optional status line.
|
|
124
|
+
*
|
|
125
|
+
* @param state - Current pager state.
|
|
126
|
+
* @param options - Rendering options (scrollbar, status line).
|
|
127
|
+
* @returns Rendered pager string with viewport and optional status.
|
|
83
128
|
*/
|
|
84
129
|
export function pager(state, options) {
|
|
85
130
|
const showScrollbar = options?.showScrollbar ?? true;
|
|
@@ -123,6 +168,10 @@ export function pager(state, options) {
|
|
|
123
168
|
* quit: { type: 'quit' },
|
|
124
169
|
* });
|
|
125
170
|
* ```
|
|
171
|
+
*
|
|
172
|
+
* @template Msg - Application message type dispatched by key bindings.
|
|
173
|
+
* @param actions - Map of navigation actions to message values.
|
|
174
|
+
* @returns Preconfigured key map with vim-style pager bindings.
|
|
126
175
|
*/
|
|
127
176
|
export function pagerKeyMap(actions) {
|
|
128
177
|
return createKeyMap()
|
package/dist/pager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pager.js","sourceRoot":"","sources":["../src/pager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAEL,QAAQ,EACR,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,cAAc,EACd,QAAQ,EACR,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAe,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"pager.js","sourceRoot":"","sources":["../src/pager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAEL,QAAQ,EACR,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,cAAc,EACd,QAAQ,EACR,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAe,MAAM,kBAAkB,CAAC;AAoC7D,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAqB;IACpD,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3C,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,uBA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,CAAC,MAAM,CAAC,CAC3C;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/panels.d.ts
CHANGED
|
@@ -9,23 +9,78 @@ import type { KeyMsg } from './types.js';
|
|
|
9
9
|
import type { KeyMap } from './keybindings.js';
|
|
10
10
|
import type { InputStack } from './inputstack.js';
|
|
11
11
|
import type { BijouContext } from '@flyingrobots/bijou';
|
|
12
|
+
/**
|
|
13
|
+
* Definition of a single panel within a panel group.
|
|
14
|
+
*
|
|
15
|
+
* @template A - Action type produced by the panel's key map.
|
|
16
|
+
*/
|
|
12
17
|
export interface PanelDef<A> {
|
|
18
|
+
/** Unique identifier for this panel. */
|
|
13
19
|
readonly id: string;
|
|
20
|
+
/** Single key that focuses this panel when pressed. */
|
|
14
21
|
readonly hotkey: string;
|
|
22
|
+
/** Human-readable label displayed in the panel tab bar. */
|
|
15
23
|
readonly label: string;
|
|
24
|
+
/** Key map that handles input when this panel is focused. */
|
|
16
25
|
readonly keyMap: KeyMap<A>;
|
|
17
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Configuration for creating a panel group.
|
|
29
|
+
*
|
|
30
|
+
* @template A - Action type produced by panel key maps.
|
|
31
|
+
*/
|
|
18
32
|
export interface PanelGroupOptions<A> {
|
|
33
|
+
/** Panel definitions to include in the group. */
|
|
19
34
|
readonly panels: readonly PanelDef<A>[];
|
|
35
|
+
/** ID of the panel that is focused initially. Must match an existing panel. */
|
|
20
36
|
readonly defaultFocus: string;
|
|
37
|
+
/** Optional input stack for automatic layer management on focus changes. */
|
|
21
38
|
readonly inputStack?: InputStack<KeyMsg, A>;
|
|
22
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Runtime panel group that tracks focus and routes input.
|
|
42
|
+
*
|
|
43
|
+
* @template A - Action type produced by panel key maps.
|
|
44
|
+
*/
|
|
23
45
|
export interface PanelGroup<A> {
|
|
46
|
+
/** ID of the currently focused panel. */
|
|
24
47
|
readonly focused: string;
|
|
48
|
+
/**
|
|
49
|
+
* Switch focus to the panel with the given ID.
|
|
50
|
+
*
|
|
51
|
+
* @param id - Target panel ID. No-op if already focused or ID is unknown.
|
|
52
|
+
*/
|
|
25
53
|
focus(id: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* Route a key message through hotkey detection and the focused panel's key map.
|
|
56
|
+
*
|
|
57
|
+
* @param msg - Incoming key event.
|
|
58
|
+
* @returns Action from the focused panel's key map, or undefined if unmatched.
|
|
59
|
+
*/
|
|
26
60
|
handle(msg: KeyMsg): A | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Format a panel label for display, applying focus-aware styling.
|
|
63
|
+
*
|
|
64
|
+
* @param id - Panel ID whose label to format.
|
|
65
|
+
* @param ctx - Optional Bijou context for styled output.
|
|
66
|
+
* @returns Formatted label string (plain if no ctx, styled otherwise).
|
|
67
|
+
*/
|
|
27
68
|
formatLabel(id: string, ctx?: BijouContext): string;
|
|
69
|
+
/**
|
|
70
|
+
* Remove all input stack layers owned by this panel group.
|
|
71
|
+
*/
|
|
28
72
|
dispose(): void;
|
|
29
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Create a panel group that manages focus and input routing across panels.
|
|
76
|
+
*
|
|
77
|
+
* Register hotkey and panel layers on the optional input stack. Hotkey presses
|
|
78
|
+
* switch focus; the focused panel's key map handles all other input.
|
|
79
|
+
*
|
|
80
|
+
* @template A - Action type produced by panel key maps.
|
|
81
|
+
* @param options - Panel group configuration.
|
|
82
|
+
* @returns Panel group instance with focus management and input routing.
|
|
83
|
+
* @throws {Error} If `defaultFocus` does not match any panel ID.
|
|
84
|
+
*/
|
|
30
85
|
export declare function createPanelGroup<A>(options: PanelGroupOptions<A>): PanelGroup<A>;
|
|
31
86
|
//# sourceMappingURL=panels.d.ts.map
|
package/dist/panels.d.ts.map
CHANGED
|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;IACH,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;IACpD;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CACjB;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAuHhF"}
|
package/dist/panels.js
CHANGED
|
@@ -8,6 +8,17 @@
|
|
|
8
8
|
// ---------------------------------------------------------------------------
|
|
9
9
|
// Implementation
|
|
10
10
|
// ---------------------------------------------------------------------------
|
|
11
|
+
/**
|
|
12
|
+
* Create a panel group that manages focus and input routing across panels.
|
|
13
|
+
*
|
|
14
|
+
* Register hotkey and panel layers on the optional input stack. Hotkey presses
|
|
15
|
+
* switch focus; the focused panel's key map handles all other input.
|
|
16
|
+
*
|
|
17
|
+
* @template A - Action type produced by panel key maps.
|
|
18
|
+
* @param options - Panel group configuration.
|
|
19
|
+
* @returns Panel group instance with focus management and input routing.
|
|
20
|
+
* @throws {Error} If `defaultFocus` does not match any panel ID.
|
|
21
|
+
*/
|
|
11
22
|
export function createPanelGroup(options) {
|
|
12
23
|
const panelMap = new Map();
|
|
13
24
|
const hotkeyMap = new Map();
|
package/dist/panels.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panels.js","sourceRoot":"","sources":["../src/panels.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"panels.js","sourceRoot":"","sources":["../src/panels.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA4EH,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAAI,OAA6B;IAC/D,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAuB,CAAC;IAChD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAk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CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -8,6 +8,12 @@ import type { App, RunOptions } from './types.js';
|
|
|
8
8
|
*
|
|
9
9
|
* All input sources (keyboard, resize, commands) are unified through an
|
|
10
10
|
* internal EventBus — a single subscription drives the update cycle.
|
|
11
|
+
*
|
|
12
|
+
* @template Model - The application model type.
|
|
13
|
+
* @template M - The message (action) type for the TEA update cycle.
|
|
14
|
+
* @param app - The TEA application definition (init, update, view).
|
|
15
|
+
* @param options - Optional runtime configuration (context, alt screen, cursor, mouse).
|
|
16
|
+
* @returns A promise that resolves when the application exits.
|
|
11
17
|
*/
|
|
12
18
|
export declare function run<Model, M>(app: App<Model, M>, options?: RunOptions): Promise<void>;
|
|
13
19
|
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAO,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAO,UAAU,EAAE,MAAM,YAAY,CAAC;AAkBvD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,GAAG,CAAC,KAAK,EAAE,CAAC,EAChC,GAAG,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,EAClB,OAAO,CAAC,EAAE,UAAU,GACnB,OAAO,CAAC,IAAI,CAAC,CA+Ff"}
|
package/dist/runtime.js
CHANGED
|
@@ -7,6 +7,12 @@ import { createEventBus } from './eventbus.js';
|
|
|
7
7
|
* Some terminals auto-enable mouse tracking in alt screen mode.
|
|
8
8
|
*/
|
|
9
9
|
const DISABLE_MOUSE = '\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l';
|
|
10
|
+
/**
|
|
11
|
+
* Enable SGR mouse reporting.
|
|
12
|
+
* 1000 = basic press/release, 1002 = button-event tracking (drag),
|
|
13
|
+
* 1006 = SGR extended format (supports large coordinates, explicit release).
|
|
14
|
+
*/
|
|
15
|
+
const ENABLE_MOUSE = '\x1b[?1000h\x1b[?1002h\x1b[?1006h';
|
|
10
16
|
/**
|
|
11
17
|
* Run a TEA application.
|
|
12
18
|
*
|
|
@@ -16,11 +22,18 @@ const DISABLE_MOUSE = '\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l';
|
|
|
16
22
|
*
|
|
17
23
|
* All input sources (keyboard, resize, commands) are unified through an
|
|
18
24
|
* internal EventBus — a single subscription drives the update cycle.
|
|
25
|
+
*
|
|
26
|
+
* @template Model - The application model type.
|
|
27
|
+
* @template M - The message (action) type for the TEA update cycle.
|
|
28
|
+
* @param app - The TEA application definition (init, update, view).
|
|
29
|
+
* @param options - Optional runtime configuration (context, alt screen, cursor, mouse).
|
|
30
|
+
* @returns A promise that resolves when the application exits.
|
|
19
31
|
*/
|
|
20
32
|
export async function run(app, options) {
|
|
21
33
|
const ctx = options?.ctx ?? getDefaultContext();
|
|
22
34
|
const useAltScreen = options?.altScreen ?? true;
|
|
23
35
|
const useHideCursor = options?.hideCursor ?? true;
|
|
36
|
+
const useMouse = options?.mouse ?? false;
|
|
24
37
|
const [initModel, initCmds] = app.init();
|
|
25
38
|
// Non-interactive: render once and return
|
|
26
39
|
if (ctx.mode !== 'interactive') {
|
|
@@ -44,7 +57,12 @@ export async function run(app, options) {
|
|
|
44
57
|
if (useAltScreen || useHideCursor) {
|
|
45
58
|
enterScreen(ctx.io);
|
|
46
59
|
}
|
|
47
|
-
|
|
60
|
+
if (useMouse) {
|
|
61
|
+
ctx.io.write(ENABLE_MOUSE);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
ctx.io.write(DISABLE_MOUSE);
|
|
65
|
+
}
|
|
48
66
|
// Render helper
|
|
49
67
|
function render() {
|
|
50
68
|
if (!running)
|
|
@@ -57,8 +75,8 @@ export async function run(app, options) {
|
|
|
57
75
|
bus.runCmd(cmd);
|
|
58
76
|
}
|
|
59
77
|
}
|
|
60
|
-
// Connect I/O sources — keyboard + resize, parsed and unified
|
|
61
|
-
bus.connectIO(ctx.io);
|
|
78
|
+
// Connect I/O sources — keyboard + resize (+ mouse when enabled), parsed and unified
|
|
79
|
+
bus.connectIO(ctx.io, { mouse: useMouse });
|
|
62
80
|
// Handle quit signals from commands
|
|
63
81
|
bus.onQuit(shutdown);
|
|
64
82
|
// Single subscription drives the entire update cycle
|
|
@@ -90,6 +108,9 @@ export async function run(app, options) {
|
|
|
90
108
|
});
|
|
91
109
|
// Cleanup — bus disposes all I/O connections
|
|
92
110
|
bus.dispose();
|
|
111
|
+
if (useMouse) {
|
|
112
|
+
ctx.io.write(DISABLE_MOUSE);
|
|
113
|
+
}
|
|
93
114
|
if (useAltScreen || useHideCursor) {
|
|
94
115
|
exitScreen(ctx.io);
|
|
95
116
|
}
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C;;;GAGG;AACH,MAAM,aAAa,GAAG,8CAA8C,CAAC;AAErE
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,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GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAChD,KAAK,GAAG,QAAQ,CAAC;QACjB,MAAM,EAAE,CAAC;QACT,eAAe,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,oCAAoC;IACpC,MAAM,EAAE,CAAC;IACT,eAAe,CAAC,QAAQ,CAAC,CAAC;IAE1B,uBAAuB;IACvB,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QAClC,WAAW,GAAG,OAAO,CAAC;QACtB,IAAI,CAAC,OAAO;YAAE,OAAO,EAAE,CAAC;IAC1B,CAAC,CAAC,CAAC;IAEH,6CAA6C;IAC7C,GAAG,CAAC,OAAO,EAAE,CAAC;IACd,IAAI,QAAQ,EAAE,CAAC;QACb,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAC9B,CAAC;IACD,IAAI,YAAY,IAAI,aAAa,EAAE,CAAC;QAClC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACrB,CAAC;AACH,CAAC"}
|
package/dist/screen.d.ts
CHANGED
|
@@ -1,20 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ANSI escape sequences and helpers for terminal screen management.
|
|
3
|
+
*
|
|
4
|
+
* Provides low-level building blocks used by the TEA runtime to
|
|
5
|
+
* enter/exit alternate screen mode and render flicker-free frames.
|
|
6
|
+
*
|
|
7
|
+
* @module screen
|
|
8
|
+
*/
|
|
1
9
|
import type { IOPort } from '@flyingrobots/bijou';
|
|
10
|
+
/** ANSI escape: enter alternate screen buffer (DEC Private Mode 1049). */
|
|
2
11
|
export declare const ENTER_ALT_SCREEN = "\u001B[?1049h";
|
|
12
|
+
/** ANSI escape: exit alternate screen buffer (DEC Private Mode 1049). */
|
|
3
13
|
export declare const EXIT_ALT_SCREEN = "\u001B[?1049l";
|
|
14
|
+
/** ANSI escape: hide the text cursor (DEC Private Mode 25). */
|
|
4
15
|
export declare const HIDE_CURSOR = "\u001B[?25l";
|
|
16
|
+
/** ANSI escape: show the text cursor (DEC Private Mode 25). */
|
|
5
17
|
export declare const SHOW_CURSOR = "\u001B[?25h";
|
|
18
|
+
/** ANSI escape: disable line wrapping (DEC Private Mode 7). */
|
|
6
19
|
export declare const WRAP_DISABLE = "\u001B[?7l";
|
|
20
|
+
/** ANSI escape: enable line wrapping (DEC Private Mode 7). */
|
|
7
21
|
export declare const WRAP_ENABLE = "\u001B[?7h";
|
|
22
|
+
/** ANSI escape: clear entire screen (ED 2). */
|
|
8
23
|
export declare const CLEAR_SCREEN = "\u001B[2J";
|
|
24
|
+
/** ANSI escape: clear from cursor to end of screen (ED 0). */
|
|
9
25
|
export declare const CLEAR_TO_END = "\u001B[J";
|
|
26
|
+
/** ANSI escape: clear from cursor to end of current line (EL 0). */
|
|
10
27
|
export declare const CLEAR_LINE_TO_END = "\u001B[K";
|
|
28
|
+
/** ANSI escape: move cursor to row 1, column 1 (CUP). */
|
|
11
29
|
export declare const HOME = "\u001B[H";
|
|
30
|
+
/** ANSI escape: clear entire current line (EL 2). */
|
|
12
31
|
export declare const CLEAR_LINE = "\u001B[2K";
|
|
13
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Enter alt screen buffer, hide cursor, disable wrap, and clear screen.
|
|
34
|
+
*
|
|
35
|
+
* @param io - The I/O port to write escape sequences to.
|
|
36
|
+
*/
|
|
14
37
|
export declare function enterScreen(io: IOPort): void;
|
|
15
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Show cursor, enable wrap, and exit alt screen buffer.
|
|
40
|
+
*
|
|
41
|
+
* @param io - The I/O port to write escape sequences to.
|
|
42
|
+
*/
|
|
16
43
|
export declare function exitScreen(io: IOPort): void;
|
|
17
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Clear screen and move cursor to home position.
|
|
46
|
+
*
|
|
47
|
+
* @param io - The I/O port to write escape sequences to.
|
|
48
|
+
*/
|
|
18
49
|
export declare function clearAndHome(io: IOPort): void;
|
|
19
50
|
/**
|
|
20
51
|
* Flicker-free render: move cursor home, write content line-by-line,
|
|
@@ -22,6 +53,9 @@ export declare function clearAndHome(io: IOPort): void;
|
|
|
22
53
|
*
|
|
23
54
|
* Disabling wrap in enterScreen() ensures the terminal won't scroll
|
|
24
55
|
* if we write to the bottom-right cell.
|
|
56
|
+
*
|
|
57
|
+
* @param io - The I/O port to write the composed frame to.
|
|
58
|
+
* @param content - The rendered view string (may contain newlines).
|
|
25
59
|
*/
|
|
26
60
|
export declare function renderFrame(io: IOPort, content: string): void;
|
|
27
61
|
//# sourceMappingURL=screen.d.ts.map
|
package/dist/screen.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../src/screen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,eAAO,MAAM,gBAAgB,kBAAgB,CAAC;AAC9C,eAAO,MAAM,eAAe,kBAAgB,CAAC;AAC7C,eAAO,MAAM,WAAW,gBAAc,CAAC;AACvC,eAAO,MAAM,WAAW,gBAAc,CAAC;AACvC,eAAO,MAAM,YAAY,eAAa,CAAC;AACvC,eAAO,MAAM,WAAW,eAAa,CAAC;AACtC,eAAO,MAAM,YAAY,cAAY,CAAC;AACtC,eAAO,MAAM,YAAY,aAAW,CAAC;AACrC,eAAO,MAAM,iBAAiB,aAAW,CAAC;AAC1C,eAAO,MAAM,IAAI,aAAW,CAAC;AAC7B,eAAO,MAAM,UAAU,cAAY,CAAC;AAEpC
|
|
1
|
+
{"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../src/screen.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,kBAAgB,CAAC;AAC9C,yEAAyE;AACzE,eAAO,MAAM,eAAe,kBAAgB,CAAC;AAC7C,+DAA+D;AAC/D,eAAO,MAAM,WAAW,gBAAc,CAAC;AACvC,+DAA+D;AAC/D,eAAO,MAAM,WAAW,gBAAc,CAAC;AACvC,+DAA+D;AAC/D,eAAO,MAAM,YAAY,eAAa,CAAC;AACvC,8DAA8D;AAC9D,eAAO,MAAM,WAAW,eAAa,CAAC;AACtC,+CAA+C;AAC/C,eAAO,MAAM,YAAY,cAAY,CAAC;AACtC,8DAA8D;AAC9D,eAAO,MAAM,YAAY,aAAW,CAAC;AACrC,oEAAoE;AACpE,eAAO,MAAM,iBAAiB,aAAW,CAAC;AAC1C,yDAAyD;AACzD,eAAO,MAAM,IAAI,aAAW,CAAC;AAC7B,qDAAqD;AACrD,eAAO,MAAM,UAAU,cAAY,CAAC;AAEpC;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAE3C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAI7D"}
|
package/dist/screen.js
CHANGED
|
@@ -1,23 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ANSI escape sequences and helpers for terminal screen management.
|
|
3
|
+
*
|
|
4
|
+
* Provides low-level building blocks used by the TEA runtime to
|
|
5
|
+
* enter/exit alternate screen mode and render flicker-free frames.
|
|
6
|
+
*
|
|
7
|
+
* @module screen
|
|
8
|
+
*/
|
|
9
|
+
/** ANSI escape: enter alternate screen buffer (DEC Private Mode 1049). */
|
|
1
10
|
export const ENTER_ALT_SCREEN = '\x1b[?1049h';
|
|
11
|
+
/** ANSI escape: exit alternate screen buffer (DEC Private Mode 1049). */
|
|
2
12
|
export const EXIT_ALT_SCREEN = '\x1b[?1049l';
|
|
13
|
+
/** ANSI escape: hide the text cursor (DEC Private Mode 25). */
|
|
3
14
|
export const HIDE_CURSOR = '\x1b[?25l';
|
|
15
|
+
/** ANSI escape: show the text cursor (DEC Private Mode 25). */
|
|
4
16
|
export const SHOW_CURSOR = '\x1b[?25h';
|
|
17
|
+
/** ANSI escape: disable line wrapping (DEC Private Mode 7). */
|
|
5
18
|
export const WRAP_DISABLE = '\x1b[?7l';
|
|
19
|
+
/** ANSI escape: enable line wrapping (DEC Private Mode 7). */
|
|
6
20
|
export const WRAP_ENABLE = '\x1b[?7h';
|
|
21
|
+
/** ANSI escape: clear entire screen (ED 2). */
|
|
7
22
|
export const CLEAR_SCREEN = '\x1b[2J';
|
|
23
|
+
/** ANSI escape: clear from cursor to end of screen (ED 0). */
|
|
8
24
|
export const CLEAR_TO_END = '\x1b[J';
|
|
25
|
+
/** ANSI escape: clear from cursor to end of current line (EL 0). */
|
|
9
26
|
export const CLEAR_LINE_TO_END = '\x1b[K';
|
|
27
|
+
/** ANSI escape: move cursor to row 1, column 1 (CUP). */
|
|
10
28
|
export const HOME = '\x1b[H';
|
|
29
|
+
/** ANSI escape: clear entire current line (EL 2). */
|
|
11
30
|
export const CLEAR_LINE = '\x1b[2K';
|
|
12
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Enter alt screen buffer, hide cursor, disable wrap, and clear screen.
|
|
33
|
+
*
|
|
34
|
+
* @param io - The I/O port to write escape sequences to.
|
|
35
|
+
*/
|
|
13
36
|
export function enterScreen(io) {
|
|
14
37
|
io.write(ENTER_ALT_SCREEN + HIDE_CURSOR + WRAP_DISABLE + CLEAR_SCREEN + HOME);
|
|
15
38
|
}
|
|
16
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Show cursor, enable wrap, and exit alt screen buffer.
|
|
41
|
+
*
|
|
42
|
+
* @param io - The I/O port to write escape sequences to.
|
|
43
|
+
*/
|
|
17
44
|
export function exitScreen(io) {
|
|
18
45
|
io.write(SHOW_CURSOR + WRAP_ENABLE + EXIT_ALT_SCREEN);
|
|
19
46
|
}
|
|
20
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Clear screen and move cursor to home position.
|
|
49
|
+
*
|
|
50
|
+
* @param io - The I/O port to write escape sequences to.
|
|
51
|
+
*/
|
|
21
52
|
export function clearAndHome(io) {
|
|
22
53
|
io.write(CLEAR_SCREEN + HOME);
|
|
23
54
|
}
|
|
@@ -27,6 +58,9 @@ export function clearAndHome(io) {
|
|
|
27
58
|
*
|
|
28
59
|
* Disabling wrap in enterScreen() ensures the terminal won't scroll
|
|
29
60
|
* if we write to the bottom-right cell.
|
|
61
|
+
*
|
|
62
|
+
* @param io - The I/O port to write the composed frame to.
|
|
63
|
+
* @param content - The rendered view string (may contain newlines).
|
|
30
64
|
*/
|
|
31
65
|
export function renderFrame(io, content) {
|
|
32
66
|
const lines = content.split('\n');
|
package/dist/screen.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screen.js","sourceRoot":"","sources":["../src/screen.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"screen.js","sourceRoot":"","sources":["../src/screen.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,0EAA0E;AAC1E,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAC9C,yEAAyE;AACzE,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAC7C,+DAA+D;AAC/D,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC;AACvC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC;AACvC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;AACvC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC;AACtC,+CAA+C;AAC/C,MAAM,CAAC,MAAM,YAA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