mol_wire_pub 1.0.82 → 1.0.85

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 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/node.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/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,CA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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":"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_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,CAA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,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":"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\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/node.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/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;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,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":"node.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/p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AKD,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":"node.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/node.test.js CHANGED
@@ -84,8 +84,8 @@ var $;
84
84
  promote() {
85
85
  $mol_wire_auto()?.track_next(this);
86
86
  }
87
- up() { }
88
- down() { }
87
+ refresh() { }
88
+ commit() { }
89
89
  emit(quant = $mol_wire_cursor.stale) {
90
90
  for (let i = this.sub_from; i < this.length; i += 2) {
91
91
  ;
@@ -1081,26 +1081,6 @@ var $;
1081
1081
  ;
1082
1082
  "use strict";
1083
1083
  var $;
1084
- (function ($) {
1085
- function $mol_wire_sync(obj) {
1086
- return new Proxy(obj, {
1087
- get(obj, field) {
1088
- const val = obj[field];
1089
- if (typeof val !== 'function')
1090
- return val;
1091
- return function $mol_wire_sync(...args) {
1092
- const fiber = $mol_wire_fiber.temp(obj, val, ...args);
1093
- return fiber.sync();
1094
- };
1095
- }
1096
- });
1097
- }
1098
- $.$mol_wire_sync = $mol_wire_sync;
1099
- })($ || ($ = {}));
1100
- //mol/wire/sync/sync.ts
1101
- ;
1102
- "use strict";
1103
- var $;
1104
1084
  (function ($) {
1105
1085
  function $mol_promise() {
1106
1086
  let done;
@@ -1188,6 +1168,26 @@ var $;
1188
1168
  ;
1189
1169
  "use strict";
1190
1170
  var $;
1171
+ (function ($) {
1172
+ function $mol_wire_sync(obj) {
1173
+ return new Proxy(obj, {
1174
+ get(obj, field) {
1175
+ const val = obj[field];
1176
+ if (typeof val !== 'function')
1177
+ return val;
1178
+ return function $mol_wire_sync(...args) {
1179
+ const fiber = $mol_wire_fiber.temp(obj, val, ...args);
1180
+ return fiber.sync();
1181
+ };
1182
+ }
1183
+ });
1184
+ }
1185
+ $.$mol_wire_sync = $mol_wire_sync;
1186
+ })($ || ($ = {}));
1187
+ //mol/wire/sync/sync.ts
1188
+ ;
1189
+ "use strict";
1190
+ var $;
1191
1191
  (function ($) {
1192
1192
  function $mol_wait_timeout_async(timeout) {
1193
1193
  const promise = $mol_promise();
@@ -1294,19 +1294,13 @@ var $;
1294
1294
  static value(next = 1) {
1295
1295
  return next + 1;
1296
1296
  }
1297
- static test() {
1298
- $mol_assert_equal(App.value(), 2);
1299
- App.value(2);
1300
- $mol_assert_equal(App.value(), 3);
1301
- }
1302
1297
  }
1303
1298
  __decorate([
1304
1299
  $mol_wire_mem(0)
1305
1300
  ], App, "value", null);
1306
- __decorate([
1307
- $mol_wire_method
1308
- ], App, "test", null);
1309
- App.test();
1301
+ $mol_assert_equal(App.value(), 2);
1302
+ App.value(2);
1303
+ $mol_assert_equal(App.value(), 3);
1310
1304
  },
1311
1305
  'Mem overrides mem'($) {
1312
1306
  class Base extends $mol_object2 {
@@ -1330,19 +1324,13 @@ var $;
1330
1324
  static value(next) {
1331
1325
  return super.value(next) * 3;
1332
1326
  }
1333
- static test() {
1334
- $mol_assert_equal(this.value(), 9);
1335
- $mol_assert_equal(this.value(5), 21);
1336
- $mol_assert_equal(this.value(), 21);
1337
- }
1338
1327
  }
1339
1328
  __decorate([
1340
1329
  $mol_wire_mem(0)
1341
1330
  ], App, "value", null);
1342
- __decorate([
1343
- $mol_wire_method
1344
- ], App, "test", null);
1345
- App.test();
1331
+ $mol_assert_equal(App.value(), 9);
1332
+ $mol_assert_equal(App.value(5), 21);
1333
+ $mol_assert_equal(App.value(), 21);
1346
1334
  },
1347
1335
  'Auto recalculation of cached values'($) {
1348
1336
  class App extends $mol_object2 {
@@ -1356,12 +1344,6 @@ var $;
1356
1344
  static zzz() {
1357
1345
  return this.yyy() + 1;
1358
1346
  }
1359
- static test() {
1360
- $mol_assert_equal(App.yyy(), 2);
1361
- $mol_assert_equal(App.zzz(), 3);
1362
- App.xxx(5);
1363
- $mol_assert_equal(App.zzz(), 7);
1364
- }
1365
1347
  }
1366
1348
  __decorate([
1367
1349
  $mol_wire_mem(0)
@@ -1372,10 +1354,10 @@ var $;
1372
1354
  __decorate([
1373
1355
  $mol_wire_mem(0)
1374
1356
  ], App, "zzz", null);
1375
- __decorate([
1376
- $mol_wire_method
1377
- ], App, "test", null);
1378
- App.test();
1357
+ $mol_assert_equal(App.yyy(), 2);
1358
+ $mol_assert_equal(App.zzz(), 3);
1359
+ App.xxx(5);
1360
+ $mol_assert_equal(App.zzz(), 7);
1379
1361
  },
1380
1362
  'Skip recalculation when actually no dependency changes'($) {
1381
1363
  const log = [];
@@ -1393,13 +1375,6 @@ var $;
1393
1375
  log.push('zzz');
1394
1376
  return this.yyy()[0] + 1;
1395
1377
  }
1396
- static test() {
1397
- App.zzz();
1398
- $mol_assert_like(log, ['zzz', 'yyy', 'xxx']);
1399
- App.xxx(5);
1400
- App.zzz();
1401
- $mol_assert_like(log, ['zzz', 'yyy', 'xxx', 'xxx', 'yyy']);
1402
- }
1403
1378
  }
1404
1379
  __decorate([
1405
1380
  $mol_wire_mem(0)
@@ -1410,10 +1385,12 @@ var $;
1410
1385
  __decorate([
1411
1386
  $mol_wire_mem(0)
1412
1387
  ], App, "zzz", null);
1413
- __decorate([
1414
- $mol_wire_method
1415
- ], App, "test", null);
1416
- App.test();
1388
+ App.zzz();
1389
+ $mol_assert_like(log, ['zzz', 'yyy', 'xxx']);
1390
+ App.xxx(5);
1391
+ $mol_assert_like(log, ['zzz', 'yyy', 'xxx', 'xxx']);
1392
+ App.zzz();
1393
+ $mol_assert_like(log, ['zzz', 'yyy', 'xxx', 'xxx', 'yyy']);
1417
1394
  },
1418
1395
  'Flow: Auto'($) {
1419
1396
  class App extends $mol_object2 {
@@ -1458,13 +1435,6 @@ var $;
1458
1435
  static bar() {
1459
1436
  return { ...this.foo(), count: ++counter };
1460
1437
  }
1461
- static test() {
1462
- $mol_assert_like(App.bar(), { numbs: [1], count: 1 });
1463
- App.foo({ numbs: [1] });
1464
- $mol_assert_like(App.bar(), { numbs: [1], count: 1 });
1465
- App.foo({ numbs: [2] });
1466
- $mol_assert_like(App.bar(), { numbs: [2], count: 2 });
1467
- }
1468
1438
  }
1469
1439
  __decorate([
1470
1440
  $mol_wire_mem(0)
@@ -1472,10 +1442,11 @@ var $;
1472
1442
  __decorate([
1473
1443
  $mol_wire_mem(0)
1474
1444
  ], App, "bar", null);
1475
- __decorate([
1476
- $mol_wire_method
1477
- ], App, "test", null);
1478
- App.test();
1445
+ $mol_assert_like(App.bar(), { numbs: [1], count: 1 });
1446
+ App.foo({ numbs: [1] });
1447
+ $mol_assert_like(App.bar(), { numbs: [1], count: 1 });
1448
+ App.foo({ numbs: [2] });
1449
+ $mol_assert_like(App.bar(), { numbs: [2], count: 2 });
1479
1450
  },
1480
1451
  'Cycle: Fail'($) {
1481
1452
  class App extends $mol_object2 {
@@ -1513,13 +1484,6 @@ var $;
1513
1484
  static slow(next) {
1514
1485
  return this.store(next);
1515
1486
  }
1516
- static test() {
1517
- App.fast();
1518
- $mol_assert_equal(App.slow(666), 666);
1519
- $mol_assert_equal(App.fast(), App.slow(), 666);
1520
- App.store(777);
1521
- $mol_assert_equal(App.fast(), App.slow(), 777);
1522
- }
1523
1487
  }
1524
1488
  __decorate([
1525
1489
  $mol_wire_mem(0)
@@ -1530,10 +1494,11 @@ var $;
1530
1494
  __decorate([
1531
1495
  $mol_wire_mem(0)
1532
1496
  ], App, "slow", null);
1533
- __decorate([
1534
- $mol_wire_method
1535
- ], App, "test", null);
1536
- App.test();
1497
+ App.fast();
1498
+ $mol_assert_equal(App.slow(666), 666);
1499
+ $mol_assert_equal(App.fast(), App.slow(), 666);
1500
+ App.store(777);
1501
+ $mol_assert_equal(App.fast(), App.slow(), 777);
1537
1502
  },
1538
1503
  'Actions inside invariant'($) {
1539
1504
  class App extends $mol_object2 {
@@ -1550,11 +1515,6 @@ var $;
1550
1515
  this.count(count + 1);
1551
1516
  return count + 1;
1552
1517
  }
1553
- static test() {
1554
- $mol_assert_like(App.res(), 1);
1555
- App.count(5);
1556
- $mol_assert_like(App.res(), 6);
1557
- }
1558
1518
  }
1559
1519
  __decorate([
1560
1520
  $mol_wire_mem(0)
@@ -1565,10 +1525,39 @@ var $;
1565
1525
  __decorate([
1566
1526
  $mol_wire_mem(0)
1567
1527
  ], App, "res", null);
1528
+ $mol_assert_like(App.res(), 1);
1529
+ App.count(5);
1530
+ $mol_assert_like(App.res(), 6);
1531
+ },
1532
+ async 'Toggle with async'($) {
1533
+ class App extends $mol_object2 {
1534
+ static $ = $;
1535
+ static checked(next = false) {
1536
+ $$.$mol_wait_timeout(0);
1537
+ return next;
1538
+ }
1539
+ static toggle() {
1540
+ const prev = this.checked();
1541
+ $mol_assert_unique(this.checked(!prev), prev);
1542
+ $mol_assert_equal(this.checked(), prev);
1543
+ }
1544
+ static res() {
1545
+ return this.checked();
1546
+ }
1547
+ }
1548
+ __decorate([
1549
+ $mol_wire_mem(0)
1550
+ ], App, "checked", null);
1568
1551
  __decorate([
1569
1552
  $mol_wire_method
1570
- ], App, "test", null);
1571
- App.test();
1553
+ ], App, "toggle", null);
1554
+ __decorate([
1555
+ $mol_wire_mem(0)
1556
+ ], App, "res", null);
1557
+ const app = $mol_wire_async(App);
1558
+ $mol_assert_equal(await app.res(), false);
1559
+ await app.toggle();
1560
+ $mol_assert_equal(await app.res(), true);
1572
1561
  },
1573
1562
  'Restore after error'($) {
1574
1563
  class App extends $mol_object2 {
@@ -1739,9 +1728,6 @@ var $;
1739
1728
  ];
1740
1729
  }
1741
1730
  static test() {
1742
- $mol_assert_like(this.user_names(), ['jin', 'john']);
1743
- Team.user_name('jin', 'JIN');
1744
- $mol_assert_like(this.user_names(), ['JIN', 'john']);
1745
1731
  }
1746
1732
  }
1747
1733
  __decorate([
@@ -1753,7 +1739,9 @@ var $;
1753
1739
  __decorate([
1754
1740
  $mol_wire_method
1755
1741
  ], Team, "test", null);
1756
- Team.test();
1742
+ $mol_assert_like(Team.user_names(), ['jin', 'john']);
1743
+ Team.user_name('jin', 'JIN');
1744
+ $mol_assert_like(Team.user_names(), ['JIN', 'john']);
1757
1745
  },
1758
1746
  'Memoize by single complex key'($) {
1759
1747
  class Map extends $mol_object2 {
@@ -1830,21 +1818,15 @@ var $;
1830
1818
  ++this.sums;
1831
1819
  return this.value(index - 1) + this.value(index - 2);
1832
1820
  }
1833
- static test() {
1834
- $mol_assert_equal(this.value(4), 5);
1835
- $mol_assert_equal(this.sums, 3);
1836
- this.value(1, 2);
1837
- $mol_assert_equal(this.value(4), 8);
1838
- $mol_assert_equal(this.sums, 6);
1839
- }
1840
1821
  }
1841
1822
  __decorate([
1842
1823
  $mol_wire_mem(1)
1843
1824
  ], Fib, "value", null);
1844
- __decorate([
1845
- $mol_wire_method
1846
- ], Fib, "test", null);
1847
- Fib.test();
1825
+ $mol_assert_equal(Fib.value(4), 5);
1826
+ $mol_assert_equal(Fib.sums, 3);
1827
+ Fib.value(1, 2);
1828
+ $mol_assert_equal(Fib.value(4), 8);
1829
+ $mol_assert_equal(Fib.sums, 6);
1848
1830
  },
1849
1831
  'Unsubscribe from temp pubs on complete'($) {
1850
1832
  class Random extends $mol_object2 {
@@ -1859,12 +1841,6 @@ var $;
1859
1841
  this.resets();
1860
1842
  return this.seed();
1861
1843
  }
1862
- static test() {
1863
- const first = this.value();
1864
- this.resets(null);
1865
- const second = this.value();
1866
- $mol_assert_unique(first, second);
1867
- }
1868
1844
  }
1869
1845
  __decorate([
1870
1846
  $mol_wire_method
@@ -1875,10 +1851,9 @@ var $;
1875
1851
  __decorate([
1876
1852
  $mol_wire_mem(0)
1877
1853
  ], Random, "value", null);
1878
- __decorate([
1879
- $mol_wire_method
1880
- ], Random, "test", null);
1881
- Random.test();
1854
+ const first = Random.value();
1855
+ Random.resets(null);
1856
+ $mol_assert_unique(Random.value(), first);
1882
1857
  },
1883
1858
  });
1884
1859
  })($ || ($ = {}));
@@ -2188,7 +2163,7 @@ var $;
2188
2163
  }
2189
2164
  for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
2190
2165
  const pub = this[cursor];
2191
- pub.up();
2166
+ pub.refresh();
2192
2167
  }
2193
2168
  this.cursor = $mol_wire_cursor.fresh;
2194
2169
  }
@@ -2231,6 +2206,16 @@ var $;
2231
2206
  }
2232
2207
  this.sub_from = this.cursor;
2233
2208
  }
2209
+ commit() {
2210
+ this.commit_pubs();
2211
+ }
2212
+ commit_pubs() {
2213
+ const limit = this.cursor < 0 ? this.sub_from : this.cursor;
2214
+ for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
2215
+ const pub = this[cursor];
2216
+ pub?.commit();
2217
+ }
2218
+ }
2234
2219
  absorb(quant = $mol_wire_cursor.stale) {
2235
2220
  if (this.cursor === $mol_wire_cursor.final)
2236
2221
  return;
@@ -2536,7 +2521,7 @@ var $;
2536
2521
  while (this.planning.length) {
2537
2522
  const fibers = this.planning.splice(0, this.planning.length);
2538
2523
  for (const fiber of fibers) {
2539
- fiber.up();
2524
+ fiber.refresh();
2540
2525
  }
2541
2526
  }
2542
2527
  while (this.reaping.length) {
@@ -2552,14 +2537,14 @@ var $;
2552
2537
  get args() {
2553
2538
  return this.slice(0, this.pub_from);
2554
2539
  }
2555
- get result() {
2540
+ result() {
2556
2541
  if (this.cache instanceof Promise)
2557
2542
  return;
2558
2543
  if (this.cache instanceof Error)
2559
2544
  return;
2560
2545
  return this.cache;
2561
2546
  }
2562
- get persist() {
2547
+ persistent() {
2563
2548
  const id = this[Symbol.toStringTag];
2564
2549
  return id[id.length - 2] !== '#';
2565
2550
  }
@@ -2581,7 +2566,7 @@ var $;
2581
2566
  if ($mol_owning_check(this, prev)) {
2582
2567
  prev.destructor();
2583
2568
  }
2584
- if (this.persist) {
2569
+ if (this.persistent()) {
2585
2570
  if (this.pub_from === 0) {
2586
2571
  ;
2587
2572
  (this.host ?? this.task)[this.field()] = null;
@@ -2624,12 +2609,16 @@ var $;
2624
2609
  else
2625
2610
  super.emit(quant);
2626
2611
  }
2627
- down() {
2628
- if (this.persist)
2612
+ commit() {
2613
+ if (this.persistent())
2629
2614
  return;
2615
+ super.commit();
2616
+ if (this.host instanceof $mol_wire_fiber) {
2617
+ this.host.put(this.cache);
2618
+ }
2630
2619
  this.destructor();
2631
2620
  }
2632
- up() {
2621
+ refresh() {
2633
2622
  if (this.cursor === $mol_wire_cursor.fresh)
2634
2623
  return;
2635
2624
  if (this.cursor === $mol_wire_cursor.final)
@@ -2637,7 +2626,7 @@ var $;
2637
2626
  check: if (this.cursor === $mol_wire_cursor.doubt) {
2638
2627
  for (let i = this.pub_from; i < this.sub_from; i += 2) {
2639
2628
  ;
2640
- this[i]?.up();
2629
+ this[i]?.refresh();
2641
2630
  if (this.cursor !== $mol_wire_cursor.doubt)
2642
2631
  break check;
2643
2632
  }
@@ -2685,7 +2674,7 @@ var $;
2685
2674
  prev.destructor();
2686
2675
  }
2687
2676
  this.cache = next;
2688
- if (this.persist && $mol_owning_catch(this, next)) {
2677
+ if (this.persistent() && $mol_owning_catch(this, next)) {
2689
2678
  try {
2690
2679
  next[Symbol.toStringTag] = this[Symbol.toStringTag];
2691
2680
  }
@@ -2700,28 +2689,25 @@ var $;
2700
2689
  this.cursor = $mol_wire_cursor.fresh;
2701
2690
  if (next instanceof Promise)
2702
2691
  return next;
2703
- if (this.persist) {
2704
- for (let cursor = this.pub_from; cursor < this.sub_from; cursor += 2) {
2705
- const pub = this[cursor];
2706
- pub?.down();
2707
- }
2692
+ if (this.persistent()) {
2693
+ this.commit_pubs();
2708
2694
  }
2709
2695
  else {
2710
- this.cursor = this.pub_from;
2711
- this.track_cut();
2712
- this.cursor = $mol_wire_cursor.fresh;
2696
+ if (this.sub_empty) {
2697
+ this.commit();
2698
+ }
2713
2699
  }
2714
2700
  return next;
2715
2701
  }
2716
2702
  recall(...args) {
2717
- return this.put(this.task.call(this.host, ...args));
2703
+ return this.task.call(this.host, ...args);
2718
2704
  }
2719
2705
  sync() {
2720
2706
  if (!$mol_wire_fiber.warm) {
2721
- return this.result;
2707
+ return this.result();
2722
2708
  }
2723
2709
  this.promote();
2724
- this.up();
2710
+ this.refresh();
2725
2711
  if (this.cache instanceof Error) {
2726
2712
  return $mol_fail_hidden(this.cache);
2727
2713
  }
@@ -2732,7 +2718,7 @@ var $;
2732
2718
  }
2733
2719
  async async() {
2734
2720
  while (true) {
2735
- this.up();
2721
+ this.refresh();
2736
2722
  if (this.cache instanceof Error) {
2737
2723
  $mol_fail_hidden(this.cache);
2738
2724
  }