mol_wire_lib 1.0.98 → 1.0.101

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
@@ -691,84 +691,6 @@ var $;
691
691
  ;
692
692
  "use strict";
693
693
  var $;
694
- (function ($) {
695
- function $mol_guid(length = 8, exists = () => false) {
696
- for (;;) {
697
- let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
698
- if (exists(id))
699
- continue;
700
- return id;
701
- }
702
- }
703
- $.$mol_guid = $mol_guid;
704
- })($ || ($ = {}));
705
- //mol/guid/guid.ts
706
- ;
707
- "use strict";
708
- var $;
709
- (function ($) {
710
- $.$mol_key_store = new WeakMap();
711
- function $mol_key(value) {
712
- if (!value)
713
- return JSON.stringify(value);
714
- if (typeof value !== 'object' && typeof value !== 'function')
715
- return JSON.stringify(value);
716
- return JSON.stringify(value, (field, value) => {
717
- if (!value)
718
- return value;
719
- if (typeof value !== 'object' && typeof value !== 'function')
720
- return value;
721
- if (Array.isArray(value))
722
- return value;
723
- const proto = Reflect.getPrototypeOf(value);
724
- if (!proto)
725
- return value;
726
- if (Reflect.getPrototypeOf(proto) === null)
727
- return value;
728
- if ('toJSON' in value)
729
- return value;
730
- if (value instanceof RegExp)
731
- return value.toString();
732
- let key = $.$mol_key_store.get(value);
733
- if (key)
734
- return key;
735
- key = $mol_guid();
736
- $.$mol_key_store.set(value, key);
737
- return key;
738
- });
739
- }
740
- $.$mol_key = $mol_key;
741
- })($ || ($ = {}));
742
- //mol/key/key.ts
743
- ;
744
- "use strict";
745
- var $;
746
- (function ($) {
747
- function $mol_wire_method(host, field, descr) {
748
- if (!descr)
749
- descr = Reflect.getOwnPropertyDescriptor(host, field);
750
- const orig = descr?.value ?? host[field];
751
- const sup = Reflect.getPrototypeOf(host);
752
- if (typeof sup[field] === 'function') {
753
- Object.defineProperty(orig, 'name', { value: sup[field].name });
754
- }
755
- const temp = $mol_wire_fiber_temp.getter(orig);
756
- const value = function (...args) {
757
- const fiber = temp(this ?? null, args);
758
- return fiber.sync();
759
- };
760
- Object.defineProperty(value, 'name', { value: orig.name + ' ' });
761
- Object.assign(value, { orig });
762
- const descr2 = { ...descr, value };
763
- Reflect.defineProperty(host, field, descr2);
764
- return descr2;
765
- }
766
- $.$mol_wire_method = $mol_wire_method;
767
- })($ || ($ = {}));
768
- //mol/wire/method/method.ts
769
- ;
770
- "use strict";
771
- var $;
772
694
  (function ($) {
773
695
  const handled = new WeakSet();
774
696
  class $mol_wire_fiber extends $mol_wire_pub_sub {
@@ -982,6 +904,40 @@ var $;
982
904
  }
983
905
  }
984
906
  $.$mol_wire_fiber = $mol_wire_fiber;
907
+ })($ || ($ = {}));
908
+ //mol/wire/fiber/fiber.ts
909
+ ;
910
+ "use strict";
911
+ var $;
912
+ (function ($) {
913
+ function $mol_wire_probe(task, next) {
914
+ const warm = $mol_wire_fiber.warm;
915
+ try {
916
+ $mol_wire_fiber.warm = false;
917
+ return task();
918
+ }
919
+ finally {
920
+ $mol_wire_fiber.warm = warm;
921
+ }
922
+ }
923
+ $.$mol_wire_probe = $mol_wire_probe;
924
+ })($ || ($ = {}));
925
+ //mol/wire/probe/probe.ts
926
+ ;
927
+ "use strict";
928
+ var $;
929
+ (function ($) {
930
+ function $mol_wire_solid() {
931
+ $mol_wire_auto().reap = nothing;
932
+ }
933
+ $.$mol_wire_solid = $mol_wire_solid;
934
+ const nothing = () => { };
935
+ })($ || ($ = {}));
936
+ //mol/wire/solid/solid.ts
937
+ ;
938
+ "use strict";
939
+ var $;
940
+ (function ($) {
985
941
  class $mol_wire_fiber_temp extends $mol_wire_fiber {
986
942
  static getter(task) {
987
943
  return function $mol_wire_fiber_temp_get(host, args) {
@@ -1001,10 +957,139 @@ var $;
1001
957
  };
1002
958
  }
1003
959
  complete() {
1004
- this.destructor();
960
+ if (this.sub_empty)
961
+ this.destructor();
1005
962
  }
1006
963
  }
1007
964
  $.$mol_wire_fiber_temp = $mol_wire_fiber_temp;
965
+ })($ || ($ = {}));
966
+ //mol/wire/fiber/temp/temp.ts
967
+ ;
968
+ "use strict";
969
+ var $;
970
+ (function ($) {
971
+ function $mol_wire_sync(obj) {
972
+ return new Proxy(obj, {
973
+ get(obj, field) {
974
+ const val = obj[field];
975
+ if (typeof val !== 'function')
976
+ return val;
977
+ const temp = $mol_wire_fiber_temp.getter(val);
978
+ return function $mol_wire_sync(...args) {
979
+ const fiber = temp(obj, args);
980
+ return fiber.sync();
981
+ };
982
+ }
983
+ });
984
+ }
985
+ $.$mol_wire_sync = $mol_wire_sync;
986
+ })($ || ($ = {}));
987
+ //mol/wire/sync/sync.ts
988
+ ;
989
+ "use strict";
990
+ var $;
991
+ (function ($) {
992
+ function $mol_wire_async(obj) {
993
+ return new Proxy(obj, {
994
+ get(obj, field) {
995
+ const val = obj[field];
996
+ if (typeof val !== 'function')
997
+ return val;
998
+ let fiber;
999
+ const temp = $mol_wire_fiber_temp.getter(val);
1000
+ return function $mol_wire_async(...args) {
1001
+ fiber?.destructor();
1002
+ fiber = temp(obj, args);
1003
+ return fiber.async();
1004
+ };
1005
+ }
1006
+ });
1007
+ }
1008
+ $.$mol_wire_async = $mol_wire_async;
1009
+ })($ || ($ = {}));
1010
+ //mol/wire/async/async.ts
1011
+ ;
1012
+ "use strict";
1013
+ var $;
1014
+ (function ($) {
1015
+ function $mol_guid(length = 8, exists = () => false) {
1016
+ for (;;) {
1017
+ let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
1018
+ if (exists(id))
1019
+ continue;
1020
+ return id;
1021
+ }
1022
+ }
1023
+ $.$mol_guid = $mol_guid;
1024
+ })($ || ($ = {}));
1025
+ //mol/guid/guid.ts
1026
+ ;
1027
+ "use strict";
1028
+ var $;
1029
+ (function ($) {
1030
+ $.$mol_key_store = new WeakMap();
1031
+ function $mol_key(value) {
1032
+ if (!value)
1033
+ return JSON.stringify(value);
1034
+ if (typeof value !== 'object' && typeof value !== 'function')
1035
+ return JSON.stringify(value);
1036
+ return JSON.stringify(value, (field, value) => {
1037
+ if (!value)
1038
+ return value;
1039
+ if (typeof value !== 'object' && typeof value !== 'function')
1040
+ return value;
1041
+ if (Array.isArray(value))
1042
+ return value;
1043
+ const proto = Reflect.getPrototypeOf(value);
1044
+ if (!proto)
1045
+ return value;
1046
+ if (Reflect.getPrototypeOf(proto) === null)
1047
+ return value;
1048
+ if ('toJSON' in value)
1049
+ return value;
1050
+ if (value instanceof RegExp)
1051
+ return value.toString();
1052
+ let key = $.$mol_key_store.get(value);
1053
+ if (key)
1054
+ return key;
1055
+ key = $mol_guid();
1056
+ $.$mol_key_store.set(value, key);
1057
+ return key;
1058
+ });
1059
+ }
1060
+ $.$mol_key = $mol_key;
1061
+ })($ || ($ = {}));
1062
+ //mol/key/key.ts
1063
+ ;
1064
+ "use strict";
1065
+ var $;
1066
+ (function ($) {
1067
+ function $mol_wire_method(host, field, descr) {
1068
+ if (!descr)
1069
+ descr = Reflect.getOwnPropertyDescriptor(host, field);
1070
+ const orig = descr?.value ?? host[field];
1071
+ const sup = Reflect.getPrototypeOf(host);
1072
+ if (typeof sup[field] === 'function') {
1073
+ Object.defineProperty(orig, 'name', { value: sup[field].name });
1074
+ }
1075
+ const temp = $mol_wire_fiber_temp.getter(orig);
1076
+ const value = function (...args) {
1077
+ const fiber = temp(this ?? null, args);
1078
+ return fiber.sync();
1079
+ };
1080
+ Object.defineProperty(value, 'name', { value: orig.name + ' ' });
1081
+ Object.assign(value, { orig });
1082
+ const descr2 = { ...descr, value };
1083
+ Reflect.defineProperty(host, field, descr2);
1084
+ return descr2;
1085
+ }
1086
+ $.$mol_wire_method = $mol_wire_method;
1087
+ })($ || ($ = {}));
1088
+ //mol/wire/method/method.ts
1089
+ ;
1090
+ "use strict";
1091
+ var $;
1092
+ (function ($) {
1008
1093
  class $mol_wire_fiber_persist extends $mol_wire_fiber {
1009
1094
  static getter(task, keys) {
1010
1095
  const field = task.name + '()';
@@ -1077,79 +1162,7 @@ var $;
1077
1162
  ], $mol_wire_fiber_persist.prototype, "once", null);
1078
1163
  $.$mol_wire_fiber_persist = $mol_wire_fiber_persist;
1079
1164
  })($ || ($ = {}));
1080
- //mol/wire/fiber/fiber.ts
1081
- ;
1082
- "use strict";
1083
- var $;
1084
- (function ($) {
1085
- function $mol_wire_probe(task, next) {
1086
- const warm = $mol_wire_fiber.warm;
1087
- try {
1088
- $mol_wire_fiber.warm = false;
1089
- return task();
1090
- }
1091
- finally {
1092
- $mol_wire_fiber.warm = warm;
1093
- }
1094
- }
1095
- $.$mol_wire_probe = $mol_wire_probe;
1096
- })($ || ($ = {}));
1097
- //mol/wire/probe/probe.ts
1098
- ;
1099
- "use strict";
1100
- var $;
1101
- (function ($) {
1102
- function $mol_wire_solid() {
1103
- $mol_wire_auto().reap = nothing;
1104
- }
1105
- $.$mol_wire_solid = $mol_wire_solid;
1106
- const nothing = () => { };
1107
- })($ || ($ = {}));
1108
- //mol/wire/solid/solid.ts
1109
- ;
1110
- "use strict";
1111
- var $;
1112
- (function ($) {
1113
- function $mol_wire_sync(obj) {
1114
- return new Proxy(obj, {
1115
- get(obj, field) {
1116
- const val = obj[field];
1117
- if (typeof val !== 'function')
1118
- return val;
1119
- const temp = $mol_wire_fiber_temp.getter(val);
1120
- return function $mol_wire_sync(...args) {
1121
- const fiber = temp(obj, args);
1122
- return fiber.sync();
1123
- };
1124
- }
1125
- });
1126
- }
1127
- $.$mol_wire_sync = $mol_wire_sync;
1128
- })($ || ($ = {}));
1129
- //mol/wire/sync/sync.ts
1130
- ;
1131
- "use strict";
1132
- var $;
1133
- (function ($) {
1134
- function $mol_wire_async(obj) {
1135
- return new Proxy(obj, {
1136
- get(obj, field) {
1137
- const val = obj[field];
1138
- if (typeof val !== 'function')
1139
- return val;
1140
- let fiber;
1141
- const temp = $mol_wire_fiber_temp.getter(val);
1142
- return function $mol_wire_async(...args) {
1143
- fiber?.destructor();
1144
- fiber = temp(obj, args);
1145
- return fiber.async();
1146
- };
1147
- }
1148
- });
1149
- }
1150
- $.$mol_wire_async = $mol_wire_async;
1151
- })($ || ($ = {}));
1152
- //mol/wire/async/async.ts
1165
+ //mol/wire/fiber/persist/persist.ts
1153
1166
  ;
1154
1167
  "use strict";
1155
1168
  var $;