mol_jsx_lib 0.0.1666 → 0.0.1667
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/giper/baza/diagram/dict.png +0 -0
- package/giper/baza/diagram/gift.png +0 -0
- package/giper/baza/diagram/jepsen.png +0 -0
- package/giper/baza/diagram/json.png +0 -0
- package/giper/baza/diagram/list.png +0 -0
- package/giper/baza/diagram/network.png +0 -0
- package/giper/baza/diagram/pack.png +0 -0
- package/giper/baza/diagram/pass.png +0 -0
- package/giper/baza/diagram/reg.png +0 -0
- package/giper/baza/diagram/rich.png +0 -0
- package/giper/baza/diagram/sand.png +0 -0
- package/giper/baza/diagram/sync.png +0 -0
- package/giper/baza/diagram/text.png +0 -0
- package/giper/baza/diagram/tree.png +0 -0
- package/giper/baza/logo/bg.webp +0 -0
- package/giper/baza/logo/logo-512.png +0 -0
- package/giper/baza/logo/logo.svg +3 -0
- package/node.d.ts +8 -3
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +97 -69
- package/node.js.map +1 -1
- package/node.mjs +97 -69
- package/node.test.js +14490 -413
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +8 -3
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +97 -69
- package/web.js.map +1 -1
- package/web.mjs +97 -69
- package/web.test.js +32208 -254
- package/web.test.js.map +1 -1
package/node.mjs
CHANGED
|
@@ -505,10 +505,12 @@ var $;
|
|
|
505
505
|
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
|
506
506
|
/** Some of (transitive) pub update required. */
|
|
507
507
|
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
508
|
+
/** Doubt check in progress, so any incoming quant is noticeable. */
|
|
509
|
+
$mol_wire_cursor[$mol_wire_cursor["check"] = -3] = "check";
|
|
508
510
|
/** Actual state but may be dropped. */
|
|
509
|
-
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -
|
|
511
|
+
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -4] = "fresh";
|
|
510
512
|
/** State will never be changed. */
|
|
511
|
-
$mol_wire_cursor[$mol_wire_cursor["final"] = -
|
|
513
|
+
$mol_wire_cursor[$mol_wire_cursor["final"] = -5] = "final";
|
|
512
514
|
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
513
515
|
})($ || ($ = {}));
|
|
514
516
|
|
|
@@ -587,6 +589,12 @@ var $;
|
|
|
587
589
|
* Enforce actualization. Should not throw errors.
|
|
588
590
|
*/
|
|
589
591
|
fresh() { }
|
|
592
|
+
/**
|
|
593
|
+
* Lives inside single calculation of subscriber or not.
|
|
594
|
+
*/
|
|
595
|
+
get temp() {
|
|
596
|
+
return false;
|
|
597
|
+
}
|
|
590
598
|
/**
|
|
591
599
|
* Allow to put data to caches in the subtree.
|
|
592
600
|
*/
|
|
@@ -873,9 +881,6 @@ var $;
|
|
|
873
881
|
class $mol_wire_pub_sub extends $mol_wire_pub {
|
|
874
882
|
pub_from = 0; // 4B
|
|
875
883
|
cursor = $mol_wire_cursor.stale; // 4B
|
|
876
|
-
get temp() {
|
|
877
|
-
return false;
|
|
878
|
-
}
|
|
879
884
|
get pub_list() {
|
|
880
885
|
const res = [];
|
|
881
886
|
const max = this.cursor >= 0 ? this.cursor : this.sub_from;
|
|
@@ -895,6 +900,9 @@ var $;
|
|
|
895
900
|
if (this.cursor >= this.pub_from) {
|
|
896
901
|
$mol_fail(new Error('Circular subscription'));
|
|
897
902
|
}
|
|
903
|
+
if (this.cursor === $mol_wire_cursor.check) {
|
|
904
|
+
$mol_fail(new Error('Circular checking'));
|
|
905
|
+
}
|
|
898
906
|
super.promote();
|
|
899
907
|
}
|
|
900
908
|
track_next(pub) {
|
|
@@ -936,7 +944,8 @@ var $;
|
|
|
936
944
|
}
|
|
937
945
|
for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
|
|
938
946
|
const pub = this.data[cursor];
|
|
939
|
-
|
|
947
|
+
// Slot may be cleared by pub_off when a temp was destroyed mid-calc.
|
|
948
|
+
pub?.fresh();
|
|
940
949
|
}
|
|
941
950
|
this.cursor = $mol_wire_cursor.fresh;
|
|
942
951
|
}
|
|
@@ -945,6 +954,10 @@ var $;
|
|
|
945
954
|
this.data[sub_pos + 1] = undefined;
|
|
946
955
|
}
|
|
947
956
|
destructor() {
|
|
957
|
+
// Mid-calc destroy (absorb restarts a temp): stop promoting into this
|
|
958
|
+
// fiber so track_next does not throw 'Promo to non begun sub'.
|
|
959
|
+
if ($mol_wire_auto() === this)
|
|
960
|
+
$mol_wire_auto(null);
|
|
948
961
|
for (let cursor = this.data.length - 2; cursor >= this.sub_from; cursor -= 2) {
|
|
949
962
|
const sub = this.data[cursor];
|
|
950
963
|
const pos = this.data[cursor + 1];
|
|
@@ -990,20 +1003,21 @@ var $;
|
|
|
990
1003
|
return;
|
|
991
1004
|
this.cursor = quant;
|
|
992
1005
|
this.emit($mol_wire_cursor.doubt);
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
//
|
|
998
|
-
//
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1006
|
+
if (quant !== $mol_wire_cursor.stale)
|
|
1007
|
+
return;
|
|
1008
|
+
if (!this.incompleted)
|
|
1009
|
+
return;
|
|
1010
|
+
// Notice from own task resumes the same calculation, but from a regular
|
|
1011
|
+
// pub it makes awaited tasks based on outdated data, so restart them.
|
|
1012
|
+
const pub = this.data[pos];
|
|
1013
|
+
if (pub?.temp)
|
|
1014
|
+
return;
|
|
1015
|
+
for (let cursor = this.pub_from; cursor < this.sub_from; cursor += 2) {
|
|
1016
|
+
const pub = this.data[cursor];
|
|
1017
|
+
if (pub?.temp) {
|
|
1018
|
+
pub.destructor();
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1007
1021
|
}
|
|
1008
1022
|
[$mol_dev_format_head]() {
|
|
1009
1023
|
return $mol_dev_format_native(this);
|
|
@@ -1143,7 +1157,8 @@ var $;
|
|
|
1143
1157
|
[$mol_dev_format_head]() {
|
|
1144
1158
|
const cursor = {
|
|
1145
1159
|
[$mol_wire_cursor.stale]: '🔴',
|
|
1146
|
-
[$mol_wire_cursor.doubt]: '
|
|
1160
|
+
[$mol_wire_cursor.doubt]: '🟠',
|
|
1161
|
+
[$mol_wire_cursor.check]: '🟡',
|
|
1147
1162
|
[$mol_wire_cursor.fresh]: '🟢',
|
|
1148
1163
|
[$mol_wire_cursor.final]: '🔵',
|
|
1149
1164
|
}[this.cursor] ?? this.cursor.toString();
|
|
@@ -1167,10 +1182,11 @@ var $;
|
|
|
1167
1182
|
if (this.cursor === $mol_wire_cursor.final)
|
|
1168
1183
|
return;
|
|
1169
1184
|
check: if (this.cursor === $mol_wire_cursor.doubt) {
|
|
1185
|
+
this.cursor = $mol_wire_cursor.check;
|
|
1170
1186
|
for (let i = this.pub_from; i < this.sub_from; i += 2) {
|
|
1171
1187
|
;
|
|
1172
1188
|
this.data[i]?.fresh();
|
|
1173
|
-
if (this.cursor !== $mol_wire_cursor.
|
|
1189
|
+
if (this.cursor !== $mol_wire_cursor.check)
|
|
1174
1190
|
break check;
|
|
1175
1191
|
}
|
|
1176
1192
|
this.cursor = $mol_wire_cursor.fresh;
|
|
@@ -1179,62 +1195,74 @@ var $;
|
|
|
1179
1195
|
const bu = this.track_on();
|
|
1180
1196
|
let result;
|
|
1181
1197
|
try {
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
if ($mol_promise_like(result)) {
|
|
1194
|
-
if (wrappers.has(result)) {
|
|
1195
|
-
result = wrappers.get(result).then(a => a);
|
|
1198
|
+
try {
|
|
1199
|
+
switch (this.pub_from) {
|
|
1200
|
+
case 0:
|
|
1201
|
+
result = this.task.call(this.host);
|
|
1202
|
+
break;
|
|
1203
|
+
case 1:
|
|
1204
|
+
result = this.task.call(this.host, this.data[0]);
|
|
1205
|
+
break;
|
|
1206
|
+
default:
|
|
1207
|
+
result = this.task.call(this.host, ...this.args);
|
|
1208
|
+
break;
|
|
1196
1209
|
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1210
|
+
if ($mol_promise_like(result)) {
|
|
1211
|
+
if (wrappers.has(result)) {
|
|
1212
|
+
result = wrappers.get(result).then(a => a);
|
|
1213
|
+
}
|
|
1214
|
+
else {
|
|
1215
|
+
const put = (res) => {
|
|
1216
|
+
if (this.cache === result)
|
|
1217
|
+
this.put(res);
|
|
1218
|
+
return res;
|
|
1219
|
+
};
|
|
1220
|
+
wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
|
|
1221
|
+
wrappers.set(result, result);
|
|
1222
|
+
const error = new Error(`Promise in ${this}`);
|
|
1223
|
+
Object.defineProperty(result, 'stack', { get: () => error.stack });
|
|
1224
|
+
}
|
|
1207
1225
|
}
|
|
1208
1226
|
}
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
result = error;
|
|
1213
|
-
}
|
|
1214
|
-
else {
|
|
1215
|
-
result = new Error(String(error), { cause: error });
|
|
1216
|
-
}
|
|
1217
|
-
if ($mol_promise_like(result)) {
|
|
1218
|
-
if (wrappers.has(result)) {
|
|
1219
|
-
result = wrappers.get(result);
|
|
1227
|
+
catch (error) {
|
|
1228
|
+
if (error instanceof Error || $mol_promise_like(error)) {
|
|
1229
|
+
result = error;
|
|
1220
1230
|
}
|
|
1221
1231
|
else {
|
|
1222
|
-
|
|
1223
|
-
if (this.cache === result)
|
|
1224
|
-
this.absorb();
|
|
1225
|
-
return v;
|
|
1226
|
-
};
|
|
1227
|
-
wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
|
|
1228
|
-
const error = new Error(`Promise in ${this}`);
|
|
1229
|
-
Object.defineProperty(result, 'stack', { get: () => error.stack });
|
|
1232
|
+
result = new Error(String(error), { cause: error });
|
|
1230
1233
|
}
|
|
1234
|
+
if ($mol_promise_like(result)) {
|
|
1235
|
+
if (wrappers.has(result)) {
|
|
1236
|
+
result = wrappers.get(result);
|
|
1237
|
+
}
|
|
1238
|
+
else {
|
|
1239
|
+
const put = (v) => {
|
|
1240
|
+
if (this.cache === result)
|
|
1241
|
+
this.absorb();
|
|
1242
|
+
return v;
|
|
1243
|
+
};
|
|
1244
|
+
wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
|
|
1245
|
+
const error = new Error(`Promise in ${this}`);
|
|
1246
|
+
Object.defineProperty(result, 'stack', { get: () => error.stack });
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
// Temp destroyed mid-calc (absorb restart): cut/off would throw.
|
|
1251
|
+
if (this.cursor < this.pub_from)
|
|
1252
|
+
return this;
|
|
1253
|
+
if (!$mol_promise_like(result)) {
|
|
1254
|
+
this.track_cut();
|
|
1231
1255
|
}
|
|
1256
|
+
this.track_off(bu);
|
|
1257
|
+
this.put(result);
|
|
1232
1258
|
}
|
|
1233
|
-
|
|
1234
|
-
|
|
1259
|
+
finally {
|
|
1260
|
+
// If cut threw or destructor nulled auto — put outer back
|
|
1261
|
+
// (else once()/onclose → Promo to non begun sub).
|
|
1262
|
+
if ($mol_wire_auto() === this || !$mol_wire_auto()) {
|
|
1263
|
+
$mol_wire_auto(bu);
|
|
1264
|
+
}
|
|
1235
1265
|
}
|
|
1236
|
-
this.track_off(bu);
|
|
1237
|
-
this.put(result);
|
|
1238
1266
|
return this;
|
|
1239
1267
|
}
|
|
1240
1268
|
refresh() {
|