@nu-art/commando 0.204.17 → 0.204.18

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.
@@ -1,14 +1,14 @@
1
1
  import { ResolvableContent } from '@nu-art/ts-common';
2
2
  import { BoxOptions, ScreenOptions, WidgetTypes } from './types';
3
- import * as blessed from 'neo-blessed';
4
- export declare abstract class Screen<State extends object> {
3
+ export declare abstract class ConsoleScreen<State extends object> {
5
4
  protected state: State;
6
5
  private screen;
7
- protected readonly widgets: blessed.Widgets.Node[];
6
+ protected readonly widgets: any[];
8
7
  constructor(props?: ScreenOptions);
9
8
  setState(state: ResolvableContent<Partial<State>>): void;
10
9
  createWidget(type: WidgetTypes, props: Omit<BoxOptions, 'parent'>): any;
11
10
  getFocusedWidget(): any;
11
+ private _render;
12
12
  protected abstract render(): void;
13
13
  enable(): void;
14
14
  disable(): void;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConsoleScreen = void 0;
4
+ // @ts-ignore
5
+ const neo_blessed_1 = require("neo-blessed");
6
+ const ts_common_1 = require("@nu-art/ts-common");
7
+ class ConsoleScreen {
8
+ constructor(props) {
9
+ var _a;
10
+ this.widgets = [];
11
+ this.screen = neo_blessed_1.blessed.screen(props);
12
+ (_a = props === null || props === void 0 ? void 0 : props.keyBinding) === null || _a === void 0 ? void 0 : _a.map(keyBinding => {
13
+ this.screen.key(keyBinding.keys, keyBinding.callback);
14
+ });
15
+ }
16
+ setState(state) {
17
+ this.state = (0, ts_common_1.mergeObject)(this.state, state);
18
+ this._render();
19
+ }
20
+ createWidget(type, props) {
21
+ const widget = neo_blessed_1.blessed[type](Object.assign(Object.assign({}, props), { parent: this.screen }));
22
+ this.widgets.push(widget);
23
+ return widget;
24
+ }
25
+ getFocusedWidget() {
26
+ return this.screen.focused;
27
+ }
28
+ _render() {
29
+ this.render();
30
+ this.screen.render();
31
+ }
32
+ enable() {
33
+ this.widgets.forEach(widget => {
34
+ widget.focusable = true;
35
+ widget.interactive = true;
36
+ });
37
+ this._render();
38
+ }
39
+ disable() {
40
+ this.widgets.forEach(widget => {
41
+ widget.focusable = false;
42
+ widget.interactive = false;
43
+ });
44
+ this._render();
45
+ }
46
+ /**
47
+ * Clears all widgets from the screen and optionally clears the screen.
48
+ */
49
+ clearScreen(clearContent = true) {
50
+ this.widgets.forEach(widget => widget.detach());
51
+ this.widgets.forEach(widget => (0, ts_common_1.removeFromArray)(this.widgets, widget));
52
+ if (clearContent) {
53
+ this.screen.clear();
54
+ }
55
+ this._render();
56
+ }
57
+ }
58
+ exports.ConsoleScreen = ConsoleScreen;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
- import * as blessed from 'neo-blessed';
3
2
  /**
4
3
  * Styles configuration for the box component.
5
4
  */
@@ -50,7 +49,7 @@ export type BoxStyle = {
50
49
  */
51
50
  export type BoxOptions = {
52
51
  /** Parent screen object. */
53
- parent?: blessed.Widgets.Screen;
52
+ parent?: any;
54
53
  /** Top position (can be in pixels or percentage). */
55
54
  top?: number | string;
56
55
  /** Left position (can be in pixels or percentage). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nu-art/commando",
3
- "version": "0.204.17",
3
+ "version": "0.204.18",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "TacB0sS",
package/screen/Screen.js DELETED
@@ -1,77 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Screen = void 0;
27
- const ts_common_1 = require("@nu-art/ts-common");
28
- // @ts-ignore
29
- const blessed = __importStar(require("neo-blessed"));
30
- class Screen {
31
- constructor(props) {
32
- var _a;
33
- this.widgets = [];
34
- this.screen = blessed.screen(props);
35
- (_a = props === null || props === void 0 ? void 0 : props.keyBinding) === null || _a === void 0 ? void 0 : _a.map(keyBinding => {
36
- this.screen.key(keyBinding.keys, keyBinding.callback);
37
- });
38
- }
39
- setState(state) {
40
- this.state = Object.freeze((0, ts_common_1.mergeObject)(this.state, state));
41
- this.render();
42
- }
43
- createWidget(type, props) {
44
- const widget = blessed[type](Object.assign(Object.assign({}, props), { parent: this.screen }));
45
- this.widgets.push(widget);
46
- return widget;
47
- }
48
- getFocusedWidget() {
49
- return this.screen.focused;
50
- }
51
- enable() {
52
- this.widgets.forEach(widget => {
53
- widget.focusable = true;
54
- widget.interactive = true;
55
- });
56
- this.screen.render();
57
- }
58
- disable() {
59
- this.widgets.forEach(widget => {
60
- widget.focusable = false;
61
- widget.interactive = false;
62
- });
63
- this.screen.render();
64
- }
65
- /**
66
- * Clears all widgets from the screen and optionally clears the screen.
67
- */
68
- clearScreen(clearContent = true) {
69
- this.widgets.forEach(widget => widget.detach());
70
- this.widgets.forEach(widget => (0, ts_common_1.removeFromArray)(this.widgets, widget));
71
- if (clearContent) {
72
- this.screen.clear();
73
- }
74
- this.screen.render();
75
- }
76
- }
77
- exports.Screen = Screen;
File without changes