vasille 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/es2015.js +0 -692
- package/cdn/es5.js +661 -926
- package/flow-typed/vasille.js +0 -46
- package/lib-node/binding/attribute.js +35 -0
- package/lib-node/binding/binding.js +33 -0
- package/lib-node/binding/class.js +48 -0
- package/lib-node/binding/style.js +27 -0
- package/lib-node/core/core.js +243 -0
- package/lib-node/core/destroyable.js +49 -0
- package/lib-node/core/errors.js +23 -0
- package/lib-node/core/ivalue.js +63 -0
- package/lib-node/functional/options.js +2 -0
- package/lib-node/index.js +49 -0
- package/lib-node/models/array-model.js +218 -0
- package/lib-node/models/listener.js +134 -0
- package/lib-node/models/map-model.js +70 -0
- package/lib-node/models/model.js +2 -0
- package/lib-node/models/object-model.js +82 -0
- package/lib-node/models/set-model.js +66 -0
- package/lib-node/node/app.js +54 -0
- package/lib-node/node/node.js +885 -0
- package/lib-node/node/watch.js +23 -0
- package/lib-node/spec/html.js +2 -0
- package/lib-node/spec/react.js +2 -0
- package/lib-node/spec/svg.js +2 -0
- package/lib-node/value/expression.js +90 -0
- package/lib-node/value/mirror.js +60 -0
- package/lib-node/value/pointer.js +30 -0
- package/lib-node/value/reference.js +55 -0
- package/lib-node/views/array-view.js +21 -0
- package/lib-node/views/base-view.js +43 -0
- package/lib-node/views/map-view.js +18 -0
- package/lib-node/views/object-view.js +20 -0
- package/lib-node/views/repeat-node.js +71 -0
- package/lib-node/views/set-view.js +19 -0
- package/package.json +21 -17
- package/lib/core/executor.js +0 -154
- package/lib/core/signal.js +0 -50
- package/lib/core/slot.js +0 -47
- package/lib/functional/components.js +0 -17
- package/lib/functional/merge.js +0 -41
- package/lib/functional/models.js +0 -26
- package/lib/functional/reactivity.js +0 -33
- package/lib/functional/stack.js +0 -127
- package/lib/node/interceptor.js +0 -83
- package/lib/v/index.js +0 -23
- package/lib/views/repeater.js +0 -63
- package/types/functional/components.d.ts +0 -4
- package/types/functional/merge.d.ts +0 -1
- package/types/functional/models.d.ts +0 -10
- package/types/functional/reactivity.d.ts +0 -11
- package/types/functional/stack.d.ts +0 -24
- package/types/v/index.d.ts +0 -36
package/cdn/es2015.js
CHANGED
|
@@ -569,111 +569,6 @@ class ArrayModel extends Array {
|
|
|
569
569
|
|
|
570
570
|
window.ArrayModel = ArrayModel;
|
|
571
571
|
|
|
572
|
-
// ./lib/core/signal.js
|
|
573
|
-
/**
|
|
574
|
-
* Signal is an event generator
|
|
575
|
-
* @class Signal
|
|
576
|
-
*/
|
|
577
|
-
class Signal {
|
|
578
|
-
constructor() {
|
|
579
|
-
/**
|
|
580
|
-
* Handler of event
|
|
581
|
-
* @type {Set}
|
|
582
|
-
* @private
|
|
583
|
-
*/
|
|
584
|
-
this.handlers = new Set;
|
|
585
|
-
}
|
|
586
|
-
/**
|
|
587
|
-
* Emit event
|
|
588
|
-
* @param a1 {*} argument
|
|
589
|
-
* @param a2 {*} argument
|
|
590
|
-
* @param a3 {*} argument
|
|
591
|
-
* @param a4 {*} argument
|
|
592
|
-
* @param a5 {*} argument
|
|
593
|
-
* @param a6 {*} argument
|
|
594
|
-
* @param a7 {*} argument
|
|
595
|
-
* @param a8 {*} argument
|
|
596
|
-
* @param a9 {*} argument
|
|
597
|
-
*/
|
|
598
|
-
emit(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
|
599
|
-
this.handlers.forEach(handler => {
|
|
600
|
-
try {
|
|
601
|
-
handler(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
|
602
|
-
}
|
|
603
|
-
catch (e) {
|
|
604
|
-
console.error(`Vasille.js: Handler throw exception: `, e);
|
|
605
|
-
}
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
/**
|
|
609
|
-
* Subscribe to event
|
|
610
|
-
* @param func {function} handler
|
|
611
|
-
*/
|
|
612
|
-
subscribe(func) {
|
|
613
|
-
this.handlers.add(func);
|
|
614
|
-
}
|
|
615
|
-
/**
|
|
616
|
-
* Unsubscribe from event
|
|
617
|
-
* @param func {function} handler
|
|
618
|
-
*/
|
|
619
|
-
unsubscribe(func) {
|
|
620
|
-
this.handlers.delete(func);
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
window.Signal = Signal;
|
|
625
|
-
|
|
626
|
-
// ./lib/core/slot.js
|
|
627
|
-
/**
|
|
628
|
-
* Component slot
|
|
629
|
-
* @class Slot
|
|
630
|
-
*/
|
|
631
|
-
class Slot {
|
|
632
|
-
/**
|
|
633
|
-
* Sets the runner
|
|
634
|
-
* @param func {function} the function to run
|
|
635
|
-
*/
|
|
636
|
-
insert(func) {
|
|
637
|
-
this.runner = func;
|
|
638
|
-
}
|
|
639
|
-
/**
|
|
640
|
-
* @param a0 {Fragment} node to paste content
|
|
641
|
-
* @param a1 {*} 1st argument
|
|
642
|
-
* @param a2 {*} 2nd argument
|
|
643
|
-
* @param a3 {*} 3rd argument
|
|
644
|
-
* @param a4 {*} 4th argument
|
|
645
|
-
* @param a5 {*} 5th argument
|
|
646
|
-
* @param a6 {*} 6th argument
|
|
647
|
-
* @param a7 {*} 7th argument
|
|
648
|
-
* @param a8 {*} 8th argument
|
|
649
|
-
* @param a9 {*} 9th argument
|
|
650
|
-
*/
|
|
651
|
-
release(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
|
652
|
-
if (this.runner) {
|
|
653
|
-
this.runner(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
/**
|
|
657
|
-
* Predefine a handler for a slot
|
|
658
|
-
* @param func {function(node : Fragment)} Function to run if no handler specified
|
|
659
|
-
* @param a0 {Fragment} node to paste content
|
|
660
|
-
* @param a1 {*} 1st argument
|
|
661
|
-
* @param a2 {*} 2nd argument
|
|
662
|
-
* @param a3 {*} 3rd argument
|
|
663
|
-
* @param a4 {*} 4th argument
|
|
664
|
-
* @param a5 {*} 5th argument
|
|
665
|
-
* @param a6 {*} 6th argument
|
|
666
|
-
* @param a7 {*} 7th argument
|
|
667
|
-
* @param a8 {*} 8th argument
|
|
668
|
-
* @param a9 {*} 9th argument
|
|
669
|
-
*/
|
|
670
|
-
predefine(func, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
|
671
|
-
(this.runner || func)(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
window.Slot = Slot;
|
|
676
|
-
|
|
677
572
|
// ./lib/core/errors.js
|
|
678
573
|
const reportIt = "Report it here: https://gitlab.com/vasille-js/vasille-js/-/issues";
|
|
679
574
|
function notOverwritten() {
|
|
@@ -697,167 +592,6 @@ window.internalError = internalError;
|
|
|
697
592
|
window.userError = userError;
|
|
698
593
|
window.wrongBinding = wrongBinding;
|
|
699
594
|
|
|
700
|
-
// ./lib/core/executor.js
|
|
701
|
-
/**
|
|
702
|
-
* Represents an executor unit interface
|
|
703
|
-
* @class Executor
|
|
704
|
-
*/
|
|
705
|
-
class Executor {
|
|
706
|
-
/**
|
|
707
|
-
* Adds a CSS class
|
|
708
|
-
* @param el {Element} element to manipulate
|
|
709
|
-
* @param cl {string} class to be added
|
|
710
|
-
*/
|
|
711
|
-
addClass(el, cl) {
|
|
712
|
-
throw notOverwritten();
|
|
713
|
-
}
|
|
714
|
-
/**
|
|
715
|
-
* Removes a CSS class
|
|
716
|
-
* @param el {Element} element to manipulate
|
|
717
|
-
* @param cl {string} class to be removed
|
|
718
|
-
*/
|
|
719
|
-
removeClass(el, cl) {
|
|
720
|
-
throw notOverwritten();
|
|
721
|
-
}
|
|
722
|
-
/**
|
|
723
|
-
* Sets a tag attribute
|
|
724
|
-
* @param el {Element} element to manipulate
|
|
725
|
-
* @param name {string} name of attribute
|
|
726
|
-
* @param value {string} value of attribute
|
|
727
|
-
*/
|
|
728
|
-
setAttribute(el, name, value) {
|
|
729
|
-
throw notOverwritten();
|
|
730
|
-
}
|
|
731
|
-
/**
|
|
732
|
-
* Removes a tag attribute
|
|
733
|
-
* @param el {Element} element to manipulate
|
|
734
|
-
* @param name {string} name of attribute
|
|
735
|
-
*/
|
|
736
|
-
removeAttribute(el, name) {
|
|
737
|
-
throw notOverwritten();
|
|
738
|
-
}
|
|
739
|
-
/**
|
|
740
|
-
* Sets a style attribute
|
|
741
|
-
* @param el {HTMLElement} element to manipulate
|
|
742
|
-
* @param prop {string} property name
|
|
743
|
-
* @param value {string} property value
|
|
744
|
-
*/
|
|
745
|
-
setStyle(el, prop, value) {
|
|
746
|
-
throw notOverwritten();
|
|
747
|
-
}
|
|
748
|
-
/**
|
|
749
|
-
* Inserts a child before target
|
|
750
|
-
* @param target {Element} target element
|
|
751
|
-
* @param child {Node} element to insert before
|
|
752
|
-
*/
|
|
753
|
-
insertBefore(target, child) {
|
|
754
|
-
throw notOverwritten();
|
|
755
|
-
}
|
|
756
|
-
/**
|
|
757
|
-
* Appends a child to element
|
|
758
|
-
* @param el {Element} element
|
|
759
|
-
* @param child {Node} child to be inserted
|
|
760
|
-
*/
|
|
761
|
-
appendChild(el, child) {
|
|
762
|
-
throw notOverwritten();
|
|
763
|
-
}
|
|
764
|
-
/**
|
|
765
|
-
* Calls a call-back function
|
|
766
|
-
* @param cb {function} call-back function
|
|
767
|
-
*/
|
|
768
|
-
callCallback(cb) {
|
|
769
|
-
throw notOverwritten();
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
/**
|
|
773
|
-
* Executor which execute any commands immediately
|
|
774
|
-
* @class InstantExecutor
|
|
775
|
-
* @extends Executor
|
|
776
|
-
*/
|
|
777
|
-
class InstantExecutor extends Executor {
|
|
778
|
-
addClass(el, cl) {
|
|
779
|
-
el.classList.add(cl);
|
|
780
|
-
}
|
|
781
|
-
removeClass(el, cl) {
|
|
782
|
-
el.classList.remove(cl);
|
|
783
|
-
}
|
|
784
|
-
setAttribute(el, name, value) {
|
|
785
|
-
el.setAttribute(name, value);
|
|
786
|
-
}
|
|
787
|
-
removeAttribute(el, name) {
|
|
788
|
-
el.removeAttribute(name);
|
|
789
|
-
}
|
|
790
|
-
setStyle(el, prop, value) {
|
|
791
|
-
el.style.setProperty(prop, value);
|
|
792
|
-
}
|
|
793
|
-
insertBefore(target, child) {
|
|
794
|
-
const parent = target.parentNode;
|
|
795
|
-
if (!parent) {
|
|
796
|
-
throw internalError('element don\'t have a parent node');
|
|
797
|
-
}
|
|
798
|
-
parent.insertBefore(child, target);
|
|
799
|
-
}
|
|
800
|
-
appendChild(el, child) {
|
|
801
|
-
el.appendChild(child);
|
|
802
|
-
}
|
|
803
|
-
callCallback(cb) {
|
|
804
|
-
cb();
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
/**
|
|
808
|
-
* Executor which execute any commands over timeout
|
|
809
|
-
* @class TimeoutExecutor
|
|
810
|
-
* @extends InstantExecutor
|
|
811
|
-
*/
|
|
812
|
-
class TimeoutExecutor extends InstantExecutor {
|
|
813
|
-
addClass(el, cl) {
|
|
814
|
-
setTimeout(() => {
|
|
815
|
-
super.addClass(el, cl);
|
|
816
|
-
}, 0);
|
|
817
|
-
}
|
|
818
|
-
removeClass(el, cl) {
|
|
819
|
-
setTimeout(() => {
|
|
820
|
-
super.removeClass(el, cl);
|
|
821
|
-
}, 0);
|
|
822
|
-
}
|
|
823
|
-
setAttribute(el, name, value) {
|
|
824
|
-
setTimeout(() => {
|
|
825
|
-
super.setAttribute(el, name, value);
|
|
826
|
-
}, 0);
|
|
827
|
-
}
|
|
828
|
-
removeAttribute(el, name) {
|
|
829
|
-
setTimeout(() => {
|
|
830
|
-
super.removeAttribute(el, name);
|
|
831
|
-
}, 0);
|
|
832
|
-
}
|
|
833
|
-
setStyle(el, prop, value) {
|
|
834
|
-
setTimeout(() => {
|
|
835
|
-
super.setStyle(el, prop, value);
|
|
836
|
-
}, 0);
|
|
837
|
-
}
|
|
838
|
-
insertBefore(target, child) {
|
|
839
|
-
setTimeout(() => {
|
|
840
|
-
super.insertBefore(target, child);
|
|
841
|
-
}, 0);
|
|
842
|
-
}
|
|
843
|
-
appendChild(el, child) {
|
|
844
|
-
setTimeout(() => {
|
|
845
|
-
super.appendChild(el, child);
|
|
846
|
-
}, 0);
|
|
847
|
-
}
|
|
848
|
-
callCallback(cb) {
|
|
849
|
-
setTimeout(cb, 0);
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
const instantExecutor = new InstantExecutor();
|
|
853
|
-
const timeoutExecutor = new TimeoutExecutor();
|
|
854
|
-
|
|
855
|
-
window.Executor = Executor;
|
|
856
|
-
window.InstantExecutor = InstantExecutor;
|
|
857
|
-
window.TimeoutExecutor = TimeoutExecutor;
|
|
858
|
-
window.instantExecutor = instantExecutor;
|
|
859
|
-
window.timeoutExecutor = timeoutExecutor;
|
|
860
|
-
|
|
861
595
|
// ./lib/core/destroyable.js
|
|
862
596
|
/**
|
|
863
597
|
* Mark an object which can be destroyed
|
|
@@ -2413,90 +2147,6 @@ window.AppNode = AppNode;
|
|
|
2413
2147
|
window.App = App;
|
|
2414
2148
|
window.Portal = Portal;
|
|
2415
2149
|
|
|
2416
|
-
// ./lib/node/interceptor.js
|
|
2417
|
-
/**
|
|
2418
|
-
* Interceptor is designed to connect signals & methods of children elements
|
|
2419
|
-
* @class Interceptor
|
|
2420
|
-
* @extends Destroyable
|
|
2421
|
-
*/
|
|
2422
|
-
class Interceptor extends Destroyable {
|
|
2423
|
-
constructor() {
|
|
2424
|
-
super(...arguments);
|
|
2425
|
-
/**
|
|
2426
|
-
* Set of signals
|
|
2427
|
-
* @type Set
|
|
2428
|
-
*/
|
|
2429
|
-
this.signals = new Set;
|
|
2430
|
-
/**
|
|
2431
|
-
* Set of handlers
|
|
2432
|
-
* @type Set
|
|
2433
|
-
*/
|
|
2434
|
-
this.handlers = new Set;
|
|
2435
|
-
}
|
|
2436
|
-
/**
|
|
2437
|
-
* Connect a signal or a handler
|
|
2438
|
-
* @param thing {Signal | function}
|
|
2439
|
-
*/
|
|
2440
|
-
connect(thing) {
|
|
2441
|
-
// interceptor will connect signals and handlers together
|
|
2442
|
-
if (thing instanceof Signal) {
|
|
2443
|
-
this.handlers.forEach(handler => {
|
|
2444
|
-
thing.subscribe(handler);
|
|
2445
|
-
});
|
|
2446
|
-
this.signals.add(thing);
|
|
2447
|
-
}
|
|
2448
|
-
else {
|
|
2449
|
-
this.signals.forEach(signal => {
|
|
2450
|
-
signal.subscribe(thing);
|
|
2451
|
-
});
|
|
2452
|
-
this.handlers.add(thing);
|
|
2453
|
-
}
|
|
2454
|
-
}
|
|
2455
|
-
/**
|
|
2456
|
-
* Disconnect a handler from signals
|
|
2457
|
-
* @param handler {function}
|
|
2458
|
-
*/
|
|
2459
|
-
disconnect(handler) {
|
|
2460
|
-
this.signals.forEach(signal => {
|
|
2461
|
-
signal.unsubscribe(handler);
|
|
2462
|
-
});
|
|
2463
|
-
}
|
|
2464
|
-
destroy() {
|
|
2465
|
-
super.destroy();
|
|
2466
|
-
this.signals.forEach(signal => {
|
|
2467
|
-
this.handlers.forEach(handler => {
|
|
2468
|
-
signal.unsubscribe(handler);
|
|
2469
|
-
});
|
|
2470
|
-
});
|
|
2471
|
-
}
|
|
2472
|
-
}
|
|
2473
|
-
/**
|
|
2474
|
-
* Interceptor node to implement directly to vasille DOM
|
|
2475
|
-
* @class InterceptorNode
|
|
2476
|
-
* @extends Extension
|
|
2477
|
-
*/
|
|
2478
|
-
class InterceptorNode extends Fragment {
|
|
2479
|
-
constructor() {
|
|
2480
|
-
super(...arguments);
|
|
2481
|
-
/**
|
|
2482
|
-
* Internal interceptor
|
|
2483
|
-
* @type Interceptor
|
|
2484
|
-
*/
|
|
2485
|
-
this.interceptor = new Interceptor;
|
|
2486
|
-
/**
|
|
2487
|
-
* The default slot of node
|
|
2488
|
-
* @type Slot
|
|
2489
|
-
*/
|
|
2490
|
-
this.slot = new Slot;
|
|
2491
|
-
}
|
|
2492
|
-
compose() {
|
|
2493
|
-
this.slot.release(this, this.interceptor);
|
|
2494
|
-
}
|
|
2495
|
-
}
|
|
2496
|
-
|
|
2497
|
-
window.Interceptor = Interceptor;
|
|
2498
|
-
window.InterceptorNode = InterceptorNode;
|
|
2499
|
-
|
|
2500
2150
|
// ./lib/binding/attribute.js
|
|
2501
2151
|
/**
|
|
2502
2152
|
* Represents an Attribute binding description
|
|
@@ -2674,72 +2324,6 @@ class RepeatNode extends Fragment {
|
|
|
2674
2324
|
window.RepeatNodePrivate = RepeatNodePrivate;
|
|
2675
2325
|
window.RepeatNode = RepeatNode;
|
|
2676
2326
|
|
|
2677
|
-
// ./lib/views/repeater.js
|
|
2678
|
-
/**
|
|
2679
|
-
* Private part of repeater
|
|
2680
|
-
* @class RepeaterPrivate
|
|
2681
|
-
* @extends RepeatNodePrivate
|
|
2682
|
-
*/
|
|
2683
|
-
class RepeaterPrivate extends RepeatNodePrivate {
|
|
2684
|
-
constructor() {
|
|
2685
|
-
super();
|
|
2686
|
-
/**
|
|
2687
|
-
* Current count of child nodes
|
|
2688
|
-
*/
|
|
2689
|
-
this.currentCount = 0;
|
|
2690
|
-
this.seal();
|
|
2691
|
-
}
|
|
2692
|
-
}
|
|
2693
|
-
/**
|
|
2694
|
-
* The simplest repeat node interpretation, repeat children pack a several times
|
|
2695
|
-
* @class Repeater
|
|
2696
|
-
* @extends RepeatNode
|
|
2697
|
-
*/
|
|
2698
|
-
class Repeater extends RepeatNode {
|
|
2699
|
-
constructor($) {
|
|
2700
|
-
super($ || new RepeaterPrivate);
|
|
2701
|
-
/**
|
|
2702
|
-
* The count of children
|
|
2703
|
-
*/
|
|
2704
|
-
this.count = new Reference(0);
|
|
2705
|
-
this.seal();
|
|
2706
|
-
}
|
|
2707
|
-
/**
|
|
2708
|
-
* Changes the children count
|
|
2709
|
-
*/
|
|
2710
|
-
changeCount(number) {
|
|
2711
|
-
const $ = this.$;
|
|
2712
|
-
if (number > $.currentCount) {
|
|
2713
|
-
for (let i = $.currentCount; i < number; i++) {
|
|
2714
|
-
this.createChild(i, i);
|
|
2715
|
-
}
|
|
2716
|
-
}
|
|
2717
|
-
else {
|
|
2718
|
-
for (let i = $.currentCount - 1; i >= number; i--) {
|
|
2719
|
-
this.destroyChild(i, i);
|
|
2720
|
-
}
|
|
2721
|
-
}
|
|
2722
|
-
$.currentCount = number;
|
|
2723
|
-
}
|
|
2724
|
-
created() {
|
|
2725
|
-
const $ = this.$;
|
|
2726
|
-
super.created();
|
|
2727
|
-
$.updateHandler = this.changeCount.bind(this);
|
|
2728
|
-
this.count.on($.updateHandler);
|
|
2729
|
-
}
|
|
2730
|
-
ready() {
|
|
2731
|
-
this.changeCount(this.count.$);
|
|
2732
|
-
}
|
|
2733
|
-
destroy() {
|
|
2734
|
-
const $ = this.$;
|
|
2735
|
-
super.destroy();
|
|
2736
|
-
this.count.off($.updateHandler);
|
|
2737
|
-
}
|
|
2738
|
-
}
|
|
2739
|
-
|
|
2740
|
-
window.RepeaterPrivate = RepeaterPrivate;
|
|
2741
|
-
window.Repeater = Repeater;
|
|
2742
|
-
|
|
2743
2327
|
// ./lib/views/base-view.js
|
|
2744
2328
|
/**
|
|
2745
2329
|
* Private part of BaseView
|
|
@@ -2878,284 +2462,8 @@ class SetView extends BaseView {
|
|
|
2878
2462
|
|
|
2879
2463
|
window.SetView = SetView;
|
|
2880
2464
|
|
|
2881
|
-
// ./lib/functional/merge.js
|
|
2882
|
-
function merge(main, ...targets) {
|
|
2883
|
-
function refactorClass(obj) {
|
|
2884
|
-
if (Array.isArray(obj.class)) {
|
|
2885
|
-
const out = {
|
|
2886
|
-
$: []
|
|
2887
|
-
};
|
|
2888
|
-
obj.class.forEach(item => {
|
|
2889
|
-
if (item instanceof IValue) {
|
|
2890
|
-
out.$.push(item);
|
|
2891
|
-
}
|
|
2892
|
-
else if (typeof item === 'string') {
|
|
2893
|
-
out[item] = true;
|
|
2894
|
-
}
|
|
2895
|
-
else if (typeof item === 'object') {
|
|
2896
|
-
Object.assign(out, item);
|
|
2897
|
-
}
|
|
2898
|
-
});
|
|
2899
|
-
obj.class = out;
|
|
2900
|
-
}
|
|
2901
|
-
}
|
|
2902
|
-
refactorClass(main);
|
|
2903
|
-
targets.forEach(target => {
|
|
2904
|
-
Reflect.ownKeys(target).forEach((prop) => {
|
|
2905
|
-
if (!Reflect.has(main, prop)) {
|
|
2906
|
-
main[prop] = target[prop];
|
|
2907
|
-
}
|
|
2908
|
-
else if (typeof main[prop] === 'object' && typeof target[prop] === 'object') {
|
|
2909
|
-
if (prop === 'class') {
|
|
2910
|
-
refactorClass(target);
|
|
2911
|
-
}
|
|
2912
|
-
if (prop === '$' && Array.isArray(main[prop]) && Array.isArray(target[prop])) {
|
|
2913
|
-
main.$.push(...target.$);
|
|
2914
|
-
}
|
|
2915
|
-
else {
|
|
2916
|
-
merge(main[prop], target[prop]);
|
|
2917
|
-
}
|
|
2918
|
-
}
|
|
2919
|
-
});
|
|
2920
|
-
});
|
|
2921
|
-
}
|
|
2922
|
-
|
|
2923
|
-
window.merge = merge;
|
|
2924
|
-
|
|
2925
|
-
// ./lib/functional/stack.js
|
|
2926
|
-
function app(renderer) {
|
|
2927
|
-
return (node, opts) => {
|
|
2928
|
-
return new App(node, opts).runFunctional(renderer, opts);
|
|
2929
|
-
};
|
|
2930
|
-
}
|
|
2931
|
-
function component(renderer) {
|
|
2932
|
-
return (opts, callback) => {
|
|
2933
|
-
const component = new Component(opts);
|
|
2934
|
-
if (!(current instanceof Fragment))
|
|
2935
|
-
throw userError('missing parent node', 'out-of-context');
|
|
2936
|
-
let ret;
|
|
2937
|
-
if (callback)
|
|
2938
|
-
opts.slot = callback;
|
|
2939
|
-
current.create(component, node => {
|
|
2940
|
-
ret = node.runFunctional(renderer, opts);
|
|
2941
|
-
});
|
|
2942
|
-
return ret;
|
|
2943
|
-
};
|
|
2944
|
-
}
|
|
2945
|
-
function fragment(renderer) {
|
|
2946
|
-
return (opts, callback) => {
|
|
2947
|
-
const frag = new Fragment(opts);
|
|
2948
|
-
if (!(current instanceof Fragment))
|
|
2949
|
-
throw userError('missing parent node', 'out-of-context');
|
|
2950
|
-
if (callback)
|
|
2951
|
-
opts.slot = callback;
|
|
2952
|
-
current.create(frag);
|
|
2953
|
-
return frag.runFunctional(renderer, opts);
|
|
2954
|
-
};
|
|
2955
|
-
}
|
|
2956
|
-
function extension(renderer) {
|
|
2957
|
-
return (opts, callback) => {
|
|
2958
|
-
const ext = new Extension(opts);
|
|
2959
|
-
if (!(current instanceof Fragment))
|
|
2960
|
-
throw userError('missing parent node', 'out-of-context');
|
|
2961
|
-
if (callback)
|
|
2962
|
-
opts.slot = callback;
|
|
2963
|
-
current.create(ext);
|
|
2964
|
-
return ext.runFunctional(renderer, opts);
|
|
2965
|
-
};
|
|
2966
|
-
}
|
|
2967
|
-
function tag(name, opts, callback) {
|
|
2968
|
-
if (!(current instanceof Fragment))
|
|
2969
|
-
throw userError('missing parent node', 'out-of-context');
|
|
2970
|
-
return {
|
|
2971
|
-
node: current.tag(name, opts, (node) => {
|
|
2972
|
-
callback && node.runFunctional(callback);
|
|
2973
|
-
})
|
|
2974
|
-
};
|
|
2975
|
-
}
|
|
2976
|
-
function create(node, callback) {
|
|
2977
|
-
if (!(current instanceof Fragment))
|
|
2978
|
-
throw userError('missing current node', 'out-of-context');
|
|
2979
|
-
current.create(node, (node, ...args) => {
|
|
2980
|
-
callback && node.runFunctional(callback, ...args);
|
|
2981
|
-
});
|
|
2982
|
-
return node;
|
|
2983
|
-
}
|
|
2984
|
-
const vx = {
|
|
2985
|
-
if(condition, callback) {
|
|
2986
|
-
if (current instanceof Fragment) {
|
|
2987
|
-
current.if(condition, node => node.runFunctional(callback));
|
|
2988
|
-
}
|
|
2989
|
-
else {
|
|
2990
|
-
throw userError("wrong use of `v.if` function", "logic-error");
|
|
2991
|
-
}
|
|
2992
|
-
},
|
|
2993
|
-
else(callback) {
|
|
2994
|
-
if (current instanceof Fragment) {
|
|
2995
|
-
current.else(node => node.runFunctional(callback));
|
|
2996
|
-
}
|
|
2997
|
-
else {
|
|
2998
|
-
throw userError("wrong use of `v.else` function", "logic-error");
|
|
2999
|
-
}
|
|
3000
|
-
},
|
|
3001
|
-
elif(condition, callback) {
|
|
3002
|
-
if (current instanceof Fragment) {
|
|
3003
|
-
current.elif(condition, node => node.runFunctional(callback));
|
|
3004
|
-
}
|
|
3005
|
-
else {
|
|
3006
|
-
throw userError("wrong use of `v.elif` function", "logic-error");
|
|
3007
|
-
}
|
|
3008
|
-
},
|
|
3009
|
-
for(model, callback) {
|
|
3010
|
-
if (model instanceof ArrayModel) {
|
|
3011
|
-
// for arrays T & K are the same type
|
|
3012
|
-
create(new ArrayView({ model }), callback);
|
|
3013
|
-
}
|
|
3014
|
-
else if (model instanceof MapModel) {
|
|
3015
|
-
create(new MapView({ model }), callback);
|
|
3016
|
-
}
|
|
3017
|
-
else if (model instanceof SetModel) {
|
|
3018
|
-
// for sets T & K are the same type
|
|
3019
|
-
create(new SetView({ model }), callback);
|
|
3020
|
-
}
|
|
3021
|
-
else if (model instanceof ObjectModel) {
|
|
3022
|
-
// for objects K is always string
|
|
3023
|
-
create(new ObjectView({ model }), callback);
|
|
3024
|
-
}
|
|
3025
|
-
else {
|
|
3026
|
-
throw userError("wrong use of `v.for` function", 'wrong-model');
|
|
3027
|
-
}
|
|
3028
|
-
},
|
|
3029
|
-
watch(model, callback) {
|
|
3030
|
-
const opts = { model };
|
|
3031
|
-
create(new Watch(opts), callback);
|
|
3032
|
-
},
|
|
3033
|
-
nextTick(callback) {
|
|
3034
|
-
const node = current;
|
|
3035
|
-
window.setTimeout(() => {
|
|
3036
|
-
node.runFunctional(callback);
|
|
3037
|
-
}, 0);
|
|
3038
|
-
}
|
|
3039
|
-
};
|
|
3040
|
-
|
|
3041
|
-
window.app = app;
|
|
3042
|
-
window.component = component;
|
|
3043
|
-
window.fragment = fragment;
|
|
3044
|
-
window.extension = extension;
|
|
3045
|
-
window.tag = tag;
|
|
3046
|
-
window.create = create;
|
|
3047
|
-
window.vx = vx;
|
|
3048
|
-
|
|
3049
|
-
// ./lib/functional/models.js
|
|
3050
|
-
function arrayModel(arr = []) {
|
|
3051
|
-
if (!current)
|
|
3052
|
-
throw userError('missing parent node', 'out-of-context');
|
|
3053
|
-
return current.register(new ArrayModel(arr)).proxy();
|
|
3054
|
-
}
|
|
3055
|
-
function mapModel(map = []) {
|
|
3056
|
-
if (!current)
|
|
3057
|
-
throw userError('missing parent node', 'out-of-context');
|
|
3058
|
-
return current.register(new MapModel(map));
|
|
3059
|
-
}
|
|
3060
|
-
function setModel(arr = []) {
|
|
3061
|
-
if (!current)
|
|
3062
|
-
throw userError('missing parent node', 'out-of-context');
|
|
3063
|
-
return current.register(new SetModel(arr));
|
|
3064
|
-
}
|
|
3065
|
-
function objectModel(obj = {}) {
|
|
3066
|
-
if (!current)
|
|
3067
|
-
throw userError('missing parent node', 'out-of-context');
|
|
3068
|
-
return current.register(new ObjectModel(obj));
|
|
3069
|
-
}
|
|
3070
|
-
|
|
3071
|
-
window.arrayModel = arrayModel;
|
|
3072
|
-
window.mapModel = mapModel;
|
|
3073
|
-
window.setModel = setModel;
|
|
3074
|
-
window.objectModel = objectModel;
|
|
3075
|
-
|
|
3076
2465
|
// ./lib/functional/options.js
|
|
3077
2466
|
|
|
3078
2467
|
|
|
3079
2468
|
|
|
3080
|
-
// ./lib/functional/reactivity.js
|
|
3081
|
-
function ref(value) {
|
|
3082
|
-
const ref = current.ref(value);
|
|
3083
|
-
return [ref, (value) => ref.$ = value];
|
|
3084
|
-
}
|
|
3085
|
-
function mirror(value) {
|
|
3086
|
-
return current.mirror(value);
|
|
3087
|
-
}
|
|
3088
|
-
function forward(value) {
|
|
3089
|
-
return current.forward(value);
|
|
3090
|
-
}
|
|
3091
|
-
function point(value) {
|
|
3092
|
-
return current.point(value);
|
|
3093
|
-
}
|
|
3094
|
-
function expr(func, ...values) {
|
|
3095
|
-
return current.expr(func, ...values);
|
|
3096
|
-
}
|
|
3097
|
-
function watch(func, ...values) {
|
|
3098
|
-
current.watch(func, ...values);
|
|
3099
|
-
}
|
|
3100
|
-
function valueOf(value) {
|
|
3101
|
-
return value.$;
|
|
3102
|
-
}
|
|
3103
|
-
function setValue(ref, value) {
|
|
3104
|
-
if (ref instanceof Pointer && value instanceof IValue) {
|
|
3105
|
-
ref.$$ = value;
|
|
3106
|
-
}
|
|
3107
|
-
else {
|
|
3108
|
-
ref.$ = value instanceof IValue ? value.$ : value;
|
|
3109
|
-
}
|
|
3110
|
-
}
|
|
3111
|
-
|
|
3112
|
-
window.ref = ref;
|
|
3113
|
-
window.mirror = mirror;
|
|
3114
|
-
window.forward = forward;
|
|
3115
|
-
window.point = point;
|
|
3116
|
-
window.expr = expr;
|
|
3117
|
-
window.watch = watch;
|
|
3118
|
-
window.valueOf = valueOf;
|
|
3119
|
-
window.setValue = setValue;
|
|
3120
|
-
|
|
3121
|
-
// ./lib/functional/components.js
|
|
3122
|
-
function text(text) {
|
|
3123
|
-
if (!(current instanceof Fragment))
|
|
3124
|
-
throw userError('missing parent node', 'out-of-context');
|
|
3125
|
-
;
|
|
3126
|
-
current.text(text);
|
|
3127
|
-
}
|
|
3128
|
-
function debug(text) {
|
|
3129
|
-
if (!(current instanceof Fragment))
|
|
3130
|
-
throw userError('missing parent node', 'out-of-context');
|
|
3131
|
-
current.debug(text);
|
|
3132
|
-
}
|
|
3133
|
-
function predefine(slot, predefined) {
|
|
3134
|
-
return slot || predefined;
|
|
3135
|
-
}
|
|
3136
|
-
|
|
3137
|
-
window.text = text;
|
|
3138
|
-
window.debug = debug;
|
|
3139
|
-
window.predefine = predefine;
|
|
3140
|
-
|
|
3141
|
-
// ./lib/v/index.js
|
|
3142
|
-
|
|
3143
|
-
const v = Object.assign(Object.assign({ ref(value) {
|
|
3144
|
-
return current.ref(value);
|
|
3145
|
-
}, expr: expr, of: valueOf, sv: setValue, alwaysFalse: new Reference(false), app,
|
|
3146
|
-
component,
|
|
3147
|
-
fragment,
|
|
3148
|
-
extension,
|
|
3149
|
-
text,
|
|
3150
|
-
tag,
|
|
3151
|
-
create }, vx), { merge,
|
|
3152
|
-
destructor() {
|
|
3153
|
-
return current.$destroy.bind(current);
|
|
3154
|
-
},
|
|
3155
|
-
runOnDestroy(callback) {
|
|
3156
|
-
current.runOnDestroy(callback);
|
|
3157
|
-
} });
|
|
3158
|
-
|
|
3159
|
-
window.v = v;
|
|
3160
|
-
|
|
3161
2469
|
})();
|