@nan0web/ui 1.0.2 → 1.0.3

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 (44) hide show
  1. package/README.md +2 -35
  2. package/package.json +7 -2
  3. package/src/App/Core/CoreApp.js +14 -19
  4. package/src/App/Core/UI.js +5 -5
  5. package/src/App/User/UserApp.js +4 -19
  6. package/src/App/User/UserUI.js +4 -4
  7. package/src/App/User/index.js +0 -6
  8. package/src/App/index.js +0 -3
  9. package/src/README.md.js +3 -27
  10. package/src/StdIn.js +1 -3
  11. package/src/core/Error/index.js +9 -0
  12. package/src/core/Form/Form.js +36 -18
  13. package/src/core/Form/Input.js +16 -7
  14. package/src/core/Form/Message.js +6 -9
  15. package/src/core/InputAdapter.js +4 -0
  16. package/src/core/Message/InputMessage.js +11 -11
  17. package/src/core/Message/OutputMessage.js +1 -1
  18. package/src/core/index.js +2 -0
  19. package/src/index.js +1 -0
  20. package/types/App/Core/CoreApp.d.ts +9 -9
  21. package/types/App/Core/UI.d.ts +5 -5
  22. package/types/App/Core/Widget.d.ts +1 -1
  23. package/types/App/User/Command/Message.d.ts +2 -3
  24. package/types/App/User/Command/Options.d.ts +9 -2
  25. package/types/App/User/Command/index.d.ts +1 -4
  26. package/types/App/User/UserApp.d.ts +10 -7
  27. package/types/App/User/UserUI.d.ts +0 -9
  28. package/types/App/User/index.d.ts +0 -4
  29. package/types/App/index.d.ts +1 -3
  30. package/types/Frame/Frame.d.ts +5 -5
  31. package/types/View/View.d.ts +3 -3
  32. package/types/core/Error/index.d.ts +6 -0
  33. package/types/core/Form/Form.d.ts +12 -6
  34. package/types/core/Form/Input.d.ts +20 -7
  35. package/types/core/Form/Message.d.ts +10 -4
  36. package/types/core/InputAdapter.d.ts +2 -0
  37. package/types/core/Message/InputMessage.d.ts +5 -5
  38. package/types/core/Message/OutputMessage.d.ts +1 -1
  39. package/types/core/Stream.d.ts +1 -1
  40. package/types/core/StreamEntry.d.ts +1 -1
  41. package/types/core/index.d.ts +1 -0
  42. package/types/index.d.ts +1 -0
  43. package/src/App/Command/Options.js +0 -78
  44. package/src/App/Command/index.js +0 -9
@@ -1,78 +0,0 @@
1
- /**
2
- * Represents command options with default values.
3
- * Provides utilities for handling command line options.
4
- */
5
- class CommandOptions {
6
- /**
7
- * Default option values.
8
- * @type {object}
9
- * @property {boolean} help - Whether help is requested
10
- * @property {string} cwd - Current working directory
11
- */
12
- static DEFAULTS = {
13
- help: false,
14
- cwd: "",
15
- }
16
-
17
- /** @type {boolean} Whether help is requested */
18
- help
19
-
20
- /** @type {string} Current working directory */
21
- cwd
22
-
23
- /**
24
- * Creates a new CommandOptions instance.
25
- * @param {object} props - The properties for command options
26
- * @param {boolean} [props.help=false] - Whether help is requested
27
- * @param {string} [props.cwd=""] - Current working directory
28
- */
29
- constructor(props = {}) {
30
- const {
31
- help = CommandOptions.DEFAULTS.help,
32
- cwd = CommandOptions.DEFAULTS.cwd,
33
- } = props
34
- this.help = Boolean(help)
35
- this.cwd = String(cwd)
36
- }
37
-
38
- /** @type {Record<string, any>} */
39
- get DEFAULTS() {
40
- return /** @type {typeof CommandOptions} */ (this.constructor).DEFAULTS
41
- }
42
-
43
- /**
44
- * Checks if all options have their default values.
45
- * @returns {boolean} True if all options are at their default values, false otherwise
46
- */
47
- get empty() {
48
- return Object.entries(this).every(
49
- ([key, value]) => CommandOptions.DEFAULTS[key] === value
50
- )
51
- }
52
-
53
- /**
54
- * Converts the options to a string representation.
55
- * @returns {string} String representation of the options or "<no options>" if none set
56
- */
57
- toString() {
58
- const opts = Object.entries(this).map(([key, value]) => {
59
- if (this.DEFAULTS[key] === value) return false
60
- const prefix = true === value ? "--" : "-"
61
- return `${prefix}${key}${value ? ` ${value}` : ""}`
62
- }).filter(Boolean)
63
- if (0 === opts.length) return "<no options>"
64
- return opts.join(" ")
65
- }
66
-
67
- /**
68
- * Creates a CommandOptions instance from the given props.
69
- * @param {CommandOptions|object} props - The properties to create from
70
- * @returns {CommandOptions} A CommandOptions instance
71
- */
72
- static from(props) {
73
- if (props instanceof CommandOptions) return props
74
- return new this(props)
75
- }
76
- }
77
-
78
- export default CommandOptions
@@ -1,9 +0,0 @@
1
- import { CommandMessage } from "@nan0web/co"
2
- import CommandOptions from "./Options.js"
3
-
4
- export { CommandMessage, CommandOptions }
5
-
6
- export default {
7
- Message: CommandMessage,
8
- Options: CommandOptions,
9
- }