vasille 3.1.0 → 3.2.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/README.md +5 -4
- package/lib/core/core.js +6 -12
- package/lib/models/array-model.js +5 -0
- package/lib/models/map-model.js +1 -0
- package/lib/models/set-model.js +1 -0
- package/lib/node/node.js +2 -0
- package/lib/runner/web/binding/class.js +2 -0
- package/lib/runner/web/binding/style.js +1 -0
- package/lib/runner/web/runner.js +3 -0
- package/lib/value/expression.js +1 -0
- package/lib/value/pointer.js +1 -0
- package/package.json +2 -2
- package/types/core/core.d.ts +0 -5
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* [Installation](#installation)
|
|
12
12
|
* [How to use Vasille](#how-to-use-vasille)
|
|
13
13
|
* [How SAFE is Vasille](#how-safe-is-vasille)
|
|
14
|
-
* [How
|
|
14
|
+
* [How INTUITIVE is Vasille](#how-intuitive-is-vasille)
|
|
15
15
|
* [How POWERFUL is Vasille](#how-powerful-is-vasille)
|
|
16
16
|
* [Road Map](#road-map)
|
|
17
17
|
|
|
@@ -44,6 +44,7 @@ $ npx degit vasille-js/example-javascript my-project
|
|
|
44
44
|
|
|
45
45
|
### Full documentation:
|
|
46
46
|
* [Learn `Vasille` in 5 minutes](https://github.com/vasille-js/vasille-js/blob/v3/doc/V3-API.md)
|
|
47
|
+
* [Vasille Router Documentation](https://github.com/vasille-js/vasille-js/blob/v3/doc/Router-API.md)
|
|
47
48
|
|
|
48
49
|
### Examples
|
|
49
50
|
* [TypeScript Example](https://github.com/vasille-js/example-typescript)
|
|
@@ -60,7 +61,7 @@ The safe of your application is ensured by
|
|
|
60
61
|
* `strong typing` makes your javascript/typescript code safe as C++ code.
|
|
61
62
|
All entities of `vasille` core library are strongly typed, including:
|
|
62
63
|
* data fields & properties.
|
|
63
|
-
* computed properties (function parameters
|
|
64
|
+
* computed properties (function parameters and result).
|
|
64
65
|
* methods.
|
|
65
66
|
* events (defined handlers & event emit).
|
|
66
67
|
* DOM events & DOM operation (attributing, styling, etc.).
|
|
@@ -68,7 +69,7 @@ All entities of `vasille` core library are strongly typed, including:
|
|
|
68
69
|
* references to children.
|
|
69
70
|
* No asynchronous code, when the line of code is executed, the DOM and reactive things are already synced.
|
|
70
71
|
|
|
71
|
-
## How
|
|
72
|
+
## How INTUITIVE is Vasille
|
|
72
73
|
|
|
73
74
|
There is the "Hello World":
|
|
74
75
|
```typescript jsx
|
|
@@ -105,7 +106,7 @@ All of these are supported:
|
|
|
105
106
|
* [x] Develop the `Vasille Babel Plugin`.
|
|
106
107
|
* [x] `100%` Test Coverage fot babel plugin.
|
|
107
108
|
* [x] Add CSS support (define styles in components).
|
|
108
|
-
* [
|
|
109
|
+
* [x] Add router.
|
|
109
110
|
* [ ] Add SSR (server side rendering).
|
|
110
111
|
* [ ] Develop tools extension for debugging.
|
|
111
112
|
|
package/lib/core/core.js
CHANGED
|
@@ -10,11 +10,6 @@ import { OwningPointer, Pointer } from "../value/pointer.js";
|
|
|
10
10
|
export class Reactive extends Destroyable {
|
|
11
11
|
constructor(input) {
|
|
12
12
|
super();
|
|
13
|
-
/**
|
|
14
|
-
* A list of user-defined values
|
|
15
|
-
* @type {Set}
|
|
16
|
-
*/
|
|
17
|
-
this._watch = new Set();
|
|
18
13
|
/**
|
|
19
14
|
* A list of user-defined bindings
|
|
20
15
|
* @type {Set}
|
|
@@ -30,7 +25,7 @@ export class Reactive extends Destroyable {
|
|
|
30
25
|
*/
|
|
31
26
|
ref(value, name) {
|
|
32
27
|
const ref = new Reference(value);
|
|
33
|
-
this.
|
|
28
|
+
this.bindings.add(ref);
|
|
34
29
|
if (name) {
|
|
35
30
|
this.addState("ref", name, ref);
|
|
36
31
|
}
|
|
@@ -43,7 +38,7 @@ export class Reactive extends Destroyable {
|
|
|
43
38
|
*/
|
|
44
39
|
forward(value, name) {
|
|
45
40
|
const mirror = new Pointer(value);
|
|
46
|
-
this.
|
|
41
|
+
this.bindings.add(mirror);
|
|
47
42
|
if (name) {
|
|
48
43
|
this.addState("forward", name, mirror);
|
|
49
44
|
}
|
|
@@ -56,7 +51,8 @@ export class Reactive extends Destroyable {
|
|
|
56
51
|
*/
|
|
57
52
|
own(value, name) {
|
|
58
53
|
const pointer = new OwningPointer(value);
|
|
59
|
-
this.
|
|
54
|
+
this.bindings.add(pointer);
|
|
55
|
+
/* istanbul ignore else */
|
|
60
56
|
if (name) {
|
|
61
57
|
this.addState("own", name, pointer);
|
|
62
58
|
}
|
|
@@ -81,7 +77,7 @@ export class Reactive extends Destroyable {
|
|
|
81
77
|
* @param values
|
|
82
78
|
*/
|
|
83
79
|
watch(func, values) {
|
|
84
|
-
this.
|
|
80
|
+
this.bindings.add(new Expression(func, values));
|
|
85
81
|
}
|
|
86
82
|
/**
|
|
87
83
|
* Creates a computed value
|
|
@@ -92,7 +88,7 @@ export class Reactive extends Destroyable {
|
|
|
92
88
|
*/
|
|
93
89
|
expr(func, values, name) {
|
|
94
90
|
const res = new Expression(func, values);
|
|
95
|
-
this.
|
|
91
|
+
this.bindings.add(res);
|
|
96
92
|
if (name) {
|
|
97
93
|
this.addState("expr", name, res);
|
|
98
94
|
}
|
|
@@ -110,8 +106,6 @@ export class Reactive extends Destroyable {
|
|
|
110
106
|
}
|
|
111
107
|
destroy() {
|
|
112
108
|
super.destroy();
|
|
113
|
-
this._watch.forEach(value => value.destroy());
|
|
114
|
-
this._watch.clear();
|
|
115
109
|
this.bindings.forEach(binding => binding.destroy());
|
|
116
110
|
this.bindings.clear();
|
|
117
111
|
this.onDestroy?.();
|
|
@@ -27,9 +27,11 @@ export class ArrayModel extends Array {
|
|
|
27
27
|
*/
|
|
28
28
|
fill(value, start, end) {
|
|
29
29
|
this.passive = true;
|
|
30
|
+
/* istanbul ignore else */
|
|
30
31
|
if (!start) {
|
|
31
32
|
start = 0;
|
|
32
33
|
}
|
|
34
|
+
/* istanbul ignore else */
|
|
33
35
|
if (!end) {
|
|
34
36
|
end = this.length;
|
|
35
37
|
}
|
|
@@ -48,6 +50,7 @@ export class ArrayModel extends Array {
|
|
|
48
50
|
pop() {
|
|
49
51
|
this.passive = true;
|
|
50
52
|
const v = super.pop();
|
|
53
|
+
/* istanbul ignore else */
|
|
51
54
|
if (v !== undefined) {
|
|
52
55
|
this.listener.emitRemoved(v, v);
|
|
53
56
|
}
|
|
@@ -75,6 +78,7 @@ export class ArrayModel extends Array {
|
|
|
75
78
|
shift() {
|
|
76
79
|
this.passive = true;
|
|
77
80
|
const v = super.shift();
|
|
81
|
+
/* istanbul ignore else */
|
|
78
82
|
if (v !== undefined) {
|
|
79
83
|
this.listener.emitRemoved(v, v);
|
|
80
84
|
}
|
|
@@ -95,6 +99,7 @@ export class ArrayModel extends Array {
|
|
|
95
99
|
const before = this[start + deleteCount];
|
|
96
100
|
for (let i = 0; i < deleteCount; i++) {
|
|
97
101
|
const index = start + deleteCount - i - 1;
|
|
102
|
+
/* istanbul ignore else */
|
|
98
103
|
if (this[index] !== undefined) {
|
|
99
104
|
this.listener.emitRemoved(this[index], this[index]);
|
|
100
105
|
}
|
package/lib/models/map-model.js
CHANGED
package/lib/models/set-model.js
CHANGED
package/lib/node/node.js
CHANGED
|
@@ -33,6 +33,7 @@ export class Root extends Reactive {
|
|
|
33
33
|
let first;
|
|
34
34
|
for (const child of this.children) {
|
|
35
35
|
first = child.findFirstChild();
|
|
36
|
+
/* istanbul ignore else */
|
|
36
37
|
if (first) {
|
|
37
38
|
break;
|
|
38
39
|
}
|
|
@@ -322,6 +323,7 @@ export class DebugNode extends Fragment {
|
|
|
322
323
|
super(input, runner, ":debug");
|
|
323
324
|
}
|
|
324
325
|
destroy() {
|
|
326
|
+
/* istanbul ignore else */
|
|
325
327
|
if (this.handler) {
|
|
326
328
|
this.input.text.off(this.handler);
|
|
327
329
|
}
|
|
@@ -27,10 +27,12 @@ export class DynamicalClassBinding extends Binding {
|
|
|
27
27
|
super(value);
|
|
28
28
|
this.current = "";
|
|
29
29
|
this.init((value) => {
|
|
30
|
+
/* istanbul ignore else */
|
|
30
31
|
if (this.current != value) {
|
|
31
32
|
if (this.current.length) {
|
|
32
33
|
removeClass(node, this.current);
|
|
33
34
|
}
|
|
35
|
+
/* istanbul ignore else */
|
|
34
36
|
if (value.length) {
|
|
35
37
|
addClass(node, value);
|
|
36
38
|
}
|
|
@@ -23,6 +23,7 @@ export class StyleBinding extends Binding {
|
|
|
23
23
|
constructor(node, name, value) {
|
|
24
24
|
super(value);
|
|
25
25
|
this.init(value => {
|
|
26
|
+
/* istanbul ignore else */
|
|
26
27
|
if (node.element instanceof HTMLElement) {
|
|
27
28
|
node.element.style.setProperty(name, stringifyStyleValue(value));
|
|
28
29
|
}
|
package/lib/runner/web/runner.js
CHANGED
|
@@ -65,7 +65,9 @@ export class Tag extends AbstractTag {
|
|
|
65
65
|
this.register(new AttributeBinding(this, name, value));
|
|
66
66
|
}
|
|
67
67
|
else {
|
|
68
|
+
/* istanbul ignore else */
|
|
68
69
|
if (typeof value === "boolean") {
|
|
70
|
+
/* istanbul ignore else */
|
|
69
71
|
if (value) {
|
|
70
72
|
this.node.setAttribute(name, "");
|
|
71
73
|
}
|
|
@@ -140,6 +142,7 @@ export class Runner {
|
|
|
140
142
|
}
|
|
141
143
|
insertBefore(node, before) {
|
|
142
144
|
const parent = before.parentElement;
|
|
145
|
+
/* istanbul ignore else */
|
|
143
146
|
if (parent) {
|
|
144
147
|
parent.insertBefore(node, before);
|
|
145
148
|
}
|
package/lib/value/expression.js
CHANGED
package/lib/value/pointer.js
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vasille",
|
|
3
|
-
"description": "The first Developer eXperience
|
|
3
|
+
"description": "The first Developer eXperience Orientated front-end framework (core library).",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
|
-
"version": "3.1
|
|
6
|
+
"version": "3.2.1",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
9
|
"types": "./types/index.d.ts",
|
package/types/core/core.d.ts
CHANGED
|
@@ -8,11 +8,6 @@ import { Pointer } from "../value/pointer.js";
|
|
|
8
8
|
* @extends Destroyable
|
|
9
9
|
*/
|
|
10
10
|
export declare class Reactive<T extends object = object> extends Destroyable {
|
|
11
|
-
/**
|
|
12
|
-
* A list of user-defined values
|
|
13
|
-
* @type {Set}
|
|
14
|
-
*/
|
|
15
|
-
private _watch;
|
|
16
11
|
/**
|
|
17
12
|
* A list of user-defined bindings
|
|
18
13
|
* @type {Set}
|