vasille 2.3.9 → 3.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/README.md +57 -155
- package/lib/binding/attribute.js +4 -5
- package/lib/binding/binding.js +4 -5
- package/lib/binding/class.js +2 -4
- package/lib/binding/style.js +12 -4
- package/lib/core/config.js +3 -0
- package/lib/core/core.js +39 -177
- package/lib/core/destroyable.js +1 -36
- package/lib/core/ivalue.js +6 -49
- package/lib/functional/safety.js +7 -0
- package/lib/index.js +7 -8
- package/lib/models/array-model.js +40 -107
- package/lib/models/listener.js +16 -80
- package/lib/models/map-model.js +6 -13
- package/lib/models/object-model.js +6 -6
- package/lib/models/set-model.js +5 -12
- package/lib/node/app.js +8 -27
- package/lib/node/node.js +294 -524
- package/lib/node/watch.js +10 -8
- package/lib/tsconfig-build.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/value/expression.js +16 -41
- package/lib/value/mirror.js +9 -23
- package/lib/value/pointer.js +64 -16
- package/lib/value/reference.js +24 -29
- package/lib/views/array-view.js +5 -6
- package/lib/views/base-view.js +14 -26
- package/lib/views/map-view.js +4 -5
- package/lib/views/repeat-node.js +17 -34
- package/lib/views/set-view.js +7 -5
- package/lib-node/binding/attribute.js +4 -5
- package/lib-node/binding/binding.js +4 -5
- package/lib-node/binding/class.js +2 -4
- package/lib-node/binding/style.js +13 -4
- package/lib-node/core/config.js +6 -0
- package/lib-node/core/core.js +39 -180
- package/lib-node/core/destroyable.js +1 -36
- package/lib-node/core/ivalue.js +7 -51
- package/lib-node/functional/safety.js +12 -0
- package/lib-node/index.js +7 -12
- package/lib-node/models/array-model.js +41 -107
- package/lib-node/models/listener.js +16 -80
- package/lib-node/models/map-model.js +6 -13
- package/lib-node/models/object-model.js +6 -6
- package/lib-node/models/set-model.js +5 -12
- package/lib-node/node/app.js +8 -28
- package/lib-node/node/node.js +294 -529
- package/lib-node/node/watch.js +10 -8
- package/lib-node/tsconfig-build-node.tsbuildinfo +1 -1
- package/lib-node/value/expression.js +16 -41
- package/lib-node/value/mirror.js +9 -23
- package/lib-node/value/pointer.js +66 -17
- package/lib-node/value/reference.js +24 -29
- package/lib-node/views/array-view.js +5 -6
- package/lib-node/views/base-view.js +14 -27
- package/lib-node/views/map-view.js +4 -5
- package/lib-node/views/repeat-node.js +17 -35
- package/lib-node/views/set-view.js +7 -5
- package/package.json +9 -6
- package/types/binding/attribute.d.ts +2 -2
- package/types/binding/binding.d.ts +1 -1
- package/types/binding/style.d.ts +3 -2
- package/types/core/config.d.ts +3 -0
- package/types/core/core.d.ts +18 -93
- package/types/core/destroyable.d.ts +11 -6
- package/types/core/ivalue.d.ts +7 -24
- package/types/functional/options.d.ts +7 -22
- package/types/functional/safety.d.ts +2 -0
- package/types/index.d.ts +8 -10
- package/types/models/array-model.d.ts +6 -55
- package/types/models/listener.d.ts +0 -26
- package/types/models/map-model.d.ts +3 -4
- package/types/models/model.d.ts +2 -9
- package/types/models/set-model.d.ts +1 -2
- package/types/node/app.d.ts +7 -25
- package/types/node/node.d.ts +105 -222
- package/types/node/watch.d.ts +4 -5
- package/types/spec/html.d.ts +231 -231
- package/types/spec/svg.d.ts +166 -166
- package/types/tsconfig-types.tsbuildinfo +1 -1
- package/types/value/expression.d.ts +5 -7
- package/types/value/mirror.d.ts +4 -6
- package/types/value/pointer.d.ts +26 -9
- package/types/value/reference.d.ts +6 -7
- package/types/views/array-view.d.ts +3 -3
- package/types/views/base-view.d.ts +15 -23
- package/types/views/map-view.d.ts +2 -2
- package/types/views/repeat-node.d.ts +9 -23
- package/types/views/set-view.d.ts +3 -2
- package/cdn/es2015.js +0 -2480
- package/flow-typed/vasille.js +0 -2613
package/lib-node/node/watch.js
CHANGED
|
@@ -8,17 +8,19 @@ const node_1 = require("./node");
|
|
|
8
8
|
* @extends Fragment
|
|
9
9
|
*/
|
|
10
10
|
class Watch extends node_1.Fragment {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
constructor(input) {
|
|
12
|
+
super(input, ":watch");
|
|
13
|
+
}
|
|
14
|
+
compose() {
|
|
15
|
+
this.watch(value => {
|
|
16
|
+
var _a, _b;
|
|
13
17
|
this.children.forEach(child => {
|
|
14
|
-
child
|
|
18
|
+
child.destroy();
|
|
15
19
|
});
|
|
16
20
|
this.children.clear();
|
|
17
|
-
this.lastChild =
|
|
18
|
-
input.slot
|
|
19
|
-
}, input.model);
|
|
20
|
-
input.slot(this, input.model.$);
|
|
21
|
-
return {};
|
|
21
|
+
this.lastChild = undefined;
|
|
22
|
+
(_b = (_a = this.input).slot) === null || _b === void 0 ? void 0 : _b.call(_a, this, value);
|
|
23
|
+
}, this.input.model);
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
exports.Watch = Watch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/index.ts","../src/binding/attribute.ts","../src/binding/binding.ts","../src/binding/class.ts","../src/binding/style.ts","../src/core/core.ts","../src/core/destroyable.ts","../src/core/errors.ts","../src/core/ivalue.ts","../src/functional/options.ts","../src/
|
|
1
|
+
{"root":["../src/index.ts","../src/binding/attribute.ts","../src/binding/binding.ts","../src/binding/class.ts","../src/binding/style.ts","../src/core/config.ts","../src/core/core.ts","../src/core/destroyable.ts","../src/core/errors.ts","../src/core/ivalue.ts","../src/functional/options.ts","../src/functional/safety.ts","../src/models/array-model.ts","../src/models/listener.ts","../src/models/map-model.ts","../src/models/model.ts","../src/models/set-model.ts","../src/node/app.ts","../src/node/node.ts","../src/node/watch.ts","../src/value/expression.ts","../src/value/pointer.ts","../src/value/reference.ts","../src/views/array-view.ts","../src/views/base-view.ts","../src/views/map-view.ts","../src/views/repeat-node.ts","../src/views/set-view.ts"],"version":"5.6.2"}
|
|
@@ -15,14 +15,14 @@ class Expression extends ivalue_1.IValue {
|
|
|
15
15
|
* @param values
|
|
16
16
|
* @param link {Boolean} links immediately if true
|
|
17
17
|
*/
|
|
18
|
-
constructor(func,
|
|
19
|
-
super(
|
|
18
|
+
constructor(func, ...values) {
|
|
19
|
+
super();
|
|
20
20
|
/**
|
|
21
|
-
* Expression will link different handler for each value of list
|
|
21
|
+
* Expression will link different handler for each value of the list
|
|
22
22
|
*/
|
|
23
23
|
this.linkedFunc = [];
|
|
24
24
|
const handler = (i) => {
|
|
25
|
-
if (i
|
|
25
|
+
if (typeof i === "number") {
|
|
26
26
|
this.valuesCache[i] = this.values[i].$;
|
|
27
27
|
}
|
|
28
28
|
this.sync.$ = func.apply(this, this.valuesCache);
|
|
@@ -32,18 +32,13 @@ class Expression extends ivalue_1.IValue {
|
|
|
32
32
|
this.valuesCache = values.map(item => item.$);
|
|
33
33
|
this.sync = new reference_js_1.Reference(func.apply(this, this.valuesCache));
|
|
34
34
|
let i = 0;
|
|
35
|
-
values.forEach(
|
|
36
|
-
|
|
35
|
+
values.forEach(value => {
|
|
36
|
+
const updater = handler.bind(this, Number(i++));
|
|
37
|
+
this.linkedFunc.push(updater);
|
|
38
|
+
value.on(updater);
|
|
37
39
|
});
|
|
38
40
|
this.values = values;
|
|
39
41
|
this.func = handler;
|
|
40
|
-
if (link) {
|
|
41
|
-
this.$enable();
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
handler();
|
|
45
|
-
}
|
|
46
|
-
this.$seal();
|
|
47
42
|
}
|
|
48
43
|
get $() {
|
|
49
44
|
return this.sync.$;
|
|
@@ -51,40 +46,20 @@ class Expression extends ivalue_1.IValue {
|
|
|
51
46
|
set $(value) {
|
|
52
47
|
this.sync.$ = value;
|
|
53
48
|
}
|
|
54
|
-
|
|
55
|
-
this.sync
|
|
56
|
-
return this;
|
|
49
|
+
on(handler) {
|
|
50
|
+
this.sync.on(handler);
|
|
57
51
|
}
|
|
58
|
-
|
|
59
|
-
this.sync
|
|
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;
|
|
52
|
+
off(handler) {
|
|
53
|
+
this.sync.off(handler);
|
|
72
54
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
this.values[i].$off(this.linkedFunc[i]);
|
|
77
|
-
}
|
|
78
|
-
this.isEnabled = false;
|
|
55
|
+
destroy() {
|
|
56
|
+
for (let i = 0; i < this.values.length; i++) {
|
|
57
|
+
this.values[i].off(this.linkedFunc[i]);
|
|
79
58
|
}
|
|
80
|
-
return this;
|
|
81
|
-
}
|
|
82
|
-
$destroy() {
|
|
83
|
-
this.$disable();
|
|
84
59
|
this.values.splice(0);
|
|
85
60
|
this.valuesCache.splice(0);
|
|
86
61
|
this.linkedFunc.splice(0);
|
|
87
|
-
super
|
|
62
|
+
super.destroy();
|
|
88
63
|
}
|
|
89
64
|
}
|
|
90
65
|
exports.Expression = Expression;
|
package/lib-node/value/mirror.js
CHANGED
|
@@ -16,13 +16,12 @@ class Mirror extends reference_1.Reference {
|
|
|
16
16
|
*/
|
|
17
17
|
constructor(value, forwardOnly = false) {
|
|
18
18
|
super(value.$);
|
|
19
|
-
this
|
|
19
|
+
this.handler = (v) => {
|
|
20
20
|
this.$ = v;
|
|
21
21
|
};
|
|
22
|
-
this
|
|
23
|
-
this
|
|
24
|
-
value
|
|
25
|
-
this.$seal();
|
|
22
|
+
this.value = value;
|
|
23
|
+
this.forward = forwardOnly;
|
|
24
|
+
value.on(this.handler);
|
|
26
25
|
}
|
|
27
26
|
get $() {
|
|
28
27
|
// this is a ts bug
|
|
@@ -31,30 +30,17 @@ class Mirror extends reference_1.Reference {
|
|
|
31
30
|
return super.$;
|
|
32
31
|
}
|
|
33
32
|
set $(v) {
|
|
34
|
-
if (!this
|
|
35
|
-
this.$
|
|
33
|
+
if (!this.forward) {
|
|
34
|
+
this.value.$ = v;
|
|
36
35
|
}
|
|
37
36
|
// this is a ts bug
|
|
38
37
|
// eslint-disable-next-line
|
|
39
38
|
// @ts-ignore
|
|
40
39
|
super.$ = v;
|
|
41
40
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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();
|
|
41
|
+
destroy() {
|
|
42
|
+
this.value.off(this.handler);
|
|
43
|
+
super.destroy();
|
|
58
44
|
}
|
|
59
45
|
}
|
|
60
46
|
exports.Mirror = Mirror;
|
|
@@ -1,30 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Pointer = void 0;
|
|
4
|
-
const
|
|
3
|
+
exports.OwningPointer = exports.Pointer = void 0;
|
|
4
|
+
const ivalue_1 = require("../core/ivalue");
|
|
5
|
+
const reference_1 = require("./reference");
|
|
5
6
|
/**
|
|
6
7
|
* r/w pointer to a value
|
|
7
8
|
* @class Pointer
|
|
8
|
-
* @extends
|
|
9
|
+
* @extends IValue
|
|
9
10
|
*/
|
|
10
|
-
class Pointer extends
|
|
11
|
+
class Pointer extends ivalue_1.IValue {
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
-
* @param
|
|
13
|
+
* Constructs a notifiable bind to a value
|
|
14
|
+
* @param value {IValue} is initial valu
|
|
14
15
|
*/
|
|
15
|
-
constructor(value
|
|
16
|
-
super(
|
|
16
|
+
constructor(value) {
|
|
17
|
+
super();
|
|
18
|
+
this.handler = (v) => {
|
|
19
|
+
this.reference.$ = v;
|
|
20
|
+
};
|
|
21
|
+
this.target = value;
|
|
22
|
+
this.reference = new reference_1.Reference(value.$);
|
|
23
|
+
value.on(this.handler);
|
|
17
24
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
get $() {
|
|
26
|
+
return this.reference.$;
|
|
27
|
+
}
|
|
28
|
+
set $(v) {
|
|
29
|
+
var _a;
|
|
30
|
+
(_a = this.target) === null || _a === void 0 ? void 0 : _a.off(this.handler);
|
|
31
|
+
this.target = null;
|
|
32
|
+
this.reference.$ = v;
|
|
33
|
+
}
|
|
34
|
+
get $$() {
|
|
35
|
+
return this.reference.$;
|
|
36
|
+
}
|
|
37
|
+
set $$(v) {
|
|
38
|
+
if (this.target !== v) {
|
|
39
|
+
this.disconnectTarget();
|
|
40
|
+
}
|
|
41
|
+
if (v instanceof ivalue_1.IValue) {
|
|
42
|
+
this.target = v;
|
|
43
|
+
this.target.on(this.handler);
|
|
44
|
+
this.reference.$ = v.$;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.$ = v;
|
|
27
48
|
}
|
|
28
49
|
}
|
|
50
|
+
on(handler) {
|
|
51
|
+
this.reference.on(handler);
|
|
52
|
+
}
|
|
53
|
+
off(handler) {
|
|
54
|
+
this.reference.off(handler);
|
|
55
|
+
}
|
|
56
|
+
destroy() {
|
|
57
|
+
var _a;
|
|
58
|
+
(_a = this.target) === null || _a === void 0 ? void 0 : _a.off(this.handler);
|
|
59
|
+
this.reference.destroy();
|
|
60
|
+
super.destroy();
|
|
61
|
+
}
|
|
62
|
+
disconnectTarget() {
|
|
63
|
+
var _a;
|
|
64
|
+
(_a = this.target) === null || _a === void 0 ? void 0 : _a.off(this.handler);
|
|
65
|
+
}
|
|
29
66
|
}
|
|
30
67
|
exports.Pointer = Pointer;
|
|
68
|
+
class OwningPointer extends Pointer {
|
|
69
|
+
destroy() {
|
|
70
|
+
var _a;
|
|
71
|
+
(_a = this.target) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
72
|
+
super.destroy();
|
|
73
|
+
}
|
|
74
|
+
disconnectTarget() {
|
|
75
|
+
var _a;
|
|
76
|
+
(_a = this.target) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.OwningPointer = OwningPointer;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Reference = void 0;
|
|
4
4
|
const ivalue_1 = require("../core/ivalue");
|
|
5
|
+
const safety_1 = require("../functional/safety");
|
|
5
6
|
/**
|
|
6
7
|
* Declares a notifiable value
|
|
7
8
|
* @class Reference
|
|
@@ -12,44 +13,38 @@ class Reference extends ivalue_1.IValue {
|
|
|
12
13
|
* @param value {any} the initial value
|
|
13
14
|
*/
|
|
14
15
|
constructor(value) {
|
|
15
|
-
super(
|
|
16
|
-
this
|
|
17
|
-
this
|
|
18
|
-
this.$seal();
|
|
16
|
+
super();
|
|
17
|
+
this.state = value;
|
|
18
|
+
this.onChange = new Set();
|
|
19
19
|
}
|
|
20
20
|
get $() {
|
|
21
|
-
return this
|
|
21
|
+
return this.state;
|
|
22
22
|
}
|
|
23
23
|
set $(value) {
|
|
24
|
-
if (this
|
|
25
|
-
this
|
|
26
|
-
|
|
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;
|
|
24
|
+
if (this.state !== value) {
|
|
25
|
+
this.state = value;
|
|
26
|
+
this.updateDeps(value);
|
|
39
27
|
}
|
|
40
28
|
}
|
|
41
|
-
|
|
42
|
-
this.
|
|
29
|
+
on(handler) {
|
|
30
|
+
this.onChange.add(handler);
|
|
43
31
|
}
|
|
44
|
-
|
|
45
|
-
this
|
|
32
|
+
off(handler) {
|
|
33
|
+
this.onChange.delete(handler);
|
|
46
34
|
}
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
destroy() {
|
|
36
|
+
super.destroy();
|
|
37
|
+
this.onChange.clear();
|
|
49
38
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
updateDeps(value) {
|
|
40
|
+
this.onChange.forEach(handler => {
|
|
41
|
+
try {
|
|
42
|
+
handler(value);
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
(0, safety_1.reportError)(e);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
53
48
|
}
|
|
54
49
|
}
|
|
55
50
|
exports.Reference = Reference;
|
|
@@ -9,14 +9,13 @@ const base_view_1 = require("./base-view");
|
|
|
9
9
|
*/
|
|
10
10
|
class ArrayView extends base_view_1.BaseView {
|
|
11
11
|
createChild(input, id, item, before) {
|
|
12
|
-
super.createChild(input, item, item, before || this
|
|
12
|
+
super.createChild(input, item, item, before || this.nodes.get(id));
|
|
13
13
|
}
|
|
14
|
-
compose(
|
|
15
|
-
super.compose(
|
|
16
|
-
input.model.forEach(item => {
|
|
17
|
-
this.createChild(input, item, item);
|
|
14
|
+
compose() {
|
|
15
|
+
super.compose();
|
|
16
|
+
this.input.model.forEach(item => {
|
|
17
|
+
this.createChild(this.input, item, item);
|
|
18
18
|
});
|
|
19
|
-
return {};
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
exports.ArrayView = ArrayView;
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseView =
|
|
3
|
+
exports.BaseView = void 0;
|
|
4
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
5
|
/**
|
|
18
6
|
* Base class of default views
|
|
19
7
|
* @class BaseView
|
|
@@ -21,24 +9,23 @@ exports.BaseViewPrivate = BaseViewPrivate;
|
|
|
21
9
|
* @implements IModel
|
|
22
10
|
*/
|
|
23
11
|
class BaseView extends repeat_node_1.RepeatNode {
|
|
24
|
-
constructor(input,
|
|
25
|
-
super(input,
|
|
12
|
+
constructor(input, name) {
|
|
13
|
+
super(input, name);
|
|
26
14
|
}
|
|
27
|
-
compose(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.createChild(input, id, item);
|
|
15
|
+
compose() {
|
|
16
|
+
this.addHandler = (id, item) => {
|
|
17
|
+
this.createChild(this.input, id, item);
|
|
31
18
|
};
|
|
32
|
-
|
|
19
|
+
this.removeHandler = (id, item) => {
|
|
33
20
|
this.destroyChild(id, item);
|
|
34
21
|
};
|
|
35
|
-
input.model.listener.onAdd(
|
|
36
|
-
input.model.listener.onRemove(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
22
|
+
this.input.model.listener.onAdd(this.addHandler);
|
|
23
|
+
this.input.model.listener.onRemove(this.removeHandler);
|
|
24
|
+
}
|
|
25
|
+
destroy() {
|
|
26
|
+
this.input.model.listener.offAdd(this.addHandler);
|
|
27
|
+
this.input.model.listener.offRemove(this.removeHandler);
|
|
28
|
+
super.destroy();
|
|
42
29
|
}
|
|
43
30
|
}
|
|
44
31
|
exports.BaseView = BaseView;
|
|
@@ -8,12 +8,11 @@ const base_view_1 = require("./base-view");
|
|
|
8
8
|
* @extends BaseView
|
|
9
9
|
*/
|
|
10
10
|
class MapView extends base_view_1.BaseView {
|
|
11
|
-
compose(
|
|
12
|
-
super.compose(
|
|
13
|
-
input.model.forEach((value, key) => {
|
|
14
|
-
this.createChild(input, key, value);
|
|
11
|
+
compose() {
|
|
12
|
+
super.compose();
|
|
13
|
+
this.input.model.forEach((value, key) => {
|
|
14
|
+
this.createChild(this.input, key, value);
|
|
15
15
|
});
|
|
16
|
-
return {};
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
exports.MapView = MapView;
|
|
@@ -1,43 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RepeatNode =
|
|
3
|
+
exports.RepeatNode = void 0;
|
|
4
|
+
const config_1 = require("../core/config");
|
|
4
5
|
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
6
|
/**
|
|
27
7
|
* Repeat node repeats its children
|
|
28
8
|
* @class RepeatNode
|
|
29
9
|
* @extends Fragment
|
|
30
10
|
*/
|
|
31
11
|
class RepeatNode extends node_1.Fragment {
|
|
32
|
-
constructor(input,
|
|
33
|
-
super(input,
|
|
12
|
+
constructor(input, name) {
|
|
13
|
+
super(input, name);
|
|
34
14
|
/**
|
|
35
|
-
*
|
|
15
|
+
* Children node hash
|
|
16
|
+
* @type {Map}
|
|
36
17
|
*/
|
|
37
|
-
this.
|
|
18
|
+
this.nodes = new Map();
|
|
38
19
|
}
|
|
39
20
|
createChild(opts, id, item, before) {
|
|
40
|
-
const
|
|
21
|
+
const _id = id && typeof id === "object" && "id" in id ? id.id : config_1.config.debugUi ? JSON.stringify(id) : id;
|
|
22
|
+
const node = new node_1.Fragment({}, `${_id}`);
|
|
23
|
+
node.parent = this;
|
|
41
24
|
this.destroyChild(id, item);
|
|
42
25
|
if (before) {
|
|
43
26
|
this.children.add(node);
|
|
@@ -51,21 +34,20 @@ class RepeatNode extends node_1.Fragment {
|
|
|
51
34
|
this.children.add(node);
|
|
52
35
|
}
|
|
53
36
|
this.lastChild = node;
|
|
54
|
-
node.preinit(this.$.app, this);
|
|
55
|
-
node.init();
|
|
56
37
|
opts.slot && opts.slot(node, item, id);
|
|
57
|
-
|
|
58
|
-
this.$.nodes.set(id, node);
|
|
38
|
+
this.nodes.set(id, node);
|
|
59
39
|
}
|
|
60
40
|
destroyChild(id, item) {
|
|
61
|
-
const
|
|
62
|
-
const child = $.nodes.get(id);
|
|
41
|
+
const child = this.nodes.get(id);
|
|
63
42
|
if (child) {
|
|
64
43
|
child.remove();
|
|
65
|
-
child
|
|
66
|
-
this
|
|
44
|
+
child.destroy();
|
|
45
|
+
this.nodes.delete(id);
|
|
67
46
|
this.children.delete(child);
|
|
68
47
|
}
|
|
69
48
|
}
|
|
49
|
+
destroy() {
|
|
50
|
+
this.nodes.clear();
|
|
51
|
+
}
|
|
70
52
|
}
|
|
71
53
|
exports.RepeatNode = RepeatNode;
|
|
@@ -8,11 +8,13 @@ const base_view_1 = require("./base-view");
|
|
|
8
8
|
* @extends BaseView
|
|
9
9
|
*/
|
|
10
10
|
class SetView extends base_view_1.BaseView {
|
|
11
|
-
|
|
12
|
-
super
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
constructor(input) {
|
|
12
|
+
super(input, ":set-view");
|
|
13
|
+
}
|
|
14
|
+
compose() {
|
|
15
|
+
super.compose();
|
|
16
|
+
this.input.model.forEach(item => {
|
|
17
|
+
this.createChild(this.input, item, item);
|
|
16
18
|
});
|
|
17
19
|
return {};
|
|
18
20
|
}
|
package/package.json
CHANGED
|
@@ -3,18 +3,17 @@
|
|
|
3
3
|
"description": "Vasille - Safe. Simple. Powerful.",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "3.0.2",
|
|
7
7
|
"exports": {
|
|
8
8
|
"import": "./lib/index.js",
|
|
9
9
|
"browser": "./lib/index.js",
|
|
10
10
|
"node": "./lib-node/index.js",
|
|
11
11
|
"require": "./lib-node/index.js"
|
|
12
12
|
},
|
|
13
|
-
"unpkg": "./cdn/es2015.js",
|
|
14
13
|
"scripts": {
|
|
15
14
|
"prepack": "cp -f ../README.md ./README.md",
|
|
16
|
-
"prettier": "npx prettier src test --
|
|
17
|
-
"build": "tsc --build tsconfig
|
|
15
|
+
"prettier": "npx prettier src test --write",
|
|
16
|
+
"build": "tsc --build tsconfig.json",
|
|
18
17
|
"build-node": "tsc --build tsconfig-build-node.json",
|
|
19
18
|
"test": "jest",
|
|
20
19
|
"test-coverage": "jest --coverage",
|
|
@@ -23,7 +22,7 @@
|
|
|
23
22
|
},
|
|
24
23
|
"repository": {
|
|
25
24
|
"type": "git",
|
|
26
|
-
"url": "https://
|
|
25
|
+
"url": "git+https://github.com/vasille-js/vasille-js.git"
|
|
27
26
|
},
|
|
28
27
|
"type": "module",
|
|
29
28
|
"keywords": [
|
|
@@ -34,8 +33,12 @@
|
|
|
34
33
|
"simple",
|
|
35
34
|
"poweful"
|
|
36
35
|
],
|
|
37
|
-
"author": "
|
|
36
|
+
"author": "lixcode",
|
|
38
37
|
"license": "MIT",
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/vasille-js/vasille-js/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/vasille-js/vasille-js#readme",
|
|
39
42
|
"devDependencies": {
|
|
40
43
|
"@types/debug": "4.1.12",
|
|
41
44
|
"@types/eslint": "9.6.1",
|
|
@@ -6,12 +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 | number | boolean | null> {
|
|
9
|
+
export declare class AttributeBinding extends Binding<string | number | boolean | null | undefined> {
|
|
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 | number | boolean | null>);
|
|
16
|
+
constructor(node: INode, name: string, value: IValue<string | number | boolean | null | undefined>);
|
|
17
17
|
}
|
package/types/binding/style.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { Binding } from "./binding";
|
|
2
2
|
import type { INode } from "../node/node";
|
|
3
3
|
import type { IValue } from "../core/ivalue";
|
|
4
|
+
export declare function stringifyStyleValue(value: string | number | number[]): string;
|
|
4
5
|
/**
|
|
5
6
|
* Describes a style attribute binding
|
|
6
7
|
* @class StyleBinding
|
|
7
8
|
* @extends Binding
|
|
8
9
|
*/
|
|
9
|
-
export declare class StyleBinding extends Binding<string> {
|
|
10
|
+
export declare class StyleBinding extends Binding<string | number | number[]> {
|
|
10
11
|
/**
|
|
11
12
|
* Constructs a style binding attribute
|
|
12
13
|
* @param node {INode} the vasille node
|
|
13
14
|
* @param name {string} the name of style property
|
|
14
15
|
* @param value {IValue} the value to bind
|
|
15
16
|
*/
|
|
16
|
-
constructor(node: INode, name: string, value: IValue<string>);
|
|
17
|
+
constructor(node: INode, name: string, value: IValue<string | number | number[]>);
|
|
17
18
|
}
|