vasille 3.0.2 → 3.2.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 +10 -10
- package/lib/core/core.js +40 -24
- package/lib/core/ivalue.js +1 -2
- package/lib/index.js +20 -22
- package/lib/node/app.js +7 -7
- package/lib/node/node.js +47 -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 +3 -1
- package/lib/{binding → runner/web/binding}/style.js +2 -1
- package/lib/runner/web/runner.js +165 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/value/expression.js +3 -2
- package/lib/value/pointer.js +8 -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 +31 -25
- package/types/core/core.d.ts +14 -13
- package/types/index.d.ts +22 -24
- 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/array-model.js +0 -147
- package/lib/models/listener.js +0 -66
- package/lib/models/map-model.js +0 -59
- package/lib/models/model.js +0 -1
- package/lib/models/object-model.js +0 -78
- package/lib/models/set-model.js +0 -55
- 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/array-model.d.ts +0 -55
- package/types/models/listener.d.ts +0 -48
- package/types/models/map-model.d.ts +0 -34
- package/types/models/model.d.ts +0 -14
- package/types/models/object-model.d.ts +0 -38
- package/types/models/set-model.d.ts +0 -33
- 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
|
@@ -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,10 +44,11 @@ $ 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)
|
|
50
|
-
* [JavaScript Example](https://github.com/
|
|
51
|
+
* [JavaScript Example](https://github.com/vasille-js/example-javascript)
|
|
51
52
|
|
|
52
53
|
<hr>
|
|
53
54
|
|
|
@@ -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
|
|
@@ -103,12 +104,11 @@ All of these are supported:
|
|
|
103
104
|
* [x] Develop the `Vasille JSX` library.
|
|
104
105
|
* [x] `100%` Test Coverage for the JSX library.
|
|
105
106
|
* [x] Develop the `Vasille Babel Plugin`.
|
|
106
|
-
* [
|
|
107
|
-
* [
|
|
108
|
-
* [
|
|
109
|
-
* [ ] Add
|
|
110
|
-
* [ ] Develop
|
|
111
|
-
* [ ] Develop a lot of libraries for the framework.
|
|
107
|
+
* [x] `100%` Test Coverage fot babel plugin.
|
|
108
|
+
* [x] Add CSS support (define styles in components).
|
|
109
|
+
* [x] Add router.
|
|
110
|
+
* [ ] Add SSR (server side rendering).
|
|
111
|
+
* [ ] Develop tools extension for debugging.
|
|
112
112
|
|
|
113
113
|
## Questions
|
|
114
114
|
|
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
|
|
@@ -10,50 +10,62 @@ import { OwningPointer, Pointer } from "../value/pointer";
|
|
|
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}
|
|
21
16
|
*/
|
|
22
17
|
this.bindings = new Set();
|
|
23
18
|
this.input = input;
|
|
19
|
+
this.state = {};
|
|
24
20
|
}
|
|
25
21
|
/**
|
|
26
22
|
* Create a reference
|
|
27
23
|
* @param value {*} value to reference
|
|
24
|
+
* @param name {string} used for debugging internal state
|
|
28
25
|
*/
|
|
29
|
-
ref(value) {
|
|
26
|
+
ref(value, name) {
|
|
30
27
|
const ref = new Reference(value);
|
|
31
|
-
this.
|
|
28
|
+
this.bindings.add(ref);
|
|
29
|
+
if (name) {
|
|
30
|
+
this.addState("ref", name, ref);
|
|
31
|
+
}
|
|
32
32
|
return ref;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Create a forward-only pointer
|
|
36
36
|
* @param value {IValue} value to point
|
|
37
|
+
* @param name {string} used for debugging internal state
|
|
37
38
|
*/
|
|
38
|
-
forward(value) {
|
|
39
|
+
forward(value, name) {
|
|
39
40
|
const mirror = new Pointer(value);
|
|
40
|
-
this.
|
|
41
|
+
this.bindings.add(mirror);
|
|
42
|
+
if (name) {
|
|
43
|
+
this.addState("forward", name, mirror);
|
|
44
|
+
}
|
|
41
45
|
return mirror;
|
|
42
46
|
}
|
|
43
47
|
/**
|
|
44
48
|
* Creates a pointer
|
|
45
49
|
* @param value {*} default value to point
|
|
50
|
+
* @param name {string} used for debugging internal state
|
|
46
51
|
*/
|
|
47
|
-
own(value) {
|
|
52
|
+
own(value, name) {
|
|
48
53
|
const pointer = new OwningPointer(value);
|
|
49
|
-
this.
|
|
54
|
+
this.bindings.add(pointer);
|
|
55
|
+
/* istanbul ignore else */
|
|
56
|
+
if (name) {
|
|
57
|
+
this.addState("own", name, pointer);
|
|
58
|
+
}
|
|
50
59
|
return pointer;
|
|
51
60
|
}
|
|
52
61
|
/**
|
|
53
62
|
* Register a model/dependency
|
|
54
63
|
*/
|
|
55
|
-
register(data) {
|
|
64
|
+
register(data, name) {
|
|
56
65
|
this.bindings.add(data);
|
|
66
|
+
if (name) {
|
|
67
|
+
this.addState("model", name, data);
|
|
68
|
+
}
|
|
57
69
|
return data;
|
|
58
70
|
}
|
|
59
71
|
release(data) {
|
|
@@ -64,18 +76,22 @@ export class Reactive extends Destroyable {
|
|
|
64
76
|
* @param func {function} function to run on any argument change
|
|
65
77
|
* @param values
|
|
66
78
|
*/
|
|
67
|
-
watch(func,
|
|
68
|
-
this.
|
|
79
|
+
watch(func, values) {
|
|
80
|
+
this.bindings.add(new Expression(func, values));
|
|
69
81
|
}
|
|
70
82
|
/**
|
|
71
83
|
* Creates a computed value
|
|
72
84
|
* @param func {function} function to run on any argument change
|
|
73
85
|
* @param values
|
|
86
|
+
* @param name {string} used for debugging internal state
|
|
74
87
|
* @return {IValue} the created ivalue
|
|
75
88
|
*/
|
|
76
|
-
expr(func,
|
|
77
|
-
const res = new Expression(func,
|
|
78
|
-
this.
|
|
89
|
+
expr(func, values, name) {
|
|
90
|
+
const res = new Expression(func, values);
|
|
91
|
+
this.bindings.add(res);
|
|
92
|
+
if (name) {
|
|
93
|
+
this.addState("expr", name, res);
|
|
94
|
+
}
|
|
79
95
|
return res;
|
|
80
96
|
}
|
|
81
97
|
runOnDestroy(func) {
|
|
@@ -85,13 +101,13 @@ export class Reactive extends Destroyable {
|
|
|
85
101
|
}
|
|
86
102
|
this.onDestroy = func;
|
|
87
103
|
}
|
|
104
|
+
addState(method, name, state) {
|
|
105
|
+
this.state[name === "#" ? `#${Object.keys(this.state).length}` : name] = [method, state];
|
|
106
|
+
}
|
|
88
107
|
destroy() {
|
|
89
|
-
var _a;
|
|
90
108
|
super.destroy();
|
|
91
|
-
this._watch.forEach(value => value.destroy());
|
|
92
|
-
this._watch.clear();
|
|
93
109
|
this.bindings.forEach(binding => binding.destroy());
|
|
94
110
|
this.bindings.clear();
|
|
95
|
-
|
|
111
|
+
this.onDestroy?.();
|
|
96
112
|
}
|
|
97
113
|
}
|
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/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
|
}
|