mol_wire_lib 1.0.103 → 1.0.106

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.esm.js CHANGED
@@ -752,34 +752,6 @@ var $;
752
752
  ;
753
753
  "use strict";
754
754
  var $;
755
- (function ($) {
756
- function $mol_wire_probe(task, next) {
757
- const warm = $mol_wire_fiber.warm;
758
- try {
759
- $mol_wire_fiber.warm = false;
760
- return task();
761
- }
762
- finally {
763
- $mol_wire_fiber.warm = warm;
764
- }
765
- }
766
- $.$mol_wire_probe = $mol_wire_probe;
767
- })($ || ($ = {}));
768
- //mol/wire/probe/probe.ts
769
- ;
770
- "use strict";
771
- var $;
772
- (function ($) {
773
- function $mol_wire_solid() {
774
- $mol_wire_auto().reap = nothing;
775
- }
776
- $.$mol_wire_solid = $mol_wire_solid;
777
- const nothing = () => { };
778
- })($ || ($ = {}));
779
- //mol/wire/solid/solid.ts
780
- ;
781
- "use strict";
782
- var $;
783
755
  (function ($) {
784
756
  $.$mol_compare_deep_cache = new WeakMap();
785
757
  function $mol_compare_deep(left, right) {
@@ -906,12 +878,12 @@ var $;
906
878
  "use strict";
907
879
  var $;
908
880
  (function ($) {
909
- class $mol_wire_fiber_temp extends $mol_wire_fiber {
881
+ class $mol_wire_task extends $mol_wire_fiber {
910
882
  static getter(task) {
911
883
  return function $mol_wire_fiber_temp_get(host, args) {
912
884
  const existen = $mol_wire_auto()?.track_next();
913
885
  reuse: if (existen) {
914
- if (!(existen instanceof $mol_wire_fiber_temp))
886
+ if (!(existen instanceof $mol_wire_task))
915
887
  break reuse;
916
888
  if (existen.host !== host)
917
889
  break reuse;
@@ -921,7 +893,7 @@ var $;
921
893
  break reuse;
922
894
  return existen;
923
895
  }
924
- return new $mol_wire_fiber_temp(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, ...args);
896
+ return new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, ...args);
925
897
  };
926
898
  }
927
899
  complete() {
@@ -944,53 +916,9 @@ var $;
944
916
  return next;
945
917
  }
946
918
  }
947
- $.$mol_wire_fiber_temp = $mol_wire_fiber_temp;
948
- })($ || ($ = {}));
949
- //mol/wire/fiber/temp/temp.ts
950
- ;
951
- "use strict";
952
- var $;
953
- (function ($) {
954
- function $mol_wire_sync(obj) {
955
- return new Proxy(obj, {
956
- get(obj, field) {
957
- const val = obj[field];
958
- if (typeof val !== 'function')
959
- return val;
960
- const temp = $mol_wire_fiber_temp.getter(val);
961
- return function $mol_wire_sync(...args) {
962
- const fiber = temp(obj, args);
963
- return fiber.sync();
964
- };
965
- }
966
- });
967
- }
968
- $.$mol_wire_sync = $mol_wire_sync;
969
- })($ || ($ = {}));
970
- //mol/wire/sync/sync.ts
971
- ;
972
- "use strict";
973
- var $;
974
- (function ($) {
975
- function $mol_wire_async(obj) {
976
- return new Proxy(obj, {
977
- get(obj, field) {
978
- const val = obj[field];
979
- if (typeof val !== 'function')
980
- return val;
981
- let fiber;
982
- const temp = $mol_wire_fiber_temp.getter(val);
983
- return function $mol_wire_async(...args) {
984
- fiber?.destructor();
985
- fiber = temp(obj, args);
986
- return fiber.async();
987
- };
988
- }
989
- });
990
- }
991
- $.$mol_wire_async = $mol_wire_async;
919
+ $.$mol_wire_task = $mol_wire_task;
992
920
  })($ || ($ = {}));
993
- //mol/wire/async/async.ts
921
+ //mol/wire/task/task.ts
994
922
  ;
995
923
  "use strict";
996
924
  var $;
@@ -1055,7 +983,7 @@ var $;
1055
983
  if (typeof sup[field] === 'function') {
1056
984
  Object.defineProperty(orig, 'name', { value: sup[field].name });
1057
985
  }
1058
- const temp = $mol_wire_fiber_temp.getter(orig);
986
+ const temp = $mol_wire_task.getter(orig);
1059
987
  const value = function (...args) {
1060
988
  const fiber = temp(this ?? null, args);
1061
989
  return fiber.sync();
@@ -1073,7 +1001,7 @@ var $;
1073
1001
  "use strict";
1074
1002
  var $;
1075
1003
  (function ($) {
1076
- class $mol_wire_fiber_persist extends $mol_wire_fiber {
1004
+ class $mol_wire_atom extends $mol_wire_fiber {
1077
1005
  static getter(task, keys) {
1078
1006
  const field = task.name + '()';
1079
1007
  if (keys) {
@@ -1089,7 +1017,7 @@ var $;
1089
1017
  else {
1090
1018
  dict = (host ?? task)[field] = new Map();
1091
1019
  }
1092
- fiber = new $mol_wire_fiber_persist(key, task, host, ...args);
1020
+ fiber = new $mol_wire_atom(key, task, host, ...args);
1093
1021
  dict.set(key, fiber);
1094
1022
  return fiber;
1095
1023
  };
@@ -1100,7 +1028,7 @@ var $;
1100
1028
  if (existen)
1101
1029
  return existen;
1102
1030
  const key = `${host?.[Symbol.toStringTag] ?? host}.${field}`;
1103
- const fiber = new $mol_wire_fiber_persist(key, task, host, ...args);
1031
+ const fiber = new $mol_wire_atom(key, task, host, ...args);
1104
1032
  (host ?? task)[field] = fiber;
1105
1033
  return fiber;
1106
1034
  };
@@ -1164,13 +1092,85 @@ var $;
1164
1092
  }
1165
1093
  __decorate([
1166
1094
  $mol_wire_method
1167
- ], $mol_wire_fiber_persist.prototype, "recall", null);
1095
+ ], $mol_wire_atom.prototype, "recall", null);
1168
1096
  __decorate([
1169
1097
  $mol_wire_method
1170
- ], $mol_wire_fiber_persist.prototype, "once", null);
1171
- $.$mol_wire_fiber_persist = $mol_wire_fiber_persist;
1098
+ ], $mol_wire_atom.prototype, "once", null);
1099
+ $.$mol_wire_atom = $mol_wire_atom;
1172
1100
  })($ || ($ = {}));
1173
- //mol/wire/fiber/persist/persist.ts
1101
+ //mol/wire/atom/atom.ts
1102
+ ;
1103
+ "use strict";
1104
+ var $;
1105
+ (function ($) {
1106
+ function $mol_wire_probe(task, next) {
1107
+ const warm = $mol_wire_fiber.warm;
1108
+ try {
1109
+ $mol_wire_fiber.warm = false;
1110
+ return task();
1111
+ }
1112
+ finally {
1113
+ $mol_wire_fiber.warm = warm;
1114
+ }
1115
+ }
1116
+ $.$mol_wire_probe = $mol_wire_probe;
1117
+ })($ || ($ = {}));
1118
+ //mol/wire/probe/probe.ts
1119
+ ;
1120
+ "use strict";
1121
+ var $;
1122
+ (function ($) {
1123
+ function $mol_wire_solid() {
1124
+ $mol_wire_auto().reap = nothing;
1125
+ }
1126
+ $.$mol_wire_solid = $mol_wire_solid;
1127
+ const nothing = () => { };
1128
+ })($ || ($ = {}));
1129
+ //mol/wire/solid/solid.ts
1130
+ ;
1131
+ "use strict";
1132
+ var $;
1133
+ (function ($) {
1134
+ function $mol_wire_sync(obj) {
1135
+ return new Proxy(obj, {
1136
+ get(obj, field) {
1137
+ const val = obj[field];
1138
+ if (typeof val !== 'function')
1139
+ return val;
1140
+ const temp = $mol_wire_task.getter(val);
1141
+ return function $mol_wire_sync(...args) {
1142
+ const fiber = temp(obj, args);
1143
+ return fiber.sync();
1144
+ };
1145
+ }
1146
+ });
1147
+ }
1148
+ $.$mol_wire_sync = $mol_wire_sync;
1149
+ })($ || ($ = {}));
1150
+ //mol/wire/sync/sync.ts
1151
+ ;
1152
+ "use strict";
1153
+ var $;
1154
+ (function ($) {
1155
+ function $mol_wire_async(obj) {
1156
+ return new Proxy(obj, {
1157
+ get(obj, field) {
1158
+ const val = obj[field];
1159
+ if (typeof val !== 'function')
1160
+ return val;
1161
+ let fiber;
1162
+ const temp = $mol_wire_task.getter(val);
1163
+ return function $mol_wire_async(...args) {
1164
+ fiber?.destructor();
1165
+ fiber = temp(obj, args);
1166
+ return fiber.async();
1167
+ };
1168
+ }
1169
+ });
1170
+ }
1171
+ $.$mol_wire_async = $mol_wire_async;
1172
+ })($ || ($ = {}));
1173
+ //mol/wire/async/async.ts
1174
1174
  ;
1175
1175
  "use strict";
1176
1176
  var $;
@@ -1196,11 +1196,11 @@ var $;
1196
1196
  $.$mol_wire_mem = $mol_wire_mem;
1197
1197
  function $mol_wire_mem_func(keys) {
1198
1198
  return (func) => {
1199
- const persist = $mol_wire_fiber_persist.getter(func, keys);
1199
+ const persist = $mol_wire_atom.getter(func, keys);
1200
1200
  const wrapper = function (...args) {
1201
1201
  let atom = persist(this, args.slice(0, keys));
1202
1202
  if (args.length <= keys || args[keys] === undefined) {
1203
- if ($mol_wire_auto() instanceof $mol_wire_fiber_temp) {
1203
+ if ($mol_wire_auto() instanceof $mol_wire_task) {
1204
1204
  return atom.once();
1205
1205
  }
1206
1206
  else {
@@ -1238,7 +1238,7 @@ var $;
1238
1238
  if (!descr)
1239
1239
  descr = Reflect.getOwnPropertyDescriptor(host, field);
1240
1240
  const _get = descr?.get || $mol_const(descr?.value);
1241
- const persist = $mol_wire_fiber_persist.getter(_get, 0);
1241
+ const persist = $mol_wire_atom.getter(_get, 0);
1242
1242
  const _set = descr?.set || function (next) {
1243
1243
  persist(this, []).put(next);
1244
1244
  };
@@ -1249,7 +1249,7 @@ var $;
1249
1249
  function get() {
1250
1250
  return persist(this, []).sync();
1251
1251
  }
1252
- const temp = $mol_wire_fiber_temp.getter(_set);
1252
+ const temp = $mol_wire_task.getter(_set);
1253
1253
  function set(next) {
1254
1254
  temp(this, [next]).sync();
1255
1255
  }
@@ -1459,5 +1459,125 @@ var $;
1459
1459
  })($ || ($ = {}));
1460
1460
  //mol/wait/timeout/timeout.ts
1461
1461
  ;
1462
+ "use strict";
1463
+ var $;
1464
+ (function ($) {
1465
+ $.$mol_mem = $mol_wire_mem(0);
1466
+ $.$mol_mem_key = $mol_wire_mem(1);
1467
+ $.$mol_mem_key2 = $mol_wire_mem(2);
1468
+ $.$mol_mem_key3 = $mol_wire_mem(3);
1469
+ })($ || ($ = {}));
1470
+ //mol/mem/mem.ts
1471
+ ;
1472
+ "use strict";
1473
+ var $;
1474
+ (function ($) {
1475
+ function $mol_log3_area_lazy(event) {
1476
+ const self = this;
1477
+ const stack = self.$mol_log3_stack;
1478
+ const deep = stack.length;
1479
+ let logged = false;
1480
+ stack.push(() => {
1481
+ logged = true;
1482
+ self.$mol_log3_area.call(self, event);
1483
+ });
1484
+ return () => {
1485
+ if (logged)
1486
+ self.console.groupEnd();
1487
+ if (stack.length > deep)
1488
+ stack.length = deep;
1489
+ };
1490
+ }
1491
+ $.$mol_log3_area_lazy = $mol_log3_area_lazy;
1492
+ $.$mol_log3_stack = [];
1493
+ })($ || ($ = {}));
1494
+ //mol/log3/log3.ts
1495
+ ;
1496
+ "use strict";
1497
+ //mol/type/keys/extract/extract.ts
1498
+ ;
1499
+ "use strict";
1500
+ var $;
1501
+ (function ($) {
1502
+ function $mol_log3_web_make(level, color) {
1503
+ return function $mol_log3_logger(event) {
1504
+ const pending = this.$mol_log3_stack.pop();
1505
+ if (pending)
1506
+ pending();
1507
+ let tpl = '%c';
1508
+ const chunks = Object.values(event);
1509
+ for (let i = 0; i < chunks.length; ++i) {
1510
+ tpl += (typeof chunks[i] === 'string') ? ' ⦙ %s' : ' ⦙ %o';
1511
+ }
1512
+ const style = `color:${color};font-weight:bolder`;
1513
+ this.console[level](tpl, style, ...chunks);
1514
+ const self = this;
1515
+ return () => self.console.groupEnd();
1516
+ };
1517
+ }
1518
+ $.$mol_log3_web_make = $mol_log3_web_make;
1519
+ $.$mol_log3_come = $mol_log3_web_make('info', 'royalblue');
1520
+ $.$mol_log3_done = $mol_log3_web_make('info', 'forestgreen');
1521
+ $.$mol_log3_fail = $mol_log3_web_make('error', 'orangered');
1522
+ $.$mol_log3_warn = $mol_log3_web_make('warn', 'goldenrod');
1523
+ $.$mol_log3_rise = $mol_log3_web_make('log', 'magenta');
1524
+ $.$mol_log3_area = $mol_log3_web_make('group', 'cyan');
1525
+ })($ || ($ = {}));
1526
+ //mol/log3/log3.web.ts
1527
+ ;
1528
+ "use strict";
1529
+ var $;
1530
+ (function ($) {
1531
+ class $mol_wire_log extends $mol_object2 {
1532
+ static watch(task) {
1533
+ return task;
1534
+ }
1535
+ static track(fiber) {
1536
+ const prev = $mol_wire_probe(() => this.track(fiber));
1537
+ let next;
1538
+ try {
1539
+ next = fiber.sync();
1540
+ }
1541
+ finally {
1542
+ for (const pub of fiber.pub_list) {
1543
+ if (pub instanceof $mol_wire_fiber) {
1544
+ this.track(pub);
1545
+ }
1546
+ }
1547
+ }
1548
+ if (prev !== undefined && !$mol_compare_deep(prev, next)) {
1549
+ this.$.$mol_log3_rise({
1550
+ message: 'Changed',
1551
+ place: fiber,
1552
+ });
1553
+ }
1554
+ return next;
1555
+ }
1556
+ static active() {
1557
+ try {
1558
+ this.watch()?.();
1559
+ }
1560
+ finally {
1561
+ for (const pub of $mol_wire_auto().pub_list) {
1562
+ if (pub instanceof $mol_wire_fiber) {
1563
+ this.track(pub);
1564
+ }
1565
+ }
1566
+ }
1567
+ }
1568
+ }
1569
+ __decorate([
1570
+ $mol_mem
1571
+ ], $mol_wire_log, "watch", null);
1572
+ __decorate([
1573
+ $mol_mem_key
1574
+ ], $mol_wire_log, "track", null);
1575
+ __decorate([
1576
+ $mol_mem
1577
+ ], $mol_wire_log, "active", null);
1578
+ $.$mol_wire_log = $mol_wire_log;
1579
+ })($ || ($ = {}));
1580
+ //mol/wire/log/log.ts
1581
+ ;
1462
1582
  export default $
1463
1583
  //# sourceMappingURL=web.esm.js.map