vasille 2.3.1 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cdn/es5.js CHANGED
@@ -197,152 +197,89 @@ window.Reflect = window.Reflect || {
197
197
  window.Proxy = window.Proxy || function (obj) {
198
198
  return obj;
199
199
  };
200
- // ./lib-es5/models/model.js
201
- "use strict";
202
- Object.defineProperty(exports, "__esModule", { value: true });
203
-
204
-
205
- // ./lib-es5/models/listener.js
200
+ // ./lib-es5/core/destroyable.js
206
201
  "use strict";
207
202
  Object.defineProperty(exports, "__esModule", { value: true });
208
- exports.Listener = void 0;
203
+ exports.Destroyable = void 0;
209
204
  /**
210
- * Represent a listener for a model
211
- * @class Listener
205
+ * Mark an object which can be destroyed
206
+ * @class Destroyable
212
207
  */
213
- var Listener = /** @class */ (function () {
214
- function Listener() {
215
- Object.defineProperties(this, {
216
- onAdded: {
217
- value: new Set,
218
- writable: false,
219
- configurable: false
220
- },
221
- onRemoved: {
222
- value: new Set,
223
- writable: false,
224
- configurable: false
225
- },
226
- frozen: {
227
- value: false,
228
- writable: true,
229
- configurable: false
230
- },
231
- queue: {
232
- value: [],
233
- writable: false,
234
- configurable: false
235
- }
236
- });
208
+ var Destroyable = /** @class */ (function () {
209
+ function Destroyable() {
237
210
  }
238
211
  /**
239
- * Exclude the repeated operation in queue
240
- * @private
241
- */
242
- Listener.prototype.excludeRepeat = function (index) {
243
- var _this = this;
244
- this.queue.forEach(function (item, i) {
245
- if (item.index === index) {
246
- _this.queue.splice(i, 1);
247
- return true;
248
- }
249
- });
250
- return false;
251
- };
252
- /**
253
- * Emits added event to listeners
254
- * @param index {*} index of value
255
- * @param value {*} value of added item
256
- */
257
- Listener.prototype.emitAdded = function (index, value) {
258
- if (this.frozen) {
259
- if (!this.excludeRepeat(index)) {
260
- this.queue.push({ sign: true, index: index, value: value });
261
- }
262
- }
263
- else {
264
- this.onAdded.forEach(function (handler) {
265
- handler(index, value);
266
- });
267
- }
268
- };
269
- /**
270
- * Emits removed event to listeners
271
- * @param index {*} index of removed value
272
- * @param value {*} value of removed item
273
- */
274
- Listener.prototype.emitRemoved = function (index, value) {
275
- if (this.frozen) {
276
- if (!this.excludeRepeat(index)) {
277
- this.queue.push({ sign: false, index: index, value: value });
278
- }
279
- }
280
- else {
281
- this.onRemoved.forEach(function (handler) {
282
- handler(index, value);
283
- });
284
- }
285
- };
286
- /**
287
- * Adds a handler to added event
288
- * @param handler {function} function to run on event emitting
289
- */
290
- Listener.prototype.onAdd = function (handler) {
291
- this.onAdded.add(handler);
292
- };
293
- /**
294
- * Adds a handler to removed event
295
- * @param handler {function} function to run on event emitting
296
- */
297
- Listener.prototype.onRemove = function (handler) {
298
- this.onRemoved.add(handler);
299
- };
300
- /**
301
- * Removes an handler from added event
302
- * @param handler {function} handler to remove
303
- */
304
- Listener.prototype.offAdd = function (handler) {
305
- this.onAdded.delete(handler);
306
- };
307
- /**
308
- * Removes an handler form removed event
309
- * @param handler {function} handler to remove
310
- */
311
- Listener.prototype.offRemove = function (handler) {
312
- this.onRemoved.delete(handler);
313
- };
314
- /**
315
- * Run all queued operation and enable reactivity
212
+ * Make object fields non configurable
213
+ * @protected
316
214
  */
317
- Listener.prototype.enableReactivity = function () {
215
+ Destroyable.prototype.$seal = function () {
318
216
  var _this = this;
319
- this.queue.forEach(function (item) {
320
- if (item.sign) {
321
- _this.onAdded.forEach(function (handler) {
322
- handler(item.index, item.value);
323
- });
324
- }
325
- else {
326
- _this.onRemoved.forEach(function (handler) {
327
- handler(item.index, item.value);
328
- });
217
+ var $ = this;
218
+ Object.keys($).forEach(function (i) {
219
+ // eslint-disable-next-line no-prototype-builtins
220
+ if (_this.hasOwnProperty(i)) {
221
+ var config = Object.getOwnPropertyDescriptor($, i);
222
+ if (config.configurable) {
223
+ var descriptor = void 0;
224
+ if (config.set || config.get) {
225
+ descriptor = {
226
+ configurable: false,
227
+ get: config.get,
228
+ set: config.set,
229
+ enumerable: config.enumerable
230
+ };
231
+ }
232
+ else {
233
+ descriptor = {
234
+ value: $[i],
235
+ configurable: false,
236
+ writable: config.writable,
237
+ enumerable: config.enumerable
238
+ };
239
+ }
240
+ Object.defineProperty($, i, descriptor);
241
+ }
329
242
  }
330
243
  });
331
- this.queue.splice(0);
332
- this.frozen = false;
333
244
  };
334
245
  /**
335
- * Disable the reactivity and enable the queue
246
+ * Garbage collector method
336
247
  */
337
- Listener.prototype.disableReactivity = function () {
338
- this.frozen = true;
248
+ Destroyable.prototype.$destroy = function () {
249
+ // nothing here
339
250
  };
340
- return Listener;
251
+ return Destroyable;
341
252
  }());
342
- exports.Listener = Listener;
253
+ exports.Destroyable = Destroyable;
343
254
 
344
255
 
345
- // ./lib-es5/models/object-model.js
256
+ // ./lib-es5/core/errors.js
257
+ "use strict";
258
+ Object.defineProperty(exports, "__esModule", { value: true });
259
+ exports.wrongBinding = exports.userError = exports.internalError = exports.notOverwritten = void 0;
260
+ var reportIt = "Report it here: https://gitlab.com/vasille-js/vasille-js/-/issues";
261
+ function notOverwritten() {
262
+ console.error("Vasille-SFP: Internal error", "Must be overwritten", reportIt);
263
+ return "not-overwritten";
264
+ }
265
+ exports.notOverwritten = notOverwritten;
266
+ function internalError(msg) {
267
+ console.error("Vasille-SFP: Internal error", msg, reportIt);
268
+ return "internal-error";
269
+ }
270
+ exports.internalError = internalError;
271
+ function userError(msg, err) {
272
+ console.error("Vasille-SFP: User error", msg);
273
+ return err;
274
+ }
275
+ exports.userError = userError;
276
+ function wrongBinding(msg) {
277
+ return userError(msg, "wrong-binding");
278
+ }
279
+ exports.wrongBinding = wrongBinding;
280
+
281
+
282
+ // ./lib-es5/core/ivalue.js
346
283
  "use strict";
347
284
  var __extends = (this && this.__extends) || (function () {
348
285
  var extendStatics = function (d, b) {
@@ -360,97 +297,82 @@ var __extends = (this && this.__extends) || (function () {
360
297
  };
361
298
  })();
362
299
  Object.defineProperty(exports, "__esModule", { value: true });
363
- exports.ObjectModel = void 0;
364
- var listener_1 = require("./listener");
300
+ exports.IValue = exports.Switchable = void 0;
301
+ var destroyable_js_1 = require("./destroyable.js");
302
+ var errors_1 = require("./errors");
303
+ var Switchable = /** @class */ (function (_super) {
304
+ __extends(Switchable, _super);
305
+ function Switchable() {
306
+ return _super !== null && _super.apply(this, arguments) || this;
307
+ }
308
+ /**
309
+ * Enable update handlers triggering
310
+ */
311
+ Switchable.prototype.$enable = function () {
312
+ throw (0, errors_1.notOverwritten)();
313
+ };
314
+ /**
315
+ * disable update handlers triggering
316
+ */
317
+ Switchable.prototype.$disable = function () {
318
+ throw (0, errors_1.notOverwritten)();
319
+ };
320
+ return Switchable;
321
+ }(destroyable_js_1.Destroyable));
322
+ exports.Switchable = Switchable;
365
323
  /**
366
- * Object based model
367
- * @extends Object
324
+ * Interface which describes a value
325
+ * @class IValue
326
+ * @extends Destroyable
368
327
  */
369
- var ObjectModel = /** @class */ (function (_super) {
370
- __extends(ObjectModel, _super);
328
+ var IValue = /** @class */ (function (_super) {
329
+ __extends(IValue, _super);
371
330
  /**
372
- * Constructs a object model
373
- * @param obj {Object} input data
331
+ * @param isEnabled {boolean} initial is enabled state
374
332
  */
375
- function ObjectModel(obj) {
376
- if (obj === void 0) { obj = {}; }
333
+ function IValue(isEnabled) {
377
334
  var _this = this; _super.call(this);
378
- _this.container = Object.create(null);
379
- Object.defineProperty(_this, 'listener', {
380
- value: new listener_1.Listener,
381
- writable: false,
382
- configurable: false
383
- });
384
- for (var i in obj) {
385
- Object.defineProperty(_this.container, i, {
386
- value: obj[i],
387
- configurable: true,
388
- writable: true,
389
- enumerable: true
390
- });
391
- _this.listener.emitAdded(i, obj[i]);
392
- }
335
+ _this.isEnabled = isEnabled;
393
336
  return _this;
394
337
  }
395
- /**
396
- * Gets a value of a field
397
- * @param key {string}
398
- * @return {*}
399
- */
400
- ObjectModel.prototype.get = function (key) {
401
- return this.container[key];
402
- };
403
- /**
404
- * Sets an object property value
405
- * @param key {string} property name
406
- * @param v {*} property value
407
- * @return {ObjectModel} a pointer to this
408
- */
409
- ObjectModel.prototype.set = function (key, v) {
410
- if (Reflect.has(this.container, key)) {
411
- this.listener.emitRemoved(key, this.container[key]);
412
- this.container[key] = v;
413
- }
414
- else {
415
- Object.defineProperty(this.container, key, {
416
- value: v,
417
- configurable: true,
418
- writable: true,
419
- enumerable: true
420
- });
421
- }
422
- this.listener.emitAdded(key, this.container[key]);
423
- return this;
424
- };
425
- Object.defineProperty(ObjectModel.prototype, "values", {
338
+ Object.defineProperty(IValue.prototype, "$", {
339
+ /**
340
+ * Get the encapsulated value
341
+ * @return {*} the encapsulated value
342
+ */
426
343
  get: function () {
427
- return this.container;
344
+ throw (0, errors_1.notOverwritten)();
345
+ },
346
+ /**
347
+ * Sets the encapsulated value
348
+ * @param value {*} value to encapsulate
349
+ */
350
+ set: function (value) {
351
+ throw (0, errors_1.notOverwritten)();
428
352
  },
429
353
  enumerable: false,
430
354
  configurable: true
431
355
  });
432
356
  /**
433
- * Deletes an object property
434
- * @param key {string} property name
357
+ * Add a new handler to value change
358
+ * @param handler {function(value : *)} the handler to add
435
359
  */
436
- ObjectModel.prototype.delete = function (key) {
437
- if (this.container[key]) {
438
- this.listener.emitRemoved(key, this.container[key]);
439
- delete this.container[key];
440
- }
441
- };
442
- ObjectModel.prototype.enableReactivity = function () {
443
- this.listener.enableReactivity();
360
+ IValue.prototype.$on = function (handler) {
361
+ throw (0, errors_1.notOverwritten)();
444
362
  };
445
- ObjectModel.prototype.disableReactivity = function () {
446
- this.listener.disableReactivity();
363
+ /**
364
+ * Removes a handler of value change
365
+ * @param handler {function(value : *)} the handler to remove
366
+ */
367
+ IValue.prototype.$off = function (handler) {
368
+ throw (0, errors_1.notOverwritten)();
447
369
  };
448
- return ObjectModel;
449
- }(Object));
450
- exports.ObjectModel = ObjectModel;
370
+ return IValue;
371
+ }(Switchable));
372
+ exports.IValue = IValue;
451
373
 
452
374
 
453
- // ./lib-es5/models/set-model.js
375
+ // ./lib-es5/core/core.js
454
376
  "use strict";
455
377
  var __extends = (this && this.__extends) || (function () {
456
378
  var extendStatics = function (d, b) {
@@ -467,79 +389,286 @@ var __extends = (this && this.__extends) || (function () {
467
389
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
468
390
  };
469
391
  })();
392
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
393
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
394
+ if (ar || !(i in from)) {
395
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
396
+ ar[i] = from[i];
397
+ }
398
+ }
399
+ return to.concat(ar || Array.prototype.slice.call(from));
400
+ };
470
401
  Object.defineProperty(exports, "__esModule", { value: true });
471
- exports.SetModel = void 0;
472
- var listener_1 = require("./listener");
402
+ exports.Reactive = exports.ReactivePrivate = exports.unstack = exports.stack = exports.current = void 0;
403
+ var destroyable_js_1 = require("./destroyable.js");
404
+ var errors_1 = require("./errors");
405
+ var expression_1 = require("../value/expression");
406
+ var reference_1 = require("../value/reference");
407
+ var pointer_1 = require("../value/pointer");
408
+ var mirror_1 = require("../value/mirror");
409
+ exports.current = null;
410
+ var currentStack = [];
411
+ function stack(node) {
412
+ currentStack.push(exports.current);
413
+ exports.current = node;
414
+ }
415
+ exports.stack = stack;
416
+ function unstack() {
417
+ exports.current = currentStack.pop();
418
+ }
419
+ exports.unstack = unstack;
473
420
  /**
474
- * A Set based model
475
- * @class SetModel
476
- * @extends Set
477
- * @implements IModel
421
+ * Private stuff of a reactive object
422
+ * @class ReactivePrivate
423
+ * @extends Destroyable
478
424
  */
479
- var SetModel = /** @class */ (function (_super) {
480
- __extends(SetModel, _super);
481
- /**
482
- * Constructs a set model based on a set
483
- * @param set {Set} input data
484
- */
485
- function SetModel(set) {
486
- if (set === void 0) { set = []; }
425
+ var ReactivePrivate = /** @class */ (function (_super) {
426
+ __extends(ReactivePrivate, _super);
427
+ function ReactivePrivate() {
487
428
  var _this = this; _super.call(this);
488
- Object.defineProperty(_this, 'listener', {
489
- value: new listener_1.Listener,
490
- writable: false,
491
- configurable: false
492
- });
493
- set.forEach(function (item) {
494
- _super.prototype.add.call(_this, item);
495
- });
429
+ /**
430
+ * A list of user-defined values
431
+ * @type {Set}
432
+ */
433
+ _this.watch = new Set;
434
+ /**
435
+ * A list of user-defined bindings
436
+ * @type {Set}
437
+ */
438
+ _this.bindings = new Set;
439
+ /**
440
+ * A list of user defined models
441
+ */
442
+ _this.models = new Set;
443
+ /**
444
+ * Reactivity switch state
445
+ * @type {boolean}
446
+ */
447
+ _this.enabled = true;
448
+ /**
449
+ * The frozen state of object
450
+ * @type {boolean}
451
+ */
452
+ _this.frozen = false;
453
+ _this.$seal();
454
+ return _this;
455
+ }
456
+ ReactivePrivate.prototype.$destroy = function () {
457
+ this.watch.forEach(function (value) { return value.$destroy(); });
458
+ this.watch.clear();
459
+ this.bindings.forEach(function (binding) { return binding.$destroy(); });
460
+ this.bindings.clear();
461
+ this.models.forEach(function (model) { return model.disableReactivity(); });
462
+ this.models.clear();
463
+ this.freezeExpr && this.freezeExpr.$destroy();
464
+ this.onDestroy && this.onDestroy();
465
+ _super.prototype.$destroy.call(this);
466
+ };
467
+ return ReactivePrivate;
468
+ }(destroyable_js_1.Destroyable));
469
+ exports.ReactivePrivate = ReactivePrivate;
470
+ /**
471
+ * A reactive object
472
+ * @class Reactive
473
+ * @extends Destroyable
474
+ */
475
+ var Reactive = /** @class */ (function (_super) {
476
+ __extends(Reactive, _super);
477
+ function Reactive(input, $) {
478
+ var _this = this; _super.call(this);
479
+ _this.input = input;
480
+ _this.$ = $ || new ReactivePrivate;
481
+ _this.$seal();
496
482
  return _this;
497
483
  }
484
+ Object.defineProperty(Reactive.prototype, "parent", {
485
+ /**
486
+ * Get parent node
487
+ */
488
+ get: function () {
489
+ return this.$.parent;
490
+ },
491
+ enumerable: false,
492
+ configurable: true
493
+ });
498
494
  /**
499
- * Calls Set.add and notify abut changes
500
- * @param value {*} value
501
- * @return {this} a pointer to this
495
+ * Create a reference
496
+ * @param value {*} value to reference
502
497
  */
503
- SetModel.prototype.add = function (value) {
504
- if (!_super.prototype.has.call(this, value)) {
505
- this.listener.emitAdded(value, value);
506
- _super.prototype.add.call(this, value);
507
- }
508
- return this;
498
+ Reactive.prototype.ref = function (value) {
499
+ var $ = this.$;
500
+ var ref = new reference_1.Reference(value);
501
+ $.watch.add(ref);
502
+ return ref;
509
503
  };
510
504
  /**
511
- * Calls Set.clear and notify abut changes
505
+ * Create a mirror
506
+ * @param value {IValue} value to mirror
512
507
  */
513
- SetModel.prototype.clear = function () {
514
- var _this = this;
515
- this.forEach(function (item) {
516
- _this.listener.emitRemoved(item, item);
517
- });
518
- _super.prototype.clear.call(this);
508
+ Reactive.prototype.mirror = function (value) {
509
+ var mirror = new mirror_1.Mirror(value, false);
510
+ this.$.watch.add(mirror);
511
+ return mirror;
519
512
  };
520
513
  /**
521
- * Calls Set.delete and notify abut changes
522
- * @param value {*}
523
- * @return {boolean} true if a value was deleted, otherwise false
514
+ * Create a forward-only mirror
515
+ * @param value {IValue} value to mirror
524
516
  */
525
- SetModel.prototype.delete = function (value) {
526
- if (_super.prototype.has.call(this, value)) {
527
- this.listener.emitRemoved(value, value);
528
- }
529
- return _super.prototype.delete.call(this, value);
517
+ Reactive.prototype.forward = function (value) {
518
+ var mirror = new mirror_1.Mirror(value, true);
519
+ this.$.watch.add(mirror);
520
+ return mirror;
530
521
  };
531
- SetModel.prototype.enableReactivity = function () {
532
- this.listener.enableReactivity();
522
+ /**
523
+ * Creates a pointer
524
+ * @param value {*} default value to point
525
+ * @param forwardOnly {boolean} forward only sync
526
+ */
527
+ Reactive.prototype.point = function (value, forwardOnly) {
528
+ if (forwardOnly === void 0) { forwardOnly = false; }
529
+ var $ = this.$;
530
+ var pointer = new pointer_1.Pointer(value, forwardOnly);
531
+ $.watch.add(pointer);
532
+ return pointer;
533
533
  };
534
- SetModel.prototype.disableReactivity = function () {
535
- this.listener.disableReactivity();
534
+ /**
535
+ * Register a model
536
+ * @param model
537
+ */
538
+ Reactive.prototype.register = function (model) {
539
+ this.$.models.add(model);
540
+ return model;
536
541
  };
537
- return SetModel;
538
- }(Set));
539
- exports.SetModel = SetModel;
540
-
541
-
542
- // ./lib-es5/models/map-model.js
542
+ /**
543
+ * Creates a watcher
544
+ * @param func {function} function to run on any argument change
545
+ * @param values
546
+ */
547
+ Reactive.prototype.watch = function (func) {
548
+ var values = [];
549
+ for (var _i = 1; _i < arguments.length; _i++) {
550
+ values[_i - 1] = arguments[_i];
551
+ }
552
+ var $ = this.$;
553
+ $.watch.add(new (expression_1.Expression.bind.apply(expression_1.Expression, __spreadArray([void 0, func, !this.$.frozen], values, false)))());
554
+ };
555
+ /**
556
+ * Creates a computed value
557
+ * @param func {function} function to run on any argument change
558
+ * @param values
559
+ * @return {IValue} the created ivalue
560
+ */
561
+ Reactive.prototype.expr = function (func) {
562
+ var values = [];
563
+ for (var _i = 1; _i < arguments.length; _i++) {
564
+ values[_i - 1] = arguments[_i];
565
+ }
566
+ var res = new (expression_1.Expression.bind.apply(expression_1.Expression, __spreadArray([void 0, func, !this.$.frozen], values, false)))();
567
+ var $ = this.$;
568
+ $.watch.add(res);
569
+ return res;
570
+ };
571
+ /**
572
+ * Enable reactivity of fields
573
+ */
574
+ Reactive.prototype.enable = function () {
575
+ var $ = this.$;
576
+ if (!$.enabled) {
577
+ $.watch.forEach(function (watcher) {
578
+ watcher.$enable();
579
+ });
580
+ $.models.forEach(function (model) {
581
+ model.enableReactivity();
582
+ });
583
+ $.enabled = true;
584
+ }
585
+ };
586
+ /**
587
+ * Disable reactivity of fields
588
+ */
589
+ Reactive.prototype.disable = function () {
590
+ var $ = this.$;
591
+ if ($.enabled) {
592
+ $.watch.forEach(function (watcher) {
593
+ watcher.$disable();
594
+ });
595
+ $.models.forEach(function (model) {
596
+ model.disableReactivity();
597
+ });
598
+ $.enabled = false;
599
+ }
600
+ };
601
+ /**
602
+ * Disable/Enable reactivity of object fields with feedback
603
+ * @param cond {IValue} show condition
604
+ * @param onOff {function} on show feedback
605
+ * @param onOn {function} on hide feedback
606
+ */
607
+ Reactive.prototype.bindAlive = function (cond, onOff, onOn) {
608
+ var _this = this;
609
+ var $ = this.$;
610
+ if ($.freezeExpr) {
611
+ throw (0, errors_1.wrongBinding)("this component already have a freeze state");
612
+ }
613
+ if ($.watch.has(cond)) {
614
+ throw (0, errors_1.wrongBinding)("freeze state must be bound to an external component");
615
+ }
616
+ $.freezeExpr = new expression_1.Expression(function (cond) {
617
+ $.frozen = !cond;
618
+ if (cond) {
619
+ onOn === null || onOn === void 0 ? void 0 : onOn();
620
+ _this.enable();
621
+ }
622
+ else {
623
+ onOff === null || onOff === void 0 ? void 0 : onOff();
624
+ _this.disable();
625
+ }
626
+ }, true, cond);
627
+ return this;
628
+ };
629
+ Reactive.prototype.init = function () {
630
+ this.applyOptions(this.input);
631
+ return this.compose(this.input);
632
+ };
633
+ Reactive.prototype.applyOptions = function (input) {
634
+ // empty
635
+ };
636
+ Reactive.prototype.applyOptionsNow = function () {
637
+ this.applyOptions(this.input);
638
+ };
639
+ Reactive.prototype.compose = function (input) {
640
+ throw (0, errors_1.notOverwritten)();
641
+ };
642
+ Reactive.prototype.composeNow = function () {
643
+ this.compose(this.input);
644
+ };
645
+ Reactive.prototype.runFunctional = function (f) {
646
+ var args = [];
647
+ for (var _i = 1; _i < arguments.length; _i++) {
648
+ args[_i - 1] = arguments[_i];
649
+ }
650
+ stack(this);
651
+ // yet another ts bug
652
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
653
+ // @ts-ignore
654
+ var result = f.apply(void 0, args);
655
+ unstack();
656
+ return result;
657
+ };
658
+ Reactive.prototype.runOnDestroy = function (func) {
659
+ this.$.onDestroy = func;
660
+ };
661
+ Reactive.prototype.$destroy = function () {
662
+ _super.prototype.$destroy.call(this);
663
+ this.$.$destroy();
664
+ this.$ = null;
665
+ };
666
+ return Reactive;
667
+ }(destroyable_js_1.Destroyable));
668
+ exports.Reactive = Reactive;
669
+
670
+
671
+ // ./lib-es5/value/reference.js
543
672
  "use strict";
544
673
  var __extends = (this && this.__extends) || (function () {
545
674
  var extendStatics = function (d, b) {
@@ -557,83 +686,70 @@ var __extends = (this && this.__extends) || (function () {
557
686
  };
558
687
  })();
559
688
  Object.defineProperty(exports, "__esModule", { value: true });
560
- exports.MapModel = void 0;
561
- var listener_1 = require("./listener");
689
+ exports.Reference = void 0;
690
+ var ivalue_1 = require("../core/ivalue");
562
691
  /**
563
- * A Map based memory
564
- * @class MapModel
565
- * @extends Map
566
- * @implements IModel
692
+ * Declares a notifiable value
693
+ * @class Reference
694
+ * @extends IValue
567
695
  */
568
- var MapModel = /** @class */ (function (_super) {
569
- __extends(MapModel, _super);
696
+ var Reference = /** @class */ (function (_super) {
697
+ __extends(Reference, _super);
570
698
  /**
571
- * Constructs a map model
572
- * @param map {[*, *][]} input data
699
+ * @param value {any} the initial value
573
700
  */
574
- function MapModel(map) {
575
- if (map === void 0) { map = []; }
576
- var _this = this; _super.call(this);
577
- Object.defineProperty(_this, 'listener', {
578
- value: new listener_1.Listener,
579
- writable: false,
580
- configurable: false
581
- });
582
- map.forEach(function (_a) {
583
- var key = _a[0], value = _a[1];
584
- _super.prototype.set.call(_this, key, value);
585
- });
701
+ function Reference(value) {
702
+ var _this = _super.call(this, true) || this;
703
+ _this.$value = value;
704
+ _this.$onchange = new Set;
705
+ _this.$seal();
586
706
  return _this;
587
707
  }
588
- /**
589
- * Calls Map.clear and notify abut changes
590
- */
591
- MapModel.prototype.clear = function () {
708
+ Object.defineProperty(Reference.prototype, "$", {
709
+ get: function () {
710
+ return this.$value;
711
+ },
712
+ set: function (value) {
713
+ if (this.$value !== value) {
714
+ this.$value = value;
715
+ if (this.isEnabled) {
716
+ this.$onchange.forEach(function (handler) {
717
+ handler(value);
718
+ });
719
+ }
720
+ }
721
+ },
722
+ enumerable: false,
723
+ configurable: true
724
+ });
725
+ Reference.prototype.$enable = function () {
592
726
  var _this = this;
593
- this.forEach(function (value, key) {
594
- _this.listener.emitRemoved(key, value);
595
- });
596
- _super.prototype.clear.call(this);
597
- };
598
- /**
599
- * Calls Map.delete and notify abut changes
600
- * @param key {*} key
601
- * @return {boolean} true if removed something, otherwise false
602
- */
603
- MapModel.prototype.delete = function (key) {
604
- var tmp = _super.prototype.get.call(this, key);
605
- if (tmp) {
606
- this.listener.emitRemoved(key, tmp);
727
+ if (!this.isEnabled) {
728
+ this.$onchange.forEach(function (handler) {
729
+ handler(_this.$value);
730
+ });
731
+ this.isEnabled = true;
607
732
  }
608
- return _super.prototype.delete.call(this, key);
609
733
  };
610
- /**
611
- * Calls Map.set and notify abut changes
612
- * @param key {*} key
613
- * @param value {*} value
614
- * @return {MapModel} a pointer to this
615
- */
616
- MapModel.prototype.set = function (key, value) {
617
- var tmp = _super.prototype.get.call(this, key);
618
- if (tmp) {
619
- this.listener.emitRemoved(key, tmp);
620
- }
621
- _super.prototype.set.call(this, key, value);
622
- this.listener.emitAdded(key, value);
623
- return this;
734
+ Reference.prototype.$disable = function () {
735
+ this.isEnabled = false;
624
736
  };
625
- MapModel.prototype.enableReactivity = function () {
626
- this.listener.enableReactivity();
737
+ Reference.prototype.$on = function (handler) {
738
+ this.$onchange.add(handler);
627
739
  };
628
- MapModel.prototype.disableReactivity = function () {
629
- this.listener.disableReactivity();
740
+ Reference.prototype.$off = function (handler) {
741
+ this.$onchange.delete(handler);
630
742
  };
631
- return MapModel;
632
- }(Map));
633
- exports.MapModel = MapModel;
743
+ Reference.prototype.$destroy = function () {
744
+ _super.prototype.$destroy.call(this);
745
+ this.$onchange.clear();
746
+ };
747
+ return Reference;
748
+ }(ivalue_1.IValue));
749
+ exports.Reference = Reference;
634
750
 
635
751
 
636
- // ./lib-es5/models/array-model.js
752
+ // ./lib-es5/value/expression.js
637
753
  "use strict";
638
754
  var __extends = (this && this.__extends) || (function () {
639
755
  var extendStatics = function (d, b) {
@@ -650,339 +766,195 @@ var __extends = (this && this.__extends) || (function () {
650
766
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
651
767
  };
652
768
  })();
653
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
654
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
655
- if (ar || !(i in from)) {
656
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
657
- ar[i] = from[i];
658
- }
659
- }
660
- return to.concat(ar || Array.prototype.slice.call(from));
661
- };
662
769
  Object.defineProperty(exports, "__esModule", { value: true });
663
- exports.ArrayModel = void 0;
664
- var listener_1 = require("./listener");
665
- /**
666
- * Model based on Array class
667
- * @extends Array
668
- * @implements IModel
770
+ exports.Expression = void 0;
771
+ var reference_js_1 = require("./reference.js");
772
+ var ivalue_1 = require("../core/ivalue");
773
+ /**
774
+ * Bind some values to one expression
775
+ * @class Expression
776
+ * @extends IValue
669
777
  */
670
- var ArrayModel = /** @class */ (function (_super) {
671
- __extends(ArrayModel, _super);
778
+ var Expression = /** @class */ (function (_super) {
779
+ __extends(Expression, _super);
672
780
  /**
673
- * @param data {Array} input data
781
+ * Creates a function bounded to N values
782
+ * @param func {Function} the function to bound
783
+ * @param values
784
+ * @param link {Boolean} links immediately if true
674
785
  */
675
- function ArrayModel(data) {
676
- if (data === void 0) { data = []; }
677
- var _this = this; _super.call(this);
678
- Object.defineProperty(_this, 'listener', {
679
- value: new listener_1.Listener,
680
- writable: false,
681
- configurable: false
786
+ function Expression(func, link) {
787
+ var values = [];
788
+ for (var _i = 2; _i < arguments.length; _i++) {
789
+ values[_i - 2] = arguments[_i];
790
+ }
791
+ var _this = _super.call(this, false) || this;
792
+ /**
793
+ * Expression will link different handler for each value of list
794
+ */
795
+ _this.linkedFunc = [];
796
+ var handler = function (i) {
797
+ if (i != null) {
798
+ _this.valuesCache[i] = _this.values[i].$;
799
+ }
800
+ _this.sync.$ = func.apply(_this, _this.valuesCache);
801
+ };
802
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
803
+ // @ts-ignore
804
+ _this.valuesCache = values.map(function (item) { return item.$; });
805
+ _this.sync = new reference_js_1.Reference(func.apply(_this, _this.valuesCache));
806
+ var i = 0;
807
+ values.forEach(function () {
808
+ _this.linkedFunc.push(handler.bind(_this, Number(i++)));
682
809
  });
683
- for (var i = 0; i < data.length; i++) {
684
- _super.prototype.push.call(_this, data[i]);
810
+ _this.values = values;
811
+ _this.func = handler;
812
+ if (link) {
813
+ _this.$enable();
814
+ }
815
+ else {
816
+ handler();
685
817
  }
818
+ _this.$seal();
686
819
  return _this;
687
820
  }
688
- Object.defineProperty(ArrayModel.prototype, "last", {
689
- /* Array members */
690
- /**
691
- * Gets the last item of array
692
- * @return {*} the last item of array
693
- */
821
+ Object.defineProperty(Expression.prototype, "$", {
694
822
  get: function () {
695
- return this.length ? this[this.length - 1] : null;
823
+ return this.sync.$;
824
+ },
825
+ set: function (value) {
826
+ this.sync.$ = value;
696
827
  },
697
828
  enumerable: false,
698
829
  configurable: true
699
830
  });
700
- /**
701
- * Calls Array.fill and notify about changes
702
- * @param value {*} value to fill with
703
- * @param start {?number} begin index
704
- * @param end {?number} end index
705
- */
706
- ArrayModel.prototype.fill = function (value, start, end) {
707
- if (!start) {
708
- start = 0;
709
- }
710
- if (!end) {
711
- end = this.length;
712
- }
713
- for (var i = start; i < end; i++) {
714
- this.listener.emitRemoved(this[i], this[i]);
715
- this[i] = value;
716
- this.listener.emitAdded(value, value);
717
- }
831
+ Expression.prototype.$on = function (handler) {
832
+ this.sync.$on(handler);
718
833
  return this;
719
834
  };
720
- /**
721
- * Calls Array.pop and notify about changes
722
- * @return {*} removed value
723
- */
724
- ArrayModel.prototype.pop = function () {
725
- var v = _super.prototype.pop.call(this);
726
- if (v !== undefined) {
727
- this.listener.emitRemoved(v, v);
728
- }
729
- return v;
730
- };
731
- /**
732
- * Calls Array.push and notify about changes
733
- * @param items {...*} values to push
734
- * @return {number} new length of array
735
- */
736
- ArrayModel.prototype.push = function () {
737
- var _this = this;
738
- var items = [];
739
- for (var _i = 0; _i < arguments.length; _i++) {
740
- items[_i] = arguments[_i];
741
- }
742
- items.forEach(function (item) {
743
- _this.listener.emitAdded(item, item);
744
- _super.prototype.push.call(_this, item);
745
- });
746
- return this.length;
747
- };
748
- /**
749
- * Calls Array.shift and notify about changed
750
- * @return {*} the shifted value
751
- */
752
- ArrayModel.prototype.shift = function () {
753
- var v = _super.prototype.shift.call(this);
754
- if (v !== undefined) {
755
- this.listener.emitRemoved(v, v);
756
- }
757
- return v;
835
+ Expression.prototype.$off = function (handler) {
836
+ this.sync.$off(handler);
837
+ return this;
758
838
  };
759
- /**
760
- * Calls Array.splice and notify about changed
761
- * @param start {number} start index
762
- * @param deleteCount {?number} delete count
763
- * @param items {...*}
764
- * @return {ArrayModel} a pointer to this
765
- */
766
- ArrayModel.prototype.splice = function (start, deleteCount) {
767
- var items = [];
768
- for (var _i = 2; _i < arguments.length; _i++) {
769
- items[_i - 2] = arguments[_i];
770
- }
771
- start = Math.min(start, this.length);
772
- deleteCount = deleteCount || this.length - start;
773
- var before = this[start + deleteCount];
774
- for (var i = 0; i < deleteCount; i++) {
775
- var index = start + deleteCount - i - 1;
776
- if (this[index] !== undefined) {
777
- this.listener.emitRemoved(this[index], this[index]);
839
+ Expression.prototype.$enable = function () {
840
+ if (!this.isEnabled) {
841
+ for (var i = 0; i < this.values.length; i++) {
842
+ this.values[i].$on(this.linkedFunc[i]);
843
+ this.valuesCache[i] = this.values[i].$;
778
844
  }
845
+ this.func();
846
+ this.isEnabled = true;
779
847
  }
780
- for (var i = 0; i < items.length; i++) {
781
- this.listener.emitAdded(before, items[i]);
782
- }
783
- return new ArrayModel(_super.prototype.splice.apply(this, __spreadArray([start, deleteCount], items, false)));
848
+ return this;
784
849
  };
785
- /**
786
- * Calls Array.unshift and notify about changed
787
- * @param items {...*} values to insert
788
- * @return {number} the length after prepend
789
- */
790
- ArrayModel.prototype.unshift = function () {
791
- var items = [];
792
- for (var _i = 0; _i < arguments.length; _i++) {
793
- items[_i] = arguments[_i];
794
- }
795
- for (var i = 0; i < items.length; i++) {
796
- this.listener.emitAdded(this[i], items[i]);
850
+ Expression.prototype.$disable = function () {
851
+ if (this.isEnabled) {
852
+ for (var i = 0; i < this.values.length; i++) {
853
+ this.values[i].$off(this.linkedFunc[i]);
854
+ }
855
+ this.isEnabled = false;
797
856
  }
798
- return _super.prototype.unshift.apply(this, items);
799
- };
800
- /**
801
- * Inserts a value to the end of array
802
- * @param v {*} value to insert
803
- */
804
- ArrayModel.prototype.append = function (v) {
805
- this.listener.emitAdded(null, v);
806
- _super.prototype.push.call(this, v);
807
857
  return this;
808
858
  };
809
- /**
810
- * Clears array
811
- * @return {this} a pointer to this
812
- */
813
- ArrayModel.prototype.clear = function () {
814
- var _this = this;
815
- this.forEach(function (v) {
816
- _this.listener.emitRemoved(v, v);
817
- });
818
- _super.prototype.splice.call(this, 0);
819
- return this;
859
+ Expression.prototype.$destroy = function () {
860
+ this.$disable();
861
+ this.values.splice(0);
862
+ this.valuesCache.splice(0);
863
+ this.linkedFunc.splice(0);
864
+ _super.prototype.$destroy.call(this);
820
865
  };
821
- /**
822
- * Inserts a value to position `index`
823
- * @param index {number} index to insert value
824
- * @param v {*} value to insert
825
- * @return {this} a pointer to this
826
- */
827
- ArrayModel.prototype.insert = function (index, v) {
828
- this.listener.emitAdded(this[index], v);
829
- _super.prototype.splice.call(this, index, 0, v);
830
- return this;
866
+ return Expression;
867
+ }(ivalue_1.IValue));
868
+ exports.Expression = Expression;
869
+
870
+
871
+ // ./lib-es5/value/mirror.js
872
+ "use strict";
873
+ var __extends = (this && this.__extends) || (function () {
874
+ var extendStatics = function (d, b) {
875
+ extendStatics = Object.setPrototypeOf ||
876
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
877
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
878
+ return extendStatics(d, b);
831
879
  };
832
- /**
833
- * Inserts a value to the beginning of array
834
- * @param v {*} value to insert
835
- * @return {this} a pointer to this
836
- */
837
- ArrayModel.prototype.prepend = function (v) {
838
- this.listener.emitAdded(this[0], v);
839
- _super.prototype.unshift.call(this, v);
840
- return this;
880
+ return function (d, b) {
881
+ if (typeof b !== "function" && b !== null)
882
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
883
+ extendStatics(d, b);
884
+ function __() { this.constructor = d; }
885
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
841
886
  };
887
+ })();
888
+ Object.defineProperty(exports, "__esModule", { value: true });
889
+ exports.Mirror = void 0;
890
+ var reference_1 = require("./reference");
891
+ /**
892
+ * Declares a notifiable bind to a value
893
+ * @class Mirror
894
+ * @extends IValue
895
+ * @version 2
896
+ */
897
+ var Mirror = /** @class */ (function (_super) {
898
+ __extends(Mirror, _super);
842
899
  /**
843
- * Removes a value from an index
844
- * @param index {number} index of value to remove
845
- * @return {this} a pointer to this
846
- */
847
- ArrayModel.prototype.removeAt = function (index) {
848
- if (index > 0 && index < this.length) {
849
- this.listener.emitRemoved(this[index], this[index]);
850
- _super.prototype.splice.call(this, index, 1);
851
- }
852
- return this;
853
- };
854
- /**
855
- * Removes the first value of array
856
- * @return {this} a pointer to this
900
+ * Constructs a notifiable bind to a value
901
+ * @param value {IValue} is initial value
902
+ * @param forwardOnly {boolean} ensure forward only synchronization
857
903
  */
858
- ArrayModel.prototype.removeFirst = function () {
859
- if (this.length) {
860
- this.listener.emitRemoved(this[0], this[0]);
861
- _super.prototype.shift.call(this);
904
+ function Mirror(value, forwardOnly) {
905
+ if (forwardOnly === void 0) { forwardOnly = false; }
906
+ var _this = _super.call(this, value.$) || this;
907
+ _this.$handler = function (v) {
908
+ _this.$ = v;
909
+ };
910
+ _this.$pointedValue = value;
911
+ _this.$forwardOnly = forwardOnly;
912
+ value.$on(_this.$handler);
913
+ _this.$seal();
914
+ return _this;
915
+ }
916
+ Object.defineProperty(Mirror.prototype, "$", {
917
+ get: function () {
918
+ // this is a ts bug
919
+ // eslint-disable-next-line
920
+ // @ts-ignore
921
+ return _super.prototype.$;
922
+ },
923
+ set: function (v) {
924
+ if (!this.$forwardOnly) {
925
+ this.$pointedValue.$ = v;
926
+ }
927
+ // this is a ts bug
928
+ // eslint-disable-next-line
929
+ // @ts-ignore
930
+ _super.prototype.$ = v;
931
+ },
932
+ enumerable: false,
933
+ configurable: true
934
+ });
935
+ Mirror.prototype.$enable = function () {
936
+ if (!this.isEnabled) {
937
+ this.isEnabled = true;
938
+ this.$pointedValue.$on(this.$handler);
939
+ this.$ = this.$pointedValue.$;
862
940
  }
863
- return this;
864
941
  };
865
- /**
866
- * Removes the ast value of array
867
- * @return {this} a pointer to this
868
- */
869
- ArrayModel.prototype.removeLast = function () {
870
- var last = this.last;
871
- if (last != null) {
872
- this.listener.emitRemoved(this[this.length - 1], last);
873
- _super.prototype.pop.call(this);
942
+ Mirror.prototype.$disable = function () {
943
+ if (this.isEnabled) {
944
+ this.$pointedValue.$off(this.$handler);
945
+ this.isEnabled = false;
874
946
  }
875
- return this;
876
- };
877
- /**
878
- * Remove the first occurrence of value
879
- * @param v {*} value to remove
880
- * @return {this}
881
- */
882
- ArrayModel.prototype.removeOne = function (v) {
883
- this.removeAt(this.indexOf(v));
884
- return this;
885
- };
886
- ArrayModel.prototype.replace = function (at, with_) {
887
- this.listener.emitAdded(this[at], with_);
888
- this.listener.emitRemoved(this[at], this[at]);
889
- this[at] = with_;
890
- return this;
891
- };
892
- ArrayModel.prototype.enableReactivity = function () {
893
- this.listener.enableReactivity();
894
- };
895
- ArrayModel.prototype.disableReactivity = function () {
896
- this.listener.disableReactivity();
897
- };
898
- return ArrayModel;
899
- }(Array));
900
- exports.ArrayModel = ArrayModel;
901
-
902
-
903
- // ./lib-es5/core/errors.js
904
- "use strict";
905
- Object.defineProperty(exports, "__esModule", { value: true });
906
- exports.wrongBinding = exports.userError = exports.internalError = exports.notOverwritten = void 0;
907
- var reportIt = "Report it here: https://gitlab.com/vasille-js/vasille-js/-/issues";
908
- function notOverwritten() {
909
- console.error("Vasille-SFP: Internal error", "Must be overwritten", reportIt);
910
- return "not-overwritten";
911
- }
912
- exports.notOverwritten = notOverwritten;
913
- function internalError(msg) {
914
- console.error("Vasille-SFP: Internal error", msg, reportIt);
915
- return "internal-error";
916
- }
917
- exports.internalError = internalError;
918
- function userError(msg, err) {
919
- console.error("Vasille-SFP: User error", msg);
920
- return err;
921
- }
922
- exports.userError = userError;
923
- function wrongBinding(msg) {
924
- return userError(msg, "wrong-binding");
925
- }
926
- exports.wrongBinding = wrongBinding;
927
-
928
-
929
- // ./lib-es5/core/destroyable.js
930
- "use strict";
931
- Object.defineProperty(exports, "__esModule", { value: true });
932
- exports.Destroyable = void 0;
933
- /**
934
- * Mark an object which can be destroyed
935
- * @class Destroyable
936
- */
937
- var Destroyable = /** @class */ (function () {
938
- function Destroyable() {
939
- }
940
- /**
941
- * Make object fields non configurable
942
- * @protected
943
- */
944
- Destroyable.prototype.$seal = function () {
945
- var _this = this;
946
- var $ = this;
947
- Object.keys($).forEach(function (i) {
948
- // eslint-disable-next-line no-prototype-builtins
949
- if (_this.hasOwnProperty(i)) {
950
- var config = Object.getOwnPropertyDescriptor($, i);
951
- if (config.configurable) {
952
- var descriptor = void 0;
953
- if (config.set || config.get) {
954
- descriptor = {
955
- configurable: false,
956
- get: config.get,
957
- set: config.set,
958
- enumerable: config.enumerable
959
- };
960
- }
961
- else {
962
- descriptor = {
963
- value: $[i],
964
- configurable: false,
965
- writable: config.writable,
966
- enumerable: config.enumerable
967
- };
968
- }
969
- Object.defineProperty($, i, descriptor);
970
- }
971
- }
972
- });
973
947
  };
974
- /**
975
- * Garbage collector method
976
- */
977
- Destroyable.prototype.$destroy = function () {
978
- // nothing here
948
+ Mirror.prototype.$destroy = function () {
949
+ this.$disable();
950
+ _super.prototype.$destroy.call(this);
979
951
  };
980
- return Destroyable;
981
- }());
982
- exports.Destroyable = Destroyable;
952
+ return Mirror;
953
+ }(reference_1.Reference));
954
+ exports.Mirror = Mirror;
983
955
 
984
956
 
985
- // ./lib-es5/core/ivalue.js
957
+ // ./lib-es5/value/pointer.js
986
958
  "use strict";
987
959
  var __extends = (this && this.__extends) || (function () {
988
960
  var extendStatics = function (d, b) {
@@ -1000,149 +972,189 @@ var __extends = (this && this.__extends) || (function () {
1000
972
  };
1001
973
  })();
1002
974
  Object.defineProperty(exports, "__esModule", { value: true });
1003
- exports.IValue = exports.Switchable = void 0;
1004
- var destroyable_js_1 = require("./destroyable.js");
1005
- var errors_1 = require("./errors");
1006
- var Switchable = /** @class */ (function (_super) {
1007
- __extends(Switchable, _super);
1008
- function Switchable() {
1009
- return _super !== null && _super.apply(this, arguments) || this;
1010
- }
1011
- /**
1012
- * Enable update handlers triggering
1013
- */
1014
- Switchable.prototype.$enable = function () {
1015
- throw (0, errors_1.notOverwritten)();
1016
- };
1017
- /**
1018
- * disable update handlers triggering
1019
- */
1020
- Switchable.prototype.$disable = function () {
1021
- throw (0, errors_1.notOverwritten)();
1022
- };
1023
- return Switchable;
1024
- }(destroyable_js_1.Destroyable));
1025
- exports.Switchable = Switchable;
975
+ exports.Pointer = void 0;
976
+ var mirror_1 = require("./mirror");
1026
977
  /**
1027
- * Interface which describes a value
1028
- * @class IValue
1029
- * @extends Destroyable
978
+ * r/w pointer to a value
979
+ * @class Pointer
980
+ * @extends Mirror
1030
981
  */
1031
- var IValue = /** @class */ (function (_super) {
1032
- __extends(IValue, _super);
982
+ var Pointer = /** @class */ (function (_super) {
983
+ __extends(Pointer, _super);
1033
984
  /**
1034
- * @param isEnabled {boolean} initial is enabled state
985
+ * @param value {IValue} value to point
986
+ * @param forwardOnly {boolean} forward only data flow
1035
987
  */
1036
- function IValue(isEnabled) {
1037
- var _this = this; _super.call(this);
1038
- _this.isEnabled = isEnabled;
1039
- return _this;
988
+ function Pointer(value, forwardOnly) {
989
+ if (forwardOnly === void 0) { forwardOnly = false; }
990
+ return _super.call(this, value, forwardOnly) || this;
1040
991
  }
1041
- Object.defineProperty(IValue.prototype, "$", {
1042
- /**
1043
- * Get the encapsulated value
1044
- * @return {*} the encapsulated value
1045
- */
1046
- get: function () {
1047
- throw (0, errors_1.notOverwritten)();
1048
- },
992
+ Object.defineProperty(Pointer.prototype, "$$", {
1049
993
  /**
1050
- * Sets the encapsulated value
1051
- * @param value {*} value to encapsulate
994
+ * Point a new ivalue
995
+ * @param value {IValue} value to point
1052
996
  */
1053
997
  set: function (value) {
1054
- throw (0, errors_1.notOverwritten)();
998
+ if (this.$pointedValue !== value) {
999
+ this.$disable();
1000
+ this.$pointedValue = value;
1001
+ this.$enable();
1002
+ }
1055
1003
  },
1056
1004
  enumerable: false,
1057
1005
  configurable: true
1058
1006
  });
1059
- /**
1060
- * Add a new handler to value change
1061
- * @param handler {function(value : *)} the handler to add
1062
- */
1063
- IValue.prototype.$on = function (handler) {
1064
- throw (0, errors_1.notOverwritten)();
1065
- };
1066
- /**
1067
- * Removes a handler of value change
1068
- * @param handler {function(value : *)} the handler to remove
1069
- */
1070
- IValue.prototype.$off = function (handler) {
1071
- throw (0, errors_1.notOverwritten)();
1072
- };
1073
- return IValue;
1074
- }(Switchable));
1075
- exports.IValue = IValue;
1076
-
1077
-
1078
- // ./lib-es5/index.js
1079
- "use strict";
1080
- Object.defineProperty(exports, "__esModule", { value: true });
1081
- exports.Reactive = exports.Binding = exports.Expression = exports.Portal = exports.App = exports.AppNode = exports.Extension = exports.Component = exports.Tag = exports.INode = exports.Fragment = exports.SetView = exports.ObjectView = exports.MapView = exports.ArrayView = exports.Listener = exports.BaseView = exports.SetModel = exports.ObjectModel = exports.MapModel = exports.ArrayModel = exports.Pointer = exports.Mirror = exports.Reference = exports.IValue = exports.Destroyable = void 0;
1082
- var destroyable_1 = require("./core/destroyable");
1083
- Object.defineProperty(exports, "Destroyable", { enumerable: true, get: function () { return destroyable_1.Destroyable; } });
1084
- var core_1 = require("./core/core");
1085
- Object.defineProperty(exports, "Reactive", { enumerable: true, get: function () { return core_1.Reactive; } });
1086
- var ivalue_1 = require("./core/ivalue");
1087
- Object.defineProperty(exports, "IValue", { enumerable: true, get: function () { return ivalue_1.IValue; } });
1088
- var array_model_1 = require("./models/array-model");
1089
- Object.defineProperty(exports, "ArrayModel", { enumerable: true, get: function () { return array_model_1.ArrayModel; } });
1090
- var listener_1 = require("./models/listener");
1091
- Object.defineProperty(exports, "Listener", { enumerable: true, get: function () { return listener_1.Listener; } });
1092
- var map_model_1 = require("./models/map-model");
1093
- Object.defineProperty(exports, "MapModel", { enumerable: true, get: function () { return map_model_1.MapModel; } });
1094
- var object_model_1 = require("./models/object-model");
1095
- Object.defineProperty(exports, "ObjectModel", { enumerable: true, get: function () { return object_model_1.ObjectModel; } });
1096
- var set_model_1 = require("./models/set-model");
1097
- Object.defineProperty(exports, "SetModel", { enumerable: true, get: function () { return set_model_1.SetModel; } });
1098
- var app_1 = require("./node/app");
1099
- Object.defineProperty(exports, "App", { enumerable: true, get: function () { return app_1.App; } });
1100
- Object.defineProperty(exports, "AppNode", { enumerable: true, get: function () { return app_1.AppNode; } });
1101
- Object.defineProperty(exports, "Portal", { enumerable: true, get: function () { return app_1.Portal; } });
1102
- var node_1 = require("./node/node");
1103
- Object.defineProperty(exports, "Component", { enumerable: true, get: function () { return node_1.Component; } });
1104
- Object.defineProperty(exports, "Extension", { enumerable: true, get: function () { return node_1.Extension; } });
1105
- Object.defineProperty(exports, "Fragment", { enumerable: true, get: function () { return node_1.Fragment; } });
1106
- Object.defineProperty(exports, "INode", { enumerable: true, get: function () { return node_1.INode; } });
1107
- Object.defineProperty(exports, "Tag", { enumerable: true, get: function () { return node_1.Tag; } });
1108
- var expression_1 = require("./value/expression");
1109
- Object.defineProperty(exports, "Expression", { enumerable: true, get: function () { return expression_1.Expression; } });
1110
- var mirror_1 = require("./value/mirror");
1111
- Object.defineProperty(exports, "Mirror", { enumerable: true, get: function () { return mirror_1.Mirror; } });
1112
- var pointer_1 = require("./value/pointer");
1113
- Object.defineProperty(exports, "Pointer", { enumerable: true, get: function () { return pointer_1.Pointer; } });
1114
- var reference_1 = require("./value/reference");
1115
- Object.defineProperty(exports, "Reference", { enumerable: true, get: function () { return reference_1.Reference; } });
1116
- var array_view_1 = require("./views/array-view");
1117
- Object.defineProperty(exports, "ArrayView", { enumerable: true, get: function () { return array_view_1.ArrayView; } });
1118
- var base_view_1 = require("./views/base-view");
1119
- Object.defineProperty(exports, "BaseView", { enumerable: true, get: function () { return base_view_1.BaseView; } });
1120
- var map_view_1 = require("./views/map-view");
1121
- Object.defineProperty(exports, "MapView", { enumerable: true, get: function () { return map_view_1.MapView; } });
1122
- var object_view_1 = require("./views/object-view");
1123
- Object.defineProperty(exports, "ObjectView", { enumerable: true, get: function () { return object_view_1.ObjectView; } });
1124
- var set_view_1 = require("./views/set-view");
1125
- Object.defineProperty(exports, "SetView", { enumerable: true, get: function () { return set_view_1.SetView; } });
1126
- var binding_1 = require("./binding/binding");
1127
- Object.defineProperty(exports, "Binding", { enumerable: true, get: function () { return binding_1.Binding; } });
1128
-
1129
-
1130
- // ./lib-es5/spec/svg.js
1131
- "use strict";
1132
- Object.defineProperty(exports, "__esModule", { value: true });
1007
+ return Pointer;
1008
+ }(mirror_1.Mirror));
1009
+ exports.Pointer = Pointer;
1133
1010
 
1134
1011
 
1135
- // ./lib-es5/spec/react.js
1012
+ // ./lib-es5/models/listener.js
1136
1013
  "use strict";
1137
1014
  Object.defineProperty(exports, "__esModule", { value: true });
1015
+ exports.Listener = void 0;
1016
+ /**
1017
+ * Represent a listener for a model
1018
+ * @class Listener
1019
+ */
1020
+ var Listener = /** @class */ (function () {
1021
+ function Listener() {
1022
+ Object.defineProperties(this, {
1023
+ onAdded: {
1024
+ value: new Set,
1025
+ writable: false,
1026
+ configurable: false
1027
+ },
1028
+ onRemoved: {
1029
+ value: new Set,
1030
+ writable: false,
1031
+ configurable: false
1032
+ },
1033
+ frozen: {
1034
+ value: false,
1035
+ writable: true,
1036
+ configurable: false
1037
+ },
1038
+ queue: {
1039
+ value: [],
1040
+ writable: false,
1041
+ configurable: false
1042
+ }
1043
+ });
1044
+ }
1045
+ /**
1046
+ * Exclude the repeated operation in queue
1047
+ * @private
1048
+ */
1049
+ Listener.prototype.excludeRepeat = function (index) {
1050
+ var _this = this;
1051
+ this.queue.forEach(function (item, i) {
1052
+ if (item.index === index) {
1053
+ _this.queue.splice(i, 1);
1054
+ return true;
1055
+ }
1056
+ });
1057
+ return false;
1058
+ };
1059
+ /**
1060
+ * Emits added event to listeners
1061
+ * @param index {*} index of value
1062
+ * @param value {*} value of added item
1063
+ */
1064
+ Listener.prototype.emitAdded = function (index, value) {
1065
+ if (this.frozen) {
1066
+ if (!this.excludeRepeat(index)) {
1067
+ this.queue.push({ sign: true, index: index, value: value });
1068
+ }
1069
+ }
1070
+ else {
1071
+ this.onAdded.forEach(function (handler) {
1072
+ handler(index, value);
1073
+ });
1074
+ }
1075
+ };
1076
+ /**
1077
+ * Emits removed event to listeners
1078
+ * @param index {*} index of removed value
1079
+ * @param value {*} value of removed item
1080
+ */
1081
+ Listener.prototype.emitRemoved = function (index, value) {
1082
+ if (this.frozen) {
1083
+ if (!this.excludeRepeat(index)) {
1084
+ this.queue.push({ sign: false, index: index, value: value });
1085
+ }
1086
+ }
1087
+ else {
1088
+ this.onRemoved.forEach(function (handler) {
1089
+ handler(index, value);
1090
+ });
1091
+ }
1092
+ };
1093
+ /**
1094
+ * Adds a handler to added event
1095
+ * @param handler {function} function to run on event emitting
1096
+ */
1097
+ Listener.prototype.onAdd = function (handler) {
1098
+ this.onAdded.add(handler);
1099
+ };
1100
+ /**
1101
+ * Adds a handler to removed event
1102
+ * @param handler {function} function to run on event emitting
1103
+ */
1104
+ Listener.prototype.onRemove = function (handler) {
1105
+ this.onRemoved.add(handler);
1106
+ };
1107
+ /**
1108
+ * Removes an handler from added event
1109
+ * @param handler {function} handler to remove
1110
+ */
1111
+ Listener.prototype.offAdd = function (handler) {
1112
+ this.onAdded.delete(handler);
1113
+ };
1114
+ /**
1115
+ * Removes an handler form removed event
1116
+ * @param handler {function} handler to remove
1117
+ */
1118
+ Listener.prototype.offRemove = function (handler) {
1119
+ this.onRemoved.delete(handler);
1120
+ };
1121
+ /**
1122
+ * Run all queued operation and enable reactivity
1123
+ */
1124
+ Listener.prototype.enableReactivity = function () {
1125
+ var _this = this;
1126
+ this.queue.forEach(function (item) {
1127
+ if (item.sign) {
1128
+ _this.onAdded.forEach(function (handler) {
1129
+ handler(item.index, item.value);
1130
+ });
1131
+ }
1132
+ else {
1133
+ _this.onRemoved.forEach(function (handler) {
1134
+ handler(item.index, item.value);
1135
+ });
1136
+ }
1137
+ });
1138
+ this.queue.splice(0);
1139
+ this.frozen = false;
1140
+ };
1141
+ /**
1142
+ * Disable the reactivity and enable the queue
1143
+ */
1144
+ Listener.prototype.disableReactivity = function () {
1145
+ this.frozen = true;
1146
+ };
1147
+ return Listener;
1148
+ }());
1149
+ exports.Listener = Listener;
1138
1150
 
1139
1151
 
1140
- // ./lib-es5/spec/html.js
1152
+ // ./lib-es5/models/model.js
1141
1153
  "use strict";
1142
1154
  Object.defineProperty(exports, "__esModule", { value: true });
1143
1155
 
1144
1156
 
1145
- // ./lib-es5/value/expression.js
1157
+ // ./lib-es5/models/array-model.js
1146
1158
  "use strict";
1147
1159
  var __extends = (this && this.__extends) || (function () {
1148
1160
  var extendStatics = function (d, b) {
@@ -1159,109 +1171,257 @@ var __extends = (this && this.__extends) || (function () {
1159
1171
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1160
1172
  };
1161
1173
  })();
1174
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1175
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
1176
+ if (ar || !(i in from)) {
1177
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
1178
+ ar[i] = from[i];
1179
+ }
1180
+ }
1181
+ return to.concat(ar || Array.prototype.slice.call(from));
1182
+ };
1162
1183
  Object.defineProperty(exports, "__esModule", { value: true });
1163
- exports.Expression = void 0;
1164
- var reference_js_1 = require("./reference.js");
1165
- var ivalue_1 = require("../core/ivalue");
1184
+ exports.ArrayModel = void 0;
1185
+ var listener_1 = require("./listener");
1166
1186
  /**
1167
- * Bind some values to one expression
1168
- * @class Expression
1169
- * @extends IValue
1187
+ * Model based on Array class
1188
+ * @extends Array
1189
+ * @implements IModel
1170
1190
  */
1171
- var Expression = /** @class */ (function (_super) {
1172
- __extends(Expression, _super);
1191
+ var ArrayModel = /** @class */ (function (_super) {
1192
+ __extends(ArrayModel, _super);
1173
1193
  /**
1174
- * Creates a function bounded to N values
1175
- * @param func {Function} the function to bound
1176
- * @param values
1177
- * @param link {Boolean} links immediately if true
1194
+ * @param data {Array} input data
1178
1195
  */
1179
- function Expression(func, link) {
1180
- var values = [];
1181
- for (var _i = 2; _i < arguments.length; _i++) {
1182
- values[_i - 2] = arguments[_i];
1196
+ function ArrayModel(data) {
1197
+ if (data === void 0) { data = []; }
1198
+ var _this = this; _super.call(this);
1199
+ Object.defineProperty(_this, 'listener', {
1200
+ value: new listener_1.Listener,
1201
+ writable: false,
1202
+ configurable: false
1203
+ });
1204
+ for (var i = 0; i < data.length; i++) {
1205
+ _super.prototype.push.call(_this, data[i]);
1183
1206
  }
1184
- var _this = _super.call(this, false) || this;
1185
- /**
1186
- * Expression will link different handler for each value of list
1187
- */
1188
- _this.linkedFunc = [];
1189
- var handler = function (i) {
1190
- if (i != null) {
1191
- _this.valuesCache[i] = _this.values[i].$;
1192
- }
1193
- _this.sync.$ = func.apply(_this, _this.valuesCache);
1194
- };
1195
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1196
- // @ts-ignore
1197
- _this.valuesCache = values.map(function (item) { return item.$; });
1198
- _this.sync = new reference_js_1.Reference(func.apply(_this, _this.valuesCache));
1199
- var i = 0;
1200
- values.forEach(function () {
1201
- _this.linkedFunc.push(handler.bind(_this, Number(i++)));
1202
- });
1203
- _this.values = values;
1204
- _this.func = handler;
1205
- if (link) {
1206
- _this.$enable();
1207
- }
1208
- else {
1209
- handler();
1210
- }
1211
- _this.$seal();
1212
1207
  return _this;
1213
1208
  }
1214
- Object.defineProperty(Expression.prototype, "$", {
1209
+ Object.defineProperty(ArrayModel.prototype, "last", {
1210
+ /* Array members */
1211
+ /**
1212
+ * Gets the last item of array
1213
+ * @return {*} the last item of array
1214
+ */
1215
1215
  get: function () {
1216
- return this.sync.$;
1217
- },
1218
- set: function (value) {
1219
- this.sync.$ = value;
1216
+ return this.length ? this[this.length - 1] : null;
1220
1217
  },
1221
1218
  enumerable: false,
1222
1219
  configurable: true
1223
1220
  });
1224
- Expression.prototype.$on = function (handler) {
1225
- this.sync.$on(handler);
1221
+ /**
1222
+ * Calls Array.fill and notify about changes
1223
+ * @param value {*} value to fill with
1224
+ * @param start {?number} begin index
1225
+ * @param end {?number} end index
1226
+ */
1227
+ ArrayModel.prototype.fill = function (value, start, end) {
1228
+ if (!start) {
1229
+ start = 0;
1230
+ }
1231
+ if (!end) {
1232
+ end = this.length;
1233
+ }
1234
+ for (var i = start; i < end; i++) {
1235
+ this.listener.emitRemoved(this[i], this[i]);
1236
+ this[i] = value;
1237
+ this.listener.emitAdded(value, value);
1238
+ }
1226
1239
  return this;
1227
1240
  };
1228
- Expression.prototype.$off = function (handler) {
1229
- this.sync.$off(handler);
1230
- return this;
1241
+ /**
1242
+ * Calls Array.pop and notify about changes
1243
+ * @return {*} removed value
1244
+ */
1245
+ ArrayModel.prototype.pop = function () {
1246
+ var v = _super.prototype.pop.call(this);
1247
+ if (v !== undefined) {
1248
+ this.listener.emitRemoved(v, v);
1249
+ }
1250
+ return v;
1231
1251
  };
1232
- Expression.prototype.$enable = function () {
1233
- if (!this.isEnabled) {
1234
- for (var i = 0; i < this.values.length; i++) {
1235
- this.values[i].$on(this.linkedFunc[i]);
1236
- this.valuesCache[i] = this.values[i].$;
1252
+ /**
1253
+ * Calls Array.push and notify about changes
1254
+ * @param items {...*} values to push
1255
+ * @return {number} new length of array
1256
+ */
1257
+ ArrayModel.prototype.push = function () {
1258
+ var _this = this;
1259
+ var items = [];
1260
+ for (var _i = 0; _i < arguments.length; _i++) {
1261
+ items[_i] = arguments[_i];
1262
+ }
1263
+ items.forEach(function (item) {
1264
+ _this.listener.emitAdded(item, item);
1265
+ _super.prototype.push.call(_this, item);
1266
+ });
1267
+ return this.length;
1268
+ };
1269
+ /**
1270
+ * Calls Array.shift and notify about changed
1271
+ * @return {*} the shifted value
1272
+ */
1273
+ ArrayModel.prototype.shift = function () {
1274
+ var v = _super.prototype.shift.call(this);
1275
+ if (v !== undefined) {
1276
+ this.listener.emitRemoved(v, v);
1277
+ }
1278
+ return v;
1279
+ };
1280
+ /**
1281
+ * Calls Array.splice and notify about changed
1282
+ * @param start {number} start index
1283
+ * @param deleteCount {?number} delete count
1284
+ * @param items {...*}
1285
+ * @return {ArrayModel} a pointer to this
1286
+ */
1287
+ ArrayModel.prototype.splice = function (start, deleteCount) {
1288
+ var items = [];
1289
+ for (var _i = 2; _i < arguments.length; _i++) {
1290
+ items[_i - 2] = arguments[_i];
1291
+ }
1292
+ start = Math.min(start, this.length);
1293
+ deleteCount = deleteCount || this.length - start;
1294
+ var before = this[start + deleteCount];
1295
+ for (var i = 0; i < deleteCount; i++) {
1296
+ var index = start + deleteCount - i - 1;
1297
+ if (this[index] !== undefined) {
1298
+ this.listener.emitRemoved(this[index], this[index]);
1237
1299
  }
1238
- this.func();
1239
- this.isEnabled = true;
1240
1300
  }
1301
+ for (var i = 0; i < items.length; i++) {
1302
+ this.listener.emitAdded(before, items[i]);
1303
+ }
1304
+ return new ArrayModel(_super.prototype.splice.apply(this, __spreadArray([start, deleteCount], items, false)));
1305
+ };
1306
+ /**
1307
+ * Calls Array.unshift and notify about changed
1308
+ * @param items {...*} values to insert
1309
+ * @return {number} the length after prepend
1310
+ */
1311
+ ArrayModel.prototype.unshift = function () {
1312
+ var items = [];
1313
+ for (var _i = 0; _i < arguments.length; _i++) {
1314
+ items[_i] = arguments[_i];
1315
+ }
1316
+ for (var i = 0; i < items.length; i++) {
1317
+ this.listener.emitAdded(this[i], items[i]);
1318
+ }
1319
+ return _super.prototype.unshift.apply(this, items);
1320
+ };
1321
+ /**
1322
+ * Inserts a value to the end of array
1323
+ * @param v {*} value to insert
1324
+ */
1325
+ ArrayModel.prototype.append = function (v) {
1326
+ this.listener.emitAdded(null, v);
1327
+ _super.prototype.push.call(this, v);
1241
1328
  return this;
1242
1329
  };
1243
- Expression.prototype.$disable = function () {
1244
- if (this.isEnabled) {
1245
- for (var i = 0; i < this.values.length; i++) {
1246
- this.values[i].$off(this.linkedFunc[i]);
1247
- }
1248
- this.isEnabled = false;
1330
+ /**
1331
+ * Clears array
1332
+ * @return {this} a pointer to this
1333
+ */
1334
+ ArrayModel.prototype.clear = function () {
1335
+ var _this = this;
1336
+ this.forEach(function (v) {
1337
+ _this.listener.emitRemoved(v, v);
1338
+ });
1339
+ _super.prototype.splice.call(this, 0);
1340
+ return this;
1341
+ };
1342
+ /**
1343
+ * Inserts a value to position `index`
1344
+ * @param index {number} index to insert value
1345
+ * @param v {*} value to insert
1346
+ * @return {this} a pointer to this
1347
+ */
1348
+ ArrayModel.prototype.insert = function (index, v) {
1349
+ this.listener.emitAdded(this[index], v);
1350
+ _super.prototype.splice.call(this, index, 0, v);
1351
+ return this;
1352
+ };
1353
+ /**
1354
+ * Inserts a value to the beginning of array
1355
+ * @param v {*} value to insert
1356
+ * @return {this} a pointer to this
1357
+ */
1358
+ ArrayModel.prototype.prepend = function (v) {
1359
+ this.listener.emitAdded(this[0], v);
1360
+ _super.prototype.unshift.call(this, v);
1361
+ return this;
1362
+ };
1363
+ /**
1364
+ * Removes a value from an index
1365
+ * @param index {number} index of value to remove
1366
+ * @return {this} a pointer to this
1367
+ */
1368
+ ArrayModel.prototype.removeAt = function (index) {
1369
+ if (index > 0 && index < this.length) {
1370
+ this.listener.emitRemoved(this[index], this[index]);
1371
+ _super.prototype.splice.call(this, index, 1);
1249
1372
  }
1250
1373
  return this;
1251
1374
  };
1252
- Expression.prototype.$destroy = function () {
1253
- this.$disable();
1254
- this.values.splice(0);
1255
- this.valuesCache.splice(0);
1256
- this.linkedFunc.splice(0);
1257
- _super.prototype.$destroy.call(this);
1375
+ /**
1376
+ * Removes the first value of array
1377
+ * @return {this} a pointer to this
1378
+ */
1379
+ ArrayModel.prototype.removeFirst = function () {
1380
+ if (this.length) {
1381
+ this.listener.emitRemoved(this[0], this[0]);
1382
+ _super.prototype.shift.call(this);
1383
+ }
1384
+ return this;
1258
1385
  };
1259
- return Expression;
1260
- }(ivalue_1.IValue));
1261
- exports.Expression = Expression;
1386
+ /**
1387
+ * Removes the ast value of array
1388
+ * @return {this} a pointer to this
1389
+ */
1390
+ ArrayModel.prototype.removeLast = function () {
1391
+ var last = this.last;
1392
+ if (last != null) {
1393
+ this.listener.emitRemoved(this[this.length - 1], last);
1394
+ _super.prototype.pop.call(this);
1395
+ }
1396
+ return this;
1397
+ };
1398
+ /**
1399
+ * Remove the first occurrence of value
1400
+ * @param v {*} value to remove
1401
+ * @return {this}
1402
+ */
1403
+ ArrayModel.prototype.removeOne = function (v) {
1404
+ this.removeAt(this.indexOf(v));
1405
+ return this;
1406
+ };
1407
+ ArrayModel.prototype.replace = function (at, with_) {
1408
+ this.listener.emitAdded(this[at], with_);
1409
+ this.listener.emitRemoved(this[at], this[at]);
1410
+ this[at] = with_;
1411
+ return this;
1412
+ };
1413
+ ArrayModel.prototype.enableReactivity = function () {
1414
+ this.listener.enableReactivity();
1415
+ };
1416
+ ArrayModel.prototype.disableReactivity = function () {
1417
+ this.listener.disableReactivity();
1418
+ };
1419
+ return ArrayModel;
1420
+ }(Array));
1421
+ exports.ArrayModel = ArrayModel;
1262
1422
 
1263
1423
 
1264
- // ./lib-es5/value/reference.js
1424
+ // ./lib-es5/models/map-model.js
1265
1425
  "use strict";
1266
1426
  var __extends = (this && this.__extends) || (function () {
1267
1427
  var extendStatics = function (d, b) {
@@ -1279,70 +1439,83 @@ var __extends = (this && this.__extends) || (function () {
1279
1439
  };
1280
1440
  })();
1281
1441
  Object.defineProperty(exports, "__esModule", { value: true });
1282
- exports.Reference = void 0;
1283
- var ivalue_1 = require("../core/ivalue");
1442
+ exports.MapModel = void 0;
1443
+ var listener_1 = require("./listener");
1284
1444
  /**
1285
- * Declares a notifiable value
1286
- * @class Reference
1287
- * @extends IValue
1445
+ * A Map based memory
1446
+ * @class MapModel
1447
+ * @extends Map
1448
+ * @implements IModel
1288
1449
  */
1289
- var Reference = /** @class */ (function (_super) {
1290
- __extends(Reference, _super);
1450
+ var MapModel = /** @class */ (function (_super) {
1451
+ __extends(MapModel, _super);
1291
1452
  /**
1292
- * @param value {any} the initial value
1453
+ * Constructs a map model
1454
+ * @param map {[*, *][]} input data
1293
1455
  */
1294
- function Reference(value) {
1295
- var _this = _super.call(this, true) || this;
1296
- _this.$value = value;
1297
- _this.$onchange = new Set;
1298
- _this.$seal();
1456
+ function MapModel(map) {
1457
+ if (map === void 0) { map = []; }
1458
+ var _this = this; _super.call(this);
1459
+ Object.defineProperty(_this, 'listener', {
1460
+ value: new listener_1.Listener,
1461
+ writable: false,
1462
+ configurable: false
1463
+ });
1464
+ map.forEach(function (_a) {
1465
+ var key = _a[0], value = _a[1];
1466
+ _super.prototype.set.call(_this, key, value);
1467
+ });
1299
1468
  return _this;
1300
1469
  }
1301
- Object.defineProperty(Reference.prototype, "$", {
1302
- get: function () {
1303
- return this.$value;
1304
- },
1305
- set: function (value) {
1306
- if (this.$value !== value) {
1307
- this.$value = value;
1308
- if (this.isEnabled) {
1309
- this.$onchange.forEach(function (handler) {
1310
- handler(value);
1311
- });
1312
- }
1313
- }
1314
- },
1315
- enumerable: false,
1316
- configurable: true
1317
- });
1318
- Reference.prototype.$enable = function () {
1470
+ /**
1471
+ * Calls Map.clear and notify abut changes
1472
+ */
1473
+ MapModel.prototype.clear = function () {
1319
1474
  var _this = this;
1320
- if (!this.isEnabled) {
1321
- this.$onchange.forEach(function (handler) {
1322
- handler(_this.$value);
1323
- });
1324
- this.isEnabled = true;
1325
- }
1475
+ this.forEach(function (value, key) {
1476
+ _this.listener.emitRemoved(key, value);
1477
+ });
1478
+ _super.prototype.clear.call(this);
1326
1479
  };
1327
- Reference.prototype.$disable = function () {
1328
- this.isEnabled = false;
1480
+ /**
1481
+ * Calls Map.delete and notify abut changes
1482
+ * @param key {*} key
1483
+ * @return {boolean} true if removed something, otherwise false
1484
+ */
1485
+ MapModel.prototype.delete = function (key) {
1486
+ var tmp = _super.prototype.get.call(this, key);
1487
+ if (tmp) {
1488
+ this.listener.emitRemoved(key, tmp);
1489
+ }
1490
+ return _super.prototype.delete.call(this, key);
1329
1491
  };
1330
- Reference.prototype.$on = function (handler) {
1331
- this.$onchange.add(handler);
1492
+ /**
1493
+ * Calls Map.set and notify abut changes
1494
+ * @param key {*} key
1495
+ * @param value {*} value
1496
+ * @return {MapModel} a pointer to this
1497
+ */
1498
+ MapModel.prototype.set = function (key, value) {
1499
+ var tmp = _super.prototype.get.call(this, key);
1500
+ if (tmp) {
1501
+ this.listener.emitRemoved(key, tmp);
1502
+ }
1503
+ _super.prototype.set.call(this, key, value);
1504
+ this.listener.emitAdded(key, value);
1505
+ return this;
1332
1506
  };
1333
- Reference.prototype.$off = function (handler) {
1334
- this.$onchange.delete(handler);
1507
+ MapModel.prototype.enableReactivity = function () {
1508
+ this.listener.enableReactivity();
1335
1509
  };
1336
- Reference.prototype.$destroy = function () {
1337
- _super.prototype.$destroy.call(this);
1338
- this.$onchange.clear();
1510
+ MapModel.prototype.disableReactivity = function () {
1511
+ this.listener.disableReactivity();
1339
1512
  };
1340
- return Reference;
1341
- }(ivalue_1.IValue));
1342
- exports.Reference = Reference;
1513
+ return MapModel;
1514
+ }(Map));
1515
+ exports.MapModel = MapModel;
1343
1516
 
1344
1517
 
1345
- // ./lib-es5/value/mirror.js
1518
+ // ./lib-es5/models/object-model.js
1346
1519
  "use strict";
1347
1520
  var __extends = (this && this.__extends) || (function () {
1348
1521
  var extendStatics = function (d, b) {
@@ -1360,75 +1533,97 @@ var __extends = (this && this.__extends) || (function () {
1360
1533
  };
1361
1534
  })();
1362
1535
  Object.defineProperty(exports, "__esModule", { value: true });
1363
- exports.Mirror = void 0;
1364
- var reference_1 = require("./reference");
1536
+ exports.ObjectModel = void 0;
1537
+ var listener_1 = require("./listener");
1365
1538
  /**
1366
- * Declares a notifiable bind to a value
1367
- * @class Mirror
1368
- * @extends IValue
1369
- * @version 2
1539
+ * Object based model
1540
+ * @extends Object
1370
1541
  */
1371
- var Mirror = /** @class */ (function (_super) {
1372
- __extends(Mirror, _super);
1542
+ var ObjectModel = /** @class */ (function (_super) {
1543
+ __extends(ObjectModel, _super);
1373
1544
  /**
1374
- * Constructs a notifiable bind to a value
1375
- * @param value {IValue} is initial value
1376
- * @param forwardOnly {boolean} ensure forward only synchronization
1545
+ * Constructs a object model
1546
+ * @param obj {Object} input data
1377
1547
  */
1378
- function Mirror(value, forwardOnly) {
1379
- if (forwardOnly === void 0) { forwardOnly = false; }
1380
- var _this = _super.call(this, value.$) || this;
1381
- _this.$handler = function (v) {
1382
- _this.$ = v;
1383
- };
1384
- _this.$pointedValue = value;
1385
- _this.$forwardOnly = forwardOnly;
1386
- value.$on(_this.$handler);
1387
- _this.$seal();
1548
+ function ObjectModel(obj) {
1549
+ if (obj === void 0) { obj = {}; }
1550
+ var _this = this; _super.call(this);
1551
+ _this.container = Object.create(null);
1552
+ Object.defineProperty(_this, 'listener', {
1553
+ value: new listener_1.Listener,
1554
+ writable: false,
1555
+ configurable: false
1556
+ });
1557
+ for (var i in obj) {
1558
+ Object.defineProperty(_this.container, i, {
1559
+ value: obj[i],
1560
+ configurable: true,
1561
+ writable: true,
1562
+ enumerable: true
1563
+ });
1564
+ _this.listener.emitAdded(i, obj[i]);
1565
+ }
1388
1566
  return _this;
1389
1567
  }
1390
- Object.defineProperty(Mirror.prototype, "$", {
1568
+ /**
1569
+ * Gets a value of a field
1570
+ * @param key {string}
1571
+ * @return {*}
1572
+ */
1573
+ ObjectModel.prototype.get = function (key) {
1574
+ return this.container[key];
1575
+ };
1576
+ /**
1577
+ * Sets an object property value
1578
+ * @param key {string} property name
1579
+ * @param v {*} property value
1580
+ * @return {ObjectModel} a pointer to this
1581
+ */
1582
+ ObjectModel.prototype.set = function (key, v) {
1583
+ if (Reflect.has(this.container, key)) {
1584
+ this.listener.emitRemoved(key, this.container[key]);
1585
+ this.container[key] = v;
1586
+ }
1587
+ else {
1588
+ Object.defineProperty(this.container, key, {
1589
+ value: v,
1590
+ configurable: true,
1591
+ writable: true,
1592
+ enumerable: true
1593
+ });
1594
+ }
1595
+ this.listener.emitAdded(key, this.container[key]);
1596
+ return this;
1597
+ };
1598
+ Object.defineProperty(ObjectModel.prototype, "values", {
1391
1599
  get: function () {
1392
- // this is a ts bug
1393
- // eslint-disable-next-line
1394
- // @ts-ignore
1395
- return _super.prototype.$;
1396
- },
1397
- set: function (v) {
1398
- if (!this.$forwardOnly) {
1399
- this.$pointedValue.$ = v;
1400
- }
1401
- // this is a ts bug
1402
- // eslint-disable-next-line
1403
- // @ts-ignore
1404
- _super.prototype.$ = v;
1600
+ return this.container;
1405
1601
  },
1406
1602
  enumerable: false,
1407
1603
  configurable: true
1408
1604
  });
1409
- Mirror.prototype.$enable = function () {
1410
- if (!this.isEnabled) {
1411
- this.isEnabled = true;
1412
- this.$pointedValue.$on(this.$handler);
1413
- this.$ = this.$pointedValue.$;
1605
+ /**
1606
+ * Deletes an object property
1607
+ * @param key {string} property name
1608
+ */
1609
+ ObjectModel.prototype.delete = function (key) {
1610
+ if (this.container[key]) {
1611
+ this.listener.emitRemoved(key, this.container[key]);
1612
+ delete this.container[key];
1414
1613
  }
1415
1614
  };
1416
- Mirror.prototype.$disable = function () {
1417
- if (this.isEnabled) {
1418
- this.$pointedValue.$off(this.$handler);
1419
- this.isEnabled = false;
1420
- }
1615
+ ObjectModel.prototype.enableReactivity = function () {
1616
+ this.listener.enableReactivity();
1421
1617
  };
1422
- Mirror.prototype.$destroy = function () {
1423
- this.$disable();
1424
- _super.prototype.$destroy.call(this);
1618
+ ObjectModel.prototype.disableReactivity = function () {
1619
+ this.listener.disableReactivity();
1425
1620
  };
1426
- return Mirror;
1427
- }(reference_1.Reference));
1428
- exports.Mirror = Mirror;
1621
+ return ObjectModel;
1622
+ }(Object));
1623
+ exports.ObjectModel = ObjectModel;
1429
1624
 
1430
1625
 
1431
- // ./lib-es5/value/pointer.js
1626
+ // ./lib-es5/models/set-model.js
1432
1627
  "use strict";
1433
1628
  var __extends = (this && this.__extends) || (function () {
1434
1629
  var extendStatics = function (d, b) {
@@ -1446,41 +1641,90 @@ var __extends = (this && this.__extends) || (function () {
1446
1641
  };
1447
1642
  })();
1448
1643
  Object.defineProperty(exports, "__esModule", { value: true });
1449
- exports.Pointer = void 0;
1450
- var mirror_1 = require("./mirror");
1644
+ exports.SetModel = void 0;
1645
+ var listener_1 = require("./listener");
1451
1646
  /**
1452
- * r/w pointer to a value
1453
- * @class Pointer
1454
- * @extends Mirror
1647
+ * A Set based model
1648
+ * @class SetModel
1649
+ * @extends Set
1650
+ * @implements IModel
1455
1651
  */
1456
- var Pointer = /** @class */ (function (_super) {
1457
- __extends(Pointer, _super);
1652
+ var SetModel = /** @class */ (function (_super) {
1653
+ __extends(SetModel, _super);
1458
1654
  /**
1459
- * @param value {IValue} value to point
1460
- * @param forwardOnly {boolean} forward only data flow
1655
+ * Constructs a set model based on a set
1656
+ * @param set {Set} input data
1461
1657
  */
1462
- function Pointer(value, forwardOnly) {
1463
- if (forwardOnly === void 0) { forwardOnly = false; }
1464
- return _super.call(this, value, forwardOnly) || this;
1658
+ function SetModel(set) {
1659
+ if (set === void 0) { set = []; }
1660
+ var _this = this; _super.call(this);
1661
+ Object.defineProperty(_this, 'listener', {
1662
+ value: new listener_1.Listener,
1663
+ writable: false,
1664
+ configurable: false
1665
+ });
1666
+ set.forEach(function (item) {
1667
+ _super.prototype.add.call(_this, item);
1668
+ });
1669
+ return _this;
1465
1670
  }
1466
- Object.defineProperty(Pointer.prototype, "$$", {
1467
- /**
1468
- * Point a new ivalue
1469
- * @param value {IValue} value to point
1470
- */
1471
- set: function (value) {
1472
- if (this.$pointedValue !== value) {
1473
- this.$disable();
1474
- this.$pointedValue = value;
1475
- this.$enable();
1476
- }
1477
- },
1478
- enumerable: false,
1479
- configurable: true
1480
- });
1481
- return Pointer;
1482
- }(mirror_1.Mirror));
1483
- exports.Pointer = Pointer;
1671
+ /**
1672
+ * Calls Set.add and notify abut changes
1673
+ * @param value {*} value
1674
+ * @return {this} a pointer to this
1675
+ */
1676
+ SetModel.prototype.add = function (value) {
1677
+ if (!_super.prototype.has.call(this, value)) {
1678
+ this.listener.emitAdded(value, value);
1679
+ _super.prototype.add.call(this, value);
1680
+ }
1681
+ return this;
1682
+ };
1683
+ /**
1684
+ * Calls Set.clear and notify abut changes
1685
+ */
1686
+ SetModel.prototype.clear = function () {
1687
+ var _this = this;
1688
+ this.forEach(function (item) {
1689
+ _this.listener.emitRemoved(item, item);
1690
+ });
1691
+ _super.prototype.clear.call(this);
1692
+ };
1693
+ /**
1694
+ * Calls Set.delete and notify abut changes
1695
+ * @param value {*}
1696
+ * @return {boolean} true if a value was deleted, otherwise false
1697
+ */
1698
+ SetModel.prototype.delete = function (value) {
1699
+ if (_super.prototype.has.call(this, value)) {
1700
+ this.listener.emitRemoved(value, value);
1701
+ }
1702
+ return _super.prototype.delete.call(this, value);
1703
+ };
1704
+ SetModel.prototype.enableReactivity = function () {
1705
+ this.listener.enableReactivity();
1706
+ };
1707
+ SetModel.prototype.disableReactivity = function () {
1708
+ this.listener.disableReactivity();
1709
+ };
1710
+ return SetModel;
1711
+ }(Set));
1712
+ exports.SetModel = SetModel;
1713
+
1714
+
1715
+ // ./lib-es5/spec/html.js
1716
+ "use strict";
1717
+ Object.defineProperty(exports, "__esModule", { value: true });
1718
+
1719
+
1720
+ // ./lib-es5/spec/svg.js
1721
+ "use strict";
1722
+ Object.defineProperty(exports, "__esModule", { value: true });
1723
+
1724
+
1725
+ // ./lib-es5/spec/react.js
1726
+ "use strict";
1727
+ Object.defineProperty(exports, "__esModule", { value: true });
1484
1728
 
1485
1729
 
1486
1730
  // ./lib-es5/binding/binding.js
@@ -1537,7 +1781,7 @@ var Binding = /** @class */ (function (_super) {
1537
1781
  exports.Binding = Binding;
1538
1782
 
1539
1783
 
1540
- // ./lib-es5/core/core.js
1784
+ // ./lib-es5/binding/attribute.js
1541
1785
  "use strict";
1542
1786
  var __extends = (this && this.__extends) || (function () {
1543
1787
  var extendStatics = function (d, b) {
@@ -1554,281 +1798,163 @@ var __extends = (this && this.__extends) || (function () {
1554
1798
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1555
1799
  };
1556
1800
  })();
1557
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1558
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
1559
- if (ar || !(i in from)) {
1560
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
1561
- ar[i] = from[i];
1562
- }
1563
- }
1564
- return to.concat(ar || Array.prototype.slice.call(from));
1565
- };
1566
1801
  Object.defineProperty(exports, "__esModule", { value: true });
1567
- exports.Reactive = exports.ReactivePrivate = exports.current = void 0;
1568
- var destroyable_js_1 = require("./destroyable.js");
1569
- var errors_1 = require("./errors");
1570
- var expression_1 = require("../value/expression");
1571
- var reference_1 = require("../value/reference");
1572
- var pointer_1 = require("../value/pointer");
1573
- var mirror_1 = require("../value/mirror");
1574
- exports.current = null;
1575
- var currentStack = [];
1576
- function stack(node) {
1577
- currentStack.push(exports.current);
1578
- exports.current = node;
1579
- }
1580
- function unstack() {
1581
- exports.current = currentStack.pop();
1582
- }
1802
+ exports.AttributeBinding = void 0;
1803
+ var binding_1 = require("./binding");
1583
1804
  /**
1584
- * Private stuff of a reactive object
1585
- * @class ReactivePrivate
1586
- * @extends Destroyable
1805
+ * Represents an Attribute binding description
1806
+ * @class AttributeBinding
1807
+ * @extends Binding
1587
1808
  */
1588
- var ReactivePrivate = /** @class */ (function (_super) {
1589
- __extends(ReactivePrivate, _super);
1590
- function ReactivePrivate() {
1591
- var _this = this; _super.call(this);
1592
- /**
1593
- * A list of user-defined values
1594
- * @type {Set}
1595
- */
1596
- _this.watch = new Set;
1597
- /**
1598
- * A list of user-defined bindings
1599
- * @type {Set}
1600
- */
1601
- _this.bindings = new Set;
1602
- /**
1603
- * A list of user defined models
1604
- */
1605
- _this.models = new Set;
1606
- /**
1607
- * Reactivity switch state
1608
- * @type {boolean}
1609
- */
1610
- _this.enabled = true;
1611
- /**
1612
- * The frozen state of object
1613
- * @type {boolean}
1614
- */
1615
- _this.frozen = false;
1809
+ var AttributeBinding = /** @class */ (function (_super) {
1810
+ __extends(AttributeBinding, _super);
1811
+ /**
1812
+ * Constructs an attribute binding description
1813
+ * @param node {INode} the vasille node
1814
+ * @param name {String} the name of attribute
1815
+ * @param value {IValue} value to bind
1816
+ */
1817
+ function AttributeBinding(node, name, value) {
1818
+ var _this = _super.call(this, value) || this;
1819
+ _this.init(function (value) {
1820
+ if (value) {
1821
+ if (typeof value === 'boolean') {
1822
+ node.node.setAttribute(name, "");
1823
+ }
1824
+ else {
1825
+ node.node.setAttribute(name, "".concat(value));
1826
+ }
1827
+ }
1828
+ else {
1829
+ node.node.removeAttribute(name);
1830
+ }
1831
+ });
1616
1832
  _this.$seal();
1617
1833
  return _this;
1618
1834
  }
1619
- ReactivePrivate.prototype.$destroy = function () {
1620
- this.watch.forEach(function (value) { return value.$destroy(); });
1621
- this.watch.clear();
1622
- this.bindings.forEach(function (binding) { return binding.$destroy(); });
1623
- this.bindings.clear();
1624
- this.models.forEach(function (model) { return model.disableReactivity(); });
1625
- this.models.clear();
1626
- this.freezeExpr && this.freezeExpr.$destroy();
1627
- this.onDestroy && this.onDestroy();
1628
- _super.prototype.$destroy.call(this);
1835
+ return AttributeBinding;
1836
+ }(binding_1.Binding));
1837
+ exports.AttributeBinding = AttributeBinding;
1838
+
1839
+
1840
+ // ./lib-es5/binding/class.js
1841
+ "use strict";
1842
+ var __extends = (this && this.__extends) || (function () {
1843
+ var extendStatics = function (d, b) {
1844
+ extendStatics = Object.setPrototypeOf ||
1845
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1846
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
1847
+ return extendStatics(d, b);
1629
1848
  };
1630
- return ReactivePrivate;
1631
- }(destroyable_js_1.Destroyable));
1632
- exports.ReactivePrivate = ReactivePrivate;
1633
- /**
1634
- * A reactive object
1635
- * @class Reactive
1636
- * @extends Destroyable
1637
- */
1638
- var Reactive = /** @class */ (function (_super) {
1639
- __extends(Reactive, _super);
1640
- function Reactive(input, $) {
1641
- var _this = this; _super.call(this);
1642
- _this.input = input;
1643
- _this.$ = $ || new ReactivePrivate;
1849
+ return function (d, b) {
1850
+ if (typeof b !== "function" && b !== null)
1851
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1852
+ extendStatics(d, b);
1853
+ function __() { this.constructor = d; }
1854
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1855
+ };
1856
+ })();
1857
+ Object.defineProperty(exports, "__esModule", { value: true });
1858
+ exports.DynamicalClassBinding = exports.StaticClassBinding = void 0;
1859
+ var binding_1 = require("./binding");
1860
+ function addClass(node, cl) {
1861
+ node.node.classList.add(cl);
1862
+ }
1863
+ function removeClass(node, cl) {
1864
+ node.node.classList.remove(cl);
1865
+ }
1866
+ var StaticClassBinding = /** @class */ (function (_super) {
1867
+ __extends(StaticClassBinding, _super);
1868
+ function StaticClassBinding(node, name, value) {
1869
+ var _this = _super.call(this, value) || this;
1870
+ _this.current = false;
1871
+ _this.init(function (value) {
1872
+ if (value !== _this.current) {
1873
+ if (value) {
1874
+ addClass(node, name);
1875
+ }
1876
+ else {
1877
+ removeClass(node, name);
1878
+ }
1879
+ _this.current = value;
1880
+ }
1881
+ });
1644
1882
  _this.$seal();
1645
1883
  return _this;
1646
1884
  }
1647
- Object.defineProperty(Reactive.prototype, "parent", {
1648
- /**
1649
- * Get parent node
1650
- */
1651
- get: function () {
1652
- return this.$.parent;
1653
- },
1654
- enumerable: false,
1655
- configurable: true
1656
- });
1657
- /**
1658
- * Create a reference
1659
- * @param value {*} value to reference
1660
- */
1661
- Reactive.prototype.ref = function (value) {
1662
- var $ = this.$;
1663
- var ref = new reference_1.Reference(value);
1664
- $.watch.add(ref);
1665
- return ref;
1666
- };
1667
- /**
1668
- * Create a mirror
1669
- * @param value {IValue} value to mirror
1670
- */
1671
- Reactive.prototype.mirror = function (value) {
1672
- var mirror = new mirror_1.Mirror(value, false);
1673
- this.$.watch.add(mirror);
1674
- return mirror;
1675
- };
1676
- /**
1677
- * Create a forward-only mirror
1678
- * @param value {IValue} value to mirror
1679
- */
1680
- Reactive.prototype.forward = function (value) {
1681
- var mirror = new mirror_1.Mirror(value, true);
1682
- this.$.watch.add(mirror);
1683
- return mirror;
1684
- };
1685
- /**
1686
- * Creates a pointer
1687
- * @param value {*} default value to point
1688
- * @param forwardOnly {boolean} forward only sync
1689
- */
1690
- Reactive.prototype.point = function (value, forwardOnly) {
1691
- if (forwardOnly === void 0) { forwardOnly = false; }
1692
- var $ = this.$;
1693
- var pointer = new pointer_1.Pointer(value, forwardOnly);
1694
- $.watch.add(pointer);
1695
- return pointer;
1696
- };
1697
- /**
1698
- * Register a model
1699
- * @param model
1700
- */
1701
- Reactive.prototype.register = function (model) {
1702
- this.$.models.add(model);
1703
- return model;
1704
- };
1705
- /**
1706
- * Creates a watcher
1707
- * @param func {function} function to run on any argument change
1708
- * @param values
1709
- */
1710
- Reactive.prototype.watch = function (func) {
1711
- var values = [];
1712
- for (var _i = 1; _i < arguments.length; _i++) {
1713
- values[_i - 1] = arguments[_i];
1714
- }
1715
- var $ = this.$;
1716
- $.watch.add(new (expression_1.Expression.bind.apply(expression_1.Expression, __spreadArray([void 0, func, !this.$.frozen], values, false)))());
1717
- };
1718
- /**
1719
- * Creates a computed value
1720
- * @param func {function} function to run on any argument change
1721
- * @param values
1722
- * @return {IValue} the created ivalue
1723
- */
1724
- Reactive.prototype.expr = function (func) {
1725
- var values = [];
1726
- for (var _i = 1; _i < arguments.length; _i++) {
1727
- values[_i - 1] = arguments[_i];
1728
- }
1729
- var res = new (expression_1.Expression.bind.apply(expression_1.Expression, __spreadArray([void 0, func, !this.$.frozen], values, false)))();
1730
- var $ = this.$;
1731
- $.watch.add(res);
1732
- return res;
1733
- };
1734
- /**
1735
- * Enable reactivity of fields
1736
- */
1737
- Reactive.prototype.enable = function () {
1738
- var $ = this.$;
1739
- if (!$.enabled) {
1740
- $.watch.forEach(function (watcher) {
1741
- watcher.$enable();
1742
- });
1743
- $.models.forEach(function (model) {
1744
- model.enableReactivity();
1745
- });
1746
- $.enabled = true;
1747
- }
1885
+ return StaticClassBinding;
1886
+ }(binding_1.Binding));
1887
+ exports.StaticClassBinding = StaticClassBinding;
1888
+ var DynamicalClassBinding = /** @class */ (function (_super) {
1889
+ __extends(DynamicalClassBinding, _super);
1890
+ function DynamicalClassBinding(node, value) {
1891
+ var _this = _super.call(this, value) || this;
1892
+ _this.current = "";
1893
+ _this.init(function (value) {
1894
+ if (_this.current != value) {
1895
+ if (_this.current.length) {
1896
+ removeClass(node, _this.current);
1897
+ }
1898
+ if (value.length) {
1899
+ addClass(node, value);
1900
+ }
1901
+ _this.current = value;
1902
+ }
1903
+ });
1904
+ _this.$seal();
1905
+ return _this;
1906
+ }
1907
+ return DynamicalClassBinding;
1908
+ }(binding_1.Binding));
1909
+ exports.DynamicalClassBinding = DynamicalClassBinding;
1910
+
1911
+
1912
+ // ./lib-es5/binding/style.js
1913
+ "use strict";
1914
+ var __extends = (this && this.__extends) || (function () {
1915
+ var extendStatics = function (d, b) {
1916
+ extendStatics = Object.setPrototypeOf ||
1917
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1918
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
1919
+ return extendStatics(d, b);
1748
1920
  };
1749
- /**
1750
- * Disable reactivity of fields
1751
- */
1752
- Reactive.prototype.disable = function () {
1753
- var $ = this.$;
1754
- if ($.enabled) {
1755
- $.watch.forEach(function (watcher) {
1756
- watcher.$disable();
1757
- });
1758
- $.models.forEach(function (model) {
1759
- model.disableReactivity();
1760
- });
1761
- $.enabled = false;
1762
- }
1921
+ return function (d, b) {
1922
+ if (typeof b !== "function" && b !== null)
1923
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1924
+ extendStatics(d, b);
1925
+ function __() { this.constructor = d; }
1926
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1763
1927
  };
1928
+ })();
1929
+ Object.defineProperty(exports, "__esModule", { value: true });
1930
+ exports.StyleBinding = void 0;
1931
+ var binding_1 = require("./binding");
1932
+ /**
1933
+ * Describes a style attribute binding
1934
+ * @class StyleBinding
1935
+ * @extends Binding
1936
+ */
1937
+ var StyleBinding = /** @class */ (function (_super) {
1938
+ __extends(StyleBinding, _super);
1764
1939
  /**
1765
- * Disable/Enable reactivity of object fields with feedback
1766
- * @param cond {IValue} show condition
1767
- * @param onOff {function} on show feedback
1768
- * @param onOn {function} on hide feedback
1940
+ * Constructs a style binding attribute
1941
+ * @param node {INode} the vasille node
1942
+ * @param name {string} the name of style property
1943
+ * @param value {IValue} the value to bind
1769
1944
  */
1770
- Reactive.prototype.bindAlive = function (cond, onOff, onOn) {
1771
- var _this = this;
1772
- var $ = this.$;
1773
- if ($.freezeExpr) {
1774
- throw (0, errors_1.wrongBinding)("this component already have a freeze state");
1775
- }
1776
- if ($.watch.has(cond)) {
1777
- throw (0, errors_1.wrongBinding)("freeze state must be bound to an external component");
1778
- }
1779
- $.freezeExpr = new expression_1.Expression(function (cond) {
1780
- $.frozen = !cond;
1781
- if (cond) {
1782
- onOn === null || onOn === void 0 ? void 0 : onOn();
1783
- _this.enable();
1784
- }
1785
- else {
1786
- onOff === null || onOff === void 0 ? void 0 : onOff();
1787
- _this.disable();
1945
+ function StyleBinding(node, name, value) {
1946
+ var _this = _super.call(this, value) || this;
1947
+ _this.init(function (value) {
1948
+ if (node.node instanceof HTMLElement) {
1949
+ node.node.style.setProperty(name, value);
1788
1950
  }
1789
- }, true, cond);
1790
- return this;
1791
- };
1792
- Reactive.prototype.init = function () {
1793
- this.applyOptions(this.input);
1794
- return this.compose(this.input);
1795
- };
1796
- Reactive.prototype.applyOptions = function (input) {
1797
- // empty
1798
- };
1799
- Reactive.prototype.applyOptionsNow = function () {
1800
- this.applyOptions(this.input);
1801
- };
1802
- Reactive.prototype.compose = function (input) {
1803
- throw (0, errors_1.notOverwritten)();
1804
- };
1805
- Reactive.prototype.composeNow = function () {
1806
- this.compose(this.input);
1807
- };
1808
- Reactive.prototype.runFunctional = function (f) {
1809
- var args = [];
1810
- for (var _i = 1; _i < arguments.length; _i++) {
1811
- args[_i - 1] = arguments[_i];
1812
- }
1813
- stack(this);
1814
- // yet another ts bug
1815
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1816
- // @ts-ignore
1817
- var result = f.apply(void 0, args);
1818
- unstack();
1819
- return result;
1820
- };
1821
- Reactive.prototype.runOnDestroy = function (func) {
1822
- this.$.onDestroy = func;
1823
- };
1824
- Reactive.prototype.$destroy = function () {
1825
- _super.prototype.$destroy.call(this);
1826
- this.$.$destroy();
1827
- this.$ = null;
1828
- };
1829
- return Reactive;
1830
- }(destroyable_js_1.Destroyable));
1831
- exports.Reactive = Reactive;
1951
+ });
1952
+ _this.$seal();
1953
+ return _this;
1954
+ }
1955
+ return StyleBinding;
1956
+ }(binding_1.Binding));
1957
+ exports.StyleBinding = StyleBinding;
1832
1958
 
1833
1959
 
1834
1960
  // ./lib-es5/node/node.js
@@ -2023,7 +2149,9 @@ var Fragment = /** @class */ (function (_super) {
2023
2149
  * @param input
2024
2150
  * @param cb {function(Tag, *)} callback
2025
2151
  */
2026
- Fragment.prototype.tag = function (tagName, input, cb) {
2152
+ Fragment.prototype.tag = function (tagName, input, cb
2153
+ // @ts-ignore
2154
+ ) {
2027
2155
  var $ = this.$;
2028
2156
  var node = new Tag(input);
2029
2157
  input.slot = cb || input.slot;
@@ -2031,6 +2159,7 @@ var Fragment = /** @class */ (function (_super) {
2031
2159
  node.init();
2032
2160
  this.pushNode(node);
2033
2161
  node.ready();
2162
+ // @ts-ignore
2034
2163
  return node.node;
2035
2164
  };
2036
2165
  /**
@@ -2775,276 +2904,66 @@ var DebugNode = /** @class */ (function (_super) {
2775
2904
  var $ = this.$;
2776
2905
  if (!text) {
2777
2906
  throw (0, errors_1.internalError)('wrong DebugNode::$preninit call');
2778
- }
2779
- $.preinitComment(app, parent, text);
2780
- };
2781
- /**
2782
- * Runs garbage collector
2783
- */
2784
- DebugNode.prototype.$destroy = function () {
2785
- this.$.$destroy();
2786
- _super.prototype.$destroy.call(this);
2787
- };
2788
- return DebugNode;
2789
- }(Fragment));
2790
- exports.DebugNode = DebugNode;
2791
-
2792
-
2793
- // ./lib-es5/node/app.js
2794
- "use strict";
2795
- var __extends = (this && this.__extends) || (function () {
2796
- var extendStatics = function (d, b) {
2797
- extendStatics = Object.setPrototypeOf ||
2798
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
2799
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
2800
- return extendStatics(d, b);
2801
- };
2802
- return function (d, b) {
2803
- if (typeof b !== "function" && b !== null)
2804
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2805
- extendStatics(d, b);
2806
- function __() { this.constructor = d; }
2807
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2808
- };
2809
- })();
2810
- Object.defineProperty(exports, "__esModule", { value: true });
2811
- exports.Portal = exports.App = exports.AppNode = void 0;
2812
- var node_1 = require("./node");
2813
- /**
2814
- * Application Node
2815
- * @class AppNode
2816
- * @extends INode
2817
- */
2818
- var AppNode = /** @class */ (function (_super) {
2819
- __extends(AppNode, _super);
2820
- /**
2821
- * @param input
2822
- */
2823
- function AppNode(input) {
2824
- var _this = _super.call(this, input) || this;
2825
- _this.debugUi = input.debugUi || false;
2826
- _this.$seal();
2827
- return _this;
2828
- }
2829
- return AppNode;
2830
- }(node_1.INode));
2831
- exports.AppNode = AppNode;
2832
- /**
2833
- * Represents a Vasille.js application
2834
- * @class App
2835
- * @extends AppNode
2836
- */
2837
- var App = /** @class */ (function (_super) {
2838
- __extends(App, _super);
2839
- /**
2840
- * Constructs an app node
2841
- * @param node {Element} The root of application
2842
- * @param input
2843
- */
2844
- function App(node, input) {
2845
- var _this = _super.call(this, input) || this;
2846
- _this.$.node = node;
2847
- _this.preinit(_this, _this);
2848
- _this.init();
2849
- _this.$seal();
2850
- return _this;
2851
- }
2852
- App.prototype.appendNode = function (node) {
2853
- this.$.node.appendChild(node);
2854
- };
2855
- return App;
2856
- }(AppNode));
2857
- exports.App = App;
2858
- var Portal = /** @class */ (function (_super) {
2859
- __extends(Portal, _super);
2860
- function Portal(input) {
2861
- var _this = _super.call(this, input) || this;
2862
- _this.$.node = input.node;
2863
- _this.$seal();
2864
- return _this;
2865
- }
2866
- Portal.prototype.appendNode = function (node) {
2867
- this.$.node.appendChild(node);
2868
- };
2869
- return Portal;
2870
- }(AppNode));
2871
- exports.Portal = Portal;
2872
-
2873
-
2874
- // ./lib-es5/binding/attribute.js
2875
- "use strict";
2876
- var __extends = (this && this.__extends) || (function () {
2877
- var extendStatics = function (d, b) {
2878
- extendStatics = Object.setPrototypeOf ||
2879
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
2880
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
2881
- return extendStatics(d, b);
2882
- };
2883
- return function (d, b) {
2884
- if (typeof b !== "function" && b !== null)
2885
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2886
- extendStatics(d, b);
2887
- function __() { this.constructor = d; }
2888
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2889
- };
2890
- })();
2891
- Object.defineProperty(exports, "__esModule", { value: true });
2892
- exports.AttributeBinding = void 0;
2893
- var binding_1 = require("./binding");
2894
- /**
2895
- * Represents an Attribute binding description
2896
- * @class AttributeBinding
2897
- * @extends Binding
2898
- */
2899
- var AttributeBinding = /** @class */ (function (_super) {
2900
- __extends(AttributeBinding, _super);
2901
- /**
2902
- * Constructs an attribute binding description
2903
- * @param node {INode} the vasille node
2904
- * @param name {String} the name of attribute
2905
- * @param value {IValue} value to bind
2906
- */
2907
- function AttributeBinding(node, name, value) {
2908
- var _this = _super.call(this, value) || this;
2909
- _this.init(function (value) {
2910
- if (value) {
2911
- if (typeof value === 'boolean') {
2912
- node.node.setAttribute(name, "");
2913
- }
2914
- else {
2915
- node.node.setAttribute(name, "".concat(value));
2916
- }
2917
- }
2918
- else {
2919
- node.node.removeAttribute(name);
2920
- }
2921
- });
2922
- _this.$seal();
2923
- return _this;
2924
- }
2925
- return AttributeBinding;
2926
- }(binding_1.Binding));
2927
- exports.AttributeBinding = AttributeBinding;
2928
-
2929
-
2930
- // ./lib-es5/binding/style.js
2931
- "use strict";
2932
- var __extends = (this && this.__extends) || (function () {
2933
- var extendStatics = function (d, b) {
2934
- extendStatics = Object.setPrototypeOf ||
2935
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
2936
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
2937
- return extendStatics(d, b);
2938
- };
2939
- return function (d, b) {
2940
- if (typeof b !== "function" && b !== null)
2941
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2942
- extendStatics(d, b);
2943
- function __() { this.constructor = d; }
2944
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2945
- };
2946
- })();
2947
- Object.defineProperty(exports, "__esModule", { value: true });
2948
- exports.StyleBinding = void 0;
2949
- var binding_1 = require("./binding");
2950
- /**
2951
- * Describes a style attribute binding
2952
- * @class StyleBinding
2953
- * @extends Binding
2954
- */
2955
- var StyleBinding = /** @class */ (function (_super) {
2956
- __extends(StyleBinding, _super);
2957
- /**
2958
- * Constructs a style binding attribute
2959
- * @param node {INode} the vasille node
2960
- * @param name {string} the name of style property
2961
- * @param value {IValue} the value to bind
2962
- */
2963
- function StyleBinding(node, name, value) {
2964
- var _this = _super.call(this, value) || this;
2965
- _this.init(function (value) {
2966
- if (node.node instanceof HTMLElement) {
2967
- node.node.style.setProperty(name, value);
2968
- }
2969
- });
2970
- _this.$seal();
2971
- return _this;
2972
- }
2973
- return StyleBinding;
2974
- }(binding_1.Binding));
2975
- exports.StyleBinding = StyleBinding;
2976
-
2977
-
2978
- // ./lib-es5/binding/class.js
2979
- "use strict";
2980
- var __extends = (this && this.__extends) || (function () {
2981
- var extendStatics = function (d, b) {
2982
- extendStatics = Object.setPrototypeOf ||
2983
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
2984
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
2985
- return extendStatics(d, b);
2986
- };
2987
- return function (d, b) {
2988
- if (typeof b !== "function" && b !== null)
2989
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2990
- extendStatics(d, b);
2991
- function __() { this.constructor = d; }
2992
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2993
- };
2994
- })();
2995
- Object.defineProperty(exports, "__esModule", { value: true });
2996
- exports.DynamicalClassBinding = exports.StaticClassBinding = void 0;
2997
- var binding_1 = require("./binding");
2998
- function addClass(node, cl) {
2999
- node.node.classList.add(cl);
3000
- }
3001
- function removeClass(node, cl) {
3002
- node.node.classList.remove(cl);
3003
- }
3004
- var StaticClassBinding = /** @class */ (function (_super) {
3005
- __extends(StaticClassBinding, _super);
3006
- function StaticClassBinding(node, name, value) {
3007
- var _this = _super.call(this, value) || this;
3008
- _this.current = false;
3009
- _this.init(function (value) {
3010
- if (value !== _this.current) {
3011
- if (value) {
3012
- addClass(node, name);
3013
- }
3014
- else {
3015
- removeClass(node, name);
3016
- }
3017
- _this.current = value;
3018
- }
3019
- });
3020
- _this.$seal();
3021
- return _this;
3022
- }
3023
- return StaticClassBinding;
3024
- }(binding_1.Binding));
3025
- exports.StaticClassBinding = StaticClassBinding;
3026
- var DynamicalClassBinding = /** @class */ (function (_super) {
3027
- __extends(DynamicalClassBinding, _super);
3028
- function DynamicalClassBinding(node, value) {
3029
- var _this = _super.call(this, value) || this;
3030
- _this.current = "";
3031
- _this.init(function (value) {
3032
- if (_this.current != value) {
3033
- if (_this.current.length) {
3034
- removeClass(node, _this.current);
3035
- }
3036
- if (value.length) {
3037
- addClass(node, value);
3038
- }
3039
- _this.current = value;
3040
- }
3041
- });
3042
- _this.$seal();
3043
- return _this;
2907
+ }
2908
+ $.preinitComment(app, parent, text);
2909
+ };
2910
+ /**
2911
+ * Runs garbage collector
2912
+ */
2913
+ DebugNode.prototype.$destroy = function () {
2914
+ this.$.$destroy();
2915
+ _super.prototype.$destroy.call(this);
2916
+ };
2917
+ return DebugNode;
2918
+ }(Fragment));
2919
+ exports.DebugNode = DebugNode;
2920
+
2921
+
2922
+ // ./lib-es5/node/watch.js
2923
+ "use strict";
2924
+ var __extends = (this && this.__extends) || (function () {
2925
+ var extendStatics = function (d, b) {
2926
+ extendStatics = Object.setPrototypeOf ||
2927
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
2928
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
2929
+ return extendStatics(d, b);
2930
+ };
2931
+ return function (d, b) {
2932
+ if (typeof b !== "function" && b !== null)
2933
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2934
+ extendStatics(d, b);
2935
+ function __() { this.constructor = d; }
2936
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2937
+ };
2938
+ })();
2939
+ Object.defineProperty(exports, "__esModule", { value: true });
2940
+ exports.Watch = void 0;
2941
+ var node_1 = require("./node");
2942
+ /**
2943
+ * Watch Node
2944
+ * @class Watch
2945
+ * @extends Fragment
2946
+ */
2947
+ var Watch = /** @class */ (function (_super) {
2948
+ __extends(Watch, _super);
2949
+ function Watch() {
2950
+ return _super !== null && _super.apply(this, arguments) || this;
3044
2951
  }
3045
- return DynamicalClassBinding;
3046
- }(binding_1.Binding));
3047
- exports.DynamicalClassBinding = DynamicalClassBinding;
2952
+ Watch.prototype.compose = function (input) {
2953
+ var _this = this;
2954
+ this.watch(function (value) {
2955
+ _this.children.forEach(function (child) {
2956
+ child.$destroy();
2957
+ });
2958
+ _this.children.clear();
2959
+ _this.lastChild = null;
2960
+ input.slot && input.slot(_this, value);
2961
+ }, input.model);
2962
+ input.slot(this, input.model.$);
2963
+ };
2964
+ return Watch;
2965
+ }(node_1.Fragment));
2966
+ exports.Watch = Watch;
3048
2967
 
3049
2968
 
3050
2969
  // ./lib-es5/views/repeat-node.js
@@ -3254,7 +3173,7 @@ var ArrayView = /** @class */ (function (_super) {
3254
3173
  exports.ArrayView = ArrayView;
3255
3174
 
3256
3175
 
3257
- // ./lib-es5/node/watch.js
3176
+ // ./lib-es5/views/map-view.js
3258
3177
  "use strict";
3259
3178
  var __extends = (this && this.__extends) || (function () {
3260
3179
  var extendStatics = function (d, b) {
@@ -3272,33 +3191,28 @@ var __extends = (this && this.__extends) || (function () {
3272
3191
  };
3273
3192
  })();
3274
3193
  Object.defineProperty(exports, "__esModule", { value: true });
3275
- exports.Watch = void 0;
3276
- var node_1 = require("./node");
3194
+ exports.MapView = void 0;
3195
+ var base_view_1 = require("./base-view");
3277
3196
  /**
3278
- * Watch Node
3279
- * @class Watch
3280
- * @extends Fragment
3197
+ * Create a children pack for each map value
3198
+ * @class MapView
3199
+ * @extends BaseView
3281
3200
  */
3282
- var Watch = /** @class */ (function (_super) {
3283
- __extends(Watch, _super);
3284
- function Watch() {
3201
+ var MapView = /** @class */ (function (_super) {
3202
+ __extends(MapView, _super);
3203
+ function MapView() {
3285
3204
  return _super !== null && _super.apply(this, arguments) || this;
3286
3205
  }
3287
- Watch.prototype.compose = function (input) {
3206
+ MapView.prototype.compose = function (input) {
3288
3207
  var _this = this;
3289
- this.watch(function (value) {
3290
- _this.children.forEach(function (child) {
3291
- child.$destroy();
3292
- });
3293
- _this.children.clear();
3294
- _this.lastChild = null;
3295
- input.slot && input.slot(_this, value);
3296
- }, input.model);
3297
- input.slot(this, input.model.$);
3208
+ _super.prototype.compose.call(this, input);
3209
+ input.model.forEach(function (value, key) {
3210
+ _this.createChild(input, key, value);
3211
+ });
3298
3212
  };
3299
- return Watch;
3300
- }(node_1.Fragment));
3301
- exports.Watch = Watch;
3213
+ return MapView;
3214
+ }(base_view_1.BaseView));
3215
+ exports.MapView = MapView;
3302
3216
 
3303
3217
 
3304
3218
  // ./lib-es5/views/object-view.js
@@ -3344,7 +3258,7 @@ var ObjectView = /** @class */ (function (_super) {
3344
3258
  exports.ObjectView = ObjectView;
3345
3259
 
3346
3260
 
3347
- // ./lib-es5/views/map-view.js
3261
+ // ./lib-es5/views/set-view.js
3348
3262
  "use strict";
3349
3263
  var __extends = (this && this.__extends) || (function () {
3350
3264
  var extendStatics = function (d, b) {
@@ -3362,31 +3276,94 @@ var __extends = (this && this.__extends) || (function () {
3362
3276
  };
3363
3277
  })();
3364
3278
  Object.defineProperty(exports, "__esModule", { value: true });
3365
- exports.MapView = void 0;
3279
+ exports.SetView = void 0;
3366
3280
  var base_view_1 = require("./base-view");
3367
3281
  /**
3368
- * Create a children pack for each map value
3369
- * @class MapView
3282
+ * Create a children pack for each set value
3283
+ * @class SetView
3370
3284
  * @extends BaseView
3371
3285
  */
3372
- var MapView = /** @class */ (function (_super) {
3373
- __extends(MapView, _super);
3374
- function MapView() {
3286
+ var SetView = /** @class */ (function (_super) {
3287
+ __extends(SetView, _super);
3288
+ function SetView() {
3375
3289
  return _super !== null && _super.apply(this, arguments) || this;
3376
3290
  }
3377
- MapView.prototype.compose = function (input) {
3291
+ SetView.prototype.compose = function (input) {
3378
3292
  var _this = this;
3379
3293
  _super.prototype.compose.call(this, input);
3380
- input.model.forEach(function (value, key) {
3381
- _this.createChild(input, key, value);
3294
+ var set = input.model;
3295
+ set.forEach(function (item) {
3296
+ _this.createChild(input, item, item);
3382
3297
  });
3383
3298
  };
3384
- return MapView;
3299
+ return SetView;
3385
3300
  }(base_view_1.BaseView));
3386
- exports.MapView = MapView;
3301
+ exports.SetView = SetView;
3387
3302
 
3388
3303
 
3389
- // ./lib-es5/views/set-view.js
3304
+ // ./lib-es5/index.js
3305
+ "use strict";
3306
+ Object.defineProperty(exports, "__esModule", { value: true });
3307
+ exports.less = exports.Watch = exports.Reactive = exports.Binding = exports.Expression = exports.Portal = exports.App = exports.AppNode = exports.Extension = exports.Component = exports.Tag = exports.INode = exports.Fragment = exports.SetView = exports.ObjectView = exports.MapView = exports.ArrayView = exports.Listener = exports.BaseView = exports.SetModel = exports.ObjectModel = exports.MapModel = exports.ArrayModel = exports.Pointer = exports.Mirror = exports.Reference = exports.IValue = exports.Destroyable = void 0;
3308
+ var destroyable_1 = require("./core/destroyable");
3309
+ Object.defineProperty(exports, "Destroyable", { enumerable: true, get: function () { return destroyable_1.Destroyable; } });
3310
+ var core_1 = require("./core/core");
3311
+ Object.defineProperty(exports, "Reactive", { enumerable: true, get: function () { return core_1.Reactive; } });
3312
+ var ivalue_1 = require("./core/ivalue");
3313
+ Object.defineProperty(exports, "IValue", { enumerable: true, get: function () { return ivalue_1.IValue; } });
3314
+ var array_model_1 = require("./models/array-model");
3315
+ Object.defineProperty(exports, "ArrayModel", { enumerable: true, get: function () { return array_model_1.ArrayModel; } });
3316
+ var listener_1 = require("./models/listener");
3317
+ Object.defineProperty(exports, "Listener", { enumerable: true, get: function () { return listener_1.Listener; } });
3318
+ var map_model_1 = require("./models/map-model");
3319
+ Object.defineProperty(exports, "MapModel", { enumerable: true, get: function () { return map_model_1.MapModel; } });
3320
+ var object_model_1 = require("./models/object-model");
3321
+ Object.defineProperty(exports, "ObjectModel", { enumerable: true, get: function () { return object_model_1.ObjectModel; } });
3322
+ var set_model_1 = require("./models/set-model");
3323
+ Object.defineProperty(exports, "SetModel", { enumerable: true, get: function () { return set_model_1.SetModel; } });
3324
+ var app_1 = require("./node/app");
3325
+ Object.defineProperty(exports, "App", { enumerable: true, get: function () { return app_1.App; } });
3326
+ Object.defineProperty(exports, "AppNode", { enumerable: true, get: function () { return app_1.AppNode; } });
3327
+ Object.defineProperty(exports, "Portal", { enumerable: true, get: function () { return app_1.Portal; } });
3328
+ var node_1 = require("./node/node");
3329
+ Object.defineProperty(exports, "Component", { enumerable: true, get: function () { return node_1.Component; } });
3330
+ Object.defineProperty(exports, "Extension", { enumerable: true, get: function () { return node_1.Extension; } });
3331
+ Object.defineProperty(exports, "Fragment", { enumerable: true, get: function () { return node_1.Fragment; } });
3332
+ Object.defineProperty(exports, "INode", { enumerable: true, get: function () { return node_1.INode; } });
3333
+ Object.defineProperty(exports, "Tag", { enumerable: true, get: function () { return node_1.Tag; } });
3334
+ var expression_1 = require("./value/expression");
3335
+ Object.defineProperty(exports, "Expression", { enumerable: true, get: function () { return expression_1.Expression; } });
3336
+ var mirror_1 = require("./value/mirror");
3337
+ Object.defineProperty(exports, "Mirror", { enumerable: true, get: function () { return mirror_1.Mirror; } });
3338
+ var pointer_1 = require("./value/pointer");
3339
+ Object.defineProperty(exports, "Pointer", { enumerable: true, get: function () { return pointer_1.Pointer; } });
3340
+ var reference_1 = require("./value/reference");
3341
+ Object.defineProperty(exports, "Reference", { enumerable: true, get: function () { return reference_1.Reference; } });
3342
+ var array_view_1 = require("./views/array-view");
3343
+ Object.defineProperty(exports, "ArrayView", { enumerable: true, get: function () { return array_view_1.ArrayView; } });
3344
+ var base_view_1 = require("./views/base-view");
3345
+ Object.defineProperty(exports, "BaseView", { enumerable: true, get: function () { return base_view_1.BaseView; } });
3346
+ var map_view_1 = require("./views/map-view");
3347
+ Object.defineProperty(exports, "MapView", { enumerable: true, get: function () { return map_view_1.MapView; } });
3348
+ var object_view_1 = require("./views/object-view");
3349
+ Object.defineProperty(exports, "ObjectView", { enumerable: true, get: function () { return object_view_1.ObjectView; } });
3350
+ var set_view_1 = require("./views/set-view");
3351
+ Object.defineProperty(exports, "SetView", { enumerable: true, get: function () { return set_view_1.SetView; } });
3352
+ var binding_1 = require("./binding/binding");
3353
+ Object.defineProperty(exports, "Binding", { enumerable: true, get: function () { return binding_1.Binding; } });
3354
+ var errors_1 = require("./core/errors");
3355
+ var watch_1 = require("./node/watch");
3356
+ Object.defineProperty(exports, "Watch", { enumerable: true, get: function () { return watch_1.Watch; } });
3357
+ var less = {
3358
+ stack: core_1.stack,
3359
+ unstack: core_1.unstack,
3360
+ current: core_1.current,
3361
+ userError: errors_1.userError,
3362
+ };
3363
+ exports.less = less;
3364
+
3365
+
3366
+ // ./lib-es5/node/app.js
3390
3367
  "use strict";
3391
3368
  var __extends = (this && this.__extends) || (function () {
3392
3369
  var extendStatics = function (d, b) {
@@ -3404,29 +3381,67 @@ var __extends = (this && this.__extends) || (function () {
3404
3381
  };
3405
3382
  })();
3406
3383
  Object.defineProperty(exports, "__esModule", { value: true });
3407
- exports.SetView = void 0;
3408
- var base_view_1 = require("./base-view");
3384
+ exports.Portal = exports.App = exports.AppNode = void 0;
3385
+ var node_1 = require("./node");
3409
3386
  /**
3410
- * Create a children pack for each set value
3411
- * @class SetView
3412
- * @extends BaseView
3387
+ * Application Node
3388
+ * @class AppNode
3389
+ * @extends INode
3413
3390
  */
3414
- var SetView = /** @class */ (function (_super) {
3415
- __extends(SetView, _super);
3416
- function SetView() {
3417
- return _super !== null && _super.apply(this, arguments) || this;
3391
+ var AppNode = /** @class */ (function (_super) {
3392
+ __extends(AppNode, _super);
3393
+ /**
3394
+ * @param input
3395
+ */
3396
+ function AppNode(input) {
3397
+ var _this = _super.call(this, input) || this;
3398
+ _this.debugUi = input.debugUi || false;
3399
+ _this.$seal();
3400
+ return _this;
3418
3401
  }
3419
- SetView.prototype.compose = function (input) {
3420
- var _this = this;
3421
- _super.prototype.compose.call(this, input);
3422
- var set = input.model;
3423
- set.forEach(function (item) {
3424
- _this.createChild(input, item, item);
3425
- });
3402
+ return AppNode;
3403
+ }(node_1.INode));
3404
+ exports.AppNode = AppNode;
3405
+ /**
3406
+ * Represents a Vasille.js application
3407
+ * @class App
3408
+ * @extends AppNode
3409
+ */
3410
+ var App = /** @class */ (function (_super) {
3411
+ __extends(App, _super);
3412
+ /**
3413
+ * Constructs an app node
3414
+ * @param node {Element} The root of application
3415
+ * @param input
3416
+ */
3417
+ function App(node, input) {
3418
+ var _this = _super.call(this, input) || this;
3419
+ _this.$.node = node;
3420
+ _this.preinit(_this, _this);
3421
+ _this.init();
3422
+ _this.$seal();
3423
+ return _this;
3424
+ }
3425
+ App.prototype.appendNode = function (node) {
3426
+ this.$.node.appendChild(node);
3426
3427
  };
3427
- return SetView;
3428
- }(base_view_1.BaseView));
3429
- exports.SetView = SetView;
3428
+ return App;
3429
+ }(AppNode));
3430
+ exports.App = App;
3431
+ var Portal = /** @class */ (function (_super) {
3432
+ __extends(Portal, _super);
3433
+ function Portal(input) {
3434
+ var _this = _super.call(this, input) || this;
3435
+ _this.$.node = input.node;
3436
+ _this.$seal();
3437
+ return _this;
3438
+ }
3439
+ Portal.prototype.appendNode = function (node) {
3440
+ this.$.node.appendChild(node);
3441
+ };
3442
+ return Portal;
3443
+ }(AppNode));
3444
+ exports.Portal = Portal;
3430
3445
 
3431
3446
 
3432
3447
  // ./lib-es5/functional/options.js