vasille 2.2.2 → 2.3.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/README.md +34 -28
- package/cdn/es2015.js +18 -724
- package/cdn/es5.js +687 -957
- package/flow-typed/vasille.js +14 -59
- package/lib/core/core.js +3 -3
- package/lib/index.js +5 -4
- package/lib/models/array-model.js +6 -9
- package/lib/models/object-model.js +3 -17
- package/lib/node/node.js +6 -3
- package/lib/views/object-view.js +1 -1
- package/lib-node/binding/attribute.js +35 -0
- package/lib-node/binding/binding.js +33 -0
- package/lib-node/binding/class.js +48 -0
- package/lib-node/binding/style.js +27 -0
- package/lib-node/core/core.js +243 -0
- package/lib-node/core/destroyable.js +49 -0
- package/lib-node/core/errors.js +23 -0
- package/lib-node/core/ivalue.js +63 -0
- package/lib-node/functional/options.js +2 -0
- package/lib-node/index.js +54 -0
- package/lib-node/models/array-model.js +218 -0
- package/lib-node/models/listener.js +134 -0
- package/lib-node/models/map-model.js +70 -0
- package/lib-node/models/model.js +2 -0
- package/lib-node/models/object-model.js +82 -0
- package/lib-node/models/set-model.js +66 -0
- package/lib-node/node/app.js +54 -0
- package/lib-node/node/node.js +885 -0
- package/lib-node/node/watch.js +23 -0
- package/lib-node/spec/html.js +2 -0
- package/lib-node/spec/react.js +2 -0
- package/lib-node/spec/svg.js +2 -0
- package/lib-node/value/expression.js +90 -0
- package/lib-node/value/mirror.js +60 -0
- package/lib-node/value/pointer.js +30 -0
- package/lib-node/value/reference.js +55 -0
- package/lib-node/views/array-view.js +21 -0
- package/lib-node/views/base-view.js +43 -0
- package/lib-node/views/map-view.js +18 -0
- package/lib-node/views/object-view.js +20 -0
- package/lib-node/views/repeat-node.js +71 -0
- package/lib-node/views/set-view.js +19 -0
- package/package.json +21 -17
- package/types/core/core.d.ts +4 -4
- package/types/functional/options.d.ts +2 -2
- package/types/index.d.ts +10 -7
- package/types/models/array-model.d.ts +1 -1
- package/types/models/object-model.d.ts +1 -1
- package/types/node/node.d.ts +5 -4
- package/types/node/watch.d.ts +2 -2
- package/types/views/repeat-node.d.ts +2 -2
- package/lib/core/executor.js +0 -154
- package/lib/core/signal.js +0 -50
- package/lib/core/slot.js +0 -47
- package/lib/functional/components.js +0 -17
- package/lib/functional/merge.js +0 -41
- package/lib/functional/models.js +0 -26
- package/lib/functional/reactivity.js +0 -33
- package/lib/functional/stack.js +0 -127
- package/lib/node/interceptor.js +0 -83
- package/lib/v/index.js +0 -23
- package/lib/views/repeater.js +0 -63
- package/types/functional/components.d.ts +0 -4
- package/types/functional/merge.d.ts +0 -1
- package/types/functional/models.d.ts +0 -10
- package/types/functional/reactivity.d.ts +0 -11
- package/types/functional/stack.d.ts +0 -24
- package/types/v/index.d.ts +0 -36
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Watch = void 0;
|
|
4
|
+
const node_1 = require("./node");
|
|
5
|
+
/**
|
|
6
|
+
* Watch Node
|
|
7
|
+
* @class Watch
|
|
8
|
+
* @extends Fragment
|
|
9
|
+
*/
|
|
10
|
+
class Watch extends node_1.Fragment {
|
|
11
|
+
compose(input) {
|
|
12
|
+
this.watch((value) => {
|
|
13
|
+
this.children.forEach(child => {
|
|
14
|
+
child.$destroy();
|
|
15
|
+
});
|
|
16
|
+
this.children.clear();
|
|
17
|
+
this.lastChild = null;
|
|
18
|
+
input.slot && input.slot(this, value);
|
|
19
|
+
}, input.model);
|
|
20
|
+
input.slot(this, input.model.$);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.Watch = Watch;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Expression = void 0;
|
|
4
|
+
const reference_js_1 = require("./reference.js");
|
|
5
|
+
const ivalue_1 = require("../core/ivalue");
|
|
6
|
+
/**
|
|
7
|
+
* Bind some values to one expression
|
|
8
|
+
* @class Expression
|
|
9
|
+
* @extends IValue
|
|
10
|
+
*/
|
|
11
|
+
class Expression extends ivalue_1.IValue {
|
|
12
|
+
/**
|
|
13
|
+
* Creates a function bounded to N values
|
|
14
|
+
* @param func {Function} the function to bound
|
|
15
|
+
* @param values
|
|
16
|
+
* @param link {Boolean} links immediately if true
|
|
17
|
+
*/
|
|
18
|
+
constructor(func, link, ...values) {
|
|
19
|
+
super(false);
|
|
20
|
+
/**
|
|
21
|
+
* Expression will link different handler for each value of list
|
|
22
|
+
*/
|
|
23
|
+
this.linkedFunc = [];
|
|
24
|
+
const handler = (i) => {
|
|
25
|
+
if (i != null) {
|
|
26
|
+
this.valuesCache[i] = this.values[i].$;
|
|
27
|
+
}
|
|
28
|
+
this.sync.$ = func.apply(this, this.valuesCache);
|
|
29
|
+
};
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
this.valuesCache = values.map(item => item.$);
|
|
33
|
+
this.sync = new reference_js_1.Reference(func.apply(this, this.valuesCache));
|
|
34
|
+
let i = 0;
|
|
35
|
+
values.forEach(() => {
|
|
36
|
+
this.linkedFunc.push(handler.bind(this, Number(i++)));
|
|
37
|
+
});
|
|
38
|
+
this.values = values;
|
|
39
|
+
this.func = handler;
|
|
40
|
+
if (link) {
|
|
41
|
+
this.$enable();
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
handler();
|
|
45
|
+
}
|
|
46
|
+
this.$seal();
|
|
47
|
+
}
|
|
48
|
+
get $() {
|
|
49
|
+
return this.sync.$;
|
|
50
|
+
}
|
|
51
|
+
set $(value) {
|
|
52
|
+
this.sync.$ = value;
|
|
53
|
+
}
|
|
54
|
+
$on(handler) {
|
|
55
|
+
this.sync.$on(handler);
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
$off(handler) {
|
|
59
|
+
this.sync.$off(handler);
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
$enable() {
|
|
63
|
+
if (!this.isEnabled) {
|
|
64
|
+
for (let i = 0; i < this.values.length; i++) {
|
|
65
|
+
this.values[i].$on(this.linkedFunc[i]);
|
|
66
|
+
this.valuesCache[i] = this.values[i].$;
|
|
67
|
+
}
|
|
68
|
+
this.func();
|
|
69
|
+
this.isEnabled = true;
|
|
70
|
+
}
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
$disable() {
|
|
74
|
+
if (this.isEnabled) {
|
|
75
|
+
for (let i = 0; i < this.values.length; i++) {
|
|
76
|
+
this.values[i].$off(this.linkedFunc[i]);
|
|
77
|
+
}
|
|
78
|
+
this.isEnabled = false;
|
|
79
|
+
}
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
$destroy() {
|
|
83
|
+
this.$disable();
|
|
84
|
+
this.values.splice(0);
|
|
85
|
+
this.valuesCache.splice(0);
|
|
86
|
+
this.linkedFunc.splice(0);
|
|
87
|
+
super.$destroy();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.Expression = Expression;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Mirror = void 0;
|
|
4
|
+
const reference_1 = require("./reference");
|
|
5
|
+
/**
|
|
6
|
+
* Declares a notifiable bind to a value
|
|
7
|
+
* @class Mirror
|
|
8
|
+
* @extends IValue
|
|
9
|
+
* @version 2
|
|
10
|
+
*/
|
|
11
|
+
class Mirror extends reference_1.Reference {
|
|
12
|
+
/**
|
|
13
|
+
* Constructs a notifiable bind to a value
|
|
14
|
+
* @param value {IValue} is initial value
|
|
15
|
+
* @param forwardOnly {boolean} ensure forward only synchronization
|
|
16
|
+
*/
|
|
17
|
+
constructor(value, forwardOnly = false) {
|
|
18
|
+
super(value.$);
|
|
19
|
+
this.$handler = (v) => {
|
|
20
|
+
this.$ = v;
|
|
21
|
+
};
|
|
22
|
+
this.$pointedValue = value;
|
|
23
|
+
this.$forwardOnly = forwardOnly;
|
|
24
|
+
value.$on(this.$handler);
|
|
25
|
+
this.$seal();
|
|
26
|
+
}
|
|
27
|
+
get $() {
|
|
28
|
+
// this is a ts bug
|
|
29
|
+
// eslint-disable-next-line
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
return super.$;
|
|
32
|
+
}
|
|
33
|
+
set $(v) {
|
|
34
|
+
if (!this.$forwardOnly) {
|
|
35
|
+
this.$pointedValue.$ = v;
|
|
36
|
+
}
|
|
37
|
+
// this is a ts bug
|
|
38
|
+
// eslint-disable-next-line
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
super.$ = v;
|
|
41
|
+
}
|
|
42
|
+
$enable() {
|
|
43
|
+
if (!this.isEnabled) {
|
|
44
|
+
this.isEnabled = true;
|
|
45
|
+
this.$pointedValue.$on(this.$handler);
|
|
46
|
+
this.$ = this.$pointedValue.$;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
$disable() {
|
|
50
|
+
if (this.isEnabled) {
|
|
51
|
+
this.$pointedValue.$off(this.$handler);
|
|
52
|
+
this.isEnabled = false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
$destroy() {
|
|
56
|
+
this.$disable();
|
|
57
|
+
super.$destroy();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.Mirror = Mirror;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Pointer = void 0;
|
|
4
|
+
const mirror_1 = require("./mirror");
|
|
5
|
+
/**
|
|
6
|
+
* r/w pointer to a value
|
|
7
|
+
* @class Pointer
|
|
8
|
+
* @extends Mirror
|
|
9
|
+
*/
|
|
10
|
+
class Pointer extends mirror_1.Mirror {
|
|
11
|
+
/**
|
|
12
|
+
* @param value {IValue} value to point
|
|
13
|
+
* @param forwardOnly {boolean} forward only data flow
|
|
14
|
+
*/
|
|
15
|
+
constructor(value, forwardOnly = false) {
|
|
16
|
+
super(value, forwardOnly);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Point a new ivalue
|
|
20
|
+
* @param value {IValue} value to point
|
|
21
|
+
*/
|
|
22
|
+
set $$(value) {
|
|
23
|
+
if (this.$pointedValue !== value) {
|
|
24
|
+
this.$disable();
|
|
25
|
+
this.$pointedValue = value;
|
|
26
|
+
this.$enable();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.Pointer = Pointer;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Reference = void 0;
|
|
4
|
+
const ivalue_1 = require("../core/ivalue");
|
|
5
|
+
/**
|
|
6
|
+
* Declares a notifiable value
|
|
7
|
+
* @class Reference
|
|
8
|
+
* @extends IValue
|
|
9
|
+
*/
|
|
10
|
+
class Reference extends ivalue_1.IValue {
|
|
11
|
+
/**
|
|
12
|
+
* @param value {any} the initial value
|
|
13
|
+
*/
|
|
14
|
+
constructor(value) {
|
|
15
|
+
super(true);
|
|
16
|
+
this.$value = value;
|
|
17
|
+
this.$onchange = new Set;
|
|
18
|
+
this.$seal();
|
|
19
|
+
}
|
|
20
|
+
get $() {
|
|
21
|
+
return this.$value;
|
|
22
|
+
}
|
|
23
|
+
set $(value) {
|
|
24
|
+
if (this.$value !== value) {
|
|
25
|
+
this.$value = value;
|
|
26
|
+
if (this.isEnabled) {
|
|
27
|
+
this.$onchange.forEach(handler => {
|
|
28
|
+
handler(value);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
$enable() {
|
|
34
|
+
if (!this.isEnabled) {
|
|
35
|
+
this.$onchange.forEach(handler => {
|
|
36
|
+
handler(this.$value);
|
|
37
|
+
});
|
|
38
|
+
this.isEnabled = true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
$disable() {
|
|
42
|
+
this.isEnabled = false;
|
|
43
|
+
}
|
|
44
|
+
$on(handler) {
|
|
45
|
+
this.$onchange.add(handler);
|
|
46
|
+
}
|
|
47
|
+
$off(handler) {
|
|
48
|
+
this.$onchange.delete(handler);
|
|
49
|
+
}
|
|
50
|
+
$destroy() {
|
|
51
|
+
super.$destroy();
|
|
52
|
+
this.$onchange.clear();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.Reference = Reference;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayView = void 0;
|
|
4
|
+
const base_view_1 = require("./base-view");
|
|
5
|
+
/**
|
|
6
|
+
* Represents a view of an array model
|
|
7
|
+
* @class ArrayView
|
|
8
|
+
* @extends BaseView
|
|
9
|
+
*/
|
|
10
|
+
class ArrayView extends base_view_1.BaseView {
|
|
11
|
+
createChild(input, id, item, before) {
|
|
12
|
+
super.createChild(input, item, item, before || this.$.nodes.get(id));
|
|
13
|
+
}
|
|
14
|
+
compose(input) {
|
|
15
|
+
super.compose(input);
|
|
16
|
+
input.model.forEach(item => {
|
|
17
|
+
this.createChild(input, item, item);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.ArrayView = ArrayView;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseView = exports.BaseViewPrivate = void 0;
|
|
4
|
+
const repeat_node_1 = require("./repeat-node");
|
|
5
|
+
/**
|
|
6
|
+
* Private part of BaseView
|
|
7
|
+
* @class BaseViewPrivate
|
|
8
|
+
* @extends RepeatNodePrivate
|
|
9
|
+
*/
|
|
10
|
+
class BaseViewPrivate extends repeat_node_1.RepeatNodePrivate {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.$seal();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.BaseViewPrivate = BaseViewPrivate;
|
|
17
|
+
/**
|
|
18
|
+
* Base class of default views
|
|
19
|
+
* @class BaseView
|
|
20
|
+
* @extends RepeatNode
|
|
21
|
+
* @implements IModel
|
|
22
|
+
*/
|
|
23
|
+
class BaseView extends repeat_node_1.RepeatNode {
|
|
24
|
+
constructor(input, $) {
|
|
25
|
+
super(input, $ || new BaseViewPrivate);
|
|
26
|
+
}
|
|
27
|
+
compose(input) {
|
|
28
|
+
const $ = this.$;
|
|
29
|
+
$.addHandler = (id, item) => {
|
|
30
|
+
this.createChild(input, id, item);
|
|
31
|
+
};
|
|
32
|
+
$.removeHandler = (id, item) => {
|
|
33
|
+
this.destroyChild(id, item);
|
|
34
|
+
};
|
|
35
|
+
input.model.listener.onAdd($.addHandler);
|
|
36
|
+
input.model.listener.onRemove($.removeHandler);
|
|
37
|
+
this.runOnDestroy(() => {
|
|
38
|
+
input.model.listener.offAdd($.addHandler);
|
|
39
|
+
input.model.listener.offRemove($.removeHandler);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.BaseView = BaseView;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MapView = void 0;
|
|
4
|
+
const base_view_1 = require("./base-view");
|
|
5
|
+
/**
|
|
6
|
+
* Create a children pack for each map value
|
|
7
|
+
* @class MapView
|
|
8
|
+
* @extends BaseView
|
|
9
|
+
*/
|
|
10
|
+
class MapView extends base_view_1.BaseView {
|
|
11
|
+
compose(input) {
|
|
12
|
+
super.compose(input);
|
|
13
|
+
input.model.forEach((value, key) => {
|
|
14
|
+
this.createChild(input, key, value);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.MapView = MapView;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjectView = void 0;
|
|
4
|
+
const base_view_1 = require("./base-view");
|
|
5
|
+
/**
|
|
6
|
+
* Create a children pack for each object field
|
|
7
|
+
* @class ObjectView
|
|
8
|
+
* @extends BaseView
|
|
9
|
+
*/
|
|
10
|
+
class ObjectView extends base_view_1.BaseView {
|
|
11
|
+
compose(input) {
|
|
12
|
+
super.compose(input);
|
|
13
|
+
const obj = input.model.values;
|
|
14
|
+
for (const key in obj) {
|
|
15
|
+
this.createChild(input, key, obj[key]);
|
|
16
|
+
}
|
|
17
|
+
super.ready();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.ObjectView = ObjectView;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RepeatNode = exports.RepeatNodePrivate = void 0;
|
|
4
|
+
const node_1 = require("../node/node");
|
|
5
|
+
/**
|
|
6
|
+
* Private part of repeat node
|
|
7
|
+
* @class RepeatNodePrivate
|
|
8
|
+
* @extends INodePrivate
|
|
9
|
+
*/
|
|
10
|
+
class RepeatNodePrivate extends node_1.INodePrivate {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
/**
|
|
14
|
+
* Children node hash
|
|
15
|
+
* @type {Map}
|
|
16
|
+
*/
|
|
17
|
+
this.nodes = new Map();
|
|
18
|
+
this.$seal();
|
|
19
|
+
}
|
|
20
|
+
$destroy() {
|
|
21
|
+
this.nodes.clear();
|
|
22
|
+
super.$destroy();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.RepeatNodePrivate = RepeatNodePrivate;
|
|
26
|
+
/**
|
|
27
|
+
* Repeat node repeats its children
|
|
28
|
+
* @class RepeatNode
|
|
29
|
+
* @extends Fragment
|
|
30
|
+
*/
|
|
31
|
+
class RepeatNode extends node_1.Fragment {
|
|
32
|
+
constructor(input, $) {
|
|
33
|
+
super(input, $);
|
|
34
|
+
/**
|
|
35
|
+
* If false will use timeout executor, otherwise the app executor
|
|
36
|
+
*/
|
|
37
|
+
this.freezeUi = true;
|
|
38
|
+
}
|
|
39
|
+
createChild(opts, id, item, before) {
|
|
40
|
+
const node = new node_1.Fragment({});
|
|
41
|
+
this.destroyChild(id, item);
|
|
42
|
+
if (before) {
|
|
43
|
+
this.children.add(node);
|
|
44
|
+
before.insertBefore(node);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const lastChild = this.lastChild;
|
|
48
|
+
if (lastChild) {
|
|
49
|
+
lastChild.insertAfter(node);
|
|
50
|
+
}
|
|
51
|
+
this.children.add(node);
|
|
52
|
+
}
|
|
53
|
+
this.lastChild = node;
|
|
54
|
+
node.preinit(this.$.app, this);
|
|
55
|
+
node.init();
|
|
56
|
+
opts.slot && opts.slot(node, item, id);
|
|
57
|
+
node.ready();
|
|
58
|
+
this.$.nodes.set(id, node);
|
|
59
|
+
}
|
|
60
|
+
destroyChild(id, item) {
|
|
61
|
+
const $ = this.$;
|
|
62
|
+
const child = $.nodes.get(id);
|
|
63
|
+
if (child) {
|
|
64
|
+
child.remove();
|
|
65
|
+
child.$destroy();
|
|
66
|
+
this.$.nodes.delete(id);
|
|
67
|
+
this.children.delete(child);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.RepeatNode = RepeatNode;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SetView = void 0;
|
|
4
|
+
const base_view_1 = require("./base-view");
|
|
5
|
+
/**
|
|
6
|
+
* Create a children pack for each set value
|
|
7
|
+
* @class SetView
|
|
8
|
+
* @extends BaseView
|
|
9
|
+
*/
|
|
10
|
+
class SetView extends base_view_1.BaseView {
|
|
11
|
+
compose(input) {
|
|
12
|
+
super.compose(input);
|
|
13
|
+
const set = input.model;
|
|
14
|
+
set.forEach(item => {
|
|
15
|
+
this.createChild(input, item, item);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.SetView = SetView;
|
package/package.json
CHANGED
|
@@ -3,26 +3,30 @@
|
|
|
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.3.2",
|
|
7
7
|
"exports": {
|
|
8
8
|
"import": "./lib/index.js",
|
|
9
|
-
"browser": "./lib/index.js"
|
|
9
|
+
"browser": "./lib/index.js",
|
|
10
|
+
"node": "./lib-node/index.js",
|
|
11
|
+
"require": "./lib-node/index.js"
|
|
10
12
|
},
|
|
11
13
|
"unpkg": "./cdn/es2015.js",
|
|
12
14
|
"scripts": {
|
|
13
15
|
"build": "tsc --build tsconfig-build.json",
|
|
14
16
|
"build-es5": "tsc --build tsconfig-build-es5.json",
|
|
17
|
+
"build-node": "tsc --build tsconfig-build-node.json",
|
|
15
18
|
"test": "jest",
|
|
16
19
|
"test-coverage": "jest --coverage",
|
|
17
20
|
"update-types": "tsc --build tsconfig-types.json",
|
|
18
|
-
"update-flowjs": "node flow-typed/create.
|
|
19
|
-
"cdn-create": "node cdn/create.
|
|
21
|
+
"update-flowjs": "node flow-typed/create.cjs",
|
|
22
|
+
"cdn-create": "node cdn/create.cjs",
|
|
20
23
|
"es5-check": "es-check es5 cdn/*es5.js"
|
|
21
24
|
},
|
|
22
25
|
"repository": {
|
|
23
26
|
"type": "git",
|
|
24
27
|
"url": "https://gitlab.com/vasille-js/vasille-js.git"
|
|
25
28
|
},
|
|
29
|
+
"type": "module",
|
|
26
30
|
"keywords": [
|
|
27
31
|
"front-end",
|
|
28
32
|
"web",
|
|
@@ -34,22 +38,22 @@
|
|
|
34
38
|
"author": "Vasile Lixcode <lixcode@vivaldi.net> (https://t.me/lixcode)",
|
|
35
39
|
"license": "MIT",
|
|
36
40
|
"devDependencies": {
|
|
37
|
-
"@types/debug": "
|
|
38
|
-
"@types/eslint": "
|
|
39
|
-
"@types/eslint-scope": "
|
|
40
|
-
"@types/estree": "
|
|
41
|
-
"@types/events": "
|
|
42
|
-
"@types/jest": "
|
|
43
|
-
"@types/jsdom": "
|
|
44
|
-
"@types/node": "
|
|
45
|
-
"@typescript-eslint/eslint-plugin": "
|
|
46
|
-
"@typescript-eslint/parser": "
|
|
41
|
+
"@types/debug": "4.1.7",
|
|
42
|
+
"@types/eslint": "8.4.1",
|
|
43
|
+
"@types/eslint-scope": "3.7.3",
|
|
44
|
+
"@types/estree": "0.0.51",
|
|
45
|
+
"@types/events": "3.0.0",
|
|
46
|
+
"@types/jest": "27.4.1",
|
|
47
|
+
"@types/jsdom": "16.2.14",
|
|
48
|
+
"@types/node": "17.0.23",
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "5.18.0",
|
|
50
|
+
"@typescript-eslint/parser": "5.18.0",
|
|
47
51
|
"es-check": "latest",
|
|
48
52
|
"eslint": "latest",
|
|
49
53
|
"flow-bin": "latest",
|
|
50
|
-
"jest": "
|
|
51
|
-
"jsdom": "
|
|
52
|
-
"ts-jest": "
|
|
54
|
+
"jest": "27.5.1",
|
|
55
|
+
"jsdom": "19.0.0",
|
|
56
|
+
"ts-jest": "27.1.4",
|
|
53
57
|
"typescript": "latest"
|
|
54
58
|
}
|
|
55
59
|
}
|
package/types/core/core.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Expression, KindOfIValue } from "../value/expression";
|
|
|
4
4
|
import { Pointer } from "../value/pointer";
|
|
5
5
|
import { Mirror } from "../value/mirror";
|
|
6
6
|
import { IModel } from "../models/model";
|
|
7
|
-
import {
|
|
7
|
+
import { FragmentOptions } from "../functional/options";
|
|
8
8
|
export declare let current: Reactive | null;
|
|
9
9
|
/**
|
|
10
10
|
* Private stuff of a reactive object
|
|
@@ -55,7 +55,7 @@ export declare class ReactivePrivate extends Destroyable {
|
|
|
55
55
|
* @class Reactive
|
|
56
56
|
* @extends Destroyable
|
|
57
57
|
*/
|
|
58
|
-
export declare class Reactive<T extends
|
|
58
|
+
export declare class Reactive<T extends FragmentOptions = FragmentOptions> extends Destroyable {
|
|
59
59
|
/**
|
|
60
60
|
* Private stuff
|
|
61
61
|
* @protected
|
|
@@ -121,10 +121,10 @@ export declare class Reactive<T extends Options = Options> extends Destroyable {
|
|
|
121
121
|
* @param onOn {function} on hide feedback
|
|
122
122
|
*/
|
|
123
123
|
bindAlive(cond: IValue<boolean>, onOff?: () => void, onOn?: () => void): this;
|
|
124
|
-
init():
|
|
124
|
+
init(): T['return'];
|
|
125
125
|
protected applyOptions(input: T): void;
|
|
126
126
|
protected applyOptionsNow(): void;
|
|
127
|
-
protected compose(input: T):
|
|
127
|
+
protected compose(input: T): T['return'];
|
|
128
128
|
protected composeNow(): void;
|
|
129
129
|
runFunctional<F extends (...args: any) => any>(f: F, ...args: Parameters<F>): ReturnType<F>;
|
|
130
130
|
runOnDestroy(func: () => void): void;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { IValue } from "../core/ivalue";
|
|
2
2
|
import { AcceptedTagsMap, AcceptedTagsSpec } from "../spec/react";
|
|
3
3
|
import type { Fragment } from "../node/node";
|
|
4
|
-
export interface
|
|
4
|
+
export interface FragmentOptions {
|
|
5
5
|
"v:is"?: Record<string, IValue<any>>;
|
|
6
6
|
return?: any;
|
|
7
7
|
slot?: (node: Fragment, ...args: any[]) => void;
|
|
8
8
|
}
|
|
9
9
|
export declare type AttrType<T> = IValue<T | string | null> | T | string | null | undefined;
|
|
10
|
-
export interface TagOptions<T extends keyof AcceptedTagsMap> extends
|
|
10
|
+
export interface TagOptions<T extends keyof AcceptedTagsMap> extends FragmentOptions {
|
|
11
11
|
"v:attr"?: {
|
|
12
12
|
[K in keyof AcceptedTagsSpec[T]['attrs']]?: AttrType<AcceptedTagsSpec[T]['attrs'][K]>;
|
|
13
13
|
} & Record<string, AttrType<number | boolean>>;
|
package/types/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Destroyable } from "./core/destroyable";
|
|
2
|
-
import { Reactive } from "./core/core";
|
|
2
|
+
import { current, Reactive } from "./core/core";
|
|
3
3
|
import { IValue } from "./core/ivalue";
|
|
4
4
|
import { ArrayModel } from "./models/array-model";
|
|
5
5
|
import { Listener } from "./models/listener";
|
|
6
6
|
import { MapModel } from "./models/map-model";
|
|
7
7
|
import { ObjectModel } from "./models/object-model";
|
|
8
8
|
import { SetModel } from "./models/set-model";
|
|
9
|
-
import { App, AppNode } from "./node/app";
|
|
10
|
-
import { Component, Extension, Fragment, INode, Tag } from "./node/node";
|
|
11
|
-
import { Expression } from "./value/expression";
|
|
9
|
+
import { App, AppNode, AppOptions, Portal } from "./node/app";
|
|
10
|
+
import { Component, Extension, Fragment, INode, Tag, TagOptionsWithSlot } from "./node/node";
|
|
11
|
+
import { Expression, KindOfIValue } from "./value/expression";
|
|
12
12
|
import { Mirror } from "./value/mirror";
|
|
13
13
|
import { Pointer } from "./value/pointer";
|
|
14
14
|
import { Reference } from "./value/reference";
|
|
@@ -18,6 +18,9 @@ import { MapView } from "./views/map-view";
|
|
|
18
18
|
import { ObjectView } from "./views/object-view";
|
|
19
19
|
import { SetView } from "./views/set-view";
|
|
20
20
|
import { Binding } from "./binding/binding";
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
|
|
21
|
+
import { FragmentOptions, TagOptions } from "./functional/options";
|
|
22
|
+
import { AcceptedTagsMap, AcceptedTagsSpec } from "./spec/react";
|
|
23
|
+
import { userError } from "./core/errors";
|
|
24
|
+
import { ListenableModel } from "./models/model";
|
|
25
|
+
import { Watch } from "./node/watch";
|
|
26
|
+
export { Destroyable, IValue, Reference, Mirror, Pointer, ArrayModel, MapModel, ObjectModel, SetModel, BaseView, Listener, ArrayView, MapView, ObjectView, SetView, Fragment, INode, Tag, Component, Extension, AppNode, App, Portal, Expression, Binding, Reactive, Watch, FragmentOptions, TagOptions, AppOptions, AcceptedTagsSpec, AcceptedTagsMap, userError, current, KindOfIValue, ListenableModel, TagOptionsWithSlot, };
|
|
@@ -11,7 +11,6 @@ export declare class ArrayModel<T> extends Array<T> implements ListenableModel<T
|
|
|
11
11
|
* @param data {Array} input data
|
|
12
12
|
*/
|
|
13
13
|
constructor(data?: Array<T>);
|
|
14
|
-
proxy(): ArrayModel<T>;
|
|
15
14
|
/**
|
|
16
15
|
* Gets the last item of array
|
|
17
16
|
* @return {*} the last item of array
|
|
@@ -99,6 +98,7 @@ export declare class ArrayModel<T> extends Array<T> implements ListenableModel<T
|
|
|
99
98
|
* @return {this}
|
|
100
99
|
*/
|
|
101
100
|
removeOne(v: T): this;
|
|
101
|
+
replace(at: number, with_: T): this;
|
|
102
102
|
enableReactivity(): void;
|
|
103
103
|
disableReactivity(): void;
|
|
104
104
|
}
|
|
@@ -27,12 +27,12 @@ export declare class ObjectModel<T> extends Object implements ListenableModel<st
|
|
|
27
27
|
* @return {ObjectModel} a pointer to this
|
|
28
28
|
*/
|
|
29
29
|
set(key: string, v: T): this;
|
|
30
|
+
get values(): Record<string, T>;
|
|
30
31
|
/**
|
|
31
32
|
* Deletes an object property
|
|
32
33
|
* @param key {string} property name
|
|
33
34
|
*/
|
|
34
35
|
delete(key: string): void;
|
|
35
|
-
proxy(): Record<string, T>;
|
|
36
36
|
enableReactivity(): void;
|
|
37
37
|
disableReactivity(): void;
|
|
38
38
|
}
|