@nu-art/commando 0.204.48 → 0.204.50
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/console/ConsoleContainer.d.ts +89 -0
- package/console/ConsoleContainer.js +145 -0
- package/console/ConsoleScreen.d.ts +20 -22
- package/console/ConsoleScreen.js +15 -105
- package/console/types.d.ts +51 -186
- package/console/types.js +67 -42
- package/core/cli.d.ts +0 -1
- package/package.json +4 -2
- package/tsconfig.json +4 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Logger, ResolvableContent } from '@nu-art/ts-common';
|
|
2
|
+
import { BlessedWidget, BlessedWidgetOptions, BlessedWidgetsType } from './types';
|
|
3
|
+
type KeyBinding = {
|
|
4
|
+
keys: string[];
|
|
5
|
+
callback: VoidFunction;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* An abstract class representing a container for Blessed widgets with state management and key bindings.
|
|
9
|
+
*
|
|
10
|
+
* @template Type - The type of the Blessed widget.
|
|
11
|
+
* @template State - The type of the state object.
|
|
12
|
+
*/
|
|
13
|
+
export declare abstract class ConsoleContainer<Type extends BlessedWidgetsType, State extends object = {}> extends Logger {
|
|
14
|
+
private readonly containerProps?;
|
|
15
|
+
private readonly keyBinding;
|
|
16
|
+
private enabled;
|
|
17
|
+
protected state: State;
|
|
18
|
+
protected container: BlessedWidget[Type];
|
|
19
|
+
protected type: Type;
|
|
20
|
+
protected readonly widgets: BlessedWidget[BlessedWidgetsType][];
|
|
21
|
+
/**
|
|
22
|
+
* Creates an instance of ConsoleContainer.
|
|
23
|
+
*
|
|
24
|
+
* @param {Type} type - The type of the container widget.
|
|
25
|
+
* @param {BlessedWidgetOptions[Type]} [containerProps] - The properties to apply to the container widget.
|
|
26
|
+
* @param {KeyBinding[]} [keyBinding] - An array of key bindings for the container widget.
|
|
27
|
+
*/
|
|
28
|
+
protected constructor(type: Type, containerProps?: BlessedWidgetOptions[Type], keyBinding?: KeyBinding[]);
|
|
29
|
+
/**
|
|
30
|
+
* Sets the state of the container and triggers a re-render.
|
|
31
|
+
*
|
|
32
|
+
* @param {ResolvableContent<Partial<State>>} state - The new state to set.
|
|
33
|
+
* @returns {this} The current instance for method chaining.
|
|
34
|
+
*/
|
|
35
|
+
setState(state: ResolvableContent<Partial<State>>): this;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a Blessed widget of the specified type and adds it to the container.
|
|
38
|
+
*
|
|
39
|
+
* @template WidgetType - The type of the widget to create.
|
|
40
|
+
* @param {WidgetType} type - The type of the widget to create.
|
|
41
|
+
* @param {BlessedWidgetOptions[WidgetType]} props - The properties to apply to the widget.
|
|
42
|
+
* @returns {BlessedWidget[WidgetType]} The created widget.
|
|
43
|
+
*/
|
|
44
|
+
createWidget<WidgetType extends BlessedWidgetsType>(type: WidgetType, props: BlessedWidgetOptions[WidgetType]): BlessedWidget[WidgetType];
|
|
45
|
+
/**
|
|
46
|
+
* Gets the currently focused widget within the container.
|
|
47
|
+
*
|
|
48
|
+
* @returns {Widgets.Node} The focused widget.
|
|
49
|
+
*/
|
|
50
|
+
getFocusedWidget(): BlessedWidget[BlessedWidgetsType];
|
|
51
|
+
private createContainer;
|
|
52
|
+
private _createWidgets;
|
|
53
|
+
/**
|
|
54
|
+
* Creates the widgets within the container.
|
|
55
|
+
* This method should be implemented by subclasses to define the specific widgets to create.
|
|
56
|
+
*/
|
|
57
|
+
protected abstract createContent(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Creates the container and its widgets, and resumes rendering if not already enabled.
|
|
60
|
+
*
|
|
61
|
+
* @returns {this} The current instance for method chaining.
|
|
62
|
+
*/
|
|
63
|
+
readonly create: () => this;
|
|
64
|
+
/**
|
|
65
|
+
* Resumes rendering and enables focus on the widgets.
|
|
66
|
+
*
|
|
67
|
+
* @returns {this} The current instance for method chaining.
|
|
68
|
+
*/
|
|
69
|
+
readonly resume: () => this;
|
|
70
|
+
private _render;
|
|
71
|
+
/**
|
|
72
|
+
* Renders the container.
|
|
73
|
+
* This method should be implemented by subclasses to define the specific rendering logic.
|
|
74
|
+
*/
|
|
75
|
+
protected abstract render(): void;
|
|
76
|
+
/**
|
|
77
|
+
* Pauses rendering and disables focus on the widgets.
|
|
78
|
+
*
|
|
79
|
+
* @returns {this} The current instance for method chaining.
|
|
80
|
+
*/
|
|
81
|
+
readonly pause: () => this;
|
|
82
|
+
/**
|
|
83
|
+
* Disposes of the container and its widgets.
|
|
84
|
+
*
|
|
85
|
+
* @returns {this} The current instance for method chaining.
|
|
86
|
+
*/
|
|
87
|
+
readonly dispose: () => this;
|
|
88
|
+
}
|
|
89
|
+
export {};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConsoleContainer = void 0;
|
|
4
|
+
const ts_common_1 = require("@nu-art/ts-common");
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
/**
|
|
7
|
+
* An abstract class representing a container for Blessed widgets with state management and key bindings.
|
|
8
|
+
*
|
|
9
|
+
* @template Type - The type of the Blessed widget.
|
|
10
|
+
* @template State - The type of the state object.
|
|
11
|
+
*/
|
|
12
|
+
class ConsoleContainer extends ts_common_1.Logger {
|
|
13
|
+
/**
|
|
14
|
+
* Creates an instance of ConsoleContainer.
|
|
15
|
+
*
|
|
16
|
+
* @param {Type} type - The type of the container widget.
|
|
17
|
+
* @param {BlessedWidgetOptions[Type]} [containerProps] - The properties to apply to the container widget.
|
|
18
|
+
* @param {KeyBinding[]} [keyBinding] - An array of key bindings for the container widget.
|
|
19
|
+
*/
|
|
20
|
+
constructor(type, containerProps, keyBinding = []) {
|
|
21
|
+
super(containerProps === null || containerProps === void 0 ? void 0 : containerProps.name);
|
|
22
|
+
this.enabled = false;
|
|
23
|
+
this.state = {};
|
|
24
|
+
this.widgets = [];
|
|
25
|
+
/**
|
|
26
|
+
* Creates the container and its widgets, and resumes rendering if not already enabled.
|
|
27
|
+
*
|
|
28
|
+
* @returns {this} The current instance for method chaining.
|
|
29
|
+
*/
|
|
30
|
+
this.create = () => {
|
|
31
|
+
this.createContainer();
|
|
32
|
+
this._createWidgets();
|
|
33
|
+
if (!this.enabled)
|
|
34
|
+
this.resume();
|
|
35
|
+
return this;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Resumes rendering and enables focus on the widgets.
|
|
39
|
+
*
|
|
40
|
+
* @returns {this} The current instance for method chaining.
|
|
41
|
+
*/
|
|
42
|
+
this.resume = () => {
|
|
43
|
+
this.enabled = true;
|
|
44
|
+
this.widgets.forEach(widget => {
|
|
45
|
+
widget.focusable = true;
|
|
46
|
+
});
|
|
47
|
+
this._render();
|
|
48
|
+
return this;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Pauses rendering and disables focus on the widgets.
|
|
52
|
+
*
|
|
53
|
+
* @returns {this} The current instance for method chaining.
|
|
54
|
+
*/
|
|
55
|
+
this.pause = () => {
|
|
56
|
+
this.enabled = false;
|
|
57
|
+
this.widgets.forEach(widget => {
|
|
58
|
+
widget.focusable = false;
|
|
59
|
+
});
|
|
60
|
+
return this;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Disposes of the container and its widgets.
|
|
64
|
+
*
|
|
65
|
+
* @returns {this} The current instance for method chaining.
|
|
66
|
+
*/
|
|
67
|
+
this.dispose = () => {
|
|
68
|
+
if (!this.container)
|
|
69
|
+
return this;
|
|
70
|
+
this.widgets.forEach(widget => widget.detach());
|
|
71
|
+
this.widgets.length = 0;
|
|
72
|
+
this._render();
|
|
73
|
+
if (this.enabled)
|
|
74
|
+
this.pause();
|
|
75
|
+
this.container.detach();
|
|
76
|
+
this.container.destroy();
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
this.container = null;
|
|
79
|
+
return this;
|
|
80
|
+
};
|
|
81
|
+
this.type = type;
|
|
82
|
+
this.keyBinding = keyBinding;
|
|
83
|
+
this.containerProps = containerProps;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Sets the state of the container and triggers a re-render.
|
|
87
|
+
*
|
|
88
|
+
* @param {ResolvableContent<Partial<State>>} state - The new state to set.
|
|
89
|
+
* @returns {this} The current instance for method chaining.
|
|
90
|
+
*/
|
|
91
|
+
setState(state) {
|
|
92
|
+
this.state = (0, ts_common_1.mergeObject)(this.state, state);
|
|
93
|
+
this._render();
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Creates a Blessed widget of the specified type and adds it to the container.
|
|
98
|
+
*
|
|
99
|
+
* @template WidgetType - The type of the widget to create.
|
|
100
|
+
* @param {WidgetType} type - The type of the widget to create.
|
|
101
|
+
* @param {BlessedWidgetOptions[WidgetType]} props - The properties to apply to the widget.
|
|
102
|
+
* @returns {BlessedWidget[WidgetType]} The created widget.
|
|
103
|
+
*/
|
|
104
|
+
createWidget(type, props) {
|
|
105
|
+
const widget = (0, types_1.createBlessedWidget)(type, props, this.container);
|
|
106
|
+
this.widgets.push(widget);
|
|
107
|
+
return widget;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Gets the currently focused widget within the container.
|
|
111
|
+
*
|
|
112
|
+
* @returns {Widgets.Node} The focused widget.
|
|
113
|
+
*/
|
|
114
|
+
getFocusedWidget() {
|
|
115
|
+
return this.container.screen.focused;
|
|
116
|
+
}
|
|
117
|
+
createContainer() {
|
|
118
|
+
if (this.container) {
|
|
119
|
+
return this.logWarning('Container already exists!');
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
this.container = (0, types_1.createBlessedWidget)(this.type, this.containerProps, this.container);
|
|
123
|
+
this.keyBinding.forEach(keyBinding => {
|
|
124
|
+
this.container.key(keyBinding.keys, keyBinding.callback);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
this.logError('Failed to create container:', error);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
_createWidgets() {
|
|
132
|
+
if (this.widgets.length > 0) {
|
|
133
|
+
this.logWarning(`Widgets already created (${this.widgets.length} widgets)!`);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
this.createContent();
|
|
137
|
+
}
|
|
138
|
+
_render() {
|
|
139
|
+
if (!this.enabled)
|
|
140
|
+
return;
|
|
141
|
+
this.container.screen.render();
|
|
142
|
+
this.render();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.ConsoleContainer = ConsoleContainer;
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
readonly pause: () => this;
|
|
21
|
-
readonly dispose: () => this;
|
|
22
|
-
readonly releaseScreen: () => void;
|
|
1
|
+
import { ConsoleContainer } from './ConsoleContainer';
|
|
2
|
+
import { Widgets } from 'blessed';
|
|
3
|
+
type ScreenKeyBinding = {
|
|
4
|
+
keys: string[];
|
|
5
|
+
callback: VoidFunction;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* An abstract class representing a screen container for Blessed widgets with state management and key bindings.
|
|
9
|
+
*
|
|
10
|
+
* @template State - The type of the state object.
|
|
11
|
+
*/
|
|
12
|
+
export declare abstract class ConsoleScreen<State extends object> extends ConsoleContainer<'screen', State> {
|
|
13
|
+
/**
|
|
14
|
+
* Creates an instance of ConsoleScreen.
|
|
15
|
+
*
|
|
16
|
+
* @param {Widgets.IScreenOptions} [props] - The properties to apply to the screen widget.
|
|
17
|
+
* @param {ScreenKeyBinding[]} [keyBinding] - An array of key bindings for the screen widget.
|
|
18
|
+
*/
|
|
19
|
+
constructor(props?: Widgets.IScreenOptions, keyBinding?: ScreenKeyBinding[]);
|
|
23
20
|
}
|
|
21
|
+
export {};
|
package/console/ConsoleScreen.js
CHANGED
|
@@ -1,111 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.ConsoleScreen = void 0;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
this.resume = () => {
|
|
44
|
-
this.enabled = true;
|
|
45
|
-
this.widgets.forEach(widget => {
|
|
46
|
-
widget.focusable = true;
|
|
47
|
-
widget.interactive = true;
|
|
48
|
-
});
|
|
49
|
-
this._render();
|
|
50
|
-
return this;
|
|
51
|
-
};
|
|
52
|
-
this.pause = () => {
|
|
53
|
-
this.enabled = false;
|
|
54
|
-
this.widgets.forEach(widget => {
|
|
55
|
-
widget.focusable = false;
|
|
56
|
-
widget.interactive = false;
|
|
57
|
-
});
|
|
58
|
-
return this;
|
|
59
|
-
};
|
|
60
|
-
this.dispose = () => {
|
|
61
|
-
this.widgets.forEach(widget => widget.detach());
|
|
62
|
-
// @ts-ignore
|
|
63
|
-
this.widgets = [];
|
|
64
|
-
this._render();
|
|
65
|
-
if (this.enabled)
|
|
66
|
-
this.pause();
|
|
67
|
-
return this;
|
|
68
|
-
};
|
|
69
|
-
this.releaseScreen = () => {
|
|
70
|
-
if (!this.screen)
|
|
71
|
-
return;
|
|
72
|
-
this.screen.detach();
|
|
73
|
-
this.screen.destroy();
|
|
74
|
-
};
|
|
75
|
-
this.screenProps = props;
|
|
76
|
-
}
|
|
77
|
-
setState(state) {
|
|
78
|
-
this.state = (0, ts_common_1.mergeObject)(this.state, state);
|
|
79
|
-
this._render();
|
|
80
|
-
return this;
|
|
81
|
-
}
|
|
82
|
-
createWidget(type, props) {
|
|
83
|
-
const widget = blessed[type](Object.assign(Object.assign({}, props), { parent: this.screen }));
|
|
84
|
-
this.widgets.push(widget);
|
|
85
|
-
return widget;
|
|
86
|
-
}
|
|
87
|
-
getFocusedWidget() {
|
|
88
|
-
return this.screen.focused;
|
|
89
|
-
}
|
|
90
|
-
createScreen() {
|
|
91
|
-
var _a, _b;
|
|
92
|
-
if (this.screen)
|
|
93
|
-
return this.logWarning(`will not create screen, already exists!`);
|
|
94
|
-
this.screen = blessed.screen(this.screenProps);
|
|
95
|
-
(_b = (_a = this.screenProps) === null || _a === void 0 ? void 0 : _a.keyBinding) === null || _b === void 0 ? void 0 : _b.map(keyBinding => {
|
|
96
|
-
this.screen.key(keyBinding.keys, keyBinding.callback);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
_createWidgets() {
|
|
100
|
-
if (this.widgets.length > 0)
|
|
101
|
-
return this.logWarning(`will not create widgets, already have ${this.widgets.length} widgets!`);
|
|
102
|
-
this.createWidgets();
|
|
103
|
-
}
|
|
104
|
-
_render() {
|
|
105
|
-
if (!this.enabled)
|
|
106
|
-
return;
|
|
107
|
-
this.screen.render();
|
|
108
|
-
this.render();
|
|
4
|
+
const ConsoleContainer_1 = require("./ConsoleContainer");
|
|
5
|
+
/**
|
|
6
|
+
* An abstract class representing a screen container for Blessed widgets with state management and key bindings.
|
|
7
|
+
*
|
|
8
|
+
* @template State - The type of the state object.
|
|
9
|
+
*/
|
|
10
|
+
class ConsoleScreen extends ConsoleContainer_1.ConsoleContainer {
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of ConsoleScreen.
|
|
13
|
+
*
|
|
14
|
+
* @param {Widgets.IScreenOptions} [props] - The properties to apply to the screen widget.
|
|
15
|
+
* @param {ScreenKeyBinding[]} [keyBinding] - An array of key bindings for the screen widget.
|
|
16
|
+
*/
|
|
17
|
+
constructor(props, keyBinding = []) {
|
|
18
|
+
super('screen', props, keyBinding);
|
|
109
19
|
}
|
|
110
20
|
}
|
|
111
21
|
exports.ConsoleScreen = ConsoleScreen;
|
package/console/types.d.ts
CHANGED
|
@@ -1,196 +1,61 @@
|
|
|
1
|
-
|
|
1
|
+
import * as blessed from 'neo-blessed';
|
|
2
|
+
import { Widgets } from 'blessed';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* A collection of Blessed elements for easy access.
|
|
4
5
|
*/
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/** Style when focused. */
|
|
33
|
-
focus?: {
|
|
34
|
-
fg?: string;
|
|
35
|
-
bg?: string;
|
|
36
|
-
border?: {
|
|
37
|
-
fg?: string;
|
|
38
|
-
bg?: string;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
/** Scrollbar styling. */
|
|
42
|
-
scrollbar?: {
|
|
43
|
-
bg?: string;
|
|
44
|
-
fg?: string;
|
|
45
|
-
};
|
|
6
|
+
export declare const BlessedElements: {
|
|
7
|
+
screen: typeof blessed.screen;
|
|
8
|
+
box: typeof blessed.box;
|
|
9
|
+
text: typeof blessed.text;
|
|
10
|
+
list: typeof blessed.list;
|
|
11
|
+
log: typeof blessed.log;
|
|
12
|
+
textarea: typeof blessed.textarea;
|
|
13
|
+
textbox: typeof blessed.textbox;
|
|
14
|
+
form: typeof blessed.form;
|
|
15
|
+
progressbar: typeof blessed.progressbar;
|
|
16
|
+
table: typeof blessed.table;
|
|
17
|
+
listTable: typeof blessed.listtable;
|
|
18
|
+
prompt: typeof blessed.prompt;
|
|
19
|
+
message: typeof blessed.message;
|
|
20
|
+
loading: typeof blessed.loading;
|
|
21
|
+
radioSet: typeof blessed.radioset;
|
|
22
|
+
radiobutton: typeof blessed.radiobutton;
|
|
23
|
+
checkbox: typeof blessed.checkbox;
|
|
24
|
+
input: typeof blessed.input;
|
|
25
|
+
button: typeof blessed.button;
|
|
26
|
+
line: typeof blessed.line;
|
|
27
|
+
scrollableBox: typeof blessed.scrollablebox;
|
|
28
|
+
scrollableText: typeof blessed.scrollabletext;
|
|
29
|
+
terminal: typeof blessed.terminal;
|
|
30
|
+
bigText: typeof blessed.bigtext;
|
|
31
|
+
listBar: typeof blessed.listbar;
|
|
32
|
+
fileManager: typeof blessed.filemanager;
|
|
46
33
|
};
|
|
34
|
+
type Created = typeof BlessedElements;
|
|
47
35
|
/**
|
|
48
|
-
*
|
|
36
|
+
* A type representing the keys of BlessedElements.
|
|
49
37
|
*/
|
|
50
|
-
export type
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
right?: number | string;
|
|
57
|
-
/** Bottom position (can be in pixels or percentage). */
|
|
58
|
-
bottom?: number | string;
|
|
59
|
-
/** Left position (can be in pixels or percentage). */
|
|
60
|
-
left?: number | string;
|
|
61
|
-
/** Width of the box (can be in pixels or percentage). */
|
|
62
|
-
width?: number | string;
|
|
63
|
-
/** Height of the box (can be in pixels or percentage). */
|
|
64
|
-
height?: number | string;
|
|
65
|
-
/** Text content of the box. */
|
|
66
|
-
content?: string;
|
|
67
|
-
/** Enables processing of inline tags. */
|
|
68
|
-
tags?: boolean;
|
|
69
|
-
/** Enables key handling for this component. */
|
|
70
|
-
keys?: boolean;
|
|
71
|
-
/** Enables vi-like navigation. */
|
|
72
|
-
vi?: boolean;
|
|
73
|
-
/** Enables mouse interaction. */
|
|
74
|
-
mouse?: boolean;
|
|
75
|
-
/** Makes the box scrollable. */
|
|
76
|
-
scrollable?: boolean;
|
|
77
|
-
/** Always show the scrollbar if the box is scrollable. */
|
|
78
|
-
alwaysScroll?: boolean;
|
|
79
|
-
/** Border configuration. */
|
|
80
|
-
border?: {
|
|
81
|
-
/** Type of border ('line' for lines, 'bg' for background). */
|
|
82
|
-
type: 'line' | 'bg';
|
|
83
|
-
/** Color of the border. */
|
|
84
|
-
fg?: string;
|
|
85
|
-
};
|
|
86
|
-
/** Label text displayed at the top or next to the widget. */
|
|
87
|
-
label?: string;
|
|
88
|
-
/** Styling options for the box. */
|
|
89
|
-
style?: BoxStyle;
|
|
90
|
-
/** Vertical alignment of the content. */
|
|
91
|
-
valign?: 'top' | 'middle' | 'bottom';
|
|
92
|
-
/** Horizontal alignment of the content. */
|
|
93
|
-
align?: 'left' | 'center' | 'right';
|
|
94
|
-
/** Whether the box should respond to input. */
|
|
95
|
-
interactive?: boolean;
|
|
96
|
-
/** Configuration for the scrollbar. */
|
|
97
|
-
scrollbar?: {
|
|
98
|
-
/** Character used to display the scrollbar. */
|
|
99
|
-
ch?: string;
|
|
100
|
-
/** Styling for the track of the scrollbar. */
|
|
101
|
-
track?: {
|
|
102
|
-
bg?: string;
|
|
103
|
-
};
|
|
104
|
-
/** Style adjustments for the scrollbar. */
|
|
105
|
-
style?: {
|
|
106
|
-
inverse?: boolean;
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
/** Optional children components, allowing nested structures. */
|
|
110
|
-
children?: BoxOptions[];
|
|
111
|
-
};
|
|
112
|
-
export type ScreenOptions = {
|
|
113
|
-
/** Enables smart cursor routing, optimizing re-rendering. */
|
|
114
|
-
smartCSR?: boolean;
|
|
115
|
-
/** Enables a faster version of smartCSR for high performance rendering. */
|
|
116
|
-
fastCSR?: boolean;
|
|
117
|
-
/** Uses background color erase for reducing flickering. */
|
|
118
|
-
useBCE?: boolean;
|
|
119
|
-
/** Specifies the terminal type. Useful for consistent behavior across terminal types. */
|
|
120
|
-
terminal?: string;
|
|
121
|
-
/** Allows for full Unicode support. */
|
|
122
|
-
fullUnicode?: boolean;
|
|
123
|
-
/** Enables debugging, which logs information about screen operations. */
|
|
124
|
-
debug?: boolean;
|
|
125
|
-
/** Path to a file where debug logs will be written. */
|
|
126
|
-
log?: string;
|
|
127
|
-
/** Sets the terminal window title (not supported by all terminals). */
|
|
128
|
-
title?: string;
|
|
129
|
-
/** Automatically adds padding around the screen content. */
|
|
130
|
-
autoPadding?: boolean;
|
|
131
|
-
/** Controls cursor visibility and behavior. */
|
|
132
|
-
cursor?: {
|
|
133
|
-
artificial?: boolean;
|
|
134
|
-
blink?: boolean;
|
|
135
|
-
shape?: 'block' | 'underline' | 'line';
|
|
136
|
-
};
|
|
137
|
-
/** Enables mouse interaction support. */
|
|
138
|
-
mouse?: boolean;
|
|
139
|
-
/** Custom input stream for the screen, often used in testing. */
|
|
140
|
-
input?: NodeJS.ReadableStream;
|
|
141
|
-
/** Custom output stream for the screen, often used in testing. */
|
|
142
|
-
output?: NodeJS.WritableStream;
|
|
143
|
-
/** Time in milliseconds to wait after a resize event before redrawing the screen. */
|
|
144
|
-
resizeTimeout?: number;
|
|
145
|
-
keyBinding?: {
|
|
146
|
-
keys: string[];
|
|
147
|
-
callback: VoidFunction;
|
|
148
|
-
}[];
|
|
38
|
+
export type BlessedWidgetsType = keyof Created;
|
|
39
|
+
/**
|
|
40
|
+
* A type representing the options for each Blessed widget.
|
|
41
|
+
*/
|
|
42
|
+
export type BlessedWidgetOptions = {
|
|
43
|
+
[Type in keyof Created]: Parameters<Created[Type]>[0];
|
|
149
44
|
};
|
|
150
45
|
/**
|
|
151
|
-
*
|
|
46
|
+
* A type representing each Blessed widget.
|
|
152
47
|
*/
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
box: null;
|
|
156
|
-
/** Displays static text on the screen. */
|
|
157
|
-
text: null;
|
|
158
|
-
/** Shows a list of selectable items. */
|
|
159
|
-
list: null;
|
|
160
|
-
/** Designed for logging continuous text data. */
|
|
161
|
-
log: null;
|
|
162
|
-
/** A multi-line text input area for user input. */
|
|
163
|
-
textarea: null;
|
|
164
|
-
/** A single-line text input area for user input. */
|
|
165
|
-
textbox: null;
|
|
166
|
-
/** Holds input fields, buttons, and other form-related widgets. */
|
|
167
|
-
form: null;
|
|
168
|
-
/** Displays a progress bar for showing task progress. */
|
|
169
|
-
progressbar: null;
|
|
170
|
-
/** Displays tabular data. */
|
|
171
|
-
table: null;
|
|
172
|
-
/** Extends `list` with table-like functionality. */
|
|
173
|
-
listtable: null;
|
|
174
|
-
/** Prompts the user to input data. */
|
|
175
|
-
prompt: null;
|
|
176
|
-
/** Displays a message box for notifications or alerts. */
|
|
177
|
-
message: null;
|
|
178
|
-
/** Shows a loading spinner or message during operations. */
|
|
179
|
-
loading: null;
|
|
180
|
-
/** For creating groups of radio buttons for options. */
|
|
181
|
-
radioset: null;
|
|
182
|
-
/** A selectable radio button within a radioset. */
|
|
183
|
-
radiobutton: null;
|
|
184
|
-
/** Displays a checkbox that users can toggle. */
|
|
185
|
-
checkbox: null;
|
|
186
|
-
/** A single-line text input for user data. */
|
|
187
|
-
input: null;
|
|
188
|
-
/** A clickable button that can trigger actions. */
|
|
189
|
-
button: null;
|
|
190
|
-
/** A visual separator line. */
|
|
191
|
-
line: null;
|
|
192
|
-
/** A box that supports vertical scrolling of its content. */
|
|
193
|
-
scrollablebox: null;
|
|
48
|
+
export type BlessedWidget = {
|
|
49
|
+
[Type in keyof Created]: ReturnType<Created[Type]>;
|
|
194
50
|
};
|
|
195
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Creates a Blessed widget of the specified type with the given properties and parent node.
|
|
53
|
+
*
|
|
54
|
+
* @template WidgetType - The type of the widget to create.
|
|
55
|
+
* @param {WidgetType} type - The type of the widget to create.
|
|
56
|
+
* @param {BlessedWidgetOptions[WidgetType]} props - The properties to apply to the widget.
|
|
57
|
+
* @param {Widgets.Node} [parent] - The parent node for the widget.
|
|
58
|
+
* @returns {BlessedWidget[WidgetType]} The created widget.
|
|
59
|
+
*/
|
|
60
|
+
export declare function createBlessedWidget<WidgetType extends BlessedWidgetsType>(type: WidgetType, props?: BlessedWidgetOptions[WidgetType], parent?: Widgets.Node): BlessedWidget[WidgetType];
|
|
196
61
|
export {};
|
package/console/types.js
CHANGED
|
@@ -1,47 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.createBlessedWidget = exports.BlessedElements = void 0;
|
|
27
|
+
const blessed = __importStar(require("neo-blessed"));
|
|
3
28
|
/**
|
|
4
|
-
*
|
|
29
|
+
* A collection of Blessed elements for easy access.
|
|
5
30
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
box:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
/** For creating groups of radio buttons for options. */
|
|
34
|
-
radioset: null,
|
|
35
|
-
/** A selectable radio button within a radioset. */
|
|
36
|
-
radiobutton: null,
|
|
37
|
-
/** Displays a checkbox that users can toggle. */
|
|
38
|
-
checkbox: null,
|
|
39
|
-
/** A single-line text input for user data. */
|
|
40
|
-
input: null,
|
|
41
|
-
/** A clickable button that can trigger actions. */
|
|
42
|
-
button: null,
|
|
43
|
-
/** A visual separator line. */
|
|
44
|
-
line: null,
|
|
45
|
-
/** A box that supports vertical scrolling of its content. */
|
|
46
|
-
scrollablebox: null
|
|
31
|
+
exports.BlessedElements = {
|
|
32
|
+
screen: blessed.screen,
|
|
33
|
+
box: blessed.box,
|
|
34
|
+
text: blessed.text,
|
|
35
|
+
list: blessed.list,
|
|
36
|
+
log: blessed.log,
|
|
37
|
+
textarea: blessed.textarea,
|
|
38
|
+
textbox: blessed.textbox,
|
|
39
|
+
form: blessed.form,
|
|
40
|
+
progressbar: blessed.progressbar,
|
|
41
|
+
table: blessed.table,
|
|
42
|
+
listTable: blessed.listtable,
|
|
43
|
+
prompt: blessed.prompt,
|
|
44
|
+
message: blessed.message,
|
|
45
|
+
loading: blessed.loading,
|
|
46
|
+
radioSet: blessed.radioset,
|
|
47
|
+
radiobutton: blessed.radiobutton,
|
|
48
|
+
checkbox: blessed.checkbox,
|
|
49
|
+
input: blessed.input,
|
|
50
|
+
button: blessed.button,
|
|
51
|
+
line: blessed.line,
|
|
52
|
+
scrollableBox: blessed.scrollablebox,
|
|
53
|
+
scrollableText: blessed.scrollabletext,
|
|
54
|
+
terminal: blessed.terminal,
|
|
55
|
+
bigText: blessed.bigtext,
|
|
56
|
+
listBar: blessed.listbar,
|
|
57
|
+
fileManager: blessed.filemanager,
|
|
47
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* Creates a Blessed widget of the specified type with the given properties and parent node.
|
|
61
|
+
*
|
|
62
|
+
* @template WidgetType - The type of the widget to create.
|
|
63
|
+
* @param {WidgetType} type - The type of the widget to create.
|
|
64
|
+
* @param {BlessedWidgetOptions[WidgetType]} props - The properties to apply to the widget.
|
|
65
|
+
* @param {Widgets.Node} [parent] - The parent node for the widget.
|
|
66
|
+
* @returns {BlessedWidget[WidgetType]} The created widget.
|
|
67
|
+
*/
|
|
68
|
+
function createBlessedWidget(type, props = {}, parent) {
|
|
69
|
+
const element = exports.BlessedElements[type];
|
|
70
|
+
return element(Object.assign(Object.assign({}, props), { parent }));
|
|
71
|
+
}
|
|
72
|
+
exports.createBlessedWidget = createBlessedWidget;
|
package/core/cli.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nu-art/commando",
|
|
3
|
-
"version": "0.204.
|
|
3
|
+
"version": "0.204.50",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"TacB0sS",
|
|
@@ -32,9 +32,11 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"neo-blessed": "^0.2.0",
|
|
35
|
+
"blessed": "^0.1.81",
|
|
35
36
|
"@nu-art/ts-common": "~0.204.0"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@types/node": "^18.0.0"
|
|
39
|
+
"@types/node": "^18.0.0",
|
|
40
|
+
"@types/blessed": "^0.1.25"
|
|
39
41
|
}
|
|
40
42
|
}
|