vasille 3.0.0 → 3.1.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/README.md +6 -7
- package/lib/core/core.js +35 -13
- package/lib/core/ivalue.js +1 -2
- package/lib/index.js +20 -22
- package/lib/models/array-model.js +1 -1
- package/lib/models/map-model.js +2 -2
- package/lib/models/set-model.js +2 -2
- package/lib/node/app.js +7 -7
- package/lib/node/node.js +45 -360
- package/lib/node/watch.js +5 -6
- package/lib/{binding → runner/web/binding}/attribute.js +1 -1
- package/lib/{binding → runner/web/binding}/binding.js +1 -1
- package/lib/{binding → runner/web/binding}/class.js +1 -1
- package/lib/{binding → runner/web/binding}/style.js +1 -1
- package/lib/runner/web/runner.js +162 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/value/expression.js +2 -2
- package/lib/value/pointer.js +7 -12
- package/lib/value/reference.js +2 -2
- package/lib/views/array-view.js +1 -1
- package/lib/views/base-view.js +3 -3
- package/lib/views/map-view.js +1 -1
- package/lib/views/repeat-node.js +5 -6
- package/lib/views/set-view.js +3 -3
- package/package.json +37 -27
- package/types/core/core.d.ts +14 -8
- package/types/index.d.ts +22 -24
- package/types/models/array-model.d.ts +2 -2
- package/types/models/map-model.d.ts +2 -2
- package/types/models/model.d.ts +2 -2
- package/types/models/set-model.d.ts +2 -2
- package/types/node/app.d.ts +8 -7
- package/types/node/node.d.ts +49 -144
- package/types/node/runner.d.ts +10 -0
- package/types/node/watch.d.ts +7 -6
- package/types/{binding → runner/web/binding}/attribute.d.ts +4 -4
- package/types/{binding → runner/web/binding}/binding.d.ts +2 -2
- package/types/runner/web/binding/class.d.ts +11 -0
- package/types/{binding → runner/web/binding}/style.d.ts +4 -4
- package/types/runner/web/runner.d.ts +42 -0
- package/types/tsconfig-types.tsbuildinfo +1 -1
- package/types/value/expression.d.ts +2 -2
- package/types/value/pointer.d.ts +1 -1
- package/types/value/reference.d.ts +1 -1
- package/types/views/array-view.d.ts +5 -5
- package/types/views/base-view.d.ts +7 -6
- package/types/views/map-view.d.ts +3 -3
- package/types/views/repeat-node.d.ts +8 -7
- package/types/views/set-view.d.ts +5 -4
- package/lib/core/config.js +0 -3
- package/lib/models/object-model.js +0 -78
- package/lib/spec/html.js +0 -1
- package/lib/spec/react.js +0 -1
- package/lib/spec/svg.js +0 -1
- package/lib/tsconfig-build.tsbuildinfo +0 -1
- package/lib/value/mirror.js +0 -42
- package/lib/views/object-view.js +0 -17
- package/lib-node/binding/attribute.js +0 -34
- package/lib-node/binding/binding.js +0 -32
- package/lib-node/binding/class.js +0 -46
- package/lib-node/binding/style.js +0 -36
- package/lib-node/core/config.js +0 -6
- package/lib-node/core/core.js +0 -101
- package/lib-node/core/destroyable.js +0 -14
- package/lib-node/core/errors.js +0 -22
- package/lib-node/core/ivalue.js +0 -19
- package/lib-node/functional/options.js +0 -2
- package/lib-node/functional/safety.js +0 -12
- package/lib-node/index.js +0 -51
- package/lib-node/models/array-model.js +0 -152
- package/lib-node/models/listener.js +0 -70
- package/lib-node/models/map-model.js +0 -63
- package/lib-node/models/model.js +0 -2
- package/lib-node/models/object-model.js +0 -82
- package/lib-node/models/set-model.js +0 -59
- package/lib-node/node/app.js +0 -34
- package/lib-node/node/node.js +0 -656
- package/lib-node/node/watch.js +0 -26
- package/lib-node/spec/html.js +0 -2
- package/lib-node/spec/react.js +0 -2
- package/lib-node/spec/svg.js +0 -2
- package/lib-node/tsconfig-build-node.tsbuildinfo +0 -1
- package/lib-node/value/expression.js +0 -65
- package/lib-node/value/mirror.js +0 -46
- package/lib-node/value/pointer.js +0 -79
- package/lib-node/value/reference.js +0 -50
- package/lib-node/views/array-view.js +0 -21
- package/lib-node/views/base-view.js +0 -31
- package/lib-node/views/map-view.js +0 -18
- package/lib-node/views/object-view.js +0 -21
- package/lib-node/views/repeat-node.js +0 -53
- package/lib-node/views/set-view.js +0 -22
- package/types/binding/class.d.ts +0 -11
- package/types/core/config.d.ts +0 -3
- package/types/functional/options.d.ts +0 -10
- package/types/models/object-model.d.ts +0 -38
- package/types/spec/html.d.ts +0 -975
- package/types/spec/react.d.ts +0 -4
- package/types/spec/svg.d.ts +0 -314
- package/types/value/mirror.d.ts +0 -33
- package/types/views/object-view.d.ts +0 -10
- /package/lib/{functional/options.js → node/runner.js} +0 -0
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ npm install vasille-web --save
|
|
|
29
29
|
Create an app from a template
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
|
-
$
|
|
32
|
+
$ npm create vasille
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
Alternative method to create a TypeScript app.
|
|
@@ -47,7 +47,7 @@ $ npx degit vasille-js/example-javascript my-project
|
|
|
47
47
|
|
|
48
48
|
### Examples
|
|
49
49
|
* [TypeScript Example](https://github.com/vasille-js/example-typescript)
|
|
50
|
-
* [JavaScript Example](https://github.com/
|
|
50
|
+
* [JavaScript Example](https://github.com/vasille-js/example-javascript)
|
|
51
51
|
|
|
52
52
|
<hr>
|
|
53
53
|
|
|
@@ -103,12 +103,11 @@ All of these are supported:
|
|
|
103
103
|
* [x] Develop the `Vasille JSX` library.
|
|
104
104
|
* [x] `100%` Test Coverage for the JSX library.
|
|
105
105
|
* [x] Develop the `Vasille Babel Plugin`.
|
|
106
|
-
* [
|
|
107
|
-
* [
|
|
108
|
-
* [ ] Add custom `<input/>` components with 2-way value binding.
|
|
106
|
+
* [x] `100%` Test Coverage fot babel plugin.
|
|
107
|
+
* [x] Add CSS support (define styles in components).
|
|
109
108
|
* [ ] Add router.
|
|
110
|
-
* [ ]
|
|
111
|
-
* [ ] Develop
|
|
109
|
+
* [ ] Add SSR (server side rendering).
|
|
110
|
+
* [ ] Develop tools extension for debugging.
|
|
112
111
|
|
|
113
112
|
## Questions
|
|
114
113
|
|
package/lib/core/core.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Destroyable } from "./destroyable.js";
|
|
2
|
-
import { Expression } from "../value/expression";
|
|
3
|
-
import { Reference } from "../value/reference";
|
|
4
|
-
import { OwningPointer, Pointer } from "../value/pointer";
|
|
2
|
+
import { Expression } from "../value/expression.js";
|
|
3
|
+
import { Reference } from "../value/reference.js";
|
|
4
|
+
import { OwningPointer, Pointer } from "../value/pointer.js";
|
|
5
5
|
/**
|
|
6
6
|
* A reactive object
|
|
7
7
|
* @class Reactive
|
|
@@ -21,39 +21,55 @@ export class Reactive extends Destroyable {
|
|
|
21
21
|
*/
|
|
22
22
|
this.bindings = new Set();
|
|
23
23
|
this.input = input;
|
|
24
|
+
this.state = {};
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* Create a reference
|
|
27
28
|
* @param value {*} value to reference
|
|
29
|
+
* @param name {string} used for debugging internal state
|
|
28
30
|
*/
|
|
29
|
-
ref(value) {
|
|
31
|
+
ref(value, name) {
|
|
30
32
|
const ref = new Reference(value);
|
|
31
33
|
this._watch.add(ref);
|
|
34
|
+
if (name) {
|
|
35
|
+
this.addState("ref", name, ref);
|
|
36
|
+
}
|
|
32
37
|
return ref;
|
|
33
38
|
}
|
|
34
39
|
/**
|
|
35
40
|
* Create a forward-only pointer
|
|
36
41
|
* @param value {IValue} value to point
|
|
42
|
+
* @param name {string} used for debugging internal state
|
|
37
43
|
*/
|
|
38
|
-
forward(value) {
|
|
44
|
+
forward(value, name) {
|
|
39
45
|
const mirror = new Pointer(value);
|
|
40
46
|
this._watch.add(mirror);
|
|
47
|
+
if (name) {
|
|
48
|
+
this.addState("forward", name, mirror);
|
|
49
|
+
}
|
|
41
50
|
return mirror;
|
|
42
51
|
}
|
|
43
52
|
/**
|
|
44
53
|
* Creates a pointer
|
|
45
54
|
* @param value {*} default value to point
|
|
55
|
+
* @param name {string} used for debugging internal state
|
|
46
56
|
*/
|
|
47
|
-
own(value) {
|
|
57
|
+
own(value, name) {
|
|
48
58
|
const pointer = new OwningPointer(value);
|
|
49
59
|
this._watch.add(pointer);
|
|
60
|
+
if (name) {
|
|
61
|
+
this.addState("own", name, pointer);
|
|
62
|
+
}
|
|
50
63
|
return pointer;
|
|
51
64
|
}
|
|
52
65
|
/**
|
|
53
66
|
* Register a model/dependency
|
|
54
67
|
*/
|
|
55
|
-
register(data) {
|
|
68
|
+
register(data, name) {
|
|
56
69
|
this.bindings.add(data);
|
|
70
|
+
if (name) {
|
|
71
|
+
this.addState("model", name, data);
|
|
72
|
+
}
|
|
57
73
|
return data;
|
|
58
74
|
}
|
|
59
75
|
release(data) {
|
|
@@ -64,18 +80,22 @@ export class Reactive extends Destroyable {
|
|
|
64
80
|
* @param func {function} function to run on any argument change
|
|
65
81
|
* @param values
|
|
66
82
|
*/
|
|
67
|
-
watch(func,
|
|
68
|
-
this._watch.add(new Expression(func,
|
|
83
|
+
watch(func, values) {
|
|
84
|
+
this._watch.add(new Expression(func, values));
|
|
69
85
|
}
|
|
70
86
|
/**
|
|
71
87
|
* Creates a computed value
|
|
72
88
|
* @param func {function} function to run on any argument change
|
|
73
89
|
* @param values
|
|
90
|
+
* @param name {string} used for debugging internal state
|
|
74
91
|
* @return {IValue} the created ivalue
|
|
75
92
|
*/
|
|
76
|
-
expr(func,
|
|
77
|
-
const res = new Expression(func,
|
|
93
|
+
expr(func, values, name) {
|
|
94
|
+
const res = new Expression(func, values);
|
|
78
95
|
this._watch.add(res);
|
|
96
|
+
if (name) {
|
|
97
|
+
this.addState("expr", name, res);
|
|
98
|
+
}
|
|
79
99
|
return res;
|
|
80
100
|
}
|
|
81
101
|
runOnDestroy(func) {
|
|
@@ -85,13 +105,15 @@ export class Reactive extends Destroyable {
|
|
|
85
105
|
}
|
|
86
106
|
this.onDestroy = func;
|
|
87
107
|
}
|
|
108
|
+
addState(method, name, state) {
|
|
109
|
+
this.state[name === "#" ? `#${Object.keys(this.state).length}` : name] = [method, state];
|
|
110
|
+
}
|
|
88
111
|
destroy() {
|
|
89
|
-
var _a;
|
|
90
112
|
super.destroy();
|
|
91
113
|
this._watch.forEach(value => value.destroy());
|
|
92
114
|
this._watch.clear();
|
|
93
115
|
this.bindings.forEach(binding => binding.destroy());
|
|
94
116
|
this.bindings.clear();
|
|
95
|
-
|
|
117
|
+
this.onDestroy?.();
|
|
96
118
|
}
|
|
97
119
|
}
|
package/lib/core/ivalue.js
CHANGED
|
@@ -9,7 +9,6 @@ export class IValue extends Destroyable {
|
|
|
9
9
|
return this.$;
|
|
10
10
|
}
|
|
11
11
|
toString() {
|
|
12
|
-
|
|
13
|
-
return (_b = (_a = this.$) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "iValue<void>";
|
|
12
|
+
return this.$?.toString() ?? "iValue<void>";
|
|
14
13
|
}
|
|
15
14
|
}
|
package/lib/index.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
import { Watch } from "./node/watch";
|
|
22
|
-
export { Destroyable, IValue, Reference, Pointer, ArrayModel, proxyArrayModel, MapModel, SetModel, BaseView, Listener, ArrayView, MapView, SetView, Fragment, INode, Tag, Extension, App, Portal, Expression, Binding, Reactive, Watch, userError, config, setErrorHandler, reportError, };
|
|
1
|
+
import { Destroyable } from "./core/destroyable.js";
|
|
2
|
+
import { Reactive } from "./core/core.js";
|
|
3
|
+
import { IValue } from "./core/ivalue.js";
|
|
4
|
+
import { reportError, setErrorHandler } from "./functional/safety.js";
|
|
5
|
+
import { ArrayModel, proxyArrayModel } from "./models/array-model.js";
|
|
6
|
+
import { Listener } from "./models/listener.js";
|
|
7
|
+
import { MapModel } from "./models/map-model.js";
|
|
8
|
+
import { SetModel } from "./models/set-model.js";
|
|
9
|
+
import { App, Portal } from "./node/app.js";
|
|
10
|
+
import { Fragment, Tag, TextNode, DebugNode } from "./node/node.js";
|
|
11
|
+
import { Expression } from "./value/expression.js";
|
|
12
|
+
import { Pointer } from "./value/pointer.js";
|
|
13
|
+
import { Reference } from "./value/reference.js";
|
|
14
|
+
import { ArrayView } from "./views/array-view.js";
|
|
15
|
+
import { BaseView } from "./views/base-view.js";
|
|
16
|
+
import { MapView } from "./views/map-view.js";
|
|
17
|
+
import { SetView } from "./views/set-view.js";
|
|
18
|
+
import { userError } from "./core/errors.js";
|
|
19
|
+
import { Watch } from "./node/watch.js";
|
|
20
|
+
export { Destroyable, IValue, Reference, Pointer, ArrayModel, proxyArrayModel, MapModel, SetModel, BaseView, Listener, ArrayView, MapView, SetView, Fragment, Tag, App, Portal, Expression, Reactive, TextNode, DebugNode, Watch, userError, setErrorHandler, reportError, };
|
package/lib/models/map-model.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Listener } from "./listener";
|
|
1
|
+
import { Listener } from "./listener.js";
|
|
2
2
|
/**
|
|
3
3
|
* A Map based memory
|
|
4
4
|
* @class MapModel
|
|
@@ -13,7 +13,7 @@ export class MapModel extends Map {
|
|
|
13
13
|
constructor(map) {
|
|
14
14
|
super();
|
|
15
15
|
this.listener = new Listener();
|
|
16
|
-
map
|
|
16
|
+
map?.forEach(([key, value]) => {
|
|
17
17
|
super.set(key, value);
|
|
18
18
|
});
|
|
19
19
|
}
|
package/lib/models/set-model.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Listener } from "./listener";
|
|
1
|
+
import { Listener } from "./listener.js";
|
|
2
2
|
/**
|
|
3
3
|
* A Set based model
|
|
4
4
|
* @class SetModel
|
|
@@ -13,7 +13,7 @@ export class SetModel extends Set {
|
|
|
13
13
|
constructor(set) {
|
|
14
14
|
super();
|
|
15
15
|
this.listener = new Listener();
|
|
16
|
-
set
|
|
16
|
+
set?.forEach(item => {
|
|
17
17
|
super.add(item);
|
|
18
18
|
});
|
|
19
19
|
}
|
package/lib/node/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fragment, Root } from "./node";
|
|
1
|
+
import { Fragment, Root } from "./node.js";
|
|
2
2
|
/**
|
|
3
3
|
* Represents a Vasille.js application
|
|
4
4
|
* @class App
|
|
@@ -10,20 +10,20 @@ export class App extends Root {
|
|
|
10
10
|
* @param node {Element} The root of application
|
|
11
11
|
* @param input
|
|
12
12
|
*/
|
|
13
|
-
constructor(node, input) {
|
|
14
|
-
super(input);
|
|
13
|
+
constructor(node, runner, input) {
|
|
14
|
+
super(input, runner);
|
|
15
15
|
this.node = node;
|
|
16
16
|
}
|
|
17
17
|
appendNode(node) {
|
|
18
|
-
this.
|
|
18
|
+
this.runner.appendChild(this.node, node);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
export class Portal extends Fragment {
|
|
22
|
-
constructor(input) {
|
|
23
|
-
super(input, ":portal");
|
|
22
|
+
constructor(input, runner) {
|
|
23
|
+
super(input, runner, ":portal");
|
|
24
24
|
this.node = input.node;
|
|
25
25
|
}
|
|
26
26
|
appendNode(node) {
|
|
27
|
-
this.
|
|
27
|
+
this.runner.appendChild(this.node, node);
|
|
28
28
|
}
|
|
29
29
|
}
|