vasille 1.2.8 → 2.0.2
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/.gitlab-ci.yml +20 -0
- package/LICENSE.md +21 -0
- package/README.md +160 -119
- package/cdn/es2015.js +3221 -0
- package/cdn/es5.js +3673 -0
- package/flow-typed/vasille.js +837 -0
- package/lib/binding/attribute.js +32 -0
- package/lib/binding/binding.js +39 -0
- package/lib/binding/class.js +51 -0
- package/lib/binding/style.js +29 -0
- package/lib/core/core.js +178 -0
- package/lib/core/destroyable.js +45 -0
- package/lib/core/errors.js +16 -0
- package/lib/core/executor.js +154 -0
- package/lib/core/ivalue.js +56 -0
- package/lib/core/signal.js +50 -0
- package/lib/core/slot.js +47 -0
- package/lib/index.js +27 -22
- package/lib/models/array-model.js +208 -0
- package/lib/models/listener.js +130 -0
- package/lib/models/map-model.js +66 -0
- package/lib/models/model.js +1 -0
- package/lib/models/object-model.js +78 -0
- package/lib/models/set-model.js +62 -0
- package/lib/node/app.js +38 -0
- package/lib/node/interceptor.js +83 -0
- package/lib/node/node.js +1202 -0
- package/lib/node/watch.js +27 -0
- package/lib/value/expression.js +83 -0
- package/lib/value/mirror.js +58 -0
- package/lib/value/pointer.js +26 -0
- package/lib/value/reference.js +55 -0
- package/lib/views/array-view.js +23 -0
- package/lib/views/base-view.js +49 -0
- package/lib/views/map-view.js +20 -0
- package/lib/views/object-view.js +20 -0
- package/lib/views/repeat-node.js +106 -0
- package/lib/views/repeater.js +63 -0
- package/lib/views/set-view.js +23 -0
- package/package.json +27 -19
- package/types/binding/attribute.d.ts +23 -0
- package/types/binding/binding.d.ts +30 -0
- package/types/binding/class.d.ts +23 -0
- package/types/binding/style.d.ts +23 -0
- package/types/core/core.d.ts +140 -0
- package/types/core/destroyable.d.ts +15 -0
- package/types/core/errors.d.ts +4 -0
- package/types/core/executor.d.ts +87 -0
- package/types/core/ivalue.d.ts +45 -0
- package/types/core/signal.d.ts +35 -0
- package/types/core/slot.d.ts +45 -0
- package/types/index.d.ts +27 -21
- package/types/models/array-model.d.ts +103 -0
- package/types/models/listener.d.ts +74 -0
- package/types/models/map-model.d.ts +35 -0
- package/types/models/model.d.ts +19 -0
- package/types/models/object-model.d.ts +36 -0
- package/types/models/set-model.d.ts +34 -0
- package/types/node/app.d.ts +37 -0
- package/types/node/interceptor.d.ts +50 -0
- package/types/node/node.d.ts +741 -0
- package/types/node/watch.d.ts +23 -0
- package/types/value/expression.d.ts +60 -0
- package/types/value/mirror.d.ts +35 -0
- package/types/value/pointer.d.ts +19 -0
- package/types/value/reference.d.ts +30 -0
- package/types/views/array-view.d.ts +13 -0
- package/types/views/base-view.d.ts +43 -0
- package/types/views/map-view.d.ts +11 -0
- package/types/views/object-view.d.ts +11 -0
- package/types/views/repeat-node.d.ts +35 -0
- package/types/views/repeater.d.ts +38 -0
- package/types/views/set-view.d.ts +11 -0
- package/CHANGELOG.md +0 -23
- package/img/favicon.svg +0 -441
- package/img/getLocus.svg +0 -18
- package/img/logo.png +0 -0
- package/img/logo.svg +0 -550
- package/img/scores-o-log.png +0 -0
- package/img/scores-o.png +0 -0
- package/img/scores-wo-log.png +0 -0
- package/img/scores-wo.png +0 -0
- package/img/x1-x32.png +0 -0
- package/lib/attribute.js +0 -71
- package/lib/attribute.js.map +0 -1
- package/lib/bind.js +0 -286
- package/lib/bind.js.map +0 -1
- package/lib/class.js +0 -97
- package/lib/class.js.map +0 -1
- package/lib/executor.js +0 -167
- package/lib/executor.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/interfaces/core.js +0 -247
- package/lib/interfaces/core.js.map +0 -1
- package/lib/interfaces/destroyable.js +0 -39
- package/lib/interfaces/destroyable.js.map +0 -1
- package/lib/interfaces/errors.js +0 -49
- package/lib/interfaces/errors.js.map +0 -1
- package/lib/interfaces/ibind.js +0 -31
- package/lib/interfaces/ibind.js.map +0 -1
- package/lib/interfaces/idefinition.js +0 -64
- package/lib/interfaces/idefinition.js.map +0 -1
- package/lib/interfaces/ivalue.js +0 -60
- package/lib/interfaces/ivalue.js.map +0 -1
- package/lib/models.js +0 -579
- package/lib/models.js.map +0 -1
- package/lib/node.js +0 -2155
- package/lib/node.js.map +0 -1
- package/lib/property.js +0 -38
- package/lib/property.js.map +0 -1
- package/lib/style.js +0 -66
- package/lib/style.js.map +0 -1
- package/lib/value.js +0 -203
- package/lib/value.js.map +0 -1
- package/lib/views.js +0 -688
- package/lib/views.js.map +0 -1
- package/src/attribute.js +0 -70
- package/src/bind.js +0 -285
- package/src/class.js +0 -96
- package/src/executor.js +0 -165
- package/src/index.js +0 -20
- package/src/interfaces/core.js +0 -248
- package/src/interfaces/destroyable.js +0 -37
- package/src/interfaces/errors.js +0 -47
- package/src/interfaces/ibind.js +0 -29
- package/src/interfaces/idefinition.js +0 -62
- package/src/interfaces/ivalue.js +0 -58
- package/src/models.js +0 -577
- package/src/node.js +0 -2162
- package/src/property.js +0 -36
- package/src/style.js +0 -65
- package/src/value.js +0 -201
- package/src/views.js +0 -686
- package/types/attribute.d.ts +0 -18
- package/types/bind.d.ts +0 -72
- package/types/class.d.ts +0 -19
- package/types/data.d.ts +0 -11
- package/types/event.d.ts +0 -10
- package/types/executor.d.ts +0 -57
- package/types/interfaces/core.d.ts +0 -129
- package/types/interfaces/destroyable.d.ts +0 -11
- package/types/interfaces/errors.d.ts +0 -24
- package/types/interfaces/ibind.d.ts +0 -19
- package/types/interfaces/idefinition.d.ts +0 -29
- package/types/interfaces/ivalue.d.ts +0 -40
- package/types/models.d.ts +0 -179
- package/types/node.d.ts +0 -906
- package/types/property.d.ts +0 -9
- package/types/style.d.ts +0 -28
- package/types/value.d.ts +0 -43
- package/types/views.d.ts +0 -135
package/src/property.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import { Callable } from "./interfaces/idefinition.js";
|
|
3
|
-
import { IValue } from "./interfaces/ivalue.js";
|
|
4
|
-
import { Reference } from "./value.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Constructs a property field value
|
|
10
|
-
* @param value {?any} is the initial value of field
|
|
11
|
-
* @param func {?Callable} is the function to calc filed value
|
|
12
|
-
* @return {IValue} Given value or new generated
|
|
13
|
-
*/
|
|
14
|
-
export function propertify (
|
|
15
|
-
value : ?any = null,
|
|
16
|
-
func : ?Callable = null
|
|
17
|
-
) : IValue<any> {
|
|
18
|
-
if (func) {
|
|
19
|
-
let v = func.func();
|
|
20
|
-
|
|
21
|
-
if (v instanceof IValue) {
|
|
22
|
-
return v;
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
return new Reference(v);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
if (value instanceof IValue) {
|
|
30
|
-
return value;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
return new Reference(value);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
package/src/style.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import { Binding } from "./bind.js";
|
|
3
|
-
import { Callable } from "./interfaces/idefinition.js";
|
|
4
|
-
import { IValue } from "./interfaces/ivalue.js";
|
|
5
|
-
import type { INode } from "./node";
|
|
6
|
-
import { propertify } from "./property.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Constructs a style attribute value
|
|
12
|
-
* @param rt {INode} The root node
|
|
13
|
-
* @param ts {INode} The this node
|
|
14
|
-
* @param name {String} The style attribute name
|
|
15
|
-
* @param value {String | IValue | null} A value for attribute
|
|
16
|
-
* @param func {?Callable} A getter of attribute value
|
|
17
|
-
* @return {StyleBinding} A ready style binding
|
|
18
|
-
*/
|
|
19
|
-
export function stylify (
|
|
20
|
-
rt : INode,
|
|
21
|
-
ts : INode,
|
|
22
|
-
name : string,
|
|
23
|
-
value : ?string | ?IValue<string> = null,
|
|
24
|
-
func : ?Callable = null
|
|
25
|
-
) : StyleBinding {
|
|
26
|
-
return new StyleBinding(rt, ts, name, null, propertify(value, func));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Describes a style attribute binding
|
|
31
|
-
* @extends Binding
|
|
32
|
-
*/
|
|
33
|
-
export class StyleBinding extends Binding {
|
|
34
|
-
/**
|
|
35
|
-
* Constructs a style binding attribute
|
|
36
|
-
* @param rt {INode} is root component
|
|
37
|
-
* @param ts {INode} is this component
|
|
38
|
-
* @param name {string} is the name of style property
|
|
39
|
-
* @param func {function} is the function to calc style value
|
|
40
|
-
* @param values is the value to be synced
|
|
41
|
-
*/
|
|
42
|
-
constructor (
|
|
43
|
-
rt : INode,
|
|
44
|
-
ts : INode,
|
|
45
|
-
name : string,
|
|
46
|
-
func : ?Function,
|
|
47
|
-
...values : Array<IValue<string>>
|
|
48
|
-
) {
|
|
49
|
-
super(rt, ts, name, func, ...values);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Generates a function to update style property value
|
|
54
|
-
* @param name {string}
|
|
55
|
-
* @returns {Function} a function to update style property
|
|
56
|
-
*/
|
|
57
|
-
bound (name : string) : Function {
|
|
58
|
-
return function (rt : any, ts : any, value : string) {
|
|
59
|
-
if (rt.$) {
|
|
60
|
-
rt.$.app.$run.setStyle(ts.$.el, name, value);
|
|
61
|
-
}
|
|
62
|
-
return value;
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
package/src/value.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import { typeError } from "./interfaces/errors";
|
|
3
|
-
import { checkType, isSubclassOf } from "./interfaces/idefinition";
|
|
4
|
-
import { IValue } from "./interfaces/ivalue.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Declares a notifiable value
|
|
10
|
-
* @implements IValue
|
|
11
|
-
*/
|
|
12
|
-
export class Reference<T> extends IValue<T> {
|
|
13
|
-
/**
|
|
14
|
-
* The encapsulated value
|
|
15
|
-
* @type {*}
|
|
16
|
-
*/
|
|
17
|
-
value : T;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Array of handlers
|
|
21
|
-
* @type {Set<Function>}
|
|
22
|
-
*/
|
|
23
|
-
onchange : Set<Function>;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Constructs a notifiable value
|
|
27
|
-
* @param value {any} is initial value
|
|
28
|
-
*/
|
|
29
|
-
constructor (value : T) {
|
|
30
|
-
super();
|
|
31
|
-
this.value = value;
|
|
32
|
-
this.onchange = new Set<Function>();
|
|
33
|
-
this.seal();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Gets the notifiable value as js value
|
|
38
|
-
* @returns {any} contained value
|
|
39
|
-
*/
|
|
40
|
-
get $ () : T {
|
|
41
|
-
return this.value;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Sets the value and notify listeners
|
|
46
|
-
* @param value {any} is the new value
|
|
47
|
-
* @returns {Reference} a pointer to this
|
|
48
|
-
*/
|
|
49
|
-
set $ (value : T) : this {
|
|
50
|
-
if (this.value !== value) {
|
|
51
|
-
if (this.type && !checkType(value, this.type)) {
|
|
52
|
-
throw typeError("Unable to set reference value");
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
this.value = value;
|
|
56
|
-
|
|
57
|
-
for (let handler of this.onchange) {
|
|
58
|
-
handler(value);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return this;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Adds a new handler for value change
|
|
67
|
-
* @param handler {function} is a user-defined event handler
|
|
68
|
-
* @returns {Reference} a pointer to this
|
|
69
|
-
*/
|
|
70
|
-
on (handler : Function) : this {
|
|
71
|
-
this.onchange.add(handler);
|
|
72
|
-
return this;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Removes a new handler for value change
|
|
77
|
-
* @param handler {function} is a existing user-defined handler
|
|
78
|
-
* @returns {Reference} a pointer to this
|
|
79
|
-
*/
|
|
80
|
-
off (handler : Function) : this {
|
|
81
|
-
this.onchange.delete(handler);
|
|
82
|
-
return this;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Runs GC
|
|
87
|
-
*/
|
|
88
|
-
$destroy () {
|
|
89
|
-
super.$destroy();
|
|
90
|
-
this.onchange.clear();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Declares a notifiable bind to a value
|
|
96
|
-
* @extends IValue
|
|
97
|
-
*/
|
|
98
|
-
export class Pointer<T> extends IValue<IValue<T>> {
|
|
99
|
-
/**
|
|
100
|
-
* value of pointer
|
|
101
|
-
* @type {IValue<*>}
|
|
102
|
-
*/
|
|
103
|
-
value : IValue<T>;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Collection of handlers
|
|
107
|
-
* @type {Set<Function>}
|
|
108
|
-
*/
|
|
109
|
-
onchange : Set<Function>;
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Constructs a notifiable bind to a value
|
|
113
|
-
* @param value {IValue} is initial value
|
|
114
|
-
*/
|
|
115
|
-
constructor (value : IValue<T>) {
|
|
116
|
-
super();
|
|
117
|
-
this.onchange = new Set<Function>();
|
|
118
|
-
this.$ = value;
|
|
119
|
-
this.seal();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Gets the notifiable value as js value
|
|
124
|
-
* @returns {any} contained value
|
|
125
|
-
*/
|
|
126
|
-
// $FlowFixMe
|
|
127
|
-
get $ () : T {
|
|
128
|
-
return this.value.$;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Sets the value and notify listeners
|
|
133
|
-
* @param value {IValue} is the new value
|
|
134
|
-
* @returns {IValue} a pointer to this
|
|
135
|
-
*/
|
|
136
|
-
set $ (value : IValue<T>) : this {
|
|
137
|
-
if (this.value !== value) {
|
|
138
|
-
if (this.type) {
|
|
139
|
-
if (this.type !== value.type) {
|
|
140
|
-
if (value.type === null && checkType(value.$, this.type)) {
|
|
141
|
-
value.type = this.type;
|
|
142
|
-
}
|
|
143
|
-
else if (!isSubclassOf(this.type, value.type)) {
|
|
144
|
-
throw typeError("reference type incompatible with pointer type");
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
for (let handler of this.onchange) {
|
|
150
|
-
this.value.off(handler);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
this.value = value;
|
|
154
|
-
|
|
155
|
-
for (let handler of this.onchange) {
|
|
156
|
-
this.value.on(handler);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (this.value.$ !== value.$) {
|
|
160
|
-
for (let handler of this.onchange) {
|
|
161
|
-
handler(this.value.$);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return this;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Adds a new handler for value change
|
|
171
|
-
* @param handler {function} is a user-defined event handler
|
|
172
|
-
* @returns {IValue} a pointer to this
|
|
173
|
-
*/
|
|
174
|
-
on (handler : Function) : this {
|
|
175
|
-
this.onchange.add(handler);
|
|
176
|
-
this.value.on(handler);
|
|
177
|
-
return this;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Removes a new handler for value change
|
|
182
|
-
* @param handler {function} is a existing user-defined handler
|
|
183
|
-
* @returns {IValue} a pointer to this
|
|
184
|
-
*/
|
|
185
|
-
off (handler : Function) : this {
|
|
186
|
-
if (this.onchange.has(handler)) {
|
|
187
|
-
this.value.off(handler);
|
|
188
|
-
this.onchange.delete(handler);
|
|
189
|
-
}
|
|
190
|
-
return this;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Removes all bounded functions
|
|
195
|
-
*/
|
|
196
|
-
$destroy () {
|
|
197
|
-
for (let handler of this.onchange) {
|
|
198
|
-
this.value.off(handler);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|