mol_jsx_lib 0.0.1095 → 0.0.1096

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
@@ -841,7 +841,7 @@ var $;
841
841
  "use strict";
842
842
  var $;
843
843
  (function ($) {
844
- const handled = new WeakSet();
844
+ const wrappers = new WeakMap();
845
845
  class $mol_wire_fiber extends $mol_wire_pub_sub {
846
846
  task;
847
847
  host;
@@ -976,13 +976,16 @@ var $;
976
976
  result = this.task.call(this.host, ...this.args);
977
977
  break;
978
978
  }
979
- if ($mol_promise_like(result) && !handled.has(result)) {
979
+ if ($mol_promise_like(result)) {
980
980
  const put = (res) => {
981
981
  if (this.cache === result)
982
982
  this.put(res);
983
983
  return res;
984
984
  };
985
- result = result.then(put, put);
985
+ wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
986
+ wrappers.set(result, result);
987
+ const error = new Error(`Promise in ${this}`);
988
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
986
989
  }
987
990
  }
988
991
  catch (error) {
@@ -992,21 +995,15 @@ var $;
992
995
  else {
993
996
  result = new Error(String(error), { cause: error });
994
997
  }
995
- if ($mol_promise_like(result) && !handled.has(result)) {
996
- result = result.finally(() => {
998
+ if ($mol_promise_like(result)) {
999
+ wrappers.set(result, result = Object.assign(result.finally(() => {
997
1000
  if (this.cache === result)
998
1001
  this.absorb();
999
- });
1002
+ }), { destructor: result.destructor || (() => { }) }));
1003
+ const error = new Error(`Promise in ${this}`);
1004
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
1000
1005
  }
1001
1006
  }
1002
- if ($mol_promise_like(result) && !handled.has(result)) {
1003
- result = Object.assign(result, {
1004
- destructor: result['destructor'] ?? (() => { })
1005
- });
1006
- handled.add(result);
1007
- const error = new Error(`Promise in ${this}`);
1008
- Object.defineProperty(result, 'stack', { get: () => error.stack });
1009
- }
1010
1007
  if (!$mol_promise_like(result)) {
1011
1008
  this.track_cut();
1012
1009
  }