mol_wire_lib 1.0.178 → 1.0.179
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/node.d.ts +13 -1
- package/node.deps.json +1 -1
- package/node.esm.js +77 -7
- package/node.esm.js.map +1 -1
- package/node.js +77 -7
- package/node.js.map +1 -1
- package/node.test.js +77 -7
- package/node.test.js.map +1 -1
- package/package.json +3 -1
- package/web.d.ts +13 -2
- package/web.deps.json +1 -1
- package/web.esm.js +83 -11
- package/web.esm.js.map +1 -1
- package/web.js +83 -11
- package/web.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -85,7 +85,7 @@ var $;
|
|
|
85
85
|
promote() {
|
|
86
86
|
$mol_wire_auto()?.track_next(this);
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
fresh() { }
|
|
89
89
|
complete() { }
|
|
90
90
|
emit(quant = $mol_wire_cursor.stale) {
|
|
91
91
|
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
@@ -288,7 +288,7 @@ var $;
|
|
|
288
288
|
}
|
|
289
289
|
for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
|
|
290
290
|
const pub = this.data[cursor];
|
|
291
|
-
pub.
|
|
291
|
+
pub.fresh();
|
|
292
292
|
}
|
|
293
293
|
this.cursor = $mol_wire_cursor.fresh;
|
|
294
294
|
}
|
|
@@ -584,7 +584,7 @@ var $;
|
|
|
584
584
|
continue;
|
|
585
585
|
if (fiber.cursor === $mol_wire_cursor.final)
|
|
586
586
|
continue;
|
|
587
|
-
fiber.
|
|
587
|
+
fiber.fresh();
|
|
588
588
|
}
|
|
589
589
|
}
|
|
590
590
|
while (this.reaping.size) {
|
|
@@ -652,7 +652,7 @@ var $;
|
|
|
652
652
|
else
|
|
653
653
|
super.emit(quant);
|
|
654
654
|
}
|
|
655
|
-
|
|
655
|
+
fresh() {
|
|
656
656
|
if (this.cursor === $mol_wire_cursor.fresh)
|
|
657
657
|
return;
|
|
658
658
|
if (this.cursor === $mol_wire_cursor.final)
|
|
@@ -660,7 +660,7 @@ var $;
|
|
|
660
660
|
check: if (this.cursor === $mol_wire_cursor.doubt) {
|
|
661
661
|
for (let i = this.pub_from; i < this.sub_from; i += 2) {
|
|
662
662
|
;
|
|
663
|
-
this.data[i]?.
|
|
663
|
+
this.data[i]?.fresh();
|
|
664
664
|
if (this.cursor !== $mol_wire_cursor.doubt)
|
|
665
665
|
break check;
|
|
666
666
|
}
|
|
@@ -716,12 +716,16 @@ var $;
|
|
|
716
716
|
this.track_off(bu);
|
|
717
717
|
this.put(result);
|
|
718
718
|
}
|
|
719
|
+
refresh() {
|
|
720
|
+
this.cursor = $mol_wire_cursor.stale;
|
|
721
|
+
this.fresh();
|
|
722
|
+
}
|
|
719
723
|
sync() {
|
|
720
724
|
if (!$mol_wire_fiber.warm) {
|
|
721
725
|
return this.result();
|
|
722
726
|
}
|
|
723
727
|
this.promote();
|
|
724
|
-
this.
|
|
728
|
+
this.fresh();
|
|
725
729
|
if (this.cache instanceof Error) {
|
|
726
730
|
return $mol_fail_hidden(this.cache);
|
|
727
731
|
}
|
|
@@ -732,7 +736,7 @@ var $;
|
|
|
732
736
|
}
|
|
733
737
|
async async() {
|
|
734
738
|
while (true) {
|
|
735
|
-
this.
|
|
739
|
+
this.fresh();
|
|
736
740
|
if (this.cache instanceof Error) {
|
|
737
741
|
$mol_fail_hidden(this.cache);
|
|
738
742
|
}
|
|
@@ -1034,6 +1038,22 @@ var $;
|
|
|
1034
1038
|
};
|
|
1035
1039
|
}
|
|
1036
1040
|
}
|
|
1041
|
+
static watching = new Set();
|
|
1042
|
+
static watch() {
|
|
1043
|
+
new $mol_after_frame($mol_wire_atom.watch);
|
|
1044
|
+
for (const atom of $mol_wire_atom.watching) {
|
|
1045
|
+
if (atom.cursor === $mol_wire_cursor.final) {
|
|
1046
|
+
$mol_wire_atom.watching.delete(atom);
|
|
1047
|
+
}
|
|
1048
|
+
else {
|
|
1049
|
+
atom.cursor = $mol_wire_cursor.stale;
|
|
1050
|
+
atom.fresh();
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
watch() {
|
|
1055
|
+
$mol_wire_atom.watching.add(this);
|
|
1056
|
+
}
|
|
1037
1057
|
resync(args) {
|
|
1038
1058
|
return this.put(this.task.call(this.host, ...args));
|
|
1039
1059
|
}
|
|
@@ -1088,6 +1108,7 @@ var $;
|
|
|
1088
1108
|
$mol_wire_method
|
|
1089
1109
|
], $mol_wire_atom.prototype, "once", null);
|
|
1090
1110
|
$.$mol_wire_atom = $mol_wire_atom;
|
|
1111
|
+
$mol_wire_atom.watch();
|
|
1091
1112
|
})($ || ($ = {}));
|
|
1092
1113
|
//mol/wire/atom/atom.ts
|
|
1093
1114
|
;
|
|
@@ -1121,6 +1142,22 @@ var $;
|
|
|
1121
1142
|
;
|
|
1122
1143
|
"use strict";
|
|
1123
1144
|
var $;
|
|
1145
|
+
(function ($) {
|
|
1146
|
+
function $mol_wire_watch() {
|
|
1147
|
+
const atom = $mol_wire_auto();
|
|
1148
|
+
if (atom instanceof $mol_wire_atom) {
|
|
1149
|
+
atom.watch();
|
|
1150
|
+
}
|
|
1151
|
+
else {
|
|
1152
|
+
$mol_fail(new Error('Atom is equired for watching'));
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
$.$mol_wire_watch = $mol_wire_watch;
|
|
1156
|
+
})($ || ($ = {}));
|
|
1157
|
+
//mol/wire/watch/watch.ts
|
|
1158
|
+
;
|
|
1159
|
+
"use strict";
|
|
1160
|
+
var $;
|
|
1124
1161
|
(function ($) {
|
|
1125
1162
|
function $mol_wire_sync(obj) {
|
|
1126
1163
|
return new Proxy(obj, {
|
|
@@ -1260,6 +1297,39 @@ var $;
|
|
|
1260
1297
|
;
|
|
1261
1298
|
"use strict";
|
|
1262
1299
|
var $;
|
|
1300
|
+
(function ($) {
|
|
1301
|
+
function $mol_wire_patch(obj) {
|
|
1302
|
+
for (const field of Reflect.ownKeys(obj)) {
|
|
1303
|
+
const descr = Reflect.getOwnPropertyDescriptor(obj, field);
|
|
1304
|
+
if (!descr.configurable)
|
|
1305
|
+
continue;
|
|
1306
|
+
if (!descr.get)
|
|
1307
|
+
continue;
|
|
1308
|
+
const get = descr.get ?? (() => descr.value);
|
|
1309
|
+
const set = descr.set ?? (next => descr.value = next);
|
|
1310
|
+
const persist = $mol_wire_atom.getter(get, 0);
|
|
1311
|
+
Reflect.defineProperty(obj, field, {
|
|
1312
|
+
configurable: true,
|
|
1313
|
+
enumerable: descr.enumerable,
|
|
1314
|
+
get() {
|
|
1315
|
+
const atom = persist(obj, []);
|
|
1316
|
+
atom.watch();
|
|
1317
|
+
return atom.sync();
|
|
1318
|
+
},
|
|
1319
|
+
set(next) {
|
|
1320
|
+
const atom = persist(obj, []);
|
|
1321
|
+
set.call(this, next);
|
|
1322
|
+
atom.refresh();
|
|
1323
|
+
},
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
$.$mol_wire_patch = $mol_wire_patch;
|
|
1328
|
+
})($ || ($ = {}));
|
|
1329
|
+
//mol/wire/patch/patch.ts
|
|
1330
|
+
;
|
|
1331
|
+
"use strict";
|
|
1332
|
+
var $;
|
|
1263
1333
|
(function ($) {
|
|
1264
1334
|
class $mol_wire_set extends Set {
|
|
1265
1335
|
pub = new $mol_wire_pub;
|