mol_wire_pub 1.0.83 → 1.0.86

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mol_wire_pub",
3
- "version": "1.0.83",
3
+ "version": "1.0.86",
4
4
  "main": "node.js",
5
5
  "module": "node.esm.js",
6
6
  "browser": "web.js",
package/web.d.ts CHANGED
@@ -36,8 +36,8 @@ declare namespace $ {
36
36
  sub_off(sub_pos: number): void;
37
37
  reap(): void;
38
38
  promote(): void;
39
- up(): void;
40
- down(): void;
39
+ refresh(): void;
40
+ commit(): void;
41
41
  emit(quant?: $mol_wire_cursor): void;
42
42
  peer_move(from_pos: number, to_pos: number): void;
43
43
  peer_repos(peer_pos: number, self_pos: number): void;
package/web.esm.js CHANGED
@@ -92,8 +92,8 @@ var $;
92
92
  promote() {
93
93
  $mol_wire_auto()?.track_next(this);
94
94
  }
95
- up() { }
96
- down() { }
95
+ refresh() { }
96
+ commit() { }
97
97
  emit(quant = $mol_wire_cursor.stale) {
98
98
  for (let i = this.sub_from; i < this.length; i += 2) {
99
99
  ;
package/web.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,C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AAgB,EAAE,QAAgB;YAC7C,IAAI,CAAE,QAAQ,GAAG,CAAC,CAAE,GAAG,QAAQ,CAAA;QAChC,CAAC;KAED;IAhHY,eAAa,gBAgHzB,CAAA;AAEF,CAAC,EAvHS,CAAC,KAAD,CAAC,QAuHV;;;ACvHD;AACA;AACA;;ACFA,IAAU,CAAC,CAgBV;AAhBD,WAAU,CAAC;IAEV,IAAI,IAAI,GAAyB,IAAI,CAAA;IAKrC,SAAgB,cAAc,CAAE,IAAI,GAAG,IAAI;QAC1C,OAAO,IAAI,GAAG,IAAI,CAAA;IACnB,CAAC;IAFe,gBAAc,iBAE7B,CAAA;IAKY,oBAAkB,GAAG,EAAkC,CAAA;AAErE,CAAC,EAhBS,CAAC,KAAD,CAAC,QAgBV;;;ANhBD","file":"web.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_sub ).absorb( quant )\n\t\t\t}\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\tlet auto: $mol_wire_sub | null = null\n\t\n\t/**\n\t * When fulfilled, all publishers are promoted to this subscriber on access to its.\n\t */\n\texport function $mol_wire_auto( next = auto ) {\n\t\treturn auto = next\n\t}\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"]}
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;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AA;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;IAhHY,eAAa,gBAgHzB,CAAA;AAEF,CAAC,EAvHS,CAAC,KAAD,CAAC,QAuHV;;;ACvHD;AACA;AACA;;ACFA,IAAU,CAAC,CAgBV;AAhBD,WAAU,CAAC;IAEV,IAAI,IAAI,GAAyB,IAAI,CAAA;IAKrC,SAAgB,cAAc,CAAE,IAAI,GAAG,IAAI;QAC1C,OAAO,IAAI,GAAG,IAAI,CAAA;IACnB,CAAC;IAFe,gBAAc,iBAE7B,CAAA;IAKY,oBAAkB,GAAG,EAAkC,CAAA;AAErE,CAAC,EAhBS,CAAC,KAAD,CAAC,QAgBV;;;ANhBD","file":"web.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\trefresh() {}\n\t\t\n\t\t/**\n\t\t * Allow to put data to caches in the subtree.\n\t\t */\n\t\tcommit() {}\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_sub ).absorb( quant )\n\t\t\t}\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\tlet auto: $mol_wire_sub | null = null\n\t\n\t/**\n\t * When fulfilled, all publishers are promoted to this subscriber on access to its.\n\t */\n\texport function $mol_wire_auto( next = auto ) {\n\t\treturn auto = next\n\t}\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/web.js CHANGED
@@ -92,8 +92,8 @@ var $;
92
92
  promote() {
93
93
  $mol_wire_auto()?.track_next(this);
94
94
  }
95
- up() { }
96
- down() { }
95
+ refresh() { }
96
+ commit() { }
97
97
  emit(quant = $mol_wire_cursor.stale) {
98
98
  for (let i = this.sub_from; i < this.length; i += 2) {
99
99
  ;
package/web.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,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,CAuHV;AAvHD,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;YACX,MAAM,GAAG,GAAG,EAAqB,CAAA;YACjC,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAG;gBACrD,GAAG,C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AAC,CAAoB,CAAC,MAAM,CAAE,KAAK,CAAE,CAAA;aAC7C;QACF,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;IAhHY,eAAa,gBAgHzB,CAAA;AAEF,CAAC,EAvHS,CAAC,KAAD,CAAC,QAuHV;;;ACvHD;AACA;AACA;;ACFA,IAAU,CAAC,CAgBV;AAhBD,WAAU,CAAC;IAEV,IAAI,IAAI,GAAyB,IAAI,CAAA;IAKrC,SAAgB,cAAc,CAAE,IAAI,GAAG,IAAI;QAC1C,OAAO,IAAI,GAAG,IAAI,CAAA;IACnB,CAAC;IAFe,gBAAc,iBAE7B,CAAA;IAKY,oBAAkB,GAAG,EAAkC,CAAA;AAErE,CAAC,EAhBS,CAAC,KAAD,CAAC,QAgBV;;","file":"web.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_sub ).absorb( quant )\n\t\t\t}\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\tlet auto: $mol_wire_sub | null = null\n\t\n\t/**\n\t * When fulfilled, all publishers are promoted to this subscriber on access to its.\n\t */\n\texport function $mol_wire_auto( next = auto ) {\n\t\treturn auto = next\n\t}\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"]}
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,CAuHV;AAvHD,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;YACX,MAAM,GAAG,GAAG,EAAqB,CAAA;YACjC,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,QA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AAG,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,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;IAhHY,eAAa,gBAgHzB,CAAA;AAEF,CAAC,EAvHS,CAAC,KAAD,CAAC,QAuHV;;;ACvHD;AACA;AACA;;ACFA,IAAU,CAAC,CAgBV;AAhBD,WAAU,CAAC;IAEV,IAAI,IAAI,GAAyB,IAAI,CAAA;IAKrC,SAAgB,cAAc,CAAE,IAAI,GAAG,IAAI;QAC1C,OAAO,IAAI,GAAG,IAAI,CAAA;IACnB,CAAC;IAFe,gBAAc,iBAE7B,CAAA;IAKY,oBAAkB,GAAG,EAAkC,CAAA;AAErE,CAAC,EAhBS,CAAC,KAAD,CAAC,QAgBV;;","file":"web.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\trefresh() {}\n\t\t\n\t\t/**\n\t\t * Allow to put data to caches in the subtree.\n\t\t */\n\t\tcommit() {}\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_sub ).absorb( quant )\n\t\t\t}\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\tlet auto: $mol_wire_sub | null = null\n\t\n\t/**\n\t * When fulfilled, all publishers are promoted to this subscriber on access to its.\n\t */\n\texport function $mol_wire_auto( next = auto ) {\n\t\treturn auto = next\n\t}\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/web.test.js CHANGED
@@ -916,26 +916,6 @@ var $;
916
916
  ;
917
917
  "use strict";
918
918
  var $;
919
- (function ($) {
920
- function $mol_wire_sync(obj) {
921
- return new Proxy(obj, {
922
- get(obj, field) {
923
- const val = obj[field];
924
- if (typeof val !== 'function')
925
- return val;
926
- return function $mol_wire_sync(...args) {
927
- const fiber = $mol_wire_fiber.temp(obj, val, ...args);
928
- return fiber.sync();
929
- };
930
- }
931
- });
932
- }
933
- $.$mol_wire_sync = $mol_wire_sync;
934
- })($ || ($ = {}));
935
- //mol/wire/sync/sync.ts
936
- ;
937
- "use strict";
938
- var $;
939
919
  (function ($) {
940
920
  function $mol_promise() {
941
921
  let done;
@@ -1023,6 +1003,26 @@ var $;
1023
1003
  ;
1024
1004
  "use strict";
1025
1005
  var $;
1006
+ (function ($) {
1007
+ function $mol_wire_sync(obj) {
1008
+ return new Proxy(obj, {
1009
+ get(obj, field) {
1010
+ const val = obj[field];
1011
+ if (typeof val !== 'function')
1012
+ return val;
1013
+ return function $mol_wire_sync(...args) {
1014
+ const fiber = $mol_wire_fiber.temp(obj, val, ...args);
1015
+ return fiber.sync();
1016
+ };
1017
+ }
1018
+ });
1019
+ }
1020
+ $.$mol_wire_sync = $mol_wire_sync;
1021
+ })($ || ($ = {}));
1022
+ //mol/wire/sync/sync.ts
1023
+ ;
1024
+ "use strict";
1025
+ var $;
1026
1026
  (function ($) {
1027
1027
  function $mol_wait_timeout_async(timeout) {
1028
1028
  const promise = $mol_promise();
@@ -1129,19 +1129,13 @@ var $;
1129
1129
  static value(next = 1) {
1130
1130
  return next + 1;
1131
1131
  }
1132
- static test() {
1133
- $mol_assert_equal(App.value(), 2);
1134
- App.value(2);
1135
- $mol_assert_equal(App.value(), 3);
1136
- }
1137
1132
  }
1138
1133
  __decorate([
1139
1134
  $mol_wire_mem(0)
1140
1135
  ], App, "value", null);
1141
- __decorate([
1142
- $mol_wire_method
1143
- ], App, "test", null);
1144
- App.test();
1136
+ $mol_assert_equal(App.value(), 2);
1137
+ App.value(2);
1138
+ $mol_assert_equal(App.value(), 3);
1145
1139
  },
1146
1140
  'Mem overrides mem'($) {
1147
1141
  class Base extends $mol_object2 {
@@ -1165,19 +1159,13 @@ var $;
1165
1159
  static value(next) {
1166
1160
  return super.value(next) * 3;
1167
1161
  }
1168
- static test() {
1169
- $mol_assert_equal(this.value(), 9);
1170
- $mol_assert_equal(this.value(5), 21);
1171
- $mol_assert_equal(this.value(), 21);
1172
- }
1173
1162
  }
1174
1163
  __decorate([
1175
1164
  $mol_wire_mem(0)
1176
1165
  ], App, "value", null);
1177
- __decorate([
1178
- $mol_wire_method
1179
- ], App, "test", null);
1180
- App.test();
1166
+ $mol_assert_equal(App.value(), 9);
1167
+ $mol_assert_equal(App.value(5), 21);
1168
+ $mol_assert_equal(App.value(), 21);
1181
1169
  },
1182
1170
  'Auto recalculation of cached values'($) {
1183
1171
  class App extends $mol_object2 {
@@ -1191,12 +1179,6 @@ var $;
1191
1179
  static zzz() {
1192
1180
  return this.yyy() + 1;
1193
1181
  }
1194
- static test() {
1195
- $mol_assert_equal(App.yyy(), 2);
1196
- $mol_assert_equal(App.zzz(), 3);
1197
- App.xxx(5);
1198
- $mol_assert_equal(App.zzz(), 7);
1199
- }
1200
1182
  }
1201
1183
  __decorate([
1202
1184
  $mol_wire_mem(0)
@@ -1207,10 +1189,10 @@ var $;
1207
1189
  __decorate([
1208
1190
  $mol_wire_mem(0)
1209
1191
  ], App, "zzz", null);
1210
- __decorate([
1211
- $mol_wire_method
1212
- ], App, "test", null);
1213
- App.test();
1192
+ $mol_assert_equal(App.yyy(), 2);
1193
+ $mol_assert_equal(App.zzz(), 3);
1194
+ App.xxx(5);
1195
+ $mol_assert_equal(App.zzz(), 7);
1214
1196
  },
1215
1197
  'Skip recalculation when actually no dependency changes'($) {
1216
1198
  const log = [];
@@ -1228,13 +1210,6 @@ var $;
1228
1210
  log.push('zzz');
1229
1211
  return this.yyy()[0] + 1;
1230
1212
  }
1231
- static test() {
1232
- App.zzz();
1233
- $mol_assert_like(log, ['zzz', 'yyy', 'xxx']);
1234
- App.xxx(5);
1235
- App.zzz();
1236
- $mol_assert_like(log, ['zzz', 'yyy', 'xxx', 'xxx', 'yyy']);
1237
- }
1238
1213
  }
1239
1214
  __decorate([
1240
1215
  $mol_wire_mem(0)
@@ -1245,10 +1220,12 @@ var $;
1245
1220
  __decorate([
1246
1221
  $mol_wire_mem(0)
1247
1222
  ], App, "zzz", null);
1248
- __decorate([
1249
- $mol_wire_method
1250
- ], App, "test", null);
1251
- App.test();
1223
+ App.zzz();
1224
+ $mol_assert_like(log, ['zzz', 'yyy', 'xxx']);
1225
+ App.xxx(5);
1226
+ $mol_assert_like(log, ['zzz', 'yyy', 'xxx', 'xxx']);
1227
+ App.zzz();
1228
+ $mol_assert_like(log, ['zzz', 'yyy', 'xxx', 'xxx', 'yyy']);
1252
1229
  },
1253
1230
  'Flow: Auto'($) {
1254
1231
  class App extends $mol_object2 {
@@ -1293,13 +1270,6 @@ var $;
1293
1270
  static bar() {
1294
1271
  return { ...this.foo(), count: ++counter };
1295
1272
  }
1296
- static test() {
1297
- $mol_assert_like(App.bar(), { numbs: [1], count: 1 });
1298
- App.foo({ numbs: [1] });
1299
- $mol_assert_like(App.bar(), { numbs: [1], count: 1 });
1300
- App.foo({ numbs: [2] });
1301
- $mol_assert_like(App.bar(), { numbs: [2], count: 2 });
1302
- }
1303
1273
  }
1304
1274
  __decorate([
1305
1275
  $mol_wire_mem(0)
@@ -1307,10 +1277,11 @@ var $;
1307
1277
  __decorate([
1308
1278
  $mol_wire_mem(0)
1309
1279
  ], App, "bar", null);
1310
- __decorate([
1311
- $mol_wire_method
1312
- ], App, "test", null);
1313
- App.test();
1280
+ $mol_assert_like(App.bar(), { numbs: [1], count: 1 });
1281
+ App.foo({ numbs: [1] });
1282
+ $mol_assert_like(App.bar(), { numbs: [1], count: 1 });
1283
+ App.foo({ numbs: [2] });
1284
+ $mol_assert_like(App.bar(), { numbs: [2], count: 2 });
1314
1285
  },
1315
1286
  'Cycle: Fail'($) {
1316
1287
  class App extends $mol_object2 {
@@ -1348,13 +1319,6 @@ var $;
1348
1319
  static slow(next) {
1349
1320
  return this.store(next);
1350
1321
  }
1351
- static test() {
1352
- App.fast();
1353
- $mol_assert_equal(App.slow(666), 666);
1354
- $mol_assert_equal(App.fast(), App.slow(), 666);
1355
- App.store(777);
1356
- $mol_assert_equal(App.fast(), App.slow(), 777);
1357
- }
1358
1322
  }
1359
1323
  __decorate([
1360
1324
  $mol_wire_mem(0)
@@ -1365,10 +1329,11 @@ var $;
1365
1329
  __decorate([
1366
1330
  $mol_wire_mem(0)
1367
1331
  ], App, "slow", null);
1368
- __decorate([
1369
- $mol_wire_method
1370
- ], App, "test", null);
1371
- App.test();
1332
+ App.fast();
1333
+ $mol_assert_equal(App.slow(666), 666);
1334
+ $mol_assert_equal(App.fast(), App.slow(), 666);
1335
+ App.store(777);
1336
+ $mol_assert_equal(App.fast(), App.slow(), 777);
1372
1337
  },
1373
1338
  'Actions inside invariant'($) {
1374
1339
  class App extends $mol_object2 {
@@ -1385,11 +1350,6 @@ var $;
1385
1350
  this.count(count + 1);
1386
1351
  return count + 1;
1387
1352
  }
1388
- static test() {
1389
- $mol_assert_like(App.res(), 1);
1390
- App.count(5);
1391
- $mol_assert_like(App.res(), 6);
1392
- }
1393
1353
  }
1394
1354
  __decorate([
1395
1355
  $mol_wire_mem(0)
@@ -1400,10 +1360,39 @@ var $;
1400
1360
  __decorate([
1401
1361
  $mol_wire_mem(0)
1402
1362
  ], App, "res", null);
1363
+ $mol_assert_like(App.res(), 1);
1364
+ App.count(5);
1365
+ $mol_assert_like(App.res(), 6);
1366
+ },
1367
+ async 'Toggle with async'($) {
1368
+ class App extends $mol_object2 {
1369
+ static $ = $;
1370
+ static checked(next = false) {
1371
+ $$.$mol_wait_timeout(0);
1372
+ return next;
1373
+ }
1374
+ static toggle() {
1375
+ const prev = this.checked();
1376
+ $mol_assert_unique(this.checked(!prev), prev);
1377
+ $mol_assert_equal(this.checked(), prev);
1378
+ }
1379
+ static res() {
1380
+ return this.checked();
1381
+ }
1382
+ }
1383
+ __decorate([
1384
+ $mol_wire_mem(0)
1385
+ ], App, "checked", null);
1403
1386
  __decorate([
1404
1387
  $mol_wire_method
1405
- ], App, "test", null);
1406
- App.test();
1388
+ ], App, "toggle", null);
1389
+ __decorate([
1390
+ $mol_wire_mem(0)
1391
+ ], App, "res", null);
1392
+ const app = $mol_wire_async(App);
1393
+ $mol_assert_equal(await app.res(), false);
1394
+ await app.toggle();
1395
+ $mol_assert_equal(await app.res(), true);
1407
1396
  },
1408
1397
  'Restore after error'($) {
1409
1398
  class App extends $mol_object2 {
@@ -1574,9 +1563,6 @@ var $;
1574
1563
  ];
1575
1564
  }
1576
1565
  static test() {
1577
- $mol_assert_like(this.user_names(), ['jin', 'john']);
1578
- Team.user_name('jin', 'JIN');
1579
- $mol_assert_like(this.user_names(), ['JIN', 'john']);
1580
1566
  }
1581
1567
  }
1582
1568
  __decorate([
@@ -1588,7 +1574,9 @@ var $;
1588
1574
  __decorate([
1589
1575
  $mol_wire_method
1590
1576
  ], Team, "test", null);
1591
- Team.test();
1577
+ $mol_assert_like(Team.user_names(), ['jin', 'john']);
1578
+ Team.user_name('jin', 'JIN');
1579
+ $mol_assert_like(Team.user_names(), ['JIN', 'john']);
1592
1580
  },
1593
1581
  'Memoize by single complex key'($) {
1594
1582
  class Map extends $mol_object2 {
@@ -1665,21 +1653,15 @@ var $;
1665
1653
  ++this.sums;
1666
1654
  return this.value(index - 1) + this.value(index - 2);
1667
1655
  }
1668
- static test() {
1669
- $mol_assert_equal(this.value(4), 5);
1670
- $mol_assert_equal(this.sums, 3);
1671
- this.value(1, 2);
1672
- $mol_assert_equal(this.value(4), 8);
1673
- $mol_assert_equal(this.sums, 6);
1674
- }
1675
1656
  }
1676
1657
  __decorate([
1677
1658
  $mol_wire_mem(1)
1678
1659
  ], Fib, "value", null);
1679
- __decorate([
1680
- $mol_wire_method
1681
- ], Fib, "test", null);
1682
- Fib.test();
1660
+ $mol_assert_equal(Fib.value(4), 5);
1661
+ $mol_assert_equal(Fib.sums, 3);
1662
+ Fib.value(1, 2);
1663
+ $mol_assert_equal(Fib.value(4), 8);
1664
+ $mol_assert_equal(Fib.sums, 6);
1683
1665
  },
1684
1666
  'Unsubscribe from temp pubs on complete'($) {
1685
1667
  class Random extends $mol_object2 {
@@ -1694,12 +1676,6 @@ var $;
1694
1676
  this.resets();
1695
1677
  return this.seed();
1696
1678
  }
1697
- static test() {
1698
- const first = this.value();
1699
- this.resets(null);
1700
- const second = this.value();
1701
- $mol_assert_unique(first, second);
1702
- }
1703
1679
  }
1704
1680
  __decorate([
1705
1681
  $mol_wire_method
@@ -1710,10 +1686,9 @@ var $;
1710
1686
  __decorate([
1711
1687
  $mol_wire_mem(0)
1712
1688
  ], Random, "value", null);
1713
- __decorate([
1714
- $mol_wire_method
1715
- ], Random, "test", null);
1716
- Random.test();
1689
+ const first = Random.value();
1690
+ Random.resets(null);
1691
+ $mol_assert_unique(Random.value(), first);
1717
1692
  },
1718
1693
  });
1719
1694
  })($ || ($ = {}));
@@ -2023,7 +1998,7 @@ var $;
2023
1998
  }
2024
1999
  for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
2025
2000
  const pub = this[cursor];
2026
- pub.up();
2001
+ pub.refresh();
2027
2002
  }
2028
2003
  this.cursor = $mol_wire_cursor.fresh;
2029
2004
  }
@@ -2066,6 +2041,16 @@ var $;
2066
2041
  }
2067
2042
  this.sub_from = this.cursor;
2068
2043
  }
2044
+ commit() {
2045
+ this.commit_pubs();
2046
+ }
2047
+ commit_pubs() {
2048
+ const limit = this.cursor < 0 ? this.sub_from : this.cursor;
2049
+ for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
2050
+ const pub = this[cursor];
2051
+ pub?.commit();
2052
+ }
2053
+ }
2069
2054
  absorb(quant = $mol_wire_cursor.stale) {
2070
2055
  if (this.cursor === $mol_wire_cursor.final)
2071
2056
  return;
@@ -2396,7 +2381,7 @@ var $;
2396
2381
  while (this.planning.length) {
2397
2382
  const fibers = this.planning.splice(0, this.planning.length);
2398
2383
  for (const fiber of fibers) {
2399
- fiber.up();
2384
+ fiber.refresh();
2400
2385
  }
2401
2386
  }
2402
2387
  while (this.reaping.length) {
@@ -2412,14 +2397,14 @@ var $;
2412
2397
  get args() {
2413
2398
  return this.slice(0, this.pub_from);
2414
2399
  }
2415
- get result() {
2400
+ result() {
2416
2401
  if (this.cache instanceof Promise)
2417
2402
  return;
2418
2403
  if (this.cache instanceof Error)
2419
2404
  return;
2420
2405
  return this.cache;
2421
2406
  }
2422
- get persist() {
2407
+ persistent() {
2423
2408
  const id = this[Symbol.toStringTag];
2424
2409
  return id[id.length - 2] !== '#';
2425
2410
  }
@@ -2441,7 +2426,7 @@ var $;
2441
2426
  if ($mol_owning_check(this, prev)) {
2442
2427
  prev.destructor();
2443
2428
  }
2444
- if (this.persist) {
2429
+ if (this.persistent()) {
2445
2430
  if (this.pub_from === 0) {
2446
2431
  ;
2447
2432
  (this.host ?? this.task)[this.field()] = null;
@@ -2484,12 +2469,16 @@ var $;
2484
2469
  else
2485
2470
  super.emit(quant);
2486
2471
  }
2487
- down() {
2488
- if (this.persist)
2472
+ commit() {
2473
+ if (this.persistent())
2489
2474
  return;
2475
+ super.commit();
2476
+ if (this.host instanceof $mol_wire_fiber) {
2477
+ this.host.put(this.cache);
2478
+ }
2490
2479
  this.destructor();
2491
2480
  }
2492
- up() {
2481
+ refresh() {
2493
2482
  if (this.cursor === $mol_wire_cursor.fresh)
2494
2483
  return;
2495
2484
  if (this.cursor === $mol_wire_cursor.final)
@@ -2497,7 +2486,7 @@ var $;
2497
2486
  check: if (this.cursor === $mol_wire_cursor.doubt) {
2498
2487
  for (let i = this.pub_from; i < this.sub_from; i += 2) {
2499
2488
  ;
2500
- this[i]?.up();
2489
+ this[i]?.refresh();
2501
2490
  if (this.cursor !== $mol_wire_cursor.doubt)
2502
2491
  break check;
2503
2492
  }
@@ -2545,7 +2534,7 @@ var $;
2545
2534
  prev.destructor();
2546
2535
  }
2547
2536
  this.cache = next;
2548
- if (this.persist && $mol_owning_catch(this, next)) {
2537
+ if (this.persistent() && $mol_owning_catch(this, next)) {
2549
2538
  try {
2550
2539
  next[Symbol.toStringTag] = this[Symbol.toStringTag];
2551
2540
  }
@@ -2560,28 +2549,25 @@ var $;
2560
2549
  this.cursor = $mol_wire_cursor.fresh;
2561
2550
  if (next instanceof Promise)
2562
2551
  return next;
2563
- if (this.persist) {
2564
- for (let cursor = this.pub_from; cursor < this.sub_from; cursor += 2) {
2565
- const pub = this[cursor];
2566
- pub?.down();
2567
- }
2552
+ if (this.persistent()) {
2553
+ this.commit_pubs();
2568
2554
  }
2569
2555
  else {
2570
- this.cursor = this.pub_from;
2571
- this.track_cut();
2572
- this.cursor = $mol_wire_cursor.fresh;
2556
+ if (this.sub_empty) {
2557
+ this.commit();
2558
+ }
2573
2559
  }
2574
2560
  return next;
2575
2561
  }
2576
2562
  recall(...args) {
2577
- return this.put(this.task.call(this.host, ...args));
2563
+ return this.task.call(this.host, ...args);
2578
2564
  }
2579
2565
  sync() {
2580
2566
  if (!$mol_wire_fiber.warm) {
2581
- return this.result;
2567
+ return this.result();
2582
2568
  }
2583
2569
  this.promote();
2584
- this.up();
2570
+ this.refresh();
2585
2571
  if (this.cache instanceof Error) {
2586
2572
  return $mol_fail_hidden(this.cache);
2587
2573
  }
@@ -2592,7 +2578,7 @@ var $;
2592
2578
  }
2593
2579
  async async() {
2594
2580
  while (true) {
2595
- this.up();
2581
+ this.refresh();
2596
2582
  if (this.cache instanceof Error) {
2597
2583
  $mol_fail_hidden(this.cache);
2598
2584
  }