mol_jsx_lib 0.0.1094 → 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/node.mjs CHANGED
@@ -1276,7 +1276,7 @@ var $;
1276
1276
  "use strict";
1277
1277
  var $;
1278
1278
  (function ($) {
1279
- const handled = new WeakSet();
1279
+ const wrappers = new WeakMap();
1280
1280
  class $mol_wire_fiber extends $mol_wire_pub_sub {
1281
1281
  task;
1282
1282
  host;
@@ -1411,13 +1411,16 @@ var $;
1411
1411
  result = this.task.call(this.host, ...this.args);
1412
1412
  break;
1413
1413
  }
1414
- if ($mol_promise_like(result) && !handled.has(result)) {
1414
+ if ($mol_promise_like(result)) {
1415
1415
  const put = (res) => {
1416
1416
  if (this.cache === result)
1417
1417
  this.put(res);
1418
1418
  return res;
1419
1419
  };
1420
- result = result.then(put, put);
1420
+ wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
1421
+ wrappers.set(result, result);
1422
+ const error = new Error(`Promise in ${this}`);
1423
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
1421
1424
  }
1422
1425
  }
1423
1426
  catch (error) {
@@ -1427,21 +1430,15 @@ var $;
1427
1430
  else {
1428
1431
  result = new Error(String(error), { cause: error });
1429
1432
  }
1430
- if ($mol_promise_like(result) && !handled.has(result)) {
1431
- result = result.finally(() => {
1433
+ if ($mol_promise_like(result)) {
1434
+ wrappers.set(result, result = Object.assign(result.finally(() => {
1432
1435
  if (this.cache === result)
1433
1436
  this.absorb();
1434
- });
1437
+ }), { destructor: result.destructor || (() => { }) }));
1438
+ const error = new Error(`Promise in ${this}`);
1439
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
1435
1440
  }
1436
1441
  }
1437
- if ($mol_promise_like(result) && !handled.has(result)) {
1438
- result = Object.assign(result, {
1439
- destructor: result['destructor'] ?? (() => { })
1440
- });
1441
- handled.add(result);
1442
- const error = new Error(`Promise in ${this}`);
1443
- Object.defineProperty(result, 'stack', { get: () => error.stack });
1444
- }
1445
1442
  if (!$mol_promise_like(result)) {
1446
1443
  this.track_cut();
1447
1444
  }
package/node.test.js CHANGED
@@ -1267,7 +1267,7 @@ var $;
1267
1267
  "use strict";
1268
1268
  var $;
1269
1269
  (function ($) {
1270
- const handled = new WeakSet();
1270
+ const wrappers = new WeakMap();
1271
1271
  class $mol_wire_fiber extends $mol_wire_pub_sub {
1272
1272
  task;
1273
1273
  host;
@@ -1402,13 +1402,16 @@ var $;
1402
1402
  result = this.task.call(this.host, ...this.args);
1403
1403
  break;
1404
1404
  }
1405
- if ($mol_promise_like(result) && !handled.has(result)) {
1405
+ if ($mol_promise_like(result)) {
1406
1406
  const put = (res) => {
1407
1407
  if (this.cache === result)
1408
1408
  this.put(res);
1409
1409
  return res;
1410
1410
  };
1411
- result = result.then(put, put);
1411
+ wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
1412
+ wrappers.set(result, result);
1413
+ const error = new Error(`Promise in ${this}`);
1414
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
1412
1415
  }
1413
1416
  }
1414
1417
  catch (error) {
@@ -1418,21 +1421,15 @@ var $;
1418
1421
  else {
1419
1422
  result = new Error(String(error), { cause: error });
1420
1423
  }
1421
- if ($mol_promise_like(result) && !handled.has(result)) {
1422
- result = result.finally(() => {
1424
+ if ($mol_promise_like(result)) {
1425
+ wrappers.set(result, result = Object.assign(result.finally(() => {
1423
1426
  if (this.cache === result)
1424
1427
  this.absorb();
1425
- });
1428
+ }), { destructor: result.destructor || (() => { }) }));
1429
+ const error = new Error(`Promise in ${this}`);
1430
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
1426
1431
  }
1427
1432
  }
1428
- if ($mol_promise_like(result) && !handled.has(result)) {
1429
- result = Object.assign(result, {
1430
- destructor: result['destructor'] ?? (() => { })
1431
- });
1432
- handled.add(result);
1433
- const error = new Error(`Promise in ${this}`);
1434
- Object.defineProperty(result, 'stack', { get: () => error.stack });
1435
- }
1436
1433
  if (!$mol_promise_like(result)) {
1437
1434
  this.track_cut();
1438
1435
  }