mol_wire_lib 1.0.100 → 1.0.103

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/web.js CHANGED
@@ -566,131 +566,6 @@ var $;
566
566
  ;
567
567
  "use strict";
568
568
  var $;
569
- (function ($) {
570
- $.$mol_compare_deep_cache = new WeakMap();
571
- function $mol_compare_deep(left, right) {
572
- if (Object.is(left, right))
573
- return true;
574
- if (left === null)
575
- return false;
576
- if (right === null)
577
- return false;
578
- if (typeof left !== 'object')
579
- return false;
580
- if (typeof right !== 'object')
581
- return false;
582
- const left_proto = Reflect.getPrototypeOf(left);
583
- const right_proto = Reflect.getPrototypeOf(right);
584
- if (left_proto !== right_proto)
585
- return false;
586
- if (left instanceof Boolean)
587
- return Object.is(left.valueOf(), right['valueOf']());
588
- if (left instanceof Number)
589
- return Object.is(left.valueOf(), right['valueOf']());
590
- if (left instanceof String)
591
- return Object.is(left.valueOf(), right['valueOf']());
592
- if (left instanceof Date)
593
- return Object.is(left.valueOf(), right['valueOf']());
594
- if (left instanceof RegExp)
595
- return left.source === right['source'] && left.flags === right['flags'];
596
- let left_cache = $.$mol_compare_deep_cache.get(left);
597
- if (left_cache) {
598
- const right_cache = left_cache.get(right);
599
- if (typeof right_cache === 'boolean')
600
- return right_cache;
601
- }
602
- else {
603
- left_cache = new WeakMap([[right, true]]);
604
- $.$mol_compare_deep_cache.set(left, left_cache);
605
- }
606
- let result;
607
- try {
608
- if (left_proto && !Reflect.getPrototypeOf(left_proto))
609
- result = compare_pojo(left, right);
610
- else if (Array.isArray(left))
611
- result = compare_array(left, right);
612
- else if (left instanceof Set)
613
- result = compare_set(left, right);
614
- else if (left instanceof Map)
615
- result = compare_map(left, right);
616
- else if (left instanceof Error)
617
- result = left.stack === right.stack;
618
- else if (ArrayBuffer.isView(left))
619
- result = compare_buffer(left, right);
620
- else if (Symbol.toPrimitive in left)
621
- result = compare_primitive(left, right);
622
- else
623
- result = false;
624
- }
625
- finally {
626
- left_cache.set(right, result);
627
- }
628
- return result;
629
- }
630
- $.$mol_compare_deep = $mol_compare_deep;
631
- function compare_array(left, right) {
632
- const len = left.length;
633
- if (len !== right.length)
634
- return false;
635
- for (let i = 0; i < len; ++i) {
636
- if (!$mol_compare_deep(left[i], right[i]))
637
- return false;
638
- }
639
- return true;
640
- }
641
- function compare_buffer(left, right) {
642
- const len = left.byteLength;
643
- if (len !== right.byteLength)
644
- return false;
645
- for (let i = 0; i < len; ++i) {
646
- if (left[i] !== right[i])
647
- return false;
648
- }
649
- return true;
650
- }
651
- function compare_iterator(left, right, compare) {
652
- while (true) {
653
- const left_next = left.next();
654
- const right_next = right.next();
655
- if (left_next.done !== right_next.done)
656
- return false;
657
- if (left_next.done)
658
- break;
659
- if (!compare(left_next.value, right_next.value))
660
- return false;
661
- }
662
- return true;
663
- }
664
- function compare_set(left, right) {
665
- if (left.size !== right.size)
666
- return false;
667
- return compare_iterator(left.values(), right.values(), $mol_compare_deep);
668
- }
669
- function compare_map(left, right) {
670
- if (left.size !== right.size)
671
- return false;
672
- return compare_iterator(left.keys(), right.keys(), Object.is)
673
- && compare_iterator(left.values(), right.values(), $mol_compare_deep);
674
- }
675
- function compare_pojo(left, right) {
676
- const left_keys = Object.getOwnPropertyNames(left);
677
- const right_keys = Object.getOwnPropertyNames(right);
678
- if (left_keys.length !== right_keys.length)
679
- return false;
680
- for (let key of left_keys) {
681
- if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
682
- return false;
683
- }
684
- return true;
685
- }
686
- function compare_primitive(left, right) {
687
- return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
688
- }
689
- })($ || ($ = {}));
690
- //mol/compare/deep/deep.ts
691
- ;
692
- "use strict";
693
- var $;
694
569
  (function ($) {
695
570
  const handled = new WeakSet();
696
571
  class $mol_wire_fiber extends $mol_wire_pub_sub {
@@ -842,38 +717,6 @@ var $;
842
717
  this.track_off(bu);
843
718
  this.put(result);
844
719
  }
845
- put(next) {
846
- const prev = this.cache;
847
- if (next !== prev) {
848
- if ($mol_owning_check(this, prev)) {
849
- prev.destructor();
850
- }
851
- this.cache = next;
852
- if (this instanceof $mol_wire_fiber_persist && $mol_owning_catch(this, next)) {
853
- try {
854
- next[Symbol.toStringTag] = this[Symbol.toStringTag];
855
- }
856
- catch { }
857
- }
858
- if (this.sub_from < this.length) {
859
- if (!$mol_compare_deep(prev, next)) {
860
- this.emit();
861
- }
862
- }
863
- }
864
- this.cursor = $mol_wire_cursor.fresh;
865
- if (next instanceof Promise)
866
- return next;
867
- if (this instanceof $mol_wire_fiber_persist) {
868
- this.complete_pubs();
869
- }
870
- else {
871
- this.cursor = $mol_wire_cursor.final;
872
- if (this.sub_empty)
873
- this.destructor();
874
- }
875
- return next;
876
- }
877
720
  sync() {
878
721
  if (!$mol_wire_fiber.warm) {
879
722
  return this.result();
@@ -937,6 +780,131 @@ var $;
937
780
  ;
938
781
  "use strict";
939
782
  var $;
783
+ (function ($) {
784
+ $.$mol_compare_deep_cache = new WeakMap();
785
+ function $mol_compare_deep(left, right) {
786
+ if (Object.is(left, right))
787
+ return true;
788
+ if (left === null)
789
+ return false;
790
+ if (right === null)
791
+ return false;
792
+ if (typeof left !== 'object')
793
+ return false;
794
+ if (typeof right !== 'object')
795
+ return false;
796
+ const left_proto = Reflect.getPrototypeOf(left);
797
+ const right_proto = Reflect.getPrototypeOf(right);
798
+ if (left_proto !== right_proto)
799
+ return false;
800
+ if (left instanceof Boolean)
801
+ return Object.is(left.valueOf(), right['valueOf']());
802
+ if (left instanceof Number)
803
+ return Object.is(left.valueOf(), right['valueOf']());
804
+ if (left instanceof String)
805
+ return Object.is(left.valueOf(), right['valueOf']());
806
+ if (left instanceof Date)
807
+ return Object.is(left.valueOf(), right['valueOf']());
808
+ if (left instanceof RegExp)
809
+ return left.source === right['source'] && left.flags === right['flags'];
810
+ let left_cache = $.$mol_compare_deep_cache.get(left);
811
+ if (left_cache) {
812
+ const right_cache = left_cache.get(right);
813
+ if (typeof right_cache === 'boolean')
814
+ return right_cache;
815
+ }
816
+ else {
817
+ left_cache = new WeakMap([[right, true]]);
818
+ $.$mol_compare_deep_cache.set(left, left_cache);
819
+ }
820
+ let result;
821
+ try {
822
+ if (left_proto && !Reflect.getPrototypeOf(left_proto))
823
+ result = compare_pojo(left, right);
824
+ else if (Array.isArray(left))
825
+ result = compare_array(left, right);
826
+ else if (left instanceof Set)
827
+ result = compare_set(left, right);
828
+ else if (left instanceof Map)
829
+ result = compare_map(left, right);
830
+ else if (left instanceof Error)
831
+ result = left.stack === right.stack;
832
+ else if (ArrayBuffer.isView(left))
833
+ result = compare_buffer(left, right);
834
+ else if (Symbol.toPrimitive in left)
835
+ result = compare_primitive(left, right);
836
+ else
837
+ result = false;
838
+ }
839
+ finally {
840
+ left_cache.set(right, result);
841
+ }
842
+ return result;
843
+ }
844
+ $.$mol_compare_deep = $mol_compare_deep;
845
+ function compare_array(left, right) {
846
+ const len = left.length;
847
+ if (len !== right.length)
848
+ return false;
849
+ for (let i = 0; i < len; ++i) {
850
+ if (!$mol_compare_deep(left[i], right[i]))
851
+ return false;
852
+ }
853
+ return true;
854
+ }
855
+ function compare_buffer(left, right) {
856
+ const len = left.byteLength;
857
+ if (len !== right.byteLength)
858
+ return false;
859
+ for (let i = 0; i < len; ++i) {
860
+ if (left[i] !== right[i])
861
+ return false;
862
+ }
863
+ return true;
864
+ }
865
+ function compare_iterator(left, right, compare) {
866
+ while (true) {
867
+ const left_next = left.next();
868
+ const right_next = right.next();
869
+ if (left_next.done !== right_next.done)
870
+ return false;
871
+ if (left_next.done)
872
+ break;
873
+ if (!compare(left_next.value, right_next.value))
874
+ return false;
875
+ }
876
+ return true;
877
+ }
878
+ function compare_set(left, right) {
879
+ if (left.size !== right.size)
880
+ return false;
881
+ return compare_iterator(left.values(), right.values(), $mol_compare_deep);
882
+ }
883
+ function compare_map(left, right) {
884
+ if (left.size !== right.size)
885
+ return false;
886
+ return compare_iterator(left.keys(), right.keys(), Object.is)
887
+ && compare_iterator(left.values(), right.values(), $mol_compare_deep);
888
+ }
889
+ function compare_pojo(left, right) {
890
+ const left_keys = Object.getOwnPropertyNames(left);
891
+ const right_keys = Object.getOwnPropertyNames(right);
892
+ if (left_keys.length !== right_keys.length)
893
+ return false;
894
+ for (let key of left_keys) {
895
+ if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
896
+ return false;
897
+ }
898
+ return true;
899
+ }
900
+ function compare_primitive(left, right) {
901
+ return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
902
+ }
903
+ })($ || ($ = {}));
904
+ //mol/compare/deep/deep.ts
905
+ ;
906
+ "use strict";
907
+ var $;
940
908
  (function ($) {
941
909
  class $mol_wire_fiber_temp extends $mol_wire_fiber {
942
910
  static getter(task) {
@@ -960,6 +928,21 @@ var $;
960
928
  if (this.sub_empty)
961
929
  this.destructor();
962
930
  }
931
+ put(next) {
932
+ const prev = this.cache;
933
+ if (next !== prev) {
934
+ this.cache = next;
935
+ this.emit();
936
+ }
937
+ if (next instanceof Promise) {
938
+ this.cursor = $mol_wire_cursor.fresh;
939
+ return next;
940
+ }
941
+ this.cursor = $mol_wire_cursor.final;
942
+ if (this.sub_empty)
943
+ this.destructor();
944
+ return next;
945
+ }
963
946
  }
964
947
  $.$mol_wire_fiber_temp = $mol_wire_fiber_temp;
965
948
  })($ || ($ = {}));
@@ -1153,6 +1136,31 @@ var $;
1153
1136
  (this.host ?? this.task)[this.field()].delete(this[Symbol.toStringTag]);
1154
1137
  }
1155
1138
  }
1139
+ put(next) {
1140
+ const prev = this.cache;
1141
+ if (next !== prev) {
1142
+ if ($mol_owning_check(this, prev)) {
1143
+ prev.destructor();
1144
+ }
1145
+ this.cache = next;
1146
+ if ($mol_owning_catch(this, next)) {
1147
+ try {
1148
+ next[Symbol.toStringTag] = this[Symbol.toStringTag];
1149
+ }
1150
+ catch { }
1151
+ }
1152
+ if (this.sub_from < this.length) {
1153
+ if (!$mol_compare_deep(prev, next)) {
1154
+ this.emit();
1155
+ }
1156
+ }
1157
+ }
1158
+ this.cursor = $mol_wire_cursor.fresh;
1159
+ if (next instanceof Promise)
1160
+ return next;
1161
+ this.complete_pubs();
1162
+ return next;
1163
+ }
1156
1164
  }
1157
1165
  __decorate([
1158
1166
  $mol_wire_method