mol_wire_pub 1.0.33 → 1.0.37
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 +6 -7
- package/node.deps.json +1 -1
- package/node.esm.js +8 -28
- package/node.esm.js.map +1 -1
- package/node.js +8 -28
- package/node.js.map +1 -1
- package/node.test.js +31 -45
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +6 -7
- package/web.deps.json +1 -1
- package/web.esm.js +8 -28
- package/web.esm.js.map +1 -1
- package/web.js +8 -28
- package/web.js.map +1 -1
- package/web.test.js +23 -17
- package/web.test.js.map +1 -1
package/node.d.ts
CHANGED
|
@@ -19,10 +19,10 @@ declare namespace $ {
|
|
|
19
19
|
|
|
20
20
|
declare namespace $ {
|
|
21
21
|
enum $mol_wire_cursor {
|
|
22
|
-
stale,
|
|
23
|
-
doubt,
|
|
24
|
-
fresh,
|
|
25
|
-
final
|
|
22
|
+
stale = -1,
|
|
23
|
+
doubt = -2,
|
|
24
|
+
fresh = -3,
|
|
25
|
+
final = -4
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -38,9 +38,8 @@ declare namespace $ {
|
|
|
38
38
|
promote(): void;
|
|
39
39
|
up(): void;
|
|
40
40
|
down(): void;
|
|
41
|
-
emit(): void;
|
|
42
|
-
|
|
43
|
-
affect(quant: number): boolean;
|
|
41
|
+
emit(quant?: $mol_wire_cursor): void;
|
|
42
|
+
absorb(quant?: $mol_wire_cursor): boolean;
|
|
44
43
|
peer_move(from_pos: number, to_pos: number): void;
|
|
45
44
|
peer_repos(peer_pos: number, self_pos: number): void;
|
|
46
45
|
}
|
package/node.deps.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"files":["LICENSE","README.md","lang.lang.tree","mam.jam.js","mam.ts","package.json","sandbox.config.json","tsconfig.json","tsfmt.json","yarn.lock","mol/CNAME","mol/CODE_OF_CONDUCT.md","mol/CONTRIBUTING.md","mol/LICENSE","mol/index.html","mol/mol.meta.tree","mol/readme.md","mol/fail/fail.ts","mol/wire/cursor/cursor.ts","mol/wire/pub/pub.ts","mol/wire/sub/sub.ts","mol/wire/README.md","mol/wire/wire.ts"],"mods":{},"deps_in":{"mol/wire":{},"mol":{"mol/wire":-9007199254740991,"mol/fail":-9007199254740991},"":{"mol":-9007199254740991},"mol/wire/sub":{"mol/wire":-1},"mol/wire/pub":{"mol/wire/sub":-1},"mol/fail":{"mol/wire/pub":-4},"mol/wire/cursor":{"mol/wire/pub":-
|
|
1
|
+
{"files":["LICENSE","README.md","lang.lang.tree","mam.jam.js","mam.ts","package.json","sandbox.config.json","tsconfig.json","tsfmt.json","yarn.lock","mol/CNAME","mol/CODE_OF_CONDUCT.md","mol/CONTRIBUTING.md","mol/LICENSE","mol/index.html","mol/mol.meta.tree","mol/readme.md","mol/fail/fail.ts","mol/wire/cursor/cursor.ts","mol/wire/pub/pub.ts","mol/wire/sub/sub.ts","mol/wire/README.md","mol/wire/wire.ts"],"mods":{},"deps_in":{"mol/wire":{},"mol":{"mol/wire":-9007199254740991,"mol/fail":-9007199254740991},"":{"mol":-9007199254740991},"mol/wire/sub":{"mol/wire":-1},"mol/wire/pub":{"mol/wire/sub":-1},"mol/fail":{"mol/wire/pub":-4},"mol/wire/cursor":{"mol/wire/pub":-2}},"deps_out":{"mol/wire/pub":{"mol/fail":-4,"mol/wire/cursor":-2},"mol/wire":{"mol":-9007199254740991,"mol/wire/sub":-1},"mol":{"":-9007199254740991},"mol/wire/sub":{"mol/wire/pub":-1},"mol/fail":{"mol":-9007199254740991},"mol/wire/cursor":{}},"sloc":{"LICENSE":113,"md":602,"tree":31,"js":10,"ts":170,"json":85,"lock":939,"CNAME":1,"html":1},"deps":{"mol/wire/pub":{"..":-9007199254740991,"/mol/wire/pub":-1,"/mol/wire/sub":-3,"/mol/fail":-4,"/mol/wire/auto":-3,"/mol/wire/cursor/stale":-2,"/mol/wire/cursor/doubt":-3},"mol/wire":{"..":-9007199254740991,"/mol/wire/auto":-1,"/mol/wire/sub":-1,"/mol/wire/affected":-1},"mol":{"..":-9007199254740991},"":{},"mol/wire/sub":{"..":-9007199254740991,"/mol/wire/sub":-1,"/mol/wire/pub":-1},"mol/fail":{"..":-9007199254740991,"/mol/fail":-1},"mol/wire/cursor":{"..":-9007199254740991,"/mol/wire/cursor":-1}}}
|
package/node.esm.js
CHANGED
|
@@ -44,18 +44,10 @@ var $;
|
|
|
44
44
|
(function ($) {
|
|
45
45
|
let $mol_wire_cursor;
|
|
46
46
|
(function ($mol_wire_cursor) {
|
|
47
|
-
$mol_wire_cursor[$mol_wire_cursor["stale"] =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
$mol_wire_cursor[$mol_wire_cursor["
|
|
51
|
-
toString() { return '🟡'; }
|
|
52
|
-
})(-2)] = "doubt";
|
|
53
|
-
$mol_wire_cursor[$mol_wire_cursor["fresh"] = new (class fresh extends Number {
|
|
54
|
-
toString() { return '🟢'; }
|
|
55
|
-
})(-3)] = "fresh";
|
|
56
|
-
$mol_wire_cursor[$mol_wire_cursor["final"] = new (class solid extends Number {
|
|
57
|
-
toString() { return '🔵'; }
|
|
58
|
-
})(-4)] = "final";
|
|
47
|
+
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
|
48
|
+
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
49
|
+
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
50
|
+
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
59
51
|
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
60
52
|
})($ || ($ = {}));
|
|
61
53
|
//mol/wire/cursor/cursor.ts
|
|
@@ -102,26 +94,14 @@ var $;
|
|
|
102
94
|
}
|
|
103
95
|
up() { }
|
|
104
96
|
down() { }
|
|
105
|
-
emit() {
|
|
97
|
+
emit(quant = $mol_wire_cursor.stale) {
|
|
106
98
|
for (let i = this.sub_from; i < this.length; i += 2) {
|
|
107
99
|
;
|
|
108
|
-
this[i].
|
|
100
|
+
this[i].absorb(quant);
|
|
109
101
|
}
|
|
110
102
|
}
|
|
111
|
-
stale
|
|
112
|
-
|
|
113
|
-
return false;
|
|
114
|
-
while ($mol_wire_affected.length) {
|
|
115
|
-
const next = $mol_wire_affected.pop();
|
|
116
|
-
next.affect($mol_wire_cursor.doubt);
|
|
117
|
-
}
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
affect(quant) {
|
|
121
|
-
for (let i = this.sub_from; i < this.length; i += 2) {
|
|
122
|
-
const sub = this[i];
|
|
123
|
-
$mol_wire_affected.push(sub);
|
|
124
|
-
}
|
|
103
|
+
absorb(quant = $mol_wire_cursor.stale) {
|
|
104
|
+
this.emit($mol_wire_cursor.doubt);
|
|
125
105
|
return true;
|
|
126
106
|
}
|
|
127
107
|
peer_move(from_pos, to_pos) {
|
package/node.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../mam.jam.js","-","../../../../mam.ts","../../../fail/mol/fail/fail.ts","../../cursor/mol/wire/cursor/cursor.ts","../mol/wire/pub/pub.ts","../../sub/sub.ts","../../mol/wire/wire.ts"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACbA;AACA;AACA;AACA;;ACHA,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;AAK3B,IAAU,CAAC,CAMV;AAND,WAAU,CAAC;AAMX,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,CAAA;;;ADblB;AACA;AACA;;AEFA,IAAU,CAAC,CAMV;AAND,WAAU,CAAC;IAEV,SAAgB,SAAS,CAAE,KAAW;QACrC,MAAM,KAAK,CAAA;IACZ,CAAC;IAFe,WAAS,YAExB,CAAA;AAEF,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;;;;ACND,IAAU,CAAC,CAmBV;AAnBD,WAAU,CAAC;IAGV,IAAY,gBAcX;IAdD,WAAY,gBAAgB;QAG3B,
|
|
1
|
+
{"version":3,"sources":["../../../../mam.jam.js","-","../../../../mam.ts","../../../fail/mol/fail/fail.ts","../../cursor/mol/wire/cursor/cursor.ts","../mol/wire/pub/pub.ts","../../sub/sub.ts","../../mol/wire/wire.ts"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACbA;AACA;AACA;AACA;;ACHA,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;AAK3B,IAAU,CAAC,CAMV;AAND,WAAU,CAAC;AAMX,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,CAAA;;;ADblB;AACA;AACA;;AEFA,IAAU,CAAC,CAMV;AAND,WAAU,CAAC;IAEV,SAAgB,SAAS,CAAE,KAAW;QACrC,MAAM,KAAK,CAAA;IACZ,CAAC;IAFe,WAAS,YAExB,CAAA;AAEF,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;;;;ACND,IAAU,CAAC,CAmBV;AAnBD,WAAU,CAAC;IAGV,IAAY,gBAcX;IAdD,WAAY,gBAAgB;QAG3B,0DAAU,CAAA;QAGV,0DAAU,CAAA;QAGV,0DAAU,CAAA;QAGV,0DAAU,CAAA;IAEX,CAAC,EAdW,gBAAgB,GAAhB,kBAAgB,KAAhB,kBAAgB,QAc3B;AAEF,CAAC,EAnBS,CAAC,KAAD,CAAC,QAmBV;;;;ACnBD,IAAU,CAAC,CA+HV;AA/HD,WAAU,CAAC;IAKV,MAAa,aAAc,SAAQ,KAAgB;QAGlD,MAAM,KAAK,CAAE,MAAM,CAAC,OAAO,CAAE;YAC5B,OAAO,KAAK,CAAA;QACb,CAAC;QAKS,QAAQ,GAAG,CAAC,CAAA;QAKtB,IAAI,QAAQ;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AAC,KAAK;YACnC,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAG;gBACrD,CAAC;gBAAE,IAAI,CAAC,CAAC,CAAoB,CAAC,MAAM,CAAE,KAAK,CAAE,CAAA;aAC7C;QACF,CAAC;QAKD,MAAM,CAAE,KAAK,GAAG,gBAAgB,CAAC,KAAK;YACrC,IAAI,CAAC,IAAI,CAAE,gBAAgB,CAAC,KAAK,CAAE,CAAA;YACnC,OAAO,IAAI,CAAA;QACZ,CAAC;QAKD,SAAS,CAAE,QAAgB,EAAE,MAAc;YAE1C,MAAM,IAAI,GAAG,IAAI,CAAE,QAAQ,CAAmB,CAAA;YAC9C,MAAM,QAAQ,GAAG,IAAI,CAAE,QAAQ,GAAG,CAAC,CAAY,CAAA;YAE/C,IAAI,CAAE,MAAM,CAAE,GAAG,IAAI,CAAA;YACrB,IAAI,CAAE,MAAM,GAAG,CAAC,CAAE,GAAG,QAAQ,CAAA;YAE7B,IAAI,CAAC,UAAU,CAAE,QAAQ,EAAE,MAAM,CAAE,CAAA;QACpC,CAAC;QAKD,UAAU,CAAE,QAAgB,EAAE,QAAgB;YAC7C,IAAI,CAAE,QAAQ,GAAG,CAAC,CAAE,GAAG,QAAQ,CAAA;QAChC,CAAC;KAED;IAxHY,eAAa,gBAwHzB,CAAA;AAEF,CAAC,EA/HS,CAAC,KAAD,CAAC,QA+HV;;;AC/HD;AACA;AACA;;ACFA,IAAU,CAAC,CAYV;AAZD,WAAU,CAAC;IAKC,gBAAc,GAAyB,IAAI,CAAA;IAKzC,oBAAkB,GAAG,EAAkC,CAAA;AAErE,CAAC,EAZS,CAAC,KAAD,CAAC,QAYV;;;ANZD","file":"node.esm.js","sourcesContent":[null,null,"Error.stackTraceLimit = 50;\n\ndeclare let _$_: { new(): {} } & typeof globalThis\ndeclare class $ extends _$_ {}\n\nnamespace $ {\n\texport type $ = typeof $$\n\texport declare class $$ extends $ {}\n\tnamespace $$ {\n\t\texport type $$ = $\n\t}\n}\n\nmodule.exports = $\n","namespace $ {\n\n\texport function $mol_fail( error : any ) : never {\n\t\tthrow error\n\t}\n\n}\n","namespace $ {\n\t\n\t/** Special status statuses. */\n\texport enum $mol_wire_cursor {\n\t\t\n\t\t/** Update required. */\n\t\tstale = -1,\n\t\t\n\t\t/** Some of (transitive) pub update required. */\n\t\tdoubt = -2,\n\t\t\n\t\t/** Actual state but may be dropped. */\n\t\tfresh = -3,\n\t\t\n\t\t/** State will never be changed. */\n\t\tfinal = -4,\n\t\t\n\t}\n\t\n}\n","namespace $ {\n\t\n\t/**\n\t * Collects subscribers in compact array. 28B\n\t */\n\texport class $mol_wire_pub extends Array< unknown > {\n\t\t\n\t\t// Derived objects should be Arrays.\n\t\tstatic get [ Symbol.species ]() {\n\t\t\treturn Array\n\t\t}\n\t\t\n\t\t/**\n\t\t * Index of first subscriber.\n\t\t */\n\t\tprotected sub_from = 0 // 4B\n\t\t\n\t\t/**\n\t\t * All current subscribers.\n\t\t */\n\t\tget sub_list() {\n\t\t\tconst res = [] as $mol_wire_sub[]\n\t\t\tfor( let i = this.sub_from; i < this.length; i += 2 ) {\n\t\t\t\tres.push( this[i] as $mol_wire_sub )\n\t\t\t}\n\t\t\treturn res as readonly $mol_wire_sub[]\n\t\t}\n\t\t\n\t\t/**\n\t\t * Has any subscribers or not.\n\t\t */\n\t\tget sub_empty() {\n\t\t\treturn this.sub_from === this.length\n\t\t}\n\t\t\n\t\t/**\n\t\t * Subscribe subscriber to this publisher events and return position of subscriber that required to unsubscribe.\n\t\t */\n\t\tsub_on( sub: $mol_wire_pub, pub_pos: number ) {\n\t\t\tconst pos = this.length\n\t\t\tthis.push( sub, pub_pos )\n\t\t\treturn pos\n\t\t}\n\t\t\n\t\t/**\n\t\t * Unsubscribe subscriber from this publisher events by subscriber position provided by `on(pub)`.\n\t\t */\n\t\tsub_off( sub_pos: number ) {\n\t\t\t\n\t\t\tif(!( sub_pos < this.length )) {\n\t\t\t\t$mol_fail( new Error( `Wrong pos ${ sub_pos }` ) )\n\t\t\t}\n\t\t\t\n\t\t\tconst end = this.length - 2\n\t\t\tif( sub_pos !== end ) {\n\t\t\t\tthis.peer_move( end, sub_pos )\n\t\t\t}\n\t\t\t\n\t\t\tthis.pop()\n\t\t\tthis.pop()\n\t\t\t\n\t\t\tif( this.length === this.sub_from ) this.reap()\n\t\t\t\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called when last sub was unsubscribed.\n\t\t **/\n\t\treap() { }\n\t\t\n\t\t/**\n\t\t * Autowire this publisher with current subscriber.\n\t\t **/\n\t\tpromote() {\n\t\t\t$mol_wire_auto?.track_next( this )\n\t\t}\n\t\t\n\t\t/**\n\t\t * Enforce actualization. Should not throw errors.\n\t\t */\n\t\tup() {}\n\t\t\n\t\t/**\n\t\t * Subscriber stabilized and allows to free.\n\t\t */\n\t\tdown() {}\n\t\t\n\t\t/**\n\t\t * Notify subscribers about self changes.\n\t\t */\n\t\temit( quant = $mol_wire_cursor.stale ) {\n\t\t\tfor( let i = this.sub_from; i < this.length; i += 2 ) {\n\t\t\t\t;( this[i] as $mol_wire_pub ).absorb( quant )\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Receive notification about publisher changes.\n\t\t */\n\t\tabsorb( quant = $mol_wire_cursor.stale ) {\n\t\t\tthis.emit( $mol_wire_cursor.doubt )\n\t\t\treturn true\n\t\t}\n\t\t\n\t\t/**\n\t\t * Moves peer from one position to another. Doesn't clear data at old position!\n\t\t */\n\t\tpeer_move( from_pos: number, to_pos: number ) {\n\t\t\t\n\t\t\tconst peer = this[ from_pos ] as $mol_wire_pub\n\t\t\tconst self_pos = this[ from_pos + 1 ] as number\n\t\t\t\n\t\t\tthis[ to_pos ] = peer\n\t\t\tthis[ to_pos + 1 ] = self_pos\n\t\t\t\n\t\t\tpeer.peer_repos( self_pos, to_pos )\n\t\t}\n\t\t\n\t\t/**\n\t\t * Updates self position in the peer.\n\t\t */\n\t\tpeer_repos( peer_pos: number, self_pos: number ) {\n\t\t\tthis[ peer_pos + 1 ] = self_pos\n\t\t}\n\t\t\n\t}\n\t\n}\n",null,"namespace $ {\n\t\n\t/**\n\t * When fulfilled, all publishers are promoted to this subscriber on access to its.\n\t */\n\texport let $mol_wire_auto: $mol_wire_sub | null = null\n\t\n\t/**\n\t * Affection queue. Used to prevent accidental stack overflow on emit.\n\t */\n\texport const $mol_wire_affected = [] as ( $mol_wire_sub | number )[]\n\t\n}\n"]}
|
package/node.js
CHANGED
|
@@ -44,18 +44,10 @@ var $;
|
|
|
44
44
|
(function ($) {
|
|
45
45
|
let $mol_wire_cursor;
|
|
46
46
|
(function ($mol_wire_cursor) {
|
|
47
|
-
$mol_wire_cursor[$mol_wire_cursor["stale"] =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
$mol_wire_cursor[$mol_wire_cursor["
|
|
51
|
-
toString() { return '🟡'; }
|
|
52
|
-
})(-2)] = "doubt";
|
|
53
|
-
$mol_wire_cursor[$mol_wire_cursor["fresh"] = new (class fresh extends Number {
|
|
54
|
-
toString() { return '🟢'; }
|
|
55
|
-
})(-3)] = "fresh";
|
|
56
|
-
$mol_wire_cursor[$mol_wire_cursor["final"] = new (class solid extends Number {
|
|
57
|
-
toString() { return '🔵'; }
|
|
58
|
-
})(-4)] = "final";
|
|
47
|
+
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
|
48
|
+
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
49
|
+
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
50
|
+
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
59
51
|
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
60
52
|
})($ || ($ = {}));
|
|
61
53
|
//mol/wire/cursor/cursor.ts
|
|
@@ -102,26 +94,14 @@ var $;
|
|
|
102
94
|
}
|
|
103
95
|
up() { }
|
|
104
96
|
down() { }
|
|
105
|
-
emit() {
|
|
97
|
+
emit(quant = $mol_wire_cursor.stale) {
|
|
106
98
|
for (let i = this.sub_from; i < this.length; i += 2) {
|
|
107
99
|
;
|
|
108
|
-
this[i].
|
|
100
|
+
this[i].absorb(quant);
|
|
109
101
|
}
|
|
110
102
|
}
|
|
111
|
-
stale
|
|
112
|
-
|
|
113
|
-
return false;
|
|
114
|
-
while ($mol_wire_affected.length) {
|
|
115
|
-
const next = $mol_wire_affected.pop();
|
|
116
|
-
next.affect($mol_wire_cursor.doubt);
|
|
117
|
-
}
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
affect(quant) {
|
|
121
|
-
for (let i = this.sub_from; i < this.length; i += 2) {
|
|
122
|
-
const sub = this[i];
|
|
123
|
-
$mol_wire_affected.push(sub);
|
|
124
|
-
}
|
|
103
|
+
absorb(quant = $mol_wire_cursor.stale) {
|
|
104
|
+
this.emit($mol_wire_cursor.doubt);
|
|
125
105
|
return true;
|
|
126
106
|
}
|
|
127
107
|
peer_move(from_pos, to_pos) {
|
package/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../mam.jam.js","-","../../../../mam.ts","../../../fail/mol/fail/fail.ts","../../cursor/mol/wire/cursor/cursor.ts","../mol/wire/pub/pub.ts","../../sub/sub.ts","../../mol/wire/wire.ts"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACbA;AACA;AACA;AACA;;ACHA,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;AAK3B,IAAU,CAAC,CAMV;AAND,WAAU,CAAC;AAMX,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,CAAA;;;ADblB;AACA;AACA;;AEFA,IAAU,CAAC,CAMV;AAND,WAAU,CAAC;IAEV,SAAgB,SAAS,CAAE,KAAW;QACrC,MAAM,KAAK,CAAA;IACZ,CAAC;IAFe,WAAS,YAExB,CAAA;AAEF,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;;;;ACND,IAAU,CAAC,CAmBV;AAnBD,WAAU,CAAC;IAGV,IAAY,gBAcX;IAdD,WAAY,gBAAgB;QAG3B,
|
|
1
|
+
{"version":3,"sources":["../../../../mam.jam.js","-","../../../../mam.ts","../../../fail/mol/fail/fail.ts","../../cursor/mol/wire/cursor/cursor.ts","../mol/wire/pub/pub.ts","../../sub/sub.ts","../../mol/wire/wire.ts"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACbA;AACA;AACA;AACA;;ACHA,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;AAK3B,IAAU,CAAC,CAMV;AAND,WAAU,CAAC;AAMX,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,CAAA;;;ADblB;AACA;AACA;;AEFA,IAAU,CAAC,CAMV;AAND,WAAU,CAAC;IAEV,SAAgB,SAAS,CAAE,KAAW;QACrC,MAAM,KAAK,CAAA;IACZ,CAAC;IAFe,WAAS,YAExB,CAAA;AAEF,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;;;;ACND,IAAU,CAAC,CAmBV;AAnBD,WAAU,CAAC;IAGV,IAAY,gBAcX;IAdD,WAAY,gBAAgB;QAG3B,0DAAU,CAAA;QAGV,0DAAU,CAAA;QAGV,0DAAU,CAAA;QAGV,0DAAU,CAAA;IAEX,CAAC,EAdW,gBAAgB,GAAhB,kBAAgB,KAAhB,kBAAgB,QAc3B;AAEF,CAAC,EAnBS,CAAC,KAAD,CAAC,QAmBV;;;;ACnBD,IAAU,CAAC,CA+HV;AA/HD,WAAU,CAAC;IAKV,MAAa,aAAc,SAAQ,KAAgB;QAGlD,MAAM,KAAK,CAAE,MAAM,CAAC,OAAO,CAA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clare let _$_: { new(): {} } & typeof globalThis\ndeclare class $ extends _$_ {}\n\nnamespace $ {\n\texport type $ = typeof $$\n\texport declare class $$ extends $ {}\n\tnamespace $$ {\n\t\texport type $$ = $\n\t}\n}\n\nmodule.exports = $\n","namespace $ {\n\n\texport function $mol_fail( error : any ) : never {\n\t\tthrow error\n\t}\n\n}\n","namespace $ {\n\t\n\t/** Special status statuses. */\n\texport enum $mol_wire_cursor {\n\t\t\n\t\t/** Update required. */\n\t\tstale = -1,\n\t\t\n\t\t/** Some of (transitive) pub update required. */\n\t\tdoubt = -2,\n\t\t\n\t\t/** Actual state but may be dropped. */\n\t\tfresh = -3,\n\t\t\n\t\t/** State will never be changed. */\n\t\tfinal = -4,\n\t\t\n\t}\n\t\n}\n","namespace $ {\n\t\n\t/**\n\t * Collects subscribers in compact array. 28B\n\t */\n\texport class $mol_wire_pub extends Array< unknown > {\n\t\t\n\t\t// Derived objects should be Arrays.\n\t\tstatic get [ Symbol.species ]() {\n\t\t\treturn Array\n\t\t}\n\t\t\n\t\t/**\n\t\t * Index of first subscriber.\n\t\t */\n\t\tprotected sub_from = 0 // 4B\n\t\t\n\t\t/**\n\t\t * All current subscribers.\n\t\t */\n\t\tget sub_list() {\n\t\t\tconst res = [] as $mol_wire_sub[]\n\t\t\tfor( let i = this.sub_from; i < this.length; i += 2 ) {\n\t\t\t\tres.push( this[i] as $mol_wire_sub )\n\t\t\t}\n\t\t\treturn res as readonly $mol_wire_sub[]\n\t\t}\n\t\t\n\t\t/**\n\t\t * Has any subscribers or not.\n\t\t */\n\t\tget sub_empty() {\n\t\t\treturn this.sub_from === this.length\n\t\t}\n\t\t\n\t\t/**\n\t\t * Subscribe subscriber to this publisher events and return position of subscriber that required to unsubscribe.\n\t\t */\n\t\tsub_on( sub: $mol_wire_pub, pub_pos: number ) {\n\t\t\tconst pos = this.length\n\t\t\tthis.push( sub, pub_pos )\n\t\t\treturn pos\n\t\t}\n\t\t\n\t\t/**\n\t\t * Unsubscribe subscriber from this publisher events by subscriber position provided by `on(pub)`.\n\t\t */\n\t\tsub_off( sub_pos: number ) {\n\t\t\t\n\t\t\tif(!( sub_pos < this.length )) {\n\t\t\t\t$mol_fail( new Error( `Wrong pos ${ sub_pos }` ) )\n\t\t\t}\n\t\t\t\n\t\t\tconst end = this.length - 2\n\t\t\tif( sub_pos !== end ) {\n\t\t\t\tthis.peer_move( end, sub_pos )\n\t\t\t}\n\t\t\t\n\t\t\tthis.pop()\n\t\t\tthis.pop()\n\t\t\t\n\t\t\tif( this.length === this.sub_from ) this.reap()\n\t\t\t\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called when last sub was unsubscribed.\n\t\t **/\n\t\treap() { }\n\t\t\n\t\t/**\n\t\t * Autowire this publisher with current subscriber.\n\t\t **/\n\t\tpromote() {\n\t\t\t$mol_wire_auto?.track_next( this )\n\t\t}\n\t\t\n\t\t/**\n\t\t * Enforce actualization. Should not throw errors.\n\t\t */\n\t\tup() {}\n\t\t\n\t\t/**\n\t\t * Subscriber stabilized and allows to free.\n\t\t */\n\t\tdown() {}\n\t\t\n\t\t/**\n\t\t * Notify subscribers about self changes.\n\t\t */\n\t\temit( quant = $mol_wire_cursor.stale ) {\n\t\t\tfor( let i = this.sub_from; i < this.length; i += 2 ) {\n\t\t\t\t;( this[i] as $mol_wire_pub ).absorb( quant )\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Receive notification about publisher changes.\n\t\t */\n\t\tabsorb( quant = $mol_wire_cursor.stale ) {\n\t\t\tthis.emit( $mol_wire_cursor.doubt )\n\t\t\treturn true\n\t\t}\n\t\t\n\t\t/**\n\t\t * Moves peer from one position to another. Doesn't clear data at old position!\n\t\t */\n\t\tpeer_move( from_pos: number, to_pos: number ) {\n\t\t\t\n\t\t\tconst peer = this[ from_pos ] as $mol_wire_pub\n\t\t\tconst self_pos = this[ from_pos + 1 ] as number\n\t\t\t\n\t\t\tthis[ to_pos ] = peer\n\t\t\tthis[ to_pos + 1 ] = self_pos\n\t\t\t\n\t\t\tpeer.peer_repos( self_pos, to_pos )\n\t\t}\n\t\t\n\t\t/**\n\t\t * Updates self position in the peer.\n\t\t */\n\t\tpeer_repos( peer_pos: number, self_pos: number ) {\n\t\t\tthis[ peer_pos + 1 ] = self_pos\n\t\t}\n\t\t\n\t}\n\t\n}\n",null,"namespace $ {\n\t\n\t/**\n\t * When fulfilled, all publishers are promoted to this subscriber on access to its.\n\t */\n\texport let $mol_wire_auto: $mol_wire_sub | null = null\n\t\n\t/**\n\t * Affection queue. Used to prevent accidental stack overflow on emit.\n\t */\n\texport const $mol_wire_affected = [] as ( $mol_wire_sub | number )[]\n\t\n}\n"]}
|
package/node.test.js
CHANGED
|
@@ -36,18 +36,10 @@ var $;
|
|
|
36
36
|
(function ($) {
|
|
37
37
|
let $mol_wire_cursor;
|
|
38
38
|
(function ($mol_wire_cursor) {
|
|
39
|
-
$mol_wire_cursor[$mol_wire_cursor["stale"] =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
$mol_wire_cursor[$mol_wire_cursor["
|
|
43
|
-
toString() { return '🟡'; }
|
|
44
|
-
})(-2)] = "doubt";
|
|
45
|
-
$mol_wire_cursor[$mol_wire_cursor["fresh"] = new (class fresh extends Number {
|
|
46
|
-
toString() { return '🟢'; }
|
|
47
|
-
})(-3)] = "fresh";
|
|
48
|
-
$mol_wire_cursor[$mol_wire_cursor["final"] = new (class solid extends Number {
|
|
49
|
-
toString() { return '🔵'; }
|
|
50
|
-
})(-4)] = "final";
|
|
39
|
+
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
|
40
|
+
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
41
|
+
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
42
|
+
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
51
43
|
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
52
44
|
})($ || ($ = {}));
|
|
53
45
|
//mol/wire/cursor/cursor.ts
|
|
@@ -94,26 +86,14 @@ var $;
|
|
|
94
86
|
}
|
|
95
87
|
up() { }
|
|
96
88
|
down() { }
|
|
97
|
-
emit() {
|
|
89
|
+
emit(quant = $mol_wire_cursor.stale) {
|
|
98
90
|
for (let i = this.sub_from; i < this.length; i += 2) {
|
|
99
91
|
;
|
|
100
|
-
this[i].
|
|
92
|
+
this[i].absorb(quant);
|
|
101
93
|
}
|
|
102
94
|
}
|
|
103
|
-
stale
|
|
104
|
-
|
|
105
|
-
return false;
|
|
106
|
-
while ($mol_wire_affected.length) {
|
|
107
|
-
const next = $mol_wire_affected.pop();
|
|
108
|
-
next.affect($mol_wire_cursor.doubt);
|
|
109
|
-
}
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
affect(quant) {
|
|
113
|
-
for (let i = this.sub_from; i < this.length; i += 2) {
|
|
114
|
-
const sub = this[i];
|
|
115
|
-
$mol_wire_affected.push(sub);
|
|
116
|
-
}
|
|
95
|
+
absorb(quant = $mol_wire_cursor.stale) {
|
|
96
|
+
this.emit($mol_wire_cursor.doubt);
|
|
117
97
|
return true;
|
|
118
98
|
}
|
|
119
99
|
peer_move(from_pos, to_pos) {
|
|
@@ -1930,7 +1910,7 @@ var $;
|
|
|
1930
1910
|
return (func) => {
|
|
1931
1911
|
const persist = $mol_wire_fiber.persist(func, keys);
|
|
1932
1912
|
const wrapper = function (...args) {
|
|
1933
|
-
let atom = persist
|
|
1913
|
+
let atom = persist(this, args.slice(0, keys));
|
|
1934
1914
|
if (args.length <= keys || args[keys] === undefined)
|
|
1935
1915
|
return atom.sync();
|
|
1936
1916
|
try {
|
|
@@ -2251,13 +2231,13 @@ var $;
|
|
|
2251
2231
|
}
|
|
2252
2232
|
this.sub_from = this.cursor;
|
|
2253
2233
|
}
|
|
2254
|
-
|
|
2234
|
+
absorb(quant = $mol_wire_cursor.stale) {
|
|
2255
2235
|
if (this.cursor === $mol_wire_cursor.final)
|
|
2256
2236
|
return false;
|
|
2257
2237
|
if (this.cursor >= quant)
|
|
2258
2238
|
return false;
|
|
2259
2239
|
this.cursor = quant;
|
|
2260
|
-
return super.
|
|
2240
|
+
return super.absorb(quant);
|
|
2261
2241
|
}
|
|
2262
2242
|
[$mol_dev_format_head]() {
|
|
2263
2243
|
return $mol_dev_format_native(this);
|
|
@@ -2507,31 +2487,31 @@ var $;
|
|
|
2507
2487
|
static persist(task, keys) {
|
|
2508
2488
|
const field = task.name + '()';
|
|
2509
2489
|
if (keys) {
|
|
2510
|
-
return function $mol_wire_fiber_persist(
|
|
2490
|
+
return function $mol_wire_fiber_persist(host, args) {
|
|
2511
2491
|
let dict, key, fiber;
|
|
2512
|
-
key = `${
|
|
2513
|
-
dict = Object.getOwnPropertyDescriptor(
|
|
2492
|
+
key = `${host?.[Symbol.toStringTag] ?? host}.${task.name}(${args.map(v => $mol_key(v)).join(',')})`;
|
|
2493
|
+
dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
2514
2494
|
if (dict) {
|
|
2515
2495
|
const existen = dict.get(key);
|
|
2516
2496
|
if (existen)
|
|
2517
2497
|
return existen;
|
|
2518
2498
|
}
|
|
2519
2499
|
else {
|
|
2520
|
-
dict = (
|
|
2500
|
+
dict = (host ?? task)[field] = new Map();
|
|
2521
2501
|
}
|
|
2522
|
-
fiber = new $mol_wire_fiber(
|
|
2502
|
+
fiber = new $mol_wire_fiber(host, task, key, ...args);
|
|
2523
2503
|
dict.set(key, fiber);
|
|
2524
2504
|
return fiber;
|
|
2525
2505
|
};
|
|
2526
2506
|
}
|
|
2527
2507
|
else {
|
|
2528
|
-
return function $mol_wire_fiber_persist(
|
|
2529
|
-
const existen = Object.getOwnPropertyDescriptor(
|
|
2508
|
+
return function $mol_wire_fiber_persist(host, args) {
|
|
2509
|
+
const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
2530
2510
|
if (existen)
|
|
2531
2511
|
return existen;
|
|
2532
|
-
const key = `${
|
|
2533
|
-
const fiber = new $mol_wire_fiber(
|
|
2534
|
-
(
|
|
2512
|
+
const key = `${host?.[Symbol.toStringTag] ?? host}.${field}`;
|
|
2513
|
+
const fiber = new $mol_wire_fiber(host, task, key, ...args);
|
|
2514
|
+
(host ?? task)[field] = fiber;
|
|
2535
2515
|
return fiber;
|
|
2536
2516
|
};
|
|
2537
2517
|
}
|
|
@@ -2627,13 +2607,19 @@ var $;
|
|
|
2627
2607
|
return this[Symbol.toStringTag];
|
|
2628
2608
|
}
|
|
2629
2609
|
[$mol_dev_format_head]() {
|
|
2630
|
-
|
|
2610
|
+
const cursor = {
|
|
2611
|
+
[-1]: '🔴',
|
|
2612
|
+
[-2]: '🟡',
|
|
2613
|
+
[-3]: '🟢',
|
|
2614
|
+
[-4]: '🔵',
|
|
2615
|
+
}[this.cursor] ?? this.cursor.toString();
|
|
2616
|
+
return $mol_dev_format_div({}, $mol_dev_format_native(this), $mol_dev_format_shade(cursor + ' '), $mol_dev_format_auto(this.cache));
|
|
2631
2617
|
}
|
|
2632
2618
|
get $() {
|
|
2633
2619
|
return (this.host ?? this.task)['$'];
|
|
2634
2620
|
}
|
|
2635
|
-
|
|
2636
|
-
if (!super.
|
|
2621
|
+
absorb(quant = $mol_wire_cursor.stale) {
|
|
2622
|
+
if (!super.absorb(quant))
|
|
2637
2623
|
return false;
|
|
2638
2624
|
if (this.sub_from === this.length) {
|
|
2639
2625
|
this.plan();
|
|
@@ -2681,7 +2667,7 @@ var $;
|
|
|
2681
2667
|
if (result instanceof Promise && !handled.has(result)) {
|
|
2682
2668
|
result = Object.assign(result.finally(() => {
|
|
2683
2669
|
if (this.cache === result)
|
|
2684
|
-
this.
|
|
2670
|
+
this.absorb();
|
|
2685
2671
|
}), {
|
|
2686
2672
|
destructor: result['destructor']
|
|
2687
2673
|
});
|