mol_wire_pub 1.0.81 → 1.0.84

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,40 @@ 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
+ $mol_wire_solid();
1546
+ return this.checked();
1547
+ }
1548
+ }
1549
+ __decorate([
1550
+ $mol_wire_mem(0)
1551
+ ], App, "checked", null);
1568
1552
  __decorate([
1569
1553
  $mol_wire_method
1570
- ], App, "test", null);
1571
- App.test();
1554
+ ], App, "toggle", null);
1555
+ __decorate([
1556
+ $mol_wire_mem(0)
1557
+ ], App, "res", null);
1558
+ const app = $mol_wire_async(App);
1559
+ $mol_assert_equal(await app.res(), false);
1560
+ await app.toggle();
1561
+ $mol_assert_equal(await app.res(), true);
1572
1562
  },
1573
1563
  'Restore after error'($) {
1574
1564
  class App extends $mol_object2 {
@@ -1739,9 +1729,6 @@ var $;
1739
1729
  ];
1740
1730
  }
1741
1731
  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
1732
  }
1746
1733
  }
1747
1734
  __decorate([
@@ -1753,7 +1740,9 @@ var $;
1753
1740
  __decorate([
1754
1741
  $mol_wire_method
1755
1742
  ], Team, "test", null);
1756
- Team.test();
1743
+ $mol_assert_like(Team.user_names(), ['jin', 'john']);
1744
+ Team.user_name('jin', 'JIN');
1745
+ $mol_assert_like(Team.user_names(), ['JIN', 'john']);
1757
1746
  },
1758
1747
  'Memoize by single complex key'($) {
1759
1748
  class Map extends $mol_object2 {
@@ -1830,21 +1819,15 @@ var $;
1830
1819
  ++this.sums;
1831
1820
  return this.value(index - 1) + this.value(index - 2);
1832
1821
  }
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
1822
  }
1841
1823
  __decorate([
1842
1824
  $mol_wire_mem(1)
1843
1825
  ], Fib, "value", null);
1844
- __decorate([
1845
- $mol_wire_method
1846
- ], Fib, "test", null);
1847
- Fib.test();
1826
+ $mol_assert_equal(Fib.value(4), 5);
1827
+ $mol_assert_equal(Fib.sums, 3);
1828
+ Fib.value(1, 2);
1829
+ $mol_assert_equal(Fib.value(4), 8);
1830
+ $mol_assert_equal(Fib.sums, 6);
1848
1831
  },
1849
1832
  'Unsubscribe from temp pubs on complete'($) {
1850
1833
  class Random extends $mol_object2 {
@@ -1859,12 +1842,6 @@ var $;
1859
1842
  this.resets();
1860
1843
  return this.seed();
1861
1844
  }
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
1845
  }
1869
1846
  __decorate([
1870
1847
  $mol_wire_method
@@ -1875,10 +1852,9 @@ var $;
1875
1852
  __decorate([
1876
1853
  $mol_wire_mem(0)
1877
1854
  ], Random, "value", null);
1878
- __decorate([
1879
- $mol_wire_method
1880
- ], Random, "test", null);
1881
- Random.test();
1855
+ const first = Random.value();
1856
+ Random.resets(null);
1857
+ $mol_assert_unique(Random.value(), first);
1882
1858
  },
1883
1859
  });
1884
1860
  })($ || ($ = {}));
@@ -2188,7 +2164,7 @@ var $;
2188
2164
  }
2189
2165
  for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
2190
2166
  const pub = this[cursor];
2191
- pub.up();
2167
+ pub.refresh();
2192
2168
  }
2193
2169
  this.cursor = $mol_wire_cursor.fresh;
2194
2170
  }
@@ -2231,6 +2207,16 @@ var $;
2231
2207
  }
2232
2208
  this.sub_from = this.cursor;
2233
2209
  }
2210
+ commit() {
2211
+ this.commit_pubs();
2212
+ }
2213
+ commit_pubs() {
2214
+ const limit = this.cursor < 0 ? this.sub_from : this.cursor;
2215
+ for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
2216
+ const pub = this[cursor];
2217
+ pub?.commit();
2218
+ }
2219
+ }
2234
2220
  absorb(quant = $mol_wire_cursor.stale) {
2235
2221
  if (this.cursor === $mol_wire_cursor.final)
2236
2222
  return;
@@ -2536,7 +2522,7 @@ var $;
2536
2522
  while (this.planning.length) {
2537
2523
  const fibers = this.planning.splice(0, this.planning.length);
2538
2524
  for (const fiber of fibers) {
2539
- fiber.up();
2525
+ fiber.refresh();
2540
2526
  }
2541
2527
  }
2542
2528
  while (this.reaping.length) {
@@ -2552,14 +2538,14 @@ var $;
2552
2538
  get args() {
2553
2539
  return this.slice(0, this.pub_from);
2554
2540
  }
2555
- get result() {
2541
+ result() {
2556
2542
  if (this.cache instanceof Promise)
2557
2543
  return;
2558
2544
  if (this.cache instanceof Error)
2559
2545
  return;
2560
2546
  return this.cache;
2561
2547
  }
2562
- get persist() {
2548
+ persistent() {
2563
2549
  const id = this[Symbol.toStringTag];
2564
2550
  return id[id.length - 2] !== '#';
2565
2551
  }
@@ -2581,7 +2567,7 @@ var $;
2581
2567
  if ($mol_owning_check(this, prev)) {
2582
2568
  prev.destructor();
2583
2569
  }
2584
- if (this.persist) {
2570
+ if (this.persistent()) {
2585
2571
  if (this.pub_from === 0) {
2586
2572
  ;
2587
2573
  (this.host ?? this.task)[this.field()] = null;
@@ -2624,12 +2610,16 @@ var $;
2624
2610
  else
2625
2611
  super.emit(quant);
2626
2612
  }
2627
- down() {
2628
- if (this.persist)
2613
+ commit() {
2614
+ if (this.persistent())
2629
2615
  return;
2616
+ super.commit();
2617
+ if (this.host instanceof $mol_wire_fiber) {
2618
+ this.host.put(this.cache);
2619
+ }
2630
2620
  this.destructor();
2631
2621
  }
2632
- up() {
2622
+ refresh() {
2633
2623
  if (this.cursor === $mol_wire_cursor.fresh)
2634
2624
  return;
2635
2625
  if (this.cursor === $mol_wire_cursor.final)
@@ -2637,7 +2627,7 @@ var $;
2637
2627
  check: if (this.cursor === $mol_wire_cursor.doubt) {
2638
2628
  for (let i = this.pub_from; i < this.sub_from; i += 2) {
2639
2629
  ;
2640
- this[i]?.up();
2630
+ this[i]?.refresh();
2641
2631
  if (this.cursor !== $mol_wire_cursor.doubt)
2642
2632
  break check;
2643
2633
  }
@@ -2685,7 +2675,7 @@ var $;
2685
2675
  prev.destructor();
2686
2676
  }
2687
2677
  this.cache = next;
2688
- if (this.persist && $mol_owning_catch(this, next)) {
2678
+ if (this.persistent() && $mol_owning_catch(this, next)) {
2689
2679
  try {
2690
2680
  next[Symbol.toStringTag] = this[Symbol.toStringTag];
2691
2681
  }
@@ -2700,28 +2690,25 @@ var $;
2700
2690
  this.cursor = $mol_wire_cursor.fresh;
2701
2691
  if (next instanceof Promise)
2702
2692
  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
- }
2693
+ if (this.persistent()) {
2694
+ this.commit_pubs();
2708
2695
  }
2709
2696
  else {
2710
- this.cursor = this.pub_from;
2711
- this.track_cut();
2712
- this.cursor = $mol_wire_cursor.fresh;
2697
+ if (this.sub_empty) {
2698
+ this.commit();
2699
+ }
2713
2700
  }
2714
2701
  return next;
2715
2702
  }
2716
2703
  recall(...args) {
2717
- return this.put(this.task.call(this.host, ...args));
2704
+ return this.task.call(this.host, ...args);
2718
2705
  }
2719
2706
  sync() {
2720
2707
  if (!$mol_wire_fiber.warm) {
2721
- return this.result;
2708
+ return this.result();
2722
2709
  }
2723
2710
  this.promote();
2724
- this.up();
2711
+ this.refresh();
2725
2712
  if (this.cache instanceof Error) {
2726
2713
  return $mol_fail_hidden(this.cache);
2727
2714
  }
@@ -2732,7 +2719,7 @@ var $;
2732
2719
  }
2733
2720
  async async() {
2734
2721
  while (true) {
2735
- this.up();
2722
+ this.refresh();
2736
2723
  if (this.cache instanceof Error) {
2737
2724
  $mol_fail_hidden(this.cache);
2738
2725
  }
@@ -3364,5 +3351,16 @@ var $;
3364
3351
  ;
3365
3352
  "use strict";
3366
3353
  //mol/type/equals/equals.ts
3354
+ ;
3355
+ "use strict";
3356
+ var $;
3357
+ (function ($) {
3358
+ function $mol_wire_solid() {
3359
+ $mol_wire_auto().reap = nothing;
3360
+ }
3361
+ $.$mol_wire_solid = $mol_wire_solid;
3362
+ const nothing = () => { };
3363
+ })($ || ($ = {}));
3364
+ //mol/wire/solid/solid.ts
3367
3365
 
3368
3366
  //# sourceMappingURL=node.test.js.map