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/web.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
  })($ || ($ = {}));
@@ -1089,6 +1105,14 @@ var $;
1089
1105
  this.cursor = $mol_wire_cursor.fresh;
1090
1106
  if (next !== prev)
1091
1107
  this.emit();
1108
+ if ($mol_owning_catch(this, next)) {
1109
+ try {
1110
+ next[Symbol.toStringTag] = this[Symbol.toStringTag];
1111
+ }
1112
+ catch {
1113
+ Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
1114
+ }
1115
+ }
1092
1116
  return next;
1093
1117
  }
1094
1118
  this.cursor = $mol_wire_cursor.final;
@@ -1122,6 +1146,7 @@ var $;
1122
1146
  var $;
1123
1147
  (function ($) {
1124
1148
  $.$mol_key_store = new WeakMap();
1149
+ const TypedArray = Object.getPrototypeOf(Uint8Array);
1125
1150
  function $mol_key(value) {
1126
1151
  if (typeof value === 'bigint')
1127
1152
  return value.toString() + 'n';
@@ -1151,7 +1176,7 @@ var $;
1151
1176
  return value;
1152
1177
  if (value instanceof RegExp)
1153
1178
  return value.toString();
1154
- if (value instanceof Uint8Array)
1179
+ if (value instanceof TypedArray)
1155
1180
  return [...value];
1156
1181
  let key = $.$mol_key_store.get(value);
1157
1182
  if (key)
@@ -1346,10 +1371,6 @@ var $;
1346
1371
  }
1347
1372
  destructor() {
1348
1373
  super.destructor();
1349
- const prev = this.cache;
1350
- if ($mol_owning_check(this, prev)) {
1351
- prev.destructor();
1352
- }
1353
1374
  if (this.pub_from === 0) {
1354
1375
  ;
1355
1376
  (this.host ?? this.task)[this.field()] = null;