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/web.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
  }