mol_wire_lib 1.0.1228 → 1.0.1230

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
@@ -618,7 +618,7 @@ var $;
618
618
  "use strict";
619
619
  var $;
620
620
  (function ($) {
621
- const handled = new WeakSet();
621
+ const wrappers = new WeakMap();
622
622
  class $mol_wire_fiber extends $mol_wire_pub_sub {
623
623
  task;
624
624
  host;
@@ -753,13 +753,16 @@ var $;
753
753
  result = this.task.call(this.host, ...this.args);
754
754
  break;
755
755
  }
756
- if ($mol_promise_like(result) && !handled.has(result)) {
756
+ if ($mol_promise_like(result)) {
757
757
  const put = (res) => {
758
758
  if (this.cache === result)
759
759
  this.put(res);
760
760
  return res;
761
761
  };
762
- result = result.then(put, put);
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 });
763
766
  }
764
767
  }
765
768
  catch (error) {
@@ -769,21 +772,15 @@ var $;
769
772
  else {
770
773
  result = new Error(String(error), { cause: error });
771
774
  }
772
- if ($mol_promise_like(result) && !handled.has(result)) {
773
- result = result.finally(() => {
775
+ if ($mol_promise_like(result)) {
776
+ wrappers.set(result, result = Object.assign(result.finally(() => {
774
777
  if (this.cache === result)
775
778
  this.absorb();
776
- });
779
+ }), { destructor: result.destructor || (() => { }) }));
780
+ const error = new Error(`Promise in ${this}`);
781
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
777
782
  }
778
783
  }
779
- if ($mol_promise_like(result) && !handled.has(result)) {
780
- result = Object.assign(result, {
781
- destructor: result['destructor'] ?? (() => { })
782
- });
783
- handled.add(result);
784
- const error = new Error(`Promise in ${this}`);
785
- Object.defineProperty(result, 'stack', { get: () => error.stack });
786
- }
787
784
  if (!$mol_promise_like(result)) {
788
785
  this.track_cut();
789
786
  }
package/node.test.js CHANGED
@@ -609,7 +609,7 @@ var $;
609
609
  "use strict";
610
610
  var $;
611
611
  (function ($) {
612
- const handled = new WeakSet();
612
+ const wrappers = new WeakMap();
613
613
  class $mol_wire_fiber extends $mol_wire_pub_sub {
614
614
  task;
615
615
  host;
@@ -744,13 +744,16 @@ var $;
744
744
  result = this.task.call(this.host, ...this.args);
745
745
  break;
746
746
  }
747
- if ($mol_promise_like(result) && !handled.has(result)) {
747
+ if ($mol_promise_like(result)) {
748
748
  const put = (res) => {
749
749
  if (this.cache === result)
750
750
  this.put(res);
751
751
  return res;
752
752
  };
753
- result = result.then(put, put);
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 });
754
757
  }
755
758
  }
756
759
  catch (error) {
@@ -760,21 +763,15 @@ var $;
760
763
  else {
761
764
  result = new Error(String(error), { cause: error });
762
765
  }
763
- if ($mol_promise_like(result) && !handled.has(result)) {
764
- result = result.finally(() => {
766
+ if ($mol_promise_like(result)) {
767
+ wrappers.set(result, result = Object.assign(result.finally(() => {
765
768
  if (this.cache === result)
766
769
  this.absorb();
767
- });
770
+ }), { destructor: result.destructor || (() => { }) }));
771
+ const error = new Error(`Promise in ${this}`);
772
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
768
773
  }
769
774
  }
770
- if ($mol_promise_like(result) && !handled.has(result)) {
771
- result = Object.assign(result, {
772
- destructor: result['destructor'] ?? (() => { })
773
- });
774
- handled.add(result);
775
- const error = new Error(`Promise in ${this}`);
776
- Object.defineProperty(result, 'stack', { get: () => error.stack });
777
- }
778
775
  if (!$mol_promise_like(result)) {
779
776
  this.track_cut();
780
777
  }