mol_wire_lib 1.0.1230 → 1.0.1232

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.mjs CHANGED
@@ -754,15 +754,20 @@ var $;
754
754
  break;
755
755
  }
756
756
  if ($mol_promise_like(result)) {
757
- const put = (res) => {
758
- if (this.cache === result)
759
- this.put(res);
760
- return res;
761
- };
762
- wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
763
- wrappers.set(result, result);
764
- const error = new Error(`Promise in ${this}`);
765
- Object.defineProperty(result, 'stack', { get: () => error.stack });
757
+ if (wrappers.has(result)) {
758
+ result = wrappers.get(result).then(a => a);
759
+ }
760
+ else {
761
+ const put = (res) => {
762
+ if (this.cache === result)
763
+ this.put(res);
764
+ return res;
765
+ };
766
+ wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
767
+ wrappers.set(result, result);
768
+ const error = new Error(`Promise in ${this}`);
769
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
770
+ }
766
771
  }
767
772
  }
768
773
  catch (error) {
@@ -773,12 +778,17 @@ var $;
773
778
  result = new Error(String(error), { cause: error });
774
779
  }
775
780
  if ($mol_promise_like(result)) {
776
- wrappers.set(result, result = Object.assign(result.finally(() => {
777
- if (this.cache === result)
778
- this.absorb();
779
- }), { destructor: result.destructor || (() => { }) }));
780
- const error = new Error(`Promise in ${this}`);
781
- Object.defineProperty(result, 'stack', { get: () => error.stack });
781
+ if (wrappers.has(result)) {
782
+ result = wrappers.get(result);
783
+ }
784
+ else {
785
+ wrappers.set(result, result = Object.assign(result.finally(() => {
786
+ if (this.cache === result)
787
+ this.absorb();
788
+ }), { destructor: result.destructor || (() => { }) }));
789
+ const error = new Error(`Promise in ${this}`);
790
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
791
+ }
782
792
  }
783
793
  }
784
794
  if (!$mol_promise_like(result)) {
@@ -840,6 +850,12 @@ var $;
840
850
  };
841
851
  });
842
852
  }
853
+ destructor() {
854
+ super.destructor();
855
+ if ($mol_owning_check(this, this.cache)) {
856
+ this.cache.destructor();
857
+ }
858
+ }
843
859
  }
844
860
  $.$mol_wire_fiber = $mol_wire_fiber;
845
861
  })($ || ($ = {}));
@@ -1550,6 +1566,14 @@ var $;
1550
1566
  this.cursor = $mol_wire_cursor.fresh;
1551
1567
  if (next !== prev)
1552
1568
  this.emit();
1569
+ if ($mol_owning_catch(this, next)) {
1570
+ try {
1571
+ next[Symbol.toStringTag] = this[Symbol.toStringTag];
1572
+ }
1573
+ catch {
1574
+ Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
1575
+ }
1576
+ }
1553
1577
  return next;
1554
1578
  }
1555
1579
  this.cursor = $mol_wire_cursor.final;
@@ -1583,6 +1607,7 @@ var $;
1583
1607
  var $;
1584
1608
  (function ($) {
1585
1609
  $.$mol_key_store = new WeakMap();
1610
+ const TypedArray = Object.getPrototypeOf(Uint8Array);
1586
1611
  function $mol_key(value) {
1587
1612
  if (typeof value === 'bigint')
1588
1613
  return value.toString() + 'n';
@@ -1612,7 +1637,7 @@ var $;
1612
1637
  return value;
1613
1638
  if (value instanceof RegExp)
1614
1639
  return value.toString();
1615
- if (value instanceof Uint8Array)
1640
+ if (value instanceof TypedArray)
1616
1641
  return [...value];
1617
1642
  let key = $.$mol_key_store.get(value);
1618
1643
  if (key)
@@ -1801,10 +1826,6 @@ var $;
1801
1826
  }
1802
1827
  destructor() {
1803
1828
  super.destructor();
1804
- const prev = this.cache;
1805
- if ($mol_owning_check(this, prev)) {
1806
- prev.destructor();
1807
- }
1808
1829
  if (this.pub_from === 0) {
1809
1830
  ;
1810
1831
  (this.host ?? this.task)[this.field()] = null;
package/node.test.js CHANGED
@@ -745,15 +745,20 @@ var $;
745
745
  break;
746
746
  }
747
747
  if ($mol_promise_like(result)) {
748
- const put = (res) => {
749
- if (this.cache === result)
750
- this.put(res);
751
- return res;
752
- };
753
- wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
754
- wrappers.set(result, result);
755
- const error = new Error(`Promise in ${this}`);
756
- Object.defineProperty(result, 'stack', { get: () => error.stack });
748
+ if (wrappers.has(result)) {
749
+ result = wrappers.get(result).then(a => a);
750
+ }
751
+ else {
752
+ const put = (res) => {
753
+ if (this.cache === result)
754
+ this.put(res);
755
+ return res;
756
+ };
757
+ wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
758
+ wrappers.set(result, result);
759
+ const error = new Error(`Promise in ${this}`);
760
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
761
+ }
757
762
  }
758
763
  }
759
764
  catch (error) {
@@ -764,12 +769,17 @@ var $;
764
769
  result = new Error(String(error), { cause: error });
765
770
  }
766
771
  if ($mol_promise_like(result)) {
767
- wrappers.set(result, result = Object.assign(result.finally(() => {
768
- if (this.cache === result)
769
- this.absorb();
770
- }), { destructor: result.destructor || (() => { }) }));
771
- const error = new Error(`Promise in ${this}`);
772
- Object.defineProperty(result, 'stack', { get: () => error.stack });
772
+ if (wrappers.has(result)) {
773
+ result = wrappers.get(result);
774
+ }
775
+ else {
776
+ wrappers.set(result, result = Object.assign(result.finally(() => {
777
+ if (this.cache === result)
778
+ this.absorb();
779
+ }), { destructor: result.destructor || (() => { }) }));
780
+ const error = new Error(`Promise in ${this}`);
781
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
782
+ }
773
783
  }
774
784
  }
775
785
  if (!$mol_promise_like(result)) {
@@ -831,6 +841,12 @@ var $;
831
841
  };
832
842
  });
833
843
  }
844
+ destructor() {
845
+ super.destructor();
846
+ if ($mol_owning_check(this, this.cache)) {
847
+ this.cache.destructor();
848
+ }
849
+ }
834
850
  }
835
851
  $.$mol_wire_fiber = $mol_wire_fiber;
836
852
  })($ || ($ = {}));
@@ -1541,6 +1557,14 @@ var $;
1541
1557
  this.cursor = $mol_wire_cursor.fresh;
1542
1558
  if (next !== prev)
1543
1559
  this.emit();
1560
+ if ($mol_owning_catch(this, next)) {
1561
+ try {
1562
+ next[Symbol.toStringTag] = this[Symbol.toStringTag];
1563
+ }
1564
+ catch {
1565
+ Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
1566
+ }
1567
+ }
1544
1568
  return next;
1545
1569
  }
1546
1570
  this.cursor = $mol_wire_cursor.final;
@@ -1574,6 +1598,7 @@ var $;
1574
1598
  var $;
1575
1599
  (function ($) {
1576
1600
  $.$mol_key_store = new WeakMap();
1601
+ const TypedArray = Object.getPrototypeOf(Uint8Array);
1577
1602
  function $mol_key(value) {
1578
1603
  if (typeof value === 'bigint')
1579
1604
  return value.toString() + 'n';
@@ -1603,7 +1628,7 @@ var $;
1603
1628
  return value;
1604
1629
  if (value instanceof RegExp)
1605
1630
  return value.toString();
1606
- if (value instanceof Uint8Array)
1631
+ if (value instanceof TypedArray)
1607
1632
  return [...value];
1608
1633
  let key = $.$mol_key_store.get(value);
1609
1634
  if (key)
@@ -1792,10 +1817,6 @@ var $;
1792
1817
  }
1793
1818
  destructor() {
1794
1819
  super.destructor();
1795
- const prev = this.cache;
1796
- if ($mol_owning_check(this, prev)) {
1797
- prev.destructor();
1798
- }
1799
1820
  if (this.pub_from === 0) {
1800
1821
  ;
1801
1822
  (this.host ?? this.task)[this.field()] = null;