vasille 2.3.8 → 2.3.9
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/README.md +220 -0
- package/package.json +2 -1
package/README.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Vasille
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
`Vasille` core library is frontend solution for `safe`, `performant` & `powerful` applications.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/vasille)
|
|
8
|
+
|
|
9
|
+
## Table of content
|
|
10
|
+
|
|
11
|
+
* [Installation](#installation)
|
|
12
|
+
* [How to use Vasille](#how-to-use-vasille)
|
|
13
|
+
* [How SAFE is Vasille](#how-safe-is-vasille)
|
|
14
|
+
* [How SIMPLE is Vasille](#how-fast-is-vasille)
|
|
15
|
+
* [How POWERFUL is Vasille](#how-powerful-is-vasille)
|
|
16
|
+
* [Best Practices](#best-practices)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
<hr>
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
npm install vasille --save
|
|
25
|
+
npm install vasille-less --save
|
|
26
|
+
npm install vasille-magic --save
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## How to use Vasille
|
|
30
|
+
|
|
31
|
+
There are several modes to use Vasille.
|
|
32
|
+
|
|
33
|
+
### Documentation for beginners (how to create the first project step by step):
|
|
34
|
+
* [`Vasille Magic` - perfect for you - `highest-level`](https://gitlab.com/vasille-js/vasille-js/-/blob/v2/doc/magic/GetStarted.md)
|
|
35
|
+
* [`Vasille Less Library` - no transcriber usage - `high-level`](https://gitlab.com/vasille-js/vasille-js/-/blob/v2/doc/less/GetStarted.md)
|
|
36
|
+
* [`Vasille Core Library` - the hard way - `low-level`](https://gitlab.com/vasille-js/vasille-js/-/blob/v2/doc/core/GetStarted.md)
|
|
37
|
+
|
|
38
|
+
### Full documentation:
|
|
39
|
+
* [`Vasille Magic API`- compiler writes for you - `highest-level`](https://gitlab.com/vasille-js/vasille-js/-/blob/v2/doc/magic/Vasille-Magic-API.md)
|
|
40
|
+
* [`Vasille Less Library API`- write less do more - `high-level`](https://gitlab.com/vasille-js/vasille-js/-/blob/v2/doc/less/Vasille-Less-Library-API.md)
|
|
41
|
+
* [`Vasille Core Library API`- write anything - `low-level`](https://gitlab.com/vasille-js/vasille-js/-/blob/v2/doc/core/Vasille-Core-Library-API.md)
|
|
42
|
+
|
|
43
|
+
### Getting ready be example
|
|
44
|
+
* [TypeScript Example](https://gitlab.com/vasille-js/learning/vasille-ts-example)
|
|
45
|
+
* [JavaScript Example (Vasille Magic not supported)](https://gitlab.com/vasille-js/learning/vasille-js-example)
|
|
46
|
+
|
|
47
|
+
<hr>
|
|
48
|
+
|
|
49
|
+
## How SAFE is Vasille
|
|
50
|
+
|
|
51
|
+
The safe of your application is ensured by
|
|
52
|
+
* `100%` coverage of `vasille` code by unit tests.
|
|
53
|
+
Each function, each branch is working as designed.
|
|
54
|
+
* `strong typing` makes your javascript/typescript code safe as C++ code.
|
|
55
|
+
All entities of `vasille` core library are strongly typed, including:
|
|
56
|
+
* data fields & properties.
|
|
57
|
+
* computed properties (function parameters & result).
|
|
58
|
+
* methods.
|
|
59
|
+
* events (defined handlers & event emit).
|
|
60
|
+
* DOM events & DOM operation (attributing, styling, etc.).
|
|
61
|
+
* slots of component.
|
|
62
|
+
* references to children.
|
|
63
|
+
* What you write is what you get. There are no hidden operations, you can control everything.
|
|
64
|
+
* No asynchronous code, when the line of code is executed, the DOM and reactive things are already synced.
|
|
65
|
+
|
|
66
|
+
## How SIMPLE is Vasille
|
|
67
|
+
|
|
68
|
+
Can you detect the correct order of console logs in the next code snippet:
|
|
69
|
+
```javascript
|
|
70
|
+
import logo from './logo.svg';
|
|
71
|
+
import './App.css';
|
|
72
|
+
import {useEffect} from 'react';
|
|
73
|
+
|
|
74
|
+
function C1 ({children}) {
|
|
75
|
+
console.log(1);
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
console.log(2);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return <div>{children}</div>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function C2 () {
|
|
85
|
+
console.log(3);
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
console.log(4);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
return <div></div>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function App() {
|
|
95
|
+
return <C1>
|
|
96
|
+
<C2/>
|
|
97
|
+
</C1>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export default App;
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
So let's see the same example using Vasille:
|
|
104
|
+
```typescript jsx
|
|
105
|
+
interface Options extends FragmentOptions {
|
|
106
|
+
slot?: () => void;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const C1 : VFragment<Options> = ({slot}) => {
|
|
110
|
+
console.log(1);
|
|
111
|
+
|
|
112
|
+
<div>
|
|
113
|
+
<vxSlot model={slot} />
|
|
114
|
+
</div>;
|
|
115
|
+
|
|
116
|
+
console.log(2);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const C2: VFragment = () => {
|
|
120
|
+
console.log(3);
|
|
121
|
+
|
|
122
|
+
<div></div>;
|
|
123
|
+
|
|
124
|
+
console.log(4);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const App: VApp = () => {
|
|
128
|
+
<C1>
|
|
129
|
+
<C2/>
|
|
130
|
+
</C1>
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The `C2` function is sent to `C1` as function,
|
|
135
|
+
so it will be called after `console.log(1)` and before `console.log(2)`.
|
|
136
|
+
No return is present in this case,
|
|
137
|
+
then construction like `for` & `if` can be used in place of `[].map()` and ternary operator.
|
|
138
|
+
The component function is called once, no recalls on component update.
|
|
139
|
+
|
|
140
|
+
## How POWERFUL is Vasille
|
|
141
|
+
|
|
142
|
+
The secret of `Vasille` is a good task decomposition. The core library is composed of
|
|
143
|
+
an effective reactive module and a DOM generation engine based on it.
|
|
144
|
+
|
|
145
|
+
<hr>
|
|
146
|
+
|
|
147
|
+
### Reactivity Module
|
|
148
|
+
|
|
149
|
+
Reactivity module is used to create a model of data. It can contain self-updating values,
|
|
150
|
+
forward-only shared data. Reactivity of objects/fields can be disabled/enabled manually.
|
|
151
|
+
|
|
152
|
+

|
|
153
|
+
|
|
154
|
+
* `Destroyable` is an entity which has a custom destructor.
|
|
155
|
+
* `IValue<T>` is a common interface for any value container, with next members:
|
|
156
|
+
* `get $` gets the encapsulated value.
|
|
157
|
+
* `set $` manually update the encapsulated value, if enabled triggers updating of all linked data.
|
|
158
|
+
* `disable` disables the reactivity.
|
|
159
|
+
* `enable` enables the reactivity and triggers updating of all linked data.
|
|
160
|
+
* `Reference<T>` contains a value of type `T`.
|
|
161
|
+
* `Mirror<T>` syncs self value with another `IValue` container, can be used to share a value forward-only.
|
|
162
|
+
* `Pointer<T>` same as `Mirror`, but it can switch between `IValue` target anytime.
|
|
163
|
+
* `Expression<ReturnType, Args...>` is a self-updating value.
|
|
164
|
+
* `Reactive` is a reactive object which can have multiple reactive fields, emit/receive events/signals.
|
|
165
|
+
|
|
166
|
+
<hr>
|
|
167
|
+
|
|
168
|
+
### DOM Generation Engine
|
|
169
|
+
|
|
170
|
+
DOM Generation Engine is used to describe a virtual DOM of reactive fragments,
|
|
171
|
+
which will be reflected into a browser DOM and keep up to date it.
|
|
172
|
+
|
|
173
|
+

|
|
174
|
+
|
|
175
|
+
* `Fragment` describes a virtual DOM node, which has siblings, children, parent & slots.
|
|
176
|
+
* `TextNode` reflects a `Text` node.
|
|
177
|
+
* `INode` reflects a `Element` node.
|
|
178
|
+
* `Tag` reflect a self created `Element` node.
|
|
179
|
+
* `Extension` reflects an existing `Element` node.
|
|
180
|
+
* `Component` reflects a `Element` node created by a `Tag` child.
|
|
181
|
+
* `AppNode` is root of a `Vasille` application, can be used to create applications in application.
|
|
182
|
+
* `App` is root of a definitive `Vasille` application.
|
|
183
|
+
* `DebugNode` reflects a `Comment` node, useful for debug.
|
|
184
|
+
* `Watch` recompose children nodes on model value change.
|
|
185
|
+
* `RepeatNode` creates multiples children nodes using the same code multiple time.
|
|
186
|
+
* `BaseView` represent a view in context of MVC (Model-View-Controller).
|
|
187
|
+
* `ObjectView` repeats slot content for each value of `ObjectModel`.
|
|
188
|
+
* `MapView` repeats slot content for each `MapModel` value.
|
|
189
|
+
* `SetView` repeats slot content for each `SetModel` value.
|
|
190
|
+
* `ArrayView` repeats slot content for each `ArrayModel` value respecting its order.
|
|
191
|
+
|
|
192
|
+
<hr>
|
|
193
|
+
|
|
194
|
+
### CDN
|
|
195
|
+
|
|
196
|
+
```html
|
|
197
|
+
<script src="https://unpkg.com/vasille"></script>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Best Practices applicable to Vasille Core Library
|
|
201
|
+
|
|
202
|
+
* [Reactive Object Practice](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/reactive-object.ts)
|
|
203
|
+
* [Application](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/application.ts)
|
|
204
|
+
* [Application in Application (Micro frontends)](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/application-in-application.ts)
|
|
205
|
+
* [Signaling](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/signaling.ts)
|
|
206
|
+
* [Forward Only Data Exchange](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/forward-only.ts)
|
|
207
|
+
* [Absolute, Relative & Auto Values](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/auto-value.ts)
|
|
208
|
+
* [Signaling Intercepting](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/singaling-intercepting.ts)
|
|
209
|
+
* [Debugging](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/debugging.ts)
|
|
210
|
+
* [Fragment vs Component](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/fragment-component.ts)
|
|
211
|
+
* [Extensions](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/extension.ts)
|
|
212
|
+
* [Model-View-Controller](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/model-view-controller.ts)
|
|
213
|
+
|
|
214
|
+
## Questions
|
|
215
|
+
|
|
216
|
+
If you have questions, feel free to contact the maintainer of the project:
|
|
217
|
+
|
|
218
|
+
* [Author's Email](mailto:vas.lixcode@gmail.com)
|
|
219
|
+
* [Author's Telegram](https://t.me/lixcode)
|
|
220
|
+
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Vasille - Safe. Simple. Powerful.",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
|
-
"version": "2.3.
|
|
6
|
+
"version": "2.3.9",
|
|
7
7
|
"exports": {
|
|
8
8
|
"import": "./lib/index.js",
|
|
9
9
|
"browser": "./lib/index.js",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"unpkg": "./cdn/es2015.js",
|
|
14
14
|
"scripts": {
|
|
15
|
+
"prepack": "cp -f ../README.md ./README.md",
|
|
15
16
|
"prettier": "npx prettier src test --check",
|
|
16
17
|
"build": "tsc --build tsconfig-build.json",
|
|
17
18
|
"build-node": "tsc --build tsconfig-build-node.json",
|