vasille 2.0.4 → 2.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 +7 -3
- package/cdn/es2015.js +947 -1006
- package/cdn/es5.js +1053 -1023
- package/flow-typed/vasille.js +2646 -838
- package/lib/binding/attribute.js +11 -12
- package/lib/binding/binding.js +9 -19
- package/lib/binding/class.js +34 -42
- package/lib/binding/style.js +5 -11
- package/lib/core/core.js +84 -32
- package/lib/core/destroyable.js +2 -2
- package/lib/core/ivalue.js +15 -13
- package/lib/functional/components.js +17 -0
- package/lib/functional/merge.js +41 -0
- package/lib/functional/models.js +26 -0
- package/lib/functional/options.js +1 -0
- package/lib/functional/reactivity.js +33 -0
- package/lib/functional/stack.js +127 -0
- package/lib/index.js +2 -7
- package/lib/models/array-model.js +9 -0
- package/lib/models/object-model.js +28 -14
- package/lib/node/app.js +23 -14
- package/lib/node/interceptor.js +3 -3
- package/lib/node/node.js +340 -681
- package/lib/node/watch.js +9 -17
- package/lib/spec/html.js +1 -0
- package/lib/spec/react.js +1 -0
- package/lib/spec/svg.js +1 -0
- package/lib/v/index.js +23 -0
- package/lib/value/expression.js +11 -8
- package/lib/value/mirror.js +6 -8
- package/lib/value/reference.js +3 -7
- package/lib/views/array-view.js +6 -10
- package/lib/views/base-view.js +12 -23
- package/lib/views/map-view.js +4 -9
- package/lib/views/object-view.js +5 -8
- package/lib/views/repeat-node.js +20 -60
- package/lib/views/repeater.js +7 -7
- package/lib/views/set-view.js +4 -11
- package/package.json +3 -1
- package/types/binding/attribute.d.ts +2 -8
- package/types/binding/binding.d.ts +4 -13
- package/types/binding/class.d.ts +7 -19
- package/types/binding/style.d.ts +0 -6
- package/types/core/core.d.ts +42 -54
- package/types/core/destroyable.d.ts +2 -2
- package/types/core/ivalue.d.ts +13 -11
- package/types/functional/components.d.ts +4 -0
- package/types/functional/merge.d.ts +1 -0
- package/types/functional/models.d.ts +10 -0
- package/types/functional/options.d.ts +23 -0
- package/types/functional/reactivity.d.ts +11 -0
- package/types/functional/stack.d.ts +24 -0
- package/types/index.d.ts +3 -7
- package/types/models/array-model.d.ts +3 -2
- package/types/models/map-model.d.ts +2 -2
- package/types/models/model.d.ts +3 -1
- package/types/models/object-model.d.ts +4 -2
- package/types/models/set-model.d.ts +2 -2
- package/types/node/app.d.ts +21 -19
- package/types/node/node.d.ts +99 -423
- package/types/node/watch.d.ts +9 -15
- package/types/spec/html.d.ts +975 -0
- package/types/spec/react.d.ts +4 -0
- package/types/spec/svg.d.ts +314 -0
- package/types/v/index.d.ts +32 -0
- package/types/value/expression.d.ts +7 -20
- package/types/value/mirror.d.ts +3 -3
- package/types/value/reference.d.ts +5 -5
- package/types/views/array-view.d.ts +3 -4
- package/types/views/base-view.d.ts +9 -17
- package/types/views/map-view.d.ts +2 -3
- package/types/views/object-view.d.ts +2 -3
- package/types/views/repeat-node.d.ts +8 -9
- package/types/views/set-view.d.ts +2 -3
- package/types/core/executor.d.ts +0 -87
- package/types/core/signal.d.ts +0 -35
- package/types/core/slot.d.ts +0 -45
- package/types/node/interceptor.d.ts +0 -50
- package/types/views/repeater.d.ts +0 -38
package/lib/node/watch.js
CHANGED
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
import { Fragment } from "./node";
|
|
2
|
-
import { Slot } from "../core/slot";
|
|
3
2
|
/**
|
|
4
3
|
* Watch Node
|
|
5
4
|
* @class Watch
|
|
6
5
|
* @extends Fragment
|
|
7
6
|
*/
|
|
8
7
|
export class Watch extends Fragment {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.$seal();
|
|
14
|
-
}
|
|
15
|
-
$createWatchers() {
|
|
16
|
-
this.$watch((value) => {
|
|
17
|
-
this.$children.forEach(child => {
|
|
18
|
-
child.$destroy();
|
|
8
|
+
compose(input) {
|
|
9
|
+
this.watch((value) => {
|
|
10
|
+
this.children.forEach(child => {
|
|
11
|
+
child.destroy();
|
|
19
12
|
});
|
|
20
|
-
this
|
|
21
|
-
this.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.slot.release(this, this.model.$);
|
|
13
|
+
this.children.clear();
|
|
14
|
+
this.lastChild = null;
|
|
15
|
+
input.slot && input.slot(this, value);
|
|
16
|
+
}, input.model);
|
|
17
|
+
input.slot(this, input.model.$);
|
|
26
18
|
}
|
|
27
19
|
}
|
package/lib/spec/html.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/spec/svg.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/v/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { debug, text } from "../functional/components";
|
|
2
|
+
import { arrayModel, mapModel, objectModel, setModel } from "../functional/models";
|
|
3
|
+
import { expr, forward, mirror, point, ref, setValue, valueOf, watch } from "../functional/reactivity";
|
|
4
|
+
import { app, component, create, extension, fragment, tag, vx } from "../functional/stack";
|
|
5
|
+
import { current } from "../core/core";
|
|
6
|
+
import { Reference } from "../value/reference";
|
|
7
|
+
import { merge } from "../functional/merge";
|
|
8
|
+
export { debug, arrayModel, mapModel, objectModel, setModel, expr, forward, mirror, point, ref, setValue, valueOf, watch };
|
|
9
|
+
export const v = Object.assign(Object.assign({ ref(value) {
|
|
10
|
+
return current.ref(value);
|
|
11
|
+
}, expr: expr, of: valueOf, sv: setValue, alwaysFalse: new Reference(false), app,
|
|
12
|
+
component,
|
|
13
|
+
fragment,
|
|
14
|
+
extension,
|
|
15
|
+
text,
|
|
16
|
+
tag,
|
|
17
|
+
create }, vx), { merge,
|
|
18
|
+
destructor() {
|
|
19
|
+
return current.destroy.bind(current);
|
|
20
|
+
},
|
|
21
|
+
runOnDestroy(callback) {
|
|
22
|
+
current.runOnDestroy(callback);
|
|
23
|
+
} });
|
package/lib/value/expression.js
CHANGED
|
@@ -6,13 +6,18 @@ import { IValue } from "../core/ivalue";
|
|
|
6
6
|
* @extends IValue
|
|
7
7
|
*/
|
|
8
8
|
export class Expression extends IValue {
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Creates a function bounded to N values
|
|
11
|
+
* @param func {Function} the function to bound
|
|
12
|
+
* @param values
|
|
13
|
+
* @param link {Boolean} links immediately if true
|
|
14
|
+
*/
|
|
15
|
+
constructor(func, link, ...values) {
|
|
10
16
|
super(false);
|
|
11
17
|
/**
|
|
12
18
|
* Expression will link different handler for each value of list
|
|
13
19
|
*/
|
|
14
20
|
this.linkedFunc = [];
|
|
15
|
-
const values = [v1, v2, v3, v4, v5, v6, v7, v8, v9].filter(v => v instanceof IValue);
|
|
16
21
|
const handler = (i) => {
|
|
17
22
|
if (i != null) {
|
|
18
23
|
this.valuesCache[i] = this.values[i].$;
|
|
@@ -21,14 +26,12 @@ export class Expression extends IValue {
|
|
|
21
26
|
};
|
|
22
27
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
23
28
|
// @ts-ignore
|
|
24
|
-
this.valuesCache = values.map(
|
|
29
|
+
this.valuesCache = values.map(item => item.$);
|
|
25
30
|
this.sync = new Reference(func.apply(this, this.valuesCache));
|
|
26
31
|
let i = 0;
|
|
27
32
|
values.forEach(() => {
|
|
28
33
|
this.linkedFunc.push(handler.bind(this, Number(i++)));
|
|
29
34
|
});
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
31
|
-
// @ts-ignore
|
|
32
35
|
this.values = values;
|
|
33
36
|
this.func = handler;
|
|
34
37
|
if (link) {
|
|
@@ -37,7 +40,7 @@ export class Expression extends IValue {
|
|
|
37
40
|
else {
|
|
38
41
|
handler();
|
|
39
42
|
}
|
|
40
|
-
this
|
|
43
|
+
this.seal();
|
|
41
44
|
}
|
|
42
45
|
get $() {
|
|
43
46
|
return this.sync.$;
|
|
@@ -73,11 +76,11 @@ export class Expression extends IValue {
|
|
|
73
76
|
}
|
|
74
77
|
return this;
|
|
75
78
|
}
|
|
76
|
-
|
|
79
|
+
destroy() {
|
|
77
80
|
this.disable();
|
|
78
81
|
this.values.splice(0);
|
|
79
82
|
this.valuesCache.splice(0);
|
|
80
83
|
this.linkedFunc.splice(0);
|
|
81
|
-
super
|
|
84
|
+
super.destroy();
|
|
82
85
|
}
|
|
83
86
|
}
|
package/lib/value/mirror.js
CHANGED
|
@@ -19,7 +19,7 @@ export class Mirror extends Reference {
|
|
|
19
19
|
this.pointedValue = value;
|
|
20
20
|
this.forwardOnly = forwardOnly;
|
|
21
21
|
value.on(this.handler);
|
|
22
|
-
this
|
|
22
|
+
this.seal();
|
|
23
23
|
}
|
|
24
24
|
get $() {
|
|
25
25
|
// this is a ts bug
|
|
@@ -28,13 +28,13 @@ export class Mirror extends Reference {
|
|
|
28
28
|
return super.$;
|
|
29
29
|
}
|
|
30
30
|
set $(v) {
|
|
31
|
+
if (!this.forwardOnly) {
|
|
32
|
+
this.pointedValue.$ = v;
|
|
33
|
+
}
|
|
31
34
|
// this is a ts bug
|
|
32
35
|
// eslint-disable-next-line
|
|
33
36
|
// @ts-ignore
|
|
34
37
|
super.$ = v;
|
|
35
|
-
if (!this.forwardOnly) {
|
|
36
|
-
this.pointedValue.$ = v;
|
|
37
|
-
}
|
|
38
38
|
}
|
|
39
39
|
enable() {
|
|
40
40
|
if (!this.isEnabled) {
|
|
@@ -42,17 +42,15 @@ export class Mirror extends Reference {
|
|
|
42
42
|
this.pointedValue.on(this.handler);
|
|
43
43
|
this.$ = this.pointedValue.$;
|
|
44
44
|
}
|
|
45
|
-
return this;
|
|
46
45
|
}
|
|
47
46
|
disable() {
|
|
48
47
|
if (this.isEnabled) {
|
|
49
48
|
this.pointedValue.off(this.handler);
|
|
50
49
|
this.isEnabled = false;
|
|
51
50
|
}
|
|
52
|
-
return this;
|
|
53
51
|
}
|
|
54
|
-
|
|
52
|
+
destroy() {
|
|
55
53
|
this.disable();
|
|
56
|
-
super
|
|
54
|
+
super.destroy();
|
|
57
55
|
}
|
|
58
56
|
}
|
package/lib/value/reference.js
CHANGED
|
@@ -12,7 +12,7 @@ export class Reference extends IValue {
|
|
|
12
12
|
super(true);
|
|
13
13
|
this.value = value;
|
|
14
14
|
this.onchange = new Set;
|
|
15
|
-
this
|
|
15
|
+
this.seal();
|
|
16
16
|
}
|
|
17
17
|
get $() {
|
|
18
18
|
return this.value;
|
|
@@ -34,22 +34,18 @@ export class Reference extends IValue {
|
|
|
34
34
|
});
|
|
35
35
|
this.isEnabled = true;
|
|
36
36
|
}
|
|
37
|
-
return this;
|
|
38
37
|
}
|
|
39
38
|
disable() {
|
|
40
39
|
this.isEnabled = false;
|
|
41
|
-
return this;
|
|
42
40
|
}
|
|
43
41
|
on(handler) {
|
|
44
42
|
this.onchange.add(handler);
|
|
45
|
-
return this;
|
|
46
43
|
}
|
|
47
44
|
off(handler) {
|
|
48
45
|
this.onchange.delete(handler);
|
|
49
|
-
return this;
|
|
50
46
|
}
|
|
51
|
-
|
|
52
|
-
super
|
|
47
|
+
destroy() {
|
|
48
|
+
super.destroy();
|
|
53
49
|
this.onchange.clear();
|
|
54
50
|
}
|
|
55
51
|
}
|
package/lib/views/array-view.js
CHANGED
|
@@ -5,17 +5,13 @@ import { BaseView } from "./base-view";
|
|
|
5
5
|
* @extends BaseView
|
|
6
6
|
*/
|
|
7
7
|
export class ArrayView extends BaseView {
|
|
8
|
-
|
|
9
|
-
super();
|
|
10
|
-
this.model = model;
|
|
8
|
+
createChild(input, id, item, before) {
|
|
9
|
+
super.createChild(input, item, item, before || this.$.nodes.get(id));
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
super.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.model.forEach(item => {
|
|
17
|
-
this.createChild(item, item);
|
|
11
|
+
compose(input) {
|
|
12
|
+
super.compose(input);
|
|
13
|
+
input.model.forEach(item => {
|
|
14
|
+
this.createChild(input, item, item);
|
|
18
15
|
});
|
|
19
|
-
super.$ready();
|
|
20
16
|
}
|
|
21
17
|
}
|
package/lib/views/base-view.js
CHANGED
|
@@ -7,7 +7,7 @@ import { RepeatNode, RepeatNodePrivate } from "./repeat-node";
|
|
|
7
7
|
export class BaseViewPrivate extends RepeatNodePrivate {
|
|
8
8
|
constructor() {
|
|
9
9
|
super();
|
|
10
|
-
this
|
|
10
|
+
this.seal();
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
@@ -17,33 +17,22 @@ export class BaseViewPrivate extends RepeatNodePrivate {
|
|
|
17
17
|
* @implements IModel
|
|
18
18
|
*/
|
|
19
19
|
export class BaseView extends RepeatNode {
|
|
20
|
-
constructor($
|
|
21
|
-
super($
|
|
20
|
+
constructor(input, $) {
|
|
21
|
+
super(input, $ || new BaseViewPrivate);
|
|
22
|
+
}
|
|
23
|
+
compose(input) {
|
|
22
24
|
const $ = this.$;
|
|
23
25
|
$.addHandler = (id, item) => {
|
|
24
|
-
this.createChild(id, item);
|
|
26
|
+
this.createChild(input, id, item);
|
|
25
27
|
};
|
|
26
28
|
$.removeHandler = (id, item) => {
|
|
27
29
|
this.destroyChild(id, item);
|
|
28
30
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const $ = this.$;
|
|
36
|
-
this.model.listener.onAdd($.addHandler);
|
|
37
|
-
this.model.listener.onRemove($.removeHandler);
|
|
38
|
-
super.$ready();
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Handles destroy event
|
|
42
|
-
*/
|
|
43
|
-
$destroy() {
|
|
44
|
-
const $ = this.$;
|
|
45
|
-
this.model.listener.offAdd($.addHandler);
|
|
46
|
-
this.model.listener.offRemove($.removeHandler);
|
|
47
|
-
super.$destroy();
|
|
31
|
+
input.model.listener.onAdd($.addHandler);
|
|
32
|
+
input.model.listener.onRemove($.removeHandler);
|
|
33
|
+
this.runOnDestroy(() => {
|
|
34
|
+
input.model.listener.offAdd($.addHandler);
|
|
35
|
+
input.model.listener.offRemove($.removeHandler);
|
|
36
|
+
});
|
|
48
37
|
}
|
|
49
38
|
}
|
package/lib/views/map-view.js
CHANGED
|
@@ -5,15 +5,10 @@ import { BaseView } from "./base-view";
|
|
|
5
5
|
* @extends BaseView
|
|
6
6
|
*/
|
|
7
7
|
export class MapView extends BaseView {
|
|
8
|
-
|
|
9
|
-
super();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
$ready() {
|
|
13
|
-
const map = this.model;
|
|
14
|
-
map.forEach((value, key) => {
|
|
15
|
-
this.createChild(key, value);
|
|
8
|
+
compose(input) {
|
|
9
|
+
super.compose(input);
|
|
10
|
+
input.model.forEach((value, key) => {
|
|
11
|
+
this.createChild(input, key, value);
|
|
16
12
|
});
|
|
17
|
-
super.$ready();
|
|
18
13
|
}
|
|
19
14
|
}
|
package/lib/views/object-view.js
CHANGED
|
@@ -5,15 +5,12 @@ import { BaseView } from "./base-view";
|
|
|
5
5
|
* @extends BaseView
|
|
6
6
|
*/
|
|
7
7
|
export class ObjectView extends BaseView {
|
|
8
|
-
|
|
9
|
-
super();
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
$ready() {
|
|
13
|
-
const obj = this.model;
|
|
8
|
+
compose(input) {
|
|
9
|
+
super.compose(input);
|
|
10
|
+
const obj = input.model.proxy();
|
|
14
11
|
for (const key in obj) {
|
|
15
|
-
this.createChild(key, obj[key]);
|
|
12
|
+
this.createChild(input, key, obj[key]);
|
|
16
13
|
}
|
|
17
|
-
super
|
|
14
|
+
super.ready();
|
|
18
15
|
}
|
|
19
16
|
}
|
package/lib/views/repeat-node.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Fragment, INodePrivate } from "../node/node";
|
|
2
|
-
import { Slot } from "../core/slot";
|
|
3
|
-
import { timeoutExecutor } from "../core/executor";
|
|
4
2
|
/**
|
|
5
3
|
* Private part of repeat node
|
|
6
4
|
* @class RepeatNodePrivate
|
|
@@ -14,11 +12,11 @@ export class RepeatNodePrivate extends INodePrivate {
|
|
|
14
12
|
* @type {Map}
|
|
15
13
|
*/
|
|
16
14
|
this.nodes = new Map();
|
|
17
|
-
this
|
|
15
|
+
this.seal();
|
|
18
16
|
}
|
|
19
|
-
|
|
17
|
+
destroy() {
|
|
20
18
|
this.nodes.clear();
|
|
21
|
-
super
|
|
19
|
+
super.destroy();
|
|
22
20
|
}
|
|
23
21
|
}
|
|
24
22
|
/**
|
|
@@ -27,80 +25,42 @@ export class RepeatNodePrivate extends INodePrivate {
|
|
|
27
25
|
* @extends Fragment
|
|
28
26
|
*/
|
|
29
27
|
export class RepeatNode extends Fragment {
|
|
30
|
-
constructor($) {
|
|
31
|
-
super($
|
|
28
|
+
constructor(input, $) {
|
|
29
|
+
super(input, $);
|
|
32
30
|
/**
|
|
33
31
|
* If false will use timeout executor, otherwise the app executor
|
|
34
32
|
*/
|
|
35
33
|
this.freezeUi = true;
|
|
36
|
-
this.slot = new Slot;
|
|
37
34
|
}
|
|
38
|
-
createChild(id, item, before) {
|
|
39
|
-
|
|
40
|
-
const node = new Fragment();
|
|
41
|
-
// eslint-disable-next-line
|
|
42
|
-
// @ts-ignore
|
|
43
|
-
const $ = node.$;
|
|
35
|
+
createChild(opts, id, item, before) {
|
|
36
|
+
const node = new Fragment({});
|
|
44
37
|
this.destroyChild(id, item);
|
|
45
38
|
if (before) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
$.prev = before.$.prev;
|
|
50
|
-
// eslint-disable-next-line
|
|
51
|
-
// @ts-ignore
|
|
52
|
-
before.$.prev = node;
|
|
53
|
-
if ($.prev) {
|
|
54
|
-
// eslint-disable-next-line
|
|
55
|
-
// @ts-ignore
|
|
56
|
-
$.prev.$.next = node;
|
|
57
|
-
}
|
|
58
|
-
this.$children.splice(this.$children.indexOf(before), 0, node);
|
|
39
|
+
this.children.add(node);
|
|
40
|
+
before.insertBefore(node);
|
|
59
41
|
}
|
|
60
42
|
else {
|
|
61
|
-
const lastChild = this
|
|
43
|
+
const lastChild = this.lastChild;
|
|
62
44
|
if (lastChild) {
|
|
63
|
-
|
|
64
|
-
// @ts-ignore
|
|
65
|
-
lastChild.$.next = node;
|
|
45
|
+
lastChild.insertAfter(node);
|
|
66
46
|
}
|
|
67
|
-
|
|
68
|
-
this.$children.push(node);
|
|
69
|
-
}
|
|
70
|
-
node.$preinit(this.$.app, this);
|
|
71
|
-
node.$init();
|
|
72
|
-
const callback = () => {
|
|
73
|
-
this.slot.release(node, item, id);
|
|
74
|
-
node.$ready();
|
|
75
|
-
};
|
|
76
|
-
if (this.freezeUi) {
|
|
77
|
-
this.$.app.$run.callCallback(callback);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
timeoutExecutor.callCallback(callback);
|
|
47
|
+
this.children.add(node);
|
|
81
48
|
}
|
|
49
|
+
this.lastChild = node;
|
|
50
|
+
node.preinit(this.$.app, this);
|
|
51
|
+
node.init();
|
|
52
|
+
opts.slot && opts.slot(node, item, id);
|
|
53
|
+
node.ready();
|
|
82
54
|
this.$.nodes.set(id, node);
|
|
83
55
|
}
|
|
84
56
|
destroyChild(id, item) {
|
|
85
57
|
const $ = this.$;
|
|
86
58
|
const child = $.nodes.get(id);
|
|
87
59
|
if (child) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const $ = child.$;
|
|
91
|
-
if ($.prev) {
|
|
92
|
-
// eslint-disable-next-line
|
|
93
|
-
// @ts-ignore
|
|
94
|
-
$.prev.$.next = $.next;
|
|
95
|
-
}
|
|
96
|
-
if ($.next) {
|
|
97
|
-
// eslint-disable-next-line
|
|
98
|
-
// @ts-ignore
|
|
99
|
-
$.next.$.prev = $.prev;
|
|
100
|
-
}
|
|
101
|
-
child.$destroy();
|
|
60
|
+
child.remove();
|
|
61
|
+
child.destroy();
|
|
102
62
|
this.$.nodes.delete(id);
|
|
103
|
-
this
|
|
63
|
+
this.children.delete(child);
|
|
104
64
|
}
|
|
105
65
|
}
|
|
106
66
|
}
|
package/lib/views/repeater.js
CHANGED
|
@@ -12,7 +12,7 @@ export class RepeaterPrivate extends RepeatNodePrivate {
|
|
|
12
12
|
* Current count of child nodes
|
|
13
13
|
*/
|
|
14
14
|
this.currentCount = 0;
|
|
15
|
-
this
|
|
15
|
+
this.seal();
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
@@ -27,7 +27,7 @@ export class Repeater extends RepeatNode {
|
|
|
27
27
|
* The count of children
|
|
28
28
|
*/
|
|
29
29
|
this.count = new Reference(0);
|
|
30
|
-
this
|
|
30
|
+
this.seal();
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Changes the children count
|
|
@@ -46,18 +46,18 @@ export class Repeater extends RepeatNode {
|
|
|
46
46
|
}
|
|
47
47
|
$.currentCount = number;
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
created() {
|
|
50
50
|
const $ = this.$;
|
|
51
|
-
super
|
|
51
|
+
super.created();
|
|
52
52
|
$.updateHandler = this.changeCount.bind(this);
|
|
53
53
|
this.count.on($.updateHandler);
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
ready() {
|
|
56
56
|
this.changeCount(this.count.$);
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
destroy() {
|
|
59
59
|
const $ = this.$;
|
|
60
|
-
super
|
|
60
|
+
super.destroy();
|
|
61
61
|
this.count.off($.updateHandler);
|
|
62
62
|
}
|
|
63
63
|
}
|
package/lib/views/set-view.js
CHANGED
|
@@ -5,18 +5,11 @@ import { BaseView } from "./base-view";
|
|
|
5
5
|
* @extends BaseView
|
|
6
6
|
*/
|
|
7
7
|
export class SetView extends BaseView {
|
|
8
|
-
|
|
9
|
-
super();
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
$ready() {
|
|
13
|
-
const $ = this.$;
|
|
14
|
-
const set = this.model;
|
|
8
|
+
compose(input) {
|
|
9
|
+
super.compose(input);
|
|
10
|
+
const set = input.model;
|
|
15
11
|
set.forEach(item => {
|
|
16
|
-
|
|
17
|
-
this.createChild(item, item);
|
|
18
|
-
});
|
|
12
|
+
this.createChild(input, item, item);
|
|
19
13
|
});
|
|
20
|
-
super.$ready();
|
|
21
14
|
}
|
|
22
15
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Vasille - Safe. Fast. Powerful.",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.2.1",
|
|
7
7
|
"exports": {
|
|
8
8
|
"import": "./lib/index.js",
|
|
9
9
|
"browser": "./lib/index.js"
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"test": "jest",
|
|
16
16
|
"test-coverage": "jest --coverage",
|
|
17
17
|
"update-types": "tsc --build tsconfig-types.json",
|
|
18
|
+
"update-flowjs": "node flow-typed/create.js",
|
|
18
19
|
"cdn-create": "node cdn/create.js",
|
|
19
20
|
"es5-check": "es-check es5 cdn/*es5.js"
|
|
20
21
|
},
|
|
@@ -45,6 +46,7 @@
|
|
|
45
46
|
"@typescript-eslint/parser": "latest",
|
|
46
47
|
"es-check": "latest",
|
|
47
48
|
"eslint": "latest",
|
|
49
|
+
"flow-bin": "latest",
|
|
48
50
|
"jest": "latest",
|
|
49
51
|
"jsdom": "latest",
|
|
50
52
|
"ts-jest": "latest",
|
|
@@ -6,18 +6,12 @@ import type { IValue } from "../core/ivalue";
|
|
|
6
6
|
* @class AttributeBinding
|
|
7
7
|
* @extends Binding
|
|
8
8
|
*/
|
|
9
|
-
export declare class AttributeBinding extends Binding<string> {
|
|
9
|
+
export declare class AttributeBinding extends Binding<string | number | boolean | null> {
|
|
10
10
|
/**
|
|
11
11
|
* Constructs an attribute binding description
|
|
12
12
|
* @param node {INode} the vasille node
|
|
13
13
|
* @param name {String} the name of attribute
|
|
14
14
|
* @param value {IValue} value to bind
|
|
15
15
|
*/
|
|
16
|
-
constructor(node: INode, name: string, value: IValue<string>);
|
|
17
|
-
/**
|
|
18
|
-
* Generates a function which updates the attribute value
|
|
19
|
-
* @param name {String} The name of attribute
|
|
20
|
-
* @returns {Function} a function which will update attribute value
|
|
21
|
-
*/
|
|
22
|
-
protected bound(name: string): (node: INode, value: string) => void;
|
|
16
|
+
constructor(node: INode, name: string, value: IValue<string | number | boolean | null>);
|
|
23
17
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Destroyable } from "../core/destroyable";
|
|
2
2
|
import type { IValue } from "../core/ivalue";
|
|
3
|
-
import type { INode } from "../node/node";
|
|
4
3
|
/**
|
|
5
4
|
* Describe a common binding logic
|
|
6
5
|
* @class Binding
|
|
@@ -8,23 +7,15 @@ import type { INode } from "../node/node";
|
|
|
8
7
|
*/
|
|
9
8
|
export declare class Binding<T> extends Destroyable {
|
|
10
9
|
private binding;
|
|
11
|
-
private
|
|
10
|
+
private func;
|
|
12
11
|
/**
|
|
13
12
|
* Constructs a common binding logic
|
|
14
|
-
* @param node {INode} the vasille node
|
|
15
|
-
* @param name {String} the name of property/attribute/class
|
|
16
13
|
* @param value {IValue} the value to bind
|
|
17
14
|
*/
|
|
18
|
-
constructor(
|
|
19
|
-
|
|
20
|
-
* Is a virtual function to get the specific bind function
|
|
21
|
-
* @param name {String} the name of attribute/property
|
|
22
|
-
* @returns {Function} a function to update attribute/property value
|
|
23
|
-
* @throws Always throws and must be overloaded in child class
|
|
24
|
-
*/
|
|
25
|
-
protected bound(name: string): (node: INode, value: T) => void;
|
|
15
|
+
constructor(value: IValue<T>);
|
|
16
|
+
protected init(bounded: (v: T) => void): void;
|
|
26
17
|
/**
|
|
27
18
|
* Just clear bindings
|
|
28
19
|
*/
|
|
29
|
-
|
|
20
|
+
destroy(): void;
|
|
30
21
|
}
|
package/types/binding/class.d.ts
CHANGED
|
@@ -1,23 +1,11 @@
|
|
|
1
1
|
import { Binding } from "./binding";
|
|
2
2
|
import type { INode } from "../node/node";
|
|
3
3
|
import type { IValue } from "../core/ivalue";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* Constructs an HTML class binding description
|
|
12
|
-
* @param node {INode} the vasille node
|
|
13
|
-
* @param name {String} the name of class
|
|
14
|
-
* @param value {IValue} the value to bind
|
|
15
|
-
*/
|
|
16
|
-
constructor(node: INode, name: string, value: IValue<string | boolean>);
|
|
17
|
-
/**
|
|
18
|
-
* Generates a function which updates the html class value
|
|
19
|
-
* @param name {String} The name of attribute
|
|
20
|
-
* @returns {Function} a function which will update attribute value
|
|
21
|
-
*/
|
|
22
|
-
protected bound(name: string): (node: INode, value: string | boolean) => void;
|
|
4
|
+
export declare class StaticClassBinding extends Binding<boolean> {
|
|
5
|
+
private current;
|
|
6
|
+
constructor(node: INode, name: string, value: IValue<boolean>);
|
|
7
|
+
}
|
|
8
|
+
export declare class DynamicalClassBinding extends Binding<string> {
|
|
9
|
+
private current;
|
|
10
|
+
constructor(node: INode, value: IValue<string>);
|
|
23
11
|
}
|
package/types/binding/style.d.ts
CHANGED
|
@@ -14,10 +14,4 @@ export declare class StyleBinding extends Binding<string> {
|
|
|
14
14
|
* @param value {IValue} the value to bind
|
|
15
15
|
*/
|
|
16
16
|
constructor(node: INode, name: string, value: IValue<string>);
|
|
17
|
-
/**
|
|
18
|
-
* Generates a function to update style property value
|
|
19
|
-
* @param name {string}
|
|
20
|
-
* @returns {Function} a function to update style property
|
|
21
|
-
*/
|
|
22
|
-
protected bound(name: string): (node: INode, value: string) => void;
|
|
23
17
|
}
|