mol_jsx_lib 0.0.1095 → 0.0.1097

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,21 @@ 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)) {
980
- const put = (res) => {
981
- if (this.cache === result)
982
- this.put(res);
983
- return res;
984
- };
985
- result = result.then(put, put);
979
+ if ($mol_promise_like(result)) {
980
+ if (wrappers.has(result)) {
981
+ result = wrappers.get(result).then(a => a);
982
+ }
983
+ else {
984
+ const put = (res) => {
985
+ if (this.cache === result)
986
+ this.put(res);
987
+ return res;
988
+ };
989
+ wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
990
+ wrappers.set(result, result);
991
+ const error = new Error(`Promise in ${this}`);
992
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
993
+ }
986
994
  }
987
995
  }
988
996
  catch (error) {
@@ -992,21 +1000,20 @@ var $;
992
1000
  else {
993
1001
  result = new Error(String(error), { cause: error });
994
1002
  }
995
- if ($mol_promise_like(result) && !handled.has(result)) {
996
- result = result.finally(() => {
997
- if (this.cache === result)
998
- this.absorb();
999
- });
1003
+ if ($mol_promise_like(result)) {
1004
+ if (wrappers.has(result)) {
1005
+ result = wrappers.get(result);
1006
+ }
1007
+ else {
1008
+ wrappers.set(result, result = Object.assign(result.finally(() => {
1009
+ if (this.cache === result)
1010
+ this.absorb();
1011
+ }), { destructor: result.destructor || (() => { }) }));
1012
+ const error = new Error(`Promise in ${this}`);
1013
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
1014
+ }
1000
1015
  }
1001
1016
  }
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
1017
  if (!$mol_promise_like(result)) {
1011
1018
  this.track_cut();
1012
1019
  }
@@ -1090,6 +1097,7 @@ var $;
1090
1097
  var $;
1091
1098
  (function ($) {
1092
1099
  $.$mol_key_store = new WeakMap();
1100
+ const TypedArray = Object.getPrototypeOf(Uint8Array);
1093
1101
  function $mol_key(value) {
1094
1102
  if (typeof value === 'bigint')
1095
1103
  return value.toString() + 'n';
@@ -1119,7 +1127,7 @@ var $;
1119
1127
  return value;
1120
1128
  if (value instanceof RegExp)
1121
1129
  return value.toString();
1122
- if (value instanceof Uint8Array)
1130
+ if (value instanceof TypedArray)
1123
1131
  return [...value];
1124
1132
  let key = $.$mol_key_store.get(value);
1125
1133
  if (key)