mol_jsx_lib 0.0.41 → 0.0.44
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 +36 -4
- package/node.deps.json +1 -1
- package/node.esm.js +101 -31
- package/node.esm.js.map +1 -1
- package/node.js +101 -31
- package/node.js.map +1 -1
- package/node.test.js +202 -113
- package/node.test.js.map +1 -1
- package/package.json +3 -2
- package/web.d.ts +7 -4
- package/web.deps.json +1 -1
- package/web.esm.js +51 -24
- package/web.esm.js.map +1 -1
- package/web.js +51 -24
- package/web.js.map +1 -1
- package/web.test.js +108 -89
- package/web.test.js.map +1 -1
package/web.js
CHANGED
|
@@ -423,7 +423,7 @@ var $;
|
|
|
423
423
|
promote() {
|
|
424
424
|
$mol_wire_auto()?.track_next(this);
|
|
425
425
|
}
|
|
426
|
-
|
|
426
|
+
fresh() { }
|
|
427
427
|
complete() { }
|
|
428
428
|
emit(quant = $mol_wire_cursor.stale) {
|
|
429
429
|
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
@@ -626,7 +626,7 @@ var $;
|
|
|
626
626
|
}
|
|
627
627
|
for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
|
|
628
628
|
const pub = this.data[cursor];
|
|
629
|
-
pub.
|
|
629
|
+
pub.fresh();
|
|
630
630
|
}
|
|
631
631
|
this.cursor = $mol_wire_cursor.fresh;
|
|
632
632
|
}
|
|
@@ -702,18 +702,20 @@ var $;
|
|
|
702
702
|
class $mol_after_frame extends $mol_object2 {
|
|
703
703
|
task;
|
|
704
704
|
static _promise = null;
|
|
705
|
-
static _timeout = null;
|
|
706
705
|
static get promise() {
|
|
707
706
|
if (this._promise)
|
|
708
707
|
return this._promise;
|
|
709
708
|
return this._promise = new Promise(done => {
|
|
710
709
|
const complete = () => {
|
|
711
710
|
this._promise = null;
|
|
712
|
-
clearTimeout(this._timeout);
|
|
713
711
|
done();
|
|
714
712
|
};
|
|
715
|
-
requestAnimationFrame
|
|
716
|
-
|
|
713
|
+
if (typeof requestAnimationFrame === 'function') {
|
|
714
|
+
requestAnimationFrame(complete);
|
|
715
|
+
}
|
|
716
|
+
else {
|
|
717
|
+
setTimeout(complete, 16);
|
|
718
|
+
}
|
|
717
719
|
});
|
|
718
720
|
}
|
|
719
721
|
cancelled = false;
|
|
@@ -760,10 +762,13 @@ var $;
|
|
|
760
762
|
}
|
|
761
763
|
static sync() {
|
|
762
764
|
while (this.planning.size) {
|
|
763
|
-
const
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
765
|
+
for (const fiber of this.planning) {
|
|
766
|
+
this.planning.delete(fiber);
|
|
767
|
+
if (fiber.cursor >= 0)
|
|
768
|
+
continue;
|
|
769
|
+
if (fiber.cursor === $mol_wire_cursor.final)
|
|
770
|
+
continue;
|
|
771
|
+
fiber.fresh();
|
|
767
772
|
}
|
|
768
773
|
}
|
|
769
774
|
while (this.reaping.size) {
|
|
@@ -790,12 +795,13 @@ var $;
|
|
|
790
795
|
field() {
|
|
791
796
|
return this.task.name + '()';
|
|
792
797
|
}
|
|
793
|
-
constructor(id, task, host,
|
|
798
|
+
constructor(id, task, host, args) {
|
|
794
799
|
super();
|
|
795
800
|
this.task = task;
|
|
796
801
|
this.host = host;
|
|
797
|
-
|
|
798
|
-
|
|
802
|
+
if (args)
|
|
803
|
+
this.data.push(...args);
|
|
804
|
+
this.pub_from = this.sub_from = args?.length ?? 0;
|
|
799
805
|
this[Symbol.toStringTag] = id;
|
|
800
806
|
}
|
|
801
807
|
plan() {
|
|
@@ -830,7 +836,7 @@ var $;
|
|
|
830
836
|
else
|
|
831
837
|
super.emit(quant);
|
|
832
838
|
}
|
|
833
|
-
|
|
839
|
+
fresh() {
|
|
834
840
|
if (this.cursor === $mol_wire_cursor.fresh)
|
|
835
841
|
return;
|
|
836
842
|
if (this.cursor === $mol_wire_cursor.final)
|
|
@@ -838,7 +844,7 @@ var $;
|
|
|
838
844
|
check: if (this.cursor === $mol_wire_cursor.doubt) {
|
|
839
845
|
for (let i = this.pub_from; i < this.sub_from; i += 2) {
|
|
840
846
|
;
|
|
841
|
-
this.data[i]?.
|
|
847
|
+
this.data[i]?.fresh();
|
|
842
848
|
if (this.cursor !== $mol_wire_cursor.doubt)
|
|
843
849
|
break check;
|
|
844
850
|
}
|
|
@@ -856,7 +862,7 @@ var $;
|
|
|
856
862
|
result = this.task.call(this.host, this.data[0]);
|
|
857
863
|
break;
|
|
858
864
|
default:
|
|
859
|
-
result = this.task.call(this.host, ...this.
|
|
865
|
+
result = this.task.call(this.host, ...this.args);
|
|
860
866
|
break;
|
|
861
867
|
}
|
|
862
868
|
if (result instanceof Promise) {
|
|
@@ -894,12 +900,16 @@ var $;
|
|
|
894
900
|
this.track_off(bu);
|
|
895
901
|
this.put(result);
|
|
896
902
|
}
|
|
903
|
+
refresh() {
|
|
904
|
+
this.cursor = $mol_wire_cursor.stale;
|
|
905
|
+
this.fresh();
|
|
906
|
+
}
|
|
897
907
|
sync() {
|
|
898
908
|
if (!$mol_wire_fiber.warm) {
|
|
899
909
|
return this.result();
|
|
900
910
|
}
|
|
901
911
|
this.promote();
|
|
902
|
-
this.
|
|
912
|
+
this.fresh();
|
|
903
913
|
if (this.cache instanceof Error) {
|
|
904
914
|
return $mol_fail_hidden(this.cache);
|
|
905
915
|
}
|
|
@@ -910,7 +920,7 @@ var $;
|
|
|
910
920
|
}
|
|
911
921
|
async async() {
|
|
912
922
|
while (true) {
|
|
913
|
-
this.
|
|
923
|
+
this.fresh();
|
|
914
924
|
if (this.cache instanceof Error) {
|
|
915
925
|
$mol_fail_hidden(this.cache);
|
|
916
926
|
}
|
|
@@ -1122,7 +1132,7 @@ var $;
|
|
|
1122
1132
|
break reuse;
|
|
1123
1133
|
return existen;
|
|
1124
1134
|
}
|
|
1125
|
-
return new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host,
|
|
1135
|
+
return new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, args);
|
|
1126
1136
|
};
|
|
1127
1137
|
}
|
|
1128
1138
|
complete() {
|
|
@@ -1195,7 +1205,7 @@ var $;
|
|
|
1195
1205
|
else {
|
|
1196
1206
|
dict = (host ?? task)[field] = new Map();
|
|
1197
1207
|
}
|
|
1198
|
-
fiber = new $mol_wire_atom(key, task, host,
|
|
1208
|
+
fiber = new $mol_wire_atom(key, task, host, args);
|
|
1199
1209
|
dict.set(key, fiber);
|
|
1200
1210
|
return fiber;
|
|
1201
1211
|
};
|
|
@@ -1206,13 +1216,29 @@ var $;
|
|
|
1206
1216
|
if (existen)
|
|
1207
1217
|
return existen;
|
|
1208
1218
|
const key = `${host?.[Symbol.toStringTag] ?? host}.${field}`;
|
|
1209
|
-
const fiber = new $mol_wire_atom(key, task, host,
|
|
1219
|
+
const fiber = new $mol_wire_atom(key, task, host, args);
|
|
1210
1220
|
(host ?? task)[field] = fiber;
|
|
1211
1221
|
return fiber;
|
|
1212
1222
|
};
|
|
1213
1223
|
}
|
|
1214
1224
|
}
|
|
1215
|
-
|
|
1225
|
+
static watching = new Set();
|
|
1226
|
+
static watch() {
|
|
1227
|
+
new $mol_after_frame($mol_wire_atom.watch);
|
|
1228
|
+
for (const atom of $mol_wire_atom.watching) {
|
|
1229
|
+
if (atom.cursor === $mol_wire_cursor.final) {
|
|
1230
|
+
$mol_wire_atom.watching.delete(atom);
|
|
1231
|
+
}
|
|
1232
|
+
else {
|
|
1233
|
+
atom.cursor = $mol_wire_cursor.stale;
|
|
1234
|
+
atom.fresh();
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
watch() {
|
|
1239
|
+
$mol_wire_atom.watching.add(this);
|
|
1240
|
+
}
|
|
1241
|
+
resync(args) {
|
|
1216
1242
|
return this.put(this.task.call(this.host, ...args));
|
|
1217
1243
|
}
|
|
1218
1244
|
once() {
|
|
@@ -1266,6 +1292,7 @@ var $;
|
|
|
1266
1292
|
$mol_wire_method
|
|
1267
1293
|
], $mol_wire_atom.prototype, "once", null);
|
|
1268
1294
|
$.$mol_wire_atom = $mol_wire_atom;
|
|
1295
|
+
$mol_wire_atom.watch();
|
|
1269
1296
|
})($ || ($ = {}));
|
|
1270
1297
|
//mol/wire/atom/atom.ts
|
|
1271
1298
|
;
|
|
@@ -1298,7 +1325,7 @@ var $;
|
|
|
1298
1325
|
let atom = persist(this, args.slice(0, keys));
|
|
1299
1326
|
if (args.length <= keys || args[keys] === undefined) {
|
|
1300
1327
|
if (!$mol_wire_fiber.warm)
|
|
1301
|
-
return atom.
|
|
1328
|
+
return atom.result();
|
|
1302
1329
|
if ($mol_wire_auto() instanceof $mol_wire_task) {
|
|
1303
1330
|
return atom.once();
|
|
1304
1331
|
}
|
|
@@ -1306,7 +1333,7 @@ var $;
|
|
|
1306
1333
|
return atom.sync();
|
|
1307
1334
|
}
|
|
1308
1335
|
}
|
|
1309
|
-
return atom.resync(
|
|
1336
|
+
return atom.resync(args);
|
|
1310
1337
|
};
|
|
1311
1338
|
Object.defineProperty(wrapper, 'name', { value: func.name + ' ' });
|
|
1312
1339
|
Object.assign(wrapper, { orig: func });
|