mol_wire_lib 1.0.1809 → 1.0.1811
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 +3 -8
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +69 -97
- package/node.js.map +1 -1
- package/node.mjs +69 -97
- package/node.test.js +370 -14462
- package/node.test.js.map +1 -1
- package/package.json +4 -4
- package/web.d.ts +3 -8
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +69 -97
- package/web.js.map +1 -1
- package/web.mjs +69 -97
- package/web.test.js +313 -32313
- package/web.test.js.map +1 -1
- 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 +0 -3
package/node.mjs
CHANGED
|
@@ -65,12 +65,10 @@ var $;
|
|
|
65
65
|
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
|
66
66
|
/** Some of (transitive) pub update required. */
|
|
67
67
|
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
68
|
-
/** Doubt check in progress, so any incoming quant is noticeable. */
|
|
69
|
-
$mol_wire_cursor[$mol_wire_cursor["check"] = -3] = "check";
|
|
70
68
|
/** Actual state but may be dropped. */
|
|
71
|
-
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -
|
|
69
|
+
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
72
70
|
/** State will never be changed. */
|
|
73
|
-
$mol_wire_cursor[$mol_wire_cursor["final"] = -
|
|
71
|
+
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
74
72
|
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
75
73
|
})($ || ($ = {}));
|
|
76
74
|
|
|
@@ -149,12 +147,6 @@ var $;
|
|
|
149
147
|
* Enforce actualization. Should not throw errors.
|
|
150
148
|
*/
|
|
151
149
|
fresh() { }
|
|
152
|
-
/**
|
|
153
|
-
* Lives inside single calculation of subscriber or not.
|
|
154
|
-
*/
|
|
155
|
-
get temp() {
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
150
|
/**
|
|
159
151
|
* Allow to put data to caches in the subtree.
|
|
160
152
|
*/
|
|
@@ -451,6 +443,9 @@ var $;
|
|
|
451
443
|
class $mol_wire_pub_sub extends $mol_wire_pub {
|
|
452
444
|
pub_from = 0; // 4B
|
|
453
445
|
cursor = $mol_wire_cursor.stale; // 4B
|
|
446
|
+
get temp() {
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
454
449
|
get pub_list() {
|
|
455
450
|
const res = [];
|
|
456
451
|
const max = this.cursor >= 0 ? this.cursor : this.sub_from;
|
|
@@ -470,9 +465,6 @@ var $;
|
|
|
470
465
|
if (this.cursor >= this.pub_from) {
|
|
471
466
|
$mol_fail(new Error('Circular subscription'));
|
|
472
467
|
}
|
|
473
|
-
if (this.cursor === $mol_wire_cursor.check) {
|
|
474
|
-
$mol_fail(new Error('Circular checking'));
|
|
475
|
-
}
|
|
476
468
|
super.promote();
|
|
477
469
|
}
|
|
478
470
|
track_next(pub) {
|
|
@@ -514,8 +506,7 @@ var $;
|
|
|
514
506
|
}
|
|
515
507
|
for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
|
|
516
508
|
const pub = this.data[cursor];
|
|
517
|
-
|
|
518
|
-
pub?.fresh();
|
|
509
|
+
pub.fresh();
|
|
519
510
|
}
|
|
520
511
|
this.cursor = $mol_wire_cursor.fresh;
|
|
521
512
|
}
|
|
@@ -524,10 +515,6 @@ var $;
|
|
|
524
515
|
this.data[sub_pos + 1] = undefined;
|
|
525
516
|
}
|
|
526
517
|
destructor() {
|
|
527
|
-
// Mid-calc destroy (absorb restarts a temp): stop promoting into this
|
|
528
|
-
// fiber so track_next does not throw 'Promo to non begun sub'.
|
|
529
|
-
if ($mol_wire_auto() === this)
|
|
530
|
-
$mol_wire_auto(null);
|
|
531
518
|
for (let cursor = this.data.length - 2; cursor >= this.sub_from; cursor -= 2) {
|
|
532
519
|
const sub = this.data[cursor];
|
|
533
520
|
const pos = this.data[cursor + 1];
|
|
@@ -573,21 +560,20 @@ var $;
|
|
|
573
560
|
return;
|
|
574
561
|
this.cursor = quant;
|
|
575
562
|
this.emit($mol_wire_cursor.doubt);
|
|
576
|
-
if
|
|
577
|
-
|
|
578
|
-
if
|
|
579
|
-
|
|
580
|
-
//
|
|
581
|
-
//
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}
|
|
563
|
+
// if( pos >= 0 && pos < this.sub_from - 2 ) {
|
|
564
|
+
// const pub = this.data[ pos ] as $mol_wire_pub
|
|
565
|
+
// if( pub instanceof $mol_wire_task ) return
|
|
566
|
+
// for(
|
|
567
|
+
// let cursor = this.pub_from;
|
|
568
|
+
// cursor < this.sub_from;
|
|
569
|
+
// cursor += 2
|
|
570
|
+
// ) {
|
|
571
|
+
// const pub = this.data[ cursor ] as $mol_wire_pub
|
|
572
|
+
// if( pub instanceof $mol_wire_task ) {
|
|
573
|
+
// pub.destructor()
|
|
574
|
+
// }
|
|
575
|
+
// }
|
|
576
|
+
// }
|
|
591
577
|
}
|
|
592
578
|
[$mol_dev_format_head]() {
|
|
593
579
|
return $mol_dev_format_native(this);
|
|
@@ -948,8 +934,7 @@ var $;
|
|
|
948
934
|
[$mol_dev_format_head]() {
|
|
949
935
|
const cursor = {
|
|
950
936
|
[$mol_wire_cursor.stale]: '🔴',
|
|
951
|
-
[$mol_wire_cursor.doubt]: '
|
|
952
|
-
[$mol_wire_cursor.check]: '🟡',
|
|
937
|
+
[$mol_wire_cursor.doubt]: '🟡',
|
|
953
938
|
[$mol_wire_cursor.fresh]: '🟢',
|
|
954
939
|
[$mol_wire_cursor.final]: '🔵',
|
|
955
940
|
}[this.cursor] ?? this.cursor.toString();
|
|
@@ -973,11 +958,10 @@ var $;
|
|
|
973
958
|
if (this.cursor === $mol_wire_cursor.final)
|
|
974
959
|
return;
|
|
975
960
|
check: if (this.cursor === $mol_wire_cursor.doubt) {
|
|
976
|
-
this.cursor = $mol_wire_cursor.check;
|
|
977
961
|
for (let i = this.pub_from; i < this.sub_from; i += 2) {
|
|
978
962
|
;
|
|
979
963
|
this.data[i]?.fresh();
|
|
980
|
-
if (this.cursor !== $mol_wire_cursor.
|
|
964
|
+
if (this.cursor !== $mol_wire_cursor.doubt)
|
|
981
965
|
break check;
|
|
982
966
|
}
|
|
983
967
|
this.cursor = $mol_wire_cursor.fresh;
|
|
@@ -986,74 +970,62 @@ var $;
|
|
|
986
970
|
const bu = this.track_on();
|
|
987
971
|
let result;
|
|
988
972
|
try {
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
973
|
+
switch (this.pub_from) {
|
|
974
|
+
case 0:
|
|
975
|
+
result = this.task.call(this.host);
|
|
976
|
+
break;
|
|
977
|
+
case 1:
|
|
978
|
+
result = this.task.call(this.host, this.data[0]);
|
|
979
|
+
break;
|
|
980
|
+
default:
|
|
981
|
+
result = this.task.call(this.host, ...this.args);
|
|
982
|
+
break;
|
|
983
|
+
}
|
|
984
|
+
if ($mol_promise_like(result)) {
|
|
985
|
+
if (wrappers.has(result)) {
|
|
986
|
+
result = wrappers.get(result).then(a => a);
|
|
1000
987
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
|
|
1012
|
-
wrappers.set(result, result);
|
|
1013
|
-
const error = new Error(`Promise in ${this}`);
|
|
1014
|
-
Object.defineProperty(result, 'stack', { get: () => error.stack });
|
|
1015
|
-
}
|
|
988
|
+
else {
|
|
989
|
+
const put = (res) => {
|
|
990
|
+
if (this.cache === result)
|
|
991
|
+
this.put(res);
|
|
992
|
+
return res;
|
|
993
|
+
};
|
|
994
|
+
wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
|
|
995
|
+
wrappers.set(result, result);
|
|
996
|
+
const error = new Error(`Promise in ${this}`);
|
|
997
|
+
Object.defineProperty(result, 'stack', { get: () => error.stack });
|
|
1016
998
|
}
|
|
1017
999
|
}
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1000
|
+
}
|
|
1001
|
+
catch (error) {
|
|
1002
|
+
if (error instanceof Error || $mol_promise_like(error)) {
|
|
1003
|
+
result = error;
|
|
1004
|
+
}
|
|
1005
|
+
else {
|
|
1006
|
+
result = new Error(String(error), { cause: error });
|
|
1007
|
+
}
|
|
1008
|
+
if ($mol_promise_like(result)) {
|
|
1009
|
+
if (wrappers.has(result)) {
|
|
1010
|
+
result = wrappers.get(result);
|
|
1021
1011
|
}
|
|
1022
1012
|
else {
|
|
1023
|
-
|
|
1013
|
+
const put = (v) => {
|
|
1014
|
+
if (this.cache === result)
|
|
1015
|
+
this.absorb();
|
|
1016
|
+
return v;
|
|
1017
|
+
};
|
|
1018
|
+
wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
|
|
1019
|
+
const error = new Error(`Promise in ${this}`);
|
|
1020
|
+
Object.defineProperty(result, 'stack', { get: () => error.stack });
|
|
1024
1021
|
}
|
|
1025
|
-
if ($mol_promise_like(result)) {
|
|
1026
|
-
if (wrappers.has(result)) {
|
|
1027
|
-
result = wrappers.get(result);
|
|
1028
|
-
}
|
|
1029
|
-
else {
|
|
1030
|
-
const put = (v) => {
|
|
1031
|
-
if (this.cache === result)
|
|
1032
|
-
this.absorb();
|
|
1033
|
-
return v;
|
|
1034
|
-
};
|
|
1035
|
-
wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
|
|
1036
|
-
const error = new Error(`Promise in ${this}`);
|
|
1037
|
-
Object.defineProperty(result, 'stack', { get: () => error.stack });
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
// Temp destroyed mid-calc (absorb restart): cut/off would throw.
|
|
1042
|
-
if (this.cursor < this.pub_from)
|
|
1043
|
-
return this;
|
|
1044
|
-
if (!$mol_promise_like(result)) {
|
|
1045
|
-
this.track_cut();
|
|
1046
1022
|
}
|
|
1047
|
-
this.track_off(bu);
|
|
1048
|
-
this.put(result);
|
|
1049
1023
|
}
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
// (else once()/onclose → Promo to non begun sub).
|
|
1053
|
-
if ($mol_wire_auto() === this || !$mol_wire_auto()) {
|
|
1054
|
-
$mol_wire_auto(bu);
|
|
1055
|
-
}
|
|
1024
|
+
if (!$mol_promise_like(result)) {
|
|
1025
|
+
this.track_cut();
|
|
1056
1026
|
}
|
|
1027
|
+
this.track_off(bu);
|
|
1028
|
+
this.put(result);
|
|
1057
1029
|
return this;
|
|
1058
1030
|
}
|
|
1059
1031
|
refresh() {
|