vasille 1.2.8 → 2.0.2

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