@nan0web/ui 1.0.0 → 1.0.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.
- package/package.json +6 -1
- package/.datasets/README.dataset.jsonl +0 -12
- package/.editorconfig +0 -20
- package/CONTRIBUTING.md +0 -42
- package/docs/uk/README.md +0 -240
- package/playground/User.js +0 -52
- package/playground/currency.exchange.js +0 -48
- package/playground/i18n/index.js +0 -21
- package/playground/i18n/uk.js +0 -53
- package/playground/language.form.js +0 -25
- package/playground/main.js +0 -72
- package/playground/registration.form.js +0 -58
- package/playground/topup.telephone.js +0 -62
- package/src/App/User/UserApp.test.js +0 -56
- package/src/App/User/UserUI.test.js +0 -51
- package/src/Frame/Frame.test.js +0 -429
- package/src/View/View.test.js +0 -77
- package/src/core/Form/Form.test.js +0 -116
- package/src/core/Form/Input.test.js +0 -58
- package/src/core/Form/Message.test.js +0 -54
- package/src/core/InputAdapter.test.js +0 -35
- package/src/core/Message/InputMessage.test.js +0 -45
- package/src/core/Message/Message.test.js +0 -58
- package/src/core/Message/OutputMessage.test.js +0 -61
- package/src/core/OutputAdapter.test.js +0 -35
- package/src/core/Stream.test.js +0 -78
- package/src/index.test.js +0 -14
- package/stories/App/AppView.js +0 -15
- package/stories/App/AppView.test.js +0 -22
- package/stories/App/RenderOptions.js +0 -14
- package/stories/nodejs/interface.test.js +0 -27
- package/system.md +0 -187
- package/system1.md +0 -137
- package/task.md +0 -181
- package/tsconfig.json +0 -23
- package/vitest.config.js +0 -26
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import RenderOptions from "../../src/View/RenderOptions.js"
|
|
2
|
-
|
|
3
|
-
class AppRenderOptions extends RenderOptions {
|
|
4
|
-
static DEFAULTS = {
|
|
5
|
-
...RenderOptions.DEFAULTS,
|
|
6
|
-
resizeToView: true,
|
|
7
|
-
}
|
|
8
|
-
static from(props = {}) {
|
|
9
|
-
if (props instanceof AppRenderOptions) return props
|
|
10
|
-
return new this(props)
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default AppRenderOptions
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @todo write tests for the interfaces StdIn, StdOut, Locale, Frame, FrameProps and View in NodeJS with vitest.
|
|
3
|
-
* Follow the actor / scenario model.
|
|
4
|
-
* Basic interfaces must include:
|
|
5
|
-
* - read text from stdin
|
|
6
|
-
* - write text to stdout
|
|
7
|
-
* - read an option from a selectbox with the bordered frame
|
|
8
|
-
* - write result to stdout
|
|
9
|
-
*
|
|
10
|
-
* Frames and Views must follow the blessed interface as for flexibility.
|
|
11
|
-
*/
|
|
12
|
-
import { describe, it, expect } from "vitest"
|
|
13
|
-
|
|
14
|
-
describe("Interface", () => {
|
|
15
|
-
it("should read text from stdin", () => {
|
|
16
|
-
expect("").toBe("")
|
|
17
|
-
})
|
|
18
|
-
it("should write text to stdout", () => {
|
|
19
|
-
expect("").toBe("")
|
|
20
|
-
})
|
|
21
|
-
it("should read an option from a selectbox with the bordered frame", () => {
|
|
22
|
-
expect("").toBe("")
|
|
23
|
-
})
|
|
24
|
-
it("should write result to stdout with the bordered frame", () => {
|
|
25
|
-
expect("").toBe("")
|
|
26
|
-
})
|
|
27
|
-
})
|
package/system.md
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
# System intructions `system.md` / NaN•Web UI
|
|
2
|
-
|
|
3
|
-
Vanilla javascript UI interfaces with no platform dependencies.
|
|
4
|
-
Must work for nodejs, browser and other compilers that supports ESM.
|
|
5
|
-
|
|
6
|
-
## Requirements
|
|
7
|
-
|
|
8
|
-
### 1. Javascript
|
|
9
|
-
|
|
10
|
-
1.1. Pure vanilla js only.
|
|
11
|
-
1.2. Platform abstract.
|
|
12
|
-
1.3. Minimum dependency as possible.
|
|
13
|
-
1.4. Classes
|
|
14
|
-
1.4.1. Order of the class elements:
|
|
15
|
-
- static properties
|
|
16
|
-
- properties
|
|
17
|
-
- constructor
|
|
18
|
-
- getters
|
|
19
|
-
- setters
|
|
20
|
-
- base functions
|
|
21
|
-
- async functions
|
|
22
|
-
- static base functions
|
|
23
|
-
- static async functions
|
|
24
|
-
|
|
25
|
-
1.5. Views, every must:
|
|
26
|
-
1.5.1. Have a separate file and test file `View/AppView.js` and `View/AppView.test.js`.
|
|
27
|
-
1.6. Components, every must:
|
|
28
|
-
1.6.1. Have a separate directory in `View/Component/*` or registered from any other directory with files:
|
|
29
|
-
- `Component.js`
|
|
30
|
-
- `Component.test.js`
|
|
31
|
-
- `ComponentInput.js`
|
|
32
|
-
- `index.js`
|
|
33
|
-
```js
|
|
34
|
-
export default Component
|
|
35
|
-
export { ComponentInput }
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### 2. Tests
|
|
39
|
-
|
|
40
|
-
Every model, component, class must have their own tests file to cover their functionality in isolated environment.
|
|
41
|
-
|
|
42
|
-
#### node:test
|
|
43
|
-
|
|
44
|
-
For the core (base), cgi and cli interfaces, and web interfaces non `.jsx` components `node:test` with `node:assert/strict` must be used for tests.
|
|
45
|
-
|
|
46
|
-
#### vitest
|
|
47
|
-
|
|
48
|
-
For `React` apps and any that uses `.jsx` components `vitest` must be used for tests.
|
|
49
|
-
|
|
50
|
-
## Interfaces
|
|
51
|
-
|
|
52
|
-
1. `base` - Самий базовий інтерфейс, який має описувати всі доступні для інтерфейсів функції + тести `node:test`.
|
|
53
|
-
1. `cli` - Console line application на основі команд через `argv[]` і вивід на екран за допомогою `@nan0web/log`.
|
|
54
|
-
1. `api` - API який працює постійно для надання даних для `web`, `mobile` та інших інтерфейсів.
|
|
55
|
-
1. `cgi` - Console graphic interface з віконцями і кнопками за допомогою `blessed`.
|
|
56
|
-
1. `web` - Веб інтерфейс з `Web.customElements`, `Lit`, або `React`.
|
|
57
|
-
1. `mobile` - Мобільний інтерфейс з `Ionic` або `Swift` і `Java`.
|
|
58
|
-
1. `desktop` - Веб інтерфейс у обкладинці `Electron` або `Tauri`.
|
|
59
|
-
1. `chat` - Чат інтерфейс `@nan0web/chat-ui`.
|
|
60
|
-
1. `audio` - Мовний (голосовий) інтерфейс `@nan0web/audio-ui`.
|
|
61
|
-
|
|
62
|
-
Базовий інтерфейс описує всі взаємодії і можливі функції.
|
|
63
|
-
Всі інші інтерфейси мають розширювати базовий.
|
|
64
|
-
|
|
65
|
-
Інтерфейси клієнти, у випадку коли є окремий `api` сервер, можуть розширювати свій `ClientUI`.
|
|
66
|
-
|
|
67
|
-
Приклад успадкування:
|
|
68
|
-
```js
|
|
69
|
-
import UI from "@nan0web/ui"
|
|
70
|
-
|
|
71
|
-
class BaseUI extends UI {}
|
|
72
|
-
|
|
73
|
-
class CliUI extends BaseUI {}
|
|
74
|
-
|
|
75
|
-
class APIUI extends CliUI {}
|
|
76
|
-
|
|
77
|
-
class CgiUI extends CliUI {}
|
|
78
|
-
|
|
79
|
-
class WebUI extends BaseUI {}
|
|
80
|
-
|
|
81
|
-
class MobileUI extends BaseUI {}
|
|
82
|
-
|
|
83
|
-
class DesktopUI extends WebUI {}
|
|
84
|
-
|
|
85
|
-
class ChatUI extends BaseUI {}
|
|
86
|
-
|
|
87
|
-
class AudioUI extends ChatUI {}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Views
|
|
91
|
-
|
|
92
|
-
#### Widgets
|
|
93
|
-
|
|
94
|
-
Widget is a control alement including a view with and ask() ability to input data.
|
|
95
|
-
|
|
96
|
-
#### Output
|
|
97
|
-
|
|
98
|
-
Output data is passed to the view but also in specific format:
|
|
99
|
-
```js
|
|
100
|
-
function UserDocumentsView(input = {}) {
|
|
101
|
-
input = UserDocumentsInput.from(input)
|
|
102
|
-
if (empty(input)) {
|
|
103
|
-
throw new Error("Input data required in a format off UserDocumentsInput")
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return Frame.from([
|
|
107
|
-
['Documents'],
|
|
108
|
-
...input.documents.map(d => d.name),
|
|
109
|
-
])
|
|
110
|
-
}
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
In this scenario I can easily define Input classes for the every View and Widget to be sure all the input pass, and easily require the proper input from the app before running a job.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
#### Input
|
|
117
|
-
|
|
118
|
-
When application needs any data it requires.
|
|
119
|
-
|
|
120
|
-
The input might be a command line `node start.js -user.name root` or, if not provided, user input through the provided infterface (any of CLI, API, voice, mobile, table, desktop, web, etc.)
|
|
121
|
-
|
|
122
|
-
```js
|
|
123
|
-
class App {
|
|
124
|
-
async requireUser() {
|
|
125
|
-
const user = await this.view.ask("User")()
|
|
126
|
-
if (user instanceof User) return user
|
|
127
|
-
throw new TypeError("User is required to continue")
|
|
128
|
-
}
|
|
129
|
-
async run() {
|
|
130
|
-
const user = await this.requireUser()
|
|
131
|
-
this.view.render("Welcome")({ user })
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
## Cross platform
|
|
137
|
-
|
|
138
|
-
Very important that I can extend basic UI with different apps, for instance:
|
|
139
|
-
```jsx
|
|
140
|
-
// apps/web/src/components/User/DocumentsView.jsx
|
|
141
|
-
import React from "react"
|
|
142
|
-
/** the very basic component **/
|
|
143
|
-
import UserDocumentsInput from "src/components/User/DocumentsInput.js"
|
|
144
|
-
|
|
145
|
-
function UserDocumentsView(input = {}) {
|
|
146
|
-
input = UserDocumentsInput.from(input)
|
|
147
|
-
if (empty(input)) {
|
|
148
|
-
throw new Error("Input data required in a format off UserDocumentsInput")
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return <div>
|
|
152
|
-
<h3>Documents</h3>
|
|
153
|
-
<ul>
|
|
154
|
-
{input.documents.map((d, i) => <li key={i}>{d.name}</li>)}
|
|
155
|
-
</ul>
|
|
156
|
-
</div>
|
|
157
|
-
}
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
### Apps locations
|
|
161
|
-
|
|
162
|
-
#### Core application
|
|
163
|
-
|
|
164
|
-
Core application s with the minimum stdin, stdout
|
|
165
|
-
- `src/*`
|
|
166
|
-
- `src/App.js`
|
|
167
|
-
- `bin/start.js`
|
|
168
|
-
- `package.json`
|
|
169
|
-
|
|
170
|
-
Core application might have own resository, for instance `@nan0web/app`.
|
|
171
|
-
|
|
172
|
-
#### CLI application
|
|
173
|
-
|
|
174
|
-
CLI application can utilize `blessed` or other CLI library for rich UI experience, compared to Core.
|
|
175
|
-
|
|
176
|
-
- `apps/cli/src/*`
|
|
177
|
-
- `apps/cli/bin/start.js`
|
|
178
|
-
- `apps/cli/package.json`
|
|
179
|
-
|
|
180
|
-
#### Web application
|
|
181
|
-
|
|
182
|
-
Web applications can utilize `react` or `lit` or other Web UI library for rich UI experience.
|
|
183
|
-
Most desired is `lit` to avoid using typescript or jsx.
|
|
184
|
-
|
|
185
|
-
- `apps/web/src/*`
|
|
186
|
-
- `apps/web/bin/start.js`
|
|
187
|
-
- `apps/web/package.json`
|
package/system1.md
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
# System Instructions for NaN•UI
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
NaN•UI is a Vanilla JavaScript UI framework designed to be platform-agnostic, working seamlessly in Node.js, browsers, and other environments that support ESM. The framework emphasizes minimal dependencies, clean class structures, and comprehensive testing with Vitest.
|
|
5
|
-
|
|
6
|
-
## Requirements
|
|
7
|
-
|
|
8
|
-
### JavaScript
|
|
9
|
-
1. **Pure Vanilla JS**: Only use vanilla JavaScript without platform-specific dependencies.
|
|
10
|
-
2. **Platform Abstraction**: Ensure the code works across different platforms.
|
|
11
|
-
3. **Minimal Dependencies**: Keep dependencies to a minimum.
|
|
12
|
-
4. **Class Structure**:
|
|
13
|
-
- **Order of Class Elements**:
|
|
14
|
-
- Static properties
|
|
15
|
-
- Properties
|
|
16
|
-
- Constructor
|
|
17
|
-
- Getters
|
|
18
|
-
- Setters
|
|
19
|
-
- Base functions
|
|
20
|
-
- Async functions
|
|
21
|
-
- Static base functions
|
|
22
|
-
- Static async functions
|
|
23
|
-
5. **Views**:
|
|
24
|
-
- Each view must have a separate file and test file (`View/AppView.js` and `View/AppView.test.js`).
|
|
25
|
-
6. **Components**:
|
|
26
|
-
- Each component must have a separate directory in `View/Component/*` or be registered from another directory with the following files:
|
|
27
|
-
- `Component.js`
|
|
28
|
-
- `Component.test.js`
|
|
29
|
-
- `ComponentInput.js`
|
|
30
|
-
- `index.js` (exporting the component and its input class).
|
|
31
|
-
|
|
32
|
-
### Vitest
|
|
33
|
-
- All tests must run with Vitest.
|
|
34
|
-
- Every model, component, and class must have its own test file to cover functionality in an isolated environment.
|
|
35
|
-
|
|
36
|
-
## Interfaces
|
|
37
|
-
|
|
38
|
-
### Views
|
|
39
|
-
- **Widgets**: Control elements that include a view and the ability to input data.
|
|
40
|
-
- **Output**: Data passed to the view in a specific format.
|
|
41
|
-
- **Input**: Data required by the application, which can be provided via command line or user input.
|
|
42
|
-
|
|
43
|
-
### Cross-Platform
|
|
44
|
-
- Extend basic UI with different apps (e.g., CLI, web).
|
|
45
|
-
- **Core Application**: Minimal stdin/stdout implementation.
|
|
46
|
-
- **CLI Application**: Utilizes libraries like `blessed` for rich CLI UI.
|
|
47
|
-
- **Web Application**: Utilizes libraries like `lit` for rich web UI.
|
|
48
|
-
|
|
49
|
-
## Code Structure
|
|
50
|
-
|
|
51
|
-
### Core Application
|
|
52
|
-
- **`src/App/Command/Args.js`**: Handles command arguments.
|
|
53
|
-
- **`src/App/Command/Message.js`**: Parses and processes command messages.
|
|
54
|
-
- **`src/App/Command/Options.js`**: Manages command options.
|
|
55
|
-
- **`src/App/Core/CCoreApp.js`**: Abstract base class for all apps.
|
|
56
|
-
- **`src/App/Core/UI.js`**: Abstract UI class to connect apps and widgets.
|
|
57
|
-
- **`src/App/Core/Widget.js`**: Abstract widget class with input/output capabilities.
|
|
58
|
-
|
|
59
|
-
### User Application
|
|
60
|
-
- **`src/App/User/UserApp.js`**: User-specific application logic.
|
|
61
|
-
- **`src/App/User/UserUI.js`**: Connects UserApp and View.
|
|
62
|
-
|
|
63
|
-
### Components
|
|
64
|
-
- **`src/Component/Process/Process.js`**: Process component with input handling.
|
|
65
|
-
- **`src/Component/Welcome/Welcome.js`**: Welcome component with user input handling.
|
|
66
|
-
|
|
67
|
-
### Views
|
|
68
|
-
- **`src/View/View.js`**: Main view class with rendering and input/output capabilities.
|
|
69
|
-
|
|
70
|
-
### Models
|
|
71
|
-
- **`src/Model/User/User.js`**: User model class.
|
|
72
|
-
|
|
73
|
-
### Utilities
|
|
74
|
-
- **`src/Frame/Frame.js`**: Handles frame rendering and formatting.
|
|
75
|
-
- **`src/InputMessage.js`**: Manages input messages.
|
|
76
|
-
- **`src/Locale.js`**: Handles localization and formatting.
|
|
77
|
-
- **`src/StdIn.js`**: Manages standard input.
|
|
78
|
-
- **`src/StdOut.js`**: Manages standard output.
|
|
79
|
-
|
|
80
|
-
## Testing
|
|
81
|
-
- **Vitest**: All tests are written using Vitest.
|
|
82
|
-
- **Test Files**: Each component, model, and class has a corresponding test file (e.g., `Component.test.js`, `Model.test.js`).
|
|
83
|
-
|
|
84
|
-
## Apps
|
|
85
|
-
- **CLI App**: Located in `apps/cli/src/`, handles command-line interface.
|
|
86
|
-
- **Web App**: Located in `apps/web/src/`, handles web interface.
|
|
87
|
-
|
|
88
|
-
## Example Usage
|
|
89
|
-
|
|
90
|
-
### CLI App
|
|
91
|
-
```javascript
|
|
92
|
-
import process from "node:process"
|
|
93
|
-
import { App, View, StdIn, StdOut, Frame, Component } from "@nan0web/ui"
|
|
94
|
-
|
|
95
|
-
async function main(argv) {
|
|
96
|
-
const app = new App.User.App({ argv })
|
|
97
|
-
const view = new View({
|
|
98
|
-
stdin: new StdIn({ processor: process.stdin }),
|
|
99
|
-
stdout: new StdOut({ processor: process.stdout }),
|
|
100
|
-
renderMethod: Frame.RenderMethod.VISIBLE,
|
|
101
|
-
})
|
|
102
|
-
view.register(Component.Welcome)
|
|
103
|
-
|
|
104
|
-
const ui = new App.User.UI(app, view)
|
|
105
|
-
await ui.process(argv)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
main(process.argv.slice(2)).then(() => {
|
|
109
|
-
process.exit(0)
|
|
110
|
-
}).catch(err => {
|
|
111
|
-
console.error("Error:", err)
|
|
112
|
-
process.exit(1)
|
|
113
|
-
})
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### Web App
|
|
117
|
-
```javascript
|
|
118
|
-
import React from "react"
|
|
119
|
-
import UserDocumentsInput from "src/components/User/DocumentsInput.js"
|
|
120
|
-
|
|
121
|
-
function UserDocumentsView(input = {}) {
|
|
122
|
-
input = UserDocumentsInput.from(input)
|
|
123
|
-
if (empty(input)) {
|
|
124
|
-
throw new Error("Input data required in a format off UserDocumentsInput")
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return <div>
|
|
128
|
-
<h3>Documents</h3>
|
|
129
|
-
<ul>
|
|
130
|
-
{input.documents.map((d, i) => <li key={i}>{d.name}</li>)}
|
|
131
|
-
</ul>
|
|
132
|
-
</div>
|
|
133
|
-
}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
## Conclusion
|
|
137
|
-
NaN•UI provides a robust, platform-agnostic framework for building UIs with minimal dependencies. The code is structured to ensure clarity, maintainability, and comprehensive test coverage. By following the outlined requirements and structure, developers can build scalable and maintainable UI components and applications.
|
package/task.md
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
Інструкція для наступних кроків
|
|
2
|
-
|
|
3
|
-
## [+] Написання тестів для всіх класів
|
|
4
|
-
|
|
5
|
-
План дій:
|
|
6
|
-
- **Створити тестові файли** для кожного класу у тій самій директорії з суфіксом `.test.js`:
|
|
7
|
-
|
|
8
|
-
```
|
|
9
|
-
src/
|
|
10
|
-
├── core/
|
|
11
|
-
│ ├── Form/
|
|
12
|
-
│ │ ├── Form.test.js
|
|
13
|
-
│ │ ├── Message.test.js
|
|
14
|
-
│ │ └── Input.test.js
|
|
15
|
-
│ ├── Message/
|
|
16
|
-
│ │ ├── InputMessage.test.js
|
|
17
|
-
│ │ ├── Message.test.js
|
|
18
|
-
│ │ ├── OutputMessage.test.js
|
|
19
|
-
│ ├── InputAdapter.test.js
|
|
20
|
-
│ ├── OutputAdapter.test.js
|
|
21
|
-
│ └── Stream.test.js
|
|
22
|
-
```
|
|
23
|
-
- **Використовувати `node:test`** для тестування базових класів (не `.jsx` компонентів)
|
|
24
|
-
|
|
25
|
-
- **Тестувати всі можливі випадки**:
|
|
26
|
-
|
|
27
|
-
- Конструктори з різними типами вхідних даних
|
|
28
|
-
- Методи `from()` для нормалізації
|
|
29
|
-
- Роботу з обов'язковими/необов'язковими полями
|
|
30
|
-
- Валідацію форм
|
|
31
|
-
- Поведінку потоків
|
|
32
|
-
- **Використовувати асерти**:
|
|
33
|
-
```js
|
|
34
|
-
import { describe, it } from "node:test"
|
|
35
|
-
import { strict as assert } from "node:assert"
|
|
36
|
-
|
|
37
|
-
describe("ClassName", () => {
|
|
38
|
-
it("should create instance", () => {
|
|
39
|
-
// Ваш тест
|
|
40
|
-
})
|
|
41
|
-
})
|
|
42
|
-
```
|
|
43
|
-
- **Запуск тестів**:
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
npm test
|
|
47
|
-
# або
|
|
48
|
-
node --test --experimental-worker
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## [+] Написання прикладів використання (playground)
|
|
52
|
-
|
|
53
|
-
План дій:
|
|
54
|
-
- **Створити директорію** `playground/` у корені проекту
|
|
55
|
-
|
|
56
|
-
- **Створити окремі файли** для різних сценаріїв:
|
|
57
|
-
|
|
58
|
-
```
|
|
59
|
-
playground/
|
|
60
|
-
├── form-basic.js # Базова форма
|
|
61
|
-
├── form-advanced.js # Складна форма з різними типами полів
|
|
62
|
-
├── stream-basic.js # Базовий потік даних
|
|
63
|
-
├── stream-interactive.js # Інтерактивний потік
|
|
64
|
-
├── error-handling.js # Обробка помилок
|
|
65
|
-
└── integration.js # Інтеграція з реальним додатком
|
|
66
|
-
```
|
|
67
|
-
- **Кожен приклад має містити**:
|
|
68
|
-
|
|
69
|
-
- Імпорти необхідних класів
|
|
70
|
-
- Створення екземплярів
|
|
71
|
-
- Налаштування обробників подій
|
|
72
|
-
- Приклади використання
|
|
73
|
-
- **Додати інструкцію** у `README.md` як запускати приклади:
|
|
74
|
-
```bash
|
|
75
|
-
node playground/form-basic.js
|
|
76
|
-
```
|
|
77
|
-
- **Перевірити працездатність** всіх прикладів
|
|
78
|
-
|
|
79
|
-
## [+] Написання JSDoc для всіх полів і функцій
|
|
80
|
-
|
|
81
|
-
План дій:
|
|
82
|
-
- **Пройтися по всім файлам** і додати JSDoc коментарі до:
|
|
83
|
-
|
|
84
|
-
**Для класів:**
|
|
85
|
-
```js
|
|
86
|
-
/**
|
|
87
|
-
* Опис класу
|
|
88
|
-
* @class
|
|
89
|
-
* @extends {BaseClass}
|
|
90
|
-
* @example
|
|
91
|
-
* // Приклад використання
|
|
92
|
-
* const instance = new ClassName()
|
|
93
|
-
*/
|
|
94
|
-
```
|
|
95
|
-
**Для властивостей:**
|
|
96
|
-
```js
|
|
97
|
-
/** @type {string} Опис властивості */
|
|
98
|
-
propertyName
|
|
99
|
-
```
|
|
100
|
-
**Для конструкторів:**
|
|
101
|
-
```js
|
|
102
|
-
/**
|
|
103
|
-
* Створює екземпляр класу
|
|
104
|
-
* @param {Object} [props] - Властивості екземпляра
|
|
105
|
-
* @param {string} [props.name=""] - Ім'я елемента
|
|
106
|
-
* @param {boolean} [props.active=false] - Чи активний елемент
|
|
107
|
-
*/
|
|
108
|
-
constructor(props = {}) { ... }
|
|
109
|
-
```
|
|
110
|
-
**Для методів:**
|
|
111
|
-
```js
|
|
112
|
-
/**
|
|
113
|
-
* Опис методу
|
|
114
|
-
* @param {string} paramName - Опис параметра
|
|
115
|
-
* @returns {ReturnType} Опис поверненого значення
|
|
116
|
-
* @throws {Error} Опис можливих помилок
|
|
117
|
-
*/
|
|
118
|
-
methodName(paramName) { ... }
|
|
119
|
-
```
|
|
120
|
-
- **Використовувати англійську мову** для всіх коментарів
|
|
121
|
-
|
|
122
|
-
- **Перевірити сумісність** з TypeScript деклараціями (використання `@typedef`, `@template` тощо)
|
|
123
|
-
|
|
124
|
-
- **Запуск `tsc --emitDeclarationOnly`** для перевірки генерації `.d.ts` файлів
|
|
125
|
-
|
|
126
|
-
## [ ] Написання README.md
|
|
127
|
-
|
|
128
|
-
Структура README.md:
|
|
129
|
-
- **Заголовок та короткий опис**
|
|
130
|
-
|
|
131
|
-
```
|
|
132
|
-
# @nan0web/ui
|
|
133
|
-
Агностичний UI фреймворк для багатошарових додатків.
|
|
134
|
-
Одна логіка, багато інтерфейсів.
|
|
135
|
-
```
|
|
136
|
-
- **Функціональність**
|
|
137
|
-
|
|
138
|
-
- Базові повідомлення: `InputMessage`, `OutputMessage`
|
|
139
|
-
- Форми та їх валідація
|
|
140
|
-
- Потокові операції
|
|
141
|
-
- Абстрактні адаптери
|
|
142
|
-
- **Встановлення**
|
|
143
|
-
|
|
144
|
-
```bash
|
|
145
|
-
npm install @nan0web/ui
|
|
146
|
-
```
|
|
147
|
-
- **Приклади використання**
|
|
148
|
-
|
|
149
|
-
```js
|
|
150
|
-
import { InputMessage, OutputMessage } from '@nan0web/ui'
|
|
151
|
-
const input = InputMessage.from({ value: 'Hello' })
|
|
152
|
-
const output = OutputMessage.from({ content: ['Hello World'] })
|
|
153
|
-
```
|
|
154
|
-
- **Основні класи**
|
|
155
|
-
|
|
156
|
-
- `UIMessage` - базовий клас для всіх повідомлень
|
|
157
|
-
- `InputMessage` - для отримання даних від користувача
|
|
158
|
-
- `OutputMessage` - для відображення даних
|
|
159
|
-
- `UIForm` - для роботи з формами
|
|
160
|
-
- `UIStream` - для асинхронних операцій
|
|
161
|
-
- **API Документація**
|
|
162
|
-
|
|
163
|
-
Посилання на файли з JSDoc
|
|
164
|
-
- **Приклади**
|
|
165
|
-
|
|
166
|
-
Посилання на директорію `playground/`
|
|
167
|
-
- **Запуск тестів**
|
|
168
|
-
|
|
169
|
-
```bash
|
|
170
|
-
npm test
|
|
171
|
-
```
|
|
172
|
-
- **Ліцензія**
|
|
173
|
-
|
|
174
|
-
```
|
|
175
|
-
MIT License
|
|
176
|
-
```
|
|
177
|
-
Загальна послідовність дій:
|
|
178
|
-
- **Спочатку напишіть тести** - це допоможе зрозуміти, чи все працює як очікувалось
|
|
179
|
-
- **Потім створіть приклади** - вони стануть частиною документації
|
|
180
|
-
- **Додайте JSDoc коментарі** - природно зробити це під час перегляду коду
|
|
181
|
-
- **Напишіть README.md** - використовуючи матеріали з попередніх кроків
|
package/tsconfig.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "esnext",
|
|
4
|
-
"module": "nodenext",
|
|
5
|
-
"lib": ["esnext"],
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"declarationMap": false,
|
|
8
|
-
"emitDeclarationOnly": true,
|
|
9
|
-
"outDir": "./types",
|
|
10
|
-
"rootDir": "./src",
|
|
11
|
-
"strict": true,
|
|
12
|
-
"esModuleInterop": true,
|
|
13
|
-
"skipLibCheck": true,
|
|
14
|
-
"forceConsistentCasingInFileNames": true,
|
|
15
|
-
"moduleResolution": "nodenext",
|
|
16
|
-
"allowSyntheticDefaultImports": true,
|
|
17
|
-
"noImplicitAny": false,
|
|
18
|
-
"allowJs": true,
|
|
19
|
-
"checkJs": true
|
|
20
|
-
},
|
|
21
|
-
"include": ["src/**/*"],
|
|
22
|
-
"exclude": ["node_modules", "src/**/*.test.js", "src/README.md.js"]
|
|
23
|
-
}
|
package/vitest.config.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import process from "node:process"
|
|
2
|
-
import { defineConfig } from "vitest/config"
|
|
3
|
-
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
test: {
|
|
6
|
-
sourcemap: true,
|
|
7
|
-
environment: "node",
|
|
8
|
-
cache: false,
|
|
9
|
-
root: process.cwd(),
|
|
10
|
-
coverage: {
|
|
11
|
-
provider: "v8",
|
|
12
|
-
},
|
|
13
|
-
exclude: [
|
|
14
|
-
"apps/**",
|
|
15
|
-
"node_modules/**",
|
|
16
|
-
],
|
|
17
|
-
isolate: false,
|
|
18
|
-
// Try to force inline source maps for best debugging
|
|
19
|
-
// (Vite will use inline source maps for dev by default)
|
|
20
|
-
},
|
|
21
|
-
resolve: {
|
|
22
|
-
alias: {
|
|
23
|
-
"@": "/src",
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
})
|