vasille 2.2.2 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -28
- package/cdn/es2015.js +18 -724
- package/cdn/es5.js +687 -957
- package/flow-typed/vasille.js +14 -59
- package/lib/core/core.js +3 -3
- package/lib/index.js +5 -4
- package/lib/models/array-model.js +6 -9
- package/lib/models/object-model.js +3 -17
- package/lib/node/node.js +6 -3
- package/lib/views/object-view.js +1 -1
- package/lib-node/binding/attribute.js +35 -0
- package/lib-node/binding/binding.js +33 -0
- package/lib-node/binding/class.js +48 -0
- package/lib-node/binding/style.js +27 -0
- package/lib-node/core/core.js +243 -0
- package/lib-node/core/destroyable.js +49 -0
- package/lib-node/core/errors.js +23 -0
- package/lib-node/core/ivalue.js +63 -0
- package/lib-node/functional/options.js +2 -0
- package/lib-node/index.js +54 -0
- package/lib-node/models/array-model.js +218 -0
- package/lib-node/models/listener.js +134 -0
- package/lib-node/models/map-model.js +70 -0
- package/lib-node/models/model.js +2 -0
- package/lib-node/models/object-model.js +82 -0
- package/lib-node/models/set-model.js +66 -0
- package/lib-node/node/app.js +54 -0
- package/lib-node/node/node.js +885 -0
- package/lib-node/node/watch.js +23 -0
- package/lib-node/spec/html.js +2 -0
- package/lib-node/spec/react.js +2 -0
- package/lib-node/spec/svg.js +2 -0
- package/lib-node/value/expression.js +90 -0
- package/lib-node/value/mirror.js +60 -0
- package/lib-node/value/pointer.js +30 -0
- package/lib-node/value/reference.js +55 -0
- package/lib-node/views/array-view.js +21 -0
- package/lib-node/views/base-view.js +43 -0
- package/lib-node/views/map-view.js +18 -0
- package/lib-node/views/object-view.js +20 -0
- package/lib-node/views/repeat-node.js +71 -0
- package/lib-node/views/set-view.js +19 -0
- package/package.json +21 -17
- package/types/core/core.d.ts +4 -4
- package/types/functional/options.d.ts +2 -2
- package/types/index.d.ts +10 -7
- package/types/models/array-model.d.ts +1 -1
- package/types/models/object-model.d.ts +1 -1
- package/types/node/node.d.ts +5 -4
- package/types/node/watch.d.ts +2 -2
- package/types/views/repeat-node.d.ts +2 -2
- package/lib/core/executor.js +0 -154
- package/lib/core/signal.js +0 -50
- package/lib/core/slot.js +0 -47
- package/lib/functional/components.js +0 -17
- package/lib/functional/merge.js +0 -41
- package/lib/functional/models.js +0 -26
- package/lib/functional/reactivity.js +0 -33
- package/lib/functional/stack.js +0 -127
- package/lib/node/interceptor.js +0 -83
- package/lib/v/index.js +0 -23
- package/lib/views/repeater.js +0 -63
- package/types/functional/components.d.ts +0 -4
- package/types/functional/merge.d.ts +0 -1
- package/types/functional/models.d.ts +0 -10
- package/types/functional/reactivity.d.ts +0 -11
- package/types/functional/stack.d.ts +0 -24
- package/types/v/index.d.ts +0 -36
package/cdn/es2015.js
CHANGED
|
@@ -195,6 +195,9 @@ class ObjectModel extends Object {
|
|
|
195
195
|
this.listener.emitAdded(key, this.container[key]);
|
|
196
196
|
return this;
|
|
197
197
|
}
|
|
198
|
+
get values() {
|
|
199
|
+
return this.container;
|
|
200
|
+
}
|
|
198
201
|
/**
|
|
199
202
|
* Deletes an object property
|
|
200
203
|
* @param key {string} property name
|
|
@@ -205,23 +208,6 @@ class ObjectModel extends Object {
|
|
|
205
208
|
delete this.container[key];
|
|
206
209
|
}
|
|
207
210
|
}
|
|
208
|
-
proxy() {
|
|
209
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
210
|
-
const ts = this;
|
|
211
|
-
return new Proxy(this.container, {
|
|
212
|
-
get(target, p) {
|
|
213
|
-
return ts.get(p);
|
|
214
|
-
},
|
|
215
|
-
set(target, p, value) {
|
|
216
|
-
ts.set(p, value);
|
|
217
|
-
return true;
|
|
218
|
-
},
|
|
219
|
-
deleteProperty(target, p) {
|
|
220
|
-
ts.delete(p);
|
|
221
|
-
return true;
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
211
|
enableReactivity() {
|
|
226
212
|
this.listener.enableReactivity();
|
|
227
213
|
}
|
|
@@ -387,15 +373,6 @@ class ArrayModel extends Array {
|
|
|
387
373
|
super.push(data[i]);
|
|
388
374
|
}
|
|
389
375
|
}
|
|
390
|
-
// proxy
|
|
391
|
-
proxy() {
|
|
392
|
-
return new Proxy(this, {
|
|
393
|
-
set(target, p, value) {
|
|
394
|
-
target.splice(parseInt(p), 1, value);
|
|
395
|
-
return true;
|
|
396
|
-
}
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
376
|
/* Array members */
|
|
400
377
|
/**
|
|
401
378
|
* Gets the last item of array
|
|
@@ -576,6 +553,12 @@ class ArrayModel extends Array {
|
|
|
576
553
|
this.removeAt(this.indexOf(v));
|
|
577
554
|
return this;
|
|
578
555
|
}
|
|
556
|
+
replace(at, with_) {
|
|
557
|
+
this.listener.emitAdded(this[at], with_);
|
|
558
|
+
this.listener.emitRemoved(this[at], this[at]);
|
|
559
|
+
this[at] = with_;
|
|
560
|
+
return this;
|
|
561
|
+
}
|
|
579
562
|
enableReactivity() {
|
|
580
563
|
this.listener.enableReactivity();
|
|
581
564
|
}
|
|
@@ -586,111 +569,6 @@ class ArrayModel extends Array {
|
|
|
586
569
|
|
|
587
570
|
window.ArrayModel = ArrayModel;
|
|
588
571
|
|
|
589
|
-
// ./lib/core/signal.js
|
|
590
|
-
/**
|
|
591
|
-
* Signal is an event generator
|
|
592
|
-
* @class Signal
|
|
593
|
-
*/
|
|
594
|
-
class Signal {
|
|
595
|
-
constructor() {
|
|
596
|
-
/**
|
|
597
|
-
* Handler of event
|
|
598
|
-
* @type {Set}
|
|
599
|
-
* @private
|
|
600
|
-
*/
|
|
601
|
-
this.handlers = new Set;
|
|
602
|
-
}
|
|
603
|
-
/**
|
|
604
|
-
* Emit event
|
|
605
|
-
* @param a1 {*} argument
|
|
606
|
-
* @param a2 {*} argument
|
|
607
|
-
* @param a3 {*} argument
|
|
608
|
-
* @param a4 {*} argument
|
|
609
|
-
* @param a5 {*} argument
|
|
610
|
-
* @param a6 {*} argument
|
|
611
|
-
* @param a7 {*} argument
|
|
612
|
-
* @param a8 {*} argument
|
|
613
|
-
* @param a9 {*} argument
|
|
614
|
-
*/
|
|
615
|
-
emit(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
|
616
|
-
this.handlers.forEach(handler => {
|
|
617
|
-
try {
|
|
618
|
-
handler(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
|
619
|
-
}
|
|
620
|
-
catch (e) {
|
|
621
|
-
console.error(`Vasille.js: Handler throw exception: `, e);
|
|
622
|
-
}
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
/**
|
|
626
|
-
* Subscribe to event
|
|
627
|
-
* @param func {function} handler
|
|
628
|
-
*/
|
|
629
|
-
subscribe(func) {
|
|
630
|
-
this.handlers.add(func);
|
|
631
|
-
}
|
|
632
|
-
/**
|
|
633
|
-
* Unsubscribe from event
|
|
634
|
-
* @param func {function} handler
|
|
635
|
-
*/
|
|
636
|
-
unsubscribe(func) {
|
|
637
|
-
this.handlers.delete(func);
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
window.Signal = Signal;
|
|
642
|
-
|
|
643
|
-
// ./lib/core/slot.js
|
|
644
|
-
/**
|
|
645
|
-
* Component slot
|
|
646
|
-
* @class Slot
|
|
647
|
-
*/
|
|
648
|
-
class Slot {
|
|
649
|
-
/**
|
|
650
|
-
* Sets the runner
|
|
651
|
-
* @param func {function} the function to run
|
|
652
|
-
*/
|
|
653
|
-
insert(func) {
|
|
654
|
-
this.runner = func;
|
|
655
|
-
}
|
|
656
|
-
/**
|
|
657
|
-
* @param a0 {Fragment} node to paste content
|
|
658
|
-
* @param a1 {*} 1st argument
|
|
659
|
-
* @param a2 {*} 2nd argument
|
|
660
|
-
* @param a3 {*} 3rd argument
|
|
661
|
-
* @param a4 {*} 4th argument
|
|
662
|
-
* @param a5 {*} 5th argument
|
|
663
|
-
* @param a6 {*} 6th argument
|
|
664
|
-
* @param a7 {*} 7th argument
|
|
665
|
-
* @param a8 {*} 8th argument
|
|
666
|
-
* @param a9 {*} 9th argument
|
|
667
|
-
*/
|
|
668
|
-
release(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
|
669
|
-
if (this.runner) {
|
|
670
|
-
this.runner(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
/**
|
|
674
|
-
* Predefine a handler for a slot
|
|
675
|
-
* @param func {function(node : Fragment)} Function to run if no handler specified
|
|
676
|
-
* @param a0 {Fragment} node to paste content
|
|
677
|
-
* @param a1 {*} 1st argument
|
|
678
|
-
* @param a2 {*} 2nd argument
|
|
679
|
-
* @param a3 {*} 3rd argument
|
|
680
|
-
* @param a4 {*} 4th argument
|
|
681
|
-
* @param a5 {*} 5th argument
|
|
682
|
-
* @param a6 {*} 6th argument
|
|
683
|
-
* @param a7 {*} 7th argument
|
|
684
|
-
* @param a8 {*} 8th argument
|
|
685
|
-
* @param a9 {*} 9th argument
|
|
686
|
-
*/
|
|
687
|
-
predefine(func, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
|
688
|
-
(this.runner || func)(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
window.Slot = Slot;
|
|
693
|
-
|
|
694
572
|
// ./lib/core/errors.js
|
|
695
573
|
const reportIt = "Report it here: https://gitlab.com/vasille-js/vasille-js/-/issues";
|
|
696
574
|
function notOverwritten() {
|
|
@@ -714,167 +592,6 @@ window.internalError = internalError;
|
|
|
714
592
|
window.userError = userError;
|
|
715
593
|
window.wrongBinding = wrongBinding;
|
|
716
594
|
|
|
717
|
-
// ./lib/core/executor.js
|
|
718
|
-
/**
|
|
719
|
-
* Represents an executor unit interface
|
|
720
|
-
* @class Executor
|
|
721
|
-
*/
|
|
722
|
-
class Executor {
|
|
723
|
-
/**
|
|
724
|
-
* Adds a CSS class
|
|
725
|
-
* @param el {Element} element to manipulate
|
|
726
|
-
* @param cl {string} class to be added
|
|
727
|
-
*/
|
|
728
|
-
addClass(el, cl) {
|
|
729
|
-
throw notOverwritten();
|
|
730
|
-
}
|
|
731
|
-
/**
|
|
732
|
-
* Removes a CSS class
|
|
733
|
-
* @param el {Element} element to manipulate
|
|
734
|
-
* @param cl {string} class to be removed
|
|
735
|
-
*/
|
|
736
|
-
removeClass(el, cl) {
|
|
737
|
-
throw notOverwritten();
|
|
738
|
-
}
|
|
739
|
-
/**
|
|
740
|
-
* Sets a tag attribute
|
|
741
|
-
* @param el {Element} element to manipulate
|
|
742
|
-
* @param name {string} name of attribute
|
|
743
|
-
* @param value {string} value of attribute
|
|
744
|
-
*/
|
|
745
|
-
setAttribute(el, name, value) {
|
|
746
|
-
throw notOverwritten();
|
|
747
|
-
}
|
|
748
|
-
/**
|
|
749
|
-
* Removes a tag attribute
|
|
750
|
-
* @param el {Element} element to manipulate
|
|
751
|
-
* @param name {string} name of attribute
|
|
752
|
-
*/
|
|
753
|
-
removeAttribute(el, name) {
|
|
754
|
-
throw notOverwritten();
|
|
755
|
-
}
|
|
756
|
-
/**
|
|
757
|
-
* Sets a style attribute
|
|
758
|
-
* @param el {HTMLElement} element to manipulate
|
|
759
|
-
* @param prop {string} property name
|
|
760
|
-
* @param value {string} property value
|
|
761
|
-
*/
|
|
762
|
-
setStyle(el, prop, value) {
|
|
763
|
-
throw notOverwritten();
|
|
764
|
-
}
|
|
765
|
-
/**
|
|
766
|
-
* Inserts a child before target
|
|
767
|
-
* @param target {Element} target element
|
|
768
|
-
* @param child {Node} element to insert before
|
|
769
|
-
*/
|
|
770
|
-
insertBefore(target, child) {
|
|
771
|
-
throw notOverwritten();
|
|
772
|
-
}
|
|
773
|
-
/**
|
|
774
|
-
* Appends a child to element
|
|
775
|
-
* @param el {Element} element
|
|
776
|
-
* @param child {Node} child to be inserted
|
|
777
|
-
*/
|
|
778
|
-
appendChild(el, child) {
|
|
779
|
-
throw notOverwritten();
|
|
780
|
-
}
|
|
781
|
-
/**
|
|
782
|
-
* Calls a call-back function
|
|
783
|
-
* @param cb {function} call-back function
|
|
784
|
-
*/
|
|
785
|
-
callCallback(cb) {
|
|
786
|
-
throw notOverwritten();
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
/**
|
|
790
|
-
* Executor which execute any commands immediately
|
|
791
|
-
* @class InstantExecutor
|
|
792
|
-
* @extends Executor
|
|
793
|
-
*/
|
|
794
|
-
class InstantExecutor extends Executor {
|
|
795
|
-
addClass(el, cl) {
|
|
796
|
-
el.classList.add(cl);
|
|
797
|
-
}
|
|
798
|
-
removeClass(el, cl) {
|
|
799
|
-
el.classList.remove(cl);
|
|
800
|
-
}
|
|
801
|
-
setAttribute(el, name, value) {
|
|
802
|
-
el.setAttribute(name, value);
|
|
803
|
-
}
|
|
804
|
-
removeAttribute(el, name) {
|
|
805
|
-
el.removeAttribute(name);
|
|
806
|
-
}
|
|
807
|
-
setStyle(el, prop, value) {
|
|
808
|
-
el.style.setProperty(prop, value);
|
|
809
|
-
}
|
|
810
|
-
insertBefore(target, child) {
|
|
811
|
-
const parent = target.parentNode;
|
|
812
|
-
if (!parent) {
|
|
813
|
-
throw internalError('element don\'t have a parent node');
|
|
814
|
-
}
|
|
815
|
-
parent.insertBefore(child, target);
|
|
816
|
-
}
|
|
817
|
-
appendChild(el, child) {
|
|
818
|
-
el.appendChild(child);
|
|
819
|
-
}
|
|
820
|
-
callCallback(cb) {
|
|
821
|
-
cb();
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
/**
|
|
825
|
-
* Executor which execute any commands over timeout
|
|
826
|
-
* @class TimeoutExecutor
|
|
827
|
-
* @extends InstantExecutor
|
|
828
|
-
*/
|
|
829
|
-
class TimeoutExecutor extends InstantExecutor {
|
|
830
|
-
addClass(el, cl) {
|
|
831
|
-
setTimeout(() => {
|
|
832
|
-
super.addClass(el, cl);
|
|
833
|
-
}, 0);
|
|
834
|
-
}
|
|
835
|
-
removeClass(el, cl) {
|
|
836
|
-
setTimeout(() => {
|
|
837
|
-
super.removeClass(el, cl);
|
|
838
|
-
}, 0);
|
|
839
|
-
}
|
|
840
|
-
setAttribute(el, name, value) {
|
|
841
|
-
setTimeout(() => {
|
|
842
|
-
super.setAttribute(el, name, value);
|
|
843
|
-
}, 0);
|
|
844
|
-
}
|
|
845
|
-
removeAttribute(el, name) {
|
|
846
|
-
setTimeout(() => {
|
|
847
|
-
super.removeAttribute(el, name);
|
|
848
|
-
}, 0);
|
|
849
|
-
}
|
|
850
|
-
setStyle(el, prop, value) {
|
|
851
|
-
setTimeout(() => {
|
|
852
|
-
super.setStyle(el, prop, value);
|
|
853
|
-
}, 0);
|
|
854
|
-
}
|
|
855
|
-
insertBefore(target, child) {
|
|
856
|
-
setTimeout(() => {
|
|
857
|
-
super.insertBefore(target, child);
|
|
858
|
-
}, 0);
|
|
859
|
-
}
|
|
860
|
-
appendChild(el, child) {
|
|
861
|
-
setTimeout(() => {
|
|
862
|
-
super.appendChild(el, child);
|
|
863
|
-
}, 0);
|
|
864
|
-
}
|
|
865
|
-
callCallback(cb) {
|
|
866
|
-
setTimeout(cb, 0);
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
const instantExecutor = new InstantExecutor();
|
|
870
|
-
const timeoutExecutor = new TimeoutExecutor();
|
|
871
|
-
|
|
872
|
-
window.Executor = Executor;
|
|
873
|
-
window.InstantExecutor = InstantExecutor;
|
|
874
|
-
window.TimeoutExecutor = TimeoutExecutor;
|
|
875
|
-
window.instantExecutor = instantExecutor;
|
|
876
|
-
window.timeoutExecutor = timeoutExecutor;
|
|
877
|
-
|
|
878
595
|
// ./lib/core/destroyable.js
|
|
879
596
|
/**
|
|
880
597
|
* Mark an object which can be destroyed
|
|
@@ -1464,7 +1181,7 @@ class Reactive extends Destroyable {
|
|
|
1464
1181
|
}
|
|
1465
1182
|
init() {
|
|
1466
1183
|
this.applyOptions(this.input);
|
|
1467
|
-
this.compose(this.input);
|
|
1184
|
+
return this.compose(this.input);
|
|
1468
1185
|
}
|
|
1469
1186
|
applyOptions(input) {
|
|
1470
1187
|
// empty
|
|
@@ -1473,7 +1190,7 @@ class Reactive extends Destroyable {
|
|
|
1473
1190
|
this.applyOptions(this.input);
|
|
1474
1191
|
}
|
|
1475
1192
|
compose(input) {
|
|
1476
|
-
|
|
1193
|
+
throw notOverwritten();
|
|
1477
1194
|
}
|
|
1478
1195
|
composeNow() {
|
|
1479
1196
|
this.compose(this.input);
|
|
@@ -1565,11 +1282,11 @@ class Fragment extends Reactive {
|
|
|
1565
1282
|
$.preinit(app, parent);
|
|
1566
1283
|
}
|
|
1567
1284
|
init() {
|
|
1568
|
-
super.init();
|
|
1285
|
+
const ret = super.init();
|
|
1569
1286
|
this.ready();
|
|
1287
|
+
return ret;
|
|
1570
1288
|
}
|
|
1571
1289
|
compose(input) {
|
|
1572
|
-
super.compose(input);
|
|
1573
1290
|
input.slot && input.slot(this);
|
|
1574
1291
|
}
|
|
1575
1292
|
/** To be overloaded: ready event handler */
|
|
@@ -1677,7 +1394,7 @@ class Fragment extends Reactive {
|
|
|
1677
1394
|
node.preinit($.app, this);
|
|
1678
1395
|
node.input.slot = callback || node.input.slot;
|
|
1679
1396
|
this.pushNode(node);
|
|
1680
|
-
node.init();
|
|
1397
|
+
return node.init();
|
|
1681
1398
|
}
|
|
1682
1399
|
/**
|
|
1683
1400
|
* Defines an if node
|
|
@@ -2172,6 +1889,9 @@ class Extension extends INode {
|
|
|
2172
1889
|
throw userError("A extension node can be encapsulated only in a tag/extension/component", "virtual-dom");
|
|
2173
1890
|
}
|
|
2174
1891
|
}
|
|
1892
|
+
extend(options) {
|
|
1893
|
+
this.applyOptions(options);
|
|
1894
|
+
}
|
|
2175
1895
|
$destroy() {
|
|
2176
1896
|
super.$destroy();
|
|
2177
1897
|
}
|
|
@@ -2427,90 +2147,6 @@ window.AppNode = AppNode;
|
|
|
2427
2147
|
window.App = App;
|
|
2428
2148
|
window.Portal = Portal;
|
|
2429
2149
|
|
|
2430
|
-
// ./lib/node/interceptor.js
|
|
2431
|
-
/**
|
|
2432
|
-
* Interceptor is designed to connect signals & methods of children elements
|
|
2433
|
-
* @class Interceptor
|
|
2434
|
-
* @extends Destroyable
|
|
2435
|
-
*/
|
|
2436
|
-
class Interceptor extends Destroyable {
|
|
2437
|
-
constructor() {
|
|
2438
|
-
super(...arguments);
|
|
2439
|
-
/**
|
|
2440
|
-
* Set of signals
|
|
2441
|
-
* @type Set
|
|
2442
|
-
*/
|
|
2443
|
-
this.signals = new Set;
|
|
2444
|
-
/**
|
|
2445
|
-
* Set of handlers
|
|
2446
|
-
* @type Set
|
|
2447
|
-
*/
|
|
2448
|
-
this.handlers = new Set;
|
|
2449
|
-
}
|
|
2450
|
-
/**
|
|
2451
|
-
* Connect a signal or a handler
|
|
2452
|
-
* @param thing {Signal | function}
|
|
2453
|
-
*/
|
|
2454
|
-
connect(thing) {
|
|
2455
|
-
// interceptor will connect signals and handlers together
|
|
2456
|
-
if (thing instanceof Signal) {
|
|
2457
|
-
this.handlers.forEach(handler => {
|
|
2458
|
-
thing.subscribe(handler);
|
|
2459
|
-
});
|
|
2460
|
-
this.signals.add(thing);
|
|
2461
|
-
}
|
|
2462
|
-
else {
|
|
2463
|
-
this.signals.forEach(signal => {
|
|
2464
|
-
signal.subscribe(thing);
|
|
2465
|
-
});
|
|
2466
|
-
this.handlers.add(thing);
|
|
2467
|
-
}
|
|
2468
|
-
}
|
|
2469
|
-
/**
|
|
2470
|
-
* Disconnect a handler from signals
|
|
2471
|
-
* @param handler {function}
|
|
2472
|
-
*/
|
|
2473
|
-
disconnect(handler) {
|
|
2474
|
-
this.signals.forEach(signal => {
|
|
2475
|
-
signal.unsubscribe(handler);
|
|
2476
|
-
});
|
|
2477
|
-
}
|
|
2478
|
-
destroy() {
|
|
2479
|
-
super.destroy();
|
|
2480
|
-
this.signals.forEach(signal => {
|
|
2481
|
-
this.handlers.forEach(handler => {
|
|
2482
|
-
signal.unsubscribe(handler);
|
|
2483
|
-
});
|
|
2484
|
-
});
|
|
2485
|
-
}
|
|
2486
|
-
}
|
|
2487
|
-
/**
|
|
2488
|
-
* Interceptor node to implement directly to vasille DOM
|
|
2489
|
-
* @class InterceptorNode
|
|
2490
|
-
* @extends Extension
|
|
2491
|
-
*/
|
|
2492
|
-
class InterceptorNode extends Fragment {
|
|
2493
|
-
constructor() {
|
|
2494
|
-
super(...arguments);
|
|
2495
|
-
/**
|
|
2496
|
-
* Internal interceptor
|
|
2497
|
-
* @type Interceptor
|
|
2498
|
-
*/
|
|
2499
|
-
this.interceptor = new Interceptor;
|
|
2500
|
-
/**
|
|
2501
|
-
* The default slot of node
|
|
2502
|
-
* @type Slot
|
|
2503
|
-
*/
|
|
2504
|
-
this.slot = new Slot;
|
|
2505
|
-
}
|
|
2506
|
-
compose() {
|
|
2507
|
-
this.slot.release(this, this.interceptor);
|
|
2508
|
-
}
|
|
2509
|
-
}
|
|
2510
|
-
|
|
2511
|
-
window.Interceptor = Interceptor;
|
|
2512
|
-
window.InterceptorNode = InterceptorNode;
|
|
2513
|
-
|
|
2514
2150
|
// ./lib/binding/attribute.js
|
|
2515
2151
|
/**
|
|
2516
2152
|
* Represents an Attribute binding description
|
|
@@ -2688,72 +2324,6 @@ class RepeatNode extends Fragment {
|
|
|
2688
2324
|
window.RepeatNodePrivate = RepeatNodePrivate;
|
|
2689
2325
|
window.RepeatNode = RepeatNode;
|
|
2690
2326
|
|
|
2691
|
-
// ./lib/views/repeater.js
|
|
2692
|
-
/**
|
|
2693
|
-
* Private part of repeater
|
|
2694
|
-
* @class RepeaterPrivate
|
|
2695
|
-
* @extends RepeatNodePrivate
|
|
2696
|
-
*/
|
|
2697
|
-
class RepeaterPrivate extends RepeatNodePrivate {
|
|
2698
|
-
constructor() {
|
|
2699
|
-
super();
|
|
2700
|
-
/**
|
|
2701
|
-
* Current count of child nodes
|
|
2702
|
-
*/
|
|
2703
|
-
this.currentCount = 0;
|
|
2704
|
-
this.seal();
|
|
2705
|
-
}
|
|
2706
|
-
}
|
|
2707
|
-
/**
|
|
2708
|
-
* The simplest repeat node interpretation, repeat children pack a several times
|
|
2709
|
-
* @class Repeater
|
|
2710
|
-
* @extends RepeatNode
|
|
2711
|
-
*/
|
|
2712
|
-
class Repeater extends RepeatNode {
|
|
2713
|
-
constructor($) {
|
|
2714
|
-
super($ || new RepeaterPrivate);
|
|
2715
|
-
/**
|
|
2716
|
-
* The count of children
|
|
2717
|
-
*/
|
|
2718
|
-
this.count = new Reference(0);
|
|
2719
|
-
this.seal();
|
|
2720
|
-
}
|
|
2721
|
-
/**
|
|
2722
|
-
* Changes the children count
|
|
2723
|
-
*/
|
|
2724
|
-
changeCount(number) {
|
|
2725
|
-
const $ = this.$;
|
|
2726
|
-
if (number > $.currentCount) {
|
|
2727
|
-
for (let i = $.currentCount; i < number; i++) {
|
|
2728
|
-
this.createChild(i, i);
|
|
2729
|
-
}
|
|
2730
|
-
}
|
|
2731
|
-
else {
|
|
2732
|
-
for (let i = $.currentCount - 1; i >= number; i--) {
|
|
2733
|
-
this.destroyChild(i, i);
|
|
2734
|
-
}
|
|
2735
|
-
}
|
|
2736
|
-
$.currentCount = number;
|
|
2737
|
-
}
|
|
2738
|
-
created() {
|
|
2739
|
-
const $ = this.$;
|
|
2740
|
-
super.created();
|
|
2741
|
-
$.updateHandler = this.changeCount.bind(this);
|
|
2742
|
-
this.count.on($.updateHandler);
|
|
2743
|
-
}
|
|
2744
|
-
ready() {
|
|
2745
|
-
this.changeCount(this.count.$);
|
|
2746
|
-
}
|
|
2747
|
-
destroy() {
|
|
2748
|
-
const $ = this.$;
|
|
2749
|
-
super.destroy();
|
|
2750
|
-
this.count.off($.updateHandler);
|
|
2751
|
-
}
|
|
2752
|
-
}
|
|
2753
|
-
|
|
2754
|
-
window.RepeaterPrivate = RepeaterPrivate;
|
|
2755
|
-
window.Repeater = Repeater;
|
|
2756
|
-
|
|
2757
2327
|
// ./lib/views/base-view.js
|
|
2758
2328
|
/**
|
|
2759
2329
|
* Private part of BaseView
|
|
@@ -2847,7 +2417,7 @@ window.Watch = Watch;
|
|
|
2847
2417
|
class ObjectView extends BaseView {
|
|
2848
2418
|
compose(input) {
|
|
2849
2419
|
super.compose(input);
|
|
2850
|
-
const obj = input.model.
|
|
2420
|
+
const obj = input.model.values;
|
|
2851
2421
|
for (const key in obj) {
|
|
2852
2422
|
this.createChild(input, key, obj[key]);
|
|
2853
2423
|
}
|
|
@@ -2892,284 +2462,8 @@ class SetView extends BaseView {
|
|
|
2892
2462
|
|
|
2893
2463
|
window.SetView = SetView;
|
|
2894
2464
|
|
|
2895
|
-
// ./lib/functional/merge.js
|
|
2896
|
-
function merge(main, ...targets) {
|
|
2897
|
-
function refactorClass(obj) {
|
|
2898
|
-
if (Array.isArray(obj.class)) {
|
|
2899
|
-
const out = {
|
|
2900
|
-
$: []
|
|
2901
|
-
};
|
|
2902
|
-
obj.class.forEach(item => {
|
|
2903
|
-
if (item instanceof IValue) {
|
|
2904
|
-
out.$.push(item);
|
|
2905
|
-
}
|
|
2906
|
-
else if (typeof item === 'string') {
|
|
2907
|
-
out[item] = true;
|
|
2908
|
-
}
|
|
2909
|
-
else if (typeof item === 'object') {
|
|
2910
|
-
Object.assign(out, item);
|
|
2911
|
-
}
|
|
2912
|
-
});
|
|
2913
|
-
obj.class = out;
|
|
2914
|
-
}
|
|
2915
|
-
}
|
|
2916
|
-
refactorClass(main);
|
|
2917
|
-
targets.forEach(target => {
|
|
2918
|
-
Reflect.ownKeys(target).forEach((prop) => {
|
|
2919
|
-
if (!Reflect.has(main, prop)) {
|
|
2920
|
-
main[prop] = target[prop];
|
|
2921
|
-
}
|
|
2922
|
-
else if (typeof main[prop] === 'object' && typeof target[prop] === 'object') {
|
|
2923
|
-
if (prop === 'class') {
|
|
2924
|
-
refactorClass(target);
|
|
2925
|
-
}
|
|
2926
|
-
if (prop === '$' && Array.isArray(main[prop]) && Array.isArray(target[prop])) {
|
|
2927
|
-
main.$.push(...target.$);
|
|
2928
|
-
}
|
|
2929
|
-
else {
|
|
2930
|
-
merge(main[prop], target[prop]);
|
|
2931
|
-
}
|
|
2932
|
-
}
|
|
2933
|
-
});
|
|
2934
|
-
});
|
|
2935
|
-
}
|
|
2936
|
-
|
|
2937
|
-
window.merge = merge;
|
|
2938
|
-
|
|
2939
|
-
// ./lib/functional/stack.js
|
|
2940
|
-
function app(renderer) {
|
|
2941
|
-
return (node, opts) => {
|
|
2942
|
-
return new App(node, opts).runFunctional(renderer, opts);
|
|
2943
|
-
};
|
|
2944
|
-
}
|
|
2945
|
-
function component(renderer) {
|
|
2946
|
-
return (opts, callback) => {
|
|
2947
|
-
const component = new Component(opts);
|
|
2948
|
-
if (!(current instanceof Fragment))
|
|
2949
|
-
throw userError('missing parent node', 'out-of-context');
|
|
2950
|
-
let ret;
|
|
2951
|
-
if (callback)
|
|
2952
|
-
opts.slot = callback;
|
|
2953
|
-
current.create(component, node => {
|
|
2954
|
-
ret = node.runFunctional(renderer, opts);
|
|
2955
|
-
});
|
|
2956
|
-
return ret;
|
|
2957
|
-
};
|
|
2958
|
-
}
|
|
2959
|
-
function fragment(renderer) {
|
|
2960
|
-
return (opts, callback) => {
|
|
2961
|
-
const frag = new Fragment(opts);
|
|
2962
|
-
if (!(current instanceof Fragment))
|
|
2963
|
-
throw userError('missing parent node', 'out-of-context');
|
|
2964
|
-
if (callback)
|
|
2965
|
-
opts.slot = callback;
|
|
2966
|
-
current.create(frag);
|
|
2967
|
-
return frag.runFunctional(renderer, opts);
|
|
2968
|
-
};
|
|
2969
|
-
}
|
|
2970
|
-
function extension(renderer) {
|
|
2971
|
-
return (opts, callback) => {
|
|
2972
|
-
const ext = new Extension(opts);
|
|
2973
|
-
if (!(current instanceof Fragment))
|
|
2974
|
-
throw userError('missing parent node', 'out-of-context');
|
|
2975
|
-
if (callback)
|
|
2976
|
-
opts.slot = callback;
|
|
2977
|
-
current.create(ext);
|
|
2978
|
-
return ext.runFunctional(renderer, opts);
|
|
2979
|
-
};
|
|
2980
|
-
}
|
|
2981
|
-
function tag(name, opts, callback) {
|
|
2982
|
-
if (!(current instanceof Fragment))
|
|
2983
|
-
throw userError('missing parent node', 'out-of-context');
|
|
2984
|
-
return {
|
|
2985
|
-
node: current.tag(name, opts, (node) => {
|
|
2986
|
-
callback && node.runFunctional(callback);
|
|
2987
|
-
})
|
|
2988
|
-
};
|
|
2989
|
-
}
|
|
2990
|
-
function create(node, callback) {
|
|
2991
|
-
if (!(current instanceof Fragment))
|
|
2992
|
-
throw userError('missing current node', 'out-of-context');
|
|
2993
|
-
current.create(node, (node, ...args) => {
|
|
2994
|
-
callback && node.runFunctional(callback, ...args);
|
|
2995
|
-
});
|
|
2996
|
-
return node;
|
|
2997
|
-
}
|
|
2998
|
-
const vx = {
|
|
2999
|
-
if(condition, callback) {
|
|
3000
|
-
if (current instanceof Fragment) {
|
|
3001
|
-
current.if(condition, node => node.runFunctional(callback));
|
|
3002
|
-
}
|
|
3003
|
-
else {
|
|
3004
|
-
throw userError("wrong use of `v.if` function", "logic-error");
|
|
3005
|
-
}
|
|
3006
|
-
},
|
|
3007
|
-
else(callback) {
|
|
3008
|
-
if (current instanceof Fragment) {
|
|
3009
|
-
current.else(node => node.runFunctional(callback));
|
|
3010
|
-
}
|
|
3011
|
-
else {
|
|
3012
|
-
throw userError("wrong use of `v.else` function", "logic-error");
|
|
3013
|
-
}
|
|
3014
|
-
},
|
|
3015
|
-
elif(condition, callback) {
|
|
3016
|
-
if (current instanceof Fragment) {
|
|
3017
|
-
current.elif(condition, node => node.runFunctional(callback));
|
|
3018
|
-
}
|
|
3019
|
-
else {
|
|
3020
|
-
throw userError("wrong use of `v.elif` function", "logic-error");
|
|
3021
|
-
}
|
|
3022
|
-
},
|
|
3023
|
-
for(model, callback) {
|
|
3024
|
-
if (model instanceof ArrayModel) {
|
|
3025
|
-
// for arrays T & K are the same type
|
|
3026
|
-
create(new ArrayView({ model }), callback);
|
|
3027
|
-
}
|
|
3028
|
-
else if (model instanceof MapModel) {
|
|
3029
|
-
create(new MapView({ model }), callback);
|
|
3030
|
-
}
|
|
3031
|
-
else if (model instanceof SetModel) {
|
|
3032
|
-
// for sets T & K are the same type
|
|
3033
|
-
create(new SetView({ model }), callback);
|
|
3034
|
-
}
|
|
3035
|
-
else if (model instanceof ObjectModel) {
|
|
3036
|
-
// for objects K is always string
|
|
3037
|
-
create(new ObjectView({ model }), callback);
|
|
3038
|
-
}
|
|
3039
|
-
else {
|
|
3040
|
-
throw userError("wrong use of `v.for` function", 'wrong-model');
|
|
3041
|
-
}
|
|
3042
|
-
},
|
|
3043
|
-
watch(model, callback) {
|
|
3044
|
-
const opts = { model };
|
|
3045
|
-
create(new Watch(opts), callback);
|
|
3046
|
-
},
|
|
3047
|
-
nextTick(callback) {
|
|
3048
|
-
const node = current;
|
|
3049
|
-
window.setTimeout(() => {
|
|
3050
|
-
node.runFunctional(callback);
|
|
3051
|
-
}, 0);
|
|
3052
|
-
}
|
|
3053
|
-
};
|
|
3054
|
-
|
|
3055
|
-
window.app = app;
|
|
3056
|
-
window.component = component;
|
|
3057
|
-
window.fragment = fragment;
|
|
3058
|
-
window.extension = extension;
|
|
3059
|
-
window.tag = tag;
|
|
3060
|
-
window.create = create;
|
|
3061
|
-
window.vx = vx;
|
|
3062
|
-
|
|
3063
|
-
// ./lib/functional/models.js
|
|
3064
|
-
function arrayModel(arr = []) {
|
|
3065
|
-
if (!current)
|
|
3066
|
-
throw userError('missing parent node', 'out-of-context');
|
|
3067
|
-
return current.register(new ArrayModel(arr)).proxy();
|
|
3068
|
-
}
|
|
3069
|
-
function mapModel(map = []) {
|
|
3070
|
-
if (!current)
|
|
3071
|
-
throw userError('missing parent node', 'out-of-context');
|
|
3072
|
-
return current.register(new MapModel(map));
|
|
3073
|
-
}
|
|
3074
|
-
function setModel(arr = []) {
|
|
3075
|
-
if (!current)
|
|
3076
|
-
throw userError('missing parent node', 'out-of-context');
|
|
3077
|
-
return current.register(new SetModel(arr));
|
|
3078
|
-
}
|
|
3079
|
-
function objectModel(obj = {}) {
|
|
3080
|
-
if (!current)
|
|
3081
|
-
throw userError('missing parent node', 'out-of-context');
|
|
3082
|
-
return current.register(new ObjectModel(obj));
|
|
3083
|
-
}
|
|
3084
|
-
|
|
3085
|
-
window.arrayModel = arrayModel;
|
|
3086
|
-
window.mapModel = mapModel;
|
|
3087
|
-
window.setModel = setModel;
|
|
3088
|
-
window.objectModel = objectModel;
|
|
3089
|
-
|
|
3090
2465
|
// ./lib/functional/options.js
|
|
3091
2466
|
|
|
3092
2467
|
|
|
3093
2468
|
|
|
3094
|
-
// ./lib/functional/reactivity.js
|
|
3095
|
-
function ref(value) {
|
|
3096
|
-
const ref = current.ref(value);
|
|
3097
|
-
return [ref, (value) => ref.$ = value];
|
|
3098
|
-
}
|
|
3099
|
-
function mirror(value) {
|
|
3100
|
-
return current.mirror(value);
|
|
3101
|
-
}
|
|
3102
|
-
function forward(value) {
|
|
3103
|
-
return current.forward(value);
|
|
3104
|
-
}
|
|
3105
|
-
function point(value) {
|
|
3106
|
-
return current.point(value);
|
|
3107
|
-
}
|
|
3108
|
-
function expr(func, ...values) {
|
|
3109
|
-
return current.expr(func, ...values);
|
|
3110
|
-
}
|
|
3111
|
-
function watch(func, ...values) {
|
|
3112
|
-
current.watch(func, ...values);
|
|
3113
|
-
}
|
|
3114
|
-
function valueOf(value) {
|
|
3115
|
-
return value.$;
|
|
3116
|
-
}
|
|
3117
|
-
function setValue(ref, value) {
|
|
3118
|
-
if (ref instanceof Pointer && value instanceof IValue) {
|
|
3119
|
-
ref.$$ = value;
|
|
3120
|
-
}
|
|
3121
|
-
else {
|
|
3122
|
-
ref.$ = value instanceof IValue ? value.$ : value;
|
|
3123
|
-
}
|
|
3124
|
-
}
|
|
3125
|
-
|
|
3126
|
-
window.ref = ref;
|
|
3127
|
-
window.mirror = mirror;
|
|
3128
|
-
window.forward = forward;
|
|
3129
|
-
window.point = point;
|
|
3130
|
-
window.expr = expr;
|
|
3131
|
-
window.watch = watch;
|
|
3132
|
-
window.valueOf = valueOf;
|
|
3133
|
-
window.setValue = setValue;
|
|
3134
|
-
|
|
3135
|
-
// ./lib/functional/components.js
|
|
3136
|
-
function text(text) {
|
|
3137
|
-
if (!(current instanceof Fragment))
|
|
3138
|
-
throw userError('missing parent node', 'out-of-context');
|
|
3139
|
-
;
|
|
3140
|
-
current.text(text);
|
|
3141
|
-
}
|
|
3142
|
-
function debug(text) {
|
|
3143
|
-
if (!(current instanceof Fragment))
|
|
3144
|
-
throw userError('missing parent node', 'out-of-context');
|
|
3145
|
-
current.debug(text);
|
|
3146
|
-
}
|
|
3147
|
-
function predefine(slot, predefined) {
|
|
3148
|
-
return slot || predefined;
|
|
3149
|
-
}
|
|
3150
|
-
|
|
3151
|
-
window.text = text;
|
|
3152
|
-
window.debug = debug;
|
|
3153
|
-
window.predefine = predefine;
|
|
3154
|
-
|
|
3155
|
-
// ./lib/v/index.js
|
|
3156
|
-
|
|
3157
|
-
const v = Object.assign(Object.assign({ ref(value) {
|
|
3158
|
-
return current.ref(value);
|
|
3159
|
-
}, expr: expr, of: valueOf, sv: setValue, alwaysFalse: new Reference(false), app,
|
|
3160
|
-
component,
|
|
3161
|
-
fragment,
|
|
3162
|
-
extension,
|
|
3163
|
-
text,
|
|
3164
|
-
tag,
|
|
3165
|
-
create }, vx), { merge,
|
|
3166
|
-
destructor() {
|
|
3167
|
-
return current.$destroy.bind(current);
|
|
3168
|
-
},
|
|
3169
|
-
runOnDestroy(callback) {
|
|
3170
|
-
current.runOnDestroy(callback);
|
|
3171
|
-
} });
|
|
3172
|
-
|
|
3173
|
-
window.v = v;
|
|
3174
|
-
|
|
3175
2469
|
})();
|