@nan0web/ui 1.12.3 → 3.1.1

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.
Files changed (136) hide show
  1. package/package.json +29 -20
  2. package/src/Component/index.js +1 -5
  3. package/src/Model/Element.js +183 -0
  4. package/src/Theme/AppTheme.js +19 -0
  5. package/src/Theme/CustomTheme.js +32 -0
  6. package/src/Theme/DarkLightTheme.js +34 -0
  7. package/src/Theme/Theme.js +25 -0
  8. package/src/Theme/atoms/Avatar.js +20 -0
  9. package/src/Theme/atoms/Badge.js +28 -0
  10. package/src/Theme/atoms/Button.js +88 -0
  11. package/src/Theme/atoms/Checkbox.js +26 -0
  12. package/src/Theme/atoms/Input.js +28 -0
  13. package/src/Theme/atoms/Radio.js +26 -0
  14. package/src/Theme/atoms/Select.js +16 -0
  15. package/src/Theme/atoms/TextArea.js +17 -0
  16. package/src/Theme/atoms/Typography.js +26 -0
  17. package/src/Theme/atoms/index.js +11 -0
  18. package/src/Theme/createTheme.js +22 -0
  19. package/src/Theme/index.js +20 -0
  20. package/src/Theme/molecules/Card.js +24 -0
  21. package/src/Theme/molecules/index.js +3 -0
  22. package/src/Theme/organisms/Modal.js +24 -0
  23. package/src/Theme/organisms/index.js +3 -0
  24. package/src/Theme/presets/HighContrastTheme.js +65 -0
  25. package/src/Theme/presets/NightTheme.js +66 -0
  26. package/src/Theme/presets/index.js +4 -0
  27. package/src/Theme/tokens.js +115 -0
  28. package/src/core/InputAdapter.js +1 -2
  29. package/src/core/Intent.js +22 -8
  30. package/src/core/Message/Message.js +3 -0
  31. package/src/core/OutputAdapter.js +9 -13
  32. package/src/core/index.js +7 -4
  33. package/src/domain/ModelAsApp.js +1 -1
  34. package/src/domain/app/IntentAuditor.js +53 -0
  35. package/src/domain/app/JsIntentAuditor.js +145 -0
  36. package/src/domain/app/PyIntentAuditor.js +144 -0
  37. package/src/domain/app/SnapshotAuditor.js +8 -8
  38. package/src/domain/components/ShellModel.js +2 -2
  39. package/src/index.js +35 -9
  40. package/src/inspect.js +3 -0
  41. package/src/utils/format.js +21 -0
  42. package/src/utils/processI18n.js +27 -0
  43. package/src/utils/resolveContext.js +79 -0
  44. package/types/Component/index.d.ts +1 -5
  45. package/types/Model/Element.d.ts +87 -0
  46. package/types/Theme/AppTheme.d.ts +14 -0
  47. package/types/Theme/CustomTheme.d.ts +21 -0
  48. package/types/Theme/DarkLightTheme.d.ts +16 -0
  49. package/types/Theme/Theme.d.ts +18 -0
  50. package/types/Theme/atoms/Avatar.d.ts +14 -0
  51. package/types/Theme/atoms/Badge.d.ts +22 -0
  52. package/types/Theme/atoms/Button.d.ts +144 -0
  53. package/types/Theme/atoms/Checkbox.d.ts +20 -0
  54. package/types/Theme/atoms/Input.d.ts +22 -0
  55. package/types/Theme/atoms/Radio.d.ts +20 -0
  56. package/types/Theme/atoms/Select.d.ts +15 -0
  57. package/types/Theme/atoms/TextArea.d.ts +17 -0
  58. package/types/Theme/atoms/Typography.d.ts +47 -0
  59. package/types/Theme/atoms/index.d.ts +10 -0
  60. package/types/Theme/createTheme.d.ts +7 -0
  61. package/types/Theme/index.d.ts +10 -0
  62. package/types/Theme/molecules/Card.d.ts +18 -0
  63. package/types/Theme/molecules/index.d.ts +2 -0
  64. package/types/Theme/organisms/Modal.d.ts +18 -0
  65. package/types/Theme/organisms/index.d.ts +2 -0
  66. package/types/Theme/presets/HighContrastTheme.d.ts +2 -0
  67. package/types/Theme/presets/NightTheme.d.ts +2 -0
  68. package/types/Theme/presets/index.d.ts +3 -0
  69. package/types/Theme/tokens.d.ts +119 -0
  70. package/types/core/Intent.d.ts +10 -7
  71. package/types/core/Message/Message.d.ts +3 -0
  72. package/types/core/OutputAdapter.d.ts +2 -4
  73. package/types/core/index.d.ts +5 -2
  74. package/types/domain/Document.d.ts +2 -1
  75. package/types/domain/FooterModel.d.ts +2 -1
  76. package/types/domain/ModelAsApp.d.ts +48 -48
  77. package/types/domain/app/IntentAuditor.d.ts +23 -0
  78. package/types/domain/app/JsIntentAuditor.d.ts +22 -0
  79. package/types/domain/app/PyIntentAuditor.d.ts +22 -0
  80. package/types/domain/app/SnapshotAuditor.d.ts +5 -6
  81. package/types/domain/components/ShellModel.d.ts +1 -5
  82. package/types/index.d.ts +7 -9
  83. package/types/inspect.d.ts +3 -0
  84. package/types/utils/format.d.ts +5 -0
  85. package/types/utils/processI18n.d.ts +8 -0
  86. package/types/utils/resolveContext.d.ts +21 -0
  87. package/src/App/Command/DepsCommand.js +0 -24
  88. package/src/App/Core/CoreApp.js +0 -125
  89. package/src/App/Core/UI.js +0 -63
  90. package/src/App/Core/Widget.js +0 -61
  91. package/src/App/Core/index.js +0 -11
  92. package/src/App/Scenario.js +0 -45
  93. package/src/App/User/Command/Message.js +0 -3
  94. package/src/App/User/Command/index.js +0 -5
  95. package/src/App/User/UserApp.js +0 -85
  96. package/src/App/User/UserUI.js +0 -20
  97. package/src/App/User/index.js +0 -9
  98. package/src/App/index.js +0 -14
  99. package/src/Component/Process/Input.js +0 -63
  100. package/src/Component/Process/Process.js +0 -24
  101. package/src/Component/Process/index.js +0 -5
  102. package/src/Component/Welcome/Input.js +0 -48
  103. package/src/Component/Welcome/Welcome.js +0 -22
  104. package/src/Component/Welcome/index.js +0 -5
  105. package/src/Frame/Frame.js +0 -608
  106. package/src/Frame/Props.js +0 -96
  107. package/src/StdIn.js +0 -100
  108. package/src/StdOut.js +0 -95
  109. package/src/View/RenderOptions.js +0 -48
  110. package/src/View/View.js +0 -306
  111. package/src/core/Message/index.js +0 -6
  112. package/types/App/Command/DepsCommand.d.ts +0 -14
  113. package/types/App/Core/CoreApp.d.ts +0 -70
  114. package/types/App/Core/UI.d.ts +0 -38
  115. package/types/App/Core/Widget.d.ts +0 -39
  116. package/types/App/Core/index.d.ts +0 -10
  117. package/types/App/Scenario.d.ts +0 -26
  118. package/types/App/User/Command/Message.d.ts +0 -2
  119. package/types/App/User/Command/index.d.ts +0 -3
  120. package/types/App/User/UserApp.d.ts +0 -41
  121. package/types/App/User/UserUI.d.ts +0 -9
  122. package/types/App/User/index.d.ts +0 -8
  123. package/types/App/index.d.ts +0 -12
  124. package/types/Component/Process/Input.d.ts +0 -48
  125. package/types/Component/Process/Process.d.ts +0 -13
  126. package/types/Component/Process/index.d.ts +0 -4
  127. package/types/Component/Welcome/Input.d.ts +0 -34
  128. package/types/Component/Welcome/Welcome.d.ts +0 -13
  129. package/types/Component/Welcome/index.d.ts +0 -4
  130. package/types/Frame/Frame.d.ts +0 -186
  131. package/types/Frame/Props.d.ts +0 -77
  132. package/types/StdIn.d.ts +0 -62
  133. package/types/StdOut.d.ts +0 -52
  134. package/types/View/RenderOptions.d.ts +0 -29
  135. package/types/View/View.d.ts +0 -124
  136. package/types/core/Message/index.d.ts +0 -4
@@ -1,39 +0,0 @@
1
- /** @typedef {import("./UI.js").ComponentFn} ComponentFn */
2
- /**
3
- * Abstract Widget class.
4
- * Widget is a view with ability to input data in a specific format.
5
- * Input and output data are typed classes.
6
- */
7
- export default class Widget extends EventProcessor {
8
- /**
9
- * Creates a new Widget instance.
10
- * @param {View} [view] - View instance (default: new View())
11
- */
12
- constructor(view?: View);
13
- /** @type {View} The view associated with this widget */
14
- view: View;
15
- /**
16
- * Ask user for input data of specific class.
17
- * @param {UiMessage} input - instance of UiMessage or similar
18
- * @returns {Promise<UiMessage | null>} instance of UiMessage or null
19
- */
20
- ask(input: UiMessage): Promise<UiMessage | null>;
21
- /**
22
- * @param {AsyncGenerator<StreamEntry>} stream
23
- * @returns {Promise<void>}
24
- */
25
- read(stream: AsyncGenerator<StreamEntry>): Promise<void>;
26
- /**
27
- * Render output data using a view function.
28
- * @param {Function|string} viewFnOrName - View function or registered view name
29
- * @param {object} outputData - Typed output data instance
30
- * @returns {any} Rendered output
31
- * @throws {Error} If view component is not found when using string name
32
- */
33
- render(viewFnOrName: Function | string, outputData: object): any;
34
- }
35
- export type ComponentFn = import("./UI.js").ComponentFn;
36
- import EventProcessor from '@nan0web/event/oop';
37
- import View from '../../View/View.js';
38
- import { UiMessage } from '../../core/index.js';
39
- import { StreamEntry } from '@nan0web/db';
@@ -1,10 +0,0 @@
1
- declare namespace _default {
2
- export { CoreApp as App };
3
- export { UI };
4
- export { Widget };
5
- }
6
- export default _default;
7
- import CoreApp from './CoreApp.js';
8
- import UI from './UI.js';
9
- import Widget from './Widget.js';
10
- export { CoreApp, UI };
@@ -1,26 +0,0 @@
1
- /** @typedef {import("./Core/CoreApp.js").default} CoreApp */
2
- /**
3
- * Abstract Scenario class to test app logic.
4
- * Scenarios run input commands and verify output.
5
- */
6
- export default class Scenario {
7
- /**
8
- * Creates a new Scenario instance.
9
- * @param {CoreApp} app - App instance to run scenarios against
10
- * @param {UI} ui - User interface
11
- * @throws {TypeError} If app is not an App.Core.App instance
12
- */
13
- constructor(app: CoreApp, ui: UI);
14
- /** @type {CoreApp} The app to run scenarios against */
15
- app: CoreApp;
16
- ui: UI;
17
- /**
18
- * Run scenario with input commands and expected output.
19
- * @param {Array<any[]>} inputCommands - Array of command arrays
20
- * @param {Array<any>} expectedOutputs - Expected outputs for each command
21
- * @returns {Promise<boolean>} True if all outputs match expected
22
- */
23
- run(inputCommands: Array<any[]>, expectedOutputs: Array<any>): Promise<boolean>;
24
- }
25
- export type CoreApp = import("./Core/CoreApp.js").default;
26
- import UI from './Core/UI.js';
@@ -1,2 +0,0 @@
1
- export default UiMessage;
2
- import UiMessage from '../../../core/Message/Message.js';
@@ -1,3 +0,0 @@
1
- export { CommandMessage };
2
- export default CommandMessage;
3
- import CommandMessage from './Message.js';
@@ -1,41 +0,0 @@
1
- /**
2
- * UserApp requires user name and shows Welcome view.
3
- * If user.name is provided in command input, ignores user input.
4
- * User can change user data to see another Welcome view.
5
- */
6
- export default class UserApp extends CoreApp {
7
- /**
8
- * Creates a new UserApp instance.
9
- * @param {Partial<CoreApp>} [props={}] - UserApp properties
10
- */
11
- constructor(props?: Partial<CoreApp>);
12
- /**
13
- * Handle deps command with async generator for stream processing.
14
- * @param {DepsCommand} cmd - Command message with deps parameters
15
- * @param {UserUI} ui - UI instance
16
- * @returns {Promise<Object>} Command output
17
- */
18
- handleDeps(cmd: DepsCommand, ui: UserUI): Promise<any>;
19
- /**
20
- * Set user data from params.
21
- * @param {UserAppCommandMessage} cmd - Command message with user data
22
- * @param {UserUI} ui - UI instance
23
- * @returns {Promise<{ message: string }>} Welcome message
24
- */
25
- setUser(cmd: UserAppCommandMessage, ui: UserUI): Promise<{
26
- message: string;
27
- }>;
28
- /**
29
- * Show welcome message for current user.
30
- * @param {UserAppCommandMessage} cmd - Command message
31
- * @param {UserUI} ui - UI instance
32
- * @returns {Promise<string[][]>} Welcome view output
33
- */
34
- welcome(cmd: UserAppCommandMessage, ui: UserUI): Promise<string[][]>;
35
- user: User | undefined;
36
- }
37
- import CoreApp from '../Core/CoreApp.js';
38
- import DepsCommand from './Command/Message.js';
39
- import UserUI from './UserUI.js';
40
- import UserAppCommandMessage from './Command/Message.js';
41
- import User from '../../Model/User/User.js';
@@ -1,9 +0,0 @@
1
- declare const UserUI_base: typeof import("../Core/UI.js").default;
2
- /**
3
- * UserUI connects UserApp and View.
4
- * It asks user for name if not provided in command input.
5
- * Allows user to change user data to see another Welcome view.
6
- */
7
- export default class UserUI extends UserUI_base {
8
- }
9
- export {};
@@ -1,8 +0,0 @@
1
- declare namespace _default {
2
- export { UserApp as App };
3
- export { UserUI as UI };
4
- }
5
- export default _default;
6
- import UserApp from './UserApp.js';
7
- import UserUI from './UserUI.js';
8
- export { UserApp, UserUI };
@@ -1,12 +0,0 @@
1
- declare namespace _default {
2
- export { Core };
3
- export { User };
4
- export { Scenario };
5
- export { UI };
6
- }
7
- export default _default;
8
- import Core from './Core/index.js';
9
- import User from './User/index.js';
10
- import Scenario from './Scenario.js';
11
- import UI from './Core/UI.js';
12
- export { Core, User, Scenario, UI };
@@ -1,48 +0,0 @@
1
- export default ProcessInput;
2
- /**
3
- * Represents input data for the Process component.
4
- * Holds configuration for rendering a progress bar.
5
- */
6
- declare class ProcessInput {
7
- /**
8
- * Creates a ProcessInput instance from the given props.
9
- * @param {ProcessInput|object} props - The properties to create from
10
- * @returns {ProcessInput} A ProcessInput instance
11
- */
12
- static from(props?: ProcessInput | object): ProcessInput;
13
- /**
14
- * Creates a new ProcessInput instance.
15
- * @param {object} props - Process input properties
16
- * @param {string} [props.name="NaN•Coding"] - Process name
17
- * @param {number} [props.i=0] - Current progress index
18
- * @param {number} [props.top=9] - Top limit for progress normalization
19
- * @param {number} [props.width=9] - Width of the progress bar
20
- * @param {string} [props.space='•'] - Character for empty space
21
- * @param {string} [props.char='*'] - Character for filled progress
22
- */
23
- constructor(props?: {
24
- name?: string | undefined;
25
- i?: number | undefined;
26
- top?: number | undefined;
27
- width?: number | undefined;
28
- space?: string | undefined;
29
- char?: string | undefined;
30
- });
31
- /** @type {string} Process name to display */
32
- name: string;
33
- /** @type {number} Current progress index */
34
- i: number;
35
- /** @type {number} Top limit for progress normalization */
36
- top: number;
37
- /** @type {number} Width of the progress bar */
38
- width: number;
39
- /** @type {string} Character to use for empty space */
40
- space: string;
41
- /** @type {string} Character to use for filled progress */
42
- char: string;
43
- /**
44
- * Converts the input to a string representation.
45
- * @returns {string} String representation of the ProcessInput
46
- */
47
- toString(): string;
48
- }
@@ -1,13 +0,0 @@
1
- export default Process;
2
- /**
3
- * Renders a progress bar based on input configuration.
4
- * @this {View}
5
- * @param {ProcessInput|object} props - Process component properties
6
- * @returns {string[][]} Rendered progress bar as array of strings
7
- */
8
- declare function Process(this: View, props?: ProcessInput | object): string[][];
9
- declare namespace Process {
10
- export { ProcessInput as Input };
11
- }
12
- import ProcessInput from './Input.js';
13
- import View from '../../View/View.js';
@@ -1,4 +0,0 @@
1
- export default Process;
2
- export { ProcessInput };
3
- import Process from './Process.js';
4
- import ProcessInput from './Input.js';
@@ -1,34 +0,0 @@
1
- export default WelcomeInput;
2
- /**
3
- * Represents input data for the Welcome component.
4
- * Holds user data to display in the welcome message.
5
- */
6
- declare class WelcomeInput {
7
- /**
8
- * Creates a WelcomeInput instance from the given props.
9
- * @param {WelcomeInput|object} props - The properties to create from
10
- * @returns {WelcomeInput} A WelcomeInput instance
11
- */
12
- static from(props?: WelcomeInput | object): WelcomeInput;
13
- /**
14
- * Creates a new WelcomeInput instance.
15
- * @param {object} props - Welcome input properties
16
- * @param {User|object} [props.user=new User()] - User data
17
- */
18
- constructor(props?: {
19
- user?: User | object;
20
- });
21
- /** @type {User} User data for welcome message */
22
- user: User;
23
- /**
24
- * Checks if the input is empty (no user data).
25
- * @returns {boolean} True if user data is empty, false otherwise
26
- */
27
- get empty(): boolean;
28
- /**
29
- * Converts the input to a string representation.
30
- * @returns {string} String representation of the WelcomeInput
31
- */
32
- toString(): string;
33
- }
34
- import { User } from '../../Model/index.js';
@@ -1,13 +0,0 @@
1
- export default Welcome;
2
- /**
3
- * Renders a welcome message for a user.
4
- * @param {WelcomeInput|object} props - Welcome component properties
5
- * @returns {string[][]} Rendered welcome message as array of strings
6
- * @throws {Error} If no user data is provided
7
- */
8
- declare function Welcome(props?: WelcomeInput | object): string[][];
9
- declare namespace Welcome {
10
- export { WelcomeInput as Input };
11
- export function ask(): Promise<string>;
12
- }
13
- import WelcomeInput from './Input.js';
@@ -1,4 +0,0 @@
1
- export default Welcome;
2
- export { WelcomeInput };
3
- import Welcome from './Welcome.js';
4
- import WelcomeInput from './Input.js';
@@ -1,186 +0,0 @@
1
- export class FrameRenderMethod {
2
- static APPEND: string;
3
- static REPLACE: string;
4
- static VISIBLE: string;
5
- }
6
- /**
7
- * @link https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797 - ANSI escape codes
8
- */
9
- export default class Frame {
10
- /** @type {typeof FrameRenderMethod} */
11
- static RenderMethod: typeof FrameRenderMethod;
12
- static Props: typeof FrameProps;
13
- /** @type {string} End of line */
14
- static EOL: string;
15
- /** @type {string} Beginning of line */
16
- static BOL: string;
17
- /** @type {string} Beginning of frame */
18
- static BOF: string;
19
- /** @type {string} Hide cursor */
20
- static HIDE_CURSOR: string;
21
- /** @type {string} Show cursor */
22
- static SHOW_CURSOR: string;
23
- /** @type {string} Tab */
24
- static TAB: string;
25
- /** @type {string} Bold */
26
- static BOLD: string;
27
- /** @type {string} Italic */
28
- static ITALIC: string;
29
- /** @type {string} Underline */
30
- static UNDERLINE: string;
31
- /** @type {string} Strikethrough */
32
- static STRIKETHROUGH: string;
33
- /** @type {string} Reset */
34
- static RESET: string;
35
- /** @type {string} Clear line */
36
- static CLEAR_LINE: string;
37
- /**
38
- * Check if a value can be used to create a Frame instance.
39
- * @param {*} value - Value to check.
40
- * @returns {boolean} True if the value is valid for Frame creation.
41
- */
42
- static is(value: any): boolean;
43
- /**
44
- * Create a Frame instance from input.
45
- * @param {*} input - Input value to convert.
46
- * @returns {Frame} A new Frame instance.
47
- */
48
- static from(input: any): Frame;
49
- /**
50
- * Create a function to space columns based on options.
51
- * @param {object} options - Spacing options.
52
- * @param {number[]} [options.cols=[]] - Widths of the columns.
53
- * @param {number} [options.padding=1] - Padding between columns.
54
- * @param {string[]} [options.aligns=[]] - Alignment for each column ('l' or 'r').
55
- * @returns {Function} Function that spaces a row.
56
- */
57
- static spaces(options?: {
58
- cols?: number[] | undefined;
59
- padding?: number | undefined;
60
- aligns?: string[] | undefined;
61
- }): Function;
62
- /**
63
- *
64
- * @param {Array} arr
65
- * @returns {(v) => number[]}
66
- */
67
- static weight(arr: any[]): (v: any) => number[];
68
- /**
69
- *
70
- * @param {object} options
71
- * @param {Function} [options.fn=(fn = v => v)] - Function to calculate weight.
72
- * @param {number[]} [options.cols=[]] - Widths of the columns.
73
- * @param {number} [options.padding=1] - The padding between columns.
74
- * @param {string[]} [options.aligns=[]] - The column aligns: l, r
75
- * @returns {(arr: []) => string[][]}
76
- */
77
- static table(options?: {
78
- fn?: Function | undefined;
79
- cols?: number[] | undefined;
80
- padding?: number | undefined;
81
- aligns?: string[] | undefined;
82
- }): (arr: []) => string[][];
83
- /**
84
- * Move cursor up by specified lines.
85
- * @param {number} [lines=1] - Number of lines to move up.
86
- * @returns {string} ANSI escape code for cursor movement.
87
- */
88
- static cursorUp(lines?: number): string;
89
- /**
90
- * Move cursor down by specified lines.
91
- * @param {number} [lines=1] - Number of lines to move down.
92
- * @returns {string} ANSI escape code for cursor movement.
93
- */
94
- static cursorDown(lines?: number): string;
95
- /**
96
- * Clear the current line.
97
- * @param {string} [str="\r"] - String to append after clearing.
98
- * @returns {string} ANSI escape code for line clearing followed by the string.
99
- */
100
- static clearLine(str?: string): string;
101
- /**
102
- * Clear the entire screen.
103
- * @returns {string} ANSI escape codes for screen clearing.
104
- */
105
- static clearScreen(): string;
106
- /**
107
- * @param {object} [input]
108
- * @param {string[]|string[][]} [input.value]
109
- * @param {number} [input.width]
110
- * @param {number} [input.height]
111
- * @param {string} [input.imprint]
112
- * @param {string} [input.renderMethod]
113
- * @param {FrameProps} [input.defaultProps]
114
- */
115
- constructor(input?: {
116
- value?: string[] | string[][] | undefined;
117
- width?: number | undefined;
118
- height?: number | undefined;
119
- imprint?: string | undefined;
120
- renderMethod?: string | undefined;
121
- defaultProps?: FrameProps | undefined;
122
- });
123
- /**
124
- * @example
125
- * ```js
126
- * new Frame([
127
- * ["Hello", "World"],
128
- * [["Hello", { color: "red", bgColor: "#009" }], "World"],
129
- * ["<b i fg=#900>Hello</b>", "<i>World</i>"],
130
- * ])
131
- * ```
132
- * @type {string[][]|any[][]}
133
- */
134
- value: string[][] | any[][];
135
- /** @type {FrameProps} */
136
- defaultProps: FrameProps;
137
- /** @type {string} */
138
- imprint: string;
139
- /** @type {number} */
140
- width: number;
141
- /** @type {number} */
142
- height: number;
143
- /** @type {string} */
144
- renderMethod: string;
145
- /**
146
- * Get whether the frame is empty.
147
- * @returns {boolean} True if the frame has no content.
148
- */
149
- get empty(): boolean;
150
- /**
151
- * Calculate the visual width of a string.
152
- * @param {string} str
153
- * @returns {number} The visual width of the string.
154
- */
155
- lengthOf(str: string): number;
156
- /**
157
- * Render the frame into a string representation.
158
- * @param {object} [options]
159
- * @param {string} [options.method] - Render method to use.
160
- * @param {FrameProps} [options.props] - Properties to apply during rendering.
161
- * @returns {string} The rendered frame as a string.
162
- */
163
- render(options?: {
164
- method?: string | undefined;
165
- props?: FrameProps | undefined;
166
- }): string;
167
- /**
168
- * Convert the frame to its string representation.
169
- * @returns {string} The frame's imprint.
170
- */
171
- toString(): string;
172
- /**
173
- * Transform each cell in the frame using a function.
174
- * @param {Function} fn - Function to apply to each cell.
175
- * @returns {Frame} A new Frame with transformed values.
176
- */
177
- transform(fn: Function): Frame;
178
- /**
179
- * Set the window size for the frame.
180
- * @param {number} width - The width of the window.
181
- * @param {number} height - The height of the window.
182
- */
183
- setWindowSize(width: number, height: number): void;
184
- #private;
185
- }
186
- import FrameProps from './Props.js';
@@ -1,77 +0,0 @@
1
- export default FrameProps;
2
- /**
3
- * Represents default styling properties for Frame rendering.
4
- * Every tag must be a separate value in the array of rows/columns.
5
- * If you want to apply the same props to multiple values, you can use an array of values.
6
- * If you want to apply different props to multiple values, you can use an object with the props.
7
- * If you want to apply props to a single value, you can use a string with the props in XML format.
8
- * Parser checks every atom for its beginning and end and if it's a tag, it applies the props to the value.
9
- *
10
- * @example
11
- * const defaultProps = new FrameProps({
12
- * color: "red",
13
- * bgColor: "blue",
14
- * bold: true,
15
- * italic: true,
16
- * underline: true,
17
- * strikethrough: true,
18
- * })
19
- * or by aliases:
20
- * const defaultProps = new FrameProps({
21
- * fg: "red",
22
- * bg: "blue",
23
- * b: true,
24
- * i: true,
25
- * u: true,
26
- * s: true,
27
- * })
28
- * from an array of strings:
29
- * const rows = [
30
- * ["Hello", "World"],
31
- * ["<fg=red>Hello</>", "<bg=blue>World</>"],
32
- * ["<b>Hello</b>", "<i>World</i>"],
33
- * ["<u>Hello</u>", "<s>World</s>"],
34
- * ["<b fg=red>Hello</b>", "<i bg=blue>World</i>"],
35
- * ["<b i>Hello</b>", "<i b>World</i>"],
36
- * ["<b i s>Some</b>", ["thing", {b: true, i: true, s: true}]],
37
- * [["Hello", "World", {b: true}]],
38
- * ]
39
- * const defaultProps = new FrameProps(rows)
40
- */
41
- declare class FrameProps extends ObjectWithAlias {
42
- /**
43
- * Property aliases for shorthand notation.
44
- * @type {Record<string, string>}
45
- */
46
- static ALIAS: Record<string, string>;
47
- /**
48
- * @param {object} props - Frame properties
49
- * @param {string} [props.color=""] - Text color
50
- * @param {string} [props.bgColor=""] - Background color
51
- * @param {boolean} [props.bold=false] - Bold text flag
52
- * @param {boolean} [props.italic=false] - Italic text flag
53
- * @param {boolean} [props.underline=false] - Underline text flag
54
- * @param {boolean} [props.strikethrough=false] - Strikethrough text flag
55
- */
56
- constructor(props?: {
57
- color?: string | undefined;
58
- bgColor?: string | undefined;
59
- bold?: boolean | undefined;
60
- italic?: boolean | undefined;
61
- underline?: boolean | undefined;
62
- strikethrough?: boolean | undefined;
63
- });
64
- /** @type {string} Text color */
65
- color: string;
66
- /** @type {string} Background color */
67
- bgColor: string;
68
- /** @type {boolean} Bold text flag */
69
- bold: boolean;
70
- /** @type {boolean} Italic text flag */
71
- italic: boolean;
72
- /** @type {boolean} Underline text flag */
73
- underline: boolean;
74
- /** @type {boolean} Strikethrough text flag */
75
- strikethrough: boolean;
76
- }
77
- import { ObjectWithAlias } from '@nan0web/types';
package/types/StdIn.d.ts DELETED
@@ -1,62 +0,0 @@
1
- /**
2
- * Handles standard input stream with message buffering.
3
- */
4
- export default class StdIn extends EventProcessor {
5
- /** @type {number} Read interval in milliseconds */
6
- static READ_INTERVAL: number;
7
- /** @type {string[]} Messages to ignore */
8
- static IGNORE_MESSAGES: string[];
9
- /**
10
- * Creates a StdIn instance from the given input.
11
- * @param {StdIn|object} input - The input to create from
12
- * @returns {StdIn} A StdIn instance
13
- */
14
- static from(input: StdIn | object): StdIn;
15
- /**
16
- * Creates a new StdIn instance.
17
- * @param {object} props - StdIn properties
18
- * @param {Processor} [props.processor] - Input processor
19
- * @param {UiMessage[]} [props.stream=[]] - Initial input stream
20
- */
21
- constructor(props?: {
22
- processor?: Processor | undefined;
23
- stream?: UiMessage[] | undefined;
24
- });
25
- /** @type {Processor} Input processor */
26
- processor: Processor;
27
- /** @type {UiMessage[]} Input message buffer */
28
- stream: UiMessage[];
29
- /**
30
- * Checks if there are messages waiting in the input stream.
31
- * @returns {boolean} True if waiting messages, false otherwise
32
- */
33
- get waiting(): boolean;
34
- /**
35
- * Checks if the input stream has ended (no messages left).
36
- * @returns {boolean} True if no messages left, false otherwise
37
- */
38
- get ended(): boolean;
39
- /**
40
- * Reads a message from the input stream.
41
- * Waits until messages are available if stream is empty.
42
- * @returns {Promise<UiMessage>} Next input message
43
- */
44
- read(): Promise<UiMessage>;
45
- /**
46
- * Writes a message to the input stream.
47
- * @param {string} message - Message to write
48
- * @returns {boolean} True if message accepted, False if ignored
49
- */
50
- write(message: string): boolean;
51
- /**
52
- * Decodes a message into an UiMessage instance.
53
- * @param {UiMessage | string[] | any} message - Message to decode
54
- * @returns {UiMessage} Decoded input message
55
- */
56
- decode(message: UiMessage | string[] | any): UiMessage;
57
- }
58
- import EventProcessor from '@nan0web/event/oop';
59
- declare class Processor extends EventProcessor {
60
- }
61
- import { UiMessage } from './core/index.js';
62
- export {};
package/types/StdOut.d.ts DELETED
@@ -1,52 +0,0 @@
1
- export default StdOut;
2
- /**
3
- * Handles standard output stream with formatting capabilities.
4
- */
5
- declare class StdOut extends EventProcessor {
6
- /** @type {string} End of line character */
7
- static EOL: string;
8
- /** @type {string} Beginning of line character */
9
- static BOL: string;
10
- /** @type {string} Reset formatting escape code */
11
- static RESET: string;
12
- /** @type {string} Clear screen escape code */
13
- static CLEAR: string;
14
- /** @type {object} Color escape codes */
15
- static COLORS: object;
16
- /** @type {Record<string, string>} Style escape codes */
17
- static STYLES: Record<string, string>;
18
- /**
19
- * Creates a new StdOut instance.
20
- * @param {object} props - StdOut properties
21
- * @param {any} [props.processor] - Output processor
22
- * @param {string[]} [props.stream=[]] - Initial output stream
23
- * @param {number[]} [props.windowSize=[144, 33]] - Window size [width, height]
24
- */
25
- constructor(props?: {
26
- processor?: any;
27
- stream?: string[] | undefined;
28
- windowSize?: number[] | undefined;
29
- });
30
- /**
31
- * @todo define go top by rows constants.
32
- */
33
- /** @type {string[]} Output stream buffer */
34
- stream: string[];
35
- /** @type {number[]} Window size [width, height] */
36
- windowSize: number[];
37
- /** @type {any} Output processor */
38
- processor: any;
39
- /**
40
- * Writes output to the output stream.
41
- * Must be overwritten by other apps.
42
- * @param {any} output - Output to write
43
- * @param {Function} onError - Error handler callback
44
- */
45
- write(output: any, onError?: Function): void;
46
- /**
47
- * Gets the window size.
48
- * @returns {number[]} Window size [width, height]
49
- */
50
- getWindowSize(): number[];
51
- }
52
- import EventProcessor from '@nan0web/event/oop';