@nan0web/ui 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/.datasets/README.dataset.jsonl +12 -0
- package/.editorconfig +20 -0
- package/CONTRIBUTING.md +42 -0
- package/LICENSE +15 -0
- package/README.md +238 -0
- package/docs/uk/README.md +240 -0
- package/package.json +64 -0
- package/playground/User.js +52 -0
- package/playground/currency.exchange.js +48 -0
- package/playground/i18n/index.js +21 -0
- package/playground/i18n/uk.js +53 -0
- package/playground/language.form.js +25 -0
- package/playground/main.js +72 -0
- package/playground/registration.form.js +58 -0
- package/playground/topup.telephone.js +62 -0
- package/src/App/Command/Options.js +78 -0
- package/src/App/Command/index.js +9 -0
- package/src/App/Core/CoreApp.js +129 -0
- package/src/App/Core/UI.js +116 -0
- package/src/App/Core/Widget.js +67 -0
- package/src/App/Core/index.js +11 -0
- package/src/App/Scenario.js +45 -0
- package/src/App/User/Command/Message.js +44 -0
- package/src/App/User/Command/Options.js +48 -0
- package/src/App/User/Command/index.js +11 -0
- package/src/App/User/UserApp.js +73 -0
- package/src/App/User/UserApp.test.js +56 -0
- package/src/App/User/UserUI.js +20 -0
- package/src/App/User/UserUI.test.js +51 -0
- package/src/App/User/index.js +15 -0
- package/src/App/index.js +22 -0
- package/src/Component/Process/Input.js +70 -0
- package/src/Component/Process/Process.js +26 -0
- package/src/Component/Process/index.js +5 -0
- package/src/Component/Welcome/Input.js +50 -0
- package/src/Component/Welcome/Welcome.js +26 -0
- package/src/Component/Welcome/index.js +5 -0
- package/src/Component/index.js +9 -0
- package/src/Frame/Frame.js +591 -0
- package/src/Frame/Frame.test.js +429 -0
- package/src/Frame/Props.js +102 -0
- package/src/Locale.js +119 -0
- package/src/Model/User/User.js +56 -0
- package/src/Model/index.js +7 -0
- package/src/README.md.js +371 -0
- package/src/StdIn.js +111 -0
- package/src/StdOut.js +99 -0
- package/src/View/RenderOptions.js +48 -0
- package/src/View/View.js +289 -0
- package/src/View/View.test.js +77 -0
- package/src/core/Form/Form.js +289 -0
- package/src/core/Form/Form.test.js +116 -0
- package/src/core/Form/Input.js +116 -0
- package/src/core/Form/Input.test.js +58 -0
- package/src/core/Form/Message.js +86 -0
- package/src/core/Form/Message.test.js +54 -0
- package/src/core/Form/index.js +11 -0
- package/src/core/InputAdapter.js +41 -0
- package/src/core/InputAdapter.test.js +35 -0
- package/src/core/Message/InputMessage.js +119 -0
- package/src/core/Message/InputMessage.test.js +45 -0
- package/src/core/Message/Message.js +77 -0
- package/src/core/Message/Message.test.js +58 -0
- package/src/core/Message/OutputMessage.js +143 -0
- package/src/core/Message/OutputMessage.test.js +61 -0
- package/src/core/Message/index.js +7 -0
- package/src/core/OutputAdapter.js +50 -0
- package/src/core/OutputAdapter.test.js +35 -0
- package/src/core/Stream.js +71 -0
- package/src/core/Stream.test.js +78 -0
- package/src/core/StreamEntry.js +59 -0
- package/src/core/index.js +13 -0
- package/src/functions.js +38 -0
- package/src/index.js +34 -0
- package/src/index.test.js +14 -0
- package/src/models/SimpleUser.js +18 -0
- package/stories/App/AppView.js +15 -0
- package/stories/App/AppView.test.js +22 -0
- package/stories/App/RenderOptions.js +14 -0
- package/stories/nodejs/interface.test.js +27 -0
- package/system.md +187 -0
- package/system1.md +137 -0
- package/task.md +181 -0
- package/tsconfig.json +23 -0
- package/types/App/Command/Options.d.ts +46 -0
- package/types/App/Command/index.d.ts +8 -0
- package/types/App/Core/CoreApp.d.ts +70 -0
- package/types/App/Core/UI.d.ts +49 -0
- package/types/App/Core/Widget.d.ts +40 -0
- package/types/App/Core/index.d.ts +10 -0
- package/types/App/Scenario.d.ts +26 -0
- package/types/App/User/Command/Message.d.ts +30 -0
- package/types/App/User/Command/Options.d.ts +27 -0
- package/types/App/User/Command/index.d.ts +8 -0
- package/types/App/User/UserApp.d.ts +31 -0
- package/types/App/User/UserUI.d.ts +18 -0
- package/types/App/User/index.d.ts +12 -0
- package/types/App/index.d.ts +14 -0
- package/types/Component/Process/Input.d.ts +48 -0
- package/types/Component/Process/Process.d.ts +13 -0
- package/types/Component/Process/index.d.ts +4 -0
- package/types/Component/Welcome/Input.d.ts +34 -0
- package/types/Component/Welcome/Welcome.d.ts +13 -0
- package/types/Component/Welcome/index.d.ts +4 -0
- package/types/Component/index.d.ts +8 -0
- package/types/Frame/Frame.d.ts +186 -0
- package/types/Frame/Props.d.ts +77 -0
- package/types/Locale.d.ts +55 -0
- package/types/Model/User/User.d.ts +36 -0
- package/types/Model/index.d.ts +6 -0
- package/types/StdIn.d.ts +62 -0
- package/types/StdOut.d.ts +52 -0
- package/types/View/RenderOptions.d.ts +29 -0
- package/types/View/View.d.ts +115 -0
- package/types/core/Form/Form.d.ts +123 -0
- package/types/core/Form/Input.d.ts +69 -0
- package/types/core/Form/Message.d.ts +28 -0
- package/types/core/Form/index.d.ts +5 -0
- package/types/core/InputAdapter.d.ts +28 -0
- package/types/core/Message/InputMessage.d.ts +71 -0
- package/types/core/Message/Message.d.ts +50 -0
- package/types/core/Message/OutputMessage.d.ts +53 -0
- package/types/core/Message/index.d.ts +5 -0
- package/types/core/OutputAdapter.d.ts +33 -0
- package/types/core/Stream.d.ts +27 -0
- package/types/core/StreamEntry.d.ts +45 -0
- package/types/core/index.d.ts +9 -0
- package/types/functions.d.ts +3 -0
- package/types/index.d.ts +20 -0
- package/types/models/SimpleUser.d.ts +21 -0
- package/vitest.config.js +26 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export default CommandOptions;
|
|
2
|
+
/**
|
|
3
|
+
* Represents command options with default values.
|
|
4
|
+
* Provides utilities for handling command line options.
|
|
5
|
+
*/
|
|
6
|
+
declare class CommandOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Default option values.
|
|
9
|
+
* @type {object}
|
|
10
|
+
* @property {boolean} help - Whether help is requested
|
|
11
|
+
* @property {string} cwd - Current working directory
|
|
12
|
+
*/
|
|
13
|
+
static DEFAULTS: object;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a CommandOptions instance from the given props.
|
|
16
|
+
* @param {CommandOptions|object} props - The properties to create from
|
|
17
|
+
* @returns {CommandOptions} A CommandOptions instance
|
|
18
|
+
*/
|
|
19
|
+
static from(props: CommandOptions | object): CommandOptions;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new CommandOptions instance.
|
|
22
|
+
* @param {object} props - The properties for command options
|
|
23
|
+
* @param {boolean} [props.help=false] - Whether help is requested
|
|
24
|
+
* @param {string} [props.cwd=""] - Current working directory
|
|
25
|
+
*/
|
|
26
|
+
constructor(props?: {
|
|
27
|
+
help?: boolean | undefined;
|
|
28
|
+
cwd?: string | undefined;
|
|
29
|
+
});
|
|
30
|
+
/** @type {boolean} Whether help is requested */
|
|
31
|
+
help: boolean;
|
|
32
|
+
/** @type {string} Current working directory */
|
|
33
|
+
cwd: string;
|
|
34
|
+
/** @type {Record<string, any>} */
|
|
35
|
+
get DEFAULTS(): Record<string, any>;
|
|
36
|
+
/**
|
|
37
|
+
* Checks if all options have their default values.
|
|
38
|
+
* @returns {boolean} True if all options are at their default values, false otherwise
|
|
39
|
+
*/
|
|
40
|
+
get empty(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Converts the options to a string representation.
|
|
43
|
+
* @returns {string} String representation of the options or "<no options>" if none set
|
|
44
|
+
*/
|
|
45
|
+
toString(): string;
|
|
46
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
export { CommandMessage as Message };
|
|
3
|
+
export { CommandOptions as Options };
|
|
4
|
+
}
|
|
5
|
+
export default _default;
|
|
6
|
+
import { CommandMessage } from "@nan0web/co";
|
|
7
|
+
import CommandOptions from "./Options.js";
|
|
8
|
+
export { CommandMessage, CommandOptions };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** @typedef {Function} CommandFn */
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for all apps.
|
|
4
|
+
* Each app processes input commands and produces output.
|
|
5
|
+
*/
|
|
6
|
+
export default class CoreApp {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new CoreApp instance.
|
|
9
|
+
* @param {object} props - CoreApp properties
|
|
10
|
+
* @param {string} [props.name="CoreApp"] - App name
|
|
11
|
+
* @param {object} [props.state={}] - Initial state object
|
|
12
|
+
* @param {string[]} [props.argv=[]] - Command line arguments to parse
|
|
13
|
+
*/
|
|
14
|
+
constructor(props?: {
|
|
15
|
+
name?: string | undefined;
|
|
16
|
+
state?: object;
|
|
17
|
+
argv?: string[] | undefined;
|
|
18
|
+
});
|
|
19
|
+
/** @type {string} App name */
|
|
20
|
+
name: string;
|
|
21
|
+
/** @type {Map<string, CommandFn>} Registered command handlers */
|
|
22
|
+
commands: Map<string, CommandFn>;
|
|
23
|
+
/** @type {object} App state */
|
|
24
|
+
state: object;
|
|
25
|
+
/** @type {CommandMessage} Starting command parsed from argv */
|
|
26
|
+
startCommand: CommandMessage;
|
|
27
|
+
/**
|
|
28
|
+
* Sets app state.
|
|
29
|
+
* @param {string|object} state - State key or object with multiple keys
|
|
30
|
+
* @param {any} [value] - State value if state is a string key
|
|
31
|
+
* @returns {object} Updated state
|
|
32
|
+
*/
|
|
33
|
+
set(state: string | object, value?: any): object;
|
|
34
|
+
/**
|
|
35
|
+
* Register a command handler.
|
|
36
|
+
* @param {string} commandName - Name of the command to register
|
|
37
|
+
* @param {Function} handler - async function or sync function that accepts params and returns output
|
|
38
|
+
*/
|
|
39
|
+
registerCommand(commandName: string, handler: Function): void;
|
|
40
|
+
/**
|
|
41
|
+
* Returns a string representation of the app.
|
|
42
|
+
* @returns {string} String representation including name and state
|
|
43
|
+
*/
|
|
44
|
+
toString(): string;
|
|
45
|
+
/**
|
|
46
|
+
* Process a command message.
|
|
47
|
+
* @param {CommandMessage} commandMessage - Command to process
|
|
48
|
+
* @param {UI} ui - UI instance to use for rendering
|
|
49
|
+
* @returns {Promise<any>} Output of the command
|
|
50
|
+
* @throws {Error} If the command is not registered
|
|
51
|
+
*/
|
|
52
|
+
processCommand(commandMessage: CommandMessage, ui: UI): Promise<any>;
|
|
53
|
+
/**
|
|
54
|
+
* Process an array of command messages sequentially.
|
|
55
|
+
* @param {CommandMessage[]} commandMessages - Array of commands to process
|
|
56
|
+
* @param {UI} ui - UI instance to use for rendering
|
|
57
|
+
* @returns {Promise<any[]>} Array of command outputs
|
|
58
|
+
*/
|
|
59
|
+
processCommands(commandMessages: CommandMessage[], ui: UI): Promise<any[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Select a command to run. Must be implemented by subclasses.
|
|
62
|
+
* @param {UI} ui - UI instance for interaction
|
|
63
|
+
* @returns {Promise<string>} Command name to execute
|
|
64
|
+
* @throws {Error} Always thrown as this method must be implemented by subclasses
|
|
65
|
+
*/
|
|
66
|
+
selectCommand(ui: UI): Promise<string>;
|
|
67
|
+
}
|
|
68
|
+
export type CommandFn = Function;
|
|
69
|
+
import { CommandMessage } from "../Command/index.js";
|
|
70
|
+
import UI from "./UI.js";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export default UI;
|
|
2
|
+
export type ComponentFn = import("../../View/View.js").ComponentFn;
|
|
3
|
+
/** @typedef {import("../../View/View.js").ComponentFn} ComponentFn */
|
|
4
|
+
/**
|
|
5
|
+
* Abstract UI class to connect apps and widgets.
|
|
6
|
+
* Supports input/output data typed classes and views.
|
|
7
|
+
*/
|
|
8
|
+
declare class UI extends Widget {
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new UI instance.
|
|
11
|
+
* @param {CoreApp} app - The app to connect to this UI
|
|
12
|
+
* @param {View} [view] - View instance for rendering (default: new View())
|
|
13
|
+
*/
|
|
14
|
+
constructor(app: CoreApp, view?: View | undefined);
|
|
15
|
+
/** @type {CoreApp} The app instance connected to this UI */
|
|
16
|
+
app: CoreApp;
|
|
17
|
+
/**
|
|
18
|
+
* Convert raw input to CommandMessage array.
|
|
19
|
+
* Must be implemented by subclasses.
|
|
20
|
+
* @param {any} rawInput - Raw input to convert
|
|
21
|
+
* @returns {CommandMessage[]} Array of command messages
|
|
22
|
+
* @throws {Error} Always thrown as this method must be implemented by subclasses
|
|
23
|
+
*/
|
|
24
|
+
convertInput(rawInput: any): CommandMessage[];
|
|
25
|
+
/**
|
|
26
|
+
* Process input, run commands on app, and output results.
|
|
27
|
+
* Supports progress callback.
|
|
28
|
+
* @emits {start} Emitted when processing begins
|
|
29
|
+
* @emits {data} Emitted for each command being processed
|
|
30
|
+
* @emits {end} Emitted when all commands have been processed
|
|
31
|
+
* @param {any} rawInput - Raw input to process
|
|
32
|
+
* @returns {Promise<any[]>} Results of command processing
|
|
33
|
+
*/
|
|
34
|
+
process(rawInput: any): Promise<any[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Sets up event handlers for UI process events.
|
|
37
|
+
* @param {ComponentFn} UIProcess - Process view component
|
|
38
|
+
*/
|
|
39
|
+
show(UIProcess: ComponentFn): void;
|
|
40
|
+
/**
|
|
41
|
+
* Output results to the interface.
|
|
42
|
+
* @param {any[]} results - Results to output
|
|
43
|
+
*/
|
|
44
|
+
output(results: any[]): void;
|
|
45
|
+
}
|
|
46
|
+
import Widget from "./Widget.js";
|
|
47
|
+
import CoreApp from "./CoreApp.js";
|
|
48
|
+
import { CommandMessage } from "../Command/index.js";
|
|
49
|
+
import View from "../../View/View.js";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export default Widget;
|
|
2
|
+
export type ComponentFn = import("./UI.js").ComponentFn;
|
|
3
|
+
/** @typedef {import("./UI.js").ComponentFn} ComponentFn */
|
|
4
|
+
/**
|
|
5
|
+
* Abstract Widget class.
|
|
6
|
+
* Widget is a view with ability to input data in a specific format.
|
|
7
|
+
* Input and output data are typed classes.
|
|
8
|
+
*/
|
|
9
|
+
declare class Widget extends EventProcessor {
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new Widget instance.
|
|
12
|
+
* @param {View} [view] - View instance (default: new View())
|
|
13
|
+
*/
|
|
14
|
+
constructor(view?: View | undefined);
|
|
15
|
+
/** @type {View} The view associated with this widget */
|
|
16
|
+
view: View;
|
|
17
|
+
/**
|
|
18
|
+
* Ask user for input data of specific class.
|
|
19
|
+
* @param {InputMessage} input - instance of InputMessage or similar
|
|
20
|
+
* @returns {Promise<InputMessage | null>} instance of InputMessage or null
|
|
21
|
+
*/
|
|
22
|
+
ask(input: InputMessage): Promise<InputMessage | null>;
|
|
23
|
+
/**
|
|
24
|
+
* @param {AsyncGenerator<StreamEntry>} stream
|
|
25
|
+
* @returns {Promise<void>}
|
|
26
|
+
*/
|
|
27
|
+
read(stream: AsyncGenerator<StreamEntry>): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Render output data using a view function.
|
|
30
|
+
* @param {Function|string} viewFnOrName - View function or registered view name
|
|
31
|
+
* @param {object} outputData - Typed output data instance
|
|
32
|
+
* @returns {any} Rendered output
|
|
33
|
+
* @throws {Error} If view component is not found when using string name
|
|
34
|
+
*/
|
|
35
|
+
render(viewFnOrName: Function | string, outputData: object): any;
|
|
36
|
+
}
|
|
37
|
+
import EventProcessor from "@nan0web/event/oop";
|
|
38
|
+
import View from "../../View/View.js";
|
|
39
|
+
import InputMessage from "../../core/Message/InputMessage.js";
|
|
40
|
+
import { StreamEntry } from "@nan0web/db";
|
|
@@ -0,0 +1,26 @@
|
|
|
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";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default UserAppCommandMessage;
|
|
2
|
+
/**
|
|
3
|
+
* Extends Command.Message to include user-specific command options.
|
|
4
|
+
*/
|
|
5
|
+
declare class UserAppCommandMessage extends CommandMessage {
|
|
6
|
+
/**
|
|
7
|
+
* Parses an array of strings into a UserAppCommandMessage.
|
|
8
|
+
* @param {string[] | string} value - Arguments to parse
|
|
9
|
+
* @returns {UserAppCommandMessage} Parsed command message
|
|
10
|
+
*/
|
|
11
|
+
static parse(value?: string[] | string): UserAppCommandMessage;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new UserAppCommandMessage instance.
|
|
14
|
+
* @param {object} props - Command message properties
|
|
15
|
+
* @param {string[]} [props.args=[]] - Command arguments
|
|
16
|
+
* @param {Partial<UserAppCommandOptions>} [props.opts={}] - User-specific options
|
|
17
|
+
*/
|
|
18
|
+
constructor(props?: {
|
|
19
|
+
args?: string[] | undefined;
|
|
20
|
+
opts?: Partial<UserAppCommandOptions> | undefined;
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* @param {Partial<UserAppCommandOptions>} value
|
|
24
|
+
*/
|
|
25
|
+
set opts(arg: UserAppCommandOptions);
|
|
26
|
+
/** @returns {UserAppCommandOptions} */
|
|
27
|
+
get opts(): UserAppCommandOptions;
|
|
28
|
+
}
|
|
29
|
+
import { CommandMessage } from "../../Command/index.js";
|
|
30
|
+
import UserAppCommandOptions from "./Options.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export default UserAppCommandOptions;
|
|
2
|
+
/**
|
|
3
|
+
* Extends CommandOptions to include user-specific options.
|
|
4
|
+
*/
|
|
5
|
+
declare class UserAppCommandOptions extends CommandOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a UserAppCommandOptions instance from the given props.
|
|
8
|
+
* @param {UserAppCommandOptions|object} props - The properties to create from
|
|
9
|
+
* @returns {UserAppCommandOptions} A UserAppCommandOptions instance
|
|
10
|
+
*/
|
|
11
|
+
static from(props: UserAppCommandOptions | object): UserAppCommandOptions;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new UserAppCommandOptions instance.
|
|
14
|
+
* @param {object} props - Options properties
|
|
15
|
+
* @param {boolean} [props.help=false] - Whether help is requested
|
|
16
|
+
* @param {string} [props.cwd=""] - Current working directory
|
|
17
|
+
* @param {string} [props.user=""] - User name
|
|
18
|
+
*/
|
|
19
|
+
constructor(props?: {
|
|
20
|
+
help?: boolean | undefined;
|
|
21
|
+
cwd?: string | undefined;
|
|
22
|
+
user?: string | undefined;
|
|
23
|
+
});
|
|
24
|
+
/** @type {string} User name */
|
|
25
|
+
user: string;
|
|
26
|
+
}
|
|
27
|
+
import CommandOptions from "../../Command/Options.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
export { CommandMessage as Message };
|
|
3
|
+
export { CommandOptions as Options };
|
|
4
|
+
}
|
|
5
|
+
export default _default;
|
|
6
|
+
import CommandMessage from "./Message.js";
|
|
7
|
+
import CommandOptions from "./Options.js";
|
|
8
|
+
export { CommandMessage, CommandOptions };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export default UserApp;
|
|
2
|
+
/**
|
|
3
|
+
* UserApp requires user name and shows Welcome view.
|
|
4
|
+
* If user.name is provided in command input, ignores user input.
|
|
5
|
+
* User can change user data to see another Welcome view.
|
|
6
|
+
*/
|
|
7
|
+
declare class UserApp extends CoreApp {
|
|
8
|
+
/** @type {CommandMessage} Starting command parsed from argv */
|
|
9
|
+
startCommand: CommandMessage;
|
|
10
|
+
/**
|
|
11
|
+
* Set user data from params.
|
|
12
|
+
* @param {CommandMessage} cmd - Command message with user data
|
|
13
|
+
* @param {UserUI} ui - UI instance
|
|
14
|
+
* @returns {Promise<{ message: string }>} Welcome message
|
|
15
|
+
*/
|
|
16
|
+
setUser(cmd: CommandMessage, ui: UserUI): Promise<{
|
|
17
|
+
message: string;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Show welcome message for current user.
|
|
21
|
+
* @param {CommandMessage} cmd - Command message
|
|
22
|
+
* @param {UserUI} ui - UI instance
|
|
23
|
+
* @returns {Promise<string[][]>} Welcome view output
|
|
24
|
+
*/
|
|
25
|
+
welcome(cmd: CommandMessage, ui: UserUI): Promise<string[][]>;
|
|
26
|
+
user: User | undefined;
|
|
27
|
+
}
|
|
28
|
+
import CoreApp from "../Core/CoreApp.js";
|
|
29
|
+
import { CommandMessage } from "./Command/index.js";
|
|
30
|
+
import UserUI from "./UserUI.js";
|
|
31
|
+
import User from "../../Model/User/User.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
* Convert raw input to CommandMessage array.
|
|
10
|
+
* If user.name provided in rawInput, use it directly.
|
|
11
|
+
* Otherwise ask user for name.
|
|
12
|
+
* @param {any} rawInput - Raw input to convert
|
|
13
|
+
* @returns {CommandMessage[]} Array of command messages
|
|
14
|
+
*/
|
|
15
|
+
convertInput(rawInput: any): CommandMessage[];
|
|
16
|
+
}
|
|
17
|
+
import { CommandMessage } from "./Command/index.js";
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
export { UserApp as App };
|
|
3
|
+
export { UserUI as UI };
|
|
4
|
+
export let Command: {
|
|
5
|
+
Message: typeof import("./Command/Message.js").default;
|
|
6
|
+
Options: typeof import("./Command/Options.js").default;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export default _default;
|
|
10
|
+
import UserApp from "./UserApp.js";
|
|
11
|
+
import UserUI from "./UserUI.js";
|
|
12
|
+
export { UserApp, UserUI };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
export { Core };
|
|
3
|
+
export { User };
|
|
4
|
+
export { Command };
|
|
5
|
+
export { Scenario };
|
|
6
|
+
export { UI };
|
|
7
|
+
}
|
|
8
|
+
export default _default;
|
|
9
|
+
import Core from "./Core/index.js";
|
|
10
|
+
import User from "./User/index.js";
|
|
11
|
+
import Command from "./Command/index.js";
|
|
12
|
+
import Scenario from "./Scenario.js";
|
|
13
|
+
import UI from "./Core/UI.js";
|
|
14
|
+
export { Core, User, Command, Scenario, UI };
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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";
|
|
@@ -0,0 +1,34 @@
|
|
|
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";
|
|
@@ -0,0 +1,13 @@
|
|
|
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";
|