vasille 2.3.4 → 2.3.5
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 +5 -5
- package/flow-typed/vasille.js +14 -12
- package/package.json +3 -3
- package/types/functional/options.d.ts +1 -1
- package/types/spec/html.d.ts +6 -6
- package/types/spec/react.d.ts +2 -2
- package/types/spec/svg.d.ts +2 -2
- package/types/value/expression.d.ts +1 -1
- package/cdn/es2015.js +0 -2474
- package/cdn/es5.js +0 -3449
package/cdn/es5.js
DELETED
|
@@ -1,3449 +0,0 @@
|
|
|
1
|
-
(function(){
|
|
2
|
-
var __extends = function (child, parent) {
|
|
3
|
-
child.prototype = Object.create(parent.prototype);
|
|
4
|
-
}
|
|
5
|
-
var __spreadArray = function (to, from, pack) {
|
|
6
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
7
|
-
if (ar || !(i in from)) {
|
|
8
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
9
|
-
ar[i] = from[i];
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
var __assign = function(o1, o2) {
|
|
16
|
-
for (var i in o2) {
|
|
17
|
-
o1[i] = o2[i];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return o1;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
var Set = window.Set || /** @class */ (function (_super) {
|
|
24
|
-
__extends(Set, _super);
|
|
25
|
-
function Set(set) {
|
|
26
|
-
if (set === void 0) { set = []; }
|
|
27
|
-
var _this = this; _super.call(this);
|
|
28
|
-
set.forEach(function (item) {
|
|
29
|
-
_this.add (item)
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(_this, 'hash', {
|
|
32
|
-
value: Object.create(null),
|
|
33
|
-
writable: true
|
|
34
|
-
});
|
|
35
|
-
return _this;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
Set.prototype.has = function (value) {
|
|
39
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
40
|
-
return this.hash[value] !== void 0;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
return this.indexOf(value) !== -1;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
Set.prototype.add = function (value) {
|
|
48
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
49
|
-
if (this.hash[value]) {
|
|
50
|
-
return this;
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
this.hash[value] = true;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
if (this.indexOf(value) !== -1) {
|
|
58
|
-
return this;
|
|
59
|
-
}
|
|
60
|
-
this.push(value);
|
|
61
|
-
}
|
|
62
|
-
return this;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
Set.prototype.clear = function () {
|
|
66
|
-
this.hash = Object.create(null);
|
|
67
|
-
this.splice(0);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
Set.prototype.delete = function (value) {
|
|
71
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
72
|
-
if (this.hash[value] !== void 0) {
|
|
73
|
-
delete this.hash[value];
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
var index = this.indexOf(value);
|
|
78
|
-
if (index !== -1) {
|
|
79
|
-
this.splice(index, 1);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
this.push(value);
|
|
83
|
-
return this;
|
|
84
|
-
};
|
|
85
|
-
return Set;
|
|
86
|
-
}(Array));
|
|
87
|
-
|
|
88
|
-
var Map = window.Map || /** @class */ (function (_super) {
|
|
89
|
-
__extends(Map, _super);
|
|
90
|
-
|
|
91
|
-
function Map(map) {
|
|
92
|
-
if (map === void 0) { map = []; }
|
|
93
|
-
var _this = this; _super.call(this);
|
|
94
|
-
Object.defineProperty(_this, 'hash', {
|
|
95
|
-
value: Object.create(null),
|
|
96
|
-
writable: true
|
|
97
|
-
});
|
|
98
|
-
map.forEach(function (_a) {
|
|
99
|
-
var key = _a[0], value = _a[1];
|
|
100
|
-
this.set(key, value);
|
|
101
|
-
});
|
|
102
|
-
return _this;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
Map.prototype.clear = function () {
|
|
106
|
-
this.hash = Object.create(null);
|
|
107
|
-
this.splice(0);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
Map.prototype.delete = function (key) {
|
|
111
|
-
if (typeof key === "string" || typeof key === "number") {
|
|
112
|
-
if (this.hash[key] !== void 0) {
|
|
113
|
-
delete this.hash[key];
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
for (var i = 0; i < this.length; i++) {
|
|
118
|
-
if (this[i][0] === key) {
|
|
119
|
-
this.splice(i, 1);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
function indexOfKey(key) {
|
|
126
|
-
for (var i = 0; i < this.length; i++) {
|
|
127
|
-
if (this[i][0] === key) {
|
|
128
|
-
return i;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return -1;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
Map.prototype.set = function (key, value) {
|
|
135
|
-
if (typeof key === "string" || typeof key === "number") {
|
|
136
|
-
this.hash[key] = value;
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
var index = indexOfKey.call(this, key);
|
|
140
|
-
if (index === -1) {
|
|
141
|
-
this.push([key, value]);
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
this[index][1] = value;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
Map.prototype.has = function (key) {
|
|
151
|
-
if (typeof key === "string" || typeof key === "number") {
|
|
152
|
-
return !!this.hash[key];
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
return indexOfKey.call(this, key) !== -1;
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
Map.prototype.get = function (key) {
|
|
160
|
-
if (typeof key === "string" || typeof key === "number") {
|
|
161
|
-
return this.hash[key];
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
var index = indexOfKey.call(this, key);
|
|
165
|
-
if (index !== -1) {
|
|
166
|
-
return this[index][1];
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
return void 0;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
return Map;
|
|
175
|
-
}(Array));
|
|
176
|
-
|
|
177
|
-
window.Reflect = window.Reflect || {
|
|
178
|
-
has: function (obj, p) {
|
|
179
|
-
for (var i in obj) {
|
|
180
|
-
if (i == p) return true;
|
|
181
|
-
}
|
|
182
|
-
return false;
|
|
183
|
-
},
|
|
184
|
-
ownKeys: function (obj) {
|
|
185
|
-
var ret = [];
|
|
186
|
-
|
|
187
|
-
for (var i in obj) {
|
|
188
|
-
if (obj.hasOwnProperty(i)) {
|
|
189
|
-
ret.push(i);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return ret;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
window.Proxy = window.Proxy || function (obj) {
|
|
198
|
-
return obj;
|
|
199
|
-
};
|
|
200
|
-
// ./lib-es5/core/destroyable.js
|
|
201
|
-
"use strict";
|
|
202
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
203
|
-
exports.Destroyable = void 0;
|
|
204
|
-
/**
|
|
205
|
-
* Mark an object which can be destroyed
|
|
206
|
-
* @class Destroyable
|
|
207
|
-
*/
|
|
208
|
-
var Destroyable = /** @class */ (function () {
|
|
209
|
-
function Destroyable() {
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Make object fields non configurable
|
|
213
|
-
* @protected
|
|
214
|
-
*/
|
|
215
|
-
Destroyable.prototype.$seal = function () {
|
|
216
|
-
var _this = this;
|
|
217
|
-
var $ = this;
|
|
218
|
-
Object.keys($).forEach(function (i) {
|
|
219
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
220
|
-
if (_this.hasOwnProperty(i)) {
|
|
221
|
-
var config = Object.getOwnPropertyDescriptor($, i);
|
|
222
|
-
if (config.configurable) {
|
|
223
|
-
var descriptor = void 0;
|
|
224
|
-
if (config.set || config.get) {
|
|
225
|
-
descriptor = {
|
|
226
|
-
configurable: false,
|
|
227
|
-
get: config.get,
|
|
228
|
-
set: config.set,
|
|
229
|
-
enumerable: config.enumerable
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
descriptor = {
|
|
234
|
-
value: $[i],
|
|
235
|
-
configurable: false,
|
|
236
|
-
writable: config.writable,
|
|
237
|
-
enumerable: config.enumerable
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
Object.defineProperty($, i, descriptor);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
};
|
|
245
|
-
/**
|
|
246
|
-
* Garbage collector method
|
|
247
|
-
*/
|
|
248
|
-
Destroyable.prototype.$destroy = function () {
|
|
249
|
-
// nothing here
|
|
250
|
-
};
|
|
251
|
-
return Destroyable;
|
|
252
|
-
}());
|
|
253
|
-
exports.Destroyable = Destroyable;
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
// ./lib-es5/core/errors.js
|
|
257
|
-
"use strict";
|
|
258
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
259
|
-
exports.wrongBinding = exports.userError = exports.internalError = exports.notOverwritten = void 0;
|
|
260
|
-
var reportIt = "Report it here: https://gitlab.com/vasille-js/vasille-js/-/issues";
|
|
261
|
-
function notOverwritten() {
|
|
262
|
-
console.error("Vasille-SFP: Internal error", "Must be overwritten", reportIt);
|
|
263
|
-
return "not-overwritten";
|
|
264
|
-
}
|
|
265
|
-
exports.notOverwritten = notOverwritten;
|
|
266
|
-
function internalError(msg) {
|
|
267
|
-
console.error("Vasille-SFP: Internal error", msg, reportIt);
|
|
268
|
-
return "internal-error";
|
|
269
|
-
}
|
|
270
|
-
exports.internalError = internalError;
|
|
271
|
-
function userError(msg, err) {
|
|
272
|
-
console.error("Vasille-SFP: User error", msg);
|
|
273
|
-
return err;
|
|
274
|
-
}
|
|
275
|
-
exports.userError = userError;
|
|
276
|
-
function wrongBinding(msg) {
|
|
277
|
-
return userError(msg, "wrong-binding");
|
|
278
|
-
}
|
|
279
|
-
exports.wrongBinding = wrongBinding;
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
// ./lib-es5/core/ivalue.js
|
|
283
|
-
"use strict";
|
|
284
|
-
var __extends = (this && this.__extends) || (function () {
|
|
285
|
-
var extendStatics = function (d, b) {
|
|
286
|
-
extendStatics = Object.setPrototypeOf ||
|
|
287
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
288
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
289
|
-
return extendStatics(d, b);
|
|
290
|
-
};
|
|
291
|
-
return function (d, b) {
|
|
292
|
-
if (typeof b !== "function" && b !== null)
|
|
293
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
294
|
-
extendStatics(d, b);
|
|
295
|
-
function __() { this.constructor = d; }
|
|
296
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
297
|
-
};
|
|
298
|
-
})();
|
|
299
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
300
|
-
exports.IValue = exports.Switchable = void 0;
|
|
301
|
-
var destroyable_js_1 = require("./destroyable.js");
|
|
302
|
-
var errors_1 = require("./errors");
|
|
303
|
-
var Switchable = /** @class */ (function (_super) {
|
|
304
|
-
__extends(Switchable, _super);
|
|
305
|
-
function Switchable() {
|
|
306
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Enable update handlers triggering
|
|
310
|
-
*/
|
|
311
|
-
Switchable.prototype.$enable = function () {
|
|
312
|
-
throw (0, errors_1.notOverwritten)();
|
|
313
|
-
};
|
|
314
|
-
/**
|
|
315
|
-
* disable update handlers triggering
|
|
316
|
-
*/
|
|
317
|
-
Switchable.prototype.$disable = function () {
|
|
318
|
-
throw (0, errors_1.notOverwritten)();
|
|
319
|
-
};
|
|
320
|
-
return Switchable;
|
|
321
|
-
}(destroyable_js_1.Destroyable));
|
|
322
|
-
exports.Switchable = Switchable;
|
|
323
|
-
/**
|
|
324
|
-
* Interface which describes a value
|
|
325
|
-
* @class IValue
|
|
326
|
-
* @extends Destroyable
|
|
327
|
-
*/
|
|
328
|
-
var IValue = /** @class */ (function (_super) {
|
|
329
|
-
__extends(IValue, _super);
|
|
330
|
-
/**
|
|
331
|
-
* @param isEnabled {boolean} initial is enabled state
|
|
332
|
-
*/
|
|
333
|
-
function IValue(isEnabled) {
|
|
334
|
-
var _this = this; _super.call(this);
|
|
335
|
-
_this.isEnabled = isEnabled;
|
|
336
|
-
return _this;
|
|
337
|
-
}
|
|
338
|
-
Object.defineProperty(IValue.prototype, "$", {
|
|
339
|
-
/**
|
|
340
|
-
* Get the encapsulated value
|
|
341
|
-
* @return {*} the encapsulated value
|
|
342
|
-
*/
|
|
343
|
-
get: function () {
|
|
344
|
-
throw (0, errors_1.notOverwritten)();
|
|
345
|
-
},
|
|
346
|
-
/**
|
|
347
|
-
* Sets the encapsulated value
|
|
348
|
-
* @param value {*} value to encapsulate
|
|
349
|
-
*/
|
|
350
|
-
set: function (value) {
|
|
351
|
-
throw (0, errors_1.notOverwritten)();
|
|
352
|
-
},
|
|
353
|
-
enumerable: false,
|
|
354
|
-
configurable: true
|
|
355
|
-
});
|
|
356
|
-
/**
|
|
357
|
-
* Add a new handler to value change
|
|
358
|
-
* @param handler {function(value : *)} the handler to add
|
|
359
|
-
*/
|
|
360
|
-
IValue.prototype.$on = function (handler) {
|
|
361
|
-
throw (0, errors_1.notOverwritten)();
|
|
362
|
-
};
|
|
363
|
-
/**
|
|
364
|
-
* Removes a handler of value change
|
|
365
|
-
* @param handler {function(value : *)} the handler to remove
|
|
366
|
-
*/
|
|
367
|
-
IValue.prototype.$off = function (handler) {
|
|
368
|
-
throw (0, errors_1.notOverwritten)();
|
|
369
|
-
};
|
|
370
|
-
return IValue;
|
|
371
|
-
}(Switchable));
|
|
372
|
-
exports.IValue = IValue;
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
// ./lib-es5/core/core.js
|
|
376
|
-
"use strict";
|
|
377
|
-
var __extends = (this && this.__extends) || (function () {
|
|
378
|
-
var extendStatics = function (d, b) {
|
|
379
|
-
extendStatics = Object.setPrototypeOf ||
|
|
380
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
381
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
382
|
-
return extendStatics(d, b);
|
|
383
|
-
};
|
|
384
|
-
return function (d, b) {
|
|
385
|
-
if (typeof b !== "function" && b !== null)
|
|
386
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
387
|
-
extendStatics(d, b);
|
|
388
|
-
function __() { this.constructor = d; }
|
|
389
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
390
|
-
};
|
|
391
|
-
})();
|
|
392
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
393
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
394
|
-
if (ar || !(i in from)) {
|
|
395
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
396
|
-
ar[i] = from[i];
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
400
|
-
};
|
|
401
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
402
|
-
exports.Reactive = exports.ReactivePrivate = exports.unstack = exports.stack = exports.current = void 0;
|
|
403
|
-
var destroyable_js_1 = require("./destroyable.js");
|
|
404
|
-
var errors_1 = require("./errors");
|
|
405
|
-
var expression_1 = require("../value/expression");
|
|
406
|
-
var reference_1 = require("../value/reference");
|
|
407
|
-
var pointer_1 = require("../value/pointer");
|
|
408
|
-
var mirror_1 = require("../value/mirror");
|
|
409
|
-
exports.current = null;
|
|
410
|
-
var currentStack = [];
|
|
411
|
-
function stack(node) {
|
|
412
|
-
currentStack.push(exports.current);
|
|
413
|
-
exports.current = node;
|
|
414
|
-
}
|
|
415
|
-
exports.stack = stack;
|
|
416
|
-
function unstack() {
|
|
417
|
-
exports.current = currentStack.pop();
|
|
418
|
-
}
|
|
419
|
-
exports.unstack = unstack;
|
|
420
|
-
/**
|
|
421
|
-
* Private stuff of a reactive object
|
|
422
|
-
* @class ReactivePrivate
|
|
423
|
-
* @extends Destroyable
|
|
424
|
-
*/
|
|
425
|
-
var ReactivePrivate = /** @class */ (function (_super) {
|
|
426
|
-
__extends(ReactivePrivate, _super);
|
|
427
|
-
function ReactivePrivate() {
|
|
428
|
-
var _this = this; _super.call(this);
|
|
429
|
-
/**
|
|
430
|
-
* A list of user-defined values
|
|
431
|
-
* @type {Set}
|
|
432
|
-
*/
|
|
433
|
-
_this.watch = new Set;
|
|
434
|
-
/**
|
|
435
|
-
* A list of user-defined bindings
|
|
436
|
-
* @type {Set}
|
|
437
|
-
*/
|
|
438
|
-
_this.bindings = new Set;
|
|
439
|
-
/**
|
|
440
|
-
* A list of user defined models
|
|
441
|
-
*/
|
|
442
|
-
_this.models = new Set;
|
|
443
|
-
/**
|
|
444
|
-
* Reactivity switch state
|
|
445
|
-
* @type {boolean}
|
|
446
|
-
*/
|
|
447
|
-
_this.enabled = true;
|
|
448
|
-
/**
|
|
449
|
-
* The frozen state of object
|
|
450
|
-
* @type {boolean}
|
|
451
|
-
*/
|
|
452
|
-
_this.frozen = false;
|
|
453
|
-
_this.$seal();
|
|
454
|
-
return _this;
|
|
455
|
-
}
|
|
456
|
-
ReactivePrivate.prototype.$destroy = function () {
|
|
457
|
-
this.watch.forEach(function (value) { return value.$destroy(); });
|
|
458
|
-
this.watch.clear();
|
|
459
|
-
this.bindings.forEach(function (binding) { return binding.$destroy(); });
|
|
460
|
-
this.bindings.clear();
|
|
461
|
-
this.models.forEach(function (model) { return model.disableReactivity(); });
|
|
462
|
-
this.models.clear();
|
|
463
|
-
this.freezeExpr && this.freezeExpr.$destroy();
|
|
464
|
-
this.onDestroy && this.onDestroy();
|
|
465
|
-
_super.prototype.$destroy.call(this);
|
|
466
|
-
};
|
|
467
|
-
return ReactivePrivate;
|
|
468
|
-
}(destroyable_js_1.Destroyable));
|
|
469
|
-
exports.ReactivePrivate = ReactivePrivate;
|
|
470
|
-
/**
|
|
471
|
-
* A reactive object
|
|
472
|
-
* @class Reactive
|
|
473
|
-
* @extends Destroyable
|
|
474
|
-
*/
|
|
475
|
-
var Reactive = /** @class */ (function (_super) {
|
|
476
|
-
__extends(Reactive, _super);
|
|
477
|
-
function Reactive(input, $) {
|
|
478
|
-
var _this = this; _super.call(this);
|
|
479
|
-
_this.input = input;
|
|
480
|
-
_this.$ = $ || new ReactivePrivate;
|
|
481
|
-
_this.$seal();
|
|
482
|
-
return _this;
|
|
483
|
-
}
|
|
484
|
-
Object.defineProperty(Reactive.prototype, "parent", {
|
|
485
|
-
/**
|
|
486
|
-
* Get parent node
|
|
487
|
-
*/
|
|
488
|
-
get: function () {
|
|
489
|
-
return this.$.parent;
|
|
490
|
-
},
|
|
491
|
-
enumerable: false,
|
|
492
|
-
configurable: true
|
|
493
|
-
});
|
|
494
|
-
/**
|
|
495
|
-
* Create a reference
|
|
496
|
-
* @param value {*} value to reference
|
|
497
|
-
*/
|
|
498
|
-
Reactive.prototype.ref = function (value) {
|
|
499
|
-
var $ = this.$;
|
|
500
|
-
var ref = new reference_1.Reference(value);
|
|
501
|
-
$.watch.add(ref);
|
|
502
|
-
return ref;
|
|
503
|
-
};
|
|
504
|
-
/**
|
|
505
|
-
* Create a mirror
|
|
506
|
-
* @param value {IValue} value to mirror
|
|
507
|
-
*/
|
|
508
|
-
Reactive.prototype.mirror = function (value) {
|
|
509
|
-
var mirror = new mirror_1.Mirror(value, false);
|
|
510
|
-
this.$.watch.add(mirror);
|
|
511
|
-
return mirror;
|
|
512
|
-
};
|
|
513
|
-
/**
|
|
514
|
-
* Create a forward-only mirror
|
|
515
|
-
* @param value {IValue} value to mirror
|
|
516
|
-
*/
|
|
517
|
-
Reactive.prototype.forward = function (value) {
|
|
518
|
-
var mirror = new mirror_1.Mirror(value, true);
|
|
519
|
-
this.$.watch.add(mirror);
|
|
520
|
-
return mirror;
|
|
521
|
-
};
|
|
522
|
-
/**
|
|
523
|
-
* Creates a pointer
|
|
524
|
-
* @param value {*} default value to point
|
|
525
|
-
* @param forwardOnly {boolean} forward only sync
|
|
526
|
-
*/
|
|
527
|
-
Reactive.prototype.point = function (value, forwardOnly) {
|
|
528
|
-
if (forwardOnly === void 0) { forwardOnly = false; }
|
|
529
|
-
var $ = this.$;
|
|
530
|
-
var pointer = new pointer_1.Pointer(value, forwardOnly);
|
|
531
|
-
$.watch.add(pointer);
|
|
532
|
-
return pointer;
|
|
533
|
-
};
|
|
534
|
-
/**
|
|
535
|
-
* Register a model
|
|
536
|
-
* @param model
|
|
537
|
-
*/
|
|
538
|
-
Reactive.prototype.register = function (model) {
|
|
539
|
-
this.$.models.add(model);
|
|
540
|
-
return model;
|
|
541
|
-
};
|
|
542
|
-
/**
|
|
543
|
-
* Creates a watcher
|
|
544
|
-
* @param func {function} function to run on any argument change
|
|
545
|
-
* @param values
|
|
546
|
-
*/
|
|
547
|
-
Reactive.prototype.watch = function (func) {
|
|
548
|
-
var values = [];
|
|
549
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
550
|
-
values[_i - 1] = arguments[_i];
|
|
551
|
-
}
|
|
552
|
-
var $ = this.$;
|
|
553
|
-
$.watch.add(new (expression_1.Expression.bind.apply(expression_1.Expression, __spreadArray([void 0, func, !this.$.frozen], values, false)))());
|
|
554
|
-
};
|
|
555
|
-
/**
|
|
556
|
-
* Creates a computed value
|
|
557
|
-
* @param func {function} function to run on any argument change
|
|
558
|
-
* @param values
|
|
559
|
-
* @return {IValue} the created ivalue
|
|
560
|
-
*/
|
|
561
|
-
Reactive.prototype.expr = function (func) {
|
|
562
|
-
var values = [];
|
|
563
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
564
|
-
values[_i - 1] = arguments[_i];
|
|
565
|
-
}
|
|
566
|
-
var res = new (expression_1.Expression.bind.apply(expression_1.Expression, __spreadArray([void 0, func, !this.$.frozen], values, false)))();
|
|
567
|
-
var $ = this.$;
|
|
568
|
-
$.watch.add(res);
|
|
569
|
-
return res;
|
|
570
|
-
};
|
|
571
|
-
/**
|
|
572
|
-
* Enable reactivity of fields
|
|
573
|
-
*/
|
|
574
|
-
Reactive.prototype.enable = function () {
|
|
575
|
-
var $ = this.$;
|
|
576
|
-
if (!$.enabled) {
|
|
577
|
-
$.watch.forEach(function (watcher) {
|
|
578
|
-
watcher.$enable();
|
|
579
|
-
});
|
|
580
|
-
$.models.forEach(function (model) {
|
|
581
|
-
model.enableReactivity();
|
|
582
|
-
});
|
|
583
|
-
$.enabled = true;
|
|
584
|
-
}
|
|
585
|
-
};
|
|
586
|
-
/**
|
|
587
|
-
* Disable reactivity of fields
|
|
588
|
-
*/
|
|
589
|
-
Reactive.prototype.disable = function () {
|
|
590
|
-
var $ = this.$;
|
|
591
|
-
if ($.enabled) {
|
|
592
|
-
$.watch.forEach(function (watcher) {
|
|
593
|
-
watcher.$disable();
|
|
594
|
-
});
|
|
595
|
-
$.models.forEach(function (model) {
|
|
596
|
-
model.disableReactivity();
|
|
597
|
-
});
|
|
598
|
-
$.enabled = false;
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
|
-
/**
|
|
602
|
-
* Disable/Enable reactivity of object fields with feedback
|
|
603
|
-
* @param cond {IValue} show condition
|
|
604
|
-
* @param onOff {function} on show feedback
|
|
605
|
-
* @param onOn {function} on hide feedback
|
|
606
|
-
*/
|
|
607
|
-
Reactive.prototype.bindAlive = function (cond, onOff, onOn) {
|
|
608
|
-
var _this = this;
|
|
609
|
-
var $ = this.$;
|
|
610
|
-
if ($.freezeExpr) {
|
|
611
|
-
throw (0, errors_1.wrongBinding)("this component already have a freeze state");
|
|
612
|
-
}
|
|
613
|
-
if ($.watch.has(cond)) {
|
|
614
|
-
throw (0, errors_1.wrongBinding)("freeze state must be bound to an external component");
|
|
615
|
-
}
|
|
616
|
-
$.freezeExpr = new expression_1.Expression(function (cond) {
|
|
617
|
-
$.frozen = !cond;
|
|
618
|
-
if (cond) {
|
|
619
|
-
onOn === null || onOn === void 0 ? void 0 : onOn();
|
|
620
|
-
_this.enable();
|
|
621
|
-
}
|
|
622
|
-
else {
|
|
623
|
-
onOff === null || onOff === void 0 ? void 0 : onOff();
|
|
624
|
-
_this.disable();
|
|
625
|
-
}
|
|
626
|
-
}, true, cond);
|
|
627
|
-
return this;
|
|
628
|
-
};
|
|
629
|
-
Reactive.prototype.init = function () {
|
|
630
|
-
this.applyOptions(this.input);
|
|
631
|
-
return this.compose(this.input);
|
|
632
|
-
};
|
|
633
|
-
Reactive.prototype.applyOptions = function (input) {
|
|
634
|
-
// empty
|
|
635
|
-
};
|
|
636
|
-
Reactive.prototype.applyOptionsNow = function () {
|
|
637
|
-
this.applyOptions(this.input);
|
|
638
|
-
};
|
|
639
|
-
Reactive.prototype.compose = function (input) {
|
|
640
|
-
throw (0, errors_1.notOverwritten)();
|
|
641
|
-
};
|
|
642
|
-
Reactive.prototype.composeNow = function () {
|
|
643
|
-
this.compose(this.input);
|
|
644
|
-
};
|
|
645
|
-
Reactive.prototype.runFunctional = function (f) {
|
|
646
|
-
var args = [];
|
|
647
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
648
|
-
args[_i - 1] = arguments[_i];
|
|
649
|
-
}
|
|
650
|
-
stack(this);
|
|
651
|
-
// yet another ts bug
|
|
652
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
653
|
-
// @ts-ignore
|
|
654
|
-
var result = f.apply(void 0, args);
|
|
655
|
-
unstack();
|
|
656
|
-
return result;
|
|
657
|
-
};
|
|
658
|
-
Reactive.prototype.runOnDestroy = function (func) {
|
|
659
|
-
this.$.onDestroy = func;
|
|
660
|
-
};
|
|
661
|
-
Reactive.prototype.$destroy = function () {
|
|
662
|
-
_super.prototype.$destroy.call(this);
|
|
663
|
-
this.$.$destroy();
|
|
664
|
-
this.$ = null;
|
|
665
|
-
};
|
|
666
|
-
return Reactive;
|
|
667
|
-
}(destroyable_js_1.Destroyable));
|
|
668
|
-
exports.Reactive = Reactive;
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
// ./lib-es5/value/reference.js
|
|
672
|
-
"use strict";
|
|
673
|
-
var __extends = (this && this.__extends) || (function () {
|
|
674
|
-
var extendStatics = function (d, b) {
|
|
675
|
-
extendStatics = Object.setPrototypeOf ||
|
|
676
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
677
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
678
|
-
return extendStatics(d, b);
|
|
679
|
-
};
|
|
680
|
-
return function (d, b) {
|
|
681
|
-
if (typeof b !== "function" && b !== null)
|
|
682
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
683
|
-
extendStatics(d, b);
|
|
684
|
-
function __() { this.constructor = d; }
|
|
685
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
686
|
-
};
|
|
687
|
-
})();
|
|
688
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
689
|
-
exports.Reference = void 0;
|
|
690
|
-
var ivalue_1 = require("../core/ivalue");
|
|
691
|
-
/**
|
|
692
|
-
* Declares a notifiable value
|
|
693
|
-
* @class Reference
|
|
694
|
-
* @extends IValue
|
|
695
|
-
*/
|
|
696
|
-
var Reference = /** @class */ (function (_super) {
|
|
697
|
-
__extends(Reference, _super);
|
|
698
|
-
/**
|
|
699
|
-
* @param value {any} the initial value
|
|
700
|
-
*/
|
|
701
|
-
function Reference(value) {
|
|
702
|
-
var _this = _super.call(this, true) || this;
|
|
703
|
-
_this.$value = value;
|
|
704
|
-
_this.$onchange = new Set;
|
|
705
|
-
_this.$seal();
|
|
706
|
-
return _this;
|
|
707
|
-
}
|
|
708
|
-
Object.defineProperty(Reference.prototype, "$", {
|
|
709
|
-
get: function () {
|
|
710
|
-
return this.$value;
|
|
711
|
-
},
|
|
712
|
-
set: function (value) {
|
|
713
|
-
if (this.$value !== value) {
|
|
714
|
-
this.$value = value;
|
|
715
|
-
if (this.isEnabled) {
|
|
716
|
-
this.$onchange.forEach(function (handler) {
|
|
717
|
-
handler(value);
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
},
|
|
722
|
-
enumerable: false,
|
|
723
|
-
configurable: true
|
|
724
|
-
});
|
|
725
|
-
Reference.prototype.$enable = function () {
|
|
726
|
-
var _this = this;
|
|
727
|
-
if (!this.isEnabled) {
|
|
728
|
-
this.$onchange.forEach(function (handler) {
|
|
729
|
-
handler(_this.$value);
|
|
730
|
-
});
|
|
731
|
-
this.isEnabled = true;
|
|
732
|
-
}
|
|
733
|
-
};
|
|
734
|
-
Reference.prototype.$disable = function () {
|
|
735
|
-
this.isEnabled = false;
|
|
736
|
-
};
|
|
737
|
-
Reference.prototype.$on = function (handler) {
|
|
738
|
-
this.$onchange.add(handler);
|
|
739
|
-
};
|
|
740
|
-
Reference.prototype.$off = function (handler) {
|
|
741
|
-
this.$onchange.delete(handler);
|
|
742
|
-
};
|
|
743
|
-
Reference.prototype.$destroy = function () {
|
|
744
|
-
_super.prototype.$destroy.call(this);
|
|
745
|
-
this.$onchange.clear();
|
|
746
|
-
};
|
|
747
|
-
return Reference;
|
|
748
|
-
}(ivalue_1.IValue));
|
|
749
|
-
exports.Reference = Reference;
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
// ./lib-es5/value/expression.js
|
|
753
|
-
"use strict";
|
|
754
|
-
var __extends = (this && this.__extends) || (function () {
|
|
755
|
-
var extendStatics = function (d, b) {
|
|
756
|
-
extendStatics = Object.setPrototypeOf ||
|
|
757
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
758
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
759
|
-
return extendStatics(d, b);
|
|
760
|
-
};
|
|
761
|
-
return function (d, b) {
|
|
762
|
-
if (typeof b !== "function" && b !== null)
|
|
763
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
764
|
-
extendStatics(d, b);
|
|
765
|
-
function __() { this.constructor = d; }
|
|
766
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
767
|
-
};
|
|
768
|
-
})();
|
|
769
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
770
|
-
exports.Expression = void 0;
|
|
771
|
-
var reference_js_1 = require("./reference.js");
|
|
772
|
-
var ivalue_1 = require("../core/ivalue");
|
|
773
|
-
/**
|
|
774
|
-
* Bind some values to one expression
|
|
775
|
-
* @class Expression
|
|
776
|
-
* @extends IValue
|
|
777
|
-
*/
|
|
778
|
-
var Expression = /** @class */ (function (_super) {
|
|
779
|
-
__extends(Expression, _super);
|
|
780
|
-
/**
|
|
781
|
-
* Creates a function bounded to N values
|
|
782
|
-
* @param func {Function} the function to bound
|
|
783
|
-
* @param values
|
|
784
|
-
* @param link {Boolean} links immediately if true
|
|
785
|
-
*/
|
|
786
|
-
function Expression(func, link) {
|
|
787
|
-
var values = [];
|
|
788
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
789
|
-
values[_i - 2] = arguments[_i];
|
|
790
|
-
}
|
|
791
|
-
var _this = _super.call(this, false) || this;
|
|
792
|
-
/**
|
|
793
|
-
* Expression will link different handler for each value of list
|
|
794
|
-
*/
|
|
795
|
-
_this.linkedFunc = [];
|
|
796
|
-
var handler = function (i) {
|
|
797
|
-
if (i != null) {
|
|
798
|
-
_this.valuesCache[i] = _this.values[i].$;
|
|
799
|
-
}
|
|
800
|
-
_this.sync.$ = func.apply(_this, _this.valuesCache);
|
|
801
|
-
};
|
|
802
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
803
|
-
// @ts-ignore
|
|
804
|
-
_this.valuesCache = values.map(function (item) { return item.$; });
|
|
805
|
-
_this.sync = new reference_js_1.Reference(func.apply(_this, _this.valuesCache));
|
|
806
|
-
var i = 0;
|
|
807
|
-
values.forEach(function () {
|
|
808
|
-
_this.linkedFunc.push(handler.bind(_this, Number(i++)));
|
|
809
|
-
});
|
|
810
|
-
_this.values = values;
|
|
811
|
-
_this.func = handler;
|
|
812
|
-
if (link) {
|
|
813
|
-
_this.$enable();
|
|
814
|
-
}
|
|
815
|
-
else {
|
|
816
|
-
handler();
|
|
817
|
-
}
|
|
818
|
-
_this.$seal();
|
|
819
|
-
return _this;
|
|
820
|
-
}
|
|
821
|
-
Object.defineProperty(Expression.prototype, "$", {
|
|
822
|
-
get: function () {
|
|
823
|
-
return this.sync.$;
|
|
824
|
-
},
|
|
825
|
-
set: function (value) {
|
|
826
|
-
this.sync.$ = value;
|
|
827
|
-
},
|
|
828
|
-
enumerable: false,
|
|
829
|
-
configurable: true
|
|
830
|
-
});
|
|
831
|
-
Expression.prototype.$on = function (handler) {
|
|
832
|
-
this.sync.$on(handler);
|
|
833
|
-
return this;
|
|
834
|
-
};
|
|
835
|
-
Expression.prototype.$off = function (handler) {
|
|
836
|
-
this.sync.$off(handler);
|
|
837
|
-
return this;
|
|
838
|
-
};
|
|
839
|
-
Expression.prototype.$enable = function () {
|
|
840
|
-
if (!this.isEnabled) {
|
|
841
|
-
for (var i = 0; i < this.values.length; i++) {
|
|
842
|
-
this.values[i].$on(this.linkedFunc[i]);
|
|
843
|
-
this.valuesCache[i] = this.values[i].$;
|
|
844
|
-
}
|
|
845
|
-
this.func();
|
|
846
|
-
this.isEnabled = true;
|
|
847
|
-
}
|
|
848
|
-
return this;
|
|
849
|
-
};
|
|
850
|
-
Expression.prototype.$disable = function () {
|
|
851
|
-
if (this.isEnabled) {
|
|
852
|
-
for (var i = 0; i < this.values.length; i++) {
|
|
853
|
-
this.values[i].$off(this.linkedFunc[i]);
|
|
854
|
-
}
|
|
855
|
-
this.isEnabled = false;
|
|
856
|
-
}
|
|
857
|
-
return this;
|
|
858
|
-
};
|
|
859
|
-
Expression.prototype.$destroy = function () {
|
|
860
|
-
this.$disable();
|
|
861
|
-
this.values.splice(0);
|
|
862
|
-
this.valuesCache.splice(0);
|
|
863
|
-
this.linkedFunc.splice(0);
|
|
864
|
-
_super.prototype.$destroy.call(this);
|
|
865
|
-
};
|
|
866
|
-
return Expression;
|
|
867
|
-
}(ivalue_1.IValue));
|
|
868
|
-
exports.Expression = Expression;
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
// ./lib-es5/value/mirror.js
|
|
872
|
-
"use strict";
|
|
873
|
-
var __extends = (this && this.__extends) || (function () {
|
|
874
|
-
var extendStatics = function (d, b) {
|
|
875
|
-
extendStatics = Object.setPrototypeOf ||
|
|
876
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
877
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
878
|
-
return extendStatics(d, b);
|
|
879
|
-
};
|
|
880
|
-
return function (d, b) {
|
|
881
|
-
if (typeof b !== "function" && b !== null)
|
|
882
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
883
|
-
extendStatics(d, b);
|
|
884
|
-
function __() { this.constructor = d; }
|
|
885
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
886
|
-
};
|
|
887
|
-
})();
|
|
888
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
889
|
-
exports.Mirror = void 0;
|
|
890
|
-
var reference_1 = require("./reference");
|
|
891
|
-
/**
|
|
892
|
-
* Declares a notifiable bind to a value
|
|
893
|
-
* @class Mirror
|
|
894
|
-
* @extends IValue
|
|
895
|
-
* @version 2
|
|
896
|
-
*/
|
|
897
|
-
var Mirror = /** @class */ (function (_super) {
|
|
898
|
-
__extends(Mirror, _super);
|
|
899
|
-
/**
|
|
900
|
-
* Constructs a notifiable bind to a value
|
|
901
|
-
* @param value {IValue} is initial value
|
|
902
|
-
* @param forwardOnly {boolean} ensure forward only synchronization
|
|
903
|
-
*/
|
|
904
|
-
function Mirror(value, forwardOnly) {
|
|
905
|
-
if (forwardOnly === void 0) { forwardOnly = false; }
|
|
906
|
-
var _this = _super.call(this, value.$) || this;
|
|
907
|
-
_this.$handler = function (v) {
|
|
908
|
-
_this.$ = v;
|
|
909
|
-
};
|
|
910
|
-
_this.$pointedValue = value;
|
|
911
|
-
_this.$forwardOnly = forwardOnly;
|
|
912
|
-
value.$on(_this.$handler);
|
|
913
|
-
_this.$seal();
|
|
914
|
-
return _this;
|
|
915
|
-
}
|
|
916
|
-
Object.defineProperty(Mirror.prototype, "$", {
|
|
917
|
-
get: function () {
|
|
918
|
-
// this is a ts bug
|
|
919
|
-
// eslint-disable-next-line
|
|
920
|
-
// @ts-ignore
|
|
921
|
-
return _super.prototype.$;
|
|
922
|
-
},
|
|
923
|
-
set: function (v) {
|
|
924
|
-
if (!this.$forwardOnly) {
|
|
925
|
-
this.$pointedValue.$ = v;
|
|
926
|
-
}
|
|
927
|
-
// this is a ts bug
|
|
928
|
-
// eslint-disable-next-line
|
|
929
|
-
// @ts-ignore
|
|
930
|
-
_super.prototype.$ = v;
|
|
931
|
-
},
|
|
932
|
-
enumerable: false,
|
|
933
|
-
configurable: true
|
|
934
|
-
});
|
|
935
|
-
Mirror.prototype.$enable = function () {
|
|
936
|
-
if (!this.isEnabled) {
|
|
937
|
-
this.isEnabled = true;
|
|
938
|
-
this.$pointedValue.$on(this.$handler);
|
|
939
|
-
this.$ = this.$pointedValue.$;
|
|
940
|
-
}
|
|
941
|
-
};
|
|
942
|
-
Mirror.prototype.$disable = function () {
|
|
943
|
-
if (this.isEnabled) {
|
|
944
|
-
this.$pointedValue.$off(this.$handler);
|
|
945
|
-
this.isEnabled = false;
|
|
946
|
-
}
|
|
947
|
-
};
|
|
948
|
-
Mirror.prototype.$destroy = function () {
|
|
949
|
-
this.$disable();
|
|
950
|
-
_super.prototype.$destroy.call(this);
|
|
951
|
-
};
|
|
952
|
-
return Mirror;
|
|
953
|
-
}(reference_1.Reference));
|
|
954
|
-
exports.Mirror = Mirror;
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
// ./lib-es5/value/pointer.js
|
|
958
|
-
"use strict";
|
|
959
|
-
var __extends = (this && this.__extends) || (function () {
|
|
960
|
-
var extendStatics = function (d, b) {
|
|
961
|
-
extendStatics = Object.setPrototypeOf ||
|
|
962
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
963
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
964
|
-
return extendStatics(d, b);
|
|
965
|
-
};
|
|
966
|
-
return function (d, b) {
|
|
967
|
-
if (typeof b !== "function" && b !== null)
|
|
968
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
969
|
-
extendStatics(d, b);
|
|
970
|
-
function __() { this.constructor = d; }
|
|
971
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
972
|
-
};
|
|
973
|
-
})();
|
|
974
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
975
|
-
exports.Pointer = void 0;
|
|
976
|
-
var mirror_1 = require("./mirror");
|
|
977
|
-
/**
|
|
978
|
-
* r/w pointer to a value
|
|
979
|
-
* @class Pointer
|
|
980
|
-
* @extends Mirror
|
|
981
|
-
*/
|
|
982
|
-
var Pointer = /** @class */ (function (_super) {
|
|
983
|
-
__extends(Pointer, _super);
|
|
984
|
-
/**
|
|
985
|
-
* @param value {IValue} value to point
|
|
986
|
-
* @param forwardOnly {boolean} forward only data flow
|
|
987
|
-
*/
|
|
988
|
-
function Pointer(value, forwardOnly) {
|
|
989
|
-
if (forwardOnly === void 0) { forwardOnly = false; }
|
|
990
|
-
return _super.call(this, value, forwardOnly) || this;
|
|
991
|
-
}
|
|
992
|
-
Object.defineProperty(Pointer.prototype, "$$", {
|
|
993
|
-
/**
|
|
994
|
-
* Point a new ivalue
|
|
995
|
-
* @param value {IValue} value to point
|
|
996
|
-
*/
|
|
997
|
-
set: function (value) {
|
|
998
|
-
if (this.$pointedValue !== value) {
|
|
999
|
-
this.$disable();
|
|
1000
|
-
this.$pointedValue = value;
|
|
1001
|
-
this.$enable();
|
|
1002
|
-
}
|
|
1003
|
-
},
|
|
1004
|
-
enumerable: false,
|
|
1005
|
-
configurable: true
|
|
1006
|
-
});
|
|
1007
|
-
return Pointer;
|
|
1008
|
-
}(mirror_1.Mirror));
|
|
1009
|
-
exports.Pointer = Pointer;
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
// ./lib-es5/models/listener.js
|
|
1013
|
-
"use strict";
|
|
1014
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1015
|
-
exports.Listener = void 0;
|
|
1016
|
-
/**
|
|
1017
|
-
* Represent a listener for a model
|
|
1018
|
-
* @class Listener
|
|
1019
|
-
*/
|
|
1020
|
-
var Listener = /** @class */ (function () {
|
|
1021
|
-
function Listener() {
|
|
1022
|
-
Object.defineProperties(this, {
|
|
1023
|
-
onAdded: {
|
|
1024
|
-
value: new Set,
|
|
1025
|
-
writable: false,
|
|
1026
|
-
configurable: false
|
|
1027
|
-
},
|
|
1028
|
-
onRemoved: {
|
|
1029
|
-
value: new Set,
|
|
1030
|
-
writable: false,
|
|
1031
|
-
configurable: false
|
|
1032
|
-
},
|
|
1033
|
-
frozen: {
|
|
1034
|
-
value: false,
|
|
1035
|
-
writable: true,
|
|
1036
|
-
configurable: false
|
|
1037
|
-
},
|
|
1038
|
-
queue: {
|
|
1039
|
-
value: [],
|
|
1040
|
-
writable: false,
|
|
1041
|
-
configurable: false
|
|
1042
|
-
}
|
|
1043
|
-
});
|
|
1044
|
-
}
|
|
1045
|
-
/**
|
|
1046
|
-
* Exclude the repeated operation in queue
|
|
1047
|
-
* @private
|
|
1048
|
-
*/
|
|
1049
|
-
Listener.prototype.excludeRepeat = function (index) {
|
|
1050
|
-
var _this = this;
|
|
1051
|
-
this.queue.forEach(function (item, i) {
|
|
1052
|
-
if (item.index === index) {
|
|
1053
|
-
_this.queue.splice(i, 1);
|
|
1054
|
-
return true;
|
|
1055
|
-
}
|
|
1056
|
-
});
|
|
1057
|
-
return false;
|
|
1058
|
-
};
|
|
1059
|
-
/**
|
|
1060
|
-
* Emits added event to listeners
|
|
1061
|
-
* @param index {*} index of value
|
|
1062
|
-
* @param value {*} value of added item
|
|
1063
|
-
*/
|
|
1064
|
-
Listener.prototype.emitAdded = function (index, value) {
|
|
1065
|
-
if (this.frozen) {
|
|
1066
|
-
if (!this.excludeRepeat(index)) {
|
|
1067
|
-
this.queue.push({ sign: true, index: index, value: value });
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
else {
|
|
1071
|
-
this.onAdded.forEach(function (handler) {
|
|
1072
|
-
handler(index, value);
|
|
1073
|
-
});
|
|
1074
|
-
}
|
|
1075
|
-
};
|
|
1076
|
-
/**
|
|
1077
|
-
* Emits removed event to listeners
|
|
1078
|
-
* @param index {*} index of removed value
|
|
1079
|
-
* @param value {*} value of removed item
|
|
1080
|
-
*/
|
|
1081
|
-
Listener.prototype.emitRemoved = function (index, value) {
|
|
1082
|
-
if (this.frozen) {
|
|
1083
|
-
if (!this.excludeRepeat(index)) {
|
|
1084
|
-
this.queue.push({ sign: false, index: index, value: value });
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
else {
|
|
1088
|
-
this.onRemoved.forEach(function (handler) {
|
|
1089
|
-
handler(index, value);
|
|
1090
|
-
});
|
|
1091
|
-
}
|
|
1092
|
-
};
|
|
1093
|
-
/**
|
|
1094
|
-
* Adds a handler to added event
|
|
1095
|
-
* @param handler {function} function to run on event emitting
|
|
1096
|
-
*/
|
|
1097
|
-
Listener.prototype.onAdd = function (handler) {
|
|
1098
|
-
this.onAdded.add(handler);
|
|
1099
|
-
};
|
|
1100
|
-
/**
|
|
1101
|
-
* Adds a handler to removed event
|
|
1102
|
-
* @param handler {function} function to run on event emitting
|
|
1103
|
-
*/
|
|
1104
|
-
Listener.prototype.onRemove = function (handler) {
|
|
1105
|
-
this.onRemoved.add(handler);
|
|
1106
|
-
};
|
|
1107
|
-
/**
|
|
1108
|
-
* Removes an handler from added event
|
|
1109
|
-
* @param handler {function} handler to remove
|
|
1110
|
-
*/
|
|
1111
|
-
Listener.prototype.offAdd = function (handler) {
|
|
1112
|
-
this.onAdded.delete(handler);
|
|
1113
|
-
};
|
|
1114
|
-
/**
|
|
1115
|
-
* Removes an handler form removed event
|
|
1116
|
-
* @param handler {function} handler to remove
|
|
1117
|
-
*/
|
|
1118
|
-
Listener.prototype.offRemove = function (handler) {
|
|
1119
|
-
this.onRemoved.delete(handler);
|
|
1120
|
-
};
|
|
1121
|
-
/**
|
|
1122
|
-
* Run all queued operation and enable reactivity
|
|
1123
|
-
*/
|
|
1124
|
-
Listener.prototype.enableReactivity = function () {
|
|
1125
|
-
var _this = this;
|
|
1126
|
-
this.queue.forEach(function (item) {
|
|
1127
|
-
if (item.sign) {
|
|
1128
|
-
_this.onAdded.forEach(function (handler) {
|
|
1129
|
-
handler(item.index, item.value);
|
|
1130
|
-
});
|
|
1131
|
-
}
|
|
1132
|
-
else {
|
|
1133
|
-
_this.onRemoved.forEach(function (handler) {
|
|
1134
|
-
handler(item.index, item.value);
|
|
1135
|
-
});
|
|
1136
|
-
}
|
|
1137
|
-
});
|
|
1138
|
-
this.queue.splice(0);
|
|
1139
|
-
this.frozen = false;
|
|
1140
|
-
};
|
|
1141
|
-
/**
|
|
1142
|
-
* Disable the reactivity and enable the queue
|
|
1143
|
-
*/
|
|
1144
|
-
Listener.prototype.disableReactivity = function () {
|
|
1145
|
-
this.frozen = true;
|
|
1146
|
-
};
|
|
1147
|
-
return Listener;
|
|
1148
|
-
}());
|
|
1149
|
-
exports.Listener = Listener;
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
// ./lib-es5/models/model.js
|
|
1153
|
-
"use strict";
|
|
1154
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
// ./lib-es5/models/array-model.js
|
|
1158
|
-
"use strict";
|
|
1159
|
-
var __extends = (this && this.__extends) || (function () {
|
|
1160
|
-
var extendStatics = function (d, b) {
|
|
1161
|
-
extendStatics = Object.setPrototypeOf ||
|
|
1162
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1163
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1164
|
-
return extendStatics(d, b);
|
|
1165
|
-
};
|
|
1166
|
-
return function (d, b) {
|
|
1167
|
-
if (typeof b !== "function" && b !== null)
|
|
1168
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1169
|
-
extendStatics(d, b);
|
|
1170
|
-
function __() { this.constructor = d; }
|
|
1171
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1172
|
-
};
|
|
1173
|
-
})();
|
|
1174
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
1175
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1176
|
-
if (ar || !(i in from)) {
|
|
1177
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1178
|
-
ar[i] = from[i];
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1182
|
-
};
|
|
1183
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1184
|
-
exports.ArrayModel = void 0;
|
|
1185
|
-
var listener_1 = require("./listener");
|
|
1186
|
-
/**
|
|
1187
|
-
* Model based on Array class
|
|
1188
|
-
* @extends Array
|
|
1189
|
-
* @implements IModel
|
|
1190
|
-
*/
|
|
1191
|
-
var ArrayModel = /** @class */ (function (_super) {
|
|
1192
|
-
__extends(ArrayModel, _super);
|
|
1193
|
-
/**
|
|
1194
|
-
* @param data {Array} input data
|
|
1195
|
-
*/
|
|
1196
|
-
function ArrayModel(data) {
|
|
1197
|
-
if (data === void 0) { data = []; }
|
|
1198
|
-
var _this = this; _super.call(this);
|
|
1199
|
-
Object.defineProperty(_this, 'listener', {
|
|
1200
|
-
value: new listener_1.Listener,
|
|
1201
|
-
writable: false,
|
|
1202
|
-
configurable: false
|
|
1203
|
-
});
|
|
1204
|
-
for (var i = 0; i < data.length; i++) {
|
|
1205
|
-
_super.prototype.push.call(_this, data[i]);
|
|
1206
|
-
}
|
|
1207
|
-
return _this;
|
|
1208
|
-
}
|
|
1209
|
-
Object.defineProperty(ArrayModel.prototype, "last", {
|
|
1210
|
-
/* Array members */
|
|
1211
|
-
/**
|
|
1212
|
-
* Gets the last item of array
|
|
1213
|
-
* @return {*} the last item of array
|
|
1214
|
-
*/
|
|
1215
|
-
get: function () {
|
|
1216
|
-
return this.length ? this[this.length - 1] : null;
|
|
1217
|
-
},
|
|
1218
|
-
enumerable: false,
|
|
1219
|
-
configurable: true
|
|
1220
|
-
});
|
|
1221
|
-
/**
|
|
1222
|
-
* Calls Array.fill and notify about changes
|
|
1223
|
-
* @param value {*} value to fill with
|
|
1224
|
-
* @param start {?number} begin index
|
|
1225
|
-
* @param end {?number} end index
|
|
1226
|
-
*/
|
|
1227
|
-
ArrayModel.prototype.fill = function (value, start, end) {
|
|
1228
|
-
if (!start) {
|
|
1229
|
-
start = 0;
|
|
1230
|
-
}
|
|
1231
|
-
if (!end) {
|
|
1232
|
-
end = this.length;
|
|
1233
|
-
}
|
|
1234
|
-
for (var i = start; i < end; i++) {
|
|
1235
|
-
this.listener.emitRemoved(this[i], this[i]);
|
|
1236
|
-
this[i] = value;
|
|
1237
|
-
this.listener.emitAdded(value, value);
|
|
1238
|
-
}
|
|
1239
|
-
return this;
|
|
1240
|
-
};
|
|
1241
|
-
/**
|
|
1242
|
-
* Calls Array.pop and notify about changes
|
|
1243
|
-
* @return {*} removed value
|
|
1244
|
-
*/
|
|
1245
|
-
ArrayModel.prototype.pop = function () {
|
|
1246
|
-
var v = _super.prototype.pop.call(this);
|
|
1247
|
-
if (v !== undefined) {
|
|
1248
|
-
this.listener.emitRemoved(v, v);
|
|
1249
|
-
}
|
|
1250
|
-
return v;
|
|
1251
|
-
};
|
|
1252
|
-
/**
|
|
1253
|
-
* Calls Array.push and notify about changes
|
|
1254
|
-
* @param items {...*} values to push
|
|
1255
|
-
* @return {number} new length of array
|
|
1256
|
-
*/
|
|
1257
|
-
ArrayModel.prototype.push = function () {
|
|
1258
|
-
var _this = this;
|
|
1259
|
-
var items = [];
|
|
1260
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1261
|
-
items[_i] = arguments[_i];
|
|
1262
|
-
}
|
|
1263
|
-
items.forEach(function (item) {
|
|
1264
|
-
_this.listener.emitAdded(item, item);
|
|
1265
|
-
_super.prototype.push.call(_this, item);
|
|
1266
|
-
});
|
|
1267
|
-
return this.length;
|
|
1268
|
-
};
|
|
1269
|
-
/**
|
|
1270
|
-
* Calls Array.shift and notify about changed
|
|
1271
|
-
* @return {*} the shifted value
|
|
1272
|
-
*/
|
|
1273
|
-
ArrayModel.prototype.shift = function () {
|
|
1274
|
-
var v = _super.prototype.shift.call(this);
|
|
1275
|
-
if (v !== undefined) {
|
|
1276
|
-
this.listener.emitRemoved(v, v);
|
|
1277
|
-
}
|
|
1278
|
-
return v;
|
|
1279
|
-
};
|
|
1280
|
-
/**
|
|
1281
|
-
* Calls Array.splice and notify about changed
|
|
1282
|
-
* @param start {number} start index
|
|
1283
|
-
* @param deleteCount {?number} delete count
|
|
1284
|
-
* @param items {...*}
|
|
1285
|
-
* @return {ArrayModel} a pointer to this
|
|
1286
|
-
*/
|
|
1287
|
-
ArrayModel.prototype.splice = function (start, deleteCount) {
|
|
1288
|
-
var items = [];
|
|
1289
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1290
|
-
items[_i - 2] = arguments[_i];
|
|
1291
|
-
}
|
|
1292
|
-
start = Math.min(start, this.length);
|
|
1293
|
-
deleteCount = deleteCount || this.length - start;
|
|
1294
|
-
var before = this[start + deleteCount];
|
|
1295
|
-
for (var i = 0; i < deleteCount; i++) {
|
|
1296
|
-
var index = start + deleteCount - i - 1;
|
|
1297
|
-
if (this[index] !== undefined) {
|
|
1298
|
-
this.listener.emitRemoved(this[index], this[index]);
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
for (var i = 0; i < items.length; i++) {
|
|
1302
|
-
this.listener.emitAdded(before, items[i]);
|
|
1303
|
-
}
|
|
1304
|
-
return new ArrayModel(_super.prototype.splice.apply(this, __spreadArray([start, deleteCount], items, false)));
|
|
1305
|
-
};
|
|
1306
|
-
/**
|
|
1307
|
-
* Calls Array.unshift and notify about changed
|
|
1308
|
-
* @param items {...*} values to insert
|
|
1309
|
-
* @return {number} the length after prepend
|
|
1310
|
-
*/
|
|
1311
|
-
ArrayModel.prototype.unshift = function () {
|
|
1312
|
-
var items = [];
|
|
1313
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1314
|
-
items[_i] = arguments[_i];
|
|
1315
|
-
}
|
|
1316
|
-
for (var i = 0; i < items.length; i++) {
|
|
1317
|
-
this.listener.emitAdded(this[i], items[i]);
|
|
1318
|
-
}
|
|
1319
|
-
return _super.prototype.unshift.apply(this, items);
|
|
1320
|
-
};
|
|
1321
|
-
/**
|
|
1322
|
-
* Inserts a value to the end of array
|
|
1323
|
-
* @param v {*} value to insert
|
|
1324
|
-
*/
|
|
1325
|
-
ArrayModel.prototype.append = function (v) {
|
|
1326
|
-
this.listener.emitAdded(null, v);
|
|
1327
|
-
_super.prototype.push.call(this, v);
|
|
1328
|
-
return this;
|
|
1329
|
-
};
|
|
1330
|
-
/**
|
|
1331
|
-
* Clears array
|
|
1332
|
-
* @return {this} a pointer to this
|
|
1333
|
-
*/
|
|
1334
|
-
ArrayModel.prototype.clear = function () {
|
|
1335
|
-
var _this = this;
|
|
1336
|
-
this.forEach(function (v) {
|
|
1337
|
-
_this.listener.emitRemoved(v, v);
|
|
1338
|
-
});
|
|
1339
|
-
_super.prototype.splice.call(this, 0);
|
|
1340
|
-
return this;
|
|
1341
|
-
};
|
|
1342
|
-
/**
|
|
1343
|
-
* Inserts a value to position `index`
|
|
1344
|
-
* @param index {number} index to insert value
|
|
1345
|
-
* @param v {*} value to insert
|
|
1346
|
-
* @return {this} a pointer to this
|
|
1347
|
-
*/
|
|
1348
|
-
ArrayModel.prototype.insert = function (index, v) {
|
|
1349
|
-
this.listener.emitAdded(this[index], v);
|
|
1350
|
-
_super.prototype.splice.call(this, index, 0, v);
|
|
1351
|
-
return this;
|
|
1352
|
-
};
|
|
1353
|
-
/**
|
|
1354
|
-
* Inserts a value to the beginning of array
|
|
1355
|
-
* @param v {*} value to insert
|
|
1356
|
-
* @return {this} a pointer to this
|
|
1357
|
-
*/
|
|
1358
|
-
ArrayModel.prototype.prepend = function (v) {
|
|
1359
|
-
this.listener.emitAdded(this[0], v);
|
|
1360
|
-
_super.prototype.unshift.call(this, v);
|
|
1361
|
-
return this;
|
|
1362
|
-
};
|
|
1363
|
-
/**
|
|
1364
|
-
* Removes a value from an index
|
|
1365
|
-
* @param index {number} index of value to remove
|
|
1366
|
-
* @return {this} a pointer to this
|
|
1367
|
-
*/
|
|
1368
|
-
ArrayModel.prototype.removeAt = function (index) {
|
|
1369
|
-
if (index > 0 && index < this.length) {
|
|
1370
|
-
this.listener.emitRemoved(this[index], this[index]);
|
|
1371
|
-
_super.prototype.splice.call(this, index, 1);
|
|
1372
|
-
}
|
|
1373
|
-
return this;
|
|
1374
|
-
};
|
|
1375
|
-
/**
|
|
1376
|
-
* Removes the first value of array
|
|
1377
|
-
* @return {this} a pointer to this
|
|
1378
|
-
*/
|
|
1379
|
-
ArrayModel.prototype.removeFirst = function () {
|
|
1380
|
-
if (this.length) {
|
|
1381
|
-
this.listener.emitRemoved(this[0], this[0]);
|
|
1382
|
-
_super.prototype.shift.call(this);
|
|
1383
|
-
}
|
|
1384
|
-
return this;
|
|
1385
|
-
};
|
|
1386
|
-
/**
|
|
1387
|
-
* Removes the ast value of array
|
|
1388
|
-
* @return {this} a pointer to this
|
|
1389
|
-
*/
|
|
1390
|
-
ArrayModel.prototype.removeLast = function () {
|
|
1391
|
-
var last = this.last;
|
|
1392
|
-
if (last != null) {
|
|
1393
|
-
this.listener.emitRemoved(this[this.length - 1], last);
|
|
1394
|
-
_super.prototype.pop.call(this);
|
|
1395
|
-
}
|
|
1396
|
-
return this;
|
|
1397
|
-
};
|
|
1398
|
-
/**
|
|
1399
|
-
* Remove the first occurrence of value
|
|
1400
|
-
* @param v {*} value to remove
|
|
1401
|
-
* @return {this}
|
|
1402
|
-
*/
|
|
1403
|
-
ArrayModel.prototype.removeOne = function (v) {
|
|
1404
|
-
this.removeAt(this.indexOf(v));
|
|
1405
|
-
return this;
|
|
1406
|
-
};
|
|
1407
|
-
ArrayModel.prototype.replace = function (at, with_) {
|
|
1408
|
-
this.listener.emitAdded(this[at], with_);
|
|
1409
|
-
this.listener.emitRemoved(this[at], this[at]);
|
|
1410
|
-
this[at] = with_;
|
|
1411
|
-
return this;
|
|
1412
|
-
};
|
|
1413
|
-
ArrayModel.prototype.enableReactivity = function () {
|
|
1414
|
-
this.listener.enableReactivity();
|
|
1415
|
-
};
|
|
1416
|
-
ArrayModel.prototype.disableReactivity = function () {
|
|
1417
|
-
this.listener.disableReactivity();
|
|
1418
|
-
};
|
|
1419
|
-
return ArrayModel;
|
|
1420
|
-
}(Array));
|
|
1421
|
-
exports.ArrayModel = ArrayModel;
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
// ./lib-es5/models/map-model.js
|
|
1425
|
-
"use strict";
|
|
1426
|
-
var __extends = (this && this.__extends) || (function () {
|
|
1427
|
-
var extendStatics = function (d, b) {
|
|
1428
|
-
extendStatics = Object.setPrototypeOf ||
|
|
1429
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1430
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1431
|
-
return extendStatics(d, b);
|
|
1432
|
-
};
|
|
1433
|
-
return function (d, b) {
|
|
1434
|
-
if (typeof b !== "function" && b !== null)
|
|
1435
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1436
|
-
extendStatics(d, b);
|
|
1437
|
-
function __() { this.constructor = d; }
|
|
1438
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1439
|
-
};
|
|
1440
|
-
})();
|
|
1441
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1442
|
-
exports.MapModel = void 0;
|
|
1443
|
-
var listener_1 = require("./listener");
|
|
1444
|
-
/**
|
|
1445
|
-
* A Map based memory
|
|
1446
|
-
* @class MapModel
|
|
1447
|
-
* @extends Map
|
|
1448
|
-
* @implements IModel
|
|
1449
|
-
*/
|
|
1450
|
-
var MapModel = /** @class */ (function (_super) {
|
|
1451
|
-
__extends(MapModel, _super);
|
|
1452
|
-
/**
|
|
1453
|
-
* Constructs a map model
|
|
1454
|
-
* @param map {[*, *][]} input data
|
|
1455
|
-
*/
|
|
1456
|
-
function MapModel(map) {
|
|
1457
|
-
if (map === void 0) { map = []; }
|
|
1458
|
-
var _this = this; _super.call(this);
|
|
1459
|
-
Object.defineProperty(_this, 'listener', {
|
|
1460
|
-
value: new listener_1.Listener,
|
|
1461
|
-
writable: false,
|
|
1462
|
-
configurable: false
|
|
1463
|
-
});
|
|
1464
|
-
map.forEach(function (_a) {
|
|
1465
|
-
var key = _a[0], value = _a[1];
|
|
1466
|
-
_super.prototype.set.call(_this, key, value);
|
|
1467
|
-
});
|
|
1468
|
-
return _this;
|
|
1469
|
-
}
|
|
1470
|
-
/**
|
|
1471
|
-
* Calls Map.clear and notify abut changes
|
|
1472
|
-
*/
|
|
1473
|
-
MapModel.prototype.clear = function () {
|
|
1474
|
-
var _this = this;
|
|
1475
|
-
this.forEach(function (value, key) {
|
|
1476
|
-
_this.listener.emitRemoved(key, value);
|
|
1477
|
-
});
|
|
1478
|
-
_super.prototype.clear.call(this);
|
|
1479
|
-
};
|
|
1480
|
-
/**
|
|
1481
|
-
* Calls Map.delete and notify abut changes
|
|
1482
|
-
* @param key {*} key
|
|
1483
|
-
* @return {boolean} true if removed something, otherwise false
|
|
1484
|
-
*/
|
|
1485
|
-
MapModel.prototype.delete = function (key) {
|
|
1486
|
-
var tmp = _super.prototype.get.call(this, key);
|
|
1487
|
-
if (tmp) {
|
|
1488
|
-
this.listener.emitRemoved(key, tmp);
|
|
1489
|
-
}
|
|
1490
|
-
return _super.prototype.delete.call(this, key);
|
|
1491
|
-
};
|
|
1492
|
-
/**
|
|
1493
|
-
* Calls Map.set and notify abut changes
|
|
1494
|
-
* @param key {*} key
|
|
1495
|
-
* @param value {*} value
|
|
1496
|
-
* @return {MapModel} a pointer to this
|
|
1497
|
-
*/
|
|
1498
|
-
MapModel.prototype.set = function (key, value) {
|
|
1499
|
-
var tmp = _super.prototype.get.call(this, key);
|
|
1500
|
-
if (tmp) {
|
|
1501
|
-
this.listener.emitRemoved(key, tmp);
|
|
1502
|
-
}
|
|
1503
|
-
_super.prototype.set.call(this, key, value);
|
|
1504
|
-
this.listener.emitAdded(key, value);
|
|
1505
|
-
return this;
|
|
1506
|
-
};
|
|
1507
|
-
MapModel.prototype.enableReactivity = function () {
|
|
1508
|
-
this.listener.enableReactivity();
|
|
1509
|
-
};
|
|
1510
|
-
MapModel.prototype.disableReactivity = function () {
|
|
1511
|
-
this.listener.disableReactivity();
|
|
1512
|
-
};
|
|
1513
|
-
return MapModel;
|
|
1514
|
-
}(Map));
|
|
1515
|
-
exports.MapModel = MapModel;
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
// ./lib-es5/models/object-model.js
|
|
1519
|
-
"use strict";
|
|
1520
|
-
var __extends = (this && this.__extends) || (function () {
|
|
1521
|
-
var extendStatics = function (d, b) {
|
|
1522
|
-
extendStatics = Object.setPrototypeOf ||
|
|
1523
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1524
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1525
|
-
return extendStatics(d, b);
|
|
1526
|
-
};
|
|
1527
|
-
return function (d, b) {
|
|
1528
|
-
if (typeof b !== "function" && b !== null)
|
|
1529
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1530
|
-
extendStatics(d, b);
|
|
1531
|
-
function __() { this.constructor = d; }
|
|
1532
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1533
|
-
};
|
|
1534
|
-
})();
|
|
1535
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1536
|
-
exports.ObjectModel = void 0;
|
|
1537
|
-
var listener_1 = require("./listener");
|
|
1538
|
-
/**
|
|
1539
|
-
* Object based model
|
|
1540
|
-
* @extends Object
|
|
1541
|
-
*/
|
|
1542
|
-
var ObjectModel = /** @class */ (function (_super) {
|
|
1543
|
-
__extends(ObjectModel, _super);
|
|
1544
|
-
/**
|
|
1545
|
-
* Constructs a object model
|
|
1546
|
-
* @param obj {Object} input data
|
|
1547
|
-
*/
|
|
1548
|
-
function ObjectModel(obj) {
|
|
1549
|
-
if (obj === void 0) { obj = {}; }
|
|
1550
|
-
var _this = this; _super.call(this);
|
|
1551
|
-
_this.container = Object.create(null);
|
|
1552
|
-
Object.defineProperty(_this, 'listener', {
|
|
1553
|
-
value: new listener_1.Listener,
|
|
1554
|
-
writable: false,
|
|
1555
|
-
configurable: false
|
|
1556
|
-
});
|
|
1557
|
-
for (var i in obj) {
|
|
1558
|
-
Object.defineProperty(_this.container, i, {
|
|
1559
|
-
value: obj[i],
|
|
1560
|
-
configurable: true,
|
|
1561
|
-
writable: true,
|
|
1562
|
-
enumerable: true
|
|
1563
|
-
});
|
|
1564
|
-
_this.listener.emitAdded(i, obj[i]);
|
|
1565
|
-
}
|
|
1566
|
-
return _this;
|
|
1567
|
-
}
|
|
1568
|
-
/**
|
|
1569
|
-
* Gets a value of a field
|
|
1570
|
-
* @param key {string}
|
|
1571
|
-
* @return {*}
|
|
1572
|
-
*/
|
|
1573
|
-
ObjectModel.prototype.get = function (key) {
|
|
1574
|
-
return this.container[key];
|
|
1575
|
-
};
|
|
1576
|
-
/**
|
|
1577
|
-
* Sets an object property value
|
|
1578
|
-
* @param key {string} property name
|
|
1579
|
-
* @param v {*} property value
|
|
1580
|
-
* @return {ObjectModel} a pointer to this
|
|
1581
|
-
*/
|
|
1582
|
-
ObjectModel.prototype.set = function (key, v) {
|
|
1583
|
-
if (Reflect.has(this.container, key)) {
|
|
1584
|
-
this.listener.emitRemoved(key, this.container[key]);
|
|
1585
|
-
this.container[key] = v;
|
|
1586
|
-
}
|
|
1587
|
-
else {
|
|
1588
|
-
Object.defineProperty(this.container, key, {
|
|
1589
|
-
value: v,
|
|
1590
|
-
configurable: true,
|
|
1591
|
-
writable: true,
|
|
1592
|
-
enumerable: true
|
|
1593
|
-
});
|
|
1594
|
-
}
|
|
1595
|
-
this.listener.emitAdded(key, this.container[key]);
|
|
1596
|
-
return this;
|
|
1597
|
-
};
|
|
1598
|
-
Object.defineProperty(ObjectModel.prototype, "values", {
|
|
1599
|
-
get: function () {
|
|
1600
|
-
return this.container;
|
|
1601
|
-
},
|
|
1602
|
-
enumerable: false,
|
|
1603
|
-
configurable: true
|
|
1604
|
-
});
|
|
1605
|
-
/**
|
|
1606
|
-
* Deletes an object property
|
|
1607
|
-
* @param key {string} property name
|
|
1608
|
-
*/
|
|
1609
|
-
ObjectModel.prototype.delete = function (key) {
|
|
1610
|
-
if (this.container[key]) {
|
|
1611
|
-
this.listener.emitRemoved(key, this.container[key]);
|
|
1612
|
-
delete this.container[key];
|
|
1613
|
-
}
|
|
1614
|
-
};
|
|
1615
|
-
ObjectModel.prototype.enableReactivity = function () {
|
|
1616
|
-
this.listener.enableReactivity();
|
|
1617
|
-
};
|
|
1618
|
-
ObjectModel.prototype.disableReactivity = function () {
|
|
1619
|
-
this.listener.disableReactivity();
|
|
1620
|
-
};
|
|
1621
|
-
return ObjectModel;
|
|
1622
|
-
}(Object));
|
|
1623
|
-
exports.ObjectModel = ObjectModel;
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
// ./lib-es5/models/set-model.js
|
|
1627
|
-
"use strict";
|
|
1628
|
-
var __extends = (this && this.__extends) || (function () {
|
|
1629
|
-
var extendStatics = function (d, b) {
|
|
1630
|
-
extendStatics = Object.setPrototypeOf ||
|
|
1631
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1632
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1633
|
-
return extendStatics(d, b);
|
|
1634
|
-
};
|
|
1635
|
-
return function (d, b) {
|
|
1636
|
-
if (typeof b !== "function" && b !== null)
|
|
1637
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1638
|
-
extendStatics(d, b);
|
|
1639
|
-
function __() { this.constructor = d; }
|
|
1640
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1641
|
-
};
|
|
1642
|
-
})();
|
|
1643
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1644
|
-
exports.SetModel = void 0;
|
|
1645
|
-
var listener_1 = require("./listener");
|
|
1646
|
-
/**
|
|
1647
|
-
* A Set based model
|
|
1648
|
-
* @class SetModel
|
|
1649
|
-
* @extends Set
|
|
1650
|
-
* @implements IModel
|
|
1651
|
-
*/
|
|
1652
|
-
var SetModel = /** @class */ (function (_super) {
|
|
1653
|
-
__extends(SetModel, _super);
|
|
1654
|
-
/**
|
|
1655
|
-
* Constructs a set model based on a set
|
|
1656
|
-
* @param set {Set} input data
|
|
1657
|
-
*/
|
|
1658
|
-
function SetModel(set) {
|
|
1659
|
-
if (set === void 0) { set = []; }
|
|
1660
|
-
var _this = this; _super.call(this);
|
|
1661
|
-
Object.defineProperty(_this, 'listener', {
|
|
1662
|
-
value: new listener_1.Listener,
|
|
1663
|
-
writable: false,
|
|
1664
|
-
configurable: false
|
|
1665
|
-
});
|
|
1666
|
-
set.forEach(function (item) {
|
|
1667
|
-
_super.prototype.add.call(_this, item);
|
|
1668
|
-
});
|
|
1669
|
-
return _this;
|
|
1670
|
-
}
|
|
1671
|
-
/**
|
|
1672
|
-
* Calls Set.add and notify abut changes
|
|
1673
|
-
* @param value {*} value
|
|
1674
|
-
* @return {this} a pointer to this
|
|
1675
|
-
*/
|
|
1676
|
-
SetModel.prototype.add = function (value) {
|
|
1677
|
-
if (!_super.prototype.has.call(this, value)) {
|
|
1678
|
-
this.listener.emitAdded(value, value);
|
|
1679
|
-
_super.prototype.add.call(this, value);
|
|
1680
|
-
}
|
|
1681
|
-
return this;
|
|
1682
|
-
};
|
|
1683
|
-
/**
|
|
1684
|
-
* Calls Set.clear and notify abut changes
|
|
1685
|
-
*/
|
|
1686
|
-
SetModel.prototype.clear = function () {
|
|
1687
|
-
var _this = this;
|
|
1688
|
-
this.forEach(function (item) {
|
|
1689
|
-
_this.listener.emitRemoved(item, item);
|
|
1690
|
-
});
|
|
1691
|
-
_super.prototype.clear.call(this);
|
|
1692
|
-
};
|
|
1693
|
-
/**
|
|
1694
|
-
* Calls Set.delete and notify abut changes
|
|
1695
|
-
* @param value {*}
|
|
1696
|
-
* @return {boolean} true if a value was deleted, otherwise false
|
|
1697
|
-
*/
|
|
1698
|
-
SetModel.prototype.delete = function (value) {
|
|
1699
|
-
if (_super.prototype.has.call(this, value)) {
|
|
1700
|
-
this.listener.emitRemoved(value, value);
|
|
1701
|
-
}
|
|
1702
|
-
return _super.prototype.delete.call(this, value);
|
|
1703
|
-
};
|
|
1704
|
-
SetModel.prototype.enableReactivity = function () {
|
|
1705
|
-
this.listener.enableReactivity();
|
|
1706
|
-
};
|
|
1707
|
-
SetModel.prototype.disableReactivity = function () {
|
|
1708
|
-
this.listener.disableReactivity();
|
|
1709
|
-
};
|
|
1710
|
-
return SetModel;
|
|
1711
|
-
}(Set));
|
|
1712
|
-
exports.SetModel = SetModel;
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
// ./lib-es5/spec/html.js
|
|
1716
|
-
"use strict";
|
|
1717
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
// ./lib-es5/spec/svg.js
|
|
1721
|
-
"use strict";
|
|
1722
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
// ./lib-es5/spec/react.js
|
|
1726
|
-
"use strict";
|
|
1727
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
// ./lib-es5/binding/binding.js
|
|
1731
|
-
"use strict";
|
|
1732
|
-
var __extends = (this && this.__extends) || (function () {
|
|
1733
|
-
var extendStatics = function (d, b) {
|
|
1734
|
-
extendStatics = Object.setPrototypeOf ||
|
|
1735
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1736
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1737
|
-
return extendStatics(d, b);
|
|
1738
|
-
};
|
|
1739
|
-
return function (d, b) {
|
|
1740
|
-
if (typeof b !== "function" && b !== null)
|
|
1741
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1742
|
-
extendStatics(d, b);
|
|
1743
|
-
function __() { this.constructor = d; }
|
|
1744
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1745
|
-
};
|
|
1746
|
-
})();
|
|
1747
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1748
|
-
exports.Binding = void 0;
|
|
1749
|
-
var destroyable_1 = require("../core/destroyable");
|
|
1750
|
-
/**
|
|
1751
|
-
* Describe a common binding logic
|
|
1752
|
-
* @class Binding
|
|
1753
|
-
* @extends Destroyable
|
|
1754
|
-
*/
|
|
1755
|
-
var Binding = /** @class */ (function (_super) {
|
|
1756
|
-
__extends(Binding, _super);
|
|
1757
|
-
/**
|
|
1758
|
-
* Constructs a common binding logic
|
|
1759
|
-
* @param value {IValue} the value to bind
|
|
1760
|
-
*/
|
|
1761
|
-
function Binding(value) {
|
|
1762
|
-
var _this = this; _super.call(this);
|
|
1763
|
-
_this.binding = value;
|
|
1764
|
-
_this.$seal();
|
|
1765
|
-
return _this;
|
|
1766
|
-
}
|
|
1767
|
-
Binding.prototype.init = function (bounded) {
|
|
1768
|
-
this.func = bounded;
|
|
1769
|
-
this.binding.$on(this.func);
|
|
1770
|
-
this.func(this.binding.$);
|
|
1771
|
-
};
|
|
1772
|
-
/**
|
|
1773
|
-
* Just clear bindings
|
|
1774
|
-
*/
|
|
1775
|
-
Binding.prototype.$destroy = function () {
|
|
1776
|
-
this.binding.$off(this.func);
|
|
1777
|
-
_super.prototype.$destroy.call(this);
|
|
1778
|
-
};
|
|
1779
|
-
return Binding;
|
|
1780
|
-
}(destroyable_1.Destroyable));
|
|
1781
|
-
exports.Binding = Binding;
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
// ./lib-es5/binding/attribute.js
|
|
1785
|
-
"use strict";
|
|
1786
|
-
var __extends = (this && this.__extends) || (function () {
|
|
1787
|
-
var extendStatics = function (d, b) {
|
|
1788
|
-
extendStatics = Object.setPrototypeOf ||
|
|
1789
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1790
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1791
|
-
return extendStatics(d, b);
|
|
1792
|
-
};
|
|
1793
|
-
return function (d, b) {
|
|
1794
|
-
if (typeof b !== "function" && b !== null)
|
|
1795
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1796
|
-
extendStatics(d, b);
|
|
1797
|
-
function __() { this.constructor = d; }
|
|
1798
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1799
|
-
};
|
|
1800
|
-
})();
|
|
1801
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1802
|
-
exports.AttributeBinding = void 0;
|
|
1803
|
-
var binding_1 = require("./binding");
|
|
1804
|
-
/**
|
|
1805
|
-
* Represents an Attribute binding description
|
|
1806
|
-
* @class AttributeBinding
|
|
1807
|
-
* @extends Binding
|
|
1808
|
-
*/
|
|
1809
|
-
var AttributeBinding = /** @class */ (function (_super) {
|
|
1810
|
-
__extends(AttributeBinding, _super);
|
|
1811
|
-
/**
|
|
1812
|
-
* Constructs an attribute binding description
|
|
1813
|
-
* @param node {INode} the vasille node
|
|
1814
|
-
* @param name {String} the name of attribute
|
|
1815
|
-
* @param value {IValue} value to bind
|
|
1816
|
-
*/
|
|
1817
|
-
function AttributeBinding(node, name, value) {
|
|
1818
|
-
var _this = _super.call(this, value) || this;
|
|
1819
|
-
_this.init(function (value) {
|
|
1820
|
-
if (value) {
|
|
1821
|
-
if (typeof value === 'boolean') {
|
|
1822
|
-
node.node.setAttribute(name, "");
|
|
1823
|
-
}
|
|
1824
|
-
else {
|
|
1825
|
-
node.node.setAttribute(name, "".concat(value));
|
|
1826
|
-
}
|
|
1827
|
-
}
|
|
1828
|
-
else {
|
|
1829
|
-
node.node.removeAttribute(name);
|
|
1830
|
-
}
|
|
1831
|
-
});
|
|
1832
|
-
_this.$seal();
|
|
1833
|
-
return _this;
|
|
1834
|
-
}
|
|
1835
|
-
return AttributeBinding;
|
|
1836
|
-
}(binding_1.Binding));
|
|
1837
|
-
exports.AttributeBinding = AttributeBinding;
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
// ./lib-es5/binding/class.js
|
|
1841
|
-
"use strict";
|
|
1842
|
-
var __extends = (this && this.__extends) || (function () {
|
|
1843
|
-
var extendStatics = function (d, b) {
|
|
1844
|
-
extendStatics = Object.setPrototypeOf ||
|
|
1845
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1846
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1847
|
-
return extendStatics(d, b);
|
|
1848
|
-
};
|
|
1849
|
-
return function (d, b) {
|
|
1850
|
-
if (typeof b !== "function" && b !== null)
|
|
1851
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1852
|
-
extendStatics(d, b);
|
|
1853
|
-
function __() { this.constructor = d; }
|
|
1854
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1855
|
-
};
|
|
1856
|
-
})();
|
|
1857
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1858
|
-
exports.DynamicalClassBinding = exports.StaticClassBinding = void 0;
|
|
1859
|
-
var binding_1 = require("./binding");
|
|
1860
|
-
function addClass(node, cl) {
|
|
1861
|
-
node.node.classList.add(cl);
|
|
1862
|
-
}
|
|
1863
|
-
function removeClass(node, cl) {
|
|
1864
|
-
node.node.classList.remove(cl);
|
|
1865
|
-
}
|
|
1866
|
-
var StaticClassBinding = /** @class */ (function (_super) {
|
|
1867
|
-
__extends(StaticClassBinding, _super);
|
|
1868
|
-
function StaticClassBinding(node, name, value) {
|
|
1869
|
-
var _this = _super.call(this, value) || this;
|
|
1870
|
-
_this.current = false;
|
|
1871
|
-
_this.init(function (value) {
|
|
1872
|
-
if (value !== _this.current) {
|
|
1873
|
-
if (value) {
|
|
1874
|
-
addClass(node, name);
|
|
1875
|
-
}
|
|
1876
|
-
else {
|
|
1877
|
-
removeClass(node, name);
|
|
1878
|
-
}
|
|
1879
|
-
_this.current = value;
|
|
1880
|
-
}
|
|
1881
|
-
});
|
|
1882
|
-
_this.$seal();
|
|
1883
|
-
return _this;
|
|
1884
|
-
}
|
|
1885
|
-
return StaticClassBinding;
|
|
1886
|
-
}(binding_1.Binding));
|
|
1887
|
-
exports.StaticClassBinding = StaticClassBinding;
|
|
1888
|
-
var DynamicalClassBinding = /** @class */ (function (_super) {
|
|
1889
|
-
__extends(DynamicalClassBinding, _super);
|
|
1890
|
-
function DynamicalClassBinding(node, value) {
|
|
1891
|
-
var _this = _super.call(this, value) || this;
|
|
1892
|
-
_this.current = "";
|
|
1893
|
-
_this.init(function (value) {
|
|
1894
|
-
if (_this.current != value) {
|
|
1895
|
-
if (_this.current.length) {
|
|
1896
|
-
removeClass(node, _this.current);
|
|
1897
|
-
}
|
|
1898
|
-
if (value.length) {
|
|
1899
|
-
addClass(node, value);
|
|
1900
|
-
}
|
|
1901
|
-
_this.current = value;
|
|
1902
|
-
}
|
|
1903
|
-
});
|
|
1904
|
-
_this.$seal();
|
|
1905
|
-
return _this;
|
|
1906
|
-
}
|
|
1907
|
-
return DynamicalClassBinding;
|
|
1908
|
-
}(binding_1.Binding));
|
|
1909
|
-
exports.DynamicalClassBinding = DynamicalClassBinding;
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
// ./lib-es5/binding/style.js
|
|
1913
|
-
"use strict";
|
|
1914
|
-
var __extends = (this && this.__extends) || (function () {
|
|
1915
|
-
var extendStatics = function (d, b) {
|
|
1916
|
-
extendStatics = Object.setPrototypeOf ||
|
|
1917
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1918
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1919
|
-
return extendStatics(d, b);
|
|
1920
|
-
};
|
|
1921
|
-
return function (d, b) {
|
|
1922
|
-
if (typeof b !== "function" && b !== null)
|
|
1923
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1924
|
-
extendStatics(d, b);
|
|
1925
|
-
function __() { this.constructor = d; }
|
|
1926
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1927
|
-
};
|
|
1928
|
-
})();
|
|
1929
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1930
|
-
exports.StyleBinding = void 0;
|
|
1931
|
-
var binding_1 = require("./binding");
|
|
1932
|
-
/**
|
|
1933
|
-
* Describes a style attribute binding
|
|
1934
|
-
* @class StyleBinding
|
|
1935
|
-
* @extends Binding
|
|
1936
|
-
*/
|
|
1937
|
-
var StyleBinding = /** @class */ (function (_super) {
|
|
1938
|
-
__extends(StyleBinding, _super);
|
|
1939
|
-
/**
|
|
1940
|
-
* Constructs a style binding attribute
|
|
1941
|
-
* @param node {INode} the vasille node
|
|
1942
|
-
* @param name {string} the name of style property
|
|
1943
|
-
* @param value {IValue} the value to bind
|
|
1944
|
-
*/
|
|
1945
|
-
function StyleBinding(node, name, value) {
|
|
1946
|
-
var _this = _super.call(this, value) || this;
|
|
1947
|
-
_this.init(function (value) {
|
|
1948
|
-
if (node.node instanceof HTMLElement) {
|
|
1949
|
-
node.node.style.setProperty(name, value);
|
|
1950
|
-
}
|
|
1951
|
-
});
|
|
1952
|
-
_this.$seal();
|
|
1953
|
-
return _this;
|
|
1954
|
-
}
|
|
1955
|
-
return StyleBinding;
|
|
1956
|
-
}(binding_1.Binding));
|
|
1957
|
-
exports.StyleBinding = StyleBinding;
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
// ./lib-es5/node/node.js
|
|
1961
|
-
"use strict";
|
|
1962
|
-
var __extends = (this && this.__extends) || (function () {
|
|
1963
|
-
var extendStatics = function (d, b) {
|
|
1964
|
-
extendStatics = Object.setPrototypeOf ||
|
|
1965
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1966
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1967
|
-
return extendStatics(d, b);
|
|
1968
|
-
};
|
|
1969
|
-
return function (d, b) {
|
|
1970
|
-
if (typeof b !== "function" && b !== null)
|
|
1971
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1972
|
-
extendStatics(d, b);
|
|
1973
|
-
function __() { this.constructor = d; }
|
|
1974
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1975
|
-
};
|
|
1976
|
-
})();
|
|
1977
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1978
|
-
exports.DebugNode = exports.DebugPrivate = exports.SwitchedNode = exports.SwitchedNodePrivate = exports.Component = exports.Extension = exports.Tag = exports.INode = exports.INodePrivate = exports.TextNode = exports.TextNodePrivate = exports.Fragment = exports.FragmentPrivate = void 0;
|
|
1979
|
-
var core_1 = require("../core/core");
|
|
1980
|
-
var ivalue_1 = require("../core/ivalue");
|
|
1981
|
-
var reference_1 = require("../value/reference");
|
|
1982
|
-
var expression_1 = require("../value/expression");
|
|
1983
|
-
var attribute_1 = require("../binding/attribute");
|
|
1984
|
-
var class_1 = require("../binding/class");
|
|
1985
|
-
var style_1 = require("../binding/style");
|
|
1986
|
-
var errors_1 = require("../core/errors");
|
|
1987
|
-
/**
|
|
1988
|
-
* Represents a Vasille.js node
|
|
1989
|
-
* @class FragmentPrivate
|
|
1990
|
-
* @extends ReactivePrivate
|
|
1991
|
-
*/
|
|
1992
|
-
var FragmentPrivate = /** @class */ (function (_super) {
|
|
1993
|
-
__extends(FragmentPrivate, _super);
|
|
1994
|
-
function FragmentPrivate() {
|
|
1995
|
-
var _this = this; _super.call(this);
|
|
1996
|
-
_this.$seal();
|
|
1997
|
-
return _this;
|
|
1998
|
-
}
|
|
1999
|
-
/**
|
|
2000
|
-
* Pre-initializes the base of a fragment
|
|
2001
|
-
* @param app {App} the app node
|
|
2002
|
-
* @param parent {Fragment} the parent node
|
|
2003
|
-
*/
|
|
2004
|
-
FragmentPrivate.prototype.preinit = function (app, parent) {
|
|
2005
|
-
this.app = app;
|
|
2006
|
-
this.parent = parent;
|
|
2007
|
-
};
|
|
2008
|
-
/**
|
|
2009
|
-
* Unlinks all bindings
|
|
2010
|
-
*/
|
|
2011
|
-
FragmentPrivate.prototype.$destroy = function () {
|
|
2012
|
-
this.next = null;
|
|
2013
|
-
this.prev = null;
|
|
2014
|
-
_super.prototype.$destroy.call(this);
|
|
2015
|
-
};
|
|
2016
|
-
return FragmentPrivate;
|
|
2017
|
-
}(core_1.ReactivePrivate));
|
|
2018
|
-
exports.FragmentPrivate = FragmentPrivate;
|
|
2019
|
-
/**
|
|
2020
|
-
* This class is symbolic
|
|
2021
|
-
* @extends Reactive
|
|
2022
|
-
*/
|
|
2023
|
-
var Fragment = /** @class */ (function (_super) {
|
|
2024
|
-
__extends(Fragment, _super);
|
|
2025
|
-
/**
|
|
2026
|
-
* Constructs a Vasille Node
|
|
2027
|
-
* @param input
|
|
2028
|
-
* @param $ {FragmentPrivate}
|
|
2029
|
-
*/
|
|
2030
|
-
function Fragment(input, $) {
|
|
2031
|
-
var _this = _super.call(this, input, $ || new FragmentPrivate) || this;
|
|
2032
|
-
/**
|
|
2033
|
-
* The children list
|
|
2034
|
-
* @type Array
|
|
2035
|
-
*/
|
|
2036
|
-
_this.children = new Set;
|
|
2037
|
-
_this.lastChild = null;
|
|
2038
|
-
return _this;
|
|
2039
|
-
}
|
|
2040
|
-
Object.defineProperty(Fragment.prototype, "app", {
|
|
2041
|
-
/**
|
|
2042
|
-
* Gets the app of node
|
|
2043
|
-
*/
|
|
2044
|
-
get: function () {
|
|
2045
|
-
return this.$.app;
|
|
2046
|
-
},
|
|
2047
|
-
enumerable: false,
|
|
2048
|
-
configurable: true
|
|
2049
|
-
});
|
|
2050
|
-
/**
|
|
2051
|
-
* Prepare to init fragment
|
|
2052
|
-
* @param app {AppNode} app of node
|
|
2053
|
-
* @param parent {Fragment} parent of node
|
|
2054
|
-
* @param data {*} additional data
|
|
2055
|
-
*/
|
|
2056
|
-
Fragment.prototype.preinit = function (app, parent, data) {
|
|
2057
|
-
var $ = this.$;
|
|
2058
|
-
$.preinit(app, parent);
|
|
2059
|
-
};
|
|
2060
|
-
Fragment.prototype.init = function () {
|
|
2061
|
-
var ret = _super.prototype.init.call(this);
|
|
2062
|
-
this.ready();
|
|
2063
|
-
return ret;
|
|
2064
|
-
};
|
|
2065
|
-
Fragment.prototype.compose = function (input) {
|
|
2066
|
-
input.slot && input.slot(this);
|
|
2067
|
-
};
|
|
2068
|
-
/** To be overloaded: ready event handler */
|
|
2069
|
-
Fragment.prototype.ready = function () {
|
|
2070
|
-
// empty
|
|
2071
|
-
};
|
|
2072
|
-
/**
|
|
2073
|
-
* Pushes a node to children immediately
|
|
2074
|
-
* @param node {Fragment} A node to push
|
|
2075
|
-
* @protected
|
|
2076
|
-
*/
|
|
2077
|
-
Fragment.prototype.pushNode = function (node) {
|
|
2078
|
-
if (this.lastChild) {
|
|
2079
|
-
this.lastChild.$.next = node;
|
|
2080
|
-
}
|
|
2081
|
-
node.$.prev = this.lastChild;
|
|
2082
|
-
this.lastChild = node;
|
|
2083
|
-
this.children.add(node);
|
|
2084
|
-
};
|
|
2085
|
-
/**
|
|
2086
|
-
* Find first node in element if so exists
|
|
2087
|
-
* @return {?Element}
|
|
2088
|
-
* @protected
|
|
2089
|
-
*/
|
|
2090
|
-
Fragment.prototype.findFirstChild = function () {
|
|
2091
|
-
var first;
|
|
2092
|
-
this.children.forEach(function (child) {
|
|
2093
|
-
first = first || child.findFirstChild();
|
|
2094
|
-
});
|
|
2095
|
-
return first;
|
|
2096
|
-
};
|
|
2097
|
-
/**
|
|
2098
|
-
* Append a node to end of element
|
|
2099
|
-
* @param node {Node} node to insert
|
|
2100
|
-
*/
|
|
2101
|
-
Fragment.prototype.appendNode = function (node) {
|
|
2102
|
-
var $ = this.$;
|
|
2103
|
-
if ($.next) {
|
|
2104
|
-
$.next.insertAdjacent(node);
|
|
2105
|
-
}
|
|
2106
|
-
else {
|
|
2107
|
-
$.parent.appendNode(node);
|
|
2108
|
-
}
|
|
2109
|
-
};
|
|
2110
|
-
/**
|
|
2111
|
-
* Insert a node as a sibling of this
|
|
2112
|
-
* @param node {Node} node to insert
|
|
2113
|
-
*/
|
|
2114
|
-
Fragment.prototype.insertAdjacent = function (node) {
|
|
2115
|
-
var child = this.findFirstChild();
|
|
2116
|
-
var $ = this.$;
|
|
2117
|
-
if (child) {
|
|
2118
|
-
child.parentElement.insertBefore(node, child);
|
|
2119
|
-
}
|
|
2120
|
-
else if ($.next) {
|
|
2121
|
-
$.next.insertAdjacent(node);
|
|
2122
|
-
}
|
|
2123
|
-
else {
|
|
2124
|
-
$.parent.appendNode(node);
|
|
2125
|
-
}
|
|
2126
|
-
};
|
|
2127
|
-
/**
|
|
2128
|
-
* Defines a text fragment
|
|
2129
|
-
* @param text {String | IValue} A text fragment string
|
|
2130
|
-
* @param cb {function (TextNode)} Callback if previous is slot name
|
|
2131
|
-
*/
|
|
2132
|
-
Fragment.prototype.text = function (text, cb) {
|
|
2133
|
-
var $ = this.$;
|
|
2134
|
-
var node = new TextNode();
|
|
2135
|
-
node.preinit($.app, this, text);
|
|
2136
|
-
this.pushNode(node);
|
|
2137
|
-
cb && cb(node);
|
|
2138
|
-
};
|
|
2139
|
-
Fragment.prototype.debug = function (text) {
|
|
2140
|
-
if (this.$.app.debugUi) {
|
|
2141
|
-
var node = new DebugNode();
|
|
2142
|
-
node.preinit(this.$.app, this, text);
|
|
2143
|
-
this.pushNode(node);
|
|
2144
|
-
}
|
|
2145
|
-
};
|
|
2146
|
-
/**
|
|
2147
|
-
* Defines a tag element
|
|
2148
|
-
* @param tagName {String} the tag name
|
|
2149
|
-
* @param input
|
|
2150
|
-
* @param cb {function(Tag, *)} callback
|
|
2151
|
-
*/
|
|
2152
|
-
Fragment.prototype.tag = function (tagName, input, cb
|
|
2153
|
-
// @ts-ignore
|
|
2154
|
-
) {
|
|
2155
|
-
var $ = this.$;
|
|
2156
|
-
var node = new Tag(input);
|
|
2157
|
-
input.slot = cb || input.slot;
|
|
2158
|
-
node.preinit($.app, this, tagName);
|
|
2159
|
-
node.init();
|
|
2160
|
-
this.pushNode(node);
|
|
2161
|
-
node.ready();
|
|
2162
|
-
// @ts-ignore
|
|
2163
|
-
return node.node;
|
|
2164
|
-
};
|
|
2165
|
-
/**
|
|
2166
|
-
* Defines a custom element
|
|
2167
|
-
* @param node {Fragment} vasille element to insert
|
|
2168
|
-
* @param callback {function($ : *)}
|
|
2169
|
-
*/
|
|
2170
|
-
Fragment.prototype.create = function (node, callback) {
|
|
2171
|
-
var $ = this.$;
|
|
2172
|
-
node.$.parent = this;
|
|
2173
|
-
node.preinit($.app, this);
|
|
2174
|
-
node.input.slot = callback || node.input.slot;
|
|
2175
|
-
this.pushNode(node);
|
|
2176
|
-
return node.init();
|
|
2177
|
-
};
|
|
2178
|
-
/**
|
|
2179
|
-
* Defines an if node
|
|
2180
|
-
* @param cond {IValue} condition
|
|
2181
|
-
* @param cb {function(Fragment)} callback to run on true
|
|
2182
|
-
* @return {this}
|
|
2183
|
-
*/
|
|
2184
|
-
Fragment.prototype.if = function (cond, cb) {
|
|
2185
|
-
var node = new SwitchedNode();
|
|
2186
|
-
node.preinit(this.$.app, this);
|
|
2187
|
-
node.init();
|
|
2188
|
-
this.pushNode(node);
|
|
2189
|
-
node.addCase(this.case(cond, cb));
|
|
2190
|
-
node.ready();
|
|
2191
|
-
};
|
|
2192
|
-
Fragment.prototype.else = function (cb) {
|
|
2193
|
-
if (this.lastChild instanceof SwitchedNode) {
|
|
2194
|
-
this.lastChild.addCase(this.default(cb));
|
|
2195
|
-
}
|
|
2196
|
-
else {
|
|
2197
|
-
throw (0, errors_1.userError)('wrong `else` function use', 'logic-error');
|
|
2198
|
-
}
|
|
2199
|
-
};
|
|
2200
|
-
Fragment.prototype.elif = function (cond, cb) {
|
|
2201
|
-
if (this.lastChild instanceof SwitchedNode) {
|
|
2202
|
-
this.lastChild.addCase(this.case(cond, cb));
|
|
2203
|
-
}
|
|
2204
|
-
else {
|
|
2205
|
-
throw (0, errors_1.userError)('wrong `elif` function use', 'logic-error');
|
|
2206
|
-
}
|
|
2207
|
-
};
|
|
2208
|
-
/**
|
|
2209
|
-
* Create a case for switch
|
|
2210
|
-
* @param cond {IValue<boolean>}
|
|
2211
|
-
* @param cb {function(Fragment) : void}
|
|
2212
|
-
* @return {{cond : IValue, cb : (function(Fragment) : void)}}
|
|
2213
|
-
*/
|
|
2214
|
-
Fragment.prototype.case = function (cond, cb) {
|
|
2215
|
-
return { cond: cond, cb: cb };
|
|
2216
|
-
};
|
|
2217
|
-
/**
|
|
2218
|
-
* @param cb {(function(Fragment) : void)}
|
|
2219
|
-
* @return {{cond : IValue, cb : (function(Fragment) : void)}}
|
|
2220
|
-
*/
|
|
2221
|
-
Fragment.prototype.default = function (cb) {
|
|
2222
|
-
return { cond: trueIValue, cb: cb };
|
|
2223
|
-
};
|
|
2224
|
-
Fragment.prototype.insertBefore = function (node) {
|
|
2225
|
-
var $ = this.$;
|
|
2226
|
-
node.$.prev = $.prev;
|
|
2227
|
-
node.$.next = this;
|
|
2228
|
-
if ($.prev) {
|
|
2229
|
-
$.prev.$.next = node;
|
|
2230
|
-
}
|
|
2231
|
-
$.prev = node;
|
|
2232
|
-
};
|
|
2233
|
-
Fragment.prototype.insertAfter = function (node) {
|
|
2234
|
-
var $ = this.$;
|
|
2235
|
-
node.$.prev = this;
|
|
2236
|
-
node.$.next = $.next;
|
|
2237
|
-
$.next = node;
|
|
2238
|
-
};
|
|
2239
|
-
Fragment.prototype.remove = function () {
|
|
2240
|
-
var $ = this.$;
|
|
2241
|
-
if ($.next) {
|
|
2242
|
-
$.next.$.prev = $.prev;
|
|
2243
|
-
}
|
|
2244
|
-
if ($.prev) {
|
|
2245
|
-
$.prev.$.next = $.next;
|
|
2246
|
-
}
|
|
2247
|
-
};
|
|
2248
|
-
Fragment.prototype.$destroy = function () {
|
|
2249
|
-
this.children.forEach(function (child) { return child.$destroy(); });
|
|
2250
|
-
this.children.clear();
|
|
2251
|
-
this.lastChild = null;
|
|
2252
|
-
if (this.$.parent.lastChild === this) {
|
|
2253
|
-
this.$.parent.lastChild = this.$.prev;
|
|
2254
|
-
}
|
|
2255
|
-
_super.prototype.$destroy.call(this);
|
|
2256
|
-
};
|
|
2257
|
-
return Fragment;
|
|
2258
|
-
}(core_1.Reactive));
|
|
2259
|
-
exports.Fragment = Fragment;
|
|
2260
|
-
var trueIValue = new reference_1.Reference(true);
|
|
2261
|
-
/**
|
|
2262
|
-
* The private part of a text node
|
|
2263
|
-
* @class TextNodePrivate
|
|
2264
|
-
* @extends FragmentPrivate
|
|
2265
|
-
*/
|
|
2266
|
-
var TextNodePrivate = /** @class */ (function (_super) {
|
|
2267
|
-
__extends(TextNodePrivate, _super);
|
|
2268
|
-
function TextNodePrivate() {
|
|
2269
|
-
var _this = this; _super.call(this);
|
|
2270
|
-
_this.$seal();
|
|
2271
|
-
return _this;
|
|
2272
|
-
}
|
|
2273
|
-
/**
|
|
2274
|
-
* Pre-initializes a text node
|
|
2275
|
-
* @param app {AppNode} the app node
|
|
2276
|
-
* @param parent
|
|
2277
|
-
* @param text {IValue}
|
|
2278
|
-
*/
|
|
2279
|
-
TextNodePrivate.prototype.preinitText = function (app, parent, text) {
|
|
2280
|
-
var _this = this;
|
|
2281
|
-
_super.prototype.preinit.call(this, app, parent);
|
|
2282
|
-
this.node = document.createTextNode(text instanceof ivalue_1.IValue ? text.$ : text);
|
|
2283
|
-
if (text instanceof ivalue_1.IValue) {
|
|
2284
|
-
this.bindings.add(new expression_1.Expression(function (v) {
|
|
2285
|
-
_this.node.replaceData(0, -1, v);
|
|
2286
|
-
}, true, text));
|
|
2287
|
-
}
|
|
2288
|
-
};
|
|
2289
|
-
/**
|
|
2290
|
-
* Clear node data
|
|
2291
|
-
*/
|
|
2292
|
-
TextNodePrivate.prototype.$destroy = function () {
|
|
2293
|
-
_super.prototype.$destroy.call(this);
|
|
2294
|
-
};
|
|
2295
|
-
return TextNodePrivate;
|
|
2296
|
-
}(FragmentPrivate));
|
|
2297
|
-
exports.TextNodePrivate = TextNodePrivate;
|
|
2298
|
-
/**
|
|
2299
|
-
* Represents a text node
|
|
2300
|
-
* @class TextNode
|
|
2301
|
-
* @extends Fragment
|
|
2302
|
-
*/
|
|
2303
|
-
var TextNode = /** @class */ (function (_super) {
|
|
2304
|
-
__extends(TextNode, _super);
|
|
2305
|
-
function TextNode($) {
|
|
2306
|
-
if ($ === void 0) { $ = new TextNodePrivate(); }
|
|
2307
|
-
var _this = _super.call(this, {}, $) || this;
|
|
2308
|
-
_this.$seal();
|
|
2309
|
-
return _this;
|
|
2310
|
-
}
|
|
2311
|
-
TextNode.prototype.preinit = function (app, parent, text) {
|
|
2312
|
-
var $ = this.$;
|
|
2313
|
-
if (!text) {
|
|
2314
|
-
throw (0, errors_1.internalError)('wrong TextNode::$preninit call');
|
|
2315
|
-
}
|
|
2316
|
-
$.preinitText(app, parent, text);
|
|
2317
|
-
$.parent.appendNode($.node);
|
|
2318
|
-
};
|
|
2319
|
-
TextNode.prototype.findFirstChild = function () {
|
|
2320
|
-
return this.$.node;
|
|
2321
|
-
};
|
|
2322
|
-
TextNode.prototype.$destroy = function () {
|
|
2323
|
-
this.$.node.remove();
|
|
2324
|
-
this.$.$destroy();
|
|
2325
|
-
_super.prototype.$destroy.call(this);
|
|
2326
|
-
};
|
|
2327
|
-
return TextNode;
|
|
2328
|
-
}(Fragment));
|
|
2329
|
-
exports.TextNode = TextNode;
|
|
2330
|
-
/**
|
|
2331
|
-
* The private part of a base node
|
|
2332
|
-
* @class INodePrivate
|
|
2333
|
-
* @extends FragmentPrivate
|
|
2334
|
-
*/
|
|
2335
|
-
var INodePrivate = /** @class */ (function (_super) {
|
|
2336
|
-
__extends(INodePrivate, _super);
|
|
2337
|
-
function INodePrivate() {
|
|
2338
|
-
var _this = this; _super.call(this);
|
|
2339
|
-
/**
|
|
2340
|
-
* Defines if node is unmounted
|
|
2341
|
-
* @type {boolean}
|
|
2342
|
-
*/
|
|
2343
|
-
_this.unmounted = false;
|
|
2344
|
-
_this.$seal();
|
|
2345
|
-
return _this;
|
|
2346
|
-
}
|
|
2347
|
-
INodePrivate.prototype.$destroy = function () {
|
|
2348
|
-
_super.prototype.$destroy.call(this);
|
|
2349
|
-
};
|
|
2350
|
-
return INodePrivate;
|
|
2351
|
-
}(FragmentPrivate));
|
|
2352
|
-
exports.INodePrivate = INodePrivate;
|
|
2353
|
-
/**
|
|
2354
|
-
* Vasille node which can manipulate an element node
|
|
2355
|
-
* @class INode
|
|
2356
|
-
* @extends Fragment
|
|
2357
|
-
*/
|
|
2358
|
-
var INode = /** @class */ (function (_super) {
|
|
2359
|
-
__extends(INode, _super);
|
|
2360
|
-
/**
|
|
2361
|
-
* Constructs a base node
|
|
2362
|
-
* @param input
|
|
2363
|
-
* @param $ {?INodePrivate}
|
|
2364
|
-
*/
|
|
2365
|
-
function INode(input, $) {
|
|
2366
|
-
var _this = _super.call(this, input, $ || new INodePrivate) || this;
|
|
2367
|
-
_this.$seal();
|
|
2368
|
-
return _this;
|
|
2369
|
-
}
|
|
2370
|
-
Object.defineProperty(INode.prototype, "node", {
|
|
2371
|
-
/**
|
|
2372
|
-
* Get the bound node
|
|
2373
|
-
*/
|
|
2374
|
-
get: function () {
|
|
2375
|
-
return this.$.node;
|
|
2376
|
-
},
|
|
2377
|
-
enumerable: false,
|
|
2378
|
-
configurable: true
|
|
2379
|
-
});
|
|
2380
|
-
/**
|
|
2381
|
-
* Bind attribute value
|
|
2382
|
-
* @param name {String} name of attribute
|
|
2383
|
-
* @param value {IValue} value
|
|
2384
|
-
*/
|
|
2385
|
-
INode.prototype.attr = function (name, value) {
|
|
2386
|
-
var $ = this.$;
|
|
2387
|
-
var attr = new attribute_1.AttributeBinding(this, name, value);
|
|
2388
|
-
$.bindings.add(attr);
|
|
2389
|
-
};
|
|
2390
|
-
/**
|
|
2391
|
-
* Set attribute value
|
|
2392
|
-
* @param name {string} name of attribute
|
|
2393
|
-
* @param value {string} value
|
|
2394
|
-
*/
|
|
2395
|
-
INode.prototype.setAttr = function (name, value) {
|
|
2396
|
-
if (typeof value === 'boolean') {
|
|
2397
|
-
if (value) {
|
|
2398
|
-
this.$.node.setAttribute(name, "");
|
|
2399
|
-
}
|
|
2400
|
-
}
|
|
2401
|
-
else {
|
|
2402
|
-
this.$.node.setAttribute(name, "".concat(value));
|
|
2403
|
-
}
|
|
2404
|
-
return this;
|
|
2405
|
-
};
|
|
2406
|
-
/**
|
|
2407
|
-
* Adds a CSS class
|
|
2408
|
-
* @param cl {string} Class name
|
|
2409
|
-
*/
|
|
2410
|
-
INode.prototype.addClass = function (cl) {
|
|
2411
|
-
this.$.node.classList.add(cl);
|
|
2412
|
-
return this;
|
|
2413
|
-
};
|
|
2414
|
-
/**
|
|
2415
|
-
* Adds some CSS classes
|
|
2416
|
-
* @param cls {...string} classes names
|
|
2417
|
-
*/
|
|
2418
|
-
INode.prototype.removeClasse = function (cl) {
|
|
2419
|
-
this.$.node.classList.remove(cl);
|
|
2420
|
-
return this;
|
|
2421
|
-
};
|
|
2422
|
-
/**
|
|
2423
|
-
* Bind a CSS class
|
|
2424
|
-
* @param className {IValue}
|
|
2425
|
-
*/
|
|
2426
|
-
INode.prototype.bindClass = function (className) {
|
|
2427
|
-
var $ = this.$;
|
|
2428
|
-
$.bindings.add(new class_1.DynamicalClassBinding(this, className));
|
|
2429
|
-
return this;
|
|
2430
|
-
};
|
|
2431
|
-
/**
|
|
2432
|
-
* Bind a floating class name
|
|
2433
|
-
* @param cond {IValue} condition
|
|
2434
|
-
* @param className {string} class name
|
|
2435
|
-
*/
|
|
2436
|
-
INode.prototype.floatingClass = function (cond, className) {
|
|
2437
|
-
this.$.bindings.add(new class_1.StaticClassBinding(this, className, cond));
|
|
2438
|
-
return this;
|
|
2439
|
-
};
|
|
2440
|
-
/**
|
|
2441
|
-
* Defines a style attribute
|
|
2442
|
-
* @param name {String} name of style attribute
|
|
2443
|
-
* @param value {IValue} value
|
|
2444
|
-
*/
|
|
2445
|
-
INode.prototype.style = function (name, value) {
|
|
2446
|
-
var $ = this.$;
|
|
2447
|
-
if ($.node instanceof HTMLElement) {
|
|
2448
|
-
$.bindings.add(new style_1.StyleBinding(this, name, value));
|
|
2449
|
-
}
|
|
2450
|
-
else {
|
|
2451
|
-
throw (0, errors_1.userError)('style can be applied to HTML elements only', 'non-html-element');
|
|
2452
|
-
}
|
|
2453
|
-
return this;
|
|
2454
|
-
};
|
|
2455
|
-
/**
|
|
2456
|
-
* Sets a style property value
|
|
2457
|
-
* @param prop {string} Property name
|
|
2458
|
-
* @param value {string} Property value
|
|
2459
|
-
*/
|
|
2460
|
-
INode.prototype.setStyle = function (prop, value) {
|
|
2461
|
-
if (this.$.node instanceof HTMLElement) {
|
|
2462
|
-
this.$.node.style.setProperty(prop, value);
|
|
2463
|
-
}
|
|
2464
|
-
else {
|
|
2465
|
-
throw (0, errors_1.userError)("Style can be set for HTML elements only", "non-html-element");
|
|
2466
|
-
}
|
|
2467
|
-
return this;
|
|
2468
|
-
};
|
|
2469
|
-
/**
|
|
2470
|
-
* Add a listener for an event
|
|
2471
|
-
* @param name {string} Event name
|
|
2472
|
-
* @param handler {function (Event)} Event handler
|
|
2473
|
-
* @param options {Object | boolean} addEventListener options
|
|
2474
|
-
*/
|
|
2475
|
-
INode.prototype.listen = function (name, handler, options) {
|
|
2476
|
-
this.$.node.addEventListener(name, handler, options);
|
|
2477
|
-
return this;
|
|
2478
|
-
};
|
|
2479
|
-
INode.prototype.insertAdjacent = function (node) {
|
|
2480
|
-
this.$.node.parentNode.insertBefore(node, this.$.node);
|
|
2481
|
-
};
|
|
2482
|
-
/**
|
|
2483
|
-
* A v-show & ngShow alternative
|
|
2484
|
-
* @param cond {IValue} show condition
|
|
2485
|
-
*/
|
|
2486
|
-
INode.prototype.bindShow = function (cond) {
|
|
2487
|
-
var $ = this.$;
|
|
2488
|
-
var node = $.node;
|
|
2489
|
-
if (node instanceof HTMLElement) {
|
|
2490
|
-
var lastDisplay_1 = node.style.display;
|
|
2491
|
-
var htmlNode_1 = node;
|
|
2492
|
-
return this.bindAlive(cond, function () {
|
|
2493
|
-
lastDisplay_1 = htmlNode_1.style.display;
|
|
2494
|
-
htmlNode_1.style.display = 'none';
|
|
2495
|
-
}, function () {
|
|
2496
|
-
htmlNode_1.style.display = lastDisplay_1;
|
|
2497
|
-
});
|
|
2498
|
-
}
|
|
2499
|
-
else {
|
|
2500
|
-
throw (0, errors_1.userError)('the element must be a html element', 'bind-show');
|
|
2501
|
-
}
|
|
2502
|
-
};
|
|
2503
|
-
/**
|
|
2504
|
-
* bind HTML
|
|
2505
|
-
* @param value {IValue}
|
|
2506
|
-
*/
|
|
2507
|
-
INode.prototype.bindDomApi = function (name, value) {
|
|
2508
|
-
var $ = this.$;
|
|
2509
|
-
var node = $.node;
|
|
2510
|
-
if (node instanceof HTMLElement) {
|
|
2511
|
-
node[name] = value.$;
|
|
2512
|
-
this.watch(function (v) {
|
|
2513
|
-
node[name] = v;
|
|
2514
|
-
}, value);
|
|
2515
|
-
}
|
|
2516
|
-
else {
|
|
2517
|
-
throw (0, errors_1.userError)("HTML can be bound for HTML nodes only", "dom-error");
|
|
2518
|
-
}
|
|
2519
|
-
};
|
|
2520
|
-
INode.prototype.applyOptions = function (options) {
|
|
2521
|
-
var _this = this;
|
|
2522
|
-
options["v:attr"] && Object.keys(options["v:attr"]).forEach(function (name) {
|
|
2523
|
-
var value = options["v:attr"][name];
|
|
2524
|
-
if (value instanceof ivalue_1.IValue) {
|
|
2525
|
-
_this.attr(name, value);
|
|
2526
|
-
}
|
|
2527
|
-
else {
|
|
2528
|
-
_this.setAttr(name, value);
|
|
2529
|
-
}
|
|
2530
|
-
});
|
|
2531
|
-
if (options.class) {
|
|
2532
|
-
var handleClass_1 = function (name, value) {
|
|
2533
|
-
if (value instanceof ivalue_1.IValue) {
|
|
2534
|
-
_this.floatingClass(value, name);
|
|
2535
|
-
}
|
|
2536
|
-
else if (value && name !== '$') {
|
|
2537
|
-
_this.addClass(name);
|
|
2538
|
-
}
|
|
2539
|
-
else {
|
|
2540
|
-
_this.removeClasse(name);
|
|
2541
|
-
}
|
|
2542
|
-
};
|
|
2543
|
-
if (Array.isArray(options.class)) {
|
|
2544
|
-
options.class.forEach(function (item) {
|
|
2545
|
-
if (item instanceof ivalue_1.IValue) {
|
|
2546
|
-
_this.bindClass(item);
|
|
2547
|
-
}
|
|
2548
|
-
else if (typeof item == "string") {
|
|
2549
|
-
_this.addClass(item);
|
|
2550
|
-
}
|
|
2551
|
-
else {
|
|
2552
|
-
Reflect.ownKeys(item).forEach(function (name) {
|
|
2553
|
-
handleClass_1(name, item[name]);
|
|
2554
|
-
});
|
|
2555
|
-
}
|
|
2556
|
-
});
|
|
2557
|
-
}
|
|
2558
|
-
else {
|
|
2559
|
-
options.class.$.forEach(function (item) {
|
|
2560
|
-
_this.bindClass(item);
|
|
2561
|
-
});
|
|
2562
|
-
Reflect.ownKeys(options.class).forEach(function (name) {
|
|
2563
|
-
handleClass_1(name, options.class[name]);
|
|
2564
|
-
});
|
|
2565
|
-
}
|
|
2566
|
-
}
|
|
2567
|
-
options.style && Object.keys(options.style).forEach(function (name) {
|
|
2568
|
-
var value = options.style[name];
|
|
2569
|
-
if (value instanceof ivalue_1.IValue) {
|
|
2570
|
-
_this.style(name, value);
|
|
2571
|
-
}
|
|
2572
|
-
else if (typeof value === "string") {
|
|
2573
|
-
_this.setStyle(name, value);
|
|
2574
|
-
}
|
|
2575
|
-
else {
|
|
2576
|
-
if (value[0] instanceof ivalue_1.IValue) {
|
|
2577
|
-
_this.style(name, _this.expr(function (v) { return v + value[1]; }, value[0]));
|
|
2578
|
-
}
|
|
2579
|
-
else {
|
|
2580
|
-
_this.setStyle(name, value[0] + value[1]);
|
|
2581
|
-
}
|
|
2582
|
-
}
|
|
2583
|
-
});
|
|
2584
|
-
options["v:events"] && Object.keys(options["v:events"]).forEach(function (name) {
|
|
2585
|
-
_this.listen(name, options["v:events"][name]);
|
|
2586
|
-
});
|
|
2587
|
-
if (options["v:bind"]) {
|
|
2588
|
-
var inode_1 = this.node;
|
|
2589
|
-
Reflect.ownKeys(options["v:bind"]).forEach(function (k) {
|
|
2590
|
-
var value = options["v:bind"][k];
|
|
2591
|
-
if (k === 'value' && (inode_1 instanceof HTMLInputElement || inode_1 instanceof HTMLTextAreaElement)) {
|
|
2592
|
-
inode_1.oninput = function () { return value.$ = inode_1.value; };
|
|
2593
|
-
}
|
|
2594
|
-
else if (k === 'checked' && inode_1 instanceof HTMLInputElement) {
|
|
2595
|
-
inode_1.oninput = function () { return value.$ = inode_1.checked; };
|
|
2596
|
-
}
|
|
2597
|
-
else if (k === 'volume' && inode_1 instanceof HTMLMediaElement) {
|
|
2598
|
-
inode_1.onvolumechange = function () { return value.$ = inode_1.volume; };
|
|
2599
|
-
}
|
|
2600
|
-
_this.bindDomApi(k, value);
|
|
2601
|
-
});
|
|
2602
|
-
}
|
|
2603
|
-
options["v:set"] && Object.keys(options["v:set"]).forEach(function (key) {
|
|
2604
|
-
_this.node[key] = options["v:set"][key];
|
|
2605
|
-
});
|
|
2606
|
-
};
|
|
2607
|
-
return INode;
|
|
2608
|
-
}(Fragment));
|
|
2609
|
-
exports.INode = INode;
|
|
2610
|
-
/**
|
|
2611
|
-
* Represents an Vasille.js HTML element node
|
|
2612
|
-
* @class Tag
|
|
2613
|
-
* @extends INode
|
|
2614
|
-
*/
|
|
2615
|
-
var Tag = /** @class */ (function (_super) {
|
|
2616
|
-
__extends(Tag, _super);
|
|
2617
|
-
function Tag(input) {
|
|
2618
|
-
var _this = _super.call(this, input) || this;
|
|
2619
|
-
_this.$seal();
|
|
2620
|
-
return _this;
|
|
2621
|
-
}
|
|
2622
|
-
Tag.prototype.preinit = function (app, parent, tagName) {
|
|
2623
|
-
if (!tagName || typeof tagName !== "string") {
|
|
2624
|
-
throw (0, errors_1.internalError)('wrong Tag::$preinit call');
|
|
2625
|
-
}
|
|
2626
|
-
var node = document.createElement(tagName);
|
|
2627
|
-
var $ = this.$;
|
|
2628
|
-
$.preinit(app, parent);
|
|
2629
|
-
$.node = node;
|
|
2630
|
-
$.parent.appendNode(node);
|
|
2631
|
-
};
|
|
2632
|
-
Tag.prototype.compose = function (input) {
|
|
2633
|
-
input.slot && input.slot(this);
|
|
2634
|
-
};
|
|
2635
|
-
Tag.prototype.findFirstChild = function () {
|
|
2636
|
-
return this.$.unmounted ? null : this.$.node;
|
|
2637
|
-
};
|
|
2638
|
-
Tag.prototype.insertAdjacent = function (node) {
|
|
2639
|
-
if (this.$.unmounted) {
|
|
2640
|
-
if (this.$.next) {
|
|
2641
|
-
this.$.next.insertAdjacent(node);
|
|
2642
|
-
}
|
|
2643
|
-
else {
|
|
2644
|
-
this.$.parent.appendNode(node);
|
|
2645
|
-
}
|
|
2646
|
-
}
|
|
2647
|
-
else {
|
|
2648
|
-
_super.prototype.insertAdjacent.call(this, node);
|
|
2649
|
-
}
|
|
2650
|
-
};
|
|
2651
|
-
Tag.prototype.appendNode = function (node) {
|
|
2652
|
-
this.$.node.appendChild(node);
|
|
2653
|
-
};
|
|
2654
|
-
/**
|
|
2655
|
-
* Mount/Unmount a node
|
|
2656
|
-
* @param cond {IValue} show condition
|
|
2657
|
-
*/
|
|
2658
|
-
Tag.prototype.bindMount = function (cond) {
|
|
2659
|
-
var _this = this;
|
|
2660
|
-
var $ = this.$;
|
|
2661
|
-
this.bindAlive(cond, function () {
|
|
2662
|
-
$.node.remove();
|
|
2663
|
-
$.unmounted = true;
|
|
2664
|
-
}, function () {
|
|
2665
|
-
if ($.unmounted) {
|
|
2666
|
-
_this.insertAdjacent($.node);
|
|
2667
|
-
$.unmounted = false;
|
|
2668
|
-
}
|
|
2669
|
-
});
|
|
2670
|
-
};
|
|
2671
|
-
/**
|
|
2672
|
-
* Runs GC
|
|
2673
|
-
*/
|
|
2674
|
-
Tag.prototype.$destroy = function () {
|
|
2675
|
-
this.node.remove();
|
|
2676
|
-
_super.prototype.$destroy.call(this);
|
|
2677
|
-
};
|
|
2678
|
-
return Tag;
|
|
2679
|
-
}(INode));
|
|
2680
|
-
exports.Tag = Tag;
|
|
2681
|
-
/**
|
|
2682
|
-
* Represents a vasille extension node
|
|
2683
|
-
* @class Extension
|
|
2684
|
-
* @extends INode
|
|
2685
|
-
*/
|
|
2686
|
-
var Extension = /** @class */ (function (_super) {
|
|
2687
|
-
__extends(Extension, _super);
|
|
2688
|
-
function Extension() {
|
|
2689
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
2690
|
-
}
|
|
2691
|
-
Extension.prototype.preinit = function (app, parent) {
|
|
2692
|
-
var $ = this.$;
|
|
2693
|
-
var it = parent;
|
|
2694
|
-
while (it && !(it instanceof INode)) {
|
|
2695
|
-
it = it.parent;
|
|
2696
|
-
}
|
|
2697
|
-
if (it && it instanceof INode) {
|
|
2698
|
-
$.node = it.node;
|
|
2699
|
-
}
|
|
2700
|
-
$.preinit(app, parent);
|
|
2701
|
-
if (!it) {
|
|
2702
|
-
throw (0, errors_1.userError)("A extension node can be encapsulated only in a tag/extension/component", "virtual-dom");
|
|
2703
|
-
}
|
|
2704
|
-
};
|
|
2705
|
-
Extension.prototype.extend = function (options) {
|
|
2706
|
-
this.applyOptions(options);
|
|
2707
|
-
};
|
|
2708
|
-
Extension.prototype.$destroy = function () {
|
|
2709
|
-
_super.prototype.$destroy.call(this);
|
|
2710
|
-
};
|
|
2711
|
-
return Extension;
|
|
2712
|
-
}(INode));
|
|
2713
|
-
exports.Extension = Extension;
|
|
2714
|
-
/**
|
|
2715
|
-
* Node which cas has just a child
|
|
2716
|
-
* @class Component
|
|
2717
|
-
* @extends Extension
|
|
2718
|
-
*/
|
|
2719
|
-
var Component = /** @class */ (function (_super) {
|
|
2720
|
-
__extends(Component, _super);
|
|
2721
|
-
function Component() {
|
|
2722
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
2723
|
-
}
|
|
2724
|
-
Component.prototype.init = function () {
|
|
2725
|
-
_super.prototype.composeNow.call(this);
|
|
2726
|
-
this.ready();
|
|
2727
|
-
_super.prototype.applyOptionsNow.call(this);
|
|
2728
|
-
};
|
|
2729
|
-
Component.prototype.ready = function () {
|
|
2730
|
-
_super.prototype.ready.call(this);
|
|
2731
|
-
if (this.children.size !== 1) {
|
|
2732
|
-
throw (0, errors_1.userError)("Component must have a child only", "dom-error");
|
|
2733
|
-
}
|
|
2734
|
-
var child = this.lastChild;
|
|
2735
|
-
if (child instanceof Tag || child instanceof Component) {
|
|
2736
|
-
var $ = this.$;
|
|
2737
|
-
$.node = child.node;
|
|
2738
|
-
}
|
|
2739
|
-
else {
|
|
2740
|
-
throw (0, errors_1.userError)("Component child must be Tag or Component", "dom-error");
|
|
2741
|
-
}
|
|
2742
|
-
};
|
|
2743
|
-
Component.prototype.preinit = function (app, parent) {
|
|
2744
|
-
this.$.preinit(app, parent);
|
|
2745
|
-
};
|
|
2746
|
-
return Component;
|
|
2747
|
-
}(Extension));
|
|
2748
|
-
exports.Component = Component;
|
|
2749
|
-
/**
|
|
2750
|
-
* Private part of switch node
|
|
2751
|
-
* @class SwitchedNodePrivate
|
|
2752
|
-
* @extends INodePrivate
|
|
2753
|
-
*/
|
|
2754
|
-
var SwitchedNodePrivate = /** @class */ (function (_super) {
|
|
2755
|
-
__extends(SwitchedNodePrivate, _super);
|
|
2756
|
-
function SwitchedNodePrivate() {
|
|
2757
|
-
var _this = this; _super.call(this);
|
|
2758
|
-
/**
|
|
2759
|
-
* Array of possible cases
|
|
2760
|
-
* @type {Array<{cond : IValue<boolean>, cb : function(Fragment)}>}
|
|
2761
|
-
*/
|
|
2762
|
-
_this.cases = [];
|
|
2763
|
-
_this.$seal();
|
|
2764
|
-
return _this;
|
|
2765
|
-
}
|
|
2766
|
-
/**
|
|
2767
|
-
* Runs GC
|
|
2768
|
-
*/
|
|
2769
|
-
SwitchedNodePrivate.prototype.$destroy = function () {
|
|
2770
|
-
this.cases.forEach(function (c) {
|
|
2771
|
-
delete c.cond;
|
|
2772
|
-
delete c.cb;
|
|
2773
|
-
});
|
|
2774
|
-
this.cases.splice(0);
|
|
2775
|
-
_super.prototype.$destroy.call(this);
|
|
2776
|
-
};
|
|
2777
|
-
return SwitchedNodePrivate;
|
|
2778
|
-
}(FragmentPrivate));
|
|
2779
|
-
exports.SwitchedNodePrivate = SwitchedNodePrivate;
|
|
2780
|
-
/**
|
|
2781
|
-
* Defines a node witch can switch its children conditionally
|
|
2782
|
-
*/
|
|
2783
|
-
var SwitchedNode = /** @class */ (function (_super) {
|
|
2784
|
-
__extends(SwitchedNode, _super);
|
|
2785
|
-
/**
|
|
2786
|
-
* Constructs a switch node and define a sync function
|
|
2787
|
-
*/
|
|
2788
|
-
function SwitchedNode() {
|
|
2789
|
-
var _this = _super.call(this, {}, new SwitchedNodePrivate) || this;
|
|
2790
|
-
_this.$.sync = function () {
|
|
2791
|
-
var $ = _this.$;
|
|
2792
|
-
var i = 0;
|
|
2793
|
-
for (; i < $.cases.length; i++) {
|
|
2794
|
-
if ($.cases[i].cond.$) {
|
|
2795
|
-
break;
|
|
2796
|
-
}
|
|
2797
|
-
}
|
|
2798
|
-
if (i === $.index) {
|
|
2799
|
-
return;
|
|
2800
|
-
}
|
|
2801
|
-
if (_this.lastChild) {
|
|
2802
|
-
_this.lastChild.$destroy();
|
|
2803
|
-
_this.children.clear();
|
|
2804
|
-
_this.lastChild = null;
|
|
2805
|
-
}
|
|
2806
|
-
if (i !== $.cases.length) {
|
|
2807
|
-
$.index = i;
|
|
2808
|
-
_this.createChild($.cases[i].cb);
|
|
2809
|
-
}
|
|
2810
|
-
else {
|
|
2811
|
-
$.index = -1;
|
|
2812
|
-
}
|
|
2813
|
-
};
|
|
2814
|
-
_this.$seal();
|
|
2815
|
-
return _this;
|
|
2816
|
-
}
|
|
2817
|
-
SwitchedNode.prototype.addCase = function (case_) {
|
|
2818
|
-
this.$.cases.push(case_);
|
|
2819
|
-
case_.cond.$on(this.$.sync);
|
|
2820
|
-
this.$.sync();
|
|
2821
|
-
};
|
|
2822
|
-
/**
|
|
2823
|
-
* Creates a child node
|
|
2824
|
-
* @param cb {function(Fragment)} Call-back
|
|
2825
|
-
*/
|
|
2826
|
-
SwitchedNode.prototype.createChild = function (cb) {
|
|
2827
|
-
var node = new Fragment({});
|
|
2828
|
-
node.preinit(this.$.app, this);
|
|
2829
|
-
node.init();
|
|
2830
|
-
this.lastChild = node;
|
|
2831
|
-
this.children.add(node);
|
|
2832
|
-
cb(node);
|
|
2833
|
-
};
|
|
2834
|
-
SwitchedNode.prototype.ready = function () {
|
|
2835
|
-
var $ = this.$;
|
|
2836
|
-
$.cases.forEach(function (c) {
|
|
2837
|
-
c.cond.$on($.sync);
|
|
2838
|
-
});
|
|
2839
|
-
$.sync();
|
|
2840
|
-
};
|
|
2841
|
-
SwitchedNode.prototype.$destroy = function () {
|
|
2842
|
-
var $ = this.$;
|
|
2843
|
-
$.cases.forEach(function (c) {
|
|
2844
|
-
c.cond.$off($.sync);
|
|
2845
|
-
});
|
|
2846
|
-
_super.prototype.$destroy.call(this);
|
|
2847
|
-
};
|
|
2848
|
-
return SwitchedNode;
|
|
2849
|
-
}(Fragment));
|
|
2850
|
-
exports.SwitchedNode = SwitchedNode;
|
|
2851
|
-
/**
|
|
2852
|
-
* The private part of a text node
|
|
2853
|
-
*/
|
|
2854
|
-
var DebugPrivate = /** @class */ (function (_super) {
|
|
2855
|
-
__extends(DebugPrivate, _super);
|
|
2856
|
-
function DebugPrivate() {
|
|
2857
|
-
var _this = this; _super.call(this);
|
|
2858
|
-
_this.$seal();
|
|
2859
|
-
return _this;
|
|
2860
|
-
}
|
|
2861
|
-
/**
|
|
2862
|
-
* Pre-initializes a text node
|
|
2863
|
-
* @param app {App} the app node
|
|
2864
|
-
* @param parent {Fragment} parent node
|
|
2865
|
-
* @param text {String | IValue}
|
|
2866
|
-
*/
|
|
2867
|
-
DebugPrivate.prototype.preinitComment = function (app, parent, text) {
|
|
2868
|
-
var _this = this;
|
|
2869
|
-
_super.prototype.preinit.call(this, app, parent);
|
|
2870
|
-
this.node = document.createComment(text.$);
|
|
2871
|
-
this.bindings.add(new expression_1.Expression(function (v) {
|
|
2872
|
-
_this.node.replaceData(0, -1, v);
|
|
2873
|
-
}, true, text));
|
|
2874
|
-
this.parent.appendNode(this.node);
|
|
2875
|
-
};
|
|
2876
|
-
/**
|
|
2877
|
-
* Clear node data
|
|
2878
|
-
*/
|
|
2879
|
-
DebugPrivate.prototype.$destroy = function () {
|
|
2880
|
-
this.node.remove();
|
|
2881
|
-
_super.prototype.$destroy.call(this);
|
|
2882
|
-
};
|
|
2883
|
-
return DebugPrivate;
|
|
2884
|
-
}(FragmentPrivate));
|
|
2885
|
-
exports.DebugPrivate = DebugPrivate;
|
|
2886
|
-
/**
|
|
2887
|
-
* Represents a debug node
|
|
2888
|
-
* @class DebugNode
|
|
2889
|
-
* @extends Fragment
|
|
2890
|
-
*/
|
|
2891
|
-
var DebugNode = /** @class */ (function (_super) {
|
|
2892
|
-
__extends(DebugNode, _super);
|
|
2893
|
-
function DebugNode() {
|
|
2894
|
-
var _this = _super.call(this, {}) || this;
|
|
2895
|
-
/**
|
|
2896
|
-
* private data
|
|
2897
|
-
* @type {DebugNode}
|
|
2898
|
-
*/
|
|
2899
|
-
_this.$ = new DebugPrivate();
|
|
2900
|
-
_this.$seal();
|
|
2901
|
-
return _this;
|
|
2902
|
-
}
|
|
2903
|
-
DebugNode.prototype.preinit = function (app, parent, text) {
|
|
2904
|
-
var $ = this.$;
|
|
2905
|
-
if (!text) {
|
|
2906
|
-
throw (0, errors_1.internalError)('wrong DebugNode::$preninit call');
|
|
2907
|
-
}
|
|
2908
|
-
$.preinitComment(app, parent, text);
|
|
2909
|
-
};
|
|
2910
|
-
/**
|
|
2911
|
-
* Runs garbage collector
|
|
2912
|
-
*/
|
|
2913
|
-
DebugNode.prototype.$destroy = function () {
|
|
2914
|
-
this.$.$destroy();
|
|
2915
|
-
_super.prototype.$destroy.call(this);
|
|
2916
|
-
};
|
|
2917
|
-
return DebugNode;
|
|
2918
|
-
}(Fragment));
|
|
2919
|
-
exports.DebugNode = DebugNode;
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
// ./lib-es5/node/watch.js
|
|
2923
|
-
"use strict";
|
|
2924
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2925
|
-
var extendStatics = function (d, b) {
|
|
2926
|
-
extendStatics = Object.setPrototypeOf ||
|
|
2927
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
2928
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
2929
|
-
return extendStatics(d, b);
|
|
2930
|
-
};
|
|
2931
|
-
return function (d, b) {
|
|
2932
|
-
if (typeof b !== "function" && b !== null)
|
|
2933
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
2934
|
-
extendStatics(d, b);
|
|
2935
|
-
function __() { this.constructor = d; }
|
|
2936
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2937
|
-
};
|
|
2938
|
-
})();
|
|
2939
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2940
|
-
exports.Watch = void 0;
|
|
2941
|
-
var node_1 = require("./node");
|
|
2942
|
-
/**
|
|
2943
|
-
* Watch Node
|
|
2944
|
-
* @class Watch
|
|
2945
|
-
* @extends Fragment
|
|
2946
|
-
*/
|
|
2947
|
-
var Watch = /** @class */ (function (_super) {
|
|
2948
|
-
__extends(Watch, _super);
|
|
2949
|
-
function Watch() {
|
|
2950
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
2951
|
-
}
|
|
2952
|
-
Watch.prototype.compose = function (input) {
|
|
2953
|
-
var _this = this;
|
|
2954
|
-
this.watch(function (value) {
|
|
2955
|
-
_this.children.forEach(function (child) {
|
|
2956
|
-
child.$destroy();
|
|
2957
|
-
});
|
|
2958
|
-
_this.children.clear();
|
|
2959
|
-
_this.lastChild = null;
|
|
2960
|
-
input.slot && input.slot(_this, value);
|
|
2961
|
-
}, input.model);
|
|
2962
|
-
input.slot(this, input.model.$);
|
|
2963
|
-
};
|
|
2964
|
-
return Watch;
|
|
2965
|
-
}(node_1.Fragment));
|
|
2966
|
-
exports.Watch = Watch;
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
// ./lib-es5/views/repeat-node.js
|
|
2970
|
-
"use strict";
|
|
2971
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2972
|
-
var extendStatics = function (d, b) {
|
|
2973
|
-
extendStatics = Object.setPrototypeOf ||
|
|
2974
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
2975
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
2976
|
-
return extendStatics(d, b);
|
|
2977
|
-
};
|
|
2978
|
-
return function (d, b) {
|
|
2979
|
-
if (typeof b !== "function" && b !== null)
|
|
2980
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
2981
|
-
extendStatics(d, b);
|
|
2982
|
-
function __() { this.constructor = d; }
|
|
2983
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2984
|
-
};
|
|
2985
|
-
})();
|
|
2986
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2987
|
-
exports.RepeatNode = exports.RepeatNodePrivate = void 0;
|
|
2988
|
-
var node_1 = require("../node/node");
|
|
2989
|
-
/**
|
|
2990
|
-
* Private part of repeat node
|
|
2991
|
-
* @class RepeatNodePrivate
|
|
2992
|
-
* @extends INodePrivate
|
|
2993
|
-
*/
|
|
2994
|
-
var RepeatNodePrivate = /** @class */ (function (_super) {
|
|
2995
|
-
__extends(RepeatNodePrivate, _super);
|
|
2996
|
-
function RepeatNodePrivate() {
|
|
2997
|
-
var _this = this; _super.call(this);
|
|
2998
|
-
/**
|
|
2999
|
-
* Children node hash
|
|
3000
|
-
* @type {Map}
|
|
3001
|
-
*/
|
|
3002
|
-
_this.nodes = new Map();
|
|
3003
|
-
_this.$seal();
|
|
3004
|
-
return _this;
|
|
3005
|
-
}
|
|
3006
|
-
RepeatNodePrivate.prototype.$destroy = function () {
|
|
3007
|
-
this.nodes.clear();
|
|
3008
|
-
_super.prototype.$destroy.call(this);
|
|
3009
|
-
};
|
|
3010
|
-
return RepeatNodePrivate;
|
|
3011
|
-
}(node_1.INodePrivate));
|
|
3012
|
-
exports.RepeatNodePrivate = RepeatNodePrivate;
|
|
3013
|
-
/**
|
|
3014
|
-
* Repeat node repeats its children
|
|
3015
|
-
* @class RepeatNode
|
|
3016
|
-
* @extends Fragment
|
|
3017
|
-
*/
|
|
3018
|
-
var RepeatNode = /** @class */ (function (_super) {
|
|
3019
|
-
__extends(RepeatNode, _super);
|
|
3020
|
-
function RepeatNode(input, $) {
|
|
3021
|
-
var _this = _super.call(this, input, $) || this;
|
|
3022
|
-
/**
|
|
3023
|
-
* If false will use timeout executor, otherwise the app executor
|
|
3024
|
-
*/
|
|
3025
|
-
_this.freezeUi = true;
|
|
3026
|
-
return _this;
|
|
3027
|
-
}
|
|
3028
|
-
RepeatNode.prototype.createChild = function (opts, id, item, before) {
|
|
3029
|
-
var node = new node_1.Fragment({});
|
|
3030
|
-
this.destroyChild(id, item);
|
|
3031
|
-
if (before) {
|
|
3032
|
-
this.children.add(node);
|
|
3033
|
-
before.insertBefore(node);
|
|
3034
|
-
}
|
|
3035
|
-
else {
|
|
3036
|
-
var lastChild = this.lastChild;
|
|
3037
|
-
if (lastChild) {
|
|
3038
|
-
lastChild.insertAfter(node);
|
|
3039
|
-
}
|
|
3040
|
-
this.children.add(node);
|
|
3041
|
-
}
|
|
3042
|
-
this.lastChild = node;
|
|
3043
|
-
node.preinit(this.$.app, this);
|
|
3044
|
-
node.init();
|
|
3045
|
-
opts.slot && opts.slot(node, item, id);
|
|
3046
|
-
node.ready();
|
|
3047
|
-
this.$.nodes.set(id, node);
|
|
3048
|
-
};
|
|
3049
|
-
RepeatNode.prototype.destroyChild = function (id, item) {
|
|
3050
|
-
var $ = this.$;
|
|
3051
|
-
var child = $.nodes.get(id);
|
|
3052
|
-
if (child) {
|
|
3053
|
-
child.remove();
|
|
3054
|
-
child.$destroy();
|
|
3055
|
-
this.$.nodes.delete(id);
|
|
3056
|
-
this.children.delete(child);
|
|
3057
|
-
}
|
|
3058
|
-
};
|
|
3059
|
-
return RepeatNode;
|
|
3060
|
-
}(node_1.Fragment));
|
|
3061
|
-
exports.RepeatNode = RepeatNode;
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
// ./lib-es5/views/base-view.js
|
|
3065
|
-
"use strict";
|
|
3066
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3067
|
-
var extendStatics = function (d, b) {
|
|
3068
|
-
extendStatics = Object.setPrototypeOf ||
|
|
3069
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
3070
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
3071
|
-
return extendStatics(d, b);
|
|
3072
|
-
};
|
|
3073
|
-
return function (d, b) {
|
|
3074
|
-
if (typeof b !== "function" && b !== null)
|
|
3075
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
3076
|
-
extendStatics(d, b);
|
|
3077
|
-
function __() { this.constructor = d; }
|
|
3078
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
3079
|
-
};
|
|
3080
|
-
})();
|
|
3081
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3082
|
-
exports.BaseView = exports.BaseViewPrivate = void 0;
|
|
3083
|
-
var repeat_node_1 = require("./repeat-node");
|
|
3084
|
-
/**
|
|
3085
|
-
* Private part of BaseView
|
|
3086
|
-
* @class BaseViewPrivate
|
|
3087
|
-
* @extends RepeatNodePrivate
|
|
3088
|
-
*/
|
|
3089
|
-
var BaseViewPrivate = /** @class */ (function (_super) {
|
|
3090
|
-
__extends(BaseViewPrivate, _super);
|
|
3091
|
-
function BaseViewPrivate() {
|
|
3092
|
-
var _this = this; _super.call(this);
|
|
3093
|
-
_this.$seal();
|
|
3094
|
-
return _this;
|
|
3095
|
-
}
|
|
3096
|
-
return BaseViewPrivate;
|
|
3097
|
-
}(repeat_node_1.RepeatNodePrivate));
|
|
3098
|
-
exports.BaseViewPrivate = BaseViewPrivate;
|
|
3099
|
-
/**
|
|
3100
|
-
* Base class of default views
|
|
3101
|
-
* @class BaseView
|
|
3102
|
-
* @extends RepeatNode
|
|
3103
|
-
* @implements IModel
|
|
3104
|
-
*/
|
|
3105
|
-
var BaseView = /** @class */ (function (_super) {
|
|
3106
|
-
__extends(BaseView, _super);
|
|
3107
|
-
function BaseView(input, $) {
|
|
3108
|
-
return _super.call(this, input, $ || new BaseViewPrivate) || this;
|
|
3109
|
-
}
|
|
3110
|
-
BaseView.prototype.compose = function (input) {
|
|
3111
|
-
var _this = this;
|
|
3112
|
-
var $ = this.$;
|
|
3113
|
-
$.addHandler = function (id, item) {
|
|
3114
|
-
_this.createChild(input, id, item);
|
|
3115
|
-
};
|
|
3116
|
-
$.removeHandler = function (id, item) {
|
|
3117
|
-
_this.destroyChild(id, item);
|
|
3118
|
-
};
|
|
3119
|
-
input.model.listener.onAdd($.addHandler);
|
|
3120
|
-
input.model.listener.onRemove($.removeHandler);
|
|
3121
|
-
this.runOnDestroy(function () {
|
|
3122
|
-
input.model.listener.offAdd($.addHandler);
|
|
3123
|
-
input.model.listener.offRemove($.removeHandler);
|
|
3124
|
-
});
|
|
3125
|
-
};
|
|
3126
|
-
return BaseView;
|
|
3127
|
-
}(repeat_node_1.RepeatNode));
|
|
3128
|
-
exports.BaseView = BaseView;
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
// ./lib-es5/views/array-view.js
|
|
3132
|
-
"use strict";
|
|
3133
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3134
|
-
var extendStatics = function (d, b) {
|
|
3135
|
-
extendStatics = Object.setPrototypeOf ||
|
|
3136
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
3137
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
3138
|
-
return extendStatics(d, b);
|
|
3139
|
-
};
|
|
3140
|
-
return function (d, b) {
|
|
3141
|
-
if (typeof b !== "function" && b !== null)
|
|
3142
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
3143
|
-
extendStatics(d, b);
|
|
3144
|
-
function __() { this.constructor = d; }
|
|
3145
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
3146
|
-
};
|
|
3147
|
-
})();
|
|
3148
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3149
|
-
exports.ArrayView = void 0;
|
|
3150
|
-
var base_view_1 = require("./base-view");
|
|
3151
|
-
/**
|
|
3152
|
-
* Represents a view of an array model
|
|
3153
|
-
* @class ArrayView
|
|
3154
|
-
* @extends BaseView
|
|
3155
|
-
*/
|
|
3156
|
-
var ArrayView = /** @class */ (function (_super) {
|
|
3157
|
-
__extends(ArrayView, _super);
|
|
3158
|
-
function ArrayView() {
|
|
3159
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3160
|
-
}
|
|
3161
|
-
ArrayView.prototype.createChild = function (input, id, item, before) {
|
|
3162
|
-
_super.prototype.createChild.call(this, input, item, item, before || this.$.nodes.get(id));
|
|
3163
|
-
};
|
|
3164
|
-
ArrayView.prototype.compose = function (input) {
|
|
3165
|
-
var _this = this;
|
|
3166
|
-
_super.prototype.compose.call(this, input);
|
|
3167
|
-
input.model.forEach(function (item) {
|
|
3168
|
-
_this.createChild(input, item, item);
|
|
3169
|
-
});
|
|
3170
|
-
};
|
|
3171
|
-
return ArrayView;
|
|
3172
|
-
}(base_view_1.BaseView));
|
|
3173
|
-
exports.ArrayView = ArrayView;
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
// ./lib-es5/views/map-view.js
|
|
3177
|
-
"use strict";
|
|
3178
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3179
|
-
var extendStatics = function (d, b) {
|
|
3180
|
-
extendStatics = Object.setPrototypeOf ||
|
|
3181
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
3182
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
3183
|
-
return extendStatics(d, b);
|
|
3184
|
-
};
|
|
3185
|
-
return function (d, b) {
|
|
3186
|
-
if (typeof b !== "function" && b !== null)
|
|
3187
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
3188
|
-
extendStatics(d, b);
|
|
3189
|
-
function __() { this.constructor = d; }
|
|
3190
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
3191
|
-
};
|
|
3192
|
-
})();
|
|
3193
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3194
|
-
exports.MapView = void 0;
|
|
3195
|
-
var base_view_1 = require("./base-view");
|
|
3196
|
-
/**
|
|
3197
|
-
* Create a children pack for each map value
|
|
3198
|
-
* @class MapView
|
|
3199
|
-
* @extends BaseView
|
|
3200
|
-
*/
|
|
3201
|
-
var MapView = /** @class */ (function (_super) {
|
|
3202
|
-
__extends(MapView, _super);
|
|
3203
|
-
function MapView() {
|
|
3204
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3205
|
-
}
|
|
3206
|
-
MapView.prototype.compose = function (input) {
|
|
3207
|
-
var _this = this;
|
|
3208
|
-
_super.prototype.compose.call(this, input);
|
|
3209
|
-
input.model.forEach(function (value, key) {
|
|
3210
|
-
_this.createChild(input, key, value);
|
|
3211
|
-
});
|
|
3212
|
-
};
|
|
3213
|
-
return MapView;
|
|
3214
|
-
}(base_view_1.BaseView));
|
|
3215
|
-
exports.MapView = MapView;
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
// ./lib-es5/views/object-view.js
|
|
3219
|
-
"use strict";
|
|
3220
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3221
|
-
var extendStatics = function (d, b) {
|
|
3222
|
-
extendStatics = Object.setPrototypeOf ||
|
|
3223
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
3224
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
3225
|
-
return extendStatics(d, b);
|
|
3226
|
-
};
|
|
3227
|
-
return function (d, b) {
|
|
3228
|
-
if (typeof b !== "function" && b !== null)
|
|
3229
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
3230
|
-
extendStatics(d, b);
|
|
3231
|
-
function __() { this.constructor = d; }
|
|
3232
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
3233
|
-
};
|
|
3234
|
-
})();
|
|
3235
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3236
|
-
exports.ObjectView = void 0;
|
|
3237
|
-
var base_view_1 = require("./base-view");
|
|
3238
|
-
/**
|
|
3239
|
-
* Create a children pack for each object field
|
|
3240
|
-
* @class ObjectView
|
|
3241
|
-
* @extends BaseView
|
|
3242
|
-
*/
|
|
3243
|
-
var ObjectView = /** @class */ (function (_super) {
|
|
3244
|
-
__extends(ObjectView, _super);
|
|
3245
|
-
function ObjectView() {
|
|
3246
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3247
|
-
}
|
|
3248
|
-
ObjectView.prototype.compose = function (input) {
|
|
3249
|
-
_super.prototype.compose.call(this, input);
|
|
3250
|
-
var obj = input.model.values;
|
|
3251
|
-
for (var key in obj) {
|
|
3252
|
-
this.createChild(input, key, obj[key]);
|
|
3253
|
-
}
|
|
3254
|
-
_super.prototype.ready.call(this);
|
|
3255
|
-
};
|
|
3256
|
-
return ObjectView;
|
|
3257
|
-
}(base_view_1.BaseView));
|
|
3258
|
-
exports.ObjectView = ObjectView;
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
// ./lib-es5/views/set-view.js
|
|
3262
|
-
"use strict";
|
|
3263
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3264
|
-
var extendStatics = function (d, b) {
|
|
3265
|
-
extendStatics = Object.setPrototypeOf ||
|
|
3266
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
3267
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
3268
|
-
return extendStatics(d, b);
|
|
3269
|
-
};
|
|
3270
|
-
return function (d, b) {
|
|
3271
|
-
if (typeof b !== "function" && b !== null)
|
|
3272
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
3273
|
-
extendStatics(d, b);
|
|
3274
|
-
function __() { this.constructor = d; }
|
|
3275
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
3276
|
-
};
|
|
3277
|
-
})();
|
|
3278
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3279
|
-
exports.SetView = void 0;
|
|
3280
|
-
var base_view_1 = require("./base-view");
|
|
3281
|
-
/**
|
|
3282
|
-
* Create a children pack for each set value
|
|
3283
|
-
* @class SetView
|
|
3284
|
-
* @extends BaseView
|
|
3285
|
-
*/
|
|
3286
|
-
var SetView = /** @class */ (function (_super) {
|
|
3287
|
-
__extends(SetView, _super);
|
|
3288
|
-
function SetView() {
|
|
3289
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3290
|
-
}
|
|
3291
|
-
SetView.prototype.compose = function (input) {
|
|
3292
|
-
var _this = this;
|
|
3293
|
-
_super.prototype.compose.call(this, input);
|
|
3294
|
-
var set = input.model;
|
|
3295
|
-
set.forEach(function (item) {
|
|
3296
|
-
_this.createChild(input, item, item);
|
|
3297
|
-
});
|
|
3298
|
-
};
|
|
3299
|
-
return SetView;
|
|
3300
|
-
}(base_view_1.BaseView));
|
|
3301
|
-
exports.SetView = SetView;
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
// ./lib-es5/index.js
|
|
3305
|
-
"use strict";
|
|
3306
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3307
|
-
exports.current = exports.userError = exports.unstack = exports.stack = exports.Watch = exports.Reactive = exports.Binding = exports.Expression = exports.Portal = exports.App = exports.AppNode = exports.Extension = exports.Component = exports.Tag = exports.INode = exports.Fragment = exports.SetView = exports.ObjectView = exports.MapView = exports.ArrayView = exports.Listener = exports.BaseView = exports.SetModel = exports.ObjectModel = exports.MapModel = exports.ArrayModel = exports.Pointer = exports.Mirror = exports.Reference = exports.IValue = exports.Destroyable = void 0;
|
|
3308
|
-
var destroyable_1 = require("./core/destroyable");
|
|
3309
|
-
Object.defineProperty(exports, "Destroyable", { enumerable: true, get: function () { return destroyable_1.Destroyable; } });
|
|
3310
|
-
var core_1 = require("./core/core");
|
|
3311
|
-
Object.defineProperty(exports, "current", { enumerable: true, get: function () { return core_1.current; } });
|
|
3312
|
-
Object.defineProperty(exports, "Reactive", { enumerable: true, get: function () { return core_1.Reactive; } });
|
|
3313
|
-
Object.defineProperty(exports, "stack", { enumerable: true, get: function () { return core_1.stack; } });
|
|
3314
|
-
Object.defineProperty(exports, "unstack", { enumerable: true, get: function () { return core_1.unstack; } });
|
|
3315
|
-
var ivalue_1 = require("./core/ivalue");
|
|
3316
|
-
Object.defineProperty(exports, "IValue", { enumerable: true, get: function () { return ivalue_1.IValue; } });
|
|
3317
|
-
var array_model_1 = require("./models/array-model");
|
|
3318
|
-
Object.defineProperty(exports, "ArrayModel", { enumerable: true, get: function () { return array_model_1.ArrayModel; } });
|
|
3319
|
-
var listener_1 = require("./models/listener");
|
|
3320
|
-
Object.defineProperty(exports, "Listener", { enumerable: true, get: function () { return listener_1.Listener; } });
|
|
3321
|
-
var map_model_1 = require("./models/map-model");
|
|
3322
|
-
Object.defineProperty(exports, "MapModel", { enumerable: true, get: function () { return map_model_1.MapModel; } });
|
|
3323
|
-
var object_model_1 = require("./models/object-model");
|
|
3324
|
-
Object.defineProperty(exports, "ObjectModel", { enumerable: true, get: function () { return object_model_1.ObjectModel; } });
|
|
3325
|
-
var set_model_1 = require("./models/set-model");
|
|
3326
|
-
Object.defineProperty(exports, "SetModel", { enumerable: true, get: function () { return set_model_1.SetModel; } });
|
|
3327
|
-
var app_1 = require("./node/app");
|
|
3328
|
-
Object.defineProperty(exports, "App", { enumerable: true, get: function () { return app_1.App; } });
|
|
3329
|
-
Object.defineProperty(exports, "AppNode", { enumerable: true, get: function () { return app_1.AppNode; } });
|
|
3330
|
-
Object.defineProperty(exports, "Portal", { enumerable: true, get: function () { return app_1.Portal; } });
|
|
3331
|
-
var node_1 = require("./node/node");
|
|
3332
|
-
Object.defineProperty(exports, "Component", { enumerable: true, get: function () { return node_1.Component; } });
|
|
3333
|
-
Object.defineProperty(exports, "Extension", { enumerable: true, get: function () { return node_1.Extension; } });
|
|
3334
|
-
Object.defineProperty(exports, "Fragment", { enumerable: true, get: function () { return node_1.Fragment; } });
|
|
3335
|
-
Object.defineProperty(exports, "INode", { enumerable: true, get: function () { return node_1.INode; } });
|
|
3336
|
-
Object.defineProperty(exports, "Tag", { enumerable: true, get: function () { return node_1.Tag; } });
|
|
3337
|
-
var expression_1 = require("./value/expression");
|
|
3338
|
-
Object.defineProperty(exports, "Expression", { enumerable: true, get: function () { return expression_1.Expression; } });
|
|
3339
|
-
var mirror_1 = require("./value/mirror");
|
|
3340
|
-
Object.defineProperty(exports, "Mirror", { enumerable: true, get: function () { return mirror_1.Mirror; } });
|
|
3341
|
-
var pointer_1 = require("./value/pointer");
|
|
3342
|
-
Object.defineProperty(exports, "Pointer", { enumerable: true, get: function () { return pointer_1.Pointer; } });
|
|
3343
|
-
var reference_1 = require("./value/reference");
|
|
3344
|
-
Object.defineProperty(exports, "Reference", { enumerable: true, get: function () { return reference_1.Reference; } });
|
|
3345
|
-
var array_view_1 = require("./views/array-view");
|
|
3346
|
-
Object.defineProperty(exports, "ArrayView", { enumerable: true, get: function () { return array_view_1.ArrayView; } });
|
|
3347
|
-
var base_view_1 = require("./views/base-view");
|
|
3348
|
-
Object.defineProperty(exports, "BaseView", { enumerable: true, get: function () { return base_view_1.BaseView; } });
|
|
3349
|
-
var map_view_1 = require("./views/map-view");
|
|
3350
|
-
Object.defineProperty(exports, "MapView", { enumerable: true, get: function () { return map_view_1.MapView; } });
|
|
3351
|
-
var object_view_1 = require("./views/object-view");
|
|
3352
|
-
Object.defineProperty(exports, "ObjectView", { enumerable: true, get: function () { return object_view_1.ObjectView; } });
|
|
3353
|
-
var set_view_1 = require("./views/set-view");
|
|
3354
|
-
Object.defineProperty(exports, "SetView", { enumerable: true, get: function () { return set_view_1.SetView; } });
|
|
3355
|
-
var binding_1 = require("./binding/binding");
|
|
3356
|
-
Object.defineProperty(exports, "Binding", { enumerable: true, get: function () { return binding_1.Binding; } });
|
|
3357
|
-
var errors_1 = require("./core/errors");
|
|
3358
|
-
Object.defineProperty(exports, "userError", { enumerable: true, get: function () { return errors_1.userError; } });
|
|
3359
|
-
var watch_1 = require("./node/watch");
|
|
3360
|
-
Object.defineProperty(exports, "Watch", { enumerable: true, get: function () { return watch_1.Watch; } });
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
// ./lib-es5/node/app.js
|
|
3364
|
-
"use strict";
|
|
3365
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3366
|
-
var extendStatics = function (d, b) {
|
|
3367
|
-
extendStatics = Object.setPrototypeOf ||
|
|
3368
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
3369
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
3370
|
-
return extendStatics(d, b);
|
|
3371
|
-
};
|
|
3372
|
-
return function (d, b) {
|
|
3373
|
-
if (typeof b !== "function" && b !== null)
|
|
3374
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
3375
|
-
extendStatics(d, b);
|
|
3376
|
-
function __() { this.constructor = d; }
|
|
3377
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
3378
|
-
};
|
|
3379
|
-
})();
|
|
3380
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3381
|
-
exports.Portal = exports.App = exports.AppNode = void 0;
|
|
3382
|
-
var node_1 = require("./node");
|
|
3383
|
-
/**
|
|
3384
|
-
* Application Node
|
|
3385
|
-
* @class AppNode
|
|
3386
|
-
* @extends INode
|
|
3387
|
-
*/
|
|
3388
|
-
var AppNode = /** @class */ (function (_super) {
|
|
3389
|
-
__extends(AppNode, _super);
|
|
3390
|
-
/**
|
|
3391
|
-
* @param input
|
|
3392
|
-
*/
|
|
3393
|
-
function AppNode(input) {
|
|
3394
|
-
var _this = _super.call(this, input) || this;
|
|
3395
|
-
_this.debugUi = input.debugUi || false;
|
|
3396
|
-
_this.$seal();
|
|
3397
|
-
return _this;
|
|
3398
|
-
}
|
|
3399
|
-
return AppNode;
|
|
3400
|
-
}(node_1.INode));
|
|
3401
|
-
exports.AppNode = AppNode;
|
|
3402
|
-
/**
|
|
3403
|
-
* Represents a Vasille.js application
|
|
3404
|
-
* @class App
|
|
3405
|
-
* @extends AppNode
|
|
3406
|
-
*/
|
|
3407
|
-
var App = /** @class */ (function (_super) {
|
|
3408
|
-
__extends(App, _super);
|
|
3409
|
-
/**
|
|
3410
|
-
* Constructs an app node
|
|
3411
|
-
* @param node {Element} The root of application
|
|
3412
|
-
* @param input
|
|
3413
|
-
*/
|
|
3414
|
-
function App(node, input) {
|
|
3415
|
-
var _this = _super.call(this, input) || this;
|
|
3416
|
-
_this.$.node = node;
|
|
3417
|
-
_this.preinit(_this, _this);
|
|
3418
|
-
_this.init();
|
|
3419
|
-
_this.$seal();
|
|
3420
|
-
return _this;
|
|
3421
|
-
}
|
|
3422
|
-
App.prototype.appendNode = function (node) {
|
|
3423
|
-
this.$.node.appendChild(node);
|
|
3424
|
-
};
|
|
3425
|
-
return App;
|
|
3426
|
-
}(AppNode));
|
|
3427
|
-
exports.App = App;
|
|
3428
|
-
var Portal = /** @class */ (function (_super) {
|
|
3429
|
-
__extends(Portal, _super);
|
|
3430
|
-
function Portal(input) {
|
|
3431
|
-
var _this = _super.call(this, input) || this;
|
|
3432
|
-
_this.$.node = input.node;
|
|
3433
|
-
_this.$seal();
|
|
3434
|
-
return _this;
|
|
3435
|
-
}
|
|
3436
|
-
Portal.prototype.appendNode = function (node) {
|
|
3437
|
-
this.$.node.appendChild(node);
|
|
3438
|
-
};
|
|
3439
|
-
return Portal;
|
|
3440
|
-
}(AppNode));
|
|
3441
|
-
exports.Portal = Portal;
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
// ./lib-es5/functional/options.js
|
|
3445
|
-
"use strict";
|
|
3446
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
})();
|