xray-manager 1.1.1 → 1.3.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/README.md +31 -859
- package/dist/commands/interactive.d.ts +0 -42
- package/dist/commands/interactive.d.ts.map +1 -1
- package/dist/commands/interactive.js +73 -173
- package/dist/commands/interactive.js.map +1 -1
- package/dist/commands/service.d.ts.map +1 -1
- package/dist/commands/service.js +33 -15
- package/dist/commands/service.js.map +1 -1
- package/dist/commands/user.d.ts.map +1 -1
- package/dist/commands/user.js +32 -12
- package/dist/commands/user.js.map +1 -1
- package/dist/components/dashboard-widget.d.ts +18 -0
- package/dist/components/dashboard-widget.d.ts.map +1 -0
- package/dist/components/dashboard-widget.js +159 -0
- package/dist/components/dashboard-widget.js.map +1 -0
- package/dist/components/user-table.d.ts +8 -0
- package/dist/components/user-table.d.ts.map +1 -0
- package/dist/components/user-table.js +86 -0
- package/dist/components/user-table.js.map +1 -0
- package/dist/config/i18n.d.ts +4 -0
- package/dist/config/i18n.d.ts.map +1 -1
- package/dist/config/i18n.js +8 -0
- package/dist/config/i18n.js.map +1 -1
- package/dist/constants/theme.d.ts +34 -0
- package/dist/constants/theme.d.ts.map +1 -0
- package/dist/constants/theme.js +52 -0
- package/dist/constants/theme.js.map +1 -0
- package/dist/constants/ui-symbols.d.ts +1 -0
- package/dist/constants/ui-symbols.d.ts.map +1 -1
- package/dist/constants/ui-symbols.js +1 -0
- package/dist/constants/ui-symbols.js.map +1 -1
- package/dist/services/layout-manager.d.ts +94 -0
- package/dist/services/layout-manager.d.ts.map +1 -0
- package/dist/services/layout-manager.js +192 -0
- package/dist/services/layout-manager.js.map +1 -0
- package/dist/services/navigation-manager.d.ts +23 -0
- package/dist/services/navigation-manager.d.ts.map +1 -0
- package/dist/services/navigation-manager.js +39 -0
- package/dist/services/navigation-manager.js.map +1 -0
- package/dist/services/screen-manager.d.ts +13 -0
- package/dist/services/screen-manager.d.ts.map +1 -0
- package/dist/services/screen-manager.js +42 -0
- package/dist/services/screen-manager.js.map +1 -0
- package/dist/types/layout.d.ts +119 -0
- package/dist/types/layout.d.ts.map +1 -0
- package/dist/types/layout.js +142 -0
- package/dist/types/layout.js.map +1 -0
- package/dist/types/ui-components.d.ts +53 -0
- package/dist/types/ui-components.d.ts.map +1 -0
- package/dist/types/ui-components.js +3 -0
- package/dist/types/ui-components.js.map +1 -0
- package/dist/types/user.d.ts +11 -0
- package/dist/types/user.d.ts.map +1 -1
- package/dist/utils/layout.d.ts +142 -0
- package/dist/utils/layout.d.ts.map +1 -0
- package/dist/utils/layout.js +381 -0
- package/dist/utils/layout.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Layout Type Definitions
|
|
4
|
+
*
|
|
5
|
+
* Core types for terminal layout system supporting responsive layouts
|
|
6
|
+
* and multi-column displays.
|
|
7
|
+
*
|
|
8
|
+
* Feature: 005-ui-layout-expansion
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.LAYOUT_MODE_THRESHOLDS = exports.MIN_TERMINAL_SIZE = exports.DEFAULT_LAYOUT = exports.ContentRegionType = exports.LayoutMode = void 0;
|
|
12
|
+
exports.validateLayout = validateLayout;
|
|
13
|
+
exports.validateRegion = validateRegion;
|
|
14
|
+
/**
|
|
15
|
+
* Layout mode enum - defines different terminal size strategies
|
|
16
|
+
*/
|
|
17
|
+
/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
|
|
18
|
+
var LayoutMode;
|
|
19
|
+
(function (LayoutMode) {
|
|
20
|
+
/** Narrow terminals (< 80 columns) */
|
|
21
|
+
LayoutMode["COMPACT"] = "compact";
|
|
22
|
+
/** Standard terminals (80-120 columns) */
|
|
23
|
+
LayoutMode["STANDARD"] = "standard";
|
|
24
|
+
/** Wide terminals (> 120 columns) */
|
|
25
|
+
LayoutMode["WIDE"] = "wide";
|
|
26
|
+
})(LayoutMode || (exports.LayoutMode = LayoutMode = {}));
|
|
27
|
+
/* eslint-enable @typescript-eslint/no-unused-vars, no-unused-vars */
|
|
28
|
+
/**
|
|
29
|
+
* Content region type enum - categorizes different UI regions
|
|
30
|
+
*/
|
|
31
|
+
/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
|
|
32
|
+
var ContentRegionType;
|
|
33
|
+
(function (ContentRegionType) {
|
|
34
|
+
/** Page header/title area */
|
|
35
|
+
ContentRegionType["HEADER"] = "header";
|
|
36
|
+
/** Menu options area */
|
|
37
|
+
ContentRegionType["MENU"] = "menu";
|
|
38
|
+
/** Status information area */
|
|
39
|
+
ContentRegionType["STATUS"] = "status";
|
|
40
|
+
/** Main content area */
|
|
41
|
+
ContentRegionType["CONTENT"] = "content";
|
|
42
|
+
/** Footer/hints area */
|
|
43
|
+
ContentRegionType["FOOTER"] = "footer";
|
|
44
|
+
})(ContentRegionType || (exports.ContentRegionType = ContentRegionType = {}));
|
|
45
|
+
/**
|
|
46
|
+
* Default layout configuration for non-TTY or fallback scenarios
|
|
47
|
+
*/
|
|
48
|
+
exports.DEFAULT_LAYOUT = {
|
|
49
|
+
width: 80,
|
|
50
|
+
height: 24,
|
|
51
|
+
mode: LayoutMode.STANDARD,
|
|
52
|
+
columns: 1,
|
|
53
|
+
regions: [],
|
|
54
|
+
timestamp: 0,
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Minimum terminal size constraints
|
|
58
|
+
*/
|
|
59
|
+
exports.MIN_TERMINAL_SIZE = {
|
|
60
|
+
width: 60,
|
|
61
|
+
height: 20,
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Layout mode thresholds for width-based mode selection
|
|
65
|
+
*/
|
|
66
|
+
exports.LAYOUT_MODE_THRESHOLDS = {
|
|
67
|
+
COMPACT_MAX: 79,
|
|
68
|
+
STANDARD_MIN: 80,
|
|
69
|
+
STANDARD_MAX: 120,
|
|
70
|
+
WIDE_MIN: 121,
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Validate that a TerminalLayout configuration is valid
|
|
74
|
+
*
|
|
75
|
+
* @param layout - Layout to validate
|
|
76
|
+
* @returns true if valid
|
|
77
|
+
* @throws Error if validation fails
|
|
78
|
+
*/
|
|
79
|
+
function validateLayout(layout) {
|
|
80
|
+
// 1. Check minimum size
|
|
81
|
+
if (layout.width < exports.MIN_TERMINAL_SIZE.width || layout.height < exports.MIN_TERMINAL_SIZE.height) {
|
|
82
|
+
throw new Error(`Terminal too small: ${layout.width}x${layout.height} (min: ${exports.MIN_TERMINAL_SIZE.width}x${exports.MIN_TERMINAL_SIZE.height})`);
|
|
83
|
+
}
|
|
84
|
+
// 2. Check mode matches width
|
|
85
|
+
const expectedMode = layout.width < exports.LAYOUT_MODE_THRESHOLDS.STANDARD_MIN
|
|
86
|
+
? LayoutMode.COMPACT
|
|
87
|
+
: layout.width > exports.LAYOUT_MODE_THRESHOLDS.STANDARD_MAX
|
|
88
|
+
? LayoutMode.WIDE
|
|
89
|
+
: LayoutMode.STANDARD;
|
|
90
|
+
if (layout.mode !== expectedMode) {
|
|
91
|
+
throw new Error(`LayoutMode mismatch: expected ${expectedMode} for width ${layout.width}, got ${layout.mode}`);
|
|
92
|
+
}
|
|
93
|
+
// 3. Check columns constraint
|
|
94
|
+
if (layout.mode === LayoutMode.WIDE && layout.columns < 2) {
|
|
95
|
+
throw new Error(`WIDE mode requires columns >= 2, got ${layout.columns}`);
|
|
96
|
+
}
|
|
97
|
+
if (layout.mode !== LayoutMode.WIDE && layout.columns !== 1) {
|
|
98
|
+
throw new Error(`Non-WIDE mode requires columns = 1, got ${layout.columns}`);
|
|
99
|
+
}
|
|
100
|
+
// 4. Validate all content regions
|
|
101
|
+
for (const region of layout.regions) {
|
|
102
|
+
validateRegion(region, layout);
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Validate that a ContentRegion is valid within a given layout
|
|
108
|
+
*
|
|
109
|
+
* @param region - Region to validate
|
|
110
|
+
* @param layout - Parent layout
|
|
111
|
+
* @returns true if valid
|
|
112
|
+
* @throws Error if validation fails
|
|
113
|
+
*/
|
|
114
|
+
function validateRegion(region, layout) {
|
|
115
|
+
// 1. Check position bounds
|
|
116
|
+
if (region.position.row < 0 || region.position.row >= layout.height) {
|
|
117
|
+
throw new Error(`Region ${region.id}: row ${region.position.row} out of bounds (0-${layout.height - 1})`);
|
|
118
|
+
}
|
|
119
|
+
if (region.position.column < 0 || region.position.column >= layout.width) {
|
|
120
|
+
throw new Error(`Region ${region.id}: column ${region.position.column} out of bounds (0-${layout.width - 1})`);
|
|
121
|
+
}
|
|
122
|
+
// 2. Check size bounds
|
|
123
|
+
const maxWidth = layout.width - region.position.column;
|
|
124
|
+
const maxHeight = layout.height - region.position.row;
|
|
125
|
+
if (region.size.width <= 0 || region.size.width > maxWidth) {
|
|
126
|
+
throw new Error(`Region ${region.id}: width ${region.size.width} out of bounds (1-${maxWidth})`);
|
|
127
|
+
}
|
|
128
|
+
if (region.size.height <= 0 || region.size.height > maxHeight) {
|
|
129
|
+
throw new Error(`Region ${region.id}: height ${region.size.height} out of bounds (1-${maxHeight})`);
|
|
130
|
+
}
|
|
131
|
+
// 3. Check padding validity
|
|
132
|
+
const totalHorizontalPadding = region.padding.left + region.padding.right;
|
|
133
|
+
const totalVerticalPadding = region.padding.top + region.padding.bottom;
|
|
134
|
+
if (totalHorizontalPadding >= region.size.width) {
|
|
135
|
+
throw new Error(`Region ${region.id}: horizontal padding ${totalHorizontalPadding} >= width ${region.size.width}`);
|
|
136
|
+
}
|
|
137
|
+
if (totalVerticalPadding >= region.size.height) {
|
|
138
|
+
throw new Error(`Region ${region.id}: vertical padding ${totalVerticalPadding} >= height ${region.size.height}`);
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1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AAC,EAAE,YAAY,MAAM,CAAC,IAAI,CAAC,MAAM,qBAAqB,SAAS,GAAG,CAAC,CAAC;IACtG,CAAC;IAED,4BAA4B;IAC5B,MAAM,sBAAsB,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;IAC1E,MAAM,oBAAoB,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;IAExE,IAAI,sBAAsB,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CACb,UAAU,MAAM,CAAC,EAAE,wBAAwB,sBAAsB,aAAa,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAClG,CAAC;IACJ,CAAC;IACD,IAAI,oBAAoB,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CACb,UAAU,MAAM,CAAC,EAAE,sBAAsB,oBAAoB,cAAc,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAChG,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for the Dashboard Widget
|
|
3
|
+
* Responsible for rendering the persistent status header.
|
|
4
|
+
*/
|
|
5
|
+
export interface IDashboardWidget {
|
|
6
|
+
/**
|
|
7
|
+
* Refreshes the internal data snapshot (service status, user count, etc.)
|
|
8
|
+
*/
|
|
9
|
+
refresh(): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Renders the dashboard as a formatted string string suitable for printing.
|
|
12
|
+
* Should respect terminal width and use box-drawing characters.
|
|
13
|
+
* @param width - The available width in columns.
|
|
14
|
+
*/
|
|
15
|
+
render(_width: number): string;
|
|
16
|
+
}
|
|
17
|
+
export interface IScreenManager {
|
|
18
|
+
/**
|
|
19
|
+
* Clears the terminal screen and scrollback (if supported/configured).
|
|
20
|
+
*/
|
|
21
|
+
clear(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Renders the complete frame: Dashboard + Breadcrumb + Content Placeholder
|
|
24
|
+
* @param dashboard - The dashboard widget instance
|
|
25
|
+
* @param breadcrumb - The current breadcrumb string
|
|
26
|
+
*/
|
|
27
|
+
renderHeader(_dashboard: IDashboardWidget, _breadcrumb: string): void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Interface for Navigation Manager
|
|
31
|
+
* Tracks the user's current location in the menu hierarchy.
|
|
32
|
+
*/
|
|
33
|
+
export interface INavigationManager {
|
|
34
|
+
/**
|
|
35
|
+
* Pushes a new menu level onto the stack.
|
|
36
|
+
* @param label - The display label for the new level.
|
|
37
|
+
*/
|
|
38
|
+
push(_label: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* Pops the current level off the stack.
|
|
41
|
+
* @returns The label of the popped level.
|
|
42
|
+
*/
|
|
43
|
+
pop(): string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the formatted breadcrumb string (e.g., "Home > User Management")
|
|
46
|
+
*/
|
|
47
|
+
getBreadcrumb(): string;
|
|
48
|
+
/**
|
|
49
|
+
* Gets the current depth of the stack.
|
|
50
|
+
*/
|
|
51
|
+
getDepth(): number;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=ui-components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-components.d.ts","sourceRoot":"","sources":["../../src/types/ui-components.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzB;;;;OAIG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;IAEd;;;;OAIG;IACH,YAAY,CAAC,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CACvE;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAE3B;;;OAGG;IACH,GAAG,IAAI,MAAM,GAAG,SAAS,CAAC;IAE1B;;OAEG;IACH,aAAa,IAAI,MAAM,CAAC;IAExB;;OAEG;IACH,QAAQ,IAAI,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-components.js","sourceRoot":"","sources":["../../src/types/ui-components.ts"],"names":[],"mappings":""}
|
package/dist/types/user.d.ts
CHANGED
|
@@ -21,6 +21,17 @@ export interface User {
|
|
|
21
21
|
/** 最后修改时间 */
|
|
22
22
|
updatedAt?: string;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* 用户配置(用于显示)
|
|
26
|
+
*/
|
|
27
|
+
export interface UserConfig {
|
|
28
|
+
username: string;
|
|
29
|
+
uuid: string;
|
|
30
|
+
port?: number;
|
|
31
|
+
protocol?: string;
|
|
32
|
+
flow?: string;
|
|
33
|
+
status?: string;
|
|
34
|
+
}
|
|
24
35
|
/**
|
|
25
36
|
* 用户创建参数
|
|
26
37
|
*/
|
package/dist/types/user.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/types/user.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,sBAAsB;IACtB,EAAE,EAAE,MAAM,CAAC;IAEX,eAAe;IACf,KAAK,EAAE,MAAM,CAAC;IAEd,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;IAElB,0BAA0B;IAC1B,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAC;IAE9B,eAAe;IACf,IA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EAAE,WAAW,GAAG,OAAO,GAAG,WAAW,CAAC;IAE7C,WAAW;IACX,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAE3B,cAAc;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,cAAc;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,aAAa;IACb,OAAO,EAAE,OAAO,CAAC;IAEjB,WAAW;IACX,SAAS,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;IAEzD,iBAAiB;IACjB,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ,iBAAiB;IACjB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IAEf,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,eAAe;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,mBAAmB;IACnB,MAAM,EAAE,MAAM,CAAC;IAEf,YAAY;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout Utility Functions
|
|
3
|
+
*
|
|
4
|
+
* Pure functions for layout calculations, text fitting, and rendering
|
|
5
|
+
* Feature: 005-ui-layout-expansion
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Table column definition
|
|
9
|
+
*/
|
|
10
|
+
export interface TableColumn {
|
|
11
|
+
header: string;
|
|
12
|
+
key: string;
|
|
13
|
+
width?: number;
|
|
14
|
+
align?: 'left' | 'center' | 'right';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Render options for tables and sections
|
|
18
|
+
*/
|
|
19
|
+
export interface RenderOptions {
|
|
20
|
+
showBorder?: boolean;
|
|
21
|
+
borderStyle?: 'single' | 'double' | 'compact';
|
|
22
|
+
padding?: {
|
|
23
|
+
top: number;
|
|
24
|
+
right: number;
|
|
25
|
+
bottom: number;
|
|
26
|
+
left: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Calculate the display width of a string, accounting for Chinese characters
|
|
31
|
+
*
|
|
32
|
+
* Chinese characters (and other full-width characters) occupy 2 columns,
|
|
33
|
+
* while ASCII characters occupy 1 column.
|
|
34
|
+
*
|
|
35
|
+
* @param text - Input text
|
|
36
|
+
* @returns Display width in terminal columns
|
|
37
|
+
*/
|
|
38
|
+
export declare function calculateDisplayWidth(text: string): number;
|
|
39
|
+
/**
|
|
40
|
+
* Calculate the width of each column in a multi-column layout
|
|
41
|
+
*
|
|
42
|
+
* Formula: (totalWidth - (columns - 1) * gap) / columns
|
|
43
|
+
*
|
|
44
|
+
* @param totalWidth - Total available width
|
|
45
|
+
* @param columns - Number of columns
|
|
46
|
+
* @param gap - Space between columns
|
|
47
|
+
* @returns Width of each column (rounded down)
|
|
48
|
+
*/
|
|
49
|
+
export declare function calculateColumnWidth(totalWidth: number, columns: number, gap: number): number;
|
|
50
|
+
/**
|
|
51
|
+
* Fit text to a specific width by truncating or padding
|
|
52
|
+
*
|
|
53
|
+
* @param text - Input text
|
|
54
|
+
* @param width - Target width in columns
|
|
55
|
+
* @param align - Alignment ('left', 'center', 'right')
|
|
56
|
+
* @param ellipsis - Ellipsis string for truncation (default '...')
|
|
57
|
+
* @returns Text adjusted to exact width
|
|
58
|
+
*/
|
|
59
|
+
export declare function fitText(text: string, width: number, align?: 'left' | 'center' | 'right', ellipsis?: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Render a horizontal separator line
|
|
62
|
+
*
|
|
63
|
+
* @param width - Width of separator in columns
|
|
64
|
+
* @param char - Character to use (default '─')
|
|
65
|
+
* @param color - Optional chalk color name
|
|
66
|
+
* @returns Separator string
|
|
67
|
+
*/
|
|
68
|
+
export declare function renderSeparator(width: number, char?: string, color?: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* Render a header with optional alignment and border
|
|
71
|
+
*
|
|
72
|
+
* @param title - Header title text
|
|
73
|
+
* @param width - Total width
|
|
74
|
+
* @param align - Alignment
|
|
75
|
+
* @param options - Render options
|
|
76
|
+
* @returns Rendered header string
|
|
77
|
+
*/
|
|
78
|
+
export declare function renderHeader(title: string, width: number, align?: 'left' | 'center' | 'right', options?: {
|
|
79
|
+
showBorder?: boolean;
|
|
80
|
+
color?: string;
|
|
81
|
+
}): string;
|
|
82
|
+
/**
|
|
83
|
+
* Apply padding to a text block
|
|
84
|
+
*
|
|
85
|
+
* @param text - Original text (can be multi-line)
|
|
86
|
+
* @param padding - Padding configuration
|
|
87
|
+
* @param width - Target width (for horizontal padding)
|
|
88
|
+
* @returns Padded text
|
|
89
|
+
*/
|
|
90
|
+
export declare function applyPadding(text: string, padding: {
|
|
91
|
+
top: number;
|
|
92
|
+
right: number;
|
|
93
|
+
bottom: number;
|
|
94
|
+
left: number;
|
|
95
|
+
}, width: number): string;
|
|
96
|
+
/**
|
|
97
|
+
* Render a table using cli-table3
|
|
98
|
+
*
|
|
99
|
+
* @param columns - Column definitions
|
|
100
|
+
* @param rows - Data rows
|
|
101
|
+
* @param options - Render options
|
|
102
|
+
* @returns Rendered table string
|
|
103
|
+
*/
|
|
104
|
+
export declare function renderTable(columns: TableColumn[], rows: Record<string, unknown>[], options?: RenderOptions): string;
|
|
105
|
+
/**
|
|
106
|
+
* Render a section with title and content
|
|
107
|
+
*
|
|
108
|
+
* @param title - Section title
|
|
109
|
+
* @param content - Section content (can be multi-line)
|
|
110
|
+
* @param options - Render options
|
|
111
|
+
* @returns Rendered section string
|
|
112
|
+
*/
|
|
113
|
+
export declare function renderSection(title: string, content: string, options?: RenderOptions): string;
|
|
114
|
+
/**
|
|
115
|
+
* Distribute items evenly across multiple columns
|
|
116
|
+
*
|
|
117
|
+
* @param items - Array of items to distribute
|
|
118
|
+
* @param columnCount - Number of columns to create
|
|
119
|
+
* @returns Array of columns, each containing a subset of items
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* distributeToColumns(['A', 'B', 'C', 'D', 'E', 'F'], 2)
|
|
123
|
+
* // Returns: [['A', 'B', 'C'], ['D', 'E', 'F']]
|
|
124
|
+
*
|
|
125
|
+
* distributeToColumns(['A', 'B', 'C', 'D', 'E'], 2)
|
|
126
|
+
* // Returns: [['A', 'B', 'C'], ['D', 'E']]
|
|
127
|
+
*/
|
|
128
|
+
export declare function distributeToColumns<T>(items: T[], columnCount: number): T[][];
|
|
129
|
+
/**
|
|
130
|
+
* Render multiple columns of text side by side
|
|
131
|
+
*
|
|
132
|
+
* @param columns - Array of columns, each containing lines of text
|
|
133
|
+
* @param totalWidth - Total width available for all columns
|
|
134
|
+
* @param gap - Space between columns (default: 2)
|
|
135
|
+
* @returns Rendered multi-column text
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* renderColumns([['Line 1', 'Line 2'], ['Col 2 Line 1', 'Col 2 Line 2']], 80, 2)
|
|
139
|
+
* // Returns text with two columns side by side
|
|
140
|
+
*/
|
|
141
|
+
export declare function renderColumns(columns: string[][], totalWidth: number, gap?: number): string;
|
|
142
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/utils/layout.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC9C,OAAO,CAAC,EA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