mol_jsx_lib 0.0.46 → 0.0.49

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mol_jsx_lib",
3
- "version": "0.0.46",
3
+ "version": "0.0.49",
4
4
  "main": "node.js",
5
5
  "module": "node.esm.js",
6
6
  "browser": "web.js",
package/web.test.js CHANGED
@@ -490,201 +490,6 @@ var $;
490
490
  ;
491
491
  "use strict";
492
492
  var $;
493
- (function ($) {
494
- function $mol_promise() {
495
- let done;
496
- let fail;
497
- const promise = new Promise((d, f) => {
498
- done = d;
499
- fail = f;
500
- });
501
- return Object.assign(promise, {
502
- done,
503
- fail,
504
- });
505
- }
506
- $.$mol_promise = $mol_promise;
507
- })($ || ($ = {}));
508
- //mol/promise/promise.ts
509
- ;
510
- "use strict";
511
- var $;
512
- (function ($) {
513
- $.$mol_after_mock_queue = [];
514
- function $mol_after_mock_warp() {
515
- const queue = $.$mol_after_mock_queue.splice(0);
516
- for (const task of queue)
517
- task();
518
- }
519
- $.$mol_after_mock_warp = $mol_after_mock_warp;
520
- class $mol_after_mock_commmon extends $mol_object2 {
521
- task;
522
- promise = Promise.resolve();
523
- cancelled = false;
524
- id;
525
- constructor(task) {
526
- super();
527
- this.task = task;
528
- $.$mol_after_mock_queue.push(task);
529
- }
530
- destructor() {
531
- const index = $.$mol_after_mock_queue.indexOf(this.task);
532
- if (index >= 0)
533
- $.$mol_after_mock_queue.splice(index, 1);
534
- }
535
- }
536
- $.$mol_after_mock_commmon = $mol_after_mock_commmon;
537
- class $mol_after_mock_timeout extends $mol_after_mock_commmon {
538
- delay;
539
- constructor(delay, task) {
540
- super(task);
541
- this.delay = delay;
542
- }
543
- }
544
- $.$mol_after_mock_timeout = $mol_after_mock_timeout;
545
- })($ || ($ = {}));
546
- //mol/after/mock/mock.test.ts
547
- ;
548
- "use strict";
549
- var $;
550
- (function ($_1) {
551
- $mol_test_mocks.push($ => {
552
- $.$mol_after_timeout = $mol_after_mock_timeout;
553
- });
554
- })($ || ($ = {}));
555
- //mol/after/timeout/timeout.test.ts
556
- ;
557
- "use strict";
558
- var $;
559
- (function ($) {
560
- class $mol_after_timeout extends $mol_object2 {
561
- delay;
562
- task;
563
- id;
564
- constructor(delay, task) {
565
- super();
566
- this.delay = delay;
567
- this.task = task;
568
- this.id = setTimeout(task, delay);
569
- }
570
- destructor() {
571
- clearTimeout(this.id);
572
- }
573
- }
574
- $.$mol_after_timeout = $mol_after_timeout;
575
- })($ || ($ = {}));
576
- //mol/after/timeout/timeout.ts
577
- ;
578
- "use strict";
579
- var $;
580
- (function ($) {
581
- function $mol_wire_sync(obj) {
582
- return new Proxy(obj, {
583
- get(obj, field) {
584
- const val = obj[field];
585
- if (typeof val !== 'function')
586
- return val;
587
- const temp = $mol_wire_task.getter(val);
588
- return function $mol_wire_sync(...args) {
589
- const fiber = temp(obj, args);
590
- return fiber.sync();
591
- };
592
- },
593
- apply(obj, self, args) {
594
- const temp = $mol_wire_task.getter(obj);
595
- const fiber = temp(self, args);
596
- return fiber.sync();
597
- },
598
- });
599
- }
600
- $.$mol_wire_sync = $mol_wire_sync;
601
- })($ || ($ = {}));
602
- //mol/wire/sync/sync.ts
603
- ;
604
- "use strict";
605
- var $;
606
- (function ($) {
607
- function $mol_wait_timeout_async(timeout) {
608
- const promise = $mol_promise();
609
- const task = new this.$mol_after_timeout(timeout, () => promise.done());
610
- return Object.assign(promise, {
611
- destructor: () => task.destructor()
612
- });
613
- }
614
- $.$mol_wait_timeout_async = $mol_wait_timeout_async;
615
- function $mol_wait_timeout(timeout) {
616
- return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
617
- }
618
- $.$mol_wait_timeout = $mol_wait_timeout;
619
- })($ || ($ = {}));
620
- //mol/wait/timeout/timeout.ts
621
- ;
622
- "use strict";
623
- var $;
624
- (function ($_1) {
625
- $mol_test({
626
- async 'Latest Calls Wins on Concurrency'($) {
627
- class NameLogger extends $mol_object2 {
628
- static $ = $;
629
- static first = [];
630
- static last = [];
631
- static send(next) {
632
- $mol_wire_sync(this.first).push(next);
633
- this.$.$mol_wait_timeout(0);
634
- this.last.push(next);
635
- }
636
- }
637
- const name = $mol_wire_async(NameLogger).send;
638
- name('john');
639
- const promise = name('jin');
640
- $.$mol_after_mock_warp();
641
- await promise;
642
- $mol_assert_like(NameLogger.first, ['john', 'jin']);
643
- $mol_assert_like(NameLogger.last, ['jin']);
644
- },
645
- async 'Wrap function'($) {
646
- const name = $mol_wire_async(function (name) {
647
- $.$mol_wait_timeout(0);
648
- return name;
649
- });
650
- const promise = name('jin');
651
- $.$mol_after_mock_warp();
652
- $mol_assert_like(await promise, 'jin');
653
- },
654
- });
655
- })($ || ($ = {}));
656
- //mol/wire/async/async.test.ts
657
- ;
658
- "use strict";
659
- var $;
660
- (function ($) {
661
- function $mol_wire_async(obj) {
662
- return new Proxy(obj, {
663
- get(obj, field) {
664
- const val = obj[field];
665
- if (typeof val !== 'function')
666
- return val;
667
- let fiber;
668
- const temp = $mol_wire_task.getter(val);
669
- return function $mol_wire_async(...args) {
670
- fiber?.destructor();
671
- fiber = temp(obj, args);
672
- return fiber.async();
673
- };
674
- },
675
- apply(obj, self, args) {
676
- const temp = $mol_wire_task.getter(obj);
677
- const fiber = temp(self, args);
678
- return fiber.async();
679
- },
680
- });
681
- }
682
- $.$mol_wire_async = $mol_wire_async;
683
- })($ || ($ = {}));
684
- //mol/wire/async/async.ts
685
- ;
686
- "use strict";
687
- var $;
688
493
  (function ($_1) {
689
494
  $mol_test({
690
495
  'Collect deps'() {
@@ -743,6 +548,44 @@ var $;
743
548
  ;
744
549
  "use strict";
745
550
  var $;
551
+ (function ($) {
552
+ $.$mol_after_mock_queue = [];
553
+ function $mol_after_mock_warp() {
554
+ const queue = $.$mol_after_mock_queue.splice(0);
555
+ for (const task of queue)
556
+ task();
557
+ }
558
+ $.$mol_after_mock_warp = $mol_after_mock_warp;
559
+ class $mol_after_mock_commmon extends $mol_object2 {
560
+ task;
561
+ promise = Promise.resolve();
562
+ cancelled = false;
563
+ id;
564
+ constructor(task) {
565
+ super();
566
+ this.task = task;
567
+ $.$mol_after_mock_queue.push(task);
568
+ }
569
+ destructor() {
570
+ const index = $.$mol_after_mock_queue.indexOf(this.task);
571
+ if (index >= 0)
572
+ $.$mol_after_mock_queue.splice(index, 1);
573
+ }
574
+ }
575
+ $.$mol_after_mock_commmon = $mol_after_mock_commmon;
576
+ class $mol_after_mock_timeout extends $mol_after_mock_commmon {
577
+ delay;
578
+ constructor(delay, task) {
579
+ super(task);
580
+ this.delay = delay;
581
+ }
582
+ }
583
+ $.$mol_after_mock_timeout = $mol_after_mock_timeout;
584
+ })($ || ($ = {}));
585
+ //mol/after/mock/mock.test.ts
586
+ ;
587
+ "use strict";
588
+ var $;
746
589
  (function ($_1) {
747
590
  $mol_test_mocks.push($ => {
748
591
  $.$mol_after_frame = $mol_after_mock_commmon;
@@ -929,6 +772,172 @@ var $;
929
772
  ;
930
773
  "use strict";
931
774
  var $;
775
+ (function ($) {
776
+ function $mol_wire_sync(obj) {
777
+ return new Proxy(obj, {
778
+ get(obj, field) {
779
+ const val = obj[field];
780
+ if (typeof val !== 'function')
781
+ return val;
782
+ const temp = $mol_wire_task.getter(val);
783
+ return function $mol_wire_sync(...args) {
784
+ const fiber = temp(obj, args);
785
+ return fiber.sync();
786
+ };
787
+ },
788
+ apply(obj, self, args) {
789
+ const temp = $mol_wire_task.getter(obj);
790
+ const fiber = temp(self, args);
791
+ return fiber.sync();
792
+ },
793
+ });
794
+ }
795
+ $.$mol_wire_sync = $mol_wire_sync;
796
+ })($ || ($ = {}));
797
+ //mol/wire/sync/sync.ts
798
+ ;
799
+ "use strict";
800
+ var $;
801
+ (function ($) {
802
+ function $mol_promise() {
803
+ let done;
804
+ let fail;
805
+ const promise = new Promise((d, f) => {
806
+ done = d;
807
+ fail = f;
808
+ });
809
+ return Object.assign(promise, {
810
+ done,
811
+ fail,
812
+ });
813
+ }
814
+ $.$mol_promise = $mol_promise;
815
+ })($ || ($ = {}));
816
+ //mol/promise/promise.ts
817
+ ;
818
+ "use strict";
819
+ var $;
820
+ (function ($_1) {
821
+ $mol_test_mocks.push($ => {
822
+ $.$mol_after_timeout = $mol_after_mock_timeout;
823
+ });
824
+ })($ || ($ = {}));
825
+ //mol/after/timeout/timeout.test.ts
826
+ ;
827
+ "use strict";
828
+ var $;
829
+ (function ($) {
830
+ class $mol_after_timeout extends $mol_object2 {
831
+ delay;
832
+ task;
833
+ id;
834
+ constructor(delay, task) {
835
+ super();
836
+ this.delay = delay;
837
+ this.task = task;
838
+ this.id = setTimeout(task, delay);
839
+ }
840
+ destructor() {
841
+ clearTimeout(this.id);
842
+ }
843
+ }
844
+ $.$mol_after_timeout = $mol_after_timeout;
845
+ })($ || ($ = {}));
846
+ //mol/after/timeout/timeout.ts
847
+ ;
848
+ "use strict";
849
+ var $;
850
+ (function ($) {
851
+ function $mol_wait_timeout_async(timeout) {
852
+ const promise = $mol_promise();
853
+ const task = new this.$mol_after_timeout(timeout, () => promise.done());
854
+ return Object.assign(promise, {
855
+ destructor: () => task.destructor()
856
+ });
857
+ }
858
+ $.$mol_wait_timeout_async = $mol_wait_timeout_async;
859
+ function $mol_wait_timeout(timeout) {
860
+ return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
861
+ }
862
+ $.$mol_wait_timeout = $mol_wait_timeout;
863
+ })($ || ($ = {}));
864
+ //mol/wait/timeout/timeout.ts
865
+ ;
866
+ "use strict";
867
+ var $;
868
+ (function ($_1) {
869
+ $mol_test({
870
+ async 'Latest method calls wins'($) {
871
+ class NameLogger extends $mol_object2 {
872
+ static $ = $;
873
+ static first = [];
874
+ static last = [];
875
+ static send(next) {
876
+ $mol_wire_sync(this.first).push(next);
877
+ this.$.$mol_wait_timeout(0);
878
+ this.last.push(next);
879
+ }
880
+ }
881
+ const name = $mol_wire_async(NameLogger).send;
882
+ name('john');
883
+ const promise = name('jin');
884
+ $.$mol_after_mock_warp();
885
+ await promise;
886
+ $mol_assert_like(NameLogger.first, ['john', 'jin']);
887
+ $mol_assert_like(NameLogger.last, ['jin']);
888
+ },
889
+ async 'Latest function calls wins'($) {
890
+ const first = [];
891
+ const last = [];
892
+ function send_name(next) {
893
+ $mol_wire_sync(first).push(next);
894
+ $.$mol_wait_timeout(0);
895
+ last.push(next);
896
+ }
897
+ const name = $mol_wire_async(send_name);
898
+ name('john');
899
+ const promise = name('jin');
900
+ $.$mol_after_mock_warp();
901
+ await promise;
902
+ $mol_assert_like(first, ['john', 'jin']);
903
+ $mol_assert_like(last, ['jin']);
904
+ },
905
+ });
906
+ })($ || ($ = {}));
907
+ //mol/wire/async/async.test.ts
908
+ ;
909
+ "use strict";
910
+ var $;
911
+ (function ($) {
912
+ function $mol_wire_async(obj) {
913
+ let fiber;
914
+ const temp = $mol_wire_task.getter(obj);
915
+ return new Proxy(obj, {
916
+ get(obj, field) {
917
+ const val = obj[field];
918
+ if (typeof val !== 'function')
919
+ return val;
920
+ let fiber;
921
+ const temp = $mol_wire_task.getter(val);
922
+ return function $mol_wire_async(...args) {
923
+ fiber?.destructor();
924
+ fiber = temp(obj, args);
925
+ return fiber.async();
926
+ };
927
+ },
928
+ apply(obj, self, args) {
929
+ fiber?.destructor();
930
+ fiber = temp(self, args);
931
+ return fiber.async();
932
+ },
933
+ });
934
+ }
935
+ $.$mol_wire_async = $mol_wire_async;
936
+ })($ || ($ = {}));
937
+ //mol/wire/async/async.ts
938
+ ;
939
+ "use strict";
940
+ var $;
932
941
  (function ($_1) {
933
942
  $mol_test({
934
943
  'Cached channel'($) {