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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mol_wire_pub",
3
- "version": "1.0.81",
3
+ "version": "1.0.84",
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,40 @@ 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
+ $mol_wire_solid();
1381
+ return this.checked();
1382
+ }
1383
+ }
1384
+ __decorate([
1385
+ $mol_wire_mem(0)
1386
+ ], App, "checked", null);
1403
1387
  __decorate([
1404
1388
  $mol_wire_method
1405
- ], App, "test", null);
1406
- App.test();
1389
+ ], App, "toggle", null);
1390
+ __decorate([
1391
+ $mol_wire_mem(0)
1392
+ ], App, "res", null);
1393
+ const app = $mol_wire_async(App);
1394
+ $mol_assert_equal(await app.res(), false);
1395
+ await app.toggle();
1396
+ $mol_assert_equal(await app.res(), true);
1407
1397
  },
1408
1398
  'Restore after error'($) {
1409
1399
  class App extends $mol_object2 {
@@ -1574,9 +1564,6 @@ var $;
1574
1564
  ];
1575
1565
  }
1576
1566
  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
1567
  }
1581
1568
  }
1582
1569
  __decorate([
@@ -1588,7 +1575,9 @@ var $;
1588
1575
  __decorate([
1589
1576
  $mol_wire_method
1590
1577
  ], Team, "test", null);
1591
- Team.test();
1578
+ $mol_assert_like(Team.user_names(), ['jin', 'john']);
1579
+ Team.user_name('jin', 'JIN');
1580
+ $mol_assert_like(Team.user_names(), ['JIN', 'john']);
1592
1581
  },
1593
1582
  'Memoize by single complex key'($) {
1594
1583
  class Map extends $mol_object2 {
@@ -1665,21 +1654,15 @@ var $;
1665
1654
  ++this.sums;
1666
1655
  return this.value(index - 1) + this.value(index - 2);
1667
1656
  }
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
1657
  }
1676
1658
  __decorate([
1677
1659
  $mol_wire_mem(1)
1678
1660
  ], Fib, "value", null);
1679
- __decorate([
1680
- $mol_wire_method
1681
- ], Fib, "test", null);
1682
- Fib.test();
1661
+ $mol_assert_equal(Fib.value(4), 5);
1662
+ $mol_assert_equal(Fib.sums, 3);
1663
+ Fib.value(1, 2);
1664
+ $mol_assert_equal(Fib.value(4), 8);
1665
+ $mol_assert_equal(Fib.sums, 6);
1683
1666
  },
1684
1667
  'Unsubscribe from temp pubs on complete'($) {
1685
1668
  class Random extends $mol_object2 {
@@ -1694,12 +1677,6 @@ var $;
1694
1677
  this.resets();
1695
1678
  return this.seed();
1696
1679
  }
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
1680
  }
1704
1681
  __decorate([
1705
1682
  $mol_wire_method
@@ -1710,10 +1687,9 @@ var $;
1710
1687
  __decorate([
1711
1688
  $mol_wire_mem(0)
1712
1689
  ], Random, "value", null);
1713
- __decorate([
1714
- $mol_wire_method
1715
- ], Random, "test", null);
1716
- Random.test();
1690
+ const first = Random.value();
1691
+ Random.resets(null);
1692
+ $mol_assert_unique(Random.value(), first);
1717
1693
  },
1718
1694
  });
1719
1695
  })($ || ($ = {}));
@@ -2023,7 +1999,7 @@ var $;
2023
1999
  }
2024
2000
  for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
2025
2001
  const pub = this[cursor];
2026
- pub.up();
2002
+ pub.refresh();
2027
2003
  }
2028
2004
  this.cursor = $mol_wire_cursor.fresh;
2029
2005
  }
@@ -2066,6 +2042,16 @@ var $;
2066
2042
  }
2067
2043
  this.sub_from = this.cursor;
2068
2044
  }
2045
+ commit() {
2046
+ this.commit_pubs();
2047
+ }
2048
+ commit_pubs() {
2049
+ const limit = this.cursor < 0 ? this.sub_from : this.cursor;
2050
+ for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
2051
+ const pub = this[cursor];
2052
+ pub?.commit();
2053
+ }
2054
+ }
2069
2055
  absorb(quant = $mol_wire_cursor.stale) {
2070
2056
  if (this.cursor === $mol_wire_cursor.final)
2071
2057
  return;
@@ -2396,7 +2382,7 @@ var $;
2396
2382
  while (this.planning.length) {
2397
2383
  const fibers = this.planning.splice(0, this.planning.length);
2398
2384
  for (const fiber of fibers) {
2399
- fiber.up();
2385
+ fiber.refresh();
2400
2386
  }
2401
2387
  }
2402
2388
  while (this.reaping.length) {
@@ -2412,14 +2398,14 @@ var $;
2412
2398
  get args() {
2413
2399
  return this.slice(0, this.pub_from);
2414
2400
  }
2415
- get result() {
2401
+ result() {
2416
2402
  if (this.cache instanceof Promise)
2417
2403
  return;
2418
2404
  if (this.cache instanceof Error)
2419
2405
  return;
2420
2406
  return this.cache;
2421
2407
  }
2422
- get persist() {
2408
+ persistent() {
2423
2409
  const id = this[Symbol.toStringTag];
2424
2410
  return id[id.length - 2] !== '#';
2425
2411
  }
@@ -2441,7 +2427,7 @@ var $;
2441
2427
  if ($mol_owning_check(this, prev)) {
2442
2428
  prev.destructor();
2443
2429
  }
2444
- if (this.persist) {
2430
+ if (this.persistent()) {
2445
2431
  if (this.pub_from === 0) {
2446
2432
  ;
2447
2433
  (this.host ?? this.task)[this.field()] = null;
@@ -2484,12 +2470,16 @@ var $;
2484
2470
  else
2485
2471
  super.emit(quant);
2486
2472
  }
2487
- down() {
2488
- if (this.persist)
2473
+ commit() {
2474
+ if (this.persistent())
2489
2475
  return;
2476
+ super.commit();
2477
+ if (this.host instanceof $mol_wire_fiber) {
2478
+ this.host.put(this.cache);
2479
+ }
2490
2480
  this.destructor();
2491
2481
  }
2492
- up() {
2482
+ refresh() {
2493
2483
  if (this.cursor === $mol_wire_cursor.fresh)
2494
2484
  return;
2495
2485
  if (this.cursor === $mol_wire_cursor.final)
@@ -2497,7 +2487,7 @@ var $;
2497
2487
  check: if (this.cursor === $mol_wire_cursor.doubt) {
2498
2488
  for (let i = this.pub_from; i < this.sub_from; i += 2) {
2499
2489
  ;
2500
- this[i]?.up();
2490
+ this[i]?.refresh();
2501
2491
  if (this.cursor !== $mol_wire_cursor.doubt)
2502
2492
  break check;
2503
2493
  }
@@ -2545,7 +2535,7 @@ var $;
2545
2535
  prev.destructor();
2546
2536
  }
2547
2537
  this.cache = next;
2548
- if (this.persist && $mol_owning_catch(this, next)) {
2538
+ if (this.persistent() && $mol_owning_catch(this, next)) {
2549
2539
  try {
2550
2540
  next[Symbol.toStringTag] = this[Symbol.toStringTag];
2551
2541
  }
@@ -2560,28 +2550,25 @@ var $;
2560
2550
  this.cursor = $mol_wire_cursor.fresh;
2561
2551
  if (next instanceof Promise)
2562
2552
  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
- }
2553
+ if (this.persistent()) {
2554
+ this.commit_pubs();
2568
2555
  }
2569
2556
  else {
2570
- this.cursor = this.pub_from;
2571
- this.track_cut();
2572
- this.cursor = $mol_wire_cursor.fresh;
2557
+ if (this.sub_empty) {
2558
+ this.commit();
2559
+ }
2573
2560
  }
2574
2561
  return next;
2575
2562
  }
2576
2563
  recall(...args) {
2577
- return this.put(this.task.call(this.host, ...args));
2564
+ return this.task.call(this.host, ...args);
2578
2565
  }
2579
2566
  sync() {
2580
2567
  if (!$mol_wire_fiber.warm) {
2581
- return this.result;
2568
+ return this.result();
2582
2569
  }
2583
2570
  this.promote();
2584
- this.up();
2571
+ this.refresh();
2585
2572
  if (this.cache instanceof Error) {
2586
2573
  return $mol_fail_hidden(this.cache);
2587
2574
  }
@@ -2592,7 +2579,7 @@ var $;
2592
2579
  }
2593
2580
  async async() {
2594
2581
  while (true) {
2595
- this.up();
2582
+ this.refresh();
2596
2583
  if (this.cache instanceof Error) {
2597
2584
  $mol_fail_hidden(this.cache);
2598
2585
  }
@@ -2768,5 +2755,16 @@ var $;
2768
2755
  ;
2769
2756
  "use strict";
2770
2757
  //mol/type/equals/equals.ts
2758
+ ;
2759
+ "use strict";
2760
+ var $;
2761
+ (function ($) {
2762
+ function $mol_wire_solid() {
2763
+ $mol_wire_auto().reap = nothing;
2764
+ }
2765
+ $.$mol_wire_solid = $mol_wire_solid;
2766
+ const nothing = () => { };
2767
+ })($ || ($ = {}));
2768
+ //mol/wire/solid/solid.ts
2771
2769
 
2772
2770
  //# sourceMappingURL=web.test.js.map