vasille 2.3.0 → 2.3.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/cdn/es2015.js +0 -692
- package/cdn/es5.js +661 -926
- package/flow-typed/vasille.js +0 -46
- 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 +49 -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/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,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayModel = void 0;
|
|
4
|
+
const listener_1 = require("./listener");
|
|
5
|
+
/**
|
|
6
|
+
* Model based on Array class
|
|
7
|
+
* @extends Array
|
|
8
|
+
* @implements IModel
|
|
9
|
+
*/
|
|
10
|
+
class ArrayModel extends Array {
|
|
11
|
+
/**
|
|
12
|
+
* @param data {Array} input data
|
|
13
|
+
*/
|
|
14
|
+
constructor(data = []) {
|
|
15
|
+
super();
|
|
16
|
+
Object.defineProperty(this, 'listener', {
|
|
17
|
+
value: new listener_1.Listener,
|
|
18
|
+
writable: false,
|
|
19
|
+
configurable: false
|
|
20
|
+
});
|
|
21
|
+
for (let i = 0; i < data.length; i++) {
|
|
22
|
+
super.push(data[i]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/* Array members */
|
|
26
|
+
/**
|
|
27
|
+
* Gets the last item of array
|
|
28
|
+
* @return {*} the last item of array
|
|
29
|
+
*/
|
|
30
|
+
get last() {
|
|
31
|
+
return this.length ? this[this.length - 1] : null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Calls Array.fill and notify about changes
|
|
35
|
+
* @param value {*} value to fill with
|
|
36
|
+
* @param start {?number} begin index
|
|
37
|
+
* @param end {?number} end index
|
|
38
|
+
*/
|
|
39
|
+
fill(value, start, end) {
|
|
40
|
+
if (!start) {
|
|
41
|
+
start = 0;
|
|
42
|
+
}
|
|
43
|
+
if (!end) {
|
|
44
|
+
end = this.length;
|
|
45
|
+
}
|
|
46
|
+
for (let i = start; i < end; i++) {
|
|
47
|
+
this.listener.emitRemoved(this[i], this[i]);
|
|
48
|
+
this[i] = value;
|
|
49
|
+
this.listener.emitAdded(value, value);
|
|
50
|
+
}
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Calls Array.pop and notify about changes
|
|
55
|
+
* @return {*} removed value
|
|
56
|
+
*/
|
|
57
|
+
pop() {
|
|
58
|
+
const v = super.pop();
|
|
59
|
+
if (v !== undefined) {
|
|
60
|
+
this.listener.emitRemoved(v, v);
|
|
61
|
+
}
|
|
62
|
+
return v;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Calls Array.push and notify about changes
|
|
66
|
+
* @param items {...*} values to push
|
|
67
|
+
* @return {number} new length of array
|
|
68
|
+
*/
|
|
69
|
+
push(...items) {
|
|
70
|
+
items.forEach(item => {
|
|
71
|
+
this.listener.emitAdded(item, item);
|
|
72
|
+
super.push(item);
|
|
73
|
+
});
|
|
74
|
+
return this.length;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Calls Array.shift and notify about changed
|
|
78
|
+
* @return {*} the shifted value
|
|
79
|
+
*/
|
|
80
|
+
shift() {
|
|
81
|
+
const v = super.shift();
|
|
82
|
+
if (v !== undefined) {
|
|
83
|
+
this.listener.emitRemoved(v, v);
|
|
84
|
+
}
|
|
85
|
+
return v;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Calls Array.splice and notify about changed
|
|
89
|
+
* @param start {number} start index
|
|
90
|
+
* @param deleteCount {?number} delete count
|
|
91
|
+
* @param items {...*}
|
|
92
|
+
* @return {ArrayModel} a pointer to this
|
|
93
|
+
*/
|
|
94
|
+
splice(start, deleteCount, ...items) {
|
|
95
|
+
start = Math.min(start, this.length);
|
|
96
|
+
deleteCount = deleteCount || this.length - start;
|
|
97
|
+
const before = this[start + deleteCount];
|
|
98
|
+
for (let i = 0; i < deleteCount; i++) {
|
|
99
|
+
const index = start + deleteCount - i - 1;
|
|
100
|
+
if (this[index] !== undefined) {
|
|
101
|
+
this.listener.emitRemoved(this[index], this[index]);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
for (let i = 0; i < items.length; i++) {
|
|
105
|
+
this.listener.emitAdded(before, items[i]);
|
|
106
|
+
}
|
|
107
|
+
return new ArrayModel(super.splice(start, deleteCount, ...items));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Calls Array.unshift and notify about changed
|
|
111
|
+
* @param items {...*} values to insert
|
|
112
|
+
* @return {number} the length after prepend
|
|
113
|
+
*/
|
|
114
|
+
unshift(...items) {
|
|
115
|
+
for (let i = 0; i < items.length; i++) {
|
|
116
|
+
this.listener.emitAdded(this[i], items[i]);
|
|
117
|
+
}
|
|
118
|
+
return super.unshift(...items);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Inserts a value to the end of array
|
|
122
|
+
* @param v {*} value to insert
|
|
123
|
+
*/
|
|
124
|
+
append(v) {
|
|
125
|
+
this.listener.emitAdded(null, v);
|
|
126
|
+
super.push(v);
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Clears array
|
|
131
|
+
* @return {this} a pointer to this
|
|
132
|
+
*/
|
|
133
|
+
clear() {
|
|
134
|
+
this.forEach(v => {
|
|
135
|
+
this.listener.emitRemoved(v, v);
|
|
136
|
+
});
|
|
137
|
+
super.splice(0);
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Inserts a value to position `index`
|
|
142
|
+
* @param index {number} index to insert value
|
|
143
|
+
* @param v {*} value to insert
|
|
144
|
+
* @return {this} a pointer to this
|
|
145
|
+
*/
|
|
146
|
+
insert(index, v) {
|
|
147
|
+
this.listener.emitAdded(this[index], v);
|
|
148
|
+
super.splice(index, 0, v);
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Inserts a value to the beginning of array
|
|
153
|
+
* @param v {*} value to insert
|
|
154
|
+
* @return {this} a pointer to this
|
|
155
|
+
*/
|
|
156
|
+
prepend(v) {
|
|
157
|
+
this.listener.emitAdded(this[0], v);
|
|
158
|
+
super.unshift(v);
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Removes a value from an index
|
|
163
|
+
* @param index {number} index of value to remove
|
|
164
|
+
* @return {this} a pointer to this
|
|
165
|
+
*/
|
|
166
|
+
removeAt(index) {
|
|
167
|
+
if (index > 0 && index < this.length) {
|
|
168
|
+
this.listener.emitRemoved(this[index], this[index]);
|
|
169
|
+
super.splice(index, 1);
|
|
170
|
+
}
|
|
171
|
+
return this;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Removes the first value of array
|
|
175
|
+
* @return {this} a pointer to this
|
|
176
|
+
*/
|
|
177
|
+
removeFirst() {
|
|
178
|
+
if (this.length) {
|
|
179
|
+
this.listener.emitRemoved(this[0], this[0]);
|
|
180
|
+
super.shift();
|
|
181
|
+
}
|
|
182
|
+
return this;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Removes the ast value of array
|
|
186
|
+
* @return {this} a pointer to this
|
|
187
|
+
*/
|
|
188
|
+
removeLast() {
|
|
189
|
+
const last = this.last;
|
|
190
|
+
if (last != null) {
|
|
191
|
+
this.listener.emitRemoved(this[this.length - 1], last);
|
|
192
|
+
super.pop();
|
|
193
|
+
}
|
|
194
|
+
return this;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Remove the first occurrence of value
|
|
198
|
+
* @param v {*} value to remove
|
|
199
|
+
* @return {this}
|
|
200
|
+
*/
|
|
201
|
+
removeOne(v) {
|
|
202
|
+
this.removeAt(this.indexOf(v));
|
|
203
|
+
return this;
|
|
204
|
+
}
|
|
205
|
+
replace(at, with_) {
|
|
206
|
+
this.listener.emitAdded(this[at], with_);
|
|
207
|
+
this.listener.emitRemoved(this[at], this[at]);
|
|
208
|
+
this[at] = with_;
|
|
209
|
+
return this;
|
|
210
|
+
}
|
|
211
|
+
enableReactivity() {
|
|
212
|
+
this.listener.enableReactivity();
|
|
213
|
+
}
|
|
214
|
+
disableReactivity() {
|
|
215
|
+
this.listener.disableReactivity();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
exports.ArrayModel = ArrayModel;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Listener = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Represent a listener for a model
|
|
6
|
+
* @class Listener
|
|
7
|
+
*/
|
|
8
|
+
class Listener {
|
|
9
|
+
constructor() {
|
|
10
|
+
Object.defineProperties(this, {
|
|
11
|
+
onAdded: {
|
|
12
|
+
value: new Set,
|
|
13
|
+
writable: false,
|
|
14
|
+
configurable: false
|
|
15
|
+
},
|
|
16
|
+
onRemoved: {
|
|
17
|
+
value: new Set,
|
|
18
|
+
writable: false,
|
|
19
|
+
configurable: false
|
|
20
|
+
},
|
|
21
|
+
frozen: {
|
|
22
|
+
value: false,
|
|
23
|
+
writable: true,
|
|
24
|
+
configurable: false
|
|
25
|
+
},
|
|
26
|
+
queue: {
|
|
27
|
+
value: [],
|
|
28
|
+
writable: false,
|
|
29
|
+
configurable: false
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Exclude the repeated operation in queue
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
excludeRepeat(index) {
|
|
38
|
+
this.queue.forEach((item, i) => {
|
|
39
|
+
if (item.index === index) {
|
|
40
|
+
this.queue.splice(i, 1);
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Emits added event to listeners
|
|
48
|
+
* @param index {*} index of value
|
|
49
|
+
* @param value {*} value of added item
|
|
50
|
+
*/
|
|
51
|
+
emitAdded(index, value) {
|
|
52
|
+
if (this.frozen) {
|
|
53
|
+
if (!this.excludeRepeat(index)) {
|
|
54
|
+
this.queue.push({ sign: true, index, value });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.onAdded.forEach(handler => {
|
|
59
|
+
handler(index, value);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Emits removed event to listeners
|
|
65
|
+
* @param index {*} index of removed value
|
|
66
|
+
* @param value {*} value of removed item
|
|
67
|
+
*/
|
|
68
|
+
emitRemoved(index, value) {
|
|
69
|
+
if (this.frozen) {
|
|
70
|
+
if (!this.excludeRepeat(index)) {
|
|
71
|
+
this.queue.push({ sign: false, index, value });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
this.onRemoved.forEach(handler => {
|
|
76
|
+
handler(index, value);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Adds a handler to added event
|
|
82
|
+
* @param handler {function} function to run on event emitting
|
|
83
|
+
*/
|
|
84
|
+
onAdd(handler) {
|
|
85
|
+
this.onAdded.add(handler);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Adds a handler to removed event
|
|
89
|
+
* @param handler {function} function to run on event emitting
|
|
90
|
+
*/
|
|
91
|
+
onRemove(handler) {
|
|
92
|
+
this.onRemoved.add(handler);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Removes an handler from added event
|
|
96
|
+
* @param handler {function} handler to remove
|
|
97
|
+
*/
|
|
98
|
+
offAdd(handler) {
|
|
99
|
+
this.onAdded.delete(handler);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Removes an handler form removed event
|
|
103
|
+
* @param handler {function} handler to remove
|
|
104
|
+
*/
|
|
105
|
+
offRemove(handler) {
|
|
106
|
+
this.onRemoved.delete(handler);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Run all queued operation and enable reactivity
|
|
110
|
+
*/
|
|
111
|
+
enableReactivity() {
|
|
112
|
+
this.queue.forEach(item => {
|
|
113
|
+
if (item.sign) {
|
|
114
|
+
this.onAdded.forEach(handler => {
|
|
115
|
+
handler(item.index, item.value);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
this.onRemoved.forEach(handler => {
|
|
120
|
+
handler(item.index, item.value);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
this.queue.splice(0);
|
|
125
|
+
this.frozen = false;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Disable the reactivity and enable the queue
|
|
129
|
+
*/
|
|
130
|
+
disableReactivity() {
|
|
131
|
+
this.frozen = true;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.Listener = Listener;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MapModel = void 0;
|
|
4
|
+
const listener_1 = require("./listener");
|
|
5
|
+
/**
|
|
6
|
+
* A Map based memory
|
|
7
|
+
* @class MapModel
|
|
8
|
+
* @extends Map
|
|
9
|
+
* @implements IModel
|
|
10
|
+
*/
|
|
11
|
+
class MapModel extends Map {
|
|
12
|
+
/**
|
|
13
|
+
* Constructs a map model
|
|
14
|
+
* @param map {[*, *][]} input data
|
|
15
|
+
*/
|
|
16
|
+
constructor(map = []) {
|
|
17
|
+
super();
|
|
18
|
+
Object.defineProperty(this, 'listener', {
|
|
19
|
+
value: new listener_1.Listener,
|
|
20
|
+
writable: false,
|
|
21
|
+
configurable: false
|
|
22
|
+
});
|
|
23
|
+
map.forEach(([key, value]) => {
|
|
24
|
+
super.set(key, value);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Calls Map.clear and notify abut changes
|
|
29
|
+
*/
|
|
30
|
+
clear() {
|
|
31
|
+
this.forEach((value, key) => {
|
|
32
|
+
this.listener.emitRemoved(key, value);
|
|
33
|
+
});
|
|
34
|
+
super.clear();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Calls Map.delete and notify abut changes
|
|
38
|
+
* @param key {*} key
|
|
39
|
+
* @return {boolean} true if removed something, otherwise false
|
|
40
|
+
*/
|
|
41
|
+
delete(key) {
|
|
42
|
+
const tmp = super.get(key);
|
|
43
|
+
if (tmp) {
|
|
44
|
+
this.listener.emitRemoved(key, tmp);
|
|
45
|
+
}
|
|
46
|
+
return super.delete(key);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Calls Map.set and notify abut changes
|
|
50
|
+
* @param key {*} key
|
|
51
|
+
* @param value {*} value
|
|
52
|
+
* @return {MapModel} a pointer to this
|
|
53
|
+
*/
|
|
54
|
+
set(key, value) {
|
|
55
|
+
const tmp = super.get(key);
|
|
56
|
+
if (tmp) {
|
|
57
|
+
this.listener.emitRemoved(key, tmp);
|
|
58
|
+
}
|
|
59
|
+
super.set(key, value);
|
|
60
|
+
this.listener.emitAdded(key, value);
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
enableReactivity() {
|
|
64
|
+
this.listener.enableReactivity();
|
|
65
|
+
}
|
|
66
|
+
disableReactivity() {
|
|
67
|
+
this.listener.disableReactivity();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.MapModel = MapModel;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjectModel = void 0;
|
|
4
|
+
const listener_1 = require("./listener");
|
|
5
|
+
/**
|
|
6
|
+
* Object based model
|
|
7
|
+
* @extends Object
|
|
8
|
+
*/
|
|
9
|
+
class ObjectModel extends Object {
|
|
10
|
+
/**
|
|
11
|
+
* Constructs a object model
|
|
12
|
+
* @param obj {Object} input data
|
|
13
|
+
*/
|
|
14
|
+
constructor(obj = {}) {
|
|
15
|
+
super();
|
|
16
|
+
this.container = Object.create(null);
|
|
17
|
+
Object.defineProperty(this, 'listener', {
|
|
18
|
+
value: new listener_1.Listener,
|
|
19
|
+
writable: false,
|
|
20
|
+
configurable: false
|
|
21
|
+
});
|
|
22
|
+
for (const i in obj) {
|
|
23
|
+
Object.defineProperty(this.container, i, {
|
|
24
|
+
value: obj[i],
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
enumerable: true
|
|
28
|
+
});
|
|
29
|
+
this.listener.emitAdded(i, obj[i]);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Gets a value of a field
|
|
34
|
+
* @param key {string}
|
|
35
|
+
* @return {*}
|
|
36
|
+
*/
|
|
37
|
+
get(key) {
|
|
38
|
+
return this.container[key];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Sets an object property value
|
|
42
|
+
* @param key {string} property name
|
|
43
|
+
* @param v {*} property value
|
|
44
|
+
* @return {ObjectModel} a pointer to this
|
|
45
|
+
*/
|
|
46
|
+
set(key, v) {
|
|
47
|
+
if (Reflect.has(this.container, key)) {
|
|
48
|
+
this.listener.emitRemoved(key, this.container[key]);
|
|
49
|
+
this.container[key] = v;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
Object.defineProperty(this.container, key, {
|
|
53
|
+
value: v,
|
|
54
|
+
configurable: true,
|
|
55
|
+
writable: true,
|
|
56
|
+
enumerable: true
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
this.listener.emitAdded(key, this.container[key]);
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
get values() {
|
|
63
|
+
return this.container;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Deletes an object property
|
|
67
|
+
* @param key {string} property name
|
|
68
|
+
*/
|
|
69
|
+
delete(key) {
|
|
70
|
+
if (this.container[key]) {
|
|
71
|
+
this.listener.emitRemoved(key, this.container[key]);
|
|
72
|
+
delete this.container[key];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
enableReactivity() {
|
|
76
|
+
this.listener.enableReactivity();
|
|
77
|
+
}
|
|
78
|
+
disableReactivity() {
|
|
79
|
+
this.listener.disableReactivity();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.ObjectModel = ObjectModel;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SetModel = void 0;
|
|
4
|
+
const listener_1 = require("./listener");
|
|
5
|
+
/**
|
|
6
|
+
* A Set based model
|
|
7
|
+
* @class SetModel
|
|
8
|
+
* @extends Set
|
|
9
|
+
* @implements IModel
|
|
10
|
+
*/
|
|
11
|
+
class SetModel extends Set {
|
|
12
|
+
/**
|
|
13
|
+
* Constructs a set model based on a set
|
|
14
|
+
* @param set {Set} input data
|
|
15
|
+
*/
|
|
16
|
+
constructor(set = []) {
|
|
17
|
+
super();
|
|
18
|
+
Object.defineProperty(this, 'listener', {
|
|
19
|
+
value: new listener_1.Listener,
|
|
20
|
+
writable: false,
|
|
21
|
+
configurable: false
|
|
22
|
+
});
|
|
23
|
+
set.forEach(item => {
|
|
24
|
+
super.add(item);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Calls Set.add and notify abut changes
|
|
29
|
+
* @param value {*} value
|
|
30
|
+
* @return {this} a pointer to this
|
|
31
|
+
*/
|
|
32
|
+
add(value) {
|
|
33
|
+
if (!super.has(value)) {
|
|
34
|
+
this.listener.emitAdded(value, value);
|
|
35
|
+
super.add(value);
|
|
36
|
+
}
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Calls Set.clear and notify abut changes
|
|
41
|
+
*/
|
|
42
|
+
clear() {
|
|
43
|
+
this.forEach(item => {
|
|
44
|
+
this.listener.emitRemoved(item, item);
|
|
45
|
+
});
|
|
46
|
+
super.clear();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Calls Set.delete and notify abut changes
|
|
50
|
+
* @param value {*}
|
|
51
|
+
* @return {boolean} true if a value was deleted, otherwise false
|
|
52
|
+
*/
|
|
53
|
+
delete(value) {
|
|
54
|
+
if (super.has(value)) {
|
|
55
|
+
this.listener.emitRemoved(value, value);
|
|
56
|
+
}
|
|
57
|
+
return super.delete(value);
|
|
58
|
+
}
|
|
59
|
+
enableReactivity() {
|
|
60
|
+
this.listener.enableReactivity();
|
|
61
|
+
}
|
|
62
|
+
disableReactivity() {
|
|
63
|
+
this.listener.disableReactivity();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.SetModel = SetModel;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Portal = exports.App = exports.AppNode = void 0;
|
|
4
|
+
const node_1 = require("./node");
|
|
5
|
+
/**
|
|
6
|
+
* Application Node
|
|
7
|
+
* @class AppNode
|
|
8
|
+
* @extends INode
|
|
9
|
+
*/
|
|
10
|
+
class AppNode extends node_1.INode {
|
|
11
|
+
/**
|
|
12
|
+
* @param input
|
|
13
|
+
*/
|
|
14
|
+
constructor(input) {
|
|
15
|
+
super(input);
|
|
16
|
+
this.debugUi = input.debugUi || false;
|
|
17
|
+
this.$seal();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.AppNode = AppNode;
|
|
21
|
+
/**
|
|
22
|
+
* Represents a Vasille.js application
|
|
23
|
+
* @class App
|
|
24
|
+
* @extends AppNode
|
|
25
|
+
*/
|
|
26
|
+
class App extends AppNode {
|
|
27
|
+
/**
|
|
28
|
+
* Constructs an app node
|
|
29
|
+
* @param node {Element} The root of application
|
|
30
|
+
* @param input
|
|
31
|
+
*/
|
|
32
|
+
constructor(node, input) {
|
|
33
|
+
super(input);
|
|
34
|
+
this.$.node = node;
|
|
35
|
+
this.preinit(this, this);
|
|
36
|
+
this.init();
|
|
37
|
+
this.$seal();
|
|
38
|
+
}
|
|
39
|
+
appendNode(node) {
|
|
40
|
+
this.$.node.appendChild(node);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.App = App;
|
|
44
|
+
class Portal extends AppNode {
|
|
45
|
+
constructor(input) {
|
|
46
|
+
super(input);
|
|
47
|
+
this.$.node = input.node;
|
|
48
|
+
this.$seal();
|
|
49
|
+
}
|
|
50
|
+
appendNode(node) {
|
|
51
|
+
this.$.node.appendChild(node);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.Portal = Portal;
|