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/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,21 @@ 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)) {
1415
- const put = (res) => {
1416
- if (this.cache === result)
1417
- this.put(res);
1418
- return res;
1419
- };
1420
- result = result.then(put, put);
1414
+ if ($mol_promise_like(result)) {
1415
+ if (wrappers.has(result)) {
1416
+ result = wrappers.get(result).then(a => a);
1417
+ }
1418
+ else {
1419
+ const put = (res) => {
1420
+ if (this.cache === result)
1421
+ this.put(res);
1422
+ return res;
1423
+ };
1424
+ wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
1425
+ wrappers.set(result, result);
1426
+ const error = new Error(`Promise in ${this}`);
1427
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
1428
+ }
1421
1429
  }
1422
1430
  }
1423
1431
  catch (error) {
@@ -1427,21 +1435,20 @@ var $;
1427
1435
  else {
1428
1436
  result = new Error(String(error), { cause: error });
1429
1437
  }
1430
- if ($mol_promise_like(result) && !handled.has(result)) {
1431
- result = result.finally(() => {
1432
- if (this.cache === result)
1433
- this.absorb();
1434
- });
1438
+ if ($mol_promise_like(result)) {
1439
+ if (wrappers.has(result)) {
1440
+ result = wrappers.get(result);
1441
+ }
1442
+ else {
1443
+ wrappers.set(result, result = Object.assign(result.finally(() => {
1444
+ if (this.cache === result)
1445
+ this.absorb();
1446
+ }), { destructor: result.destructor || (() => { }) }));
1447
+ const error = new Error(`Promise in ${this}`);
1448
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
1449
+ }
1435
1450
  }
1436
1451
  }
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
1452
  if (!$mol_promise_like(result)) {
1446
1453
  this.track_cut();
1447
1454
  }
@@ -2094,6 +2101,7 @@ var $;
2094
2101
  var $;
2095
2102
  (function ($) {
2096
2103
  $.$mol_key_store = new WeakMap();
2104
+ const TypedArray = Object.getPrototypeOf(Uint8Array);
2097
2105
  function $mol_key(value) {
2098
2106
  if (typeof value === 'bigint')
2099
2107
  return value.toString() + 'n';
@@ -2123,7 +2131,7 @@ var $;
2123
2131
  return value;
2124
2132
  if (value instanceof RegExp)
2125
2133
  return value.toString();
2126
- if (value instanceof Uint8Array)
2134
+ if (value instanceof TypedArray)
2127
2135
  return [...value];
2128
2136
  let key = $.$mol_key_store.get(value);
2129
2137
  if (key)
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,21 @@ 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)) {
1406
- const put = (res) => {
1407
- if (this.cache === result)
1408
- this.put(res);
1409
- return res;
1410
- };
1411
- result = result.then(put, put);
1405
+ if ($mol_promise_like(result)) {
1406
+ if (wrappers.has(result)) {
1407
+ result = wrappers.get(result).then(a => a);
1408
+ }
1409
+ else {
1410
+ const put = (res) => {
1411
+ if (this.cache === result)
1412
+ this.put(res);
1413
+ return res;
1414
+ };
1415
+ wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
1416
+ wrappers.set(result, result);
1417
+ const error = new Error(`Promise in ${this}`);
1418
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
1419
+ }
1412
1420
  }
1413
1421
  }
1414
1422
  catch (error) {
@@ -1418,21 +1426,20 @@ var $;
1418
1426
  else {
1419
1427
  result = new Error(String(error), { cause: error });
1420
1428
  }
1421
- if ($mol_promise_like(result) && !handled.has(result)) {
1422
- result = result.finally(() => {
1423
- if (this.cache === result)
1424
- this.absorb();
1425
- });
1429
+ if ($mol_promise_like(result)) {
1430
+ if (wrappers.has(result)) {
1431
+ result = wrappers.get(result);
1432
+ }
1433
+ else {
1434
+ wrappers.set(result, result = Object.assign(result.finally(() => {
1435
+ if (this.cache === result)
1436
+ this.absorb();
1437
+ }), { destructor: result.destructor || (() => { }) }));
1438
+ const error = new Error(`Promise in ${this}`);
1439
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
1440
+ }
1426
1441
  }
1427
1442
  }
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
1443
  if (!$mol_promise_like(result)) {
1437
1444
  this.track_cut();
1438
1445
  }
@@ -2085,6 +2092,7 @@ var $;
2085
2092
  var $;
2086
2093
  (function ($) {
2087
2094
  $.$mol_key_store = new WeakMap();
2095
+ const TypedArray = Object.getPrototypeOf(Uint8Array);
2088
2096
  function $mol_key(value) {
2089
2097
  if (typeof value === 'bigint')
2090
2098
  return value.toString() + 'n';
@@ -2114,7 +2122,7 @@ var $;
2114
2122
  return value;
2115
2123
  if (value instanceof RegExp)
2116
2124
  return value.toString();
2117
- if (value instanceof Uint8Array)
2125
+ if (value instanceof TypedArray)
2118
2126
  return [...value];
2119
2127
  let key = $.$mol_key_store.get(value);
2120
2128
  if (key)